summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>1999-03-26 18:24:02 +0000
committercvs2svn <admin@example.com>1999-03-26 18:24:02 +0000
commit31dbf5249c74bc884a4f1c6fbb3f13ae58d67022 (patch)
treeaf769f6648929b3b2c1f9e053a3754fa989ce302
parent536c76cbb863bab152f19842ab88772c01e922c7 (diff)
downloadopenbsd-31dbf5249c74bc884a4f1c6fbb3f13ae58d67022.tar.gz
openbsd-31dbf5249c74bc884a4f1c6fbb3f13ae58d67022.tar.bz2
openbsd-31dbf5249c74bc884a4f1c6fbb3f13ae58d67022.zip
This commit was manufactured by cvs2git to create tag 'OPENBSD_2_5_BASE'.OPENBSD_2_5_BASE
-rw-r--r--src/lib/libc/crypt/Makefile.inc12
-rw-r--r--src/lib/libc/crypt/arc4random.383
-rw-r--r--src/lib/libc/crypt/arc4random.c176
-rw-r--r--src/lib/libc/crypt/bcrypt.c362
-rw-r--r--src/lib/libc/crypt/blowfish.3104
-rw-r--r--src/lib/libc/crypt/blowfish.c774
-rw-r--r--src/lib/libc/crypt/cast.c779
-rw-r--r--src/lib/libc/crypt/crypt.3298
-rw-r--r--src/lib/libc/crypt/crypt.c714
-rw-r--r--src/lib/libc/crypt/md5crypt.c157
-rw-r--r--src/lib/libc/crypt/morecrypt.c628
-rw-r--r--src/lib/libc/crypt/skipjack.c258
-rw-r--r--src/lib/libc/include/namespace.h18
-rw-r--r--src/lib/libc/include/thread_private.h179
-rw-r--r--src/lib/libc/net/Makefile.inc56
-rw-r--r--src/lib/libc/net/base64.c317
-rw-r--r--src/lib/libc/net/byteorder.3155
-rw-r--r--src/lib/libc/net/ethers.3109
-rw-r--r--src/lib/libc/net/ethers.c270
-rw-r--r--src/lib/libc/net/gethostbyname.3266
-rw-r--r--src/lib/libc/net/gethostnamadr.c1147
-rw-r--r--src/lib/libc/net/getnetbyaddr.c56
-rw-r--r--src/lib/libc/net/getnetbyname.c62
-rw-r--r--src/lib/libc/net/getnetent.3148
-rw-r--r--src/lib/libc/net/getnetent.c129
-rw-r--r--src/lib/libc/net/getnetnamadr.c382
-rw-r--r--src/lib/libc/net/getproto.c55
-rw-r--r--src/lib/libc/net/getprotoent.3144
-rw-r--r--src/lib/libc/net/getprotoent.c123
-rw-r--r--src/lib/libc/net/getprotoname.c62
-rw-r--r--src/lib/libc/net/getservbyname.c87
-rw-r--r--src/lib/libc/net/getservbyport.c60
-rw-r--r--src/lib/libc/net/getservent.3155
-rw-r--r--src/lib/libc/net/getservent.c125
-rw-r--r--src/lib/libc/net/herror.c121
-rw-r--r--src/lib/libc/net/htonl.c25
-rw-r--r--src/lib/libc/net/htons.c29
-rw-r--r--src/lib/libc/net/inet.3319
-rw-r--r--src/lib/libc/net/inet_addr.c187
-rw-r--r--src/lib/libc/net/inet_lnaof.c59
-rw-r--r--src/lib/libc/net/inet_makeaddr.c62
-rw-r--r--src/lib/libc/net/inet_net.3149
-rw-r--r--src/lib/libc/net/inet_net_ntop.c139
-rw-r--r--src/lib/libc/net/inet_net_pton.c207
-rw-r--r--src/lib/libc/net/inet_neta.c83
-rw-r--r--src/lib/libc/net/inet_netof.c58
-rw-r--r--src/lib/libc/net/inet_network.c92
-rw-r--r--src/lib/libc/net/inet_ntoa.c59
-rw-r--r--src/lib/libc/net/inet_ntop.c194
-rw-r--r--src/lib/libc/net/inet_pton.c220
-rw-r--r--src/lib/libc/net/ipx.3126
-rw-r--r--src/lib/libc/net/ipx_addr.c229
-rw-r--r--src/lib/libc/net/ipx_ntoa.c58
-rw-r--r--src/lib/libc/net/iso_addr.3110
-rw-r--r--src/lib/libc/net/iso_addr.c119
-rw-r--r--src/lib/libc/net/link_addr.3131
-rw-r--r--src/lib/libc/net/linkaddr.c158
-rw-r--r--src/lib/libc/net/ns.3130
-rw-r--r--src/lib/libc/net/ns_addr.c228
-rw-r--r--src/lib/libc/net/ns_ntoa.c101
-rw-r--r--src/lib/libc/net/nsap_addr.c109
-rw-r--r--src/lib/libc/net/ntohl.c25
-rw-r--r--src/lib/libc/net/ntohs.c29
-rw-r--r--src/lib/libc/net/rcmd.3227
-rw-r--r--src/lib/libc/net/rcmd.c607
-rw-r--r--src/lib/libc/net/rcmdsh.3108
-rw-r--r--src/lib/libc/net/rcmdsh.c124
-rw-r--r--src/lib/libc/net/recv.c50
-rw-r--r--src/lib/libc/net/res_comp.c510
-rw-r--r--src/lib/libc/net/res_data.c117
-rw-r--r--src/lib/libc/net/res_debug.c1518
-rw-r--r--src/lib/libc/net/res_init.c518
-rw-r--r--src/lib/libc/net/res_mkquery.c195
-rw-r--r--src/lib/libc/net/res_query.c398
-rw-r--r--src/lib/libc/net/res_random.c233
-rw-r--r--src/lib/libc/net/res_send.c780
-rw-r--r--src/lib/libc/net/resolver.3345
-rw-r--r--src/lib/libc/net/send.c50
-rw-r--r--src/lib/libc/net/sethostent.c60
-rw-r--r--src/lib/libc/stdlib/Makefile.inc54
-rw-r--r--src/lib/libc/stdlib/_rand48.c50
-rw-r--r--src/lib/libc/stdlib/a64l.3122
-rw-r--r--src/lib/libc/stdlib/a64l.c46
-rw-r--r--src/lib/libc/stdlib/abort.370
-rw-r--r--src/lib/libc/stdlib/abort.c86
-rw-r--r--src/lib/libc/stdlib/abs.373
-rw-r--r--src/lib/libc/stdlib/abs.c45
-rw-r--r--src/lib/libc/stdlib/alloca.375
-rw-r--r--src/lib/libc/stdlib/atexit.377
-rw-r--r--src/lib/libc/stdlib/atexit.c67
-rw-r--r--src/lib/libc/stdlib/atexit.h45
-rw-r--r--src/lib/libc/stdlib/atof.373
-rw-r--r--src/lib/libc/stdlib/atof.c45
-rw-r--r--src/lib/libc/stdlib/atoi.373
-rw-r--r--src/lib/libc/stdlib/atoi.c45
-rw-r--r--src/lib/libc/stdlib/atol.374
-rw-r--r--src/lib/libc/stdlib/atol.c45
-rw-r--r--src/lib/libc/stdlib/bsearch.390
-rw-r--r--src/lib/libc/stdlib/bsearch.c79
-rw-r--r--src/lib/libc/stdlib/calloc.370
-rw-r--r--src/lib/libc/stdlib/calloc.c53
-rw-r--r--src/lib/libc/stdlib/cfree.c49
-rw-r--r--src/lib/libc/stdlib/div.369
-rw-r--r--src/lib/libc/stdlib/div.c79
-rw-r--r--src/lib/libc/stdlib/drand48.c26
-rw-r--r--src/lib/libc/stdlib/erand48.c27
-rw-r--r--src/lib/libc/stdlib/exit.383
-rw-r--r--src/lib/libc/stdlib/exit.c69
-rw-r--r--src/lib/libc/stdlib/getenv.3155
-rw-r--r--src/lib/libc/stdlib/getenv.c89
-rw-r--r--src/lib/libc/stdlib/getopt.3261
-rw-r--r--src/lib/libc/stdlib/getopt.c117
-rw-r--r--src/lib/libc/stdlib/getsubopt.3148
-rw-r--r--src/lib/libc/stdlib/getsubopt.c106
-rw-r--r--src/lib/libc/stdlib/heapsort.c183
-rw-r--r--src/lib/libc/stdlib/jrand48.c25
-rw-r--r--src/lib/libc/stdlib/l64a.c46
-rw-r--r--src/lib/libc/stdlib/labs.366
-rw-r--r--src/lib/libc/stdlib/labs.c45
-rw-r--r--src/lib/libc/stdlib/lcong48.c34
-rw-r--r--src/lib/libc/stdlib/ldiv.371
-rw-r--r--src/lib/libc/stdlib/ldiv.c58
-rw-r--r--src/lib/libc/stdlib/lrand48.c27
-rw-r--r--src/lib/libc/stdlib/malloc.3355
-rw-r--r--src/lib/libc/stdlib/malloc.c1263
-rw-r--r--src/lib/libc/stdlib/memory.370
-rw-r--r--src/lib/libc/stdlib/merge.c347
-rw-r--r--src/lib/libc/stdlib/mrand48.c27
-rw-r--r--src/lib/libc/stdlib/multibyte.c130
-rw-r--r--src/lib/libc/stdlib/nrand48.c25
-rw-r--r--src/lib/libc/stdlib/putenv.c58
-rw-r--r--src/lib/libc/stdlib/qabs.361
-rw-r--r--src/lib/libc/stdlib/qabs.c45
-rw-r--r--src/lib/libc/stdlib/qdiv.365
-rw-r--r--src/lib/libc/stdlib/qdiv.c58
-rw-r--r--src/lib/libc/stdlib/qsort.3233
-rw-r--r--src/lib/libc/stdlib/qsort.c175
-rw-r--r--src/lib/libc/stdlib/radixsort.3161
-rw-r--r--src/lib/libc/stdlib/radixsort.c317
-rw-r--r--src/lib/libc/stdlib/rand.3104
-rw-r--r--src/lib/libc/stdlib/rand.c65
-rw-r--r--src/lib/libc/stdlib/rand48.3161
-rw-r--r--src/lib/libc/stdlib/rand48.h32
-rw-r--r--src/lib/libc/stdlib/random.3183
-rw-r--r--src/lib/libc/stdlib/random.c370
-rw-r--r--src/lib/libc/stdlib/realpath.3125
-rw-r--r--src/lib/libc/stdlib/realpath.c163
-rw-r--r--src/lib/libc/stdlib/seed48.c40
-rw-r--r--src/lib/libc/stdlib/setenv.c120
-rw-r--r--src/lib/libc/stdlib/srand48.c34
-rw-r--r--src/lib/libc/stdlib/strtod.3113
-rw-r--r--src/lib/libc/stdlib/strtod.c2529
-rw-r--r--src/lib/libc/stdlib/strtol.3168
-rw-r--r--src/lib/libc/stdlib/strtol.c150
-rw-r--r--src/lib/libc/stdlib/strtoq.c152
-rw-r--r--src/lib/libc/stdlib/strtoul.3163
-rw-r--r--src/lib/libc/stdlib/strtoul.c112
-rw-r--r--src/lib/libc/stdlib/strtouq.c114
-rw-r--r--src/lib/libc/stdlib/system.398
-rw-r--r--src/lib/libc/stdlib/system.c80
-rw-r--r--src/lib/libc/stdlib/tfind.c41
-rw-r--r--src/lib/libc/stdlib/tsearch.3116
-rw-r--r--src/lib/libc/stdlib/tsearch.c126
-rw-r--r--src/lib/libc/string/Makefile.inc128
-rw-r--r--src/lib/libc/string/__strerror.c111
-rw-r--r--src/lib/libc/string/__strsignal.c104
-rw-r--r--src/lib/libc/string/bcmp.371
-rw-r--r--src/lib/libc/string/bcmp.c63
-rw-r--r--src/lib/libc/string/bcopy.371
-rw-r--r--src/lib/libc/string/bcopy.c138
-rw-r--r--src/lib/libc/string/bm.3113
-rw-r--r--src/lib/libc/string/bm.c219
-rw-r--r--src/lib/libc/string/bstring.3109
-rw-r--r--src/lib/libc/string/bzero.367
-rw-r--r--src/lib/libc/string/bzero.c56
-rw-r--r--src/lib/libc/string/ffs.362
-rw-r--r--src/lib/libc/string/ffs.c58
-rw-r--r--src/lib/libc/string/index.382
-rw-r--r--src/lib/libc/string/index.c55
-rw-r--r--src/lib/libc/string/memccpy.375
-rw-r--r--src/lib/libc/string/memccpy.c64
-rw-r--r--src/lib/libc/string/memchr.381
-rw-r--r--src/lib/libc/string/memchr.c58
-rw-r--r--src/lib/libc/string/memcmp.382
-rw-r--r--src/lib/libc/string/memcmp.c60
-rw-r--r--src/lib/libc/string/memcpy.383
-rw-r--r--src/lib/libc/string/memmove.375
-rw-r--r--src/lib/libc/string/memset.372
-rw-r--r--src/lib/libc/string/memset.c58
-rw-r--r--src/lib/libc/string/rindex.380
-rw-r--r--src/lib/libc/string/rindex.c57
-rw-r--r--src/lib/libc/string/strcasecmp.389
-rw-r--r--src/lib/libc/string/strcasecmp.c120
-rw-r--r--src/lib/libc/string/strcat.3137
-rw-r--r--src/lib/libc/string/strcat.c54
-rw-r--r--src/lib/libc/string/strchr.387
-rw-r--r--src/lib/libc/string/strcmp.393
-rw-r--r--src/lib/libc/string/strcmp.c58
-rw-r--r--src/lib/libc/string/strcoll.374
-rw-r--r--src/lib/libc/string/strcoll.c52
-rw-r--r--src/lib/libc/string/strcpy.3154
-rw-r--r--src/lib/libc/string/strcpy.c53
-rw-r--r--src/lib/libc/string/strcspn.384
-rw-r--r--src/lib/libc/string/strcspn.c67
-rw-r--r--src/lib/libc/string/strdup.368
-rw-r--r--src/lib/libc/string/strdup.c62
-rw-r--r--src/lib/libc/string/strerror.365
-rw-r--r--src/lib/libc/string/strerror.c55
-rw-r--r--src/lib/libc/string/string.3155
-rw-r--r--src/lib/libc/string/strlcat.c71
-rw-r--r--src/lib/libc/string/strlcpy.3147
-rw-r--r--src/lib/libc/string/strlcpy.c63
-rw-r--r--src/lib/libc/string/strlen.370
-rw-r--r--src/lib/libc/string/strlen.c53
-rw-r--r--src/lib/libc/string/strmode.3152
-rw-r--r--src/lib/libc/string/strmode.c152
-rw-r--r--src/lib/libc/string/strncat.c67
-rw-r--r--src/lib/libc/string/strncmp.c59
-rw-r--r--src/lib/libc/string/strncpy.c67
-rw-r--r--src/lib/libc/string/strpbrk.379
-rw-r--r--src/lib/libc/string/strpbrk.c56
-rw-r--r--src/lib/libc/string/strrchr.390
-rw-r--r--src/lib/libc/string/strsep.3110
-rw-r--r--src/lib/libc/string/strsep.c85
-rw-r--r--src/lib/libc/string/strsignal.360
-rw-r--r--src/lib/libc/string/strsignal.c49
-rw-r--r--src/lib/libc/string/strspn.379
-rw-r--r--src/lib/libc/string/strspn.c60
-rw-r--r--src/lib/libc/string/strstr.388
-rw-r--r--src/lib/libc/string/strstr.c64
-rw-r--r--src/lib/libc/string/strtok.3112
-rw-r--r--src/lib/libc/string/strtok.c89
-rw-r--r--src/lib/libc/string/strxfrm.368
-rw-r--r--src/lib/libc/string/strxfrm.c73
-rw-r--r--src/lib/libc/string/swab.365
-rw-r--r--src/lib/libc/string/swab.c65
-rw-r--r--src/lib/libcrypto/Makefile.ssl161
-rw-r--r--src/lib/libcrypto/asn1/Makefile.ssl120
-rw-r--r--src/lib/libcrypto/asn1/a_bmp.c90
-rw-r--r--src/lib/libcrypto/asn1/asn1.err182
-rw-r--r--src/lib/libcrypto/asn1/d2i_dhp.c108
-rw-r--r--src/lib/libcrypto/asn1/d2i_dsap.c101
-rw-r--r--src/lib/libcrypto/asn1/d2i_r_pr.c129
-rw-r--r--src/lib/libcrypto/asn1/d2i_r_pu.c100
-rw-r--r--src/lib/libcrypto/asn1/d2i_s_pr.c113
-rw-r--r--src/lib/libcrypto/asn1/d2i_s_pu.c124
-rw-r--r--src/lib/libcrypto/asn1/f.c80
-rw-r--r--src/lib/libcrypto/asn1/i2d_dhp.c128
-rw-r--r--src/lib/libcrypto/asn1/i2d_dsap.c121
-rw-r--r--src/lib/libcrypto/asn1/i2d_r_pr.c132
-rw-r--r--src/lib/libcrypto/asn1/i2d_r_pu.c118
-rw-r--r--src/lib/libcrypto/asn1/i2d_s_pr.c128
-rw-r--r--src/lib/libcrypto/asn1/i2d_s_pu.c133
-rw-r--r--src/lib/libcrypto/asn1/p7_dgst.c130
-rw-r--r--src/lib/libcrypto/asn1/p7_enc.c120
-rw-r--r--src/lib/libcrypto/asn1/p7_enc_c.c127
-rw-r--r--src/lib/libcrypto/asn1/p7_evp.c125
-rw-r--r--src/lib/libcrypto/asn1/p7_i_s.c120
-rw-r--r--src/lib/libcrypto/asn1/p7_lib.c299
-rw-r--r--src/lib/libcrypto/asn1/p7_recip.c132
-rw-r--r--src/lib/libcrypto/asn1/p7_s_e.c146
-rw-r--r--src/lib/libcrypto/asn1/p7_signd.c140
-rw-r--r--src/lib/libcrypto/asn1/p7_signi.c149
-rw-r--r--src/lib/libcrypto/asn1/pkcs8.c142
-rw-r--r--src/lib/libcrypto/asn1/x_cinf.c197
-rw-r--r--src/lib/libcrypto/bf/Makefile.ssl107
-rw-r--r--src/lib/libcrypto/bf/Makefile.uni169
-rw-r--r--src/lib/libcrypto/bf/asm/b-win32.asm906
-rw-r--r--src/lib/libcrypto/bf/asm/bx86unix.cpp976
-rw-r--r--src/lib/libcrypto/bf/bf_locl.org242
-rw-r--r--src/lib/libcrypto/bio/Makefile.ssl92
-rw-r--r--src/lib/libcrypto/bio/bio.err46
-rw-r--r--src/lib/libcrypto/bn/Makefile.ssl133
-rw-r--r--src/lib/libcrypto/bn/asm/bn-win32.asm689
-rw-r--r--src/lib/libcrypto/bn/asm/bn86unix.cpp752
-rw-r--r--src/lib/libcrypto/bn/asm/sparc.s462
-rw-r--r--src/lib/libcrypto/bn/asm/x86w16.asm297
-rw-r--r--src/lib/libcrypto/bn/asm/x86w32.asm362
-rw-r--r--src/lib/libcrypto/bn/bn.err27
-rw-r--r--src/lib/libcrypto/bn/bn.org502
-rw-r--r--src/lib/libcrypto/bn/bn_m.c169
-rw-r--r--src/lib/libcrypto/bn/bn_mulw.c366
-rw-r--r--src/lib/libcrypto/bn/bn_sub.c180
-rw-r--r--src/lib/libcrypto/buffer/Makefile.ssl84
-rw-r--r--src/lib/libcrypto/buffer/buffer.err9
-rw-r--r--src/lib/libcrypto/cast/Makefile.ssl109
-rw-r--r--src/lib/libcrypto/cast/Makefile.uni123
-rw-r--r--src/lib/libcrypto/cast/asm/c-win32.asm940
-rw-r--r--src/lib/libcrypto/cast/asm/cx86unix.cpp1010
-rw-r--r--src/lib/libcrypto/conf/Makefile.ssl85
-rw-r--r--src/lib/libcrypto/conf/conf.c727
-rw-r--r--src/lib/libcrypto/conf/conf.err12
-rw-r--r--src/lib/libcrypto/conf/conf_lcl.h102
-rw-r--r--src/lib/libcrypto/cryptall.h110
-rw-r--r--src/lib/libcrypto/crypto.c575
-rw-r--r--src/lib/libcrypto/crypto.err8
-rw-r--r--src/lib/libcrypto/date.h1
-rw-r--r--src/lib/libcrypto/des/DES.pod16
-rw-r--r--src/lib/libcrypto/des/FILES96
-rw-r--r--src/lib/libcrypto/des/MODES.DES84
-rw-r--r--src/lib/libcrypto/des/Makefile.PL14
-rw-r--r--src/lib/libcrypto/des/Makefile.lit250
-rw-r--r--src/lib/libcrypto/des/Makefile.ssl140
-rw-r--r--src/lib/libcrypto/des/Makefile.uni263
-rw-r--r--src/lib/libcrypto/des/PC128
-rw-r--r--src/lib/libcrypto/des/PC257
-rw-r--r--src/lib/libcrypto/des/asm/d-win32.asm3132
-rw-r--r--src/lib/libcrypto/des/asm/dx86unix.cpp3202
-rw-r--r--src/lib/libcrypto/des/asm/y-win32.asm929
-rw-r--r--src/lib/libcrypto/des/asm/yx86unix.cpp976
-rw-r--r--src/lib/libcrypto/des/des.man186
-rw-r--r--src/lib/libcrypto/des/des.org301
-rw-r--r--src/lib/libcrypto/des/des.pl552
-rw-r--r--src/lib/libcrypto/des/des_crypt.man508
-rw-r--r--src/lib/libcrypto/des/des_locl.org516
-rw-r--r--src/lib/libcrypto/des/doIP46
-rw-r--r--src/lib/libcrypto/des/doPC1110
-rw-r--r--src/lib/libcrypto/des/doPC294
-rw-r--r--src/lib/libcrypto/des/ede_enc.c190
-rw-r--r--src/lib/libcrypto/des/podd.h75
-rw-r--r--src/lib/libcrypto/des/ranlib.sh23
-rw-r--r--src/lib/libcrypto/des/shifts.pl198
-rw-r--r--src/lib/libcrypto/des/sk.h204
-rw-r--r--src/lib/libcrypto/des/supp.c109
-rw-r--r--src/lib/libcrypto/des/testdes.pl167
-rw-r--r--src/lib/libcrypto/des/vms.com90
-rw-r--r--src/lib/libcrypto/dh/Makefile.ssl84
-rw-r--r--src/lib/libcrypto/dh/dh.err12
-rw-r--r--src/lib/libcrypto/dsa/Makefile.ssl84
-rw-r--r--src/lib/libcrypto/dsa/dsa.err15
-rw-r--r--src/lib/libcrypto/err/Makefile.ssl80
-rw-r--r--src/lib/libcrypto/err/err_code.pl105
-rw-r--r--src/lib/libcrypto/err/err_genc.pl198
-rw-r--r--src/lib/libcrypto/err/error.err13
-rw-r--r--src/lib/libcrypto/err/ssleay.ec57
-rw-r--r--src/lib/libcrypto/evp/Makefile.ssl111
-rw-r--r--src/lib/libcrypto/evp/e_cbc_3d.c163
-rw-r--r--src/lib/libcrypto/evp/e_cbc_bf.c119
-rw-r--r--src/lib/libcrypto/evp/e_cbc_c.c119
-rw-r--r--src/lib/libcrypto/evp/e_cbc_d.c116
-rw-r--r--src/lib/libcrypto/evp/e_cbc_i.c131
-rw-r--r--src/lib/libcrypto/evp/e_cbc_r2.c136
-rw-r--r--src/lib/libcrypto/evp/e_cbc_r5.c120
-rw-r--r--src/lib/libcrypto/evp/e_cfb_3d.c166
-rw-r--r--src/lib/libcrypto/evp/e_cfb_bf.c121
-rw-r--r--src/lib/libcrypto/evp/e_cfb_c.c121
-rw-r--r--src/lib/libcrypto/evp/e_cfb_d.c118
-rw-r--r--src/lib/libcrypto/evp/e_cfb_i.c121
-rw-r--r--src/lib/libcrypto/evp/e_cfb_r2.c122
-rw-r--r--src/lib/libcrypto/evp/e_cfb_r5.c122
-rw-r--r--src/lib/libcrypto/evp/e_ecb_3d.c161
-rw-r--r--src/lib/libcrypto/evp/e_ecb_bf.c122
-rw-r--r--src/lib/libcrypto/evp/e_ecb_c.c122
-rw-r--r--src/lib/libcrypto/evp/e_ecb_d.c118
-rw-r--r--src/lib/libcrypto/evp/e_ecb_i.c133
-rw-r--r--src/lib/libcrypto/evp/e_ecb_r2.c123
-rw-r--r--src/lib/libcrypto/evp/e_ecb_r5.c123
-rw-r--r--src/lib/libcrypto/evp/e_ofb_3d.c165
-rw-r--r--src/lib/libcrypto/evp/e_ofb_bf.c122
-rw-r--r--src/lib/libcrypto/evp/e_ofb_c.c122
-rw-r--r--src/lib/libcrypto/evp/e_ofb_d.c118
-rw-r--r--src/lib/libcrypto/evp/e_ofb_i.c121
-rw-r--r--src/lib/libcrypto/evp/e_ofb_r2.c123
-rw-r--r--src/lib/libcrypto/evp/e_ofb_r5.c123
-rw-r--r--src/lib/libcrypto/evp/evp.err24
-rw-r--r--src/lib/libcrypto/evp/pk_lib.c82
-rw-r--r--src/lib/libcrypto/hmac/Makefile.ssl80
-rw-r--r--src/lib/libcrypto/idea/Makefile.ssl80
-rw-r--r--src/lib/libcrypto/lhash/Makefile.ssl80
-rw-r--r--src/lib/libcrypto/libvms.com31
-rw-r--r--src/lib/libcrypto/md2/Makefile.ssl80
-rw-r--r--src/lib/libcrypto/md2/md2.org106
-rw-r--r--src/lib/libcrypto/md5/Makefile.ssl104
-rw-r--r--src/lib/libcrypto/md5/Makefile.uni109
-rw-r--r--src/lib/libcrypto/md5/asm/m5-win32.asm686
-rw-r--r--src/lib/libcrypto/md5/asm/mx86unix.cpp730
-rw-r--r--src/lib/libcrypto/mdc2/Makefile.ssl80
-rw-r--r--src/lib/libcrypto/objects/Makefile.ssl87
-rw-r--r--src/lib/libcrypto/objects/objects.err12
-rw-r--r--src/lib/libcrypto/pem/Makefile.ssl96
-rw-r--r--src/lib/libcrypto/pem/ctx_size.c122
-rw-r--r--src/lib/libcrypto/pem/pem.err38
-rw-r--r--src/lib/libcrypto/pem/pem.org562
-rw-r--r--src/lib/libcrypto/pkcs7/Makefile.ssl86
-rw-r--r--src/lib/libcrypto/pkcs7/README5
-rw-r--r--src/lib/libcrypto/pkcs7/mf.p718
-rw-r--r--src/lib/libcrypto/pkcs7/p7.tst33
-rw-r--r--src/lib/libcrypto/pkcs7/pkcs7.err26
-rw-r--r--src/lib/libcrypto/rand/Makefile.ssl80
-rw-r--r--src/lib/libcrypto/ranlib.sh23
-rw-r--r--src/lib/libcrypto/rc2/Makefile.ssl80
-rw-r--r--src/lib/libcrypto/rc2/Makefile.uni72
-rw-r--r--src/lib/libcrypto/rc2/rc2.org118
-rw-r--r--src/lib/libcrypto/rc4/Makefile.ssl108
-rw-r--r--src/lib/libcrypto/rc4/Makefile.uni102
-rw-r--r--src/lib/libcrypto/rc4/asm/r4-win32.asm314
-rw-r--r--src/lib/libcrypto/rc4/asm/rx86unix.cpp358
-rw-r--r--src/lib/libcrypto/rc4/rc4.org103
-rw-r--r--src/lib/libcrypto/rc4/rc4_locl.org70
-rw-r--r--src/lib/libcrypto/rc5/Makefile.ssl107
-rw-r--r--src/lib/libcrypto/rc5/Makefile.uni72
-rw-r--r--src/lib/libcrypto/rc5/asm/r5-win32.asm574
-rw-r--r--src/lib/libcrypto/rc5/asm/r586unix.cpp628
-rw-r--r--src/lib/libcrypto/rc5/asm/rc5-586.pl109
-rw-r--r--src/lib/libcrypto/ripemd/Makefile.ssl104
-rw-r--r--src/lib/libcrypto/ripemd/Makefile.uni109
-rw-r--r--src/lib/libcrypto/ripemd/asm/rm-win32.asm1972
-rw-r--r--src/lib/libcrypto/ripemd/asm/rm86unix.cpp2016
-rw-r--r--src/lib/libcrypto/rsa/Makefile.ssl86
-rw-r--r--src/lib/libcrypto/rsa/rsa.err45
-rw-r--r--src/lib/libcrypto/sha/Makefile.ssl103
-rw-r--r--src/lib/libcrypto/sha/Makefile.uni122
-rw-r--r--src/lib/libcrypto/sha/asm/s1-win32.asm1664
-rw-r--r--src/lib/libcrypto/sha/asm/sx86unix.cpp1948
-rw-r--r--src/lib/libcrypto/sha/sha_sgst.c246
-rw-r--r--src/lib/libcrypto/stack/Makefile.ssl80
-rw-r--r--src/lib/libcrypto/txt_db/Makefile.ssl80
-rw-r--r--src/lib/libcrypto/util/mklink.sh35
-rw-r--r--src/lib/libcrypto/util/ranlib.sh23
-rw-r--r--src/lib/libcrypto/util/sep_lib.sh37
-rw-r--r--src/lib/libcrypto/util/ssldir.pl52
-rw-r--r--src/lib/libcrypto/util/up_ver.pl79
-rw-r--r--src/lib/libcrypto/x509/Makefile.ssl96
-rw-r--r--src/lib/libcrypto/x509/attrib38
-rw-r--r--src/lib/libcrypto/x509/v3_net.c87
-rw-r--r--src/lib/libcrypto/x509/v3_x509.c253
-rw-r--r--src/lib/libcrypto/x509/x509.doc27
-rw-r--r--src/lib/libcrypto/x509/x509.err46
-rw-r--r--src/lib/libcrypto/x509/x509pack.c157
-rw-r--r--src/lib/libcrypto/x509/x509v3.doc24
-rw-r--r--src/lib/libcrypto/x509v3/format92
-rw-r--r--src/lib/libcrypto/x509v3/header6
-rw-r--r--src/lib/libcrypto/x509v3/v3_ku.c318
-rw-r--r--src/lib/libssl/Makefile10
-rw-r--r--src/lib/libssl/Makefile.bsd-wrapper100
-rw-r--r--src/lib/libssl/README.OPENBSD66
-rw-r--r--src/lib/libssl/crypto-patent/Makefile179
-rw-r--r--src/lib/libssl/crypto-patent/shlib_version2
-rw-r--r--src/lib/libssl/crypto/Makefile183
-rw-r--r--src/lib/libssl/crypto/shlib_version2
-rw-r--r--src/lib/libssl/src/COPYRIGHT65
-rw-r--r--src/lib/libssl/src/Configure2
-rw-r--r--src/lib/libssl/src/HISTORY316
-rw-r--r--src/lib/libssl/src/HISTORY.066443
-rw-r--r--src/lib/libssl/src/MICROSOFT146
-rw-r--r--src/lib/libssl/src/MINFO968
-rw-r--r--src/lib/libssl/src/Makefile.ssl331
-rw-r--r--src/lib/libssl/src/PATENTS9
-rw-r--r--src/lib/libssl/src/README.06627
-rw-r--r--src/lib/libssl/src/README.080147
-rw-r--r--src/lib/libssl/src/README.09071
-rw-r--r--src/lib/libssl/src/TODO28
-rw-r--r--src/lib/libssl/src/VERSION24
-rw-r--r--src/lib/libssl/src/apps/Makefile.ssl144
-rw-r--r--src/lib/libssl/src/apps/der_chop305
-rw-r--r--src/lib/libssl/src/apps/eay.c130
-rw-r--r--src/lib/libssl/src/apps/ext.v32
-rw-r--r--src/lib/libssl/src/apps/g_ssleay.pl114
-rw-r--r--src/lib/libssl/src/apps/mklinks7
-rw-r--r--src/lib/libssl/src/apps/pem_mail.c170
-rw-r--r--src/lib/libssl/src/apps/rmlinks6
-rw-r--r--src/lib/libssl/src/apps/ssleay.c342
-rw-r--r--src/lib/libssl/src/apps/ssleay.cnf116
-rw-r--r--src/lib/libssl/src/apps/tkca66
-rw-r--r--src/lib/libssl/src/certs/ICE-CA.pem59
-rw-r--r--src/lib/libssl/src/certs/ICE-root.pem48
-rw-r--r--src/lib/libssl/src/certs/ICE-user.pem63
-rw-r--r--src/lib/libssl/src/certs/ICE.crl9
-rw-r--r--src/lib/libssl/src/certs/ca-cert.pem31
-rw-r--r--src/lib/libssl/src/certs/dsa-ca.pem43
-rw-r--r--src/lib/libssl/src/certs/dsa-pca.pem49
-rw-r--r--src/lib/libssl/src/certs/factory.pem15
-rw-r--r--src/lib/libssl/src/certs/nortelCA.pem16
-rw-r--r--src/lib/libssl/src/certs/pca-cert.pem31
-rw-r--r--src/lib/libssl/src/certs/rsa-cca.pem19
-rw-r--r--src/lib/libssl/src/certs/rsa-ssca.pem19
-rw-r--r--src/lib/libssl/src/certs/timCA.pem16
-rw-r--r--src/lib/libssl/src/certs/tjhCA.pem15
-rw-r--r--src/lib/libssl/src/certs/vsign2.pem31
-rw-r--r--src/lib/libssl/src/certs/vsign4.pem16
-rw-r--r--src/lib/libssl/src/crypto/Makefile.ssl161
-rw-r--r--src/lib/libssl/src/crypto/asn1/Makefile.ssl120
-rw-r--r--src/lib/libssl/src/crypto/asn1/a_bmp.c90
-rw-r--r--src/lib/libssl/src/crypto/asn1/asn1.err182
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_dhp.c108
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_dsap.c101
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_r_pr.c129
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_r_pu.c100
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_s_pr.c113
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_s_pu.c124
-rw-r--r--src/lib/libssl/src/crypto/asn1/f.c80
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_dhp.c128
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_dsap.c121
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_r_pr.c132
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_r_pu.c118
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_s_pr.c128
-rw-r--r--src/lib/libssl/src/crypto/asn1/i2d_s_pu.c133
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_dgst.c130
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_enc.c120
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_enc_c.c127
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_evp.c125
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_i_s.c120
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_lib.c299
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_recip.c132
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_s_e.c146
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_signd.c140
-rw-r--r--src/lib/libssl/src/crypto/asn1/p7_signi.c149
-rw-r--r--src/lib/libssl/src/crypto/asn1/pkcs8.c142
-rw-r--r--src/lib/libssl/src/crypto/asn1/x_cinf.c197
-rw-r--r--src/lib/libssl/src/crypto/bf/Makefile.ssl107
-rw-r--r--src/lib/libssl/src/crypto/bf/Makefile.uni169
-rw-r--r--src/lib/libssl/src/crypto/bf/asm/b-win32.asm906
-rw-r--r--src/lib/libssl/src/crypto/bf/asm/bx86unix.cpp976
-rw-r--r--src/lib/libssl/src/crypto/bf/bf_locl.org242
-rw-r--r--src/lib/libssl/src/crypto/bio/Makefile.ssl92
-rw-r--r--src/lib/libssl/src/crypto/bio/bio.err46
-rw-r--r--src/lib/libssl/src/crypto/bn/Makefile.ssl133
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/bn-win32.asm689
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/bn86unix.cpp752
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/sparc.s462
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/x86w16.asm297
-rw-r--r--src/lib/libssl/src/crypto/bn/asm/x86w32.asm362
-rw-r--r--src/lib/libssl/src/crypto/bn/bn.err27
-rw-r--r--src/lib/libssl/src/crypto/bn/bn.org502
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_m.c169
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_mulw.c366
-rw-r--r--src/lib/libssl/src/crypto/bn/bn_sub.c180
-rw-r--r--src/lib/libssl/src/crypto/buffer/Makefile.ssl84
-rw-r--r--src/lib/libssl/src/crypto/buffer/buffer.err9
-rw-r--r--src/lib/libssl/src/crypto/cast/Makefile.ssl109
-rw-r--r--src/lib/libssl/src/crypto/cast/Makefile.uni123
-rw-r--r--src/lib/libssl/src/crypto/cast/asm/c-win32.asm940
-rw-r--r--src/lib/libssl/src/crypto/cast/asm/cx86unix.cpp1010
-rw-r--r--src/lib/libssl/src/crypto/conf/Makefile.ssl85
-rw-r--r--src/lib/libssl/src/crypto/conf/conf.c727
-rw-r--r--src/lib/libssl/src/crypto/conf/conf.err12
-rw-r--r--src/lib/libssl/src/crypto/conf/conf_lcl.h102
-rw-r--r--src/lib/libssl/src/crypto/cryptall.h110
-rw-r--r--src/lib/libssl/src/crypto/crypto.c575
-rw-r--r--src/lib/libssl/src/crypto/crypto.err8
-rw-r--r--src/lib/libssl/src/crypto/date.h1
-rw-r--r--src/lib/libssl/src/crypto/des/DES.pod16
-rw-r--r--src/lib/libssl/src/crypto/des/FILES96
-rw-r--r--src/lib/libssl/src/crypto/des/MODES.DES84
-rw-r--r--src/lib/libssl/src/crypto/des/Makefile.PL14
-rw-r--r--src/lib/libssl/src/crypto/des/Makefile.lit250
-rw-r--r--src/lib/libssl/src/crypto/des/Makefile.ssl140
-rw-r--r--src/lib/libssl/src/crypto/des/Makefile.uni263
-rw-r--r--src/lib/libssl/src/crypto/des/PC128
-rw-r--r--src/lib/libssl/src/crypto/des/PC257
-rw-r--r--src/lib/libssl/src/crypto/des/asm/d-win32.asm3132
-rw-r--r--src/lib/libssl/src/crypto/des/asm/dx86unix.cpp3202
-rw-r--r--src/lib/libssl/src/crypto/des/asm/y-win32.asm929
-rw-r--r--src/lib/libssl/src/crypto/des/asm/yx86unix.cpp976
-rw-r--r--src/lib/libssl/src/crypto/des/des.man186
-rw-r--r--src/lib/libssl/src/crypto/des/des.org301
-rw-r--r--src/lib/libssl/src/crypto/des/des.pl552
-rw-r--r--src/lib/libssl/src/crypto/des/des_crypt.man508
-rw-r--r--src/lib/libssl/src/crypto/des/des_locl.org516
-rw-r--r--src/lib/libssl/src/crypto/des/doIP46
-rw-r--r--src/lib/libssl/src/crypto/des/doPC1110
-rw-r--r--src/lib/libssl/src/crypto/des/doPC294
-rw-r--r--src/lib/libssl/src/crypto/des/ede_enc.c190
-rw-r--r--src/lib/libssl/src/crypto/des/podd.h75
-rw-r--r--src/lib/libssl/src/crypto/des/ranlib.sh23
-rw-r--r--src/lib/libssl/src/crypto/des/shifts.pl198
-rw-r--r--src/lib/libssl/src/crypto/des/sk.h204
-rw-r--r--src/lib/libssl/src/crypto/des/supp.c109
-rw-r--r--src/lib/libssl/src/crypto/des/testdes.pl167
-rw-r--r--src/lib/libssl/src/crypto/des/vms.com90
-rw-r--r--src/lib/libssl/src/crypto/dh/Makefile.ssl84
-rw-r--r--src/lib/libssl/src/crypto/dh/dh.err12
-rw-r--r--src/lib/libssl/src/crypto/dsa/Makefile.ssl84
-rw-r--r--src/lib/libssl/src/crypto/dsa/dsa.err15
-rw-r--r--src/lib/libssl/src/crypto/err/Makefile.ssl80
-rw-r--r--src/lib/libssl/src/crypto/err/err_code.pl105
-rw-r--r--src/lib/libssl/src/crypto/err/err_genc.pl198
-rw-r--r--src/lib/libssl/src/crypto/err/error.err13
-rw-r--r--src/lib/libssl/src/crypto/err/ssleay.ec57
-rw-r--r--src/lib/libssl/src/crypto/evp/Makefile.ssl111
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cbc_3d.c163
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cbc_bf.c119
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cbc_c.c119
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cbc_d.c116
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cbc_i.c131
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cbc_r2.c136
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cbc_r5.c120
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cfb_3d.c166
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cfb_bf.c121
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cfb_c.c121
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cfb_d.c118
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cfb_i.c121
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cfb_r2.c122
-rw-r--r--src/lib/libssl/src/crypto/evp/e_cfb_r5.c122
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ecb_3d.c161
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ecb_bf.c122
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ecb_c.c122
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ecb_d.c118
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ecb_i.c133
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ecb_r2.c123
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ecb_r5.c123
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ofb_3d.c165
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ofb_bf.c122
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ofb_c.c122
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ofb_d.c118
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ofb_i.c121
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ofb_r2.c123
-rw-r--r--src/lib/libssl/src/crypto/evp/e_ofb_r5.c123
-rw-r--r--src/lib/libssl/src/crypto/evp/evp.err24
-rw-r--r--src/lib/libssl/src/crypto/evp/pk_lib.c82
-rw-r--r--src/lib/libssl/src/crypto/hmac/Makefile.ssl80
-rw-r--r--src/lib/libssl/src/crypto/idea/Makefile.ssl80
-rw-r--r--src/lib/libssl/src/crypto/lhash/Makefile.ssl80
-rw-r--r--src/lib/libssl/src/crypto/libvms.com31
-rw-r--r--src/lib/libssl/src/crypto/md2/Makefile.ssl80
-rw-r--r--src/lib/libssl/src/crypto/md2/md2.org106
-rw-r--r--src/lib/libssl/src/crypto/md5/Makefile.ssl104
-rw-r--r--src/lib/libssl/src/crypto/md5/Makefile.uni109
-rw-r--r--src/lib/libssl/src/crypto/md5/asm/m5-win32.asm686
-rw-r--r--src/lib/libssl/src/crypto/md5/asm/mx86unix.cpp730
-rw-r--r--src/lib/libssl/src/crypto/mdc2/Makefile.ssl80
-rw-r--r--src/lib/libssl/src/crypto/objects/Makefile.ssl87
-rw-r--r--src/lib/libssl/src/crypto/objects/objects.err12
-rw-r--r--src/lib/libssl/src/crypto/pem/Makefile.ssl96
-rw-r--r--src/lib/libssl/src/crypto/pem/ctx_size.c122
-rw-r--r--src/lib/libssl/src/crypto/pem/pem.err38
-rw-r--r--src/lib/libssl/src/crypto/pem/pem.org562
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/Makefile.ssl86
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/README5
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/mf.p718
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/p7.tst33
-rw-r--r--src/lib/libssl/src/crypto/pkcs7/pkcs7.err26
-rw-r--r--src/lib/libssl/src/crypto/rand/Makefile.ssl80
-rw-r--r--src/lib/libssl/src/crypto/ranlib.sh23
-rw-r--r--src/lib/libssl/src/crypto/rc2/Makefile.ssl80
-rw-r--r--src/lib/libssl/src/crypto/rc2/Makefile.uni72
-rw-r--r--src/lib/libssl/src/crypto/rc2/rc2.org118
-rw-r--r--src/lib/libssl/src/crypto/rc4/Makefile.ssl108
-rw-r--r--src/lib/libssl/src/crypto/rc4/Makefile.uni102
-rw-r--r--src/lib/libssl/src/crypto/rc4/asm/r4-win32.asm314
-rw-r--r--src/lib/libssl/src/crypto/rc4/asm/rx86unix.cpp358
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4.org103
-rw-r--r--src/lib/libssl/src/crypto/rc4/rc4_locl.org70
-rw-r--r--src/lib/libssl/src/crypto/rc5/Makefile.ssl107
-rw-r--r--src/lib/libssl/src/crypto/rc5/Makefile.uni72
-rw-r--r--src/lib/libssl/src/crypto/rc5/asm/r5-win32.asm574
-rw-r--r--src/lib/libssl/src/crypto/rc5/asm/r586unix.cpp628
-rw-r--r--src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl109
-rw-r--r--src/lib/libssl/src/crypto/ripemd/Makefile.ssl104
-rw-r--r--src/lib/libssl/src/crypto/ripemd/Makefile.uni109
-rw-r--r--src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm1972
-rw-r--r--src/lib/libssl/src/crypto/ripemd/asm/rm86unix.cpp2016
-rw-r--r--src/lib/libssl/src/crypto/rsa/Makefile.ssl86
-rw-r--r--src/lib/libssl/src/crypto/rsa/rsa.err45
-rw-r--r--src/lib/libssl/src/crypto/sha/Makefile.ssl103
-rw-r--r--src/lib/libssl/src/crypto/sha/Makefile.uni122
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/s1-win32.asm1664
-rw-r--r--src/lib/libssl/src/crypto/sha/asm/sx86unix.cpp1948
-rw-r--r--src/lib/libssl/src/crypto/sha/sha_sgst.c246
-rw-r--r--src/lib/libssl/src/crypto/stack/Makefile.ssl80
-rw-r--r--src/lib/libssl/src/crypto/txt_db/Makefile.ssl80
-rw-r--r--src/lib/libssl/src/crypto/x509/Makefile.ssl96
-rw-r--r--src/lib/libssl/src/crypto/x509/attrib38
-rw-r--r--src/lib/libssl/src/crypto/x509/v3_net.c87
-rw-r--r--src/lib/libssl/src/crypto/x509/v3_x509.c253
-rw-r--r--src/lib/libssl/src/crypto/x509/x509.doc27
-rw-r--r--src/lib/libssl/src/crypto/x509/x509.err46
-rw-r--r--src/lib/libssl/src/crypto/x509/x509pack.c157
-rw-r--r--src/lib/libssl/src/crypto/x509/x509v3.doc24
-rw-r--r--src/lib/libssl/src/crypto/x509v3/format92
-rw-r--r--src/lib/libssl/src/crypto/x509v3/header6
-rw-r--r--src/lib/libssl/src/crypto/x509v3/v3_ku.c318
-rw-r--r--src/lib/libssl/src/dep/crypto.txt1043
-rw-r--r--src/lib/libssl/src/dep/files574
-rw-r--r--src/lib/libssl/src/dep/gen.pl113
-rw-r--r--src/lib/libssl/src/dep/ssl.txt156
-rw-r--r--src/lib/libssl/src/doc/API.doc24
-rw-r--r--src/lib/libssl/src/doc/a_verify.doc85
-rw-r--r--src/lib/libssl/src/doc/apps.doc53
-rw-r--r--src/lib/libssl/src/doc/asn1.doc401
-rw-r--r--src/lib/libssl/src/doc/bio.doc423
-rw-r--r--src/lib/libssl/src/doc/blowfish.doc146
-rw-r--r--src/lib/libssl/src/doc/bn.doc381
-rw-r--r--src/lib/libssl/src/doc/ca.1121
-rw-r--r--src/lib/libssl/src/doc/callback.doc240
-rw-r--r--src/lib/libssl/src/doc/cipher.doc345
-rw-r--r--src/lib/libssl/src/doc/cipher.m128
-rw-r--r--src/lib/libssl/src/doc/conf.doc89
-rw-r--r--src/lib/libssl/src/doc/des.doc505
-rw-r--r--src/lib/libssl/src/doc/digest.doc94
-rw-r--r--src/lib/libssl/src/doc/encode.doc15
-rw-r--r--src/lib/libssl/src/doc/envelope.doc67
-rw-r--r--src/lib/libssl/src/doc/error.doc115
-rw-r--r--src/lib/libssl/src/doc/legal.doc117
-rw-r--r--src/lib/libssl/src/doc/lhash.doc151
-rw-r--r--src/lib/libssl/src/doc/md2.doc49
-rw-r--r--src/lib/libssl/src/doc/md5.doc50
-rw-r--r--src/lib/libssl/src/doc/memory.doc27
-rw-r--r--src/lib/libssl/src/doc/ms3-ca.doc398
-rw-r--r--src/lib/libssl/src/doc/ns-ca.doc154
-rw-r--r--src/lib/libssl/src/doc/obj.doc69
-rw-r--r--src/lib/libssl/src/doc/rand.doc141
-rw-r--r--src/lib/libssl/src/doc/rc2.doc165
-rw-r--r--src/lib/libssl/src/doc/rc4.doc44
-rw-r--r--src/lib/libssl/src/doc/readme6
-rw-r--r--src/lib/libssl/src/doc/ref.doc48
-rw-r--r--src/lib/libssl/src/doc/req.1137
-rw-r--r--src/lib/libssl/src/doc/rsa.doc135
-rw-r--r--src/lib/libssl/src/doc/rsaref.doc35
-rw-r--r--src/lib/libssl/src/doc/s_mult.doc17
-rw-r--r--src/lib/libssl/src/doc/session.doc297
-rw-r--r--src/lib/libssl/src/doc/sha.doc52
-rw-r--r--src/lib/libssl/src/doc/speed.doc96
-rw-r--r--src/lib/libssl/src/doc/ssl-ciph.doc84
-rw-r--r--src/lib/libssl/src/doc/ssl.doc172
-rw-r--r--src/lib/libssl/src/doc/ssl_ctx.doc68
-rw-r--r--src/lib/libssl/src/doc/ssleay.doc213
-rw-r--r--src/lib/libssl/src/doc/ssluse.doc45
-rw-r--r--src/lib/libssl/src/doc/stack.doc96
-rw-r--r--src/lib/libssl/src/doc/threads.doc90
-rw-r--r--src/lib/libssl/src/doc/txt_db.doc4
-rw-r--r--src/lib/libssl/src/doc/verify22
-rw-r--r--src/lib/libssl/src/doc/why.doc79
-rw-r--r--src/lib/libssl/src/makefile.one1781
-rw-r--r--src/lib/libssl/src/ms/cipher.out93
-rw-r--r--src/lib/libssl/src/ms/clear.out93
-rw-r--r--src/lib/libssl/src/ms/libeay16.def987
-rw-r--r--src/lib/libssl/src/ms/libeay32.def1035
-rw-r--r--src/lib/libssl/src/ms/ntdll.mak1853
-rw-r--r--src/lib/libssl/src/ms/ssleay16.def171
-rw-r--r--src/lib/libssl/src/ms/ssleay32.def164
-rw-r--r--src/lib/libssl/src/ms/w31dll.mak2295
-rw-r--r--src/lib/libssl/src/mt/README14
-rw-r--r--src/lib/libssl/src/mt/mttest.c1115
-rw-r--r--src/lib/libssl/src/mt/profile.sh4
-rw-r--r--src/lib/libssl/src/mt/ptest.bat4
-rw-r--r--src/lib/libssl/src/mt/pthread.sh9
-rw-r--r--src/lib/libssl/src/mt/purify.sh4
-rw-r--r--src/lib/libssl/src/mt/solaris.sh4
-rw-r--r--src/lib/libssl/src/mt/win32.bat4
-rw-r--r--src/lib/libssl/src/perl/MANIFEST17
-rw-r--r--src/lib/libssl/src/perl/Makefile.PL25
-rw-r--r--src/lib/libssl/src/perl/SSLeay.pm78
-rw-r--r--src/lib/libssl/src/perl/SSLeay.xs63
-rw-r--r--src/lib/libssl/src/perl/b.pl21
-rw-r--r--src/lib/libssl/src/perl/bio.pl28
-rw-r--r--src/lib/libssl/src/perl/bio.txt36
-rw-r--r--src/lib/libssl/src/perl/bio.xs448
-rw-r--r--src/lib/libssl/src/perl/bn.pl23
-rw-r--r--src/lib/libssl/src/perl/bn.txt38
-rw-r--r--src/lib/libssl/src/perl/bn.xs589
-rw-r--r--src/lib/libssl/src/perl/callback.c103
-rw-r--r--src/lib/libssl/src/perl/cipher.pl39
-rw-r--r--src/lib/libssl/src/perl/cipher.txt10
-rw-r--r--src/lib/libssl/src/perl/cipher.xs152
-rw-r--r--src/lib/libssl/src/perl/dh.pl40
-rw-r--r--src/lib/libssl/src/perl/digest.txt7
-rw-r--r--src/lib/libssl/src/perl/digest.xs83
-rw-r--r--src/lib/libssl/src/perl/err.txt2
-rw-r--r--src/lib/libssl/src/perl/err.xs46
-rw-r--r--src/lib/libssl/src/perl/f.pl25
-rw-r--r--src/lib/libssl/src/perl/g.pl18
-rw-r--r--src/lib/libssl/src/perl/gen_rsa.pl49
-rw-r--r--src/lib/libssl/src/perl/mul.pl56
-rw-r--r--src/lib/libssl/src/perl/p5SSLeay.h96
-rw-r--r--src/lib/libssl/src/perl/r.pl56
-rw-r--r--src/lib/libssl/src/perl/s.pl72
-rw-r--r--src/lib/libssl/src/perl/s2.pl49
-rw-r--r--src/lib/libssl/src/perl/server.pem369
-rw-r--r--src/lib/libssl/src/perl/ss.pl64
-rw-r--r--src/lib/libssl/src/perl/ssl.pl71
-rw-r--r--src/lib/libssl/src/perl/ssl.txt43
-rw-r--r--src/lib/libssl/src/perl/ssl.xs474
-rw-r--r--src/lib/libssl/src/perl/ssl_srvr.pl35
-rw-r--r--src/lib/libssl/src/perl/sslbio.pl40
-rw-r--r--src/lib/libssl/src/perl/t.pl12
-rw-r--r--src/lib/libssl/src/perl/test32
-rw-r--r--src/lib/libssl/src/perl/test.pl30
-rw-r--r--src/lib/libssl/src/perl/test.txt36
-rw-r--r--src/lib/libssl/src/perl/test2.pl28
-rw-r--r--src/lib/libssl/src/perl/test3.pl19
-rw-r--r--src/lib/libssl/src/perl/test8.pl19
-rw-r--r--src/lib/libssl/src/perl/test9.pl38
-rw-r--r--src/lib/libssl/src/perl/testbn.pl23
-rw-r--r--src/lib/libssl/src/perl/testdec.pl14
-rw-r--r--src/lib/libssl/src/perl/testmd.pl26
-rw-r--r--src/lib/libssl/src/perl/tt.pl15
-rw-r--r--src/lib/libssl/src/perl/typemap96
-rw-r--r--src/lib/libssl/src/perl/x509.txt6
-rw-r--r--src/lib/libssl/src/perl/x509.xs74
-rw-r--r--src/lib/libssl/src/perl/xstmp.c102
-rw-r--r--src/lib/libssl/src/perl/y.pl7
-rw-r--r--src/lib/libssl/src/perl/yy.pl19
-rw-r--r--src/lib/libssl/src/perl/z.pl32
-rw-r--r--src/lib/libssl/src/perl/zz.pl22
-rw-r--r--src/lib/libssl/src/shlib/linux.sh76
-rw-r--r--src/lib/libssl/src/ssl/Makefile.ssl100
-rw-r--r--src/lib/libssl/src/ssl/readme277
-rw-r--r--src/lib/libssl/src/ssl/ssl.c172
-rw-r--r--src/lib/libssl/src/ssl/ssl.err290
-rw-r--r--src/lib/libssl/src/test/.rndbin0 -> 1024 bytes
-rw-r--r--src/lib/libssl/src/test/Makefile.ssl294
-rw-r--r--src/lib/libssl/src/test/certCA.srl1
-rw-r--r--src/lib/libssl/src/test/demoCA/index.txt0
-rw-r--r--src/lib/libssl/src/test/demoCA/private/cakey.pem2
-rw-r--r--src/lib/libssl/src/test/demoCA/serial1
-rw-r--r--src/lib/libssl/src/test/dsa-ca.pem43
-rw-r--r--src/lib/libssl/src/test/dsa-pca.pem49
-rw-r--r--src/lib/libssl/src/test/p294
-rw-r--r--src/lib/libssl/src/test/riptestbin0 -> 13325 bytes
-rw-r--r--src/lib/libssl/src/test/test.txt31
-rw-r--r--src/lib/libssl/src/test/testkey.pem2
-rw-r--r--src/lib/libssl/src/test/testreq.pem9
-rw-r--r--src/lib/libssl/src/tools/Makefile.ssl54
-rw-r--r--src/lib/libssl/src/util/mklink.sh35
-rw-r--r--src/lib/libssl/src/util/ranlib.sh23
-rw-r--r--src/lib/libssl/src/util/sep_lib.sh37
-rw-r--r--src/lib/libssl/src/util/ssldir.pl52
-rw-r--r--src/lib/libssl/src/util/up_ver.pl79
-rw-r--r--src/lib/libssl/ssl-patent/Makefile90
-rw-r--r--src/lib/libssl/ssl-patent/shlib_version2
-rw-r--r--src/lib/libssl/ssl/Makefile90
-rw-r--r--src/lib/libssl/ssl/shlib_version2
-rw-r--r--src/lib/libssl/ssleay.cnf65
-rw-r--r--src/lib/libssl/test/.rndbin0 -> 1024 bytes
-rw-r--r--src/lib/libssl/test/Makefile.ssl294
-rw-r--r--src/lib/libssl/test/certCA.srl1
-rw-r--r--src/lib/libssl/test/demoCA/index.txt0
-rw-r--r--src/lib/libssl/test/demoCA/private/cakey.pem2
-rw-r--r--src/lib/libssl/test/demoCA/serial1
-rw-r--r--src/lib/libssl/test/dsa-ca.pem43
-rw-r--r--src/lib/libssl/test/dsa-pca.pem49
-rw-r--r--src/lib/libssl/test/p294
-rw-r--r--src/lib/libssl/test/riptestbin0 -> 13325 bytes
-rw-r--r--src/lib/libssl/test/test.txt31
-rw-r--r--src/lib/libssl/test/testkey.pem2
-rw-r--r--src/lib/libssl/test/testreq.pem9
-rw-r--r--src/regress/lib/libc/Makefile16
-rw-r--r--src/regress/lib/libc/_setjmp/Makefile16
-rw-r--r--src/regress/lib/libc/arch/alpha/Makefile10
-rw-r--r--src/regress/lib/libc/arch/alpha/divremtest/Makefile29
-rw-r--r--src/regress/lib/libc/arch/alpha/divremtest/divremtest.c183
-rw-r--r--src/regress/lib/libc/arch/alpha/divremtest/mkcases.c63
-rw-r--r--src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c67
-rw-r--r--src/regress/lib/libc/db/Makefile17
-rw-r--r--src/regress/lib/libc/db/README68
-rw-r--r--src/regress/lib/libc/db/dbtest.c759
-rw-r--r--src/regress/lib/libc/db/run.test706
-rw-r--r--src/regress/lib/libc/ieeefp/Makefile9
-rw-r--r--src/regress/lib/libc/ieeefp/except/Makefile12
-rw-r--r--src/regress/lib/libc/ieeefp/except/except.c88
-rw-r--r--src/regress/lib/libc/ieeefp/round/Makefile12
-rw-r--r--src/regress/lib/libc/ieeefp/round/round.c44
-rw-r--r--src/regress/lib/libc/regex/Makefile16
-rw-r--r--src/regress/lib/libc/regex/debug.c244
-rw-r--r--src/regress/lib/libc/regex/debug.ih16
-rw-r--r--src/regress/lib/libc/regex/main.c515
-rw-r--r--src/regress/lib/libc/regex/main.ih21
-rw-r--r--src/regress/lib/libc/regex/split.c318
-rw-r--r--src/regress/lib/libc/regex/tests477
-rw-r--r--src/regress/lib/libc/setjmp/Makefile16
-rw-r--r--src/regress/lib/libc/setjmp/jmptest.c135
-rw-r--r--src/regress/lib/libc/sigsetjmp/Makefile17
-rw-r--r--src/regress/lib/libssl/Makefile11
-rw-r--r--src/regress/lib/libssl/README8
-rw-r--r--src/regress/lib/libssl/ssleay.cnf27
-rw-r--r--src/regress/lib/libssl/test_client.sh11
-rw-r--r--src/regress/lib/libssl/test_server.sh9
-rw-r--r--src/regress/lib/libssl/testdsa.sh27
-rw-r--r--src/regress/lib/libssl/testenc.sh63
-rw-r--r--src/regress/lib/libssl/testrsa.sh36
-rw-r--r--src/usr.bin/nc/Makefile7
-rw-r--r--src/usr.bin/nc/README946
-rw-r--r--src/usr.bin/nc/data/Makefile10
-rw-r--r--src/usr.bin/nc/data/README9
-rw-r--r--src/usr.bin/nc/data/data.c274
-rw-r--r--src/usr.bin/nc/data/dns-any.d36
-rw-r--r--src/usr.bin/nc/data/nfs-0.d59
-rw-r--r--src/usr.bin/nc/data/pm.d8
-rw-r--r--src/usr.bin/nc/data/pmap-dump.d60
-rw-r--r--src/usr.bin/nc/data/pmap-mnt.d78
-rw-r--r--src/usr.bin/nc/data/rip.d52
-rw-r--r--src/usr.bin/nc/data/rservice.c68
-rw-r--r--src/usr.bin/nc/data/showmount.d63
-rw-r--r--src/usr.bin/nc/data/xor.c92
-rw-r--r--src/usr.bin/nc/generic.h377
-rw-r--r--src/usr.bin/nc/nc.1215
-rw-r--r--src/usr.bin/nc/netcat.blurb61
-rw-r--r--src/usr.bin/nc/netcat.c1670
-rw-r--r--src/usr.bin/nc/scripts/README5
-rw-r--r--src/usr.bin/nc/scripts/alta33
-rw-r--r--src/usr.bin/nc/scripts/bsh29
-rw-r--r--src/usr.bin/nc/scripts/dist.sh23
-rw-r--r--src/usr.bin/nc/scripts/irc79
-rw-r--r--src/usr.bin/nc/scripts/iscan35
-rw-r--r--src/usr.bin/nc/scripts/ncp46
-rw-r--r--src/usr.bin/nc/scripts/probe50
-rw-r--r--src/usr.bin/nc/scripts/web148
-rw-r--r--src/usr.bin/nc/scripts/webproxy138
-rw-r--r--src/usr.bin/nc/scripts/webrelay44
-rw-r--r--src/usr.bin/nc/scripts/websearch77
901 files changed, 169096 insertions, 0 deletions
diff --git a/src/lib/libc/crypt/Makefile.inc b/src/lib/libc/crypt/Makefile.inc
new file mode 100644
index 0000000000..068172d8eb
--- /dev/null
+++ b/src/lib/libc/crypt/Makefile.inc
@@ -0,0 +1,12 @@
1# $OpenBSD: Makefile.inc,v 1.12 1999/02/26 00:54:00 deraadt Exp $
2
3.PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/crypt ${LIBCSRCDIR}/crypt
4
5SRCS+= cast.c crypt.c morecrypt.c md5crypt.c arc4random.c blowfish.c
6SRCS+= bcrypt.c skipjack.c
7
8MAN+= crypt.3 blowfish.3 arc4random.3
9MLINKS+=crypt.3 encrypt.3 crypt.3 setkey.3 crypt.3 des_cipher.3
10MLINKS+=crypt.3 des_setkey.3 blowfish.3 blf_key.3 blowfish.3 blf_enc.3
11MLINKS+=blowfish.3 blf_dec.3
12MLINKS+=arc4random.3 arc4random_stir.3 arc4random.3 arc4random_addrandom.3
diff --git a/src/lib/libc/crypt/arc4random.3 b/src/lib/libc/crypt/arc4random.3
new file mode 100644
index 0000000000..741965c5ac
--- /dev/null
+++ b/src/lib/libc/crypt/arc4random.3
@@ -0,0 +1,83 @@
1.\" $OpenBSD: arc4random.3,v 1.4 1998/09/07 16:44:34 aaron Exp $
2.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\" must display the following acknowledgement:
15.\" This product includes software developed by Niels Provos.
16.\" 4. The name of the author may not be used to endorse or promote products
17.\" derived from this software without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" Manual page, using -mandoc macros
31.\"
32.Dd April 15, 1997
33.Dt ARC4RANDOM 3
34.Os "OpenBSD 2.0"
35.Sh NAME
36.Nm arc4random,
37.Nm arc4random_stir,
38.Nm arc4random_addrandom
39.Nd arc4 random number generator.
40.Sh SYNOPSIS
41.Fd #include <stdlib.h>
42.Ft u_int32_t
43.Fn arc4random "void"
44.Ft void
45.Fn arc4random_stir "void"
46.Ft void
47.Fn arc4random_addrandom "u_char *dat" "int datlen"
48.Sh DESCRIPTION
49The
50.Fn arc4random
51function uses the key stream generator employed by the
52arc4 cipher, which uses 8*8 8 bit S-Boxes. The S-Boxes
53can be in about
54.if t 2\u\s71700\s10\d
55.if n (2**1700)
56states.
57.Pp
58The
59.Fn arc4random_stir
60function reads data from
61.Pa /dev/arandom
62and uses it to permutate the S-Boxes via
63.Fn arc4random_addrandom .
64.Pp
65There is no need to call
66.Fn arc4random_stir
67before using
68.Fn arc4random ,
69since
70.Fn arc4random
71automatically initalizes itself.
72.Sh SEE ALSO
73.Xr rand48 3 ,
74.Xr rand 3 ,
75.Xr random 3
76.Sh HISTORY
77.Pa RC4
78has been designed by RSA Data Security, Inc. It was posted anonymously
79to the USENET and was confirmed to be equivalent by several sources who
80had access to the original cipher. Since
81.Pa RC4
82used to be a trade secret, the cipher is now referred to as
83.Pa ARC4 .
diff --git a/src/lib/libc/crypt/arc4random.c b/src/lib/libc/crypt/arc4random.c
new file mode 100644
index 0000000000..5279c21518
--- /dev/null
+++ b/src/lib/libc/crypt/arc4random.c
@@ -0,0 +1,176 @@
1/* $OpenBSD: arc4random.c,v 1.3 1998/03/22 19:01:16 niklas Exp $ */
2
3/*
4 * Arc4 random number generator for OpenBSD.
5 * Copyright 1996 David Mazieres <dm@lcs.mit.edu>.
6 *
7 * Modification and redistribution in source and binary forms is
8 * permitted provided that due credit is given to the author and the
9 * OpenBSD project (for instance by leaving this copyright notice
10 * intact).
11 */
12
13/*
14 * This code is derived from section 17.1 of Applied Cryptography,
15 * second edition, which describes a stream cipher allegedly
16 * compatible with RSA Labs "RC4" cipher (the actual description of
17 * which is a trade secret). The same algorithm is used as a stream
18 * cipher called "arcfour" in Tatu Ylonen's ssh package.
19 *
20 * Here the stream cipher has been modified always to include the time
21 * when initializing the state. That makes it impossible to
22 * regenerate the same random sequence twice, so this can't be used
23 * for encryption, but will generate good random numbers.
24 *
25 * RC4 is a registered trademark of RSA Laboratories.
26 */
27
28#include <fcntl.h>
29#include <stdlib.h>
30#include <unistd.h>
31#include <sys/types.h>
32#include <sys/time.h>
33
34#ifdef __GNUC__
35#define inline __inline
36#else /* !__GNUC__ */
37#define inline
38#endif /* !__GNUC__ */
39
40struct arc4_stream {
41 u_int8_t i;
42 u_int8_t j;
43 u_int8_t s[256];
44};
45
46int rs_initialized;
47static struct arc4_stream rs;
48
49static inline void
50arc4_init(as)
51 struct arc4_stream *as;
52{
53 int n;
54
55 for (n = 0; n < 256; n++)
56 as->s[n] = n;
57 as->i = 0;
58 as->j = 0;
59}
60
61static inline void
62arc4_addrandom(as, dat, datlen)
63 struct arc4_stream *as;
64 u_char *dat;
65 int datlen;
66{
67 int n;
68 u_int8_t si;
69
70 as->i--;
71 for (n = 0; n < 256; n++) {
72 as->i = (as->i + 1);
73 si = as->s[as->i];
74 as->j = (as->j + si + dat[n % datlen]);
75 as->s[as->i] = as->s[as->j];
76 as->s[as->j] = si;
77 }
78}
79
80static void
81arc4_stir(as)
82 struct arc4_stream *as;
83{
84 int fd;
85 struct {
86 struct timeval tv;
87 u_int8_t rnd[128 - sizeof(struct timeval)];
88 } rdat;
89
90 gettimeofday(&rdat.tv, NULL);
91 fd = open("/dev/arandom", O_RDONLY);
92 if (fd >= 0) {
93 read(fd, rdat.rnd, sizeof(rdat.rnd));
94 close(fd);
95 }
96 /* fd < 0? Ah, what the heck. We'll just take whatever was on the
97 * stack... */
98
99 arc4_addrandom(as, (void *) &rdat, sizeof(rdat));
100}
101
102static inline u_int8_t
103arc4_getbyte(as)
104 struct arc4_stream *as;
105{
106 u_int8_t si, sj;
107
108 as->i = (as->i + 1);
109 si = as->s[as->i];
110 as->j = (as->j + si);
111 sj = as->s[as->j];
112 as->s[as->i] = sj;
113 as->s[as->j] = si;
114 return (as->s[(si + sj) & 0xff]);
115}
116
117static inline u_int32_t
118arc4_getword(as)
119 struct arc4_stream *as;
120{
121 u_int32_t val;
122 val = arc4_getbyte(as) << 24;
123 val |= arc4_getbyte(as) << 16;
124 val |= arc4_getbyte(as) << 8;
125 val |= arc4_getbyte(as);
126 return val;
127}
128
129void
130arc4random_stir()
131{
132 if (!rs_initialized) {
133 arc4_init(&rs);
134 rs_initialized = 1;
135 }
136 arc4_stir(&rs);
137}
138
139void
140arc4random_addrandom(dat, datlen)
141 u_char *dat;
142 int datlen;
143{
144 if (!rs_initialized)
145 arc4random_stir();
146 arc4_addrandom(&rs, dat, datlen);
147}
148
149u_int32_t
150arc4random()
151{
152 if (!rs_initialized)
153 arc4random_stir();
154 return arc4_getword(&rs);
155}
156
157#if 0
158/*-------- Test code for i386 --------*/
159#include <stdio.h>
160#include <machine/pctr.h>
161int
162main(int argc, char **argv)
163{
164 const int iter = 1000000;
165 int i;
166 pctrval v;
167
168 v = rdtsc();
169 for (i = 0; i < iter; i++)
170 arc4random();
171 v = rdtsc() - v;
172 v /= iter;
173
174 printf("%qd cycles\n", v);
175}
176#endif
diff --git a/src/lib/libc/crypt/bcrypt.c b/src/lib/libc/crypt/bcrypt.c
new file mode 100644
index 0000000000..1b121fb28f
--- /dev/null
+++ b/src/lib/libc/crypt/bcrypt.c
@@ -0,0 +1,362 @@
1/* $OpenBSD: bcrypt.c,v 1.12 1998/08/10 18:33:07 provos Exp $ */
2
3/*
4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Niels Provos.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33/* This password hashing algorithm was designed by David Mazieres
34 * <dm@lcs.mit.edu> and works as follows:
35 *
36 * 1. state := InitState ()
37 * 2. state := ExpandKey (state, salt, password) 3.
38 * REPEAT rounds:
39 * state := ExpandKey (state, 0, salt)
40 * state := ExpandKey(state, 0, password)
41 * 4. ctext := "OrpheanBeholderScryDoubt"
42 * 5. REPEAT 64:
43 * ctext := Encrypt_ECB (state, ctext);
44 * 6. RETURN Concatenate (salt, ctext);
45 *
46 */
47
48#if 0
49#include <stdio.h>
50#endif
51
52#include <stdio.h>
53#include <stdlib.h>
54#include <sys/types.h>
55#include <string.h>
56#include <pwd.h>
57#include <blf.h>
58
59/* This implementation is adaptable to current computing power.
60 * You can have up to 2^31 rounds which should be enough for some
61 * time to come.
62 */
63
64#define BCRYPT_VERSION '2'
65#define BCRYPT_MAXSALT 16 /* Precomputation is just so nice */
66#define BCRYPT_BLOCKS 6 /* Ciphertext blocks */
67#define BCRYPT_MINROUNDS 16 /* we have log2(rounds) in salt */
68
69char *bcrypt_gensalt __P((u_int8_t));
70
71static void encode_salt __P((char *, u_int8_t *, u_int16_t, u_int8_t));
72static void encode_base64 __P((u_int8_t *, u_int8_t *, u_int16_t));
73static void decode_base64 __P((u_int8_t *, u_int16_t, u_int8_t *));
74
75static char encrypted[_PASSWORD_LEN];
76static char gsalt[BCRYPT_MAXSALT * 4 / 3 + 1];
77static char error[] = ":";
78
79const static u_int8_t Base64Code[] =
80"./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
81
82const static u_int8_t index_64[128] =
83{
84 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
85 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
86 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
87 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
88 255, 255, 255, 255, 255, 255, 0, 1, 54, 55,
89 56, 57, 58, 59, 60, 61, 62, 63, 255, 255,
90 255, 255, 255, 255, 255, 2, 3, 4, 5, 6,
91 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
92 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
93 255, 255, 255, 255, 255, 255, 28, 29, 30,
94 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
95 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
96 51, 52, 53, 255, 255, 255, 255, 255
97};
98#define CHAR64(c) ( (c) > 127 ? 255 : index_64[(c)])
99
100#ifdef __STDC__
101static void
102decode_base64(u_int8_t *buffer, u_int16_t len, u_int8_t *data)
103#else
104static void
105decode_base64(buffer, len, data)
106 u_int8_t *buffer;
107 u_int16_t len;
108 u_int8_t *data;
109#endif
110{
111 u_int8_t *bp = buffer;
112 u_int8_t *p = data;
113 u_int8_t c1, c2, c3, c4;
114 while (bp < buffer + len) {
115 c1 = CHAR64(*p);
116 c2 = CHAR64(*(p + 1));
117
118 /* Invalid data */
119 if (c1 == 255 || c2 == 255)
120 break;
121
122 *bp++ = (c1 << 2) | ((c2 & 0x30) >> 4);
123 if (bp >= buffer + len)
124 break;
125
126 c3 = CHAR64(*(p + 2));
127 if (c3 == 255)
128 break;
129
130 *bp++ = ((c2 & 0x0f) << 4) | ((c3 & 0x3c) >> 2);
131 if (bp >= buffer + len)
132 break;
133
134 c4 = CHAR64(*(p + 3));
135 if (c4 == 255)
136 break;
137 *bp++ = ((c3 & 0x03) << 6) | c4;
138
139 p += 4;
140 }
141}
142
143#ifdef __STDC__
144static void
145encode_salt(char *salt, u_int8_t *csalt, u_int16_t clen, u_int8_t logr)
146#else
147static void
148encode_salt(salt, csalt, clen, logr)
149 char *salt;
150 u_int8_t *csalt;
151 u_int16_t clen;
152 u_int8_t logr;
153#endif
154{
155 salt[0] = '$';
156 salt[1] = BCRYPT_VERSION;
157 salt[2] = 'a';
158 salt[3] = '$';
159
160 snprintf(salt + 4, 4, "%2.2u$", logr);
161
162 encode_base64((u_int8_t *) salt + 7, csalt, clen);
163}
164/* Generates a salt for this version of crypt.
165 Since versions may change. Keeping this here
166 seems sensible.
167 */
168
169#ifdef __STDC__
170char *
171bcrypt_gensalt(u_int8_t log_rounds)
172#else
173char *
174bcrypt_gensalt(log_rounds)
175 u_int8_t log_rounds;
176#endif
177{
178 u_int8_t csalt[BCRYPT_MAXSALT];
179 u_int16_t i;
180 u_int32_t seed = 0;
181
182 for (i = 0; i < BCRYPT_MAXSALT; i++) {
183 if (i % 4 == 0)
184 seed = arc4random();
185 csalt[i] = seed & 0xff;
186 seed = seed >> 8;
187 }
188
189 if (log_rounds < 4)
190 log_rounds = 4;
191
192 encode_salt(gsalt, csalt, BCRYPT_MAXSALT, log_rounds);
193 return gsalt;
194}
195/* We handle $Vers$log2(NumRounds)$salt+passwd$
196 i.e. $2$04$iwouldntknowwhattosayetKdJ6iFtacBqJdKe6aW7ou */
197
198char *
199bcrypt(key, salt)
200 const char *key;
201 const char *salt;
202{
203 blf_ctx state;
204 u_int32_t rounds, i, k;
205 u_int16_t j;
206 u_int8_t key_len, salt_len, logr, minor;
207 u_int8_t ciphertext[4 * BCRYPT_BLOCKS] = "OrpheanBeholderScryDoubt";
208 u_int8_t csalt[BCRYPT_MAXSALT];
209 u_int32_t cdata[BCRYPT_BLOCKS];
210
211 /* Discard "$" identifier */
212 salt++;
213
214 if (*salt > BCRYPT_VERSION) {
215 /* How do I handle errors ? Return ':' */
216 return error;
217 }
218
219 /* Check for minor versions */
220 if (salt[1] != '$') {
221 switch (salt[1]) {
222 case 'a':
223 /* 'ab' should not yield the same as 'abab' */
224 minor = salt[1];
225 salt++;
226 break;
227 default:
228 return error;
229 }
230 } else
231 minor = 0;
232
233 /* Discard version + "$" identifier */
234 salt += 2;
235
236 if (salt[2] != '$')
237 /* Out of sync with passwd entry */
238 return error;
239
240 /* Computer power doesnt increase linear, 2^x should be fine */
241 if ((rounds = (u_int32_t) 1 << (logr = atoi(salt))) < BCRYPT_MINROUNDS)
242 return error;
243
244 /* Discard num rounds + "$" identifier */
245 salt += 3;
246
247 /* We dont want the base64 salt but the raw data */
248 decode_base64(csalt, BCRYPT_MAXSALT, (u_int8_t *) salt);
249 salt_len = BCRYPT_MAXSALT;
250 key_len = strlen(key) + (minor >= 'a' ? 1 : 0);
251
252 /* Setting up S-Boxes and Subkeys */
253 Blowfish_initstate(&state);
254 Blowfish_expandstate(&state, csalt, salt_len,
255 (u_int8_t *) key, key_len);
256 for (k = 0; k < rounds; k++) {
257 Blowfish_expand0state(&state, (u_int8_t *) key, key_len);
258 Blowfish_expand0state(&state, csalt, salt_len);
259 }
260
261 /* This can be precomputed later */
262 j = 0;
263 for (i = 0; i < BCRYPT_BLOCKS; i++)
264 cdata[i] = Blowfish_stream2word(ciphertext, 4 * BCRYPT_BLOCKS, &j);
265
266 /* Now do the encryption */
267 for (k = 0; k < 64; k++)
268 blf_enc(&state, cdata, BCRYPT_BLOCKS / 2);
269
270 for (i = 0; i < BCRYPT_BLOCKS; i++) {
271 ciphertext[4 * i + 3] = cdata[i] & 0xff;
272 cdata[i] = cdata[i] >> 8;
273 ciphertext[4 * i + 2] = cdata[i] & 0xff;
274 cdata[i] = cdata[i] >> 8;
275 ciphertext[4 * i + 1] = cdata[i] & 0xff;
276 cdata[i] = cdata[i] >> 8;
277 ciphertext[4 * i + 0] = cdata[i] & 0xff;
278 }
279
280
281 i = 0;
282 encrypted[i++] = '$';
283 encrypted[i++] = BCRYPT_VERSION;
284 if (minor)
285 encrypted[i++] = minor;
286 encrypted[i++] = '$';
287
288 snprintf(encrypted + i, 4, "%2.2u$", logr);
289
290 encode_base64((u_int8_t *) encrypted + i + 3, csalt, BCRYPT_MAXSALT);
291 encode_base64((u_int8_t *) encrypted + strlen(encrypted), ciphertext,
292 4 * BCRYPT_BLOCKS - 1);
293 return encrypted;
294}
295
296#ifdef __STDC__
297static void
298encode_base64(u_int8_t *buffer, u_int8_t *data, u_int16_t len)
299#else
300static void
301encode_base64(buffer, data, len)
302 u_int8_t *buffer;
303 u_int8_t *data;
304 u_int16_t len;
305#endif
306{
307 u_int8_t *bp = buffer;
308 u_int8_t *p = data;
309 u_int8_t c1, c2;
310 while (p < data + len) {
311 c1 = *p++;
312 *bp++ = Base64Code[(c1 >> 2)];
313 c1 = (c1 & 0x03) << 4;
314 if (p >= data + len) {
315 *bp++ = Base64Code[c1];
316 break;
317 }
318 c2 = *p++;
319 c1 |= (c2 >> 4) & 0x0f;
320 *bp++ = Base64Code[c1];
321 c1 = (c2 & 0x0f) << 2;
322 if (p >= data + len) {
323 *bp++ = Base64Code[c1];
324 break;
325 }
326 c2 = *p++;
327 c1 |= (c2 >> 6) & 0x03;
328 *bp++ = Base64Code[c1];
329 *bp++ = Base64Code[c2 & 0x3f];
330 }
331 *bp = '\0';
332}
333#if 0
334void
335main()
336{
337 char blubber[73];
338 char salt[100];
339 char *p;
340 salt[0] = '$';
341 salt[1] = BCRYPT_VERSION;
342 salt[2] = '$';
343
344 snprintf(salt + 3, 4, "%2.2u$", 5);
345
346 printf("24 bytes of salt: ");
347 fgets(salt + 6, 94, stdin);
348 salt[99] = 0;
349 printf("72 bytes of password: ");
350 fpurge(stdin);
351 fgets(blubber, 73, stdin);
352 blubber[72] = 0;
353
354 p = crypt(blubber, salt);
355 printf("Passwd entry: %s\n\n", p);
356
357 p = bcrypt_gensalt(5);
358 printf("Generated salt: %s\n", p);
359 p = crypt(blubber, p);
360 printf("Passwd entry: %s\n", p);
361}
362#endif
diff --git a/src/lib/libc/crypt/blowfish.3 b/src/lib/libc/crypt/blowfish.3
new file mode 100644
index 0000000000..02a1ef8738
--- /dev/null
+++ b/src/lib/libc/crypt/blowfish.3
@@ -0,0 +1,104 @@
1.\" $OpenBSD: blowfish.3,v 1.2 1998/08/10 18:40:58 provos Exp $
2.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\" must display the following acknowledgement:
15.\" This product includes software developed by Niels Provos.
16.\" 4. The name of the author may not be used to endorse or promote products
17.\" derived from this software without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29.\"
30.\" Manual page, using -mandoc macros
31.\"
32.Dd February 13, 1997
33.Dt BLOWFISH 3
34.Os "OpenBSD 2.0"
35.Sh NAME
36.Nm blf_key,
37.Nm blf_enc,
38.Nm blf_dec
39.Nd Blowfish encryption
40.Sh SYNOPSIS
41.Fd #include <blf.h>
42.Ft void
43.Fn blf_key "blf_ctx *state" "const u_int8_t *key" "u_int16_t keylen"
44.Ft void
45.Fn blf_enc "blf_ctx *state" "u_int32_t *data" "u_int16_t datalen"
46.Ft void
47.Fn blf_dec "blf_ctx *state" "u_int32_t *data" "u_int16_t datalen"
48.Ft void
49.Fn blf_ecb_encrypt "blf_ctx *state" "u_int8_t *data" "u_int32_t datalen"
50.Ft void
51.Fn blf_ecb_decrypt "blf_ctx *state" "u_int8_t *data" "u_int32_t datalen"
52.Ft void
53.Fn blf_cbc_encrypt "blf_ctx *state" "u_int8_t *iv" "u_int8_t *data" "u_int32_t datalen"
54.Ft void
55.Fn blf_cbc_decrypt "blf_ctx *state" "u_int8_t *iv" "u_int8_t *data" "u_int32_t datalen"
56.Sh DESCRIPTION
57.Pa Blowfish
58is a fast unpatented block cipher designed by Bruce Schneier.
59It basically consists of a 16 times iterated Feistel network.
60The block size is 64 bit and the key size is maximal 448 bit.
61.Pp
62The
63.Fn blf_key
64function initializes the 4 8bit S-boxes and the 18 Subkeys with
65the hexadecimal digits of Pi. The key is used for further randomization.
66The first argument to
67.Fn blf_enc
68is the initalized state derived from
69.Fn blf_key .
70The stream of 32-bit words is encrypted in Electronic Codebook
71Mode (ECB) and
72.Pa datalen
73must be even.
74.Fn blf_dec
75is used for decrypting Blowfish encrypted blocks.
76.Pp
77The functions
78.Fn blf_ecb_encrypt
79and
80.Fn blf_ecb_decrypt
81are used for encrypting and decrypting octet streams in ECB mode.
82The functions
83.Fn blf_cbc_encrypt
84and
85.Fn blf_cbc_decrypt
86are used for encrypting and decrypting octet streams in
87Cipherblock Chaining Mode (CBC).
88.Pp
89The functions
90.Fn Blowfish_initstate ,
91.Fn Blowfish_expand0state ,
92.Fn Blowfish_expandstate ,
93.Fn Blowfish_encipher
94and
95.Fn Blowfish_decipher
96are used for customization of the
97.Pa Blowfish
98cipher, e.g. for the blowfish password hashing function.
99.Sh SEE ALSO
100.Xr crypt 3 ,
101.Xr passwd 1 ,
102.Xr passwd 5
103.Sh AUTHOR
104Niels Provos <provos@physnet.uni-hamburg.de>
diff --git a/src/lib/libc/crypt/blowfish.c b/src/lib/libc/crypt/blowfish.c
new file mode 100644
index 0000000000..6cddbc64b3
--- /dev/null
+++ b/src/lib/libc/crypt/blowfish.c
@@ -0,0 +1,774 @@
1/* $OpenBSD: blowfish.c,v 1.12 1998/08/30 22:35:39 niklas Exp $ */
2/*
3 * Blowfish block cipher for OpenBSD
4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
5 * All rights reserved.
6 *
7 * Implementation advice by David Mazieres <dm@lcs.mit.edu>.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by Niels Provos.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/*
36 * This code is derived from section 14.3 and the given source
37 * in section V of Applied Cryptography, second edition.
38 * Blowfish is an unpatented fast block cipher designed by
39 * Bruce Schneier.
40 */
41
42#if 0
43#include <stdio.h> /* used for debugging */
44#include <string.h>
45#endif
46
47#include <sys/types.h>
48#include <blf.h>
49
50#undef inline
51#ifdef __GNUC__
52#define inline __inline
53#else /* !__GNUC__ */
54#define inline
55#endif /* !__GNUC__ */
56
57/* Function for Feistel Networks */
58
59#define F(bc, x) ((((bc)->S[0][((x) & 0xFF000000) >> 24] \
60 + (bc)->S[1][((x) &0xFF0000 ) >> 16]) \
61 ^ (bc)->S[2][((x) & 0xFF00) >> 8]) \
62 + (bc)->S[3][(x) & 0x00FF])
63
64#define BLFRND(bc,i,j,n) (i ^= F(bc,j) ^ (bc)->P[n])
65
66void
67Blowfish_encipher(c, xl, xr)
68 blf_ctx *c;
69 u_int32_t *xl;
70 u_int32_t *xr;
71{
72 u_int32_t Xl;
73 u_int32_t Xr;
74
75 Xl = *xl;
76 Xr = *xr;
77
78 Xl ^= c->P[0];
79 BLFRND(c, Xr, Xl, 1); BLFRND(c, Xl, Xr, 2);
80 BLFRND(c, Xr, Xl, 3); BLFRND(c, Xl, Xr, 4);
81 BLFRND(c, Xr, Xl, 5); BLFRND(c, Xl, Xr, 6);
82 BLFRND(c, Xr, Xl, 7); BLFRND(c, Xl, Xr, 8);
83 BLFRND(c, Xr, Xl, 9); BLFRND(c, Xl, Xr, 10);
84 BLFRND(c, Xr, Xl, 11); BLFRND(c, Xl, Xr, 12);
85 BLFRND(c, Xr, Xl, 13); BLFRND(c, Xl, Xr, 14);
86 BLFRND(c, Xr, Xl, 15); BLFRND(c, Xl, Xr, 16);
87
88 *xl = Xr ^ c->P[17];
89 *xr = Xl;
90}
91
92void
93Blowfish_decipher(c, xl, xr)
94 blf_ctx *c;
95 u_int32_t *xl;
96 u_int32_t *xr;
97{
98 u_int32_t Xl;
99 u_int32_t Xr;
100
101 Xl = *xl;
102 Xr = *xr;
103
104 Xl ^= c->P[17];
105 BLFRND(c, Xr, Xl, 16); BLFRND(c, Xl, Xr, 15);
106 BLFRND(c, Xr, Xl, 14); BLFRND(c, Xl, Xr, 13);
107 BLFRND(c, Xr, Xl, 12); BLFRND(c, Xl, Xr, 11);
108 BLFRND(c, Xr, Xl, 10); BLFRND(c, Xl, Xr, 9);
109 BLFRND(c, Xr, Xl, 8); BLFRND(c, Xl, Xr, 7);
110 BLFRND(c, Xr, Xl, 6); BLFRND(c, Xl, Xr, 5);
111 BLFRND(c, Xr, Xl, 4); BLFRND(c, Xl, Xr, 3);
112 BLFRND(c, Xr, Xl, 2); BLFRND(c, Xl, Xr, 1);
113
114 *xl = Xr ^ c->P[0];
115 *xr = Xl;
116}
117
118void
119Blowfish_initstate(c)
120 blf_ctx *c;
121{
122
123/* P-box and S-box tables initialized with digits of Pi */
124
125 const blf_ctx initstate =
126
127 { {
128 {
129 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
130 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
131 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
132 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
133 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
134 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
135 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
136 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
137 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
138 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
139 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
140 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
141 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
142 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
143 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
144 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
145 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
146 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
147 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
148 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
149 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
150 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
151 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
152 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
153 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
154 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
155 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
156 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
157 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
158 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
159 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
160 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
161 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
162 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
163 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
164 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
165 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
166 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
167 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
168 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
169 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
170 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
171 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
172 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
173 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
174 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
175 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
176 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
177 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
178 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
179 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
180 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
181 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
182 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
183 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
184 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
185 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
186 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
187 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
188 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
189 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
190 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
191 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
192 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a},
193 {
194 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
195 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
196 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
197 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
198 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
199 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
200 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
201 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
202 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
203 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
204 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
205 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
206 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
207 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
208 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
209 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
210 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
211 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
212 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
213 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
214 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
215 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
216 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
217 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
218 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
219 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
220 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
221 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
222 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
223 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
224 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
225 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
226 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
227 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
228 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
229 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
230 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
231 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
232 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
233 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
234 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
235 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
236 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
237 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
238 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
239 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
240 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
241 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
242 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
243 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
244 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
245 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
246 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
247 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
248 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
249 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
250 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
251 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
252 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
253 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
254 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
255 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
256 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
257 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7},
258 {
259 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
260 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
261 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
262 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
263 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
264 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
265 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
266 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
267 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
268 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
269 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
270 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
271 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
272 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
273 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
274 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
275 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
276 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
277 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
278 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
279 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
280 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
281 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
282 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
283 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
284 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
285 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
286 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
287 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
288 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
289 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
290 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
291 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
292 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
293 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
294 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
295 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
296 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
297 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
298 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
299 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
300 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
301 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
302 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
303 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
304 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
305 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
306 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
307 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
308 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
309 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
310 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
311 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
312 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
313 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
314 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
315 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
316 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
317 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
318 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
319 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
320 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
321 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
322 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0},
323 {
324 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
325 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
326 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
327 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
328 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
329 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
330 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
331 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
332 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
333 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
334 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
335 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
336 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
337 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
338 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
339 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
340 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
341 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
342 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
343 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
344 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
345 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
346 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
347 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
348 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
349 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
350 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
351 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
352 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
353 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
354 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
355 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
356 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
357 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
358 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
359 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
360 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
361 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
362 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
363 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
364 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
365 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
366 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
367 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
368 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
369 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
370 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
371 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
372 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
373 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
374 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
375 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
376 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
377 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
378 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
379 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
380 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
381 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
382 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
383 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
384 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
385 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
386 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
387 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6}
388 },
389 {
390 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
391 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
392 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
393 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
394 0x9216d5d9, 0x8979fb1b
395 } };
396
397 *c = initstate;
398
399}
400
401#ifdef __STDC__
402u_int32_t
403Blowfish_stream2word(const u_int8_t *data, u_int16_t databytes, u_int16_t *current)
404#else
405u_int32_t
406Blowfish_stream2word(data, databytes, current)
407 const u_int8_t *data;
408 u_int16_t databytes;
409 u_int16_t *current;
410#endif
411{
412 u_int8_t i;
413 u_int16_t j;
414 u_int32_t temp;
415
416 temp = 0x00000000;
417 j = *current;
418
419 for (i = 0; i < 4; i++, j++) {
420 if (j >= databytes)
421 j = 0;
422 temp = (temp << 8) | data[j];
423 }
424
425 *current = j;
426 return temp;
427}
428
429#if __STDC__
430void
431Blowfish_expand0state(blf_ctx *c, const u_int8_t *key, u_int16_t keybytes)
432#else
433void
434Blowfish_expand0state(c, key, keybytes)
435 blf_ctx *c;
436 const u_int8_t *key;
437 u_int16_t keybytes;
438#endif
439{
440 u_int16_t i;
441 u_int16_t j;
442 u_int16_t k;
443 u_int32_t temp;
444 u_int32_t datal;
445 u_int32_t datar;
446
447 j = 0;
448 for (i = 0; i < BLF_N + 2; i++) {
449 /* Extract 4 int8 to 1 int32 from keystream */
450 temp = Blowfish_stream2word(key, keybytes, &j);
451 c->P[i] = c->P[i] ^ temp;
452 }
453
454 j = 0;
455 datal = 0x00000000;
456 datar = 0x00000000;
457 for (i = 0; i < BLF_N + 2; i += 2) {
458 Blowfish_encipher(c, &datal, &datar);
459
460 c->P[i] = datal;
461 c->P[i + 1] = datar;
462 }
463
464 for (i = 0; i < 4; i++) {
465 for (k = 0; k < 256; k += 2) {
466 Blowfish_encipher(c, &datal, &datar);
467
468 c->S[i][k] = datal;
469 c->S[i][k + 1] = datar;
470 }
471 }
472}
473
474
475#if __STDC__
476void
477Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
478 const u_int8_t *key, u_int16_t keybytes)
479#else
480void
481Blowfish_expandstate(c, data, databytes, key, keybytes)
482 blf_ctx *c;
483 const u_int8_t *data;
484 u_int16_t databytes;
485 const u_int8_t *key;
486 u_int16_t keybytes;
487#endif
488{
489 u_int16_t i;
490 u_int16_t j;
491 u_int16_t k;
492 u_int32_t temp;
493 u_int32_t datal;
494 u_int32_t datar;
495
496 j = 0;
497 for (i = 0; i < BLF_N + 2; i++) {
498 /* Extract 4 int8 to 1 int32 from keystream */
499 temp = Blowfish_stream2word(key, keybytes, &j);
500 c->P[i] = c->P[i] ^ temp;
501 }
502
503 j = 0;
504 datal = 0x00000000;
505 datar = 0x00000000;
506 for (i = 0; i < BLF_N + 2; i += 2) {
507 datal ^= Blowfish_stream2word(data, databytes, &j);
508 datar ^= Blowfish_stream2word(data, databytes, &j);
509 Blowfish_encipher(c, &datal, &datar);
510
511 c->P[i] = datal;
512 c->P[i + 1] = datar;
513 }
514
515 for (i = 0; i < 4; i++) {
516 for (k = 0; k < 256; k += 2) {
517 datal ^= Blowfish_stream2word(data, databytes, &j);
518 datar ^= Blowfish_stream2word(data, databytes, &j);
519 Blowfish_encipher(c, &datal, &datar);
520
521 c->S[i][k] = datal;
522 c->S[i][k + 1] = datar;
523 }
524 }
525
526}
527
528#if __STDC__
529void
530blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len)
531#else
532void
533blf_key(c, k, len)
534 blf_ctx *c;
535 const u_int8_t *k;
536 u_int16_t len;
537#endif
538{
539 /* Initalize S-boxes and subkeys with Pi */
540 Blowfish_initstate(c);
541
542 /* Transform S-boxes and subkeys with key */
543 Blowfish_expand0state(c, k, len);
544}
545
546#if __STDC__
547void
548blf_enc(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
549#else
550void
551blf_enc(c, data, blocks)
552 blf_ctx *c;
553 u_int32_t *data;
554 u_int16_t blocks;
555#endif
556{
557 u_int32_t *d;
558 u_int16_t i;
559
560 d = data;
561 for (i = 0; i < blocks; i++) {
562 Blowfish_encipher(c, d, d + 1);
563 d += 2;
564 }
565}
566
567#if __STDC__
568void
569blf_dec(blf_ctx *c, u_int32_t *data, u_int16_t blocks)
570#else
571void
572blf_dec(c, data, blocks)
573 blf_ctx *c;
574 u_int32_t *data;
575 u_int16_t blocks;
576#endif
577{
578 u_int32_t *d;
579 u_int16_t i;
580
581 d = data;
582 for (i = 0; i < blocks; i++) {
583 Blowfish_decipher(c, d, d + 1);
584 d += 2;
585 }
586}
587
588#if __STDC__
589void
590blf_ecb_encrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
591#else
592void
593blf_ecb_encrypt(c, data, len)
594 blf_ctx *c;
595 u_int8_t *data;
596 u_int32_t len;
597#endif
598{
599 u_int32_t l, r;
600 u_int32_t i;
601
602 for (i = 0; i < len; i += 8) {
603 l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
604 r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
605 Blowfish_encipher(c, &l, &r);
606 data[0] = l >> 24 & 0xff;
607 data[1] = l >> 16 & 0xff;
608 data[2] = l >> 8 & 0xff;
609 data[3] = l & 0xff;
610 data[4] = r >> 24 & 0xff;
611 data[5] = r >> 16 & 0xff;
612 data[6] = r >> 8 & 0xff;
613 data[7] = r & 0xff;
614 data += 8;
615 }
616}
617
618#if __STDC__
619void
620blf_ecb_decrypt(blf_ctx *c, u_int8_t *data, u_int32_t len)
621#else
622void
623blf_ecb_decrypt(c, data, len)
624 blf_ctx *c;
625 u_int8_t *data;
626 u_int32_t len;
627#endif
628{
629 u_int32_t l, r;
630 u_int32_t i;
631
632 for (i = 0; i < len; i += 8) {
633 l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
634 r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
635 Blowfish_decipher(c, &l, &r);
636 data[0] = l >> 24 & 0xff;
637 data[1] = l >> 16 & 0xff;
638 data[2] = l >> 8 & 0xff;
639 data[3] = l & 0xff;
640 data[4] = r >> 24 & 0xff;
641 data[5] = r >> 16 & 0xff;
642 data[6] = r >> 8 & 0xff;
643 data[7] = r & 0xff;
644 data += 8;
645 }
646}
647
648#if __STDC__
649void
650blf_cbc_encrypt(blf_ctx *c, u_int8_t *iv, u_int8_t *data, u_int32_t len)
651#else
652void
653blf_cbc_encrypt(c, iv, data, len)
654 blf_ctx *c;
655 u_int8_t *iv;
656 u_int8_t *data;
657 u_int32_t len;
658#endif
659{
660 u_int32_t l, r;
661 u_int32_t i, j;
662
663 for (i = 0; i < len; i += 8) {
664 for (j = 0; j < 8; j++)
665 data[j] ^= iv[j];
666 l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
667 r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
668 Blowfish_encipher(c, &l, &r);
669 data[0] = l >> 24 & 0xff;
670 data[1] = l >> 16 & 0xff;
671 data[2] = l >> 8 & 0xff;
672 data[3] = l & 0xff;
673 data[4] = r >> 24 & 0xff;
674 data[5] = r >> 16 & 0xff;
675 data[6] = r >> 8 & 0xff;
676 data[7] = r & 0xff;
677 iv = data;
678 data += 8;
679 }
680}
681
682#if __STDC__
683void
684blf_cbc_decrypt(blf_ctx *c, u_int8_t *iva, u_int8_t *data, u_int32_t len)
685#else
686void
687blf_cbc_decrypt(c, iva, data, len)
688 blf_ctx *c;
689 u_int8_t *iva;
690 u_int8_t *data;
691 u_int32_t len;
692#endif
693{
694 u_int32_t l, r;
695 u_int8_t *iv;
696 u_int32_t i, j;
697
698 iv = data + len - 16;
699 data = data + len - 8;
700 for (i = len - 8; i >= 8; i -= 8) {
701 l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
702 r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
703 Blowfish_decipher(c, &l, &r);
704 data[0] = l >> 24 & 0xff;
705 data[1] = l >> 16 & 0xff;
706 data[2] = l >> 8 & 0xff;
707 data[3] = l & 0xff;
708 data[4] = r >> 24 & 0xff;
709 data[5] = r >> 16 & 0xff;
710 data[6] = r >> 8 & 0xff;
711 data[7] = r & 0xff;
712 for (j = 0; j < 8; j++)
713 data[j] ^= iv[j];
714 iv = data;
715 data -= 8;
716 }
717 l = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
718 r = data[4] << 24 | data[5] << 16 | data[6] << 8 | data[7];
719 Blowfish_decipher(c, &l, &r);
720 data[0] = l >> 24 & 0xff;
721 data[1] = l >> 16 & 0xff;
722 data[2] = l >> 8 & 0xff;
723 data[3] = l & 0xff;
724 data[4] = r >> 24 & 0xff;
725 data[5] = r >> 16 & 0xff;
726 data[6] = r >> 8 & 0xff;
727 data[7] = r & 0xff;
728 for (j = 0; j < 8; j++)
729 data[j] ^= iva[j];
730}
731
732#if 0
733void
734report(u_int32_t data[], u_int16_t len)
735{
736 u_int16_t i;
737 for (i = 0; i < len; i += 2)
738 printf("Block %0hd: %08lx %08lx.\n",
739 i / 2, data[i], data[i + 1]);
740}
741void
742main(void)
743{
744
745 blf_ctx c;
746 char key[] = "AAAAA";
747 char key2[] = "abcdefghijklmnopqrstuvwxyz";
748
749 u_int32_t data[10];
750 u_int32_t data2[] =
751 {0x424c4f57l, 0x46495348l};
752
753 u_int16_t i;
754
755 /* First test */
756 for (i = 0; i < 10; i++)
757 data[i] = i;
758
759 blf_key(&c, (u_int8_t *) key, 5);
760 blf_enc(&c, data, 5);
761 blf_dec(&c, data, 1);
762 blf_dec(&c, data + 2, 4);
763 printf("Should read as 0 - 9.\n");
764 report(data, 10);
765
766 /* Second test */
767 blf_key(&c, (u_int8_t *) key2, strlen(key2));
768 blf_enc(&c, data2, 1);
769 printf("\nShould read as: 0x324ed0fe 0xf413a203.\n");
770 report(data2, 2);
771 blf_dec(&c, data2, 1);
772 report(data2, 2);
773}
774#endif
diff --git a/src/lib/libc/crypt/cast.c b/src/lib/libc/crypt/cast.c
new file mode 100644
index 0000000000..264138f03e
--- /dev/null
+++ b/src/lib/libc/crypt/cast.c
@@ -0,0 +1,779 @@
1/* $OpenBSD: cast.c,v 1.2 1998/07/21 22:42:03 provos Exp $ */
2/*
3 * CAST-128 in C
4 * Written by Steve Reid <sreid@sea-to-sky.net>
5 * 100% Public Domain - no warranty
6 * Released 1997.10.11
7 */
8
9#include <sys/types.h>
10
11#include <cast.h>
12
13/* CAST S-Boxes */
14
15static const u_int32_t cast_sbox1[256] = {
16 0x30FB40D4, 0x9FA0FF0B, 0x6BECCD2F, 0x3F258C7A,
17 0x1E213F2F, 0x9C004DD3, 0x6003E540, 0xCF9FC949,
18 0xBFD4AF27, 0x88BBBDB5, 0xE2034090, 0x98D09675,
19 0x6E63A0E0, 0x15C361D2, 0xC2E7661D, 0x22D4FF8E,
20 0x28683B6F, 0xC07FD059, 0xFF2379C8, 0x775F50E2,
21 0x43C340D3, 0xDF2F8656, 0x887CA41A, 0xA2D2BD2D,
22 0xA1C9E0D6, 0x346C4819, 0x61B76D87, 0x22540F2F,
23 0x2ABE32E1, 0xAA54166B, 0x22568E3A, 0xA2D341D0,
24 0x66DB40C8, 0xA784392F, 0x004DFF2F, 0x2DB9D2DE,
25 0x97943FAC, 0x4A97C1D8, 0x527644B7, 0xB5F437A7,
26 0xB82CBAEF, 0xD751D159, 0x6FF7F0ED, 0x5A097A1F,
27 0x827B68D0, 0x90ECF52E, 0x22B0C054, 0xBC8E5935,
28 0x4B6D2F7F, 0x50BB64A2, 0xD2664910, 0xBEE5812D,
29 0xB7332290, 0xE93B159F, 0xB48EE411, 0x4BFF345D,
30 0xFD45C240, 0xAD31973F, 0xC4F6D02E, 0x55FC8165,
31 0xD5B1CAAD, 0xA1AC2DAE, 0xA2D4B76D, 0xC19B0C50,
32 0x882240F2, 0x0C6E4F38, 0xA4E4BFD7, 0x4F5BA272,
33 0x564C1D2F, 0xC59C5319, 0xB949E354, 0xB04669FE,
34 0xB1B6AB8A, 0xC71358DD, 0x6385C545, 0x110F935D,
35 0x57538AD5, 0x6A390493, 0xE63D37E0, 0x2A54F6B3,
36 0x3A787D5F, 0x6276A0B5, 0x19A6FCDF, 0x7A42206A,
37 0x29F9D4D5, 0xF61B1891, 0xBB72275E, 0xAA508167,
38 0x38901091, 0xC6B505EB, 0x84C7CB8C, 0x2AD75A0F,
39 0x874A1427, 0xA2D1936B, 0x2AD286AF, 0xAA56D291,
40 0xD7894360, 0x425C750D, 0x93B39E26, 0x187184C9,
41 0x6C00B32D, 0x73E2BB14, 0xA0BEBC3C, 0x54623779,
42 0x64459EAB, 0x3F328B82, 0x7718CF82, 0x59A2CEA6,
43 0x04EE002E, 0x89FE78E6, 0x3FAB0950, 0x325FF6C2,
44 0x81383F05, 0x6963C5C8, 0x76CB5AD6, 0xD49974C9,
45 0xCA180DCF, 0x380782D5, 0xC7FA5CF6, 0x8AC31511,
46 0x35E79E13, 0x47DA91D0, 0xF40F9086, 0xA7E2419E,
47 0x31366241, 0x051EF495, 0xAA573B04, 0x4A805D8D,
48 0x548300D0, 0x00322A3C, 0xBF64CDDF, 0xBA57A68E,
49 0x75C6372B, 0x50AFD341, 0xA7C13275, 0x915A0BF5,
50 0x6B54BFAB, 0x2B0B1426, 0xAB4CC9D7, 0x449CCD82,
51 0xF7FBF265, 0xAB85C5F3, 0x1B55DB94, 0xAAD4E324,
52 0xCFA4BD3F, 0x2DEAA3E2, 0x9E204D02, 0xC8BD25AC,
53 0xEADF55B3, 0xD5BD9E98, 0xE31231B2, 0x2AD5AD6C,
54 0x954329DE, 0xADBE4528, 0xD8710F69, 0xAA51C90F,
55 0xAA786BF6, 0x22513F1E, 0xAA51A79B, 0x2AD344CC,
56 0x7B5A41F0, 0xD37CFBAD, 0x1B069505, 0x41ECE491,
57 0xB4C332E6, 0x032268D4, 0xC9600ACC, 0xCE387E6D,
58 0xBF6BB16C, 0x6A70FB78, 0x0D03D9C9, 0xD4DF39DE,
59 0xE01063DA, 0x4736F464, 0x5AD328D8, 0xB347CC96,
60 0x75BB0FC3, 0x98511BFB, 0x4FFBCC35, 0xB58BCF6A,
61 0xE11F0ABC, 0xBFC5FE4A, 0xA70AEC10, 0xAC39570A,
62 0x3F04442F, 0x6188B153, 0xE0397A2E, 0x5727CB79,
63 0x9CEB418F, 0x1CACD68D, 0x2AD37C96, 0x0175CB9D,
64 0xC69DFF09, 0xC75B65F0, 0xD9DB40D8, 0xEC0E7779,
65 0x4744EAD4, 0xB11C3274, 0xDD24CB9E, 0x7E1C54BD,
66 0xF01144F9, 0xD2240EB1, 0x9675B3FD, 0xA3AC3755,
67 0xD47C27AF, 0x51C85F4D, 0x56907596, 0xA5BB15E6,
68 0x580304F0, 0xCA042CF1, 0x011A37EA, 0x8DBFAADB,
69 0x35BA3E4A, 0x3526FFA0, 0xC37B4D09, 0xBC306ED9,
70 0x98A52666, 0x5648F725, 0xFF5E569D, 0x0CED63D0,
71 0x7C63B2CF, 0x700B45E1, 0xD5EA50F1, 0x85A92872,
72 0xAF1FBDA7, 0xD4234870, 0xA7870BF3, 0x2D3B4D79,
73 0x42E04198, 0x0CD0EDE7, 0x26470DB8, 0xF881814C,
74 0x474D6AD7, 0x7C0C5E5C, 0xD1231959, 0x381B7298,
75 0xF5D2F4DB, 0xAB838653, 0x6E2F1E23, 0x83719C9E,
76 0xBD91E046, 0x9A56456E, 0xDC39200C, 0x20C8C571,
77 0x962BDA1C, 0xE1E696FF, 0xB141AB08, 0x7CCA89B9,
78 0x1A69E783, 0x02CC4843, 0xA2F7C579, 0x429EF47D,
79 0x427B169C, 0x5AC9F049, 0xDD8F0F00, 0x5C8165BF
80};
81
82static const u_int32_t cast_sbox2[256] = {
83 0x1F201094, 0xEF0BA75B, 0x69E3CF7E, 0x393F4380,
84 0xFE61CF7A, 0xEEC5207A, 0x55889C94, 0x72FC0651,
85 0xADA7EF79, 0x4E1D7235, 0xD55A63CE, 0xDE0436BA,
86 0x99C430EF, 0x5F0C0794, 0x18DCDB7D, 0xA1D6EFF3,
87 0xA0B52F7B, 0x59E83605, 0xEE15B094, 0xE9FFD909,
88 0xDC440086, 0xEF944459, 0xBA83CCB3, 0xE0C3CDFB,
89 0xD1DA4181, 0x3B092AB1, 0xF997F1C1, 0xA5E6CF7B,
90 0x01420DDB, 0xE4E7EF5B, 0x25A1FF41, 0xE180F806,
91 0x1FC41080, 0x179BEE7A, 0xD37AC6A9, 0xFE5830A4,
92 0x98DE8B7F, 0x77E83F4E, 0x79929269, 0x24FA9F7B,
93 0xE113C85B, 0xACC40083, 0xD7503525, 0xF7EA615F,
94 0x62143154, 0x0D554B63, 0x5D681121, 0xC866C359,
95 0x3D63CF73, 0xCEE234C0, 0xD4D87E87, 0x5C672B21,
96 0x071F6181, 0x39F7627F, 0x361E3084, 0xE4EB573B,
97 0x602F64A4, 0xD63ACD9C, 0x1BBC4635, 0x9E81032D,
98 0x2701F50C, 0x99847AB4, 0xA0E3DF79, 0xBA6CF38C,
99 0x10843094, 0x2537A95E, 0xF46F6FFE, 0xA1FF3B1F,
100 0x208CFB6A, 0x8F458C74, 0xD9E0A227, 0x4EC73A34,
101 0xFC884F69, 0x3E4DE8DF, 0xEF0E0088, 0x3559648D,
102 0x8A45388C, 0x1D804366, 0x721D9BFD, 0xA58684BB,
103 0xE8256333, 0x844E8212, 0x128D8098, 0xFED33FB4,
104 0xCE280AE1, 0x27E19BA5, 0xD5A6C252, 0xE49754BD,
105 0xC5D655DD, 0xEB667064, 0x77840B4D, 0xA1B6A801,
106 0x84DB26A9, 0xE0B56714, 0x21F043B7, 0xE5D05860,
107 0x54F03084, 0x066FF472, 0xA31AA153, 0xDADC4755,
108 0xB5625DBF, 0x68561BE6, 0x83CA6B94, 0x2D6ED23B,
109 0xECCF01DB, 0xA6D3D0BA, 0xB6803D5C, 0xAF77A709,
110 0x33B4A34C, 0x397BC8D6, 0x5EE22B95, 0x5F0E5304,
111 0x81ED6F61, 0x20E74364, 0xB45E1378, 0xDE18639B,
112 0x881CA122, 0xB96726D1, 0x8049A7E8, 0x22B7DA7B,
113 0x5E552D25, 0x5272D237, 0x79D2951C, 0xC60D894C,
114 0x488CB402, 0x1BA4FE5B, 0xA4B09F6B, 0x1CA815CF,
115 0xA20C3005, 0x8871DF63, 0xB9DE2FCB, 0x0CC6C9E9,
116 0x0BEEFF53, 0xE3214517, 0xB4542835, 0x9F63293C,
117 0xEE41E729, 0x6E1D2D7C, 0x50045286, 0x1E6685F3,
118 0xF33401C6, 0x30A22C95, 0x31A70850, 0x60930F13,
119 0x73F98417, 0xA1269859, 0xEC645C44, 0x52C877A9,
120 0xCDFF33A6, 0xA02B1741, 0x7CBAD9A2, 0x2180036F,
121 0x50D99C08, 0xCB3F4861, 0xC26BD765, 0x64A3F6AB,
122 0x80342676, 0x25A75E7B, 0xE4E6D1FC, 0x20C710E6,
123 0xCDF0B680, 0x17844D3B, 0x31EEF84D, 0x7E0824E4,
124 0x2CCB49EB, 0x846A3BAE, 0x8FF77888, 0xEE5D60F6,
125 0x7AF75673, 0x2FDD5CDB, 0xA11631C1, 0x30F66F43,
126 0xB3FAEC54, 0x157FD7FA, 0xEF8579CC, 0xD152DE58,
127 0xDB2FFD5E, 0x8F32CE19, 0x306AF97A, 0x02F03EF8,
128 0x99319AD5, 0xC242FA0F, 0xA7E3EBB0, 0xC68E4906,
129 0xB8DA230C, 0x80823028, 0xDCDEF3C8, 0xD35FB171,
130 0x088A1BC8, 0xBEC0C560, 0x61A3C9E8, 0xBCA8F54D,
131 0xC72FEFFA, 0x22822E99, 0x82C570B4, 0xD8D94E89,
132 0x8B1C34BC, 0x301E16E6, 0x273BE979, 0xB0FFEAA6,
133 0x61D9B8C6, 0x00B24869, 0xB7FFCE3F, 0x08DC283B,
134 0x43DAF65A, 0xF7E19798, 0x7619B72F, 0x8F1C9BA4,
135 0xDC8637A0, 0x16A7D3B1, 0x9FC393B7, 0xA7136EEB,
136 0xC6BCC63E, 0x1A513742, 0xEF6828BC, 0x520365D6,
137 0x2D6A77AB, 0x3527ED4B, 0x821FD216, 0x095C6E2E,
138 0xDB92F2FB, 0x5EEA29CB, 0x145892F5, 0x91584F7F,
139 0x5483697B, 0x2667A8CC, 0x85196048, 0x8C4BACEA,
140 0x833860D4, 0x0D23E0F9, 0x6C387E8A, 0x0AE6D249,
141 0xB284600C, 0xD835731D, 0xDCB1C647, 0xAC4C56EA,
142 0x3EBD81B3, 0x230EABB0, 0x6438BC87, 0xF0B5B1FA,
143 0x8F5EA2B3, 0xFC184642, 0x0A036B7A, 0x4FB089BD,
144 0x649DA589, 0xA345415E, 0x5C038323, 0x3E5D3BB9,
145 0x43D79572, 0x7E6DD07C, 0x06DFDF1E, 0x6C6CC4EF,
146 0x7160A539, 0x73BFBE70, 0x83877605, 0x4523ECF1
147};
148
149static const u_int32_t cast_sbox3[256] = {
150 0x8DEFC240, 0x25FA5D9F, 0xEB903DBF, 0xE810C907,
151 0x47607FFF, 0x369FE44B, 0x8C1FC644, 0xAECECA90,
152 0xBEB1F9BF, 0xEEFBCAEA, 0xE8CF1950, 0x51DF07AE,
153 0x920E8806, 0xF0AD0548, 0xE13C8D83, 0x927010D5,
154 0x11107D9F, 0x07647DB9, 0xB2E3E4D4, 0x3D4F285E,
155 0xB9AFA820, 0xFADE82E0, 0xA067268B, 0x8272792E,
156 0x553FB2C0, 0x489AE22B, 0xD4EF9794, 0x125E3FBC,
157 0x21FFFCEE, 0x825B1BFD, 0x9255C5ED, 0x1257A240,
158 0x4E1A8302, 0xBAE07FFF, 0x528246E7, 0x8E57140E,
159 0x3373F7BF, 0x8C9F8188, 0xA6FC4EE8, 0xC982B5A5,
160 0xA8C01DB7, 0x579FC264, 0x67094F31, 0xF2BD3F5F,
161 0x40FFF7C1, 0x1FB78DFC, 0x8E6BD2C1, 0x437BE59B,
162 0x99B03DBF, 0xB5DBC64B, 0x638DC0E6, 0x55819D99,
163 0xA197C81C, 0x4A012D6E, 0xC5884A28, 0xCCC36F71,
164 0xB843C213, 0x6C0743F1, 0x8309893C, 0x0FEDDD5F,
165 0x2F7FE850, 0xD7C07F7E, 0x02507FBF, 0x5AFB9A04,
166 0xA747D2D0, 0x1651192E, 0xAF70BF3E, 0x58C31380,
167 0x5F98302E, 0x727CC3C4, 0x0A0FB402, 0x0F7FEF82,
168 0x8C96FDAD, 0x5D2C2AAE, 0x8EE99A49, 0x50DA88B8,
169 0x8427F4A0, 0x1EAC5790, 0x796FB449, 0x8252DC15,
170 0xEFBD7D9B, 0xA672597D, 0xADA840D8, 0x45F54504,
171 0xFA5D7403, 0xE83EC305, 0x4F91751A, 0x925669C2,
172 0x23EFE941, 0xA903F12E, 0x60270DF2, 0x0276E4B6,
173 0x94FD6574, 0x927985B2, 0x8276DBCB, 0x02778176,
174 0xF8AF918D, 0x4E48F79E, 0x8F616DDF, 0xE29D840E,
175 0x842F7D83, 0x340CE5C8, 0x96BBB682, 0x93B4B148,
176 0xEF303CAB, 0x984FAF28, 0x779FAF9B, 0x92DC560D,
177 0x224D1E20, 0x8437AA88, 0x7D29DC96, 0x2756D3DC,
178 0x8B907CEE, 0xB51FD240, 0xE7C07CE3, 0xE566B4A1,
179 0xC3E9615E, 0x3CF8209D, 0x6094D1E3, 0xCD9CA341,
180 0x5C76460E, 0x00EA983B, 0xD4D67881, 0xFD47572C,
181 0xF76CEDD9, 0xBDA8229C, 0x127DADAA, 0x438A074E,
182 0x1F97C090, 0x081BDB8A, 0x93A07EBE, 0xB938CA15,
183 0x97B03CFF, 0x3DC2C0F8, 0x8D1AB2EC, 0x64380E51,
184 0x68CC7BFB, 0xD90F2788, 0x12490181, 0x5DE5FFD4,
185 0xDD7EF86A, 0x76A2E214, 0xB9A40368, 0x925D958F,
186 0x4B39FFFA, 0xBA39AEE9, 0xA4FFD30B, 0xFAF7933B,
187 0x6D498623, 0x193CBCFA, 0x27627545, 0x825CF47A,
188 0x61BD8BA0, 0xD11E42D1, 0xCEAD04F4, 0x127EA392,
189 0x10428DB7, 0x8272A972, 0x9270C4A8, 0x127DE50B,
190 0x285BA1C8, 0x3C62F44F, 0x35C0EAA5, 0xE805D231,
191 0x428929FB, 0xB4FCDF82, 0x4FB66A53, 0x0E7DC15B,
192 0x1F081FAB, 0x108618AE, 0xFCFD086D, 0xF9FF2889,
193 0x694BCC11, 0x236A5CAE, 0x12DECA4D, 0x2C3F8CC5,
194 0xD2D02DFE, 0xF8EF5896, 0xE4CF52DA, 0x95155B67,
195 0x494A488C, 0xB9B6A80C, 0x5C8F82BC, 0x89D36B45,
196 0x3A609437, 0xEC00C9A9, 0x44715253, 0x0A874B49,
197 0xD773BC40, 0x7C34671C, 0x02717EF6, 0x4FEB5536,
198 0xA2D02FFF, 0xD2BF60C4, 0xD43F03C0, 0x50B4EF6D,
199 0x07478CD1, 0x006E1888, 0xA2E53F55, 0xB9E6D4BC,
200 0xA2048016, 0x97573833, 0xD7207D67, 0xDE0F8F3D,
201 0x72F87B33, 0xABCC4F33, 0x7688C55D, 0x7B00A6B0,
202 0x947B0001, 0x570075D2, 0xF9BB88F8, 0x8942019E,
203 0x4264A5FF, 0x856302E0, 0x72DBD92B, 0xEE971B69,
204 0x6EA22FDE, 0x5F08AE2B, 0xAF7A616D, 0xE5C98767,
205 0xCF1FEBD2, 0x61EFC8C2, 0xF1AC2571, 0xCC8239C2,
206 0x67214CB8, 0xB1E583D1, 0xB7DC3E62, 0x7F10BDCE,
207 0xF90A5C38, 0x0FF0443D, 0x606E6DC6, 0x60543A49,
208 0x5727C148, 0x2BE98A1D, 0x8AB41738, 0x20E1BE24,
209 0xAF96DA0F, 0x68458425, 0x99833BE5, 0x600D457D,
210 0x282F9350, 0x8334B362, 0xD91D1120, 0x2B6D8DA0,
211 0x642B1E31, 0x9C305A00, 0x52BCE688, 0x1B03588A,
212 0xF7BAEFD5, 0x4142ED9C, 0xA4315C11, 0x83323EC5,
213 0xDFEF4636, 0xA133C501, 0xE9D3531C, 0xEE353783
214};
215
216static const u_int32_t cast_sbox4[256] = {
217 0x9DB30420, 0x1FB6E9DE, 0xA7BE7BEF, 0xD273A298,
218 0x4A4F7BDB, 0x64AD8C57, 0x85510443, 0xFA020ED1,
219 0x7E287AFF, 0xE60FB663, 0x095F35A1, 0x79EBF120,
220 0xFD059D43, 0x6497B7B1, 0xF3641F63, 0x241E4ADF,
221 0x28147F5F, 0x4FA2B8CD, 0xC9430040, 0x0CC32220,
222 0xFDD30B30, 0xC0A5374F, 0x1D2D00D9, 0x24147B15,
223 0xEE4D111A, 0x0FCA5167, 0x71FF904C, 0x2D195FFE,
224 0x1A05645F, 0x0C13FEFE, 0x081B08CA, 0x05170121,
225 0x80530100, 0xE83E5EFE, 0xAC9AF4F8, 0x7FE72701,
226 0xD2B8EE5F, 0x06DF4261, 0xBB9E9B8A, 0x7293EA25,
227 0xCE84FFDF, 0xF5718801, 0x3DD64B04, 0xA26F263B,
228 0x7ED48400, 0x547EEBE6, 0x446D4CA0, 0x6CF3D6F5,
229 0x2649ABDF, 0xAEA0C7F5, 0x36338CC1, 0x503F7E93,
230 0xD3772061, 0x11B638E1, 0x72500E03, 0xF80EB2BB,
231 0xABE0502E, 0xEC8D77DE, 0x57971E81, 0xE14F6746,
232 0xC9335400, 0x6920318F, 0x081DBB99, 0xFFC304A5,
233 0x4D351805, 0x7F3D5CE3, 0xA6C866C6, 0x5D5BCCA9,
234 0xDAEC6FEA, 0x9F926F91, 0x9F46222F, 0x3991467D,
235 0xA5BF6D8E, 0x1143C44F, 0x43958302, 0xD0214EEB,
236 0x022083B8, 0x3FB6180C, 0x18F8931E, 0x281658E6,
237 0x26486E3E, 0x8BD78A70, 0x7477E4C1, 0xB506E07C,
238 0xF32D0A25, 0x79098B02, 0xE4EABB81, 0x28123B23,
239 0x69DEAD38, 0x1574CA16, 0xDF871B62, 0x211C40B7,
240 0xA51A9EF9, 0x0014377B, 0x041E8AC8, 0x09114003,
241 0xBD59E4D2, 0xE3D156D5, 0x4FE876D5, 0x2F91A340,
242 0x557BE8DE, 0x00EAE4A7, 0x0CE5C2EC, 0x4DB4BBA6,
243 0xE756BDFF, 0xDD3369AC, 0xEC17B035, 0x06572327,
244 0x99AFC8B0, 0x56C8C391, 0x6B65811C, 0x5E146119,
245 0x6E85CB75, 0xBE07C002, 0xC2325577, 0x893FF4EC,
246 0x5BBFC92D, 0xD0EC3B25, 0xB7801AB7, 0x8D6D3B24,
247 0x20C763EF, 0xC366A5FC, 0x9C382880, 0x0ACE3205,
248 0xAAC9548A, 0xECA1D7C7, 0x041AFA32, 0x1D16625A,
249 0x6701902C, 0x9B757A54, 0x31D477F7, 0x9126B031,
250 0x36CC6FDB, 0xC70B8B46, 0xD9E66A48, 0x56E55A79,
251 0x026A4CEB, 0x52437EFF, 0x2F8F76B4, 0x0DF980A5,
252 0x8674CDE3, 0xEDDA04EB, 0x17A9BE04, 0x2C18F4DF,
253 0xB7747F9D, 0xAB2AF7B4, 0xEFC34D20, 0x2E096B7C,
254 0x1741A254, 0xE5B6A035, 0x213D42F6, 0x2C1C7C26,
255 0x61C2F50F, 0x6552DAF9, 0xD2C231F8, 0x25130F69,
256 0xD8167FA2, 0x0418F2C8, 0x001A96A6, 0x0D1526AB,
257 0x63315C21, 0x5E0A72EC, 0x49BAFEFD, 0x187908D9,
258 0x8D0DBD86, 0x311170A7, 0x3E9B640C, 0xCC3E10D7,
259 0xD5CAD3B6, 0x0CAEC388, 0xF73001E1, 0x6C728AFF,
260 0x71EAE2A1, 0x1F9AF36E, 0xCFCBD12F, 0xC1DE8417,
261 0xAC07BE6B, 0xCB44A1D8, 0x8B9B0F56, 0x013988C3,
262 0xB1C52FCA, 0xB4BE31CD, 0xD8782806, 0x12A3A4E2,
263 0x6F7DE532, 0x58FD7EB6, 0xD01EE900, 0x24ADFFC2,
264 0xF4990FC5, 0x9711AAC5, 0x001D7B95, 0x82E5E7D2,
265 0x109873F6, 0x00613096, 0xC32D9521, 0xADA121FF,
266 0x29908415, 0x7FBB977F, 0xAF9EB3DB, 0x29C9ED2A,
267 0x5CE2A465, 0xA730F32C, 0xD0AA3FE8, 0x8A5CC091,
268 0xD49E2CE7, 0x0CE454A9, 0xD60ACD86, 0x015F1919,
269 0x77079103, 0xDEA03AF6, 0x78A8565E, 0xDEE356DF,
270 0x21F05CBE, 0x8B75E387, 0xB3C50651, 0xB8A5C3EF,
271 0xD8EEB6D2, 0xE523BE77, 0xC2154529, 0x2F69EFDF,
272 0xAFE67AFB, 0xF470C4B2, 0xF3E0EB5B, 0xD6CC9876,
273 0x39E4460C, 0x1FDA8538, 0x1987832F, 0xCA007367,
274 0xA99144F8, 0x296B299E, 0x492FC295, 0x9266BEAB,
275 0xB5676E69, 0x9BD3DDDA, 0xDF7E052F, 0xDB25701C,
276 0x1B5E51EE, 0xF65324E6, 0x6AFCE36C, 0x0316CC04,
277 0x8644213E, 0xB7DC59D0, 0x7965291F, 0xCCD6FD43,
278 0x41823979, 0x932BCDF6, 0xB657C34D, 0x4EDFD282,
279 0x7AE5290C, 0x3CB9536B, 0x851E20FE, 0x9833557E,
280 0x13ECF0B0, 0xD3FFB372, 0x3F85C5C1, 0x0AEF7ED2
281};
282
283static const u_int32_t cast_sbox5[256] = {
284 0x7EC90C04, 0x2C6E74B9, 0x9B0E66DF, 0xA6337911,
285 0xB86A7FFF, 0x1DD358F5, 0x44DD9D44, 0x1731167F,
286 0x08FBF1FA, 0xE7F511CC, 0xD2051B00, 0x735ABA00,
287 0x2AB722D8, 0x386381CB, 0xACF6243A, 0x69BEFD7A,
288 0xE6A2E77F, 0xF0C720CD, 0xC4494816, 0xCCF5C180,
289 0x38851640, 0x15B0A848, 0xE68B18CB, 0x4CAADEFF,
290 0x5F480A01, 0x0412B2AA, 0x259814FC, 0x41D0EFE2,
291 0x4E40B48D, 0x248EB6FB, 0x8DBA1CFE, 0x41A99B02,
292 0x1A550A04, 0xBA8F65CB, 0x7251F4E7, 0x95A51725,
293 0xC106ECD7, 0x97A5980A, 0xC539B9AA, 0x4D79FE6A,
294 0xF2F3F763, 0x68AF8040, 0xED0C9E56, 0x11B4958B,
295 0xE1EB5A88, 0x8709E6B0, 0xD7E07156, 0x4E29FEA7,
296 0x6366E52D, 0x02D1C000, 0xC4AC8E05, 0x9377F571,
297 0x0C05372A, 0x578535F2, 0x2261BE02, 0xD642A0C9,
298 0xDF13A280, 0x74B55BD2, 0x682199C0, 0xD421E5EC,
299 0x53FB3CE8, 0xC8ADEDB3, 0x28A87FC9, 0x3D959981,
300 0x5C1FF900, 0xFE38D399, 0x0C4EFF0B, 0x062407EA,
301 0xAA2F4FB1, 0x4FB96976, 0x90C79505, 0xB0A8A774,
302 0xEF55A1FF, 0xE59CA2C2, 0xA6B62D27, 0xE66A4263,
303 0xDF65001F, 0x0EC50966, 0xDFDD55BC, 0x29DE0655,
304 0x911E739A, 0x17AF8975, 0x32C7911C, 0x89F89468,
305 0x0D01E980, 0x524755F4, 0x03B63CC9, 0x0CC844B2,
306 0xBCF3F0AA, 0x87AC36E9, 0xE53A7426, 0x01B3D82B,
307 0x1A9E7449, 0x64EE2D7E, 0xCDDBB1DA, 0x01C94910,
308 0xB868BF80, 0x0D26F3FD, 0x9342EDE7, 0x04A5C284,
309 0x636737B6, 0x50F5B616, 0xF24766E3, 0x8ECA36C1,
310 0x136E05DB, 0xFEF18391, 0xFB887A37, 0xD6E7F7D4,
311 0xC7FB7DC9, 0x3063FCDF, 0xB6F589DE, 0xEC2941DA,
312 0x26E46695, 0xB7566419, 0xF654EFC5, 0xD08D58B7,
313 0x48925401, 0xC1BACB7F, 0xE5FF550F, 0xB6083049,
314 0x5BB5D0E8, 0x87D72E5A, 0xAB6A6EE1, 0x223A66CE,
315 0xC62BF3CD, 0x9E0885F9, 0x68CB3E47, 0x086C010F,
316 0xA21DE820, 0xD18B69DE, 0xF3F65777, 0xFA02C3F6,
317 0x407EDAC3, 0xCBB3D550, 0x1793084D, 0xB0D70EBA,
318 0x0AB378D5, 0xD951FB0C, 0xDED7DA56, 0x4124BBE4,
319 0x94CA0B56, 0x0F5755D1, 0xE0E1E56E, 0x6184B5BE,
320 0x580A249F, 0x94F74BC0, 0xE327888E, 0x9F7B5561,
321 0xC3DC0280, 0x05687715, 0x646C6BD7, 0x44904DB3,
322 0x66B4F0A3, 0xC0F1648A, 0x697ED5AF, 0x49E92FF6,
323 0x309E374F, 0x2CB6356A, 0x85808573, 0x4991F840,
324 0x76F0AE02, 0x083BE84D, 0x28421C9A, 0x44489406,
325 0x736E4CB8, 0xC1092910, 0x8BC95FC6, 0x7D869CF4,
326 0x134F616F, 0x2E77118D, 0xB31B2BE1, 0xAA90B472,
327 0x3CA5D717, 0x7D161BBA, 0x9CAD9010, 0xAF462BA2,
328 0x9FE459D2, 0x45D34559, 0xD9F2DA13, 0xDBC65487,
329 0xF3E4F94E, 0x176D486F, 0x097C13EA, 0x631DA5C7,
330 0x445F7382, 0x175683F4, 0xCDC66A97, 0x70BE0288,
331 0xB3CDCF72, 0x6E5DD2F3, 0x20936079, 0x459B80A5,
332 0xBE60E2DB, 0xA9C23101, 0xEBA5315C, 0x224E42F2,
333 0x1C5C1572, 0xF6721B2C, 0x1AD2FFF3, 0x8C25404E,
334 0x324ED72F, 0x4067B7FD, 0x0523138E, 0x5CA3BC78,
335 0xDC0FD66E, 0x75922283, 0x784D6B17, 0x58EBB16E,
336 0x44094F85, 0x3F481D87, 0xFCFEAE7B, 0x77B5FF76,
337 0x8C2302BF, 0xAAF47556, 0x5F46B02A, 0x2B092801,
338 0x3D38F5F7, 0x0CA81F36, 0x52AF4A8A, 0x66D5E7C0,
339 0xDF3B0874, 0x95055110, 0x1B5AD7A8, 0xF61ED5AD,
340 0x6CF6E479, 0x20758184, 0xD0CEFA65, 0x88F7BE58,
341 0x4A046826, 0x0FF6F8F3, 0xA09C7F70, 0x5346ABA0,
342 0x5CE96C28, 0xE176EDA3, 0x6BAC307F, 0x376829D2,
343 0x85360FA9, 0x17E3FE2A, 0x24B79767, 0xF5A96B20,
344 0xD6CD2595, 0x68FF1EBF, 0x7555442C, 0xF19F06BE,
345 0xF9E0659A, 0xEEB9491D, 0x34010718, 0xBB30CAB8,
346 0xE822FE15, 0x88570983, 0x750E6249, 0xDA627E55,
347 0x5E76FFA8, 0xB1534546, 0x6D47DE08, 0xEFE9E7D4
348};
349
350static const u_int32_t cast_sbox6[256] = {
351 0xF6FA8F9D, 0x2CAC6CE1, 0x4CA34867, 0xE2337F7C,
352 0x95DB08E7, 0x016843B4, 0xECED5CBC, 0x325553AC,
353 0xBF9F0960, 0xDFA1E2ED, 0x83F0579D, 0x63ED86B9,
354 0x1AB6A6B8, 0xDE5EBE39, 0xF38FF732, 0x8989B138,
355 0x33F14961, 0xC01937BD, 0xF506C6DA, 0xE4625E7E,
356 0xA308EA99, 0x4E23E33C, 0x79CBD7CC, 0x48A14367,
357 0xA3149619, 0xFEC94BD5, 0xA114174A, 0xEAA01866,
358 0xA084DB2D, 0x09A8486F, 0xA888614A, 0x2900AF98,
359 0x01665991, 0xE1992863, 0xC8F30C60, 0x2E78EF3C,
360 0xD0D51932, 0xCF0FEC14, 0xF7CA07D2, 0xD0A82072,
361 0xFD41197E, 0x9305A6B0, 0xE86BE3DA, 0x74BED3CD,
362 0x372DA53C, 0x4C7F4448, 0xDAB5D440, 0x6DBA0EC3,
363 0x083919A7, 0x9FBAEED9, 0x49DBCFB0, 0x4E670C53,
364 0x5C3D9C01, 0x64BDB941, 0x2C0E636A, 0xBA7DD9CD,
365 0xEA6F7388, 0xE70BC762, 0x35F29ADB, 0x5C4CDD8D,
366 0xF0D48D8C, 0xB88153E2, 0x08A19866, 0x1AE2EAC8,
367 0x284CAF89, 0xAA928223, 0x9334BE53, 0x3B3A21BF,
368 0x16434BE3, 0x9AEA3906, 0xEFE8C36E, 0xF890CDD9,
369 0x80226DAE, 0xC340A4A3, 0xDF7E9C09, 0xA694A807,
370 0x5B7C5ECC, 0x221DB3A6, 0x9A69A02F, 0x68818A54,
371 0xCEB2296F, 0x53C0843A, 0xFE893655, 0x25BFE68A,
372 0xB4628ABC, 0xCF222EBF, 0x25AC6F48, 0xA9A99387,
373 0x53BDDB65, 0xE76FFBE7, 0xE967FD78, 0x0BA93563,
374 0x8E342BC1, 0xE8A11BE9, 0x4980740D, 0xC8087DFC,
375 0x8DE4BF99, 0xA11101A0, 0x7FD37975, 0xDA5A26C0,
376 0xE81F994F, 0x9528CD89, 0xFD339FED, 0xB87834BF,
377 0x5F04456D, 0x22258698, 0xC9C4C83B, 0x2DC156BE,
378 0x4F628DAA, 0x57F55EC5, 0xE2220ABE, 0xD2916EBF,
379 0x4EC75B95, 0x24F2C3C0, 0x42D15D99, 0xCD0D7FA0,
380 0x7B6E27FF, 0xA8DC8AF0, 0x7345C106, 0xF41E232F,
381 0x35162386, 0xE6EA8926, 0x3333B094, 0x157EC6F2,
382 0x372B74AF, 0x692573E4, 0xE9A9D848, 0xF3160289,
383 0x3A62EF1D, 0xA787E238, 0xF3A5F676, 0x74364853,
384 0x20951063, 0x4576698D, 0xB6FAD407, 0x592AF950,
385 0x36F73523, 0x4CFB6E87, 0x7DA4CEC0, 0x6C152DAA,
386 0xCB0396A8, 0xC50DFE5D, 0xFCD707AB, 0x0921C42F,
387 0x89DFF0BB, 0x5FE2BE78, 0x448F4F33, 0x754613C9,
388 0x2B05D08D, 0x48B9D585, 0xDC049441, 0xC8098F9B,
389 0x7DEDE786, 0xC39A3373, 0x42410005, 0x6A091751,
390 0x0EF3C8A6, 0x890072D6, 0x28207682, 0xA9A9F7BE,
391 0xBF32679D, 0xD45B5B75, 0xB353FD00, 0xCBB0E358,
392 0x830F220A, 0x1F8FB214, 0xD372CF08, 0xCC3C4A13,
393 0x8CF63166, 0x061C87BE, 0x88C98F88, 0x6062E397,
394 0x47CF8E7A, 0xB6C85283, 0x3CC2ACFB, 0x3FC06976,
395 0x4E8F0252, 0x64D8314D, 0xDA3870E3, 0x1E665459,
396 0xC10908F0, 0x513021A5, 0x6C5B68B7, 0x822F8AA0,
397 0x3007CD3E, 0x74719EEF, 0xDC872681, 0x073340D4,
398 0x7E432FD9, 0x0C5EC241, 0x8809286C, 0xF592D891,
399 0x08A930F6, 0x957EF305, 0xB7FBFFBD, 0xC266E96F,
400 0x6FE4AC98, 0xB173ECC0, 0xBC60B42A, 0x953498DA,
401 0xFBA1AE12, 0x2D4BD736, 0x0F25FAAB, 0xA4F3FCEB,
402 0xE2969123, 0x257F0C3D, 0x9348AF49, 0x361400BC,
403 0xE8816F4A, 0x3814F200, 0xA3F94043, 0x9C7A54C2,
404 0xBC704F57, 0xDA41E7F9, 0xC25AD33A, 0x54F4A084,
405 0xB17F5505, 0x59357CBE, 0xEDBD15C8, 0x7F97C5AB,
406 0xBA5AC7B5, 0xB6F6DEAF, 0x3A479C3A, 0x5302DA25,
407 0x653D7E6A, 0x54268D49, 0x51A477EA, 0x5017D55B,
408 0xD7D25D88, 0x44136C76, 0x0404A8C8, 0xB8E5A121,
409 0xB81A928A, 0x60ED5869, 0x97C55B96, 0xEAEC991B,
410 0x29935913, 0x01FDB7F1, 0x088E8DFA, 0x9AB6F6F5,
411 0x3B4CBF9F, 0x4A5DE3AB, 0xE6051D35, 0xA0E1D855,
412 0xD36B4CF1, 0xF544EDEB, 0xB0E93524, 0xBEBB8FBD,
413 0xA2D762CF, 0x49C92F54, 0x38B5F331, 0x7128A454,
414 0x48392905, 0xA65B1DB8, 0x851C97BD, 0xD675CF2F
415};
416
417static const u_int32_t cast_sbox7[256] = {
418 0x85E04019, 0x332BF567, 0x662DBFFF, 0xCFC65693,
419 0x2A8D7F6F, 0xAB9BC912, 0xDE6008A1, 0x2028DA1F,
420 0x0227BCE7, 0x4D642916, 0x18FAC300, 0x50F18B82,
421 0x2CB2CB11, 0xB232E75C, 0x4B3695F2, 0xB28707DE,
422 0xA05FBCF6, 0xCD4181E9, 0xE150210C, 0xE24EF1BD,
423 0xB168C381, 0xFDE4E789, 0x5C79B0D8, 0x1E8BFD43,
424 0x4D495001, 0x38BE4341, 0x913CEE1D, 0x92A79C3F,
425 0x089766BE, 0xBAEEADF4, 0x1286BECF, 0xB6EACB19,
426 0x2660C200, 0x7565BDE4, 0x64241F7A, 0x8248DCA9,
427 0xC3B3AD66, 0x28136086, 0x0BD8DFA8, 0x356D1CF2,
428 0x107789BE, 0xB3B2E9CE, 0x0502AA8F, 0x0BC0351E,
429 0x166BF52A, 0xEB12FF82, 0xE3486911, 0xD34D7516,
430 0x4E7B3AFF, 0x5F43671B, 0x9CF6E037, 0x4981AC83,
431 0x334266CE, 0x8C9341B7, 0xD0D854C0, 0xCB3A6C88,
432 0x47BC2829, 0x4725BA37, 0xA66AD22B, 0x7AD61F1E,
433 0x0C5CBAFA, 0x4437F107, 0xB6E79962, 0x42D2D816,
434 0x0A961288, 0xE1A5C06E, 0x13749E67, 0x72FC081A,
435 0xB1D139F7, 0xF9583745, 0xCF19DF58, 0xBEC3F756,
436 0xC06EBA30, 0x07211B24, 0x45C28829, 0xC95E317F,
437 0xBC8EC511, 0x38BC46E9, 0xC6E6FA14, 0xBAE8584A,
438 0xAD4EBC46, 0x468F508B, 0x7829435F, 0xF124183B,
439 0x821DBA9F, 0xAFF60FF4, 0xEA2C4E6D, 0x16E39264,
440 0x92544A8B, 0x009B4FC3, 0xABA68CED, 0x9AC96F78,
441 0x06A5B79A, 0xB2856E6E, 0x1AEC3CA9, 0xBE838688,
442 0x0E0804E9, 0x55F1BE56, 0xE7E5363B, 0xB3A1F25D,
443 0xF7DEBB85, 0x61FE033C, 0x16746233, 0x3C034C28,
444 0xDA6D0C74, 0x79AAC56C, 0x3CE4E1AD, 0x51F0C802,
445 0x98F8F35A, 0x1626A49F, 0xEED82B29, 0x1D382FE3,
446 0x0C4FB99A, 0xBB325778, 0x3EC6D97B, 0x6E77A6A9,
447 0xCB658B5C, 0xD45230C7, 0x2BD1408B, 0x60C03EB7,
448 0xB9068D78, 0xA33754F4, 0xF430C87D, 0xC8A71302,
449 0xB96D8C32, 0xEBD4E7BE, 0xBE8B9D2D, 0x7979FB06,
450 0xE7225308, 0x8B75CF77, 0x11EF8DA4, 0xE083C858,
451 0x8D6B786F, 0x5A6317A6, 0xFA5CF7A0, 0x5DDA0033,
452 0xF28EBFB0, 0xF5B9C310, 0xA0EAC280, 0x08B9767A,
453 0xA3D9D2B0, 0x79D34217, 0x021A718D, 0x9AC6336A,
454 0x2711FD60, 0x438050E3, 0x069908A8, 0x3D7FEDC4,
455 0x826D2BEF, 0x4EEB8476, 0x488DCF25, 0x36C9D566,
456 0x28E74E41, 0xC2610ACA, 0x3D49A9CF, 0xBAE3B9DF,
457 0xB65F8DE6, 0x92AEAF64, 0x3AC7D5E6, 0x9EA80509,
458 0xF22B017D, 0xA4173F70, 0xDD1E16C3, 0x15E0D7F9,
459 0x50B1B887, 0x2B9F4FD5, 0x625ABA82, 0x6A017962,
460 0x2EC01B9C, 0x15488AA9, 0xD716E740, 0x40055A2C,
461 0x93D29A22, 0xE32DBF9A, 0x058745B9, 0x3453DC1E,
462 0xD699296E, 0x496CFF6F, 0x1C9F4986, 0xDFE2ED07,
463 0xB87242D1, 0x19DE7EAE, 0x053E561A, 0x15AD6F8C,
464 0x66626C1C, 0x7154C24C, 0xEA082B2A, 0x93EB2939,
465 0x17DCB0F0, 0x58D4F2AE, 0x9EA294FB, 0x52CF564C,
466 0x9883FE66, 0x2EC40581, 0x763953C3, 0x01D6692E,
467 0xD3A0C108, 0xA1E7160E, 0xE4F2DFA6, 0x693ED285,
468 0x74904698, 0x4C2B0EDD, 0x4F757656, 0x5D393378,
469 0xA132234F, 0x3D321C5D, 0xC3F5E194, 0x4B269301,
470 0xC79F022F, 0x3C997E7E, 0x5E4F9504, 0x3FFAFBBD,
471 0x76F7AD0E, 0x296693F4, 0x3D1FCE6F, 0xC61E45BE,
472 0xD3B5AB34, 0xF72BF9B7, 0x1B0434C0, 0x4E72B567,
473 0x5592A33D, 0xB5229301, 0xCFD2A87F, 0x60AEB767,
474 0x1814386B, 0x30BCC33D, 0x38A0C07D, 0xFD1606F2,
475 0xC363519B, 0x589DD390, 0x5479F8E6, 0x1CB8D647,
476 0x97FD61A9, 0xEA7759F4, 0x2D57539D, 0x569A58CF,
477 0xE84E63AD, 0x462E1B78, 0x6580F87E, 0xF3817914,
478 0x91DA55F4, 0x40A230F3, 0xD1988F35, 0xB6E318D2,
479 0x3FFA50BC, 0x3D40F021, 0xC3C0BDAE, 0x4958C24C,
480 0x518F36B2, 0x84B1D370, 0x0FEDCE83, 0x878DDADA,
481 0xF2A279C7, 0x94E01BE8, 0x90716F4B, 0x954B8AA3
482};
483
484static const u_int32_t cast_sbox8[256] = {
485 0xE216300D, 0xBBDDFFFC, 0xA7EBDABD, 0x35648095,
486 0x7789F8B7, 0xE6C1121B, 0x0E241600, 0x052CE8B5,
487 0x11A9CFB0, 0xE5952F11, 0xECE7990A, 0x9386D174,
488 0x2A42931C, 0x76E38111, 0xB12DEF3A, 0x37DDDDFC,
489 0xDE9ADEB1, 0x0A0CC32C, 0xBE197029, 0x84A00940,
490 0xBB243A0F, 0xB4D137CF, 0xB44E79F0, 0x049EEDFD,
491 0x0B15A15D, 0x480D3168, 0x8BBBDE5A, 0x669DED42,
492 0xC7ECE831, 0x3F8F95E7, 0x72DF191B, 0x7580330D,
493 0x94074251, 0x5C7DCDFA, 0xABBE6D63, 0xAA402164,
494 0xB301D40A, 0x02E7D1CA, 0x53571DAE, 0x7A3182A2,
495 0x12A8DDEC, 0xFDAA335D, 0x176F43E8, 0x71FB46D4,
496 0x38129022, 0xCE949AD4, 0xB84769AD, 0x965BD862,
497 0x82F3D055, 0x66FB9767, 0x15B80B4E, 0x1D5B47A0,
498 0x4CFDE06F, 0xC28EC4B8, 0x57E8726E, 0x647A78FC,
499 0x99865D44, 0x608BD593, 0x6C200E03, 0x39DC5FF6,
500 0x5D0B00A3, 0xAE63AFF2, 0x7E8BD632, 0x70108C0C,
501 0xBBD35049, 0x2998DF04, 0x980CF42A, 0x9B6DF491,
502 0x9E7EDD53, 0x06918548, 0x58CB7E07, 0x3B74EF2E,
503 0x522FFFB1, 0xD24708CC, 0x1C7E27CD, 0xA4EB215B,
504 0x3CF1D2E2, 0x19B47A38, 0x424F7618, 0x35856039,
505 0x9D17DEE7, 0x27EB35E6, 0xC9AFF67B, 0x36BAF5B8,
506 0x09C467CD, 0xC18910B1, 0xE11DBF7B, 0x06CD1AF8,
507 0x7170C608, 0x2D5E3354, 0xD4DE495A, 0x64C6D006,
508 0xBCC0C62C, 0x3DD00DB3, 0x708F8F34, 0x77D51B42,
509 0x264F620F, 0x24B8D2BF, 0x15C1B79E, 0x46A52564,
510 0xF8D7E54E, 0x3E378160, 0x7895CDA5, 0x859C15A5,
511 0xE6459788, 0xC37BC75F, 0xDB07BA0C, 0x0676A3AB,
512 0x7F229B1E, 0x31842E7B, 0x24259FD7, 0xF8BEF472,
513 0x835FFCB8, 0x6DF4C1F2, 0x96F5B195, 0xFD0AF0FC,
514 0xB0FE134C, 0xE2506D3D, 0x4F9B12EA, 0xF215F225,
515 0xA223736F, 0x9FB4C428, 0x25D04979, 0x34C713F8,
516 0xC4618187, 0xEA7A6E98, 0x7CD16EFC, 0x1436876C,
517 0xF1544107, 0xBEDEEE14, 0x56E9AF27, 0xA04AA441,
518 0x3CF7C899, 0x92ECBAE6, 0xDD67016D, 0x151682EB,
519 0xA842EEDF, 0xFDBA60B4, 0xF1907B75, 0x20E3030F,
520 0x24D8C29E, 0xE139673B, 0xEFA63FB8, 0x71873054,
521 0xB6F2CF3B, 0x9F326442, 0xCB15A4CC, 0xB01A4504,
522 0xF1E47D8D, 0x844A1BE5, 0xBAE7DFDC, 0x42CBDA70,
523 0xCD7DAE0A, 0x57E85B7A, 0xD53F5AF6, 0x20CF4D8C,
524 0xCEA4D428, 0x79D130A4, 0x3486EBFB, 0x33D3CDDC,
525 0x77853B53, 0x37EFFCB5, 0xC5068778, 0xE580B3E6,
526 0x4E68B8F4, 0xC5C8B37E, 0x0D809EA2, 0x398FEB7C,
527 0x132A4F94, 0x43B7950E, 0x2FEE7D1C, 0x223613BD,
528 0xDD06CAA2, 0x37DF932B, 0xC4248289, 0xACF3EBC3,
529 0x5715F6B7, 0xEF3478DD, 0xF267616F, 0xC148CBE4,
530 0x9052815E, 0x5E410FAB, 0xB48A2465, 0x2EDA7FA4,
531 0xE87B40E4, 0xE98EA084, 0x5889E9E1, 0xEFD390FC,
532 0xDD07D35B, 0xDB485694, 0x38D7E5B2, 0x57720101,
533 0x730EDEBC, 0x5B643113, 0x94917E4F, 0x503C2FBA,
534 0x646F1282, 0x7523D24A, 0xE0779695, 0xF9C17A8F,
535 0x7A5B2121, 0xD187B896, 0x29263A4D, 0xBA510CDF,
536 0x81F47C9F, 0xAD1163ED, 0xEA7B5965, 0x1A00726E,
537 0x11403092, 0x00DA6D77, 0x4A0CDD61, 0xAD1F4603,
538 0x605BDFB0, 0x9EEDC364, 0x22EBE6A8, 0xCEE7D28A,
539 0xA0E736A0, 0x5564A6B9, 0x10853209, 0xC7EB8F37,
540 0x2DE705CA, 0x8951570F, 0xDF09822B, 0xBD691A6C,
541 0xAA12E4F2, 0x87451C0F, 0xE0F6A27A, 0x3ADA4819,
542 0x4CF1764F, 0x0D771C2B, 0x67CDB156, 0x350D8384,
543 0x5938FA0F, 0x42399EF3, 0x36997B07, 0x0E84093D,
544 0x4AA93E61, 0x8360D87B, 0x1FA98B0C, 0x1149382C,
545 0xE97625A5, 0x0614D1B7, 0x0E25244B, 0x0C768347,
546 0x589E8D82, 0x0D2059D1, 0xA466BB1E, 0xF8DA0A82,
547 0x04F19130, 0xBA6E4EC0, 0x99265164, 0x1EE7230D,
548 0x50B2AD80, 0xEAEE6801, 0x8DB2A283, 0xEA8BF59E
549};
550
551/* Macros to access 8-bit bytes out of a 32-bit word */
552#define U8a(x) ( (u_int8_t) (x>>24) )
553#define U8b(x) ( (u_int8_t) ((x>>16)&255) )
554#define U8c(x) ( (u_int8_t) ((x>>8)&255) )
555#define U8d(x) ( (u_int8_t) ((x)&255) )
556
557/* Circular left shift */
558#define ROL(x, n) ( ((x)<<(n)) | ((x)>>(32-(n))) )
559
560/* CAST-128 uses three different round functions */
561#define F1(l, r, i) \
562 t = ROL(key->xkey[i] + r, key->xkey[i+16]); \
563 l ^= ((cast_sbox1[U8a(t)] ^ cast_sbox2[U8b(t)]) - \
564 cast_sbox3[U8c(t)]) + cast_sbox4[U8d(t)];
565#define F2(l, r, i) \
566 t = ROL(key->xkey[i] ^ r, key->xkey[i+16]); \
567 l ^= ((cast_sbox1[U8a(t)] - cast_sbox2[U8b(t)]) + \
568 cast_sbox3[U8c(t)]) ^ cast_sbox4[U8d(t)];
569#define F3(l, r, i) \
570 t = ROL(key->xkey[i] - r, key->xkey[i+16]); \
571 l ^= ((cast_sbox1[U8a(t)] + cast_sbox2[U8b(t)]) ^ \
572 cast_sbox3[U8c(t)]) - cast_sbox4[U8d(t)];
573
574
575/***** Encryption Function *****/
576
577void cast_encrypt(cast_key* key, u_int8_t* inblock, u_int8_t* outblock)
578{
579u_int32_t t, l, r;
580
581 /* Get inblock into l,r */
582 l = ((u_int32_t)inblock[0] << 24) | ((u_int32_t)inblock[1] << 16) |
583 ((u_int32_t)inblock[2] << 8) | (u_int32_t)inblock[3];
584 r = ((u_int32_t)inblock[4] << 24) | ((u_int32_t)inblock[5] << 16) |
585 ((u_int32_t)inblock[6] << 8) | (u_int32_t)inblock[7];
586 /* Do the work */
587 F1(l, r, 0);
588 F2(r, l, 1);
589 F3(l, r, 2);
590 F1(r, l, 3);
591 F2(l, r, 4);
592 F3(r, l, 5);
593 F1(l, r, 6);
594 F2(r, l, 7);
595 F3(l, r, 8);
596 F1(r, l, 9);
597 F2(l, r, 10);
598 F3(r, l, 11);
599 /* Only do full 16 rounds if key length > 80 bits */
600 if (key->rounds > 12) {
601 F1(l, r, 12);
602 F2(r, l, 13);
603 F3(l, r, 14);
604 F1(r, l, 15);
605 }
606 /* Put l,r into outblock */
607 outblock[0] = U8a(r);
608 outblock[1] = U8b(r);
609 outblock[2] = U8c(r);
610 outblock[3] = U8d(r);
611 outblock[4] = U8a(l);
612 outblock[5] = U8b(l);
613 outblock[6] = U8c(l);
614 outblock[7] = U8d(l);
615 /* Wipe clean */
616 t = l = r = 0;
617}
618
619
620/***** Decryption Function *****/
621
622void cast_decrypt(cast_key* key, u_int8_t* inblock, u_int8_t* outblock)
623{
624u_int32_t t, l, r;
625
626 /* Get inblock into l,r */
627 r = ((u_int32_t)inblock[0] << 24) | ((u_int32_t)inblock[1] << 16) |
628 ((u_int32_t)inblock[2] << 8) | (u_int32_t)inblock[3];
629 l = ((u_int32_t)inblock[4] << 24) | ((u_int32_t)inblock[5] << 16) |
630 ((u_int32_t)inblock[6] << 8) | (u_int32_t)inblock[7];
631 /* Do the work */
632 /* Only do full 16 rounds if key length > 80 bits */
633 if (key->rounds > 12) {
634 F1(r, l, 15);
635 F3(l, r, 14);
636 F2(r, l, 13);
637 F1(l, r, 12);
638 }
639 F3(r, l, 11);
640 F2(l, r, 10);
641 F1(r, l, 9);
642 F3(l, r, 8);
643 F2(r, l, 7);
644 F1(l, r, 6);
645 F3(r, l, 5);
646 F2(l, r, 4);
647 F1(r, l, 3);
648 F3(l, r, 2);
649 F2(r, l, 1);
650 F1(l, r, 0);
651 /* Put l,r into outblock */
652 outblock[0] = U8a(l);
653 outblock[1] = U8b(l);
654 outblock[2] = U8c(l);
655 outblock[3] = U8d(l);
656 outblock[4] = U8a(r);
657 outblock[5] = U8b(r);
658 outblock[6] = U8c(r);
659 outblock[7] = U8d(r);
660 /* Wipe clean */
661 t = l = r = 0;
662}
663
664
665/***** Key Schedual *****/
666
667void cast_setkey(cast_key* key, u_int8_t* rawkey, int keybytes)
668{
669u_int32_t t[4], z[4], x[4];
670int i;
671
672 /* Set number of rounds to 12 or 16, depending on key length */
673 key->rounds = (keybytes <= 10 ? 12 : 16);
674
675 /* Copy key to workspace x */
676 for (i = 0; i < 4; i++) {
677 x[i] = 0;
678 if ((i*4+0) < keybytes) x[i] = (u_int32_t)rawkey[i*4+0] << 24;
679 if ((i*4+1) < keybytes) x[i] |= (u_int32_t)rawkey[i*4+1] << 16;
680 if ((i*4+2) < keybytes) x[i] |= (u_int32_t)rawkey[i*4+2] << 8;
681 if ((i*4+3) < keybytes) x[i] |= (u_int32_t)rawkey[i*4+3];
682 }
683 /* Generate 32 subkeys, four at a time */
684 for (i = 0; i < 32; i+=4) {
685 switch (i & 4) {
686 case 0:
687 t[0] = z[0] = x[0] ^ cast_sbox5[U8b(x[3])] ^
688 cast_sbox6[U8d(x[3])] ^ cast_sbox7[U8a(x[3])] ^
689 cast_sbox8[U8c(x[3])] ^ cast_sbox7[U8a(x[2])];
690 t[1] = z[1] = x[2] ^ cast_sbox5[U8a(z[0])] ^
691 cast_sbox6[U8c(z[0])] ^ cast_sbox7[U8b(z[0])] ^
692 cast_sbox8[U8d(z[0])] ^ cast_sbox8[U8c(x[2])];
693 t[2] = z[2] = x[3] ^ cast_sbox5[U8d(z[1])] ^
694 cast_sbox6[U8c(z[1])] ^ cast_sbox7[U8b(z[1])] ^
695 cast_sbox8[U8a(z[1])] ^ cast_sbox5[U8b(x[2])];
696 t[3] = z[3] = x[1] ^ cast_sbox5[U8c(z[2])] ^
697 cast_sbox6[U8b(z[2])] ^ cast_sbox7[U8d(z[2])] ^
698 cast_sbox8[U8a(z[2])] ^ cast_sbox6[U8d(x[2])];
699 break;
700 case 4:
701 t[0] = x[0] = z[2] ^ cast_sbox5[U8b(z[1])] ^
702 cast_sbox6[U8d(z[1])] ^ cast_sbox7[U8a(z[1])] ^
703 cast_sbox8[U8c(z[1])] ^ cast_sbox7[U8a(z[0])];
704 t[1] = x[1] = z[0] ^ cast_sbox5[U8a(x[0])] ^
705 cast_sbox6[U8c(x[0])] ^ cast_sbox7[U8b(x[0])] ^
706 cast_sbox8[U8d(x[0])] ^ cast_sbox8[U8c(z[0])];
707 t[2] = x[2] = z[1] ^ cast_sbox5[U8d(x[1])] ^
708 cast_sbox6[U8c(x[1])] ^ cast_sbox7[U8b(x[1])] ^
709 cast_sbox8[U8a(x[1])] ^ cast_sbox5[U8b(z[0])];
710 t[3] = x[3] = z[3] ^ cast_sbox5[U8c(x[2])] ^
711 cast_sbox6[U8b(x[2])] ^ cast_sbox7[U8d(x[2])] ^
712 cast_sbox8[U8a(x[2])] ^ cast_sbox6[U8d(z[0])];
713 break;
714 }
715 switch (i & 12) {
716 case 0:
717 case 12:
718 key->xkey[i+0] = cast_sbox5[U8a(t[2])] ^ cast_sbox6[U8b(t[2])] ^
719 cast_sbox7[U8d(t[1])] ^ cast_sbox8[U8c(t[1])];
720 key->xkey[i+1] = cast_sbox5[U8c(t[2])] ^ cast_sbox6[U8d(t[2])] ^
721 cast_sbox7[U8b(t[1])] ^ cast_sbox8[U8a(t[1])];
722 key->xkey[i+2] = cast_sbox5[U8a(t[3])] ^ cast_sbox6[U8b(t[3])] ^
723 cast_sbox7[U8d(t[0])] ^ cast_sbox8[U8c(t[0])];
724 key->xkey[i+3] = cast_sbox5[U8c(t[3])] ^ cast_sbox6[U8d(t[3])] ^
725 cast_sbox7[U8b(t[0])] ^ cast_sbox8[U8a(t[0])];
726 break;
727 case 4:
728 case 8:
729 key->xkey[i+0] = cast_sbox5[U8d(t[0])] ^ cast_sbox6[U8c(t[0])] ^
730 cast_sbox7[U8a(t[3])] ^ cast_sbox8[U8b(t[3])];
731 key->xkey[i+1] = cast_sbox5[U8b(t[0])] ^ cast_sbox6[U8a(t[0])] ^
732 cast_sbox7[U8c(t[3])] ^ cast_sbox8[U8d(t[3])];
733 key->xkey[i+2] = cast_sbox5[U8d(t[1])] ^ cast_sbox6[U8c(t[1])] ^
734 cast_sbox7[U8a(t[2])] ^ cast_sbox8[U8b(t[2])];
735 key->xkey[i+3] = cast_sbox5[U8b(t[1])] ^ cast_sbox6[U8a(t[1])] ^
736 cast_sbox7[U8c(t[2])] ^ cast_sbox8[U8d(t[2])];
737 break;
738 }
739 switch (i & 12) {
740 case 0:
741 key->xkey[i+0] ^= cast_sbox5[U8c(z[0])];
742 key->xkey[i+1] ^= cast_sbox6[U8c(z[1])];
743 key->xkey[i+2] ^= cast_sbox7[U8b(z[2])];
744 key->xkey[i+3] ^= cast_sbox8[U8a(z[3])];
745 break;
746 case 4:
747 key->xkey[i+0] ^= cast_sbox5[U8a(x[2])];
748 key->xkey[i+1] ^= cast_sbox6[U8b(x[3])];
749 key->xkey[i+2] ^= cast_sbox7[U8d(x[0])];
750 key->xkey[i+3] ^= cast_sbox8[U8d(x[1])];
751 break;
752 case 8:
753 key->xkey[i+0] ^= cast_sbox5[U8b(z[2])];
754 key->xkey[i+1] ^= cast_sbox6[U8a(z[3])];
755 key->xkey[i+2] ^= cast_sbox7[U8c(z[0])];
756 key->xkey[i+3] ^= cast_sbox8[U8c(z[1])];
757 break;
758 case 12:
759 key->xkey[i+0] ^= cast_sbox5[U8d(x[0])];
760 key->xkey[i+1] ^= cast_sbox6[U8d(x[1])];
761 key->xkey[i+2] ^= cast_sbox7[U8a(x[2])];
762 key->xkey[i+3] ^= cast_sbox8[U8b(x[3])];
763 break;
764 }
765 if (i >= 16) {
766 key->xkey[i+0] &= 31;
767 key->xkey[i+1] &= 31;
768 key->xkey[i+2] &= 31;
769 key->xkey[i+3] &= 31;
770 }
771 }
772 /* Wipe clean */
773 for (i = 0; i < 4; i++) {
774 t[i] = x[i] = z[i] = 0;
775 }
776}
777
778/* Made in Canada */
779
diff --git a/src/lib/libc/crypt/crypt.3 b/src/lib/libc/crypt/crypt.3
new file mode 100644
index 0000000000..239c9b3089
--- /dev/null
+++ b/src/lib/libc/crypt/crypt.3
@@ -0,0 +1,298 @@
1.\" $OpenBSD: crypt.3,v 1.12 1999/03/18 11:08:33 aaron Exp $
2.\"
3.\" FreeSec: libcrypt
4.\"
5.\" Copyright (c) 1994 David Burren
6.\" All rights reserved.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 4. Neither the name of the author nor the names of other contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" Manual page, using -mandoc macros
33.\"
34.Dd March 9, 1994
35.Dt CRYPT 3
36.Os
37.Sh NAME
38.Nm crypt ,
39.Nm setkey ,
40.Nm encrypt ,
41.Nm des_setkey ,
42.Nm des_cipher
43.Nd DES encryption
44.Sh SYNOPSIS
45.Fd #include <unistd.h>
46.Ft char
47.Fn *crypt "const char *key" "const char *setting"
48.Ft int
49.Fn setkey "char *key"
50.Ft int
51.Fn encrypt "char *block" "int flag"
52.Ft int
53.Fn des_setkey "const char *key"
54.Ft int
55.Fn des_cipher "const char *in" "char *out" "int32_t salt" "int count"
56.Sh DESCRIPTION
57The
58.Fn crypt
59function performs password encryption, based on the
60.Tn NBS
61Data Encryption Standard (DES).
62Additional code has been added to deter key search attempts and to use
63stronger hashing algorithms.
64The first argument to
65.Fn crypt
66is a
67.Dv null Ns -terminated
68string, typically a user's typed password.
69The second is in one of three forms:
70if it begins with an underscore (``_'') then an extended format is used
71in interpreting both the key and the setting, as outlined below. If it begins
72with an string character (``$'') and a number then a different algorithm
73is used depending on the number. At the moment a ``$1'' chooses MD5 hashing
74and a ``$2'' chooses Blowfish hashing, see below for more information.
75.Ss Extended crypt:
76.Pp
77The
78.Ar key
79is divided into groups of 8 characters (the last group is null-padded)
80and the low-order 7 bits of each character (56 bits per group) are
81used to form the DES key as follows:
82the first group of 56 bits becomes the initial DES key.
83For each additional group, the XOR of the encryption of the current DES
84key with itself and the group bits becomes the next DES key.
85.Pp
86The setting is a 9-character array consisting of an underscore followed
87by 4 bytes of iteration count and 4 bytes of salt.
88These are encoded as printable characters, 6 bits per character,
89least significant character first.
90The values 0 to 63 are encoded as ``./0-9A-Za-z''.
91This allows 24 bits for both
92.Fa count
93and
94.Fa salt .
95.Ss "MD5" crypt:
96.Pp
97For
98.Tn MD5
99crypt the version number,
100.Fa salt
101and the hashed password are separated
102by the ``$'' character. The maximum length of a password is limited by
103the length counter of the MD5 context, which is about
1042**64. A valid MD5 password entry looks like this:
105.Pp
106``$1$caeiHQwX$hsKqOjrFRRN6K32OWkCBf1''.
107.Pp
108The whole MD5 password string is passed as
109.Fa setting
110for interpretation.
111.Ss "Blowfish" crypt:
112.Pp
113The
114.Tn Blowfish
115version of crypt has 128 bits of
116.Fa salt
117in order to make building
118dictionaries of common passwords space consuming. The initial state
119of the
120.Tn Blowfish
121cipher is expanded using the
122.Fa salt
123and the
124.Fa password
125repeating the process a variable number of rounds, which is encoded in
126the password string. The maximum password length is 72. The final Blowfish
127password entry is created by encrypting
128the string ``OrpheanBeholderScryDoubt'' with the
129.Tn Blowfish
130state 64 times.
131.Pp
132The version number, the logarithm of the number of rounds and
133the concatenation of salt and
134hashed password are separated by the ``$'' character. An encoded ``8''
135would specify 256 rounds.
136A valid Blowfish password looks like this:
137.Pp
138``$2a$12$eIAq8PR8sIUnJ1HaohxX2O9x9Qlm2vK97LJ5dsXdmB.eXF42qjchC''.
139.Pp
140The whole Blowfish password string is passed as
141.Fa setting
142for interpretation.
143.Ss "Traditional" crypt:
144.Pp
145The first 8 bytes of the key are null-padded, and the low-order 7 bits of
146each character is used to form the 56-bit
147.Tn DES
148key.
149.Pp
150The setting is a 2-character array of the ASCII-encoded salt.
151Thus only 12 bits of
152.Fa salt
153are used.
154.Fa count
155is set to 25.
156.Ss DES Algorithm:
157.Pp
158The
159.Fa salt
160introduces disorder in the
161.Tn DES
162algorithm in one of 16777216 or 4096 possible ways
163(ie. with 24 or 12 bits: if bit
164.Em i
165of the
166.Ar salt
167is set, then bits
168.Em i
169and
170.Em i+24
171are swapped in the
172.Tn DES
173E-box output).
174.Pp
175The DES key is used to encrypt a 64-bit constant using
176.Ar count
177iterations of
178.Tn DES .
179The value returned is a
180.Dv null Ns -terminated
181string, 20 or 13 bytes (plus null) in length, consisting of the
182.Ar setting
183followed by the encoded 64-bit encryption.
184.Pp
185The functions,
186.Fn encrypt ,
187.Fn setkey ,
188.Fn des_setkey
189and
190.Fn des_cipher
191provide access to the
192.Tn DES
193algorithm itself.
194.Fn setkey
195is passed a 64-byte array of binary values (numeric 0 or 1).
196A 56-bit key is extracted from this array by dividing the
197array into groups of 8, and ignoring the last bit in each group.
198That bit is reserved for a byte parity check by DES, but is ignored
199by these functions.
200.Pp
201The
202.Fa block
203argument to
204.Fn encrypt
205is also a 64-byte array of binary values.
206If the value of
207.Fa flag
208is 0,
209.Fa block
210is encrypted otherwise it is decrypted.
211The result is returned in the original array
212.Fa block
213after using the key specified by
214.Fn setkey
215to process it.
216.Pp
217The argument to
218.Fn des_setkey
219is a character array of length 8.
220The least significant bit (the parity bit) in each character is ignored,
221and the remaining bits are concatenated to form a 56-bit key.
222The function
223.Fn des_cipher
224encrypts (or decrypts if
225.Fa count
226is negative) the 64-bits stored in the 8 characters at
227.Fa in
228using
229.Xr abs 3
230of
231.Fa count
232iterations of
233.Tn DES
234and stores the 64-bit result in the 8 characters at
235.Fa out
236(which may be the same as
237.Fa in
238).
239The
240.Fa salt
241specifies perturbations to the
242.Tn DES
243E-box output as described above.
244.Pp
245The function
246.Fn crypt
247returns a pointer to the encrypted value on success, and NULL on failure.
248The functions
249.Fn setkey ,
250.Fn encrypt ,
251.Fn des_setkey ,
252and
253.Fn des_cipher
254return 0 on success and 1 on failure.
255.Pp
256The
257.Fn crypt ,
258.Fn setkey
259and
260.Fn des_setkey
261functions all manipulate the same key space.
262.Sh SEE ALSO
263.Xr login 1 ,
264.Xr passwd 1 ,
265.Xr blowfish 3 ,
266.Xr getpass 3 ,
267.Xr md5 3 ,
268.Xr passwd 5
269.Sh BUGS
270The
271.Fn crypt
272function returns a pointer to static data, and subsequent calls to
273.Fn crypt
274will modify the same object.
275.Sh HISTORY
276A rotor-based
277.Fn crypt
278function appeared in
279.At v6 .
280The current style
281.Fn crypt
282first appeared in
283.At v7 .
284.Pp
285This library (FreeSec 1.0) was developed outside the United States of America
286as an unencumbered replacement for the U.S.-only libcrypt encryption
287library.
288Programs linked against the
289.Fn crypt
290interface may be exported from the U.S.A. only if they use
291.Fn crypt
292solely for authentication purposes and avoid use of
293the other programmer interfaces listed above. Special care has been taken
294in the library so that programs which only use the
295.Fn crypt
296interface do not pull in the other components.
297.Sh AUTHOR
298David Burren <davidb@werj.com.au>
diff --git a/src/lib/libc/crypt/crypt.c b/src/lib/libc/crypt/crypt.c
new file mode 100644
index 0000000000..8fd319a4f3
--- /dev/null
+++ b/src/lib/libc/crypt/crypt.c
@@ -0,0 +1,714 @@
1/* $OpenBSD: crypt.c,v 1.13 1998/03/22 19:01:18 niklas Exp $ */
2
3/*
4 * FreeSec: libcrypt
5 *
6 * Copyright (c) 1994 David Burren
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 4. Neither the name of the author nor the names of other contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 *
34 * This is an original implementation of the DES and the crypt(3) interfaces
35 * by David Burren <davidb@werj.com.au>.
36 *
37 * An excellent reference on the underlying algorithm (and related
38 * algorithms) is:
39 *
40 * B. Schneier, Applied Cryptography: protocols, algorithms,
41 * and source code in C, John Wiley & Sons, 1994.
42 *
43 * Note that in that book's description of DES the lookups for the initial,
44 * pbox, and final permutations are inverted (this has been brought to the
45 * attention of the author). A list of errata for this book has been
46 * posted to the sci.crypt newsgroup by the author and is available for FTP.
47 *
48 * NOTE:
49 * This file has a static version of des_setkey() so that crypt.o exports
50 * only the crypt() interface. This is required to make binaries linked
51 * against crypt.o exportable or re-exportable from the USA.
52 */
53
54#if defined(LIBC_SCCS) && !defined(lint)
55static char rcsid[] = "$OpenBSD: crypt.c,v 1.13 1998/03/22 19:01:18 niklas Exp $";
56#endif /* LIBC_SCCS and not lint */
57
58#include <sys/types.h>
59#include <sys/param.h>
60#include <pwd.h>
61#include <string.h>
62
63#ifdef DEBUG
64# include <stdio.h>
65#endif
66
67static u_char IP[64] = {
68 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
69 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
70 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
71 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7
72};
73
74static u_char inv_key_perm[64];
75static u_char u_key_perm[56];
76static u_char key_perm[56] = {
77 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
78 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36,
79 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,
80 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
81};
82
83static u_char key_shifts[16] = {
84 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
85};
86
87static u_char inv_comp_perm[56];
88static u_char comp_perm[48] = {
89 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10,
90 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2,
91 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
92 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
93};
94
95/*
96 * No E box is used, as it's replaced by some ANDs, shifts, and ORs.
97 */
98
99static u_char u_sbox[8][64];
100static u_char sbox[8][64] = {
101 {
102 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
103 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
104 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
105 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13
106 },
107 {
108 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
109 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
110 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
111 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9
112 },
113 {
114 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
115 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
116 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
117 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12
118 },
119 {
120 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
121 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
122 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
123 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14
124 },
125 {
126 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
127 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
128 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
129 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3
130 },
131 {
132 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
133 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
134 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
135 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13
136 },
137 {
138 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
139 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
140 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
141 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12
142 },
143 {
144 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
145 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
146 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
147 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11
148 }
149};
150
151static u_char un_pbox[32];
152static u_char pbox[32] = {
153 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
154 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25
155};
156
157static u_int32_t bits32[32] =
158{
159 0x80000000, 0x40000000, 0x20000000, 0x10000000,
160 0x08000000, 0x04000000, 0x02000000, 0x01000000,
161 0x00800000, 0x00400000, 0x00200000, 0x00100000,
162 0x00080000, 0x00040000, 0x00020000, 0x00010000,
163 0x00008000, 0x00004000, 0x00002000, 0x00001000,
164 0x00000800, 0x00000400, 0x00000200, 0x00000100,
165 0x00000080, 0x00000040, 0x00000020, 0x00000010,
166 0x00000008, 0x00000004, 0x00000002, 0x00000001
167};
168
169static u_char bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
170
171static u_int32_t saltbits;
172static int32_t old_salt;
173static u_int32_t *bits28, *bits24;
174static u_char init_perm[64], final_perm[64];
175static u_int32_t en_keysl[16], en_keysr[16];
176static u_int32_t de_keysl[16], de_keysr[16];
177static int des_initialised = 0;
178static u_char m_sbox[4][4096];
179static u_int32_t psbox[4][256];
180static u_int32_t ip_maskl[8][256], ip_maskr[8][256];
181static u_int32_t fp_maskl[8][256], fp_maskr[8][256];
182static u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
183static u_int32_t comp_maskl[8][128], comp_maskr[8][128];
184static u_int32_t old_rawkey0, old_rawkey1;
185
186static u_char ascii64[] =
187 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
188/* 0000000000111111111122222222223333333333444444444455555555556666 */
189/* 0123456789012345678901234567890123456789012345678901234567890123 */
190
191static __inline int
192ascii_to_bin(ch)
193 char ch;
194{
195 if (ch > 'z')
196 return(0);
197 if (ch >= 'a')
198 return(ch - 'a' + 38);
199 if (ch > 'Z')
200 return(0);
201 if (ch >= 'A')
202 return(ch - 'A' + 12);
203 if (ch > '9')
204 return(0);
205 if (ch >= '.')
206 return(ch - '.');
207 return(0);
208}
209
210static void
211des_init()
212{
213 int i, j, b, k, inbit, obit;
214 u_int32_t *p, *il, *ir, *fl, *fr;
215
216 old_rawkey0 = old_rawkey1 = 0;
217 saltbits = 0;
218 old_salt = 0;
219 bits24 = (bits28 = bits32 + 4) + 4;
220
221 /*
222 * Invert the S-boxes, reordering the input bits.
223 */
224 for (i = 0; i < 8; i++)
225 for (j = 0; j < 64; j++) {
226 b = (j & 0x20) | ((j & 1) << 4) | ((j >> 1) & 0xf);
227 u_sbox[i][j] = sbox[i][b];
228 }
229
230 /*
231 * Convert the inverted S-boxes into 4 arrays of 8 bits.
232 * Each will handle 12 bits of the S-box input.
233 */
234 for (b = 0; b < 4; b++)
235 for (i = 0; i < 64; i++)
236 for (j = 0; j < 64; j++)
237 m_sbox[b][(i << 6) | j] =
238 (u_sbox[(b << 1)][i] << 4) |
239 u_sbox[(b << 1) + 1][j];
240
241 /*
242 * Set up the initial & final permutations into a useful form, and
243 * initialise the inverted key permutation.
244 */
245 for (i = 0; i < 64; i++) {
246 init_perm[final_perm[i] = IP[i] - 1] = i;
247 inv_key_perm[i] = 255;
248 }
249
250 /*
251 * Invert the key permutation and initialise the inverted key
252 * compression permutation.
253 */
254 for (i = 0; i < 56; i++) {
255 u_key_perm[i] = key_perm[i] - 1;
256 inv_key_perm[key_perm[i] - 1] = i;
257 inv_comp_perm[i] = 255;
258 }
259
260 /*
261 * Invert the key compression permutation.
262 */
263 for (i = 0; i < 48; i++) {
264 inv_comp_perm[comp_perm[i] - 1] = i;
265 }
266
267 /*
268 * Set up the OR-mask arrays for the initial and final permutations,
269 * and for the key initial and compression permutations.
270 */
271 for (k = 0; k < 8; k++) {
272 for (i = 0; i < 256; i++) {
273 *(il = &ip_maskl[k][i]) = 0;
274 *(ir = &ip_maskr[k][i]) = 0;
275 *(fl = &fp_maskl[k][i]) = 0;
276 *(fr = &fp_maskr[k][i]) = 0;
277 for (j = 0; j < 8; j++) {
278 inbit = 8 * k + j;
279 if (i & bits8[j]) {
280 if ((obit = init_perm[inbit]) < 32)
281 *il |= bits32[obit];
282 else
283 *ir |= bits32[obit-32];
284 if ((obit = final_perm[inbit]) < 32)
285 *fl |= bits32[obit];
286 else
287 *fr |= bits32[obit - 32];
288 }
289 }
290 }
291 for (i = 0; i < 128; i++) {
292 *(il = &key_perm_maskl[k][i]) = 0;
293 *(ir = &key_perm_maskr[k][i]) = 0;
294 for (j = 0; j < 7; j++) {
295 inbit = 8 * k + j;
296 if (i & bits8[j + 1]) {
297 if ((obit = inv_key_perm[inbit]) == 255)
298 continue;
299 if (obit < 28)
300 *il |= bits28[obit];
301 else
302 *ir |= bits28[obit - 28];
303 }
304 }
305 *(il = &comp_maskl[k][i]) = 0;
306 *(ir = &comp_maskr[k][i]) = 0;
307 for (j = 0; j < 7; j++) {
308 inbit = 7 * k + j;
309 if (i & bits8[j + 1]) {
310 if ((obit=inv_comp_perm[inbit]) == 255)
311 continue;
312 if (obit < 24)
313 *il |= bits24[obit];
314 else
315 *ir |= bits24[obit - 24];
316 }
317 }
318 }
319 }
320
321 /*
322 * Invert the P-box permutation, and convert into OR-masks for
323 * handling the output of the S-box arrays setup above.
324 */
325 for (i = 0; i < 32; i++)
326 un_pbox[pbox[i] - 1] = i;
327
328 for (b = 0; b < 4; b++)
329 for (i = 0; i < 256; i++) {
330 *(p = &psbox[b][i]) = 0;
331 for (j = 0; j < 8; j++) {
332 if (i & bits8[j])
333 *p |= bits32[un_pbox[8 * b + j]];
334 }
335 }
336
337 des_initialised = 1;
338}
339
340static void
341setup_salt(salt)
342 int32_t salt;
343{
344 u_int32_t obit, saltbit;
345 int i;
346
347 if (salt == old_salt)
348 return;
349 old_salt = salt;
350
351 saltbits = 0;
352 saltbit = 1;
353 obit = 0x800000;
354 for (i = 0; i < 24; i++) {
355 if (salt & saltbit)
356 saltbits |= obit;
357 saltbit <<= 1;
358 obit >>= 1;
359 }
360}
361
362static int
363des_setkey(key)
364 const char *key;
365{
366 u_int32_t k0, k1, rawkey0, rawkey1;
367 int shifts, round;
368
369 if (!des_initialised)
370 des_init();
371
372 rawkey0 = ntohl(*(u_int32_t *) key);
373 rawkey1 = ntohl(*(u_int32_t *) (key + 4));
374
375 if ((rawkey0 | rawkey1)
376 && rawkey0 == old_rawkey0
377 && rawkey1 == old_rawkey1) {
378 /*
379 * Already setup for this key.
380 * This optimisation fails on a zero key (which is weak and
381 * has bad parity anyway) in order to simplify the starting
382 * conditions.
383 */
384 return(0);
385 }
386 old_rawkey0 = rawkey0;
387 old_rawkey1 = rawkey1;
388
389 /*
390 * Do key permutation and split into two 28-bit subkeys.
391 */
392 k0 = key_perm_maskl[0][rawkey0 >> 25]
393 | key_perm_maskl[1][(rawkey0 >> 17) & 0x7f]
394 | key_perm_maskl[2][(rawkey0 >> 9) & 0x7f]
395 | key_perm_maskl[3][(rawkey0 >> 1) & 0x7f]
396 | key_perm_maskl[4][rawkey1 >> 25]
397 | key_perm_maskl[5][(rawkey1 >> 17) & 0x7f]
398 | key_perm_maskl[6][(rawkey1 >> 9) & 0x7f]
399 | key_perm_maskl[7][(rawkey1 >> 1) & 0x7f];
400 k1 = key_perm_maskr[0][rawkey0 >> 25]
401 | key_perm_maskr[1][(rawkey0 >> 17) & 0x7f]
402 | key_perm_maskr[2][(rawkey0 >> 9) & 0x7f]
403 | key_perm_maskr[3][(rawkey0 >> 1) & 0x7f]
404 | key_perm_maskr[4][rawkey1 >> 25]
405 | key_perm_maskr[5][(rawkey1 >> 17) & 0x7f]
406 | key_perm_maskr[6][(rawkey1 >> 9) & 0x7f]
407 | key_perm_maskr[7][(rawkey1 >> 1) & 0x7f];
408 /*
409 * Rotate subkeys and do compression permutation.
410 */
411 shifts = 0;
412 for (round = 0; round < 16; round++) {
413 u_int32_t t0, t1;
414
415 shifts += key_shifts[round];
416
417 t0 = (k0 << shifts) | (k0 >> (28 - shifts));
418 t1 = (k1 << shifts) | (k1 >> (28 - shifts));
419
420 de_keysl[15 - round] =
421 en_keysl[round] = comp_maskl[0][(t0 >> 21) & 0x7f]
422 | comp_maskl[1][(t0 >> 14) & 0x7f]
423 | comp_maskl[2][(t0 >> 7) & 0x7f]
424 | comp_maskl[3][t0 & 0x7f]
425 | comp_maskl[4][(t1 >> 21) & 0x7f]
426 | comp_maskl[5][(t1 >> 14) & 0x7f]
427 | comp_maskl[6][(t1 >> 7) & 0x7f]
428 | comp_maskl[7][t1 & 0x7f];
429
430 de_keysr[15 - round] =
431 en_keysr[round] = comp_maskr[0][(t0 >> 21) & 0x7f]
432 | comp_maskr[1][(t0 >> 14) & 0x7f]
433 | comp_maskr[2][(t0 >> 7) & 0x7f]
434 | comp_maskr[3][t0 & 0x7f]
435 | comp_maskr[4][(t1 >> 21) & 0x7f]
436 | comp_maskr[5][(t1 >> 14) & 0x7f]
437 | comp_maskr[6][(t1 >> 7) & 0x7f]
438 | comp_maskr[7][t1 & 0x7f];
439 }
440 return(0);
441}
442
443static int
444do_des(l_in, r_in, l_out, r_out, count)
445 u_int32_t l_in, r_in, *l_out, *r_out;
446 int count;
447{
448 /*
449 * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
450 */
451 u_int32_t l, r, *kl, *kr, *kl1, *kr1;
452 u_int32_t f, r48l, r48r;
453 int round;
454
455 if (count == 0) {
456 return(1);
457 } else if (count > 0) {
458 /*
459 * Encrypting
460 */
461 kl1 = en_keysl;
462 kr1 = en_keysr;
463 } else {
464 /*
465 * Decrypting
466 */
467 count = -count;
468 kl1 = de_keysl;
469 kr1 = de_keysr;
470 }
471
472 /*
473 * Do initial permutation (IP).
474 */
475 l = ip_maskl[0][l_in >> 24]
476 | ip_maskl[1][(l_in >> 16) & 0xff]
477 | ip_maskl[2][(l_in >> 8) & 0xff]
478 | ip_maskl[3][l_in & 0xff]
479 | ip_maskl[4][r_in >> 24]
480 | ip_maskl[5][(r_in >> 16) & 0xff]
481 | ip_maskl[6][(r_in >> 8) & 0xff]
482 | ip_maskl[7][r_in & 0xff];
483 r = ip_maskr[0][l_in >> 24]
484 | ip_maskr[1][(l_in >> 16) & 0xff]
485 | ip_maskr[2][(l_in >> 8) & 0xff]
486 | ip_maskr[3][l_in & 0xff]
487 | ip_maskr[4][r_in >> 24]
488 | ip_maskr[5][(r_in >> 16) & 0xff]
489 | ip_maskr[6][(r_in >> 8) & 0xff]
490 | ip_maskr[7][r_in & 0xff];
491
492 while (count--) {
493 /*
494 * Do each round.
495 */
496 kl = kl1;
497 kr = kr1;
498 round = 16;
499 while (round--) {
500 /*
501 * Expand R to 48 bits (simulate the E-box).
502 */
503 r48l = ((r & 0x00000001) << 23)
504 | ((r & 0xf8000000) >> 9)
505 | ((r & 0x1f800000) >> 11)
506 | ((r & 0x01f80000) >> 13)
507 | ((r & 0x001f8000) >> 15);
508
509 r48r = ((r & 0x0001f800) << 7)
510 | ((r & 0x00001f80) << 5)
511 | ((r & 0x000001f8) << 3)
512 | ((r & 0x0000001f) << 1)
513 | ((r & 0x80000000) >> 31);
514 /*
515 * Do salting for crypt() and friends, and
516 * XOR with the permuted key.
517 */
518 f = (r48l ^ r48r) & saltbits;
519 r48l ^= f ^ *kl++;
520 r48r ^= f ^ *kr++;
521 /*
522 * Do sbox lookups (which shrink it back to 32 bits)
523 * and do the pbox permutation at the same time.
524 */
525 f = psbox[0][m_sbox[0][r48l >> 12]]
526 | psbox[1][m_sbox[1][r48l & 0xfff]]
527 | psbox[2][m_sbox[2][r48r >> 12]]
528 | psbox[3][m_sbox[3][r48r & 0xfff]];
529 /*
530 * Now that we've permuted things, complete f().
531 */
532 f ^= l;
533 l = r;
534 r = f;
535 }
536 r = l;
537 l = f;
538 }
539 /*
540 * Do final permutation (inverse of IP).
541 */
542 *l_out = fp_maskl[0][l >> 24]
543 | fp_maskl[1][(l >> 16) & 0xff]
544 | fp_maskl[2][(l >> 8) & 0xff]
545 | fp_maskl[3][l & 0xff]
546 | fp_maskl[4][r >> 24]
547 | fp_maskl[5][(r >> 16) & 0xff]
548 | fp_maskl[6][(r >> 8) & 0xff]
549 | fp_maskl[7][r & 0xff];
550 *r_out = fp_maskr[0][l >> 24]
551 | fp_maskr[1][(l >> 16) & 0xff]
552 | fp_maskr[2][(l >> 8) & 0xff]
553 | fp_maskr[3][l & 0xff]
554 | fp_maskr[4][r >> 24]
555 | fp_maskr[5][(r >> 16) & 0xff]
556 | fp_maskr[6][(r >> 8) & 0xff]
557 | fp_maskr[7][r & 0xff];
558 return(0);
559}
560
561static int
562des_cipher(in, out, salt, count)
563 const char *in;
564 char *out;
565 int32_t salt;
566 int count;
567{
568 u_int32_t l_out, r_out, rawl, rawr;
569 u_int32_t x[2];
570 int retval;
571
572 if (!des_initialised)
573 des_init();
574
575 setup_salt(salt);
576
577 memcpy(x, in, sizeof x);
578 rawl = ntohl(x[0]);
579 rawr = ntohl(x[1]);
580 retval = do_des(rawl, rawr, &l_out, &r_out, count);
581
582 x[0] = htonl(l_out);
583 x[1] = htonl(r_out);
584 memcpy(out, x, sizeof x);
585 return(retval);
586}
587
588char *
589crypt(key, setting)
590 const char *key;
591 const char *setting;
592{
593 int i;
594 u_int32_t count, salt, l, r0, r1, keybuf[2];
595 u_char *p, *q;
596 static u_char output[21];
597 extern char *md5crypt __P((const char *, const char *));
598 extern char *bcrypt __P((const char *, const char *));
599
600 if (setting[0] == '$') {
601 switch (setting[1]) {
602 case '1':
603 return (md5crypt(key, setting));
604 default:
605 return bcrypt(key, setting);
606 }
607 }
608
609 if (!des_initialised)
610 des_init();
611
612 /*
613 * Copy the key, shifting each character up by one bit
614 * and padding with zeros.
615 */
616 q = (u_char *) keybuf;
617 while ((q - (u_char *) keybuf) < sizeof(keybuf)) {
618 if ((*q++ = *key << 1))
619 key++;
620 }
621 if (des_setkey((u_char *) keybuf))
622 return(NULL);
623
624 if (*setting == _PASSWORD_EFMT1) {
625 /*
626 * "new"-style:
627 * setting - underscore, 4 bytes of count, 4 bytes of salt
628 * key - unlimited characters
629 */
630 for (i = 1, count = 0; i < 5; i++)
631 count |= ascii_to_bin(setting[i]) << (i - 1) * 6;
632
633 for (i = 5, salt = 0; i < 9; i++)
634 salt |= ascii_to_bin(setting[i]) << (i - 5) * 6;
635
636 while (*key) {
637 /*
638 * Encrypt the key with itself.
639 */
640 if (des_cipher((u_char*)keybuf, (u_char*)keybuf, 0, 1))
641 return(NULL);
642 /*
643 * And XOR with the next 8 characters of the key.
644 */
645 q = (u_char *) keybuf;
646 while (((q - (u_char *) keybuf) < sizeof(keybuf)) &&
647 *key)
648 *q++ ^= *key++ << 1;
649
650 if (des_setkey((u_char *) keybuf))
651 return(NULL);
652 }
653 strncpy((char *)output, setting, 9);
654
655 /*
656 * Double check that we weren't given a short setting.
657 * If we were, the above code will probably have created
658 * wierd values for count and salt, but we don't really care.
659 * Just make sure the output string doesn't have an extra
660 * NUL in it.
661 */
662 output[9] = '\0';
663 p = output + strlen((const char *)output);
664 } else {
665 /*
666 * "old"-style:
667 * setting - 2 bytes of salt
668 * key - up to 8 characters
669 */
670 count = 25;
671
672 salt = (ascii_to_bin(setting[1]) << 6)
673 | ascii_to_bin(setting[0]);
674
675 output[0] = setting[0];
676 /*
677 * If the encrypted password that the salt was extracted from
678 * is only 1 character long, the salt will be corrupted. We
679 * need to ensure that the output string doesn't have an extra
680 * NUL in it!
681 */
682 output[1] = setting[1] ? setting[1] : output[0];
683
684 p = output + 2;
685 }
686 setup_salt(salt);
687 /*
688 * Do it.
689 */
690 if (do_des(0, 0, &r0, &r1, count))
691 return(NULL);
692 /*
693 * Now encode the result...
694 */
695 l = (r0 >> 8);
696 *p++ = ascii64[(l >> 18) & 0x3f];
697 *p++ = ascii64[(l >> 12) & 0x3f];
698 *p++ = ascii64[(l >> 6) & 0x3f];
699 *p++ = ascii64[l & 0x3f];
700
701 l = (r0 << 16) | ((r1 >> 16) & 0xffff);
702 *p++ = ascii64[(l >> 18) & 0x3f];
703 *p++ = ascii64[(l >> 12) & 0x3f];
704 *p++ = ascii64[(l >> 6) & 0x3f];
705 *p++ = ascii64[l & 0x3f];
706
707 l = r1 << 2;
708 *p++ = ascii64[(l >> 12) & 0x3f];
709 *p++ = ascii64[(l >> 6) & 0x3f];
710 *p++ = ascii64[l & 0x3f];
711 *p = 0;
712
713 return((char *)output);
714}
diff --git a/src/lib/libc/crypt/md5crypt.c b/src/lib/libc/crypt/md5crypt.c
new file mode 100644
index 0000000000..7ec60f38e0
--- /dev/null
+++ b/src/lib/libc/crypt/md5crypt.c
@@ -0,0 +1,157 @@
1/* $OpenBSD: md5crypt.c,v 1.9 1997/07/23 20:58:27 kstailey Exp $ */
2
3/*
4 * ----------------------------------------------------------------------------
5 * "THE BEER-WARE LICENSE" (Revision 42):
6 * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
7 * can do whatever you want with this stuff. If we meet some day, and you think
8 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
9 * ----------------------------------------------------------------------------
10 *
11 * $FreeBSD: crypt.c,v 1.5 1996/10/14 08:34:02 phk Exp $
12 *
13 */
14
15#if defined(LIBC_SCCS) && !defined(lint)
16static char rcsid[] = "$OpenBSD: md5crypt.c,v 1.9 1997/07/23 20:58:27 kstailey Exp $";
17#endif /* LIBC_SCCS and not lint */
18
19#include <unistd.h>
20#include <stdio.h>
21#include <string.h>
22#include <md5.h>
23#include <string.h>
24
25static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */
26 "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
27
28static void to64 __P((char *, u_int32_t, int));
29
30static void
31to64(s, v, n)
32 char *s;
33 u_int32_t v;
34 int n;
35{
36 while (--n >= 0) {
37 *s++ = itoa64[v&0x3f];
38 v >>= 6;
39 }
40}
41
42/*
43 * UNIX password
44 *
45 * Use MD5 for what it is best at...
46 */
47
48char *
49md5crypt(pw, salt)
50 register const char *pw;
51 register const char *salt;
52{
53 /*
54 * This string is magic for this algorithm. Having
55 * it this way, we can get get better later on
56 */
57 static unsigned char *magic = (unsigned char *)"$1$";
58
59 static char passwd[120], *p;
60 static const unsigned char *sp,*ep;
61 unsigned char final[16];
62 int sl,pl,i;
63 MD5_CTX ctx,ctx1;
64 u_int32_t l;
65
66 /* Refine the Salt first */
67 sp = (const unsigned char *)salt;
68
69 /* If it starts with the magic string, then skip that */
70 if(!strncmp((const char *)sp,(const char *)magic,strlen((const char *)magic)))
71 sp += strlen((const char *)magic);
72
73 /* It stops at the first '$', max 8 chars */
74 for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
75 continue;
76
77 /* get the length of the true salt */
78 sl = ep - sp;
79
80 MD5Init(&ctx);
81
82 /* The password first, since that is what is most unknown */
83 MD5Update(&ctx,(const unsigned char *)pw,strlen(pw));
84
85 /* Then our magic string */
86 MD5Update(&ctx,magic,strlen((const char *)magic));
87
88 /* Then the raw salt */
89 MD5Update(&ctx,sp,sl);
90
91 /* Then just as many characters of the MD5(pw,salt,pw) */
92 MD5Init(&ctx1);
93 MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
94 MD5Update(&ctx1,sp,sl);
95 MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
96 MD5Final(final,&ctx1);
97 for(pl = strlen(pw); pl > 0; pl -= 16)
98 MD5Update(&ctx,final,pl>16 ? 16 : pl);
99
100 /* Don't leave anything around in vm they could use. */
101 memset(final,0,sizeof final);
102
103 /* Then something really weird... */
104 for (i = strlen(pw); i ; i >>= 1)
105 if(i&1)
106 MD5Update(&ctx, final, 1);
107 else
108 MD5Update(&ctx, (const unsigned char *)pw, 1);
109
110 /* Now make the output string */
111 strcpy(passwd,(const char *)magic);
112 strncat(passwd,(const char *)sp,sl);
113 strcat(passwd,"$");
114
115 MD5Final(final,&ctx);
116
117 /*
118 * and now, just to make sure things don't run too fast
119 * On a 60 Mhz Pentium this takes 34 msec, so you would
120 * need 30 seconds to build a 1000 entry dictionary...
121 */
122 for(i=0;i<1000;i++) {
123 MD5Init(&ctx1);
124 if(i & 1)
125 MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
126 else
127 MD5Update(&ctx1,final,16);
128
129 if(i % 3)
130 MD5Update(&ctx1,sp,sl);
131
132 if(i % 7)
133 MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
134
135 if(i & 1)
136 MD5Update(&ctx1,final,16);
137 else
138 MD5Update(&ctx1,(const unsigned char *)pw,strlen(pw));
139 MD5Final(final,&ctx1);
140 }
141
142 p = passwd + strlen(passwd);
143
144 l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; to64(p,l,4); p += 4;
145 l = (final[ 1]<<16) | (final[ 7]<<8) | final[13]; to64(p,l,4); p += 4;
146 l = (final[ 2]<<16) | (final[ 8]<<8) | final[14]; to64(p,l,4); p += 4;
147 l = (final[ 3]<<16) | (final[ 9]<<8) | final[15]; to64(p,l,4); p += 4;
148 l = (final[ 4]<<16) | (final[10]<<8) | final[ 5]; to64(p,l,4); p += 4;
149 l = final[11] ; to64(p,l,2); p += 2;
150 *p = '\0';
151
152 /* Don't leave anything around in vm they could use. */
153 memset(final,0,sizeof final);
154
155 return passwd;
156}
157
diff --git a/src/lib/libc/crypt/morecrypt.c b/src/lib/libc/crypt/morecrypt.c
new file mode 100644
index 0000000000..e9e0ced4c1
--- /dev/null
+++ b/src/lib/libc/crypt/morecrypt.c
@@ -0,0 +1,628 @@
1/* $OpenBSD: morecrypt.c,v 1.9 1998/03/22 19:01:20 niklas Exp $ */
2
3/*
4 * FreeSec: libcrypt
5 *
6 * Copyright (c) 1994 David Burren
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 4. Neither the name of the author nor the names of other contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 *
34 * This is an original implementation of the DES and the crypt(3) interfaces
35 * by David Burren <davidb@werj.com.au>.
36 *
37 * An excellent reference on the underlying algorithm (and related
38 * algorithms) is:
39 *
40 * B. Schneier, Applied Cryptography: protocols, algorithms,
41 * and source code in C, John Wiley & Sons, 1994.
42 *
43 * Note that in that book's description of DES the lookups for the initial,
44 * pbox, and final permutations are inverted (this has been brought to the
45 * attention of the author). A list of errata for this book has been
46 * posted to the sci.crypt newsgroup by the author and is available for FTP.
47 *
48 * NOTE:
49 * This file must copy certain chunks of crypt.c for legal reasons.
50 * crypt.c can only export the interface crypt(), to make binaries
51 * exportable from the USA. Hence, to also have the other crypto interfaces
52 * available we have to copy pieces...
53 */
54
55#if defined(LIBC_SCCS) && !defined(lint)
56static char rcsid[] = "$OpenBSD: morecrypt.c,v 1.9 1998/03/22 19:01:20 niklas Exp $";
57#endif /* LIBC_SCCS and not lint */
58
59#include <sys/types.h>
60#include <sys/param.h>
61#include <pwd.h>
62#include <string.h>
63
64#ifdef DEBUG
65# include <stdio.h>
66#endif
67
68static u_char IP[64] = {
69 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4,
70 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8,
71 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3,
72 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7
73};
74
75static u_char inv_key_perm[64];
76static u_char u_key_perm[56];
77static u_char key_perm[56] = {
78 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
79 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36,
80 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22,
81 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
82};
83
84static u_char key_shifts[16] = {
85 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
86};
87
88static u_char inv_comp_perm[56];
89static u_char comp_perm[48] = {
90 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10,
91 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2,
92 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
93 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
94};
95
96/*
97 * No E box is used, as it's replaced by some ANDs, shifts, and ORs.
98 */
99
100static u_char u_sbox[8][64];
101static u_char sbox[8][64] = {
102 {
103 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
104 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
105 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
106 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13
107 },
108 {
109 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
110 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
111 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
112 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9
113 },
114 {
115 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
116 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
117 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
118 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12
119 },
120 {
121 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
122 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
123 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
124 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14
125 },
126 {
127 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
128 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
129 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
130 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3
131 },
132 {
133 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
134 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
135 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
136 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13
137 },
138 {
139 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
140 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
141 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
142 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12
143 },
144 {
145 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
146 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
147 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
148 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11
149 }
150};
151
152static u_char un_pbox[32];
153static u_char pbox[32] = {
154 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
155 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25
156};
157
158static u_int32_t bits32[32] =
159{
160 0x80000000, 0x40000000, 0x20000000, 0x10000000,
161 0x08000000, 0x04000000, 0x02000000, 0x01000000,
162 0x00800000, 0x00400000, 0x00200000, 0x00100000,
163 0x00080000, 0x00040000, 0x00020000, 0x00010000,
164 0x00008000, 0x00004000, 0x00002000, 0x00001000,
165 0x00000800, 0x00000400, 0x00000200, 0x00000100,
166 0x00000080, 0x00000040, 0x00000020, 0x00000010,
167 0x00000008, 0x00000004, 0x00000002, 0x00000001
168};
169
170static u_char bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
171
172static u_int32_t saltbits;
173static int32_t old_salt;
174static u_int32_t *bits28, *bits24;
175static u_char init_perm[64], final_perm[64];
176static u_int32_t en_keysl[16], en_keysr[16];
177static u_int32_t de_keysl[16], de_keysr[16];
178static int des_initialised = 0;
179static u_char m_sbox[4][4096];
180static u_int32_t psbox[4][256];
181static u_int32_t ip_maskl[8][256], ip_maskr[8][256];
182static u_int32_t fp_maskl[8][256], fp_maskr[8][256];
183static u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128];
184static u_int32_t comp_maskl[8][128], comp_maskr[8][128];
185static u_int32_t old_rawkey0, old_rawkey1;
186
187static __inline int
188ascii_to_bin(ch)
189 char ch;
190{
191 if (ch > 'z')
192 return(0);
193 if (ch >= 'a')
194 return(ch - 'a' + 38);
195 if (ch > 'Z')
196 return(0);
197 if (ch >= 'A')
198 return(ch - 'A' + 12);
199 if (ch > '9')
200 return(0);
201 if (ch >= '.')
202 return(ch - '.');
203 return(0);
204}
205
206void
207des_init()
208{
209 int i, j, b, k, inbit, obit;
210 u_int32_t *p, *il, *ir, *fl, *fr;
211
212 old_rawkey0 = old_rawkey1 = 0;
213 saltbits = 0;
214 old_salt = 0;
215 bits24 = (bits28 = bits32 + 4) + 4;
216
217 /*
218 * Invert the S-boxes, reordering the input bits.
219 */
220 for (i = 0; i < 8; i++)
221 for (j = 0; j < 64; j++) {
222 b = (j & 0x20) | ((j & 1) << 4) | ((j >> 1) & 0xf);
223 u_sbox[i][j] = sbox[i][b];
224 }
225
226 /*
227 * Convert the inverted S-boxes into 4 arrays of 8 bits.
228 * Each will handle 12 bits of the S-box input.
229 */
230 for (b = 0; b < 4; b++)
231 for (i = 0; i < 64; i++)
232 for (j = 0; j < 64; j++)
233 m_sbox[b][(i << 6) | j] =
234 (u_sbox[(b << 1)][i] << 4) |
235 u_sbox[(b << 1) + 1][j];
236
237 /*
238 * Set up the initial & final permutations into a useful form, and
239 * initialise the inverted key permutation.
240 */
241 for (i = 0; i < 64; i++) {
242 init_perm[final_perm[i] = IP[i] - 1] = i;
243 inv_key_perm[i] = 255;
244 }
245
246 /*
247 * Invert the key permutation and initialise the inverted key
248 * compression permutation.
249 */
250 for (i = 0; i < 56; i++) {
251 u_key_perm[i] = key_perm[i] - 1;
252 inv_key_perm[key_perm[i] - 1] = i;
253 inv_comp_perm[i] = 255;
254 }
255
256 /*
257 * Invert the key compression permutation.
258 */
259 for (i = 0; i < 48; i++) {
260 inv_comp_perm[comp_perm[i] - 1] = i;
261 }
262
263 /*
264 * Set up the OR-mask arrays for the initial and final permutations,
265 * and for the key initial and compression permutations.
266 */
267 for (k = 0; k < 8; k++) {
268 for (i = 0; i < 256; i++) {
269 *(il = &ip_maskl[k][i]) = 0;
270 *(ir = &ip_maskr[k][i]) = 0;
271 *(fl = &fp_maskl[k][i]) = 0;
272 *(fr = &fp_maskr[k][i]) = 0;
273 for (j = 0; j < 8; j++) {
274 inbit = 8 * k + j;
275 if (i & bits8[j]) {
276 if ((obit = init_perm[inbit]) < 32)
277 *il |= bits32[obit];
278 else
279 *ir |= bits32[obit-32];
280 if ((obit = final_perm[inbit]) < 32)
281 *fl |= bits32[obit];
282 else
283 *fr |= bits32[obit - 32];
284 }
285 }
286 }
287 for (i = 0; i < 128; i++) {
288 *(il = &key_perm_maskl[k][i]) = 0;
289 *(ir = &key_perm_maskr[k][i]) = 0;
290 for (j = 0; j < 7; j++) {
291 inbit = 8 * k + j;
292 if (i & bits8[j + 1]) {
293 if ((obit = inv_key_perm[inbit]) == 255)
294 continue;
295 if (obit < 28)
296 *il |= bits28[obit];
297 else
298 *ir |= bits28[obit - 28];
299 }
300 }
301 *(il = &comp_maskl[k][i]) = 0;
302 *(ir = &comp_maskr[k][i]) = 0;
303 for (j = 0; j < 7; j++) {
304 inbit = 7 * k + j;
305 if (i & bits8[j + 1]) {
306 if ((obit=inv_comp_perm[inbit]) == 255)
307 continue;
308 if (obit < 24)
309 *il |= bits24[obit];
310 else
311 *ir |= bits24[obit - 24];
312 }
313 }
314 }
315 }
316
317 /*
318 * Invert the P-box permutation, and convert into OR-masks for
319 * handling the output of the S-box arrays setup above.
320 */
321 for (i = 0; i < 32; i++)
322 un_pbox[pbox[i] - 1] = i;
323
324 for (b = 0; b < 4; b++)
325 for (i = 0; i < 256; i++) {
326 *(p = &psbox[b][i]) = 0;
327 for (j = 0; j < 8; j++) {
328 if (i & bits8[j])
329 *p |= bits32[un_pbox[8 * b + j]];
330 }
331 }
332
333 des_initialised = 1;
334}
335
336void
337setup_salt(salt)
338 int32_t salt;
339{
340 u_int32_t obit, saltbit;
341 int i;
342
343 if (salt == old_salt)
344 return;
345 old_salt = salt;
346
347 saltbits = 0;
348 saltbit = 1;
349 obit = 0x800000;
350 for (i = 0; i < 24; i++) {
351 if (salt & saltbit)
352 saltbits |= obit;
353 saltbit <<= 1;
354 obit >>= 1;
355 }
356}
357
358int
359do_des(l_in, r_in, l_out, r_out, count)
360 u_int32_t l_in, r_in, *l_out, *r_out;
361 int count;
362{
363 /*
364 * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format.
365 */
366 u_int32_t l, r, *kl, *kr, *kl1, *kr1;
367 u_int32_t f, r48l, r48r;
368 int round;
369
370 if (count == 0) {
371 return(1);
372 } else if (count > 0) {
373 /*
374 * Encrypting
375 */
376 kl1 = en_keysl;
377 kr1 = en_keysr;
378 } else {
379 /*
380 * Decrypting
381 */
382 count = -count;
383 kl1 = de_keysl;
384 kr1 = de_keysr;
385 }
386
387 /*
388 * Do initial permutation (IP).
389 */
390 l = ip_maskl[0][l_in >> 24]
391 | ip_maskl[1][(l_in >> 16) & 0xff]
392 | ip_maskl[2][(l_in >> 8) & 0xff]
393 | ip_maskl[3][l_in & 0xff]
394 | ip_maskl[4][r_in >> 24]
395 | ip_maskl[5][(r_in >> 16) & 0xff]
396 | ip_maskl[6][(r_in >> 8) & 0xff]
397 | ip_maskl[7][r_in & 0xff];
398 r = ip_maskr[0][l_in >> 24]
399 | ip_maskr[1][(l_in >> 16) & 0xff]
400 | ip_maskr[2][(l_in >> 8) & 0xff]
401 | ip_maskr[3][l_in & 0xff]
402 | ip_maskr[4][r_in >> 24]
403 | ip_maskr[5][(r_in >> 16) & 0xff]
404 | ip_maskr[6][(r_in >> 8) & 0xff]
405 | ip_maskr[7][r_in & 0xff];
406
407 while (count--) {
408 /*
409 * Do each round.
410 */
411 kl = kl1;
412 kr = kr1;
413 round = 16;
414 while (round--) {
415 /*
416 * Expand R to 48 bits (simulate the E-box).
417 */
418 r48l = ((r & 0x00000001) << 23)
419 | ((r & 0xf8000000) >> 9)
420 | ((r & 0x1f800000) >> 11)
421 | ((r & 0x01f80000) >> 13)
422 | ((r & 0x001f8000) >> 15);
423
424 r48r = ((r & 0x0001f800) << 7)
425 | ((r & 0x00001f80) << 5)
426 | ((r & 0x000001f8) << 3)
427 | ((r & 0x0000001f) << 1)
428 | ((r & 0x80000000) >> 31);
429 /*
430 * Do salting for crypt() and friends, and
431 * XOR with the permuted key.
432 */
433 f = (r48l ^ r48r) & saltbits;
434 r48l ^= f ^ *kl++;
435 r48r ^= f ^ *kr++;
436 /*
437 * Do sbox lookups (which shrink it back to 32 bits)
438 * and do the pbox permutation at the same time.
439 */
440 f = psbox[0][m_sbox[0][r48l >> 12]]
441 | psbox[1][m_sbox[1][r48l & 0xfff]]
442 | psbox[2][m_sbox[2][r48r >> 12]]
443 | psbox[3][m_sbox[3][r48r & 0xfff]];
444 /*
445 * Now that we've permuted things, complete f().
446 */
447 f ^= l;
448 l = r;
449 r = f;
450 }
451 r = l;
452 l = f;
453 }
454 /*
455 * Do final permutation (inverse of IP).
456 */
457 *l_out = fp_maskl[0][l >> 24]
458 | fp_maskl[1][(l >> 16) & 0xff]
459 | fp_maskl[2][(l >> 8) & 0xff]
460 | fp_maskl[3][l & 0xff]
461 | fp_maskl[4][r >> 24]
462 | fp_maskl[5][(r >> 16) & 0xff]
463 | fp_maskl[6][(r >> 8) & 0xff]
464 | fp_maskl[7][r & 0xff];
465 *r_out = fp_maskr[0][l >> 24]
466 | fp_maskr[1][(l >> 16) & 0xff]
467 | fp_maskr[2][(l >> 8) & 0xff]
468 | fp_maskr[3][l & 0xff]
469 | fp_maskr[4][r >> 24]
470 | fp_maskr[5][(r >> 16) & 0xff]
471 | fp_maskr[6][(r >> 8) & 0xff]
472 | fp_maskr[7][r & 0xff];
473 return(0);
474}
475
476int
477des_cipher(in, out, salt, count)
478 const char *in;
479 char *out;
480 long salt;
481 int count;
482{
483 u_int32_t l_out, r_out, rawl, rawr;
484 u_int32_t x[2];
485 int retval;
486
487 if (!des_initialised)
488 des_init();
489
490 setup_salt((int32_t)salt);
491
492 memcpy(x, in, sizeof x);
493 rawl = ntohl(x[0]);
494 rawr = ntohl(x[1]);
495 retval = do_des(rawl, rawr, &l_out, &r_out, count);
496
497 x[0] = htonl(l_out);
498 x[1] = htonl(r_out);
499 memcpy(out, x, sizeof x);
500 return(retval);
501}
502
503int
504des_setkey(key)
505 const char *key;
506{
507 u_int32_t k0, k1, rawkey0, rawkey1;
508 int shifts, round;
509
510 if (!des_initialised)
511 des_init();
512
513 rawkey0 = ntohl(*(u_int32_t *) key);
514 rawkey1 = ntohl(*(u_int32_t *) (key + 4));
515
516 if ((rawkey0 | rawkey1)
517 && rawkey0 == old_rawkey0
518 && rawkey1 == old_rawkey1) {
519 /*
520 * Already setup for this key.
521 * This optimisation fails on a zero key (which is weak and
522 * has bad parity anyway) in order to simplify the starting
523 * conditions.
524 */
525 return(0);
526 }
527 old_rawkey0 = rawkey0;
528 old_rawkey1 = rawkey1;
529
530 /*
531 * Do key permutation and split into two 28-bit subkeys.
532 */
533 k0 = key_perm_maskl[0][rawkey0 >> 25]
534 | key_perm_maskl[1][(rawkey0 >> 17) & 0x7f]
535 | key_perm_maskl[2][(rawkey0 >> 9) & 0x7f]
536 | key_perm_maskl[3][(rawkey0 >> 1) & 0x7f]
537 | key_perm_maskl[4][rawkey1 >> 25]
538 | key_perm_maskl[5][(rawkey1 >> 17) & 0x7f]
539 | key_perm_maskl[6][(rawkey1 >> 9) & 0x7f]
540 | key_perm_maskl[7][(rawkey1 >> 1) & 0x7f];
541 k1 = key_perm_maskr[0][rawkey0 >> 25]
542 | key_perm_maskr[1][(rawkey0 >> 17) & 0x7f]
543 | key_perm_maskr[2][(rawkey0 >> 9) & 0x7f]
544 | key_perm_maskr[3][(rawkey0 >> 1) & 0x7f]
545 | key_perm_maskr[4][rawkey1 >> 25]
546 | key_perm_maskr[5][(rawkey1 >> 17) & 0x7f]
547 | key_perm_maskr[6][(rawkey1 >> 9) & 0x7f]
548 | key_perm_maskr[7][(rawkey1 >> 1) & 0x7f];
549 /*
550 * Rotate subkeys and do compression permutation.
551 */
552 shifts = 0;
553 for (round = 0; round < 16; round++) {
554 u_int32_t t0, t1;
555
556 shifts += key_shifts[round];
557
558 t0 = (k0 << shifts) | (k0 >> (28 - shifts));
559 t1 = (k1 << shifts) | (k1 >> (28 - shifts));
560
561 de_keysl[15 - round] =
562 en_keysl[round] = comp_maskl[0][(t0 >> 21) & 0x7f]
563 | comp_maskl[1][(t0 >> 14) & 0x7f]
564 | comp_maskl[2][(t0 >> 7) & 0x7f]
565 | comp_maskl[3][t0 & 0x7f]
566 | comp_maskl[4][(t1 >> 21) & 0x7f]
567 | comp_maskl[5][(t1 >> 14) & 0x7f]
568 | comp_maskl[6][(t1 >> 7) & 0x7f]
569 | comp_maskl[7][t1 & 0x7f];
570
571 de_keysr[15 - round] =
572 en_keysr[round] = comp_maskr[0][(t0 >> 21) & 0x7f]
573 | comp_maskr[1][(t0 >> 14) & 0x7f]
574 | comp_maskr[2][(t0 >> 7) & 0x7f]
575 | comp_maskr[3][t0 & 0x7f]
576 | comp_maskr[4][(t1 >> 21) & 0x7f]
577 | comp_maskr[5][(t1 >> 14) & 0x7f]
578 | comp_maskr[6][(t1 >> 7) & 0x7f]
579 | comp_maskr[7][t1 & 0x7f];
580 }
581 return(0);
582}
583
584int
585setkey(key)
586 const char *key;
587{
588 int i, j;
589 u_int32_t packed_keys[2];
590 u_char *p;
591
592 p = (u_char *) packed_keys;
593
594 for (i = 0; i < 8; i++) {
595 p[i] = 0;
596 for (j = 0; j < 8; j++)
597 if (*key++ & 1)
598 p[i] |= bits8[j];
599 }
600 return(des_setkey(p));
601}
602
603int
604encrypt(block, flag)
605 char *block;
606 int flag;
607{
608 u_int32_t io[2];
609 u_char *p;
610 int i, j, retval;
611
612 if (!des_initialised)
613 des_init();
614
615 setup_salt((int32_t)0);
616 p = (u_char *)block;
617 for (i = 0; i < 2; i++) {
618 io[i] = 0L;
619 for (j = 0; j < 32; j++)
620 if (*p++ & 1)
621 io[i] |= bits32[j];
622 }
623 retval = do_des(io[0], io[1], io, io + 1, flag ? -1 : 1);
624 for (i = 0; i < 2; i++)
625 for (j = 0; j < 32; j++)
626 block[(i << 5) | j] = (io[i] & bits32[j]) ? 1 : 0;
627 return(retval);
628}
diff --git a/src/lib/libc/crypt/skipjack.c b/src/lib/libc/crypt/skipjack.c
new file mode 100644
index 0000000000..e700f40c39
--- /dev/null
+++ b/src/lib/libc/crypt/skipjack.c
@@ -0,0 +1,258 @@
1/*
2 * Further optimized test implementation of SKIPJACK algorithm
3 * Mark Tillotson <markt@chaos.org.uk>, 25 June 98
4 * Optimizations suit RISC (lots of registers) machine best.
5 *
6 * based on unoptimized implementation of
7 * Panu Rissanen <bande@lut.fi> 960624
8 *
9 * SKIPJACK and KEA Algorithm Specifications
10 * Version 2.0
11 * 29 May 1998
12*/
13
14#include <sys/param.h>
15#include <skipjack.h>
16#include <stdlib.h>
17
18static const u_int8_t ftable[0x100] =
19{
20 0xa3, 0xd7, 0x09, 0x83, 0xf8, 0x48, 0xf6, 0xf4,
21 0xb3, 0x21, 0x15, 0x78, 0x99, 0xb1, 0xaf, 0xf9,
22 0xe7, 0x2d, 0x4d, 0x8a, 0xce, 0x4c, 0xca, 0x2e,
23 0x52, 0x95, 0xd9, 0x1e, 0x4e, 0x38, 0x44, 0x28,
24 0x0a, 0xdf, 0x02, 0xa0, 0x17, 0xf1, 0x60, 0x68,
25 0x12, 0xb7, 0x7a, 0xc3, 0xe9, 0xfa, 0x3d, 0x53,
26 0x96, 0x84, 0x6b, 0xba, 0xf2, 0x63, 0x9a, 0x19,
27 0x7c, 0xae, 0xe5, 0xf5, 0xf7, 0x16, 0x6a, 0xa2,
28 0x39, 0xb6, 0x7b, 0x0f, 0xc1, 0x93, 0x81, 0x1b,
29 0xee, 0xb4, 0x1a, 0xea, 0xd0, 0x91, 0x2f, 0xb8,
30 0x55, 0xb9, 0xda, 0x85, 0x3f, 0x41, 0xbf, 0xe0,
31 0x5a, 0x58, 0x80, 0x5f, 0x66, 0x0b, 0xd8, 0x90,
32 0x35, 0xd5, 0xc0, 0xa7, 0x33, 0x06, 0x65, 0x69,
33 0x45, 0x00, 0x94, 0x56, 0x6d, 0x98, 0x9b, 0x76,
34 0x97, 0xfc, 0xb2, 0xc2, 0xb0, 0xfe, 0xdb, 0x20,
35 0xe1, 0xeb, 0xd6, 0xe4, 0xdd, 0x47, 0x4a, 0x1d,
36 0x42, 0xed, 0x9e, 0x6e, 0x49, 0x3c, 0xcd, 0x43,
37 0x27, 0xd2, 0x07, 0xd4, 0xde, 0xc7, 0x67, 0x18,
38 0x89, 0xcb, 0x30, 0x1f, 0x8d, 0xc6, 0x8f, 0xaa,
39 0xc8, 0x74, 0xdc, 0xc9, 0x5d, 0x5c, 0x31, 0xa4,
40 0x70, 0x88, 0x61, 0x2c, 0x9f, 0x0d, 0x2b, 0x87,
41 0x50, 0x82, 0x54, 0x64, 0x26, 0x7d, 0x03, 0x40,
42 0x34, 0x4b, 0x1c, 0x73, 0xd1, 0xc4, 0xfd, 0x3b,
43 0xcc, 0xfb, 0x7f, 0xab, 0xe6, 0x3e, 0x5b, 0xa5,
44 0xad, 0x04, 0x23, 0x9c, 0x14, 0x51, 0x22, 0xf0,
45 0x29, 0x79, 0x71, 0x7e, 0xff, 0x8c, 0x0e, 0xe2,
46 0x0c, 0xef, 0xbc, 0x72, 0x75, 0x6f, 0x37, 0xa1,
47 0xec, 0xd3, 0x8e, 0x62, 0x8b, 0x86, 0x10, 0xe8,
48 0x08, 0x77, 0x11, 0xbe, 0x92, 0x4f, 0x24, 0xc5,
49 0x32, 0x36, 0x9d, 0xcf, 0xf3, 0xa6, 0xbb, 0xac,
50 0x5e, 0x6c, 0xa9, 0x13, 0x57, 0x25, 0xb5, 0xe3,
51 0xbd, 0xa8, 0x3a, 0x01, 0x05, 0x59, 0x2a, 0x46
52};
53
54/*
55 * For each key byte generate a table to represent the function
56 * ftable [in ^ keybyte]
57 *
58 * These tables used to save an XOR in each stage of the G-function
59 * the tables are hopefully pointed to by register allocated variables
60 * k0, k1..k9
61 */
62void
63subkey_table_gen (u_int8_t *key, u_int8_t **key_tables)
64{
65 int i, k;
66
67 for (k = 0; k < 10; k++) {
68 u_int8_t key_byte = key[k];
69 u_int8_t * table = (u_int8_t *) malloc(0x100);
70 /* XXX */
71
72 key_tables[k] = table;
73 for (i = 0; i < 0x100; i++)
74 table[i] = ftable[i ^ key_byte];
75 }
76}
77
78
79#define g(k0, k1, k2, k3, ih, il, oh, ol) \
80{ \
81 oh = k##k0 [il] ^ ih; \
82 ol = k##k1 [oh] ^ il; \
83 oh = k##k2 [ol] ^ oh; \
84 ol = k##k3 [oh] ^ ol; \
85}
86
87#define g0(ih, il, oh, ol) g(0, 1, 2, 3, ih, il, oh, ol)
88#define g4(ih, il, oh, ol) g(4, 5, 6, 7, ih, il, oh, ol)
89#define g8(ih, il, oh, ol) g(8, 9, 0, 1, ih, il, oh, ol)
90#define g2(ih, il, oh, ol) g(2, 3, 4, 5, ih, il, oh, ol)
91#define g6(ih, il, oh, ol) g(6, 7, 8, 9, ih, il, oh, ol)
92
93
94#define g_inv(k0, k1, k2, k3, ih, il, oh, ol) \
95{ \
96 ol = k##k3 [ih] ^ il; \
97 oh = k##k2 [ol] ^ ih; \
98 ol = k##k1 [oh] ^ ol; \
99 oh = k##k0 [ol] ^ oh; \
100}
101
102
103#define g0_inv(ih, il, oh, ol) g_inv(0, 1, 2, 3, ih, il, oh, ol)
104#define g4_inv(ih, il, oh, ol) g_inv(4, 5, 6, 7, ih, il, oh, ol)
105#define g8_inv(ih, il, oh, ol) g_inv(8, 9, 0, 1, ih, il, oh, ol)
106#define g2_inv(ih, il, oh, ol) g_inv(2, 3, 4, 5, ih, il, oh, ol)
107#define g6_inv(ih, il, oh, ol) g_inv(6, 7, 8, 9, ih, il, oh, ol)
108
109/* optimized version of Skipjack algorithm
110 *
111 * the appropriate g-function is inlined for each round
112 *
113 * the data movement is minimized by rotating the names of the
114 * variables w1..w4, not their contents (saves 3 moves per round)
115 *
116 * the loops are completely unrolled (needed to staticize choice of g)
117 *
118 * compiles to about 470 instructions on a Sparc (gcc -O)
119 * which is about 58 instructions per byte, 14 per round.
120 * gcc seems to leave in some unnecessary and with 0xFF operations
121 * but only in the latter part of the functions. Perhaps it
122 * runs out of resources to properly optimize long inlined function?
123 * in theory should get about 11 instructions per round, not 14
124 */
125
126void
127skipjack_forwards(u_int8_t *plain, u_int8_t *cipher, u_int8_t **key_tables)
128{
129 u_int8_t wh1 = plain[0]; u_int8_t wl1 = plain[1];
130 u_int8_t wh2 = plain[2]; u_int8_t wl2 = plain[3];
131 u_int8_t wh3 = plain[4]; u_int8_t wl3 = plain[5];
132 u_int8_t wh4 = plain[6]; u_int8_t wl4 = plain[7];
133
134 u_int8_t * k0 = key_tables [0];
135 u_int8_t * k1 = key_tables [1];
136 u_int8_t * k2 = key_tables [2];
137 u_int8_t * k3 = key_tables [3];
138 u_int8_t * k4 = key_tables [4];
139 u_int8_t * k5 = key_tables [5];
140 u_int8_t * k6 = key_tables [6];
141 u_int8_t * k7 = key_tables [7];
142 u_int8_t * k8 = key_tables [8];
143 u_int8_t * k9 = key_tables [9];
144
145 /* first 8 rounds */
146 g0 (wh1,wl1, wh1,wl1); wl4 ^= wl1 ^ 1; wh4 ^= wh1;
147 g4 (wh4,wl4, wh4,wl4); wl3 ^= wl4 ^ 2; wh3 ^= wh4;
148 g8 (wh3,wl3, wh3,wl3); wl2 ^= wl3 ^ 3; wh2 ^= wh3;
149 g2 (wh2,wl2, wh2,wl2); wl1 ^= wl2 ^ 4; wh1 ^= wh2;
150 g6 (wh1,wl1, wh1,wl1); wl4 ^= wl1 ^ 5; wh4 ^= wh1;
151 g0 (wh4,wl4, wh4,wl4); wl3 ^= wl4 ^ 6; wh3 ^= wh4;
152 g4 (wh3,wl3, wh3,wl3); wl2 ^= wl3 ^ 7; wh2 ^= wh3;
153 g8 (wh2,wl2, wh2,wl2); wl1 ^= wl2 ^ 8; wh1 ^= wh2;
154
155 /* second 8 rounds */
156 wh2 ^= wh1; wl2 ^= wl1 ^ 9 ; g2 (wh1,wl1, wh1,wl1);
157 wh1 ^= wh4; wl1 ^= wl4 ^ 10; g6 (wh4,wl4, wh4,wl4);
158 wh4 ^= wh3; wl4 ^= wl3 ^ 11; g0 (wh3,wl3, wh3,wl3);
159 wh3 ^= wh2; wl3 ^= wl2 ^ 12; g4 (wh2,wl2, wh2,wl2);
160 wh2 ^= wh1; wl2 ^= wl1 ^ 13; g8 (wh1,wl1, wh1,wl1);
161 wh1 ^= wh4; wl1 ^= wl4 ^ 14; g2 (wh4,wl4, wh4,wl4);
162 wh4 ^= wh3; wl4 ^= wl3 ^ 15; g6 (wh3,wl3, wh3,wl3);
163 wh3 ^= wh2; wl3 ^= wl2 ^ 16; g0 (wh2,wl2, wh2,wl2);
164
165 /* third 8 rounds */
166 g4 (wh1,wl1, wh1,wl1); wl4 ^= wl1 ^ 17; wh4 ^= wh1;
167 g8 (wh4,wl4, wh4,wl4); wl3 ^= wl4 ^ 18; wh3 ^= wh4;
168 g2 (wh3,wl3, wh3,wl3); wl2 ^= wl3 ^ 19; wh2 ^= wh3;
169 g6 (wh2,wl2, wh2,wl2); wl1 ^= wl2 ^ 20; wh1 ^= wh2;
170 g0 (wh1,wl1, wh1,wl1); wl4 ^= wl1 ^ 21; wh4 ^= wh1;
171 g4 (wh4,wl4, wh4,wl4); wl3 ^= wl4 ^ 22; wh3 ^= wh4;
172 g8 (wh3,wl3, wh3,wl3); wl2 ^= wl3 ^ 23; wh2 ^= wh3;
173 g2 (wh2,wl2, wh2,wl2); wl1 ^= wl2 ^ 24; wh1 ^= wh2;
174
175 /* last 8 rounds */
176 wh2 ^= wh1; wl2 ^= wl1 ^ 25; g6 (wh1,wl1, wh1,wl1);
177 wh1 ^= wh4; wl1 ^= wl4 ^ 26; g0 (wh4,wl4, wh4,wl4);
178 wh4 ^= wh3; wl4 ^= wl3 ^ 27; g4 (wh3,wl3, wh3,wl3);
179 wh3 ^= wh2; wl3 ^= wl2 ^ 28; g8 (wh2,wl2, wh2,wl2);
180 wh2 ^= wh1; wl2 ^= wl1 ^ 29; g2 (wh1,wl1, wh1,wl1);
181 wh1 ^= wh4; wl1 ^= wl4 ^ 30; g6 (wh4,wl4, wh4,wl4);
182 wh4 ^= wh3; wl4 ^= wl3 ^ 31; g0 (wh3,wl3, wh3,wl3);
183 wh3 ^= wh2; wl3 ^= wl2 ^ 32; g4 (wh2,wl2, wh2,wl2);
184
185 /* pack into byte vector */
186 cipher [0] = wh1; cipher [1] = wl1;
187 cipher [2] = wh2; cipher [3] = wl2;
188 cipher [4] = wh3; cipher [5] = wl3;
189 cipher [6] = wh4; cipher [7] = wl4;
190}
191
192
193void
194skipjack_backwards (u_int8_t *cipher, u_int8_t *plain, u_int8_t **key_tables)
195{
196 /* setup 4 16-bit portions */
197 u_int8_t wh1 = cipher[0]; u_int8_t wl1 = cipher[1];
198 u_int8_t wh2 = cipher[2]; u_int8_t wl2 = cipher[3];
199 u_int8_t wh3 = cipher[4]; u_int8_t wl3 = cipher[5];
200 u_int8_t wh4 = cipher[6]; u_int8_t wl4 = cipher[7];
201
202 u_int8_t * k0 = key_tables [0];
203 u_int8_t * k1 = key_tables [1];
204 u_int8_t * k2 = key_tables [2];
205 u_int8_t * k3 = key_tables [3];
206 u_int8_t * k4 = key_tables [4];
207 u_int8_t * k5 = key_tables [5];
208 u_int8_t * k6 = key_tables [6];
209 u_int8_t * k7 = key_tables [7];
210 u_int8_t * k8 = key_tables [8];
211 u_int8_t * k9 = key_tables [9];
212
213 /* first 8 rounds */
214 g4_inv (wh2,wl2, wh2,wl2); wl3 ^= wl2 ^ 32; wh3 ^= wh2;
215 g0_inv (wh3,wl3, wh3,wl3); wl4 ^= wl3 ^ 31; wh4 ^= wh3;
216 g6_inv (wh4,wl4, wh4,wl4); wl1 ^= wl4 ^ 30; wh1 ^= wh4;
217 g2_inv (wh1,wl1, wh1,wl1); wl2 ^= wl1 ^ 29; wh2 ^= wh1;
218 g8_inv (wh2,wl2, wh2,wl2); wl3 ^= wl2 ^ 28; wh3 ^= wh2;
219 g4_inv (wh3,wl3, wh3,wl3); wl4 ^= wl3 ^ 27; wh4 ^= wh3;
220 g0_inv (wh4,wl4, wh4,wl4); wl1 ^= wl4 ^ 26; wh1 ^= wh4;
221 g6_inv (wh1,wl1, wh1,wl1); wl2 ^= wl1 ^ 25; wh2 ^= wh1;
222
223 /* second 8 rounds */
224 wh1 ^= wh2; wl1 ^= wl2 ^ 24; g2_inv (wh2,wl2, wh2,wl2);
225 wh2 ^= wh3; wl2 ^= wl3 ^ 23; g8_inv (wh3,wl3, wh3,wl3);
226 wh3 ^= wh4; wl3 ^= wl4 ^ 22; g4_inv (wh4,wl4, wh4,wl4);
227 wh4 ^= wh1; wl4 ^= wl1 ^ 21; g0_inv (wh1,wl1, wh1,wl1);
228 wh1 ^= wh2; wl1 ^= wl2 ^ 20; g6_inv (wh2,wl2, wh2,wl2);
229 wh2 ^= wh3; wl2 ^= wl3 ^ 19; g2_inv (wh3,wl3, wh3,wl3);
230 wh3 ^= wh4; wl3 ^= wl4 ^ 18; g8_inv (wh4,wl4, wh4,wl4);
231 wh4 ^= wh1; wl4 ^= wl1 ^ 17; g4_inv (wh1,wl1, wh1,wl1);
232
233 /* third 8 rounds */
234 g0_inv (wh2,wl2, wh2,wl2); wl3 ^= wl2 ^ 16; wh3 ^= wh2;
235 g6_inv (wh3,wl3, wh3,wl3); wl4 ^= wl3 ^ 15; wh4 ^= wh3;
236 g2_inv (wh4,wl4, wh4,wl4); wl1 ^= wl4 ^ 14; wh1 ^= wh4;
237 g8_inv (wh1,wl1, wh1,wl1); wl2 ^= wl1 ^ 13; wh2 ^= wh1;
238 g4_inv (wh2,wl2, wh2,wl2); wl3 ^= wl2 ^ 12; wh3 ^= wh2;
239 g0_inv (wh3,wl3, wh3,wl3); wl4 ^= wl3 ^ 11; wh4 ^= wh3;
240 g6_inv (wh4,wl4, wh4,wl4); wl1 ^= wl4 ^ 10; wh1 ^= wh4;
241 g2_inv (wh1,wl1, wh1,wl1); wl2 ^= wl1 ^ 9; wh2 ^= wh1;
242
243 /* last 8 rounds */
244 wh1 ^= wh2; wl1 ^= wl2 ^ 8; g8_inv (wh2,wl2, wh2,wl2);
245 wh2 ^= wh3; wl2 ^= wl3 ^ 7; g4_inv (wh3,wl3, wh3,wl3);
246 wh3 ^= wh4; wl3 ^= wl4 ^ 6; g0_inv (wh4,wl4, wh4,wl4);
247 wh4 ^= wh1; wl4 ^= wl1 ^ 5; g6_inv (wh1,wl1, wh1,wl1);
248 wh1 ^= wh2; wl1 ^= wl2 ^ 4; g2_inv (wh2,wl2, wh2,wl2);
249 wh2 ^= wh3; wl2 ^= wl3 ^ 3; g8_inv (wh3,wl3, wh3,wl3);
250 wh3 ^= wh4; wl3 ^= wl4 ^ 2; g4_inv (wh4,wl4, wh4,wl4);
251 wh4 ^= wh1; wl4 ^= wl1 ^ 1; g0_inv (wh1,wl1, wh1,wl1);
252
253 /* pack into byte vector */
254 plain [0] = wh1; plain [1] = wl1;
255 plain [2] = wh2; plain [3] = wl2;
256 plain [4] = wh3; plain [5] = wl3;
257 plain [6] = wh4; plain [7] = wl4;
258}
diff --git a/src/lib/libc/include/namespace.h b/src/lib/libc/include/namespace.h
new file mode 100644
index 0000000000..4a51f15ddf
--- /dev/null
+++ b/src/lib/libc/include/namespace.h
@@ -0,0 +1,18 @@
1/* $OpenBSD: namespace.h,v 1.2 1996/08/19 08:28:08 tholo Exp $ */
2
3#define catclose _catclose
4#define catgets _catgets
5#define catopen _catopen
6#define err _err
7#define errx _errx
8#define strtoq _strtoq
9#define strtouq _strtouq
10#define sys_errlist _sys_errlist
11#define sys_nerr _sys_nerr
12#define sys_siglist _sys_siglist
13#define verr _verr
14#define verrx _verrx
15#define vwarn _vwarn
16#define vwarnx _vwarnx
17#define warn _warn
18#define warnx _warnx
diff --git a/src/lib/libc/include/thread_private.h b/src/lib/libc/include/thread_private.h
new file mode 100644
index 0000000000..0027468269
--- /dev/null
+++ b/src/lib/libc/include/thread_private.h
@@ -0,0 +1,179 @@
1/*
2 *
3 * Support for thread-safety in libc and libc_r common code using macros
4 * to declare thread-safe data structures.
5 *
6 * $OpenBSD: thread_private.h,v 1.2 1999/01/06 05:19:32 d Exp $
7 */
8
9#ifndef _THREAD_PRIVATE_H_
10#define _THREAD_PRIVATE_H_
11
12/*
13 * Parts of this file are
14 * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
15 * All rights reserved.
16 *
17 * $Id: thread_private.h,v 1.2 1999/01/06 05:19:32 d Exp $
18 * $OpenBSD: thread_private.h,v 1.2 1999/01/06 05:19:32 d Exp $
19 */
20
21/*
22 * This global flag is non-zero when a process has created one
23 * or more threads. It is used to avoid calling locking functions
24 * when they are not required. In libc, this is always assumed
25 * to be zero.
26 */
27
28extern volatile int __isthreaded;
29
30#ifdef _THREAD_SAFE
31
32#include <pthread.h>
33#include "pthread_private.h"
34
35/*
36 * File lock contention is difficult to diagnose without knowing
37 * where locks were set. Allow a debug library to be built which
38 * records the source file and line number of each lock call.
39 */
40#ifdef _FLOCK_DEBUG
41#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__)
42#else
43#define _FLOCKFILE(x) flockfile(x)
44#endif
45
46/*
47 * These macros help in making persistent storage thread-specific.
48 * Libc makes extensive use of private static data structures
49 * that hold state across function invocation, and these macros
50 * are no-ops when _THREAD_SAFE is not defined.
51 * In a thread-safe library, the static variables are used only for
52 * initialising the per-thread instances of the state variables.
53 */
54
55/*
56 * Give names to the private variables used to hold per-thread
57 * data structures.
58 */
59#ifdef __STDC__
60#define __THREAD_MUTEXP_NAME(name) _thread_mutexp_inst__ ## name
61#define __THREAD_MUTEX_NAME(name) _thread_mutex_inst__ ## name
62#define __THREAD_KEY_NAME(name) _thread_key_inst__ ## name
63#else
64#define __THREAD_MUTEXP_NAME(name) _thread_mutexp_inst__/**/name
65#define __THREAD_MUTEX_NAME(name) _thread_mutex_inst__/**/name
66#define __THREAD_KEY_NAME(name) _thread_key_inst__/**/name
67#endif
68
69/*
70 * Mutex declare, lock and unlock macros.
71 */
72#define _THREAD_PRIVATE_MUTEX(name) \
73 static struct pthread_mutex __THREAD_MUTEXP_NAME(name) = \
74 PTHREAD_MUTEX_STATIC_INITIALIZER; \
75 static pthread_mutex_t __THREAD_MUTEX_NAME(name) = \
76 &__THREAD_MUTEXP_NAME(name);
77
78#define _THREAD_PRIVATE_MUTEX_LOCK(name) \
79 pthread_mutex_lock(&__THREAD_MUTEX_NAME(name))
80
81#define _THREAD_PRIVATE_MUTEX_UNLOCK(name) \
82 pthread_mutex_unlock(&__THREAD_MUTEX_NAME(name))
83
84/*
85 * A mutexed data structure used to hold the persistent state's key.
86 */
87struct _thread_private_key_struct {
88 struct pthread_mutex lockd;
89 pthread_mutex_t lock;
90 int init;
91 pthread_key_t key;
92};
93
94/*
95 * Declaration of a per-thread state key.
96 */
97#define _THREAD_PRIVATE_KEY(name) \
98 static volatile struct _thread_private_key_struct \
99 __THREAD_KEY_NAME(name) = { \
100 PTHREAD_MUTEX_STATIC_INITIALIZER, \
101 &__THREAD_KEY_NAME(name).lockd, \
102 0 \
103 };
104
105/*
106 * Initialisation of storage space for a per-thread state variable.
107 * A pointer to a per-thread *copy* of the _initv parameter is returned.
108 * It calls malloc the first time and the space is automatically free'd
109 * when the thread dies. If you need something a bit more complicated
110 * than free() you will need to roll-your-own.
111 */
112#define _THREAD_PRIVATE(keyname, _initv, _errv) \
113 ({ \
114 struct _thread_private_key_struct * __k = \
115 &__THREAD_KEY_NAME(keyname); \
116 void* __p; \
117 extern void free __P((void*)); \
118 extern void* malloc __P((size_t)); \
119 \
120 if (!__isthreaded) { \
121 /* non-threaded behaviour */ \
122 __p = &(_initv); \
123 goto _ok; \
124 } \
125 \
126 /* create key for first thread */ \
127 pthread_mutex_lock(&__k->lock); \
128 if (__k->init == 0) { \
129 if (pthread_key_create(&__k->key, free)) { \
130 pthread_mutex_unlock(&__k->lock); \
131 goto _err; \
132 } \
133 __k->init = 1; \
134 } \
135 pthread_mutex_unlock(&__k->lock); \
136 \
137 if ((__p = pthread_getspecific(__k->key)) == NULL) { \
138 /* alloc space on 1st call in this thread */ \
139 if ((__p = malloc(sizeof(_initv))) == NULL) \
140 goto _err; \
141 if (pthread_setspecific(__k->key, __p) != 0) { \
142 free(__p); \
143 goto _err; \
144 } \
145 /* initialise with _initv */ \
146 memcpy(__p, &_initv, sizeof(_initv)); \
147 } \
148 goto _ok; \
149 _err: \
150 __p = (_errv); \
151 _ok: \
152 __p; \
153 })
154
155/*
156 * Macros for locking and unlocking FILEs. These test if the
157 * process is threaded to avoid locking when not required.
158 */
159#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp)
160#define FUNLOCKFILE(fp) if (__isthreaded) funlockfile(fp)
161
162#else /* !_THREAD_SAFE */
163
164/*
165 * Do-nothing macros for single-threaded case.
166 */
167#define _FD_LOCK(f,o,p) (0)
168#define _FD_UNLOCK(f,o) /* nothing */
169#define _THREAD_PRIVATE_KEY(_key) /* nothing */
170#define _THREAD_PRIVATE(keyname, _initv, _errv) (&(_initv))
171#define _THREAD_PRIVATE_MUTEX(_name) /* nothing */
172#define _THREAD_PRIVATE_MUTEX_LOCK(_name) /* nothing */
173#define _THREAD_PRIVATE_MUTEX_UNLOCK(_name) /* nothing */
174#define FLOCKFILE(fp) /* nothing */
175#define FUNLOCKFILE(fp) /* nothing */
176
177#endif /* !_THREAD_SAFE */
178
179#endif _THREAD_PRIVATE_H_
diff --git a/src/lib/libc/net/Makefile.inc b/src/lib/libc/net/Makefile.inc
new file mode 100644
index 0000000000..35a9632a94
--- /dev/null
+++ b/src/lib/libc/net/Makefile.inc
@@ -0,0 +1,56 @@
1# $OpenBSD: Makefile.inc,v 1.17 1998/11/20 11:18:43 d Exp $
2
3# net sources
4.PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/net ${LIBCSRCDIR}/net
5
6CFLAGS+=-DRESOLVSORT
7
8SRCS+= base64.c gethostnamadr.c getnetbyaddr.c getnetbyname.c getnetent.c \
9 getnetnamadr.c getproto.c getprotoent.c getprotoname.c getservbyname.c \
10 getservbyport.c getservent.c herror.c inet_addr.c inet_lnaof.c \
11 inet_makeaddr.c inet_neta.c inet_netof.c inet_network.c \
12 inet_net_ntop.c inet_net_pton.c inet_ntoa.c inet_ntop.c \
13 inet_pton.c ipx_addr.c ipx_ntoa.c \
14 iso_addr.c linkaddr.c ns_addr.c ns_ntoa.c nsap_addr.c rcmd.c recv.c \
15 res_comp.c res_data.c res_debug.c res_init.c res_mkquery.c res_query.c \
16 res_random.c res_send.c send.c sethostent.c ethers.c rcmdsh.c
17
18# machine-dependent net sources
19# m-d Makefile.inc must include sources for:
20# htonl() htons() ntohl() ntohs()
21
22.include "${LIBCSRCDIR}/arch/${MACHINE_ARCH}/net/Makefile.inc"
23
24MAN+= byteorder.3 ethers.3 gethostbyname.3 getnetent.3 getprotoent.3 \
25 getservent.3 inet.3 inet_net.3 iso_addr.3 link_addr.3 ns.3 ipx.3 \
26 rcmd.3 rcmdsh.3 resolver.3
27
28MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \
29 byteorder.3 ntohs.3 byteorder.3 htobe16.3 byteorder.3 htobe32.3 \
30 byteorder.3 betoh16.3 byteorder.3 betoh32.3 byteorder.3 htole16.3 \
31 byteorder.3 htole32.3 byteorder.3 letoh16.3 byteorder.3 letoh32.3 \
32 byteorder.3 swap16.3 byteorder.3 swap32.3
33MLINKS+=ethers.3 ether_aton.3 ethers.3 ether_hostton.3 ethers.3 ether_line.3 \
34 ethers.3 ether_ntoa.3 ethers.3 ether_ntohost.3 ethers.3 ether_addr.3
35MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \
36 gethostbyname.3 sethostent.3 gethostbyname.3 gethostent.3 \
37 gethostbyname.3 herror.3 gethostbyname.3 gethostbyname2.3 \
38 gethostbyname.3 hstrerror.3
39MLINKS+=getnetent.3 endnetent.3 getnetent.3 getnetbyaddr.3 \
40 getnetent.3 getnetbyname.3 getnetent.3 setnetent.3
41MLINKS+=getprotoent.3 endprotoent.3 getprotoent.3 getprotobyname.3 \
42 getprotoent.3 getprotobynumber.3 getprotoent.3 setprotoent.3
43MLINKS+=getservent.3 endservent.3 getservent.3 getservbyname.3 \
44 getservent.3 getservbyport.3 getservent.3 setservent.3
45MLINKS+=inet.3 addr.3 inet.3 inet_addr.3 inet.3 inet_aton.3 \
46 inet.3 inet_lnaof.3 inet.3 inet_makeaddr.3 inet.3 inet_netof.3 \
47 inet.3 inet_network.3 inet.3 inet_ntoa.3 inet.3 network.3 \
48 inet.3 ntoa.3 inet.3 inet_ntop.3 inet.3 inet_pton.3
49MLINKS+=iso_addr.3 iso_ntoa.3
50MLINKS+=link_addr.3 link_ntoa.3
51MLINKS+=ipx.3 ipx_addr.3 ipx.3 ipx_ntoa.3
52MLINKS+=ns.3 ns_addr.3 ns.3 ns_ntoa.3
53MLINKS+=rcmd.3 iruserok.3 rcmd.3 rresvport.3 rcmd.3 ruserok.3
54MLINKS+=resolver.3 dn_comp.3 resolver.3 dn_expand.3 resolver.3 res_init.3 \
55 resolver.3 res_mkquery.3 resolver.3 res_send.3 resolver.3 res_query.3 \
56 resolver.3 res_search.3
diff --git a/src/lib/libc/net/base64.c b/src/lib/libc/net/base64.c
new file mode 100644
index 0000000000..452fe5afcc
--- /dev/null
+++ b/src/lib/libc/net/base64.c
@@ -0,0 +1,317 @@
1/* $OpenBSD: base64.c,v 1.3 1997/11/08 20:46:55 deraadt Exp $ */
2
3/*
4 * Copyright (c) 1996 by Internet Software Consortium.
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
11 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
12 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
13 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
16 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
17 * SOFTWARE.
18 */
19
20/*
21 * Portions Copyright (c) 1995 by International Business Machines, Inc.
22 *
23 * International Business Machines, Inc. (hereinafter called IBM) grants
24 * permission under its copyrights to use, copy, modify, and distribute this
25 * Software with or without fee, provided that the above copyright notice and
26 * all paragraphs of this notice appear in all copies, and that the name of IBM
27 * not be used in connection with the marketing of any product incorporating
28 * the Software or modifications thereof, without specific, written prior
29 * permission.
30 *
31 * To the extent it has a right to do so, IBM grants an immunity from suit
32 * under its patents, if any, for the use, sale or manufacture of products to
33 * the extent that such products are used for performing Domain Name System
34 * dynamic updates in TCP/IP networks by means of the Software. No immunity is
35 * granted for any product per se or for any other function of any product.
36 *
37 * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
38 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
39 * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
40 * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
41 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
42 * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#include <sys/types.h>
46#include <sys/param.h>
47#include <sys/socket.h>
48#include <netinet/in.h>
49#include <arpa/inet.h>
50#include <arpa/nameser.h>
51
52#include <ctype.h>
53#include <resolv.h>
54#include <stdio.h>
55
56#include <stdlib.h>
57#include <string.h>
58
59#define Assert(Cond) if (!(Cond)) abort()
60
61static const char Base64[] =
62 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
63static const char Pad64 = '=';
64
65/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
66 The following encoding technique is taken from RFC 1521 by Borenstein
67 and Freed. It is reproduced here in a slightly edited form for
68 convenience.
69
70 A 65-character subset of US-ASCII is used, enabling 6 bits to be
71 represented per printable character. (The extra 65th character, "=",
72 is used to signify a special processing function.)
73
74 The encoding process represents 24-bit groups of input bits as output
75 strings of 4 encoded characters. Proceeding from left to right, a
76 24-bit input group is formed by concatenating 3 8-bit input groups.
77 These 24 bits are then treated as 4 concatenated 6-bit groups, each
78 of which is translated into a single digit in the base64 alphabet.
79
80 Each 6-bit group is used as an index into an array of 64 printable
81 characters. The character referenced by the index is placed in the
82 output string.
83
84 Table 1: The Base64 Alphabet
85
86 Value Encoding Value Encoding Value Encoding Value Encoding
87 0 A 17 R 34 i 51 z
88 1 B 18 S 35 j 52 0
89 2 C 19 T 36 k 53 1
90 3 D 20 U 37 l 54 2
91 4 E 21 V 38 m 55 3
92 5 F 22 W 39 n 56 4
93 6 G 23 X 40 o 57 5
94 7 H 24 Y 41 p 58 6
95 8 I 25 Z 42 q 59 7
96 9 J 26 a 43 r 60 8
97 10 K 27 b 44 s 61 9
98 11 L 28 c 45 t 62 +
99 12 M 29 d 46 u 63 /
100 13 N 30 e 47 v
101 14 O 31 f 48 w (pad) =
102 15 P 32 g 49 x
103 16 Q 33 h 50 y
104
105 Special processing is performed if fewer than 24 bits are available
106 at the end of the data being encoded. A full encoding quantum is
107 always completed at the end of a quantity. When fewer than 24 input
108 bits are available in an input group, zero bits are added (on the
109 right) to form an integral number of 6-bit groups. Padding at the
110 end of the data is performed using the '=' character.
111
112 Since all base64 input is an integral number of octets, only the
113 -------------------------------------------------
114 following cases can arise:
115
116 (1) the final quantum of encoding input is an integral
117 multiple of 24 bits; here, the final unit of encoded
118 output will be an integral multiple of 4 characters
119 with no "=" padding,
120 (2) the final quantum of encoding input is exactly 8 bits;
121 here, the final unit of encoded output will be two
122 characters followed by two "=" padding characters, or
123 (3) the final quantum of encoding input is exactly 16 bits;
124 here, the final unit of encoded output will be three
125 characters followed by one "=" padding character.
126 */
127
128int
129b64_ntop(src, srclength, target, targsize)
130 u_char const *src;
131 size_t srclength;
132 char *target;
133 size_t targsize;
134{
135 size_t datalength = 0;
136 u_char input[3];
137 u_char output[4];
138 int i;
139
140 while (2 < srclength) {
141 input[0] = *src++;
142 input[1] = *src++;
143 input[2] = *src++;
144 srclength -= 3;
145
146 output[0] = input[0] >> 2;
147 output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
148 output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
149 output[3] = input[2] & 0x3f;
150 Assert(output[0] < 64);
151 Assert(output[1] < 64);
152 Assert(output[2] < 64);
153 Assert(output[3] < 64);
154
155 if (datalength + 4 > targsize)
156 return (-1);
157 target[datalength++] = Base64[output[0]];
158 target[datalength++] = Base64[output[1]];
159 target[datalength++] = Base64[output[2]];
160 target[datalength++] = Base64[output[3]];
161 }
162
163 /* Now we worry about padding. */
164 if (0 != srclength) {
165 /* Get what's left. */
166 input[0] = input[1] = input[2] = '\0';
167 for (i = 0; i < srclength; i++)
168 input[i] = *src++;
169
170 output[0] = input[0] >> 2;
171 output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
172 output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
173 Assert(output[0] < 64);
174 Assert(output[1] < 64);
175 Assert(output[2] < 64);
176
177 if (datalength + 4 > targsize)
178 return (-1);
179 target[datalength++] = Base64[output[0]];
180 target[datalength++] = Base64[output[1]];
181 if (srclength == 1)
182 target[datalength++] = Pad64;
183 else
184 target[datalength++] = Base64[output[2]];
185 target[datalength++] = Pad64;
186 }
187 if (datalength >= targsize)
188 return (-1);
189 target[datalength] = '\0'; /* Returned value doesn't count \0. */
190 return (datalength);
191}
192
193/* skips all whitespace anywhere.
194 converts characters, four at a time, starting at (or after)
195 src from base - 64 numbers into three 8 bit bytes in the target area.
196 it returns the number of data bytes stored at the target, or -1 on error.
197 */
198
199int
200b64_pton(src, target, targsize)
201 char const *src;
202 u_char *target;
203 size_t targsize;
204{
205 int tarindex, state, ch;
206 char *pos;
207
208 state = 0;
209 tarindex = 0;
210
211 while ((ch = *src++) != '\0') {
212 if (isspace(ch)) /* Skip whitespace anywhere. */
213 continue;
214
215 if (ch == Pad64)
216 break;
217
218 pos = strchr(Base64, ch);
219 if (pos == 0) /* A non-base64 character. */
220 return (-1);
221
222 switch (state) {
223 case 0:
224 if (target) {
225 if (tarindex >= targsize)
226 return (-1);
227 target[tarindex] = (pos - Base64) << 2;
228 }
229 state = 1;
230 break;
231 case 1:
232 if (target) {
233 if (tarindex + 1 >= targsize)
234 return (-1);
235 target[tarindex] |= (pos - Base64) >> 4;
236 target[tarindex+1] = ((pos - Base64) & 0x0f)
237 << 4 ;
238 }
239 tarindex++;
240 state = 2;
241 break;
242 case 2:
243 if (target) {
244 if (tarindex + 1 >= targsize)
245 return (-1);
246 target[tarindex] |= (pos - Base64) >> 2;
247 target[tarindex+1] = ((pos - Base64) & 0x03)
248 << 6;
249 }
250 tarindex++;
251 state = 3;
252 break;
253 case 3:
254 if (target) {
255 if (tarindex >= targsize)
256 return (-1);
257 target[tarindex] |= (pos - Base64);
258 }
259 tarindex++;
260 state = 0;
261 break;
262 }
263 }
264
265 /*
266 * We are done decoding Base-64 chars. Let's see if we ended
267 * on a byte boundary, and/or with erroneous trailing characters.
268 */
269
270 if (ch == Pad64) { /* We got a pad char. */
271 ch = *src++; /* Skip it, get next. */
272 switch (state) {
273 case 0: /* Invalid = in first position */
274 case 1: /* Invalid = in second position */
275 return (-1);
276
277 case 2: /* Valid, means one byte of info */
278 /* Skip any number of spaces. */
279 for (; ch != '\0'; ch = *src++)
280 if (!isspace(ch))
281 break;
282 /* Make sure there is another trailing = sign. */
283 if (ch != Pad64)
284 return (-1);
285 ch = *src++; /* Skip the = */
286 /* Fall through to "single trailing =" case. */
287 /* FALLTHROUGH */
288
289 case 3: /* Valid, means two bytes of info */
290 /*
291 * We know this char is an =. Is there anything but
292 * whitespace after it?
293 */
294 for (; ch != '\0'; ch = *src++)
295 if (!isspace(ch))
296 return (-1);
297
298 /*
299 * Now make sure for cases 2 and 3 that the "extra"
300 * bits that slopped past the last full byte were
301 * zeros. If we don't check them, they become a
302 * subliminal channel.
303 */
304 if (target && target[tarindex] != 0)
305 return (-1);
306 }
307 } else {
308 /*
309 * We ended by seeing the end of the string. Make sure we
310 * have no partial bytes lying around.
311 */
312 if (state != 0)
313 return (-1);
314 }
315
316 return (tarindex);
317}
diff --git a/src/lib/libc/net/byteorder.3 b/src/lib/libc/net/byteorder.3
new file mode 100644
index 0000000000..f2788b25dc
--- /dev/null
+++ b/src/lib/libc/net/byteorder.3
@@ -0,0 +1,155 @@
1.\" $OpenBSD: byteorder.3,v 1.5 1997/11/19 23:30:17 niklas Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd June 4, 1993
35.Dt BYTEORDER 3
36.Os BSD 4.2
37.Sh NAME
38.Nm htonl ,
39.Nm htons ,
40.Nm ntohl ,
41.Nm ntohs ,
42.Nm htobe32 ,
43.Nm htobe16 ,
44.Nm betoh32 ,
45.Nm betoh16 ,
46.Nm htole32 ,
47.Nm htole16 ,
48.Nm letoh32 ,
49.Nm letoh16 ,
50.Nm swap32 ,
51.Nm swap16
52.Nd convert values between different byte orderings
53.Sh SYNOPSIS
54.Fd #include <sys/types.h>
55.Fd #include <machine/endian.h>
56.Ft u_int32_t
57.Fn htonl "u_int32_t host32"
58.Ft u_int16_t
59.Fn htons "u_int16_t host16"
60.Ft u_int32_t
61.Fn ntohl "u_int32_t net32"
62.Ft u_int16_t
63.Fn ntohs "u_int16_t net16"
64.Ft u_int32_t
65.Fn htobe32 "u_int32_t host32"
66.Ft u_int16_t
67.Fn htobe16 "u_int16_t host16"
68.Ft u_int32_t
69.Fn betoh32 "u_int32_t big32"
70.Ft u_int16_t
71.Fn betoh16 "u_int16_t big16"
72.Ft u_int32_t
73.Fn htole32 "u_int32_t host32"
74.Ft u_int16_t
75.Fn htole16 "u_int16_t host16"
76.Ft u_int32_t
77.Fn letoh32 "u_int32_t little32"
78.Ft u_int16_t
79.Fn letoh16 "u_int16_t little16"
80.Ft u_int32_t
81.Fn swap32 "u_int32_t val32"
82.Ft u_int16_t
83.Fn swap16 "u_int16_t val16"
84.Sh DESCRIPTION
85These routines convert 16 and 32 bit quantities between different
86byte orderings. The "swap" functions reverse the byte ordering of
87the given quantity, the others converts either from/to the native
88byte order used by the host to/from either little- or big-endian (a.k.a
89network) order.
90.Pp
91Apart from the "swap" functions, the names can be described by this form:
92{src-order}to{dst-order}{size}.
93Both {src-order} and {dst-order} can take the following forms:
94.Bl -tag -width "be "
95.It Em h
96host order
97.It Em n
98network order (big-endian)
99.It Em be
100big-endian (Most significant byte first)
101.It Em le
102little-endian (Least significant byte first)
103.El
104.Pp
105One of the specified orderings must be "h".
106{Size} will take these forms:
107.Bl -tag -width "32 "
108.It Em l
109long (32-bit, used in conjunction with forms involving "n")
110.It Em s
111short (16-bit, used in conjunction with forms involving "n")
112.It Em 16
11316-bit
114.It Em 32
11532-bit
116.El
117.Pp
118The "swap" functions are of the form: swap{size}.
119.Pp
120Names involving "n" convert quantities between network
121byte order and host byte order. The last letter (s/l) is a mnemonic
122for the traditional names for such quantities, short and long,
123respectively. Today, the C concept of "short"/"long" integers
124need not coincide with this traditional misunderstanding.
125On machines which have a byte order which is the same as the network
126order, routines are defined as null macros.
127.Pp
128The functions involving either "be", "le" or "swap" use the numbers
129(16/32) for specifying the bitwidth of the quantities they operate on.
130Currently all supported architectures are either big- or little-endian
131so either the "be" or the "le" variants are implemented as null macros.
132.Pp
133The routines mentioned above which have either {src-order} or {dst-order}
134set to "n" are most often used in
135conjunction with Internet addresses and ports as returned by
136.Xr gethostbyname 3
137and
138.Xr getservent 3 .
139.Sh SEE ALSO
140.Xr gethostbyname 3 ,
141.Xr getservent 3
142.Sh HISTORY
143The
144.Nm byteorder
145functions appeared in
146.Bx 4.2 .
147.Sh BUGS
148On the
149.Tn vax ,
150.Tn alpha ,
151.Tn i386 ,
152and so far
153.Tn mips
154bytes are handled backwards from most everyone else in
155the world. This is not expected to be fixed in the near future.
diff --git a/src/lib/libc/net/ethers.3 b/src/lib/libc/net/ethers.3
new file mode 100644
index 0000000000..74d153fce6
--- /dev/null
+++ b/src/lib/libc/net/ethers.3
@@ -0,0 +1,109 @@
1.\" $OpenBSD: ethers.3,v 1.10 1999/03/18 11:09:15 aaron Exp $
2.\"
3.\" Written by roland@frob.com. Public domain.
4.\"
5.Dd December 16, 1993
6.Dt ETHERS 3
7.Os
8.Sh NAME
9.Nm ether_aton ,
10.Nm ether_ntoa ,
11.Nm ether_addr ,
12.Nm ether_ntohost ,
13.Nm ether_hostton ,
14.Nm ether_line
15.Nd get ethers entry
16.Sh SYNOPSIS
17.Fd #include <netinet/if_ether.h>
18.Ft char *
19.Fn ether_ntoa "struct ether_addr *e"
20.Ft struct ether_addr *
21.Fn ether_aton "char *s"
22.Ft int
23.Fn ether_ntohost "char *hostname" "struct ether_addr *e"
24.Ft int
25.Fn ether_hostton "char *hostname" "struct ether_addr *e"
26.Ft int
27.Fn ether_line "char *l" "struct ether_addr *e" "char *hostname"
28.Sh DESCRIPTION
29Ethernet addresses are represented by the
30following structure:
31.Bd -literal -offset indent
32struct ether_addr {
33 u_int8_t ether_addr_octet[6];
34};
35.Ed
36.Pp
37The
38.Fn ether_ntoa
39function converts this structure into an ASCII string of the form
40``xx:xx:xx:xx:xx:xx'', consisting of 6 hexadecimal numbers separated
41by colons. It returns a pointer to a static buffer that is reused for
42each call.
43The
44.Fn ether_aton
45converts an ASCII string of the same form and to a structure
46containing the 6 octets of the address. It returns a pointer to a
47static structure that is reused for each call.
48.Pp
49The
50.Fn ether_ntohost
51and
52.Fn ether_hostton
53functions interrogate the data base mapping host names to Ethernet
54addresses,
55.Pa /etc/ethers .
56The
57.Fn ether_ntohost
58function looks up the given Ethernet address and writes the associated
59host name into the character buffer passed. This buffer should be
60.Ev MAXHOSTNAMELEN
61characters in size.
62The
63.Fn ether_hostton
64function looks up the given host name and writes the associated
65Ethernet address into the structure passed. Both functions return
66zero if they find the requested host name or address, and -1 if not.
67.Pp
68Each call reads
69.Pa /etc/ethers
70from the beginning; if a + appears alone on a line in the file, then
71.Fn ether_hostton
72will consult the
73.Pa ethers.byname
74YP map, and
75.Fn ether_ntohost
76will consult the
77.Pa ethers.byaddr
78YP map.
79.Pp
80The
81.Fn ether_line
82function parses a line from the
83.Pa /etc/ethers
84file and fills in the passed ``struct ether_addr'' and character
85buffer with the Ethernet address and host name on the line. It
86returns zero if the line was successfully parsed and -1 if not.
87The character buffer should be
88.Ev MAXHOSTNAMELEN
89characters in size.
90.Sh FILES
91.Bl -tag -width /etc/ethers -compact
92.It Pa /etc/ethers
93.El
94.Sh SEE ALSO
95.Xr ethers 5
96.Sh HISTORY
97The
98.Fn ether_ntoa ,
99.Fn ether_aton ,
100.Fn ether_ntohost ,
101.Fn ether_hostton ,
102and
103.Fn ether_line
104functions were adopted from SunOS and appeared in
105NetBSD 0.9b.
106.Sh BUGS
107The data space used by these functions is static; if future use
108requires the data, it should be copied before any subsequent calls to
109these functions overwrite it.
diff --git a/src/lib/libc/net/ethers.c b/src/lib/libc/net/ethers.c
new file mode 100644
index 0000000000..94ae5c996a
--- /dev/null
+++ b/src/lib/libc/net/ethers.c
@@ -0,0 +1,270 @@
1/* $OpenBSD: ethers.c,v 1.10 1998/11/18 23:28:54 deraadt Exp $ */
2
3/*
4 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/*
31 * ethers(3) a la Sun.
32 * Originally Written by Roland McGrath <roland@frob.com> 10/14/93.
33 * Substantially modified by Todd C. Miller <Todd.Miller@courtesan.com>
34 */
35
36#if defined(LIBC_SCCS) && !defined(lint)
37static char rcsid[] = "$OpenBSD: ethers.c,v 1.10 1998/11/18 23:28:54 deraadt Exp $";
38#endif /* LIBC_SCCS and not lint */
39
40#include <sys/types.h>
41#include <sys/socket.h>
42#include <net/if.h>
43#include <netinet/in.h>
44#include <netinet/if_ether.h>
45#include <sys/param.h>
46#include <paths.h>
47#include <errno.h>
48#include <stdio.h>
49#include <stdlib.h>
50#include <string.h>
51#include <ctype.h>
52
53#ifndef _PATH_ETHERS
54#define _PATH_ETHERS "/etc/ethers"
55#endif
56
57static char * _ether_aton __P((char *, struct ether_addr *));
58
59char *
60ether_ntoa(e)
61 struct ether_addr *e;
62{
63 static char a[] = "xx:xx:xx:xx:xx:xx";
64
65 if (e->ether_addr_octet[0] > 0xFF || e->ether_addr_octet[1] > 0xFF ||
66 e->ether_addr_octet[2] > 0xFF || e->ether_addr_octet[3] > 0xFF ||
67 e->ether_addr_octet[4] > 0xFF || e->ether_addr_octet[5] > 0xFF) {
68 errno = EINVAL;
69 return (NULL);
70 }
71
72 (void)sprintf(a, "%02x:%02x:%02x:%02x:%02x:%02x",
73 e->ether_addr_octet[0], e->ether_addr_octet[1],
74 e->ether_addr_octet[2], e->ether_addr_octet[3],
75 e->ether_addr_octet[4], e->ether_addr_octet[5]);
76
77 return (a);
78}
79
80static char *
81_ether_aton(s, e)
82 char *s;
83 struct ether_addr *e;
84{
85 int i;
86 long l;
87 char *pp;
88
89 while (isspace(*s))
90 s++;
91
92 /* expect 6 hex octets separated by ':' or space/NUL if last octet */
93 for (i = 0; i < 6; i++) {
94 l = strtol(s, &pp, 16);
95 if (pp == s || l > 0xFF || l < 0)
96 return (NULL);
97 if (!(*pp == ':' || (i == 5 && (isspace(*pp) || *pp == '\0'))))
98 return (NULL);
99 e->ether_addr_octet[i] = (u_char)l;
100 s = pp + 1;
101 }
102
103 /* return character after the octets ala strtol(3) */
104 return (pp);
105}
106
107struct ether_addr *
108ether_aton(s)
109 char *s;
110{
111 static struct ether_addr n;
112
113 return (_ether_aton(s, &n) ? &n : NULL);
114}
115
116int
117ether_ntohost(hostname, e)
118 char *hostname;
119 struct ether_addr *e;
120{
121 FILE *f;
122 char buf[BUFSIZ+1], *p;
123 size_t len;
124 struct ether_addr try;
125#ifdef YP
126 char trybuf[sizeof("xx:xx:xx:xx:xx:xx")];
127 int trylen;
128#endif
129
130 if (e->ether_addr_octet[0] > 0xFF || e->ether_addr_octet[1] > 0xFF ||
131 e->ether_addr_octet[2] > 0xFF || e->ether_addr_octet[3] > 0xFF ||
132 e->ether_addr_octet[4] > 0xFF || e->ether_addr_octet[5] > 0xFF) {
133 errno = EINVAL;
134 return (-1);
135 }
136
137#ifdef YP
138 sprintf(trybuf, "%x:%x:%x:%x:%x:%x",
139 e->ether_addr_octet[0], e->ether_addr_octet[1],
140 e->ether_addr_octet[2], e->ether_addr_octet[3],
141 e->ether_addr_octet[4], e->ether_addr_octet[5]);
142 trylen = strlen(trybuf);
143#endif
144
145 f = fopen(_PATH_ETHERS, "r");
146 if (f == NULL)
147 return (-1);
148 while ((p = fgetln(f, &len)) != NULL) {
149 if (p[len-1] == '\n')
150 len--;
151 if (len > sizeof(buf) - 2)
152 continue;
153 (void)memcpy(buf, p, len);
154 buf[len] = '\n'; /* code assumes newlines later on */
155 buf[len+1] = '\0';
156#ifdef YP
157 /* A + in the file means try YP now. */
158 if (!strncmp(buf, "+\n", sizeof(buf))) {
159 char *ypbuf, *ypdom;
160 int ypbuflen;
161
162 if (yp_get_default_domain(&ypdom))
163 continue;
164 if (yp_match(ypdom, "ethers.byaddr", trybuf,
165 trylen, &ypbuf, &ypbuflen))
166 continue;
167 if (ether_line(ypbuf, &try, hostname) == 0) {
168 free(ypbuf);
169 (void)fclose(f);
170 return (0);
171 }
172 free(ypbuf);
173 continue;
174 }
175#endif
176 if (ether_line(buf, &try, hostname) == 0 &&
177 memcmp((void *)&try, (void *)e, sizeof(try)) == 0) {
178 (void)fclose(f);
179 return (0);
180 }
181 }
182 (void)fclose(f);
183 errno = ENOENT;
184 return (-1);
185}
186
187int
188ether_hostton(hostname, e)
189 char *hostname;
190 struct ether_addr *e;
191{
192 FILE *f;
193 char buf[BUFSIZ+1], *p;
194 char try[MAXHOSTNAMELEN];
195 size_t len;
196#ifdef YP
197 int hostlen = strlen(hostname);
198#endif
199
200 f = fopen(_PATH_ETHERS, "r");
201 if (f==NULL)
202 return (-1);
203
204 while ((p = fgetln(f, &len)) != NULL) {
205 if (p[len-1] == '\n')
206 len--;
207 if (len > sizeof(buf) - 2)
208 continue;
209 memcpy(buf, p, len);
210 buf[len] = '\n'; /* code assumes newlines later on */
211 buf[len+1] = '\0';
212#ifdef YP
213 /* A + in the file means try YP now. */
214 if (!strncmp(buf, "+\n", sizeof(buf))) {
215 char *ypbuf, *ypdom;
216 int ypbuflen;
217
218 if (yp_get_default_domain(&ypdom))
219 continue;
220 if (yp_match(ypdom, "ethers.byname", hostname, hostlen,
221 &ypbuf, &ypbuflen))
222 continue;
223 if (ether_line(ypbuf, e, try) == 0) {
224 free(ypbuf);
225 (void)fclose(f);
226 return (0);
227 }
228 free(ypbuf);
229 continue;
230 }
231#endif
232 if (ether_line(buf, e, try) == 0 && strcmp(hostname, try) == 0) {
233 (void)fclose(f);
234 return (0);
235 }
236 }
237 (void)fclose(f);
238 errno = ENOENT;
239 return (-1);
240}
241
242int
243ether_line(line, e, hostname)
244 char *line;
245 struct ether_addr *e;
246 char *hostname;
247{
248 char *p;
249 size_t n;
250
251 /* Parse "xx:xx:xx:xx:xx:xx" */
252 if ((p = _ether_aton(line, e)) == NULL || (*p != ' ' && *p != '\t'))
253 goto bad;
254
255 /* Now get the hostname */
256 while (isspace(*p))
257 p++;
258 if (*p == '\0')
259 goto bad;
260 n = strcspn(p, " \t\n");
261 if (n >= MAXHOSTNAMELEN)
262 goto bad;
263 (void)strncpy(hostname, p, n);
264 hostname[n] = '\0';
265 return (0);
266
267bad:
268 errno = EINVAL;
269 return (-1);
270}
diff --git a/src/lib/libc/net/gethostbyname.3 b/src/lib/libc/net/gethostbyname.3
new file mode 100644
index 0000000000..e28fed361c
--- /dev/null
+++ b/src/lib/libc/net/gethostbyname.3
@@ -0,0 +1,266 @@
1.\" $OpenBSD: gethostbyname.3,v 1.10 1999/02/27 21:55:27 deraadt Exp $
2.\"
3.\" Copyright (c) 1983, 1987, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd March 13, 1997
35.Dt GETHOSTBYNAME 3
36.Os
37.Sh NAME
38.Nm gethostbyname ,
39.Nm gethostbyname2 ,
40.Nm gethostbyaddr ,
41.Nm gethostent ,
42.Nm sethostent ,
43.Nm endhostent ,
44.Nm hstrerror ,
45.Nm herror
46.Nd get network host entry
47.Sh SYNOPSIS
48.Fd #include <netdb.h>
49.Fd extern int h_errno;
50.Ft struct hostent *
51.Fn gethostbyname "const char *name"
52.Ft struct hostent *
53.Fn gethostbyname2 "const char *name" "int af"
54.Ft struct hostent *
55.Fn gethostbyaddr "const char *addr" "int len" "int type"
56.Ft struct hostent *
57.Fn gethostent void
58.Ft void
59.Fn sethostent "int stayopen"
60.Ft void
61.Fn endhostent void
62.Ft void
63.Fn herror "const char *string"
64.Ft const char *
65.Fn hstrerror "int err"
66.Sh DESCRIPTION
67The
68.Fn gethostbyname
69and
70.Fn gethostbyaddr
71functions
72each return a pointer to an object with the
73following structure describing an internet host
74referenced by name or by address, respectively.
75This structure contains either the information obtained from the name server,
76.Xr named 8 ,
77broken-out fields from a line in
78.Pa /etc/hosts ,
79or database entries supplied by the
80.Xr yp 8
81system .
82If the local name server is not running these routines do a lookup in
83.Pa /etc/hosts .
84.Bd -literal
85struct hostent {
86 char *h_name; /* official name of host */
87 char **h_aliases; /* alias list */
88 int h_addrtype; /* host address type */
89 int h_length; /* length of address */
90 char **h_addr_list; /* list of addresses from name server */
91};
92#define h_addr h_addr_list[0] /* address, for backward compatibility */
93.Ed
94.Pp
95The members of this structure are:
96.Bl -tag -width h_addr_list
97.It Fa h_name
98Official name of the host.
99.It Fa h_aliases
100A zero terminated array of alternate names for the host.
101.It Fa h_addrtype
102The type of address being returned.
103.It Fa h_length
104The length, in bytes, of the address.
105.It Fa h_addr_list
106A zero terminated array of network addresses for the host.
107Host addresses are returned in network byte order.
108.It Fa h_addr
109The first address in
110.Fa h_addr_list ;
111this is for backward compatibility.
112.El
113.Pp
114When using the nameserver,
115.Fn gethostbyname
116will search for the named host in the current domain and its parents
117unless the name ends in a dot.
118If the name contains no dot, and if the environment variable
119.Dq Ev HOSTALIASES
120contains the name of an alias file, the alias file will first be searched
121for an alias matching the input name.
122See
123.Xr hostname 7
124for the domain search procedure and the alias file format.
125.Pp
126.Fn gethostbyname2
127is an advanced form of
128.Fn gethostbyname
129which allows lookups in address families other than
130.Dv AF_INET ,
131for example
132.Dv AF_INET6 .
133.Pp
134The
135.Fn sethostent
136function
137may be used to request the use of a connected
138.Tn TCP
139socket for queries.
140If the
141.Fa stayopen
142flag is non-zero,
143this sets the option to send all queries to the name server using
144.Tn TCP
145and to retain the connection after each call to
146.Fn gethostbyname
147or
148.Fn gethostbyaddr .
149Otherwise, queries are performed using
150.Tn UDP
151datagrams.
152.Pp
153The
154.Fn endhostent
155function
156closes the
157.Tn TCP
158connection.
159.Pp
160The
161.Fn herror
162function prints an error message describing the failure. If its argument
163.Fa string
164is
165.Pf non Dv -NULL ,
166it is prepended to the message string and separated from it by a colon
167and a space. The error message is printed with a trailing newline.
168The contents of the error message is the same as that returned by
169.Fn hstrerror
170with argument
171.Fa h_errno .
172.Sh FILES
173.Bl -tag -width /etc/hosts -compact
174.It Pa /etc/hosts
175.El
176.Sh DIAGNOSTICS
177Error return status from
178.Fn gethostbyname ,
179.Fn gethostbyname2 ,
180and
181.Fn gethostbyaddr
182is indicated by return of a null pointer.
183The external integer
184.Va h_errno
185may then be checked to see whether this is a temporary failure
186or an invalid or unknown host.
187.Pp
188The variable
189.Va h_errno
190can have the following values:
191.Bl -tag -width HOST_NOT_FOUND
192.It Dv HOST_NOT_FOUND
193No such host is known.
194.It Dv TRY_AGAIN
195This is usually a temporary error
196and means that the local server did not receive
197a response from an authoritative server.
198A retry at some later time may succeed.
199.It Dv NO_RECOVERY
200Some unexpected server failure was encountered.
201This is a non-recoverable error.
202.It Dv NO_DATA
203The requested name is valid but does not have an IP address;
204this is not a temporary error.
205This means that the name is known to the name server but there is no address
206associated with this name.
207Another type of request to the name server using this domain name
208will result in an answer;
209for example, a mail-forwarder may be registered for this domain.
210.El
211.Sh SEE ALSO
212.Xr resolver 3 ,
213.Xr hosts 5 ,
214.Xr hostname 7 ,
215.Xr named 8
216.Sh CAVEAT
217The
218.Fn gethostent
219function
220reads the next line of
221.Pa /etc/hosts ,
222opening the file if necessary.
223.Pp
224The
225.Fn sethostent
226function
227opens and/or rewinds the file
228.Pa /etc/hosts .
229If the
230.Fa stayopen
231argument is non-zero,
232the file will not be closed after each call to
233.Fn gethostbyname ,
234.Fn gethostbyname2 ,
235or
236.Fn gethostbyaddr .
237.Pp
238The
239.Fn endhostent
240function
241closes the file.
242.Sh HISTORY
243The
244.Fn herror
245function appeared in
246.Bx 4.3 .
247The
248.Fn endhostent ,
249.Fn gethostbyaddr ,
250.Fn gethostbyname ,
251.Fn gethostent ,
252and
253.Fn sethostent
254functions appeared in
255.Bx 4.2 .
256.Sh BUGS
257These functions use static data storage;
258if the data is needed for future use, it should be
259copied before any subsequent calls overwrite it.
260Only the Internet
261address formats are currently understood.
262.Pp
263YP does not support any address families other than
264.Dv AF_INET
265and uses
266the traditional database format.
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c
new file mode 100644
index 0000000000..6ff456fb0c
--- /dev/null
+++ b/src/lib/libc/net/gethostnamadr.c
@@ -0,0 +1,1147 @@
1/*-
2 * Copyright (c) 1985, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 * -
33 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
34 *
35 * Permission to use, copy, modify, and distribute this software for any
36 * purpose with or without fee is hereby granted, provided that the above
37 * copyright notice and this permission notice appear in all copies, and that
38 * the name of Digital Equipment Corporation not be used in advertising or
39 * publicity pertaining to distribution of the document or software without
40 * specific, written prior permission.
41 *
42 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
43 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
44 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
45 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
46 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
47 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
48 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
49 * SOFTWARE.
50 * -
51 * --Copyright--
52 */
53
54#if defined(LIBC_SCCS) && !defined(lint)
55static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.31 1998/11/20 11:18:44 d Exp $";
56#endif /* LIBC_SCCS and not lint */
57
58#include <sys/param.h>
59#include <sys/socket.h>
60#include <netinet/in.h>
61#include <arpa/inet.h>
62#include <arpa/nameser.h>
63#include <netdb.h>
64#include <resolv.h>
65#include <stdio.h>
66#include <ctype.h>
67#include <errno.h>
68#include <string.h>
69#include <syslog.h>
70#include <stdlib.h>
71#ifdef YP
72#include <rpc/rpc.h>
73#include <rpcsvc/yp.h>
74#include <rpcsvc/ypclnt.h>
75#include "ypinternal.h"
76#endif
77#include "thread_private.h"
78
79#define MULTI_PTRS_ARE_ALIASES 1 /* XXX - experimental */
80
81#define MAXALIASES 35
82#define MAXADDRS 35
83
84static char *h_addr_ptrs[MAXADDRS + 1];
85
86#ifdef YP
87static char *__ypdomain;
88#endif
89
90static struct hostent host;
91static char *host_aliases[MAXALIASES];
92static char hostbuf[BUFSIZ+1];
93static union {
94 struct in_addr _host_in_addr;
95 u_char _host_addr[16]; /* IPv4 or IPv6 */
96} _host_addr_u;
97#define host_addr _host_addr_u._host_addr
98static FILE *hostf = NULL;
99static int stayopen = 0;
100
101static void map_v4v6_address __P((const char *src, char *dst));
102static void map_v4v6_hostent __P((struct hostent *hp, char **bp, int *len));
103
104#ifdef RESOLVSORT
105static void addrsort __P((char **, int));
106#endif
107
108int _hokchar __P((const char *));
109
110static const char AskedForGot[] =
111 "gethostby*.getanswer: asked for \"%s\", got \"%s\"";
112
113#if PACKETSZ > 1024
114#define MAXPACKET PACKETSZ
115#else
116#define MAXPACKET 1024
117#endif
118
119typedef union {
120 HEADER hdr;
121 u_char buf[MAXPACKET];
122} querybuf;
123
124typedef union {
125 int32_t al;
126 char ac;
127} align;
128
129static struct hostent *getanswer __P((const querybuf *, int, const char *,
130 int));
131
132extern int h_errno;
133
134int
135_hokchar(p)
136 const char *p;
137{
138 char c;
139
140 /*
141 * Many people do not obey RFC 822 and 1035. The valid
142 * characters are a-z, A-Z, 0-9, '-' and . But the others
143 * tested for below can happen, and we must be more permissive
144 * than the resolver until those idiots clean up their act.
145 * We let '/' through, but not '..'
146 */
147 while ((c = *p++)) {
148 if (('a' <= c && c <= 'z') ||
149 ('A' <= c && c <= 'Z') ||
150 ('0' <= c && c <= '9'))
151 continue;
152 if (strchr("-_/", c))
153 continue;
154 if (c == '.' && *p != '.')
155 continue;
156 return 0;
157 }
158 return 1;
159}
160
161static struct hostent *
162getanswer(answer, anslen, qname, qtype)
163 const querybuf *answer;
164 int anslen;
165 const char *qname;
166 int qtype;
167{
168 register const HEADER *hp;
169 register const u_char *cp;
170 register int n;
171 const u_char *eom;
172 char *bp, **ap, **hap;
173 int type, class, buflen, ancount, qdcount;
174 int haveanswer, had_error;
175 int toobig = 0;
176 char tbuf[MAXDNAME];
177 const char *tname;
178 int (*name_ok) __P((const char *));
179
180 tname = qname;
181 host.h_name = NULL;
182 eom = answer->buf + anslen;
183 switch (qtype) {
184 case T_A:
185 case T_AAAA:
186#ifdef USE_RESOLV_NAME_OK
187 name_ok = res_hnok;
188 break;
189#endif
190 case T_PTR:
191#ifdef USE_RESOLV_NAME_OK
192 name_ok = res_dnok;
193#else
194 name_ok = _hokchar;
195#endif
196 break;
197 default:
198 return (NULL);
199 }
200 /*
201 * find first satisfactory answer
202 */
203 hp = &answer->hdr;
204 ancount = ntohs(hp->ancount);
205 qdcount = ntohs(hp->qdcount);
206 bp = hostbuf;
207 buflen = sizeof hostbuf;
208 cp = answer->buf + HFIXEDSZ;
209 if (qdcount != 1) {
210 h_errno = NO_RECOVERY;
211 return (NULL);
212 }
213 n = dn_expand(answer->buf, eom, cp, bp, buflen);
214 if ((n < 0) || !(*name_ok)(bp)) {
215 h_errno = NO_RECOVERY;
216 return (NULL);
217 }
218 cp += n + QFIXEDSZ;
219 if (qtype == T_A || qtype == T_AAAA) {
220 /* res_send() has already verified that the query name is the
221 * same as the one we sent; this just gets the expanded name
222 * (i.e., with the succeeding search-domain tacked on).
223 */
224 n = strlen(bp) + 1; /* for the \0 */
225 host.h_name = bp;
226 bp += n;
227 buflen -= n;
228 /* The qname can be abbreviated, but h_name is now absolute. */
229 qname = host.h_name;
230 }
231 ap = host_aliases;
232 *ap = NULL;
233 host.h_aliases = host_aliases;
234 hap = h_addr_ptrs;
235 *hap = NULL;
236 host.h_addr_list = h_addr_ptrs;
237 haveanswer = 0;
238 had_error = 0;
239 while (ancount-- > 0 && cp < eom && !had_error) {
240 n = dn_expand(answer->buf, eom, cp, bp, buflen);
241 if ((n < 0) || !(*name_ok)(bp)) {
242 had_error++;
243 continue;
244 }
245 cp += n; /* name */
246 type = _getshort(cp);
247 cp += INT16SZ; /* type */
248 class = _getshort(cp);
249 cp += INT16SZ + INT32SZ; /* class, TTL */
250 n = _getshort(cp);
251 cp += INT16SZ; /* len */
252 if (class != C_IN) {
253 /* XXX - debug? syslog? */
254 cp += n;
255 continue; /* XXX - had_error++ ? */
256 }
257 if ((qtype == T_A || qtype == T_AAAA) && type == T_CNAME) {
258 if (ap >= &host_aliases[MAXALIASES-1])
259 continue;
260 n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf);
261 if ((n < 0) || !(*name_ok)(tbuf)) {
262 had_error++;
263 continue;
264 }
265 cp += n;
266 /* Store alias. */
267 *ap++ = bp;
268 n = strlen(bp) + 1; /* for the \0 */
269 bp += n;
270 buflen -= n;
271 /* Get canonical name. */
272 n = strlen(tbuf) + 1; /* for the \0 */
273 if (n > buflen) {
274 had_error++;
275 continue;
276 }
277 strcpy(bp, tbuf);
278 host.h_name = bp;
279 bp += n;
280 buflen -= n;
281 continue;
282 }
283 if (qtype == T_PTR && type == T_CNAME) {
284 n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf);
285 if ((n < 0) || !res_hnok(tbuf)) {
286 had_error++;
287 continue;
288 }
289 cp += n;
290 /* Get canonical name. */
291 n = strlen(tbuf) + 1; /* for the \0 */
292 if (n > buflen) {
293 had_error++;
294 continue;
295 }
296 strcpy(bp, tbuf);
297 tname = bp;
298 bp += n;
299 buflen -= n;
300 continue;
301 }
302 if (type != qtype) {
303 syslog(LOG_NOTICE|LOG_AUTH,
304 "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"",
305 qname, p_class(C_IN), p_type(qtype),
306 p_type(type));
307 cp += n;
308 continue; /* XXX - had_error++ ? */
309 }
310 switch (type) {
311 case T_PTR:
312 if (strcasecmp(tname, bp) != 0) {
313 syslog(LOG_NOTICE|LOG_AUTH,
314 AskedForGot, qname, bp);
315 cp += n;
316 continue; /* XXX - had_error++ ? */
317 }
318 n = dn_expand(answer->buf, eom, cp, bp, buflen);
319 if ((n < 0) || !res_hnok(bp)) {
320 had_error++;
321 break;
322 }
323#if MULTI_PTRS_ARE_ALIASES
324 cp += n;
325 if (!haveanswer)
326 host.h_name = bp;
327 else if (ap < &host_aliases[MAXALIASES-1])
328 *ap++ = bp;
329 else
330 n = -1;
331 if (n != -1) {
332 n = strlen(bp) + 1; /* for the \0 */
333 bp += n;
334 buflen -= n;
335 }
336 break;
337#else
338 host.h_name = bp;
339 if (_res.options & RES_USE_INET6) {
340 n = strlen(bp) + 1; /* for the \0 */
341 bp += n;
342 buflen -= n;
343 map_v4v6_hostent(&host, &bp, &buflen);
344 }
345 h_errno = NETDB_SUCCESS;
346 return (&host);
347#endif
348 case T_A:
349 case T_AAAA:
350 if (strcasecmp(host.h_name, bp) != 0) {
351 syslog(LOG_NOTICE|LOG_AUTH,
352 AskedForGot, host.h_name, bp);
353 cp += n;
354 continue; /* XXX - had_error++ ? */
355 }
356 if (n != host.h_length) {
357 cp += n;
358 continue;
359 }
360 if (!haveanswer) {
361 register int nn;
362
363 host.h_name = bp;
364 nn = strlen(bp) + 1; /* for the \0 */
365 bp += nn;
366 buflen -= nn;
367 }
368
369 bp += sizeof(align) - ((u_long)bp % sizeof(align));
370
371 if (bp + n >= &hostbuf[sizeof hostbuf]) {
372#ifdef DEBUG
373 if (_res.options & RES_DEBUG)
374 printf("size (%d) too big\n", n);
375#endif
376 had_error++;
377 continue;
378 }
379 if (hap >= &h_addr_ptrs[MAXADDRS-1]) {
380 if (!toobig++)
381#ifdef DEBUG
382 if (_res.options & RES_DEBUG)
383 printf("Too many addresses (%d)\n", MAXADDRS);
384#endif
385 cp += n;
386 continue;
387 }
388 bcopy(cp, *hap++ = bp, n);
389 bp += n;
390 buflen -= n;
391 cp += n;
392 break;
393 }
394 if (!had_error)
395 haveanswer++;
396 }
397 if (haveanswer) {
398 *ap = NULL;
399 *hap = NULL;
400# if defined(RESOLVSORT)
401 /*
402 * Note: we sort even if host can take only one address
403 * in its return structures - should give it the "best"
404 * address in that case, not some random one
405 */
406 if (_res.nsort && haveanswer > 1 && qtype == T_A)
407 addrsort(h_addr_ptrs, haveanswer);
408# endif /*RESOLVSORT*/
409 if (!host.h_name) {
410 n = strlen(qname) + 1; /* for the \0 */
411 if (n > buflen)
412 goto try_again;
413 strcpy(bp, qname);
414 host.h_name = bp;
415 bp += n;
416 buflen -= n;
417 }
418 if (_res.options & RES_USE_INET6)
419 map_v4v6_hostent(&host, &bp, &buflen);
420 h_errno = NETDB_SUCCESS;
421 return (&host);
422 }
423 try_again:
424 h_errno = TRY_AGAIN;
425 return (NULL);
426}
427
428#ifndef notyet
429/*
430 * XXX This is an extremely bogus implementations.
431 *
432 * FreeBSD has this interface:
433 * int gethostbyaddr_r(const char *addr, int len, int type,
434 * struct hostent *result, struct hostent_data *buffer)
435 */
436
437struct hostent *
438gethostbyname_r(name, hp, buf, buflen, errorp)
439 const char * name;
440 struct hostent * hp;
441 char * buf;
442 int buflen;
443 int * errorp;
444{
445 struct hostent *res;
446
447 res = gethostbyname(name);
448 *errorp = h_errno;
449 if (res == NULL)
450 return NULL;
451 memcpy(hp, res, sizeof *hp); /* XXX not sufficient */
452 return hp;
453}
454
455/*
456 * XXX This is an extremely bogus implementations.
457 */
458struct hostent *
459gethostbyaddr_r(addr, len, af, he, buf, buflen, errorp)
460 const char *addr; /* XXX should have been def'd as u_char! */
461 int len, af;
462 struct hostent * he;
463 char * buf;
464 int buflen;
465 int * errorp;
466{
467 struct hostent * res;
468
469 res = gethostbyaddr(addr, len, af);
470 *errorp = h_errno;
471 if (res == NULL)
472 return NULL;
473 memcpy(he, res, sizeof *he); /* XXX not sufficient */
474 return he;
475}
476
477/* XXX RFC2133 expects a gethostbyname2_r() -- unimplemented */
478#endif
479
480_THREAD_PRIVATE_MUTEX(gethostnamadr)
481
482struct hostent *
483gethostbyname(name)
484 const char *name;
485{
486 struct hostent *hp;
487 extern struct hostent *_gethtbyname2();
488
489 _THREAD_PRIVATE_MUTEX_LOCK(gethostnamadr);
490 if ((_res.options & RES_INIT) == 0 && res_init() == -1)
491 hp = _gethtbyname2(name, AF_INET);
492
493 else if (_res.options & RES_USE_INET6) {
494 hp = gethostbyname2(name, AF_INET6);
495 if (hp == NULL)
496 hp = gethostbyname2(name, AF_INET);
497 }
498 else
499 hp = gethostbyname2(name, AF_INET);
500 _THREAD_PRIVATE_MUTEX_UNLOCK(gethostnamadr);
501 return hp;
502}
503
504struct hostent *
505gethostbyname2(name, af)
506 const char *name;
507 int af;
508{
509 querybuf buf;
510 register const char *cp;
511 char *bp;
512 int n, size, type, len, i;
513 extern struct hostent *_gethtbyname2(), *_yp_gethtbyname();
514 register struct hostent *hp;
515 char lookups[MAXDNSLUS];
516
517 if ((_res.options & RES_INIT) == 0 && res_init() == -1)
518 return (_gethtbyname2(name, af));
519
520 switch (af) {
521 case AF_INET:
522 size = INADDRSZ;
523 type = T_A;
524 break;
525 case AF_INET6:
526 size = IN6ADDRSZ;
527 type = T_AAAA;
528 break;
529 default:
530 h_errno = NETDB_INTERNAL;
531 errno = EAFNOSUPPORT;
532 return (NULL);
533 }
534
535 host.h_addrtype = af;
536 host.h_length = size;
537
538 /*
539 * if there aren't any dots, it could be a user-level alias.
540 * this is also done in res_query() since we are not the only
541 * function that looks up host names.
542 */
543 if (!strchr(name, '.') && (cp = __hostalias(name)))
544 name = cp;
545
546 /*
547 * disallow names consisting only of digits/dots, unless
548 * they end in a dot.
549 */
550 if (isdigit(name[0]))
551 for (cp = name;; ++cp) {
552 if (!*cp) {
553 if (*--cp == '.')
554 break;
555 /*
556 * All-numeric, no dot at the end.
557 * Fake up a hostent as if we'd actually
558 * done a lookup.
559 */
560 if (inet_pton(af, name, host_addr) <= 0) {
561 h_errno = HOST_NOT_FOUND;
562 return (NULL);
563 }
564 strncpy(hostbuf, name, MAXHOSTNAMELEN-1);
565 hostbuf[MAXHOSTNAMELEN-1] = '\0';
566 bp = hostbuf + MAXHOSTNAMELEN;
567 len = sizeof hostbuf - MAXHOSTNAMELEN;
568 host.h_name = hostbuf;
569 host.h_aliases = host_aliases;
570 host_aliases[0] = NULL;
571 h_addr_ptrs[0] = (char *)host_addr;
572 h_addr_ptrs[1] = NULL;
573 host.h_addr_list = h_addr_ptrs;
574 if (_res.options & RES_USE_INET6)
575 map_v4v6_hostent(&host, &bp, &len);
576 h_errno = NETDB_SUCCESS;
577 return (&host);
578 }
579 if (!isdigit(*cp) && *cp != '.')
580 break;
581 }
582 if ((isxdigit(name[0]) && strchr(name, ':') != NULL) ||
583 name[0] == ':')
584 for (cp = name;; ++cp) {
585 if (!*cp) {
586 if (*--cp == '.')
587 break;
588 /*
589 * All-IPv6-legal, no dot at the end.
590 * Fake up a hostent as if we'd actually
591 * done a lookup.
592 */
593 if (inet_pton(af, name, host_addr) <= 0) {
594 h_errno = HOST_NOT_FOUND;
595 return (NULL);
596 }
597 strncpy(hostbuf, name, MAXHOSTNAMELEN-1);
598 hostbuf[MAXHOSTNAMELEN-1] = '\0';
599 bp = hostbuf + MAXHOSTNAMELEN;
600 len = sizeof hostbuf - MAXHOSTNAMELEN;
601 host.h_name = hostbuf;
602 host.h_aliases = host_aliases;
603 host_aliases[0] = NULL;
604 h_addr_ptrs[0] = (char *)host_addr;
605 h_addr_ptrs[1] = NULL;
606 host.h_addr_list = h_addr_ptrs;
607 h_errno = NETDB_SUCCESS;
608 return (&host);
609 }
610 if (!isxdigit(*cp) && *cp != ':' && *cp != '.')
611 break;
612 }
613
614 bcopy(_res.lookups, lookups, sizeof lookups);
615 if (lookups[0] == '\0')
616 strncpy(lookups, "bf", sizeof lookups);
617
618 hp = (struct hostent *)NULL;
619 for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) {
620 switch (lookups[i]) {
621#ifdef YP
622 case 'y':
623 /* YP only supports AF_INET. */
624 if (af == AF_INET)
625 hp = _yp_gethtbyname(name);
626 break;
627#endif
628 case 'b':
629 if ((n = res_search(name, C_IN, type, buf.buf,
630 sizeof(buf))) < 0) {
631#ifdef DEBUG
632 if (_res.options & RES_DEBUG)
633 printf("res_search failed\n");
634#endif
635 break;
636 }
637 hp = getanswer(&buf, n, name, type);
638 break;
639 case 'f':
640 hp = _gethtbyname2(name, af);
641 break;
642 }
643 }
644 /* XXX h_errno not correct in all cases... */
645 return (hp);
646}
647
648struct hostent *
649gethostbyaddr(addr, len, af)
650 const char *addr; /* XXX should have been def'd as u_char! */
651 int len, af;
652{
653 const u_char *uaddr = (const u_char *)addr;
654 static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff };
655 static const u_char tunnelled[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 };
656 int n, size, i;
657 querybuf buf;
658 register struct hostent *hp;
659 char qbuf[MAXDNAME+1], *qp;
660 extern struct hostent *_gethtbyaddr(), *_yp_gethtbyaddr();
661 char lookups[MAXDNSLUS];
662 struct hostent *res;
663
664 _THREAD_PRIVATE_MUTEX_LOCK(gethostnamadr);
665 if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
666 res = _gethtbyaddr(addr, len, af);
667 _THREAD_PRIVATE_MUTEX_UNLOCK(gethostnamadr);
668 return (res);
669 }
670
671 if (af == AF_INET6 && len == IN6ADDRSZ &&
672 (!bcmp(uaddr, mapped, sizeof mapped) ||
673 !bcmp(uaddr, tunnelled, sizeof tunnelled))) {
674 /* Unmap. */
675 addr += sizeof mapped;
676 uaddr += sizeof mapped;
677 af = AF_INET;
678 len = INADDRSZ;
679 }
680 switch (af) {
681 case AF_INET:
682 size = INADDRSZ;
683 break;
684 case AF_INET6:
685 size = IN6ADDRSZ;
686 break;
687 default:
688 errno = EAFNOSUPPORT;
689 h_errno = NETDB_INTERNAL;
690 _THREAD_PRIVATE_MUTEX_UNLOCK(gethostnamadr);
691 return (NULL);
692 }
693 if (size != len) {
694 errno = EINVAL;
695 h_errno = NETDB_INTERNAL;
696 _THREAD_PRIVATE_MUTEX_UNLOCK(gethostnamadr);
697 return (NULL);
698 }
699 switch (af) {
700 case AF_INET:
701 (void) sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa",
702 (uaddr[3] & 0xff),
703 (uaddr[2] & 0xff),
704 (uaddr[1] & 0xff),
705 (uaddr[0] & 0xff));
706 break;
707 case AF_INET6:
708 qp = qbuf;
709 for (n = IN6ADDRSZ - 1; n >= 0; n--) {
710 qp += sprintf(qp, "%x.%x.",
711 uaddr[n] & 0xf,
712 (uaddr[n] >> 4) & 0xf);
713 }
714 strcpy(qp, "ip6.int");
715 break;
716 }
717
718 bcopy(_res.lookups, lookups, sizeof lookups);
719 if (lookups[0] == '\0')
720 strncpy(lookups, "bf", sizeof lookups);
721
722 hp = (struct hostent *)NULL;
723 for (i = 0; i < MAXDNSLUS && hp == NULL && lookups[i]; i++) {
724 switch (lookups[i]) {
725#ifdef YP
726 case 'y':
727 /* YP only supports AF_INET. */
728 if (af == AF_INET)
729 hp = _yp_gethtbyaddr(addr);
730 break;
731#endif
732 case 'b':
733 n = res_query(qbuf, C_IN, T_PTR, (u_char *)buf.buf,
734 sizeof buf.buf);
735 if (n < 0) {
736#ifdef DEBUG
737 if (_res.options & RES_DEBUG)
738 printf("res_query failed\n");
739#endif
740 break;
741 }
742 if (!(hp = getanswer(&buf, n, qbuf, T_PTR)))
743 break;
744 hp->h_addrtype = af;
745 hp->h_length = len;
746 bcopy(addr, host_addr, len);
747 h_addr_ptrs[0] = (char *)host_addr;
748 h_addr_ptrs[1] = NULL;
749 if (af == AF_INET && (_res.options & RES_USE_INET6)) {
750 map_v4v6_address((char*)host_addr,
751 (char*)host_addr);
752 hp->h_addrtype = AF_INET6;
753 hp->h_length = IN6ADDRSZ;
754 }
755 h_errno = NETDB_SUCCESS;
756 break;
757 case 'f':
758 hp = _gethtbyaddr(addr, len, af);
759 break;
760 }
761 }
762 _THREAD_PRIVATE_MUTEX_UNLOCK(gethostnamadr);
763 /* XXX h_errno not correct in all cases... */
764 return (hp);
765}
766
767void
768_sethtent(f)
769 int f;
770{
771 if (hostf == NULL)
772 hostf = fopen(_PATH_HOSTS, "r" );
773 else
774 rewind(hostf);
775 stayopen = f;
776}
777
778void
779_endhtent()
780{
781 if (hostf && !stayopen) {
782 (void) fclose(hostf);
783 hostf = NULL;
784 }
785}
786
787struct hostent *
788_gethtent()
789{
790 char *p;
791 register char *cp, **q;
792 int af;
793 size_t len;
794
795 if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) {
796 h_errno = NETDB_INTERNAL;
797 return (NULL);
798 }
799 again:
800 if ((p = fgetln(hostf, &len)) == NULL) {
801 h_errno = HOST_NOT_FOUND;
802 return (NULL);
803 }
804 if (p[len-1] == '\n')
805 len--;
806 if (len >= sizeof(hostbuf) || len == 0)
807 goto again;
808 p = memcpy(hostbuf, p, len);
809 hostbuf[len] = '\0';
810 if (*p == '#')
811 goto again;
812 if ((cp = strchr(p, '#')))
813 *cp = '\0';
814 if (!(cp = strpbrk(p, " \t")))
815 goto again;
816 *cp++ = '\0';
817 if ((_res.options & RES_USE_INET6) &&
818 inet_pton(AF_INET6, p, host_addr) > 0) {
819 af = AF_INET6;
820 len = IN6ADDRSZ;
821 } else if (inet_pton(AF_INET, p, host_addr) > 0) {
822 if (_res.options & RES_USE_INET6) {
823 map_v4v6_address((char*)host_addr, (char*)host_addr);
824 af = AF_INET6;
825 len = IN6ADDRSZ;
826 } else {
827 af = AF_INET;
828 len = INADDRSZ;
829 }
830 } else {
831 goto again;
832 }
833 h_addr_ptrs[0] = (char *)host_addr;
834 h_addr_ptrs[1] = NULL;
835 host.h_addr_list = h_addr_ptrs;
836 host.h_length = len;
837 host.h_addrtype = af;
838 while (*cp == ' ' || *cp == '\t')
839 cp++;
840 host.h_name = cp;
841 q = host.h_aliases = host_aliases;
842 if ((cp = strpbrk(cp, " \t")))
843 *cp++ = '\0';
844 while (cp && *cp) {
845 if (*cp == ' ' || *cp == '\t') {
846 cp++;
847 continue;
848 }
849 if (q < &host_aliases[MAXALIASES - 1])
850 *q++ = cp;
851 if ((cp = strpbrk(cp, " \t")))
852 *cp++ = '\0';
853 }
854 *q = NULL;
855 if (_res.options & RES_USE_INET6) {
856 char *bp = hostbuf;
857 int buflen = sizeof hostbuf;
858
859 map_v4v6_hostent(&host, &bp, &buflen);
860 }
861 h_errno = NETDB_SUCCESS;
862 return (&host);
863}
864
865struct hostent *
866_gethtbyname(name)
867 const char *name;
868{
869 extern struct hostent *_gethtbyname2();
870 struct hostent *hp;
871
872 if (_res.options & RES_USE_INET6) {
873 hp = _gethtbyname2(name, AF_INET6);
874 if (hp)
875 return (hp);
876 }
877 return (_gethtbyname2(name, AF_INET));
878}
879
880struct hostent *
881_gethtbyname2(name, af)
882 const char *name;
883 int af;
884{
885 register struct hostent *p;
886 register char **cp;
887
888 _sethtent(0);
889 while ((p = _gethtent())) {
890 if (p->h_addrtype != af)
891 continue;
892 if (strcasecmp(p->h_name, name) == 0)
893 break;
894 for (cp = p->h_aliases; *cp != 0; cp++)
895 if (strcasecmp(*cp, name) == 0)
896 goto found;
897 }
898 found:
899 _endhtent();
900 return (p);
901}
902
903struct hostent *
904_gethtbyaddr(addr, len, af)
905 const char *addr;
906 int len, af;
907{
908 register struct hostent *p;
909
910 _sethtent(0);
911 while ((p = _gethtent()))
912 if (p->h_addrtype == af && !bcmp(p->h_addr, addr, len))
913 break;
914 _endhtent();
915 return (p);
916}
917
918#ifdef YP
919struct hostent *
920_yphostent(line)
921 char *line;
922{
923 static struct in_addr host_addrs[MAXADDRS];
924 char *p = line;
925 char *cp, **q;
926 char **hap;
927 struct in_addr *buf;
928 int more;
929
930 host.h_name = NULL;
931 host.h_addr_list = h_addr_ptrs;
932 host.h_length = INADDRSZ;
933 host.h_addrtype = AF_INET;
934 hap = h_addr_ptrs;
935 buf = host_addrs;
936 q = host.h_aliases = host_aliases;
937
938nextline:
939 more = 0;
940 cp = strpbrk(p, " \t");
941 if (cp == NULL) {
942 if (host.h_name == NULL)
943 return (NULL);
944 else
945 goto done;
946 }
947 *cp++ = '\0';
948
949 *hap++ = (char *)buf;
950 (void) inet_aton(p, buf++);
951
952 while (*cp == ' ' || *cp == '\t')
953 cp++;
954 p = cp;
955 cp = strpbrk(p, " \t\n");
956 if (cp != NULL) {
957 if (*cp == '\n')
958 more = 1;
959 *cp++ = '\0';
960 }
961 if (!host.h_name)
962 host.h_name = p;
963 else if (strcmp(host.h_name, p)==0)
964 ;
965 else if (q < &host_aliases[MAXALIASES - 1])
966 *q++ = p;
967 p = cp;
968 if (more)
969 goto nextline;
970
971 while (cp && *cp) {
972 if (*cp == ' ' || *cp == '\t') {
973 cp++;
974 continue;
975 }
976 if (*cp == '\n') {
977 cp++;
978 goto nextline;
979 }
980 if (q < &host_aliases[MAXALIASES - 1])
981 *q++ = cp;
982 cp = strpbrk(cp, " \t");
983 if (cp != NULL)
984 *cp++ = '\0';
985 }
986done:
987 *q = NULL;
988 *hap = NULL;
989 return (&host);
990}
991
992struct hostent *
993_yp_gethtbyaddr(addr)
994 const char *addr;
995{
996 struct hostent *hp = (struct hostent *)NULL;
997 static char *__ypcurrent;
998 int __ypcurrentlen, r;
999 char name[sizeof("xxx.xxx.xxx.xxx") + 1];
1000
1001 if (!__ypdomain) {
1002 if (_yp_check(&__ypdomain) == 0)
1003 return (hp);
1004 }
1005 sprintf(name, "%u.%u.%u.%u",
1006 ((unsigned)addr[0] & 0xff),
1007 ((unsigned)addr[1] & 0xff),
1008 ((unsigned)addr[2] & 0xff),
1009 ((unsigned)addr[3] & 0xff));
1010 if (__ypcurrent)
1011 free(__ypcurrent);
1012 __ypcurrent = NULL;
1013 r = yp_match(__ypdomain, "hosts.byaddr", name,
1014 strlen(name), &__ypcurrent, &__ypcurrentlen);
1015 if (r==0)
1016 hp = _yphostent(__ypcurrent);
1017 if (hp==NULL)
1018 h_errno = HOST_NOT_FOUND;
1019 return (hp);
1020}
1021
1022struct hostent *
1023_yp_gethtbyname(name)
1024 const char *name;
1025{
1026 struct hostent *hp = (struct hostent *)NULL;
1027 static char *__ypcurrent;
1028 int __ypcurrentlen, r;
1029
1030 if (strlen(name) >= MAXHOSTNAMELEN)
1031 return (NULL);
1032 if (!__ypdomain) {
1033 if (_yp_check(&__ypdomain) == 0)
1034 return (hp);
1035 }
1036 if (__ypcurrent)
1037 free(__ypcurrent);
1038 __ypcurrent = NULL;
1039 r = yp_match(__ypdomain, "hosts.byname", name,
1040 strlen(name), &__ypcurrent, &__ypcurrentlen);
1041 if (r == 0)
1042 hp = _yphostent(__ypcurrent);
1043 if (hp == NULL)
1044 h_errno = HOST_NOT_FOUND;
1045 return (hp);
1046}
1047#endif
1048
1049static void
1050map_v4v6_address(src, dst)
1051 const char *src;
1052 char *dst;
1053{
1054 u_char *p = (u_char *)dst;
1055 char tmp[INADDRSZ];
1056 int i;
1057
1058 /* Stash a temporary copy so our caller can update in place. */
1059 bcopy(src, tmp, INADDRSZ);
1060 /* Mark this ipv6 addr as a mapped ipv4. */
1061 for (i = 0; i < 10; i++)
1062 *p++ = 0x00;
1063 *p++ = 0xff;
1064 *p++ = 0xff;
1065 /* Retrieve the saved copy and we're done. */
1066 bcopy(tmp, (void*)p, INADDRSZ);
1067}
1068
1069static void
1070map_v4v6_hostent(hp, bpp, lenp)
1071 struct hostent *hp;
1072 char **bpp;
1073 int *lenp;
1074{
1075 char **ap;
1076
1077 if (hp->h_addrtype != AF_INET || hp->h_length != INADDRSZ)
1078 return;
1079 hp->h_addrtype = AF_INET6;
1080 hp->h_length = IN6ADDRSZ;
1081 for (ap = hp->h_addr_list; *ap; ap++) {
1082 int i = sizeof(align) - ((u_long)*bpp % sizeof(align));
1083
1084 if (*lenp < (i + IN6ADDRSZ)) {
1085 /* Out of memory. Truncate address list here. XXX */
1086 *ap = NULL;
1087 return;
1088 }
1089 *bpp += i;
1090 *lenp -= i;
1091 map_v4v6_address(*ap, *bpp);
1092 *ap = *bpp;
1093 *bpp += IN6ADDRSZ;
1094 *lenp -= IN6ADDRSZ;
1095 }
1096}
1097
1098struct hostent *
1099gethostent()
1100{
1101 return (_gethtent());
1102}
1103
1104#ifdef RESOLVSORT
1105static void
1106addrsort(ap, num)
1107 char **ap;
1108 int num;
1109{
1110 int i, j;
1111 char **p;
1112 short aval[MAXADDRS];
1113 int needsort = 0;
1114
1115 p = ap;
1116 for (i = 0; i < num; i++, p++) {
1117 for (j = 0 ; (unsigned)j < _res.nsort; j++)
1118 if (_res.sort_list[j].addr.s_addr ==
1119 (((struct in_addr *)(*p))->s_addr & _res.sort_list[j].mask))
1120 break;
1121 aval[i] = j;
1122 if (needsort == 0 && i > 0 && j < aval[i-1])
1123 needsort = i;
1124 }
1125 if (!needsort)
1126 return;
1127
1128 while (needsort < num) {
1129 for (j = needsort - 1; j >= 0; j--) {
1130 if (aval[j] > aval[j+1]) {
1131 char *hp;
1132
1133 i = aval[j];
1134 aval[j] = aval[j+1];
1135 aval[j+1] = i;
1136
1137 hp = ap[j];
1138 ap[j] = ap[j+1];
1139 ap[j+1] = hp;
1140
1141 } else
1142 break;
1143 }
1144 needsort++;
1145 }
1146}
1147#endif
diff --git a/src/lib/libc/net/getnetbyaddr.c b/src/lib/libc/net/getnetbyaddr.c
new file mode 100644
index 0000000000..925d1d5895
--- /dev/null
+++ b/src/lib/libc/net/getnetbyaddr.c
@@ -0,0 +1,56 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: getnetbyaddr.c,v 1.5 1997/07/09 01:08:28 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <netdb.h>
39
40extern int _net_stayopen;
41
42struct netent *
43_getnetbyaddr(net, type)
44 register in_addr_t net;
45 register int type;
46{
47 register struct netent *p;
48
49 setnetent(_net_stayopen);
50 while ((p = getnetent()))
51 if (p->n_addrtype == type && p->n_net == net)
52 break;
53 if (!_net_stayopen)
54 endnetent();
55 return (p);
56}
diff --git a/src/lib/libc/net/getnetbyname.c b/src/lib/libc/net/getnetbyname.c
new file mode 100644
index 0000000000..4e39cf6860
--- /dev/null
+++ b/src/lib/libc/net/getnetbyname.c
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: getnetbyname.c,v 1.5 1997/07/09 01:08:29 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <netdb.h>
39#include <string.h>
40
41extern int _net_stayopen;
42
43struct netent *
44_getnetbyname(name)
45 register const char *name;
46{
47 register struct netent *p;
48 register char **cp;
49
50 setnetent(_net_stayopen);
51 while ((p = getnetent())) {
52 if (strcasecmp(p->n_name, name) == 0)
53 break;
54 for (cp = p->n_aliases; *cp != 0; cp++)
55 if (strcasecmp(*cp, name) == 0)
56 goto found;
57 }
58found:
59 if (!_net_stayopen)
60 endnetent();
61 return (p);
62}
diff --git a/src/lib/libc/net/getnetent.3 b/src/lib/libc/net/getnetent.3
new file mode 100644
index 0000000000..5864b75839
--- /dev/null
+++ b/src/lib/libc/net/getnetent.3
@@ -0,0 +1,148 @@
1.\" $OpenBSD: getnetent.3,v 1.5 1998/03/16 05:06:56 millert Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd March 13, 1997
35.Dt GETNETENT 3
36.Os
37.Sh NAME
38.Nm getnetent ,
39.Nm getnetbyaddr ,
40.Nm getnetbyname ,
41.Nm setnetent ,
42.Nm endnetent
43.Nd get network entry
44.Sh SYNOPSIS
45.Fd #include <netdb.h>
46.Ft struct netent *
47.Fn getnetent
48.Ft struct netent *
49.Fn getnetbyname "char *name"
50.Ft struct netent *
51.Fn getnetbyaddr "in_addr_t net" "int type"
52.Fn setnetent "int stayopen"
53.Fn endnetent
54.Sh DESCRIPTION
55The
56.Fn getnetent ,
57.Fn getnetbyname ,
58and
59.Fn getnetbyaddr
60functions
61each return a pointer to an object with the
62following structure
63containing the broken-out
64fields of a line in the network data base,
65.Pa /etc/networks .
66.Bd -literal -offset indent
67struct netent {
68 char *n_name; /* official name of net */
69 char **n_aliases; /* alias list */
70 int n_addrtype; /* net number type */
71 in_addr_t n_net; /* net number */
72};
73.Ed
74.Pp
75The members of this structure are:
76.Bl -tag -width n_addrtype
77.It Fa n_name
78The official name of the network.
79.It Fa n_aliases
80A zero terminated list of alternate names for the network.
81.It Fa n_addrtype
82The type of the network number returned; currently only AF_INET.
83.It Fa n_net
84The network number. Network numbers are returned in machine byte
85order.
86.El
87.Pp
88The
89.Fn getnetent
90function
91reads the next line of the file, opening the file if necessary.
92.Pp
93The
94.Fn setnetent
95function
96opens and rewinds the file. If the
97.Fa stayopen
98flag is non-zero,
99the net data base will not be closed after each call to
100.Fn getnetbyname
101or
102.Fn getnetbyaddr .
103.Pp
104The
105.Fn endnetent
106function
107closes the file.
108.Pp
109The
110.Fn getnetbyname
111function
112and
113.Fn getnetbyaddr
114search the domain name server if the system is configured to use one.
115If the search fails, or no name server is configured, they sequentially
116search from the beginning of the file until a matching net name or
117net address and type is found, or until
118.Dv EOF
119is encountered.
120Network numbers are supplied in host order.
121.Sh FILES
122.Bl -tag -width /etc/networks -compact
123.It Pa /etc/networks
124.El
125.Sh DIAGNOSTICS
126Null pointer
127(0) returned on
128.Dv EOF
129or error.
130.Sh SEE ALSO
131.Xr networks 5 ,
132.Xr resolver 3
133.Sh HISTORY
134The
135.Fn getnetent ,
136.Fn getnetbyaddr ,
137.Fn getnetbyname ,
138.Fn setnetent ,
139and
140.Fn endnetent
141functions appeared in
142.Bx 4.2 .
143.Sh BUGS
144The data space used by these functions is static; if future use
145requires the data, it should be copied before any subsequent calls
146to these functions overwrite it. Only Internet network numbers
147are currently understood. Expecting network numbers to fit in no
148more than 32 bits is naive.
diff --git a/src/lib/libc/net/getnetent.c b/src/lib/libc/net/getnetent.c
new file mode 100644
index 0000000000..8f618a1d5e
--- /dev/null
+++ b/src/lib/libc/net/getnetent.c
@@ -0,0 +1,129 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: getnetent.c,v 1.8 1998/03/16 05:06:57 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <sys/socket.h>
40#include <netinet/in.h>
41#include <arpa/inet.h>
42#include <netdb.h>
43#include <stdio.h>
44#include <string.h>
45
46#define MAXALIASES 35
47
48static FILE *netf;
49static char line[BUFSIZ+1];
50static struct netent net;
51static char *net_aliases[MAXALIASES];
52int _net_stayopen;
53
54void
55setnetent(f)
56 int f;
57{
58 if (netf == NULL)
59 netf = fopen(_PATH_NETWORKS, "r" );
60 else
61 rewind(netf);
62 _net_stayopen |= f;
63}
64
65void
66endnetent()
67{
68 if (netf) {
69 fclose(netf);
70 netf = NULL;
71 }
72 _net_stayopen = 0;
73}
74
75struct netent *
76getnetent()
77{
78 char *p, *cp, **q;
79 size_t len;
80
81 if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL)
82 return (NULL);
83again:
84 if ((p = fgetln(netf, &len)) == NULL)
85 return (NULL);
86 if (p[len-1] == '\n')
87 len--;
88 if (len >= sizeof(line) || len == 0)
89 goto again;
90 p = memcpy(line, p, len);
91 line[len] = '\0';
92 if (*p == '#')
93 goto again;
94 if ((cp = strchr(p, '#')) != NULL)
95 *cp = '\0';
96 net.n_name = p;
97 if (strlen(net.n_name) >= MAXHOSTNAMELEN-1)
98 net.n_name[MAXHOSTNAMELEN-1] = '\0';
99 cp = strpbrk(p, " \t");
100 if (cp == NULL)
101 goto again;
102 *cp++ = '\0';
103 while (*cp == ' ' || *cp == '\t')
104 cp++;
105 p = strpbrk(cp, " \t");
106 if (p != NULL)
107 *p++ = '\0';
108 net.n_net = inet_network(cp);
109 net.n_addrtype = AF_INET;
110 q = net.n_aliases = net_aliases;
111 if (p != NULL)
112 cp = p;
113 while (cp && *cp) {
114 if (*cp == ' ' || *cp == '\t') {
115 cp++;
116 continue;
117 }
118 if (q < &net_aliases[MAXALIASES - 1]) {
119 *q++ = cp;
120 if (strlen(cp) >= MAXHOSTNAMELEN-1)
121 cp[MAXHOSTNAMELEN-1] = '\0';
122 }
123 cp = strpbrk(cp, " \t");
124 if (cp != NULL)
125 *cp++ = '\0';
126 }
127 *q = NULL;
128 return (&net);
129}
diff --git a/src/lib/libc/net/getnetnamadr.c b/src/lib/libc/net/getnetnamadr.c
new file mode 100644
index 0000000000..de208bbac9
--- /dev/null
+++ b/src/lib/libc/net/getnetnamadr.c
@@ -0,0 +1,382 @@
1/* $OpenBSD: getnetnamadr.c,v 1.10 1997/12/02 01:34:05 deraadt Exp $ */
2
3/*
4 * Copyright (c) 1997, Jason Downs. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Jason Downs for the
17 * OpenBSD system.
18 * 4. Neither the name(s) of the author(s) nor the name OpenBSD
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
23 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro
35 * Dep. Matematica Universidade de Coimbra, Portugal, Europe
36 *
37 * Permission to use, copy, modify, and distribute this software for any
38 * purpose with or without fee is hereby granted, provided that the above
39 * copyright notice and this permission notice appear in all copies.
40 */
41/*
42 * Copyright (c) 1983, 1993
43 * The Regents of the University of California. All rights reserved.
44 *
45 * Redistribution and use in source and binary forms, with or without
46 * modification, are permitted provided that the following conditions
47 * are met:
48 * 1. Redistributions of source code must retain the above copyright
49 * notice, this list of conditions and the following disclaimer.
50 * 2. Redistributions in binary form must reproduce the above copyright
51 * notice, this list of conditions and the following disclaimer in the
52 * documentation and/or other materials provided with the distribution.
53 * 3. All advertising materials mentioning features or use of this software
54 * must display the following acknowledgement:
55 * This product includes software developed by the University of
56 * California, Berkeley and its contributors.
57 * 4. Neither the name of the University nor the names of its contributors
58 * may be used to endorse or promote products derived from this software
59 * without specific prior written permission.
60 *
61 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
62 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
63 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
64 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
65 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
66 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
67 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
68 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
69 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
70 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
71 * SUCH DAMAGE.
72 */
73
74#if defined(LIBC_SCCS) && !defined(lint)
75#if 0
76static char sccsid[] = "@(#)getnetbyaddr.c 8.1 (Berkeley) 6/4/93";
77static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03";
78static char rcsid[] = "$From: getnetnamadr.c,v 8.7 1996/08/05 08:31:35 vixie Exp $";
79#else
80static char rcsid[] = "$OpenBSD: getnetnamadr.c,v 1.10 1997/12/02 01:34:05 deraadt Exp $";
81#endif
82#endif /* LIBC_SCCS and not lint */
83
84#include <sys/types.h>
85#include <sys/param.h>
86#include <sys/socket.h>
87#include <netinet/in.h>
88#include <arpa/inet.h>
89#include <arpa/nameser.h>
90
91#include <stdio.h>
92#include <netdb.h>
93#include <resolv.h>
94#include <ctype.h>
95#include <errno.h>
96#include <string.h>
97
98extern int h_errno;
99
100struct netent *_getnetbyaddr __P((in_addr_t net, int type));
101struct netent *_getnetbyname __P((const char *name));
102
103int _hokchar __P((const char *));
104
105#define BYADDR 0
106#define BYNAME 1
107#define MAXALIASES 35
108
109#if PACKETSZ > 1024
110#define MAXPACKET PACKETSZ
111#else
112#define MAXPACKET 1024
113#endif
114
115typedef union {
116 HEADER hdr;
117 u_char buf[MAXPACKET];
118} querybuf;
119
120typedef union {
121 long al;
122 char ac;
123} align;
124
125static struct netent *
126getnetanswer(answer, anslen, net_i)
127 querybuf *answer;
128 int anslen;
129 int net_i;
130{
131
132 register HEADER *hp;
133 register u_char *cp;
134 register int n;
135 u_char *eom;
136 int type, class, buflen, ancount, qdcount, haveanswer, i, nchar;
137 char aux1[MAXHOSTNAMELEN], aux2[MAXHOSTNAMELEN], ans[MAXHOSTNAMELEN];
138 char *in, *st, *pauxt, *bp, **ap;
139 char *paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0;
140 static struct netent net_entry;
141 static char *net_aliases[MAXALIASES], netbuf[BUFSIZ+1];
142
143 /*
144 * find first satisfactory answer
145 *
146 * answer --> +------------+ ( MESSAGE )
147 * | Header |
148 * +------------+
149 * | Question | the question for the name server
150 * +------------+
151 * | Answer | RRs answering the question
152 * +------------+
153 * | Authority | RRs pointing toward an authority
154 * | Additional | RRs holding additional information
155 * +------------+
156 */
157 eom = answer->buf + anslen;
158 hp = &answer->hdr;
159 ancount = ntohs(hp->ancount); /* #/records in the answer section */
160 qdcount = ntohs(hp->qdcount); /* #/entries in the question section */
161 bp = netbuf;
162 buflen = sizeof(netbuf);
163 cp = answer->buf + HFIXEDSZ;
164 if (!qdcount) {
165 if (hp->aa)
166 h_errno = HOST_NOT_FOUND;
167 else
168 h_errno = TRY_AGAIN;
169 return (NULL);
170 }
171 while (qdcount-- > 0)
172 cp += __dn_skipname(cp, eom) + QFIXEDSZ;
173 ap = net_aliases;
174 *ap = NULL;
175 net_entry.n_aliases = net_aliases;
176 haveanswer = 0;
177 while (--ancount >= 0 && cp < eom) {
178 n = dn_expand(answer->buf, eom, cp, bp, buflen);
179#ifdef USE_RESOLV_NAME_OK
180 if ((n < 0) || !res_dnok(bp))
181#else
182 if ((n < 0) || !_hokchar(bp))
183#endif
184 break;
185 cp += n;
186 ans[0] = '\0';
187 (void)strncpy(&ans[0], bp, sizeof ans-1);
188 ans[sizeof ans-1] = '\0';
189 GETSHORT(type, cp);
190 GETSHORT(class, cp);
191 cp += INT32SZ; /* TTL */
192 GETSHORT(n, cp);
193 if (class == C_IN && type == T_PTR) {
194 n = dn_expand(answer->buf, eom, cp, bp, buflen);
195 if ((n < 0) || !res_hnok(bp)) {
196 cp += n;
197 return (NULL);
198 }
199 cp += n;
200 *ap++ = bp;
201 bp += strlen(bp) + 1;
202 net_entry.n_addrtype =
203 (class == C_IN) ? AF_INET : AF_UNSPEC;
204 haveanswer++;
205 }
206 }
207 if (haveanswer) {
208 *ap = NULL;
209 switch (net_i) {
210 case BYADDR:
211 net_entry.n_name = *net_entry.n_aliases;
212 net_entry.n_net = 0L;
213 break;
214 case BYNAME:
215 in = *net_entry.n_aliases;
216 net_entry.n_name = &ans[0];
217 aux2[0] = '\0';
218 for (i = 0; i < 4; i++) {
219 for (st = in, nchar = 0;
220 *st != '.';
221 st++, nchar++)
222 ;
223 if (nchar != 1 || *in != '0' || flag) {
224 flag = 1;
225 (void)strncpy(paux1,
226 (i==0) ? in : in-1,
227 (i==0) ?nchar : nchar+1);
228 paux1[(i==0) ? nchar : nchar+1] = '\0';
229 pauxt = paux2;
230 paux2 = strcat(paux1, paux2);
231 paux1 = pauxt;
232 }
233 in = ++st;
234 }
235 net_entry.n_net = inet_network(paux2);
236 break;
237 }
238 net_entry.n_aliases++;
239 return (&net_entry);
240 }
241 h_errno = TRY_AGAIN;
242 return (NULL);
243}
244
245struct netent *
246getnetbyaddr(net, net_type)
247 register in_addr_t net;
248 register int net_type;
249{
250 unsigned int netbr[4];
251 int nn, anslen;
252 querybuf buf;
253 char qbuf[MAXDNAME];
254 in_addr_t net2;
255 struct netent *net_entry = NULL;
256 char lookups[MAXDNSLUS];
257 int i;
258
259 if ((_res.options & RES_INIT) == 0 && res_init() == -1)
260 return(_getnetbyaddr(net, net_type));
261
262 bcopy(_res.lookups, lookups, sizeof lookups);
263 if (lookups[0] == '\0')
264 strncpy(lookups, "bf", sizeof lookups);
265
266 for (i = 0; i < MAXDNSLUS && lookups[i]; i++) {
267 switch (lookups[i]) {
268#ifdef YP
269 case 'y':
270 /* There is no YP support. */
271 break;
272#endif /* YP */
273 case 'b':
274 if (net_type != AF_INET)
275 break; /* DNS only supports AF_INET? */
276
277 for (nn = 4, net2 = net; net2; net2 >>= 8)
278 netbr[--nn] = net2 & 0xff;
279 switch (nn) {
280 case 3: /* Class A */
281 snprintf(qbuf, sizeof(qbuf),
282 "0.0.0.%u.in-addr.arpa", netbr[3]);
283 break;
284 case 2: /* Class B */
285 snprintf(qbuf, sizeof(qbuf),
286 "0.0.%u.%u.in-addr.arpa",
287 netbr[3], netbr[2]);
288 break;
289 case 1: /* Class C */
290 snprintf(qbuf, sizeof(qbuf),
291 "0.%u.%u.%u.in-addr.arpa",
292 netbr[3], netbr[2], netbr[1]);
293 break;
294 case 0: /* Class D - E */
295 snprintf(qbuf, sizeof(qbuf),
296 "%u.%u.%u.%u.in-addr.arpa",
297 netbr[3], netbr[2], netbr[1], netbr[0]);
298 break;
299 }
300 anslen = res_query(qbuf, C_IN, T_PTR, (u_char *)&buf,
301 sizeof(buf));
302 if (anslen < 0) {
303#ifdef DEBUG
304 if (_res.options & RES_DEBUG)
305 printf("res_query failed\n");
306#endif
307 break;
308 }
309 net_entry = getnetanswer(&buf, anslen, BYADDR);
310 if (net_entry != NULL) {
311 unsigned u_net = net; /* maybe net should be unsigned ? */
312
313 /* Strip trailing zeros */
314 while ((u_net & 0xff) == 0 && u_net != 0)
315 u_net >>= 8;
316 net_entry->n_net = u_net;
317 return (net_entry);
318 }
319 break;
320 case 'f':
321 net_entry = _getnetbyaddr(net, net_type);
322 if (net_entry != NULL)
323 return (net_entry);
324 }
325 }
326
327 /* Nothing matched. */
328 return (NULL);
329}
330
331struct netent *
332getnetbyname(net)
333 register const char *net;
334{
335 int anslen;
336 querybuf buf;
337 char qbuf[MAXDNAME];
338 struct netent *net_entry = NULL;
339 char lookups[MAXDNSLUS];
340 int i;
341
342 if ((_res.options & RES_INIT) == 0 && res_init() == -1)
343 return (_getnetbyname(net));
344
345 bcopy(_res.lookups, lookups, sizeof lookups);
346 if (lookups[0] == '\0')
347 strncpy(lookups, "bf", sizeof lookups);
348
349 for (i = 0; i < MAXDNSLUS && lookups[i]; i++) {
350 switch (lookups[i]) {
351#ifdef YP
352 case 'y':
353 /* There is no YP support. */
354 break;
355#endif /* YP */
356 case 'b':
357 strncpy(qbuf, net, sizeof qbuf-1);
358 qbuf[sizeof qbuf-1] = '\0';
359 anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)&buf,
360 sizeof(buf));
361 if (anslen < 0) {
362#ifdef DEBUG
363 if (_res.options & RES_DEBUG)
364 printf("res_query failed\n");
365#endif
366 break;
367 }
368 net_entry = getnetanswer(&buf, anslen, BYNAME);
369 if (net_entry != NULL)
370 return (net_entry);
371 break;
372 case 'f':
373 net_entry = _getnetbyname(net);
374 if (net_entry != NULL)
375 return (net_entry);
376 break;
377 }
378 }
379
380 /* Nothing matched. */
381 return (NULL);
382}
diff --git a/src/lib/libc/net/getproto.c b/src/lib/libc/net/getproto.c
new file mode 100644
index 0000000000..474d8d9427
--- /dev/null
+++ b/src/lib/libc/net/getproto.c
@@ -0,0 +1,55 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: getproto.c,v 1.3 1997/07/09 01:08:31 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <netdb.h>
39
40extern int _proto_stayopen;
41
42struct protoent *
43getprotobynumber(proto)
44 register int proto;
45{
46 register struct protoent *p;
47
48 setprotoent(_proto_stayopen);
49 while ((p = getprotoent()))
50 if (p->p_proto == proto)
51 break;
52 if (!_proto_stayopen)
53 endprotoent();
54 return (p);
55}
diff --git a/src/lib/libc/net/getprotoent.3 b/src/lib/libc/net/getprotoent.3
new file mode 100644
index 0000000000..f67987954f
--- /dev/null
+++ b/src/lib/libc/net/getprotoent.3
@@ -0,0 +1,144 @@
1.\" $OpenBSD: getprotoent.3,v 1.2 1996/08/19 08:28:50 tholo Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd June 4, 1993
35.Dt GETPROTOENT 3
36.Os BSD 4.2
37.Sh NAME
38.Nm getprotoent ,
39.Nm getprotobynumber ,
40.Nm getprotobyname ,
41.Nm setprotoent ,
42.Nm endprotoent
43.Nd get protocol entry
44.Sh SYNOPSIS
45.Fd #include <netdb.h>
46.Ft struct protoent *
47.Fn getprotoent
48.Ft struct protoent *
49.Fn getprotobyname "char *name"
50.Ft struct protoent *
51.Fn getprotobynumber "int proto"
52.Fn setprotoent "int stayopen"
53.Fn endprotoent
54.Sh DESCRIPTION
55The
56.Fn getprotoent ,
57.Fn getprotobyname ,
58and
59.Fn getprotobynumber
60functions
61each return a pointer to an object with the
62following structure
63containing the broken-out
64fields of a line in the network protocol data base,
65.Pa /etc/protocols .
66.Bd -literal -offset indent
67.Pp
68struct protoent {
69 char *p_name; /* official name of protocol */
70 char **p_aliases; /* alias list */
71 int p_proto; /* protocol number */
72};
73.Ed
74.Pp
75The members of this structure are:
76.Bl -tag -width p_aliases
77.It Fa p_name
78The official name of the protocol.
79.It Fa p_aliases
80A zero terminated list of alternate names for the protocol.
81.It Fa p_proto
82The protocol number.
83.El
84.Pp
85The
86.Fn getprotoent
87function
88reads the next line of the file, opening the file if necessary.
89.Pp
90The
91.Fn setprotoent
92function
93opens and rewinds the file. If the
94.Fa stayopen
95flag is non-zero,
96the net data base will not be closed after each call to
97.Fn getprotobyname
98or
99.Fn getprotobynumber .
100.Pp
101The
102.Fn endprotoent
103function
104closes the file.
105.Pp
106The
107.Fn getprotobyname
108function
109and
110.Fn getprotobynumber
111sequentially search from the beginning
112of the file until a matching
113protocol name or
114protocol number is found,
115or until
116.Dv EOF
117is encountered.
118.Sh RETURN VALUES
119Null pointer
120(0) returned on
121.Dv EOF
122or error.
123.Sh FILES
124.Bl -tag -width /etc/protocols -compact
125.It Pa /etc/protocols
126.El
127.Sh SEE ALSO
128.Xr protocols 5
129.Sh HISTORY
130The
131.Fn getprotoent ,
132.Fn getprotobynumber ,
133.Fn getprotobyname ,
134.Fn setprotoent ,
135and
136.Fn endprotoent
137functions appeared in
138.Bx 4.2 .
139.Sh BUGS
140These functions use a static data space;
141if the data is needed for future use, it should be
142copied before any subsequent calls overwrite it.
143Only the Internet
144protocols are currently understood.
diff --git a/src/lib/libc/net/getprotoent.c b/src/lib/libc/net/getprotoent.c
new file mode 100644
index 0000000000..2bef526e7a
--- /dev/null
+++ b/src/lib/libc/net/getprotoent.c
@@ -0,0 +1,123 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: getprotoent.c,v 1.3 1998/03/16 05:06:59 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <sys/socket.h>
40#include <netdb.h>
41#include <stdio.h>
42#include <stdlib.h>
43#include <string.h>
44
45#define MAXALIASES 35
46
47static FILE *protof = NULL;
48static char line[BUFSIZ+1];
49static struct protoent proto;
50static char *proto_aliases[MAXALIASES];
51int _proto_stayopen;
52
53void
54setprotoent(f)
55 int f;
56{
57 if (protof == NULL)
58 protof = fopen(_PATH_PROTOCOLS, "r" );
59 else
60 rewind(protof);
61 _proto_stayopen |= f;
62}
63
64void
65endprotoent()
66{
67 if (protof) {
68 fclose(protof);
69 protof = NULL;
70 }
71 _proto_stayopen = 0;
72}
73
74struct protoent *
75getprotoent()
76{
77 char *p, *cp, **q;
78 size_t len;
79
80 if (protof == NULL && (protof = fopen(_PATH_PROTOCOLS, "r" )) == NULL)
81 return (NULL);
82again:
83 if ((p = fgetln(protof, &len)) == NULL)
84 return (NULL);
85 if (p[len-1] == '\n')
86 len--;
87 if (len >= sizeof(line) || len == 0)
88 goto again;
89 p = memcpy(line, p, len);
90 line[len] = '\0';
91 if (*p == '#')
92 goto again;
93 if ((cp = strchr(p, '#')) != NULL)
94 *cp = '\0';
95 proto.p_name = p;
96 cp = strpbrk(p, " \t");
97 if (cp == NULL)
98 goto again;
99 *cp++ = '\0';
100 while (*cp == ' ' || *cp == '\t')
101 cp++;
102 p = strpbrk(cp, " \t");
103 if (p != NULL)
104 *p++ = '\0';
105 proto.p_proto = atoi(cp);
106 q = proto.p_aliases = proto_aliases;
107 if (p != NULL) {
108 cp = p;
109 while (cp && *cp) {
110 if (*cp == ' ' || *cp == '\t') {
111 cp++;
112 continue;
113 }
114 if (q < &proto_aliases[MAXALIASES - 1])
115 *q++ = cp;
116 cp = strpbrk(cp, " \t");
117 if (cp != NULL)
118 *cp++ = '\0';
119 }
120 }
121 *q = NULL;
122 return (&proto);
123}
diff --git a/src/lib/libc/net/getprotoname.c b/src/lib/libc/net/getprotoname.c
new file mode 100644
index 0000000000..7a4e5fede5
--- /dev/null
+++ b/src/lib/libc/net/getprotoname.c
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: getprotoname.c,v 1.3 1997/07/09 01:08:32 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <netdb.h>
39#include <string.h>
40
41extern int _proto_stayopen;
42
43struct protoent *
44getprotobyname(name)
45 register const char *name;
46{
47 register struct protoent *p;
48 register char **cp;
49
50 setprotoent(_proto_stayopen);
51 while ((p = getprotoent())) {
52 if (strcmp(p->p_name, name) == 0)
53 break;
54 for (cp = p->p_aliases; *cp != 0; cp++)
55 if (strcmp(*cp, name) == 0)
56 goto found;
57 }
58found:
59 if (!_proto_stayopen)
60 endprotoent();
61 return (p);
62}
diff --git a/src/lib/libc/net/getservbyname.c b/src/lib/libc/net/getservbyname.c
new file mode 100644
index 0000000000..7375c89404
--- /dev/null
+++ b/src/lib/libc/net/getservbyname.c
@@ -0,0 +1,87 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: getservbyname.c,v 1.4 1998/11/20 11:18:44 d Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <netdb.h>
39#include <string.h>
40#include "thread_private.h"
41
42extern int _serv_stayopen;
43
44_THREAD_PRIVATE_MUTEX(getservbyname_r)
45
46struct servent *
47getservbyname_r(name, proto, se, buf, buflen)
48 const char *name, *proto;
49 struct servent *se;
50 char *buf;
51 int buflen;
52{
53 register struct servent *p;
54 register char **cp;
55
56 _THREAD_PRIVATE_MUTEX_LOCK(getservbyname_r);
57 setservent(_serv_stayopen);
58 while ((p = getservent())) {
59 if (strcmp(name, p->s_name) == 0)
60 goto gotname;
61 for (cp = p->s_aliases; *cp; cp++)
62 if (strcmp(name, *cp) == 0)
63 goto gotname;
64 continue;
65gotname:
66 if (proto == 0 || strcmp(p->s_proto, proto) == 0)
67 break;
68 }
69 if (!_serv_stayopen)
70 endservent();
71 _THREAD_PRIVATE_MUTEX_UNLOCK(getservbyname_r);
72 return (p);
73}
74
75struct servent *getservbyname(name, proto)
76 const char *name, *proto;
77{
78 _THREAD_PRIVATE_KEY(getservbyname)
79 static char buf[4096];
80 char *bufp = (char*)_THREAD_PRIVATE(getservbyname, buf, NULL);
81
82 if (bufp == NULL)
83 return (NULL);
84 return getservbyname_r(name, proto, (struct servent*) bufp,
85 bufp + sizeof(struct servent),
86 sizeof buf - sizeof(struct servent) );
87}
diff --git a/src/lib/libc/net/getservbyport.c b/src/lib/libc/net/getservbyport.c
new file mode 100644
index 0000000000..4b063760d2
--- /dev/null
+++ b/src/lib/libc/net/getservbyport.c
@@ -0,0 +1,60 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: getservbyport.c,v 1.3 1997/07/09 01:08:35 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <netdb.h>
39#include <string.h>
40
41extern int _serv_stayopen;
42
43struct servent *
44getservbyport(port, proto)
45 int port;
46 const char *proto;
47{
48 register struct servent *p;
49
50 setservent(_serv_stayopen);
51 while ((p = getservent())) {
52 if (p->s_port != port)
53 continue;
54 if (proto == 0 || strcmp(p->s_proto, proto) == 0)
55 break;
56 }
57 if (!_serv_stayopen)
58 endservent();
59 return (p);
60}
diff --git a/src/lib/libc/net/getservent.3 b/src/lib/libc/net/getservent.3
new file mode 100644
index 0000000000..3bbcc38a6b
--- /dev/null
+++ b/src/lib/libc/net/getservent.3
@@ -0,0 +1,155 @@
1.\" $OpenBSD: getservent.3,v 1.4 1999/03/02 03:47:46 deraadt Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd January 12, 1994
35.Dt GETSERVENT 3
36.Os BSD 4.2
37.Sh NAME
38.Nm getservent ,
39.Nm getservbyport ,
40.Nm getservbyname ,
41.Nm setservent ,
42.Nm endservent
43.Nd get service entry
44.Sh SYNOPSIS
45.Fd #include <netdb.h>
46.Ft struct servent *
47.Fn getservent
48.Ft struct servent *
49.Fn getservbyname "char *name" "char *proto"
50.Ft struct servent *
51.Fn getservbyport "int port" "char *proto"
52.Ft void
53.Fn setservent "int stayopen"
54.Ft void
55.Fn endservent void
56.Sh DESCRIPTION
57The
58.Fn getservent ,
59.Fn getservbyname ,
60and
61.Fn getservbyport
62functions
63each return a pointer to an object with the
64following structure
65containing the broken-out
66fields of a line in the network services data base,
67.Pa /etc/services .
68.Bd -literal -offset indent
69struct servent {
70 char *s_name; /* official name of service */
71 char **s_aliases; /* alias list */
72 int s_port; /* port service resides at */
73 char *s_proto; /* protocol to use */
74};
75.Ed
76.Pp
77The members of this structure are:
78.Bl -tag -width s_aliases
79.It Fa s_name
80The official name of the service.
81.It Fa s_aliases
82A zero terminated list of alternate names for the service.
83.It Fa s_port
84The port number at which the service resides.
85Port numbers are returned in network byte order.
86.It Fa s_proto
87The name of the protocol to use when contacting the
88service.
89.El
90.Pp
91The
92.Fn getservent
93function
94reads the next line of the file, opening the file if necessary.
95.Pp
96The
97.Fn setservent
98function
99opens and rewinds the file. If the
100.Fa stayopen
101flag is non-zero,
102the net data base will not be closed after each call to
103.Fn getservbyname
104or
105.Fn getservbyport .
106.Pp
107The
108.Fn endservent
109function
110closes the file.
111.Pp
112The
113.Fn getservbyname
114and
115.Fn getservbyport
116functions
117sequentially search from the beginning
118of the file until a matching
119protocol name or
120port number (specified in network byte order) is found,
121or until
122.Dv EOF
123is encountered.
124If a protocol name is also supplied (non-
125.Dv NULL ) ,
126searches must also match the protocol.
127.ne 1i
128.Sh FILES
129.Bl -tag -width /etc/services -compact
130.It Pa /etc/services
131.El
132.Sh DIAGNOSTICS
133Null pointer
134(0) returned on
135.Dv EOF
136or error.
137.Sh SEE ALSO
138.Xr getprotoent 3 ,
139.Xr services 5
140.Sh HISTORY
141The
142.Fn getservent ,
143.Fn getservbyport ,
144.Fn getservbyname ,
145.Fn setservent ,
146and
147.Fn endservent
148functions appeared in
149.Bx 4.2 .
150.Sh BUGS
151These functions use static data storage;
152if the data is needed for future use, it should be
153copied before any subsequent calls overwrite it.
154Expecting port numbers to fit in a 32 bit
155quantity is probably naive.
diff --git a/src/lib/libc/net/getservent.c b/src/lib/libc/net/getservent.c
new file mode 100644
index 0000000000..7d8cb6d8ca
--- /dev/null
+++ b/src/lib/libc/net/getservent.c
@@ -0,0 +1,125 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: getservent.c,v 1.4 1998/03/16 05:07:00 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <sys/socket.h>
40#include <netdb.h>
41#include <stdio.h>
42#include <string.h>
43#include <stdlib.h>
44
45#define MAXALIASES 35
46
47static FILE *servf = NULL;
48static char line[BUFSIZ+1];
49static struct servent serv;
50static char *serv_aliases[MAXALIASES];
51int _serv_stayopen;
52
53void
54setservent(f)
55 int f;
56{
57 if (servf == NULL)
58 servf = fopen(_PATH_SERVICES, "r" );
59 else
60 rewind(servf);
61 _serv_stayopen |= f;
62}
63
64void
65endservent()
66{
67 if (servf) {
68 fclose(servf);
69 servf = NULL;
70 }
71 _serv_stayopen = 0;
72}
73
74struct servent *
75getservent()
76{
77 char *p, *cp, **q;
78 size_t len;
79
80 if (servf == NULL && (servf = fopen(_PATH_SERVICES, "r" )) == NULL)
81 return (NULL);
82again:
83 if ((p = fgetln(servf, &len)) == NULL)
84 return (NULL);
85 if (p[len-1] == '\n')
86 len--;
87 if (len >= sizeof(line) || len == 0)
88 goto again;
89 p = memcpy(line, p, len);
90 line[len] = '\0';
91 if (*p == '#')
92 goto again;
93 if ((cp = strchr(p, '#')) != NULL)
94 *cp = '\0';
95 serv.s_name = p;
96 p = strpbrk(p, " \t");
97 if (p == NULL)
98 goto again;
99 *p++ = '\0';
100 while (*p == ' ' || *p == '\t')
101 p++;
102 cp = strpbrk(p, ",/");
103 if (cp == NULL)
104 goto again;
105 *cp++ = '\0';
106 serv.s_port = htons((in_port_t)atoi(p));
107 serv.s_proto = cp;
108 q = serv.s_aliases = serv_aliases;
109 cp = strpbrk(cp, " \t");
110 if (cp != NULL)
111 *cp++ = '\0';
112 while (cp && *cp) {
113 if (*cp == ' ' || *cp == '\t') {
114 cp++;
115 continue;
116 }
117 if (q < &serv_aliases[MAXALIASES - 1])
118 *q++ = cp;
119 cp = strpbrk(cp, " \t");
120 if (cp != NULL)
121 *cp++ = '\0';
122 }
123 *q = NULL;
124 return (&serv);
125}
diff --git a/src/lib/libc/net/herror.c b/src/lib/libc/net/herror.c
new file mode 100644
index 0000000000..737bb115a7
--- /dev/null
+++ b/src/lib/libc/net/herror.c
@@ -0,0 +1,121 @@
1/* $OpenBSD: herror.c,v 1.4 1997/03/13 19:07:28 downsj Exp $ */
2
3/*
4 * ++Copyright++ 1987, 1993
5 * -
6 * Copyright (c) 1987, 1993
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 * -
37 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
38 *
39 * Permission to use, copy, modify, and distribute this software for any
40 * purpose with or without fee is hereby granted, provided that the above
41 * copyright notice and this permission notice appear in all copies, and that
42 * the name of Digital Equipment Corporation not be used in advertising or
43 * publicity pertaining to distribution of the document or software without
44 * specific, written prior permission.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
47 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
49 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
50 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
52 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 * SOFTWARE.
54 * -
55 * --Copyright--
56 */
57
58#if defined(LIBC_SCCS) && !defined(lint)
59#if 0
60static char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93";
61static char rcsid[] = "$From: herror.c,v 8.3 1996/08/05 08:31:35 vixie Exp $";
62#else
63static char rcsid[] = "$OpenBSD: herror.c,v 1.4 1997/03/13 19:07:28 downsj Exp $";
64#endif
65#endif /* LIBC_SCCS and not lint */
66
67#include <sys/types.h>
68#include <sys/param.h>
69#include <sys/uio.h>
70#include <netdb.h>
71#include <unistd.h>
72#include <string.h>
73
74const char *h_errlist[] = {
75 "Resolver Error 0 (no error)",
76 "Unknown host", /* 1 HOST_NOT_FOUND */
77 "Host name lookup failure", /* 2 TRY_AGAIN */
78 "Unknown server error", /* 3 NO_RECOVERY */
79 "No address associated with name", /* 4 NO_ADDRESS */
80};
81int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] };
82
83extern int h_errno;
84
85/*
86 * herror --
87 * print the error indicated by the h_errno value.
88 */
89void
90herror(s)
91 const char *s;
92{
93 struct iovec iov[4];
94 register struct iovec *v = iov;
95
96 if (s && *s) {
97 v->iov_base = (char *)s;
98 v->iov_len = strlen(s);
99 v++;
100 v->iov_base = ": ";
101 v->iov_len = 2;
102 v++;
103 }
104 v->iov_base = (char *)hstrerror(h_errno);
105 v->iov_len = strlen(v->iov_base);
106 v++;
107 v->iov_base = "\n";
108 v->iov_len = 1;
109 writev(STDERR_FILENO, iov, (v - iov) + 1);
110}
111
112const char *
113hstrerror(err)
114 int err;
115{
116 if (err < 0)
117 return ("Resolver internal error");
118 else if (err < h_nerr)
119 return (h_errlist[err]);
120 return ("Unknown resolver error");
121}
diff --git a/src/lib/libc/net/htonl.c b/src/lib/libc/net/htonl.c
new file mode 100644
index 0000000000..73b7432731
--- /dev/null
+++ b/src/lib/libc/net/htonl.c
@@ -0,0 +1,25 @@
1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 */
5
6#if defined(LIBC_SCCS) && !defined(lint)
7static char *rcsid = "$OpenBSD: htonl.c,v 1.4 1996/12/12 03:19:55 tholo Exp $";
8#endif /* LIBC_SCCS and not lint */
9
10#include <sys/types.h>
11#include <machine/endian.h>
12
13#undef htonl
14
15u_int32_t
16htonl(x)
17 u_int32_t x;
18{
19#if BYTE_ORDER == LITTLE_ENDIAN
20 u_char *s = (u_char *)&x;
21 return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
22#else
23 return x;
24#endif
25}
diff --git a/src/lib/libc/net/htons.c b/src/lib/libc/net/htons.c
new file mode 100644
index 0000000000..47cf25952d
--- /dev/null
+++ b/src/lib/libc/net/htons.c
@@ -0,0 +1,29 @@
1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 */
5
6#if defined(LIBC_SCCS) && !defined(lint)
7static char *rcsid = "$OpenBSD: htons.c,v 1.6 1997/07/25 20:30:07 mickey Exp $";
8#endif /* LIBC_SCCS and not lint */
9
10#include <sys/types.h>
11#include <machine/endian.h>
12
13#undef htons
14
15u_int16_t
16#ifdef __STDC__
17htons(u_int16_t x)
18#else
19htons(x)
20 u_int16_t x;
21#endif
22{
23#if BYTE_ORDER == LITTLE_ENDIAN
24 u_char *s = (u_char *) &x;
25 return (u_int16_t)(s[0] << 8 | s[1]);
26#else
27 return x;
28#endif
29}
diff --git a/src/lib/libc/net/inet.3 b/src/lib/libc/net/inet.3
new file mode 100644
index 0000000000..2fb86cd927
--- /dev/null
+++ b/src/lib/libc/net/inet.3
@@ -0,0 +1,319 @@
1.\" $OpenBSD: inet.3,v 1.4 1997/06/23 04:01:11 millert Exp $
2.\" $NetBSD: inet.3,v 1.7 1997/06/18 02:25:24 lukem Exp $
3.\"
4.\" Copyright (c) 1983, 1990, 1991, 1993
5.\" The Regents of the University of California. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\" @(#)inet.3 8.1 (Berkeley) 6/4/93
36.\"
37.Dd June 18, 1997
38.Dt INET 3
39.Os BSD 4.2
40.Sh NAME
41.Nm inet_addr ,
42.Nm inet_aton ,
43.Nm inet_lnaof ,
44.Nm inet_makeaddr ,
45.Nm inet_netof ,
46.Nm inet_network ,
47.Nm inet_ntoa ,
48.Nm inet_ntop ,
49.Nm inet_pton
50.Nd Internet address manipulation routines
51.Sh SYNOPSIS
52.Fd #include <sys/socket.h>
53.Fd #include <netinet/in.h>
54.Fd #include <arpa/inet.h>
55.Ft in_addr_t
56.Fn inet_addr "const char *cp"
57.Ft int
58.Fn inet_aton "const char *cp" "struct in_addr *addr"
59.Ft in_addr_t
60.Fn inet_lnaof "struct in_addr in"
61.Ft struct in_addr
62.Fn inet_makeaddr "unsigned long net" "unsigned long lna"
63.Ft in_addr_t
64.Fn inet_netof "struct in_addr in"
65.Ft in_addr_t
66.Fn inet_network "const char *cp"
67.Ft char *
68.Fn inet_ntoa "struct in_addr in"
69.Ft const char *
70.Fn inet_ntop "int af" "const void *src" "char *dst" "size_t size"
71.Ft int
72.Fn inet_pton "int af" "const char *src" "void *dst"
73.Sh DESCRIPTION
74The routines
75.Fn inet_aton ,
76.Fn inet_addr
77and
78.Fn inet_network
79interpret character strings representing
80numbers expressed in the Internet standard
81.Ql \&.
82notation.
83The
84.Fn inet_pton
85function converts a presentation format address (that is, printable form
86as held in a character string) to network format (usually a
87.Ft struct in_addr
88or some other internal binary representation, in network byte order). It
89returns 1 if the address was valid for the specified address family, or
900 if the address wasn't parseable in the specified address family, or -1
91if some system error occurred (in which case
92.Va errno
93will have been set). This function is presently valid for AF_INET and
94AF_INET6. The
95.Fn inet_aton
96routine interprets the specified character string as an Internet address,
97placing the address into the structure provided.
98It returns 1 if the string was successfully interpreted,
99or 0 if the string is invalid.
100The
101.Fn inet_addr
102and
103.Fn inet_network
104functions return numbers suitable for use
105as Internet addresses and Internet network
106numbers, respectively.
107.Pp
108The function
109.Fn inet_ntop
110converts an address from network format (usually a
111.Ft struct in_addr
112or some other binary form, in network byte order) to presentation format
113(suitable for external display purposes). It returns NULL if a system
114error occurs (in which case,
115.Va errno
116will have been set), or it returns a pointer to the destination string.
117The routine
118.Fn inet_ntoa
119takes an Internet address and returns an
120.Tn ASCII
121string representing the address in
122.Ql \&.
123notation. The routine
124.Fn inet_makeaddr
125takes an Internet network number and a local
126network address and constructs an Internet address
127from it. The routines
128.Fn inet_netof
129and
130.Fn inet_lnaof
131break apart Internet host addresses, returning
132the network number and local network address part,
133respectively.
134.Pp
135All Internet addresses are returned in network
136order (bytes ordered from left to right).
137All network numbers and local address parts are
138returned as machine format integer values.
139.Sh INTERNET ADDRESSES (IP VERSION 4)
140Values specified using the
141.Ql \&.
142notation take one
143of the following forms:
144.Bd -literal -offset indent
145a.b.c.d
146a.b.c
147a.b
148a
149.Ed
150.Pp
151When four parts are specified, each is interpreted
152as a byte of data and assigned, from left to right,
153to the four bytes of an Internet address. Note
154that when an Internet address is viewed as a 32-bit
155integer quantity on a system that uses little-endian
156byte order (such as the
157.Tn Intel 386, 486
158and
159.Tn Pentium
160processors) the bytes referred to above appear as
161.Dq Li d.c.b.a .
162That is, little-endian bytes are ordered from right to left.
163.Pp
164When a three part address is specified, the last
165part is interpreted as a 16-bit quantity and placed
166in the right-most two bytes of the network address.
167This makes the three part address format convenient
168for specifying Class B network addresses as
169.Dq Li 128.net.host .
170.Pp
171When a two part address is supplied, the last part
172is interpreted as a 24-bit quantity and placed in
173the right most three bytes of the network address.
174This makes the two part address format convenient
175for specifying Class A network addresses as
176.Dq Li net.host .
177.Pp
178When only one part is given, the value is stored
179directly in the network address without any byte
180rearrangement.
181.Pp
182All numbers supplied as
183.Dq parts
184in a
185.Ql \&.
186notation
187may be decimal, octal, or hexadecimal, as specified
188in the C language (i.e., a leading 0x or 0X implies
189hexadecimal; otherwise, a leading 0 implies octal;
190otherwise, the number is interpreted as decimal).
191.Sh INTERNET ADDRESSES (IP VERSION 6)
192The presentation format of an IPv6 address is given in [RFC1884 2.2]:
193.Pp
194There are three conventional forms for representing IPv6 addresses as
195text strings:
196.Bl -enum
197.It
198The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the
199hexadecimal values of the eight 16-bit pieces of the address.
200Examples:
201.Bd -literal -offset indent
202FEDC:BA98:7654:3210:FEDC:BA98:7654:3210
2031080:0:0:0:8:800:200C:417A
204.Ed
205.Pp
206Note that it is not necessary to write the leading zeros in an
207individual field, but there must be at least one numeral in
208every field (except for the case described in 2.).
209.It
210Due to the method of allocating certain styles of IPv6
211addresses, it will be common for addresses to contain long
212strings of zero bits. In order to make writing addresses
213.Pp
214containing zero bits easier a special syntax is available to
215compress the zeros. The use of ``::'' indicates multiple groups
216of 16-bits of zeros. The ``::'' can only appear once in an
217address. The ``::'' can also be used to compress the leading
218and/or trailing zeros in an address.
219.Pp
220For example the following addresses:
221.Bd -literal -offset indent
2221080:0:0:0:8:800:200C:417A a unicast address
223FF01:0:0:0:0:0:0:43 a multicast address
2240:0:0:0:0:0:0:1 the loopback address
2250:0:0:0:0:0:0:0 the unspecified addresses
226.Ed
227.Pp
228may be represented as:
229.Bd -literal -offset indent
2301080::8:800:200C:417A a unicast address
231FF01::43 a multicast address
232::1 the loopback address
233:: the unspecified addresses
234.Ed
235.It
236An alternative form that is sometimes more convenient when
237dealing with a mixed environment of IPv4 and IPv6 nodes is
238x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values
239of the six high-order 16-bit pieces of the address, and the 'd's
240are the decimal values of the four low-order 8-bit pieces of the
241address (standard IPv4 representation). Examples:
242.Bd -literal -offset indent
2430:0:0:0:0:0:13.1.68.3
2440:0:0:0:0:FFFF:129.144.52.38
245.Ed
246.Pp
247or in compressed form:
248.Bd -literal -offset indent
249::13.1.68.3
250::FFFF:129.144.52.38
251.Ed
252.El
253.Sh DIAGNOSTICS
254The constant
255.Dv INADDR_NONE
256is returned by
257.Fn inet_addr
258and
259.Fn inet_network
260for malformed requests.
261.Sh SEE ALSO
262.Xr byteorder 3 ,
263.Xr gethostbyname 3 ,
264.Xr getnetent 3 ,
265.Xr inet_net 3 ,
266.Xr hosts 5 ,
267.Xr networks 5
268.Sh STANDARDS
269The
270.Nm inet_ntop
271and
272.Nm inet_pton
273functions conforms to the IETF IPng BSD API and address formatting
274specifications. Note that
275.Nm inet_pton
276does not accept 1-, 2-, or 3-part dotted addresses; all four parts
277must be specified. This is a narrower input set than that accepted by
278.Nm inet_aton .
279.Sh HISTORY
280The
281.Nm inet_addr ,
282.Nm inet_network ,
283.Nm inet_makeaddr ,
284.Nm inet_lnaof
285and
286.Nm inet_netof
287functions appeared in
288.Bx 4.2 .
289The
290.Nm inet_aton
291and
292.Nm inet_ntoa
293functions appeared in
294.Bx 4.3 .
295The
296.Nm inet_pton
297and
298.Nm inet_ntop
299functions appeared in BIND 4.9.4.
300.Sh BUGS
301The value
302.Dv INADDR_NONE
303(0xffffffff) is a valid broadcast address, but
304.Fn inet_addr
305cannot return that value without indicating failure.
306The newer
307.Fn inet_aton
308function does not share this problem.
309.Pp
310The problem of host byte ordering versus network byte ordering is
311confusing.
312.Pp
313The string returned by
314.Fn inet_ntoa
315resides in a static memory area.
316.Pp
317.Fn inet_addr
318should return a
319.Fa "struct in_addr" .
diff --git a/src/lib/libc/net/inet_addr.c b/src/lib/libc/net/inet_addr.c
new file mode 100644
index 0000000000..5e4dcdafb2
--- /dev/null
+++ b/src/lib/libc/net/inet_addr.c
@@ -0,0 +1,187 @@
1/* $OpenBSD: inet_addr.c,v 1.5 1997/04/05 21:13:10 millert Exp $ */
2
3/*
4 * ++Copyright++ 1983, 1990, 1993
5 * -
6 * Copyright (c) 1983, 1990, 1993
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 * -
37 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
38 *
39 * Permission to use, copy, modify, and distribute this software for any
40 * purpose with or without fee is hereby granted, provided that the above
41 * copyright notice and this permission notice appear in all copies, and that
42 * the name of Digital Equipment Corporation not be used in advertising or
43 * publicity pertaining to distribution of the document or software without
44 * specific, written prior permission.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
47 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
49 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
50 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
52 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 * SOFTWARE.
54 * -
55 * --Copyright--
56 */
57
58#if defined(LIBC_SCCS) && !defined(lint)
59#if 0
60static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
61static char rcsid[] = "$From: inet_addr.c,v 8.5 1996/08/05 08:31:35 vixie Exp $";
62#else
63static char rcsid[] = "$OpenBSD: inet_addr.c,v 1.5 1997/04/05 21:13:10 millert Exp $";
64#endif
65#endif /* LIBC_SCCS and not lint */
66
67#include <sys/types.h>
68#include <sys/param.h>
69#include <netinet/in.h>
70#include <arpa/inet.h>
71#include <ctype.h>
72
73/*
74 * Ascii internet address interpretation routine.
75 * The value returned is in network order.
76 */
77in_addr_t
78inet_addr(cp)
79 register const char *cp;
80{
81 struct in_addr val;
82
83 if (inet_aton(cp, &val))
84 return (val.s_addr);
85 return (INADDR_NONE);
86}
87
88/*
89 * Check whether "cp" is a valid ascii representation
90 * of an Internet address and convert to a binary address.
91 * Returns 1 if the address is valid, 0 if not.
92 * This replaces inet_addr, the return value from which
93 * cannot distinguish between failure and a local broadcast address.
94 */
95int
96inet_aton(cp, addr)
97 register const char *cp;
98 struct in_addr *addr;
99{
100 register in_addr_t val;
101 register int base, n;
102 register char c;
103 u_int parts[4];
104 register u_int *pp = parts;
105
106 c = *cp;
107 for (;;) {
108 /*
109 * Collect number up to ``.''.
110 * Values are specified as for C:
111 * 0x=hex, 0=octal, isdigit=decimal.
112 */
113 if (!isdigit(c))
114 return (0);
115 val = 0; base = 10;
116 if (c == '0') {
117 c = *++cp;
118 if (c == 'x' || c == 'X')
119 base = 16, c = *++cp;
120 else
121 base = 8;
122 }
123 for (;;) {
124 if (isascii(c) && isdigit(c)) {
125 val = (val * base) + (c - '0');
126 c = *++cp;
127 } else if (base == 16 && isascii(c) && isxdigit(c)) {
128 val = (val << 4) |
129 (c + 10 - (islower(c) ? 'a' : 'A'));
130 c = *++cp;
131 } else
132 break;
133 }
134 if (c == '.') {
135 /*
136 * Internet format:
137 * a.b.c.d
138 * a.b.c (with c treated as 16 bits)
139 * a.b (with b treated as 24 bits)
140 */
141 if (pp >= parts + 3)
142 return (0);
143 *pp++ = val;
144 c = *++cp;
145 } else
146 break;
147 }
148 /*
149 * Check for trailing characters.
150 */
151 if (c != '\0' && (!isascii(c) || !isspace(c)))
152 return (0);
153 /*
154 * Concoct the address according to
155 * the number of parts specified.
156 */
157 n = pp - parts + 1;
158 switch (n) {
159
160 case 0:
161 return (0); /* initial nondigit */
162
163 case 1: /* a -- 32 bits */
164 break;
165
166 case 2: /* a.b -- 8.24 bits */
167 if (val > 0xffffff)
168 return (0);
169 val |= parts[0] << 24;
170 break;
171
172 case 3: /* a.b.c -- 8.8.16 bits */
173 if (val > 0xffff)
174 return (0);
175 val |= (parts[0] << 24) | (parts[1] << 16);
176 break;
177
178 case 4: /* a.b.c.d -- 8.8.8.8 bits */
179 if (val > 0xff)
180 return (0);
181 val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
182 break;
183 }
184 if (addr)
185 addr->s_addr = htonl(val);
186 return (1);
187}
diff --git a/src/lib/libc/net/inet_lnaof.c b/src/lib/libc/net/inet_lnaof.c
new file mode 100644
index 0000000000..6aed18699b
--- /dev/null
+++ b/src/lib/libc/net/inet_lnaof.c
@@ -0,0 +1,59 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: inet_lnaof.c,v 1.3 1997/04/05 21:13:11 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/param.h>
39#include <netinet/in.h>
40#include <arpa/inet.h>
41
42/*
43 * Return the local network address portion of an
44 * internet address; handles class a/b/c network
45 * number formats.
46 */
47in_addr_t
48inet_lnaof(in)
49 struct in_addr in;
50{
51 register in_addr_t i = ntohl(in.s_addr);
52
53 if (IN_CLASSA(i))
54 return ((i)&IN_CLASSA_HOST);
55 else if (IN_CLASSB(i))
56 return ((i)&IN_CLASSB_HOST);
57 else
58 return ((i)&IN_CLASSC_HOST);
59}
diff --git a/src/lib/libc/net/inet_makeaddr.c b/src/lib/libc/net/inet_makeaddr.c
new file mode 100644
index 0000000000..196a589e4c
--- /dev/null
+++ b/src/lib/libc/net/inet_makeaddr.c
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: inet_makeaddr.c,v 1.3 1997/04/05 21:13:12 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/param.h>
39#include <netinet/in.h>
40#include <arpa/inet.h>
41
42/*
43 * Formulate an Internet address from network + host. Used in
44 * building addresses stored in the ifnet structure.
45 */
46struct in_addr
47inet_makeaddr(net, host)
48 in_addr_t net, host;
49{
50 in_addr_t addr;
51
52 if (net < 128)
53 addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
54 else if (net < 65536)
55 addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST);
56 else if (net < 16777216L)
57 addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST);
58 else
59 addr = net | host;
60 addr = htonl(addr);
61 return (*(struct in_addr *)&addr);
62}
diff --git a/src/lib/libc/net/inet_net.3 b/src/lib/libc/net/inet_net.3
new file mode 100644
index 0000000000..1a42aff6ea
--- /dev/null
+++ b/src/lib/libc/net/inet_net.3
@@ -0,0 +1,149 @@
1.\" $OpenBSD: inet_net.3,v 1.1 1997/06/23 03:37:26 millert Exp $
2.\" $NetBSD: inet_net.3,v 1.1 1997/06/18 02:25:27 lukem Exp $
3.\"
4.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
5.\" All rights reserved.
6.\"
7.\" This code is derived from software contributed to The NetBSD Foundation
8.\" by Luke Mewburn.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\" notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\" notice, this list of conditions and the following disclaimer in the
17.\" documentation and/or other materials provided with the distribution.
18.\" 3. All advertising materials mentioning features or use of this software
19.\" must display the following acknowledgement:
20.\" This product includes software developed by the NetBSD
21.\" Foundation, Inc. and its contributors.
22.\" 4. Neither the name of The NetBSD Foundation nor the names of its
23.\" contributors may be used to endorse or promote products derived
24.\" from this software without specific prior written permission.
25.\"
26.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
30.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36.\" POSSIBILITY OF SUCH DAMAGE.
37.\"
38.Dd June 18, 1997
39.Dt INET_NET 3
40.Os
41.Sh NAME
42.Nm inet_net_ntop ,
43.Nm inet_net_pton
44.Nd Internet network number manipulation routines
45.Sh SYNOPSIS
46.Fd #include <sys/socket.h>
47.Fd #include <netinet/in.h>
48.Fd #include <arpa/inet.h>
49.Ft char *
50.Fn inet_net_ntop "int af" "const void *src" "int bits" "char *dst" "size_t size"
51.Ft int
52.Fn inet_net_pton "int af" "const char *src" "void *dst" "size_t size"
53.Sh DESCRIPTION
54The
55.Fn inet_net_ntop
56function converts an Internet network number from network format (usually a
57.Ft struct in_addr
58or some other binary form, in network byte order) to CIDR presentation format
59(suitable for external display purposes).
60.Fa bits
61is the number of bits in
62.Fa src
63that are the network number.
64It returns NULL if a system error occurs (in which case,
65.Va errno
66will have been set), or it returns a pointer to the destination string.
67.Pp
68The
69.Fn inet_net_pton
70function converts a presentation format Internet network number (that is,
71printable form as held in a character string) to network format (usually a
72.Ft struct in_addr
73or some other internal binary representation, in network byte order).
74It returns the number of bits (either computed based on the class, or
75specified with /CIDR), or -1 if a failure occurred
76(in which case
77.Va errno
78will have been set.
79It will be set to
80.Er ENOENT
81if the Internet network number was not valid).
82.Pp
83The currently supported value for
84.Fa af
85is: AF_INET.
86.Fa size
87is the size of the result buffer
88.Fa dst .
89.Pp
90.Sh NETWORK NUMBERS (IP VERSION 4)
91Internet network numbers may be specified in one of the following forms:
92.Bd -literal -offset indent
93a.b.c.d/bits
94a.b.c.d
95a.b.c
96a.b
97a
98.Ed
99.Pp
100When four parts are specified, each is interpreted
101as a byte of data and assigned, from left to right,
102to the four bytes of an Internet network number. Note
103that when an Internet network number is viewed as a 32-bit
104integer quantity on a system that uses little-endian
105byte order (such as the
106.Tn Intel 386, 486
107and
108.Tn Pentium
109processors) the bytes referred to above appear as
110.Dq Li d.c.b.a .
111That is, little-endian bytes are ordered from right to left.
112.Pp
113When a three part number is specified, the last
114part is interpreted as a 16-bit quantity and placed
115in the right-most two bytes of the Internet network number.
116This makes the three part number format convenient
117for specifying Class B network numbers as
118.Dq Li 128.net.host .
119.Pp
120When a two part number is supplied, the last part
121is interpreted as a 24-bit quantity and placed in
122the right most three bytes of the Internet network number.
123This makes the two part number format convenient
124for specifying Class A network numbers as
125.Dq Li net.host .
126.Pp
127When only one part is given, the value is stored
128directly in the Internet network number without any byte
129rearrangement.
130.Pp
131All numbers supplied as
132.Dq parts
133in a
134.Ql \&.
135notation
136may be decimal, octal, or hexadecimal, as specified
137in the C language (i.e., a leading 0x or 0X implies
138hexadecimal; otherwise, a leading 0 implies octal;
139otherwise, the number is interpreted as decimal).
140.Sh SEE ALSO
141.Xr byteorder 3 ,
142.Xr inet 3 ,
143.Xr networks 5
144.Sh HISTORY
145The
146.Nm inet_net_ntop
147and
148.Nm inet_net_pton
149functions first appeared in BIND 4.9.4.
diff --git a/src/lib/libc/net/inet_net_ntop.c b/src/lib/libc/net/inet_net_ntop.c
new file mode 100644
index 0000000000..943ec44550
--- /dev/null
+++ b/src/lib/libc/net/inet_net_ntop.c
@@ -0,0 +1,139 @@
1/* $OpenBSD: inet_net_ntop.c,v 1.1 1997/03/13 19:07:30 downsj Exp $ */
2
3/*
4 * Copyright (c) 1996 by Internet Software Consortium.
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
11 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
12 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
13 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
16 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
17 * SOFTWARE.
18 */
19
20#if defined(LIBC_SCCS) && !defined(lint)
21#if 0
22static const char rcsid[] = "$From: inet_net_ntop.c,v 8.2 1996/08/08 06:54:44 vixie Exp $";
23#else
24static const char rcsid[] = "$OpenBSD: inet_net_ntop.c,v 1.1 1997/03/13 19:07:30 downsj Exp $";
25#endif
26#endif
27
28#include <sys/types.h>
29#include <sys/socket.h>
30#include <netinet/in.h>
31#include <arpa/inet.h>
32
33#include <errno.h>
34#include <stdio.h>
35#include <string.h>
36#include <stdlib.h>
37
38static char * inet_net_ntop_ipv4 __P((const u_char *src, int bits,
39 char *dst, size_t size));
40
41/*
42 * char *
43 * inet_net_ntop(af, src, bits, dst, size)
44 * convert network number from network to presentation format.
45 * generates CIDR style result always.
46 * return:
47 * pointer to dst, or NULL if an error occurred (check errno).
48 * author:
49 * Paul Vixie (ISC), July 1996
50 */
51char *
52inet_net_ntop(af, src, bits, dst, size)
53 int af;
54 const void *src;
55 int bits;
56 char *dst;
57 size_t size;
58{
59 switch (af) {
60 case AF_INET:
61 return (inet_net_ntop_ipv4(src, bits, dst, size));
62 default:
63 errno = EAFNOSUPPORT;
64 return (NULL);
65 }
66}
67
68/*
69 * static char *
70 * inet_net_ntop_ipv4(src, bits, dst, size)
71 * convert IPv4 network number from network to presentation format.
72 * generates CIDR style result always.
73 * return:
74 * pointer to dst, or NULL if an error occurred (check errno).
75 * note:
76 * network byte order assumed. this means 192.5.5.240/28 has
77 * 0x11110000 in its fourth octet.
78 * author:
79 * Paul Vixie (ISC), July 1996
80 */
81static char *
82inet_net_ntop_ipv4(src, bits, dst, size)
83 const u_char *src;
84 int bits;
85 char *dst;
86 size_t size;
87{
88 char *odst = dst;
89 char *t;
90 u_int m;
91 int b;
92
93 if (bits < 0 || bits > 32) {
94 errno = EINVAL;
95 return (NULL);
96 }
97 if (bits == 0) {
98 if (size < sizeof "0")
99 goto emsgsize;
100 *dst++ = '0';
101 *dst = '\0';
102 }
103
104 /* Format whole octets. */
105 for (b = bits / 8; b > 0; b--) {
106 if (size < sizeof "255.")
107 goto emsgsize;
108 t = dst;
109 dst += sprintf(dst, "%u", *src++);
110 if (b > 1) {
111 *dst++ = '.';
112 *dst = '\0';
113 }
114 size -= (size_t)(dst - t);
115 }
116
117 /* Format partial octet. */
118 b = bits % 8;
119 if (b > 0) {
120 if (size < sizeof ".255")
121 goto emsgsize;
122 t = dst;
123 if (dst != odst)
124 *dst++ = '.';
125 m = ((1 << b) - 1) << (8 - b);
126 dst += sprintf(dst, "%u", *src & m);
127 size -= (size_t)(dst - t);
128 }
129
130 /* Format CIDR /width. */
131 if (size < sizeof "/32")
132 goto emsgsize;
133 dst += sprintf(dst, "/%u", bits);
134 return (odst);
135
136 emsgsize:
137 errno = EMSGSIZE;
138 return (NULL);
139}
diff --git a/src/lib/libc/net/inet_net_pton.c b/src/lib/libc/net/inet_net_pton.c
new file mode 100644
index 0000000000..b529e83664
--- /dev/null
+++ b/src/lib/libc/net/inet_net_pton.c
@@ -0,0 +1,207 @@
1/* $OpenBSD: inet_net_pton.c,v 1.1 1997/03/13 19:07:30 downsj Exp $ */
2
3/*
4 * Copyright (c) 1996 by Internet Software Consortium.
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
11 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
12 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
13 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
16 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
17 * SOFTWARE.
18 */
19
20#if defined(LIBC_SCCS) && !defined(lint)
21#if 0
22static const char rcsid[] = "$From: inet_net_pton.c,v 8.3 1996/11/11 06:36:52 vixie Exp $";
23#else
24static const char rcsid[] = "$OpenBSD: inet_net_pton.c,v 1.1 1997/03/13 19:07:30 downsj Exp $";
25#endif
26#endif
27
28#include <sys/types.h>
29#include <sys/socket.h>
30#include <netinet/in.h>
31#include <arpa/inet.h>
32
33#include <assert.h>
34#include <ctype.h>
35#include <errno.h>
36#include <stdio.h>
37#include <string.h>
38#include <stdlib.h>
39
40static int inet_net_pton_ipv4 __P((const char *src, u_char *dst,
41 size_t size));
42
43/*
44 * static int
45 * inet_net_pton(af, src, dst, size)
46 * convert network number from presentation to network format.
47 * accepts hex octets, hex strings, decimal octets, and /CIDR.
48 * "size" is in bytes and describes "dst".
49 * return:
50 * number of bits, either imputed classfully or specified with /CIDR,
51 * or -1 if some failure occurred (check errno). ENOENT means it was
52 * not a valid network specification.
53 * author:
54 * Paul Vixie (ISC), June 1996
55 */
56int
57inet_net_pton(af, src, dst, size)
58 int af;
59 const char *src;
60 void *dst;
61 size_t size;
62{
63 switch (af) {
64 case AF_INET:
65 return (inet_net_pton_ipv4(src, dst, size));
66 default:
67 errno = EAFNOSUPPORT;
68 return (-1);
69 }
70}
71
72/*
73 * static int
74 * inet_net_pton_ipv4(src, dst, size)
75 * convert IPv4 network number from presentation to network format.
76 * accepts hex octets, hex strings, decimal octets, and /CIDR.
77 * "size" is in bytes and describes "dst".
78 * return:
79 * number of bits, either imputed classfully or specified with /CIDR,
80 * or -1 if some failure occurred (check errno). ENOENT means it was
81 * not an IPv4 network specification.
82 * note:
83 * network byte order assumed. this means 192.5.5.240/28 has
84 * 0x11110000 in its fourth octet.
85 * author:
86 * Paul Vixie (ISC), June 1996
87 */
88static int
89inet_net_pton_ipv4(src, dst, size)
90 const char *src;
91 u_char *dst;
92 size_t size;
93{
94 static const char
95 xdigits[] = "0123456789abcdef",
96 digits[] = "0123456789";
97 int n, ch, tmp, dirty, bits;
98 const u_char *odst = dst;
99
100 ch = *src++;
101 if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
102 && isascii(src[1]) && isxdigit(src[1])) {
103 /* Hexadecimal: Eat nybble string. */
104 if (size <= 0)
105 goto emsgsize;
106 *dst = 0, dirty = 0;
107 src++; /* skip x or X. */
108 while ((ch = *src++) != '\0' &&
109 isascii(ch) && isxdigit(ch)) {
110 if (isupper(ch))
111 ch = tolower(ch);
112 n = strchr(xdigits, ch) - xdigits;
113 assert(n >= 0 && n <= 15);
114 *dst |= n;
115 if (!dirty++)
116 *dst <<= 4;
117 else if (size-- > 0)
118 *++dst = 0, dirty = 0;
119 else
120 goto emsgsize;
121 }
122 if (dirty)
123 size--;
124 } else if (isascii(ch) && isdigit(ch)) {
125 /* Decimal: eat dotted digit string. */
126 for (;;) {
127 tmp = 0;
128 do {
129 n = strchr(digits, ch) - digits;
130 assert(n >= 0 && n <= 9);
131 tmp *= 10;
132 tmp += n;
133 if (tmp > 255)
134 goto enoent;
135 } while ((ch = *src++) != '\0' &&
136 isascii(ch) && isdigit(ch));
137 if (size-- <= 0)
138 goto emsgsize;
139 *dst++ = (u_char) tmp;
140 if (ch == '\0' || ch == '/')
141 break;
142 if (ch != '.')
143 goto enoent;
144 ch = *src++;
145 if (!isascii(ch) || !isdigit(ch))
146 goto enoent;
147 }
148 } else
149 goto enoent;
150
151 bits = -1;
152 if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) {
153 /* CIDR width specifier. Nothing can follow it. */
154 ch = *src++; /* Skip over the /. */
155 bits = 0;
156 do {
157 n = strchr(digits, ch) - digits;
158 assert(n >= 0 && n <= 9);
159 bits *= 10;
160 bits += n;
161 } while ((ch = *src++) != '\0' &&
162 isascii(ch) && isdigit(ch));
163 if (ch != '\0')
164 goto enoent;
165 if (bits > 32)
166 goto emsgsize;
167 }
168
169 /* Firey death and destruction unless we prefetched EOS. */
170 if (ch != '\0')
171 goto enoent;
172
173 /* If nothing was written to the destination, we found no address. */
174 if (dst == odst)
175 goto enoent;
176 /* If no CIDR spec was given, infer width from net class. */
177 if (bits == -1) {
178 if (*odst >= 240) /* Class E */
179 bits = 32;
180 else if (*odst >= 224) /* Class D */
181 bits = 4;
182 else if (*odst >= 192) /* Class C */
183 bits = 24;
184 else if (*odst >= 128) /* Class B */
185 bits = 16;
186 else /* Class A */
187 bits = 8;
188 /* If imputed mask is narrower than specified octets, widen. */
189 if (bits >= 8 && bits < ((dst - odst) * 8))
190 bits = (dst - odst) * 8;
191 }
192 /* Extend network to cover the actual mask. */
193 while (bits > ((dst - odst) * 8)) {
194 if (size-- <= 0)
195 goto emsgsize;
196 *dst++ = '\0';
197 }
198 return (bits);
199
200 enoent:
201 errno = ENOENT;
202 return (-1);
203
204 emsgsize:
205 errno = EMSGSIZE;
206 return (-1);
207}
diff --git a/src/lib/libc/net/inet_neta.c b/src/lib/libc/net/inet_neta.c
new file mode 100644
index 0000000000..ffcddd8d91
--- /dev/null
+++ b/src/lib/libc/net/inet_neta.c
@@ -0,0 +1,83 @@
1/* $OpenBSD: inet_neta.c,v 1.2 1997/04/05 21:13:12 millert Exp $ */
2
3/*
4 * Copyright (c) 1996 by Internet Software Consortium.
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
11 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
12 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
13 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
16 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
17 * SOFTWARE.
18 */
19
20#if defined(LIBC_SCCS) && !defined(lint)
21#if 0
22static const char rcsid[] = "$Id: inet_neta.c,v 1.2 1997/04/05 21:13:12 millert Exp $";
23#else
24static const char rcsid[] = "$OpenBSD: inet_neta.c,v 1.2 1997/04/05 21:13:12 millert Exp $";
25#endif
26#endif
27
28#include <sys/types.h>
29#include <sys/socket.h>
30#include <netinet/in.h>
31#include <arpa/inet.h>
32
33#include <errno.h>
34#include <stdio.h>
35#include <string.h>
36
37/*
38 * char *
39 * inet_neta(src, dst, size)
40 * format an in_addr_t network number into presentation format.
41 * return:
42 * pointer to dst, or NULL if an error occurred (check errno).
43 * note:
44 * format of ``src'' is as for inet_network().
45 * author:
46 * Paul Vixie (ISC), July 1996
47 */
48char *
49inet_neta(src, dst, size)
50 in_addr_t src;
51 char *dst;
52 size_t size;
53{
54 char *odst = dst;
55 char *tp;
56
57 while (src & 0xffffffff) {
58 u_char b = (src & 0xff000000) >> 24;
59
60 src <<= 8;
61 if (b) {
62 if (size < sizeof "255.")
63 goto emsgsize;
64 tp = dst;
65 dst += sprintf(dst, "%u", b);
66 if (src != 0L) {
67 *dst++ = '.';
68 *dst = '\0';
69 }
70 size -= (size_t)(dst - tp);
71 }
72 }
73 if (dst == odst) {
74 if (size < sizeof "0.0.0.0")
75 goto emsgsize;
76 strcpy(dst, "0.0.0.0");
77 }
78 return (odst);
79
80 emsgsize:
81 errno = EMSGSIZE;
82 return (NULL);
83}
diff --git a/src/lib/libc/net/inet_netof.c b/src/lib/libc/net/inet_netof.c
new file mode 100644
index 0000000000..f3b9c01697
--- /dev/null
+++ b/src/lib/libc/net/inet_netof.c
@@ -0,0 +1,58 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: inet_netof.c,v 1.3 1997/04/05 21:13:13 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/param.h>
39#include <netinet/in.h>
40#include <arpa/inet.h>
41
42/*
43 * Return the network number from an internet
44 * address; handles class a/b/c network #'s.
45 */
46in_addr_t
47inet_netof(in)
48 struct in_addr in;
49{
50 register in_addr_t i = ntohl(in.s_addr);
51
52 if (IN_CLASSA(i))
53 return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT);
54 else if (IN_CLASSB(i))
55 return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT);
56 else
57 return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
58}
diff --git a/src/lib/libc/net/inet_network.c b/src/lib/libc/net/inet_network.c
new file mode 100644
index 0000000000..8a9a555d62
--- /dev/null
+++ b/src/lib/libc/net/inet_network.c
@@ -0,0 +1,92 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: inet_network.c,v 1.7 1997/07/09 01:08:37 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <netinet/in.h>
40#include <arpa/inet.h>
41#include <ctype.h>
42
43/*
44 * Internet network address interpretation routine.
45 * The library routines call this routine to interpret
46 * network numbers.
47 */
48in_addr_t
49inet_network(cp)
50 register const char *cp;
51{
52 register in_addr_t val, base, n;
53 register char c;
54 in_addr_t parts[4], *pp = parts;
55 register int i;
56
57again:
58 val = 0; base = 10;
59 if (*cp == '0')
60 base = 8, cp++;
61 if (*cp == 'x' || *cp == 'X')
62 base = 16, cp++;
63 while ((c = *cp)) {
64 if (isdigit(c)) {
65 val = (val * base) + (c - '0');
66 cp++;
67 continue;
68 }
69 if (base == 16 && isxdigit(c)) {
70 val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
71 cp++;
72 continue;
73 }
74 break;
75 }
76 if (*cp == '.') {
77 if (pp >= parts + 3)
78 return (INADDR_NONE);
79 *pp++ = val, cp++;
80 goto again;
81 }
82 if (*cp && !isspace(*cp))
83 return (INADDR_NONE);
84 *pp++ = val;
85 n = pp - parts;
86 for (val = 0, i = 0; i < 4; i++) {
87 val <<= 8;
88 if (i < n)
89 val |= parts[i] & 0xff;
90 }
91 return (val);
92}
diff --git a/src/lib/libc/net/inet_ntoa.c b/src/lib/libc/net/inet_ntoa.c
new file mode 100644
index 0000000000..148732ba5a
--- /dev/null
+++ b/src/lib/libc/net/inet_ntoa.c
@@ -0,0 +1,59 @@
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: inet_ntoa.c,v 1.2 1996/08/19 08:29:16 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38/*
39 * Convert network-format internet address
40 * to base 256 d.d.d.d representation.
41 */
42#include <sys/types.h>
43#include <netinet/in.h>
44#include <arpa/inet.h>
45#include <stdio.h>
46
47char *
48inet_ntoa(in)
49 struct in_addr in;
50{
51 static char b[18];
52 register char *p;
53
54 p = (char *)&in;
55#define UC(b) (((int)b)&0xff)
56 (void)snprintf(b, sizeof(b),
57 "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
58 return (b);
59}
diff --git a/src/lib/libc/net/inet_ntop.c b/src/lib/libc/net/inet_ntop.c
new file mode 100644
index 0000000000..64d0d13768
--- /dev/null
+++ b/src/lib/libc/net/inet_ntop.c
@@ -0,0 +1,194 @@
1/* $OpenBSD: inet_ntop.c,v 1.1 1997/03/13 19:07:32 downsj Exp $ */
2
3/* Copyright (c) 1996 by Internet Software Consortium.
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
10 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
11 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
12 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
15 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
16 * SOFTWARE.
17 */
18
19#if defined(LIBC_SCCS) && !defined(lint)
20#if 0
21static char rcsid[] = "$From: inet_ntop.c,v 8.7 1996/08/05 08:41:18 vixie Exp $";
22#else
23static char rcsid[] = "$OpenBSD: inet_ntop.c,v 1.1 1997/03/13 19:07:32 downsj Exp $";
24#endif
25#endif /* LIBC_SCCS and not lint */
26
27#include <sys/param.h>
28#include <sys/types.h>
29#include <sys/socket.h>
30#include <netinet/in.h>
31#include <arpa/inet.h>
32#include <arpa/nameser.h>
33#include <string.h>
34#include <errno.h>
35#include <stdio.h>
36
37/*
38 * WARNING: Don't even consider trying to compile this on a system where
39 * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
40 */
41
42static const char *inet_ntop4 __P((const u_char *src, char *dst, size_t size));
43static const char *inet_ntop6 __P((const u_char *src, char *dst, size_t size));
44
45/* char *
46 * inet_ntop(af, src, dst, size)
47 * convert a network format address to presentation format.
48 * return:
49 * pointer to presentation format address (`dst'), or NULL (see errno).
50 * author:
51 * Paul Vixie, 1996.
52 */
53const char *
54inet_ntop(af, src, dst, size)
55 int af;
56 const void *src;
57 char *dst;
58 size_t size;
59{
60 switch (af) {
61 case AF_INET:
62 return (inet_ntop4(src, dst, size));
63 case AF_INET6:
64 return (inet_ntop6(src, dst, size));
65 default:
66 errno = EAFNOSUPPORT;
67 return (NULL);
68 }
69 /* NOTREACHED */
70}
71
72/* const char *
73 * inet_ntop4(src, dst, size)
74 * format an IPv4 address, more or less like inet_ntoa()
75 * return:
76 * `dst' (as a const)
77 * notes:
78 * (1) uses no statics
79 * (2) takes a u_char* not an in_addr as input
80 * author:
81 * Paul Vixie, 1996.
82 */
83static const char *
84inet_ntop4(src, dst, size)
85 const u_char *src;
86 char *dst;
87 size_t size;
88{
89 static const char fmt[] = "%u.%u.%u.%u";
90 char tmp[sizeof "255.255.255.255"];
91
92 if (sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) > size) {
93 errno = ENOSPC;
94 return (NULL);
95 }
96 strcpy(dst, tmp);
97 return (dst);
98}
99
100/* const char *
101 * inet_ntop6(src, dst, size)
102 * convert IPv6 binary address into presentation (printable) format
103 * author:
104 * Paul Vixie, 1996.
105 */
106static const char *
107inet_ntop6(src, dst, size)
108 const u_char *src;
109 char *dst;
110 size_t size;
111{
112 /*
113 * Note that int32_t and int16_t need only be "at least" large enough
114 * to contain a value of the specified size. On some systems, like
115 * Crays, there is no such thing as an integer variable with 16 bits.
116 * Keep this in mind if you think this function should have been coded
117 * to use pointer overlays. All the world's not a VAX.
118 */
119 char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
120 struct { int base, len; } best, cur;
121 u_int words[IN6ADDRSZ / INT16SZ];
122 int i;
123
124 /*
125 * Preprocess:
126 * Copy the input (bytewise) array into a wordwise array.
127 * Find the longest run of 0x00's in src[] for :: shorthanding.
128 */
129 memset(words, '\0', sizeof words);
130 for (i = 0; i < IN6ADDRSZ; i++)
131 words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
132 best.base = -1;
133 cur.base = -1;
134 for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
135 if (words[i] == 0) {
136 if (cur.base == -1)
137 cur.base = i, cur.len = 1;
138 else
139 cur.len++;
140 } else {
141 if (cur.base != -1) {
142 if (best.base == -1 || cur.len > best.len)
143 best = cur;
144 cur.base = -1;
145 }
146 }
147 }
148 if (cur.base != -1) {
149 if (best.base == -1 || cur.len > best.len)
150 best = cur;
151 }
152 if (best.base != -1 && best.len < 2)
153 best.base = -1;
154
155 /*
156 * Format the result.
157 */
158 tp = tmp;
159 for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
160 /* Are we inside the best run of 0x00's? */
161 if (best.base != -1 && i >= best.base &&
162 i < (best.base + best.len)) {
163 if (i == best.base)
164 *tp++ = ':';
165 continue;
166 }
167 /* Are we following an initial run of 0x00s or any real hex? */
168 if (i != 0)
169 *tp++ = ':';
170 /* Is this address an encapsulated IPv4? */
171 if (i == 6 && best.base == 0 &&
172 (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
173 if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
174 return (NULL);
175 tp += strlen(tp);
176 break;
177 }
178 tp += sprintf(tp, "%x", words[i]);
179 }
180 /* Was it a trailing run of 0x00's? */
181 if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
182 *tp++ = ':';
183 *tp++ = '\0';
184
185 /*
186 * Check for overflow, copy, and we're done.
187 */
188 if ((size_t)(tp - tmp) > size) {
189 errno = ENOSPC;
190 return (NULL);
191 }
192 strcpy(dst, tmp);
193 return (dst);
194}
diff --git a/src/lib/libc/net/inet_pton.c b/src/lib/libc/net/inet_pton.c
new file mode 100644
index 0000000000..46b4b24819
--- /dev/null
+++ b/src/lib/libc/net/inet_pton.c
@@ -0,0 +1,220 @@
1/* $OpenBSD: inet_pton.c,v 1.2 1997/04/13 05:08:24 deraadt Exp $ */
2
3/* Copyright (c) 1996 by Internet Software Consortium.
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
10 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
11 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
12 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
15 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
16 * SOFTWARE.
17 */
18
19#if defined(LIBC_SCCS) && !defined(lint)
20#if 0
21static char rcsid[] = "$From: inet_pton.c,v 8.7 1996/08/05 08:31:35 vixie Exp $";
22#else
23static char rcsid[] = "$OpenBSD: inet_pton.c,v 1.2 1997/04/13 05:08:24 deraadt Exp $";
24#endif
25#endif /* LIBC_SCCS and not lint */
26
27#include <sys/param.h>
28#include <sys/types.h>
29#include <sys/socket.h>
30#include <netinet/in.h>
31#include <arpa/inet.h>
32#include <arpa/nameser.h>
33#include <string.h>
34#include <errno.h>
35
36/*
37 * WARNING: Don't even consider trying to compile this on a system where
38 * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
39 */
40
41static int inet_pton4 __P((const char *src, u_char *dst));
42static int inet_pton6 __P((const char *src, u_char *dst));
43
44/* int
45 * inet_pton(af, src, dst)
46 * convert from presentation format (which usually means ASCII printable)
47 * to network format (which is usually some kind of binary format).
48 * return:
49 * 1 if the address was valid for the specified address family
50 * 0 if the address wasn't valid (`dst' is untouched in this case)
51 * -1 if some other error occurred (`dst' is untouched in this case, too)
52 * author:
53 * Paul Vixie, 1996.
54 */
55int
56inet_pton(af, src, dst)
57 int af;
58 const char *src;
59 void *dst;
60{
61 switch (af) {
62 case AF_INET:
63 return (inet_pton4(src, dst));
64 case AF_INET6:
65 return (inet_pton6(src, dst));
66 default:
67 errno = EAFNOSUPPORT;
68 return (-1);
69 }
70 /* NOTREACHED */
71}
72
73/* int
74 * inet_pton4(src, dst)
75 * like inet_aton() but without all the hexadecimal and shorthand.
76 * return:
77 * 1 if `src' is a valid dotted quad, else 0.
78 * notice:
79 * does not touch `dst' unless it's returning 1.
80 * author:
81 * Paul Vixie, 1996.
82 */
83static int
84inet_pton4(src, dst)
85 const char *src;
86 u_char *dst;
87{
88 static const char digits[] = "0123456789";
89 int saw_digit, octets, ch;
90 u_char tmp[INADDRSZ], *tp;
91
92 saw_digit = 0;
93 octets = 0;
94 *(tp = tmp) = 0;
95 while ((ch = *src++) != '\0') {
96 const char *pch;
97
98 if ((pch = strchr(digits, ch)) != NULL) {
99 u_int new = *tp * 10 + (pch - digits);
100
101 if (new > 255)
102 return (0);
103 if (! saw_digit) {
104 if (++octets > 4)
105 return (0);
106 saw_digit = 1;
107 }
108 *tp = new;
109 } else if (ch == '.' && saw_digit) {
110 if (octets == 4)
111 return (0);
112 *++tp = 0;
113 saw_digit = 0;
114 } else
115 return (0);
116 }
117 if (octets < 4)
118 return (0);
119
120 memcpy(dst, tmp, INADDRSZ);
121 return (1);
122}
123
124/* int
125 * inet_pton6(src, dst)
126 * convert presentation level address to network order binary form.
127 * return:
128 * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
129 * notice:
130 * (1) does not touch `dst' unless it's returning 1.
131 * (2) :: in a full address is silently ignored.
132 * credit:
133 * inspired by Mark Andrews.
134 * author:
135 * Paul Vixie, 1996.
136 */
137static int
138inet_pton6(src, dst)
139 const char *src;
140 u_char *dst;
141{
142 static const char xdigits_l[] = "0123456789abcdef",
143 xdigits_u[] = "0123456789ABCDEF";
144 u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
145 const char *xdigits, *curtok;
146 int ch, saw_xdigit;
147 u_int val;
148
149 memset((tp = tmp), '\0', IN6ADDRSZ);
150 endp = tp + IN6ADDRSZ;
151 colonp = NULL;
152 /* Leading :: requires some special handling. */
153 if (*src == ':')
154 if (*++src != ':')
155 return (0);
156 curtok = src;
157 saw_xdigit = 0;
158 val = 0;
159 while ((ch = *src++) != '\0') {
160 const char *pch;
161
162 if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
163 pch = strchr((xdigits = xdigits_u), ch);
164 if (pch != NULL) {
165 val <<= 4;
166 val |= (pch - xdigits);
167 if (val > 0xffff)
168 return (0);
169 saw_xdigit = 1;
170 continue;
171 }
172 if (ch == ':') {
173 curtok = src;
174 if (!saw_xdigit) {
175 if (colonp)
176 return (0);
177 colonp = tp;
178 continue;
179 }
180 if (tp + INT16SZ > endp)
181 return (0);
182 *tp++ = (u_char) (val >> 8) & 0xff;
183 *tp++ = (u_char) val & 0xff;
184 saw_xdigit = 0;
185 val = 0;
186 continue;
187 }
188 if (ch == '.' && ((tp + INADDRSZ) <= endp) &&
189 inet_pton4(curtok, tp) > 0) {
190 tp += INADDRSZ;
191 saw_xdigit = 0;
192 break; /* '\0' was seen by inet_pton4(). */
193 }
194 return (0);
195 }
196 if (saw_xdigit) {
197 if (tp + INT16SZ > endp)
198 return (0);
199 *tp++ = (u_char) (val >> 8) & 0xff;
200 *tp++ = (u_char) val & 0xff;
201 }
202 if (colonp != NULL) {
203 /*
204 * Since some memmove()'s erroneously fail to handle
205 * overlapping regions, we'll do the shift by hand.
206 */
207 const int n = tp - colonp;
208 int i;
209
210 for (i = 1; i <= n; i++) {
211 endp[- i] = colonp[n - i];
212 colonp[n - i] = 0;
213 }
214 tp = endp;
215 }
216 if (tp != endp)
217 return (0);
218 memcpy(dst, tmp, IN6ADDRSZ);
219 return (1);
220}
diff --git a/src/lib/libc/net/ipx.3 b/src/lib/libc/net/ipx.3
new file mode 100644
index 0000000000..073be74807
--- /dev/null
+++ b/src/lib/libc/net/ipx.3
@@ -0,0 +1,126 @@
1.\" $OpenBSD: ipx.3,v 1.3 1997/09/09 11:45:17 kstailey Exp $
2.\"
3.\" Copyright (c) 1986, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd June 4, 1993
35.Dt IPX 3
36.Os OpenBSD 1.2
37.Sh NAME
38.Nm ipx_addr ,
39.Nm ipx_ntoa
40.Nd IPX address conversion routines
41.Sh SYNOPSIS
42.Fd #include <sys/types.h>
43.Fd #include <netipx/ipx.h>
44.Ft struct ipx_addr
45.Fn ipx_addr "char *cp"
46.Ft char *
47.Fn ipx_ntoa "struct ipx_addr ipx"
48.Sh DESCRIPTION
49The routine
50.Fn ipx_addr
51interprets character strings representing
52.Tn IPX
53addresses, returning binary information suitable
54for use in system calls.
55The routine
56.Fn ipx_ntoa
57takes
58.Tn IPX
59addresses and returns
60.Tn ASCII
61strings representing the address in a
62notation in common use:
63.Bd -filled -offset indent
64<network number>.<host number>.<port number>
65.Ed
66.Pp
67Trailing zero fields are suppressed, and each number is printed in hexadecimal,
68in a format suitable for input to
69.Fn ipx_addr .
70Any fields lacking super-decimal digits will have a
71trailing
72.Ql H
73appended.
74.Pp
75An effort has been made to insure that
76.Fn ipx_addr
77be compatible with most formats in common use.
78It will first separate an address into 1 to 3 fields using a single delimiter
79chosen from
80period
81.Ql \&. ,
82colon
83.Ql \&:
84or pound-sign
85.Ql \&# .
86Each field is then examined for byte separators (colon or period).
87If there are byte separators, each subfield separated is taken to be
88a small hexadecimal number, and the entirety is taken as a network-byte-ordered
89quantity to be zero extended in the high-network-order bytes.
90Next, the field is inspected for hyphens, in which case
91the field is assumed to be a number in decimal notation
92with hyphens separating the millenia.
93Next, the field is assumed to be a number:
94It is interpreted
95as hexadecimal if there is a leading
96.Ql 0x
97(as in C),
98a trailing
99.Ql H
100(as in Mesa), or there are any super-decimal digits present.
101It is interpreted as octal is there is a leading
102.Ql 0
103and there are no super-octal digits.
104Otherwise, it is converted as a decimal number.
105.Sh RETURN VALUES
106None. (See
107.Sx BUGS . )
108.Sh SEE ALSO
109.Xr ns 4 ,
110.Xr hosts 5 ,
111.Xr networks 5
112.Sh HISTORY
113The precursor
114.Fn ns_addr
115and
116.Fn ns_ntoa
117functions appeared in
118.Bx 4.3 .
119.Sh BUGS
120The string returned by
121.Fn ipx_ntoa
122resides in a static memory area.
123The function
124.Fn ipx_addr
125should diagnose improperly formed input, and there should be an unambiguous
126way to recognize this.
diff --git a/src/lib/libc/net/ipx_addr.c b/src/lib/libc/net/ipx_addr.c
new file mode 100644
index 0000000000..a76e03e913
--- /dev/null
+++ b/src/lib/libc/net/ipx_addr.c
@@ -0,0 +1,229 @@
1/*
2 * Copyright (c) 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * J.Q. Johnson.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from @(#)ipx_addr.c
37 */
38
39#if defined(LIBC_SCCS) && !defined(lint)
40static char rcsid[] = "$OpenBSD: ipx_addr.c,v 1.3 1997/07/09 01:08:39 millert Exp $";
41#endif /* LIBC_SCCS and not lint */
42
43#include <sys/param.h>
44#include <netipx/ipx.h>
45#include <stdio.h>
46#include <string.h>
47
48static struct ipx_addr addr, zero_addr;
49
50static void Field(), cvtbase();
51
52struct ipx_addr
53ipx_addr(name)
54 const char *name;
55{
56 char separator;
57 char *hostname, *socketname, *cp;
58 char buf[50];
59
60 (void)strncpy(buf, name, sizeof(buf) - 1);
61 buf[sizeof(buf) - 1] = '\0';
62
63 /*
64 * First, figure out what he intends as a field separtor.
65 * Despite the way this routine is written, the prefered
66 * form 2-272.AA001234H.01777, i.e. XDE standard.
67 * Great efforts are made to insure backward compatability.
68 */
69 if ((hostname = strchr(buf, '#')))
70 separator = '#';
71 else {
72 hostname = strchr(buf, '.');
73 if ((cp = strchr(buf, ':')) &&
74 ((hostname && cp < hostname) || (hostname == 0))) {
75 hostname = cp;
76 separator = ':';
77 } else
78 separator = '.';
79 }
80 if (hostname)
81 *hostname++ = 0;
82
83 addr = zero_addr;
84 Field(buf, addr.ipx_net.c_net, 4);
85 if (hostname == 0)
86 return (addr); /* No separator means net only */
87
88 socketname = strchr(hostname, separator);
89 if (socketname) {
90 *socketname++ = 0;
91 Field(socketname, (u_char *)&addr.ipx_port, 2);
92 }
93
94 Field(hostname, addr.ipx_host.c_host, 6);
95
96 return (addr);
97}
98
99static void
100Field(buf, out, len)
101 char *buf;
102 u_char *out;
103 int len;
104{
105 register char *bp = buf;
106 int i, ibase, base16 = 0, base10 = 0, clen = 0;
107 int hb[6], *hp;
108 char *fmt;
109
110 /*
111 * first try 2-273#2-852-151-014#socket
112 */
113 if ((*buf != '-') &&
114 (1 < (i = sscanf(buf, "%d-%d-%d-%d-%d",
115 &hb[0], &hb[1], &hb[2], &hb[3], &hb[4])))) {
116 cvtbase(1000L, 256, hb, i, out, len);
117 return;
118 }
119 /*
120 * try form 8E1#0.0.AA.0.5E.E6#socket
121 */
122 if (1 < (i = sscanf(buf,"%x.%x.%x.%x.%x.%x",
123 &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) {
124 cvtbase(256L, 256, hb, i, out, len);
125 return;
126 }
127 /*
128 * try form 8E1#0:0:AA:0:5E:E6#socket
129 */
130 if (1 < (i = sscanf(buf,"%x:%x:%x:%x:%x:%x",
131 &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) {
132 cvtbase(256L, 256, hb, i, out, len);
133 return;
134 }
135 /*
136 * This is REALLY stretching it but there was a
137 * comma notation separting shorts -- definitely non standard
138 */
139 if (1 < (i = sscanf(buf,"%x,%x,%x",
140 &hb[0], &hb[1], &hb[2]))) {
141 hb[0] = htons(hb[0]); hb[1] = htons(hb[1]);
142 hb[2] = htons(hb[2]);
143 cvtbase(65536L, 256, hb, i, out, len);
144 return;
145 }
146
147 /* Need to decide if base 10, 16 or 8 */
148 while (*bp) switch (*bp++) {
149
150 case '0': case '1': case '2': case '3': case '4': case '5':
151 case '6': case '7': case '-':
152 break;
153
154 case '8': case '9':
155 base10 = 1;
156 break;
157
158 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
159 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
160 base16 = 1;
161 break;
162
163 case 'x': case 'X':
164 *--bp = '0';
165 base16 = 1;
166 break;
167
168 case 'h': case 'H':
169 base16 = 1;
170 /* fall into */
171
172 default:
173 *--bp = 0; /* Ends Loop */
174 }
175 if (base16) {
176 fmt = "%3x";
177 ibase = 4096;
178 } else if (base10 == 0 && *buf == '0') {
179 fmt = "%3o";
180 ibase = 512;
181 } else {
182 fmt = "%3d";
183 ibase = 1000;
184 }
185
186 for (bp = buf; *bp++; ) clen++;
187 if (clen == 0) clen++;
188 if (clen > 18) clen = 18;
189 i = ((clen - 1) / 3) + 1;
190 bp = clen + buf - 3;
191 hp = hb + i - 1;
192
193 while (hp > hb) {
194 (void)sscanf(bp, fmt, hp);
195 bp[0] = 0;
196 hp--;
197 bp -= 3;
198 }
199 (void)sscanf(buf, fmt, hp);
200 cvtbase((long)ibase, 256, hb, i, out, len);
201}
202
203static void
204cvtbase(oldbase,newbase,input,inlen,result,reslen)
205 long oldbase;
206 int newbase;
207 int input[];
208 int inlen;
209 unsigned char result[];
210 int reslen;
211{
212 int d, e;
213 long sum;
214
215 e = 1;
216 while (e > 0 && reslen > 0) {
217 d = 0; e = 0; sum = 0;
218 /* long division: input=input/newbase */
219 while (d < inlen) {
220 sum = sum*oldbase + (long) input[d];
221 e += (sum > 0);
222 input[d++] = sum / newbase;
223 sum %= newbase;
224 }
225 result[--reslen] = sum; /* accumulate remainder */
226 }
227 for (d=0; d < reslen; d++)
228 result[d] = 0;
229}
diff --git a/src/lib/libc/net/ipx_ntoa.c b/src/lib/libc/net/ipx_ntoa.c
new file mode 100644
index 0000000000..1dcfe7181b
--- /dev/null
+++ b/src/lib/libc/net/ipx_ntoa.c
@@ -0,0 +1,58 @@
1/*
2 * Copyright (c) 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: ipx_ntoa.c,v 1.2 1996/08/19 08:29:20 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/param.h>
39#include <netipx/ipx.h>
40#include <stdio.h>
41
42char *
43ipx_ntoa(addr)
44 struct ipx_addr addr;
45{
46 static char obuf[] = "xxxx.xx:xx:xx:xx:xx:xx.uuuuu";
47
48 sprintf(obuf, "%8xH.%02x:%02x:%02x:%02x:%02x:%02x.%u",
49 ntohl(addr.ipx_net.l_net),
50 addr.ipx_host.c_host[0],
51 addr.ipx_host.c_host[1],
52 addr.ipx_host.c_host[2],
53 addr.ipx_host.c_host[3],
54 addr.ipx_host.c_host[4],
55 addr.ipx_host.c_host[5],
56 ntohs(addr.ipx_port));
57 return (obuf);
58}
diff --git a/src/lib/libc/net/iso_addr.3 b/src/lib/libc/net/iso_addr.3
new file mode 100644
index 0000000000..d9bf9086be
--- /dev/null
+++ b/src/lib/libc/net/iso_addr.3
@@ -0,0 +1,110 @@
1.\" $OpenBSD: iso_addr.3,v 1.2 1996/08/19 08:29:22 tholo Exp $
2.\"
3.\" Copyright (c) 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd June 4, 1993
35.Dt ISO_ADDR 3
36.Os
37.Sh NAME
38.Nm iso_addr ,
39.Nm iso_ntoa
40.Nd "elementary network address conversion routines for Open System Interconnection
41.Sh SYNOPSIS
42.Fd #include <sys/types.h>
43.Fd #include <netiso/iso.h>
44.Ft struct iso_addr *
45.Fn iso_addr "char *cp"
46.Ft char *
47.Fn iso_ntoa "struct iso_addr *isoa"
48.Sh DESCRIPTION
49The routine
50.Fn iso_addr
51interprets character strings representing
52.Tn OSI
53addresses, returning binary information suitable
54for use in system calls.
55The routine
56.Fn iso_ntoa
57takes
58.Tn OSI
59addresses and returns
60.Tn ASCII
61strings representing NSAPs (network service
62access points) in a
63notation inverse to that accepted by
64.Fn iso_addr .
65.Pp
66Unfortunately, no universal standard exists for representing
67.Tn OSI
68network addresses.
69.Pp
70The format employed by
71.Fn iso_addr
72is a sequence of hexadecimal
73.Dq digits
74(optionally separated by periods),
75of the form:
76.Bd -filled -offset indent
77<hex digits>.<hex digits>.<hex digits>
78.Ed
79.Pp
80Each pair of hexadecimal digits represents a byte
81with the leading digit indicating the higher-ordered bits.
82A period following an even number of bytes has no
83effect (but may be used to increase legibility).
84A period following an odd number of bytes has the
85effect of causing the byte of address being translated
86to have its higher order bits filled with zeros.
87.Sh RETURN VALUES
88.Fn iso_ntoa
89always returns a null terminated string.
90.Fn iso_addr
91always returns a pointer to a struct iso_addr.
92(See
93.Sx BUGS . )
94.Sh SEE ALSO
95.Xr iso 4
96.Sh HISTORY
97The
98.Fn iso_addr
99and
100.Fn iso_ntoa
101functions appeared in
102.Bx 4.3 Reno .
103.Sh BUGS
104The returned values
105reside in a static memory area.
106.Pp
107The function
108.Fn iso_addr
109should diagnose improperly formed input, and there should be an unambiguous
110way to recognize this.
diff --git a/src/lib/libc/net/iso_addr.c b/src/lib/libc/net/iso_addr.c
new file mode 100644
index 0000000000..01561e395b
--- /dev/null
+++ b/src/lib/libc/net/iso_addr.c
@@ -0,0 +1,119 @@
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: iso_addr.c,v 1.2 1996/08/19 08:29:23 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <netiso/iso.h>
40#include <string.h>
41
42/* States*/
43#define VIRGIN 0
44#define GOTONE 1
45#define GOTTWO 2
46/* Inputs */
47#define DIGIT (4*0)
48#define END (4*1)
49#define DELIM (4*2)
50
51struct iso_addr *
52iso_addr(addr)
53 register const char *addr;
54{
55 static struct iso_addr out_addr;
56 register char *cp = out_addr.isoa_genaddr;
57 char *cplim = cp + sizeof(out_addr.isoa_genaddr);
58 register int byte = 0, state = VIRGIN, new;
59
60 bzero((char *)&out_addr, sizeof(out_addr));
61 do {
62 if ((*addr >= '0') && (*addr <= '9')) {
63 new = *addr - '0';
64 } else if ((*addr >= 'a') && (*addr <= 'f')) {
65 new = *addr - 'a' + 10;
66 } else if ((*addr >= 'A') && (*addr <= 'F')) {
67 new = *addr - 'A' + 10;
68 } else if (*addr == 0)
69 state |= END;
70 else
71 state |= DELIM;
72 addr++;
73 switch (state /* | INPUT */) {
74 case GOTTWO | DIGIT:
75 *cp++ = byte; /*FALLTHROUGH*/
76 case VIRGIN | DIGIT:
77 state = GOTONE; byte = new; continue;
78 case GOTONE | DIGIT:
79 state = GOTTWO; byte = new + (byte << 4); continue;
80 default: /* | DELIM */
81 state = VIRGIN; *cp++ = byte; byte = 0; continue;
82 case GOTONE | END:
83 case GOTTWO | END:
84 *cp++ = byte; /* FALLTHROUGH */
85 case VIRGIN | END:
86 break;
87 }
88 break;
89 } while (cp < cplim);
90 out_addr.isoa_len = cp - out_addr.isoa_genaddr;
91 return (&out_addr);
92}
93static char hexlist[] = "0123456789abcdef";
94
95char *
96iso_ntoa(isoa)
97 const struct iso_addr *isoa;
98{
99 static char obuf[64];
100 register char *out = obuf;
101 register int i;
102 register u_char *in = (u_char *)isoa->isoa_genaddr;
103 u_char *inlim = in + isoa->isoa_len;
104
105 out[1] = 0;
106 while (in < inlim) {
107 i = *in++;
108 *out++ = '.';
109 if (i > 0xf) {
110 out[1] = hexlist[i & 0xf];
111 i >>= 4;
112 out[0] = hexlist[i];
113 out += 2;
114 } else
115 *out++ = hexlist[i];
116 }
117 *out = 0;
118 return(obuf + 1);
119}
diff --git a/src/lib/libc/net/link_addr.3 b/src/lib/libc/net/link_addr.3
new file mode 100644
index 0000000000..eb6c952177
--- /dev/null
+++ b/src/lib/libc/net/link_addr.3
@@ -0,0 +1,131 @@
1.\" $OpenBSD: link_addr.3,v 1.2 1996/08/19 08:29:25 tholo Exp $
2.\"
3.\" Copyright (c) 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" Donn Seeley at BSDI.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in the
16.\" documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\" must display the following acknowledgement:
19.\" This product includes software developed by the University of
20.\" California, Berkeley and its contributors.
21.\" 4. Neither the name of the University nor the names of its contributors
22.\" may be used to endorse or promote products derived from this software
23.\" without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35.\" SUCH DAMAGE.
36.\"
37.Dd July 28, 1993
38.Dt LINK_ADDR 3
39.Os BSD 4.4
40.Sh NAME
41.Nm link_addr ,
42.Nm link_ntoa
43.Nd elementary address specification routines for link level access
44.Sh SYNOPSIS
45.Fd #include <sys/types.h>
46.Fd #include <sys/socket.h>
47.Fd #include <net/if_dl.h>
48.Ft void
49.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl"
50.Ft char *
51.Fn link_ntoa "const struct sockaddr_dl *sdl"
52.Sh DESCRIPTION
53The routine
54.Fn link_addr
55interprets character strings representing
56link-level addresses, returning binary information suitable
57for use in system calls.
58The routine
59.Fn link_ntoa
60takes
61a link-level
62address and returns an
63.Tn ASCII
64string representing some of the information present,
65including the link level address itself, and the interface name
66or number, if present.
67This facility is experimental and is
68still subject to change.
69.Pp
70For
71.Fn link_addr ,
72the string
73.Fa addr
74may contain
75an optional network interface identifier of the form
76.Dq "name unit-number" ,
77suitable for the first argument to
78.Xr ifconfig 4 ,
79followed in all cases by a colon and
80an interface address in the form of
81groups of hexadecimal digits
82separated by periods.
83Each group represents a byte of address;
84address bytes are filled left to right from
85low order bytes through high order bytes.
86.Pp
87.\" A regular expression may make this format clearer:
88.\" .Bd -literal -offset indent
89.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)*
90.\" .Ed
91.\" .Pp
92Thus
93.Li le0:8.0.9.13.d.30
94represents an ethernet address
95to be transmitted on the first Lance ethernet interface.
96.Sh RETURN VALUES
97.Fn link_ntoa
98always returns a null terminated string.
99.Fn link_addr
100has no return value.
101(See
102.Sx BUGS . )
103.Sh SEE ALSO
104.Xr iso 4 ,
105.Sh HISTORY
106The
107.Fn link_addr
108and
109.Fn link_ntoa
110functions appeared in
111.Bx 4.3 Reno .
112.Sh BUGS
113The returned values for link_ntoa
114reside in a static memory area.
115.Pp
116The function
117.Fn link_addr
118should diagnose improperly formed input, and there should be an unambiguous
119way to recognize this.
120.Pp
121If the
122.Va sdl_len
123field of the link socket address
124.Fa sdl
125is 0,
126.Fn link_ntoa
127will not insert a colon before the interface address bytes.
128If this translated address is given to
129.Fn link_addr
130without inserting an initial colon,
131the latter will not interpret it correctly.
diff --git a/src/lib/libc/net/linkaddr.c b/src/lib/libc/net/linkaddr.c
new file mode 100644
index 0000000000..fb522f3233
--- /dev/null
+++ b/src/lib/libc/net/linkaddr.c
@@ -0,0 +1,158 @@
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: linkaddr.c,v 1.2 1996/08/19 08:29:27 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <sys/socket.h>
40#include <net/if_dl.h>
41#include <string.h>
42
43/* States*/
44#define NAMING 0
45#define GOTONE 1
46#define GOTTWO 2
47#define RESET 3
48/* Inputs */
49#define DIGIT (4*0)
50#define END (4*1)
51#define DELIM (4*2)
52#define LETTER (4*3)
53
54void
55link_addr(addr, sdl)
56 register const char *addr;
57 register struct sockaddr_dl *sdl;
58{
59 register char *cp = sdl->sdl_data;
60 char *cplim = sdl->sdl_len + (char *)sdl;
61 register int byte = 0, state = NAMING, new;
62
63 bzero((char *)&sdl->sdl_family, sdl->sdl_len - 1);
64 sdl->sdl_family = AF_LINK;
65 do {
66 state &= ~LETTER;
67 if ((*addr >= '0') && (*addr <= '9')) {
68 new = *addr - '0';
69 } else if ((*addr >= 'a') && (*addr <= 'f')) {
70 new = *addr - 'a' + 10;
71 } else if ((*addr >= 'A') && (*addr <= 'F')) {
72 new = *addr - 'A' + 10;
73 } else if (*addr == 0) {
74 state |= END;
75 } else if (state == NAMING &&
76 (((*addr >= 'A') && (*addr <= 'Z')) ||
77 ((*addr >= 'a') && (*addr <= 'z'))))
78 state |= LETTER;
79 else
80 state |= DELIM;
81 addr++;
82 switch (state /* | INPUT */) {
83 case NAMING | DIGIT:
84 case NAMING | LETTER:
85 *cp++ = addr[-1];
86 continue;
87 case NAMING | DELIM:
88 state = RESET;
89 sdl->sdl_nlen = cp - sdl->sdl_data;
90 continue;
91 case GOTTWO | DIGIT:
92 *cp++ = byte;
93 /* FALLTHROUGH */
94 case RESET | DIGIT:
95 state = GOTONE;
96 byte = new;
97 continue;
98 case GOTONE | DIGIT:
99 state = GOTTWO;
100 byte = new + (byte << 4);
101 continue;
102 default: /* | DELIM */
103 state = RESET;
104 *cp++ = byte;
105 byte = 0;
106 continue;
107 case GOTONE | END:
108 case GOTTWO | END:
109 *cp++ = byte;
110 /* FALLTHROUGH */
111 case RESET | END:
112 break;
113 }
114 break;
115 } while (cp < cplim);
116 sdl->sdl_alen = cp - LLADDR(sdl);
117 new = cp - (char *)sdl;
118 if (new > sizeof(*sdl))
119 sdl->sdl_len = new;
120 return;
121}
122
123static char hexlist[] = "0123456789abcdef";
124
125char *
126link_ntoa(sdl)
127 register const struct sockaddr_dl *sdl;
128{
129 static char obuf[64];
130 register char *out = obuf;
131 register int i;
132 register u_char *in = (u_char *)LLADDR(sdl);
133 u_char *inlim = in + sdl->sdl_alen;
134 int firsttime = 1;
135
136 if (sdl->sdl_nlen) {
137 bcopy(sdl->sdl_data, obuf, sdl->sdl_nlen);
138 out += sdl->sdl_nlen;
139 if (sdl->sdl_alen)
140 *out++ = ':';
141 }
142 while (in < inlim) {
143 if (firsttime)
144 firsttime = 0;
145 else
146 *out++ = '.';
147 i = *in++;
148 if (i > 0xf) {
149 out[1] = hexlist[i & 0xf];
150 i >>= 4;
151 out[0] = hexlist[i];
152 out += 2;
153 } else
154 *out++ = hexlist[i];
155 }
156 *out = 0;
157 return (obuf);
158}
diff --git a/src/lib/libc/net/ns.3 b/src/lib/libc/net/ns.3
new file mode 100644
index 0000000000..6e096d9f4b
--- /dev/null
+++ b/src/lib/libc/net/ns.3
@@ -0,0 +1,130 @@
1.\" $OpenBSD: ns.3,v 1.2 1996/08/19 08:29:29 tholo Exp $
2.\"
3.\" Copyright (c) 1986, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd June 4, 1993
35.Dt NS 3
36.Os BSD 4.3
37.Sh NAME
38.Nm ns_addr ,
39.Nm ns_ntoa
40.Nd Xerox
41.Tn NS Ns (tm)
42address conversion routines
43.Sh SYNOPSIS
44.Fd #include <sys/types.h>
45.Fd #include <netns/ns.h>
46.Ft struct ns_addr
47.Fn ns_addr "char *cp"
48.Ft char *
49.Fn ns_ntoa "struct ns_addr ns"
50.Sh DESCRIPTION
51The routine
52.Fn ns_addr
53interprets character strings representing
54.Tn XNS
55addresses, returning binary information suitable
56for use in system calls.
57The routine
58.Fn ns_ntoa
59takes
60.Tn XNS
61addresses and returns
62.Tn ASCII
63strings representing the address in a
64notation in common use in the Xerox Development Environment:
65.Bd -filled -offset indent
66<network number>.<host number>.<port number>
67.Ed
68.Pp
69Trailing zero fields are suppressed, and each number is printed in hexadecimal,
70in a format suitable for input to
71.Fn ns_addr .
72Any fields lacking super-decimal digits will have a
73trailing
74.Ql H
75appended.
76.Pp
77Unfortunately, no universal standard exists for representing
78.Tn XNS
79addresses.
80An effort has been made to insure that
81.Fn ns_addr
82be compatible with most formats in common use.
83It will first separate an address into 1 to 3 fields using a single delimiter
84chosen from
85period
86.Ql \&. ,
87colon
88.Ql \&:
89or pound-sign
90.Ql \&# .
91Each field is then examined for byte separators (colon or period).
92If there are byte separators, each subfield separated is taken to be
93a small hexadecimal number, and the entirety is taken as a network-byte-ordered
94quantity to be zero extended in the high-network-order bytes.
95Next, the field is inspected for hyphens, in which case
96the field is assumed to be a number in decimal notation
97with hyphens separating the millenia.
98Next, the field is assumed to be a number:
99It is interpreted
100as hexadecimal if there is a leading
101.Ql 0x
102(as in C),
103a trailing
104.Ql H
105(as in Mesa), or there are any super-decimal digits present.
106It is interpreted as octal is there is a leading
107.Ql 0
108and there are no super-octal digits.
109Otherwise, it is converted as a decimal number.
110.Sh RETURN VALUES
111None. (See
112.Sx BUGS . )
113.Sh SEE ALSO
114.Xr hosts 5 ,
115.Xr networks 5 ,
116.Sh HISTORY
117The
118.Fn ns_addr
119and
120.Fn ns_toa
121functions appeared in
122.Bx 4.3 .
123.Sh BUGS
124The string returned by
125.Fn ns_ntoa
126resides in a static memory area.
127The function
128.Fn ns_addr
129should diagnose improperly formed input, and there should be an unambiguous
130way to recognize this.
diff --git a/src/lib/libc/net/ns_addr.c b/src/lib/libc/net/ns_addr.c
new file mode 100644
index 0000000000..8f2e4bc513
--- /dev/null
+++ b/src/lib/libc/net/ns_addr.c
@@ -0,0 +1,228 @@
1/*
2 * Copyright (c) 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * J.Q. Johnson.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char rcsid[] = "$OpenBSD: ns_addr.c,v 1.4 1997/07/21 20:31:05 deraadt Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <sys/param.h>
42#include <netns/ns.h>
43#include <stdio.h>
44#include <string.h>
45
46static struct ns_addr addr, zero_addr;
47
48static void Field __P((char *, u_int8_t *, int));
49static void cvtbase __P((long, int, int[], int, u_int8_t[], int));
50
51struct ns_addr
52ns_addr(name)
53 const char *name;
54{
55 char separator;
56 char *hostname, *socketname, *cp;
57 char buf[50];
58
59 (void)strncpy(buf, name, sizeof(buf) - 1);
60 buf[sizeof(buf) - 1] = '\0';
61
62 /*
63 * First, figure out what he intends as a field separtor.
64 * Despite the way this routine is written, the prefered
65 * form 2-272.AA001234H.01777, i.e. XDE standard.
66 * Great efforts are made to insure backward compatability.
67 */
68 if ((hostname = strchr(buf, '#')))
69 separator = '#';
70 else {
71 hostname = strchr(buf, '.');
72 if ((cp = strchr(buf, ':')) &&
73 ((hostname && cp < hostname) || (hostname == 0))) {
74 hostname = cp;
75 separator = ':';
76 } else
77 separator = '.';
78 }
79 if (hostname)
80 *hostname++ = 0;
81
82 addr = zero_addr;
83 Field(buf, addr.x_net.c_net, 4);
84 if (hostname == 0)
85 return (addr); /* No separator means net only */
86
87 socketname = strchr(hostname, separator);
88 if (socketname) {
89 *socketname++ = 0;
90 Field(socketname, (u_char *)&addr.x_port, 2);
91 }
92
93 Field(hostname, (u_char *)addr.x_host.c_host, 6);
94
95 return (addr);
96}
97
98static void
99Field(buf, out, len)
100 char *buf;
101 u_char *out;
102 int len;
103{
104 register char *bp = buf;
105 int i, ibase, base16 = 0, base10 = 0, clen = 0;
106 int hb[6], *hp;
107 char *fmt;
108
109 /*
110 * first try 2-273#2-852-151-014#socket
111 */
112 if ((*buf != '-') &&
113 (1 < (i = sscanf(buf, "%d-%d-%d-%d-%d",
114 &hb[0], &hb[1], &hb[2], &hb[3], &hb[4])))) {
115 cvtbase(1000L, 256, hb, i, out, len);
116 return;
117 }
118 /*
119 * try form 8E1#0.0.AA.0.5E.E6#socket
120 */
121 if (1 < (i = sscanf(buf,"%x.%x.%x.%x.%x.%x",
122 &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) {
123 cvtbase(256L, 256, hb, i, out, len);
124 return;
125 }
126 /*
127 * try form 8E1#0:0:AA:0:5E:E6#socket
128 */
129 if (1 < (i = sscanf(buf,"%x:%x:%x:%x:%x:%x",
130 &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) {
131 cvtbase(256L, 256, hb, i, out, len);
132 return;
133 }
134 /*
135 * This is REALLY stretching it but there was a
136 * comma notation separting shorts -- definitely non standard
137 */
138 if (1 < (i = sscanf(buf,"%x,%x,%x",
139 &hb[0], &hb[1], &hb[2]))) {
140 hb[0] = htons(hb[0]); hb[1] = htons(hb[1]);
141 hb[2] = htons(hb[2]);
142 cvtbase(65536L, 256, hb, i, out, len);
143 return;
144 }
145
146 /* Need to decide if base 10, 16 or 8 */
147 while (*bp) switch (*bp++) {
148
149 case '0': case '1': case '2': case '3': case '4': case '5':
150 case '6': case '7': case '-':
151 break;
152
153 case '8': case '9':
154 base10 = 1;
155 break;
156
157 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
158 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
159 base16 = 1;
160 break;
161
162 case 'x': case 'X':
163 *--bp = '0';
164 base16 = 1;
165 break;
166
167 case 'h': case 'H':
168 base16 = 1;
169 /* fall into */
170
171 default:
172 *--bp = 0; /* Ends Loop */
173 }
174 if (base16) {
175 fmt = "%3x";
176 ibase = 4096;
177 } else if (base10 == 0 && *buf == '0') {
178 fmt = "%3o";
179 ibase = 512;
180 } else {
181 fmt = "%3d";
182 ibase = 1000;
183 }
184
185 for (bp = buf; *bp++; ) clen++;
186 if (clen == 0) clen++;
187 if (clen > 18) clen = 18;
188 i = ((clen - 1) / 3) + 1;
189 bp = clen + buf - 3;
190 hp = hb + i - 1;
191
192 while (hp > hb) {
193 (void)sscanf(bp, fmt, hp);
194 bp[0] = 0;
195 hp--;
196 bp -= 3;
197 }
198 (void)sscanf(buf, fmt, hp);
199 cvtbase((long)ibase, 256, hb, i, out, len);
200}
201
202static void
203cvtbase(oldbase,newbase,input,inlen,result,reslen)
204 long oldbase;
205 int newbase;
206 int input[];
207 int inlen;
208 unsigned char result[];
209 int reslen;
210{
211 int d, e;
212 long sum;
213
214 e = 1;
215 while (e > 0 && reslen > 0) {
216 d = 0; e = 0; sum = 0;
217 /* long division: input=input/newbase */
218 while (d < inlen) {
219 sum = sum*oldbase + (long) input[d];
220 e += (sum > 0);
221 input[d++] = sum / newbase;
222 sum %= newbase;
223 }
224 result[--reslen] = sum; /* accumulate remainder */
225 }
226 for (d=0; d < reslen; d++)
227 result[d] = 0;
228}
diff --git a/src/lib/libc/net/ns_ntoa.c b/src/lib/libc/net/ns_ntoa.c
new file mode 100644
index 0000000000..c33f710966
--- /dev/null
+++ b/src/lib/libc/net/ns_ntoa.c
@@ -0,0 +1,101 @@
1/*
2 * Copyright (c) 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: ns_ntoa.c,v 1.7 1997/08/24 21:25:48 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/param.h>
39#include <netns/ns.h>
40#include <stdio.h>
41
42static char *spectHex __P((char *));
43
44char *
45ns_ntoa(addr)
46 struct ns_addr addr;
47{
48 static char obuf[40];
49 union { union ns_net net_e; u_int32_t long_e; } net;
50 in_port_t port = htons(addr.x_port);
51 register char *cp;
52 char *cp2;
53 register u_char *up = addr.x_host.c_host;
54 u_char *uplim = up + 6;
55
56 net.net_e = addr.x_net;
57 sprintf(obuf, "%x", ntohl(net.long_e));
58 cp = spectHex(obuf);
59 cp2 = cp + 1;
60 while (*up==0 && up < uplim) up++;
61 if (up == uplim) {
62 if (port) {
63 sprintf(cp, ".0");
64 cp += 2;
65 }
66 } else {
67 sprintf(cp, ".%x", *up++);
68 while (up < uplim) {
69 while (*cp) cp++;
70 sprintf(cp, "%02x", *up++);
71 }
72 cp = spectHex(cp2);
73 }
74 if (port) {
75 sprintf(cp, ".%x", port);
76 spectHex(cp + 1);
77 }
78 return (obuf);
79}
80
81static char *
82spectHex(p0)
83 char *p0;
84{
85 int ok = 0;
86 int nonzero = 0;
87 register char *p = p0;
88 for (; *p; p++) switch (*p) {
89
90 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
91 *p += ('A' - 'a');
92 /* fall into . . . */
93 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
94 ok = 1;
95 case '1': case '2': case '3': case '4': case '5':
96 case '6': case '7': case '8': case '9':
97 nonzero = 1;
98 }
99 if (nonzero && !ok) { *p++ = 'H'; *p = 0; }
100 return (p);
101}
diff --git a/src/lib/libc/net/nsap_addr.c b/src/lib/libc/net/nsap_addr.c
new file mode 100644
index 0000000000..22a5f8d66e
--- /dev/null
+++ b/src/lib/libc/net/nsap_addr.c
@@ -0,0 +1,109 @@
1/* $OpenBSD: nsap_addr.c,v 1.4 1997/07/09 01:08:45 millert Exp $ */
2
3/*
4 * Copyright (c) 1996 by Internet Software Consortium.
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
11 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
12 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
13 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
16 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
17 * SOFTWARE.
18 */
19
20#if defined(LIBC_SCCS) && !defined(lint)
21#if 0
22static char rcsid[] = "$From: nsap_addr.c,v 8.3 1996/08/05 08:31:35 vixie Exp $";
23#else
24static char rcsid[] = "$OpenBSD: nsap_addr.c,v 1.4 1997/07/09 01:08:45 millert Exp $";
25#endif
26#endif /* LIBC_SCCS and not lint */
27
28#include <sys/types.h>
29#include <sys/param.h>
30#include <sys/socket.h>
31#include <netinet/in.h>
32#include <arpa/nameser.h>
33#include <ctype.h>
34#include <resolv.h>
35
36static char
37xtob(c)
38 register int c;
39{
40 return (c - (((c >= '0') && (c <= '9')) ? '0' : '7'));
41}
42
43u_int
44inet_nsap_addr(ascii, binary, maxlen)
45 const char *ascii;
46 u_char *binary;
47 int maxlen;
48{
49 register u_char c, nib;
50 u_int len = 0;
51
52 while ((c = *ascii++) != '\0' && len < maxlen) {
53 if (c == '.' || c == '+' || c == '/')
54 continue;
55 if (!isascii(c))
56 return (0);
57 if (islower(c))
58 c = toupper(c);
59 if (isxdigit(c)) {
60 nib = xtob(c);
61 if ((c = *ascii++)) {
62 c = toupper(c);
63 if (isxdigit(c)) {
64 *binary++ = (nib << 4) | xtob(c);
65 len++;
66 } else
67 return (0);
68 }
69 else
70 return (0);
71 }
72 else
73 return (0);
74 }
75 return (len);
76}
77
78char *
79inet_nsap_ntoa(binlen, binary, ascii)
80 int binlen;
81 register const u_char *binary;
82 register char *ascii;
83{
84 register int nib;
85 int i;
86 static char tmpbuf[255*3];
87 char *start;
88
89 if (ascii)
90 start = ascii;
91 else {
92 ascii = tmpbuf;
93 start = tmpbuf;
94 }
95
96 if (binlen > 255)
97 binlen = 255;
98
99 for (i = 0; i < binlen; i++) {
100 nib = *binary >> 4;
101 *ascii++ = nib + (nib < 10 ? '0' : '7');
102 nib = *binary++ & 0x0f;
103 *ascii++ = nib + (nib < 10 ? '0' : '7');
104 if (((i % 2) == 0 && (i + 1) < binlen))
105 *ascii++ = '.';
106 }
107 *ascii = '\0';
108 return (start);
109}
diff --git a/src/lib/libc/net/ntohl.c b/src/lib/libc/net/ntohl.c
new file mode 100644
index 0000000000..7d3e227e60
--- /dev/null
+++ b/src/lib/libc/net/ntohl.c
@@ -0,0 +1,25 @@
1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 */
5
6#if defined(LIBC_SCCS) && !defined(lint)
7static char *rcsid = "$OpenBSD: ntohl.c,v 1.4 1996/12/12 03:19:56 tholo Exp $";
8#endif /* LIBC_SCCS and not lint */
9
10#include <sys/types.h>
11#include <machine/endian.h>
12
13#undef ntohl
14
15u_int32_t
16ntohl(x)
17 u_int32_t x;
18{
19#if BYTE_ORDER == LITTLE_ENDIAN
20 u_char *s = (u_char *)&x;
21 return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
22#else
23 return x;
24#endif
25}
diff --git a/src/lib/libc/net/ntohs.c b/src/lib/libc/net/ntohs.c
new file mode 100644
index 0000000000..cf6414d4a6
--- /dev/null
+++ b/src/lib/libc/net/ntohs.c
@@ -0,0 +1,29 @@
1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 */
5
6#if defined(LIBC_SCCS) && !defined(lint)
7static char *rcsid = "$OpenBSD: ntohs.c,v 1.6 1997/07/25 20:30:07 mickey Exp $";
8#endif /* LIBC_SCCS and not lint */
9
10#include <sys/types.h>
11#include <machine/endian.h>
12
13#undef ntohs
14
15u_int16_t
16#ifdef __STDC__
17ntohs(u_int16_t x)
18#else
19ntohs(x)
20 u_int16_t x;
21#endif
22{
23#if BYTE_ORDER == LITTLE_ENDIAN
24 u_char *s = (u_char *) &x;
25 return (u_int16_t)(s[0] << 8 | s[1]);
26#else
27 return x;
28#endif
29}
diff --git a/src/lib/libc/net/rcmd.3 b/src/lib/libc/net/rcmd.3
new file mode 100644
index 0000000000..e69e822834
--- /dev/null
+++ b/src/lib/libc/net/rcmd.3
@@ -0,0 +1,227 @@
1.\" $OpenBSD: rcmd.3,v 1.10 1997/09/29 18:25:47 deraadt Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd June 4, 1993
35.Dt RCMD 3
36.Os BSD 4.2
37.Sh NAME
38.Nm rcmd ,
39.Nm rresvport ,
40.Nm iruserok ,
41.Nm ruserok
42.Nd routines for returning a stream to a remote command
43.Sh SYNOPSIS
44.Fd #include <unistd.h>
45.Ft int
46.Fn rcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p"
47.Ft int
48.Fn rresvport "int *port"
49.Ft int
50.Fn iruserok "u_int32_t raddr" "int superuser" "const char *ruser" "const char *luser"
51.Ft int
52.Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser"
53.Sh DESCRIPTION
54The
55.Fn rcmd
56function
57is used by the super-user to execute a command on a remote
58machine using an authentication scheme based on reserved
59port numbers. If the calling process is not setuid and the
60.Li RSH
61environment variable is set and
62.Fa inport
63is
64.Li shell/tcp ,
65.Xr rcmdsh 3
66is called instead with the value of
67.Li RSH .
68Alternately, if the user is not the super-user,
69.Fn rcmd
70will invoke
71.Xr rcmdsh 3
72to run the command via
73.Xr rsh 1 .
74The
75.Fn rresvport
76function
77returns a descriptor to a socket
78with an address in the privileged port space.
79The
80.Fn iruserok
81and
82.Fn ruserok
83functions are used by servers
84to authenticate clients requesting service with
85.Fn rcmd .
86All four functions are present in the same file and are used
87by the
88.Xr rshd 8
89server (among others).
90.Pp
91The
92.Fn rcmd
93function
94looks up the host
95.Fa *ahost
96using
97.Xr gethostbyname 3 ,
98returning \-1 if the host does not exist.
99Otherwise
100.Fa *ahost
101is set to the standard name of the host
102and a connection is established to a server
103residing at the well-known Internet port
104.Fa inport .
105If the user is not the super-user, the only valid port is
106.Li shell/tcp ,
107(usually port 514).
108.Pp
109If the connection succeeds,
110a socket in the Internet domain of type
111.Dv SOCK_STREAM
112is returned to the caller, and given to the remote
113command as
114.Em stdin
115and
116.Em stdout .
117If
118.Fa fd2p
119is non-zero, then an auxiliary channel to a control
120process will be set up, and a descriptor for it will be placed
121in
122.Fa *fd2p .
123The control process will return diagnostic
124output from the command (unit 2) on this channel, and will also
125accept bytes on this channel as being
126.Tn UNIX
127signal numbers, to be
128forwarded to the process group of the command.
129If
130.Fa fd2p
131is 0, then the
132.Em stderr
133(unit 2 of the remote
134command) will be made the same as the
135.Em stdout
136and no
137provision is made for sending arbitrary signals to the remote process,
138although you may be able to get its attention by using out-of-band data.
139Note that if the user is not the super-user,
140.Fa fd2p
141must be 0.
142.Pp
143The protocol is described in detail in
144.Xr rshd 8 .
145.Pp
146The
147.Fn rresvport
148function is used to obtain a socket with a privileged
149address bound to it. This socket is suitable for use
150by
151.Fn rcmd
152and several other functions. Privileged Internet ports are those
153in the range 0 to 1023. Only the super-user
154is allowed to bind an address of this sort to a socket.
155.Fn rresvport
156needs to be seeded with a port number; if that port
157is not available it will find another.
158.Pp
159The
160.Fn iruserok
161and
162.Fn ruserok
163functions take a remote host's IP address or name, respectively,
164two user names and a flag indicating whether the local user's
165name is that of the super-user.
166Then, if the user is
167.Em NOT
168the super-user, it checks the
169.Pa /etc/hosts.equiv
170file.
171If that lookup is not done, or is unsuccessful, the
172.Pa .rhosts
173in the local user's home directory is checked to see if the request for
174service is allowed.
175.Pp
176If this file does not exist, is not a regular file, is owned by anyone
177other than the user or the super-user, or is writeable by anyone other
178than the owner, the check automatically fails.
179Zero is returned if the machine name is listed in the
180.Dq Pa hosts.equiv
181file, or the host and remote user name are found in the
182.Dq Pa .rhosts
183file; otherwise
184.Fn iruserok
185and
186.Fn ruserok
187return \-1.
188If the local domain (as obtained from
189.Xr gethostname 3 )
190is the same as the remote domain, only the machine name need be specified.
191.Pp
192If the IP address of the remote host is known,
193.Fn iruserok
194should be used in preference to
195.Fn ruserok ,
196as it does not require trusting the DNS server for the remote host's domain.
197.Sh DIAGNOSTICS
198The
199.Fn rcmd
200function
201returns a valid socket descriptor on success.
202It returns \-1 on error and prints a diagnostic message on the standard error.
203.Pp
204The
205.Fn rresvport
206function
207returns a valid, bound socket descriptor on success.
208It returns \-1 on error with the global value
209.Va errno
210set according to the reason for failure.
211The error code
212.Dv EAGAIN
213is overloaded to mean ``All network ports in use.''
214.Sh SEE ALSO
215.Xr rlogin 1 ,
216.Xr rsh 1 ,
217.Xr intro 2 ,
218.Xr rexec 3 ,
219.Xr rcmdsh 3 ,
220.Xr rexecd 8 ,
221.Xr rlogind 8 ,
222.Xr bindresvport 3 ,
223.Xr rshd 8
224.Sh HISTORY
225These
226functions appeared in
227.Bx 4.2 .
diff --git a/src/lib/libc/net/rcmd.c b/src/lib/libc/net/rcmd.c
new file mode 100644
index 0000000000..c933f5b447
--- /dev/null
+++ b/src/lib/libc/net/rcmd.c
@@ -0,0 +1,607 @@
1/*
2 * Copyright (c) 1995, 1996, 1998 Theo de Raadt. All rights reserved.
3 * Copyright (c) 1983, 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by the University of
17 * California, Berkeley and its contributors.
18 * This product includes software developed by Theo de Raadt.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#if defined(LIBC_SCCS) && !defined(lint)
37static char *rcsid = "$OpenBSD: rcmd.c,v 1.31 1998/03/19 00:30:05 millert Exp $";
38#endif /* LIBC_SCCS and not lint */
39
40#include <sys/param.h>
41#include <sys/socket.h>
42#include <sys/stat.h>
43
44#include <netinet/in.h>
45#include <arpa/inet.h>
46
47#include <signal.h>
48#include <fcntl.h>
49#include <netdb.h>
50#include <unistd.h>
51#include <pwd.h>
52#include <errno.h>
53#include <stdio.h>
54#include <ctype.h>
55#include <string.h>
56#include <syslog.h>
57#include <stdlib.h>
58#include <netgroup.h>
59
60int __ivaliduser __P((FILE *, in_addr_t, const char *, const char *));
61static int __icheckhost __P((u_int32_t, const char *));
62static char *__gethostloop __P((u_int32_t));
63
64int
65rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
66 char **ahost;
67 in_port_t rport;
68 const char *locuser, *remuser, *cmd;
69 int *fd2p;
70{
71 struct hostent *hp;
72 struct sockaddr_in sin, from;
73 fd_set *readsp = NULL;
74 int oldmask;
75 pid_t pid;
76 int s, lport, timo;
77 char c, *p;
78
79 /* call rcmdsh() with specified remote shell if appropriate. */
80 if (!issetugid() && (p = getenv("RSH"))) {
81 struct servent *sp = getservbyname("shell", "tcp");
82
83 if (sp && sp->s_port == rport)
84 return (rcmdsh(ahost, rport, locuser, remuser,
85 cmd, p));
86 }
87
88 /* use rsh(1) if non-root and remote port is shell. */
89 if (geteuid()) {
90 struct servent *sp = getservbyname("shell", "tcp");
91
92 if (sp && sp->s_port == rport)
93 return (rcmdsh(ahost, rport, locuser, remuser,
94 cmd, NULL));
95 }
96
97 pid = getpid();
98 hp = gethostbyname(*ahost);
99 if (hp == NULL) {
100 herror(*ahost);
101 return (-1);
102 }
103 *ahost = hp->h_name;
104
105 oldmask = sigblock(sigmask(SIGURG));
106 for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
107 s = rresvport(&lport);
108 if (s < 0) {
109 if (errno == EAGAIN)
110 (void)fprintf(stderr,
111 "rcmd: socket: All ports in use\n");
112 else
113 (void)fprintf(stderr, "rcmd: socket: %s\n",
114 strerror(errno));
115 sigsetmask(oldmask);
116 return (-1);
117 }
118 fcntl(s, F_SETOWN, pid);
119 bzero(&sin, sizeof sin);
120 sin.sin_len = sizeof(struct sockaddr_in);
121 sin.sin_family = hp->h_addrtype;
122 sin.sin_port = rport;
123 bcopy(hp->h_addr_list[0], &sin.sin_addr, hp->h_length);
124 if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
125 break;
126 (void)close(s);
127 if (errno == EADDRINUSE) {
128 lport--;
129 continue;
130 }
131 if (errno == ECONNREFUSED && timo <= 16) {
132 (void)sleep(timo);
133 timo *= 2;
134 continue;
135 }
136 if (hp->h_addr_list[1] != NULL) {
137 int oerrno = errno;
138
139 (void)fprintf(stderr, "connect to address %s: ",
140 inet_ntoa(sin.sin_addr));
141 errno = oerrno;
142 perror(0);
143 hp->h_addr_list++;
144 bcopy(hp->h_addr_list[0], &sin.sin_addr, hp->h_length);
145 (void)fprintf(stderr, "Trying %s...\n",
146 inet_ntoa(sin.sin_addr));
147 continue;
148 }
149 (void)fprintf(stderr, "%s: %s\n", hp->h_name, strerror(errno));
150 sigsetmask(oldmask);
151 return (-1);
152 }
153#if 0
154 /*
155 * try to rresvport() to the same port. This will make rresvport()
156 * fail it's first bind, resulting in it choosing a random port.
157 */
158 lport--;
159#endif
160 if (fd2p == 0) {
161 write(s, "", 1);
162 lport = 0;
163 } else {
164 char num[8];
165 int s2 = rresvport(&lport), s3;
166 int len = sizeof(from);
167 int fdssize = howmany(MAX(s, s2)+1, NFDBITS) * sizeof(fd_mask);
168
169 if (s2 < 0)
170 goto bad;
171 readsp = (fd_set *)malloc(fdssize);
172 if (readsp == NULL)
173 goto bad;
174 listen(s2, 1);
175 (void)snprintf(num, sizeof(num), "%d", lport);
176 if (write(s, num, strlen(num)+1) != strlen(num)+1) {
177 (void)fprintf(stderr,
178 "rcmd: write (setting up stderr): %s\n",
179 strerror(errno));
180 (void)close(s2);
181 goto bad;
182 }
183again:
184 bzero(readsp, fdssize);
185 FD_SET(s, readsp);
186 FD_SET(s2, readsp);
187 errno = 0;
188 if (select(MAX(s, s2) + 1, readsp, 0, 0, 0) < 1 ||
189 !FD_ISSET(s2, readsp)) {
190 if (errno != 0)
191 (void)fprintf(stderr,
192 "rcmd: select (setting up stderr): %s\n",
193 strerror(errno));
194 else
195 (void)fprintf(stderr,
196 "select: protocol failure in circuit setup\n");
197 (void)close(s2);
198 goto bad;
199 }
200 s3 = accept(s2, (struct sockaddr *)&from, &len);
201 /*
202 * XXX careful for ftp bounce attacks. If discovered, shut them
203 * down and check for the real auxiliary channel to connect.
204 */
205 if (from.sin_family == AF_INET && from.sin_port == htons(20)) {
206 close(s3);
207 goto again;
208 }
209 (void)close(s2);
210 if (s3 < 0) {
211 (void)fprintf(stderr,
212 "rcmd: accept: %s\n", strerror(errno));
213 lport = 0;
214 goto bad;
215 }
216 *fd2p = s3;
217 from.sin_port = ntohs(from.sin_port);
218 if (from.sin_family != AF_INET ||
219 from.sin_port >= IPPORT_RESERVED ||
220 from.sin_port < IPPORT_RESERVED / 2) {
221 (void)fprintf(stderr,
222 "socket: protocol failure in circuit setup.\n");
223 goto bad2;
224 }
225 }
226 (void)write(s, locuser, strlen(locuser)+1);
227 (void)write(s, remuser, strlen(remuser)+1);
228 (void)write(s, cmd, strlen(cmd)+1);
229 if (read(s, &c, 1) != 1) {
230 (void)fprintf(stderr,
231 "rcmd: %s: %s\n", *ahost, strerror(errno));
232 goto bad2;
233 }
234 if (c != 0) {
235 while (read(s, &c, 1) == 1) {
236 (void)write(STDERR_FILENO, &c, 1);
237 if (c == '\n')
238 break;
239 }
240 goto bad2;
241 }
242 sigsetmask(oldmask);
243 free(readsp);
244 return (s);
245bad2:
246 if (lport)
247 (void)close(*fd2p);
248bad:
249 if (readsp)
250 free(readsp);
251 (void)close(s);
252 sigsetmask(oldmask);
253 return (-1);
254}
255
256int
257rresvport(alport)
258 int *alport;
259{
260 struct sockaddr_in sin;
261 int s;
262
263 bzero(&sin, sizeof sin);
264 sin.sin_len = sizeof(struct sockaddr_in);
265 sin.sin_family = AF_INET;
266 sin.sin_addr.s_addr = INADDR_ANY;
267 s = socket(AF_INET, SOCK_STREAM, 0);
268 if (s < 0)
269 return (-1);
270 sin.sin_port = htons((in_port_t)*alport);
271 if (*alport < IPPORT_RESERVED - 1) {
272 if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
273 return (s);
274 if (errno != EADDRINUSE) {
275 (void)close(s);
276 return (-1);
277 }
278 }
279 sin.sin_port = 0;
280 if (bindresvport(s, &sin) == -1) {
281 (void)close(s);
282 return (-1);
283 }
284 *alport = (int)ntohs(sin.sin_port);
285 return (s);
286}
287
288int __check_rhosts_file = 1;
289char *__rcmd_errstr;
290
291int
292ruserok(rhost, superuser, ruser, luser)
293 const char *rhost, *ruser, *luser;
294 int superuser;
295{
296 struct hostent *hp;
297 char **ap;
298 int i;
299#define MAXADDRS 35
300 u_int32_t addrs[MAXADDRS + 1];
301
302 if ((hp = gethostbyname(rhost)) == NULL)
303 return (-1);
304 for (i = 0, ap = hp->h_addr_list; *ap && i < MAXADDRS; ++ap, ++i)
305 bcopy(*ap, &addrs[i], sizeof(addrs[i]));
306 addrs[i] = 0;
307
308 for (i = 0; i < MAXADDRS && addrs[i]; i++)
309 if (iruserok((in_addr_t)addrs[i], superuser, ruser, luser) == 0)
310 return (0);
311 return (-1);
312}
313
314/*
315 * New .rhosts strategy: We are passed an ip address. We spin through
316 * hosts.equiv and .rhosts looking for a match. When the .rhosts only
317 * has ip addresses, we don't have to trust a nameserver. When it
318 * contains hostnames, we spin through the list of addresses the nameserver
319 * gives us and look for a match.
320 *
321 * Returns 0 if ok, -1 if not ok.
322 */
323int
324iruserok(raddr, superuser, ruser, luser)
325 u_int32_t raddr;
326 int superuser;
327 const char *ruser, *luser;
328{
329 register char *cp;
330 struct stat sbuf;
331 struct passwd *pwd;
332 FILE *hostf;
333 uid_t uid;
334 int first;
335 char pbuf[MAXPATHLEN];
336
337 first = 1;
338 hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r");
339again:
340 if (hostf) {
341 if (__ivaliduser(hostf, raddr, luser, ruser) == 0) {
342 (void)fclose(hostf);
343 return (0);
344 }
345 (void)fclose(hostf);
346 }
347 if (first == 1 && (__check_rhosts_file || superuser)) {
348 first = 0;
349 if ((pwd = getpwnam(luser)) == NULL)
350 return (-1);
351 (void)strcpy(pbuf, pwd->pw_dir);
352 (void)strcat(pbuf, "/.rhosts");
353
354 /*
355 * Change effective uid while opening .rhosts. If root and
356 * reading an NFS mounted file system, can't read files that
357 * are protected read/write owner only.
358 */
359 uid = geteuid();
360 (void)seteuid(pwd->pw_uid);
361 hostf = fopen(pbuf, "r");
362 (void)seteuid(uid);
363
364 if (hostf == NULL)
365 return (-1);
366 /*
367 * If not a regular file, or is owned by someone other than
368 * user or root or if writeable by anyone but the owner, quit.
369 */
370 cp = NULL;
371 if (lstat(pbuf, &sbuf) < 0)
372 cp = ".rhosts lstat failed";
373 else if (!S_ISREG(sbuf.st_mode))
374 cp = ".rhosts not regular file";
375 else if (fstat(fileno(hostf), &sbuf) < 0)
376 cp = ".rhosts fstat failed";
377 else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid)
378 cp = "bad .rhosts owner";
379 else if (sbuf.st_mode & (S_IWGRP|S_IWOTH))
380 cp = ".rhosts writeable by other than owner";
381 /* If there were any problems, quit. */
382 if (cp) {
383 __rcmd_errstr = cp;
384 (void)fclose(hostf);
385 return (-1);
386 }
387 goto again;
388 }
389 return (-1);
390}
391
392/*
393 * XXX
394 * Don't make static, used by lpd(8).
395 *
396 * Returns 0 if ok, -1 if not ok.
397 */
398int
399__ivaliduser(hostf, raddrl, luser, ruser)
400 FILE *hostf;
401 in_addr_t raddrl;
402 const char *luser, *ruser;
403{
404 register char *user, *p;
405 char *buf;
406 const char *auser, *ahost;
407 int hostok, userok;
408 char *rhost = (char *)-1;
409 char domain[MAXHOSTNAMELEN];
410 u_int32_t raddr = (u_int32_t)raddrl;
411 size_t buflen;
412
413 getdomainname(domain, sizeof(domain));
414
415 while ((buf = fgetln(hostf, &buflen))) {
416 p = buf;
417 if (*p == '#')
418 continue;
419 while (*p != '\n' && *p != ' ' && *p != '\t' && p < buf + buflen) {
420 if (!isprint(*p))
421 goto bail;
422 *p = isupper(*p) ? tolower(*p) : *p;
423 p++;
424 }
425 if (p >= buf + buflen)
426 continue;
427 if (*p == ' ' || *p == '\t') {
428 *p++ = '\0';
429 while ((*p == ' ' || *p == '\t') && p < buf + buflen)
430 p++;
431 if (p >= buf + buflen)
432 continue;
433 user = p;
434 while (*p != '\n' && *p != ' ' &&
435 *p != '\t' && p < buf + buflen) {
436 if (!isprint(*p))
437 goto bail;
438 p++;
439 }
440 } else
441 user = p;
442 *p = '\0';
443
444 if (p == buf)
445 continue;
446
447 auser = *user ? user : luser;
448 ahost = buf;
449
450 if (strlen(ahost) >= MAXHOSTNAMELEN)
451 continue;
452
453 /*
454 * innetgr() must lookup a hostname (we do not attempt
455 * to change the semantics so that netgroups may have
456 * #.#.#.# addresses in the list.)
457 */
458 if (ahost[0] == '+')
459 switch (ahost[1]) {
460 case '\0':
461 hostok = 1;
462 break;
463 case '@':
464 if (rhost == (char *)-1)
465 rhost = __gethostloop(raddr);
466 hostok = 0;
467 if (rhost)
468 hostok = innetgr(&ahost[2], rhost,
469 NULL, domain);
470 break;
471 default:
472 hostok = __icheckhost(raddr, &ahost[1]);
473 break;
474 }
475 else if (ahost[0] == '-')
476 switch (ahost[1]) {
477 case '\0':
478 hostok = -1;
479 break;
480 case '@':
481 if (rhost == (char *)-1)
482 rhost = __gethostloop(raddr);
483 hostok = 0;
484 if (rhost)
485 hostok = -innetgr(&ahost[2], rhost,
486 NULL, domain);
487 break;
488 default:
489 hostok = -__icheckhost(raddr, &ahost[1]);
490 break;
491 }
492 else
493 hostok = __icheckhost(raddr, ahost);
494
495
496 if (auser[0] == '+')
497 switch (auser[1]) {
498 case '\0':
499 userok = 1;
500 break;
501 case '@':
502 userok = innetgr(&auser[2], NULL, ruser,
503 domain);
504 break;
505 default:
506 userok = strcmp(ruser, &auser[1]) ? 0 : 1;
507 break;
508 }
509 else if (auser[0] == '-')
510 switch (auser[1]) {
511 case '\0':
512 userok = -1;
513 break;
514 case '@':
515 userok = -innetgr(&auser[2], NULL, ruser,
516 domain);
517 break;
518 default:
519 userok = strcmp(ruser, &auser[1]) ? 0 : -1;
520 break;
521 }
522 else
523 userok = strcmp(ruser, auser) ? 0 : 1;
524
525 /* Check if one component did not match */
526 if (hostok == 0 || userok == 0)
527 continue;
528
529 /* Check if we got a forbidden pair */
530 if (userok <= -1 || hostok <= -1)
531 return (-1);
532
533 /* Check if we got a valid pair */
534 if (hostok >= 1 && userok >= 1)
535 return (0);
536 }
537bail:
538 return (-1);
539}
540
541/*
542 * Returns "true" if match, 0 if no match. If we do not find any
543 * semblance of an A->PTR->A loop, allow a simple #.#.#.# match to work.
544 */
545static int
546__icheckhost(raddr, lhost)
547 u_int32_t raddr;
548 const char *lhost;
549{
550 register struct hostent *hp;
551 register char **pp;
552 struct in_addr in;
553
554 hp = gethostbyname(lhost);
555 if (hp != NULL) {
556 /* Spin through ip addresses. */
557 for (pp = hp->h_addr_list; *pp; ++pp)
558 if (!bcmp(&raddr, *pp, sizeof(raddr)))
559 return (1);
560 }
561
562 in.s_addr = raddr;
563 if (strcmp(lhost, inet_ntoa(in)) == 0)
564 return (1);
565 return (0);
566}
567
568/*
569 * Return the hostname associated with the supplied address.
570 * Do a reverse lookup as well for security. If a loop cannot
571 * be found, pack the result of inet_ntoa() into the string.
572 */
573static char *
574__gethostloop(raddr)
575 u_int32_t raddr;
576{
577 static char remotehost[MAXHOSTNAMELEN];
578 struct hostent *hp;
579 struct in_addr in;
580
581 hp = gethostbyaddr((char *) &raddr, sizeof(raddr), AF_INET);
582 if (hp == NULL)
583 return (NULL);
584
585 /*
586 * Look up the name and check that the supplied
587 * address is in the list
588 */
589 strncpy(remotehost, hp->h_name, sizeof(remotehost) - 1);
590 remotehost[sizeof(remotehost) - 1] = '\0';
591 hp = gethostbyname(remotehost);
592 if (hp == NULL)
593 return (NULL);
594
595 for (; hp->h_addr_list[0] != NULL; hp->h_addr_list++)
596 if (!bcmp(hp->h_addr_list[0], (caddr_t)&raddr, sizeof(raddr)))
597 return (remotehost);
598
599 /*
600 * either the DNS adminstrator has made a configuration
601 * mistake, or someone has attempted to spoof us
602 */
603 in.s_addr = raddr;
604 syslog(LOG_NOTICE, "rcmd: address %s not listed for host %s",
605 inet_ntoa(in), hp->h_name);
606 return (NULL);
607}
diff --git a/src/lib/libc/net/rcmdsh.3 b/src/lib/libc/net/rcmdsh.3
new file mode 100644
index 0000000000..fd89acee8f
--- /dev/null
+++ b/src/lib/libc/net/rcmdsh.3
@@ -0,0 +1,108 @@
1.\" $OpenBSD: rcmdsh.3,v 1.3 1998/06/26 17:54:09 millert Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd Sep 1, 1996
35.Dt RCMDSH 3
36.Os OpenBSD
37.Sh NAME
38.Nm rcmdsh
39.Nd return a stream to a remote command without superuser
40.Sh SYNOPSIS
41.Fd #include <unistd.h>
42.Ft int
43.Fn rcmdsh "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "char *rshprog"
44.Sh DESCRIPTION
45The
46.Fn rcmdsh
47function
48is used by normal users to execute a command on
49a remote machine using an authentication scheme based
50on reserved port numbers using
51.Xr rshd 8
52or the value of
53.Fa rshprog
54(if non-NULL).
55.Pp
56The
57.Fn rcmdsh
58function
59looks up the host
60.Fa *ahost
61using
62.Xr gethostbyname 3 ,
63returning \-1 if the host does not exist.
64Otherwise
65.Fa *ahost
66is set to the standard name of the host
67and a connection is established to a server
68residing at the well-known Internet port
69.Li shell/tcp
70(or whatever port is used by
71.Fa rshprog
72). The parameter
73.Fa inport
74is ignored; it is only included to provide an interface similar to
75.Xr rcmd 3 .
76.Pp
77If the connection succeeds,
78a socket in the
79.Tn UNIX
80domain of type
81.Dv SOCK_STREAM
82is returned to the caller, and given to the remote
83command as
84.Em stdin
85and
86.Em stdout ,
87and
88.Em stderr .
89.Sh DIAGNOSTICS
90The
91.Fn rcmdsh
92function
93returns a valid socket descriptor on success.
94It returns \-1 on error and prints a diagnostic message on the standard error.
95.Sh SEE ALSO
96.Xr rsh 1 ,
97.Xr socketpair 2 ,
98.Xr rcmd 3 ,
99.Xr rshd 8
100.Sh BUGS
101If
102.Xr rsh 1
103gets an error a file descriptor is still returned instead of \-1.
104.Sh HISTORY
105The
106.Fn rcmdsh
107function first appeared in
108.Ox 2.0 .
diff --git a/src/lib/libc/net/rcmdsh.c b/src/lib/libc/net/rcmdsh.c
new file mode 100644
index 0000000000..93523a4c56
--- /dev/null
+++ b/src/lib/libc/net/rcmdsh.c
@@ -0,0 +1,124 @@
1/* $OpenBSD: rcmdsh.c,v 1.5 1998/04/25 16:23:58 millert Exp $ */
2
3/*
4 * This is an rcmd() replacement originally by
5 * Chris Siebenmann <cks@utcc.utoronto.ca>.
6 */
7
8#if defined(LIBC_SCCS) && !defined(lint)
9static char *rcsid = "$OpenBSD: rcmdsh.c,v 1.5 1998/04/25 16:23:58 millert Exp $";
10#endif /* LIBC_SCCS and not lint */
11
12#include <sys/types.h>
13#include <sys/socket.h>
14#include <sys/wait.h>
15#include <signal.h>
16#include <errno.h>
17#include <netdb.h>
18#include <stdio.h>
19#include <string.h>
20#include <pwd.h>
21#include <paths.h>
22#include <unistd.h>
23
24/*
25 * This is a replacement rcmd() function that uses the rsh(1)
26 * program in place of a direct rcmd(3) function call so as to
27 * avoid having to be root. Note that rport is ignored.
28 */
29/* ARGSUSED */
30int
31rcmdsh(ahost, rport, locuser, remuser, cmd, rshprog)
32 char **ahost;
33 int rport;
34 const char *locuser, *remuser, *cmd;
35 char *rshprog;
36{
37 struct hostent *hp;
38 int cpid, sp[2];
39 char *p;
40 struct passwd *pw;
41
42 /* What rsh/shell to use. */
43 if (rshprog == NULL)
44 rshprog = _PATH_RSH;
45
46 /* locuser must exist on this host. */
47 if ((pw = getpwnam(locuser)) == NULL) {
48 (void) fprintf(stderr, "rcmdsh: unknown user: %s\n", locuser);
49 return(-1);
50 }
51
52 /* Validate remote hostname. */
53 if (strcmp(*ahost, "localhost") != 0) {
54 if ((hp = gethostbyname(*ahost)) == NULL) {
55 herror(*ahost);
56 return(-1);
57 }
58 *ahost = hp->h_name;
59 }
60
61 /* Get a socketpair we'll use for stdin and stdout. */
62 if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, sp) < 0) {
63 perror("rcmdsh: socketpair");
64 return(-1);
65 }
66
67 cpid = fork();
68 if (cpid < 0) {
69 perror("rcmdsh: fork failed");
70 return(-1);
71 } else if (cpid == 0) {
72 /*
73 * Child. We use sp[1] to be stdin/stdout, and close sp[0].
74 */
75 (void) close(sp[0]);
76 if (dup2(sp[1], 0) < 0 || dup2(0, 1) < 0) {
77 perror("rcmdsh: dup2 failed");
78 _exit(255);
79 }
80 /* Fork again to lose parent. */
81 cpid = fork();
82 if (cpid < 0) {
83 perror("rcmdsh: fork to lose parent failed");
84 _exit(255);
85 }
86 if (cpid > 0)
87 _exit(0);
88
89 /* In grandchild here. Become local user for rshprog. */
90 if (setuid(pw->pw_uid)) {
91 (void) fprintf(stderr, "rcmdsh: setuid(%u): %s\n",
92 pw->pw_uid, strerror(errno));
93 _exit(255);
94 }
95
96 /*
97 * If remote host is "localhost" and local and remote user
98 * are the same, avoid running remote shell for efficiency.
99 */
100 if (!strcmp(*ahost, "localhost") && !strcmp(locuser, remuser)) {
101 if (pw->pw_shell[0] == '\0')
102 rshprog = _PATH_BSHELL;
103 else
104 rshprog = pw->pw_shell;
105 p = strrchr(rshprog, '/');
106 execlp(rshprog, p ? p+1 : rshprog, "-c", cmd,
107 (char *) NULL);
108 } else {
109 p = strrchr(rshprog, '/');
110 execlp(rshprog, p ? p+1 : rshprog, *ahost, "-l",
111 remuser, cmd, (char *) NULL);
112 }
113 (void) fprintf(stderr, "rcmdsh: execlp %s failed: %s\n",
114 rshprog, strerror(errno));
115 _exit(255);
116 } else {
117 /* Parent. close sp[1], return sp[0]. */
118 (void) close(sp[1]);
119 /* Reap child. */
120 (void) wait(NULL);
121 return(sp[0]);
122 }
123 /* NOTREACHED */
124}
diff --git a/src/lib/libc/net/recv.c b/src/lib/libc/net/recv.c
new file mode 100644
index 0000000000..d209a07213
--- /dev/null
+++ b/src/lib/libc/net/recv.c
@@ -0,0 +1,50 @@
1/*
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: recv.c,v 1.2 1996/08/19 08:29:40 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <sys/socket.h>
40
41#include <stddef.h>
42
43ssize_t
44recv(s, buf, len, flags)
45 int s, flags;
46 size_t len;
47 void *buf;
48{
49 return (recvfrom(s, buf, len, flags, NULL, 0));
50}
diff --git a/src/lib/libc/net/res_comp.c b/src/lib/libc/net/res_comp.c
new file mode 100644
index 0000000000..f7a0358967
--- /dev/null
+++ b/src/lib/libc/net/res_comp.c
@@ -0,0 +1,510 @@
1/* $OpenBSD: res_comp.c,v 1.8 1997/07/09 01:08:49 millert Exp $ */
2
3/*
4 * ++Copyright++ 1985, 1993
5 * -
6 * Copyright (c) 1985, 1993
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 * -
37 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
38 *
39 * Permission to use, copy, modify, and distribute this software for any
40 * purpose with or without fee is hereby granted, provided that the above
41 * copyright notice and this permission notice appear in all copies, and that
42 * the name of Digital Equipment Corporation not be used in advertising or
43 * publicity pertaining to distribution of the document or software without
44 * specific, written prior permission.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
47 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
49 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
50 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
52 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 * SOFTWARE.
54 * -
55 * --Copyright--
56 */
57
58#if defined(LIBC_SCCS) && !defined(lint)
59#if 0
60static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
61static char rcsid[] = "$From: res_comp.c,v 8.11 1996/12/02 09:17:22 vixie Exp $";
62#else
63static char rcsid[] = "$OpenBSD: res_comp.c,v 1.8 1997/07/09 01:08:49 millert Exp $";
64#endif
65#endif /* LIBC_SCCS and not lint */
66
67#include <sys/types.h>
68#include <sys/param.h>
69#include <netinet/in.h>
70#include <arpa/nameser.h>
71
72#include <stdio.h>
73#include <resolv.h>
74#include <ctype.h>
75
76#include <unistd.h>
77#include <string.h>
78
79static int dn_find __P((u_char *exp_dn, u_char *msg,
80 u_char **dnptrs, u_char **lastdnptr));
81
82/*
83 * Expand compressed domain name 'comp_dn' to full domain name.
84 * 'msg' is a pointer to the begining of the message,
85 * 'eomorig' points to the first location after the message,
86 * 'exp_dn' is a pointer to a buffer of size 'length' for the result.
87 * Return size of compressed name or -1 if there was an error.
88 */
89int
90dn_expand(msg, eomorig, comp_dn, exp_dn, length)
91 const u_char *msg, *eomorig, *comp_dn;
92 char *exp_dn;
93 int length;
94{
95 register const u_char *cp;
96 register char *dn;
97 register int n, c;
98 char *eom;
99 int len = -1, checked = 0;
100
101 dn = exp_dn;
102 cp = comp_dn;
103 if (length > MAXHOSTNAMELEN-1)
104 length = MAXHOSTNAMELEN-1;
105 eom = exp_dn + length;
106 /*
107 * fetch next label in domain name
108 */
109 while ((n = *cp++)) {
110 /*
111 * Check for indirection
112 */
113 switch (n & INDIR_MASK) {
114 case 0:
115 if (dn != exp_dn) {
116 if (dn >= eom)
117 return (-1);
118 *dn++ = '.';
119 }
120 if (dn+n >= eom)
121 return (-1);
122 checked += n + 1;
123 while (--n >= 0) {
124 if (((c = *cp++) == '.') || (c == '\\')) {
125 if (dn + n + 2 >= eom)
126 return (-1);
127 *dn++ = '\\';
128 }
129 *dn++ = c;
130 if (cp >= eomorig) /* out of range */
131 return (-1);
132 }
133 break;
134
135 case INDIR_MASK:
136 if (len < 0)
137 len = cp - comp_dn + 1;
138 cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff));
139 if (cp < msg || cp >= eomorig) /* out of range */
140 return (-1);
141 checked += 2;
142 /*
143 * Check for loops in the compressed name;
144 * if we've looked at the whole message,
145 * there must be a loop.
146 */
147 if (checked >= eomorig - msg)
148 return (-1);
149 break;
150
151 default:
152 return (-1); /* flag error */
153 }
154 }
155 *dn = '\0';
156 if (len < 0)
157 len = cp - comp_dn;
158 return (len);
159}
160
161/*
162 * Compress domain name 'exp_dn' into 'comp_dn'.
163 * Return the size of the compressed name or -1.
164 * 'length' is the size of the array pointed to by 'comp_dn'.
165 * 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0]
166 * is a pointer to the beginning of the message. The list ends with NULL.
167 * 'lastdnptr' is a pointer to the end of the arrary pointed to
168 * by 'dnptrs'. Side effect is to update the list of pointers for
169 * labels inserted into the message as we compress the name.
170 * If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr'
171 * is NULL, we don't update the list.
172 */
173int
174dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
175 const char *exp_dn;
176 u_char *comp_dn, **dnptrs, **lastdnptr;
177 int length;
178{
179 register u_char *cp, *dn;
180 register int c, l;
181 u_char **cpp, **lpp, *sp, *eob;
182 u_char *msg;
183
184 dn = (u_char *)exp_dn;
185 cp = comp_dn;
186 eob = cp + length;
187 lpp = cpp = NULL;
188 if (dnptrs != NULL) {
189 if ((msg = *dnptrs++) != NULL) {
190 for (cpp = dnptrs; *cpp != NULL; cpp++)
191 ;
192 lpp = cpp; /* end of list to search */
193 }
194 } else
195 msg = NULL;
196 for (c = *dn++; c != '\0'; ) {
197 /* look to see if we can use pointers */
198 if (msg != NULL) {
199 if ((l = dn_find(dn-1, msg, dnptrs, lpp)) >= 0) {
200 if (cp+1 >= eob)
201 return (-1);
202 *cp++ = (l >> 8) | INDIR_MASK;
203 *cp++ = l % 256;
204 return (cp - comp_dn);
205 }
206 /* not found, save it */
207 if (lastdnptr != NULL && cpp < lastdnptr-1) {
208 *cpp++ = cp;
209 *cpp = NULL;
210 }
211 }
212 sp = cp++; /* save ptr to length byte */
213 do {
214 if (c == '.') {
215 c = *dn++;
216 break;
217 }
218 if (c == '\\') {
219 if ((c = *dn++) == '\0')
220 break;
221 }
222 if (cp >= eob) {
223 if (msg != NULL)
224 *lpp = NULL;
225 return (-1);
226 }
227 *cp++ = c;
228 } while ((c = *dn++) != '\0');
229 /* catch trailing '.'s but not '..' */
230 if ((l = cp - sp - 1) == 0 && c == '\0') {
231 cp--;
232 break;
233 }
234 if (l <= 0 || l > MAXLABEL) {
235 if (msg != NULL)
236 *lpp = NULL;
237 return (-1);
238 }
239 *sp = l;
240 }
241 if (cp >= eob) {
242 if (msg != NULL)
243 *lpp = NULL;
244 return (-1);
245 }
246 *cp++ = '\0';
247 return (cp - comp_dn);
248}
249
250/*
251 * Skip over a compressed domain name. Return the size or -1.
252 */
253int
254__dn_skipname(comp_dn, eom)
255 const u_char *comp_dn, *eom;
256{
257 register const u_char *cp;
258 register int n;
259
260 cp = comp_dn;
261 while (cp < eom && (n = *cp++)) {
262 /*
263 * check for indirection
264 */
265 switch (n & INDIR_MASK) {
266 case 0: /* normal case, n == len */
267 cp += n;
268 continue;
269 case INDIR_MASK: /* indirection */
270 cp++;
271 break;
272 default: /* illegal type */
273 return (-1);
274 }
275 break;
276 }
277 if (cp > eom)
278 return (-1);
279 return (cp - comp_dn);
280}
281
282static int
283mklower(ch)
284 register int ch;
285{
286 if (isascii(ch) && isupper(ch))
287 return (tolower(ch));
288 return (ch);
289}
290
291/*
292 * Search for expanded name from a list of previously compressed names.
293 * Return the offset from msg if found or -1.
294 * dnptrs is the pointer to the first name on the list,
295 * not the pointer to the start of the message.
296 */
297static int
298dn_find(exp_dn, msg, dnptrs, lastdnptr)
299 u_char *exp_dn, *msg;
300 u_char **dnptrs, **lastdnptr;
301{
302 register u_char *dn, *cp, **cpp;
303 register int n;
304 u_char *sp;
305
306 for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
307 dn = exp_dn;
308 sp = cp = *cpp;
309 while ((n = *cp++)) {
310 /*
311 * check for indirection
312 */
313 switch (n & INDIR_MASK) {
314 case 0: /* normal case, n == len */
315 while (--n >= 0) {
316 if (*dn == '.')
317 goto next;
318 if (*dn == '\\')
319 dn++;
320 if (mklower(*dn++) != mklower(*cp++))
321 goto next;
322 }
323 if ((n = *dn++) == '\0' && *cp == '\0')
324 return (sp - msg);
325 if (n == '.')
326 continue;
327 goto next;
328
329 case INDIR_MASK: /* indirection */
330 cp = msg + (((n & 0x3f) << 8) | *cp);
331 break;
332
333 default: /* illegal type */
334 return (-1);
335 }
336 }
337 if (*dn == '\0')
338 return (sp - msg);
339 next: ;
340 }
341 return (-1);
342}
343
344/*
345 * Verify that a domain name uses an acceptable character set.
346 */
347
348/*
349 * Note the conspicuous absence of ctype macros in these definitions. On
350 * non-ASCII hosts, we can't depend on string literals or ctype macros to
351 * tell us anything about network-format data. The rest of the BIND system
352 * is not careful about this, but for some reason, we're doing it right here.
353 */
354#define PERIOD 0x2e
355#define hyphenchar(c) ((c) == 0x2d)
356#define bslashchar(c) ((c) == 0x5c)
357#define periodchar(c) ((c) == PERIOD)
358#define asterchar(c) ((c) == 0x2a)
359#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \
360 || ((c) >= 0x61 && (c) <= 0x7a))
361#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)
362
363#define borderchar(c) (alphachar(c) || digitchar(c))
364#define middlechar(c) (borderchar(c) || hyphenchar(c))
365#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)
366
367int
368res_hnok(dn)
369 const char *dn;
370{
371 int pch = PERIOD, ch = *dn++;
372
373 while (ch != '\0') {
374 int nch = *dn++;
375
376 if (periodchar(ch)) {
377 ;
378 } else if (periodchar(pch)) {
379 if (!borderchar(ch))
380 return (0);
381 } else if (periodchar(nch) || nch == '\0') {
382 if (!borderchar(ch))
383 return (0);
384 } else {
385 if (!middlechar(ch))
386 return (0);
387 }
388 pch = ch, ch = nch;
389 }
390 return (1);
391}
392
393/*
394 * hostname-like (A, MX, WKS) owners can have "*" as their first label
395 * but must otherwise be as a host name.
396 */
397int
398res_ownok(dn)
399 const char *dn;
400{
401 if (asterchar(dn[0])) {
402 if (periodchar(dn[1]))
403 return (res_hnok(dn+2));
404 if (dn[1] == '\0')
405 return (1);
406 }
407 return (res_hnok(dn));
408}
409
410/*
411 * SOA RNAMEs and RP RNAMEs can have any printable character in their first
412 * label, but the rest of the name has to look like a host name.
413 */
414int
415res_mailok(dn)
416 const char *dn;
417{
418 int ch, escaped = 0;
419
420 /* "." is a valid missing representation */
421 if (*dn == '\0')
422 return(1);
423
424 /* otherwise <label>.<hostname> */
425 while ((ch = *dn++) != '\0') {
426 if (!domainchar(ch))
427 return (0);
428 if (!escaped && periodchar(ch))
429 break;
430 if (escaped)
431 escaped = 0;
432 else if (bslashchar(ch))
433 escaped = 1;
434 }
435 if (periodchar(ch))
436 return (res_hnok(dn));
437 return(0);
438}
439
440/*
441 * This function is quite liberal, since RFC 1034's character sets are only
442 * recommendations.
443 */
444int
445res_dnok(dn)
446 const char *dn;
447{
448 int ch;
449
450 while ((ch = *dn++) != '\0')
451 if (!domainchar(ch))
452 return (0);
453 return (1);
454}
455
456/*
457 * Routines to insert/extract short/long's.
458 */
459
460u_int16_t
461_getshort(msgp)
462 register const u_char *msgp;
463{
464 register u_int16_t u;
465
466 GETSHORT(u, msgp);
467 return (u);
468}
469
470#ifdef NeXT
471/*
472 * nExt machines have some funky library conventions, which we must maintain.
473 */
474u_int16_t
475res_getshort(msgp)
476 register const u_char *msgp;
477{
478 return (_getshort(msgp));
479}
480#endif
481
482u_int32_t
483_getlong(msgp)
484 register const u_char *msgp;
485{
486 register u_int32_t u;
487
488 GETLONG(u, msgp);
489 return (u);
490}
491
492void
493#if defined(__STDC__) || defined(__cplusplus)
494__putshort(register u_int16_t s, register u_char *msgp) /* must match proto */
495#else
496__putshort(s, msgp)
497 register u_int16_t s;
498 register u_char *msgp;
499#endif
500{
501 PUTSHORT(s, msgp);
502}
503
504void
505__putlong(l, msgp)
506 register u_int32_t l;
507 register u_char *msgp;
508{
509 PUTLONG(l, msgp);
510}
diff --git a/src/lib/libc/net/res_data.c b/src/lib/libc/net/res_data.c
new file mode 100644
index 0000000000..b0d19c36bb
--- /dev/null
+++ b/src/lib/libc/net/res_data.c
@@ -0,0 +1,117 @@
1/* $OpenBSD: res_data.c,v 1.1 1997/03/13 19:07:36 downsj Exp $ */
2
3/*
4 * ++Copyright++ 1995
5 * -
6 * Copyright (c) 1995
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 * -
37 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
38 *
39 * Permission to use, copy, modify, and distribute this software for any
40 * purpose with or without fee is hereby granted, provided that the above
41 * copyright notice and this permission notice appear in all copies, and that
42 * the name of Digital Equipment Corporation not be used in advertising or
43 * publicity pertaining to distribution of the document or software without
44 * specific, written prior permission.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
47 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
49 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
50 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
52 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 * SOFTWARE.
54 * -
55 * --Copyright--
56 */
57
58#if defined(LIBC_SCCS) && !defined(lint)
59#if 0
60static char rcsid[] = "$From: res_data.c,v 8.2 1996/08/05 08:31:35 vixie Exp $";
61#else
62static char rcsid[] = "$OpenBSD: res_data.c,v 1.1 1997/03/13 19:07:36 downsj Exp $";
63#endif
64#endif /* LIBC_SCCS and not lint */
65
66#include <sys/types.h>
67#include <sys/param.h>
68#include <sys/socket.h>
69#include <sys/time.h>
70#include <netinet/in.h>
71#include <arpa/inet.h>
72#include <arpa/nameser.h>
73
74#include <stdio.h>
75#include <ctype.h>
76#include <resolv.h>
77#include <unistd.h>
78#include <stdlib.h>
79#include <string.h>
80
81const char *_res_opcodes[] = {
82 "QUERY",
83 "IQUERY",
84 "CQUERYM",
85 "CQUERYU", /* experimental */
86 "NOTIFY", /* experimental */
87 "5",
88 "6",
89 "7",
90 "8",
91 "UPDATEA",
92 "UPDATED",
93 "UPDATEDA",
94 "UPDATEM",
95 "UPDATEMA",
96 "ZONEINIT",
97 "ZONEREF",
98};
99
100const char *_res_resultcodes[] = {
101 "NOERROR",
102 "FORMERR",
103 "SERVFAIL",
104 "NXDOMAIN",
105 "NOTIMP",
106 "REFUSED",
107 "6",
108 "7",
109 "8",
110 "9",
111 "10",
112 "11",
113 "12",
114 "13",
115 "14",
116 "NOCHANGE",
117};
diff --git a/src/lib/libc/net/res_debug.c b/src/lib/libc/net/res_debug.c
new file mode 100644
index 0000000000..c2725395a0
--- /dev/null
+++ b/src/lib/libc/net/res_debug.c
@@ -0,0 +1,1518 @@
1/* $OpenBSD: res_debug.c,v 1.9 1998/03/19 00:30:06 millert Exp $ */
2
3/*
4 * ++Copyright++ 1985, 1990, 1993
5 * -
6 * Copyright (c) 1985, 1990, 1993
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 * -
37 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
38 *
39 * Permission to use, copy, modify, and distribute this software for any
40 * purpose with or without fee is hereby granted, provided that the above
41 * copyright notice and this permission notice appear in all copies, and that
42 * the name of Digital Equipment Corporation not be used in advertising or
43 * publicity pertaining to distribution of the document or software without
44 * specific, written prior permission.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
47 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
49 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
50 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
52 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 * SOFTWARE.
54 * -
55 * Portions Copyright (c) 1995 by International Business Machines, Inc.
56 *
57 * International Business Machines, Inc. (hereinafter called IBM) grants
58 * permission under its copyrights to use, copy, modify, and distribute this
59 * Software with or without fee, provided that the above copyright notice and
60 * all paragraphs of this notice appear in all copies, and that the name of IBM
61 * not be used in connection with the marketing of any product incorporating
62 * the Software or modifications thereof, without specific, written prior
63 * permission.
64 *
65 * To the extent it has a right to do so, IBM grants an immunity from suit
66 * under its patents, if any, for the use, sale or manufacture of products to
67 * the extent that such products are used for performing Domain Name System
68 * dynamic updates in TCP/IP networks by means of the Software. No immunity is
69 * granted for any product per se or for any other function of any product.
70 *
71 * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
72 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
73 * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
74 * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
75 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
76 * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
77 * --Copyright--
78 */
79
80#if defined(LIBC_SCCS) && !defined(lint)
81#if 0
82static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
83static char rcsid[] = "$From: res_debug.c,v 8.19 1996/11/26 10:11:23 vixie Exp $";
84#else
85static char rcsid[] = "$OpenBSD: res_debug.c,v 1.9 1998/03/19 00:30:06 millert Exp $";
86#endif
87#endif /* LIBC_SCCS and not lint */
88
89#include <sys/param.h>
90#include <sys/types.h>
91#include <sys/socket.h>
92#include <netinet/in.h>
93#include <arpa/inet.h>
94#include <arpa/nameser.h>
95
96#include <ctype.h>
97#include <netdb.h>
98#include <resolv.h>
99#include <stdio.h>
100#include <time.h>
101
102#include <stdlib.h>
103#include <string.h>
104
105extern const char *_res_opcodes[];
106extern const char *_res_resultcodes[];
107
108/* XXX: we should use getservbyport() instead. */
109static const char *
110dewks(wks)
111 int wks;
112{
113 static char nbuf[20];
114
115 switch (wks) {
116 case 5: return "rje";
117 case 7: return "echo";
118 case 9: return "discard";
119 case 11: return "systat";
120 case 13: return "daytime";
121 case 15: return "netstat";
122 case 17: return "qotd";
123 case 19: return "chargen";
124 case 20: return "ftp-data";
125 case 21: return "ftp";
126 case 23: return "telnet";
127 case 25: return "smtp";
128 case 37: return "time";
129 case 39: return "rlp";
130 case 42: return "name";
131 case 43: return "whois";
132 case 53: return "domain";
133 case 57: return "apts";
134 case 59: return "apfs";
135 case 67: return "bootps";
136 case 68: return "bootpc";
137 case 69: return "tftp";
138 case 77: return "rje";
139 case 79: return "finger";
140 case 87: return "link";
141 case 95: return "supdup";
142 case 100: return "newacct";
143 case 101: return "hostnames";
144 case 102: return "iso-tsap";
145 case 103: return "x400";
146 case 104: return "x400-snd";
147 case 105: return "csnet-ns";
148 case 109: return "pop-2";
149 case 111: return "sunrpc";
150 case 113: return "auth";
151 case 115: return "sftp";
152 case 117: return "uucp-path";
153 case 119: return "nntp";
154 case 121: return "erpc";
155 case 123: return "ntp";
156 case 133: return "statsrv";
157 case 136: return "profile";
158 case 144: return "NeWS";
159 case 161: return "snmp";
160 case 162: return "snmp-trap";
161 case 170: return "print-srv";
162 default: (void) sprintf(nbuf, "%d", wks); return (nbuf);
163 }
164}
165
166/* XXX: we should use getprotobynumber() instead. */
167static const char *
168deproto(protonum)
169 int protonum;
170{
171 static char nbuf[20];
172
173 switch (protonum) {
174 case 1: return "icmp";
175 case 2: return "igmp";
176 case 3: return "ggp";
177 case 5: return "st";
178 case 6: return "tcp";
179 case 7: return "ucl";
180 case 8: return "egp";
181 case 9: return "igp";
182 case 11: return "nvp-II";
183 case 12: return "pup";
184 case 16: return "chaos";
185 case 17: return "udp";
186 default: (void) sprintf(nbuf, "%d", protonum); return (nbuf);
187 }
188}
189
190static const u_char *
191do_rrset(msg, len, cp, cnt, pflag, file, hs)
192 int cnt, pflag, len;
193 const u_char *cp, *msg;
194 const char *hs;
195 FILE *file;
196{
197 int n;
198 int sflag;
199
200 /*
201 * Print answer records.
202 */
203 sflag = (_res.pfcode & pflag);
204 if ((n = ntohs(cnt))) {
205 if ((!_res.pfcode) ||
206 ((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
207 fprintf(file, hs);
208 while (--n >= 0) {
209 if ((!_res.pfcode) || sflag) {
210 cp = p_rr(cp, msg, file);
211 } else {
212 unsigned int dlen;
213 cp += __dn_skipname(cp, cp + MAXCDNAME);
214 cp += INT16SZ;
215 cp += INT16SZ;
216 cp += INT32SZ;
217 dlen = _getshort((u_char*)cp);
218 cp += INT16SZ;
219 cp += dlen;
220 }
221 if ((cp - msg) > len)
222 return (NULL);
223 }
224 if ((!_res.pfcode) ||
225 ((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
226 putc('\n', file);
227 }
228 return (cp);
229}
230
231void
232__p_query(msg)
233 const u_char *msg;
234{
235 __fp_query(msg, stdout);
236}
237
238/*
239 * Print the current options.
240 * This is intended to be primarily a debugging routine.
241 */
242void
243__fp_resstat(statp, file)
244 struct __res_state *statp;
245 FILE *file;
246{
247 register u_long mask;
248
249 fprintf(file, ";; res options:");
250 if (!statp)
251 statp = &_res;
252 for (mask = 1; mask != 0; mask <<= 1)
253 if (statp->options & mask)
254 fprintf(file, " %s", p_option(mask));
255 putc('\n', file);
256}
257
258/*
259 * Print the contents of a query.
260 * This is intended to be primarily a debugging routine.
261 */
262void
263__fp_nquery(msg, len, file)
264 const u_char *msg;
265 int len;
266 FILE *file;
267{
268 register const u_char *cp, *endMark;
269 register const HEADER *hp;
270 register int n;
271
272 if ((_res.options & RES_INIT) == 0 && res_init() == -1)
273 return;
274
275#define TruncTest(x) if (x > endMark) goto trunc
276#define ErrorTest(x) if (x == NULL) goto error
277
278 /*
279 * Print header fields.
280 */
281 hp = (HEADER *)msg;
282 cp = msg + HFIXEDSZ;
283 endMark = msg + len;
284 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX) || hp->rcode) {
285 fprintf(file, ";; ->>HEADER<<- opcode: %s, status: %s, id: %d",
286 _res_opcodes[hp->opcode],
287 _res_resultcodes[hp->rcode],
288 ntohs(hp->id));
289 putc('\n', file);
290 }
291 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX))
292 putc(';', file);
293 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) {
294 fprintf(file, "; flags:");
295 if (hp->qr)
296 fprintf(file, " qr");
297 if (hp->aa)
298 fprintf(file, " aa");
299 if (hp->tc)
300 fprintf(file, " tc");
301 if (hp->rd)
302 fprintf(file, " rd");
303 if (hp->ra)
304 fprintf(file, " ra");
305 if (hp->unused)
306 fprintf(file, " UNUSED-BIT-ON");
307 if (hp->ad)
308 fprintf(file, " ad");
309 if (hp->cd)
310 fprintf(file, " cd");
311 }
312 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) {
313 fprintf(file, "; Ques: %d", ntohs(hp->qdcount));
314 fprintf(file, ", Ans: %d", ntohs(hp->ancount));
315 fprintf(file, ", Auth: %d", ntohs(hp->nscount));
316 fprintf(file, ", Addit: %d", ntohs(hp->arcount));
317 }
318 if ((!_res.pfcode) || (_res.pfcode &
319 (RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) {
320 putc('\n',file);
321 }
322 /*
323 * Print question records.
324 */
325 if ((n = ntohs(hp->qdcount))) {
326 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
327 fprintf(file, ";; QUESTIONS:\n");
328 while (--n >= 0) {
329 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
330 fprintf(file, ";;\t");
331 TruncTest(cp);
332 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
333 cp = p_cdnname(cp, msg, len, file);
334 else {
335 int n;
336 char name[MAXDNAME];
337
338 if ((n = dn_expand(msg, msg+len, cp, name,
339 sizeof name)) < 0)
340 cp = NULL;
341 else
342 cp += n;
343 }
344 ErrorTest(cp);
345 TruncTest(cp);
346 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
347 fprintf(file, ", type = %s",
348 __p_type(_getshort((u_char*)cp)));
349 cp += INT16SZ;
350 TruncTest(cp);
351 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
352 fprintf(file, ", class = %s\n",
353 __p_class(_getshort((u_char*)cp)));
354 cp += INT16SZ;
355 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
356 putc('\n', file);
357 }
358 }
359 /*
360 * Print authoritative answer records
361 */
362 TruncTest(cp);
363 cp = do_rrset(msg, len, cp, hp->ancount, RES_PRF_ANS, file,
364 ";; ANSWERS:\n");
365 ErrorTest(cp);
366
367 /*
368 * print name server records
369 */
370 TruncTest(cp);
371 cp = do_rrset(msg, len, cp, hp->nscount, RES_PRF_AUTH, file,
372 ";; AUTHORITY RECORDS:\n");
373 ErrorTest(cp);
374
375 TruncTest(cp);
376 /*
377 * print additional records
378 */
379 cp = do_rrset(msg, len, cp, hp->arcount, RES_PRF_ADD, file,
380 ";; ADDITIONAL RECORDS:\n");
381 ErrorTest(cp);
382 return;
383 trunc:
384 fprintf(file, "\n;; ...truncated\n");
385 return;
386 error:
387 fprintf(file, "\n;; ...malformed\n");
388}
389
390void
391__fp_query(msg, file)
392 const u_char *msg;
393 FILE *file;
394{
395 fp_nquery(msg, PACKETSZ, file);
396}
397
398const u_char *
399__p_cdnname(cp, msg, len, file)
400 const u_char *cp, *msg;
401 int len;
402 FILE *file;
403{
404 char name[MAXDNAME];
405 int n;
406
407 if ((n = dn_expand(msg, msg + len, cp, name, sizeof name)) < 0)
408 return (NULL);
409 if (name[0] == '\0')
410 putc('.', file);
411 else
412 fputs(name, file);
413 return (cp + n);
414}
415
416const u_char *
417__p_cdname(cp, msg, file)
418 const u_char *cp, *msg;
419 FILE *file;
420{
421 return (p_cdnname(cp, msg, PACKETSZ, file));
422}
423
424
425/* Return a fully-qualified domain name from a compressed name (with
426 length supplied). */
427
428const u_char *
429__p_fqnname(cp, msg, msglen, name, namelen)
430 const u_char *cp, *msg;
431 int msglen;
432 char *name;
433 int namelen;
434{
435 int n, newlen;
436
437 if ((n = dn_expand(msg, cp + msglen, cp, name, namelen)) < 0)
438 return (NULL);
439 newlen = strlen (name);
440 if (newlen == 0 || name[newlen - 1] != '.') {
441 if (newlen+1 >= namelen) /* Lack space for final dot */
442 return (NULL);
443 else
444 strcpy(name + newlen, ".");
445 }
446 return (cp + n);
447}
448
449/* XXX: the rest of these functions need to become length-limited, too. (vix)
450 */
451
452const u_char *
453__p_fqname(cp, msg, file)
454 const u_char *cp, *msg;
455 FILE *file;
456{
457 char name[MAXDNAME];
458 const u_char *n;
459
460 n = __p_fqnname(cp, msg, MAXCDNAME, name, sizeof name);
461 if (n == NULL)
462 return (NULL);
463 fputs(name, file);
464 return (n);
465}
466
467/*
468 * Print resource record fields in human readable form.
469 */
470const u_char *
471__p_rr(cp, msg, file)
472 const u_char *cp, *msg;
473 FILE *file;
474{
475 int type, class, dlen, n, c;
476 struct in_addr inaddr;
477 const u_char *cp1, *cp2;
478 u_int32_t tmpttl, t;
479 int lcnt;
480 u_int16_t keyflags;
481 char rrname[MAXDNAME]; /* The fqdn of this RR */
482 char base64_key[MAX_KEY_BASE64];
483
484 if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
485 h_errno = NETDB_INTERNAL;
486 return (NULL);
487 }
488 cp = __p_fqnname(cp, msg, MAXCDNAME, rrname, sizeof rrname);
489 if (!cp)
490 return (NULL); /* compression error */
491 fputs(rrname, file);
492
493 type = _getshort((u_char*)cp);
494 cp += INT16SZ;
495 class = _getshort((u_char*)cp);
496 cp += INT16SZ;
497 tmpttl = _getlong((u_char*)cp);
498 cp += INT32SZ;
499 dlen = _getshort((u_char*)cp);
500 cp += INT16SZ;
501 cp1 = cp;
502 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_TTLID))
503 fprintf(file, "\t%lu", (u_long)tmpttl);
504 if ((!_res.pfcode) || (_res.pfcode & RES_PRF_CLASS))
505 fprintf(file, "\t%s", __p_class(class));
506 fprintf(file, "\t%s", __p_type(type));
507 /*
508 * Print type specific data, if appropriate
509 */
510 switch (type) {
511 case T_A:
512 switch (class) {
513 case C_IN:
514 case C_HS:
515 bcopy(cp, (char *)&inaddr, INADDRSZ);
516 if (dlen == 4) {
517 fprintf(file, "\t%s", inet_ntoa(inaddr));
518 cp += dlen;
519 } else if (dlen == 7) {
520 char *address;
521 u_char protocol;
522 in_port_t port;
523
524 address = inet_ntoa(inaddr);
525 cp += INADDRSZ;
526 protocol = *(u_char*)cp;
527 cp += sizeof (u_char);
528 port = _getshort((u_char*)cp);
529 cp += INT16SZ;
530 fprintf(file, "\t%s\t; proto %d, port %d",
531 address, protocol, port);
532 }
533 break;
534 default:
535 cp += dlen;
536 }
537 break;
538 case T_CNAME:
539 case T_MB:
540 case T_MG:
541 case T_MR:
542 case T_NS:
543 case T_PTR:
544 putc('\t', file);
545 if ((cp = p_fqname(cp, msg, file)) == NULL)
546 return (NULL);
547 break;
548
549 case T_HINFO:
550 case T_ISDN:
551 cp2 = cp + dlen;
552 (void) fputs("\t\"", file);
553 if ((n = (unsigned char) *cp++) != 0) {
554 for (c = n; c > 0 && cp < cp2; c--) {
555 if (strchr("\n\"\\", *cp))
556 (void) putc('\\', file);
557 (void) putc(*cp++, file);
558 }
559 }
560 putc('"', file);
561 if (cp < cp2 && (n = (unsigned char) *cp++) != 0) {
562 (void) fputs ("\t\"", file);
563 for (c = n; c > 0 && cp < cp2; c--) {
564 if (strchr("\n\"\\", *cp))
565 (void) putc('\\', file);
566 (void) putc(*cp++, file);
567 }
568 putc('"', file);
569 } else if (type == T_HINFO) {
570 (void) fputs("\"?\"", file);
571 fprintf(file, "\n;; *** Warning *** OS-type missing");
572 }
573 break;
574
575 case T_SOA:
576 putc('\t', file);
577 if ((cp = p_fqname(cp, msg, file)) == NULL)
578 return (NULL);
579 putc(' ', file);
580 if ((cp = p_fqname(cp, msg, file)) == NULL)
581 return (NULL);
582 fputs(" (\n", file);
583 t = _getlong((u_char*)cp); cp += INT32SZ;
584 fprintf(file, "\t\t\t%lu\t; serial\n", (u_long)t);
585 t = _getlong((u_char*)cp); cp += INT32SZ;
586 fprintf(file, "\t\t\t%lu\t; refresh (%s)\n",
587 (u_long)t, __p_time(t));
588 t = _getlong((u_char*)cp); cp += INT32SZ;
589 fprintf(file, "\t\t\t%lu\t; retry (%s)\n",
590 (u_long)t, __p_time(t));
591 t = _getlong((u_char*)cp); cp += INT32SZ;
592 fprintf(file, "\t\t\t%lu\t; expire (%s)\n",
593 (u_long)t, __p_time(t));
594 t = _getlong((u_char*)cp); cp += INT32SZ;
595 fprintf(file, "\t\t\t%lu )\t; minimum (%s)",
596 (u_long)t, __p_time(t));
597 break;
598
599 case T_MX:
600 case T_AFSDB:
601 case T_RT:
602 fprintf(file, "\t%d ", _getshort((u_char*)cp));
603 cp += INT16SZ;
604 if ((cp = p_fqname(cp, msg, file)) == NULL)
605 return (NULL);
606 break;
607
608 case T_PX:
609 fprintf(file, "\t%d ", _getshort((u_char*)cp));
610 cp += INT16SZ;
611 if ((cp = p_fqname(cp, msg, file)) == NULL)
612 return (NULL);
613 putc(' ', file);
614 if ((cp = p_fqname(cp, msg, file)) == NULL)
615 return (NULL);
616 break;
617
618 case T_X25:
619 cp2 = cp + dlen;
620 (void) fputs("\t\"", file);
621 if ((n = (unsigned char) *cp++) != 0) {
622 for (c = n; c > 0 && cp < cp2; c--) {
623 if (strchr("\n\"\\", *cp))
624 (void) putc('\\', file);
625 (void) putc(*cp++, file);
626 }
627 }
628 putc('"', file);
629 break;
630
631 case T_TXT:
632 (void) putc('\t', file);
633 cp2 = cp1 + dlen;
634 while (cp < cp2) {
635 putc('"', file);
636 if ((n = (unsigned char) *cp++)) {
637 for (c = n; c > 0 && cp < cp2; c--) {
638 if (strchr("\n\"\\", *cp))
639 (void) putc('\\', file);
640 (void) putc(*cp++, file);
641 }
642 }
643 putc('"', file);
644 if (cp < cp2)
645 putc(' ', file);
646 }
647 break;
648
649 case T_NSAP:
650 (void) fprintf(file, "\t%s", inet_nsap_ntoa(dlen, cp, NULL));
651 cp += dlen;
652 break;
653
654 case T_AAAA: {
655 char t[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
656
657 fprintf(file, "\t%s", inet_ntop(AF_INET6, cp, t, sizeof t));
658 cp += dlen;
659 break;
660 }
661
662 case T_LOC: {
663 char t[255];
664
665 fprintf(file, "\t%s", loc_ntoa(cp, t));
666 cp += dlen;
667 break;
668 }
669
670 case T_NAPTR: {
671 u_int order, preference;
672
673 order = _getshort(cp); cp += INT16SZ;
674 preference = _getshort(cp); cp += INT16SZ;
675 fprintf(file, "\t%u %u ",order, preference);
676 /* Flags */
677 n = *cp++;
678 fprintf(file,"\"%.*s\" ", (int)n, cp);
679 cp += n;
680 /* Service */
681 n = *cp++;
682 fprintf(file,"\"%.*s\" ", (int)n, cp);
683 cp += n;
684 /* Regexp */
685 n = *cp++;
686 fprintf(file,"\"%.*s\" ", (int)n, cp);
687 cp += n;
688 if ((cp = p_fqname(cp, msg, file)) == NULL)
689 return (NULL);
690 break;
691 }
692
693 case T_SRV: {
694 u_int priority, weight, port;
695
696 priority = _getshort(cp); cp += INT16SZ;
697 weight = _getshort(cp); cp += INT16SZ;
698 port = _getshort(cp); cp += INT16SZ;
699 fprintf(file, "\t%u %u %u ", priority, weight, port);
700 if ((cp = p_fqname(cp, msg, file)) == NULL)
701 return (NULL);
702 break;
703 }
704
705 case T_MINFO:
706 case T_RP:
707 putc('\t', file);
708 if ((cp = p_fqname(cp, msg, file)) == NULL)
709 return (NULL);
710 putc(' ', file);
711 if ((cp = p_fqname(cp, msg, file)) == NULL)
712 return (NULL);
713 break;
714
715 case T_UINFO:
716 putc('\t', file);
717 fputs((char *)cp, file);
718 cp += dlen;
719 break;
720
721 case T_UID:
722 case T_GID:
723 if (dlen == 4) {
724 fprintf(file, "\t%u", _getlong((u_char*)cp));
725 cp += INT32SZ;
726 }
727 break;
728
729 case T_WKS:
730 if (dlen < INT32SZ + 1)
731 break;
732 bcopy(cp, (char *)&inaddr, INADDRSZ);
733 cp += INT32SZ;
734 fprintf(file, "\t%s %s ( ",
735 inet_ntoa(inaddr),
736 deproto((int) *cp));
737 cp += sizeof (u_char);
738 n = 0;
739 lcnt = 0;
740 while (cp < cp1 + dlen) {
741 c = *cp++;
742 do {
743 if (c & 0200) {
744 if (lcnt == 0) {
745 fputs("\n\t\t\t", file);
746 lcnt = 5;
747 }
748 fputs(dewks(n), file);
749 putc(' ', file);
750 lcnt--;
751 }
752 c <<= 1;
753 } while (++n & 07);
754 }
755 putc(')', file);
756 break;
757
758 case T_KEY:
759 putc('\t', file);
760 keyflags = _getshort(cp);
761 cp += 2;
762 fprintf(file,"0x%04x", keyflags ); /* flags */
763 fprintf(file," %u", *cp++); /* protocol */
764 fprintf(file," %u (", *cp++); /* algorithm */
765
766 n = b64_ntop(cp, (cp1 + dlen) - cp,
767 base64_key, sizeof base64_key);
768 for (c = 0; c < n; ++c) {
769 if (0 == (c & 0x3F))
770 fprintf(file, "\n\t");
771 putc(base64_key[c], file); /* public key data */
772 }
773
774 fprintf(file, " )");
775 if (n < 0)
776 fprintf(file, "\t; BAD BASE64");
777 fflush(file);
778 cp = cp1 + dlen;
779 break;
780
781 case T_SIG:
782 type = _getshort((u_char*)cp);
783 cp += INT16SZ;
784 fprintf(file, " %s", p_type(type));
785 fprintf(file, "\t%d", *cp++); /* algorithm */
786 /* Check label value and print error if wrong. */
787 n = *cp++;
788 c = dn_count_labels (rrname);
789 if (n != c)
790 fprintf(file, "\t; LABELS WRONG (%d should be %d)\n\t",
791 n, c);
792 /* orig ttl */
793 n = _getlong((u_char*)cp);
794 if (n != tmpttl)
795 fprintf(file, " %u", n);
796 cp += INT32SZ;
797 /* sig expire */
798 fprintf(file, " (\n\t%s",
799 __p_secstodate(_getlong((u_char*)cp)));
800 cp += INT32SZ;
801 /* time signed */
802 fprintf(file, " %s", __p_secstodate(_getlong((u_char*)cp)));
803 cp += INT32SZ;
804 /* sig footprint */
805 fprintf(file," %u ", _getshort((u_char*)cp));
806 cp += INT16SZ;
807 /* signer's name */
808 cp = p_fqname(cp, msg, file);
809 n = b64_ntop(cp, (cp1 + dlen) - cp,
810 base64_key, sizeof base64_key);
811 for (c = 0; c < n; c++) {
812 if (0 == (c & 0x3F))
813 fprintf (file, "\n\t");
814 putc(base64_key[c], file); /* signature */
815 }
816 /* Clean up... */
817 fprintf(file, " )");
818 if (n < 0)
819 fprintf(file, "\t; BAD BASE64");
820 fflush(file);
821 cp = cp1+dlen;
822 break;
823
824#ifdef ALLOW_T_UNSPEC
825 case T_UNSPEC:
826 {
827 int NumBytes = 8;
828 u_char *DataPtr;
829 int i;
830
831 if (dlen < NumBytes) NumBytes = dlen;
832 fprintf(file, "\tFirst %d bytes of hex data:",
833 NumBytes);
834 for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++)
835 fprintf(file, " %x", *DataPtr);
836 cp += dlen;
837 }
838 break;
839#endif /* ALLOW_T_UNSPEC */
840
841 default:
842 fprintf(file, "\t?%d?", type);
843 cp += dlen;
844 }
845#if 0
846 fprintf(file, "\t; dlen=%d, ttl %s\n", dlen, __p_time(tmpttl));
847#else
848 putc('\n', file);
849#endif
850 if (cp - cp1 != dlen) {
851 fprintf(file, ";; packet size error (found %ld, dlen was %d)\n",
852 (long)(cp - cp1), dlen);
853 cp = NULL;
854 }
855 return (cp);
856}
857
858/*
859 * Names of RR classes and qclasses. Classes and qclasses are the same, except
860 * that C_ANY is a qclass but not a class. (You can ask for records of class
861 * C_ANY, but you can't have any records of that class in the database.)
862 */
863const struct res_sym __p_class_syms[] = {
864 {C_IN, "IN"},
865 {C_CHAOS, "CHAOS"},
866 {C_HS, "HS"},
867 {C_HS, "HESIOD"},
868 {C_ANY, "ANY"},
869 {C_IN, (char *)0}
870};
871
872/*
873 * Names of RR types and qtypes. Types and qtypes are the same, except
874 * that T_ANY is a qtype but not a type. (You can ask for records of type
875 * T_ANY, but you can't have any records of that type in the database.)
876 */
877const struct res_sym __p_type_syms[] = {
878 {T_A, "A", "address"},
879 {T_NS, "NS", "name server"},
880 {T_MD, "MD", "mail destination (deprecated)"},
881 {T_MF, "MF", "mail forwarder (deprecated)"},
882 {T_CNAME, "CNAME", "canonical name"},
883 {T_SOA, "SOA", "start of authority"},
884 {T_MB, "MB", "mailbox"},
885 {T_MG, "MG", "mail group member"},
886 {T_MR, "MR", "mail rename"},
887 {T_NULL, "NULL", "null"},
888 {T_WKS, "WKS", "well-known service (deprecated)"},
889 {T_PTR, "PTR", "domain name pointer"},
890 {T_HINFO, "HINFO", "host information"},
891 {T_MINFO, "MINFO", "mailbox information"},
892 {T_MX, "MX", "mail exchanger"},
893 {T_TXT, "TXT", "text"},
894 {T_RP, "RP", "responsible person"},
895 {T_AFSDB, "AFSDB", "DCE or AFS server"},
896 {T_X25, "X25", "X25 address"},
897 {T_ISDN, "ISDN", "ISDN address"},
898 {T_RT, "RT", "router"},
899 {T_NSAP, "NSAP", "nsap address"},
900 {T_NSAP_PTR, "NSAP_PTR", "domain name pointer"},
901 {T_SIG, "SIG", "signature"},
902 {T_KEY, "KEY", "key"},
903 {T_PX, "PX", "mapping information"},
904 {T_GPOS, "GPOS", "geographical position (withdrawn)"},
905 {T_AAAA, "AAAA", "IPv6 address"},
906 {T_LOC, "LOC", "location"},
907 {T_NXT, "NXT", "next valid name (unimplemented)"},
908 {T_EID, "EID", "endpoint identifier (unimplemented)"},
909 {T_NIMLOC, "NIMLOC", "NIMROD locator (unimplemented)"},
910 {T_SRV, "SRV", "server selection"},
911 {T_ATMA, "ATMA", "ATM address (unimplemented)"},
912 {T_IXFR, "IXFR", "incremental zone transfer"},
913 {T_AXFR, "AXFR", "zone transfer"},
914 {T_MAILB, "MAILB", "mailbox-related data (deprecated)"},
915 {T_MAILA, "MAILA", "mail agent (deprecated)"},
916 {T_UINFO, "UINFO", "user information (nonstandard)"},
917 {T_UID, "UID", "user ID (nonstandard)"},
918 {T_GID, "GID", "group ID (nonstandard)"},
919 {T_NAPTR, "NAPTR", "URN Naming Authority"},
920#ifdef ALLOW_T_UNSPEC
921 {T_UNSPEC, "UNSPEC", "unspecified data (nonstandard)"},
922#endif /* ALLOW_T_UNSPEC */
923 {T_ANY, "ANY", "\"any\""},
924 {0, NULL, NULL}
925};
926
927int
928__sym_ston(syms, name, success)
929 const struct res_sym *syms;
930 char *name;
931 int *success;
932{
933 for (; syms->name != 0; syms++) {
934 if (strcasecmp (name, syms->name) == 0) {
935 if (success)
936 *success = 1;
937 return (syms->number);
938 }
939 }
940 if (success)
941 *success = 0;
942 return (syms->number); /* The default value. */
943}
944
945const char *
946__sym_ntos(syms, number, success)
947 const struct res_sym *syms;
948 int number;
949 int *success;
950{
951 static char unname[20];
952
953 for (; syms->name != 0; syms++) {
954 if (number == syms->number) {
955 if (success)
956 *success = 1;
957 return (syms->name);
958 }
959 }
960
961 sprintf (unname, "%d", number);
962 if (success)
963 *success = 0;
964 return (unname);
965}
966
967
968const char *
969__sym_ntop(syms, number, success)
970 const struct res_sym *syms;
971 int number;
972 int *success;
973{
974 static char unname[20];
975
976 for (; syms->name != 0; syms++) {
977 if (number == syms->number) {
978 if (success)
979 *success = 1;
980 return (syms->humanname);
981 }
982 }
983 sprintf(unname, "%d", number);
984 if (success)
985 *success = 0;
986 return (unname);
987}
988
989/*
990 * Return a string for the type
991 */
992const char *
993__p_type(type)
994 int type;
995{
996 return (__sym_ntos (__p_type_syms, type, (int *)0));
997}
998
999/*
1000 * Return a mnemonic for class
1001 */
1002const char *
1003__p_class(class)
1004 int class;
1005{
1006 return (__sym_ntos (__p_class_syms, class, (int *)0));
1007}
1008
1009/*
1010 * Return a mnemonic for an option
1011 */
1012const char *
1013__p_option(option)
1014 u_long option;
1015{
1016 static char nbuf[40];
1017
1018 switch (option) {
1019 case RES_INIT: return "init";
1020 case RES_DEBUG: return "debug";
1021 case RES_AAONLY: return "aaonly(unimpl)";
1022 case RES_USEVC: return "usevc";
1023 case RES_PRIMARY: return "primry(unimpl)";
1024 case RES_IGNTC: return "igntc";
1025 case RES_RECURSE: return "recurs";
1026 case RES_DEFNAMES: return "defnam";
1027 case RES_STAYOPEN: return "styopn";
1028 case RES_DNSRCH: return "dnsrch";
1029 case RES_INSECURE1: return "insecure1";
1030 case RES_INSECURE2: return "insecure2";
1031 default: sprintf(nbuf, "?0x%lx?", (u_long)option);
1032 return (nbuf);
1033 }
1034}
1035
1036/*
1037 * Return a mnemonic for a time to live
1038 */
1039const char *
1040p_time(value)
1041 u_int32_t value;
1042{
1043 static char nbuf[40];
1044 int secs, mins, hours, days;
1045 register char *p;
1046
1047 if (value == 0) {
1048 strcpy(nbuf, "0 secs");
1049 return (nbuf);
1050 }
1051
1052 secs = value % 60;
1053 value /= 60;
1054 mins = value % 60;
1055 value /= 60;
1056 hours = value % 24;
1057 value /= 24;
1058 days = value;
1059 value = 0;
1060
1061#define PLURALIZE(x) x, (x == 1) ? "" : "s"
1062 p = nbuf;
1063 if (days) {
1064 (void)sprintf(p, "%d day%s", PLURALIZE(days));
1065 while (*++p);
1066 }
1067 if (hours) {
1068 if (days)
1069 *p++ = ' ';
1070 (void)sprintf(p, "%d hour%s", PLURALIZE(hours));
1071 while (*++p);
1072 }
1073 if (mins) {
1074 if (days || hours)
1075 *p++ = ' ';
1076 (void)sprintf(p, "%d min%s", PLURALIZE(mins));
1077 while (*++p);
1078 }
1079 if (secs || ! (days || hours || mins)) {
1080 if (days || hours || mins)
1081 *p++ = ' ';
1082 (void)sprintf(p, "%d sec%s", PLURALIZE(secs));
1083 }
1084 return (nbuf);
1085}
1086
1087/*
1088 * routines to convert between on-the-wire RR format and zone file format.
1089 * Does not contain conversion to/from decimal degrees; divide or multiply
1090 * by 60*60*1000 for that.
1091 */
1092
1093static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000,
1094 1000000,10000000,100000000,1000000000};
1095
1096/* takes an XeY precision/size value, returns a string representation. */
1097static const char *
1098precsize_ntoa(prec)
1099 u_int8_t prec;
1100{
1101 static char retbuf[sizeof "90000000.00"];
1102 unsigned long val;
1103 int mantissa, exponent;
1104
1105 mantissa = (int)((prec >> 4) & 0x0f) % 10;
1106 exponent = (int)((prec >> 0) & 0x0f) % 10;
1107
1108 val = mantissa * poweroften[exponent];
1109
1110 (void) sprintf(retbuf, "%ld.%.2ld", val/100, val%100);
1111 return (retbuf);
1112}
1113
1114/* converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer. */
1115static u_int8_t
1116precsize_aton(strptr)
1117 char **strptr;
1118{
1119 unsigned int mval = 0, cmval = 0;
1120 u_int8_t retval = 0;
1121 register char *cp;
1122 register int exponent;
1123 register int mantissa;
1124
1125 cp = *strptr;
1126
1127 while (isdigit(*cp))
1128 mval = mval * 10 + (*cp++ - '0');
1129
1130 if (*cp == '.') { /* centimeters */
1131 cp++;
1132 if (isdigit(*cp)) {
1133 cmval = (*cp++ - '0') * 10;
1134 if (isdigit(*cp)) {
1135 cmval += (*cp++ - '0');
1136 }
1137 }
1138 }
1139 cmval = (mval * 100) + cmval;
1140
1141 for (exponent = 0; exponent < 9; exponent++)
1142 if (cmval < poweroften[exponent+1])
1143 break;
1144
1145 mantissa = cmval / poweroften[exponent];
1146 if (mantissa > 9)
1147 mantissa = 9;
1148
1149 retval = (mantissa << 4) | exponent;
1150
1151 *strptr = cp;
1152
1153 return (retval);
1154}
1155
1156/* converts ascii lat/lon to unsigned encoded 32-bit number. moves pointer. */
1157static u_int32_t
1158latlon2ul(latlonstrptr,which)
1159 char **latlonstrptr;
1160 int *which;
1161{
1162 register char *cp;
1163 u_int32_t retval;
1164 int deg = 0, min = 0, secs = 0, secsfrac = 0;
1165
1166 cp = *latlonstrptr;
1167
1168 while (isdigit(*cp))
1169 deg = deg * 10 + (*cp++ - '0');
1170
1171 while (isspace(*cp))
1172 cp++;
1173
1174 if (!(isdigit(*cp)))
1175 goto fndhemi;
1176
1177 while (isdigit(*cp))
1178 min = min * 10 + (*cp++ - '0');
1179
1180 while (isspace(*cp))
1181 cp++;
1182
1183 if (!(isdigit(*cp)))
1184 goto fndhemi;
1185
1186 while (isdigit(*cp))
1187 secs = secs * 10 + (*cp++ - '0');
1188
1189 if (*cp == '.') { /* decimal seconds */
1190 cp++;
1191 if (isdigit(*cp)) {
1192 secsfrac = (*cp++ - '0') * 100;
1193 if (isdigit(*cp)) {
1194 secsfrac += (*cp++ - '0') * 10;
1195 if (isdigit(*cp)) {
1196 secsfrac += (*cp++ - '0');
1197 }
1198 }
1199 }
1200 }
1201
1202 while (!isspace(*cp)) /* if any trailing garbage */
1203 cp++;
1204
1205 while (isspace(*cp))
1206 cp++;
1207
1208 fndhemi:
1209 switch (*cp) {
1210 case 'N': case 'n':
1211 case 'E': case 'e':
1212 retval = ((unsigned)1<<31)
1213 + (((((deg * 60) + min) * 60) + secs) * 1000)
1214 + secsfrac;
1215 break;
1216 case 'S': case 's':
1217 case 'W': case 'w':
1218 retval = ((unsigned)1<<31)
1219 - (((((deg * 60) + min) * 60) + secs) * 1000)
1220 - secsfrac;
1221 break;
1222 default:
1223 retval = 0; /* invalid value -- indicates error */
1224 break;
1225 }
1226
1227 switch (*cp) {
1228 case 'N': case 'n':
1229 case 'S': case 's':
1230 *which = 1; /* latitude */
1231 break;
1232 case 'E': case 'e':
1233 case 'W': case 'w':
1234 *which = 2; /* longitude */
1235 break;
1236 default:
1237 *which = 0; /* error */
1238 break;
1239 }
1240
1241 cp++; /* skip the hemisphere */
1242
1243 while (!isspace(*cp)) /* if any trailing garbage */
1244 cp++;
1245
1246 while (isspace(*cp)) /* move to next field */
1247 cp++;
1248
1249 *latlonstrptr = cp;
1250
1251 return (retval);
1252}
1253
1254/* converts a zone file representation in a string to an RDATA on-the-wire
1255 * representation. */
1256int
1257loc_aton(ascii, binary)
1258 const char *ascii;
1259 u_char *binary;
1260{
1261 const char *maxcp;
1262 u_char *bcp;
1263 char *cp;
1264
1265 u_int32_t latit = 0, longit = 0, alt = 0;
1266 u_int32_t lltemp1 = 0, lltemp2 = 0;
1267 int altmeters = 0, altfrac = 0, altsign = 1;
1268 u_int8_t hp = 0x16; /* default = 1e6 cm = 10000.00m = 10km */
1269 u_int8_t vp = 0x13; /* default = 1e3 cm = 10.00m */
1270 u_int8_t siz = 0x12; /* default = 1e2 cm = 1.00m */
1271 int which1 = 0, which2 = 0;
1272
1273 cp = (char *)ascii;
1274 maxcp = cp + strlen(ascii);
1275
1276 lltemp1 = latlon2ul(&cp, &which1);
1277
1278 lltemp2 = latlon2ul(&cp, &which2);
1279
1280 switch (which1 + which2) {
1281 case 3: /* 1 + 2, the only valid combination */
1282 if ((which1 == 1) && (which2 == 2)) { /* normal case */
1283 latit = lltemp1;
1284 longit = lltemp2;
1285 } else if ((which1 == 2) && (which2 == 1)) { /* reversed */
1286 longit = lltemp1;
1287 latit = lltemp2;
1288 } else { /* some kind of brokenness */
1289 return (0);
1290 }
1291 break;
1292 default: /* we didn't get one of each */
1293 return (0);
1294 }
1295
1296 /* altitude */
1297 if (*cp == '-') {
1298 altsign = -1;
1299 cp++;
1300 }
1301
1302 if (*cp == '+')
1303 cp++;
1304
1305 while (isdigit(*cp))
1306 altmeters = altmeters * 10 + (*cp++ - '0');
1307
1308 if (*cp == '.') { /* decimal meters */
1309 cp++;
1310 if (isdigit(*cp)) {
1311 altfrac = (*cp++ - '0') * 10;
1312 if (isdigit(*cp)) {
1313 altfrac += (*cp++ - '0');
1314 }
1315 }
1316 }
1317
1318 alt = (10000000 + (altsign * (altmeters * 100 + altfrac)));
1319
1320 while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */
1321 cp++;
1322
1323 while (isspace(*cp) && (cp < maxcp))
1324 cp++;
1325
1326 if (cp >= maxcp)
1327 goto defaults;
1328
1329 siz = precsize_aton(&cp);
1330
1331 while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */
1332 cp++;
1333
1334 while (isspace(*cp) && (cp < maxcp))
1335 cp++;
1336
1337 if (cp >= maxcp)
1338 goto defaults;
1339
1340 hp = precsize_aton(&cp);
1341
1342 while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */
1343 cp++;
1344
1345 while (isspace(*cp) && (cp < maxcp))
1346 cp++;
1347
1348 if (cp >= maxcp)
1349 goto defaults;
1350
1351 vp = precsize_aton(&cp);
1352
1353 defaults:
1354
1355 bcp = binary;
1356 *bcp++ = (u_int8_t) 0; /* version byte */
1357 *bcp++ = siz;
1358 *bcp++ = hp;
1359 *bcp++ = vp;
1360 PUTLONG(latit,bcp);
1361 PUTLONG(longit,bcp);
1362 PUTLONG(alt,bcp);
1363
1364 return (16); /* size of RR in octets */
1365}
1366
1367/* takes an on-the-wire LOC RR and formats it in a human readable format. */
1368const char *
1369loc_ntoa(binary, ascii)
1370 const u_char *binary;
1371 char *ascii;
1372{
1373 static char *error = "?";
1374 register const u_char *cp = binary;
1375
1376 int latdeg, latmin, latsec, latsecfrac;
1377 int longdeg, longmin, longsec, longsecfrac;
1378 char northsouth, eastwest;
1379 int altmeters, altfrac, altsign;
1380
1381 const int referencealt = 100000 * 100;
1382
1383 int32_t latval, longval, altval;
1384 u_int32_t templ;
1385 u_int8_t sizeval, hpval, vpval, versionval;
1386
1387 char *sizestr, *hpstr, *vpstr;
1388
1389 versionval = *cp++;
1390
1391 if (versionval) {
1392 sprintf(ascii, "; error: unknown LOC RR version");
1393 return (ascii);
1394 }
1395
1396 sizeval = *cp++;
1397
1398 hpval = *cp++;
1399 vpval = *cp++;
1400
1401 GETLONG(templ, cp);
1402 latval = (templ - ((unsigned)1<<31));
1403
1404 GETLONG(templ, cp);
1405 longval = (templ - ((unsigned)1<<31));
1406
1407 GETLONG(templ, cp);
1408 if (templ < referencealt) { /* below WGS 84 spheroid */
1409 altval = referencealt - templ;
1410 altsign = -1;
1411 } else {
1412 altval = templ - referencealt;
1413 altsign = 1;
1414 }
1415
1416 if (latval < 0) {
1417 northsouth = 'S';
1418 latval = -latval;
1419 } else
1420 northsouth = 'N';
1421
1422 latsecfrac = latval % 1000;
1423 latval = latval / 1000;
1424 latsec = latval % 60;
1425 latval = latval / 60;
1426 latmin = latval % 60;
1427 latval = latval / 60;
1428 latdeg = latval;
1429
1430 if (longval < 0) {
1431 eastwest = 'W';
1432 longval = -longval;
1433 } else
1434 eastwest = 'E';
1435
1436 longsecfrac = longval % 1000;
1437 longval = longval / 1000;
1438 longsec = longval % 60;
1439 longval = longval / 60;
1440 longmin = longval % 60;
1441 longval = longval / 60;
1442 longdeg = longval;
1443
1444 altfrac = altval % 100;
1445 altmeters = (altval / 100) * altsign;
1446
1447 if ((sizestr = strdup(precsize_ntoa(sizeval))) == NULL)
1448 sizestr = error;
1449 if ((hpstr = strdup(precsize_ntoa(hpval))) == NULL)
1450 hpstr = error;
1451 if ((vpstr = strdup(precsize_ntoa(vpval))) == NULL)
1452 vpstr = error;
1453
1454 sprintf(ascii,
1455 "%d %.2d %.2d.%.3d %c %d %.2d %.2d.%.3d %c %d.%.2dm %sm %sm %sm",
1456 latdeg, latmin, latsec, latsecfrac, northsouth,
1457 longdeg, longmin, longsec, longsecfrac, eastwest,
1458 altmeters, altfrac, sizestr, hpstr, vpstr);
1459
1460 if (sizestr != error)
1461 free(sizestr);
1462 if (hpstr != error)
1463 free(hpstr);
1464 if (vpstr != error)
1465 free(vpstr);
1466
1467 return (ascii);
1468}
1469
1470
1471/* Return the number of DNS hierarchy levels in the name. */
1472int
1473__dn_count_labels(name)
1474 char *name;
1475{
1476 int i, len, count;
1477
1478 len = strlen(name);
1479
1480 for(i = 0, count = 0; i < len; i++) {
1481 if (name[i] == '.')
1482 count++;
1483 }
1484
1485 /* don't count initial wildcard */
1486 if (name[0] == '*')
1487 if (count)
1488 count--;
1489
1490 /* don't count the null label for root. */
1491 /* if terminating '.' not found, must adjust */
1492 /* count to include last label */
1493 if (len > 0 && name[len-1] != '.')
1494 count++;
1495 return (count);
1496}
1497
1498
1499/*
1500 * Make dates expressed in seconds-since-Jan-1-1970 easy to read.
1501 * SIG records are required to be printed like this, by the Secure DNS RFC.
1502 */
1503char *
1504__p_secstodate (secs)
1505 unsigned long secs;
1506{
1507 static char output[15]; /* YYYYMMDDHHMMSS and null */
1508 time_t clock = secs;
1509 struct tm *time;
1510
1511 time = gmtime(&clock);
1512 time->tm_year += 1900;
1513 time->tm_mon += 1;
1514 sprintf(output, "%04d%02d%02d%02d%02d%02d",
1515 time->tm_year, time->tm_mon, time->tm_mday,
1516 time->tm_hour, time->tm_min, time->tm_sec);
1517 return (output);
1518}
diff --git a/src/lib/libc/net/res_init.c b/src/lib/libc/net/res_init.c
new file mode 100644
index 0000000000..df176b7fa1
--- /dev/null
+++ b/src/lib/libc/net/res_init.c
@@ -0,0 +1,518 @@
1/* $OpenBSD: res_init.c,v 1.16 1998/03/16 05:07:01 millert Exp $ */
2
3/*
4 * ++Copyright++ 1985, 1989, 1993
5 * -
6 * Copyright (c) 1985, 1989, 1993
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 * -
37 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
38 *
39 * Permission to use, copy, modify, and distribute this software for any
40 * purpose with or without fee is hereby granted, provided that the above
41 * copyright notice and this permission notice appear in all copies, and that
42 * the name of Digital Equipment Corporation not be used in advertising or
43 * publicity pertaining to distribution of the document or software without
44 * specific, written prior permission.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
47 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
49 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
50 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
52 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 * SOFTWARE.
54 * -
55 * --Copyright--
56 */
57
58#if defined(LIBC_SCCS) && !defined(lint)
59#if 0
60static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
61static char rcsid[] = "$From: res_init.c,v 8.7 1996/09/28 06:51:07 vixie Exp $";
62#else
63static char rcsid[] = "$OpenBSD: res_init.c,v 1.16 1998/03/16 05:07:01 millert Exp $";
64#endif
65#endif /* LIBC_SCCS and not lint */
66
67#include <sys/types.h>
68#include <sys/param.h>
69#include <sys/socket.h>
70#include <sys/time.h>
71#include <netinet/in.h>
72#include <arpa/inet.h>
73#include <arpa/nameser.h>
74
75#include <stdio.h>
76#include <ctype.h>
77#include <resolv.h>
78#include <unistd.h>
79#include <stdlib.h>
80#include <string.h>
81
82/*-------------------------------------- info about "sortlist" --------------
83 * Marc Majka 1994/04/16
84 * Allan Nathanson 1994/10/29 (BIND 4.9.3.x)
85 *
86 * NetInfo resolver configuration directory support.
87 *
88 * Allow a NetInfo directory to be created in the hierarchy which
89 * contains the same information as the resolver configuration file.
90 *
91 * - The local domain name is stored as the value of the "domain" property.
92 * - The Internet address(es) of the name server(s) are stored as values
93 * of the "nameserver" property.
94 * - The name server addresses are stored as values of the "nameserver"
95 * property.
96 * - The search list for host-name lookup is stored as values of the
97 * "search" property.
98 * - The sortlist comprised of IP address netmask pairs are stored as
99 * values of the "sortlist" property. The IP address and optional netmask
100 * should be seperated by a slash (/) or ampersand (&) character.
101 * - Internal resolver variables can be set from the value of the "options"
102 * property.
103 */
104
105static void res_setoptions __P((char *, char *));
106
107#ifdef RESOLVSORT
108static const char sort_mask[] = "/&";
109#define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL)
110static u_int32_t net_mask __P((struct in_addr));
111#endif
112
113/*
114 * Resolver state default settings.
115 */
116
117struct __res_state _res
118# if defined(__BIND_RES_TEXT)
119 = { RES_TIMEOUT, } /* Motorola, et al. */
120# endif
121 ;
122
123/*
124 * Set up default settings. If the configuration file exist, the values
125 * there will have precedence. Otherwise, the server address is set to
126 * INADDR_ANY and the default domain name comes from the gethostname().
127 *
128 * An interrim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1
129 * rather than INADDR_ANY ("0.0.0.0") as the default name server address
130 * since it was noted that INADDR_ANY actually meant ``the first interface
131 * you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface,
132 * it had to be "up" in order for you to reach your own name server. It
133 * was later decided that since the recommended practice is to always
134 * install local static routes through 127.0.0.1 for all your network
135 * interfaces, that we could solve this problem without a code change.
136 *
137 * The configuration file should always be used, since it is the only way
138 * to specify a default domain. If you are running a server on your local
139 * machine, you should say "nameserver 0.0.0.0" or "nameserver 127.0.0.1"
140 * in the configuration file.
141 *
142 * Return 0 if completes successfully, -1 on error
143 */
144int
145res_init()
146{
147 register FILE *fp;
148 register char *cp, **pp;
149 register int n;
150 char buf[BUFSIZ];
151 int nserv = 0; /* number of nameserver records read from file */
152 int haveenv = 0;
153 int havesearch = 0;
154 size_t len;
155#ifdef RESOLVSORT
156 int nsort = 0;
157 char *net;
158#endif
159#ifndef RFC1535
160 int dots;
161#endif
162
163 /*
164 * These three fields used to be statically initialized. This made
165 * it hard to use this code in a shared library. It is necessary,
166 * now that we're doing dynamic initialization here, that we preserve
167 * the old semantics: if an application modifies one of these three
168 * fields of _res before res_init() is called, res_init() will not
169 * alter them. Of course, if an application is setting them to
170 * _zero_ before calling res_init(), hoping to override what used
171 * to be the static default, we can't detect it and unexpected results
172 * will follow. Zero for any of these fields would make no sense,
173 * so one can safely assume that the applications were already getting
174 * unexpected results.
175 *
176 * _res.options is tricky since some apps were known to diddle the bits
177 * before res_init() was first called. We can't replicate that semantic
178 * with dynamic initialization (they may have turned bits off that are
179 * set in RES_DEFAULT). Our solution is to declare such applications
180 * "broken". They could fool us by setting RES_INIT but none do (yet).
181 */
182 if (!_res.retrans)
183 _res.retrans = RES_TIMEOUT;
184 if (!_res.retry)
185 _res.retry = 4;
186 if (!(_res.options & RES_INIT))
187 _res.options = RES_DEFAULT;
188
189#ifdef USELOOPBACK
190 _res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
191#else
192 _res.nsaddr.sin_addr.s_addr = INADDR_ANY;
193#endif
194 _res.nsaddr.sin_family = AF_INET;
195 _res.nsaddr.sin_port = htons(NAMESERVER_PORT);
196 _res.nscount = 1;
197 _res.ndots = 1;
198 _res.pfcode = 0;
199 strncpy(_res.lookups, "f", sizeof _res.lookups);
200
201 /* Allow user to override the local domain definition */
202 if (issetugid() == 0 && (cp = getenv("LOCALDOMAIN")) != NULL) {
203 (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
204 _res.defdname[sizeof(_res.defdname) - 1] = '\0';
205 haveenv++;
206
207 /*
208 * Set search list to be blank-separated strings
209 * from rest of env value. Permits users of LOCALDOMAIN
210 * to still have a search list, and anyone to set the
211 * one that they want to use as an individual (even more
212 * important now that the rfc1535 stuff restricts searches)
213 */
214 cp = _res.defdname;
215 pp = _res.dnsrch;
216 *pp++ = cp;
217 for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
218 if (*cp == '\n') /* silly backwards compat */
219 break;
220 else if (*cp == ' ' || *cp == '\t') {
221 *cp = 0;
222 n = 1;
223 } else if (n) {
224 *pp++ = cp;
225 n = 0;
226 havesearch = 1;
227 }
228 }
229 /* null terminate last domain if there are excess */
230 while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n')
231 cp++;
232 *cp = '\0';
233 *pp++ = 0;
234 }
235
236#define MATCH(line, name) \
237 (!strncmp(line, name, sizeof(name) - 1) && \
238 (line[sizeof(name) - 1] == ' ' || \
239 line[sizeof(name) - 1] == '\t'))
240
241 if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
242 strncpy(_res.lookups, "bf", sizeof _res.lookups);
243
244 /* read the config file */
245 buf[0] = '\0';
246 while ((cp = fgetln(fp, &len)) != NULL) {
247 /* skip lines that are too long or zero length */
248 if (len >= sizeof(buf) || len == 0)
249 continue;
250 (void)memcpy(buf, cp, len);
251 buf[len] = '\0';
252 /* skip comments */
253 if ((cp = strpbrk(buf, ";#")) != NULL)
254 *cp = '\0';
255 if (buf[0] == '\0')
256 continue;
257 /* read default domain name */
258 if (MATCH(buf, "domain")) {
259 if (haveenv) /* skip if have from environ */
260 continue;
261 cp = buf + sizeof("domain") - 1;
262 while (*cp == ' ' || *cp == '\t')
263 cp++;
264 if ((*cp == '\0') || (*cp == '\n'))
265 continue;
266 strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
267 _res.defdname[sizeof(_res.defdname) - 1] = '\0';
268 if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL)
269 *cp = '\0';
270 havesearch = 0;
271 continue;
272 }
273 /* lookup types */
274 if (MATCH(buf, "lookup")) {
275 char *sp = NULL;
276
277 bzero(_res.lookups, sizeof _res.lookups);
278 cp = buf + sizeof("lookup") - 1;
279 for (n = 0;; cp++) {
280 if (n == MAXDNSLUS)
281 break;
282 if ((*cp == '\0') || (*cp == '\n')) {
283 if (sp) {
284 if (*sp=='y' || *sp=='b' || *sp=='f')
285 _res.lookups[n++] = *sp;
286 sp = NULL;
287 }
288 break;
289 } else if ((*cp == ' ') || (*cp == '\t') || (*cp == ',')) {
290 if (sp) {
291 if (*sp=='y' || *sp=='b' || *sp=='f')
292 _res.lookups[n++] = *sp;
293 sp = NULL;
294 }
295 } else if (sp == NULL)
296 sp = cp;
297 }
298 continue;
299 }
300 /* set search list */
301 if (MATCH(buf, "search")) {
302 if (haveenv) /* skip if have from environ */
303 continue;
304 cp = buf + sizeof("search") - 1;
305 while (*cp == ' ' || *cp == '\t')
306 cp++;
307 if ((*cp == '\0') || (*cp == '\n'))
308 continue;
309 strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
310 _res.defdname[sizeof(_res.defdname) - 1] = '\0';
311 if ((cp = strchr(_res.defdname, '\n')) != NULL)
312 *cp = '\0';
313 /*
314 * Set search list to be blank-separated strings
315 * on rest of line.
316 */
317 cp = _res.defdname;
318 pp = _res.dnsrch;
319 *pp++ = cp;
320 for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
321 if (*cp == ' ' || *cp == '\t') {
322 *cp = 0;
323 n = 1;
324 } else if (n) {
325 *pp++ = cp;
326 n = 0;
327 }
328 }
329 /* null terminate last domain if there are excess */
330 while (*cp != '\0' && *cp != ' ' && *cp != '\t')
331 cp++;
332 *cp = '\0';
333 *pp++ = 0;
334 havesearch = 1;
335 continue;
336 }
337 /* read nameservers to query */
338 if (MATCH(buf, "nameserver") && nserv < MAXNS) {
339 struct in_addr a;
340
341 cp = buf + sizeof("nameserver") - 1;
342 while (*cp == ' ' || *cp == '\t')
343 cp++;
344 if ((*cp != '\0') && (*cp != '\n') && inet_aton(cp, &a)) {
345 _res.nsaddr_list[nserv].sin_addr = a;
346 _res.nsaddr_list[nserv].sin_family = AF_INET;
347 _res.nsaddr_list[nserv].sin_port =
348 htons(NAMESERVER_PORT);
349 nserv++;
350 }
351 continue;
352 }
353#ifdef RESOLVSORT
354 if (MATCH(buf, "sortlist")) {
355 struct in_addr a;
356
357 cp = buf + sizeof("sortlist") - 1;
358 while (nsort < MAXRESOLVSORT) {
359 while (*cp == ' ' || *cp == '\t')
360 cp++;
361 if (*cp == '\0' || *cp == '\n' || *cp == ';')
362 break;
363 net = cp;
364 while (*cp && !ISSORTMASK(*cp) && *cp != ';' &&
365 isascii(*cp) && !isspace(*cp))
366 cp++;
367 n = *cp;
368 *cp = 0;
369 if (inet_aton(net, &a)) {
370 _res.sort_list[nsort].addr = a;
371 if (ISSORTMASK(n)) {
372 *cp++ = n;
373 net = cp;
374 while (*cp && *cp != ';' &&
375 isascii(*cp) && !isspace(*cp))
376 cp++;
377 n = *cp;
378 *cp = 0;
379 if (inet_aton(net, &a)) {
380 _res.sort_list[nsort].mask = a.s_addr;
381 } else {
382 _res.sort_list[nsort].mask =
383 net_mask(_res.sort_list[nsort].addr);
384 }
385 } else {
386 _res.sort_list[nsort].mask =
387 net_mask(_res.sort_list[nsort].addr);
388 }
389 nsort++;
390 }
391 *cp = n;
392 }
393 continue;
394 }
395#endif
396 if (MATCH(buf, "options")) {
397 res_setoptions(buf + sizeof("options") - 1, "conf");
398 continue;
399 }
400 }
401 if (nserv > 1)
402 _res.nscount = nserv;
403#ifdef RESOLVSORT
404 _res.nsort = nsort;
405#endif
406 (void) fclose(fp);
407 }
408 if (_res.defdname[0] == 0 &&
409 gethostname(buf, sizeof(_res.defdname) - 1) == 0 &&
410 (cp = strchr(buf, '.')) != NULL)
411 {
412 strncpy(_res.defdname, cp + 1,
413 sizeof(_res.defdname) - 1);
414 _res.defdname[sizeof(_res.defdname) - 1] = '\0';
415 }
416
417 /* find components of local domain that might be searched */
418 if (havesearch == 0) {
419 pp = _res.dnsrch;
420 *pp++ = _res.defdname;
421 *pp = NULL;
422
423#ifndef RFC1535
424 dots = 0;
425 for (cp = _res.defdname; *cp; cp++)
426 dots += (*cp == '.');
427
428 cp = _res.defdname;
429 while (pp < _res.dnsrch + MAXDFLSRCH) {
430 if (dots < LOCALDOMAINPARTS)
431 break;
432 cp = strchr(cp, '.') + 1; /* we know there is one */
433 *pp++ = cp;
434 dots--;
435 }
436 *pp = NULL;
437#ifdef DEBUG
438 if (_res.options & RES_DEBUG) {
439 printf(";; res_init()... default dnsrch list:\n");
440 for (pp = _res.dnsrch; *pp; pp++)
441 printf(";;\t%s\n", *pp);
442 printf(";;\t..END..\n");
443 }
444#endif /* DEBUG */
445#endif /* !RFC1535 */
446 }
447
448 if (issetugid())
449 _res.options |= RES_NOALIASES;
450 else if ((cp = getenv("RES_OPTIONS")) != NULL)
451 res_setoptions(cp, "env");
452 _res.options |= RES_INIT;
453 return (0);
454}
455
456/* ARGSUSED */
457static void
458res_setoptions(options, source)
459 char *options, *source;
460{
461 char *cp = options;
462 int i;
463
464#ifdef DEBUG
465 if (_res.options & RES_DEBUG)
466 printf(";; res_setoptions(\"%s\", \"%s\")...\n",
467 options, source);
468#endif
469 while (*cp) {
470 /* skip leading and inner runs of spaces */
471 while (*cp == ' ' || *cp == '\t')
472 cp++;
473 /* search for and process individual options */
474 if (!strncmp(cp, "ndots:", sizeof("ndots:") - 1)) {
475 i = atoi(cp + sizeof("ndots:") - 1);
476 if (i <= RES_MAXNDOTS)
477 _res.ndots = i;
478 else
479 _res.ndots = RES_MAXNDOTS;
480#ifdef DEBUG
481 if (_res.options & RES_DEBUG)
482 printf(";;\tndots=%d\n", _res.ndots);
483#endif
484 } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
485#ifdef DEBUG
486 if (!(_res.options & RES_DEBUG)) {
487 printf(";; res_setoptions(\"%s\", \"%s\")..\n",
488 options, source);
489 _res.options |= RES_DEBUG;
490 }
491 printf(";;\tdebug\n");
492#endif
493 } else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) {
494 _res.options |= RES_USE_INET6;
495 } else {
496 /* XXX - print a warning here? */
497 }
498 /* skip to next run of spaces */
499 while (*cp && *cp != ' ' && *cp != '\t')
500 cp++;
501 }
502}
503
504#ifdef RESOLVSORT
505/* XXX - should really support CIDR which means explicit masks always. */
506static u_int32_t
507net_mask(in) /* XXX - should really use system's version of this */
508 struct in_addr in;
509{
510 register u_int32_t i = ntohl(in.s_addr);
511
512 if (IN_CLASSA(i))
513 return (htonl(IN_CLASSA_NET));
514 else if (IN_CLASSB(i))
515 return (htonl(IN_CLASSB_NET));
516 return (htonl(IN_CLASSC_NET));
517}
518#endif
diff --git a/src/lib/libc/net/res_mkquery.c b/src/lib/libc/net/res_mkquery.c
new file mode 100644
index 0000000000..3e7e2ae5d3
--- /dev/null
+++ b/src/lib/libc/net/res_mkquery.c
@@ -0,0 +1,195 @@
1/* $OpenBSD: res_mkquery.c,v 1.8 1997/04/13 22:37:21 provos Exp $ */
2
3/*
4 * ++Copyright++ 1985, 1993
5 * -
6 * Copyright (c) 1985, 1993
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 * -
37 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
38 *
39 * Permission to use, copy, modify, and distribute this software for any
40 * purpose with or without fee is hereby granted, provided that the above
41 * copyright notice and this permission notice appear in all copies, and that
42 * the name of Digital Equipment Corporation not be used in advertising or
43 * publicity pertaining to distribution of the document or software without
44 * specific, written prior permission.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
47 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
49 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
50 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
52 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 * SOFTWARE.
54 * -
55 * --Copyright--
56 */
57
58#if defined(LIBC_SCCS) && !defined(lint)
59#if 0
60static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
61static char rcsid[] = "$From: res_mkquery.c,v 8.5 1996/08/27 08:33:28 vixie Exp $";
62#else
63static char rcsid[] = "$OpenBSD: res_mkquery.c,v 1.8 1997/04/13 22:37:21 provos Exp $";
64#endif
65#endif /* LIBC_SCCS and not lint */
66
67#include <sys/types.h>
68#include <sys/param.h>
69#include <netinet/in.h>
70#include <arpa/nameser.h>
71
72#include <stdio.h>
73#include <netdb.h>
74#include <resolv.h>
75#include <string.h>
76
77/*
78 * Form all types of queries.
79 * Returns the size of the result or -1.
80 */
81/* ARGSUSED */
82int
83res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
84 int op; /* opcode of query */
85 const char *dname; /* domain name */
86 int class, type; /* class and type of query */
87 const u_char *data; /* resource record data */
88 int datalen; /* length of data */
89 const u_char *newrr_in; /* new rr for modify or append */
90 u_char *buf; /* buffer to put query */
91 int buflen; /* size of buffer */
92{
93 register HEADER *hp;
94 register u_char *cp;
95 register int n;
96 u_char *dnptrs[20], **dpp, **lastdnptr;
97
98 if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
99 h_errno = NETDB_INTERNAL;
100 return (-1);
101 }
102#ifdef DEBUG
103 if (_res.options & RES_DEBUG)
104 printf(";; res_mkquery(%d, %s, %d, %d)\n",
105 op, dname, class, type);
106#endif
107 /*
108 * Initialize header fields.
109 *
110 * A special random number generator is used to create non predictable
111 * and non repeating ids over a long period. It also avoids reuse
112 * by switching between two distinct number cycles.
113 */
114
115 if ((buf == NULL) || (buflen < HFIXEDSZ))
116 return (-1);
117 bzero(buf, HFIXEDSZ);
118 hp = (HEADER *) buf;
119 _res.id = res_randomid();
120 hp->id = htons(_res.id);
121 hp->opcode = op;
122 hp->rd = (_res.options & RES_RECURSE) != 0;
123 hp->rcode = NOERROR;
124 cp = buf + HFIXEDSZ;
125 buflen -= HFIXEDSZ;
126 dpp = dnptrs;
127 *dpp++ = buf;
128 *dpp++ = NULL;
129 lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0];
130 /*
131 * perform opcode specific processing
132 */
133 switch (op) {
134 case QUERY: /*FALLTHROUGH*/
135 case NS_NOTIFY_OP:
136 if ((buflen -= QFIXEDSZ) < 0)
137 return (-1);
138 if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
139 return (-1);
140 cp += n;
141 buflen -= n;
142 __putshort(type, cp);
143 cp += INT16SZ;
144 __putshort(class, cp);
145 cp += INT16SZ;
146 hp->qdcount = htons(1);
147 if (op == QUERY || data == NULL)
148 break;
149 /*
150 * Make an additional record for completion domain.
151 */
152 buflen -= RRFIXEDSZ;
153 n = dn_comp((char *)data, cp, buflen, dnptrs, lastdnptr);
154 if (n < 0)
155 return (-1);
156 cp += n;
157 buflen -= n;
158 __putshort(T_NULL, cp);
159 cp += INT16SZ;
160 __putshort(class, cp);
161 cp += INT16SZ;
162 __putlong(0, cp);
163 cp += INT32SZ;
164 __putshort(0, cp);
165 cp += INT16SZ;
166 hp->arcount = htons(1);
167 break;
168
169 case IQUERY:
170 /*
171 * Initialize answer section
172 */
173 if (buflen < 1 + RRFIXEDSZ + datalen)
174 return (-1);
175 *cp++ = '\0'; /* no domain name */
176 __putshort(type, cp);
177 cp += INT16SZ;
178 __putshort(class, cp);
179 cp += INT16SZ;
180 __putlong(0, cp);
181 cp += INT32SZ;
182 __putshort(datalen, cp);
183 cp += INT16SZ;
184 if (datalen) {
185 bcopy(data, cp, datalen);
186 cp += datalen;
187 }
188 hp->ancount = htons(1);
189 break;
190
191 default:
192 return (-1);
193 }
194 return (cp - buf);
195}
diff --git a/src/lib/libc/net/res_query.c b/src/lib/libc/net/res_query.c
new file mode 100644
index 0000000000..a08897b45a
--- /dev/null
+++ b/src/lib/libc/net/res_query.c
@@ -0,0 +1,398 @@
1/* $OpenBSD: res_query.c,v 1.12 1998/08/31 18:15:29 deraadt Exp $ */
2
3/*
4 * ++Copyright++ 1988, 1993
5 * -
6 * Copyright (c) 1988, 1993
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 * -
37 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
38 *
39 * Permission to use, copy, modify, and distribute this software for any
40 * purpose with or without fee is hereby granted, provided that the above
41 * copyright notice and this permission notice appear in all copies, and that
42 * the name of Digital Equipment Corporation not be used in advertising or
43 * publicity pertaining to distribution of the document or software without
44 * specific, written prior permission.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
47 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
49 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
50 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
52 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 * SOFTWARE.
54 * -
55 * --Copyright--
56 */
57
58#if defined(LIBC_SCCS) && !defined(lint)
59#if 0
60static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
61static char rcsid[] = "$From: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $";
62#else
63static char rcsid[] = "$OpenBSD: res_query.c,v 1.12 1998/08/31 18:15:29 deraadt Exp $";
64#endif
65#endif /* LIBC_SCCS and not lint */
66
67#include <sys/types.h>
68#include <sys/param.h>
69#include <netinet/in.h>
70#include <arpa/inet.h>
71#include <arpa/nameser.h>
72
73#include <stdio.h>
74#include <netdb.h>
75#include <resolv.h>
76#include <ctype.h>
77#include <errno.h>
78#include <stdlib.h>
79#include <string.h>
80#include <unistd.h>
81
82#if PACKETSZ > 1024
83#define MAXPACKET PACKETSZ
84#else
85#define MAXPACKET 1024
86#endif
87
88const char *hostalias __P((const char *));
89int h_errno;
90
91/*
92 * Formulate a normal query, send, and await answer.
93 * Returned answer is placed in supplied buffer "answer".
94 * Perform preliminary check of answer, returning success only
95 * if no error is indicated and the answer count is nonzero.
96 * Return the size of the response on success, -1 on error.
97 * Error number is left in h_errno.
98 *
99 * Caller must parse answer and determine whether it answers the question.
100 */
101int
102res_query(name, class, type, answer, anslen)
103 const char *name; /* domain name */
104 int class, type; /* class and type of query */
105 u_char *answer; /* buffer to put answer */
106 int anslen; /* size of answer buffer */
107{
108 u_char buf[MAXPACKET];
109 register HEADER *hp = (HEADER *) answer;
110 int n;
111
112 hp->rcode = NOERROR; /* default */
113
114 if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
115 h_errno = NETDB_INTERNAL;
116 return (-1);
117 }
118#ifdef DEBUG
119 if (_res.options & RES_DEBUG)
120 printf(";; res_query(%s, %d, %d)\n", name, class, type);
121#endif
122
123 n = res_mkquery(QUERY, name, class, type, NULL, 0, NULL,
124 buf, sizeof(buf));
125 if (n <= 0) {
126#ifdef DEBUG
127 if (_res.options & RES_DEBUG)
128 printf(";; res_query: mkquery failed\n");
129#endif
130 h_errno = NO_RECOVERY;
131 return (n);
132 }
133 n = res_send(buf, n, answer, anslen);
134 if (n < 0) {
135#ifdef DEBUG
136 if (_res.options & RES_DEBUG)
137 printf(";; res_query: send error\n");
138#endif
139 h_errno = TRY_AGAIN;
140 return (n);
141 }
142
143 if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
144#ifdef DEBUG
145 if (_res.options & RES_DEBUG)
146 printf(";; rcode = %d, ancount=%d\n", hp->rcode,
147 ntohs(hp->ancount));
148#endif
149 switch (hp->rcode) {
150 case NXDOMAIN:
151 h_errno = HOST_NOT_FOUND;
152 break;
153 case SERVFAIL:
154 h_errno = TRY_AGAIN;
155 break;
156 case NOERROR:
157 h_errno = NO_DATA;
158 break;
159 case FORMERR:
160 case NOTIMP:
161 case REFUSED:
162 default:
163 h_errno = NO_RECOVERY;
164 break;
165 }
166 return (-1);
167 }
168 return (n);
169}
170
171/*
172 * Formulate a normal query, send, and retrieve answer in supplied buffer.
173 * Return the size of the response on success, -1 on error.
174 * If enabled, implement search rules until answer or unrecoverable failure
175 * is detected. Error code, if any, is left in h_errno.
176 */
177int
178res_search(name, class, type, answer, anslen)
179 const char *name; /* domain name */
180 int class, type; /* class and type of query */
181 u_char *answer; /* buffer to put answer */
182 int anslen; /* size of answer */
183{
184 register const char *cp, * const *domain;
185 HEADER *hp = (HEADER *) answer;
186 u_int dots;
187 int trailing_dot, ret, saved_herrno;
188 int got_nodata = 0, got_servfail = 0, tried_as_is = 0;
189
190 if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
191 h_errno = NETDB_INTERNAL;
192 return (-1);
193 }
194 errno = 0;
195 h_errno = HOST_NOT_FOUND; /* default, if we never query */
196 dots = 0;
197 for (cp = name; *cp; cp++)
198 dots += (*cp == '.');
199 trailing_dot = 0;
200 if (cp > name && *--cp == '.')
201 trailing_dot++;
202
203 /*
204 * if there aren't any dots, it could be a user-level alias
205 */
206 if (!dots && (cp = __hostalias(name)) != NULL)
207 return (res_query(cp, class, type, answer, anslen));
208
209 /*
210 * If there are dots in the name already, let's just give it a try
211 * 'as is'. The threshold can be set with the "ndots" option.
212 */
213 saved_herrno = -1;
214 if (dots >= _res.ndots) {
215 ret = res_querydomain(name, NULL, class, type, answer, anslen);
216 if (ret > 0)
217 return (ret);
218 saved_herrno = h_errno;
219 tried_as_is++;
220 }
221
222 /*
223 * We do at least one level of search if
224 * - there is no dot and RES_DEFNAME is set, or
225 * - there is at least one dot, there is no trailing dot,
226 * and RES_DNSRCH is set.
227 */
228 if ((!dots && (_res.options & RES_DEFNAMES)) ||
229 (dots && !trailing_dot && (_res.options & RES_DNSRCH))) {
230 int done = 0;
231
232 for (domain = (const char * const *)_res.dnsrch;
233 *domain && !done;
234 domain++) {
235
236 ret = res_querydomain(name, *domain, class, type,
237 answer, anslen);
238 if (ret > 0)
239 return (ret);
240
241 /*
242 * If no server present, give up.
243 * If name isn't found in this domain,
244 * keep trying higher domains in the search list
245 * (if that's enabled).
246 * On a NO_DATA error, keep trying, otherwise
247 * a wildcard entry of another type could keep us
248 * from finding this entry higher in the domain.
249 * If we get some other error (negative answer or
250 * server failure), then stop searching up,
251 * but try the input name below in case it's
252 * fully-qualified.
253 */
254 if (errno == ECONNREFUSED) {
255 h_errno = TRY_AGAIN;
256 return (-1);
257 }
258
259 switch (h_errno) {
260 case NO_DATA:
261 got_nodata++;
262 /* FALLTHROUGH */
263 case HOST_NOT_FOUND:
264 /* keep trying */
265 break;
266 case TRY_AGAIN:
267 if (hp->rcode == SERVFAIL) {
268 /* try next search element, if any */
269 got_servfail++;
270 break;
271 }
272 /* FALLTHROUGH */
273 default:
274 /* anything else implies that we're done */
275 done++;
276 }
277
278 /* if we got here for some reason other than DNSRCH,
279 * we only wanted one iteration of the loop, so stop.
280 */
281 if (!(_res.options & RES_DNSRCH))
282 done++;
283 }
284 }
285
286 /* if we have not already tried the name "as is", do that now.
287 * note that we do this regardless of how many dots were in the
288 * name or whether it ends with a dot.
289 */
290 if (!tried_as_is) {
291 ret = res_querydomain(name, NULL, class, type, answer, anslen);
292 if (ret > 0)
293 return (ret);
294 }
295
296 /* if we got here, we didn't satisfy the search.
297 * if we did an initial full query, return that query's h_errno
298 * (note that we wouldn't be here if that query had succeeded).
299 * else if we ever got a nodata, send that back as the reason.
300 * else send back meaningless h_errno, that being the one from
301 * the last DNSRCH we did.
302 */
303 if (saved_herrno != -1)
304 h_errno = saved_herrno;
305 else if (got_nodata)
306 h_errno = NO_DATA;
307 else if (got_servfail)
308 h_errno = TRY_AGAIN;
309 return (-1);
310}
311
312/*
313 * Perform a call on res_query on the concatenation of name and domain,
314 * removing a trailing dot from name if domain is NULL.
315 */
316int
317res_querydomain(name, domain, class, type, answer, anslen)
318 const char *name, *domain;
319 int class, type; /* class and type of query */
320 u_char *answer; /* buffer to put answer */
321 int anslen; /* size of answer */
322{
323 char nbuf[MAXDNAME*2+1];
324 const char *longname = nbuf;
325 int n;
326
327 if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
328 h_errno = NETDB_INTERNAL;
329 return (-1);
330 }
331#ifdef DEBUG
332 if (_res.options & RES_DEBUG)
333 printf(";; res_querydomain(%s, %s, %d, %d)\n",
334 name, domain?domain:"<Nil>", class, type);
335#endif
336 if (domain == NULL) {
337 /*
338 * Check for trailing '.';
339 * copy without '.' if present.
340 */
341 n = strlen(name) - 1;
342 if (n != (0 - 1) && name[n] == '.' && n < sizeof(nbuf) - 1) {
343 bcopy(name, nbuf, n);
344 nbuf[n] = '\0';
345 } else
346 longname = name;
347 } else
348 sprintf(nbuf, "%.*s.%.*s", MAXDNAME, name, MAXDNAME, domain);
349
350 return (res_query(longname, class, type, answer, anslen));
351}
352
353const char *
354hostalias(name)
355 register const char *name;
356{
357 register char *cp1, *cp2;
358 FILE *fp;
359 char *file;
360 char buf[BUFSIZ];
361 static char abuf[MAXDNAME];
362 size_t len;
363
364 if (_res.options & RES_NOALIASES)
365 return (NULL);
366 file = getenv("HOSTALIASES");
367 if (issetugid() != 0 || file == NULL || (fp = fopen(file, "r")) == NULL)
368 return (NULL);
369 setbuf(fp, NULL);
370 while ((cp1 = fgetln(fp, &len)) != NULL) {
371 if (cp1[len-1] == '\n')
372 len--;
373 if (len >= sizeof(buf) || len == 0)
374 continue;
375 (void)memcpy(buf, cp1, len);
376 buf[len] = '\0';
377
378 for (cp1 = buf; *cp1 && !isspace(*cp1); ++cp1)
379 ;
380 if (!*cp1)
381 break;
382 *cp1 = '\0';
383 if (!strcasecmp(buf, name)) {
384 while (isspace(*++cp1))
385 ;
386 if (!*cp1)
387 break;
388 for (cp2 = cp1 + 1; *cp2 && !isspace(*cp2); ++cp2)
389 ;
390 strncpy(abuf, cp1, sizeof(abuf) - 1);
391 abuf[sizeof(abuf) - 1] = *cp2 = '\0';
392 fclose(fp);
393 return (abuf);
394 }
395 }
396 fclose(fp);
397 return (NULL);
398}
diff --git a/src/lib/libc/net/res_random.c b/src/lib/libc/net/res_random.c
new file mode 100644
index 0000000000..bd32a50c33
--- /dev/null
+++ b/src/lib/libc/net/res_random.c
@@ -0,0 +1,233 @@
1/* $OpenBSD: res_random.c,v 1.7 1997/07/25 20:30:08 mickey Exp $ */
2
3/*
4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
5 * All rights reserved.
6 *
7 * Theo de Raadt <deraadt@openbsd.org> came up with the idea of using
8 * such a mathematical system to generate more random (yet non-repeating)
9 * ids to solve the resolver/named problem. But Niels designed the
10 * actual system based on the constraints.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by Niels Provos.
23 * 4. The name of the author may not be used to endorse or promote products
24 * derived from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38/*
39 * seed = random 15bit
40 * n = prime, g0 = generator to n,
41 * j = random so that gcd(j,n-1) == 1
42 * g = g0^j mod n will be a generator again.
43 *
44 * X[0] = random seed.
45 * X[n] = a*X[n-1]+b mod m is a Linear Congruential Generator
46 * with a = 7^(even random) mod m,
47 * b = random with gcd(b,m) == 1
48 * m = 31104 and a maximal period of m-1.
49 *
50 * The transaction id is determined by:
51 * id[n] = seed xor (g^X[n] mod n)
52 *
53 * Effectivly the id is restricted to the lower 15 bits, thus
54 * yielding two different cycles by toggling the msb on and off.
55 * This avoids reuse issues caused by reseeding.
56 *
57 * The 16 bit space is very small and brute force attempts are
58 * entirly feasible, we skip a random number of transaction ids
59 * so that an attacker will not get sequential ids.
60 */
61
62#include <sys/types.h>
63#include <netinet/in.h>
64#include <sys/time.h>
65#include <resolv.h>
66
67#include <unistd.h>
68#include <stdlib.h>
69#include <string.h>
70
71#define RU_OUT 180 /* Time after wich will be reseeded */
72#define RU_MAX 30000 /* Uniq cycle, avoid blackjack prediction */
73#define RU_GEN 2 /* Starting generator */
74#define RU_N 32749 /* RU_N-1 = 2*2*3*2729 */
75#define RU_AGEN 7 /* determine ru_a as RU_AGEN^(2*rand) */
76#define RU_M 31104 /* RU_M = 2^7*3^5 - don't change */
77
78#define PFAC_N 3
79const static u_int16_t pfacts[PFAC_N] = {
80 2,
81 3,
82 2729
83};
84
85static u_int16_t ru_x;
86static u_int16_t ru_seed;
87static u_int16_t ru_a, ru_b;
88static u_int16_t ru_g;
89static u_int16_t ru_counter = 0;
90static u_int16_t ru_msb = 0;
91static long ru_reseed;
92static u_int32_t tmp; /* Storage for unused random */
93static struct timeval tv;
94
95static u_int16_t pmod __P((u_int16_t, u_int16_t, u_int16_t));
96static void res_initid __P((void));
97
98/*
99 * Do a fast modular exponation, returned value will be in the range
100 * of 0 - (mod-1)
101 */
102
103#ifdef __STDC__
104static u_int16_t
105pmod(u_int16_t gen, u_int16_t exp, u_int16_t mod)
106#else
107static u_int16_t
108pmod(gen, exp, mod)
109 u_int16_t gen, exp, mod;
110#endif
111{
112 u_int16_t s, t, u;
113
114 s = 1;
115 t = gen;
116 u = exp;
117
118 while (u) {
119 if (u & 1)
120 s = (s*t) % mod;
121 u >>= 1;
122 t = (t*t) % mod;
123 }
124 return (s);
125}
126
127/*
128 * Initalizes the seed and chooses a suitable generator. Also toggles
129 * the msb flag. The msb flag is used to generate two distinct
130 * cycles of random numbers and thus avoiding reuse of ids.
131 *
132 * This function is called from res_randomid() when needed, an
133 * application does not have to worry about it.
134 */
135static void
136res_initid()
137{
138 u_int16_t j, i;
139 int noprime = 1;
140
141 tmp = arc4random();
142 ru_x = (tmp & 0xFFFF) % RU_M;
143
144 /* 15 bits of random seed */
145 ru_seed = (tmp >> 16) & 0x7FFF;
146
147 tmp = arc4random();
148
149 /* Determine the LCG we use */
150 ru_b = (tmp & 0xfffe) | 1;
151 ru_a = pmod(RU_AGEN, (tmp >> 16) & 0xfffe, RU_M);
152 while (ru_b % 3 == 0)
153 ru_b += 2;
154
155 tmp = arc4random();
156 j = tmp % RU_N;
157 tmp = tmp >> 16;
158
159 /*
160 * Do a fast gcd(j,RU_N-1), so we can find a j with
161 * gcd(j, RU_N-1) == 1, giving a new generator for
162 * RU_GEN^j mod RU_N
163 */
164
165 while (noprime) {
166 for (i=0; i<PFAC_N; i++)
167 if (j%pfacts[i] == 0)
168 break;
169
170 if (i>=PFAC_N)
171 noprime = 0;
172 else
173 j = (j+1) % RU_N;
174 }
175
176 ru_g = pmod(RU_GEN,j,RU_N);
177 ru_counter = 0;
178
179 gettimeofday(&tv, NULL);
180 ru_reseed = tv.tv_sec + RU_OUT;
181 ru_msb = ru_msb == 0x8000 ? 0 : 0x8000;
182}
183
184u_int
185res_randomid()
186{
187 int i, n;
188
189 gettimeofday(&tv, NULL);
190 if (ru_counter >= RU_MAX || tv.tv_sec > ru_reseed)
191 res_initid();
192
193 if (!tmp)
194 tmp = arc4random();
195
196 /* Skip a random number of ids */
197 n = tmp & 0x7; tmp = tmp >> 3;
198 if (ru_counter + n >= RU_MAX)
199 res_initid();
200
201 for (i=0; i<=n; i++)
202 /* Linear Congruential Generator */
203 ru_x = (ru_a*ru_x + ru_b) % RU_M;
204
205 ru_counter += i;
206
207 return (ru_seed ^ pmod(ru_g,ru_x,RU_N)) | ru_msb;
208}
209
210#if 0
211void
212main(int argc, char **argv)
213{
214 int i, n;
215 u_int16_t wert;
216
217 res_initid();
218
219 printf("Generator: %d\n", ru_g);
220 printf("Seed: %d\n", ru_seed);
221 printf("Reseed at %ld\n", ru_reseed);
222 printf("Ru_X: %d\n", ru_x);
223 printf("Ru_A: %d\n", ru_a);
224 printf("Ru_B: %d\n", ru_b);
225
226 n = atoi(argv[1]);
227 for (i=0;i<n;i++) {
228 wert = res_randomid();
229 printf("%06d\n", wert);
230 }
231}
232#endif
233
diff --git a/src/lib/libc/net/res_send.c b/src/lib/libc/net/res_send.c
new file mode 100644
index 0000000000..0cda3510eb
--- /dev/null
+++ b/src/lib/libc/net/res_send.c
@@ -0,0 +1,780 @@
1/* $OpenBSD: res_send.c,v 1.8 1998/03/19 00:30:08 millert Exp $ */
2
3/*
4 * ++Copyright++ 1985, 1989, 1993
5 * -
6 * Copyright (c) 1985, 1989, 1993
7 * The Regents of the University of California. All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 * -
37 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
38 *
39 * Permission to use, copy, modify, and distribute this software for any
40 * purpose with or without fee is hereby granted, provided that the above
41 * copyright notice and this permission notice appear in all copies, and that
42 * the name of Digital Equipment Corporation not be used in advertising or
43 * publicity pertaining to distribution of the document or software without
44 * specific, written prior permission.
45 *
46 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
47 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
48 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
49 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
50 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
52 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
53 * SOFTWARE.
54 * -
55 * --Copyright--
56 */
57
58#if defined(LIBC_SCCS) && !defined(lint)
59#if 0
60static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
61static char rcsid[] = "$From: res_send.c,v 8.12 1996/10/08 04:51:06 vixie Exp $";
62#else
63static char rcsid[] = "$OpenBSD: res_send.c,v 1.8 1998/03/19 00:30:08 millert Exp $";
64#endif
65#endif /* LIBC_SCCS and not lint */
66
67 /* change this to "0"
68 * if you talk to a lot
69 * of multi-homed SunOS
70 * ("broken") name servers.
71 */
72#define CHECK_SRVR_ADDR 1 /* XXX - should be in options.h */
73
74/*
75 * Send query to name server and wait for reply.
76 */
77
78#include <sys/types.h>
79#include <sys/param.h>
80#include <sys/time.h>
81#include <sys/socket.h>
82#include <sys/uio.h>
83#include <netinet/in.h>
84#include <arpa/nameser.h>
85#include <arpa/inet.h>
86
87#include <stdio.h>
88#include <netdb.h>
89#include <errno.h>
90#include <resolv.h>
91#include <stdlib.h>
92#include <string.h>
93#include <unistd.h>
94
95static int s = -1; /* socket used for communications */
96static int connected = 0; /* is the socket connected */
97static int vc = 0; /* is the socket a virtual ciruit? */
98
99#ifndef FD_SET
100/* XXX - should be in portability.h */
101#define NFDBITS 32
102#define FD_SETSIZE 32
103#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
104#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
105#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
106#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
107#endif
108
109#define CAN_RECONNECT 1
110
111#ifndef DEBUG
112# define Dprint(cond, args) /*empty*/
113# define DprintQ(cond, args, query, size) /*empty*/
114# define Aerror(file, string, error, address) /*empty*/
115# define Perror(file, string, error) /*empty*/
116#else
117# define Dprint(cond, args) if (cond) {fprintf args;} else {}
118# define DprintQ(cond, args, query, size) if (cond) {\
119 fprintf args;\
120 __fp_nquery(query, size, stdout);\
121 } else {}
122 static void
123 Aerror(file, string, error, address)
124 FILE *file;
125 char *string;
126 int error;
127 struct sockaddr_in address;
128 {
129 int save = errno;
130
131 if (_res.options & RES_DEBUG) {
132 fprintf(file, "res_send: %s ([%s].%u): %s\n",
133 string,
134 inet_ntoa(address.sin_addr),
135 ntohs(address.sin_port),
136 strerror(error));
137 }
138 errno = save;
139 }
140 static void
141 Perror(file, string, error)
142 FILE *file;
143 char *string;
144 int error;
145 {
146 int save = errno;
147
148 if (_res.options & RES_DEBUG) {
149 fprintf(file, "res_send: %s: %s\n",
150 string, strerror(error));
151 }
152 errno = save;
153 }
154#endif
155
156static res_send_qhook Qhook = NULL;
157static res_send_rhook Rhook = NULL;
158
159void
160res_send_setqhook(hook)
161 res_send_qhook hook;
162{
163
164 Qhook = hook;
165}
166
167void
168res_send_setrhook(hook)
169 res_send_rhook hook;
170{
171
172 Rhook = hook;
173}
174
175/* int
176 * res_isourserver(ina)
177 * looks up "ina" in _res.ns_addr_list[]
178 * returns:
179 * 0 : not found
180 * >0 : found
181 * author:
182 * paul vixie, 29may94
183 */
184int
185res_isourserver(inp)
186 const struct sockaddr_in *inp;
187{
188 struct sockaddr_in ina;
189 register int ns, ret;
190
191 ina = *inp;
192 ret = 0;
193 for (ns = 0; ns < _res.nscount; ns++) {
194 register const struct sockaddr_in *srv = &_res.nsaddr_list[ns];
195
196 if (srv->sin_family == ina.sin_family &&
197 srv->sin_port == ina.sin_port &&
198 (srv->sin_addr.s_addr == INADDR_ANY ||
199 srv->sin_addr.s_addr == ina.sin_addr.s_addr)) {
200 ret++;
201 break;
202 }
203 }
204 return (ret);
205}
206
207/* int
208 * res_nameinquery(name, type, class, buf, eom)
209 * look for (name,type,class) in the query section of packet (buf,eom)
210 * returns:
211 * -1 : format error
212 * 0 : not found
213 * >0 : found
214 * author:
215 * paul vixie, 29may94
216 */
217int
218res_nameinquery(name, type, class, buf, eom)
219 const char *name;
220 register int type, class;
221 const u_char *buf, *eom;
222{
223 register const u_char *cp = buf + HFIXEDSZ;
224 int qdcount = ntohs(((HEADER*)buf)->qdcount);
225
226 while (qdcount-- > 0) {
227 char tname[MAXDNAME+1];
228 register int n, ttype, tclass;
229
230 n = dn_expand(buf, eom, cp, tname, sizeof tname);
231 if (n < 0)
232 return (-1);
233 cp += n;
234 ttype = _getshort(cp); cp += INT16SZ;
235 tclass = _getshort(cp); cp += INT16SZ;
236 if (ttype == type &&
237 tclass == class &&
238 strcasecmp(tname, name) == 0)
239 return (1);
240 }
241 return (0);
242}
243
244/* int
245 * res_queriesmatch(buf1, eom1, buf2, eom2)
246 * is there a 1:1 mapping of (name,type,class)
247 * in (buf1,eom1) and (buf2,eom2)?
248 * returns:
249 * -1 : format error
250 * 0 : not a 1:1 mapping
251 * >0 : is a 1:1 mapping
252 * author:
253 * paul vixie, 29may94
254 */
255int
256res_queriesmatch(buf1, eom1, buf2, eom2)
257 const u_char *buf1, *eom1;
258 const u_char *buf2, *eom2;
259{
260 register const u_char *cp = buf1 + HFIXEDSZ;
261 int qdcount = ntohs(((HEADER*)buf1)->qdcount);
262
263 if (qdcount != ntohs(((HEADER*)buf2)->qdcount))
264 return (0);
265 while (qdcount-- > 0) {
266 char tname[MAXDNAME+1];
267 register int n, ttype, tclass;
268
269 n = dn_expand(buf1, eom1, cp, tname, sizeof tname);
270 if (n < 0)
271 return (-1);
272 cp += n;
273 ttype = _getshort(cp); cp += INT16SZ;
274 tclass = _getshort(cp); cp += INT16SZ;
275 if (!res_nameinquery(tname, ttype, tclass, buf2, eom2))
276 return (0);
277 }
278 return (1);
279}
280
281int
282res_send(buf, buflen, ans, anssiz)
283 const u_char *buf;
284 int buflen;
285 u_char *ans;
286 int anssiz;
287{
288 HEADER *hp = (HEADER *) buf;
289 HEADER *anhp = (HEADER *) ans;
290 int gotsomewhere, connreset, terrno, try, v_circuit, resplen, ns;
291 register int n;
292 u_int badns; /* XXX NSMAX can't exceed #/bits in this var */
293
294 if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
295 /* errno should have been set by res_init() in this case. */
296 return (-1);
297 }
298 DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_QUERY),
299 (stdout, ";; res_send()\n"), buf, buflen);
300 v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ;
301 gotsomewhere = 0;
302 connreset = 0;
303 terrno = ETIMEDOUT;
304 badns = 0;
305
306 /*
307 * Send request, RETRY times, or until successful
308 */
309 for (try = 0; try < _res.retry; try++) {
310 for (ns = 0; ns < _res.nscount; ns++) {
311 struct sockaddr_in *nsap = &_res.nsaddr_list[ns];
312 same_ns:
313 if (badns & (1 << ns)) {
314 res_close();
315 goto next_ns;
316 }
317
318 if (Qhook) {
319 int done = 0, loops = 0;
320
321 do {
322 res_sendhookact act;
323
324 act = (*Qhook)(&nsap, &buf, &buflen,
325 ans, anssiz, &resplen);
326 switch (act) {
327 case res_goahead:
328 done = 1;
329 break;
330 case res_nextns:
331 res_close();
332 goto next_ns;
333 case res_done:
334 return (resplen);
335 case res_modified:
336 /* give the hook another try */
337 if (++loops < 42) /*doug adams*/
338 break;
339 /*FALLTHROUGH*/
340 case res_error:
341 /*FALLTHROUGH*/
342 default:
343 return (-1);
344 }
345 } while (!done);
346 }
347
348 Dprint(_res.options & RES_DEBUG,
349 (stdout, ";; Querying server (# %d) address = %s\n",
350 ns + 1, inet_ntoa(nsap->sin_addr)));
351
352 if (v_circuit) {
353 int truncated;
354 struct iovec iov[2];
355 u_short len;
356 u_char *cp;
357
358 /*
359 * Use virtual circuit;
360 * at most one attempt per server.
361 */
362 try = _res.retry;
363 truncated = 0;
364 if ((s < 0) || (!vc)) {
365 if (s >= 0)
366 res_close();
367
368 s = socket(PF_INET, SOCK_STREAM, 0);
369 if (s < 0) {
370 terrno = errno;
371 Perror(stderr, "socket(vc)", errno);
372 return (-1);
373 }
374 errno = 0;
375 if (connect(s, (struct sockaddr *)nsap,
376 sizeof(struct sockaddr)) < 0) {
377 terrno = errno;
378 Aerror(stderr, "connect/vc",
379 errno, *nsap);
380 badns |= (1 << ns);
381 res_close();
382 goto next_ns;
383 }
384 vc = 1;
385 }
386 /*
387 * Send length & message
388 */
389 putshort((u_short)buflen, (u_char*)&len);
390 iov[0].iov_base = (caddr_t)&len;
391 iov[0].iov_len = INT16SZ;
392 iov[1].iov_base = (caddr_t)buf;
393 iov[1].iov_len = buflen;
394 if (writev(s, iov, 2) != (INT16SZ + buflen)) {
395 terrno = errno;
396 Perror(stderr, "write failed", errno);
397 badns |= (1 << ns);
398 res_close();
399 goto next_ns;
400 }
401 /*
402 * Receive length & response
403 */
404read_len:
405 cp = ans;
406 len = INT16SZ;
407 while ((n = read(s, (char *)cp, (int)len)) > 0) {
408 cp += n;
409 if ((len -= n) <= 0)
410 break;
411 }
412 if (n <= 0) {
413 terrno = errno;
414 Perror(stderr, "read failed", errno);
415 res_close();
416 /*
417 * A long running process might get its TCP
418 * connection reset if the remote server was
419 * restarted. Requery the server instead of
420 * trying a new one. When there is only one
421 * server, this means that a query might work
422 * instead of failing. We only allow one reset
423 * per query to prevent looping.
424 */
425 if (terrno == ECONNRESET && !connreset) {
426 connreset = 1;
427 res_close();
428 goto same_ns;
429 }
430 res_close();
431 goto next_ns;
432 }
433 resplen = _getshort(ans);
434 if (resplen > anssiz) {
435 Dprint(_res.options & RES_DEBUG,
436 (stdout, ";; response truncated\n")
437 );
438 truncated = 1;
439 len = anssiz;
440 } else
441 len = resplen;
442 cp = ans;
443 while (len != 0 &&
444 (n = read(s, (char *)cp, (int)len)) > 0) {
445 cp += n;
446 len -= n;
447 }
448 if (n <= 0) {
449 terrno = errno;
450 Perror(stderr, "read(vc)", errno);
451 res_close();
452 goto next_ns;
453 }
454 if (truncated) {
455 /*
456 * Flush rest of answer
457 * so connection stays in synch.
458 */
459 anhp->tc = 1;
460 len = resplen - anssiz;
461 while (len != 0) {
462 char junk[PACKETSZ];
463
464 n = (len > sizeof(junk)
465 ? sizeof(junk)
466 : len);
467 if ((n = read(s, junk, n)) > 0)
468 len -= n;
469 else
470 break;
471 }
472 }
473 /*
474 * The calling applicating has bailed out of
475 * a previous call and failed to arrange to have
476 * the circuit closed or the server has got
477 * itself confused. Anyway drop the packet and
478 * wait for the correct one.
479 */
480 if (hp->id != anhp->id) {
481 DprintQ((_res.options & RES_DEBUG) ||
482 (_res.pfcode & RES_PRF_REPLY),
483 (stdout, ";; old answer (unexpected):\n"),
484 ans, (resplen>anssiz)?anssiz:resplen);
485 goto read_len;
486 }
487 } else {
488 /*
489 * Use datagrams.
490 */
491 struct timeval timeout;
492 fd_set *dsmaskp;
493 struct sockaddr_in from;
494 int fromlen;
495
496 if ((s < 0) || vc) {
497 if (vc)
498 res_close();
499 s = socket(PF_INET, SOCK_DGRAM, 0);
500 if (s < 0) {
501#if !CAN_RECONNECT
502 bad_dg_sock:
503#endif
504 terrno = errno;
505 Perror(stderr, "socket(dg)", errno);
506 return (-1);
507 }
508 connected = 0;
509 }
510 /*
511 * On a 4.3BSD+ machine (client and server,
512 * actually), sending to a nameserver datagram
513 * port with no nameserver will cause an
514 * ICMP port unreachable message to be returned.
515 * If our datagram socket is "connected" to the
516 * server, we get an ECONNREFUSED error on the next
517 * socket operation, and select returns if the
518 * error message is received. We can thus detect
519 * the absence of a nameserver without timing out.
520 * If we have sent queries to at least two servers,
521 * however, we don't want to remain connected,
522 * as we wish to receive answers from the first
523 * server to respond.
524 */
525 if (_res.nscount == 1 || (try == 0 && ns == 0)) {
526 /*
527 * Connect only if we are sure we won't
528 * receive a response from another server.
529 */
530 if (!connected) {
531 if (connect(s, (struct sockaddr *)nsap,
532 sizeof(struct sockaddr)
533 ) < 0) {
534 Aerror(stderr,
535 "connect(dg)",
536 errno, *nsap);
537 badns |= (1 << ns);
538 res_close();
539 goto next_ns;
540 }
541 connected = 1;
542 }
543 if (send(s, (char*)buf, buflen, 0) != buflen) {
544 Perror(stderr, "send", errno);
545 badns |= (1 << ns);
546 res_close();
547 goto next_ns;
548 }
549 } else {
550 /*
551 * Disconnect if we want to listen
552 * for responses from more than one server.
553 */
554 if (connected) {
555#if CAN_RECONNECT
556 struct sockaddr_in no_addr;
557
558 no_addr.sin_family = AF_INET;
559 no_addr.sin_addr.s_addr = INADDR_ANY;
560 no_addr.sin_port = 0;
561 (void) connect(s,
562 (struct sockaddr *)
563 &no_addr,
564 sizeof(no_addr));
565#else
566 int s1 = socket(PF_INET, SOCK_DGRAM,0);
567 if (s1 < 0)
568 goto bad_dg_sock;
569 (void) dup2(s1, s);
570 (void) close(s1);
571 Dprint(_res.options & RES_DEBUG,
572 (stdout, ";; new DG socket\n"))
573#endif
574 connected = 0;
575 errno = 0;
576 }
577 if (sendto(s, (char*)buf, buflen, 0,
578 (struct sockaddr *)nsap,
579 sizeof(struct sockaddr))
580 != buflen) {
581 Aerror(stderr, "sendto", errno, *nsap);
582 badns |= (1 << ns);
583 res_close();
584 goto next_ns;
585 }
586 }
587
588 /*
589 * Wait for reply
590 */
591 timeout.tv_sec = (_res.retrans << try);
592 if (try > 0)
593 timeout.tv_sec /= _res.nscount;
594 if ((long) timeout.tv_sec <= 0)
595 timeout.tv_sec = 1;
596 timeout.tv_usec = 0;
597 wait:
598 dsmaskp = (fd_set *)calloc(howmany(s+1, NFDBITS),
599 sizeof(fd_mask));
600 if (dsmaskp == NULL) {
601 res_close();
602 goto next_ns;
603 }
604 FD_SET(s, dsmaskp);
605 n = select(s+1, dsmaskp, (fd_set *)NULL,
606 (fd_set *)NULL, &timeout);
607 free(dsmaskp);
608 if (n < 0) {
609 if (errno == EINTR)
610 goto wait;
611 Perror(stderr, "select", errno);
612 res_close();
613 goto next_ns;
614 }
615 if (n == 0) {
616 /*
617 * timeout
618 */
619 Dprint(_res.options & RES_DEBUG,
620 (stdout, ";; timeout\n"));
621 gotsomewhere = 1;
622 res_close();
623 goto next_ns;
624 }
625 errno = 0;
626 fromlen = sizeof(struct sockaddr_in);
627 resplen = recvfrom(s, (char*)ans, anssiz, 0,
628 (struct sockaddr *)&from, &fromlen);
629 if (resplen <= 0) {
630 Perror(stderr, "recvfrom", errno);
631 res_close();
632 goto next_ns;
633 }
634 gotsomewhere = 1;
635 if (hp->id != anhp->id) {
636 /*
637 * response from old query, ignore it.
638 * XXX - potential security hazard could
639 * be detected here.
640 */
641 DprintQ((_res.options & RES_DEBUG) ||
642 (_res.pfcode & RES_PRF_REPLY),
643 (stdout, ";; old answer:\n"),
644 ans, (resplen>anssiz)?anssiz:resplen);
645 goto wait;
646 }
647#if CHECK_SRVR_ADDR
648 if (!(_res.options & RES_INSECURE1) &&
649 !res_isourserver(&from)) {
650 /*
651 * response from wrong server? ignore it.
652 * XXX - potential security hazard could
653 * be detected here.
654 */
655 DprintQ((_res.options & RES_DEBUG) ||
656 (_res.pfcode & RES_PRF_REPLY),
657 (stdout, ";; not our server:\n"),
658 ans, (resplen>anssiz)?anssiz:resplen);
659 goto wait;
660 }
661#endif
662 if (!(_res.options & RES_INSECURE2) &&
663 !res_queriesmatch(buf, buf + buflen,
664 ans, ans + anssiz)) {
665 /*
666 * response contains wrong query? ignore it.
667 * XXX - potential security hazard could
668 * be detected here.
669 */
670 DprintQ((_res.options & RES_DEBUG) ||
671 (_res.pfcode & RES_PRF_REPLY),
672 (stdout, ";; wrong query name:\n"),
673 ans, (resplen>anssiz)?anssiz:resplen);
674 goto wait;
675 }
676 if (anhp->rcode == SERVFAIL ||
677 anhp->rcode == NOTIMP ||
678 anhp->rcode == REFUSED) {
679 DprintQ(_res.options & RES_DEBUG,
680 (stdout, "server rejected query:\n"),
681 ans, (resplen>anssiz)?anssiz:resplen);
682 badns |= (1 << ns);
683 res_close();
684 /* don't retry if called from dig */
685 if (!_res.pfcode)
686 goto next_ns;
687 }
688 if (!(_res.options & RES_IGNTC) && anhp->tc) {
689 /*
690 * get rest of answer;
691 * use TCP with same server.
692 */
693 Dprint(_res.options & RES_DEBUG,
694 (stdout, ";; truncated answer\n"));
695 v_circuit = 1;
696 res_close();
697 goto same_ns;
698 }
699 } /*if vc/dg*/
700 Dprint((_res.options & RES_DEBUG) ||
701 ((_res.pfcode & RES_PRF_REPLY) &&
702 (_res.pfcode & RES_PRF_HEAD1)),
703 (stdout, ";; got answer:\n"));
704 DprintQ((_res.options & RES_DEBUG) ||
705 (_res.pfcode & RES_PRF_REPLY),
706 (stdout, ""),
707 ans, (resplen>anssiz)?anssiz:resplen);
708 /*
709 * If using virtual circuits, we assume that the first server
710 * is preferred over the rest (i.e. it is on the local
711 * machine) and only keep that one open.
712 * If we have temporarily opened a virtual circuit,
713 * or if we haven't been asked to keep a socket open,
714 * close the socket.
715 */
716 if ((v_circuit && (!(_res.options & RES_USEVC) || ns != 0)) ||
717 !(_res.options & RES_STAYOPEN)) {
718 res_close();
719 }
720 if (Rhook) {
721 int done = 0, loops = 0;
722
723 do {
724 res_sendhookact act;
725
726 act = (*Rhook)(nsap, buf, buflen,
727 ans, anssiz, &resplen);
728 switch (act) {
729 case res_goahead:
730 case res_done:
731 done = 1;
732 break;
733 case res_nextns:
734 res_close();
735 goto next_ns;
736 case res_modified:
737 /* give the hook another try */
738 if (++loops < 42) /*doug adams*/
739 break;
740 /*FALLTHROUGH*/
741 case res_error:
742 /*FALLTHROUGH*/
743 default:
744 return (-1);
745 }
746 } while (!done);
747
748 }
749 return (resplen);
750 next_ns: ;
751 } /*foreach ns*/
752 } /*foreach retry*/
753 res_close();
754 if (!v_circuit) {
755 if (!gotsomewhere)
756 errno = ECONNREFUSED; /* no nameservers found */
757 else
758 errno = ETIMEDOUT; /* no answer obtained */
759 } else
760 errno = terrno;
761 return (-1);
762}
763
764/*
765 * This routine is for closing the socket if a virtual circuit is used and
766 * the program wants to close it. This provides support for endhostent()
767 * which expects to close the socket.
768 *
769 * This routine is not expected to be user visible.
770 */
771void
772res_close()
773{
774 if (s >= 0) {
775 (void) close(s);
776 s = -1;
777 connected = 0;
778 vc = 0;
779 }
780}
diff --git a/src/lib/libc/net/resolver.3 b/src/lib/libc/net/resolver.3
new file mode 100644
index 0000000000..389906d8a3
--- /dev/null
+++ b/src/lib/libc/net/resolver.3
@@ -0,0 +1,345 @@
1.\" $OpenBSD: resolver.3,v 1.6 1999/02/27 21:55:34 deraadt Exp $
2.\"
3.\" Copyright (c) 1985, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.Dd June 4, 1993
35.Dt RESOLVER 3
36.Os BSD 4.3
37.Sh NAME
38.Nm res_query ,
39.Nm res_search ,
40.Nm res_mkquery ,
41.Nm res_send ,
42.Nm res_init ,
43.Nm dn_comp ,
44.Nm dn_expand
45.Nd resolver routines
46.Sh SYNOPSIS
47.Fd #include <sys/types.h>
48.Fd #include <netinet/in.h>
49.Fd #include <arpa/nameser.h>
50.Fd #include <resolv.h>
51.Fo res_query
52.Fa "char *dname"
53.Fa "int class"
54.Fa "int type"
55.Fa "u_char *answer"
56.Fa "int anslen"
57.Fc
58.Fo res_search
59.Fa "char *dname"
60.Fa "int class"
61.Fa "int type"
62.Fa "u_char *answer"
63.Fa "int anslen"
64.Fc
65.Fo res_mkquery
66.Fa "int op"
67.Fa "char *dname"
68.Fa "int class"
69.Fa "int type"
70.Fa "char *data"
71.Fa "int datalen"
72.Fa "struct rrec *newrr"
73.Fa "char *buf"
74.Fa "int buflen"
75.Fc
76.Fo res_send
77.Fa "char *msg"
78.Fa "int msglen"
79.Fa "char *answer"
80.Fa "int anslen"
81.Fc
82.Fn res_init
83.Fo dn_comp
84.Fa "char *exp_dn"
85.Fa "char *comp_dn"
86.Fa "int length"
87.Fa "char **dnptrs"
88.Fa "char **lastdnptr"
89.Fc
90.Fo dn_expand
91.Fa "u_char *msg"
92.Fa "u_char *eomorig"
93.Fa "u_char *comp_dn"
94.Fa "u_char *exp_dn"
95.Fa "int length"
96.Fc
97.Sh DESCRIPTION
98These routines are used for making, sending and interpreting
99query and reply messages with Internet domain name servers.
100.Pp
101Global configuration and state information that is used by the
102resolver routines is kept in the structure
103.Em _res .
104Most of the values have reasonable defaults and can be ignored.
105Options
106stored in
107.Em _res.options
108are defined in
109.Pa resolv.h
110and are as follows.
111Options are stored as a simple bit mask containing the bitwise ``or''
112of the options enabled.
113.Bl -tag -width RES_USE_INET6
114.It Dv RES_INIT
115True if the initial name server address and default domain name are
116initialized (i.e.,
117.Fn res_init
118has been called).
119.It Dv RES_DEBUG
120Print debugging messages.
121.It Dv RES_AAONLY
122Accept authoritative answers only.
123With this option,
124.Fn res_send
125should continue until it finds an authoritative answer or finds an error.
126Currently this is not implemented.
127.It Dv RES_USEVC
128Use
129.Tn TCP
130connections for queries instead of
131.Tn UDP
132datagrams.
133.It Dv RES_STAYOPEN
134Used with
135.Dv RES_USEVC
136to keep the
137.Tn TCP
138connection open between
139queries.
140This is useful only in programs that regularly do many queries.
141.Tn UDP
142should be the normal mode used.
143.It Dv RES_IGNTC
144Unused currently (ignore truncation errors, i.e., don't retry with
145.Tn TCP ) .
146.It Dv RES_RECURSE
147Set the recursion-desired bit in queries.
148This is the default.
149.Pf ( Fn res_send
150does not do iterative queries and expects the name server
151to handle recursion.)
152.It Dv RES_DEFNAMES
153If set,
154.Fn res_search
155will append the default domain name to single-component names
156(those that do not contain a dot).
157This option is enabled by default.
158.It Dv RES_DNSRCH
159If this option is set,
160.Fn res_search
161will search for host names in the current domain and in parent domains; see
162.Xr hostname 7 .
163This is used by the standard host lookup routine
164.Xr gethostbyname 3 .
165This option is enabled by default.
166.It Dv RES_USE_INET6
167Enable support for IPv6 addresses.
168.El
169.Pp
170The
171.Fn res_init
172routine
173reads the configuration file (if any; see
174.Xr resolv.conf 5 )
175to get the default domain name,
176search list and
177the Internet address of the local name server(s).
178If no server is configured, the host running
179the resolver is tried.
180The current domain name is defined by the hostname
181if not specified in the configuration file;
182it can be overridden by the environment variable
183.Ev LOCALDOMAIN .
184This environment variable may contain several blank-separated
185tokens if you wish to override the
186.Fa search list
187on a per-process basis.
188This is similar to the
189.Fa search
190command in the configuration file.
191Another environment variable
192.Ev RES_OPTIONS
193can be set to override certain internal resolver options which
194are otherwise set by changing fields in the
195.Fa _res
196structure or are inherited from the configuration file's
197.Fa options
198command.
199The syntax of the
200.Ev RES_OPTIONS
201environment variable is explained in
202.Xr resolv.conf 5 .
203Initialization normally occurs on the first call
204to one of the following routines.
205.Pp
206The
207.Fn res_query
208function provides an interface to the server query mechanism.
209It constructs a query, sends it to the local server,
210awaits a response, and makes preliminary checks on the reply.
211The query requests information of the specified
212.Fa type
213and
214.Fa class
215for the specified fully-qualified domain name
216.Fa dname .
217The reply message is left in the
218.Fa answer
219buffer with length
220.Fa anslen
221supplied by the caller.
222.Pp
223The
224.Fn res_search
225routine makes a query and awaits a response like
226.Fn res_query ,
227but in addition, it implements the default and search rules
228controlled by the
229.Dv RES_DEFNAMES
230and
231.Dv RES_DNSRCH
232options.
233It returns the first successful reply.
234.Pp
235The remaining routines are lower-level routines used by
236.Fn res_query .
237The
238.Fn res_mkquery
239function
240constructs a standard query message and places it in
241.Fa buf .
242It returns the size of the query, or \-1 if the query is
243larger than
244.Fa buflen .
245The query type
246.Fa op
247is usually
248.Dv QUERY ,
249but can be any of the query types defined in
250.Aq Pa arpa/nameser.h .
251The domain name for the query is given by
252.Fa dname .
253.Fa newrr
254is currently unused but is intended for making update messages.
255.Pp
256The
257.Fn res_send
258routine
259sends a pre-formatted query and returns an answer.
260It will call
261.Fn res_init
262if
263.Dv RES_INIT
264is not set, send the query to the local name server, and
265handle timeouts and retries.
266The length of the reply message is returned, or
267\-1 if there were errors.
268.Pp
269The
270.Fn dn_comp
271function
272compresses the domain name
273.Fa exp_dn
274and stores it in
275.Fa comp_dn .
276The size of the compressed name is returned or \-1 if there were errors.
277The size of the array pointed to by
278.Fa comp_dn
279is given by
280.Fa length .
281The compression uses
282an array of pointers
283.Fa dnptrs
284to previously-compressed names in the current message.
285The first pointer points
286to the beginning of the message and the list ends with
287.Dv NULL .
288The limit to the array is specified by
289.Fa lastdnptr .
290A side effect of
291.Fn dn_comp
292is to update the list of pointers for
293labels inserted into the message
294as the name is compressed.
295If
296.Em dnptr
297is
298.Dv NULL, names are not compressed.
299If
300.Fa lastdnptr
301is
302.Dv NULL ,
303the list of labels is not updated.
304.Pp
305The
306.Fn dn_expand
307entry
308expands the compressed domain name
309.Fa comp_dn
310to a full domain name
311The compressed name is contained in a query or reply message;
312.Fa msg
313is a pointer to the beginning of the message.
314The uncompressed name is placed in the buffer indicated by
315.Fa exp_dn
316which is of size
317.Fa length .
318The size of compressed name is returned or \-1 if there was an error.
319.Sh FILES
320.Bl -tag -width Pa
321/etc/resolv.conf
322The configuration file
323see
324.Xr resolv.conf 5 .
325.El
326.Sh SEE ALSO
327.Xr gethostbyname 3 ,
328.Xr named 8 ,
329.Xr resolv.conf 5 ,
330.Xr hostname 7 ,
331.Pp
332.%T RFC1032 ,
333.%T RFC1033 ,
334.%T RFC1034 ,
335.%T RFC1035 ,
336.%T RFC1535 ,
337.%T RFC974
338.Rs
339.%T "Name Server Operations Guide for BIND"
340.Re
341.Sh HISTORY
342The
343.Nm
344function appeared in
345.Bx 4.3 .
diff --git a/src/lib/libc/net/send.c b/src/lib/libc/net/send.c
new file mode 100644
index 0000000000..8495931ca3
--- /dev/null
+++ b/src/lib/libc/net/send.c
@@ -0,0 +1,50 @@
1/*
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: send.c,v 1.2 1996/08/19 08:29:52 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <sys/socket.h>
40
41#include <stddef.h>
42
43ssize_t
44send(s, msg, len, flags)
45 int s, flags;
46 size_t len;
47 const void *msg;
48{
49 return (sendto(s, msg, len, flags, NULL, 0));
50}
diff --git a/src/lib/libc/net/sethostent.c b/src/lib/libc/net/sethostent.c
new file mode 100644
index 0000000000..5392a2f11b
--- /dev/null
+++ b/src/lib/libc/net/sethostent.c
@@ -0,0 +1,60 @@
1/*
2 * Copyright (c) 1985, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: sethostent.c,v 1.4 1997/03/15 21:53:50 pefo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/param.h>
39#include <netinet/in.h>
40#include <arpa/nameser.h>
41#include <netdb.h>
42#include <resolv.h>
43
44void
45sethostent(stayopen)
46 int stayopen;
47{
48
49 if ((_res.options & RES_INIT) == 0 && res_init() == -1)
50 return;
51 if (stayopen)
52 _res.options |= RES_STAYOPEN | RES_USEVC;
53}
54
55void
56endhostent()
57{
58 _res.options &= ~(RES_STAYOPEN | RES_USEVC);
59 res_close();
60}
diff --git a/src/lib/libc/stdlib/Makefile.inc b/src/lib/libc/stdlib/Makefile.inc
new file mode 100644
index 0000000000..3191f08328
--- /dev/null
+++ b/src/lib/libc/stdlib/Makefile.inc
@@ -0,0 +1,54 @@
1# $OpenBDS: Makefile.inc,v 1.6 1996/08/21 03:47:21 tholo Exp $
2
3# stdlib sources
4.PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/stdlib ${LIBCSRCDIR}/stdlib
5
6SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c bsearch.c calloc.c \
7 cfree.c exit.c getenv.c getopt.c getsubopt.c heapsort.c l64a.c \
8 malloc.c merge.c multibyte.c putenv.c qsort.c radixsort.c rand.c \
9 random.c realpath.c setenv.c strtod.c strtol.c strtoq.c strtoul.c \
10 strtouq.c system.c tfind.c tsearch.c \
11 _rand48.c drand48.c erand48.c jrand48.c lcong48.c lrand48.c \
12 mrand48.c nrand48.c seed48.c srand48.c qabs.c qdiv.c
13
14.if (${MACHINE_ARCH} == "m68k")
15SRCS+= abs.S div.c labs.c ldiv.c
16LSRCS+= abs.c
17.elif (${MACHINE_ARCH} == "i386")
18SRCS+= abs.S div.S labs.S ldiv.S
19LSRCS+= abs.c div.c labs.c ldiv.c
20.elif (${MACHINE_ARCH} == "ns32k")
21SRCS+= abs.S div.c labs.c ldiv.c
22LSRCS+= abs.c
23.elif (${MACHINE_ARCH} == "tahoe")
24SRCS+= abs.S div.c labs.c ldiv.c
25LSRCS+= abs.c
26.elif (${MACHINE_ARCH} == "vax")
27SRCS+= abs.c div.c labs.c ldiv.c
28.elif (${MACHINE_ARCH} == "alpha")
29# XXX should be .S's
30SRCS+= abs.c div.c labs.c ldiv.c
31.else
32SRCS+= abs.c div.c labs.c ldiv.c
33.endif
34
35MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 bsearch.3 \
36 calloc.3 div.3 exit.3 getenv.3 getopt.3 getsubopt.3 labs.3 ldiv.3 \
37 malloc.3 memory.3 qabs.3 qdiv.3 qsort.3 radixsort.3 rand48.3 rand.3 \
38 random.3 realpath.3 strtod.3 strtol.3 strtoul.3 system.3 tsearch.3
39
40MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3
41MLINKS+=malloc.3 free.3 malloc.3 realloc.3
42MLINKS+=malloc.3 cfree.3 malloc.3 malloc.conf.5
43MLINKS+=qsort.3 heapsort.3 qsort.3 mergesort.3
44MLINKS+=rand.3 srand.3
45MLINKS+=random.3 initstate.3 random.3 setstate.3 random.3 srandom.3
46MLINKS+=rand48.3 drand48.3 rand48.3 erand48.3 rand48.3 lrand48.3
47MLINKS+=rand48.3 mrand48.3 rand48.3 nrand48.3 rand48.3 jrand48.3
48MLINKS+=rand48.3 srand48.3 rand48.3 seed48.3 rand48.3 lcong48.3
49MLINKS+=strtol.3 strtoq.3
50MLINKS+=strtoul.3 strtouq.3
51MLINKS+=tsearch.3 tfind.3
52MLINKS+=tsearch.3 tdelete.3
53MLINKS+=tsearch.3 twalk.3
54MLINKS+=a64l.3 l64a.3
diff --git a/src/lib/libc/stdlib/_rand48.c b/src/lib/libc/stdlib/_rand48.c
new file mode 100644
index 0000000000..fed7372f68
--- /dev/null
+++ b/src/lib/libc/stdlib/_rand48.c
@@ -0,0 +1,50 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 */
13
14#if defined(LIBC_SCCS) && !defined(lint)
15static char rcsid[] = "$OpenBSD: _rand48.c,v 1.2 1996/08/19 08:33:19 tholo Exp $";
16#endif /* LIBC_SCCS and not lint */
17
18#include "rand48.h"
19
20unsigned short __rand48_seed[3] = {
21 RAND48_SEED_0,
22 RAND48_SEED_1,
23 RAND48_SEED_2
24};
25unsigned short __rand48_mult[3] = {
26 RAND48_MULT_0,
27 RAND48_MULT_1,
28 RAND48_MULT_2
29};
30unsigned short __rand48_add = RAND48_ADD;
31
32void
33__dorand48(unsigned short xseed[3])
34{
35 unsigned long accu;
36 unsigned short temp[2];
37
38 accu = (unsigned long) __rand48_mult[0] * (unsigned long) xseed[0] +
39 (unsigned long) __rand48_add;
40 temp[0] = (unsigned short) accu; /* lower 16 bits */
41 accu >>= sizeof(unsigned short) * 8;
42 accu += (unsigned long) __rand48_mult[0] * (unsigned long) xseed[1] +
43 (unsigned long) __rand48_mult[1] * (unsigned long) xseed[0];
44 temp[1] = (unsigned short) accu; /* middle 16 bits */
45 accu >>= sizeof(unsigned short) * 8;
46 accu += __rand48_mult[0] * xseed[2] + __rand48_mult[1] * xseed[1] + __rand48_mult[2] * xseed[0];
47 xseed[0] = temp[0];
48 xseed[1] = temp[1];
49 xseed[2] = (unsigned short) accu;
50}
diff --git a/src/lib/libc/stdlib/a64l.3 b/src/lib/libc/stdlib/a64l.3
new file mode 100644
index 0000000000..0607338cba
--- /dev/null
+++ b/src/lib/libc/stdlib/a64l.3
@@ -0,0 +1,122 @@
1.\"
2.\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution.
13.\" 3. The name of the author may not be used to endorse or promote products
14.\" derived from this software without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
17.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
19.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26.\"
27.\" $OpenBSD: a64l.3,v 1.3 1999/02/27 21:55:53 deraadt Exp $
28.\"
29.Dd August 17, 1997
30.Dt A64L 3
31.Os
32.Sh NAME
33.Nm a64l ,
34.Nm l64a
35.Nd convert between 32-bit integer and radix-64 ASCII string
36.Sh SYNOPSIS
37.Fd #include <stdlib.h>
38.Ft long
39.Fn a64l "const char *s"
40.Ft char *
41.Fn l64a "long l"
42.Sh DESCRIPTION
43The
44.Fn a64l
45and
46.Fn l64a
47functions are used to maintain numbers stored in radix-64
48ASCII characters. This is a notation by which 32-bit integers
49can be represented by up to six characters; each character
50represents a "digit" in a radix-64 notation.
51.Pp
52The characters used to represent "digits" are '.' for 0, '/' for 1,
53'0' through '9' for 2-11, 'A' through 'Z' for 12-37, and 'a' through
54'z' for 38-63.
55.Pp
56The
57.Fn a64l
58function takes a pointer to a null-terminated radix-64 representation
59and returns a corresponding 32-bit value. If the string pointed to by
60.Ar s
61contains more than six characters,
62.Fn a64l
63will use the first six.
64.Fn a64l
65scans the character string from left to right, decoding
66each character as a 6-bit radix-64 number. If a long integer is
67larger than 32 bits, the return value will be sign-extended.
68.Pp
69.Fn l64a
70takes a long integer argument
71.Ar l
72and returns a pointer to the corresponding radix-64 representation.
73.Sh RETURN VALUES
74On success,
75.Fn a64l
76returns a 32-bit representation of
77.Ar s .
78If
79.Ar s
80is a NULL pointer or if it contains "digits" other than those described above,
81.Fn a64l
82returns -1L and sets the global variable errno to
83.Va EINVAL .
84.Pp
85On success,
86.Fn l64a
87returns a pointer to a string containing the radix-64 representation of
88.Ar l .
89If
90.Ar l
91is 0,
92.Fn l64a
93returns a pointer to the empty string.
94If
95.Ar l
96is negative,
97.Fn l64a
98returns a NULL pointer and sets the global variable errno to
99.Va EINVAL .
100.Sh WARNINGS
101The value returned by
102.Fn l64a
103is a pointer into a static buffer, the contents of which
104will be overwritten by subsequent calls.
105.Pp
106The value returned by
107.Fn a64l
108may be incorrect if the value is too large; for that reason, only strings
109that resulted from a call to
110.Fn l64a
111should be used to call
112.Fn a64l .
113.Pp
114If a long integer is larger than 32 bits, only the low-order
11532 bits are used.
116.Sh STANDARDS
117The
118.Fn a64l
119and
120.Fn l64a
121functions conform to
122.St -xpg4.2 .
diff --git a/src/lib/libc/stdlib/a64l.c b/src/lib/libc/stdlib/a64l.c
new file mode 100644
index 0000000000..a68f0a6dcd
--- /dev/null
+++ b/src/lib/libc/stdlib/a64l.c
@@ -0,0 +1,46 @@
1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 */
5
6#if defined(LIBC_SCCS) && !defined(lint)
7static char *rcsid = "$OpenBSD: a64l.c,v 1.3 1997/08/17 22:58:34 millert Exp $";
8#endif /* LIBC_SCCS and not lint */
9
10#include <errno.h>
11#include <stdlib.h>
12
13long
14a64l(s)
15 const char *s;
16{
17 long value, digit, shift;
18 int i;
19
20 if (s == NULL) {
21 errno = EINVAL;
22 return(-1L);
23 }
24
25 value = 0;
26 shift = 0;
27 for (i = 0; *s && i < 6; i++, s++) {
28 if (*s >= '.' && *s <= '/')
29 digit = *s - '.';
30 else if (*s >= '0' && *s <= '9')
31 digit = *s - '0' + 2;
32 else if (*s >= 'A' && *s <= 'Z')
33 digit = *s - 'A' + 12;
34 else if (*s >= 'a' && *s <= 'z')
35 digit = *s - 'a' + 38;
36 else {
37 errno = EINVAL;
38 return(-1L);
39 }
40
41 value |= digit << shift;
42 shift += 6;
43 }
44
45 return(value);
46}
diff --git a/src/lib/libc/stdlib/abort.3 b/src/lib/libc/stdlib/abort.3
new file mode 100644
index 0000000000..92c9a354d0
--- /dev/null
+++ b/src/lib/libc/stdlib/abort.3
@@ -0,0 +1,70 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: abort.3,v 1.4 1997/07/17 07:39:41 deraadt Exp $
37.\"
38.Dd June 29, 1991
39.Dt ABORT 3
40.Os
41.Sh NAME
42.Nm abort
43.Nd cause abnormal program termination
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft void
47.Fn abort void
48.Sh DESCRIPTION
49The
50.Fn abort
51function causes abnormal program termination to occur, unless the
52signal
53.Dv SIGABRT
54is being caught and the signal handler does not return.
55.Pp
56Any open streams are flushed and closed.
57.Sh RETURN VALUES
58The
59.Nm abort
60function
61never returns.
62.Sh SEE ALSO
63.Xr sigaction 2 ,
64.Xr exit 3
65.Sh STANDARDS
66The
67.Fn abort
68function
69conforms to
70.St -p1003.1-90 .
diff --git a/src/lib/libc/stdlib/abort.c b/src/lib/libc/stdlib/abort.c
new file mode 100644
index 0000000000..4cc6257acb
--- /dev/null
+++ b/src/lib/libc/stdlib/abort.c
@@ -0,0 +1,86 @@
1/*
2 * Copyright (c) 1985 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: abort.c,v 1.6 1998/11/20 11:18:49 d Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <signal.h>
39#include <stdlib.h>
40#include <unistd.h>
41#include "thread_private.h"
42
43void (*__cleanup)();
44
45void
46abort()
47{
48 static int cleanup_called = 0;
49 sigset_t mask;
50
51
52 sigfillset(&mask);
53 /*
54 * don't block SIGABRT to give any handler a chance; we ignore
55 * any errors -- X311J doesn't allow abort to return anyway.
56 */
57 sigdelset(&mask, SIGABRT);
58#ifdef _THREAD_SAFE
59 (void)_thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
60#else _THREAD_SAFE
61 (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
62#endif _THREAD_SAFE
63
64 /*
65 * POSIX requires we flush stdio buffers on abort
66 */
67 if (cleanup_called == 0 && __cleanup != NULL) {
68 cleanup_called = 1;
69 (*__cleanup)();
70 }
71
72 (void)kill(getpid(), SIGABRT);
73
74 /*
75 * if SIGABRT ignored, or caught and the handler returns, do
76 * it again, only harder.
77 */
78 (void)signal(SIGABRT, SIG_DFL);
79#ifdef _THREAD_SAFE
80 (void)_thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
81#else _THREAD_SAFE
82 (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
83#endif _THREAD_SAFE
84 (void)kill(getpid(), SIGABRT);
85 exit(1);
86}
diff --git a/src/lib/libc/stdlib/abs.3 b/src/lib/libc/stdlib/abs.3
new file mode 100644
index 0000000000..77f82b9402
--- /dev/null
+++ b/src/lib/libc/stdlib/abs.3
@@ -0,0 +1,73 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: abs.3,v 1.2 1996/08/19 08:33:21 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt ABS 3
40.Os
41.Sh NAME
42.Nm abs
43.Nd integer absolute value function
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft int
47.Fn abs "int j"
48.Sh DESCRIPTION
49The
50.Fn abs
51function
52computes
53the absolute value of the integer
54.Ar j .
55.Sh RETURN VALUES
56The
57.Fn abs
58function
59returns
60the absolute value.
61.Sh SEE ALSO
62.Xr floor 3 ,
63.Xr labs 3 ,
64.Xr cabs 3 ,
65.Xr hypot 3 ,
66.Xr math 3
67.Sh STANDARDS
68The
69.Fn abs
70function conforms to
71.St -ansiC .
72.Sh BUGS
73The absolute value of the most negative integer remains negative.
diff --git a/src/lib/libc/stdlib/abs.c b/src/lib/libc/stdlib/abs.c
new file mode 100644
index 0000000000..7c79e4073c
--- /dev/null
+++ b/src/lib/libc/stdlib/abs.c
@@ -0,0 +1,45 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: abs.c,v 1.2 1996/08/19 08:33:21 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39
40int
41abs(j)
42 int j;
43{
44 return(j < 0 ? -j : j);
45}
diff --git a/src/lib/libc/stdlib/alloca.3 b/src/lib/libc/stdlib/alloca.3
new file mode 100644
index 0000000000..ef87220772
--- /dev/null
+++ b/src/lib/libc/stdlib/alloca.3
@@ -0,0 +1,75 @@
1.\" Copyright (c) 1980, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" $OpenBSD: alloca.3,v 1.3 1996/08/19 08:33:22 tholo Exp $
33.\"
34.Dd May 2, 1991
35.Dt ALLOCA 3
36.Os BSD 4
37.Sh NAME
38.Nm alloca
39.Nd memory allocator
40.Sh SYNOPSIS
41.Fd #include <stdlib.h>
42.Ft void *
43.Fn alloca "size_t size"
44.Sh DESCRIPTION
45The
46.Fn alloca
47function
48allocates
49.Fa size
50bytes of space in the stack frame of the caller.
51This temporary space is automatically freed on
52return.
53.Sh RETURN VALUES
54The
55.Fn alloca
56function returns a pointer to the beginning of the allocated space.
57.Sh SEE ALSO
58.Xr brk 2 ,
59.Xr pagesize 2
60.Xr calloc 3 ,
61.Xr malloc 3 ,
62.Xr realloc 3 ,
63.Sh BUGS
64The
65.Fn alloca
66function
67is machine dependent; its use is discouraged.
68.\" .Sh HISTORY
69.\" The
70.\" .Fn alloca
71.\" function appeared in
72.\" .Bx ?? .
73.\" The function appeared in 32v, pwb and pwb.2 and in 3bsd 4bsd
74.\" The first man page (or link to a man page that I can find at the
75.\" moment is 4.3...
diff --git a/src/lib/libc/stdlib/atexit.3 b/src/lib/libc/stdlib/atexit.3
new file mode 100644
index 0000000000..0b10f010fa
--- /dev/null
+++ b/src/lib/libc/stdlib/atexit.3
@@ -0,0 +1,77 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: atexit.3,v 1.2 1996/08/19 08:33:22 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt ATEXIT 3
40.Os
41.Sh NAME
42.Nm atexit
43.Nd register a function to be called on exit
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft int
47.Fn atexit "void (*function)(void)"
48.Sh DESCRIPTION
49The
50.Fn atexit
51function
52registers the given
53.Ar function
54to be called at program exit, whether via
55.Xr exit 3
56or via return from the program's
57.Em main .
58Functions so registered are called in reverse order;
59no arguments are passed.
60At least 32 functions can always be registered,
61and more are allowed as long as sufficient memory can be allocated.
62.Sh RETURN VALUES
63.Rv -std atexit
64.Sh ERRORS
65.Bl -tag -width Er
66.It Bq Er ENOMEM
67No memory was available to add the function to the list.
68The existing list of functions is unmodified.
69.El
70.Sh SEE ALSO
71.Xr exit 3
72.Sh STANDARDS
73The
74.Fn atexit
75function
76conforms to
77.St -ansiC .
diff --git a/src/lib/libc/stdlib/atexit.c b/src/lib/libc/stdlib/atexit.c
new file mode 100644
index 0000000000..c0fb624141
--- /dev/null
+++ b/src/lib/libc/stdlib/atexit.c
@@ -0,0 +1,67 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: atexit.c,v 1.2 1996/08/19 08:33:22 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <stdlib.h>
42#include "atexit.h"
43
44struct atexit *__atexit;
45
46/*
47 * Register a function to be performed at exit.
48 */
49int
50atexit(fn)
51 void (*fn)();
52{
53 static struct atexit __atexit0; /* one guaranteed table */
54 register struct atexit *p;
55
56 if ((p = __atexit) == NULL)
57 __atexit = p = &__atexit0;
58 else if (p->ind >= ATEXIT_SIZE) {
59 if ((p = malloc(sizeof(*p))) == NULL)
60 return (-1);
61 p->ind = 0;
62 p->next = __atexit;
63 __atexit = p;
64 }
65 p->fns[p->ind++] = fn;
66 return (0);
67}
diff --git a/src/lib/libc/stdlib/atexit.h b/src/lib/libc/stdlib/atexit.h
new file mode 100644
index 0000000000..e41a7cb86c
--- /dev/null
+++ b/src/lib/libc/stdlib/atexit.h
@@ -0,0 +1,45 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $OpenBSD: atexit.h,v 1.2 1996/08/19 08:33:23 tholo Exp $
34 */
35
36/* must be at least 32 to guarantee ANSI conformance */
37#define ATEXIT_SIZE 32
38
39struct atexit {
40 struct atexit *next; /* next in list */
41 int ind; /* next index in this table */
42 void (*fns[ATEXIT_SIZE])(); /* the table itself */
43};
44
45extern struct atexit *__atexit; /* points to head of LIFO stack */
diff --git a/src/lib/libc/stdlib/atof.3 b/src/lib/libc/stdlib/atof.3
new file mode 100644
index 0000000000..cc1b500b0f
--- /dev/null
+++ b/src/lib/libc/stdlib/atof.3
@@ -0,0 +1,73 @@
1.\" Copyright (c) 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: atof.3,v 1.2 1996/08/19 08:33:23 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt ATOF 3
40.Os
41.Sh NAME
42.Nm atof
43.Nd convert
44.Tn ASCII
45string to double
46.Sh SYNOPSIS
47.Fd #include <stdlib.h>
48.Ft double
49.Fn atof "const char *nptr"
50.Sh DESCRIPTION
51The
52.Fn atof
53function converts the initial portion of the string pointed to by
54.Ar nptr
55to
56.Ar double
57representation.
58.Pp
59It is equivalent to:
60.Bd -literal -offset indent
61strtod(nptr, (char **)NULL);
62.Ed
63.Sh SEE ALSO
64.Xr atoi 3 ,
65.Xr atol 3 ,
66.Xr strtod 3 ,
67.Xr strtol 3 ,
68.Xr strtoul 3
69.Sh STANDARDS
70The
71.Fn atof
72function conforms to
73.St -ansiC .
diff --git a/src/lib/libc/stdlib/atof.c b/src/lib/libc/stdlib/atof.c
new file mode 100644
index 0000000000..30bac19899
--- /dev/null
+++ b/src/lib/libc/stdlib/atof.c
@@ -0,0 +1,45 @@
1/*
2 * Copyright (c) 1988 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: atof.c,v 1.2 1996/08/19 08:33:24 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39
40double
41atof(ascii)
42 const char *ascii;
43{
44 return(strtod(ascii, (char **)NULL));
45}
diff --git a/src/lib/libc/stdlib/atoi.3 b/src/lib/libc/stdlib/atoi.3
new file mode 100644
index 0000000000..280a989e8e
--- /dev/null
+++ b/src/lib/libc/stdlib/atoi.3
@@ -0,0 +1,73 @@
1.\" Copyright (c) 1990, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: atoi.3,v 1.2 1996/08/10 04:51:31 tholo Exp $
37.\"
38.Dd June 4, 1993
39.Dt ATOI 3
40.Os
41.Sh NAME
42.Nm atoi
43.Nd convert
44.Tn ASCII
45string to integer
46.Sh SYNOPSIS
47.Fd #include <stdlib.h>
48.Ft int
49.Fn atoi "const char *nptr"
50.Sh DESCRIPTION
51The
52.Fn atoi
53function converts the initial portion of the string pointed to by
54.Em nptr
55to
56.Em integer
57representation.
58.Pp
59It is equivalent to:
60.Bd -literal -offset indent
61(int)strtol(nptr, (char **)NULL, 10);
62.Ed
63.Sh SEE ALSO
64.Xr atof 3 ,
65.Xr atol 3 ,
66.Xr strtod 3 ,
67.Xr strtol 3 ,
68.Xr strtoul 3
69.Sh STANDARDS
70The
71.Fn atoi
72function conforms to
73.St -ansiC .
diff --git a/src/lib/libc/stdlib/atoi.c b/src/lib/libc/stdlib/atoi.c
new file mode 100644
index 0000000000..a74d6e1351
--- /dev/null
+++ b/src/lib/libc/stdlib/atoi.c
@@ -0,0 +1,45 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: atoi.c,v 1.2 1996/08/19 08:33:24 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39
40int
41atoi(str)
42 const char *str;
43{
44 return((int)strtol(str, (char **)NULL, 10));
45}
diff --git a/src/lib/libc/stdlib/atol.3 b/src/lib/libc/stdlib/atol.3
new file mode 100644
index 0000000000..2b49bd1f2c
--- /dev/null
+++ b/src/lib/libc/stdlib/atol.3
@@ -0,0 +1,74 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: atol.3,v 1.2 1996/08/19 08:33:25 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt ATOL 3
40.Os
41.Sh NAME
42.Nm atol
43.Nd convert
44.Tn ASCII
45string to long integer
46.Sh SYNOPSIS
47.Fd #include <stdlib.h>
48.Ft long
49.Fn atol "const char *nptr"
50.Sh DESCRIPTION
51The
52.Fn atol
53function converts the initial portion of the string pointed to by
54.Ar nptr
55to
56.Em long integer
57representation.
58.Pp
59It is equivalent to:
60.Bd -literal -offset indent
61strtol(nptr, (char **)NULL, 10);
62.Ed
63.Sh SEE ALSO
64.Xr atof 3 ,
65.Xr atoi 3 ,
66.Xr strtod 3 ,
67.Xr strtol 3 ,
68.Xr strtoul 3
69.Sh STANDARDS
70The
71.Fn atol
72function
73conforms to
74.St -ansiC .
diff --git a/src/lib/libc/stdlib/atol.c b/src/lib/libc/stdlib/atol.c
new file mode 100644
index 0000000000..528a932214
--- /dev/null
+++ b/src/lib/libc/stdlib/atol.c
@@ -0,0 +1,45 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: atol.c,v 1.2 1996/08/19 08:33:26 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39
40long
41atol(str)
42 const char *str;
43{
44 return(strtol(str, (char **)NULL, 10));
45}
diff --git a/src/lib/libc/stdlib/bsearch.3 b/src/lib/libc/stdlib/bsearch.3
new file mode 100644
index 0000000000..570a4227b4
--- /dev/null
+++ b/src/lib/libc/stdlib/bsearch.3
@@ -0,0 +1,90 @@
1.\" Copyright (c) 1990, 1991, 1993, 1994
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: bsearch.3,v 1.3 1997/06/13 23:41:35 deraadt Exp $
37.\"
38.Dd April 19, 1994
39.Dt BSEARCH 3
40.Os
41.Sh NAME
42.Nm bsearch
43.Nd binary search of a sorted table
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft void *
47.Fn bsearch "const void *key" "const void *base" "size_t nmemb" "size_t size" "int (*compar) (const void *, const void *)"
48.Sh DESCRIPTION
49The
50.Fn bsearch
51function searches an array of
52.Fa nmemb
53objects, the initial member of which is
54pointed to by
55.Fa base ,
56for a member that matches the object pointed to by
57.Fa key .
58The size of each member of the array is specified by
59.Fa size .
60.Pp
61The contents of the array should be in ascending sorted order according
62to the comparison function referenced by
63.Fa compar .
64The
65.Fa compar
66routine
67is expected to have
68two arguments which point to the
69.Fa key
70object and to an array member, in that order, and should return an integer
71less than, equal to, or greater than zero if the
72.Fa key
73object is found, respectively, to be less than, to match, or be
74greater than the array member.
75.Sh RETURN VALUES
76The
77.Fn bsearch
78function returns a pointer to a matching member of the array, or a null
79pointer if no match is found.
80If two members compare as equal, which member is matched is unspecified.
81.Sh SEE ALSO
82.Xr db 3 ,
83.Xr lsearch 3 ,
84.Xr qsort 3 ,
85.Xr tsearch 3
86.Sh STANDARDS
87The
88.Fn bsearch
89function conforms to
90.St -ansiC .
diff --git a/src/lib/libc/stdlib/bsearch.c b/src/lib/libc/stdlib/bsearch.c
new file mode 100644
index 0000000000..eeef9bffc6
--- /dev/null
+++ b/src/lib/libc/stdlib/bsearch.c
@@ -0,0 +1,79 @@
1/*
2 * Copyright (c) 1990 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: bsearch.c,v 1.2 1996/08/19 08:33:26 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39
40/*
41 * Perform a binary search.
42 *
43 * The code below is a bit sneaky. After a comparison fails, we
44 * divide the work in half by moving either left or right. If lim
45 * is odd, moving left simply involves halving lim: e.g., when lim
46 * is 5 we look at item 2, so we change lim to 2 so that we will
47 * look at items 0 & 1. If lim is even, the same applies. If lim
48 * is odd, moving right again involes halving lim, this time moving
49 * the base up one item past p: e.g., when lim is 5 we change base
50 * to item 3 and make lim 2 so that we will look at items 3 and 4.
51 * If lim is even, however, we have to shrink it by one before
52 * halving: e.g., when lim is 4, we still looked at item 2, so we
53 * have to make lim 3, then halve, obtaining 1, so that we will only
54 * look at item 3.
55 */
56void *
57bsearch(key, base0, nmemb, size, compar)
58 register const void *key;
59 const void *base0;
60 size_t nmemb;
61 register size_t size;
62 register int (*compar) __P((const void *, const void *));
63{
64 register const char *base = base0;
65 register int lim, cmp;
66 register const void *p;
67
68 for (lim = nmemb; lim != 0; lim >>= 1) {
69 p = base + (lim >> 1) * size;
70 cmp = (*compar)(key, p);
71 if (cmp == 0)
72 return ((void *)p);
73 if (cmp > 0) { /* key > p: move right */
74 base = (char *)p + size;
75 lim--;
76 } /* else move left */
77 }
78 return (NULL);
79}
diff --git a/src/lib/libc/stdlib/calloc.3 b/src/lib/libc/stdlib/calloc.3
new file mode 100644
index 0000000000..13a912169c
--- /dev/null
+++ b/src/lib/libc/stdlib/calloc.3
@@ -0,0 +1,70 @@
1.\" Copyright (c) 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: calloc.3,v 1.3 1996/12/10 09:06:10 deraadt Exp $
37.\"
38.Dd June 29, 1991
39.Dt CALLOC 3
40.Os
41.Sh NAME
42.Nm calloc
43.Nd allocate clean memory (zero initialized space)
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft void *
47.Fn calloc "size_t nmemb" "size_t size"
48.Sh DESCRIPTION
49The
50.Fn calloc
51function allocates space for an array of
52.Fa nmemb
53objects, each of whose size is
54.Fa size .
55The space is initialized to all bits zero.
56.Sh RETURN VALUES
57The
58.Fn calloc
59function returns
60a pointer to
61the allocated space if successful; otherwise a null pointer is returned.
62.Sh SEE ALSO
63.Xr malloc 3 ,
64.Xr realloc 3 ,
65.Xr free 3
66.Sh STANDARDS
67The
68.Fn calloc
69function conforms to
70.St -ansiC .
diff --git a/src/lib/libc/stdlib/calloc.c b/src/lib/libc/stdlib/calloc.c
new file mode 100644
index 0000000000..a2c4f84493
--- /dev/null
+++ b/src/lib/libc/stdlib/calloc.c
@@ -0,0 +1,53 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: calloc.c,v 1.3 1996/08/20 17:42:33 downsj Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39#include <string.h>
40
41void *
42calloc(num, size)
43 size_t num;
44 register size_t size;
45{
46 register void *p;
47
48 size *= num;
49 p = malloc(size);
50 if (p)
51 memset(p, '\0', size);
52 return(p);
53}
diff --git a/src/lib/libc/stdlib/cfree.c b/src/lib/libc/stdlib/cfree.c
new file mode 100644
index 0000000000..3af32039a9
--- /dev/null
+++ b/src/lib/libc/stdlib/cfree.c
@@ -0,0 +1,49 @@
1/* $OpenBSD: cfree.c,v 1.1 1996/08/21 03:47:22 tholo Exp $ */
2
3/*
4 * Copyright (c) 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by SigmaSoft, Th. Lockert.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#if defined(LIBC_SCCS) && !defined(lint)
34static char rcsid[] = "$OpenBSD: cfree.c,v 1.1 1996/08/21 03:47:22 tholo Exp $";
35#endif /* LIBC_SCCS and not lint */
36
37#include <sys/cdefs.h>
38
39#ifdef __indr_reference
40__indr_reference(free, cfree);
41#else
42
43void
44cfree(p)
45 void *p;
46{
47 free(p);
48}
49#endif
diff --git a/src/lib/libc/stdlib/div.3 b/src/lib/libc/stdlib/div.3
new file mode 100644
index 0000000000..0d8c56d86b
--- /dev/null
+++ b/src/lib/libc/stdlib/div.3
@@ -0,0 +1,69 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $OpenBSD: div.3,v 1.2 1996/08/19 08:33:28 tholo Exp $
35.\"
36.Dd April 19, 1991
37.Dt DIV 3
38.Os
39.Sh NAME
40.Nm div
41.Nd return quotient and remainder from division
42.Sh SYNOPSIS
43.Fd #include <stdlib.h>
44.Ft div_t
45.Fn div "int num" "int denom"
46.Sh DESCRIPTION
47The
48.Fn div
49function
50computes the value
51.Fa num/denom
52and returns the quotient and remainder in a structure named
53.Fa div_t
54that contains two
55.Em int
56members named
57.Fa quot
58and
59.Fa rem .
60.Sh SEE ALSO
61.Xr ldiv 3 ,
62.Xr qdiv 3 ,
63.Xr math 3
64.Sh STANDARDS
65The
66.Fn div
67function
68conforms to
69.St -ansiC .
diff --git a/src/lib/libc/stdlib/div.c b/src/lib/libc/stdlib/div.c
new file mode 100644
index 0000000000..c1fae29008
--- /dev/null
+++ b/src/lib/libc/stdlib/div.c
@@ -0,0 +1,79 @@
1/*
2 * Copyright (c) 1990 Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: div.c,v 1.2 1996/08/19 08:33:29 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <stdlib.h> /* div_t */
42
43div_t
44div(num, denom)
45 int num, denom;
46{
47 div_t r;
48
49 r.quot = num / denom;
50 r.rem = num % denom;
51 /*
52 * The ANSI standard says that |r.quot| <= |n/d|, where
53 * n/d is to be computed in infinite precision. In other
54 * words, we should always truncate the quotient towards
55 * 0, never -infinity.
56 *
57 * Machine division and remainer may work either way when
58 * one or both of n or d is negative. If only one is
59 * negative and r.quot has been truncated towards -inf,
60 * r.rem will have the same sign as denom and the opposite
61 * sign of num; if both are negative and r.quot has been
62 * truncated towards -inf, r.rem will be positive (will
63 * have the opposite sign of num). These are considered
64 * `wrong'.
65 *
66 * If both are num and denom are positive, r will always
67 * be positive.
68 *
69 * This all boils down to:
70 * if num >= 0, but r.rem < 0, we got the wrong answer.
71 * In that case, to get the right answer, add 1 to r.quot and
72 * subtract denom from r.rem.
73 */
74 if (num >= 0 && r.rem < 0) {
75 r.quot++;
76 r.rem -= denom;
77 }
78 return (r);
79}
diff --git a/src/lib/libc/stdlib/drand48.c b/src/lib/libc/stdlib/drand48.c
new file mode 100644
index 0000000000..02886d5b62
--- /dev/null
+++ b/src/lib/libc/stdlib/drand48.c
@@ -0,0 +1,26 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 */
13
14#if defined(LIBC_SCCS) && !defined(lint)
15static char rcsid[] = "$OpenBSD: drand48.c,v 1.2 1996/08/19 08:33:29 tholo Exp $";
16#endif /* LIBC_SCCS and not lint */
17
18#include "rand48.h"
19
20extern unsigned short __rand48_seed[3];
21
22double
23drand48(void)
24{
25 return erand48(__rand48_seed);
26}
diff --git a/src/lib/libc/stdlib/erand48.c b/src/lib/libc/stdlib/erand48.c
new file mode 100644
index 0000000000..b92dacffcc
--- /dev/null
+++ b/src/lib/libc/stdlib/erand48.c
@@ -0,0 +1,27 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 */
13
14#if defined(LIBC_SCCS) && !defined(lint)
15static char rcsid[] = "$OpenBSD: erand48.c,v 1.2 1996/08/19 08:33:29 tholo Exp $";
16#endif /* LIBC_SCCS and not lint */
17
18#include "rand48.h"
19
20double
21erand48(unsigned short xseed[3])
22{
23 __dorand48(xseed);
24 return ldexp((double) xseed[0], -48) +
25 ldexp((double) xseed[1], -32) +
26 ldexp((double) xseed[2], -16);
27}
diff --git a/src/lib/libc/stdlib/exit.3 b/src/lib/libc/stdlib/exit.3
new file mode 100644
index 0000000000..326c5539a8
--- /dev/null
+++ b/src/lib/libc/stdlib/exit.3
@@ -0,0 +1,83 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: exit.3,v 1.3 1999/02/27 21:55:55 deraadt Exp $
37.\"
38.Dd June 29, 1991
39.Dt EXIT 3
40.Os
41.Sh NAME
42.Nm exit
43.Nd perform normal program termination
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft void
47.Fn exit "int status"
48.Sh DESCRIPTION
49.Fn exit
50terminates a process.
51.Pp
52Before termination it performs the following functions in the
53order listed:
54.Bl -enum -offset indent
55.It
56Call the functions registered with the
57.Xr atexit 3
58function, in the reverse order of their registration.
59.It
60Flush all open output streams.
61.It
62Close all open streams.
63.It
64Unlink all files created with the
65.Xr tmpfile 3
66function.
67.El
68.Sh RETURN VALUES
69The
70.Fn exit
71function
72never returns.
73.Sh SEE ALSO
74.Xr _exit 2 ,
75.Xr atexit 3 ,
76.Xr intro 3 ,
77.Xr tmpfile 3
78.Sh STANDARDS
79The
80.Fn exit
81function
82conforms to
83.St -ansiC .
diff --git a/src/lib/libc/stdlib/exit.c b/src/lib/libc/stdlib/exit.c
new file mode 100644
index 0000000000..bc7fd395ca
--- /dev/null
+++ b/src/lib/libc/stdlib/exit.c
@@ -0,0 +1,69 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: exit.c,v 1.3 1998/11/20 11:18:50 d Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39#include <unistd.h>
40#include "atexit.h"
41
42void (*__cleanup)();
43
44/*
45 * This variable is zero until a process has created a thread.
46 * It is used to avoid calling locking functions in libc when they
47 * are not required. By default, libc is intended to be(come)
48 * thread-safe, but without a (significant) penalty to non-threaded
49 * processes.
50 */
51int __isthreaded = 0;
52
53/*
54 * Exit, flushing stdio buffers if necessary.
55 */
56void
57exit(status)
58 int status;
59{
60 register struct atexit *p;
61 register int n;
62
63 for (p = __atexit; p; p = p->next)
64 for (n = p->ind; --n >= 0;)
65 (*p->fns[n])();
66 if (__cleanup)
67 (*__cleanup)();
68 _exit(status);
69}
diff --git a/src/lib/libc/stdlib/getenv.3 b/src/lib/libc/stdlib/getenv.3
new file mode 100644
index 0000000000..ed89ccbe7d
--- /dev/null
+++ b/src/lib/libc/stdlib/getenv.3
@@ -0,0 +1,155 @@
1.\" Copyright (c) 1988, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: getenv.3,v 1.3 1998/11/10 22:27:30 espie Exp $
37.\"
38.Dd December 11, 1993
39.Dt GETENV 3
40.Os
41.Sh NAME
42.Nm getenv ,
43.Nm putenv ,
44.Nm setenv ,
45.Nm unsetenv
46.Nd environment variable functions
47.Sh SYNOPSIS
48.Fd #include <stdlib.h>
49.Ft char *
50.Fn getenv "const char *name"
51.Ft int
52.Fn setenv "const char *name" "const char *value" "int overwrite"
53.Ft int
54.Fn putenv "const char *string"
55.Ft void
56.Fn unsetenv "const char *name"
57.Sh DESCRIPTION
58These functions set, unset and fetch environment variables from the
59host
60.Em environment list .
61For compatibility with differing environment conventions,
62the given arguments
63.Ar name
64and
65.Ar value
66may be appended and prepended,
67respectively,
68with an equal sign
69.Dq Li \&= .
70.Pp
71The
72.Fn getenv
73function obtains the current value of the environment variable,
74.Ar name .
75If the variable
76.Ar name
77is not in the current environment,
78a null pointer is returned.
79.Pp
80The
81.Fn setenv
82function inserts or resets the environment variable
83.Ar name
84in the current environment list.
85If the variable
86.Ar name
87does not exist in the list,
88it is inserted with the given
89.Ar value.
90If the variable does exist, the argument
91.Ar overwrite
92is tested; if
93.Ar overwrite is
94zero, the
95variable is not reset, otherwise it is reset
96to the given
97.Ar value .
98.Pp
99The
100.Fn putenv
101function takes an argument of the form ``name=value'' and is
102equivalent to:
103.Bd -literal -offset indent
104setenv(name, value, 1);
105.Ed
106.Pp
107The
108.Fn unsetenv
109function
110deletes all instances of the variable name pointed to by
111.Fa name
112from the list.
113.Sh RETURN VALUES
114The functions
115.Fn setenv
116and
117.Fn putenv
118return zero if successful; otherwise the global variable
119.Va errno
120is set to indicate the error and a
121\-1 is returned.
122.Pp
123If
124.Fn getenv
125is succesful, the string returned should be considered read-only.
126.Sh ERRORS
127.Bl -tag -width [ENOMEM]
128.It Bq Er ENOMEM
129The function
130.Fn setenv
131or
132.Fn putenv
133failed because they were unable to allocate memory for the environment.
134.El
135.Sh SEE ALSO
136.Xr csh 1 ,
137.Xr sh 1 ,
138.Xr execve 2 ,
139.Xr environ 7
140.Sh STANDARDS
141The
142.Fn getenv
143function conforms to
144.St -ansiC .
145.Sh HISTORY
146The functions
147.Fn setenv
148and
149.Fn unsetenv
150appeared in
151.At v7 .
152The
153.Fn putenv
154function appeared in
155.Bx 4.3 Reno .
diff --git a/src/lib/libc/stdlib/getenv.c b/src/lib/libc/stdlib/getenv.c
new file mode 100644
index 0000000000..4db86df915
--- /dev/null
+++ b/src/lib/libc/stdlib/getenv.c
@@ -0,0 +1,89 @@
1/*
2 * Copyright (c) 1987, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: getenv.c,v 1.4 1998/07/16 18:02:33 deraadt Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39#include <string.h>
40
41/*
42 * __findenv --
43 * Returns pointer to value associated with name, if any, else NULL.
44 * Sets offset to be the offset of the name/value combination in the
45 * environmental array, for use by setenv(3) and unsetenv(3).
46 * Explicitly removes '=' in argument name.
47 *
48 * This routine *should* be a static; don't use it.
49 */
50char *
51__findenv(name, offset)
52 register const char *name;
53 int *offset;
54{
55 extern char **environ;
56 register int len, i;
57 register const char *np;
58 register char **p, *cp;
59
60 if (name == NULL || environ == NULL)
61 return (NULL);
62 for (np = name; *np && *np != '='; ++np)
63 ;
64 len = np - name;
65 for (p = environ; (cp = *p) != NULL; ++p) {
66 for (np = name, i = len; i && *cp; i--)
67 if (*cp++ != *np++)
68 break;
69 if (i == 0 && *cp++ == '=') {
70 *offset = p - environ;
71 return (cp);
72 }
73 }
74 return (NULL);
75}
76
77/*
78 * getenv --
79 * Returns ptr to value associated with name, if any, else NULL.
80 */
81char *
82getenv(name)
83 const char *name;
84{
85 int offset;
86 char *__findenv();
87
88 return(__findenv(name, &offset));
89}
diff --git a/src/lib/libc/stdlib/getopt.3 b/src/lib/libc/stdlib/getopt.3
new file mode 100644
index 0000000000..4340ff54fd
--- /dev/null
+++ b/src/lib/libc/stdlib/getopt.3
@@ -0,0 +1,261 @@
1.\" Copyright (c) 1988, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" $OpenBSD: getopt.3,v 1.6 1998/05/05 19:36:03 deraadt Exp $
33.\"
34.Dd April 19, 1994
35.Dt GETOPT 3
36.Os BSD 4.3
37.Sh NAME
38.Nm getopt
39.Nd get option character from command line argument list
40.Sh SYNOPSIS
41.Fd #include <unistd.h>
42.Vt extern char *optarg;
43.Vt extern int optind;
44.Vt extern int optopt;
45.Vt extern int opterr;
46.Vt extern int optreset;
47.Ft int
48.Fn getopt "int argc" "char * const *argv" "const char *optstring"
49.Sh DESCRIPTION
50The
51.Fn getopt
52function incrementally parses a command line argument list
53.Fa argv
54and returns the next
55.Em known
56option character.
57An option character is
58.Em known
59if it has been specified in the string of accepted option characters,
60.Fa optstring .
61.Pp
62The option string
63.Fa optstring
64may contain the following elements: individual characters, and
65characters followed by a colon to indicate an option argument
66is to follow.
67For example, an option string
68.Li "\&""x""
69recognizes an option
70.Dq Fl x ,
71and an option string
72.Li "\&""x:""
73recognizes an option and argument
74.Dq Fl x Ar argument .
75It does not matter to
76.Fn getopt
77if a following argument has leading white space.
78.Pp
79On return from
80.Fn getopt ,
81.Va optarg
82points to an option argument, if it is anticipated,
83and the variable
84.Va optind
85contains the index to the next
86.Fa argv
87argument for a subsequent call
88to
89.Fn getopt .
90The variable
91.Va optopt
92saves the last
93.Em known
94option character returned by
95.Fn getopt .
96.Pp
97The variable
98.Va opterr
99and
100.Va optind
101are both initialized to 1.
102The
103.Va optind
104variable may be set to another value before a set of calls to
105.Fn getopt
106in order to skip over more or less argv entries.
107.Pp
108In order to use
109.Fn getopt
110to evaluate multiple sets of arguments, or to evaluate a single set of
111arguments multiple times,
112the variable
113.Va optreset
114must be set to 1 before the second and each additional set of calls to
115.Fn getopt ,
116and the variable
117.Va optind
118must be reinitialized.
119.Pp
120The
121.Fn getopt
122function
123returns \-1
124when the argument list is exhausted, or a non-recognized
125option is encountered.
126The interpretation of options in the argument list may be cancelled
127by the option
128.Ql --
129(double dash) which causes
130.Fn getopt
131to signal the end of argument processing and returns \-1.
132When all options have been processed (i.e., up to the first non-option
133argument),
134.Fn getopt
135returns \-1.
136.Sh DIAGNOSTICS
137If the
138.Fn getopt
139function encounters a character not found in the string
140.Va optstring
141or detects
142a missing option argument it writes an error message to
143.Em stderr
144and returns
145.Ql ? .
146Setting
147.Va opterr
148to a zero will disable these error messages.
149If
150.Va optstring
151has a leading
152.Ql \&:
153then a missing option argument causes a
154.Ql \&:
155to be returned in addition to suppressing any error messages.
156.Pp
157Option arguments are allowed to begin with
158.Dq Li \- ;
159this is reasonable but
160reduces the amount of error checking possible.
161.Sh EXTENSIONS
162The
163.Va optreset
164variable was added to make it possible to call the
165.Fn getopt
166function multiple times.
167This is an extension to the
168.St -p1003.2
169specification.
170.Sh EXAMPLE
171.Bd -literal -compact
172extern char *optarg;
173extern int optind;
174int bflag, ch, fd;
175
176bflag = 0;
177while ((ch = getopt(argc, argv, "bf:")) != -1) {
178 switch (ch) {
179 case 'b':
180 bflag = 1;
181 break;
182 case 'f':
183 if ((fd = open(optarg, O_RDONLY, 0)) < 0) {
184 (void)fprintf(stderr,
185 "myname: %s: %s\en", optarg, strerror(errno));
186 exit(1);
187 }
188 break;
189 case '?':
190 default:
191 usage();
192 }
193}
194argc -= optind;
195argv += optind;
196.Ed
197.Sh HISTORY
198The
199.Fn getopt
200function appeared
201.Bx 4.3 .
202.Sh BUGS
203The
204.Fn getopt
205function was once specified to return
206.Dv EOF
207instead of \-1.
208This was changed by
209.St -p1003.2-92
210to decouple
211.Fn getopt
212from
213.Pa <stdio.h> .
214.Pp
215A single dash
216.Dq Li -
217may be specified as a character in
218.Fa optstring ,
219however it should
220.Em never
221have an argument associated with it.
222This allows
223.Fn getopt
224to be used with programs that expect
225.Dq Li -
226as an option flag.
227This practice is wrong, and should not be used in any current development.
228It is provided for backward compatibility
229.Em only .
230By default, a single dash causes
231.Fn getopt
232to return \-1.
233This is, we believe, compatible with System V.
234.Pp
235It is also possible to handle digits as option letters.
236This allows
237.Fn getopt
238to be used with programs that expect a number
239.Pq Dq Li \&-\&3
240as an option.
241This practice is wrong, and should not be used in any current development.
242It is provided for backward compatibility
243.Em only .
244The following code fragment works in most cases.
245.Bd -literal -offset indent
246int length;
247char *p;
248
249while ((c = getopt(argc, argv, "0123456789")) != -1)
250 switch (c) {
251 case '0': case '1': case '2': case '3': case '4':
252 case '5': case '6': case '7': case '8': case '9':
253 p = argv[optind - 1];
254 if (p[0] == '-' && p[1] == ch && !p[2])
255 length = atoi(++p);
256 else
257 length = atoi(argv[optind] + 1);
258 break;
259 }
260}
261.Ed
diff --git a/src/lib/libc/stdlib/getopt.c b/src/lib/libc/stdlib/getopt.c
new file mode 100644
index 0000000000..b7f6163662
--- /dev/null
+++ b/src/lib/libc/stdlib/getopt.c
@@ -0,0 +1,117 @@
1/*
2 * Copyright (c) 1987, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: getopt.c,v 1.2 1996/08/19 08:33:32 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdio.h>
39#include <stdlib.h>
40#include <string.h>
41
42int opterr = 1, /* if error message should be printed */
43 optind = 1, /* index into parent argv vector */
44 optopt, /* character checked for validity */
45 optreset; /* reset getopt */
46char *optarg; /* argument associated with option */
47
48#define BADCH (int)'?'
49#define BADARG (int)':'
50#define EMSG ""
51
52/*
53 * getopt --
54 * Parse argc/argv argument vector.
55 */
56int
57getopt(nargc, nargv, ostr)
58 int nargc;
59 char * const *nargv;
60 const char *ostr;
61{
62 extern char *__progname;
63 static char *place = EMSG; /* option letter processing */
64 char *oli; /* option letter list index */
65
66 if (optreset || !*place) { /* update scanning pointer */
67 optreset = 0;
68 if (optind >= nargc || *(place = nargv[optind]) != '-') {
69 place = EMSG;
70 return (-1);
71 }
72 if (place[1] && *++place == '-') { /* found "--" */
73 ++optind;
74 place = EMSG;
75 return (-1);
76 }
77 } /* option letter okay? */
78 if ((optopt = (int)*place++) == (int)':' ||
79 !(oli = strchr(ostr, optopt))) {
80 /*
81 * if the user didn't specify '-' as an option,
82 * assume it means -1.
83 */
84 if (optopt == (int)'-')
85 return (-1);
86 if (!*place)
87 ++optind;
88 if (opterr && *ostr != ':')
89 (void)fprintf(stderr,
90 "%s: illegal option -- %c\n", __progname, optopt);
91 return (BADCH);
92 }
93 if (*++oli != ':') { /* don't need argument */
94 optarg = NULL;
95 if (!*place)
96 ++optind;
97 }
98 else { /* need an argument */
99 if (*place) /* no white space */
100 optarg = place;
101 else if (nargc <= ++optind) { /* no arg */
102 place = EMSG;
103 if (*ostr == ':')
104 return (BADARG);
105 if (opterr)
106 (void)fprintf(stderr,
107 "%s: option requires an argument -- %c\n",
108 __progname, optopt);
109 return (BADCH);
110 }
111 else /* white space */
112 optarg = nargv[optind];
113 place = EMSG;
114 ++optind;
115 }
116 return (optopt); /* dump back option letter */
117}
diff --git a/src/lib/libc/stdlib/getsubopt.3 b/src/lib/libc/stdlib/getsubopt.3
new file mode 100644
index 0000000000..8acc91bdd1
--- /dev/null
+++ b/src/lib/libc/stdlib/getsubopt.3
@@ -0,0 +1,148 @@
1.\" $OpenBSD: getsubopt.3,v 1.2 1998/06/15 17:55:07 mickey Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" @(#)getsubopt.3 8.1 (Berkeley) 6/9/93
35.\"
36.Dd June 9, 1993
37.Dt GETSUBOPT 3
38.Os
39.Sh NAME
40.Nm getsubopt
41.Nd get sub options from an argument
42.Sh SYNOPSIS
43.Fd #include <stdlib.h>
44.Vt extern char *suboptarg
45.Ft int
46.Fn getsubopt "char **optionp" "char * const *tokens" "char **valuep"
47.Sh DESCRIPTION
48The
49.Fn getsubopt
50function
51parses a string containing tokens delimited by one or more tab, space or
52comma
53.Pq Ql \&,
54characters.
55It is intended for use in parsing groups of option arguments provided
56as part of a utility command line.
57.Pp
58The argument
59.Fa optionp
60is a pointer to a pointer to the string.
61The argument
62.Fa tokens
63is a pointer to a
64.Dv NULL Ns -terminated
65array of pointers to strings.
66.Pp
67The
68.Fn getsubopt
69function
70returns the zero-based offset of the pointer in the
71.Fa tokens
72array referencing a string which matches the first token
73in the string, or, \-1 if the string contains no tokens or
74.Fa tokens
75does not contain a matching string.
76.Pp
77If the token is of the form ``name=value'', the location referenced by
78.Fa valuep
79will be set to point to the start of the ``value'' portion of the token.
80.Pp
81On return from
82.Fn getsubopt ,
83.Fa optionp
84will be set to point to the start of the next token in the string,
85or the null at the end of the string if no more tokens are present.
86The external variable
87.Fa suboptarg
88will be set to point to the start of the current token, or
89.Dv NULL
90if no
91tokens were present.
92The argument
93.Fa valuep
94will be set to point to the ``value'' portion of the token, or
95.Dv NULL
96if no ``value'' portion was present.
97.Sh EXAMPLE
98.Bd -literal -compact
99char *tokens[] = {
100 #define ONE 0
101 "one",
102 #define TWO 1
103 "two",
104 NULL
105};
106
107\&...
108
109extern char *optarg, *suboptarg;
110char *options, *value;
111
112while ((ch = getopt(argc, argv, "ab:")) != \-1) {
113 switch(ch) {
114 case 'a':
115 /* process ``a'' option */
116 break;
117 case 'b':
118 options = optarg;
119 while (*options) {
120 switch(getsubopt(&options, tokens, &value)) {
121 case ONE:
122 /* process ``one'' sub option */
123 break;
124 case TWO:
125 /* process ``two'' sub option */
126 if (!value)
127 error("no value for two");
128 i = atoi(value);
129 break;
130 case \-1:
131 if (suboptarg)
132 error("illegal sub option %s",
133 suboptarg);
134 else
135 error("missing sub option");
136 break;
137 }
138 break;
139 }
140.Ed
141.Sh SEE ALSO
142.Xr getopt 3 ,
143.Xr strsep 3
144.Sh HISTORY
145The
146.Fn getsubopt
147function first appeared in
148.Bx 4.4 .
diff --git a/src/lib/libc/stdlib/getsubopt.c b/src/lib/libc/stdlib/getsubopt.c
new file mode 100644
index 0000000000..1667a31d7d
--- /dev/null
+++ b/src/lib/libc/stdlib/getsubopt.c
@@ -0,0 +1,106 @@
1/* $OpenBSD: getsubopt.c,v 1.1 1997/08/20 04:02:17 millert Exp $ */
2
3/*-
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#ifndef lint
37#if 0
38static char sccsid[] = "@(#)getsubopt.c 8.1 (Berkeley) 6/4/93";
39#else
40static char rcsid[] = "$OpenBSD: getsubopt.c,v 1.1 1997/08/20 04:02:17 millert Exp $";
41#endif
42#endif /* not lint */
43
44#include <unistd.h>
45#include <stdlib.h>
46#include <string.h>
47
48/*
49 * The SVID interface to getsubopt provides no way of figuring out which
50 * part of the suboptions list wasn't matched. This makes error messages
51 * tricky... The extern variable suboptarg is a pointer to the token
52 * which didn't match.
53 */
54char *suboptarg;
55
56int
57getsubopt(optionp, tokens, valuep)
58 register char **optionp, **valuep;
59 register char * const *tokens;
60{
61 register int cnt;
62 register char *p;
63
64 suboptarg = *valuep = NULL;
65
66 if (!optionp || !*optionp)
67 return(-1);
68
69 /* skip leading white-space, commas */
70 for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
71
72 if (!*p) {
73 *optionp = p;
74 return(-1);
75 }
76
77 /* save the start of the token, and skip the rest of the token. */
78 for (suboptarg = p;
79 *++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';);
80
81 if (*p) {
82 /*
83 * If there's an equals sign, set the value pointer, and
84 * skip over the value part of the token. Terminate the
85 * token.
86 */
87 if (*p == '=') {
88 *p = '\0';
89 for (*valuep = ++p;
90 *p && *p != ',' && *p != ' ' && *p != '\t'; ++p);
91 if (*p)
92 *p++ = '\0';
93 } else
94 *p++ = '\0';
95 /* Skip any whitespace or commas after this token. */
96 for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
97 }
98
99 /* set optionp for next round. */
100 *optionp = p;
101
102 for (cnt = 0; *tokens; ++tokens, ++cnt)
103 if (!strcmp(suboptarg, *tokens))
104 return(cnt);
105 return(-1);
106}
diff --git a/src/lib/libc/stdlib/heapsort.c b/src/lib/libc/stdlib/heapsort.c
new file mode 100644
index 0000000000..e3e4392e05
--- /dev/null
+++ b/src/lib/libc/stdlib/heapsort.c
@@ -0,0 +1,183 @@
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Ronnie Kon at Mindcraft Inc., Kevin Lew and Elmer Yglesias.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: heapsort.c,v 1.2 1996/08/19 08:33:32 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <sys/types.h>
42#include <errno.h>
43#include <stdlib.h>
44
45/*
46 * Swap two areas of size number of bytes. Although qsort(3) permits random
47 * blocks of memory to be sorted, sorting pointers is almost certainly the
48 * common case (and, were it not, could easily be made so). Regardless, it
49 * isn't worth optimizing; the SWAP's get sped up by the cache, and pointer
50 * arithmetic gets lost in the time required for comparison function calls.
51 */
52#define SWAP(a, b, count, size, tmp) { \
53 count = size; \
54 do { \
55 tmp = *a; \
56 *a++ = *b; \
57 *b++ = tmp; \
58 } while (--count); \
59}
60
61/* Copy one block of size size to another. */
62#define COPY(a, b, count, size, tmp1, tmp2) { \
63 count = size; \
64 tmp1 = a; \
65 tmp2 = b; \
66 do { \
67 *tmp1++ = *tmp2++; \
68 } while (--count); \
69}
70
71/*
72 * Build the list into a heap, where a heap is defined such that for
73 * the records K1 ... KN, Kj/2 >= Kj for 1 <= j/2 <= j <= N.
74 *
75 * There two cases. If j == nmemb, select largest of Ki and Kj. If
76 * j < nmemb, select largest of Ki, Kj and Kj+1.
77 */
78#define CREATE(initval, nmemb, par_i, child_i, par, child, size, count, tmp) { \
79 for (par_i = initval; (child_i = par_i * 2) <= nmemb; \
80 par_i = child_i) { \
81 child = base + child_i * size; \
82 if (child_i < nmemb && compar(child, child + size) < 0) { \
83 child += size; \
84 ++child_i; \
85 } \
86 par = base + par_i * size; \
87 if (compar(child, par) <= 0) \
88 break; \
89 SWAP(par, child, count, size, tmp); \
90 } \
91}
92
93/*
94 * Select the top of the heap and 'heapify'. Since by far the most expensive
95 * action is the call to the compar function, a considerable optimization
96 * in the average case can be achieved due to the fact that k, the displaced
97 * elememt, is ususally quite small, so it would be preferable to first
98 * heapify, always maintaining the invariant that the larger child is copied
99 * over its parent's record.
100 *
101 * Then, starting from the *bottom* of the heap, finding k's correct place,
102 * again maintianing the invariant. As a result of the invariant no element
103 * is 'lost' when k is assigned its correct place in the heap.
104 *
105 * The time savings from this optimization are on the order of 15-20% for the
106 * average case. See Knuth, Vol. 3, page 158, problem 18.
107 *
108 * XXX Don't break the #define SELECT line, below. Reiser cpp gets upset.
109 */
110#define SELECT(par_i, child_i, nmemb, par, child, size, k, count, tmp1, tmp2) { \
111 for (par_i = 1; (child_i = par_i * 2) <= nmemb; par_i = child_i) { \
112 child = base + child_i * size; \
113 if (child_i < nmemb && compar(child, child + size) < 0) { \
114 child += size; \
115 ++child_i; \
116 } \
117 par = base + par_i * size; \
118 COPY(par, child, count, size, tmp1, tmp2); \
119 } \
120 for (;;) { \
121 child_i = par_i; \
122 par_i = child_i / 2; \
123 child = base + child_i * size; \
124 par = base + par_i * size; \
125 if (child_i == 1 || compar(k, par) < 0) { \
126 COPY(child, k, count, size, tmp1, tmp2); \
127 break; \
128 } \
129 COPY(child, par, count, size, tmp1, tmp2); \
130 } \
131}
132
133/*
134 * Heapsort -- Knuth, Vol. 3, page 145. Runs in O (N lg N), both average
135 * and worst. While heapsort is faster than the worst case of quicksort,
136 * the BSD quicksort does median selection so that the chance of finding
137 * a data set that will trigger the worst case is nonexistent. Heapsort's
138 * only advantage over quicksort is that it requires little additional memory.
139 */
140int
141heapsort(vbase, nmemb, size, compar)
142 void *vbase;
143 size_t nmemb, size;
144 int (*compar) __P((const void *, const void *));
145{
146 register int cnt, i, j, l;
147 register char tmp, *tmp1, *tmp2;
148 char *base, *k, *p, *t;
149
150 if (nmemb <= 1)
151 return (0);
152
153 if (!size) {
154 errno = EINVAL;
155 return (-1);
156 }
157
158 if ((k = malloc(size)) == NULL)
159 return (-1);
160
161 /*
162 * Items are numbered from 1 to nmemb, so offset from size bytes
163 * below the starting address.
164 */
165 base = (char *)vbase - size;
166
167 for (l = nmemb / 2 + 1; --l;)
168 CREATE(l, nmemb, i, j, t, p, size, cnt, tmp);
169
170 /*
171 * For each element of the heap, save the largest element into its
172 * final slot, save the displaced element (k), then recreate the
173 * heap.
174 */
175 while (nmemb > 1) {
176 COPY(k, base + nmemb * size, cnt, size, tmp1, tmp2);
177 COPY(base + nmemb * size, base + size, cnt, size, tmp1, tmp2);
178 --nmemb;
179 SELECT(i, j, nmemb, t, p, size, k, cnt, tmp1, tmp2);
180 }
181 free(k);
182 return (0);
183}
diff --git a/src/lib/libc/stdlib/jrand48.c b/src/lib/libc/stdlib/jrand48.c
new file mode 100644
index 0000000000..99cddb71e5
--- /dev/null
+++ b/src/lib/libc/stdlib/jrand48.c
@@ -0,0 +1,25 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 */
13
14#if defined(LIBC_SCCS) && !defined(lint)
15static char rcsid[] = "$OpenBSD: jrand48.c,v 1.2 1996/08/19 08:33:33 tholo Exp $";
16#endif /* LIBC_SCCS and not lint */
17
18#include "rand48.h"
19
20long
21jrand48(unsigned short xseed[3])
22{
23 __dorand48(xseed);
24 return ((long) xseed[2] << 16) + (long) xseed[1];
25}
diff --git a/src/lib/libc/stdlib/l64a.c b/src/lib/libc/stdlib/l64a.c
new file mode 100644
index 0000000000..4e99391254
--- /dev/null
+++ b/src/lib/libc/stdlib/l64a.c
@@ -0,0 +1,46 @@
1/*
2 * Written by J.T. Conklin <jtc@netbsd.org>.
3 * Public domain.
4 */
5
6#if defined(LIBC_SCCS) && !defined(lint)
7static char *rcsid = "$OpenBSD: l64a.c,v 1.3 1997/08/17 22:58:34 millert Exp $";
8#endif /* LIBC_SCCS and not lint */
9
10#include <errno.h>
11#include <stdlib.h>
12
13char *
14l64a(value)
15 long value;
16{
17 static char buf[8];
18 char *s = buf;
19 int digit;
20 int i;
21
22 if (value < 0) {
23 errno = EINVAL;
24 return(NULL);
25 }
26
27 for (i = 0; value != 0 && i < 6; i++) {
28 digit = value & 0x3f;
29
30 if (digit < 2)
31 *s = digit + '.';
32 else if (digit < 12)
33 *s = digit + '0' - 2;
34 else if (digit < 38)
35 *s = digit + 'A' - 12;
36 else
37 *s = digit + 'a' - 38;
38
39 value >>= 6;
40 s++;
41 }
42
43 *s = '\0';
44
45 return(buf);
46}
diff --git a/src/lib/libc/stdlib/labs.3 b/src/lib/libc/stdlib/labs.3
new file mode 100644
index 0000000000..05eae329df
--- /dev/null
+++ b/src/lib/libc/stdlib/labs.3
@@ -0,0 +1,66 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: labs.3,v 1.2 1996/08/19 08:33:34 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt LABS 3
40.Os
41.Sh NAME
42.Nm labs
43.Nd return the absolute value of a long integer
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft long
47.Fn labs "long j"
48.Sh DESCRIPTION
49The
50.Fn labs
51function
52returns the absolute value of the long integer
53.Ar j .
54.Sh SEE ALSO
55.Xr abs 3 ,
56.Xr floor 3 ,
57.Xr cabs 3 ,
58.Xr math 3
59.Sh STANDARDS
60The
61.Fn labs
62function
63conforms to
64.St -ansiC .
65.Sh BUGS
66The absolute value of the most negative integer remains negative.
diff --git a/src/lib/libc/stdlib/labs.c b/src/lib/libc/stdlib/labs.c
new file mode 100644
index 0000000000..f20e2c29be
--- /dev/null
+++ b/src/lib/libc/stdlib/labs.c
@@ -0,0 +1,45 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: labs.c,v 1.2 1996/08/19 08:33:34 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39
40long
41labs(j)
42 long j;
43{
44 return(j < 0 ? -j : j);
45}
diff --git a/src/lib/libc/stdlib/lcong48.c b/src/lib/libc/stdlib/lcong48.c
new file mode 100644
index 0000000000..44bd74e48a
--- /dev/null
+++ b/src/lib/libc/stdlib/lcong48.c
@@ -0,0 +1,34 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 */
13
14#if defined(LIBC_SCCS) && !defined(lint)
15static char rcsid[] = "$OpenBSD: lcong48.c,v 1.2 1996/08/19 08:33:35 tholo Exp $";
16#endif /* LIBC_SCCS and not lint */
17
18#include "rand48.h"
19
20extern unsigned short __rand48_seed[3];
21extern unsigned short __rand48_mult[3];
22extern unsigned short __rand48_add;
23
24void
25lcong48(unsigned short p[7])
26{
27 __rand48_seed[0] = p[0];
28 __rand48_seed[1] = p[1];
29 __rand48_seed[2] = p[2];
30 __rand48_mult[0] = p[3];
31 __rand48_mult[1] = p[4];
32 __rand48_mult[2] = p[5];
33 __rand48_add = p[6];
34}
diff --git a/src/lib/libc/stdlib/ldiv.3 b/src/lib/libc/stdlib/ldiv.3
new file mode 100644
index 0000000000..8757f4ddd5
--- /dev/null
+++ b/src/lib/libc/stdlib/ldiv.3
@@ -0,0 +1,71 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: ldiv.3,v 1.2 1996/08/19 08:33:35 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt LDIV 3
40.Os
41.Sh NAME
42.Nm ldiv
43.Nd return quotient and remainder from division
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft ldiv_t
47.Fn ldiv "long num" "long denom"
48.Sh DESCRIPTION
49The
50.Fn ldiv
51function
52computes the value
53.Ar num/denom
54and returns the quotient and remainder in a structure named
55.Ar ldiv_t
56that contains two
57.Em long integer
58members named
59.Ar quot
60and
61.Ar rem .
62.Sh SEE ALSO
63.Xr div 3 ,
64.Xr qdiv 3 ,
65.Xr math 3
66.Sh STANDARDS
67The
68.Fn ldiv
69function
70conforms to
71.St -ansiC .
diff --git a/src/lib/libc/stdlib/ldiv.c b/src/lib/libc/stdlib/ldiv.c
new file mode 100644
index 0000000000..908c2bf0aa
--- /dev/null
+++ b/src/lib/libc/stdlib/ldiv.c
@@ -0,0 +1,58 @@
1/*
2 * Copyright (c) 1990 Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: ldiv.c,v 1.2 1996/08/19 08:33:35 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <stdlib.h> /* ldiv_t */
42
43ldiv_t
44ldiv(num, denom)
45 long num, denom;
46{
47 ldiv_t r;
48
49 /* see div.c for comments */
50
51 r.quot = num / denom;
52 r.rem = num % denom;
53 if (num >= 0 && r.rem < 0) {
54 r.quot++;
55 r.rem -= denom;
56 }
57 return (r);
58}
diff --git a/src/lib/libc/stdlib/lrand48.c b/src/lib/libc/stdlib/lrand48.c
new file mode 100644
index 0000000000..6b7524a51b
--- /dev/null
+++ b/src/lib/libc/stdlib/lrand48.c
@@ -0,0 +1,27 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 */
13
14#if defined(LIBC_SCCS) && !defined(lint)
15static char rcsid[] = "$OpenBSD: lrand48.c,v 1.2 1996/08/19 08:33:36 tholo Exp $";
16#endif /* LIBC_SCCS and not lint */
17
18#include "rand48.h"
19
20extern unsigned short __rand48_seed[3];
21
22long
23lrand48(void)
24{
25 __dorand48(__rand48_seed);
26 return ((long) __rand48_seed[2] << 15) + ((long) __rand48_seed[1] >> 1);
27}
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3
new file mode 100644
index 0000000000..9edff6709c
--- /dev/null
+++ b/src/lib/libc/stdlib/malloc.3
@@ -0,0 +1,355 @@
1.\" Copyright (c) 1980, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: malloc.3,v 1.11 1999/03/23 21:07:57 millert Exp $
37.\"
38.Dd August 27, 1996
39.Dt MALLOC 3
40.Os OpenBSD
41.Sh NAME
42.Nm malloc ,
43.Nd general memory allocation function
44.Pp
45.Nm free ,
46.Nm cfree
47.Nd free up memory allocated with malloc, calloc or realloc
48.Pp
49.Nm realloc
50.Nd reallocation of memory function
51.Sh SYNOPSIS
52.Fd #include <stdlib.h>
53.Ft void *
54.Fn malloc "size_t size"
55.Ft void
56.Fn free "void *ptr"
57.Ft void
58.Fn cfree "void *ptr"
59.Ft void *
60.Fn realloc "void *ptr" "size_t size"
61.Ft char *
62.Va malloc_options
63.Sh DESCRIPTION
64The
65.Fn malloc
66function allocates uninitialized space for an object whose
67size is specified by
68.Fa size .
69The
70.Fn malloc
71function maintains multiple lists of free blocks according to size, allocating
72space from the appropriate list.
73.Pp
74The allocated space is
75suitably aligned (after possible pointer
76coercion) for storage of any type of object. If the space is of
77.Em pagesize
78or larger, the memory returned will be page-aligned.
79.Pp
80Allocation of a zero size object returns a pointer to a zero size object.
81.Pp
82The
83.Fn free
84function causes the space pointed to by
85.Fa ptr
86to be deallocated, that is, at least made available for further allocation,
87but if possible, it will passed back to the kernel with
88.Xr sbrk 2 .
89If
90.Fa ptr
91is a null pointer, no action occurs.
92.Pp
93A
94.Fn cfree
95function is also provided for compatibility with old systems and other
96.Nm malloc
97libraries; it is simply an alias for
98.Fn free .
99.Pp
100The
101.Fn realloc
102function changes the size of the object pointed to by
103.Fa ptr
104to
105.Fa size
106bytes and returns a pointer to the (possibly moved) object.
107The contents of the object are unchanged up to the lesser
108of the new and old sizes.
109If the new size is larger, the value of the newly allocated portion
110of the object is indeterminate and uninitialized.
111If
112.Fa ptr
113is a null pointer, the
114.Fn realloc
115function behaves like the
116.Fn malloc
117function for the specified size.
118If the space cannot be allocated, the object
119pointed to by
120.Fa ptr
121is unchanged.
122If
123.Fa size
124is zero and
125.Fa ptr
126is not a null pointer, the object it points to is freed and a new zero size
127object is returned.
128.Pp
129When using
130.Fn realloc
131one must be careful to avoid the following idiom:
132.Pp
133.Bd -literal -offset indent
134if ((p = realloc(p, nsize)) == NULL)
135 return NULL;
136.Ed
137.Pp
138In most cases, this will result in a leak of memory.
139As stated earlier, a return value of
140.Fa NULL
141indicates that the old object still remains allocated.
142Better code looks like this:
143.Bd -literal -offset indent
144if ((p2 = realloc(p, nsize)) == NULL) {
145 if (p)
146 free(p);
147 p = NULL;
148 return NULL;
149}
150p = p2;
151.Ed
152.Pp
153Malloc will first look for a symbolic link called
154.Pa /etc/malloc.conf
155and next check the environment for a variable called
156.Ev MALLOC_OPTIONS
157and finally for the global variable
158.Va malloc_options
159and scan them for flags in that order.
160Flags are single letters, uppercase means on, lowercase means off.
161.Bl -tag -width indent
162.It A
163``abort'' malloc will coredump the process, rather than tolerate failure.
164This is a very handy debugging aid, since the core file will represent the
165time of failure,
166rather than when the NULL pointer was accessed.
167
168.It D
169``dump'' malloc will dump statistics in a file called ``malloc.out'' at exit.
170This option requires the library to have been compiled with -DMALLOC_STATS in
171order to have any effect.
172
173.It J
174``junk'' fill some junk into the area allocated.
175Currently junk is bytes of 0xd0, this is pronounced ``Duh'' :-)
176
177.It H
178``hint'' pass a hint to the kernel about pages we don't use. If the
179machine is paging a lot this may help a bit.
180
181.It N
182Do not output warning messages when encountering possible corruption
183or bad pointers.
184
185.It R
186``realloc'' always reallocate when
187.Fn realloc
188is called, even if the initial allocation was big enough.
189This can substantially aid in compacting memory.
190
191.It U
192``utrace'' generate entries for
193.Xr ktrace 1
194for all operations.
195Consult the source for this one.
196
197.It X
198``xmalloc''
199rather than return failure,
200.Xr abort 3
201the program with a diagnostic message on stderr.
202It is the intention that this option be set at compile time by
203including in the source:
204.Bd -literal -offset indent
205extern char *malloc_options;
206malloc_options = "X";
207.Ed
208
209.It Z
210``zero'' fill some junk into the area allocated (see ``J''),
211except for the exact length the user asked for, which is zeroed.
212
213.It <
214``Half the cache size'' Reduce the size of the cache by a factor of two.
215
216.It >
217``Double the cache size'' Double the size of the cache by a factor of two.
218.El
219.Pp
220So to set a systemwide reduction of cache size and coredumps on problems
221one would:
222.Li ln -s 'A<' /etc/malloc.conf
223.Pp
224The ``J'' and ``Z'' is mostly for testing and debugging,
225if a program changes behavior if either of these options are used,
226it is buggy.
227.Pp
228The default cache size is 16 pages.
229.Sh ENVIRONMENT
230See above.
231.Sh RETURN VALUES
232The
233.Fn malloc
234function returns
235a pointer to the allocated space if successful; otherwise
236a null pointer is returned.
237.Pp
238The
239.Fn free
240function returns no value.
241.Pp
242The
243.Fn realloc
244function a pointer to the possibly moved allocated space;
245otherwise a null pointer is returned.
246.Sh MESSAGES
247If
248.Fn malloc ,
249.Fn free
250or
251.Fn realloc
252detects an error or warning condition,
253a message will be printed to filedescriptor
2542 (not using stdio).
255Errors will always result in the process being
256.Xr abort 2 'ed,
257If the ``A'' option has been specified, also warnings will
258.Xr abort 2
259the process.
260.Pp
261Here is a brief description of the error messages and what they mean:
262.Pp
263``(ES): mumble mumble mumble'':
264malloc have been compiled with -DEXTRA_SANITY and something looks
265fishy in there. Consult sources and or wizards.
266.Pp
267``allocation failed''
268if the ``A'' option is specified it is an error for
269.Fn malloc
270or
271.Fn realloc
272to return NULL.
273.Pp
274``mmap(2) failed, check limits.''
275This is a rather weird condition that is most likely to mean that
276the system is seriously overloaded or that your ulimits are sick.
277.Pp
278``freelist is destroyed.''
279mallocs internal freelist has been stomped on.
280.Pp
281Here is a brief description of the warning messages and what they mean:
282.Pp
283``chunk/page is already free.''
284A pointer to a free chunk is attempted freed again.
285.Pp
286``junk pointer, too high to make sense.''
287The pointer doesn't make sense. It's above the area of memory that
288malloc knows something about.
289This could be a pointer from some
290.Xr mmap 2 'ed
291memory.
292.Pp
293``junk pointer, too low to make sense.''
294The pointer doesn't make sense. It's below the area of memory that
295malloc knows something about.
296This pointer probably came from your data or bss segments.
297.Pp
298``malloc() has never been called.''
299Nothing has ever been allocated, yet something is being freed or
300realloc'ed.
301.Pp
302``modified (chunk-/page-) pointer.''
303The pointer passed to free or realloc has been modified.
304.Pp
305``pointer to wrong page.''
306The pointer that malloc is trying to free is not pointing to
307a sensible page.
308.Pp
309``recursive call.''
310You have tried to call recursively into these functions.
311I can only imagine this as happening if you call one of these
312functions from a signal function, which happens to be called
313while you're already in here.
314Well, sorry to say: that's not supported.
315If this is a problem for you I'd like to hear about it. It
316would be possible to add a sigblock() around this package,
317but it would have a performance penalty that is not acceptable
318as the default.
319.Pp
320``unknown char in MALLOC_OPTIONS''
321we found something we didn't understand.
322.Sh FILES
323.Bl -tag -width "/etc/malloc.conf"
324.It Pa /etc/malloc.conf
325symbolic link to file containing option flags
326.Sh SEE ALSO
327.Xr brk 2 ,
328.Xr alloca 3 ,
329.Xr calloc 3 ,
330.Xr getpagesize 3 ,
331.Xr memory 3
332.Pa /usr/share/doc/papers/malloc.ascii.gz
333.Sh STANDARDS
334The
335.Fn malloc
336function conforms to
337.St -ansiC .
338.Sh HISTORY
339The present implementation of malloc started out as a filesystem on a drum
340attached to a 20bit binary challenged computer built with discrete germanium
341transistors, and it has since graduated to handle primary storage rather than
342secondary.
343.Pp
344The main difference from other malloc implementations are believed to be that
345the free pages are not accessed until allocated.
346Most malloc implementations will store a data structure containing a,
347possibly double-, linked list in the free chunks of memory, used to tie
348all the free memory together.
349That is a quite suboptimal thing to do.
350Every time the free-list is traversed, all the otherwise unused, and very
351likely paged out, pages get faulted into primary memory, just to see what
352lies after them in the list.
353.Pp
354On systems which are paging, this can make a factor five in difference on the
355page-faults of a process.
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
new file mode 100644
index 0000000000..e75c7cdb09
--- /dev/null
+++ b/src/lib/libc/stdlib/malloc.c
@@ -0,0 +1,1263 @@
1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
8 */
9
10#if defined(LIBC_SCCS) && !defined(lint)
11static char rcsid[] = "$OpenBSD: malloc.c,v 1.35 1999/02/03 03:58:05 d Exp $";
12#endif /* LIBC_SCCS and not lint */
13
14/*
15 * Defining MALLOC_EXTRA_SANITY will enable extra checks which are
16 * related to internal conditions and consistency in malloc.c. This has
17 * a noticeable runtime performance hit, and generally will not do you
18 * any good unless you fiddle with the internals of malloc or want
19 * to catch random pointer corruption as early as possible.
20 */
21#ifndef MALLOC_EXTRA_SANITY
22#undef MALLOC_EXTRA_SANITY
23#endif
24
25/*
26 * Defining MALLOC_STATS will enable you to call malloc_dump() and set
27 * the [dD] options in the MALLOC_OPTIONS environment variable.
28 * It has no run-time performance hit, but does pull in stdio...
29 */
30#ifndef MALLOC_STATS
31#undef MALLOC_STATS
32#endif
33
34/*
35 * What to use for Junk. This is the byte value we use to fill with
36 * when the 'J' option is enabled.
37 */
38#define SOME_JUNK 0xd0 /* as in "Duh" :-) */
39
40#include <stdio.h>
41#include <stdlib.h>
42#include <string.h>
43#include <unistd.h>
44#include <fcntl.h>
45#include <errno.h>
46#include <sys/types.h>
47#include <sys/param.h>
48#include <sys/mman.h>
49
50/*
51 * The basic parameters you can tweak.
52 *
53 * malloc_pageshift pagesize = 1 << malloc_pageshift
54 * It's probably best if this is the native
55 * page size, but it shouldn't have to be.
56 *
57 * malloc_minsize minimum size of an allocation in bytes.
58 * If this is too small it's too much work
59 * to manage them. This is also the smallest
60 * unit of alignment used for the storage
61 * returned by malloc/realloc.
62 *
63 */
64
65#if defined(__i386__) && defined(__FreeBSD__)
66# define malloc_pageshift 12U
67# define malloc_minsize 16U
68#endif /* __i386__ && __FreeBSD__ */
69
70#if defined(__sparc__) && !defined(__OpenBSD__)
71# define malloc_pageshirt 12U
72# define malloc_minsize 16U
73# define MAP_ANON (0)
74# define USE_DEV_ZERO
75# define MADV_FREE MADV_DONTNEED
76#endif /* __sparc__ */
77
78/* Insert your combination here... */
79#if defined(__FOOCPU__) && defined(__BAROS__)
80# define malloc_pageshift 12U
81# define malloc_minsize 16U
82#endif /* __FOOCPU__ && __BAROS__ */
83
84#if defined(__OpenBSD__) && !defined(__sparc__)
85# define malloc_pageshift (PGSHIFT)
86# define malloc_minsize 16U
87#endif /* __OpenBSD__ */
88
89#ifdef _THREAD_SAFE
90# include "thread_private.h"
91# if 0
92 /* kernel threads */
93# include <pthread.h>
94 static pthread_mutex_t malloc_lock;
95# define THREAD_LOCK() pthread_mutex_lock(&malloc_lock)
96# define THREAD_UNLOCK() pthread_mutex_unlock(&malloc_lock)
97# define THREAD_LOCK_INIT() pthread_mutex_init(&malloc_lock, 0);
98# else
99 /* user threads */
100# include "spinlock.h"
101 static spinlock_t malloc_lock = _SPINLOCK_INITIALIZER;
102# define THREAD_LOCK() if (__isthreaded) _SPINLOCK(&malloc_lock)
103# define THREAD_UNLOCK() if (__isthreaded) _SPINUNLOCK(&malloc_lock)
104# define THREAD_LOCK_INIT()
105 /*
106 * Malloc can't use the wrapped write() if it fails very early, so
107 * we use the unwrapped syscall _thread_sys_write()
108 */
109# define write _thread_sys_write
110 ssize_t write __P((int, const void *, size_t));
111# undef malloc
112# undef realloc
113# undef free
114# endif
115#else
116 /* no threads */
117# define THREAD_LOCK()
118# define THREAD_UNLOCK()
119# define THREAD_LOCK_INIT()
120#endif
121
122/*
123 * No user serviceable parts behind this point.
124 *
125 * This structure describes a page worth of chunks.
126 */
127
128struct pginfo {
129 struct pginfo *next; /* next on the free list */
130 void *page; /* Pointer to the page */
131 u_short size; /* size of this page's chunks */
132 u_short shift; /* How far to shift for this size chunks */
133 u_short free; /* How many free chunks */
134 u_short total; /* How many chunk */
135 u_long bits[1]; /* Which chunks are free */
136};
137
138/*
139 * This structure describes a number of free pages.
140 */
141
142struct pgfree {
143 struct pgfree *next; /* next run of free pages */
144 struct pgfree *prev; /* prev run of free pages */
145 void *page; /* pointer to free pages */
146 void *end; /* pointer to end of free pages */
147 u_long size; /* number of bytes free */
148};
149
150/*
151 * How many bits per u_long in the bitmap.
152 * Change only if not 8 bits/byte
153 */
154#define MALLOC_BITS (8*sizeof(u_long))
155
156/*
157 * Magic values to put in the page_directory
158 */
159#define MALLOC_NOT_MINE ((struct pginfo*) 0)
160#define MALLOC_FREE ((struct pginfo*) 1)
161#define MALLOC_FIRST ((struct pginfo*) 2)
162#define MALLOC_FOLLOW ((struct pginfo*) 3)
163#define MALLOC_MAGIC ((struct pginfo*) 4)
164
165#ifndef malloc_pageshift
166#define malloc_pageshift 12U
167#endif
168
169#ifndef malloc_minsize
170#define malloc_minsize 16U
171#endif
172
173#ifndef malloc_pageshift
174#error "malloc_pageshift undefined"
175#endif
176
177#if !defined(malloc_pagesize)
178#define malloc_pagesize (1UL<<malloc_pageshift)
179#endif
180
181#if ((1UL<<malloc_pageshift) != malloc_pagesize)
182#error "(1UL<<malloc_pageshift) != malloc_pagesize"
183#endif
184
185#ifndef malloc_maxsize
186#define malloc_maxsize ((malloc_pagesize)>>1)
187#endif
188
189/* A mask for the offset inside a page. */
190#define malloc_pagemask ((malloc_pagesize)-1)
191
192#define pageround(foo) (((foo) + (malloc_pagemask))&(~(malloc_pagemask)))
193#define ptr2index(foo) (((u_long)(foo) >> malloc_pageshift)-malloc_origo)
194
195/* fd of /dev/zero */
196#ifdef USE_DEV_ZERO
197static int fdzero;
198#define MMAP_FD fdzero
199#define INIT_MMAP() \
200 { if ((fdzero=open("/dev/zero", O_RDWR, 0000)) == -1) \
201 wrterror("open of /dev/zero"); }
202#else
203#define MMAP_FD (-1)
204#define INIT_MMAP()
205#endif
206
207/* Set when initialization has been done */
208static unsigned malloc_started;
209
210/* Number of free pages we cache */
211static unsigned malloc_cache = 16;
212
213/* The offset from pagenumber to index into the page directory */
214static u_long malloc_origo;
215
216/* The last index in the page directory we care about */
217static u_long last_index;
218
219/* Pointer to page directory. Allocated "as if with" malloc */
220static struct pginfo **page_dir;
221
222/* How many slots in the page directory */
223static size_t malloc_ninfo;
224
225/* Free pages line up here */
226static struct pgfree free_list;
227
228/* Abort(), user doesn't handle problems. */
229static int malloc_abort;
230
231/* Are we trying to die ? */
232static int suicide;
233
234#ifdef MALLOC_STATS
235/* dump statistics */
236static int malloc_stats;
237#endif
238
239/* avoid outputting warnings? */
240static int malloc_silent;
241
242/* always realloc ? */
243static int malloc_realloc;
244
245#ifdef __FreeBSD__
246/* pass the kernel a hint on free pages ? */
247static int malloc_hint;
248#endif
249
250/* xmalloc behaviour ? */
251static int malloc_xmalloc;
252
253/* zero fill ? */
254static int malloc_zero;
255
256/* junk fill ? */
257static int malloc_junk;
258
259#ifdef __FreeBSD__
260/* utrace ? */
261static int malloc_utrace;
262
263struct ut { void *p; size_t s; void *r; };
264
265void utrace __P((struct ut *, int));
266
267#define UTRACE(a, b, c) \
268 if (malloc_utrace) \
269 {struct ut u; u.p=a; u.s = b; u.r=c; utrace(&u, sizeof u);}
270#else /* !__FreeBSD__ */
271#define UTRACE(a,b,c)
272#endif
273
274/* my last break. */
275static void *malloc_brk;
276
277/* one location cache for free-list holders */
278static struct pgfree *px;
279
280/* compile-time options */
281char *malloc_options;
282
283/* Name of the current public function */
284static char *malloc_func;
285
286/* Macro for mmap */
287#define MMAP(size) \
288 mmap((void *)0, (size), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, \
289 MMAP_FD, (off_t)0);
290
291/*
292 * Necessary function declarations
293 */
294static int extend_pgdir(u_long index);
295static void *imalloc(size_t size);
296static void ifree(void *ptr);
297static void *irealloc(void *ptr, size_t size);
298static void *malloc_bytes(size_t size);
299
300#ifdef MALLOC_STATS
301void
302malloc_dump(fd)
303 FILE *fd;
304{
305 struct pginfo **pd;
306 struct pgfree *pf;
307 int j;
308
309 pd = page_dir;
310
311 /* print out all the pages */
312 for(j=0;j<=last_index;j++) {
313 fprintf(fd, "%08lx %5d ", (j+malloc_origo) << malloc_pageshift, j);
314 if (pd[j] == MALLOC_NOT_MINE) {
315 for(j++;j<=last_index && pd[j] == MALLOC_NOT_MINE;j++)
316 ;
317 j--;
318 fprintf(fd, ".. %5d not mine\n", j);
319 } else if (pd[j] == MALLOC_FREE) {
320 for(j++;j<=last_index && pd[j] == MALLOC_FREE;j++)
321 ;
322 j--;
323 fprintf(fd, ".. %5d free\n", j);
324 } else if (pd[j] == MALLOC_FIRST) {
325 for(j++;j<=last_index && pd[j] == MALLOC_FOLLOW;j++)
326 ;
327 j--;
328 fprintf(fd, ".. %5d in use\n", j);
329 } else if (pd[j] < MALLOC_MAGIC) {
330 fprintf(fd, "(%p)\n", pd[j]);
331 } else {
332 fprintf(fd, "%p %d (of %d) x %d @ %p --> %p\n",
333 pd[j], pd[j]->free, pd[j]->total,
334 pd[j]->size, pd[j]->page, pd[j]->next);
335 }
336 }
337
338 for(pf=free_list.next; pf; pf=pf->next) {
339 fprintf(fd, "Free: @%p [%p...%p[ %ld ->%p <-%p\n",
340 pf, pf->page, pf->end, pf->size, pf->prev, pf->next);
341 if (pf == pf->next) {
342 fprintf(fd, "Free_list loops.\n");
343 break;
344 }
345 }
346
347 /* print out various info */
348 fprintf(fd, "Minsize\t%d\n", malloc_minsize);
349 fprintf(fd, "Maxsize\t%d\n", malloc_maxsize);
350 fprintf(fd, "Pagesize\t%lu\n", (u_long)malloc_pagesize);
351 fprintf(fd, "Pageshift\t%d\n", malloc_pageshift);
352 fprintf(fd, "FirstPage\t%ld\n", malloc_origo);
353 fprintf(fd, "LastPage\t%ld %lx\n", last_index+malloc_pageshift,
354 (last_index + malloc_pageshift) << malloc_pageshift);
355 fprintf(fd, "Break\t%ld\n", (u_long)sbrk(0) >> malloc_pageshift);
356}
357#endif /* MALLOC_STATS */
358
359extern char *__progname;
360
361static void
362wrterror(p)
363 char *p;
364{
365 char *q = " error: ";
366 write(2, __progname, strlen(__progname));
367 write(2, malloc_func, strlen(malloc_func));
368 write(2, q, strlen(q));
369 write(2, p, strlen(p));
370 suicide = 1;
371#ifdef MALLOC_STATS
372 if (malloc_stats)
373 malloc_dump(stderr);
374#endif /* MALLOC_STATS */
375 abort();
376}
377
378static void
379wrtwarning(p)
380 char *p;
381{
382 char *q = " warning: ";
383 if (malloc_abort)
384 wrterror(p);
385 else if (malloc_silent)
386 return;
387 write(2, __progname, strlen(__progname));
388 write(2, malloc_func, strlen(malloc_func));
389 write(2, q, strlen(q));
390 write(2, p, strlen(p));
391}
392
393#ifdef MALLOC_STATS
394static void
395malloc_exit()
396{
397 FILE *fd = fopen("malloc.out", "a");
398 char *q = "malloc() warning: Couldn't dump stats.\n";
399 if (fd) {
400 malloc_dump(fd);
401 fclose(fd);
402 } else
403 write(2, q, strlen(q));
404}
405#endif /* MALLOC_STATS */
406
407
408/*
409 * Allocate a number of pages from the OS
410 */
411static void *
412map_pages(pages)
413 int pages;
414{
415 caddr_t result, tail;
416
417 result = (caddr_t)pageround((u_long)sbrk(0));
418 tail = result + (pages << malloc_pageshift);
419
420 if (brk(tail)) {
421#ifdef MALLOC_EXTRA_SANITY
422 wrterror("(ES): map_pages fails\n");
423#endif /* MALLOC_EXTRA_SANITY */
424 return 0;
425 }
426
427 last_index = ptr2index(tail) - 1;
428 malloc_brk = tail;
429
430 if ((last_index+1) >= malloc_ninfo && !extend_pgdir(last_index))
431 return 0;
432
433 return result;
434}
435
436/*
437 * Extend page directory
438 */
439static int
440extend_pgdir(index)
441 u_long index;
442{
443 struct pginfo **new, **old;
444 size_t i, oldlen;
445
446 /* Make it this many pages */
447 i = index * sizeof *page_dir;
448 i /= malloc_pagesize;
449 i += 2;
450
451 /* remember the old mapping size */
452 oldlen = malloc_ninfo * sizeof *page_dir;
453
454 /*
455 * NOTE: we allocate new pages and copy the directory rather than tempt
456 * fate by trying to "grow" the region.. There is nothing to prevent
457 * us from accidently re-mapping space that's been allocated by our caller
458 * via dlopen() or other mmap().
459 *
460 * The copy problem is not too bad, as there is 4K of page index per
461 * 4MB of malloc arena.
462 *
463 * We can totally avoid the copy if we open a file descriptor to associate
464 * the anon mappings with. Then, when we remap the pages at the new
465 * address, the old pages will be "magically" remapped.. But this means
466 * keeping open a "secret" file descriptor.....
467 */
468
469 /* Get new pages */
470 new = (struct pginfo**) MMAP(i * malloc_pagesize);
471 if (new == (struct pginfo **)-1)
472 return 0;
473
474 /* Copy the old stuff */
475 memcpy(new, page_dir,
476 malloc_ninfo * sizeof *page_dir);
477
478 /* register the new size */
479 malloc_ninfo = i * malloc_pagesize / sizeof *page_dir;
480
481 /* swap the pointers */
482 old = page_dir;
483 page_dir = new;
484
485 /* Now free the old stuff */
486 munmap(old, oldlen);
487 return 1;
488}
489
490/*
491 * Initialize the world
492 */
493static void
494malloc_init ()
495{
496 char *p, b[64];
497 int i, j;
498 int save_errno = errno;
499
500 THREAD_LOCK_INIT();
501
502 INIT_MMAP();
503
504#ifdef MALLOC_EXTRA_SANITY
505 malloc_junk = 1;
506#endif /* MALLOC_EXTRA_SANITY */
507
508 for (i = 0; i < 3; i++) {
509 if (i == 0) {
510 j = readlink("/etc/malloc.conf", b, sizeof b - 1);
511 if (j <= 0)
512 continue;
513 b[j] = '\0';
514 p = b;
515 } else if (i == 1) {
516 if (issetugid() == 0)
517 p = getenv("MALLOC_OPTIONS");
518 else
519 continue;
520 } else if (i == 2) {
521 p = malloc_options;
522 }
523 for (; p && *p; p++) {
524 switch (*p) {
525 case '>': malloc_cache <<= 1; break;
526 case '<': malloc_cache >>= 1; break;
527 case 'a': malloc_abort = 0; break;
528 case 'A': malloc_abort = 1; break;
529#ifdef MALLOC_STATS
530 case 'd': malloc_stats = 0; break;
531 case 'D': malloc_stats = 1; break;
532#endif /* MALLOC_STATS */
533#ifdef __FreeBSD__
534 case 'h': malloc_hint = 0; break;
535 case 'H': malloc_hint = 1; break;
536#endif /* __FreeBSD__ */
537 case 'r': malloc_realloc = 0; break;
538 case 'R': malloc_realloc = 1; break;
539 case 'j': malloc_junk = 0; break;
540 case 'J': malloc_junk = 1; break;
541 case 'n': malloc_silent = 0; break;
542 case 'N': malloc_silent = 1; break;
543#ifdef __FreeBSD__
544 case 'u': malloc_utrace = 0; break;
545 case 'U': malloc_utrace = 1; break;
546#endif /* __FreeBSD__ */
547 case 'x': malloc_xmalloc = 0; break;
548 case 'X': malloc_xmalloc = 1; break;
549 case 'z': malloc_zero = 0; break;
550 case 'Z': malloc_zero = 1; break;
551 default:
552 j = malloc_abort;
553 malloc_abort = 0;
554 wrtwarning("unknown char in MALLOC_OPTIONS\n");
555 malloc_abort = j;
556 break;
557 }
558 }
559 }
560
561 UTRACE(0, 0, 0);
562
563 /*
564 * We want junk in the entire allocation, and zero only in the part
565 * the user asked for.
566 */
567 if (malloc_zero)
568 malloc_junk=1;
569
570#ifdef MALLOC_STATS
571 if (malloc_stats)
572 atexit(malloc_exit);
573#endif /* MALLOC_STATS */
574
575 /* Allocate one page for the page directory */
576 page_dir = (struct pginfo **) MMAP(malloc_pagesize);
577
578 if (page_dir == (struct pginfo **) -1)
579 wrterror("mmap(2) failed, check limits.\n");
580
581 /*
582 * We need a maximum of malloc_pageshift buckets, steal these from the
583 * front of the page_directory;
584 */
585 malloc_origo = ((u_long)pageround((u_long)sbrk(0))) >> malloc_pageshift;
586 malloc_origo -= malloc_pageshift;
587
588 malloc_ninfo = malloc_pagesize / sizeof *page_dir;
589
590 /* Been here, done that */
591 malloc_started++;
592
593 /* Recalculate the cache size in bytes, and make sure it's nonzero */
594
595 if (!malloc_cache)
596 malloc_cache++;
597
598 malloc_cache <<= malloc_pageshift;
599
600 /*
601 * This is a nice hack from Kaleb Keithly (kaleb@x.org).
602 * We can sbrk(2) further back when we keep this on a low address.
603 */
604 px = (struct pgfree *) imalloc (sizeof *px);
605 errno = save_errno;
606}
607
608/*
609 * Allocate a number of complete pages
610 */
611static void *
612malloc_pages(size)
613 size_t size;
614{
615 void *p, *delay_free = 0;
616 int i;
617 struct pgfree *pf;
618 u_long index;
619
620 size = pageround(size);
621
622 p = 0;
623 /* Look for free pages before asking for more */
624 for(pf = free_list.next; pf; pf = pf->next) {
625
626#ifdef MALLOC_EXTRA_SANITY
627 if (pf->size & malloc_pagemask)
628 wrterror("(ES): junk length entry on free_list\n");
629 if (!pf->size)
630 wrterror("(ES): zero length entry on free_list\n");
631 if (pf->page == pf->end)
632 wrterror("(ES): zero entry on free_list\n");
633 if (pf->page > pf->end)
634 wrterror("(ES): sick entry on free_list\n");
635 if ((void*)pf->page >= (void*)sbrk(0))
636 wrterror("(ES): entry on free_list past brk\n");
637 if (page_dir[ptr2index(pf->page)] != MALLOC_FREE)
638 wrterror("(ES): non-free first page on free-list\n");
639 if (page_dir[ptr2index(pf->end)-1] != MALLOC_FREE)
640 wrterror("(ES): non-free last page on free-list\n");
641#endif /* MALLOC_EXTRA_SANITY */
642
643 if (pf->size < size)
644 continue;
645
646 if (pf->size == size) {
647 p = pf->page;
648 if (pf->next)
649 pf->next->prev = pf->prev;
650 pf->prev->next = pf->next;
651 delay_free = pf;
652 break;
653 }
654
655 p = pf->page;
656 pf->page = (char *)pf->page + size;
657 pf->size -= size;
658 break;
659 }
660
661#ifdef MALLOC_EXTRA_SANITY
662 if (p && page_dir[ptr2index(p)] != MALLOC_FREE)
663 wrterror("(ES): allocated non-free page on free-list\n");
664#endif /* MALLOC_EXTRA_SANITY */
665
666 size >>= malloc_pageshift;
667
668 /* Map new pages */
669 if (!p)
670 p = map_pages(size);
671
672 if (p) {
673
674 index = ptr2index(p);
675 page_dir[index] = MALLOC_FIRST;
676 for (i=1;i<size;i++)
677 page_dir[index+i] = MALLOC_FOLLOW;
678
679 if (malloc_junk)
680 memset(p, SOME_JUNK, size << malloc_pageshift);
681 }
682
683 if (delay_free) {
684 if (!px)
685 px = delay_free;
686 else
687 ifree(delay_free);
688 }
689
690 return p;
691}
692
693/*
694 * Allocate a page of fragments
695 */
696
697static __inline__ int
698malloc_make_chunks(bits)
699 int bits;
700{
701 struct pginfo *bp;
702 void *pp;
703 int i, k, l;
704
705 /* Allocate a new bucket */
706 pp = malloc_pages((size_t)malloc_pagesize);
707 if (!pp)
708 return 0;
709
710 /* Find length of admin structure */
711 l = sizeof *bp - sizeof(u_long);
712 l += sizeof(u_long) *
713 (((malloc_pagesize >> bits)+MALLOC_BITS-1) / MALLOC_BITS);
714
715 /* Don't waste more than two chunks on this */
716 if ((1UL<<(bits)) <= l+l) {
717 bp = (struct pginfo *)pp;
718 } else {
719 bp = (struct pginfo *)imalloc(l);
720 if (!bp) {
721 ifree(pp);
722 return 0;
723 }
724 }
725
726 bp->size = (1UL<<bits);
727 bp->shift = bits;
728 bp->total = bp->free = malloc_pagesize >> bits;
729 bp->page = pp;
730
731 /* set all valid bits in the bitmap */
732 k = bp->total;
733 i = 0;
734
735 /* Do a bunch at a time */
736 for(;k-i >= MALLOC_BITS; i += MALLOC_BITS)
737 bp->bits[i / MALLOC_BITS] = ~0UL;
738
739 for(; i < k; i++)
740 bp->bits[i/MALLOC_BITS] |= 1UL<<(i%MALLOC_BITS);
741
742 if (bp == bp->page) {
743 /* Mark the ones we stole for ourselves */
744 for(i=0;l > 0;i++) {
745 bp->bits[i/MALLOC_BITS] &= ~(1UL<<(i%MALLOC_BITS));
746 bp->free--;
747 bp->total--;
748 l -= (1 << bits);
749 }
750 }
751
752 /* MALLOC_LOCK */
753
754 page_dir[ptr2index(pp)] = bp;
755
756 bp->next = page_dir[bits];
757 page_dir[bits] = bp;
758
759 /* MALLOC_UNLOCK */
760
761 return 1;
762}
763
764/*
765 * Allocate a fragment
766 */
767static void *
768malloc_bytes(size)
769 size_t size;
770{
771 int i,j;
772 u_long u;
773 struct pginfo *bp;
774 int k;
775 u_long *lp;
776
777 /* Don't bother with anything less than this */
778 if (size < malloc_minsize)
779 size = malloc_minsize;
780
781 /* Find the right bucket */
782 j = 1;
783 i = size-1;
784 while (i >>= 1)
785 j++;
786
787 /* If it's empty, make a page more of that size chunks */
788 if (!page_dir[j] && !malloc_make_chunks(j))
789 return 0;
790
791 bp = page_dir[j];
792
793 /* Find first word of bitmap which isn't empty */
794 for (lp = bp->bits; !*lp; lp++)
795 ;
796
797 /* Find that bit, and tweak it */
798 u = 1;
799 k = 0;
800 while (!(*lp & u)) {
801 u += u;
802 k++;
803 }
804 *lp ^= u;
805
806 /* If there are no more free, remove from free-list */
807 if (!--bp->free) {
808 page_dir[j] = bp->next;
809 bp->next = 0;
810 }
811
812 /* Adjust to the real offset of that chunk */
813 k += (lp-bp->bits)*MALLOC_BITS;
814 k <<= bp->shift;
815
816 if (malloc_junk)
817 memset((char *)bp->page + k, SOME_JUNK, bp->size);
818
819 return (u_char *)bp->page + k;
820}
821
822/*
823 * Allocate a piece of memory
824 */
825static void *
826imalloc(size)
827 size_t size;
828{
829 void *result;
830
831 if (!malloc_started)
832 malloc_init();
833
834 if (suicide)
835 abort();
836
837 if ((size + malloc_pagesize) < size) /* Check for overflow */
838 result = 0;
839 else if (size <= malloc_maxsize)
840 result = malloc_bytes(size);
841 else
842 result = malloc_pages(size);
843
844 if (malloc_abort && !result)
845 wrterror("allocation failed.\n");
846
847 if (malloc_zero && result)
848 memset(result, 0, size);
849
850 return result;
851}
852
853/*
854 * Change the size of an allocation.
855 */
856static void *
857irealloc(ptr, size)
858 void *ptr;
859 size_t size;
860{
861 void *p;
862 u_long osize, index;
863 struct pginfo **mp;
864 int i;
865
866 if (suicide)
867 abort();
868
869 if (!malloc_started) {
870 wrtwarning("malloc() has never been called.\n");
871 return 0;
872 }
873
874 index = ptr2index(ptr);
875
876 if (index < malloc_pageshift) {
877 wrtwarning("junk pointer, too low to make sense.\n");
878 return 0;
879 }
880
881 if (index > last_index) {
882 wrtwarning("junk pointer, too high to make sense.\n");
883 return 0;
884 }
885
886 mp = &page_dir[index];
887
888 if (*mp == MALLOC_FIRST) { /* Page allocation */
889
890 /* Check the pointer */
891 if ((u_long)ptr & malloc_pagemask) {
892 wrtwarning("modified (page-) pointer.\n");
893 return 0;
894 }
895
896 /* Find the size in bytes */
897 for (osize = malloc_pagesize; *++mp == MALLOC_FOLLOW;)
898 osize += malloc_pagesize;
899
900 if (!malloc_realloc && /* unless we have to, */
901 size <= osize && /* .. or are too small, */
902 size > (osize - malloc_pagesize)) { /* .. or can free a page, */
903 return ptr; /* don't do anything. */
904 }
905
906 } else if (*mp >= MALLOC_MAGIC) { /* Chunk allocation */
907
908 /* Check the pointer for sane values */
909 if (((u_long)ptr & ((*mp)->size-1))) {
910 wrtwarning("modified (chunk-) pointer.\n");
911 return 0;
912 }
913
914 /* Find the chunk index in the page */
915 i = ((u_long)ptr & malloc_pagemask) >> (*mp)->shift;
916
917 /* Verify that it isn't a free chunk already */
918 if ((*mp)->bits[i/MALLOC_BITS] & (1UL<<(i%MALLOC_BITS))) {
919 wrtwarning("chunk is already free.\n");
920 return 0;
921 }
922
923 osize = (*mp)->size;
924
925 if (!malloc_realloc && /* Unless we have to, */
926 size < osize && /* ..or are too small, */
927 (size > osize/2 || /* ..or could use a smaller size, */
928 osize == malloc_minsize)) { /* ..(if there is one) */
929 return ptr; /* ..Don't do anything */
930 }
931
932 } else {
933 wrtwarning("pointer to wrong page.\n");
934 return 0;
935 }
936
937 p = imalloc(size);
938
939 if (p) {
940 /* copy the lesser of the two sizes, and free the old one */
941 if (osize < size)
942 memcpy(p, ptr, osize);
943 else
944 memcpy(p, ptr, size);
945 ifree(ptr);
946 }
947 return p;
948}
949
950/*
951 * Free a sequence of pages
952 */
953
954static __inline__ void
955free_pages(ptr, index, info)
956 void *ptr;
957 int index;
958 struct pginfo *info;
959{
960 int i;
961 struct pgfree *pf, *pt=0;
962 u_long l;
963 void *tail;
964
965 if (info == MALLOC_FREE) {
966 wrtwarning("page is already free.\n");
967 return;
968 }
969
970 if (info != MALLOC_FIRST) {
971 wrtwarning("pointer to wrong page.\n");
972 return;
973 }
974
975 if ((u_long)ptr & malloc_pagemask) {
976 wrtwarning("modified (page-) pointer.\n");
977 return;
978 }
979
980 /* Count how many pages and mark them free at the same time */
981 page_dir[index] = MALLOC_FREE;
982 for (i = 1; page_dir[index+i] == MALLOC_FOLLOW; i++)
983 page_dir[index + i] = MALLOC_FREE;
984
985 l = i << malloc_pageshift;
986
987 if (malloc_junk)
988 memset(ptr, SOME_JUNK, l);
989
990#ifdef __FreeBSD__
991 if (malloc_hint)
992 madvise(ptr, l, MADV_FREE);
993#endif
994
995 tail = (char *)ptr+l;
996
997 /* add to free-list */
998 if (!px)
999 px = imalloc(sizeof *px); /* This cannot fail... */
1000 px->page = ptr;
1001 px->end = tail;
1002 px->size = l;
1003 if (!free_list.next) {
1004
1005 /* Nothing on free list, put this at head */
1006 px->next = free_list.next;
1007 px->prev = &free_list;
1008 free_list.next = px;
1009 pf = px;
1010 px = 0;
1011
1012 } else {
1013
1014 /* Find the right spot, leave pf pointing to the modified entry. */
1015 tail = (char *)ptr+l;
1016
1017 for(pf = free_list.next; pf->end < ptr && pf->next; pf = pf->next)
1018 ; /* Race ahead here */
1019
1020 if (pf->page > tail) {
1021 /* Insert before entry */
1022 px->next = pf;
1023 px->prev = pf->prev;
1024 pf->prev = px;
1025 px->prev->next = px;
1026 pf = px;
1027 px = 0;
1028 } else if (pf->end == ptr ) {
1029 /* Append to the previous entry */
1030 pf->end = (char *)pf->end + l;
1031 pf->size += l;
1032 if (pf->next && pf->end == pf->next->page ) {
1033 /* And collapse the next too. */
1034 pt = pf->next;
1035 pf->end = pt->end;
1036 pf->size += pt->size;
1037 pf->next = pt->next;
1038 if (pf->next)
1039 pf->next->prev = pf;
1040 }
1041 } else if (pf->page == tail) {
1042 /* Prepend to entry */
1043 pf->size += l;
1044 pf->page = ptr;
1045 } else if (!pf->next) {
1046 /* Append at tail of chain */
1047 px->next = 0;
1048 px->prev = pf;
1049 pf->next = px;
1050 pf = px;
1051 px = 0;
1052 } else {
1053 wrterror("freelist is destroyed.\n");
1054 }
1055 }
1056
1057 /* Return something to OS ? */
1058 if (!pf->next && /* If we're the last one, */
1059 pf->size > malloc_cache && /* ..and the cache is full, */
1060 pf->end == malloc_brk && /* ..and none behind us, */
1061 malloc_brk == sbrk(0)) { /* ..and it's OK to do... */
1062
1063 /*
1064 * Keep the cache intact. Notice that the '>' above guarantees that
1065 * the pf will always have at least one page afterwards.
1066 */
1067 pf->end = (char *)pf->page + malloc_cache;
1068 pf->size = malloc_cache;
1069
1070 brk(pf->end);
1071 malloc_brk = pf->end;
1072
1073 index = ptr2index(pf->end);
1074 last_index = index - 1;
1075
1076 for(i=index;i <= last_index;)
1077 page_dir[i++] = MALLOC_NOT_MINE;
1078
1079 /* XXX: We could realloc/shrink the pagedir here I guess. */
1080 }
1081 if (pt)
1082 ifree(pt);
1083}
1084
1085/*
1086 * Free a chunk, and possibly the page it's on, if the page becomes empty.
1087 */
1088
1089/* ARGSUSED */
1090static __inline__ void
1091free_bytes(ptr, index, info)
1092 void *ptr;
1093 int index;
1094 struct pginfo *info;
1095{
1096 int i;
1097 struct pginfo **mp;
1098 void *vp;
1099
1100 /* Find the chunk number on the page */
1101 i = ((u_long)ptr & malloc_pagemask) >> info->shift;
1102
1103 if (((u_long)ptr & (info->size-1))) {
1104 wrtwarning("modified (chunk-) pointer.\n");
1105 return;
1106 }
1107
1108 if (info->bits[i/MALLOC_BITS] & (1UL<<(i%MALLOC_BITS))) {
1109 wrtwarning("chunk is already free.\n");
1110 return;
1111 }
1112
1113 if (malloc_junk)
1114 memset(ptr, SOME_JUNK, info->size);
1115
1116 info->bits[i/MALLOC_BITS] |= 1UL<<(i%MALLOC_BITS);
1117 info->free++;
1118
1119 mp = page_dir + info->shift;
1120
1121 if (info->free == 1) {
1122
1123 /* Page became non-full */
1124
1125 mp = page_dir + info->shift;
1126 /* Insert in address order */
1127 while (*mp && (*mp)->next && (*mp)->next->page < info->page)
1128 mp = &(*mp)->next;
1129 info->next = *mp;
1130 *mp = info;
1131 return;
1132 }
1133
1134 if (info->free != info->total)
1135 return;
1136
1137 /* Find & remove this page in the queue */
1138 while (*mp != info) {
1139 mp = &((*mp)->next);
1140#ifdef MALLOC_EXTRA_SANITY
1141 if (!*mp)
1142 wrterror("(ES): Not on queue\n");
1143#endif /* MALLOC_EXTRA_SANITY */
1144 }
1145 *mp = info->next;
1146
1147 /* Free the page & the info structure if need be */
1148 page_dir[ptr2index(info->page)] = MALLOC_FIRST;
1149 vp = info->page; /* Order is important ! */
1150 if(vp != (void*)info)
1151 ifree(info);
1152 ifree(vp);
1153}
1154
1155static void
1156ifree(ptr)
1157 void *ptr;
1158{
1159 struct pginfo *info;
1160 int index;
1161
1162 /* This is legal */
1163 if (!ptr)
1164 return;
1165
1166 if (!malloc_started) {
1167 wrtwarning("malloc() has never been called.\n");
1168 return;
1169 }
1170
1171 /* If we're already sinking, don't make matters any worse. */
1172 if (suicide)
1173 return;
1174
1175 index = ptr2index(ptr);
1176
1177 if (index < malloc_pageshift) {
1178 wrtwarning("junk pointer, too low to make sense.\n");
1179 return;
1180 }
1181
1182 if (index > last_index) {
1183 wrtwarning("junk pointer, too high to make sense.\n");
1184 return;
1185 }
1186
1187 info = page_dir[index];
1188
1189 if (info < MALLOC_MAGIC)
1190 free_pages(ptr, index, info);
1191 else
1192 free_bytes(ptr, index, info);
1193 return;
1194}
1195
1196/*
1197 * These are the public exported interface routines.
1198 */
1199
1200static int malloc_active;
1201
1202void *
1203malloc(size_t size)
1204{
1205 register void *r;
1206
1207 malloc_func = " in malloc():";
1208 THREAD_LOCK();
1209 if (malloc_active++) {
1210 wrtwarning("recursive call.\n");
1211 malloc_active--;
1212 return (0);
1213 }
1214 r = imalloc(size);
1215 UTRACE(0, size, r);
1216 malloc_active--;
1217 THREAD_UNLOCK();
1218 if (malloc_xmalloc && !r)
1219 wrterror("out of memory.\n");
1220 return (r);
1221}
1222
1223void
1224free(void *ptr)
1225{
1226 malloc_func = " in free():";
1227 THREAD_LOCK();
1228 if (malloc_active++) {
1229 wrtwarning("recursive call.\n");
1230 malloc_active--;
1231 return;
1232 }
1233 ifree(ptr);
1234 UTRACE(ptr, 0, 0);
1235 malloc_active--;
1236 THREAD_UNLOCK();
1237 return;
1238}
1239
1240void *
1241realloc(void *ptr, size_t size)
1242{
1243 register void *r;
1244
1245 malloc_func = " in realloc():";
1246 THREAD_LOCK();
1247 if (malloc_active++) {
1248 wrtwarning("recursive call.\n");
1249 malloc_active--;
1250 return (0);
1251 }
1252 if (!ptr) {
1253 r = imalloc(size);
1254 } else {
1255 r = irealloc(ptr, size);
1256 }
1257 UTRACE(ptr, size, r);
1258 malloc_active--;
1259 THREAD_UNLOCK();
1260 if (malloc_xmalloc && !r)
1261 wrterror("out of memory.\n");
1262 return (r);
1263}
diff --git a/src/lib/libc/stdlib/memory.3 b/src/lib/libc/stdlib/memory.3
new file mode 100644
index 0000000000..712c7c45d2
--- /dev/null
+++ b/src/lib/libc/stdlib/memory.3
@@ -0,0 +1,70 @@
1.\" Copyright (c) 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" $OpenBSD: memory.3,v 1.2 1996/08/19 08:33:37 tholo Exp $
33.\"
34.Dd May 2, 1991
35.Dt MEMORY 3
36.Os BSD 4
37.Sh NAME
38.Nm malloc ,
39.Nm free ,
40.Nm realloc ,
41.Nm calloc ,
42.Nm alloca
43.Nd general memory allocation operations
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft void *
47.Fn malloc "size_t size"
48.Ft void
49.Fn free "void *ptr"
50.Ft void *
51.Fn realloc "void *ptr" "size_t size"
52.Ft void *
53.Fn calloc "size_t nelem" "size_t elsize"
54.Ft void *
55.Fn alloca "size_t size"
56.Sh DESCRIPTION
57These functions allocate and free memory for the calling process.
58They are described in the
59individual manual pages.
60.Sh SEE ALSO
61.Xr calloc 3 ,
62.Xr free 3 ,
63.Xr malloc 3 ,
64.Xr realloc 3 ,
65.Xr alloca 3 ,
66.Sh STANDARDS
67These functions, with the exception of
68.Fn alloca
69conform to
70.St -ansiC .
diff --git a/src/lib/libc/stdlib/merge.c b/src/lib/libc/stdlib/merge.c
new file mode 100644
index 0000000000..0a1015ad9d
--- /dev/null
+++ b/src/lib/libc/stdlib/merge.c
@@ -0,0 +1,347 @@
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Peter McIlroy.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: merge.c,v 1.3 1996/09/15 09:31:50 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41/*
42 * Hybrid exponential search/linear search merge sort with hybrid
43 * natural/pairwise first pass. Requires about .3% more comparisons
44 * for random data than LSMS with pairwise first pass alone.
45 * It works for objects as small as two bytes.
46 */
47
48#define NATURAL
49#define THRESHOLD 16 /* Best choice for natural merge cut-off. */
50
51/* #define NATURAL to get hybrid natural merge.
52 * (The default is pairwise merging.)
53 */
54
55#include <sys/types.h>
56
57#include <errno.h>
58#include <stdlib.h>
59#include <string.h>
60
61static void setup __P((u_char *, u_char *, size_t, size_t, int (*)()));
62static void insertionsort __P((u_char *, size_t, size_t, int (*)()));
63
64#define ISIZE sizeof(int)
65#define PSIZE sizeof(u_char *)
66#define ICOPY_LIST(src, dst, last) \
67 do \
68 *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE; \
69 while(src < last)
70#define ICOPY_ELT(src, dst, i) \
71 do \
72 *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE; \
73 while (i -= ISIZE)
74
75#define CCOPY_LIST(src, dst, last) \
76 do \
77 *dst++ = *src++; \
78 while (src < last)
79#define CCOPY_ELT(src, dst, i) \
80 do \
81 *dst++ = *src++; \
82 while (i -= 1)
83
84/*
85 * Find the next possible pointer head. (Trickery for forcing an array
86 * to do double duty as a linked list when objects do not align with word
87 * boundaries.
88 */
89/* Assumption: PSIZE is a power of 2. */
90#define EVAL(p) (u_char **) \
91 ((u_char *)0 + \
92 (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1)))
93
94/*
95 * Arguments are as for qsort.
96 */
97int
98mergesort(base, nmemb, size, cmp)
99 void *base;
100 size_t nmemb;
101 register size_t size;
102 int (*cmp) __P((const void *, const void *));
103{
104 register int i, sense;
105 int big, iflag;
106 register u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2;
107 u_char *list2, *list1, *p2, *p, *last, **p1;
108
109 if (size < PSIZE / 2) { /* Pointers must fit into 2 * size. */
110 errno = EINVAL;
111 return (-1);
112 }
113
114 /*
115 * XXX
116 * Stupid subtraction for the Cray.
117 */
118 iflag = 0;
119 if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
120 iflag = 1;
121
122 if ((list2 = malloc(nmemb * size + PSIZE)) == NULL)
123 return (-1);
124
125 list1 = base;
126 setup(list1, list2, nmemb, size, cmp);
127 last = list2 + nmemb * size;
128 i = big = 0;
129 while (*EVAL(list2) != last) {
130 l2 = list1;
131 p1 = EVAL(list1);
132 for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) {
133 p2 = *EVAL(p2);
134 f1 = l2;
135 f2 = l1 = list1 + (p2 - list2);
136 if (p2 != last)
137 p2 = *EVAL(p2);
138 l2 = list1 + (p2 - list2);
139 while (f1 < l1 && f2 < l2) {
140 if ((*cmp)(f1, f2) <= 0) {
141 q = f2;
142 b = f1, t = l1;
143 sense = -1;
144 } else {
145 q = f1;
146 b = f2, t = l2;
147 sense = 0;
148 }
149 if (!big) { /* here i = 0 */
150 while ((b += size) < t && cmp(q, b) >sense)
151 if (++i == 6) {
152 big = 1;
153 goto EXPONENTIAL;
154 }
155 } else {
156EXPONENTIAL: for (i = size; ; i <<= 1)
157 if ((p = (b + i)) >= t) {
158 if ((p = t - size) > b &&
159 (*cmp)(q, p) <= sense)
160 t = p;
161 else
162 b = p;
163 break;
164 } else if ((*cmp)(q, p) <= sense) {
165 t = p;
166 if (i == size)
167 big = 0;
168 goto FASTCASE;
169 } else
170 b = p;
171 while (t > b+size) {
172 i = (((t - b) / size) >> 1) * size;
173 if ((*cmp)(q, p = b + i) <= sense)
174 t = p;
175 else
176 b = p;
177 }
178 goto COPY;
179FASTCASE: while (i > size)
180 if ((*cmp)(q,
181 p = b + (i >>= 1)) <= sense)
182 t = p;
183 else
184 b = p;
185COPY: b = t;
186 }
187 i = size;
188 if (q == f1) {
189 if (iflag) {
190 ICOPY_LIST(f2, tp2, b);
191 ICOPY_ELT(f1, tp2, i);
192 } else {
193 CCOPY_LIST(f2, tp2, b);
194 CCOPY_ELT(f1, tp2, i);
195 }
196 } else {
197 if (iflag) {
198 ICOPY_LIST(f1, tp2, b);
199 ICOPY_ELT(f2, tp2, i);
200 } else {
201 CCOPY_LIST(f1, tp2, b);
202 CCOPY_ELT(f2, tp2, i);
203 }
204 }
205 }
206 if (f2 < l2) {
207 if (iflag)
208 ICOPY_LIST(f2, tp2, l2);
209 else
210 CCOPY_LIST(f2, tp2, l2);
211 } else if (f1 < l1) {
212 if (iflag)
213 ICOPY_LIST(f1, tp2, l1);
214 else
215 CCOPY_LIST(f1, tp2, l1);
216 }
217 *p1 = l2;
218 }
219 tp2 = list1; /* swap list1, list2 */
220 list1 = list2;
221 list2 = tp2;
222 last = list2 + nmemb*size;
223 }
224 if (base == list2) {
225 memmove(list2, list1, nmemb*size);
226 list2 = list1;
227 }
228 free(list2);
229 return (0);
230}
231
232#define swap(a, b) { \
233 s = b; \
234 i = size; \
235 do { \
236 tmp = *a; *a++ = *s; *s++ = tmp; \
237 } while (--i); \
238 a -= size; \
239 }
240#define reverse(bot, top) { \
241 s = top; \
242 do { \
243 i = size; \
244 do { \
245 tmp = *bot; *bot++ = *s; *s++ = tmp; \
246 } while (--i); \
247 s -= size2; \
248 } while(bot < s); \
249}
250
251/*
252 * Optional hybrid natural/pairwise first pass. Eats up list1 in runs of
253 * increasing order, list2 in a corresponding linked list. Checks for runs
254 * when THRESHOLD/2 pairs compare with same sense. (Only used when NATURAL
255 * is defined. Otherwise simple pairwise merging is used.)
256 */
257void
258setup(list1, list2, n, size, cmp)
259 size_t n, size;
260 int (*cmp) __P((const void *, const void *));
261 u_char *list1, *list2;
262{
263 int i, length, size2, tmp, sense;
264 u_char *f1, *f2, *s, *l2, *last, *p2;
265
266 size2 = size*2;
267 if (n <= 5) {
268 insertionsort(list1, n, size, cmp);
269 *EVAL(list2) = (u_char*) list2 + n*size;
270 return;
271 }
272 /*
273 * Avoid running pointers out of bounds; limit n to evens
274 * for simplicity.
275 */
276 i = 4 + (n & 1);
277 insertionsort(list1 + (n - i) * size, i, size, cmp);
278 last = list1 + size * (n - i);
279 *EVAL(list2 + (last - list1)) = list2 + n * size;
280
281#ifdef NATURAL
282 p2 = list2;
283 f1 = list1;
284 sense = (cmp(f1, f1 + size) > 0);
285 for (; f1 < last; sense = !sense) {
286 length = 2;
287 /* Find pairs with same sense. */
288 for (f2 = f1 + size2; f2 < last; f2 += size2) {
289 if ((cmp(f2, f2+ size) > 0) != sense)
290 break;
291 length += 2;
292 }
293 if (length < THRESHOLD) { /* Pairwise merge */
294 do {
295 p2 = *EVAL(p2) = f1 + size2 - list1 + list2;
296 if (sense > 0)
297 swap (f1, f1 + size);
298 } while ((f1 += size2) < f2);
299 } else { /* Natural merge */
300 l2 = f2;
301 for (f2 = f1 + size2; f2 < l2; f2 += size2) {
302 if ((cmp(f2-size, f2) > 0) != sense) {
303 p2 = *EVAL(p2) = f2 - list1 + list2;
304 if (sense > 0)
305 reverse(f1, f2-size);
306 f1 = f2;
307 }
308 }
309 if (sense > 0)
310 reverse (f1, f2-size);
311 f1 = f2;
312 if (f2 < last || cmp(f2 - size, f2) > 0)
313 p2 = *EVAL(p2) = f2 - list1 + list2;
314 else
315 p2 = *EVAL(p2) = list2 + n*size;
316 }
317 }
318#else /* pairwise merge only. */
319 for (f1 = list1, p2 = list2; f1 < last; f1 += size2) {
320 p2 = *EVAL(p2) = p2 + size2;
321 if (cmp (f1, f1 + size) > 0)
322 swap(f1, f1 + size);
323 }
324#endif /* NATURAL */
325}
326
327/*
328 * This is to avoid out-of-bounds addresses in sorting the
329 * last 4 elements.
330 */
331static void
332insertionsort(a, n, size, cmp)
333 u_char *a;
334 size_t n, size;
335 int (*cmp) __P((const void *, const void *));
336{
337 u_char *ai, *s, *t, *u, tmp;
338 int i;
339
340 for (ai = a+size; --n >= 1; ai += size)
341 for (t = ai; t > a; t -= size) {
342 u = t - size;
343 if (cmp(u, t) <= 0)
344 break;
345 swap(u, t);
346 }
347}
diff --git a/src/lib/libc/stdlib/mrand48.c b/src/lib/libc/stdlib/mrand48.c
new file mode 100644
index 0000000000..cd34260b5c
--- /dev/null
+++ b/src/lib/libc/stdlib/mrand48.c
@@ -0,0 +1,27 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 */
13
14#if defined(LIBC_SCCS) && !defined(lint)
15static char rcsid[] = "$OpenBSD: mrand48.c,v 1.2 1996/08/19 08:33:39 tholo Exp $";
16#endif /* LIBC_SCCS and not lint */
17
18#include "rand48.h"
19
20extern unsigned short __rand48_seed[3];
21
22long
23mrand48(void)
24{
25 __dorand48(__rand48_seed);
26 return ((long) __rand48_seed[2] << 16) + (long) __rand48_seed[1];
27}
diff --git a/src/lib/libc/stdlib/multibyte.c b/src/lib/libc/stdlib/multibyte.c
new file mode 100644
index 0000000000..12e70c4a2c
--- /dev/null
+++ b/src/lib/libc/stdlib/multibyte.c
@@ -0,0 +1,130 @@
1/*
2 * Copyright (c) 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: multibyte.c,v 1.2 1996/08/19 08:33:39 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39
40/*
41 * Stub multibyte character functions.
42 * This cheezy implementation is fixed to the native single-byte
43 * character set.
44 */
45
46int
47mblen(s, n)
48 const char *s;
49 size_t n;
50{
51 if (s == NULL || *s == '\0')
52 return 0;
53 if (n == 0)
54 return -1;
55 return 1;
56}
57
58/*ARGSUSED*/
59int
60mbtowc(pwc, s, n)
61 wchar_t *pwc;
62 const char *s;
63 size_t n;
64{
65 if (s == NULL)
66 return 0;
67 if (n == 0)
68 return -1;
69 if (pwc)
70 *pwc = (wchar_t) *s;
71 return (*s != '\0');
72}
73
74/*ARGSUSED*/
75int
76#ifdef __STDC__
77wctomb(char *s, wchar_t wchar)
78#else
79wctomb(s, wchar)
80 char *s;
81 wchar_t wchar;
82#endif
83{
84 if (s == NULL)
85 return 0;
86
87 *s = (char) wchar;
88 return 1;
89}
90
91/*ARGSUSED*/
92size_t
93mbstowcs(pwcs, s, n)
94 wchar_t *pwcs;
95 const char *s;
96 size_t n;
97{
98 int count = 0;
99
100 if (n != 0) {
101 do {
102 if ((*pwcs++ = (wchar_t) *s++) == 0)
103 break;
104 count++;
105 } while (--n != 0);
106 }
107
108 return count;
109}
110
111/*ARGSUSED*/
112size_t
113wcstombs(s, pwcs, n)
114 char *s;
115 const wchar_t *pwcs;
116 size_t n;
117{
118 int count = 0;
119
120 if (n != 0) {
121 do {
122 if ((*s++ = (char) *pwcs++) == 0)
123 break;
124 count++;
125 } while (--n != 0);
126 }
127
128 return count;
129}
130
diff --git a/src/lib/libc/stdlib/nrand48.c b/src/lib/libc/stdlib/nrand48.c
new file mode 100644
index 0000000000..b1ec2cebb1
--- /dev/null
+++ b/src/lib/libc/stdlib/nrand48.c
@@ -0,0 +1,25 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 */
13
14#if defined(LIBC_SCCS) && !defined(lint)
15static char rcsid[] = "$OpenBSD: nrand48.c,v 1.2 1996/08/19 08:33:40 tholo Exp $";
16#endif /* LIBC_SCCS and not lint */
17
18#include "rand48.h"
19
20long
21nrand48(unsigned short xseed[3])
22{
23 __dorand48(xseed);
24 return ((long) xseed[2] << 15) + ((long) xseed[1] >> 1);
25}
diff --git a/src/lib/libc/stdlib/putenv.c b/src/lib/libc/stdlib/putenv.c
new file mode 100644
index 0000000000..d8c4886d4b
--- /dev/null
+++ b/src/lib/libc/stdlib/putenv.c
@@ -0,0 +1,58 @@
1/*-
2 * Copyright (c) 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: putenv.c,v 1.2 1996/08/10 05:03:00 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39#include <string.h>
40
41int
42putenv(str)
43 const char *str;
44{
45 char *p, *equal;
46 int rval;
47
48 if ((p = strdup(str)) == NULL)
49 return (-1);
50 if ((equal = strchr(p, '=')) == NULL) {
51 (void)free(p);
52 return (-1);
53 }
54 *equal = '\0';
55 rval = setenv(p, equal + 1, 1);
56 (void)free(p);
57 return (rval);
58}
diff --git a/src/lib/libc/stdlib/qabs.3 b/src/lib/libc/stdlib/qabs.3
new file mode 100644
index 0000000000..92a8bdc4b9
--- /dev/null
+++ b/src/lib/libc/stdlib/qabs.3
@@ -0,0 +1,61 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: qabs.3,v 1.2 1996/08/19 08:33:40 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt QABS 3
40.Os
41.Sh NAME
42.Nm qabs
43.Nd return the absolute value of a quad integer
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft quad_t
47.Fn qabs "quad_t j"
48.Sh DESCRIPTION
49The
50.Fn qabs
51function
52returns the absolute value of the quad integer
53.Ar j .
54.Sh SEE ALSO
55.Xr abs 3 ,
56.Xr labs 3 ,
57.Xr floor 3 ,
58.Xr cabs 3 ,
59.Xr math 3
60.Sh BUGS
61The absolute value of the most negative integer remains negative.
diff --git a/src/lib/libc/stdlib/qabs.c b/src/lib/libc/stdlib/qabs.c
new file mode 100644
index 0000000000..ccc42cbec6
--- /dev/null
+++ b/src/lib/libc/stdlib/qabs.c
@@ -0,0 +1,45 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: qabs.c,v 1.2 1996/08/19 08:33:40 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39
40quad_t
41qabs(j)
42 quad_t j;
43{
44 return(j < 0 ? -j : j);
45}
diff --git a/src/lib/libc/stdlib/qdiv.3 b/src/lib/libc/stdlib/qdiv.3
new file mode 100644
index 0000000000..12aca0b1ea
--- /dev/null
+++ b/src/lib/libc/stdlib/qdiv.3
@@ -0,0 +1,65 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: qdiv.3,v 1.2 1996/08/19 08:33:41 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt QDIV 3
40.Os
41.Sh NAME
42.Nm qdiv
43.Nd return quotient and remainder from division
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft qdiv_t
47.Fn qdiv "quad_t num" "quad_t denom"
48.Sh DESCRIPTION
49The
50.Fn qdiv
51function
52computes the value
53.Ar num/denom
54and returns the quotient and remainder in a structure named
55.Ar qdiv_t
56that contains two
57.Em quad integer
58members named
59.Ar quot
60and
61.Ar rem .
62.Sh SEE ALSO
63.Xr div 3 ,
64.Xr ldiv 3 ,
65.Xr math 3
diff --git a/src/lib/libc/stdlib/qdiv.c b/src/lib/libc/stdlib/qdiv.c
new file mode 100644
index 0000000000..07e84cd649
--- /dev/null
+++ b/src/lib/libc/stdlib/qdiv.c
@@ -0,0 +1,58 @@
1/*
2 * Copyright (c) 1990 Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: qdiv.c,v 1.2 1996/08/19 08:33:41 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <stdlib.h> /* qdiv_t */
42
43qdiv_t
44qdiv(num, denom)
45 quad_t num, denom;
46{
47 qdiv_t r;
48
49 /* see div.c for comments */
50
51 r.quot = num / denom;
52 r.rem = num % denom;
53 if (num >= 0 && r.rem < 0) {
54 r.quot++;
55 r.rem -= denom;
56 }
57 return (r);
58}
diff --git a/src/lib/libc/stdlib/qsort.3 b/src/lib/libc/stdlib/qsort.3
new file mode 100644
index 0000000000..0a71824450
--- /dev/null
+++ b/src/lib/libc/stdlib/qsort.3
@@ -0,0 +1,233 @@
1.\" Copyright (c) 1990, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: qsort.3,v 1.3 1999/02/27 21:56:00 deraadt Exp $
37.\"
38.Dd June 4, 1993
39.Dt QSORT 3
40.Os
41.Sh NAME
42.Nm qsort, heapsort, mergesort
43.Nd sort functions
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft void
47.Fn qsort "void *base" "size_t nmemb" "size_t size" "int (*compar)(const void *, const void *)"
48.Ft int
49.Fn heapsort "void *base" "size_t nmemb" "size_t size" "int (*compar)(const void *, const void *)"
50.Ft int
51.Fn mergesort "void *base" "size_t nmemb" "size_t size" "int (*compar)(const void *, const void *)"
52.Sh DESCRIPTION
53The
54.Fn qsort
55function is a modified partition-exchange sort, or quicksort.
56The
57.Fn heapsort
58function is a modified selection sort.
59The
60.Fn mergesort
61function is a modified merge sort with exponential search
62intended for sorting data with pre-existing order.
63.Pp
64The
65.Fn qsort
66and
67.Fn heapsort
68functions sort an array of
69.Fa nmemb
70objects, the initial member of which is pointed to by
71.Fa base .
72The size of each object is specified by
73.Fa size .
74.Fn mergesort
75behaves similarly, but
76.Em requires
77that
78.Fa size
79be greater than
80.Dq "sizeof(void *) / 2" .
81.Pp
82The contents of the array
83.Fa base
84are sorted in ascending order according to
85a comparison function pointed to by
86.Fa compar ,
87which requires two arguments pointing to the objects being
88compared.
89.Pp
90The comparison function must return an integer less than, equal to, or
91greater than zero if the first argument is considered to be respectively
92less than, equal to, or greater than the second.
93.Pp
94The functions
95.Fn qsort
96and
97.Fn heapsort
98are
99.Em not
100stable, that is, if two members compare as equal, their order in
101the sorted array is undefined.
102The function
103.Fn mergesort
104is stable.
105.Pp
106The
107.Fn qsort
108function is an implementation of C.A.R. Hoare's ``quicksort'' algorithm,
109a variant of partition-exchange sorting; in particular, see D.E. Knuth's
110Algorithm Q.
111.Fn qsort
112takes O N lg N average time.
113This implementation uses median selection to avoid its
114O N**2 worst-case behavior.
115.Pp
116The
117.Fn heapsort
118function is an implementation of J.W.J. William's ``heapsort'' algorithm,
119a variant of selection sorting; in particular, see D.E. Knuth's Algorithm H.
120.Fn heapsort
121takes O N lg N worst-case time.
122Its
123.Em only
124advantage over
125.Fn qsort
126is that it uses almost no additional memory; while
127.Fn qsort
128does not allocate memory, it is implemented using recursion.
129.Pp
130The function
131.Fn mergesort
132requires additional memory of size
133.Fa nmemb *
134.Fa size
135bytes; it should be used only when space is not at a premium.
136.Fn mergesort
137is optimized for data with pre-existing order; its worst case
138time is O N lg N; its best case is O N.
139.Pp
140Normally,
141.Fn qsort
142is faster than
143.Fn mergesort
144is faster than
145.Fn heapsort .
146Memory availability and pre-existing order in the data can make this
147untrue.
148.Sh RETURN VALUES
149The
150.Fn qsort
151function
152returns no value.
153.Pp
154Upon successful completion,
155.Fn heapsort
156and
157.Fn mergesort
158return 0.
159Otherwise, they return \-1 and the global variable
160.Va errno
161is set to indicate the error.
162.Sh ERRORS
163The
164.Fn heapsort
165function succeeds unless:
166.Bl -tag -width Er
167.It Bq Er EINVAL
168The
169.Fa size
170argument is zero, or,
171the
172.Fa size
173argument to
174.Fn mergesort
175is less than
176.Dq "sizeof(void *) / 2" .
177.It Bq Er ENOMEM
178.Fn heapsort
179or
180.Fn mergesort
181were unable to allocate memory.
182.El
183.Sh COMPATIBILITY
184Previous versions of
185.Fn qsort
186did not permit the comparison routine itself to call
187.Fn qsort 3 .
188This is no longer true.
189.Sh SEE ALSO
190.Xr sort 1 ,
191.Xr radixsort 3
192.Rs
193.%A Hoare, C.A.R.
194.%D 1962
195.%T "Quicksort"
196.%J "The Computer Journal"
197.%V 5:1
198.%P pp. 10-15
199.Re
200.Rs
201.%A Williams, J.W.J
202.%D 1964
203.%T "Heapsort"
204.%J "Communications of the ACM"
205.%V 7:1
206.%P pp. 347-348
207.Re
208.Rs
209.%A Knuth, D.E.
210.%D 1968
211.%B "The Art of Computer Programming"
212.%V Vol. 3
213.%T "Sorting and Searching"
214.%P pp. 114-123, 145-149
215.Re
216.Rs
217.%A Mcilroy, P.M.
218.%T "Optimistic Sorting and Information Theoretic Complexity"
219.%J "Fourth Annual ACM-SIAM Symposium on Discrete Algorithms"
220.%V January 1992
221.Re
222.Rs
223.%A Bentley, J.L.
224.%T "Engineering a Sort Function"
225.%J "bentley@research.att.com"
226.%V January 1992
227.Re
228.Sh STANDARDS
229The
230.Fn qsort
231function
232conforms to
233.St -ansiC .
diff --git a/src/lib/libc/stdlib/qsort.c b/src/lib/libc/stdlib/qsort.c
new file mode 100644
index 0000000000..1c3020b595
--- /dev/null
+++ b/src/lib/libc/stdlib/qsort.c
@@ -0,0 +1,175 @@
1/*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: qsort.c,v 1.5 1997/06/20 11:19:38 deraadt Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <stdlib.h>
40
41static __inline char *med3 __P((char *, char *, char *, int (*)()));
42static __inline void swapfunc __P((char *, char *, int, int));
43
44#define min(a, b) (a) < (b) ? a : b
45
46/*
47 * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
48 */
49#define swapcode(TYPE, parmi, parmj, n) { \
50 long i = (n) / sizeof (TYPE); \
51 register TYPE *pi = (TYPE *) (parmi); \
52 register TYPE *pj = (TYPE *) (parmj); \
53 do { \
54 register TYPE t = *pi; \
55 *pi++ = *pj; \
56 *pj++ = t; \
57 } while (--i > 0); \
58}
59
60#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
61 es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
62
63static __inline void
64swapfunc(a, b, n, swaptype)
65 char *a, *b;
66 int n, swaptype;
67{
68 if (swaptype <= 1)
69 swapcode(long, a, b, n)
70 else
71 swapcode(char, a, b, n)
72}
73
74#define swap(a, b) \
75 if (swaptype == 0) { \
76 long t = *(long *)(a); \
77 *(long *)(a) = *(long *)(b); \
78 *(long *)(b) = t; \
79 } else \
80 swapfunc(a, b, es, swaptype)
81
82#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
83
84static __inline char *
85med3(a, b, c, cmp)
86 char *a, *b, *c;
87 int (*cmp)();
88{
89 return cmp(a, b) < 0 ?
90 (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
91 :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
92}
93
94void
95qsort(aa, n, es, cmp)
96 void *aa;
97 size_t n, es;
98 int (*cmp)();
99{
100 char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
101 int d, r, swaptype, swap_cnt;
102 register char *a = aa;
103
104loop: SWAPINIT(a, es);
105 swap_cnt = 0;
106 if (n < 7) {
107 for (pm = (char *)a + es; pm < (char *) a + n * es; pm += es)
108 for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
109 pl -= es)
110 swap(pl, pl - es);
111 return;
112 }
113 pm = (char *)a + (n / 2) * es;
114 if (n > 7) {
115 pl = (char *)a;
116 pn = (char *)a + (n - 1) * es;
117 if (n > 40) {
118 d = (n / 8) * es;
119 pl = med3(pl, pl + d, pl + 2 * d, cmp);
120 pm = med3(pm - d, pm, pm + d, cmp);
121 pn = med3(pn - 2 * d, pn - d, pn, cmp);
122 }
123 pm = med3(pl, pm, pn, cmp);
124 }
125 swap(a, pm);
126 pa = pb = (char *)a + es;
127
128 pc = pd = (char *)a + (n - 1) * es;
129 for (;;) {
130 while (pb <= pc && (r = cmp(pb, a)) <= 0) {
131 if (r == 0) {
132 swap_cnt = 1;
133 swap(pa, pb);
134 pa += es;
135 }
136 pb += es;
137 }
138 while (pb <= pc && (r = cmp(pc, a)) >= 0) {
139 if (r == 0) {
140 swap_cnt = 1;
141 swap(pc, pd);
142 pd -= es;
143 }
144 pc -= es;
145 }
146 if (pb > pc)
147 break;
148 swap(pb, pc);
149 swap_cnt = 1;
150 pb += es;
151 pc -= es;
152 }
153 if (swap_cnt == 0) { /* Switch to insertion sort */
154 for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
155 for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
156 pl -= es)
157 swap(pl, pl - es);
158 return;
159 }
160
161 pn = (char *)a + n * es;
162 r = min(pa - (char *)a, pb - pa);
163 vecswap(a, pb - r, r);
164 r = min(pd - pc, pn - pd - es);
165 vecswap(pb, pn - r, r);
166 if ((r = pb - pa) > es)
167 qsort(a, r / es, es, cmp);
168 if ((r = pd - pc) > es) {
169 /* Iterate rather than recurse to save stack space */
170 a = pn - r;
171 n = r / es;
172 goto loop;
173 }
174/* qsort(pn - r, r / es, es, cmp);*/
175}
diff --git a/src/lib/libc/stdlib/radixsort.3 b/src/lib/libc/stdlib/radixsort.3
new file mode 100644
index 0000000000..8b0ea89a0f
--- /dev/null
+++ b/src/lib/libc/stdlib/radixsort.3
@@ -0,0 +1,161 @@
1.\" Copyright (c) 1990, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" $OpenBSD: radixsort.3,v 1.4 1998/06/15 17:55:08 mickey Exp $
33.\"
34.Dd January 27, 1994
35.Dt RADIXSORT 3
36.Os
37.Sh NAME
38.Nm radixsort
39.Nd radix sort
40.Sh SYNOPSIS
41.Fd #include <limits.h>
42.Fd #include <stdlib.h>
43.Ft int
44.Fn radixsort "const u_char **base" "int nmemb" "const u_char *table" "u_int endbyte"
45.Ft int
46.Fn sradixsort "const u_char **base" "int nmemb" "const u_char *table" "u_int endbyte"
47.Sh DESCRIPTION
48The
49.Fn radixsort
50and
51.Fn sradixsort
52functions
53are implementations of radix sort.
54.Pp
55These functions sort an array of pointers to byte strings, the initial
56member of which is referenced by
57.Fa base .
58The byte strings may contain any values; the end of each string
59is denoted by the user-specified value
60.Fa endbyte .
61.Pp
62Applications may specify a sort order by providing the
63.Fa table
64argument.
65If
66.Pf non- Dv NULL ,
67.Fa table
68must reference an array of
69.Dv UCHAR_MAX
70+ 1 bytes which contains the sort
71weight of each possible byte value.
72The end-of-string byte must have a sort weight of 0 or 255
73(for sorting in reverse order).
74More than one byte may have the same sort weight.
75The
76.Fa table
77argument
78is useful for applications which wish to sort different characters
79equally, for example, providing a table with the same weights
80for A-Z as for a-z will result in a case-insensitive sort.
81If
82.Fa table
83is NULL, the contents of the array are sorted in ascending order
84according to the
85.Tn ASCII
86order of the byte strings they reference and
87.Fa endbyte
88has a sorting weight of 0.
89.Pp
90The
91.Fn sradixsort
92function is stable, that is, if two elements compare as equal, their
93order in the sorted array is unchanged.
94The
95.Fn sradixsort
96function uses additional memory sufficient to hold
97.Fa nmemb
98pointers.
99.Pp
100The
101.Fn radixsort
102function is not stable, but uses no additional memory.
103.Pp
104These functions are variants of most-significant-byte radix sorting; in
105particular, see D.E. Knuth's Algorithm R and section 5.2.5, exercise 10.
106They take linear time relative to the number of bytes in the strings.
107.Sh RETURN VALUES
108Upon successful completion 0 is returned.
109Otherwise, \-1 is returned and the global variable
110.Va errno
111is set to indicate the error.
112.Sh ERRORS
113.Bl -tag -width Er
114.It Bq Er EINVAL
115The value of the
116.Fa endbyte
117element of
118.Fa table
119is not 0 or 255.
120.El
121.Pp
122Additionally, the
123.Fn sradixsort
124function
125may fail and set
126.Va errno
127for any of the errors specified for the library routine
128.Xr malloc 3 .
129.Sh SEE ALSO
130.Xr sort 1 ,
131.Xr qsort 3
132.Pp
133.Rs
134.%A Knuth, D.E.
135.%D 1968
136.%B "The Art of Computer Programming"
137.%T "Sorting and Searching"
138.%V Vol. 3
139.%P pp. 170-178
140.Re
141.Rs
142.%A Paige, R.
143.%D 1987
144.%T "Three Partition Refinement Algorithms"
145.%J "SIAM J. Comput."
146.%V Vol. 16
147.%N No. 6
148.Re
149.Rs
150.%A McIlroy, P.
151.%D 1993
152.%B "Engineering Radix Sort"
153.%T "Computing Systems"
154.%V Vol. 6:1
155.%P pp. 5-27
156.Re
157.Sh HISTORY
158The
159.Fn radixsort
160function first appeared in
161.Bx 4.4 .
diff --git a/src/lib/libc/stdlib/radixsort.c b/src/lib/libc/stdlib/radixsort.c
new file mode 100644
index 0000000000..41ed962466
--- /dev/null
+++ b/src/lib/libc/stdlib/radixsort.c
@@ -0,0 +1,317 @@
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Peter McIlroy and by Dan Bernstein at New York University,
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: radixsort.c,v 1.3 1996/08/19 08:33:44 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41/*
42 * Radixsort routines.
43 *
44 * Program r_sort_a() is unstable but uses O(logN) extra memory for a stack.
45 * Use radixsort(a, n, trace, endchar) for this case.
46 *
47 * For stable sorting (using N extra pointers) use sradixsort(), which calls
48 * r_sort_b().
49 *
50 * For a description of this code, see D. McIlroy, P. McIlroy, K. Bostic,
51 * "Engineering Radix Sort".
52 */
53
54#include <sys/types.h>
55#include <stdlib.h>
56#include <errno.h>
57
58typedef struct {
59 const u_char **sa;
60 int sn, si;
61} stack;
62
63static __inline void simplesort
64 __P((const u_char **, int, int, const u_char *, u_int));
65static void r_sort_a __P((const u_char **, int, int, const u_char *, u_int));
66static void r_sort_b __P((const u_char **,
67 const u_char **, int, int, const u_char *, u_int));
68
69#define THRESHOLD 20 /* Divert to simplesort(). */
70#define SIZE 512 /* Default stack size. */
71
72#define SETUP { \
73 if (tab == NULL) { \
74 tr = tr0; \
75 for (c = 0; c < endch; c++) \
76 tr0[c] = c + 1; \
77 tr0[c] = 0; \
78 for (c++; c < 256; c++) \
79 tr0[c] = c; \
80 endch = 0; \
81 } else { \
82 endch = tab[endch]; \
83 tr = tab; \
84 if (endch != 0 && endch != 255) { \
85 errno = EINVAL; \
86 return (-1); \
87 } \
88 } \
89}
90
91int
92radixsort(a, n, tab, endch)
93 const u_char **a, *tab;
94 int n;
95 u_int endch;
96{
97 const u_char *tr;
98 int c;
99 u_char tr0[256];
100
101 SETUP;
102 r_sort_a(a, n, 0, tr, endch);
103 return (0);
104}
105
106int
107sradixsort(a, n, tab, endch)
108 const u_char **a, *tab;
109 int n;
110 u_int endch;
111{
112 const u_char *tr, **ta;
113 int c;
114 u_char tr0[256];
115
116 SETUP;
117 if (n < THRESHOLD)
118 simplesort(a, n, 0, tr, endch);
119 else {
120 if ((ta = malloc(n * sizeof(a))) == NULL)
121 return (-1);
122 r_sort_b(a, ta, n, 0, tr, endch);
123 free(ta);
124 }
125 return (0);
126}
127
128#define empty(s) (s >= sp)
129#define pop(a, n, i) a = (--sp)->sa, n = sp->sn, i = sp->si
130#define push(a, n, i) sp->sa = a, sp->sn = n, (sp++)->si = i
131#define swap(a, b, t) t = a, a = b, b = t
132
133/* Unstable, in-place sort. */
134void
135r_sort_a(a, n, i, tr, endch)
136 const u_char **a;
137 int n, i;
138 const u_char *tr;
139 u_int endch;
140{
141 static int count[256], nc, bmin;
142 register int c;
143 register const u_char **ak, *r;
144 stack s[SIZE], *sp, *sp0, *sp1, temp;
145 int *cp, bigc;
146 const u_char **an, *t, **aj, **top[256];
147
148 /* Set up stack. */
149 sp = s;
150 push(a, n, i);
151 while (!empty(s)) {
152 pop(a, n, i);
153 if (n < THRESHOLD) {
154 simplesort(a, n, i, tr, endch);
155 continue;
156 }
157 an = a + n;
158
159 /* Make character histogram. */
160 if (nc == 0) {
161 bmin = 255; /* First occupied bin, excluding eos. */
162 for (ak = a; ak < an;) {
163 c = tr[(*ak++)[i]];
164 if (++count[c] == 1 && c != endch) {
165 if (c < bmin)
166 bmin = c;
167 nc++;
168 }
169 }
170 if (sp + nc > s + SIZE) { /* Get more stack. */
171 r_sort_a(a, n, i, tr, endch);
172 continue;
173 }
174 }
175
176 /*
177 * Set top[]; push incompletely sorted bins onto stack.
178 * top[] = pointers to last out-of-place element in bins.
179 * count[] = counts of elements in bins.
180 * Before permuting: top[c-1] + count[c] = top[c];
181 * during deal: top[c] counts down to top[c-1].
182 */
183 sp0 = sp1 = sp; /* Stack position of biggest bin. */
184 bigc = 2; /* Size of biggest bin. */
185 if (endch == 0) /* Special case: set top[eos]. */
186 top[0] = ak = a + count[0];
187 else {
188 ak = a;
189 top[255] = an;
190 }
191 for (cp = count + bmin; nc > 0; cp++) {
192 while (*cp == 0) /* Find next non-empty pile. */
193 cp++;
194 if (*cp > 1) {
195 if (*cp > bigc) {
196 bigc = *cp;
197 sp1 = sp;
198 }
199 push(ak, *cp, i+1);
200 }
201 top[cp-count] = ak += *cp;
202 nc--;
203 }
204 swap(*sp0, *sp1, temp); /* Play it safe -- biggest bin last. */
205
206 /*
207 * Permute misplacements home. Already home: everything
208 * before aj, and in bin[c], items from top[c] on.
209 * Inner loop:
210 * r = next element to put in place;
211 * ak = top[r[i]] = location to put the next element.
212 * aj = bottom of 1st disordered bin.
213 * Outer loop:
214 * Once the 1st disordered bin is done, ie. aj >= ak,
215 * aj<-aj + count[c] connects the bins in a linked list;
216 * reset count[c].
217 */
218 for (aj = a; aj < an; *aj = r, aj += count[c], count[c] = 0)
219 for (r = *aj; aj < (ak = --top[c = tr[r[i]]]);)
220 swap(*ak, r, t);
221 }
222}
223
224/* Stable sort, requiring additional memory. */
225void
226r_sort_b(a, ta, n, i, tr, endch)
227 const u_char **a, **ta;
228 int n, i;
229 const u_char *tr;
230 u_int endch;
231{
232 static int count[256], nc, bmin;
233 register int c;
234 register const u_char **ak, **ai;
235 stack s[512], *sp, *sp0, *sp1, temp;
236 const u_char **top[256];
237 int *cp, bigc;
238
239 sp = s;
240 push(a, n, i);
241 while (!empty(s)) {
242 pop(a, n, i);
243 if (n < THRESHOLD) {
244 simplesort(a, n, i, tr, endch);
245 continue;
246 }
247
248 if (nc == 0) {
249 bmin = 255;
250 for (ak = a + n; --ak >= a;) {
251 c = tr[(*ak)[i]];
252 if (++count[c] == 1 && c != endch) {
253 if (c < bmin)
254 bmin = c;
255 nc++;
256 }
257 }
258 if (sp + nc > s + SIZE) {
259 r_sort_b(a, ta, n, i, tr, endch);
260 continue;
261 }
262 }
263
264 sp0 = sp1 = sp;
265 bigc = 2;
266 if (endch == 0) {
267 top[0] = ak = a + count[0];
268 count[0] = 0;
269 } else {
270 ak = a;
271 top[255] = a + n;
272 count[255] = 0;
273 }
274 for (cp = count + bmin; nc > 0; cp++) {
275 while (*cp == 0)
276 cp++;
277 if ((c = *cp) > 1) {
278 if (c > bigc) {
279 bigc = c;
280 sp1 = sp;
281 }
282 push(ak, c, i+1);
283 }
284 top[cp-count] = ak += c;
285 *cp = 0; /* Reset count[]. */
286 nc--;
287 }
288 swap(*sp0, *sp1, temp);
289
290 for (ak = ta + n, ai = a+n; ak > ta;) /* Copy to temp. */
291 *--ak = *--ai;
292 for (ak = ta+n; --ak >= ta;) /* Deal to piles. */
293 *--top[tr[(*ak)[i]]] = *ak;
294 }
295}
296
297static __inline void
298simplesort(a, n, b, tr, endch) /* insertion sort */
299 register const u_char **a;
300 int n, b;
301 register const u_char *tr;
302 u_int endch;
303{
304 register u_char ch;
305 const u_char **ak, **ai, *s, *t;
306
307 for (ak = a+1; --n >= 1; ak++)
308 for (ai = ak; ai > a; ai--) {
309 for (s = ai[0] + b, t = ai[-1] + b;
310 (ch = tr[*s]) != endch; s++, t++)
311 if (ch != tr[*t])
312 break;
313 if (ch >= tr[*t])
314 break;
315 swap(ai[0], ai[-1], s);
316 }
317}
diff --git a/src/lib/libc/stdlib/rand.3 b/src/lib/libc/stdlib/rand.3
new file mode 100644
index 0000000000..28496ec12a
--- /dev/null
+++ b/src/lib/libc/stdlib/rand.3
@@ -0,0 +1,104 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: rand.3,v 1.5 1998/11/20 11:18:50 d Exp $
37.\"
38.Dd June 29, 1991
39.Dt RAND 3
40.Os
41.Sh NAME
42.Nm rand ,
43.Nm srand
44.Nd bad random number generator
45.Sh SYNOPSIS
46.Fd #include <stdlib.h>
47.Ft void
48.Fn srand "unsigned seed"
49.Ft int
50.Fn rand void
51.Ft int
52.Fn rand_r "unsigned int *seed"
53.Sh DESCRIPTION
54.Bf -symbolic
55These interfaces are obsoleted by
56.Xr random 3 .
57.Ef
58.Pp
59The
60.Fn rand
61function computes a sequence of pseudo-random integers in the range
62of 0 to
63.Dv RAND_MAX
64(as defined by the header file
65.Aq Pa stdlib.h ) .
66.Pp
67The
68.Fn srand
69function sets its argument as the seed for a new sequence of
70pseudo-random numbers to be returned by
71.Fn rand .
72These sequences are repeatable by calling
73.Fn srand
74with the same seed value.
75.Pp
76If no seed value is provided, the functions are automatically
77seeded with a value of 1.
78.Pp
79The
80.Fn rand_r
81is a thread-safe version of
82.Fn rand .
83Storage for the seed must be provided through the
84.Ar seed
85argument, and needs to have been initialized by the caller.
86.Sh SEE ALSO
87.Xr arc4random 3 ,
88.Xr rand48 3 ,
89.Xr random 3
90.Sh STANDARDS
91The
92.Fn rand
93and
94.Fn srand
95functions
96conform to
97.St -ansiC .
98.Pp
99The
100.Fn rand_r
101function
102conforms to ISO/IEC 9945-1 ANSI/IEEE
103.Pq Dq Tn POSIX
104Std 1003.1c Draft 10.
diff --git a/src/lib/libc/stdlib/rand.c b/src/lib/libc/stdlib/rand.c
new file mode 100644
index 0000000000..bb180886c0
--- /dev/null
+++ b/src/lib/libc/stdlib/rand.c
@@ -0,0 +1,65 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: rand.c,v 1.6 1998/12/07 21:47:22 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <stdlib.h>
40
41static u_int next = 1;
42
43int
44rand_r(seed)
45u_int *seed;
46{
47
48 *seed = *seed * 1103515245 + 12345;
49 return (*seed % ((u_int)RAND_MAX + 1));
50}
51
52int
53rand()
54{
55
56 return (rand_r(&next));
57}
58
59void
60srand(seed)
61u_int seed;
62{
63
64 next = seed;
65}
diff --git a/src/lib/libc/stdlib/rand48.3 b/src/lib/libc/stdlib/rand48.3
new file mode 100644
index 0000000000..efd6477364
--- /dev/null
+++ b/src/lib/libc/stdlib/rand48.3
@@ -0,0 +1,161 @@
1\" Copyright (c) 1993 Martin Birgmeier
2.\" All rights reserved.
3.\"
4.\" You may redistribute unmodified or modified versions of this source
5.\" code provided that the above copyright notice and this and the
6.\" following conditions are retained.
7.\"
8.\" This software is provided ``as is'', and comes with no warranties
9.\" of any kind. I shall in no event be liable for anything that happens
10.\" to anyone/anything when using this software.
11.\"
12.\" $OpenBSD: rand48.3,v 1.4 1999/03/11 01:35:01 pjanzen Exp $
13.\"
14.Dd October 8, 1993
15.Dt RAND48 3
16.Os
17.Sh NAME
18.Nm drand48 ,
19.Nm erand48 ,
20.Nm lrand48 ,
21.Nm nrand48 ,
22.Nm mrand48 ,
23.Nm jrand48 ,
24.Nm srand48 ,
25.Nm seed48 ,
26.Nm lcong48
27.Nd pseudo random number generators and initialization routines
28.Sh SYNOPSIS
29.Fd #include <stdlib.h>
30.Ft double
31.Fn drand48 void
32.Ft double
33.Fn erand48 "unsigned short xseed[3]"
34.Ft long
35.Fn lrand48 void
36.Ft long
37.Fn nrand48 "unsigned short xseed[3]"
38.Ft long
39.Fn mrand48 void
40.Ft long
41.Fn jrand48 "unsigned short xseed[3]"
42.Ft void
43.Fn srand48 "long seed"
44.Ft "unsigned short *"
45.Fn seed48 "unsigned short xseed[3]"
46.Ft void
47.Fn lcong48 "unsigned short p[7]"
48.Sh DESCRIPTION
49The
50.Fn rand48
51family of functions generates pseudo-random numbers using a linear
52congruential algorithm working on integers 48 bits in size. The
53particular formula employed is
54r(n+1) = (a * r(n) + c) mod m
55where the default values are
56for the multiplicand a = 0xfdeece66d = 25214903917 and
57the addend c = 0xb = 11. The modulus is always fixed at m = 2 ** 48.
58r(n) is called the seed of the random number generator.
59.Pp
60For all the six generator routines described next, the first
61computational step is to perform a single iteration of the algorithm.
62.Pp
63.Fn drand48
64and
65.Fn erand48
66return values of type double. The full 48 bits of r(n+1) are
67loaded into the mantissa of the returned value, with the exponent set
68such that the values produced lie in the interval [0.0, 1.0).
69.Pp
70.Fn lrand48
71and
72.Fn nrand48
73return values of type long in the range
74[0, 2**31-1]. The high-order (31) bits of
75r(n+1) are loaded into the lower bits of the returned value, with
76the topmost (sign) bit set to zero.
77.Pp
78.Fn mrand48
79and
80.Fn jrand48
81return values of type long in the range
82[-2**31, 2**31-1]. The high-order (32) bits of
83r(n+1) are loaded into the returned value.
84.Pp
85.Fn drand48 ,
86.Fn lrand48 ,
87and
88.Fn mrand48
89use an internal buffer to store r(n). For these functions
90the initial value of r(0) = 0x1234abcd330e = 20017429951246.
91.Pp
92On the other hand,
93.Fn erand48 ,
94.Fn nrand48 ,
95and
96.Fn jrand48
97use a user-supplied buffer to store the seed r(n),
98which consists of an array of 3 shorts, where the zeroth member
99holds the least significant bits.
100.Pp
101All functions share the same multiplicand and addend.
102.Pp
103.Fn srand48
104is used to initialize the internal buffer r(n) of
105.Fn drand48 ,
106.Fn lrand48 ,
107and
108.Fn mrand48
109such that the 32 bits of the seed value are copied into the upper 32 bits
110of r(n), with the lower 16 bits of r(n) arbitrarily being set to 0x330e.
111Additionally, the constant multiplicand and addend of the algorithm are
112reset to the default values given above.
113.Pp
114.Fn seed48
115also initializes the internal buffer r(n) of
116.Fn drand48 ,
117.Fn lrand48 ,
118and
119.Fn mrand48 ,
120but here all 48 bits of the seed can be specified in an array of 3 shorts,
121where the zeroth member specifies the lowest bits. Again,
122the constant multiplicand and addend of the algorithm are
123reset to the default values given above.
124.Fn seed48
125returns a pointer to an array of 3 shorts which contains the old seed.
126This array is statically allocated, so its contents are lost after
127each new call to
128.Fn seed48 .
129.Pp
130Finally,
131.Fn lcong48
132allows full control over the multiplicand and addend used in
133.Fn drand48 ,
134.Fn erand48 ,
135.Fn lrand48 ,
136.Fn nrand48 ,
137.Fn mrand48 ,
138and
139.Fn jrand48 ,
140and the seed used in
141.Fn drand48 ,
142.Fn lrand48 ,
143and
144.Fn mrand48 .
145An array of 7 shorts is passed as parameter; the first three shorts are
146used to initialize the seed; the second three are used to initialize the
147multiplicand; and the last short is used to initialize the addend.
148It is thus not possible to use values greater than 0xffff as the addend.
149.Pp
150Note that all three methods of seeding the random number generator
151always also set the multiplicand and addend for any of the six
152generator calls.
153.Pp
154For a more powerful random number generator, see
155.Xr random 3
156.Sh AUTHOR
157Martin Birgmeier
158.Sh SEE ALSO
159.Xr arc4random 3 ,
160.Xr rand 3 ,
161.Xr random 3 .
diff --git a/src/lib/libc/stdlib/rand48.h b/src/lib/libc/stdlib/rand48.h
new file mode 100644
index 0000000000..e7cb3e0333
--- /dev/null
+++ b/src/lib/libc/stdlib/rand48.h
@@ -0,0 +1,32 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 *
13 * $OpenBSD: rand48.h,v 1.2 1996/08/19 08:33:45 tholo Exp $
14 */
15
16#ifndef _RAND48_H_
17#define _RAND48_H_
18
19#include <math.h>
20#include <stdlib.h>
21
22void __dorand48 __P((unsigned short[3]));
23
24#define RAND48_SEED_0 (0x330e)
25#define RAND48_SEED_1 (0xabcd)
26#define RAND48_SEED_2 (0x1234)
27#define RAND48_MULT_0 (0xe66d)
28#define RAND48_MULT_1 (0xdeec)
29#define RAND48_MULT_2 (0x0005)
30#define RAND48_ADD (0x000b)
31
32#endif /* _RAND48_H_ */
diff --git a/src/lib/libc/stdlib/random.3 b/src/lib/libc/stdlib/random.3
new file mode 100644
index 0000000000..acfbd8cdeb
--- /dev/null
+++ b/src/lib/libc/stdlib/random.3
@@ -0,0 +1,183 @@
1.\" Copyright (c) 1983, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" $OpenBSD: random.3,v 1.6 1998/07/05 19:54:25 millert Exp $
33.\"
34.Dd April 19, 1991
35.Dt RANDOM 3
36.Os BSD 4.2
37.Sh NAME
38.Nm random ,
39.Nm srandom ,
40.Nm initstate ,
41.Nm setstate
42.Nd better random number generator; routines for changing generators
43.Sh SYNOPSIS
44.Fd #include <stdlib.h>
45.Ft long
46.Fn random void
47.Ft void
48.Fn srandom "unsigned int seed"
49.Ft char *
50.Fn initstate "unsigned int seed" "char *state" "size_t n"
51.Ft char *
52.Fn setstate "const char *state"
53.Sh DESCRIPTION
54The
55.Fn random
56function
57uses a non-linear additive feedback random number generator employing a
58default table of size 31 long integers to return successive pseudo-random
59numbers in the range from 0 to
60.if t 2\u\s731\s10\d\(mi1.
61.if n (2**31)\(mi1.
62The maximum value returned by
63.Fn random
64is
65.Dv LONG_MAX
66(as defined by the header file
67.Aq Pa limits.h ) .
68The period of this random number generator is very large, approximately
69.if t 16\(mu(2\u\s731\s10\d\(mi1).
70.if n 16*((2**31)\(mi1).
71.Pp
72The
73.Fn random Ns / Fn srandom
74have (almost) the same calling sequence and initialization properties as
75.Xr rand 3 Ns / Xr srand 3 .
76The difference is that
77.Xr rand
78produces a much less random sequence \(em in fact, the low dozen bits
79generated by rand go through a cyclic pattern. All the bits generated by
80.Fn random
81are usable. For example,
82.Sq Li random()&01
83will produce a random binary
84value.
85.Pp
86Unlike
87.Xr srand ,
88.Fn srandom
89does not return the old seed; the reason for this is that the amount of
90state information used is much more than a single word. (Two other
91routines are provided to deal with restarting/changing random
92number generators). Like
93.Xr rand 3 ,
94however,
95.Fn random
96will by default produce a sequence of numbers that can be duplicated
97by calling
98.Fn srandom
99with
100.Ql 1
101as the seed.
102.Pp
103The
104.Fn initstate
105routine allows a state array, passed in as an argument, to be initialized
106for future use. The size of the state array (in bytes) is used by
107.Fn initstate
108to decide how sophisticated a random number generator it should use \(em the
109more state, the better the random numbers will be.
110(Current "optimal" values for the amount of state information are
1118, 32, 64, 128, and 256 bytes; other amounts will be rounded down to
112the nearest known amount. Using less than 8 bytes will cause an error.)
113The seed for the initialization (which specifies a starting point for
114the random number sequence, and provides for restarting at the same
115point) is also an argument.
116The
117.Fn initstate
118function
119returns a pointer to the previous state information array.
120.Pp
121Once a state has been initialized, the
122.Fn setstate
123routine provides for rapid switching between states.
124The
125.Fn setstate
126function
127returns a pointer to the previous state array; its
128argument state array is used for further random number generation
129until the next call to
130.Fn initstate
131or
132.Fn setstate .
133.Pp
134Once a state array has been initialized, it may be restarted at a
135different point either by calling
136.Fn initstate
137(with the desired seed, the state array, and its size) or by calling
138both
139.Fn setstate
140(with the state array) and
141.Fn srandom
142(with the desired seed).
143The advantage of calling both
144.Fn setstate
145and
146.Fn srandom
147is that the size of the state array does not have to be remembered after
148it is initialized.
149.Pp
150With 256 bytes of state information, the period of the random number
151generator is greater than
152.if t 2\u\s769\s10\d,
153.if n 2**69
154which should be sufficient for most purposes.
155.Sh AUTHOR
156Earl T. Cohen
157.Sh DIAGNOSTICS
158If
159.Fn initstate
160is called with less than 8 bytes of state information, or if
161.Fn setstate
162detects that the state information has been garbled, error
163messages are printed on the standard error output.
164.Sh SEE ALSO
165.Xr arc4random 3 ,
166.Xr drand48 3 ,
167.Xr rand 3
168.Sh STANDARDS
169The
170.Fn random ,
171.Fn srandom ,
172.Fn initstate ,
173and
174.Fn setstate
175functions conform to
176.St -xpg4.2 .
177.Sh HISTORY
178These
179functions appeared in
180.Bx 4.2 .
181.Sh BUGS
182About 2/3 the speed of
183.Xr rand 3 .
diff --git a/src/lib/libc/stdlib/random.c b/src/lib/libc/stdlib/random.c
new file mode 100644
index 0000000000..79344f30f1
--- /dev/null
+++ b/src/lib/libc/stdlib/random.c
@@ -0,0 +1,370 @@
1/*
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: random.c,v 1.6 1998/02/07 02:16:25 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdio.h>
39#include <stdlib.h>
40
41/*
42 * random.c:
43 *
44 * An improved random number generation package. In addition to the standard
45 * rand()/srand() like interface, this package also has a special state info
46 * interface. The initstate() routine is called with a seed, an array of
47 * bytes, and a count of how many bytes are being passed in; this array is
48 * then initialized to contain information for random number generation with
49 * that much state information. Good sizes for the amount of state
50 * information are 32, 64, 128, and 256 bytes. The state can be switched by
51 * calling the setstate() routine with the same array as was initiallized
52 * with initstate(). By default, the package runs with 128 bytes of state
53 * information and generates far better random numbers than a linear
54 * congruential generator. If the amount of state information is less than
55 * 32 bytes, a simple linear congruential R.N.G. is used.
56 *
57 * Internally, the state information is treated as an array of longs; the
58 * zeroeth element of the array is the type of R.N.G. being used (small
59 * integer); the remainder of the array is the state information for the
60 * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of
61 * state information, which will allow a degree seven polynomial. (Note:
62 * the zeroeth word of state information also has some other information
63 * stored in it -- see setstate() for details).
64 *
65 * The random number generation technique is a linear feedback shift register
66 * approach, employing trinomials (since there are fewer terms to sum up that
67 * way). In this approach, the least significant bit of all the numbers in
68 * the state table will act as a linear feedback shift register, and will
69 * have period 2^deg - 1 (where deg is the degree of the polynomial being
70 * used, assuming that the polynomial is irreducible and primitive). The
71 * higher order bits will have longer periods, since their values are also
72 * influenced by pseudo-random carries out of the lower bits. The total
73 * period of the generator is approximately deg*(2**deg - 1); thus doubling
74 * the amount of state information has a vast influence on the period of the
75 * generator. Note: the deg*(2**deg - 1) is an approximation only good for
76 * large deg, when the period of the shift register is the dominant factor.
77 * With deg equal to seven, the period is actually much longer than the
78 * 7*(2**7 - 1) predicted by this formula.
79 */
80
81/*
82 * For each of the currently supported random number generators, we have a
83 * break value on the amount of state information (you need at least this
84 * many bytes of state info to support this random number generator), a degree
85 * for the polynomial (actually a trinomial) that the R.N.G. is based on, and
86 * the separation between the two lower order coefficients of the trinomial.
87 */
88#define TYPE_0 0 /* linear congruential */
89#define BREAK_0 8
90#define DEG_0 0
91#define SEP_0 0
92
93#define TYPE_1 1 /* x**7 + x**3 + 1 */
94#define BREAK_1 32
95#define DEG_1 7
96#define SEP_1 3
97
98#define TYPE_2 2 /* x**15 + x + 1 */
99#define BREAK_2 64
100#define DEG_2 15
101#define SEP_2 1
102
103#define TYPE_3 3 /* x**31 + x**3 + 1 */
104#define BREAK_3 128
105#define DEG_3 31
106#define SEP_3 3
107
108#define TYPE_4 4 /* x**63 + x + 1 */
109#define BREAK_4 256
110#define DEG_4 63
111#define SEP_4 1
112
113/*
114 * Array versions of the above information to make code run faster --
115 * relies on fact that TYPE_i == i.
116 */
117#define MAX_TYPES 5 /* max number of types above */
118
119static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 };
120static int seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 };
121
122/*
123 * Initially, everything is set up as if from:
124 *
125 * initstate(1, &randtbl, 128);
126 *
127 * Note that this initialization takes advantage of the fact that srandom()
128 * advances the front and rear pointers 10*rand_deg times, and hence the
129 * rear pointer which starts at 0 will also end up at zero; thus the zeroeth
130 * element of the state information, which contains info about the current
131 * position of the rear pointer is just
132 *
133 * MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3.
134 */
135
136static long randtbl[DEG_3 + 1] = {
137 TYPE_3,
138 0x991539b1, 0x16a5bce3, 0x6774a4cd, 0x3e01511e, 0x4e508aaa, 0x61048c05,
139 0xf5500617, 0x846b7115, 0x6a19892c, 0x896a97af, 0xdb48f936, 0x14898454,
140 0x37ffd106, 0xb58bff9c, 0x59e17104, 0xcf918a49, 0x09378c83, 0x52c7a471,
141 0x8d293ea9, 0x1f4fc301, 0xc3db71be, 0x39b44e1c, 0xf8a44ef9, 0x4c8b80b1,
142 0x19edc328, 0x87bf4bdd, 0xc9b240e5, 0xe9ee4b1b, 0x4382aee7, 0x535b6b41,
143 0xf3bec5da,
144};
145
146/*
147 * fptr and rptr are two pointers into the state info, a front and a rear
148 * pointer. These two pointers are always rand_sep places aparts, as they
149 * cycle cyclically through the state information. (Yes, this does mean we
150 * could get away with just one pointer, but the code for random() is more
151 * efficient this way). The pointers are left positioned as they would be
152 * from the call
153 *
154 * initstate(1, randtbl, 128);
155 *
156 * (The position of the rear pointer, rptr, is really 0 (as explained above
157 * in the initialization of randtbl) because the state table pointer is set
158 * to point to randtbl[1] (as explained below).
159 */
160static long *fptr = &randtbl[SEP_3 + 1];
161static long *rptr = &randtbl[1];
162
163/*
164 * The following things are the pointer to the state information table, the
165 * type of the current generator, the degree of the current polynomial being
166 * used, and the separation between the two pointers. Note that for efficiency
167 * of random(), we remember the first location of the state information, not
168 * the zeroeth. Hence it is valid to access state[-1], which is used to
169 * store the type of the R.N.G. Also, we remember the last location, since
170 * this is more efficient than indexing every time to find the address of
171 * the last element to see if the front and rear pointers have wrapped.
172 */
173static long *state = &randtbl[1];
174static int rand_type = TYPE_3;
175static int rand_deg = DEG_3;
176static int rand_sep = SEP_3;
177static long *end_ptr = &randtbl[DEG_3 + 1];
178
179/*
180 * srandom:
181 *
182 * Initialize the random number generator based on the given seed. If the
183 * type is the trivial no-state-information type, just remember the seed.
184 * Otherwise, initializes state[] based on the given "seed" via a linear
185 * congruential generator. Then, the pointers are set to known locations
186 * that are exactly rand_sep places apart. Lastly, it cycles the state
187 * information a given number of times to get rid of any initial dependencies
188 * introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
189 * for default usage relies on values produced by this routine.
190 */
191void
192srandom(x)
193 u_int x;
194{
195 register long int test;
196 register int i;
197 ldiv_t val;
198
199 if (rand_type == TYPE_0)
200 state[0] = x;
201 else {
202 state[0] = x;
203 for (i = 1; i < rand_deg; i++) {
204 /*
205 * Implement the following, without overflowing 31 bits:
206 *
207 * state[i] = (16807 * state[i - 1]) % 2147483647;
208 *
209 * 2^31-1 (prime) = 2147483647 = 127773*16807+2836
210 */
211 val = ldiv(state[i-1], 127773);
212 test = 16807 * val.rem - 2836 * val.quot;
213 state[i] = test + (test < 0 ? 2147483647 : 0);
214 }
215 fptr = &state[rand_sep];
216 rptr = &state[0];
217 for (i = 0; i < 10 * rand_deg; i++)
218 (void)random();
219 }
220}
221
222/*
223 * initstate:
224 *
225 * Initialize the state information in the given array of n bytes for future
226 * random number generation. Based on the number of bytes we are given, and
227 * the break values for the different R.N.G.'s, we choose the best (largest)
228 * one we can and set things up for it. srandom() is then called to
229 * initialize the state information.
230 *
231 * Note that on return from srandom(), we set state[-1] to be the type
232 * multiplexed with the current value of the rear pointer; this is so
233 * successive calls to initstate() won't lose this information and will be
234 * able to restart with setstate().
235 *
236 * Note: the first thing we do is save the current state, if any, just like
237 * setstate() so that it doesn't matter when initstate is called.
238 *
239 * Returns a pointer to the old state.
240 */
241char *
242initstate(seed, arg_state, n)
243 u_int seed; /* seed for R.N.G. */
244 char *arg_state; /* pointer to state array */
245 size_t n; /* # bytes of state info */
246{
247 register char *ostate = (char *)(&state[-1]);
248
249 if (rand_type == TYPE_0)
250 state[-1] = rand_type;
251 else
252 state[-1] = MAX_TYPES * (rptr - state) + rand_type;
253 if (n < BREAK_0)
254 return(NULL);
255 if (n < BREAK_1) {
256 rand_type = TYPE_0;
257 rand_deg = DEG_0;
258 rand_sep = SEP_0;
259 } else if (n < BREAK_2) {
260 rand_type = TYPE_1;
261 rand_deg = DEG_1;
262 rand_sep = SEP_1;
263 } else if (n < BREAK_3) {
264 rand_type = TYPE_2;
265 rand_deg = DEG_2;
266 rand_sep = SEP_2;
267 } else if (n < BREAK_4) {
268 rand_type = TYPE_3;
269 rand_deg = DEG_3;
270 rand_sep = SEP_3;
271 } else {
272 rand_type = TYPE_4;
273 rand_deg = DEG_4;
274 rand_sep = SEP_4;
275 }
276 state = &(((long *)arg_state)[1]); /* first location */
277 end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */
278 srandom(seed);
279 if (rand_type == TYPE_0)
280 state[-1] = rand_type;
281 else
282 state[-1] = MAX_TYPES*(rptr - state) + rand_type;
283 return(ostate);
284}
285
286/*
287 * setstate:
288 *
289 * Restore the state from the given state array.
290 *
291 * Note: it is important that we also remember the locations of the pointers
292 * in the current state information, and restore the locations of the pointers
293 * from the old state information. This is done by multiplexing the pointer
294 * location into the zeroeth word of the state information.
295 *
296 * Note that due to the order in which things are done, it is OK to call
297 * setstate() with the same state as the current state.
298 *
299 * Returns a pointer to the old state information.
300 */
301char *
302setstate(arg_state)
303 const char *arg_state;
304{
305 register long *new_state = (long *)arg_state;
306 register int type = new_state[0] % MAX_TYPES;
307 register int rear = new_state[0] / MAX_TYPES;
308 char *ostate = (char *)(&state[-1]);
309
310 if (rand_type == TYPE_0)
311 state[-1] = rand_type;
312 else
313 state[-1] = MAX_TYPES * (rptr - state) + rand_type;
314 switch(type) {
315 case TYPE_0:
316 case TYPE_1:
317 case TYPE_2:
318 case TYPE_3:
319 case TYPE_4:
320 rand_type = type;
321 rand_deg = degrees[type];
322 rand_sep = seps[type];
323 break;
324 default:
325 return(NULL);
326 }
327 state = &new_state[1];
328 if (rand_type != TYPE_0) {
329 rptr = &state[rear];
330 fptr = &state[(rear + rand_sep) % rand_deg];
331 }
332 end_ptr = &state[rand_deg]; /* set end_ptr too */
333 return(ostate);
334}
335
336/*
337 * random:
338 *
339 * If we are using the trivial TYPE_0 R.N.G., just do the old linear
340 * congruential bit. Otherwise, we do our fancy trinomial stuff, which is
341 * the same in all the other cases due to all the global variables that have
342 * been set up. The basic operation is to add the number at the rear pointer
343 * into the one at the front pointer. Then both pointers are advanced to
344 * the next location cyclically in the table. The value returned is the sum
345 * generated, reduced to 31 bits by throwing away the "least random" low bit.
346 *
347 * Note: the code takes advantage of the fact that both the front and
348 * rear pointers can't wrap on the same call by not testing the rear
349 * pointer if the front one has wrapped.
350 *
351 * Returns a 31-bit random number.
352 */
353long
354random()
355{
356 long i;
357
358 if (rand_type == TYPE_0)
359 i = state[0] = (state[0] * 1103515245 + 12345) & 0x7fffffff;
360 else {
361 *fptr += *rptr;
362 i = (*fptr >> 1) & 0x7fffffff; /* chucking least random bit */
363 if (++fptr >= end_ptr) {
364 fptr = state;
365 ++rptr;
366 } else if (++rptr >= end_ptr)
367 rptr = state;
368 }
369 return(i);
370}
diff --git a/src/lib/libc/stdlib/realpath.3 b/src/lib/libc/stdlib/realpath.3
new file mode 100644
index 0000000000..cc140029e4
--- /dev/null
+++ b/src/lib/libc/stdlib/realpath.3
@@ -0,0 +1,125 @@
1.\" Copyright (c) 1994
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Jan-Simon Pendry.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\" $OpenBSD: realpath.3,v 1.3 1997/05/30 07:48:30 deraadt Exp $
36.\"
37.Dd February, 16, 1994
38.Dt REALPATH 3
39.Os
40.Sh NAME
41.Nm realpath
42.Nd returns the canonicalized absolute pathname
43.Sh SYNOPSIS
44.Fd #include <sys/param.h>
45.Fd #include <stdlib.h>
46.Ft "char *"
47.Fn realpath "const char *pathname" "char resolvedname[MAXPATHLEN]"
48.Sh DESCRIPTION
49The
50.Fn realpath
51function resolves all symbolic links, extra
52.Dq /
53characters and references to
54.Pa /./
55and
56.Pa /../
57in
58.Fa pathname ,
59and copies the resulting absolute pathname into
60the memory referenced by
61.Fa resolvedname .
62The
63.Fa resolvedname
64argument
65.Em must
66refer to a buffer capable of storing at least
67.Dv MAXPATHLEN
68characters.
69.Pp
70The
71.Fn realpath
72function will resolve both absolute and relative paths
73and return the absolute pathname corresponding to
74.Fa pathname .
75All but the last component of
76.Fa pathname
77must exist when
78.Fn realpath
79is called.
80.Sh "RETURN VALUES"
81The
82.Fn realpath
83function returns
84.Fa resolved_name
85on success.
86If an error occurs,
87.Fn realpath
88returns
89.Dv NULL ,
90and
91.Fa resolved_name
92contains the pathname which caused the problem.
93.Sh ERRORS
94The function
95.Fn realpath
96may fail and set the external variable
97.Va errno
98for any of the errors specified for the library functions
99.Xr chdir 2 ,
100.Xr close 2 ,
101.Xr fchdir 2 ,
102.Xr lstat 2 ,
103.Xr open 2 ,
104.Xr readlink 2
105and
106.Xr getcwd 3 .
107.Sh CAVEATS
108This implementation of
109.Fn realpath
110differs slightly from the Solaris implementation.
111The
112.Bx 4.4
113version always returns absolute pathnames,
114whereas the Solaris implementation will,
115under certain circumstances, return a relative
116.Fa resolved_path
117when given a relative
118.Fa pathname .
119.Sh "SEE ALSO"
120.Xr getcwd 3
121.Sh HISTORY
122The
123.Fn realpath
124function call first appeared in
125.Bx 4.4 .
diff --git a/src/lib/libc/stdlib/realpath.c b/src/lib/libc/stdlib/realpath.c
new file mode 100644
index 0000000000..0288601464
--- /dev/null
+++ b/src/lib/libc/stdlib/realpath.c
@@ -0,0 +1,163 @@
1/*
2 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Jan-Simon Pendry.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: realpath.c,v 1.4 1998/05/18 09:55:19 deraadt Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <sys/param.h>
42#include <sys/stat.h>
43
44#include <errno.h>
45#include <fcntl.h>
46#include <stdlib.h>
47#include <string.h>
48#include <unistd.h>
49
50/*
51 * char *realpath(const char *path, char resolved_path[MAXPATHLEN]);
52 *
53 * Find the real name of path, by removing all ".", ".." and symlink
54 * components. Returns (resolved) on success, or (NULL) on failure,
55 * in which case the path which caused trouble is left in (resolved).
56 */
57char *
58realpath(path, resolved)
59 const char *path;
60 char *resolved;
61{
62 struct stat sb;
63 int fd, n, rootd, serrno;
64 char *p, *q, wbuf[MAXPATHLEN];
65 int symlinks = 0;
66
67 /* Save the starting point. */
68 if ((fd = open(".", O_RDONLY)) < 0) {
69 (void)strcpy(resolved, ".");
70 return (NULL);
71 }
72
73 /*
74 * Find the dirname and basename from the path to be resolved.
75 * Change directory to the dirname component.
76 * lstat the basename part.
77 * if it is a symlink, read in the value and loop.
78 * if it is a directory, then change to that directory.
79 * get the current directory name and append the basename.
80 */
81 (void)strncpy(resolved, path, MAXPATHLEN - 1);
82 resolved[MAXPATHLEN - 1] = '\0';
83loop:
84 q = strrchr(resolved, '/');
85 if (q != NULL) {
86 p = q + 1;
87 if (q == resolved)
88 q = "/";
89 else {
90 do {
91 --q;
92 } while (q > resolved && *q == '/');
93 q[1] = '\0';
94 q = resolved;
95 }
96 if (chdir(q) < 0)
97 goto err1;
98 } else
99 p = resolved;
100
101 /* Deal with the last component. */
102 if (lstat(p, &sb) == 0) {
103 if (S_ISLNK(sb.st_mode)) {
104 if (++symlinks > MAXSYMLINKS) {
105 errno = ELOOP;
106 goto err1;
107 }
108 n = readlink(p, resolved, MAXPATHLEN-1);
109 if (n < 0)
110 goto err1;
111 resolved[n] = '\0';
112 goto loop;
113 }
114 if (S_ISDIR(sb.st_mode)) {
115 if (chdir(p) < 0)
116 goto err1;
117 p = "";
118 }
119 }
120
121 /*
122 * Save the last component name and get the full pathname of
123 * the current directory.
124 */
125 (void)strcpy(wbuf, p);
126 if (getcwd(resolved, MAXPATHLEN) == 0)
127 goto err1;
128
129 /*
130 * Join the two strings together, ensuring that the right thing
131 * happens if the last component is empty, or the dirname is root.
132 */
133 if (resolved[0] == '/' && resolved[1] == '\0')
134 rootd = 1;
135 else
136 rootd = 0;
137
138 if (*wbuf) {
139 if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) {
140 errno = ENAMETOOLONG;
141 goto err1;
142 }
143 if (rootd == 0)
144 (void)strcat(resolved, "/");
145 (void)strcat(resolved, wbuf);
146 }
147
148 /* Go back to where we came from. */
149 if (fchdir(fd) < 0) {
150 serrno = errno;
151 goto err2;
152 }
153
154 /* It's okay if the close fails, what's an fd more or less? */
155 (void)close(fd);
156 return (resolved);
157
158err1: serrno = errno;
159 (void)fchdir(fd);
160err2: (void)close(fd);
161 errno = serrno;
162 return (NULL);
163}
diff --git a/src/lib/libc/stdlib/seed48.c b/src/lib/libc/stdlib/seed48.c
new file mode 100644
index 0000000000..c4dcd0ead8
--- /dev/null
+++ b/src/lib/libc/stdlib/seed48.c
@@ -0,0 +1,40 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 */
13
14#if defined(LIBC_SCCS) && !defined(lint)
15static char rcsid[] = "$OpenBSD: seed48.c,v 1.2 1996/08/19 08:33:48 tholo Exp $";
16#endif /* LIBC_SCCS and not lint */
17
18#include "rand48.h"
19
20extern unsigned short __rand48_seed[3];
21extern unsigned short __rand48_mult[3];
22extern unsigned short __rand48_add;
23
24unsigned short *
25seed48(unsigned short xseed[3])
26{
27 static unsigned short sseed[3];
28
29 sseed[0] = __rand48_seed[0];
30 sseed[1] = __rand48_seed[1];
31 sseed[2] = __rand48_seed[2];
32 __rand48_seed[0] = xseed[0];
33 __rand48_seed[1] = xseed[1];
34 __rand48_seed[2] = xseed[2];
35 __rand48_mult[0] = RAND48_MULT_0;
36 __rand48_mult[1] = RAND48_MULT_1;
37 __rand48_mult[2] = RAND48_MULT_2;
38 __rand48_add = RAND48_ADD;
39 return sseed;
40}
diff --git a/src/lib/libc/stdlib/setenv.c b/src/lib/libc/stdlib/setenv.c
new file mode 100644
index 0000000000..b6f261e61c
--- /dev/null
+++ b/src/lib/libc/stdlib/setenv.c
@@ -0,0 +1,120 @@
1/*
2 * Copyright (c) 1987 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: setenv.c,v 1.3 1998/02/02 22:44:53 millert Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <stdlib.h>
39#include <string.h>
40
41/*
42 * setenv --
43 * Set the value of the environmental variable "name" to be
44 * "value". If rewrite is set, replace any current value.
45 */
46int
47setenv(name, value, rewrite)
48 register const char *name;
49 register const char *value;
50 int rewrite;
51{
52 extern char **environ;
53 static int alloced; /* if allocated space before */
54 register char *C;
55 int l_value, offset;
56 char *__findenv();
57
58 if (*value == '=') /* no `=' in value */
59 ++value;
60 l_value = strlen(value);
61 if ((C = __findenv(name, &offset))) { /* find if already exists */
62 if (!rewrite)
63 return (0);
64 if (strlen(C) >= l_value) { /* old larger; copy over */
65 while (*C++ = *value++);
66 return (0);
67 }
68 } else { /* create new slot */
69 register int cnt;
70 register char **P;
71
72 for (P = environ, cnt = 0; *P; ++P, ++cnt);
73 if (alloced) { /* just increase size */
74 P = (char **)realloc((void *)environ,
75 (size_t)(sizeof(char *) * (cnt + 2)));
76 if (!P)
77 return (-1);
78 environ = P;
79 }
80 else { /* get new space */
81 alloced = 1; /* copy old entries into it */
82 P = (char **)malloc((size_t)(sizeof(char *) *
83 (cnt + 2)));
84 if (!P)
85 return (-1);
86 bcopy(environ, P, cnt * sizeof(char *));
87 environ = P;
88 }
89 environ[cnt + 1] = NULL;
90 offset = cnt;
91 }
92 for (C = (char *)name; *C && *C != '='; ++C); /* no `=' in name */
93 if (!(environ[offset] = /* name + `=' + value */
94 malloc((size_t)((int)(C - name) + l_value + 2))))
95 return (-1);
96 for (C = environ[offset]; (*C = *name++) && *C != '='; ++C)
97 ;
98 for (*C++ = '='; *C++ = *value++; )
99 ;
100 return (0);
101}
102
103/*
104 * unsetenv(name) --
105 * Delete environmental variable "name".
106 */
107void
108unsetenv(name)
109 const char *name;
110{
111 extern char **environ;
112 register char **P;
113 int offset;
114 char *__findenv();
115
116 while (__findenv(name, &offset)) /* if set multiple times */
117 for (P = &environ[offset];; ++P)
118 if (!(*P = *(P + 1)))
119 break;
120}
diff --git a/src/lib/libc/stdlib/srand48.c b/src/lib/libc/stdlib/srand48.c
new file mode 100644
index 0000000000..fcff8a172e
--- /dev/null
+++ b/src/lib/libc/stdlib/srand48.c
@@ -0,0 +1,34 @@
1/*
2 * Copyright (c) 1993 Martin Birgmeier
3 * All rights reserved.
4 *
5 * You may redistribute unmodified or modified versions of this source
6 * code provided that the above copyright notice and this and the
7 * following conditions are retained.
8 *
9 * This software is provided ``as is'', and comes with no warranties
10 * of any kind. I shall in no event be liable for anything that happens
11 * to anyone/anything when using this software.
12 */
13
14#if defined(LIBC_SCCS) && !defined(lint)
15static char rcsid[] = "$OpenBSD: srand48.c,v 1.2 1996/08/19 08:33:49 tholo Exp $";
16#endif /* LIBC_SCCS and not lint */
17
18#include "rand48.h"
19
20extern unsigned short __rand48_seed[3];
21extern unsigned short __rand48_mult[3];
22extern unsigned short __rand48_add;
23
24void
25srand48(long seed)
26{
27 __rand48_seed[0] = RAND48_SEED_0;
28 __rand48_seed[1] = (unsigned short) seed;
29 __rand48_seed[2] = (unsigned short) (seed >> 16);
30 __rand48_mult[0] = RAND48_MULT_0;
31 __rand48_mult[1] = RAND48_MULT_1;
32 __rand48_mult[2] = RAND48_MULT_2;
33 __rand48_add = RAND48_ADD;
34}
diff --git a/src/lib/libc/stdlib/strtod.3 b/src/lib/libc/stdlib/strtod.3
new file mode 100644
index 0000000000..3476fa41d6
--- /dev/null
+++ b/src/lib/libc/stdlib/strtod.3
@@ -0,0 +1,113 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strtod.3,v 1.2 1996/08/19 08:33:49 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRTOD 3
40.Os
41.Sh NAME
42.Nm strtod
43.Nd convert
44.Tn ASCII
45string to double
46.Sh SYNOPSIS
47.Fd #include <stdlib.h>
48.Ft double
49.Fn strtod "const char *nptr" "char **endptr"
50.Sh DESCRIPTION
51The
52.Fn strtod
53function converts the initial portion of the string
54pointed to by
55.Fa nptr
56to
57.Em double
58representation.
59.Pp
60The expected form of the string is an optional plus (``+'') or minus
61sign (``-'') followed by a sequence of digits optionally containing
62a decimal-point character, optionally followed by an exponent.
63An exponent consists of an ``E'' or ``e'', followed by an optional plus
64or minus sign, followed by a sequence of digits.
65.Pp
66Leading white-space characters in the string (as defined by the
67.Xr isspace 3
68function) are skipped.
69.Sh RETURN VALUES
70The
71.Fn strtod
72function returns the converted value, if any.
73.Pp
74If
75.Fa endptr
76is not
77.Dv NULL ,
78a pointer to the character after the last character used
79in the conversion is stored in the location referenced by
80.Fa endptr .
81.Pp
82If no conversion is performed, zero is returned and the value of
83.Fa nptr
84is stored in the location referenced by
85.Fa endptr .
86.Pp
87If the correct value would cause overflow, plus or minus
88.Dv HUGE_VAL
89is returned (according to the sign of the value), and
90.Dv ERANGE
91is stored in
92.Va errno .
93If the correct value would cause underflow, zero is
94returned and
95.Dv ERANGE
96is stored in
97.Va errno .
98.Sh ERRORS
99.Bl -tag -width Er
100.It Bq Er ERANGE
101Overflow or underflow occurred.
102.Sh SEE ALSO
103.Xr atof 3 ,
104.Xr atoi 3 ,
105.Xr atol 3 ,
106.Xr strtol 3 ,
107.Xr strtoul 3
108.Sh STANDARDS
109The
110.Fn strtod
111function
112conforms to
113.St -ansiC .
diff --git a/src/lib/libc/stdlib/strtod.c b/src/lib/libc/stdlib/strtod.c
new file mode 100644
index 0000000000..55d9e91224
--- /dev/null
+++ b/src/lib/libc/stdlib/strtod.c
@@ -0,0 +1,2529 @@
1/****************************************************************
2 *
3 * The author of this software is David M. Gay.
4 *
5 * Copyright (c) 1991 by AT&T.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose without fee is hereby granted, provided that this entire notice
9 * is included in all copies of any software which is or includes a copy
10 * or modification of this software and in all copies of the supporting
11 * documentation for such software.
12 *
13 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
14 * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
15 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
16 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
17 *
18 ***************************************************************/
19
20/* Please send bug reports to
21 David M. Gay
22 AT&T Bell Laboratories, Room 2C-463
23 600 Mountain Avenue
24 Murray Hill, NJ 07974-2070
25 U.S.A.
26 dmg@research.att.com or research!dmg
27 */
28
29/* strtod for IEEE-, VAX-, and IBM-arithmetic machines.
30 *
31 * This strtod returns a nearest machine number to the input decimal
32 * string (or sets errno to ERANGE). With IEEE arithmetic, ties are
33 * broken by the IEEE round-even rule. Otherwise ties are broken by
34 * biased rounding (add half and chop).
35 *
36 * Inspired loosely by William D. Clinger's paper "How to Read Floating
37 * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
38 *
39 * Modifications:
40 *
41 * 1. We only require IEEE, IBM, or VAX double-precision
42 * arithmetic (not IEEE double-extended).
43 * 2. We get by with floating-point arithmetic in a case that
44 * Clinger missed -- when we're computing d * 10^n
45 * for a small integer d and the integer n is not too
46 * much larger than 22 (the maximum integer k for which
47 * we can represent 10^k exactly), we may be able to
48 * compute (d*10^k) * 10^(e-k) with just one roundoff.
49 * 3. Rather than a bit-at-a-time adjustment of the binary
50 * result in the hard case, we use floating-point
51 * arithmetic to determine the adjustment to within
52 * one bit; only in really hard cases do we need to
53 * compute a second residual.
54 * 4. Because of 3., we don't need a large table of powers of 10
55 * for ten-to-e (just some small tables, e.g. of 10^k
56 * for 0 <= k <= 22).
57 */
58
59/*
60 * #define IEEE_LITTLE_ENDIAN for IEEE-arithmetic machines where the least
61 * significant byte has the lowest address.
62 * #define IEEE_BIG_ENDIAN for IEEE-arithmetic machines where the most
63 * significant byte has the lowest address.
64 * #define Long int on machines with 32-bit ints and 64-bit longs.
65 * #define Sudden_Underflow for IEEE-format machines without gradual
66 * underflow (i.e., that flush to zero on underflow).
67 * #define IBM for IBM mainframe-style floating-point arithmetic.
68 * #define VAX for VAX-style floating-point arithmetic.
69 * #define Unsigned_Shifts if >> does treats its left operand as unsigned.
70 * #define No_leftright to omit left-right logic in fast floating-point
71 * computation of dtoa.
72 * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3.
73 * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
74 * that use extended-precision instructions to compute rounded
75 * products and quotients) with IBM.
76 * #define ROUND_BIASED for IEEE-format with biased rounding.
77 * #define Inaccurate_Divide for IEEE-format with correctly rounded
78 * products but inaccurate quotients, e.g., for Intel i860.
79 * #define Just_16 to store 16 bits per 32-bit Long when doing high-precision
80 * integer arithmetic. Whether this speeds things up or slows things
81 * down depends on the machine and the number being converted.
82 * #define KR_headers for old-style C function headers.
83 * #define Bad_float_h if your system lacks a float.h or if it does not
84 * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,
85 * FLT_RADIX, FLT_ROUNDS, and DBL_MAX.
86 * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)
87 * if memory is available and otherwise does something you deem
88 * appropriate. If MALLOC is undefined, malloc will be invoked
89 * directly -- and assumed always to succeed.
90 */
91
92#if defined(LIBC_SCCS) && !defined(lint)
93static char *rcsid = "$OpenBSD: strtod.c,v 1.12 1998/08/28 20:49:24 mickey Exp $";
94#endif /* LIBC_SCCS and not lint */
95
96#if defined(__m68k__) || defined(__sparc__) || defined(__i386__) || \
97 defined(__mips__) || defined(__ns32k__) || defined(__alpha__) || \
98 defined(__powerpc__) || defined(__m88k__) || defined(__hppa__)
99#include <sys/types.h>
100#if BYTE_ORDER == BIG_ENDIAN
101#define IEEE_BIG_ENDIAN
102#else
103#define IEEE_LITTLE_ENDIAN
104#endif
105#endif
106
107#ifdef __arm32__
108/*
109 * Although the CPU is little endian the FP has different
110 * byte and word endianness. The byte order is still little endian
111 * but the word order is big endian.
112 */
113#define IEEE_BIG_ENDIAN
114#endif
115
116#ifdef vax
117#define VAX
118#endif
119
120#define Long int32_t
121#define ULong u_int32_t
122
123#ifdef DEBUG
124#include "stdio.h"
125#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
126#endif
127
128#ifdef __cplusplus
129#include "malloc.h"
130#include "memory.h"
131#else
132#ifndef KR_headers
133#include "stdlib.h"
134#include "string.h"
135#include "locale.h"
136#else
137#include "malloc.h"
138#include "memory.h"
139#endif
140#endif
141
142#ifdef MALLOC
143#ifdef KR_headers
144extern char *MALLOC();
145#else
146extern void *MALLOC(size_t);
147#endif
148#else
149#define MALLOC malloc
150#endif
151
152#include "ctype.h"
153#include "errno.h"
154
155#ifdef Bad_float_h
156#undef __STDC__
157#ifdef IEEE_BIG_ENDIAN
158#define IEEE_ARITHMETIC
159#endif
160#ifdef IEEE_LITTLE_ENDIAN
161#define IEEE_ARITHMETIC
162#endif
163
164#ifdef IEEE_ARITHMETIC
165#define DBL_DIG 15
166#define DBL_MAX_10_EXP 308
167#define DBL_MAX_EXP 1024
168#define FLT_RADIX 2
169#define FLT_ROUNDS 1
170#define DBL_MAX 1.7976931348623157e+308
171#endif
172
173#ifdef IBM
174#define DBL_DIG 16
175#define DBL_MAX_10_EXP 75
176#define DBL_MAX_EXP 63
177#define FLT_RADIX 16
178#define FLT_ROUNDS 0
179#define DBL_MAX 7.2370055773322621e+75
180#endif
181
182#ifdef VAX
183#define DBL_DIG 16
184#define DBL_MAX_10_EXP 38
185#define DBL_MAX_EXP 127
186#define FLT_RADIX 2
187#define FLT_ROUNDS 1
188#define DBL_MAX 1.7014118346046923e+38
189#endif
190
191#ifndef LONG_MAX
192#define LONG_MAX 2147483647
193#endif
194#else
195#include "float.h"
196#endif
197#ifndef __MATH_H__
198#include "math.h"
199#endif
200
201#ifdef __cplusplus
202extern "C" {
203#endif
204
205#ifndef CONST
206#ifdef KR_headers
207#define CONST /* blank */
208#else
209#define CONST const
210#endif
211#endif
212
213#ifdef Unsigned_Shifts
214#define Sign_Extend(a,b) if (b < 0) a |= 0xffff0000;
215#else
216#define Sign_Extend(a,b) /*no-op*/
217#endif
218
219#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + \
220 defined(IBM) != 1
221Exactly one of IEEE_LITTLE_ENDIAN IEEE_BIG_ENDIAN, VAX, or
222IBM should be defined.
223#endif
224
225typedef union {
226 double d;
227 ULong ul[2];
228} _double;
229#define value(x) ((x).d)
230#ifdef IEEE_LITTLE_ENDIAN
231#define word0(x) ((x).ul[1])
232#define word1(x) ((x).ul[0])
233#else
234#define word0(x) ((x).ul[0])
235#define word1(x) ((x).ul[1])
236#endif
237
238/* The following definition of Storeinc is appropriate for MIPS processors.
239 * An alternative that might be better on some machines is
240 * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
241 */
242#if defined(IEEE_LITTLE_ENDIAN) + defined(VAX) + defined(__arm32__)
243#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
244((unsigned short *)a)[0] = (unsigned short)c, a++)
245#else
246#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
247((unsigned short *)a)[1] = (unsigned short)c, a++)
248#endif
249
250/* #define P DBL_MANT_DIG */
251/* Ten_pmax = floor(P*log(2)/log(5)) */
252/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
253/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
254/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
255
256#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN)
257#define Exp_shift 20
258#define Exp_shift1 20
259#define Exp_msk1 0x100000
260#define Exp_msk11 0x100000
261#define Exp_mask 0x7ff00000
262#define P 53
263#define Bias 1023
264#define IEEE_Arith
265#define Emin (-1022)
266#define Exp_1 0x3ff00000
267#define Exp_11 0x3ff00000
268#define Ebits 11
269#define Frac_mask 0xfffff
270#define Frac_mask1 0xfffff
271#define Ten_pmax 22
272#define Bletch 0x10
273#define Bndry_mask 0xfffff
274#define Bndry_mask1 0xfffff
275#define LSB 1
276#define Sign_bit 0x80000000
277#define Log2P 1
278#define Tiny0 0
279#define Tiny1 1
280#define Quick_max 14
281#define Int_max 14
282#define Infinite(x) (word0(x) == 0x7ff00000) /* sufficient test for here */
283#else
284#undef Sudden_Underflow
285#define Sudden_Underflow
286#ifdef IBM
287#define Exp_shift 24
288#define Exp_shift1 24
289#define Exp_msk1 0x1000000
290#define Exp_msk11 0x1000000
291#define Exp_mask 0x7f000000
292#define P 14
293#define Bias 65
294#define Exp_1 0x41000000
295#define Exp_11 0x41000000
296#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
297#define Frac_mask 0xffffff
298#define Frac_mask1 0xffffff
299#define Bletch 4
300#define Ten_pmax 22
301#define Bndry_mask 0xefffff
302#define Bndry_mask1 0xffffff
303#define LSB 1
304#define Sign_bit 0x80000000
305#define Log2P 4
306#define Tiny0 0x100000
307#define Tiny1 0
308#define Quick_max 14
309#define Int_max 15
310#else /* VAX */
311#define Exp_shift 23
312#define Exp_shift1 7
313#define Exp_msk1 0x80
314#define Exp_msk11 0x800000
315#define Exp_mask 0x7f80
316#define P 56
317#define Bias 129
318#define Exp_1 0x40800000
319#define Exp_11 0x4080
320#define Ebits 8
321#define Frac_mask 0x7fffff
322#define Frac_mask1 0xffff007f
323#define Ten_pmax 24
324#define Bletch 2
325#define Bndry_mask 0xffff007f
326#define Bndry_mask1 0xffff007f
327#define LSB 0x10000
328#define Sign_bit 0x8000
329#define Log2P 1
330#define Tiny0 0x80
331#define Tiny1 0
332#define Quick_max 15
333#define Int_max 15
334#endif
335#endif
336
337#ifndef IEEE_Arith
338#define ROUND_BIASED
339#endif
340
341#ifdef RND_PRODQUOT
342#define rounded_product(a,b) a = rnd_prod(a, b)
343#define rounded_quotient(a,b) a = rnd_quot(a, b)
344#ifdef KR_headers
345extern double rnd_prod(), rnd_quot();
346#else
347extern double rnd_prod(double, double), rnd_quot(double, double);
348#endif
349#else
350#define rounded_product(a,b) a *= b
351#define rounded_quotient(a,b) a /= b
352#endif
353
354#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
355#define Big1 0xffffffff
356
357#ifndef Just_16
358/* When Pack_32 is not defined, we store 16 bits per 32-bit Long.
359 * This makes some inner loops simpler and sometimes saves work
360 * during multiplications, but it often seems to make things slightly
361 * slower. Hence the default is now to store 32 bits per Long.
362 */
363#ifndef Pack_32
364#define Pack_32
365#endif
366#endif
367
368#define Kmax 15
369
370#ifdef __cplusplus
371extern "C" double strtod(const char *s00, char **se);
372extern "C" char *__dtoa(double d, int mode, int ndigits,
373 int *decpt, int *sign, char **rve);
374#endif
375
376 struct
377Bigint {
378 struct Bigint *next;
379 int k, maxwds, sign, wds;
380 ULong x[1];
381 };
382
383 typedef struct Bigint Bigint;
384
385 static Bigint *freelist[Kmax+1];
386
387 static Bigint *
388Balloc
389#ifdef KR_headers
390 (k) int k;
391#else
392 (int k)
393#endif
394{
395 int x;
396 Bigint *rv;
397
398 if (rv = freelist[k]) {
399 freelist[k] = rv->next;
400 }
401 else {
402 x = 1 << k;
403 rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long));
404 rv->k = k;
405 rv->maxwds = x;
406 }
407 rv->sign = rv->wds = 0;
408 return rv;
409 }
410
411 static void
412Bfree
413#ifdef KR_headers
414 (v) Bigint *v;
415#else
416 (Bigint *v)
417#endif
418{
419 if (v) {
420 v->next = freelist[v->k];
421 freelist[v->k] = v;
422 }
423 }
424
425#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \
426y->wds*sizeof(Long) + 2*sizeof(int))
427
428 static Bigint *
429multadd
430#ifdef KR_headers
431 (b, m, a) Bigint *b; int m, a;
432#else
433 (Bigint *b, int m, int a) /* multiply by m and add a */
434#endif
435{
436 int i, wds;
437 ULong *x, y;
438#ifdef Pack_32
439 ULong xi, z;
440#endif
441 Bigint *b1;
442
443 wds = b->wds;
444 x = b->x;
445 i = 0;
446 do {
447#ifdef Pack_32
448 xi = *x;
449 y = (xi & 0xffff) * m + a;
450 z = (xi >> 16) * m + (y >> 16);
451 a = (int)(z >> 16);
452 *x++ = (z << 16) + (y & 0xffff);
453#else
454 y = *x * m + a;
455 a = (int)(y >> 16);
456 *x++ = y & 0xffff;
457#endif
458 }
459 while(++i < wds);
460 if (a) {
461 if (wds >= b->maxwds) {
462 b1 = Balloc(b->k+1);
463 Bcopy(b1, b);
464 Bfree(b);
465 b = b1;
466 }
467 b->x[wds++] = a;
468 b->wds = wds;
469 }
470 return b;
471 }
472
473 static Bigint *
474s2b
475#ifdef KR_headers
476 (s, nd0, nd, y9) CONST char *s; int nd0, nd; ULong y9;
477#else
478 (CONST char *s, int nd0, int nd, ULong y9)
479#endif
480{
481 Bigint *b;
482 int i, k;
483 Long x, y;
484
485 x = (nd + 8) / 9;
486 for(k = 0, y = 1; x > y; y <<= 1, k++) ;
487#ifdef Pack_32
488 b = Balloc(k);
489 b->x[0] = y9;
490 b->wds = 1;
491#else
492 b = Balloc(k+1);
493 b->x[0] = y9 & 0xffff;
494 b->wds = (b->x[1] = y9 >> 16) ? 2 : 1;
495#endif
496
497 i = 9;
498 if (9 < nd0) {
499 s += 9;
500 do b = multadd(b, 10, *s++ - '0');
501 while(++i < nd0);
502 s++;
503 }
504 else
505 s += 10;
506 for(; i < nd; i++)
507 b = multadd(b, 10, *s++ - '0');
508 return b;
509 }
510
511 static int
512hi0bits
513#ifdef KR_headers
514 (x) register ULong x;
515#else
516 (register ULong x)
517#endif
518{
519 register int k = 0;
520
521 if (!(x & 0xffff0000)) {
522 k = 16;
523 x <<= 16;
524 }
525 if (!(x & 0xff000000)) {
526 k += 8;
527 x <<= 8;
528 }
529 if (!(x & 0xf0000000)) {
530 k += 4;
531 x <<= 4;
532 }
533 if (!(x & 0xc0000000)) {
534 k += 2;
535 x <<= 2;
536 }
537 if (!(x & 0x80000000)) {
538 k++;
539 if (!(x & 0x40000000))
540 return 32;
541 }
542 return k;
543 }
544
545 static int
546lo0bits
547#ifdef KR_headers
548 (y) ULong *y;
549#else
550 (ULong *y)
551#endif
552{
553 register int k;
554 register ULong x = *y;
555
556 if (x & 7) {
557 if (x & 1)
558 return 0;
559 if (x & 2) {
560 *y = x >> 1;
561 return 1;
562 }
563 *y = x >> 2;
564 return 2;
565 }
566 k = 0;
567 if (!(x & 0xffff)) {
568 k = 16;
569 x >>= 16;
570 }
571 if (!(x & 0xff)) {
572 k += 8;
573 x >>= 8;
574 }
575 if (!(x & 0xf)) {
576 k += 4;
577 x >>= 4;
578 }
579 if (!(x & 0x3)) {
580 k += 2;
581 x >>= 2;
582 }
583 if (!(x & 1)) {
584 k++;
585 x >>= 1;
586 if (!x & 1)
587 return 32;
588 }
589 *y = x;
590 return k;
591 }
592
593 static Bigint *
594i2b
595#ifdef KR_headers
596 (i) int i;
597#else
598 (int i)
599#endif
600{
601 Bigint *b;
602
603 b = Balloc(1);
604 b->x[0] = i;
605 b->wds = 1;
606 return b;
607 }
608
609 static Bigint *
610mult
611#ifdef KR_headers
612 (a, b) Bigint *a, *b;
613#else
614 (Bigint *a, Bigint *b)
615#endif
616{
617 Bigint *c;
618 int k, wa, wb, wc;
619 ULong carry, y, z;
620 ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
621#ifdef Pack_32
622 ULong z2;
623#endif
624
625 if (a->wds < b->wds) {
626 c = a;
627 a = b;
628 b = c;
629 }
630 k = a->k;
631 wa = a->wds;
632 wb = b->wds;
633 wc = wa + wb;
634 if (wc > a->maxwds)
635 k++;
636 c = Balloc(k);
637 for(x = c->x, xa = x + wc; x < xa; x++)
638 *x = 0;
639 xa = a->x;
640 xae = xa + wa;
641 xb = b->x;
642 xbe = xb + wb;
643 xc0 = c->x;
644#ifdef Pack_32
645 for(; xb < xbe; xb++, xc0++) {
646 if (y = *xb & 0xffff) {
647 x = xa;
648 xc = xc0;
649 carry = 0;
650 do {
651 z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
652 carry = z >> 16;
653 z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
654 carry = z2 >> 16;
655 Storeinc(xc, z2, z);
656 }
657 while(x < xae);
658 *xc = carry;
659 }
660 if (y = *xb >> 16) {
661 x = xa;
662 xc = xc0;
663 carry = 0;
664 z2 = *xc;
665 do {
666 z = (*x & 0xffff) * y + (*xc >> 16) + carry;
667 carry = z >> 16;
668 Storeinc(xc, z, z2);
669 z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
670 carry = z2 >> 16;
671 }
672 while(x < xae);
673 *xc = z2;
674 }
675 }
676#else
677 for(; xb < xbe; xc0++) {
678 if (y = *xb++) {
679 x = xa;
680 xc = xc0;
681 carry = 0;
682 do {
683 z = *x++ * y + *xc + carry;
684 carry = z >> 16;
685 *xc++ = z & 0xffff;
686 }
687 while(x < xae);
688 *xc = carry;
689 }
690 }
691#endif
692 for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ;
693 c->wds = wc;
694 return c;
695 }
696
697 static Bigint *p5s;
698
699 static Bigint *
700pow5mult
701#ifdef KR_headers
702 (b, k) Bigint *b; int k;
703#else
704 (Bigint *b, int k)
705#endif
706{
707 Bigint *b1, *p5, *p51;
708 int i;
709 static int p05[3] = { 5, 25, 125 };
710
711 if (i = k & 3)
712 b = multadd(b, p05[i-1], 0);
713
714 if (!(k >>= 2))
715 return b;
716 if (!(p5 = p5s)) {
717 /* first time */
718 p5 = p5s = i2b(625);
719 p5->next = 0;
720 }
721 for(;;) {
722 if (k & 1) {
723 b1 = mult(b, p5);
724 Bfree(b);
725 b = b1;
726 }
727 if (!(k >>= 1))
728 break;
729 if (!(p51 = p5->next)) {
730 p51 = p5->next = mult(p5,p5);
731 p51->next = 0;
732 }
733 p5 = p51;
734 }
735 return b;
736 }
737
738 static Bigint *
739lshift
740#ifdef KR_headers
741 (b, k) Bigint *b; int k;
742#else
743 (Bigint *b, int k)
744#endif
745{
746 int i, k1, n, n1;
747 Bigint *b1;
748 ULong *x, *x1, *xe, z;
749
750#ifdef Pack_32
751 n = k >> 5;
752#else
753 n = k >> 4;
754#endif
755 k1 = b->k;
756 n1 = n + b->wds + 1;
757 for(i = b->maxwds; n1 > i; i <<= 1)
758 k1++;
759 b1 = Balloc(k1);
760 x1 = b1->x;
761 for(i = 0; i < n; i++)
762 *x1++ = 0;
763 x = b->x;
764 xe = x + b->wds;
765#ifdef Pack_32
766 if (k &= 0x1f) {
767 k1 = 32 - k;
768 z = 0;
769 do {
770 *x1++ = *x << k | z;
771 z = *x++ >> k1;
772 }
773 while(x < xe);
774 if (*x1 = z)
775 ++n1;
776 }
777#else
778 if (k &= 0xf) {
779 k1 = 16 - k;
780 z = 0;
781 do {
782 *x1++ = *x << k & 0xffff | z;
783 z = *x++ >> k1;
784 }
785 while(x < xe);
786 if (*x1 = z)
787 ++n1;
788 }
789#endif
790 else do
791 *x1++ = *x++;
792 while(x < xe);
793 b1->wds = n1 - 1;
794 Bfree(b);
795 return b1;
796 }
797
798 static int
799cmp
800#ifdef KR_headers
801 (a, b) Bigint *a, *b;
802#else
803 (Bigint *a, Bigint *b)
804#endif
805{
806 ULong *xa, *xa0, *xb, *xb0;
807 int i, j;
808
809 i = a->wds;
810 j = b->wds;
811#ifdef DEBUG
812 if (i > 1 && !a->x[i-1])
813 Bug("cmp called with a->x[a->wds-1] == 0");
814 if (j > 1 && !b->x[j-1])
815 Bug("cmp called with b->x[b->wds-1] == 0");
816#endif
817 if (i -= j)
818 return i;
819 xa0 = a->x;
820 xa = xa0 + j;
821 xb0 = b->x;
822 xb = xb0 + j;
823 for(;;) {
824 if (*--xa != *--xb)
825 return *xa < *xb ? -1 : 1;
826 if (xa <= xa0)
827 break;
828 }
829 return 0;
830 }
831
832 static Bigint *
833diff
834#ifdef KR_headers
835 (a, b) Bigint *a, *b;
836#else
837 (Bigint *a, Bigint *b)
838#endif
839{
840 Bigint *c;
841 int i, wa, wb;
842 Long borrow, y; /* We need signed shifts here. */
843 ULong *xa, *xae, *xb, *xbe, *xc;
844#ifdef Pack_32
845 Long z;
846#endif
847
848 i = cmp(a,b);
849 if (!i) {
850 c = Balloc(0);
851 c->wds = 1;
852 c->x[0] = 0;
853 return c;
854 }
855 if (i < 0) {
856 c = a;
857 a = b;
858 b = c;
859 i = 1;
860 }
861 else
862 i = 0;
863 c = Balloc(a->k);
864 c->sign = i;
865 wa = a->wds;
866 xa = a->x;
867 xae = xa + wa;
868 wb = b->wds;
869 xb = b->x;
870 xbe = xb + wb;
871 xc = c->x;
872 borrow = 0;
873#ifdef Pack_32
874 do {
875 y = (*xa & 0xffff) - (*xb & 0xffff) + borrow;
876 borrow = y >> 16;
877 Sign_Extend(borrow, y);
878 z = (*xa++ >> 16) - (*xb++ >> 16) + borrow;
879 borrow = z >> 16;
880 Sign_Extend(borrow, z);
881 Storeinc(xc, z, y);
882 }
883 while(xb < xbe);
884 while(xa < xae) {
885 y = (*xa & 0xffff) + borrow;
886 borrow = y >> 16;
887 Sign_Extend(borrow, y);
888 z = (*xa++ >> 16) + borrow;
889 borrow = z >> 16;
890 Sign_Extend(borrow, z);
891 Storeinc(xc, z, y);
892 }
893#else
894 do {
895 y = *xa++ - *xb++ + borrow;
896 borrow = y >> 16;
897 Sign_Extend(borrow, y);
898 *xc++ = y & 0xffff;
899 }
900 while(xb < xbe);
901 while(xa < xae) {
902 y = *xa++ + borrow;
903 borrow = y >> 16;
904 Sign_Extend(borrow, y);
905 *xc++ = y & 0xffff;
906 }
907#endif
908 while(!*--xc)
909 wa--;
910 c->wds = wa;
911 return c;
912 }
913
914 static double
915ulp
916#ifdef KR_headers
917 (_x) double _x;
918#else
919 (double _x)
920#endif
921{
922 _double x;
923 register Long L;
924 _double a;
925
926 value(x) = _x;
927 L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1;
928#ifndef Sudden_Underflow
929 if (L > 0) {
930#endif
931#ifdef IBM
932 L |= Exp_msk1 >> 4;
933#endif
934 word0(a) = L;
935 word1(a) = 0;
936#ifndef Sudden_Underflow
937 }
938 else {
939 L = -L >> Exp_shift;
940 if (L < Exp_shift) {
941 word0(a) = 0x80000 >> L;
942 word1(a) = 0;
943 }
944 else {
945 word0(a) = 0;
946 L -= Exp_shift;
947 word1(a) = L >= 31 ? 1 : 1 << 31 - L;
948 }
949 }
950#endif
951 return value(a);
952 }
953
954 static double
955b2d
956#ifdef KR_headers
957 (a, e) Bigint *a; int *e;
958#else
959 (Bigint *a, int *e)
960#endif
961{
962 ULong *xa, *xa0, w, y, z;
963 int k;
964 _double d;
965#ifdef VAX
966 ULong d0, d1;
967#else
968#define d0 word0(d)
969#define d1 word1(d)
970#endif
971
972 xa0 = a->x;
973 xa = xa0 + a->wds;
974 y = *--xa;
975#ifdef DEBUG
976 if (!y) Bug("zero y in b2d");
977#endif
978 k = hi0bits(y);
979 *e = 32 - k;
980#ifdef Pack_32
981 if (k < Ebits) {
982 d0 = Exp_1 | y >> Ebits - k;
983 w = xa > xa0 ? *--xa : 0;
984 d1 = y << (32-Ebits) + k | w >> Ebits - k;
985 goto ret_d;
986 }
987 z = xa > xa0 ? *--xa : 0;
988 if (k -= Ebits) {
989 d0 = Exp_1 | y << k | z >> 32 - k;
990 y = xa > xa0 ? *--xa : 0;
991 d1 = z << k | y >> 32 - k;
992 }
993 else {
994 d0 = Exp_1 | y;
995 d1 = z;
996 }
997#else
998 if (k < Ebits + 16) {
999 z = xa > xa0 ? *--xa : 0;
1000 d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;
1001 w = xa > xa0 ? *--xa : 0;
1002 y = xa > xa0 ? *--xa : 0;
1003 d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;
1004 goto ret_d;
1005 }
1006 z = xa > xa0 ? *--xa : 0;
1007 w = xa > xa0 ? *--xa : 0;
1008 k -= Ebits + 16;
1009 d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;
1010 y = xa > xa0 ? *--xa : 0;
1011 d1 = w << k + 16 | y << k;
1012#endif
1013 ret_d:
1014#ifdef VAX
1015 word0(d) = d0 >> 16 | d0 << 16;
1016 word1(d) = d1 >> 16 | d1 << 16;
1017#else
1018#undef d0
1019#undef d1
1020#endif
1021 return value(d);
1022 }
1023
1024 static Bigint *
1025d2b
1026#ifdef KR_headers
1027 (_d, e, bits) double d; int *e, *bits;
1028#else
1029 (double _d, int *e, int *bits)
1030#endif
1031{
1032 Bigint *b;
1033 int de, i, k;
1034 ULong *x, y, z;
1035 _double d;
1036#ifdef VAX
1037 ULong d0, d1;
1038#endif
1039
1040 value(d) = _d;
1041#ifdef VAX
1042 d0 = word0(d) >> 16 | word0(d) << 16;
1043 d1 = word1(d) >> 16 | word1(d) << 16;
1044#else
1045#define d0 word0(d)
1046#define d1 word1(d)
1047#endif
1048
1049#ifdef Pack_32
1050 b = Balloc(1);
1051#else
1052 b = Balloc(2);
1053#endif
1054 x = b->x;
1055
1056 z = d0 & Frac_mask;
1057 d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
1058#ifdef Sudden_Underflow
1059 de = (int)(d0 >> Exp_shift);
1060#ifndef IBM
1061 z |= Exp_msk11;
1062#endif
1063#else
1064 if (de = (int)(d0 >> Exp_shift))
1065 z |= Exp_msk1;
1066#endif
1067#ifdef Pack_32
1068 if (y = d1) {
1069 if (k = lo0bits(&y)) {
1070 x[0] = y | z << 32 - k;
1071 z >>= k;
1072 }
1073 else
1074 x[0] = y;
1075 i = b->wds = (x[1] = z) ? 2 : 1;
1076 }
1077 else {
1078#ifdef DEBUG
1079 if (!z)
1080 Bug("Zero passed to d2b");
1081#endif
1082 k = lo0bits(&z);
1083 x[0] = z;
1084 i = b->wds = 1;
1085 k += 32;
1086 }
1087#else
1088 if (y = d1) {
1089 if (k = lo0bits(&y))
1090 if (k >= 16) {
1091 x[0] = y | z << 32 - k & 0xffff;
1092 x[1] = z >> k - 16 & 0xffff;
1093 x[2] = z >> k;
1094 i = 2;
1095 }
1096 else {
1097 x[0] = y & 0xffff;
1098 x[1] = y >> 16 | z << 16 - k & 0xffff;
1099 x[2] = z >> k & 0xffff;
1100 x[3] = z >> k+16;
1101 i = 3;
1102 }
1103 else {
1104 x[0] = y & 0xffff;
1105 x[1] = y >> 16;
1106 x[2] = z & 0xffff;
1107 x[3] = z >> 16;
1108 i = 3;
1109 }
1110 }
1111 else {
1112#ifdef DEBUG
1113 if (!z)
1114 Bug("Zero passed to d2b");
1115#endif
1116 k = lo0bits(&z);
1117 if (k >= 16) {
1118 x[0] = z;
1119 i = 0;
1120 }
1121 else {
1122 x[0] = z & 0xffff;
1123 x[1] = z >> 16;
1124 i = 1;
1125 }
1126 k += 32;
1127 }
1128 while(!x[i])
1129 --i;
1130 b->wds = i + 1;
1131#endif
1132#ifndef Sudden_Underflow
1133 if (de) {
1134#endif
1135#ifdef IBM
1136 *e = (de - Bias - (P-1) << 2) + k;
1137 *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask);
1138#else
1139 *e = de - Bias - (P-1) + k;
1140 *bits = P - k;
1141#endif
1142#ifndef Sudden_Underflow
1143 }
1144 else {
1145 *e = de - Bias - (P-1) + 1 + k;
1146#ifdef Pack_32
1147 *bits = 32*i - hi0bits(x[i-1]);
1148#else
1149 *bits = (i+2)*16 - hi0bits(x[i]);
1150#endif
1151 }
1152#endif
1153 return b;
1154 }
1155#undef d0
1156#undef d1
1157
1158 static double
1159ratio
1160#ifdef KR_headers
1161 (a, b) Bigint *a, *b;
1162#else
1163 (Bigint *a, Bigint *b)
1164#endif
1165{
1166 _double da, db;
1167 int k, ka, kb;
1168
1169 value(da) = b2d(a, &ka);
1170 value(db) = b2d(b, &kb);
1171#ifdef Pack_32
1172 k = ka - kb + 32*(a->wds - b->wds);
1173#else
1174 k = ka - kb + 16*(a->wds - b->wds);
1175#endif
1176#ifdef IBM
1177 if (k > 0) {
1178 word0(da) += (k >> 2)*Exp_msk1;
1179 if (k &= 3)
1180 da *= 1 << k;
1181 }
1182 else {
1183 k = -k;
1184 word0(db) += (k >> 2)*Exp_msk1;
1185 if (k &= 3)
1186 db *= 1 << k;
1187 }
1188#else
1189 if (k > 0)
1190 word0(da) += k*Exp_msk1;
1191 else {
1192 k = -k;
1193 word0(db) += k*Exp_msk1;
1194 }
1195#endif
1196 return value(da) / value(db);
1197 }
1198
1199static CONST double
1200tens[] = {
1201 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
1202 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
1203 1e20, 1e21, 1e22
1204#ifdef VAX
1205 , 1e23, 1e24
1206#endif
1207 };
1208
1209#ifdef IEEE_Arith
1210static CONST double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 };
1211static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256 };
1212#define n_bigtens 5
1213#else
1214#ifdef IBM
1215static CONST double bigtens[] = { 1e16, 1e32, 1e64 };
1216static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 };
1217#define n_bigtens 3
1218#else
1219static CONST double bigtens[] = { 1e16, 1e32 };
1220static CONST double tinytens[] = { 1e-16, 1e-32 };
1221#define n_bigtens 2
1222#endif
1223#endif
1224
1225 double
1226strtod
1227#ifdef KR_headers
1228 (s00, se) CONST char *s00; char **se;
1229#else
1230 (CONST char *s00, char **se)
1231#endif
1232{
1233 int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
1234 e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
1235 CONST char *s, *s0, *s1;
1236 double aadj, aadj1, adj;
1237 _double rv, rv0;
1238 Long L;
1239 ULong y, z;
1240 Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
1241
1242#ifndef KR_headers
1243 CONST char decimal_point = localeconv()->decimal_point[0];
1244#else
1245 CONST char decimal_point = '.';
1246#endif
1247
1248 sign = nz0 = nz = 0;
1249 value(rv) = 0.;
1250
1251
1252 for(s = s00; isspace((unsigned char) *s); s++)
1253 ;
1254
1255 if (*s == '-') {
1256 sign = 1;
1257 s++;
1258 } else if (*s == '+') {
1259 s++;
1260 }
1261
1262 if (*s == '\0') {
1263 s = s00;
1264 goto ret;
1265 }
1266
1267 if (*s == '0') {
1268 nz0 = 1;
1269 while(*++s == '0') ;
1270 if (!*s)
1271 goto ret;
1272 }
1273 s0 = s;
1274 y = z = 0;
1275 for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
1276 if (nd < 9)
1277 y = 10*y + c - '0';
1278 else if (nd < 16)
1279 z = 10*z + c - '0';
1280 nd0 = nd;
1281 if (c == decimal_point) {
1282 c = *++s;
1283 if (!nd) {
1284 for(; c == '0'; c = *++s)
1285 nz++;
1286 if (c > '0' && c <= '9') {
1287 s0 = s;
1288 nf += nz;
1289 nz = 0;
1290 goto have_dig;
1291 }
1292 goto dig_done;
1293 }
1294 for(; c >= '0' && c <= '9'; c = *++s) {
1295 have_dig:
1296 nz++;
1297 if (c -= '0') {
1298 nf += nz;
1299 for(i = 1; i < nz; i++)
1300 if (nd++ < 9)
1301 y *= 10;
1302 else if (nd <= DBL_DIG + 1)
1303 z *= 10;
1304 if (nd++ < 9)
1305 y = 10*y + c;
1306 else if (nd <= DBL_DIG + 1)
1307 z = 10*z + c;
1308 nz = 0;
1309 }
1310 }
1311 }
1312 dig_done:
1313 e = 0;
1314 if (c == 'e' || c == 'E') {
1315 if (!nd && !nz && !nz0) {
1316 s = s00;
1317 goto ret;
1318 }
1319 s00 = s;
1320 esign = 0;
1321 switch(c = *++s) {
1322 case '-':
1323 esign = 1;
1324 case '+':
1325 c = *++s;
1326 }
1327 if (c >= '0' && c <= '9') {
1328 while(c == '0')
1329 c = *++s;
1330 if (c > '0' && c <= '9') {
1331 L = c - '0';
1332 s1 = s;
1333 while((c = *++s) >= '0' && c <= '9')
1334 L = 10*L + c - '0';
1335 if (s - s1 > 8 || L > 19999)
1336 /* Avoid confusion from exponents
1337 * so large that e might overflow.
1338 */
1339 e = 19999; /* safe for 16 bit ints */
1340 else
1341 e = (int)L;
1342 if (esign)
1343 e = -e;
1344 }
1345 else
1346 e = 0;
1347 }
1348 else
1349 s = s00;
1350 }
1351 if (!nd) {
1352 if (!nz && !nz0)
1353 s = s00;
1354 goto ret;
1355 }
1356 e1 = e -= nf;
1357
1358 /* Now we have nd0 digits, starting at s0, followed by a
1359 * decimal point, followed by nd-nd0 digits. The number we're
1360 * after is the integer represented by those digits times
1361 * 10**e */
1362
1363 if (!nd0)
1364 nd0 = nd;
1365 k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
1366 value(rv) = y;
1367 if (k > 9)
1368 value(rv) = tens[k - 9] * value(rv) + z;
1369 bd0 = 0;
1370 if (nd <= DBL_DIG
1371#ifndef RND_PRODQUOT
1372 && FLT_ROUNDS == 1
1373#endif
1374 ) {
1375 if (!e)
1376 goto ret;
1377 if (e > 0) {
1378 if (e <= Ten_pmax) {
1379#ifdef VAX
1380 goto vax_ovfl_check;
1381#else
1382 /* value(rv) = */ rounded_product(value(rv),
1383 tens[e]);
1384 goto ret;
1385#endif
1386 }
1387 i = DBL_DIG - nd;
1388 if (e <= Ten_pmax + i) {
1389 /* A fancier test would sometimes let us do
1390 * this for larger i values.
1391 */
1392 e -= i;
1393 value(rv) *= tens[i];
1394#ifdef VAX
1395 /* VAX exponent range is so narrow we must
1396 * worry about overflow here...
1397 */
1398 vax_ovfl_check:
1399 word0(rv) -= P*Exp_msk1;
1400 /* value(rv) = */ rounded_product(value(rv),
1401 tens[e]);
1402 if ((word0(rv) & Exp_mask)
1403 > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))
1404 goto ovfl;
1405 word0(rv) += P*Exp_msk1;
1406#else
1407 /* value(rv) = */ rounded_product(value(rv),
1408 tens[e]);
1409#endif
1410 goto ret;
1411 }
1412 }
1413#ifndef Inaccurate_Divide
1414 else if (e >= -Ten_pmax) {
1415 /* value(rv) = */ rounded_quotient(value(rv),
1416 tens[-e]);
1417 goto ret;
1418 }
1419#endif
1420 }
1421 e1 += nd - k;
1422
1423 /* Get starting approximation = rv * 10**e1 */
1424
1425 if (e1 > 0) {
1426 if (i = e1 & 15)
1427 value(rv) *= tens[i];
1428 if (e1 &= ~15) {
1429 if (e1 > DBL_MAX_10_EXP) {
1430 ovfl:
1431 errno = ERANGE;
1432#ifdef __STDC__
1433 value(rv) = HUGE_VAL;
1434#else
1435 /* Can't trust HUGE_VAL */
1436#ifdef IEEE_Arith
1437 word0(rv) = Exp_mask;
1438 word1(rv) = 0;
1439#else
1440 word0(rv) = Big0;
1441 word1(rv) = Big1;
1442#endif
1443#endif
1444 if (bd0)
1445 goto retfree;
1446 goto ret;
1447 }
1448 if (e1 >>= 4) {
1449 for(j = 0; e1 > 1; j++, e1 >>= 1)
1450 if (e1 & 1)
1451 value(rv) *= bigtens[j];
1452 /* The last multiplication could overflow. */
1453 word0(rv) -= P*Exp_msk1;
1454 value(rv) *= bigtens[j];
1455 if ((z = word0(rv) & Exp_mask)
1456 > Exp_msk1*(DBL_MAX_EXP+Bias-P))
1457 goto ovfl;
1458 if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) {
1459 /* set to largest number */
1460 /* (Can't trust DBL_MAX) */
1461 word0(rv) = Big0;
1462 word1(rv) = Big1;
1463 }
1464 else
1465 word0(rv) += P*Exp_msk1;
1466 }
1467
1468 }
1469 }
1470 else if (e1 < 0) {
1471 e1 = -e1;
1472 if (i = e1 & 15)
1473 value(rv) /= tens[i];
1474 if (e1 &= ~15) {
1475 e1 >>= 4;
1476 if (e1 >= 1 << n_bigtens)
1477 goto undfl;
1478 for(j = 0; e1 > 1; j++, e1 >>= 1)
1479 if (e1 & 1)
1480 value(rv) *= tinytens[j];
1481 /* The last multiplication could underflow. */
1482 value(rv0) = value(rv);
1483 value(rv) *= tinytens[j];
1484 if (!value(rv)) {
1485 value(rv) = 2.*value(rv0);
1486 value(rv) *= tinytens[j];
1487 if (!value(rv)) {
1488 undfl:
1489 value(rv) = 0.;
1490 errno = ERANGE;
1491 if (bd0)
1492 goto retfree;
1493 goto ret;
1494 }
1495 word0(rv) = Tiny0;
1496 word1(rv) = Tiny1;
1497 /* The refinement below will clean
1498 * this approximation up.
1499 */
1500 }
1501 }
1502 }
1503
1504 /* Now the hard part -- adjusting rv to the correct value.*/
1505
1506 /* Put digits into bd: true value = bd * 10^e */
1507
1508 bd0 = s2b(s0, nd0, nd, y);
1509
1510 for(;;) {
1511 bd = Balloc(bd0->k);
1512 Bcopy(bd, bd0);
1513 bb = d2b(value(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */
1514 bs = i2b(1);
1515
1516 if (e >= 0) {
1517 bb2 = bb5 = 0;
1518 bd2 = bd5 = e;
1519 }
1520 else {
1521 bb2 = bb5 = -e;
1522 bd2 = bd5 = 0;
1523 }
1524 if (bbe >= 0)
1525 bb2 += bbe;
1526 else
1527 bd2 -= bbe;
1528 bs2 = bb2;
1529#ifdef Sudden_Underflow
1530#ifdef IBM
1531 j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3);
1532#else
1533 j = P + 1 - bbbits;
1534#endif
1535#else
1536 i = bbe + bbbits - 1; /* logb(rv) */
1537 if (i < Emin) /* denormal */
1538 j = bbe + (P-Emin);
1539 else
1540 j = P + 1 - bbbits;
1541#endif
1542 bb2 += j;
1543 bd2 += j;
1544 i = bb2 < bd2 ? bb2 : bd2;
1545 if (i > bs2)
1546 i = bs2;
1547 if (i > 0) {
1548 bb2 -= i;
1549 bd2 -= i;
1550 bs2 -= i;
1551 }
1552 if (bb5 > 0) {
1553 bs = pow5mult(bs, bb5);
1554 bb1 = mult(bs, bb);
1555 Bfree(bb);
1556 bb = bb1;
1557 }
1558 if (bb2 > 0)
1559 bb = lshift(bb, bb2);
1560 if (bd5 > 0)
1561 bd = pow5mult(bd, bd5);
1562 if (bd2 > 0)
1563 bd = lshift(bd, bd2);
1564 if (bs2 > 0)
1565 bs = lshift(bs, bs2);
1566 delta = diff(bb, bd);
1567 dsign = delta->sign;
1568 delta->sign = 0;
1569 i = cmp(delta, bs);
1570 if (i < 0) {
1571 /* Error is less than half an ulp -- check for
1572 * special case of mantissa a power of two.
1573 */
1574 if (dsign || word1(rv) || word0(rv) & Bndry_mask)
1575 break;
1576 delta = lshift(delta,Log2P);
1577 if (cmp(delta, bs) > 0)
1578 goto drop_down;
1579 break;
1580 }
1581 if (i == 0) {
1582 /* exactly half-way between */
1583 if (dsign) {
1584 if ((word0(rv) & Bndry_mask1) == Bndry_mask1
1585 && word1(rv) == 0xffffffff) {
1586 /*boundary case -- increment exponent*/
1587 word0(rv) = (word0(rv) & Exp_mask)
1588 + Exp_msk1
1589#ifdef IBM
1590 | Exp_msk1 >> 4
1591#endif
1592 ;
1593 word1(rv) = 0;
1594 break;
1595 }
1596 }
1597 else if (!(word0(rv) & Bndry_mask) && !word1(rv)) {
1598 drop_down:
1599 /* boundary case -- decrement exponent */
1600#ifdef Sudden_Underflow
1601 L = word0(rv) & Exp_mask;
1602#ifdef IBM
1603 if (L < Exp_msk1)
1604#else
1605 if (L <= Exp_msk1)
1606#endif
1607 goto undfl;
1608 L -= Exp_msk1;
1609#else
1610 L = (word0(rv) & Exp_mask) - Exp_msk1;
1611#endif
1612 word0(rv) = L | Bndry_mask1;
1613 word1(rv) = 0xffffffff;
1614#ifdef IBM
1615 goto cont;
1616#else
1617 break;
1618#endif
1619 }
1620#ifndef ROUND_BIASED
1621 if (!(word1(rv) & LSB))
1622 break;
1623#endif
1624 if (dsign)
1625 value(rv) += ulp(value(rv));
1626#ifndef ROUND_BIASED
1627 else {
1628 value(rv) -= ulp(value(rv));
1629#ifndef Sudden_Underflow
1630 if (!value(rv))
1631 goto undfl;
1632#endif
1633 }
1634#endif
1635 break;
1636 }
1637 if ((aadj = ratio(delta, bs)) <= 2.) {
1638 if (dsign)
1639 aadj = aadj1 = 1.;
1640 else if (word1(rv) || word0(rv) & Bndry_mask) {
1641#ifndef Sudden_Underflow
1642 if (word1(rv) == Tiny1 && !word0(rv))
1643 goto undfl;
1644#endif
1645 aadj = 1.;
1646 aadj1 = -1.;
1647 }
1648 else {
1649 /* special case -- power of FLT_RADIX to be */
1650 /* rounded down... */
1651
1652 if (aadj < 2./FLT_RADIX)
1653 aadj = 1./FLT_RADIX;
1654 else
1655 aadj *= 0.5;
1656 aadj1 = -aadj;
1657 }
1658 }
1659 else {
1660 aadj *= 0.5;
1661 aadj1 = dsign ? aadj : -aadj;
1662#ifdef Check_FLT_ROUNDS
1663 switch(FLT_ROUNDS) {
1664 case 2: /* towards +infinity */
1665 aadj1 -= 0.5;
1666 break;
1667 case 0: /* towards 0 */
1668 case 3: /* towards -infinity */
1669 aadj1 += 0.5;
1670 }
1671#else
1672 if (FLT_ROUNDS == 0)
1673 aadj1 += 0.5;
1674#endif
1675 }
1676 y = word0(rv) & Exp_mask;
1677
1678 /* Check for overflow */
1679
1680 if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
1681 value(rv0) = value(rv);
1682 word0(rv) -= P*Exp_msk1;
1683 adj = aadj1 * ulp(value(rv));
1684 value(rv) += adj;
1685 if ((word0(rv) & Exp_mask) >=
1686 Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
1687 if (word0(rv0) == Big0 && word1(rv0) == Big1)
1688 goto ovfl;
1689 word0(rv) = Big0;
1690 word1(rv) = Big1;
1691 goto cont;
1692 }
1693 else
1694 word0(rv) += P*Exp_msk1;
1695 }
1696 else {
1697#ifdef Sudden_Underflow
1698 if ((word0(rv) & Exp_mask) <= P*Exp_msk1) {
1699 value(rv0) = value(rv);
1700 word0(rv) += P*Exp_msk1;
1701 adj = aadj1 * ulp(value(rv));
1702 value(rv) += adj;
1703#ifdef IBM
1704 if ((word0(rv) & Exp_mask) < P*Exp_msk1)
1705#else
1706 if ((word0(rv) & Exp_mask) <= P*Exp_msk1)
1707#endif
1708 {
1709 if (word0(rv0) == Tiny0
1710 && word1(rv0) == Tiny1)
1711 goto undfl;
1712 word0(rv) = Tiny0;
1713 word1(rv) = Tiny1;
1714 goto cont;
1715 }
1716 else
1717 word0(rv) -= P*Exp_msk1;
1718 }
1719 else {
1720 adj = aadj1 * ulp(value(rv));
1721 value(rv) += adj;
1722 }
1723#else
1724 /* Compute adj so that the IEEE rounding rules will
1725 * correctly round rv + adj in some half-way cases.
1726 * If rv * ulp(rv) is denormalized (i.e.,
1727 * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid
1728 * trouble from bits lost to denormalization;
1729 * example: 1.2e-307 .
1730 */
1731 if (y <= (P-1)*Exp_msk1 && aadj >= 1.) {
1732 aadj1 = (double)(int)(aadj + 0.5);
1733 if (!dsign)
1734 aadj1 = -aadj1;
1735 }
1736 adj = aadj1 * ulp(value(rv));
1737 value(rv) += adj;
1738#endif
1739 }
1740 z = word0(rv) & Exp_mask;
1741 if (y == z) {
1742 /* Can we stop now? */
1743 L = aadj;
1744 aadj -= L;
1745 /* The tolerances below are conservative. */
1746 if (dsign || word1(rv) || word0(rv) & Bndry_mask) {
1747 if (aadj < .4999999 || aadj > .5000001)
1748 break;
1749 }
1750 else if (aadj < .4999999/FLT_RADIX)
1751 break;
1752 }
1753 cont:
1754 Bfree(bb);
1755 Bfree(bd);
1756 Bfree(bs);
1757 Bfree(delta);
1758 }
1759 retfree:
1760 Bfree(bb);
1761 Bfree(bd);
1762 Bfree(bs);
1763 Bfree(bd0);
1764 Bfree(delta);
1765 ret:
1766 if (se)
1767 *se = (char *)s;
1768 return sign ? -value(rv) : value(rv);
1769 }
1770
1771 static int
1772quorem
1773#ifdef KR_headers
1774 (b, S) Bigint *b, *S;
1775#else
1776 (Bigint *b, Bigint *S)
1777#endif
1778{
1779 int n;
1780 Long borrow, y;
1781 ULong carry, q, ys;
1782 ULong *bx, *bxe, *sx, *sxe;
1783#ifdef Pack_32
1784 Long z;
1785 ULong si, zs;
1786#endif
1787
1788 n = S->wds;
1789#ifdef DEBUG
1790 /*debug*/ if (b->wds > n)
1791 /*debug*/ Bug("oversize b in quorem");
1792#endif
1793 if (b->wds < n)
1794 return 0;
1795 sx = S->x;
1796 sxe = sx + --n;
1797 bx = b->x;
1798 bxe = bx + n;
1799 q = *bxe / (*sxe + 1); /* ensure q <= true quotient */
1800#ifdef DEBUG
1801 /*debug*/ if (q > 9)
1802 /*debug*/ Bug("oversized quotient in quorem");
1803#endif
1804 if (q) {
1805 borrow = 0;
1806 carry = 0;
1807 do {
1808#ifdef Pack_32
1809 si = *sx++;
1810 ys = (si & 0xffff) * q + carry;
1811 zs = (si >> 16) * q + (ys >> 16);
1812 carry = zs >> 16;
1813 y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
1814 borrow = y >> 16;
1815 Sign_Extend(borrow, y);
1816 z = (*bx >> 16) - (zs & 0xffff) + borrow;
1817 borrow = z >> 16;
1818 Sign_Extend(borrow, z);
1819 Storeinc(bx, z, y);
1820#else
1821 ys = *sx++ * q + carry;
1822 carry = ys >> 16;
1823 y = *bx - (ys & 0xffff) + borrow;
1824 borrow = y >> 16;
1825 Sign_Extend(borrow, y);
1826 *bx++ = y & 0xffff;
1827#endif
1828 }
1829 while(sx <= sxe);
1830 if (!*bxe) {
1831 bx = b->x;
1832 while(--bxe > bx && !*bxe)
1833 --n;
1834 b->wds = n;
1835 }
1836 }
1837 if (cmp(b, S) >= 0) {
1838 q++;
1839 borrow = 0;
1840 carry = 0;
1841 bx = b->x;
1842 sx = S->x;
1843 do {
1844#ifdef Pack_32
1845 si = *sx++;
1846 ys = (si & 0xffff) + carry;
1847 zs = (si >> 16) + (ys >> 16);
1848 carry = zs >> 16;
1849 y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
1850 borrow = y >> 16;
1851 Sign_Extend(borrow, y);
1852 z = (*bx >> 16) - (zs & 0xffff) + borrow;
1853 borrow = z >> 16;
1854 Sign_Extend(borrow, z);
1855 Storeinc(bx, z, y);
1856#else
1857 ys = *sx++ + carry;
1858 carry = ys >> 16;
1859 y = *bx - (ys & 0xffff) + borrow;
1860 borrow = y >> 16;
1861 Sign_Extend(borrow, y);
1862 *bx++ = y & 0xffff;
1863#endif
1864 }
1865 while(sx <= sxe);
1866 bx = b->x;
1867 bxe = bx + n;
1868 if (!*bxe) {
1869 while(--bxe > bx && !*bxe)
1870 --n;
1871 b->wds = n;
1872 }
1873 }
1874 return q;
1875 }
1876
1877/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
1878 *
1879 * Inspired by "How to Print Floating-Point Numbers Accurately" by
1880 * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101].
1881 *
1882 * Modifications:
1883 * 1. Rather than iterating, we use a simple numeric overestimate
1884 * to determine k = floor(log10(d)). We scale relevant
1885 * quantities using O(log2(k)) rather than O(k) multiplications.
1886 * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
1887 * try to generate digits strictly left to right. Instead, we
1888 * compute with fewer bits and propagate the carry if necessary
1889 * when rounding the final digit up. This is often faster.
1890 * 3. Under the assumption that input will be rounded nearest,
1891 * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
1892 * That is, we allow equality in stopping tests when the
1893 * round-nearest rule will give the same floating-point value
1894 * as would satisfaction of the stopping test with strict
1895 * inequality.
1896 * 4. We remove common factors of powers of 2 from relevant
1897 * quantities.
1898 * 5. When converting floating-point integers less than 1e16,
1899 * we use floating-point arithmetic rather than resorting
1900 * to multiple-precision integers.
1901 * 6. When asked to produce fewer than 15 digits, we first try
1902 * to get by with floating-point arithmetic; we resort to
1903 * multiple-precision integer arithmetic only if we cannot
1904 * guarantee that the floating-point calculation has given
1905 * the correctly rounded result. For k requested digits and
1906 * "uniformly" distributed input, the probability is
1907 * something like 10^(k-15) that we must resort to the Long
1908 * calculation.
1909 */
1910
1911 char *
1912__dtoa
1913#ifdef KR_headers
1914 (_d, mode, ndigits, decpt, sign, rve)
1915 double _d; int mode, ndigits, *decpt, *sign; char **rve;
1916#else
1917 (double _d, int mode, int ndigits, int *decpt, int *sign, char **rve)
1918#endif
1919{
1920 /* Arguments ndigits, decpt, sign are similar to those
1921 of ecvt and fcvt; trailing zeros are suppressed from
1922 the returned string. If not null, *rve is set to point
1923 to the end of the return value. If d is +-Infinity or NaN,
1924 then *decpt is set to 9999.
1925
1926 mode:
1927 0 ==> shortest string that yields d when read in
1928 and rounded to nearest.
1929 1 ==> like 0, but with Steele & White stopping rule;
1930 e.g. with IEEE P754 arithmetic , mode 0 gives
1931 1e23 whereas mode 1 gives 9.999999999999999e22.
1932 2 ==> max(1,ndigits) significant digits. This gives a
1933 return value similar to that of ecvt, except
1934 that trailing zeros are suppressed.
1935 3 ==> through ndigits past the decimal point. This
1936 gives a return value similar to that from fcvt,
1937 except that trailing zeros are suppressed, and
1938 ndigits can be negative.
1939 4-9 should give the same return values as 2-3, i.e.,
1940 4 <= mode <= 9 ==> same return as mode
1941 2 + (mode & 1). These modes are mainly for
1942 debugging; often they run slower but sometimes
1943 faster than modes 2-3.
1944 4,5,8,9 ==> left-to-right digit generation.
1945 6-9 ==> don't try fast floating-point estimate
1946 (if applicable).
1947
1948 Values of mode other than 0-9 are treated as mode 0.
1949
1950 Sufficient space is allocated to the return value
1951 to hold the suppressed trailing zeros.
1952 */
1953
1954 int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1,
1955 j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
1956 spec_case, try_quick;
1957 Long L;
1958#ifndef Sudden_Underflow
1959 int denorm;
1960 ULong x;
1961#endif
1962 Bigint *b, *b1, *delta, *mlo, *mhi, *S;
1963 double ds;
1964 char *s, *s0;
1965 static Bigint *result;
1966 static int result_k;
1967 _double d, d2, eps;
1968
1969 value(d) = _d;
1970 if (result) {
1971 result->k = result_k;
1972 result->maxwds = 1 << result_k;
1973 Bfree(result);
1974 result = 0;
1975 }
1976
1977 if (word0(d) & Sign_bit) {
1978 /* set sign for everything, including 0's and NaNs */
1979 *sign = 1;
1980 word0(d) &= ~Sign_bit; /* clear sign bit */
1981 }
1982 else
1983 *sign = 0;
1984
1985#if defined(IEEE_Arith) + defined(VAX)
1986#ifdef IEEE_Arith
1987 if ((word0(d) & Exp_mask) == Exp_mask)
1988#else
1989 if (word0(d) == 0x8000)
1990#endif
1991 {
1992 /* Infinity or NaN */
1993 *decpt = 9999;
1994 s =
1995#ifdef IEEE_Arith
1996 !word1(d) && !(word0(d) & 0xfffff) ? "Infinity" :
1997#endif
1998 "NaN";
1999 if (rve)
2000 *rve =
2001#ifdef IEEE_Arith
2002 s[3] ? s + 8 :
2003#endif
2004 s + 3;
2005 return s;
2006 }
2007#endif
2008#ifdef IBM
2009 value(d) += 0; /* normalize */
2010#endif
2011 if (!value(d)) {
2012 *decpt = 1;
2013 s = "0";
2014 if (rve)
2015 *rve = s + 1;
2016 return s;
2017 }
2018
2019 b = d2b(value(d), &be, &bbits);
2020#ifdef Sudden_Underflow
2021 i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1));
2022#else
2023 if (i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1))) {
2024#endif
2025 value(d2) = value(d);
2026 word0(d2) &= Frac_mask1;
2027 word0(d2) |= Exp_11;
2028#ifdef IBM
2029 if (j = 11 - hi0bits(word0(d2) & Frac_mask))
2030 value(d2) /= 1 << j;
2031#endif
2032
2033 /* log(x) ~=~ log(1.5) + (x-1.5)/1.5
2034 * log10(x) = log(x) / log(10)
2035 * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
2036 * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)
2037 *
2038 * This suggests computing an approximation k to log10(d) by
2039 *
2040 * k = (i - Bias)*0.301029995663981
2041 * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
2042 *
2043 * We want k to be too large rather than too small.
2044 * The error in the first-order Taylor series approximation
2045 * is in our favor, so we just round up the constant enough
2046 * to compensate for any error in the multiplication of
2047 * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
2048 * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
2049 * adding 1e-13 to the constant term more than suffices.
2050 * Hence we adjust the constant term to 0.1760912590558.
2051 * (We could get a more accurate k by invoking log10,
2052 * but this is probably not worthwhile.)
2053 */
2054
2055 i -= Bias;
2056#ifdef IBM
2057 i <<= 2;
2058 i += j;
2059#endif
2060#ifndef Sudden_Underflow
2061 denorm = 0;
2062 }
2063 else {
2064 /* d is denormalized */
2065
2066 i = bbits + be + (Bias + (P-1) - 1);
2067 x = i > 32 ? word0(d) << 64 - i | word1(d) >> i - 32
2068 : word1(d) << 32 - i;
2069 value(d2) = x;
2070 word0(d2) -= 31*Exp_msk1; /* adjust exponent */
2071 i -= (Bias + (P-1) - 1) + 1;
2072 denorm = 1;
2073 }
2074#endif
2075 ds = (value(d2)-1.5)*0.289529654602168 + 0.1760912590558 +
2076 i*0.301029995663981;
2077 k = (int)ds;
2078 if (ds < 0. && ds != k)
2079 k--; /* want k = floor(ds) */
2080 k_check = 1;
2081 if (k >= 0 && k <= Ten_pmax) {
2082 if (value(d) < tens[k])
2083 k--;
2084 k_check = 0;
2085 }
2086 j = bbits - i - 1;
2087 if (j >= 0) {
2088 b2 = 0;
2089 s2 = j;
2090 }
2091 else {
2092 b2 = -j;
2093 s2 = 0;
2094 }
2095 if (k >= 0) {
2096 b5 = 0;
2097 s5 = k;
2098 s2 += k;
2099 }
2100 else {
2101 b2 -= k;
2102 b5 = -k;
2103 s5 = 0;
2104 }
2105 if (mode < 0 || mode > 9)
2106 mode = 0;
2107 try_quick = 1;
2108 if (mode > 5) {
2109 mode -= 4;
2110 try_quick = 0;
2111 }
2112 leftright = 1;
2113 switch(mode) {
2114 case 0:
2115 case 1:
2116 ilim = ilim1 = -1;
2117 i = 18;
2118 ndigits = 0;
2119 break;
2120 case 2:
2121 leftright = 0;
2122 /* no break */
2123 case 4:
2124 if (ndigits <= 0)
2125 ndigits = 1;
2126 ilim = ilim1 = i = ndigits;
2127 break;
2128 case 3:
2129 leftright = 0;
2130 /* no break */
2131 case 5:
2132 i = ndigits + k + 1;
2133 ilim = i;
2134 ilim1 = i - 1;
2135 if (i <= 0)
2136 i = 1;
2137 }
2138 j = sizeof(ULong);
2139 for(result_k = 0; sizeof(Bigint) - sizeof(ULong) + j <= i;
2140 j <<= 1) result_k++;
2141 result = Balloc(result_k);
2142 s = s0 = (char *)result;
2143
2144 if (ilim >= 0 && ilim <= Quick_max && try_quick) {
2145
2146 /* Try to get by with floating-point arithmetic. */
2147
2148 i = 0;
2149 value(d2) = value(d);
2150 k0 = k;
2151 ilim0 = ilim;
2152 ieps = 2; /* conservative */
2153 if (k > 0) {
2154 ds = tens[k&0xf];
2155 j = k >> 4;
2156 if (j & Bletch) {
2157 /* prevent overflows */
2158 j &= Bletch - 1;
2159 value(d) /= bigtens[n_bigtens-1];
2160 ieps++;
2161 }
2162 for(; j; j >>= 1, i++)
2163 if (j & 1) {
2164 ieps++;
2165 ds *= bigtens[i];
2166 }
2167 value(d) /= ds;
2168 }
2169 else if (j1 = -k) {
2170 value(d) *= tens[j1 & 0xf];
2171 for(j = j1 >> 4; j; j >>= 1, i++)
2172 if (j & 1) {
2173 ieps++;
2174 value(d) *= bigtens[i];
2175 }
2176 }
2177 if (k_check && value(d) < 1. && ilim > 0) {
2178 if (ilim1 <= 0)
2179 goto fast_failed;
2180 ilim = ilim1;
2181 k--;
2182 value(d) *= 10.;
2183 ieps++;
2184 }
2185 value(eps) = ieps*value(d) + 7.;
2186 word0(eps) -= (P-1)*Exp_msk1;
2187 if (ilim == 0) {
2188 S = mhi = 0;
2189 value(d) -= 5.;
2190 if (value(d) > value(eps))
2191 goto one_digit;
2192 if (value(d) < -value(eps))
2193 goto no_digits;
2194 goto fast_failed;
2195 }
2196#ifndef No_leftright
2197 if (leftright) {
2198 /* Use Steele & White method of only
2199 * generating digits needed.
2200 */
2201 value(eps) = 0.5/tens[ilim-1] - value(eps);
2202 for(i = 0;;) {
2203 L = value(d);
2204 value(d) -= L;
2205 *s++ = '0' + (int)L;
2206 if (value(d) < value(eps))
2207 goto ret1;
2208 if (1. - value(d) < value(eps))
2209 goto bump_up;
2210 if (++i >= ilim)
2211 break;
2212 value(eps) *= 10.;
2213 value(d) *= 10.;
2214 }
2215 }
2216 else {
2217#endif
2218 /* Generate ilim digits, then fix them up. */
2219 value(eps) *= tens[ilim-1];
2220 for(i = 1;; i++, value(d) *= 10.) {
2221 L = value(d);
2222 value(d) -= L;
2223 *s++ = '0' + (int)L;
2224 if (i == ilim) {
2225 if (value(d) > 0.5 + value(eps))
2226 goto bump_up;
2227 else if (value(d) < 0.5 - value(eps)) {
2228 while(*--s == '0');
2229 s++;
2230 goto ret1;
2231 }
2232 break;
2233 }
2234 }
2235#ifndef No_leftright
2236 }
2237#endif
2238 fast_failed:
2239 s = s0;
2240 value(d) = value(d2);
2241 k = k0;
2242 ilim = ilim0;
2243 }
2244
2245 /* Do we have a "small" integer? */
2246
2247 if (be >= 0 && k <= Int_max) {
2248 /* Yes. */
2249 ds = tens[k];
2250 if (ndigits < 0 && ilim <= 0) {
2251 S = mhi = 0;
2252 if (ilim < 0 || value(d) <= 5*ds)
2253 goto no_digits;
2254 goto one_digit;
2255 }
2256 for(i = 1;; i++) {
2257 L = value(d) / ds;
2258 value(d) -= L*ds;
2259#ifdef Check_FLT_ROUNDS
2260 /* If FLT_ROUNDS == 2, L will usually be high by 1 */
2261 if (value(d) < 0) {
2262 L--;
2263 value(d) += ds;
2264 }
2265#endif
2266 *s++ = '0' + (int)L;
2267 if (i == ilim) {
2268 value(d) += value(d);
2269 if (value(d) > ds || value(d) == ds && L & 1) {
2270 bump_up:
2271 while(*--s == '9')
2272 if (s == s0) {
2273 k++;
2274 *s = '0';
2275 break;
2276 }
2277 ++*s++;
2278 }
2279 break;
2280 }
2281 if (!(value(d) *= 10.))
2282 break;
2283 }
2284 goto ret1;
2285 }
2286
2287 m2 = b2;
2288 m5 = b5;
2289 mhi = mlo = 0;
2290 if (leftright) {
2291 if (mode < 2) {
2292 i =
2293#ifndef Sudden_Underflow
2294 denorm ? be + (Bias + (P-1) - 1 + 1) :
2295#endif
2296#ifdef IBM
2297 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3);
2298#else
2299 1 + P - bbits;
2300#endif
2301 }
2302 else {
2303 j = ilim - 1;
2304 if (m5 >= j)
2305 m5 -= j;
2306 else {
2307 s5 += j -= m5;
2308 b5 += j;
2309 m5 = 0;
2310 }
2311 if ((i = ilim) < 0) {
2312 m2 -= i;
2313 i = 0;
2314 }
2315 }
2316 b2 += i;
2317 s2 += i;
2318 mhi = i2b(1);
2319 }
2320 if (m2 > 0 && s2 > 0) {
2321 i = m2 < s2 ? m2 : s2;
2322 b2 -= i;
2323 m2 -= i;
2324 s2 -= i;
2325 }
2326 if (b5 > 0) {
2327 if (leftright) {
2328 if (m5 > 0) {
2329 mhi = pow5mult(mhi, m5);
2330 b1 = mult(mhi, b);
2331 Bfree(b);
2332 b = b1;
2333 }
2334 if (j = b5 - m5)
2335 b = pow5mult(b, j);
2336 }
2337 else
2338 b = pow5mult(b, b5);
2339 }
2340 S = i2b(1);
2341 if (s5 > 0)
2342 S = pow5mult(S, s5);
2343
2344 /* Check for special case that d is a normalized power of 2. */
2345
2346 if (mode < 2) {
2347 if (!word1(d) && !(word0(d) & Bndry_mask)
2348#ifndef Sudden_Underflow
2349 && word0(d) & Exp_mask
2350#endif
2351 ) {
2352 /* The special case */
2353 b2 += Log2P;
2354 s2 += Log2P;
2355 spec_case = 1;
2356 }
2357 else
2358 spec_case = 0;
2359 }
2360
2361 /* Arrange for convenient computation of quotients:
2362 * shift left if necessary so divisor has 4 leading 0 bits.
2363 *
2364 * Perhaps we should just compute leading 28 bits of S once
2365 * and for all and pass them and a shift to quorem, so it
2366 * can do shifts and ors to compute the numerator for q.
2367 */
2368#ifdef Pack_32
2369 if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f)
2370 i = 32 - i;
2371#else
2372 if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf)
2373 i = 16 - i;
2374#endif
2375 if (i > 4) {
2376 i -= 4;
2377 b2 += i;
2378 m2 += i;
2379 s2 += i;
2380 }
2381 else if (i < 4) {
2382 i += 28;
2383 b2 += i;
2384 m2 += i;
2385 s2 += i;
2386 }
2387 if (b2 > 0)
2388 b = lshift(b, b2);
2389 if (s2 > 0)
2390 S = lshift(S, s2);
2391 if (k_check) {
2392 if (cmp(b,S) < 0) {
2393 k--;
2394 b = multadd(b, 10, 0); /* we botched the k estimate */
2395 if (leftright)
2396 mhi = multadd(mhi, 10, 0);
2397 ilim = ilim1;
2398 }
2399 }
2400 if (ilim <= 0 && mode > 2) {
2401 if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) {
2402 /* no digits, fcvt style */
2403 no_digits:
2404 k = -1 - ndigits;
2405 goto ret;
2406 }
2407 one_digit:
2408 *s++ = '1';
2409 k++;
2410 goto ret;
2411 }
2412 if (leftright) {
2413 if (m2 > 0)
2414 mhi = lshift(mhi, m2);
2415
2416 /* Compute mlo -- check for special case
2417 * that d is a normalized power of 2.
2418 */
2419
2420 mlo = mhi;
2421 if (spec_case) {
2422 mhi = Balloc(mhi->k);
2423 Bcopy(mhi, mlo);
2424 mhi = lshift(mhi, Log2P);
2425 }
2426
2427 for(i = 1;;i++) {
2428 dig = quorem(b,S) + '0';
2429 /* Do we yet have the shortest decimal string
2430 * that will round to d?
2431 */
2432 j = cmp(b, mlo);
2433 delta = diff(S, mhi);
2434 j1 = delta->sign ? 1 : cmp(b, delta);
2435 Bfree(delta);
2436#ifndef ROUND_BIASED
2437 if (j1 == 0 && !mode && !(word1(d) & 1)) {
2438 if (dig == '9')
2439 goto round_9_up;
2440 if (j > 0)
2441 dig++;
2442 *s++ = dig;
2443 goto ret;
2444 }
2445#endif
2446 if (j < 0 || j == 0 && !mode
2447#ifndef ROUND_BIASED
2448 && !(word1(d) & 1)
2449#endif
2450 ) {
2451 if (j1 > 0) {
2452 b = lshift(b, 1);
2453 j1 = cmp(b, S);
2454 if ((j1 > 0 || j1 == 0 && dig & 1)
2455 && dig++ == '9')
2456 goto round_9_up;
2457 }
2458 *s++ = dig;
2459 goto ret;
2460 }
2461 if (j1 > 0) {
2462 if (dig == '9') { /* possible if i == 1 */
2463 round_9_up:
2464 *s++ = '9';
2465 goto roundoff;
2466 }
2467 *s++ = dig + 1;
2468 goto ret;
2469 }
2470 *s++ = dig;
2471 if (i == ilim)
2472 break;
2473 b = multadd(b, 10, 0);
2474 if (mlo == mhi)
2475 mlo = mhi = multadd(mhi, 10, 0);
2476 else {
2477 mlo = multadd(mlo, 10, 0);
2478 mhi = multadd(mhi, 10, 0);
2479 }
2480 }
2481 }
2482 else
2483 for(i = 1;; i++) {
2484 *s++ = dig = quorem(b,S) + '0';
2485 if (i >= ilim)
2486 break;
2487 b = multadd(b, 10, 0);
2488 }
2489
2490 /* Round off last digit */
2491
2492 b = lshift(b, 1);
2493 j = cmp(b, S);
2494 if (j > 0 || j == 0 && dig & 1) {
2495 roundoff:
2496 while(*--s == '9')
2497 if (s == s0) {
2498 k++;
2499 *s++ = '1';
2500 goto ret;
2501 }
2502 ++*s++;
2503 }
2504 else {
2505 while(*--s == '0');
2506 s++;
2507 }
2508 ret:
2509 Bfree(S);
2510 if (mhi) {
2511 if (mlo && mlo != mhi)
2512 Bfree(mlo);
2513 Bfree(mhi);
2514 }
2515 ret1:
2516 Bfree(b);
2517 if (s == s0) { /* don't return empty string */
2518 *s++ = '0';
2519 k = 0;
2520 }
2521 *s = 0;
2522 *decpt = k + 1;
2523 if (rve)
2524 *rve = s;
2525 return s0;
2526 }
2527#ifdef __cplusplus
2528}
2529#endif
diff --git a/src/lib/libc/stdlib/strtol.3 b/src/lib/libc/stdlib/strtol.3
new file mode 100644
index 0000000000..b7d2cd1225
--- /dev/null
+++ b/src/lib/libc/stdlib/strtol.3
@@ -0,0 +1,168 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strtol.3,v 1.3 1996/08/19 08:33:51 tholo Exp $
37.\"
38.Dd June 25, 1992
39.Dt STRTOL 3
40.Os
41.Sh NAME
42.Nm strtol, strtoq
43.Nd convert string value to a long or quad_t integer
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Fd #include <limits.h>
47.Ft long
48.Fn strtol "const char *nptr" "char **endptr" "int base"
49
50.Fd #include <sys/types.h>
51.Fd #include <stdlib.h>
52.Fd #include <limits.h>
53.Ft quad_t
54.Fn strtoq "const char *nptr" "char **endptr" "int base"
55.Sh DESCRIPTION
56The
57.Fn strtol
58function
59converts the string in
60.Fa nptr
61to a
62.Em long
63value.
64The
65.Fn strtoq
66function
67converts the string in
68.Fa nptr
69to a
70.Em quad_t
71value.
72The conversion is done according to the given
73.Fa base ,
74which must be between 2 and 36 inclusive,
75or be the special value 0.
76.Pp
77The string may begin with an arbitrary amount of white space
78(as determined by
79.Xr isspace 3 )
80followed by a single optional
81.Ql +
82or
83.Ql -
84sign.
85If
86.Fa base
87is zero or 16,
88the string may then include a
89.Ql 0x
90prefix,
91and the number will be read in base 16; otherwise, a zero
92.Fa base
93is taken as 10 (decimal) unless the next character is
94.Ql 0 ,
95in which case it is taken as 8 (octal).
96.Pp
97The remainder of the string is converted to a
98.Em long
99value in the obvious manner,
100stopping at the first character which is not a valid digit
101in the given base.
102(In bases above 10, the letter
103.Ql A
104in either upper or lower case
105represents 10,
106.Ql B
107represents 11, and so forth, with
108.Ql Z
109representing 35.)
110.Pp
111If
112.Fa endptr
113is non nil,
114.Fn strtol
115stores the address of the first invalid character in
116.Fa *endptr .
117If there were no digits at all, however,
118.Fn strtol
119stores the original value of
120.Fa nptr
121in
122.Fa *endptr .
123(Thus, if
124.Fa *nptr
125is not
126.Ql \e0
127but
128.Fa **endptr
129is
130.Ql \e0
131on return, the entire string was valid.)
132.Sh RETURN VALUES
133The
134.Fn strtol
135function
136returns the result of the conversion,
137unless the value would underflow or overflow.
138If an underflow occurs,
139.Fn strtol
140returns
141.Dv LONG_MIN .
142If an overflow occurs,
143.Fn strtol
144returns
145.Dv LONG_MAX .
146In both cases,
147.Va errno
148is set to
149.Er ERANGE .
150.Sh ERRORS
151.Bl -tag -width Er
152.It Bq Er ERANGE
153The given string was out of range; the value converted has been clamped.
154.El
155.Sh SEE ALSO
156.Xr atof 3 ,
157.Xr atoi 3 ,
158.Xr atol 3 ,
159.Xr strtod 3 ,
160.Xr strtoul 3
161.Sh STANDARDS
162The
163.Fn strtol
164function
165conforms to
166.St -ansiC .
167.Sh BUGS
168Ignores the current locale.
diff --git a/src/lib/libc/stdlib/strtol.c b/src/lib/libc/stdlib/strtol.c
new file mode 100644
index 0000000000..e4ad557fd5
--- /dev/null
+++ b/src/lib/libc/stdlib/strtol.c
@@ -0,0 +1,150 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strtol.c,v 1.4 1996/08/19 08:33:51 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <ctype.h>
39#include <errno.h>
40#include <limits.h>
41#include <stdlib.h>
42
43
44/*
45 * Convert a string to a long integer.
46 *
47 * Ignores `locale' stuff. Assumes that the upper and lower case
48 * alphabets and digits are each contiguous.
49 */
50long
51strtol(nptr, endptr, base)
52 const char *nptr;
53 char **endptr;
54 register int base;
55{
56 register const char *s;
57 register long acc, cutoff;
58 register int c;
59 register int neg, any, cutlim;
60
61 /*
62 * Skip white space and pick up leading +/- sign if any.
63 * If base is 0, allow 0x for hex and 0 for octal, else
64 * assume decimal; if base is already 16, allow 0x.
65 */
66 s = nptr;
67 do {
68 c = (unsigned char) *s++;
69 } while (isspace(c));
70 if (c == '-') {
71 neg = 1;
72 c = *s++;
73 } else {
74 neg = 0;
75 if (c == '+')
76 c = *s++;
77 }
78 if ((base == 0 || base == 16) &&
79 c == '0' && (*s == 'x' || *s == 'X')) {
80 c = s[1];
81 s += 2;
82 base = 16;
83 }
84 if (base == 0)
85 base = c == '0' ? 8 : 10;
86
87 /*
88 * Compute the cutoff value between legal numbers and illegal
89 * numbers. That is the largest legal value, divided by the
90 * base. An input number that is greater than this value, if
91 * followed by a legal input character, is too big. One that
92 * is equal to this value may be valid or not; the limit
93 * between valid and invalid numbers is then based on the last
94 * digit. For instance, if the range for longs is
95 * [-2147483648..2147483647] and the input base is 10,
96 * cutoff will be set to 214748364 and cutlim to either
97 * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
98 * a value > 214748364, or equal but the next digit is > 7 (or 8),
99 * the number is too big, and we will return a range error.
100 *
101 * Set any if any `digits' consumed; make it negative to indicate
102 * overflow.
103 */
104 cutoff = neg ? LONG_MIN : LONG_MAX;
105 cutlim = cutoff % base;
106 cutoff /= base;
107 if (neg) {
108 if (cutlim > 0) {
109 cutlim -= base;
110 cutoff += 1;
111 }
112 cutlim = -cutlim;
113 }
114 for (acc = 0, any = 0;; c = (unsigned char) *s++) {
115 if (isdigit(c))
116 c -= '0';
117 else if (isalpha(c))
118 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
119 else
120 break;
121 if (c >= base)
122 break;
123 if (any < 0)
124 continue;
125 if (neg) {
126 if (acc < cutoff || acc == cutoff && c > cutlim) {
127 any = -1;
128 acc = LONG_MIN;
129 errno = ERANGE;
130 } else {
131 any = 1;
132 acc *= base;
133 acc -= c;
134 }
135 } else {
136 if (acc > cutoff || acc == cutoff && c > cutlim) {
137 any = -1;
138 acc = LONG_MAX;
139 errno = ERANGE;
140 } else {
141 any = 1;
142 acc *= base;
143 acc += c;
144 }
145 }
146 }
147 if (endptr != 0)
148 *endptr = (char *) (any ? s - 1 : nptr);
149 return (acc);
150}
diff --git a/src/lib/libc/stdlib/strtoq.c b/src/lib/libc/stdlib/strtoq.c
new file mode 100644
index 0000000000..44aabd73f0
--- /dev/null
+++ b/src/lib/libc/stdlib/strtoq.c
@@ -0,0 +1,152 @@
1/*-
2 * Copyright (c) 1992 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: strtoq.c,v 1.4 1996/08/19 08:33:52 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39
40#include <ctype.h>
41#include <errno.h>
42#include <limits.h>
43#include <stdlib.h>
44
45/*
46 * Convert a string to a quad integer.
47 *
48 * Ignores `locale' stuff. Assumes that the upper and lower case
49 * alphabets and digits are each contiguous.
50 */
51quad_t
52strtoq(nptr, endptr, base)
53 const char *nptr;
54 char **endptr;
55 register int base;
56{
57 register const char *s;
58 register quad_t acc, cutoff;
59 register int c;
60 register int neg, any, cutlim;
61
62 /*
63 * Skip white space and pick up leading +/- sign if any.
64 * If base is 0, allow 0x for hex and 0 for octal, else
65 * assume decimal; if base is already 16, allow 0x.
66 */
67 s = nptr;
68 do {
69 c = (unsigned char) *s++;
70 } while (isspace(c));
71 if (c == '-') {
72 neg = 1;
73 c = *s++;
74 } else {
75 neg = 0;
76 if (c == '+')
77 c = *s++;
78 }
79 if ((base == 0 || base == 16) &&
80 c == '0' && (*s == 'x' || *s == 'X')) {
81 c = s[1];
82 s += 2;
83 base = 16;
84 }
85 if (base == 0)
86 base = c == '0' ? 8 : 10;
87
88 /*
89 * Compute the cutoff value between legal numbers and illegal
90 * numbers. That is the largest legal value, divided by the
91 * base. An input number that is greater than this value, if
92 * followed by a legal input character, is too big. One that
93 * is equal to this value may be valid or not; the limit
94 * between valid and invalid numbers is then based on the last
95 * digit. For instance, if the range for quads is
96 * [-9223372036854775808..9223372036854775807] and the input base
97 * is 10, cutoff will be set to 922337203685477580 and cutlim to
98 * either 7 (neg==0) or 8 (neg==1), meaning that if we have
99 * accumulated a value > 922337203685477580, or equal but the
100 * next digit is > 7 (or 8), the number is too big, and we will
101 * return a range error.
102 *
103 * Set any if any `digits' consumed; make it negative to indicate
104 * overflow.
105 */
106 cutoff = neg ? QUAD_MIN : QUAD_MAX;
107 cutlim = cutoff % base;
108 cutoff /= base;
109 if (neg) {
110 if (cutlim > 0) {
111 cutlim -= base;
112 cutoff += 1;
113 }
114 cutlim = -cutlim;
115 }
116 for (acc = 0, any = 0;; c = (unsigned char) *s++) {
117 if (isdigit(c))
118 c -= '0';
119 else if (isalpha(c))
120 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
121 else
122 break;
123 if (c >= base)
124 break;
125 if (any < 0)
126 continue;
127 if (neg) {
128 if (acc < cutoff || acc == cutoff && c > cutlim) {
129 any = -1;
130 acc = QUAD_MIN;
131 errno = ERANGE;
132 } else {
133 any = 1;
134 acc *= base;
135 acc -= c;
136 }
137 } else {
138 if (acc > cutoff || acc == cutoff && c > cutlim) {
139 any = -1;
140 acc = QUAD_MAX;
141 errno = ERANGE;
142 } else {
143 any = 1;
144 acc *= base;
145 acc += c;
146 }
147 }
148 }
149 if (endptr != 0)
150 *endptr = (char *) (any ? s - 1 : nptr);
151 return (acc);
152}
diff --git a/src/lib/libc/stdlib/strtoul.3 b/src/lib/libc/stdlib/strtoul.3
new file mode 100644
index 0000000000..b8234122a2
--- /dev/null
+++ b/src/lib/libc/stdlib/strtoul.3
@@ -0,0 +1,163 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strtoul.3,v 1.2 1996/08/19 08:33:52 tholo Exp $
37.\"
38.Dd June 25, 1992
39.Dt STRTOUL 3
40.Os
41.Sh NAME
42.Nm strtoul, strtouq
43.Nd convert a string to an unsigned long or uquad_t integer
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Fd #include <limits.h>
47.Ft unsigned long
48.Fn strtoul "const char *nptr" "char **endptr" "int base"
49
50.Fd #include <sys/types.h>
51.Fd #include <stdlib.h>
52.Fd #include <limits.h>
53.Ft u_quad_t
54.Fn strtouq "const char *nptr" "char **endptr" "int base"
55.Sh DESCRIPTION
56The
57.Fn strtoul
58function
59converts the string in
60.Fa nptr
61to an
62.Em unsigned long
63value.
64The
65.Fn strtouq
66function
67converts the string in
68.Fa nptr
69to a
70.Em u_quad_t
71value.
72The conversion is done according to the given
73.Fa base ,
74which must be between 2 and 36 inclusive,
75or be the special value 0.
76.Pp
77The string may begin with an arbitrary amount of white space
78(as determined by
79.Xr isspace 3 )
80followed by a single optional
81.Ql +
82or
83.Ql -
84sign.
85If
86.Fa base
87is zero or 16,
88the string may then include a
89.Ql 0x
90prefix,
91and the number will be read in base 16; otherwise, a zero
92.Fa base
93is taken as 10 (decimal) unless the next character is
94.Ql 0 ,
95in which case it is taken as 8 (octal).
96.Pp
97The remainder of the string is converted to an
98.Em unsigned long
99value in the obvious manner,
100stopping at the end of the string
101or at the first character that does not produce a valid digit
102in the given base.
103(In bases above 10, the letter
104.Ql A
105in either upper or lower case
106represents 10,
107.Ql B
108represents 11, and so forth, with
109.Ql Z
110representing 35.)
111.Pp
112If
113.Fa endptr
114is non nil,
115.Fn strtoul
116stores the address of the first invalid character in
117.Fa *endptr .
118If there were no digits at all, however,
119.Fn strtoul
120stores the original value of
121.Fa nptr
122in
123.Fa *endptr .
124(Thus, if
125.Fa *nptr
126is not
127.Ql \e0
128but
129.Fa **endptr
130is
131.Ql \e0
132on return, the entire string was valid.)
133.Sh RETURN VALUES
134The
135.Fn strtoul
136function
137returns either the result of the conversion
138or, if there was a leading minus sign,
139the negation of the result of the conversion,
140unless the original (non-negated) value would overflow;
141in the latter case,
142.Fn strtoul
143returns
144.Dv ULONG_MAX
145and sets the global variable
146.Va errno
147to
148.Er ERANGE .
149.Sh ERRORS
150.Bl -tag -width Er
151.It Bq Er ERANGE
152The given string was out of range; the value converted has been clamped.
153.El
154.Sh SEE ALSO
155.Xr strtol 3
156.Sh STANDARDS
157The
158.Fn strtoul
159function
160conforms to
161.St -ansiC .
162.Sh BUGS
163Ignores the current locale.
diff --git a/src/lib/libc/stdlib/strtoul.c b/src/lib/libc/stdlib/strtoul.c
new file mode 100644
index 0000000000..d3b363fa04
--- /dev/null
+++ b/src/lib/libc/stdlib/strtoul.c
@@ -0,0 +1,112 @@
1/*
2 * Copyright (c) 1990 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strtoul.c,v 1.4 1996/08/19 08:33:52 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <ctype.h>
39#include <errno.h>
40#include <limits.h>
41#include <stdlib.h>
42
43/*
44 * Convert a string to an unsigned long integer.
45 *
46 * Ignores `locale' stuff. Assumes that the upper and lower case
47 * alphabets and digits are each contiguous.
48 */
49unsigned long
50strtoul(nptr, endptr, base)
51 const char *nptr;
52 char **endptr;
53 register int base;
54{
55 register const char *s;
56 register unsigned long acc, cutoff;
57 register int c;
58 register int neg, any, cutlim;
59
60 /*
61 * See strtol for comments as to the logic used.
62 */
63 s = nptr;
64 do {
65 c = (unsigned char) *s++;
66 } while (isspace(c));
67 if (c == '-') {
68 neg = 1;
69 c = *s++;
70 } else {
71 neg = 0;
72 if (c == '+')
73 c = *s++;
74 }
75 if ((base == 0 || base == 16) &&
76 c == '0' && (*s == 'x' || *s == 'X')) {
77 c = s[1];
78 s += 2;
79 base = 16;
80 }
81 if (base == 0)
82 base = c == '0' ? 8 : 10;
83
84 cutoff = ULONG_MAX / (unsigned long)base;
85 cutlim = ULONG_MAX % (unsigned long)base;
86 for (acc = 0, any = 0;; c = (unsigned char) *s++) {
87 if (isdigit(c))
88 c -= '0';
89 else if (isalpha(c))
90 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
91 else
92 break;
93 if (c >= base)
94 break;
95 if (any < 0)
96 continue;
97 if (acc > cutoff || acc == cutoff && c > cutlim) {
98 any = -1;
99 acc = ULONG_MAX;
100 errno = ERANGE;
101 } else {
102 any = 1;
103 acc *= (unsigned long)base;
104 acc += c;
105 }
106 }
107 if (neg && any > 0)
108 acc = -acc;
109 if (endptr != 0)
110 *endptr = (char *) (any ? s - 1 : nptr);
111 return (acc);
112}
diff --git a/src/lib/libc/stdlib/strtouq.c b/src/lib/libc/stdlib/strtouq.c
new file mode 100644
index 0000000000..1f29a22f33
--- /dev/null
+++ b/src/lib/libc/stdlib/strtouq.c
@@ -0,0 +1,114 @@
1/*-
2 * Copyright (c) 1992 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char rcsid[] = "$OpenBSD: strtouq.c,v 1.4 1996/08/19 08:33:53 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39
40#include <ctype.h>
41#include <errno.h>
42#include <limits.h>
43#include <stdlib.h>
44
45/*
46 * Convert a string to an unsigned quad integer.
47 *
48 * Ignores `locale' stuff. Assumes that the upper and lower case
49 * alphabets and digits are each contiguous.
50 */
51u_quad_t
52strtouq(nptr, endptr, base)
53 const char *nptr;
54 char **endptr;
55 register int base;
56{
57 register const char *s;
58 register u_quad_t acc, cutoff;
59 register int c;
60 register int neg, any, cutlim;
61
62 /*
63 * See strtoq for comments as to the logic used.
64 */
65 s = nptr;
66 do {
67 c = (unsigned char) *s++;
68 } while (isspace(c));
69 if (c == '-') {
70 neg = 1;
71 c = *s++;
72 } else {
73 neg = 0;
74 if (c == '+')
75 c = *s++;
76 }
77 if ((base == 0 || base == 16) &&
78 c == '0' && (*s == 'x' || *s == 'X')) {
79 c = s[1];
80 s += 2;
81 base = 16;
82 }
83 if (base == 0)
84 base = c == '0' ? 8 : 10;
85
86 cutoff = UQUAD_MAX / (u_quad_t)base;
87 cutlim = UQUAD_MAX % (u_quad_t)base;
88 for (acc = 0, any = 0;; c = (unsigned char) *s++) {
89 if (isdigit(c))
90 c -= '0';
91 else if (isalpha(c))
92 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
93 else
94 break;
95 if (c >= base)
96 break;
97 if (any < 0)
98 continue;
99 if (acc > cutoff || acc == cutoff && c > cutlim) {
100 any = -1;
101 acc = UQUAD_MAX;
102 errno = ERANGE;
103 } else {
104 any = 1;
105 acc *= (u_quad_t)base;
106 acc += c;
107 }
108 }
109 if (neg && any > 0)
110 acc = -acc;
111 if (endptr != 0)
112 *endptr = (char *) (any ? s - 1 : nptr);
113 return (acc);
114}
diff --git a/src/lib/libc/stdlib/system.3 b/src/lib/libc/stdlib/system.3
new file mode 100644
index 0000000000..985adb07de
--- /dev/null
+++ b/src/lib/libc/stdlib/system.3
@@ -0,0 +1,98 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: system.3,v 1.5 1996/12/11 23:09:53 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt SYSTEM 3
40.Os
41.Sh NAME
42.Nm system
43.Nd pass a command to the shell
44.Sh SYNOPSIS
45.Fd #include <stdlib.h>
46.Ft int
47.Fn system "const char *string"
48.Sh DESCRIPTION
49The
50.Fn system
51function
52hands the argument
53.Fa string
54to the command interpreter
55.Xr sh 1 .
56The calling process waits for the shell to finish executing the command,
57ignoring
58.Dv SIGINT
59and
60.Dv SIGQUIT ,
61and blocking
62.Dv SIGCHLD .
63.Pp
64If
65.Fa string
66is a
67.Dv NULL
68pointer,
69.Fn system
70will return non-zero.
71Otherwise,
72.Fn system
73returns the termination status of the shell in the format specified by
74.Xr waitpid 2 .
75.Sh RETURN VALUES
76If a child process cannot be created, or the termination status of
77the shell cannot be obtained,
78.Fn system
79returns -1 and sets
80.Va errno
81to indicate the error.
82If execution of the shell fails,
83.Fn system
84returns the termination status for a program that terminates with a call of
85.Fn exit 127 .
86.Sh SEE ALSO
87.Xr sh 1 ,
88.Xr execve 2 ,
89.Xr waitpid 2 ,
90.Xr popen 3
91.Sh STANDARDS
92The
93.Fn system
94function
95conforms to
96.St -ansiC
97and
98.St -p1003.2-92 .
diff --git a/src/lib/libc/stdlib/system.c b/src/lib/libc/stdlib/system.c
new file mode 100644
index 0000000000..3e1b047393
--- /dev/null
+++ b/src/lib/libc/stdlib/system.c
@@ -0,0 +1,80 @@
1/*
2 * Copyright (c) 1988 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: system.c,v 1.3 1996/09/15 09:31:52 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <sys/wait.h>
40#include <signal.h>
41#include <stdlib.h>
42#include <unistd.h>
43#include <paths.h>
44
45extern char **environ;
46
47int
48system(command)
49 const char *command;
50{
51 pid_t pid;
52 sig_t intsave, quitsave;
53 int omask;
54 int pstat;
55 char *argp[] = {"sh", "-c", NULL, NULL};
56
57 if (!command) /* just checking... */
58 return(1);
59
60 argp[2] = (char *)command;
61
62 omask = sigblock(sigmask(SIGCHLD));
63 switch(pid = vfork()) {
64 case -1: /* error */
65 (void)sigsetmask(omask);
66 return(-1);
67 case 0: /* child */
68 (void)sigsetmask(omask);
69 execve(_PATH_BSHELL, argp, environ);
70 _exit(127);
71 }
72
73 intsave = signal(SIGINT, SIG_IGN);
74 quitsave = signal(SIGQUIT, SIG_IGN);
75 pid = waitpid(pid, (int *)&pstat, 0);
76 (void)sigsetmask(omask);
77 (void)signal(SIGINT, intsave);
78 (void)signal(SIGQUIT, quitsave);
79 return(pid == -1 ? -1 : pstat);
80}
diff --git a/src/lib/libc/stdlib/tfind.c b/src/lib/libc/stdlib/tfind.c
new file mode 100644
index 0000000000..9e5bd4b0f2
--- /dev/null
+++ b/src/lib/libc/stdlib/tfind.c
@@ -0,0 +1,41 @@
1/*
2 * Tree search generalized from Knuth (6.2.2) Algorithm T just like
3 * the AT&T man page says.
4 *
5 * The node_t structure is for internal use only, lint doesn't grok it.
6 *
7 * Written by reading the System V Interface Definition, not the code.
8 *
9 * Totally public domain.
10 */
11/*LINTLIBRARY*/
12#include <search.h>
13
14typedef struct node_t
15{
16 char *key;
17 struct node_t *llink, *rlink;
18} node;
19
20/* find a node, or return 0 */
21void *
22tfind(vkey, vrootp, compar)
23 const void *vkey; /* key to be found */
24 void *const *vrootp; /* address of the tree root */
25 int (*compar) __P((const void *, const void *));
26{
27 char *key = (char *)vkey;
28 node **rootp = (node **)vrootp;
29
30 if (rootp == (struct node_t **)0)
31 return ((struct node_t *)0);
32 while (*rootp != (struct node_t *)0) { /* T1: */
33 int r;
34 if ((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
35 return (*rootp); /* key found */
36 rootp = (r < 0) ?
37 &(*rootp)->llink : /* T3: follow left branch */
38 &(*rootp)->rlink; /* T4: follow right branch */
39 }
40 return (node *)0;
41}
diff --git a/src/lib/libc/stdlib/tsearch.3 b/src/lib/libc/stdlib/tsearch.3
new file mode 100644
index 0000000000..c2ef8ae6cb
--- /dev/null
+++ b/src/lib/libc/stdlib/tsearch.3
@@ -0,0 +1,116 @@
1.\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. The name of the author may not be used to endorse or promote products
13.\" derived from this software without specific prior written permission.
14.\"
15.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
16.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
17.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
18.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\" $OpenBSD: tsearch.3,v 1.3 1999/02/27 21:56:03 deraadt Exp $
27.\"
28.Dd June 15, 1997
29.Dt TSEARCH 3
30.Os
31.Sh NAME
32.Nm tsearch, tfind, tdelete, twalk
33.Nd manipulate binary search trees
34.Sh SYNOPSIS
35.Fd #include <search.h>
36.Ft void *
37.Fn tdelete "const void *key" "void **rootp", "int (*compar) (const void *, const void *)"
38.Ft void *
39.Fn tfind "const void *key" "void * const *rootp", "int (*compar) (const void *, const void *)"
40.Ft void *
41.Fn tsearch "const void *key" "void **rootp", "int (*compar) (const void *, const void *)"
42.Ft void
43.Fn twalk "const void *root" "void (*compar) (const void *, VISIT, int)"
44.Sh DESCRIPTION
45The
46.Fn tdelete ,
47.Fn tfind ,
48.Fn tsearch ,
49and
50.Fn twalk
51functions manage binary search trees based on algorithms T and D
52from Knuth (6.2.2). The comparison function passed in by
53the user has the same style of return values as
54.Xr strcmp 3 .
55.Pp
56.Fn tfind
57searches for the datum matched by the argument
58.Fa key
59in the binary tree rooted at
60.Fa rootp ,
61returning a pointer to the datum if it is found and NULL
62if it is not.
63.Pp
64.Fn tsearch
65is identical to
66.Fn tfind
67except that if no match is found,
68.Fa key
69is inserted into the tree and a pointer to it is returned. If
70.Fa rootp
71points to a NULL value a new binary search tree is created.
72.Pp
73.Fn tdelete
74deletes a node from the specified binary search tree and returns
75a pointer to the parent of the node to be deleted.
76It takes the same arguments as
77.Fn tfind
78and
79.Fn tsearch .
80If the node to be deleted is the root of the binary search tree,
81.Fa rootp
82will be adjusted.
83.Pp
84.Fn twalk
85walks the binary search tree rooted in
86.fa root
87and calls the function
88.Fa action
89on each node.
90.Fa action
91is called with three arguments: a pointer to the current node,
92a value from the enum
93.Sy "typedef enum { preorder, postorder, endorder, leaf } VISIT;"
94specifying the traversal type, and a node level (where level
95zero is the root of the tree).
96.Sh SEE ALSO
97.Xr bsearch 3 ,
98.Xr hsearch 3 ,
99.Xr lsearch 3
100.Sh RETURN VALUES
101The
102.Fn tsearch
103function returns NULL if allocation of a new node fails (usually
104due to a lack of free memory).
105.Pp
106.Fn tfind ,
107.Fn tsearch ,
108and
109.Fn tdelete
110return NULL if
111.Fa rootp
112is NULL or the datum cannot be found.
113.Pp
114The
115.Fn twalk
116function returns no value.
diff --git a/src/lib/libc/stdlib/tsearch.c b/src/lib/libc/stdlib/tsearch.c
new file mode 100644
index 0000000000..562ace1845
--- /dev/null
+++ b/src/lib/libc/stdlib/tsearch.c
@@ -0,0 +1,126 @@
1/*
2 * Tree search generalized from Knuth (6.2.2) Algorithm T just like
3 * the AT&T man page says.
4 *
5 * The node_t structure is for internal use only, lint doesn't grok it.
6 *
7 * Written by reading the System V Interface Definition, not the code.
8 *
9 * Totally public domain.
10 */
11/*LINTLIBRARY*/
12
13#include <search.h>
14#include <stdlib.h>
15
16typedef struct node_t {
17 char *key;
18 struct node_t *left, *right;
19} node;
20
21/* find or insert datum into search tree */
22void *
23tsearch(vkey, vrootp, compar)
24 const void *vkey; /* key to be located */
25 void **vrootp; /* address of tree root */
26 int (*compar) __P((const void *, const void *));
27{
28 register node *q;
29 char *key = (char *)vkey;
30 node **rootp = (node **)vrootp;
31
32 if (rootp == (struct node_t **)0)
33 return ((void *)0);
34 while (*rootp != (struct node_t *)0) { /* Knuth's T1: */
35 int r;
36
37 if ((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
38 return ((void *)*rootp); /* we found it! */
39 rootp = (r < 0) ?
40 &(*rootp)->left : /* T3: follow left branch */
41 &(*rootp)->right; /* T4: follow right branch */
42 }
43 q = (node *) malloc(sizeof(node)); /* T5: key not found */
44 if (q != (struct node_t *)0) { /* make new node */
45 *rootp = q; /* link new node to old */
46 q->key = key; /* initialize new node */
47 q->left = q->right = (struct node_t *)0;
48 }
49 return ((void *)q);
50}
51
52/* delete node with given key */
53void *
54tdelete(vkey, vrootp, compar)
55 const void *vkey; /* key to be deleted */
56 void **vrootp; /* address of the root of tree */
57 int (*compar) __P((const void *, const void *));
58{
59 node **rootp = (node **)vrootp;
60 char *key = (char *)vkey;
61 node *p;
62 register node *q;
63 register node *r;
64 int cmp;
65
66 if (rootp == (struct node_t **)0 || (p = *rootp) == (struct node_t *)0)
67 return ((struct node_t *)0);
68 while ((cmp = (*compar)(key, (*rootp)->key)) != 0) {
69 p = *rootp;
70 rootp = (cmp < 0) ?
71 &(*rootp)->left : /* follow left branch */
72 &(*rootp)->right; /* follow right branch */
73 if (*rootp == (struct node_t *)0)
74 return ((void *)0); /* key not found */
75 }
76 r = (*rootp)->right; /* D1: */
77 if ((q = (*rootp)->left) == (struct node_t *)0) /* Left (struct node_t *)0? */
78 q = r;
79 else if (r != (struct node_t *)0) { /* Right link is null? */
80 if (r->left == (struct node_t *)0) { /* D2: Find successor */
81 r->left = q;
82 q = r;
83 } else { /* D3: Find (struct node_t *)0 link */
84 for (q = r->left; q->left != (struct node_t *)0; q = r->left)
85 r = q;
86 r->left = q->right;
87 q->left = (*rootp)->left;
88 q->right = (*rootp)->right;
89 }
90 }
91 free((struct node_t *) *rootp); /* D4: Free node */
92 *rootp = q; /* link parent to new node */
93 return(p);
94}
95
96/* Walk the nodes of a tree */
97static void
98trecurse(root, action, level)
99 register node *root; /* Root of the tree to be walked */
100 register void (*action)(); /* Function to be called at each node */
101 register int level;
102{
103 if (root->left == (struct node_t *)0 && root->right == (struct node_t *)0)
104 (*action)(root, leaf, level);
105 else {
106 (*action)(root, preorder, level);
107 if (root->left != (struct node_t *)0)
108 trecurse(root->left, action, level + 1);
109 (*action)(root, postorder, level);
110 if (root->right != (struct node_t *)0)
111 trecurse(root->right, action, level + 1);
112 (*action)(root, endorder, level);
113 }
114}
115
116/* Walk the nodes of a tree */
117void
118twalk(vroot, action)
119 const void *vroot; /* Root of the tree to be walked */
120 void (*action) __P((const void *, VISIT, int));
121{
122 node *root = (node *)vroot;
123
124 if (root != (node *)0 && action != (void(*)())0)
125 trecurse(root, action, 0);
126}
diff --git a/src/lib/libc/string/Makefile.inc b/src/lib/libc/string/Makefile.inc
new file mode 100644
index 0000000000..78eee7efa5
--- /dev/null
+++ b/src/lib/libc/string/Makefile.inc
@@ -0,0 +1,128 @@
1# $OpenBSD: Makefile.inc,v 1.6 1998/11/20 11:18:51 d Exp $
2
3# string sources
4.PATH: ${LIBCSRCDIR}/arch/${MACHINE_ARCH}/string ${LIBCSRCDIR}/string
5
6SRCS+= bm.c memccpy.c strcasecmp.c strcoll.c strdup.c strerror.c \
7 strlcat.c strlcpy.c strmode.c strsignal.c strtok.c strxfrm.c \
8 __strerror.c __strsignal.c
9
10# machine-dependent net sources
11# m-d Makefile.inc must include sources for:
12# bcmp() bcopy() bzero() ffs() index() memchr() memcmp() memset()
13# rindex() strcat() strcmp() strcpy() strcspn() strlen()
14# strncat() strncmp() strncpy() strpbrk() strsep()
15# strspn() strstr() swav()
16# m-d Makefile.inc may include sources for:
17# memcpy() memmove() strchr() strrchr()
18
19.include "${LIBCSRCDIR}/arch/${MACHINE_ARCH}/string/Makefile.inc"
20
21# if no machine specific memmove(3), build one out of bcopy(3).
22.if empty(SRCS:Mmemmove.S)
23OBJS+= memmove.o
24memmove.o: bcopy.c
25 ${CC} -DMEMMOVE ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
26 @${LD} -x -r ${.TARGET}
27 @mv a.out ${.TARGET}
28
29memmove.po: bcopy.c
30 ${CC} -DMEMMOVE ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET}
31 @${LD} -X -r ${.TARGET}
32 @mv a.out ${.TARGET}
33
34memmove.so: bcopy.c
35 ${CC} ${PICFLAG} -DPIC -DMEMMOVE ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \
36 -o ${.TARGET}
37.endif
38
39# if no machine specific memcpy(3), build one out of bcopy(3).
40# if there is a machine specific memmove(3), we'll assume it aliases
41# memcpy(3).
42.if empty(SRCS:Mmemcpy.S)
43.if empty(SRCS:Mmemmove.S)
44OBJS+= memcpy.o
45memcpy.o: bcopy.c
46 ${CC} -DMEMCOPY ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
47 @${LD} -x -r ${.TARGET}
48 @mv a.out ${.TARGET}
49
50memcpy.po: bcopy.c
51 ${CC} -DMEMCOPY ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET}
52 @${LD} -X -r ${.TARGET}
53 @mv a.out ${.TARGET}
54
55memcpy.so: bcopy.c
56 ${CC} ${PICFLAG} -DPIC -DMEMCOPY ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \
57 -o ${.TARGET}
58.endif
59.endif
60
61# if no machine specific strchr(3), build one out of index(3).
62.if empty(SRCS:Mstrchr.S)
63OBJS+= strchr.o
64strchr.o: index.c
65 ${CC} -DSTRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
66 @${LD} -x -r ${.TARGET}
67 @mv a.out ${.TARGET}
68
69strchr.po: index.c
70 ${CC} -DSTRCHR ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET}
71 @${LD} -X -r ${.TARGET}
72 @mv a.out ${.TARGET}
73
74strchr.so: index.c
75 ${CC} ${PICFLAG} -DPIC -DSTRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \
76 -o ${.TARGET}
77.endif
78
79# if no machine specific strrchr(3), build one out of rindex(3).
80.if empty(SRCS:Mstrrchr.S)
81OBJS+= strrchr.o
82strrchr.o: rindex.c
83 ${CC} -DSTRRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
84 @${LD} -x -r ${.TARGET}
85 @mv a.out ${.TARGET}
86
87strrchr.po: rindex.c
88 ${CC} -DSTRRCHR ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET}
89 @${LD} -X -r ${.TARGET}
90 @mv a.out ${.TARGET}
91
92strrchr.so: rindex.c
93 ${CC} ${PICFLAG} -DPIC -DSTRRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \
94 -o ${.TARGET}
95.endif
96
97# build .ln files for memmove, memcpy, strchr and strrchr always from
98# bcopy, index, and rindex
99LOBJS+= memmove.ln memcpy.ln strchr.ln strrchr.ln
100
101memmove.ln: bcopy.c
102 lint ${LINTFLAGS} -DMEMMOVE ${CFLAGS:M-[IDU]*} -i -o ${.TARGET} \
103 ${LIBCSRCDIR}/string/bcopy.c
104
105memcpy.ln: bcopy.c
106 lint ${LINTFLAGS} -DMEMCOPY ${CFLAGS:M-[IDU]*} -i -o ${.TARGET} \
107 ${LIBCSRCDIR}/string/bcopy.c
108
109strchr.ln: index.c
110 lint ${LINTFLAGS} -DSTRCHR ${CFLAGS:M-[IDU]*} -i -o ${.TARGET} \
111 ${LIBCSRCDIR}/string/index.c
112
113strrchr.ln: rindex.c
114 lint ${LINTFLAGS} -DSTRRCHR ${CFLAGS:M-[IDU]*} -i -o ${.TARGET} \
115 ${LIBCSRCDIR}/string/rindex.c
116
117MAN+= bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \
118 memcmp.3 memcpy.3 memmove.3 memset.3 rindex.3 strcasecmp.3 strcat.3 \
119 strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strerror.3 \
120 string.3 strlen.3 strmode.3 strdup.3 strpbrk.3 strrchr.3 strsep.3 \
121 strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 strlcpy.3
122
123MLINKS+=bm.3 bm_comp.3 bm.3 bm_exec.3 bm.3 bm_free.3
124MLINKS+=strcasecmp.3 strncasecmp.3
125MLINKS+=strcat.3 strncat.3
126MLINKS+=strcmp.3 strncmp.3
127MLINKS+=strcpy.3 strncpy.3
128MLINKS+=strlcpy.3 strlcat.3
diff --git a/src/lib/libc/string/__strerror.c b/src/lib/libc/string/__strerror.c
new file mode 100644
index 0000000000..9c023f8a53
--- /dev/null
+++ b/src/lib/libc/string/__strerror.c
@@ -0,0 +1,111 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: __strerror.c,v 1.6 1996/09/25 08:17:30 deraadt Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#ifdef NLS
39#define catclose _catclose
40#define catgets _catgets
41#define catopen _catopen
42#include <nl_types.h>
43#endif
44
45#define sys_errlist _sys_errlist
46#define sys_nerr _sys_nerr
47
48#include <errno.h>
49#include <limits.h>
50#include <stdio.h>
51#include <string.h>
52
53static char *itoa(num)
54 int num;
55{
56 static char buffer[11];
57 char *p;
58
59 p = buffer + 4;
60 while (num >= 10) {
61 *--p = (num % 10) + '0';
62 num /= 10;
63 }
64 *p = (num % 10) + '0';
65 return p;
66}
67
68/*
69 * Since perror() is not allowed to change the contents of strerror()'s
70 * static buffer, both functions supply their own buffers to the
71 * internal function __strerror().
72 */
73
74char *
75__strerror(num, buf)
76 int num;
77 char *buf;
78{
79#define UPREFIX "Unknown error: "
80 register unsigned int errnum;
81
82#ifdef NLS
83 nl_catd catd;
84 catd = catopen("libc", 0);
85#endif
86
87 errnum = num; /* convert to unsigned */
88 if (errnum < sys_nerr) {
89#ifdef NLS
90 strncpy(buf, catgets(catd, 1, errnum,
91 (char *)sys_errlist[errnum]), NL_TEXTMAX-1);
92 buf[NL_TEXTMAX - 1] = '\0';
93#else
94 return(sys_errlist[errnum]);
95#endif
96 } else {
97#ifdef NLS
98 strncpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX-1);
99 buf[NL_TEXTMAX - 1] = '\0';
100#else
101 strcpy(buf, UPREFIX);
102#endif
103 strncat(buf, itoa(errnum), NL_TEXTMAX-strlen(buf)-1);
104 }
105
106#ifdef NLS
107 catclose(catd);
108#endif
109
110 return buf;
111}
diff --git a/src/lib/libc/string/__strsignal.c b/src/lib/libc/string/__strsignal.c
new file mode 100644
index 0000000000..ae0df72cd3
--- /dev/null
+++ b/src/lib/libc/string/__strsignal.c
@@ -0,0 +1,104 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: __strsignal.c,v 1.5 1996/09/25 13:19:01 deraadt Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#ifdef NLS
39#define catclose _catclose
40#define catgets _catgets
41#define catopen _catopen
42#include <nl_types.h>
43#endif
44
45#define sys_siglist _sys_siglist
46
47#include <stdio.h>
48#include <limits.h>
49#include <signal.h>
50#include <string.h>
51
52static char *itoa(num)
53 int num;
54{
55 static char buffer[11];
56 char *p;
57
58 p = buffer + 4;
59 while (num >= 10) {
60 *--p = (num % 10) + '0';
61 num /= 10;
62 }
63 *p = (num % 10) + '0';
64 return p;
65}
66
67char *
68__strsignal(num, buf)
69 int num;
70 char *buf;
71{
72#define UPREFIX "Unknown signal: "
73 register unsigned int signum;
74
75#ifdef NLS
76 nl_catd catd ;
77 catd = catopen("libc", 0);
78#endif
79
80 signum = num; /* convert to unsigned */
81 if (signum < NSIG) {
82#ifdef NLS
83 strncpy(buf, catgets(catd, 2, signum,
84 (char *)sys_siglist[signum]), NL_TEXTMAX-1);
85 buf[NL_TEXTMAX-1] = '\0';
86#else
87 return((char *)sys_siglist[signum]);
88#endif
89 } else {
90#ifdef NLS
91 strncpy(buf, catgets(catd, 1, 0xffff, UPREFIX), NL_TEXTMAX-1);
92 buf[NL_TEXTMAX-1] = '\0';
93#else
94 strcpy(buf, UPREFIX);
95#endif
96 strncat(buf, itoa(signum), NL_TEXTMAX-strlen(buf)-1);
97 }
98
99#ifdef NLS
100 catclose(catd);
101#endif
102
103 return buf;
104}
diff --git a/src/lib/libc/string/bcmp.3 b/src/lib/libc/string/bcmp.3
new file mode 100644
index 0000000000..9234b5739d
--- /dev/null
+++ b/src/lib/libc/string/bcmp.3
@@ -0,0 +1,71 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $OpenBSD: bcmp.3,v 1.2 1996/08/19 08:33:56 tholo Exp $
35.\"
36.Dd April 19, 1991
37.Dt BCMP 3
38.Os BSD 4.2
39.Sh NAME
40.Nm bcmp
41.Nd compare byte string
42.Sh SYNOPSIS
43.Fd #include <string.h>
44.Ft int
45.Fn bcmp "const void *b1" "const void *b2" "size_t len"
46.Sh DESCRIPTION
47The
48.Fn bcmp
49function
50compares byte string
51.Fa b1
52against byte string
53.Fa b2 ,
54returning zero if they are identical, non-zero otherwise.
55Both strings are assumed to be
56.Fa len
57bytes long.
58Zero-length strings are always identical.
59.Pp
60The strings may overlap.
61.Sh SEE ALSO
62.Xr memcmp 3 ,
63.Xr strcasecmp 3 ,
64.Xr strcmp 3 ,
65.Xr strcoll 3 ,
66.Xr strxfrm 3
67.Sh HISTORY
68A
69.Fn bcmp
70function first appeared in
71.Bx 4.2 .
diff --git a/src/lib/libc/string/bcmp.c b/src/lib/libc/string/bcmp.c
new file mode 100644
index 0000000000..4ed00975a4
--- /dev/null
+++ b/src/lib/libc/string/bcmp.c
@@ -0,0 +1,63 @@
1/*
2 * Copyright (c) 1987 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: bcmp.c,v 1.4 1996/08/19 08:33:57 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#ifndef _KERNEL
39#include <string.h>
40#else
41#include <lib/libkern/libkern.h>
42#endif
43
44/*
45 * bcmp -- vax cmpc3 instruction
46 */
47int
48bcmp(b1, b2, length)
49 const void *b1, *b2;
50 register size_t length;
51{
52 register char *p1, *p2;
53
54 if (length == 0)
55 return(0);
56 p1 = (char *)b1;
57 p2 = (char *)b2;
58 do
59 if (*p1++ != *p2++)
60 break;
61 while (--length);
62 return(length);
63}
diff --git a/src/lib/libc/string/bcopy.3 b/src/lib/libc/string/bcopy.3
new file mode 100644
index 0000000000..4e841562e0
--- /dev/null
+++ b/src/lib/libc/string/bcopy.3
@@ -0,0 +1,71 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\" $OpenBSD: bcopy.3,v 1.2 1996/08/19 08:33:57 tholo Exp $
36.\"
37.Dd April 19, 1991
38.Dt BCOPY 3
39.Os BSD 4.2
40.Sh NAME
41.Nm bcopy
42.Nd copy byte string
43.Sh SYNOPSIS
44.Fd #include <string.h>
45.Ft void
46.Fn bcopy "const void *src" "void *dst" "size_t len"
47.Sh DESCRIPTION
48The
49.Fn bcopy
50function
51copies
52.Fa len
53bytes from string
54.Fa src
55to string
56.Fa dst .
57The two strings may overlap.
58If
59.Fa len
60is zero, no bytes are copied.
61.Sh SEE ALSO
62.Xr memccpy 3 ,
63.Xr memcpy 3 ,
64.Xr memmove 3 ,
65.Xr strcpy 3 ,
66.Xr strncpy 3
67.Sh HISTORY
68A
69.Fn bcopy
70function appeared in
71.Bx 4.2 .
diff --git a/src/lib/libc/string/bcopy.c b/src/lib/libc/string/bcopy.c
new file mode 100644
index 0000000000..023a3b2db2
--- /dev/null
+++ b/src/lib/libc/string/bcopy.c
@@ -0,0 +1,138 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: bcopy.c,v 1.2 1996/08/19 08:33:58 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <string.h>
42
43/*
44 * sizeof(word) MUST BE A POWER OF TWO
45 * SO THAT wmask BELOW IS ALL ONES
46 */
47typedef long word; /* "word" used for optimal copy speed */
48
49#define wsize sizeof(word)
50#define wmask (wsize - 1)
51
52/*
53 * Copy a block of memory, handling overlap.
54 * This is the routine that actually implements
55 * (the portable versions of) bcopy, memcpy, and memmove.
56 */
57#ifdef MEMCOPY
58void *
59memcpy(dst0, src0, length)
60#else
61#ifdef MEMMOVE
62void *
63memmove(dst0, src0, length)
64#else
65void
66bcopy(src0, dst0, length)
67#endif
68#endif
69 void *dst0;
70 const void *src0;
71 register size_t length;
72{
73 register char *dst = dst0;
74 register const char *src = src0;
75 register size_t t;
76
77 if (length == 0 || dst == src) /* nothing to do */
78 goto done;
79
80 /*
81 * Macros: loop-t-times; and loop-t-times, t>0
82 */
83#define TLOOP(s) if (t) TLOOP1(s)
84#define TLOOP1(s) do { s; } while (--t)
85
86 if ((unsigned long)dst < (unsigned long)src) {
87 /*
88 * Copy forward.
89 */
90 t = (long)src; /* only need low bits */
91 if ((t | (long)dst) & wmask) {
92 /*
93 * Try to align operands. This cannot be done
94 * unless the low bits match.
95 */
96 if ((t ^ (long)dst) & wmask || length < wsize)
97 t = length;
98 else
99 t = wsize - (t & wmask);
100 length -= t;
101 TLOOP1(*dst++ = *src++);
102 }
103 /*
104 * Copy whole words, then mop up any trailing bytes.
105 */
106 t = length / wsize;
107 TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
108 t = length & wmask;
109 TLOOP(*dst++ = *src++);
110 } else {
111 /*
112 * Copy backwards. Otherwise essentially the same.
113 * Alignment works as before, except that it takes
114 * (t&wmask) bytes to align, not wsize-(t&wmask).
115 */
116 src += length;
117 dst += length;
118 t = (long)src;
119 if ((t | (long)dst) & wmask) {
120 if ((t ^ (long)dst) & wmask || length <= wsize)
121 t = length;
122 else
123 t &= wmask;
124 length -= t;
125 TLOOP1(*--dst = *--src);
126 }
127 t = length / wsize;
128 TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
129 t = length & wmask;
130 TLOOP(*--dst = *--src);
131 }
132done:
133#if defined(MEMCOPY) || defined(MEMMOVE)
134 return (dst0);
135#else
136 return;
137#endif
138}
diff --git a/src/lib/libc/string/bm.3 b/src/lib/libc/string/bm.3
new file mode 100644
index 0000000000..c942930163
--- /dev/null
+++ b/src/lib/libc/string/bm.3
@@ -0,0 +1,113 @@
1.\" Copyright (c) 1994
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Andrew Hume of AT&T Bell Laboratories.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\" $OpenBSD: bm.3,v 1.2 1996/08/19 08:33:58 tholo Exp $
36.\"
37.TH BM 3
38.SH NAME
39bm_comp, bm_exec, bm_free \- Boyer-Moore string search
40.SH SYNOPSIS
41.ft B
42#include <sys/types.h>
43.br
44#include <bm.h>
45.sp
46bm_pat *
47.br
48bm_comp(u_char *pattern, size_t patlen, u_char freq[256]);
49.sp
50u_char *
51.br
52bm_exec(bm_pat *pdesc, u_char *text, size_t len);
53.sp
54void
55.br
56bm_free(bm_pat *pdesc);
57.SH DESCRIPTION
58These routines implement an efficient mechanism to find an
59occurrence of a byte string within another byte string.
60.PP
61.I Bm_comp
62evaluates the
63.I patlen
64bytes starting at
65.IR pattern ,
66and returns a pointer to a structure describing them.
67The bytes referenced by
68.I pattern
69may be of any value.
70.PP
71The search takes advantage of the frequency distribution of the
72bytes in the text to be searched.
73If specified,
74.I freq
75should be an array of 256 values,
76with higher values indicating that the corresponding character occurs
77more frequently.
78(A less than optimal frequency distribution can only result in less
79than optimal performance, not incorrect results.)
80If
81.I freq
82is NULL,
83a system default table is used.
84.PP
85.I Bm_exec
86returns a pointer to the leftmost occurrence of the string given to
87.I bm_comp
88within
89.IR text ,
90or NULL if none occurs.
91The number of bytes in
92.I text
93must be specified by
94.IR len .
95.PP
96Space allocated for the returned description is discarded
97by calling
98.I bm_free
99with the returned description as an argument.
100.PP
101The asymptotic speed of
102.I bm_exec
103is
104.RI O( len / patlen ).
105.PP
106.SH "SEE ALSO"
107.IR regexp (3),
108.IR strstr (3)
109.sp
110.IR "Fast String Searching" ,
111Hume and Sunday,
112Software Practice and Experience,
113Vol. 21, 11 (November 1991) pp. 1221-48.
diff --git a/src/lib/libc/string/bm.c b/src/lib/libc/string/bm.c
new file mode 100644
index 0000000000..b191d340f6
--- /dev/null
+++ b/src/lib/libc/string/bm.c
@@ -0,0 +1,219 @@
1/*-
2 * Copyright (c) 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Andrew Hume of AT&T Bell Laboratories.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: bm.c,v 1.3 1996/08/19 08:33:59 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <sys/types.h>
42
43#include <bm.h>
44#include <errno.h>
45#include <stdlib.h>
46#include <string.h>
47
48/*
49 * XXX
50 * The default frequency table starts at 99 and counts down. The default
51 * table should probably be oriented toward text, and will necessarily be
52 * locale specific. This one is for English. It was derived from the
53 * OSF/1 and 4.4BSD formatted and unformatted manual pages, and about 100Mb
54 * of email and random text. Change it if you can find something better.
55 */
56static u_char const freq_def[256] = {
57 0, 0, 0, 0, 0, 0, 0, 0,
58 0, 77, 90, 0, 0, 0, 0, 0,
59 0, 0, 0, 0, 0, 0, 0, 0,
60 0, 0, 0, 0, 0, 0, 0, 0,
61 99, 28, 42, 27, 16, 14, 20, 51,
62 66, 65, 59, 24, 75, 76, 84, 56,
63 72, 74, 64, 55, 54, 47, 41, 37,
64 44, 61, 70, 43, 23, 53, 49, 22,
65 33, 58, 40, 46, 45, 57, 60, 26,
66 30, 63, 21, 12, 32, 50, 38, 39,
67 34, 11, 48, 67, 62, 35, 15, 29,
68 71, 18, 9, 17, 25, 13, 10, 52,
69 36, 95, 78, 86, 87, 98, 82, 80,
70 88, 94, 19, 68, 89, 83, 93, 96,
71 81, 7, 91, 92, 97, 85, 69, 73,
72 31, 79, 8, 5, 4, 6, 3, 0,
73 0, 0, 0, 0, 0, 0, 0, 0,
74 0, 0, 0, 0, 0, 0, 0, 0,
75 0, 0, 0, 0, 0, 0, 0, 0,
76 0, 0, 0, 0, 0, 0, 0, 0,
77 0, 0, 0, 0, 0, 0, 0, 0,
78 0, 0, 0, 0, 0, 0, 0, 0,
79 0, 0, 0, 0, 0, 0, 0, 0,
80 0, 0, 0, 0, 0, 0, 0, 0,
81 0, 0, 0, 0, 0, 0, 0, 0,
82 0, 0, 0, 0, 0, 0, 0, 0,
83 0, 0, 0, 0, 0, 0, 0, 0,
84 0, 0, 0, 0, 0, 0, 0, 0,
85 0, 0, 0, 0, 0, 0, 0, 0,
86 0, 0, 0, 0, 0, 0, 0, 0,
87 0, 0, 0, 0, 0, 0, 0, 0,
88 0, 0, 0, 0, 0, 0, 0, 0,
89};
90
91bm_pat *
92bm_comp(pb, len, freq)
93 u_char const *pb;
94 size_t len;
95 u_char const *freq;
96{
97 register u_char const *pe, *p;
98 register size_t *d, r;
99 register int j;
100 int sv_errno;
101 bm_pat *pat;
102
103 if (len == 0) {
104 errno = EINVAL;
105 return (NULL);
106 }
107 if ((pat = malloc(sizeof(*pat))) == NULL)
108 return (NULL);
109 pat->pat = NULL;
110 pat->delta = NULL;
111
112 pat->patlen = len; /* copy pattern */
113 if ((pat->pat = malloc(pat->patlen)) == NULL)
114 goto mem;
115 memcpy(pat->pat, pb, pat->patlen);
116 /* get skip delta */
117 if ((pat->delta = malloc(256 * sizeof(*d))) == NULL)
118 goto mem;
119 for (j = 0, d = pat->delta; j < 256; j++)
120 d[j] = pat->patlen;
121 for (pe = pb + pat->patlen - 1; pb <= pe; pb++)
122 d[*pb] = pe - pb;
123
124 if (freq == NULL) /* default freq table */
125 freq = freq_def;
126 r = 0; /* get guard */
127 for (pb = pat->pat, pe = pb + pat->patlen - 1; pb < pe; pb++)
128 if (freq[*pb] < freq[pat->pat[r]])
129 r = pb - pat->pat;
130 pat->rarec = pat->pat[r];
131 pat->rareoff = r - (pat->patlen - 1);
132
133 /* get md2 shift */
134 for (pe = pat->pat + pat->patlen - 1, p = pe - 1; p >= pat->pat; p--)
135 if (*p == *pe)
136 break;
137
138 /* *p is first leftward reoccurrence of *pe */
139 pat->md2 = pe - p;
140 return (pat);
141
142mem: sv_errno = errno;
143 bm_free(pat);
144 errno = sv_errno;
145 return (NULL);
146}
147
148void
149bm_free(pat)
150 bm_pat *pat;
151{
152 if (pat->pat != NULL)
153 free(pat->pat);
154 if (pat->delta != NULL)
155 free(pat->delta);
156 free(pat);
157}
158
159u_char *
160bm_exec(pat, base, n)
161 bm_pat *pat;
162 u_char *base;
163 size_t n;
164{
165 register u_char *e, *ep, *p, *q, *s;
166 register size_t *d0, k, md2, n1, ro;
167 register int rc;
168
169 if (n == 0)
170 return (NULL);
171
172 d0 = pat->delta;
173 n1 = pat->patlen - 1;
174 md2 = pat->md2;
175 ro = pat->rareoff;
176 rc = pat->rarec;
177 ep = pat->pat + pat->patlen - 1;
178 s = base + (pat->patlen - 1);
179
180 /* fast loop up to n - 3 * patlen */
181 e = base + n - 3 * pat->patlen;
182 while (s < e) {
183 k = d0[*s]; /* ufast skip loop */
184 while (k) {
185 k = d0[*(s += k)];
186 k = d0[*(s += k)];
187 }
188 if (s >= e)
189 break;
190 if (s[ro] != rc) /* guard test */
191 goto mismatch1;
192 /* fwd match */
193 for (p = pat->pat, q = s - n1; p < ep;)
194 if (*q++ != *p++)
195 goto mismatch1;
196 return (s - n1);
197
198mismatch1: s += md2; /* md2 shift */
199 }
200
201 /* slow loop up to end */
202 e = base + n;
203 while (s < e) {
204 s += d0[*s]; /* step */
205 if (s >= e)
206 break;
207 if (s[ro] != rc) /* guard test */
208 goto mismatch2;
209 /* fwd match */
210 for (p = pat->pat, q = s - n1; p <= ep;)
211 if (*q++ != *p++)
212 goto mismatch2;
213 return (s - n1);
214
215mismatch2: s += md2; /* md2 shift */
216 }
217
218 return (NULL);
219}
diff --git a/src/lib/libc/string/bstring.3 b/src/lib/libc/string/bstring.3
new file mode 100644
index 0000000000..b553fd0beb
--- /dev/null
+++ b/src/lib/libc/string/bstring.3
@@ -0,0 +1,109 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $OpenBSD: bstring.3,v 1.2 1996/08/19 08:33:59 tholo Exp $
35.\"
36.Dd April 19, 1991
37.Dt BSTRING 3
38.Os
39.Sh NAME
40.Nm bcmp ,
41.Nm bcopy ,
42.Nm bzero ,
43.Nm memccpy ,
44.Nm memchr ,
45.Nm memcmp ,
46.Nm memcpy ,
47.Nm memmove,
48.Nm memset
49.Nd byte string operations
50.Sh SYNOPSIS
51.Fd #include <string.h>
52.Ft int
53.Fn bcmp "const void *b1" "const void *b2" "size_t len"
54.Ft void
55.Fn bcopy "const void *src" "void *dst" "size_t len"
56.Ft void
57.Fn bzero "void *b" "size_t len"
58.Ft void *
59.Fn memchr "const void *b" "int c" "size_t len"
60.Ft int
61.Fn memcmp "const void *b1" "const void *b2" "size_t len"
62.Ft void *
63.Fn memccpy "void *dst" "const void *src" "int c" "size_t len"
64.Ft void *
65.Fn memcpy "void *dst" "const void *src" "size_t len"
66.Ft void *
67.Fn memmove "void *dst" "const void *src" "size_t len"
68.Ft void *
69.Fn memset "void *b" "int c" "size_t len"
70.Sh DESCRIPTION
71These functions operate on variable length strings of bytes.
72They do not check for terminating null bytes as the routines
73listed in
74.Xr string 3
75do.
76.Pp
77See the specific manual pages for more information.
78.Sh SEE ALSO
79.Xr bcmp 3 ,
80.Xr bcopy 3 ,
81.Xr bzero 3 ,
82.Xr memccpy 3 ,
83.Xr memchr 3 ,
84.Xr memcmp 3 ,
85.Xr memcpy 3 ,
86.Xr memmove 3 ,
87.Xr memset 3
88.Sh STANDARDS
89The functions
90.Fn memchr ,
91.Fn memcmp ,
92.Fn memcpy ,
93.Fn memmove ,
94and
95.Fn memset
96conform to
97.St -ansiC .
98.Sh HISTORY
99The functions
100.Fn bzero
101and
102.Fn memccpy
103appeared in
104.Bx 4.3 ;
105the functions
106.Fn bcmp ,
107.Fn bcopy ,
108appeared in
109.Bx 4.2 .
diff --git a/src/lib/libc/string/bzero.3 b/src/lib/libc/string/bzero.3
new file mode 100644
index 0000000000..a8e55a63c1
--- /dev/null
+++ b/src/lib/libc/string/bzero.3
@@ -0,0 +1,67 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $OpenBSD: bzero.3,v 1.2 1996/08/19 08:34:00 tholo Exp $
35.\"
36.Dd April 19, 1991
37.Dt BZERO 3
38.Os BSD 4.3
39.Sh NAME
40.Nm bzero
41.Nd write zeroes to a byte string
42.Sh SYNOPSIS
43.Fd #include <string.h>
44.Ft void
45.Fn bzero "void *b" "size_t len"
46.Sh DESCRIPTION
47The
48.Fn bzero
49function
50writes
51.Fa len
52zero bytes to the string
53.Fa b .
54If
55.Fa len
56is zero,
57.Fn bzero
58does nothing.
59.Sh SEE ALSO
60.Xr memset 3 ,
61.Xr swab 3
62.Sh HISTORY
63A
64.Fn bzero
65function
66appeared in
67.Bx 4.3 .
diff --git a/src/lib/libc/string/bzero.c b/src/lib/libc/string/bzero.c
new file mode 100644
index 0000000000..3e660a307f
--- /dev/null
+++ b/src/lib/libc/string/bzero.c
@@ -0,0 +1,56 @@
1/*
2 * Copyright (c) 1987 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: bzero.c,v 1.3 1996/08/19 08:34:00 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#ifndef _KERNEL
39#include <string.h>
40#else
41#include <lib/libkern/libkern.h>
42#endif
43
44/*
45 * bzero -- vax movc5 instruction
46 */
47void
48bzero(b, length)
49 void *b;
50 register size_t length;
51{
52 register char *p;
53
54 for (p = b; length--;)
55 *p++ = '\0';
56}
diff --git a/src/lib/libc/string/ffs.3 b/src/lib/libc/string/ffs.3
new file mode 100644
index 0000000000..9ef08aef8e
--- /dev/null
+++ b/src/lib/libc/string/ffs.3
@@ -0,0 +1,62 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $OpenBSD: ffs.3,v 1.2 1996/08/19 08:34:01 tholo Exp $
35.\"
36.Dd April 19, 1991
37.Dt FFS 3
38.Os
39.Sh NAME
40.Nm ffs
41.Nd find first bit set in a bit string
42.Sh SYNOPSIS
43.Fd #include <string.h>
44.Ft int
45.Fn ffs "int value"
46.Sh DESCRIPTION
47The
48.Fn ffs
49function
50finds the first bit set in
51.Fa value
52and returns the index of that bit.
53Bits are numbered starting from 1, starting at the right-most
54bit.
55A return value of 0 means that the argument was zero.
56.Sh SEE ALSO
57.Xr bitstring 3
58.Sh HISTORY
59The
60.Fn ffs
61function appeared in
62.Bx 4.3 .
diff --git a/src/lib/libc/string/ffs.c b/src/lib/libc/string/ffs.c
new file mode 100644
index 0000000000..a0767e50ad
--- /dev/null
+++ b/src/lib/libc/string/ffs.c
@@ -0,0 +1,58 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: ffs.c,v 1.3 1996/08/19 08:34:01 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#ifndef _KERNEL
39#include <string.h>
40#else
41#include <lib/libkern/libkern.h>
42#endif
43
44/*
45 * ffs -- vax ffs instruction
46 */
47int
48ffs(mask)
49 register int mask;
50{
51 register int bit;
52
53 if (mask == 0)
54 return(0);
55 for (bit = 1; !(mask & 1); bit++)
56 mask >>= 1;
57 return(bit);
58}
diff --git a/src/lib/libc/string/index.3 b/src/lib/libc/string/index.3
new file mode 100644
index 0000000000..d236a73a48
--- /dev/null
+++ b/src/lib/libc/string/index.3
@@ -0,0 +1,82 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $OpenBSD: index.3,v 1.4 1997/12/30 01:09:49 deraadt Exp $
35.\"
36.Dd April 19, 1991
37.Dt INDEX 3
38.Os
39.Sh NAME
40.Nm index
41.Nd locate character in string
42.Sh SYNOPSIS
43.Fd #include <string.h>
44.Ft char *
45.Fn index "const char *s" "int c"
46.Sh DESCRIPTION
47The
48.Fn index
49function
50locates the first character matching
51.Fa c
52(converted to a
53.Em char )
54in the null-terminated string
55.Fa s .
56.Sh RETURN VALUES
57If the character
58.Fa c
59is found, a pointer to it is returned; otherwise
60.Dv NULL
61is returned.
62If
63.Fa c
64is '\e0',
65.Fn index
66locates the terminating '\e0'.
67.Sh SEE ALSO
68.Xr memchr 3 ,
69.Xr rindex 3 ,
70.Xr strchr 3 ,
71.Xr strcspn 3 ,
72.Xr strpbrk 3 ,
73.Xr strrchr 3 ,
74.Xr strsep 3 ,
75.Xr strspn 3 ,
76.Xr strstr 3 ,
77.Xr strtok 3
78.Sh HISTORY
79An
80.Fn index
81function appeared in
82.At v6 .
diff --git a/src/lib/libc/string/index.c b/src/lib/libc/string/index.c
new file mode 100644
index 0000000000..86c4e75f12
--- /dev/null
+++ b/src/lib/libc/string/index.c
@@ -0,0 +1,55 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: index.c,v 1.2 1996/08/19 08:34:02 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <string.h>
39
40char *
41#ifdef STRCHR
42strchr(p, ch)
43#else
44index(p, ch)
45#endif
46 register const char *p, ch;
47{
48 for (;; ++p) {
49 if (*p == ch)
50 return((char *)p);
51 if (!*p)
52 return((char *)NULL);
53 }
54 /* NOTREACHED */
55}
diff --git a/src/lib/libc/string/memccpy.3 b/src/lib/libc/string/memccpy.3
new file mode 100644
index 0000000000..c2e15b1405
--- /dev/null
+++ b/src/lib/libc/string/memccpy.3
@@ -0,0 +1,75 @@
1.\" $OpenBSD: memccpy.3,v 1.4 1998/06/15 17:55:09 mickey Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" @(#)memccpy.3 8.1 (Berkeley) 6/9/93
35.\"
36.Dd June 9, 1993
37.Dt MEMCCPY 3
38.Os
39.Sh NAME
40.Nm memccpy
41.Nd copy string until character found
42.Sh SYNOPSIS
43.Fd #include <string.h>
44.Ft void *
45.Fn memccpy "void *dst" "const void *src" "int c" "size_t len"
46.Sh DESCRIPTION
47The
48.Fn memccpy
49function
50copies bytes from string
51.Fa src
52to string
53.Fa dst .
54If the character
55.Fa c
56(as converted to an unsigned char) occurs in the string
57.Fa src ,
58the copy stops and a pointer to the byte after the copy of
59.Fa c
60in the string
61.Fa dst
62is returned.
63Otherwise,
64.Fa len
65bytes are copied, and a NULL pointer is returned.
66.Sh SEE ALSO
67.Xr bcopy 3 ,
68.Xr memcpy 3 ,
69.Xr memmove 3 ,
70.Xr strcpy 3
71.Sh HISTORY
72The
73.Fn memccpy
74function first appeared in
75.Bx 4.4 .
diff --git a/src/lib/libc/string/memccpy.c b/src/lib/libc/string/memccpy.c
new file mode 100644
index 0000000000..020e6e5679
--- /dev/null
+++ b/src/lib/libc/string/memccpy.c
@@ -0,0 +1,64 @@
1/* $OpenBSD: memccpy.c,v 1.3 1997/08/20 04:09:39 millert Exp $ */
2
3/*-
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#if defined(LIBC_SCCS) && !defined(lint)
37#if 0
38static char sccsid[] = "@(#)memccpy.c 8.1 (Berkeley) 6/4/93";
39#else
40static char *rcsid = "$OpenBSD: memccpy.c,v 1.3 1997/08/20 04:09:39 millert Exp $";
41#endif
42#endif /* LIBC_SCCS and not lint */
43
44#include <string.h>
45
46void *
47memccpy(t, f, c, n)
48 void *t;
49 const void *f;
50 int c;
51 register size_t n;
52{
53
54 if (n) {
55 register unsigned char *tp = t;
56 register const unsigned char *fp = f;
57 register unsigned char uc = c;
58 do {
59 if ((*tp++ = *fp++) == uc)
60 return (tp);
61 } while (--n != 0);
62 }
63 return (0);
64}
diff --git a/src/lib/libc/string/memchr.3 b/src/lib/libc/string/memchr.3
new file mode 100644
index 0000000000..56a2aee9ce
--- /dev/null
+++ b/src/lib/libc/string/memchr.3
@@ -0,0 +1,81 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: memchr.3,v 1.2 1996/08/19 08:34:04 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt MEMCHR 3
40.Os
41.Sh NAME
42.Nm memchr
43.Nd locate byte in byte string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft void *
47.Fn memchr "const void *b" "int c" "size_t len"
48.Sh DESCRIPTION
49The
50.Fn memchr
51function
52locates the first occurrence of
53.Fa c
54(converted to an unsigned char)
55in string
56.Fa b .
57.Sh RETURN VALUES
58The
59.Fn memchr
60function
61returns a pointer to the byte located,
62or NULL if no such byte exists within
63.Fa len
64bytes.
65.Sh SEE ALSO
66.Xr index 3 ,
67.Xr rindex 3 ,
68.Xr strchr 3 ,
69.Xr strcspn 3 ,
70.Xr strpbrk 3 ,
71.Xr strrchr 3 ,
72.Xr strsep 3 ,
73.Xr strspn 3 ,
74.Xr strstr 3 ,
75.Xr strtok 3
76.Sh STANDARDS
77The
78.Fn memchr
79function
80conforms to
81.St -ansiC .
diff --git a/src/lib/libc/string/memchr.c b/src/lib/libc/string/memchr.c
new file mode 100644
index 0000000000..2ebb5dab32
--- /dev/null
+++ b/src/lib/libc/string/memchr.c
@@ -0,0 +1,58 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: memchr.c,v 1.2 1996/08/19 08:34:04 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <string.h>
42
43void *
44memchr(s, c, n)
45 const void *s;
46 register unsigned char c;
47 register size_t n;
48{
49 if (n != 0) {
50 register const unsigned char *p = s;
51
52 do {
53 if (*p++ == c)
54 return ((void *)(p - 1));
55 } while (--n != 0);
56 }
57 return (NULL);
58}
diff --git a/src/lib/libc/string/memcmp.3 b/src/lib/libc/string/memcmp.3
new file mode 100644
index 0000000000..34c5f60861
--- /dev/null
+++ b/src/lib/libc/string/memcmp.3
@@ -0,0 +1,82 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: memcmp.3,v 1.3 1996/12/10 09:06:11 deraadt Exp $
37.\"
38.Dd June 29, 1991
39.Dt MEMCMP 3
40.Os
41.Sh NAME
42.Nm memcmp
43.Nd compare byte string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft int
47.Fn memcmp "const void *b1" "const void *b2" "size_t len"
48.Sh DESCRIPTION
49The
50.Fn memcmp
51function
52compares byte string
53.Fa b1
54against byte string
55.Fa b2 .
56Both strings are assumed to be
57.Fa len
58bytes long.
59.Sh RETURN VALUES
60The
61.Fn memcmp
62function
63returns zero if the two strings are identical,
64otherwise returns the difference between the first two differing bytes
65(treated as unsigned char values, so that
66.Sq Li \e200
67is greater than
68.Sq Li \&\e0 ,
69for example).
70Zero-length strings are always identical.
71.Sh SEE ALSO
72.Xr bcmp 3 ,
73.Xr strcasecmp 3 ,
74.Xr strcmp 3 ,
75.Xr strcoll 3 ,
76.Xr strxfrm 3
77.Sh STANDARDS
78The
79.Fn memcmp
80function
81conforms to
82.St -ansiC .
diff --git a/src/lib/libc/string/memcmp.c b/src/lib/libc/string/memcmp.c
new file mode 100644
index 0000000000..5ce33e2998
--- /dev/null
+++ b/src/lib/libc/string/memcmp.c
@@ -0,0 +1,60 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: memcmp.c,v 1.2 1996/08/19 08:34:05 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <string.h>
42
43/*
44 * Compare memory regions.
45 */
46int
47memcmp(s1, s2, n)
48 const void *s1, *s2;
49 size_t n;
50{
51 if (n != 0) {
52 register const unsigned char *p1 = s1, *p2 = s2;
53
54 do {
55 if (*p1++ != *p2++)
56 return (*--p1 - *--p2);
57 } while (--n != 0);
58 }
59 return (0);
60}
diff --git a/src/lib/libc/string/memcpy.3 b/src/lib/libc/string/memcpy.3
new file mode 100644
index 0000000000..75eb00b2d5
--- /dev/null
+++ b/src/lib/libc/string/memcpy.3
@@ -0,0 +1,83 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: memcpy.3,v 1.2 1996/08/19 08:34:06 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt MEMCPY 3
40.Os
41.Sh NAME
42.Nm memcpy
43.Nd copy byte string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft void *
47.Fn memcpy "void *dst" "const void *src" "size_t len"
48.Sh DESCRIPTION
49The
50.Fn memcpy
51function
52copies
53.Fa len
54bytes from string
55.Fa src
56to string
57.Fa dst .
58.Sh RETURN VALUES
59The
60.Fn memcpy
61function
62returns the original value of
63.Fa dst .
64.Sh SEE ALSO
65.Xr bcopy 3 ,
66.Xr memccpy 3 ,
67.Xr memmove 3 ,
68.Xr strcpy 3
69.Sh STANDARDS
70The
71.Fn memcpy
72function
73conforms to
74.St -ansiC .
75.Sh BUGS
76In this implementation
77.Fn memcpy
78is implemented using
79.Xr bcopy 3 ,
80and therefore the strings may overlap.
81On other systems, copying overlapping strings may produce surprises.
82A simpler solution is to not use
83.Fn memcpy .
diff --git a/src/lib/libc/string/memmove.3 b/src/lib/libc/string/memmove.3
new file mode 100644
index 0000000000..95f6b7596c
--- /dev/null
+++ b/src/lib/libc/string/memmove.3
@@ -0,0 +1,75 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: memmove.3,v 1.2 1996/08/19 08:34:07 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt MEMMOVE 3
40.Os
41.Sh NAME
42.Nm memmove
43.Nd copy byte string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft void *
47.Fn memmove "void *dst" "const void *src" "size_t len"
48.Sh DESCRIPTION
49The
50.Fn memmove
51function
52copies
53.Fa len
54bytes from string
55.Fa src
56to string
57.Fa dst .
58The two strings may overlap;
59the copy is always done in a non-destructive manner.
60.Sh RETURN VALUES
61The
62.Fn memmove
63function returns the original value of
64.Fa dst .
65.Sh SEE ALSO
66.Xr bcopy 3 ,
67.Xr memccpy 3 ,
68.Xr memcpy 3 ,
69.Xr strcpy 3
70.Sh STANDARDS
71The
72.Fn memmove
73function
74conforms to
75.St -ansiC .
diff --git a/src/lib/libc/string/memset.3 b/src/lib/libc/string/memset.3
new file mode 100644
index 0000000000..e1d8583732
--- /dev/null
+++ b/src/lib/libc/string/memset.3
@@ -0,0 +1,72 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: memset.3,v 1.3 1997/08/24 21:56:45 deraadt Exp $
37.\"
38.Dd June 29, 1991
39.Dt MEMSET 3
40.Os
41.Sh NAME
42.Nm memset
43.Nd write a byte to byte string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft void *
47.Fn memset "void *b" "int c" "size_t len"
48.Sh DESCRIPTION
49The
50.Fn memset
51function
52writes
53.Fa len
54bytes of value
55.Fa c
56(converted to an unsigned char) to the string
57.Fa b .
58.Sh RETURN VALUES
59The
60.Fn memset
61function
62returns the original value of
63.Fa b .
64.Sh SEE ALSO
65.Xr bzero 3 ,
66.Xr swab 3
67.Sh STANDARDS
68The
69.Fn memset
70function
71conforms to
72.St -ansiC .
diff --git a/src/lib/libc/string/memset.c b/src/lib/libc/string/memset.c
new file mode 100644
index 0000000000..c3373a21a9
--- /dev/null
+++ b/src/lib/libc/string/memset.c
@@ -0,0 +1,58 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: memset.c,v 1.2 1996/08/19 08:34:07 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <string.h>
42
43void *
44memset(dst, c, n)
45 void *dst;
46 register int c;
47 register size_t n;
48{
49
50 if (n != 0) {
51 register char *d = dst;
52
53 do
54 *d++ = c;
55 while (--n != 0);
56 }
57 return (dst);
58}
diff --git a/src/lib/libc/string/rindex.3 b/src/lib/libc/string/rindex.3
new file mode 100644
index 0000000000..db7f8e1cd8
--- /dev/null
+++ b/src/lib/libc/string/rindex.3
@@ -0,0 +1,80 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $OpenBSD: rindex.3,v 1.3 1997/12/30 01:09:49 deraadt Exp $
35.\"
36.Dd April 19, 1991
37.Dt RINDEX 3
38.Os
39.Sh NAME
40.Nm rindex
41.Nd locate character in string
42.Sh SYNOPSIS
43.Fd #include <string.h>
44.Ft char *
45.Fn rindex "const char *s" "int c"
46.Sh DESCRIPTION
47The
48.Fn rindex
49function
50locates the last character
51matching
52.Fa c
53(converted to a
54.Em char )
55in the null-terminated string
56.Fa s .
57If the character c is found, a pointer to it is returned; otherwise NULL is returned.
58If
59.Fa c
60is
61.Ql \e0 ,
62.Fn rindex
63locates the terminating
64.Ql \e0 .
65.Sh SEE ALSO
66.Xr index 3 ,
67.Xr memchr 3 ,
68.Xr strchr 3 ,
69.Xr strcspn 3 ,
70.Xr strpbrk 3 ,
71.Xr strrchr 3 ,
72.Xr strsep 3 ,
73.Xr strspn 3 ,
74.Xr strstr 3 ,
75.Xr strtok 3
76.Sh HISTORY
77A
78.Fn rindex
79function appeared in
80.At v6 .
diff --git a/src/lib/libc/string/rindex.c b/src/lib/libc/string/rindex.c
new file mode 100644
index 0000000000..f18553f667
--- /dev/null
+++ b/src/lib/libc/string/rindex.c
@@ -0,0 +1,57 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: rindex.c,v 1.2 1996/08/19 08:34:08 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <string.h>
39
40char *
41#ifdef STRRCHR
42strrchr(p, ch)
43#else
44rindex(p, ch)
45#endif
46 register const char *p, ch;
47{
48 register char *save;
49
50 for (save = NULL;; ++p) {
51 if (*p == ch)
52 save = (char *)p;
53 if (!*p)
54 return(save);
55 }
56 /* NOTREACHED */
57}
diff --git a/src/lib/libc/string/strcasecmp.3 b/src/lib/libc/string/strcasecmp.3
new file mode 100644
index 0000000000..52a13055ee
--- /dev/null
+++ b/src/lib/libc/string/strcasecmp.3
@@ -0,0 +1,89 @@
1.\" $OpenBSD: strcasecmp.3,v 1.4 1998/06/15 17:55:11 mickey Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" Chris Torek.
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93
37.\"
38.Dd June 9, 1993
39.Dt STRCASECMP 3
40.Os
41.Sh NAME
42.Nm strcasecmp
43.Nd compare strings, ignoring case
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft int
47.Fn strcasecmp "const char *s1" "const char *s2"
48.Ft int
49.Fn strncasecmp "const char *s1" "const char *s2" "size_t len"
50.Sh DESCRIPTION
51The
52.Fn strcasecmp
53and
54.Fn strncasecmp
55functions
56compare the null-terminated strings
57.Fa s1
58and
59.Fa s2
60and return an integer greater than, equal to, or less than 0,
61according as
62.Fa s1
63is lexicographically greater than, equal to, or less than
64.Fa s2
65after translation of each corresponding character to lower-case.
66The strings themselves are not modified.
67The comparison is done using unsigned characters, so that
68.Sq Li \e200
69is greater than
70.Ql \e0 .
71.Pp
72The
73.Fn strncasecmp
74compares at most
75.Fa len
76characters.
77.Sh SEE ALSO
78.Xr bcmp 3 ,
79.Xr memcmp 3 ,
80.Xr strcmp 3 ,
81.Xr strcoll 3 ,
82.Xr strxfrm 3
83.Sh HISTORY
84The
85.Fn strcasecmp
86and
87.Fn strncasecmp
88functions first appeared in
89.Bx 4.4 .
diff --git a/src/lib/libc/string/strcasecmp.c b/src/lib/libc/string/strcasecmp.c
new file mode 100644
index 0000000000..1f487524aa
--- /dev/null
+++ b/src/lib/libc/string/strcasecmp.c
@@ -0,0 +1,120 @@
1/* $OpenBSD: strcasecmp.c,v 1.3 1997/08/20 04:13:57 millert Exp $ */
2
3/*
4 * Copyright (c) 1987, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#include <string.h>
37
38#if defined(LIBC_SCCS) && !defined(lint)
39#if 0
40static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93";
41#else
42static char *rcsid = "$OpenBSD: strcasecmp.c,v 1.3 1997/08/20 04:13:57 millert Exp $";
43#endif
44#endif /* LIBC_SCCS and not lint */
45
46typedef unsigned char u_char;
47
48/*
49 * This array is designed for mapping upper and lower case letter
50 * together for a case independent comparison. The mappings are
51 * based upon ascii character sequences.
52 */
53static const u_char charmap[] = {
54 '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
55 '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
56 '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
57 '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
58 '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
59 '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
60 '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
61 '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
62 '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
63 '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
64 '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
65 '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
66 '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
67 '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
68 '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
69 '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
70 '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
71 '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
72 '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
73 '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
74 '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
75 '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
76 '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
77 '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
78 '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
79 '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
80 '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
81 '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
82 '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
83 '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
84 '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
85 '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
86};
87
88int
89strcasecmp(s1, s2)
90 const char *s1, *s2;
91{
92 register const u_char *cm = charmap,
93 *us1 = (const u_char *)s1,
94 *us2 = (const u_char *)s2;
95
96 while (cm[*us1] == cm[*us2++])
97 if (*us1++ == '\0')
98 return (0);
99 return (cm[*us1] - cm[*--us2]);
100}
101
102int
103strncasecmp(s1, s2, n)
104 const char *s1, *s2;
105 register size_t n;
106{
107 if (n != 0) {
108 register const u_char *cm = charmap,
109 *us1 = (const u_char *)s1,
110 *us2 = (const u_char *)s2;
111
112 do {
113 if (cm[*us1] != cm[*us2++])
114 return (cm[*us1] - cm[*--us2]);
115 if (*us1++ == '\0')
116 break;
117 } while (--n != 0);
118 }
119 return (0);
120}
diff --git a/src/lib/libc/string/strcat.3 b/src/lib/libc/string/strcat.3
new file mode 100644
index 0000000000..7591423f96
--- /dev/null
+++ b/src/lib/libc/string/strcat.3
@@ -0,0 +1,137 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strcat.3,v 1.5 1999/03/06 23:41:13 millert Exp $
37.\"
38.Dd July 8, 1997
39.Dt STRCAT 3
40.Os
41.Sh NAME
42.Nm strcat
43.Nd concatenate strings
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft char *
47.Fn strcat "char *s" "const char *append"
48.Ft char *
49.Fn strncat "char *s" "const char *append" "size_t count"
50.Sh DESCRIPTION
51The
52.Fn strcat
53and
54.Fn strncat
55functions
56append a copy of the null-terminated string
57.Fa append
58to the end of the null-terminated string
59.Fa s ,
60then add a terminating
61.Ql \e0 .
62The string
63.Fa s
64must have sufficient space to hold the result.
65.Pp
66The
67.Fn strncat
68function
69appends not more than
70.Fa count
71characters where space for the terminating
72.Ql \e0
73should not be included in
74.Fa count .
75.Sh RETURN VALUES
76The
77.Fn strcat
78and
79.Fn strncat
80functions
81return the pointer
82.Fa s .
83.Sh EXAMPLES
84The following appends
85.Dq Li abc
86to
87.Dq Li chararray :
88.Bd -literal -offset indent
89char *letters = "abcdefghi";
90
91(void)strncat(chararray, letters, 3);
92.Ed
93.Pp
94The following example shows how to use
95.Fn strncat
96safely in conjunction with
97.Xr strncpy 3 .
98.Bd -literal -offset indent
99char buf[BUFSIZ];
100char *input, *suffix;
101
102(void)strncpy(buf, input, sizeof(buf) - 1);
103buf[sizeof(buf) - 1] = '\e0';
104(void)strncat(buf, suffix, sizeof(buf) - 1 - strlen(buf));
105.Ed
106.Pp
107The above will copy as many characters from
108.Dq Li input
109to
110.Dq Li buf
111as will
112fit. It then appends as many characters from suffix as will fit (or none
113if there is no space). For operations like this, the
114.Xr strlcpy 3
115and
116.Xr strlcat 3
117functions are a better choice, as shown below.
118.Bd -literal -offset indent
119(void)strlcpy(buf, input, sizeof(buf));
120(void)strlcat(buf, suffix, sizeof(buf));
121.Ed
122.Sh SEE ALSO
123.Xr bcopy 3 ,
124.Xr memccpy 3 ,
125.Xr memcpy 3 ,
126.Xr memmove 3 ,
127.Xr strcpy 3 ,
128.Xr strlcat 3 ,
129.Xr strlcpy 3
130.Sh STANDARDS
131The
132.Fn strcat
133and
134.Fn strncat
135functions
136conform to
137.St -ansiC .
diff --git a/src/lib/libc/string/strcat.c b/src/lib/libc/string/strcat.c
new file mode 100644
index 0000000000..374a2b7464
--- /dev/null
+++ b/src/lib/libc/string/strcat.c
@@ -0,0 +1,54 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strcat.c,v 1.4 1996/08/19 08:34:10 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#ifndef _KERNEL
39#include <string.h>
40#else
41#include <lib/libkern/libkern.h>
42#endif
43
44char *
45strcat(s, append)
46 register char *s;
47 register const char *append;
48{
49 char *save = s;
50
51 for (; *s; ++s);
52 while ((*s++ = *append++) != '\0');
53 return(save);
54}
diff --git a/src/lib/libc/string/strchr.3 b/src/lib/libc/string/strchr.3
new file mode 100644
index 0000000000..c3bc2f8817
--- /dev/null
+++ b/src/lib/libc/string/strchr.3
@@ -0,0 +1,87 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strchr.3,v 1.3 1997/12/29 22:31:50 deraadt Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRCHR 3
40.Os
41.Sh NAME
42.Nm strchr
43.Nd locate character in string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft char *
47.Fn strchr "const char *s" "int c"
48.Sh DESCRIPTION
49The
50.Fn strchr
51function locates the first occurrence of
52.Ar c
53in the string pointed to by
54.Ar s .
55The terminating
56.Dv NUL
57character is considered part of the string.
58If
59.Fa c
60is
61.Ql \e0 ,
62.Fn strchr
63locates the terminating
64.Ql \e0 .
65.Sh RETURN VALUES
66The function
67.Fn strchr
68returns a pointer to the located character, or
69.Dv NULL
70if the character does not appear in the string.
71.Sh SEE ALSO
72.Xr index 3 ,
73.Xr memchr 3 ,
74.Xr rindex 3 ,
75.Xr strcspn 3 ,
76.Xr strpbrk 3 ,
77.Xr strrchr 3 ,
78.Xr strsep 3 ,
79.Xr strspn 3 ,
80.Xr strstr 3 ,
81.Xr strtok 3
82.Sh STANDARDS
83The
84.Fn strchr
85function
86conforms to
87.St -ansiC .
diff --git a/src/lib/libc/string/strcmp.3 b/src/lib/libc/string/strcmp.3
new file mode 100644
index 0000000000..91e51d68fc
--- /dev/null
+++ b/src/lib/libc/string/strcmp.3
@@ -0,0 +1,93 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strcmp.3,v 1.2 1996/08/19 08:34:11 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRCMP 3
40.Os
41.Sh NAME
42.Nm strcmp
43.Nd compare strings
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft int
47.Fn strcmp "const char *s1" "const char *s2"
48.Ft int
49.Fn strncmp "const char *s1" "const char *s2" "size_t len"
50.Sh DESCRIPTION
51The
52.Fn strcmp
53and
54.Fn strncmp
55functions
56lexicographically compare the null-terminated strings
57.Fa s1
58and
59.Fa s2 .
60.Sh RETURN VALUES
61The
62.Fn strcmp
63and
64.Fn strncmp
65return an integer greater than, equal to, or less than 0, according
66as the string
67.Fa s1
68is greater than, equal to, or less than the string
69.Fa s2 .
70The comparison is done using unsigned characters, so that
71.Ql \e200
72is greater than
73.Ql \e0 .
74.Pp
75The
76.Fn strncmp
77compares not more than
78.Fa len
79characters.
80.Sh SEE ALSO
81.Xr bcmp 3 ,
82.Xr memcmp 3 ,
83.Xr strcasecmp 3 ,
84.Xr strcoll 3 ,
85.Xr strxfrm 3
86.Sh STANDARDS
87The
88.Fn strcmp
89and
90.Fn strncmp
91functions
92conform to
93.St -ansiC .
diff --git a/src/lib/libc/string/strcmp.c b/src/lib/libc/string/strcmp.c
new file mode 100644
index 0000000000..9a5b208323
--- /dev/null
+++ b/src/lib/libc/string/strcmp.c
@@ -0,0 +1,58 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: strcmp.c,v 1.3 1996/08/19 08:34:12 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#ifndef _KERNEL
42#include <string.h>
43#else
44#include <lib/libkern/libkern.h>
45#endif
46
47/*
48 * Compare strings.
49 */
50int
51strcmp(s1, s2)
52 register const char *s1, *s2;
53{
54 while (*s1 == *s2++)
55 if (*s1++ == 0)
56 return (0);
57 return (*(unsigned char *)s1 - *(unsigned char *)--s2);
58}
diff --git a/src/lib/libc/string/strcoll.3 b/src/lib/libc/string/strcoll.3
new file mode 100644
index 0000000000..20af998885
--- /dev/null
+++ b/src/lib/libc/string/strcoll.3
@@ -0,0 +1,74 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strcoll.3,v 1.2 1996/08/19 08:34:12 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRCOLL 3
40.Os
41.Sh NAME
42.Nm strcoll
43.Nd compare strings according to current collation
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft int
47.Fn strcoll "const char *s1" "const char *s2"
48.Sh DESCRIPTION
49The
50.Fn strcoll
51function
52lexicographically compares the null-terminated strings
53.Fa s1
54and
55.Fa s2
56according to the current locale collation
57and returns an integer greater than, equal to, or less than 0,
58according as
59.Fa s1
60is greater than, equal to, or less than
61.Fa s2 .
62.Sh SEE ALSO
63.Xr bcmp 3 ,
64.Xr memcmp 3 ,
65.Xr setlocale 3 ,
66.Xr strcasecmp 3 ,
67.Xr strcmp 3 ,
68.Xr strxfrm 3
69.Sh STANDARDS
70The
71.Fn strcoll
72function
73conforms to
74.St -ansiC .
diff --git a/src/lib/libc/string/strcoll.c b/src/lib/libc/string/strcoll.c
new file mode 100644
index 0000000000..dca0b10d25
--- /dev/null
+++ b/src/lib/libc/string/strcoll.c
@@ -0,0 +1,52 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: strcoll.c,v 1.2 1996/08/19 08:34:13 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <string.h>
42
43/*
44 * Compare strings according to LC_COLLATE category of current locale.
45 */
46int
47strcoll(s1, s2)
48 const char *s1, *s2;
49{
50 /* LC_COLLATE is unimplemented, hence always "C" */
51 return (strcmp(s1, s2));
52}
diff --git a/src/lib/libc/string/strcpy.3 b/src/lib/libc/string/strcpy.3
new file mode 100644
index 0000000000..626a06af7b
--- /dev/null
+++ b/src/lib/libc/string/strcpy.3
@@ -0,0 +1,154 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strcpy.3,v 1.5 1999/03/06 23:36:27 millert Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRCPY 3
40.Os BSD 4
41.Sh NAME
42.Nm strcpy
43.Nd copy strings
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft char *
47.Fn strcpy "char *dst" "const char *src"
48.Ft char *
49.Fn strncpy "char *dst" "const char *src" "size_t len"
50.Sh DESCRIPTION
51The
52.Fn strcpy
53and
54.Fn strncpy
55functions
56copy the string
57.Fa src
58to
59.Fa dst
60(including the terminating
61.Ql \e0
62character).
63.Pp
64The
65.Fn strncpy
66copies not more than
67.Fa len
68characters into
69.Fa dst ,
70appending
71.Ql \e0
72characters if
73.Fa src
74is less than
75.Fa len
76characters long, and
77.Em not
78terminating
79.Fa dst
80if
81.Fa src
82is more than
83.Fa len
84characters long.
85.Sh RETURN VALUES
86The
87.Fn strcpy
88and
89.Fn strncpy
90functions
91return
92.Fa dst .
93.Sh EXAMPLES
94The following sets
95.Dq Li chararray
96to
97.Dq Li abc\e0\e0\e0 :
98.Bd -literal -offset indent
99(void)strncpy(chararray, "abc", 6);
100.Ed
101.Pp
102The following sets
103.Dq Li chararray
104to
105.Dq Li abcdef
106and does
107.Em not
108NUL-terminate chararray because the source string is >= the length parameter.
109.Fn strncpy
110.Em only
111NUL-terminates the destination string when then length of the source
112string is less than the length parameter.
113.Bd -literal -offset indent
114(void)strncpy(chararray, "abcdefgh", 6);
115.Ed
116.Pp
117The following copies as many characters from
118.Dq Li input
119to
120.Dq Li buf
121as will fit and NUL-terminates the result. Because
122.Fn strncpy
123does
124.Em not
125guarantee to NUL-terminate the string itself, we must do this by hand.
126.Bd -literal -offset indent
127char buf[BUFSIZ];
128
129(void)strncpy(buf, input, sizeof(buf) - 1);
130buf[sizeof(buf) - 1] = '\e0';
131.Ed
132.Pp
133Note that
134.Xr strlcpy 3
135is a better choice for this kind of operation. The equivalent using
136.Xr strlcpy 3
137is simply:
138.Bd -literal -offset indent
139(void)strlcpy(buf, input, sizeof(buf));
140.Ed
141.Sh SEE ALSO
142.Xr bcopy 3 ,
143.Xr memccpy 3 ,
144.Xr memcpy 3 ,
145.Xr memmove 3 ,
146.Xr strlcpy 3
147.Sh STANDARDS
148The
149.Fn strcpy
150and
151.Fn strncpy
152functions
153conform to
154.St -ansiC .
diff --git a/src/lib/libc/string/strcpy.c b/src/lib/libc/string/strcpy.c
new file mode 100644
index 0000000000..76b063fc10
--- /dev/null
+++ b/src/lib/libc/string/strcpy.c
@@ -0,0 +1,53 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strcpy.c,v 1.4 1996/08/19 08:34:14 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#ifndef _KERNEL
39#include <string.h>
40#else
41#include <lib/libkern/libkern.h>
42#endif
43
44char *
45strcpy(to, from)
46 register char *to;
47 register const char *from;
48{
49 char *save = to;
50
51 for (; (*to = *from) != '\0'; ++from, ++to);
52 return(save);
53}
diff --git a/src/lib/libc/string/strcspn.3 b/src/lib/libc/string/strcspn.3
new file mode 100644
index 0000000000..93c6d8f84c
--- /dev/null
+++ b/src/lib/libc/string/strcspn.3
@@ -0,0 +1,84 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strcspn.3,v 1.2 1996/08/19 08:34:14 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRCSPN 3
40.Os
41.Sh NAME
42.Nm strcspn
43.Nd span the complement of a string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft size_t
47.Fn strcspn "const char *s" "const char *charset"
48.Sh DESCRIPTION
49The
50.Fn strcspn
51function
52spans the initial part of the null-terminated string
53.Fa s
54as long as the characters from
55.Fa s
56do not occur in string
57.Fa charset
58(it
59spans the
60.Em complement
61of
62.Fa charset ) .
63.Sh RETURN VALUES
64The
65.Fn strcspn
66function
67returns the number of characters spanned.
68.Sh SEE ALSO
69.Xr index 3 ,
70.Xr memchr 3 ,
71.Xr rindex 3 ,
72.Xr strchr 3 ,
73.Xr strpbrk 3 ,
74.Xr strrchr 3 ,
75.Xr strsep 3 ,
76.Xr strspn 3 ,
77.Xr strstr 3 ,
78.Xr strtok 3
79.Sh STANDARDS
80The
81.Fn strcspn
82function
83conforms to
84.St -ansiC .
diff --git a/src/lib/libc/string/strcspn.c b/src/lib/libc/string/strcspn.c
new file mode 100644
index 0000000000..f7261564a7
--- /dev/null
+++ b/src/lib/libc/string/strcspn.c
@@ -0,0 +1,67 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: strcspn.c,v 1.2 1996/08/19 08:34:15 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <string.h>
42
43/*
44 * Span the complement of string s2.
45 */
46size_t
47strcspn(s1, s2)
48 const char *s1;
49 register const char *s2;
50{
51 register const char *p, *spanp;
52 register char c, sc;
53
54 /*
55 * Stop as soon as we find any character from s2. Note that there
56 * must be a NUL in s2; it suffices to stop when we find that, too.
57 */
58 for (p = s1;;) {
59 c = *p++;
60 spanp = s2;
61 do {
62 if ((sc = *spanp++) == c)
63 return (p - 1 - s1);
64 } while (sc != 0);
65 }
66 /* NOTREACHED */
67}
diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3
new file mode 100644
index 0000000000..6abbba57cb
--- /dev/null
+++ b/src/lib/libc/string/strdup.3
@@ -0,0 +1,68 @@
1.\" $OpenBSD: strdup.3,v 1.6 1998/08/19 05:51:14 pjanzen Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" @(#)strdup.3 8.1 (Berkeley) 6/9/93
35.\"
36.Dd June 9, 1993
37.Dt STRDUP 3
38.Os
39.Sh NAME
40.Nm strdup
41.Nd save a copy of a string
42.Sh SYNOPSIS
43.Fd #include <string.h>
44.Ft char *
45.Fn strdup "const char *str"
46.Sh DESCRIPTION
47The
48.Fn strdup
49function
50allocates sufficient memory for a copy
51of the string
52.Fa str ,
53does the copy, and returns a pointer to it.
54The pointer may subsequently be used as an
55argument to the function
56.Xr free 3 .
57.Pp
58If insufficient memory is available, NULL is returned.
59.Sh SEE ALSO
60.Xr free 3 ,
61.Xr malloc 3 ,
62.Xr strcpy 3 ,
63.Xr strlen 3
64.Sh HISTORY
65The
66.Fn strdup
67function first appeared in
68.Bx 4.4 .
diff --git a/src/lib/libc/string/strdup.c b/src/lib/libc/string/strdup.c
new file mode 100644
index 0000000000..be7f7ad094
--- /dev/null
+++ b/src/lib/libc/string/strdup.c
@@ -0,0 +1,62 @@
1/* $OpenBSD: strdup.c,v 1.3 1997/08/20 04:18:52 millert Exp $ */
2
3/*
4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#if defined(LIBC_SCCS) && !defined(lint)
37#if 0
38static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93";
39#else
40static char *rcsid = "$OpenBSD: strdup.c,v 1.3 1997/08/20 04:18:52 millert Exp $";
41#endif
42#endif /* LIBC_SCCS and not lint */
43
44#include <sys/types.h>
45
46#include <stddef.h>
47#include <stdlib.h>
48#include <string.h>
49
50char *
51strdup(str)
52 const char *str;
53{
54 size_t siz;
55 char *copy;
56
57 siz = strlen(str) + 1;
58 if ((copy = malloc(siz)) == NULL)
59 return(NULL);
60 (void)memcpy(copy, str, siz);
61 return(copy);
62}
diff --git a/src/lib/libc/string/strerror.3 b/src/lib/libc/string/strerror.3
new file mode 100644
index 0000000000..487c2b0e9f
--- /dev/null
+++ b/src/lib/libc/string/strerror.3
@@ -0,0 +1,65 @@
1.\" Copyright (c) 1980, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strerror.3,v 1.2 1996/08/19 08:34:16 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRERROR 3
40.Os BSD 4
41.Sh NAME
42.Nm strerror
43.Nd get error message string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft char *
47.Fn strerror "int errnum"
48.Sh DESCRIPTION
49The
50.Fn strerror
51function returns a pointer to the language-dependent error message
52string affiliated with an error number.
53.Pp
54The array pointed to is not to be modified by the program, but may be
55overwritten by subsequent calls to
56.Fn strerror .
57.Sh SEE ALSO
58.Xr intro 2 ,
59.Xr perror 3 ,
60.Xr setlocale 3
61.Sh STANDARDS
62The
63.Fn strerror
64function conforms to
65.St -ansiC .
diff --git a/src/lib/libc/string/strerror.c b/src/lib/libc/string/strerror.c
new file mode 100644
index 0000000000..0e2690c3dd
--- /dev/null
+++ b/src/lib/libc/string/strerror.c
@@ -0,0 +1,55 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strerror.c,v 1.2 1996/08/19 08:34:17 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <string.h>
39#include <limits.h>
40
41/*
42 * Since perror() is not allowed to change the contents of strerror()'s
43 * static buffer, both functions supply their own buffers to the
44 * internal function __strerror().
45 */
46
47extern char *__strerror __P((int, char *));
48
49char *
50strerror(num)
51 int num;
52{
53 static char buf[NL_TEXTMAX];
54 return __strerror(num, buf);
55}
diff --git a/src/lib/libc/string/string.3 b/src/lib/libc/string/string.3
new file mode 100644
index 0000000000..323d4f3040
--- /dev/null
+++ b/src/lib/libc/string/string.3
@@ -0,0 +1,155 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $OpenBSD: string.3,v 1.3 1998/09/06 22:23:18 aaron Exp $
35.\"
36.Dd April 19, 1991
37.Dt STRING 3
38.Os BSD 4
39.Sh NAME
40.Nm strcat ,
41.Nm strncat ,
42.Nm strchr ,
43.Nm strrchr ,
44.Nm strcmp ,
45.Nm strncmp ,
46.Nm strcasecmp,
47.Nm strncasecmp ,
48.Nm strcpy ,
49.Nm strncpy ,
50.Nm strerror ,
51.Nm strlen ,
52.Nm strpbrk ,
53.Nm strsep,
54.Nm strspn ,
55.Nm strcspn ,
56.Nm strstr ,
57.Nm strtok ,
58.Nm index ,
59.Nm rindex
60.Nd string specific functions
61.Sh SYNOPSIS
62.Fd #include <string.h>
63.Ft char *
64.Fn strcat "char *s" "const char * append"
65.Ft char *
66.Fn strncat "char *s" "const char *append" "size_t count"
67.Ft char *
68.Fn strchr "const char *s" "int c"
69.Ft char *
70.Fn strrchr "const char *s" "int c"
71.Ft int
72.Fn strcmp "const char *s1" "const char *s2"
73.Ft int
74.Fn strncmp "const char *s1" "const char *s2" "size_t count"
75.Ft int
76.Fn strcasecmp "const char *s1" "const char *s2"
77.Ft int
78.Fn strncasecmp "const char *s1" "const char *s2" "size_t count"
79.Ft char *
80.Fn strcpy "char *dst" "const char *src"
81.Ft char *
82.Fn strncpy "char *dst" "const char *src" "size_t count"
83.Ft char *
84.Fn strerror "int errno"
85.Ft size_t
86.Fn strlen "const char *s"
87.Ft char *
88.Fn strpbrk "const char *s" "const char *charset"
89.Ft char *
90.Fn strsep "char **stringp" "const char *delim"
91.Ft size_t
92.Fn strspn "const char *s" "const char *charset"
93.Ft size_t
94.Fn strcspn "const char *s" "const char *charset"
95.Ft char *
96.Fn strstr "const char *big" "const char *little"
97.Ft char *
98.Fn strtok "char *s" "const char *delim"
99.Ft char *
100.Fn index "const char *s" "int c"
101.Ft char *
102.Fn rindex "const char *s" "int c"
103.Sh DESCRIPTION
104The string functions
105manipulate strings terminated by a
106null byte.
107.Pp
108See the specific manual pages for more information.
109For manipulating variable length generic objects as byte
110strings (without the null byte check), see
111.Xr bstring 3 .
112.Pp
113Except as noted in their specific manual pages,
114the string functions do not test the destination
115for size limitations.
116.Sh SEE ALSO
117.Xr index 3 ,
118.Xr strcat 3 ,
119.Xr strchr 3 ,
120.Xr strrchr 3 ,
121.Xr strcmp 3 ,
122.Xr strcasecmp 3 ,
123.Xr strcpy 3 ,
124.Xr strerror 3 ,
125.Xr strlen 3 ,
126.Xr strpbrk 3 ,
127.Xr strsep 3 ,
128.Xr strspn 3 ,
129.Xr strcspn 3 ,
130.Xr strstr 3 ,
131.Xr strtok 3 ,
132.Xr rindex 3
133.Xr bstring 3
134.Sh STANDARDS
135The
136.Fn strcat ,
137.Fn strncat ,
138.Fn strchr ,
139.Fn strrchr ,
140.Fn strcmp ,
141.Fn strncmp ,
142.Fn strcpy ,
143.Fn strncpy ,
144.Fn strerror ,
145.Fn strlen ,
146.Fn strpbrk ,
147.Fn strsep ,
148.Fn strspn ,
149.Fn strcspn ,
150.Fn strstr ,
151and
152.Fn strtok
153functions
154conform to
155.St -ansiC .
diff --git a/src/lib/libc/string/strlcat.c b/src/lib/libc/string/strlcat.c
new file mode 100644
index 0000000000..2e8c56926e
--- /dev/null
+++ b/src/lib/libc/string/strlcat.c
@@ -0,0 +1,71 @@
1/* $OpenBSD: strlcat.c,v 1.1 1998/07/01 01:29:45 millert Exp $ */
2
3/*
4 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#if defined(LIBC_SCCS) && !defined(lint)
31static char *rcsid = "$OpenBSD: strlcat.c,v 1.1 1998/07/01 01:29:45 millert Exp $";
32#endif /* LIBC_SCCS and not lint */
33
34#include <sys/types.h>
35#include <string.h>
36
37/*
38 * Appends src to string dst of size siz (unlike strncat, siz is the
39 * full size of dst, not space left). At most siz-1 characters
40 * will be copied. Always NUL terminates (unless siz == 0).
41 * Returns strlen(src); if retval >= siz, truncation occurred.
42 */
43size_t strlcat(dst, src, siz)
44 char *dst;
45 const char *src;
46 size_t siz;
47{
48 register char *d = dst;
49 register const char *s = src;
50 register size_t n = siz;
51 size_t dlen;
52
53 /* Find the end of dst and adjust bytes left */
54 while (*d != '\0' && n != 0)
55 d++;
56 dlen = d - dst;
57 n -= dlen;
58
59 if (n == 0)
60 return(dlen + strlen(s));
61 while (*s != '\0') {
62 if (n != 1) {
63 *d++ = *s;
64 n--;
65 }
66 s++;
67 }
68 *d = '\0';
69
70 return(dlen + (s - src)); /* count does not include NUL */
71}
diff --git a/src/lib/libc/string/strlcpy.3 b/src/lib/libc/string/strlcpy.3
new file mode 100644
index 0000000000..1e46ef2e90
--- /dev/null
+++ b/src/lib/libc/string/strlcpy.3
@@ -0,0 +1,147 @@
1.\" $OpenBSD: strlcpy.3,v 1.3 1998/11/11 17:12:02 espie Exp $
2.\"
3.\" Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. The name of the author may not be used to endorse or promote products
15.\" derived from this software without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.Dd June 22, 1998
29.Dt STRLCPY 3
30.Os
31.Sh NAME
32.Nm strlcpy,
33.Nm strlcat
34.Nd size-bounded string copying and concatenation
35.Sh SYNOPSIS
36.Fd #include <string.h>
37.Ft size_t
38.Fn strlcpy "char *dst" "const char *src" "size_t size"
39.Ft size_t
40.Fn strlcat "char *dst" "const char *src" "size_t size"
41.Sh DESCRIPTION
42The
43.Fn strlcpy
44and
45.Fn strlcat
46functions copy and concatenate strings respectively. They are designed
47to be safer, more consistent, and less error prone replacements for
48.Xr strncpy 3
49and
50.Xr strncat 3 .
51Unlike those functions,
52.Fn strlcpy
53and
54.Fn strlcat
55take the full size of the buffer (not just the length) and guarantee to
56NUL-terminate the result (as long as
57.Fa size
58is larger than 0). Note that you should include a byte for the NUL in
59.Fa size .
60.Pp
61The
62.Fn strlcpy
63function copies up to
64.Fa size
65- 1 characters from the NUL-terminated string
66.Fa src
67to
68.Fa dst ,
69NUL-terminating the result.
70.Pp
71The
72.Fn strlcat
73function appends the NUL-terminated string
74.Fa src
75to the end of
76.Fa dst .
77It will append at most
78.Fa size
79- strlen(dst) - 1 bytes, NUL-terminating the result.
80.Sh RETURN VALUES
81The
82.Fn strlcpy
83and
84.Fn strlcat
85functions return the total length of the string they tried to
86create. For
87.Fn strlcpy
88that means the length of
89.Fa src .
90For
91.Fn strlcat
92that means the initial length of
93.Fa dst
94plus
95the length of
96.Fa src .
97While this may seem somewhat confusing it was done to make
98truncation detection simple.
99.Sh EXAMPLES
100The following code fragment illustrates the simple case:
101.Bd -literal -offset indent
102char *s, *p, buf[BUFSIZ];
103
104.Li ...
105
106(void)strlcpy(buf, s, sizeof(buf));
107(void)strlcat(buf, p, sizeof(buf));
108.Ed
109.Pp
110To detect truncation, perhaps while building a pathname, something
111like the following might be used:
112.Bd -literal -offset indent
113char *dir, *file, pname[MAXPATHNAMELEN];
114
115.Li ...
116
117if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname))
118 goto toolong;
119if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname))
120 goto toolong;
121.Ed
122.Pp
123Since we know how many characters we copied the first time, we can
124speed things up a bit by using a copy instead on an append:
125.Bd -literal -offset indent
126char *dir, *file, pname[MAXPATHNAMELEN];
127size_t n;
128
129.Li ...
130
131n = strlcpy(pname, dir, sizeof(pname));
132if (n >= sizeof(pname))
133 goto toolong;
134if (strlcpy(pname + n, file, sizeof(pname) - n) >= sizeof(pname) - n)
135 goto toolong;
136.Ed
137.Pp
138However, one may question the validity of such optimizations, as they
139defeat the whole purpose of
140.Fn strlcpy
141and
142.Fn strlcat .
143As a matter of fact, the first version of this manual page got it wrong.
144.Sh SEE ALSO
145.Xr snprintf 3 ,
146.Xr strncpy 3 ,
147.Xr strncat 3
diff --git a/src/lib/libc/string/strlcpy.c b/src/lib/libc/string/strlcpy.c
new file mode 100644
index 0000000000..2b6a166175
--- /dev/null
+++ b/src/lib/libc/string/strlcpy.c
@@ -0,0 +1,63 @@
1/* $OpenBSD: strlcpy.c,v 1.2 1998/11/06 04:33:16 wvdputte Exp $ */
2
3/*
4 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#if defined(LIBC_SCCS) && !defined(lint)
31static char *rcsid = "$OpenBSD: strlcpy.c,v 1.2 1998/11/06 04:33:16 wvdputte Exp $";
32#endif /* LIBC_SCCS and not lint */
33
34#include <sys/types.h>
35#include <string.h>
36
37/*
38 * Copy src to string dst of size siz. At most siz-1 characters
39 * will be copied. Always NUL terminates (unless siz == 0).
40 * Returns strlen(src); if retval >= siz, truncation occurred.
41 */
42size_t strlcpy(dst, src, siz)
43 char *dst;
44 const char *src;
45 size_t siz;
46{
47 register char *d = dst;
48 register const char *s = src;
49 register size_t n = siz;
50
51 if (n == 0)
52 return(strlen(s));
53 while (*s != '\0') {
54 if (n != 1) {
55 *d++ = *s;
56 n--;
57 }
58 s++;
59 }
60 *d = '\0';
61
62 return(s - src); /* count does not include NUL */
63}
diff --git a/src/lib/libc/string/strlen.3 b/src/lib/libc/string/strlen.3
new file mode 100644
index 0000000000..99e7dd19c3
--- /dev/null
+++ b/src/lib/libc/string/strlen.3
@@ -0,0 +1,70 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strlen.3,v 1.2 1996/08/19 08:34:19 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRLEN 3
40.Os
41.Sh NAME
42.Nm strlen
43.Nd find length of string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft size_t
47.Fn strlen "const char *s"
48.Sh DESCRIPTION
49The
50.Fn strlen
51function
52computes the length of the string
53.Fa s .
54.Sh RETURN VALUES
55The
56.Fn strlen
57function
58returns
59the number of characters that precede the
60terminating
61.Dv NUL
62character.
63.Sh SEE ALSO
64.Xr string 3
65.Sh STANDARDS
66The
67.Fn strlen
68function
69conforms to
70.St -ansiC .
diff --git a/src/lib/libc/string/strlen.c b/src/lib/libc/string/strlen.c
new file mode 100644
index 0000000000..332d5766f9
--- /dev/null
+++ b/src/lib/libc/string/strlen.c
@@ -0,0 +1,53 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strlen.c,v 1.3 1996/08/19 08:34:19 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#ifndef _KERNEL
39#include <string.h>
40#else
41#include <lib/libkern/libkern.h>
42#endif
43
44size_t
45strlen(str)
46 const char *str;
47{
48 register const char *s;
49
50 for (s = str; *s; ++s);
51 return(s - str);
52}
53
diff --git a/src/lib/libc/string/strmode.3 b/src/lib/libc/string/strmode.3
new file mode 100644
index 0000000000..3db953704d
--- /dev/null
+++ b/src/lib/libc/string/strmode.3
@@ -0,0 +1,152 @@
1.\" $OpenBSD: strmode.3,v 1.6 1998/06/15 17:55:13 mickey Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\" must display the following acknowledgement:
16.\" This product includes software developed by the University of
17.\" California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\" may be used to endorse or promote products derived from this software
20.\" without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" @(#)strmode.3 8.3 (Berkeley) 7/28/94
35.\"
36.Dd July 28, 1994
37.Dt STRMODE 3
38.Os
39.Sh NAME
40.Nm strmode
41.Nd convert inode status information into a symbolic string
42.Sh SYNOPSIS
43.Fd #include <string.h>
44.Ft void
45.Fn strmode "mode_t mode" "char *bp"
46.Sh DESCRIPTION
47The
48.Fn strmode
49function
50converts a file
51.Fa mode
52(the type and permission information associated with an inode, see
53.Xr stat 2 )
54into a symbolic string which is stored in the location referenced by
55.Fa bp .
56This stored string is eleven characters in length plus a trailing
57.Dv NUL .
58.Pp
59The first character is the inode type, and will be one of the following:
60.Pp
61.Bl -tag -width flag -offset indent -compact
62.It \-
63regular file
64.It b
65block special
66.It c
67character special
68.It d
69directory
70.It l
71symbolic link
72.It p
73fifo
74.It s
75socket
76.It w
77whiteout
78.It ?
79unknown inode type
80.El
81.Pp
82The next nine characters encode three sets of permissions, in three
83characters each.
84The first three characters are the permissions for the owner of the
85file, the second three for the group the file belongs to, and the
86third for the ``other'', or default, set of users.
87.Pp
88Permission checking is done as specifically as possible.
89If read permission is denied to the owner of a file in the first set
90of permissions, the owner of the file will not be able to read the file.
91This is true even if the owner is in the file's group and the group
92permissions allow reading or the ``other'' permissions allow reading.
93.Pp
94If the first character of the three character set is an ``r'', the file is
95readable for that set of users; if a dash ``\-'', it is not readable.
96.Pp
97If the second character of the three character set is a ``w'', the file is
98writable for that set of users; if a dash ``\-'', it is not writable.
99.Pp
100The third character is the first of the following characters that apply:
101.Bl -tag -width xxxx
102.It S
103If the character is part of the owner permissions and the file is not
104executable or the directory is not searchable by the owner, and the
105set-user-id bit is set.
106.It S
107If the character is part of the group permissions and the file is not
108executable or the directory is not searchable by the group, and the
109set-group-id bit is set.
110.It T
111If the character is part of the other permissions and the file is not
112executable or the directory is not searchable by others, and the ``sticky''
113.Pq Dv S_ISVTX
114bit is set.
115.It s
116If the character is part of the owner permissions and the file is
117executable or the directory searchable by the owner, and the set-user-id
118bit is set.
119.It s
120If the character is part of the group permissions and the file is
121executable or the directory searchable by the group, and the set-group-id
122bit is set.
123.It t
124If the character is part of the other permissions and the file is
125executable or the directory searchable by others, and the ``sticky''
126.Pq Dv S_ISVTX
127bit is set.
128.It x
129The file is executable or the directory is searchable.
130.It \-
131None of the above apply.
132.El
133.Pp
134The last character is a plus sign ``+'' if there are any alternate
135or additional access control methods associated with the inode, otherwise
136it will be a space.
137.Sh RETURN VALUES
138The
139.Fn strmode
140function
141always returns 0.
142.Sh SEE ALSO
143.Xr chmod 1 ,
144.Xr find 1 ,
145.Xr stat 2 ,
146.Xr getmode 3 ,
147.Xr setmode 3
148.Sh HISTORY
149The
150.Fn strmode
151function first appeared in
152.Bx 4.4 .
diff --git a/src/lib/libc/string/strmode.c b/src/lib/libc/string/strmode.c
new file mode 100644
index 0000000000..5e7f15e857
--- /dev/null
+++ b/src/lib/libc/string/strmode.c
@@ -0,0 +1,152 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strmode.c,v 1.3 1997/06/13 13:57:20 deraadt Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <sys/stat.h>
40#include <string.h>
41
42void
43strmode(mode, p)
44 register mode_t mode;
45 register char *p;
46{
47 /* print type */
48 switch (mode & S_IFMT) {
49 case S_IFDIR: /* directory */
50 *p++ = 'd';
51 break;
52 case S_IFCHR: /* character special */
53 *p++ = 'c';
54 break;
55 case S_IFBLK: /* block special */
56 *p++ = 'b';
57 break;
58 case S_IFREG: /* regular */
59 *p++ = '-';
60 break;
61 case S_IFLNK: /* symbolic link */
62 *p++ = 'l';
63 break;
64 case S_IFSOCK: /* socket */
65 *p++ = 's';
66 break;
67#ifdef S_IFIFO
68 case S_IFIFO: /* fifo */
69 *p++ = 'p';
70 break;
71#endif
72#ifdef S_IFWHT
73 case S_IFWHT: /* whiteout */
74 *p++ = 'w';
75 break;
76#endif
77 default: /* unknown */
78 *p++ = '?';
79 break;
80 }
81 /* usr */
82 if (mode & S_IRUSR)
83 *p++ = 'r';
84 else
85 *p++ = '-';
86 if (mode & S_IWUSR)
87 *p++ = 'w';
88 else
89 *p++ = '-';
90 switch (mode & (S_IXUSR | S_ISUID)) {
91 case 0:
92 *p++ = '-';
93 break;
94 case S_IXUSR:
95 *p++ = 'x';
96 break;
97 case S_ISUID:
98 *p++ = 'S';
99 break;
100 case S_IXUSR | S_ISUID:
101 *p++ = 's';
102 break;
103 }
104 /* group */
105 if (mode & S_IRGRP)
106 *p++ = 'r';
107 else
108 *p++ = '-';
109 if (mode & S_IWGRP)
110 *p++ = 'w';
111 else
112 *p++ = '-';
113 switch (mode & (S_IXGRP | S_ISGID)) {
114 case 0:
115 *p++ = '-';
116 break;
117 case S_IXGRP:
118 *p++ = 'x';
119 break;
120 case S_ISGID:
121 *p++ = 'S';
122 break;
123 case S_IXGRP | S_ISGID:
124 *p++ = 's';
125 break;
126 }
127 /* other */
128 if (mode & S_IROTH)
129 *p++ = 'r';
130 else
131 *p++ = '-';
132 if (mode & S_IWOTH)
133 *p++ = 'w';
134 else
135 *p++ = '-';
136 switch (mode & (S_IXOTH | S_ISVTX)) {
137 case 0:
138 *p++ = '-';
139 break;
140 case S_IXOTH:
141 *p++ = 'x';
142 break;
143 case S_ISVTX:
144 *p++ = 'T';
145 break;
146 case S_IXOTH | S_ISVTX:
147 *p++ = 't';
148 break;
149 }
150 *p++ = ' '; /* will be a '+' if ACL's implemented */
151 *p = '\0';
152}
diff --git a/src/lib/libc/string/strncat.c b/src/lib/libc/string/strncat.c
new file mode 100644
index 0000000000..27ae2ba324
--- /dev/null
+++ b/src/lib/libc/string/strncat.c
@@ -0,0 +1,67 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: strncat.c,v 1.2 1996/08/19 08:34:21 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <string.h>
42
43/*
44 * Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes
45 * are written at dst (at most n+1 bytes being appended). Return dst.
46 */
47char *
48strncat(dst, src, n)
49 char *dst;
50 const char *src;
51 register size_t n;
52{
53 if (n != 0) {
54 register char *d = dst;
55 register const char *s = src;
56
57 while (*d != 0)
58 d++;
59 do {
60 if ((*d = *s++) == 0)
61 break;
62 d++;
63 } while (--n != 0);
64 *d = 0;
65 }
66 return (dst);
67}
diff --git a/src/lib/libc/string/strncmp.c b/src/lib/libc/string/strncmp.c
new file mode 100644
index 0000000000..0224957f8b
--- /dev/null
+++ b/src/lib/libc/string/strncmp.c
@@ -0,0 +1,59 @@
1/*
2 * Copyright (c) 1989 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strncmp.c,v 1.3 1996/08/19 08:34:21 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#ifndef _KERNEL
39#include <string.h>
40#else
41#include <lib/libkern/libkern.h>
42#endif
43
44int
45strncmp(s1, s2, n)
46 register const char *s1, *s2;
47 register size_t n;
48{
49
50 if (n == 0)
51 return (0);
52 do {
53 if (*s1 != *s2++)
54 return (*(unsigned char *)s1 - *(unsigned char *)--s2);
55 if (*s1++ == 0)
56 break;
57 } while (--n != 0);
58 return (0);
59}
diff --git a/src/lib/libc/string/strncpy.c b/src/lib/libc/string/strncpy.c
new file mode 100644
index 0000000000..01bc8a872e
--- /dev/null
+++ b/src/lib/libc/string/strncpy.c
@@ -0,0 +1,67 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: strncpy.c,v 1.2 1996/08/19 08:34:22 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <string.h>
42
43/*
44 * Copy src to dst, truncating or null-padding to always copy n bytes.
45 * Return dst.
46 */
47char *
48strncpy(dst, src, n)
49 char *dst;
50 const char *src;
51 register size_t n;
52{
53 if (n != 0) {
54 register char *d = dst;
55 register const char *s = src;
56
57 do {
58 if ((*d++ = *s++) == 0) {
59 /* NUL pad the remaining n-1 bytes */
60 while (--n != 0)
61 *d++ = 0;
62 break;
63 }
64 } while (--n != 0);
65 }
66 return (dst);
67}
diff --git a/src/lib/libc/string/strpbrk.3 b/src/lib/libc/string/strpbrk.3
new file mode 100644
index 0000000000..5876f560a9
--- /dev/null
+++ b/src/lib/libc/string/strpbrk.3
@@ -0,0 +1,79 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strpbrk.3,v 1.2 1996/08/19 08:34:22 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRPBRK 3
40.Os
41.Sh NAME
42.Nm strpbrk
43.Nd locate multiple characters in string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft char *
47.Fn strpbrk "const char *s" "const char *charset"
48.Sh DESCRIPTION
49The
50.Fn strpbrk
51function
52locates in the null-terminated string
53.Fa s
54the first occurrence of any character in the string
55.Fa charset
56and returns a pointer to this character.
57If no characters from
58.Fa charset
59occur anywhere in
60.Fa s
61.Fn strpbrk
62returns NULL.
63.Sh SEE ALSO
64.Xr index 3 ,
65.Xr memchr 3 ,
66.Xr rindex 3 ,
67.Xr strchr 3 ,
68.Xr strcspn 3 ,
69.Xr strrchr 3 ,
70.Xr strsep 3 ,
71.Xr strspn 3 ,
72.Xr strstr 3 ,
73.Xr strtok 3
74.Sh STANDARDS
75The
76.Fn strpbrk
77function
78conforms to
79.St -ansiC .
diff --git a/src/lib/libc/string/strpbrk.c b/src/lib/libc/string/strpbrk.c
new file mode 100644
index 0000000000..748a3a8c94
--- /dev/null
+++ b/src/lib/libc/string/strpbrk.c
@@ -0,0 +1,56 @@
1/*
2 * Copyright (c) 1985 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strpbrk.c,v 1.2 1996/08/19 08:34:23 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <string.h>
39
40/*
41 * Find the first occurrence in s1 of a character in s2 (excluding NUL).
42 */
43char *
44strpbrk(s1, s2)
45 register const char *s1, *s2;
46{
47 register const char *scanp;
48 register int c, sc;
49
50 while ((c = *s1++) != 0) {
51 for (scanp = s2; (sc = *scanp++) != 0;)
52 if (sc == c)
53 return ((char *)(s1 - 1));
54 }
55 return (NULL);
56}
diff --git a/src/lib/libc/string/strrchr.3 b/src/lib/libc/string/strrchr.3
new file mode 100644
index 0000000000..6dd00d32fb
--- /dev/null
+++ b/src/lib/libc/string/strrchr.3
@@ -0,0 +1,90 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strrchr.3,v 1.2 1996/08/19 08:34:23 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRRCHR 3
40.Os
41.Sh NAME
42.Nm strrchr
43.Nd locate character in string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft char *
47.Fn strrchr "const char *s" "int c"
48.Sh DESCRIPTION
49The
50.Fn strrchr
51function
52locates the last occurrence of
53.Fa c
54(converted to a char)
55in the string
56.Fa s .
57If
58.Fa c
59is
60.Ql \e0 ,
61.Fn strrchr
62locates the terminating
63.Ql \e0 .
64.Sh RETURN VALUES
65The
66.Fn strrchr
67function
68returns a pointer to the character,
69or a null
70pointer if
71.Fa c
72does not occur anywhere in
73.Fa s .
74.Sh SEE ALSO
75.Xr index 3 ,
76.Xr memchr 3 ,
77.Xr rindex 3 ,
78.Xr strchr 3 ,
79.Xr strcspn 3 ,
80.Xr strpbrk 3 ,
81.Xr strsep 3 ,
82.Xr strspn 3 ,
83.Xr strstr 3 ,
84.Xr strtok 3
85.Sh STANDARDS
86The
87.Fn strrchr
88function
89conforms to
90.St -ansiC .
diff --git a/src/lib/libc/string/strsep.3 b/src/lib/libc/string/strsep.3
new file mode 100644
index 0000000000..5af262a074
--- /dev/null
+++ b/src/lib/libc/string/strsep.3
@@ -0,0 +1,110 @@
1.\" $OpenBSD: strsep.3,v 1.4 1998/06/15 17:55:14 mickey Exp $
2.\"
3.\" Copyright (c) 1990, 1991, 1993
4.\" The Regents of the University of California. All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" Chris Torek.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in the
16.\" documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\" must display the following acknowledgement:
19.\" This product includes software developed by the University of
20.\" California, Berkeley and its contributors.
21.\" 4. Neither the name of the University nor the names of its contributors
22.\" may be used to endorse or promote products derived from this software
23.\" without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35.\" SUCH DAMAGE.
36.\"
37.\" @(#)strsep.3 8.1 (Berkeley) 6/9/93
38.\"
39.Dd June 9, 1993
40.Dt STRSEP 3
41.Os
42.Sh NAME
43.Nm strsep
44.Nd separate strings
45.Sh SYNOPSIS
46.Fd #include <string.h>
47.Ft char *
48.Fn strsep "char **stringp" "char *delim"
49.Sh DESCRIPTION
50The
51.Fn strsep
52function locates, in the string referenced by
53.Fa *stringp ,
54the first occurrence of any character in the string
55.Fa delim
56(or the terminating
57.Ql \e0
58character) and replaces it with a
59.Ql \e0 .
60The location of the next character after the delimiter character
61(or NULL, if the end of the string was reached) is stored in
62.Fa *stringp .
63The original value of
64.Fa *stringp
65is returned.
66.Pp
67An ``empty'' field, i.e. one caused by two adjacent delimiter characters,
68can be detected by comparing the location referenced by the pointer returned
69in
70.Fa *stringp
71to
72.Ql \e0 .
73.Pp
74If
75.Fa *stringp
76is initially
77.Dv NULL ,
78.Fn strsep
79returns
80.Dv NULL .
81.Sh EXAMPLES
82The following uses
83.Fn strsep
84to parse a string, containing tokens delimited by white space, into an
85argument vector:
86.Bd -literal -offset indent
87char **ap, *argv[10], *inputstring;
88
89for (ap = argv; (*ap = strsep(&inputstring, " \et")) != NULL;)
90 if (**ap != '\e0')
91 ++ap;
92.Ed
93.Sh HISTORY
94The
95.Fn strsep
96function
97is intended as a replacement for the
98.Fn strtok
99function.
100While the
101.Fn strtok
102function should be preferred for portability reasons (it conforms to
103.St -ansiC )
104it is unable to handle empty fields, i.e. detect fields delimited by
105two adjacent delimiter characters, or to be used for more than a single
106string at a time.
107The
108.Fn strsep
109function first appeared in
110.Bx 4.4 .
diff --git a/src/lib/libc/string/strsep.c b/src/lib/libc/string/strsep.c
new file mode 100644
index 0000000000..b69b715fc5
--- /dev/null
+++ b/src/lib/libc/string/strsep.c
@@ -0,0 +1,85 @@
1/* $OpenBSD: strsep.c,v 1.3 1997/08/20 04:28:14 millert Exp $ */
2
3/*-
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#include <string.h>
37#include <stdio.h>
38
39#if defined(LIBC_SCCS) && !defined(lint)
40#if 0
41static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93";
42#else
43static char *rcsid = "$OpenBSD: strsep.c,v 1.3 1997/08/20 04:28:14 millert Exp $";
44#endif
45#endif /* LIBC_SCCS and not lint */
46
47/*
48 * Get next token from string *stringp, where tokens are possibly-empty
49 * strings separated by characters from delim.
50 *
51 * Writes NULs into the string at *stringp to end tokens.
52 * delim need not remain constant from call to call.
53 * On return, *stringp points past the last NUL written (if there might
54 * be further tokens), or is NULL (if there are definitely no more tokens).
55 *
56 * If *stringp is NULL, strsep returns NULL.
57 */
58char *
59strsep(stringp, delim)
60 register char **stringp;
61 register const char *delim;
62{
63 register char *s;
64 register const char *spanp;
65 register int c, sc;
66 char *tok;
67
68 if ((s = *stringp) == NULL)
69 return (NULL);
70 for (tok = s;;) {
71 c = *s++;
72 spanp = delim;
73 do {
74 if ((sc = *spanp++) == c) {
75 if (c == 0)
76 s = NULL;
77 else
78 s[-1] = 0;
79 *stringp = s;
80 return (tok);
81 }
82 } while (sc != 0);
83 }
84 /* NOTREACHED */
85}
diff --git a/src/lib/libc/string/strsignal.3 b/src/lib/libc/string/strsignal.3
new file mode 100644
index 0000000000..42e433c259
--- /dev/null
+++ b/src/lib/libc/string/strsignal.3
@@ -0,0 +1,60 @@
1.\" Copyright (c) 1980, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strsignal.3,v 1.2 1996/08/19 08:34:25 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRSIGNAL 3
40.Os BSD 4
41.Sh NAME
42.Nm strsignal
43.Nd get signal description string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft char *
47.Fn strsignal "int sig"
48.Sh DESCRIPTION
49The
50.Fn strsignal
51function returns a pointer to the language-dependent string describing
52a signal.
53.Pp
54The array pointed to is not to be modified by the program, but may be
55overwritten by subsequent calls to
56.Fn strsignal .
57.Sh SEE ALSO
58.Xr intro 2 ,
59.Xr psignal 3 ,
60.Xr setlocale 3
diff --git a/src/lib/libc/string/strsignal.c b/src/lib/libc/string/strsignal.c
new file mode 100644
index 0000000000..cf03af5963
--- /dev/null
+++ b/src/lib/libc/string/strsignal.c
@@ -0,0 +1,49 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strsignal.c,v 1.2 1996/08/19 08:34:25 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <string.h>
39#include <limits.h>
40
41extern char *__strsignal __P((int, char *));
42
43char *
44strsignal(sig)
45 int sig;
46{
47 static char buf[NL_TEXTMAX];
48 return __strsignal(sig, buf);
49}
diff --git a/src/lib/libc/string/strspn.3 b/src/lib/libc/string/strspn.3
new file mode 100644
index 0000000000..7d15470dee
--- /dev/null
+++ b/src/lib/libc/string/strspn.3
@@ -0,0 +1,79 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strspn.3,v 1.3 1996/08/19 08:34:25 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRSPN 3
40.Os
41.Sh NAME
42.Nm strspn
43.Nd span a string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft size_t
47.Fn strspn "const char *s" "const char *charset"
48.Sh DESCRIPTION
49The
50.Fn strspn
51function
52spans the initial part of the null-terminated string
53.Fa s
54as long as the characters from
55.Fa s
56occur in string
57.Fa charset .
58.Sh RETURN VALUES
59The
60.Fn strspn
61function
62returns the number of characters spanned.
63.Sh SEE ALSO
64.Xr index 3 ,
65.Xr memchr 3 ,
66.Xr rindex 3 ,
67.Xr strchr 3 ,
68.Xr strcspn 3 ,
69.Xr strpbrk 3 ,
70.Xr strrchr 3 ,
71.Xr strsep 3 ,
72.Xr strstr 3 ,
73.Xr strtok 3
74.Sh STANDARDS
75The
76.Fn strspn
77function
78conforms to
79.St -ansiC .
diff --git a/src/lib/libc/string/strspn.c b/src/lib/libc/string/strspn.c
new file mode 100644
index 0000000000..41940f9190
--- /dev/null
+++ b/src/lib/libc/string/strspn.c
@@ -0,0 +1,60 @@
1/*
2 * Copyright (c) 1989 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strspn.c,v 1.2 1996/08/19 08:34:26 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <string.h>
39
40/*
41 * Span the string s2 (skip characters that are in s2).
42 */
43size_t
44strspn(s1, s2)
45 const char *s1;
46 register const char *s2;
47{
48 register const char *p = s1, *spanp;
49 register char c, sc;
50
51 /*
52 * Skip any characters in s2, excluding the terminating \0.
53 */
54cont:
55 c = *p++;
56 for (spanp = s2; (sc = *spanp++) != 0;)
57 if (sc == c)
58 goto cont;
59 return (p - 1 - s1);
60}
diff --git a/src/lib/libc/string/strstr.3 b/src/lib/libc/string/strstr.3
new file mode 100644
index 0000000000..fa455b426a
--- /dev/null
+++ b/src/lib/libc/string/strstr.3
@@ -0,0 +1,88 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strstr.3,v 1.2 1996/08/19 08:34:26 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRSTR 3
40.Os
41.Sh NAME
42.Nm strstr
43.Nd locate a substring in a string
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft char *
47.Fn strstr "const char *big" "const char *little"
48.Sh DESCRIPTION
49The
50.Fn strstr
51function
52locates the first occurrence of the null-terminated string
53.Fa little
54in the null-terminated string
55.Fa big .
56If
57.Fa little
58is the empty string,
59.Fn strstr
60returns
61.Fa big ;
62if
63.Fa little
64occurs nowhere in
65.Fa big ,
66.Fn strstr
67returns NULL;
68otherwise
69.Fn strstr
70returns a pointer to the first character of the first occurrence of
71.Fa little .
72.Sh SEE ALSO
73.Xr index 3 ,
74.Xr memchr 3 ,
75.Xr rindex 3 ,
76.Xr strchr 3 ,
77.Xr strcspn 3 ,
78.Xr strpbrk 3 ,
79.Xr strrchr 3 ,
80.Xr strsep 3 ,
81.Xr strspn 3 ,
82.Xr strtok 3
83.Sh STANDARDS
84The
85.Fn strstr
86function
87conforms to
88.St -ansiC .
diff --git a/src/lib/libc/string/strstr.c b/src/lib/libc/string/strstr.c
new file mode 100644
index 0000000000..763c7e29d7
--- /dev/null
+++ b/src/lib/libc/string/strstr.c
@@ -0,0 +1,64 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: strstr.c,v 1.2 1996/08/19 08:34:27 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <string.h>
42
43/*
44 * Find the first occurrence of find in s.
45 */
46char *
47strstr(s, find)
48 register const char *s, *find;
49{
50 register char c, sc;
51 register size_t len;
52
53 if ((c = *find++) != 0) {
54 len = strlen(find);
55 do {
56 do {
57 if ((sc = *s++) == 0)
58 return (NULL);
59 } while (sc != c);
60 } while (strncmp(s, find, len) != 0);
61 s--;
62 }
63 return ((char *)s);
64}
diff --git a/src/lib/libc/string/strtok.3 b/src/lib/libc/string/strtok.3
new file mode 100644
index 0000000000..876e0eb515
--- /dev/null
+++ b/src/lib/libc/string/strtok.3
@@ -0,0 +1,112 @@
1.\" Copyright (c) 1988, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strtok.3,v 1.3 1998/04/28 07:36:55 deraadt Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRTOK 3
40.Os BSD 3
41.Sh NAME
42.Nm strtok ,
43.Nm strsep
44.Nd string token operations
45.Sh SYNOPSIS
46.Fd #include <string.h>
47.Ft char *
48.Fn strtok "char *str" "const char *sep"
49.Sh DESCRIPTION
50.Bf -symbolic
51This interface is obsoleted by
52.Xr strsep 3 .
53.Ef
54.Pp
55The
56.Fn strtok
57function
58is used to isolate sequential tokens in a null-terminated string,
59.Fa str .
60These tokens are separated in the string by at least one of the
61characters in
62.Fa sep .
63The first time that
64.Fn strtok
65is called,
66.Fa str
67should be specified; subsequent calls, wishing to obtain further tokens
68from the same string, should pass a null pointer instead.
69The separator string,
70.Fa sep ,
71must be supplied each time, and may change between calls.
72.Pp
73The
74.Fn strtok
75function
76returns a pointer to the beginning of each subsequent token in the string,
77after replacing the separator character itself with a
78.Dv NUL
79character.
80When no more tokens remain, a null pointer is returned.
81.Sh SEE ALSO
82.Xr index 3 ,
83.Xr memchr 3 ,
84.Xr rindex 3 ,
85.Xr strchr 3 ,
86.Xr strcspn 3 ,
87.Xr strpbrk 3 ,
88.Xr strrchr 3 ,
89.Xr strsep 3 ,
90.Xr strspn 3 ,
91.Xr strstr 3
92.Sh STANDARDS
93The
94.Fn strtok
95function
96conforms to
97.St -ansiC .
98.Sh BUGS
99There is no way to get tokens from multiple strings simultaneously.
100.Pp
101The System V
102.Fn strtok ,
103if handed a string containing only delimiter characters,
104will not alter the next starting point, so that a call to
105.Fn strtok
106with a different (or empty) delimiter string
107may return a
108.Pf non- Dv NULL
109value.
110Since this implementation always alters the next starting point,
111such a sequence of calls would always return
112.Dv NULL .
diff --git a/src/lib/libc/string/strtok.c b/src/lib/libc/string/strtok.c
new file mode 100644
index 0000000000..2fce04c3ad
--- /dev/null
+++ b/src/lib/libc/string/strtok.c
@@ -0,0 +1,89 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strtok.c,v 1.2 1996/08/19 08:34:28 tholo Exp $";
36#endif /* LIBC_SCCS and not lint */
37
38#include <string.h>
39
40char *
41strtok(s, delim)
42 register char *s;
43 register const char *delim;
44{
45 register char *spanp;
46 register int c, sc;
47 char *tok;
48 static char *last;
49
50
51 if (s == NULL && (s = last) == NULL)
52 return (NULL);
53
54 /*
55 * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
56 */
57cont:
58 c = *s++;
59 for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
60 if (c == sc)
61 goto cont;
62 }
63
64 if (c == 0) { /* no non-delimiter characters */
65 last = NULL;
66 return (NULL);
67 }
68 tok = s - 1;
69
70 /*
71 * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
72 * Note that delim must have one NUL; we stop if we see that, too.
73 */
74 for (;;) {
75 c = *s++;
76 spanp = (char *)delim;
77 do {
78 if ((sc = *spanp++) == c) {
79 if (c == 0)
80 s = NULL;
81 else
82 s[-1] = 0;
83 last = s;
84 return (tok);
85 }
86 } while (sc != 0);
87 }
88 /* NOTREACHED */
89}
diff --git a/src/lib/libc/string/strxfrm.3 b/src/lib/libc/string/strxfrm.3
new file mode 100644
index 0000000000..3ebdd42c29
--- /dev/null
+++ b/src/lib/libc/string/strxfrm.3
@@ -0,0 +1,68 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information Processing Systems.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" $OpenBSD: strxfrm.3,v 1.2 1996/08/19 08:34:28 tholo Exp $
37.\"
38.Dd June 29, 1991
39.Dt STRXFRM 3
40.Os
41.Sh NAME
42.Nm strxfrm
43.Nd transform a string under locale
44.Sh SYNOPSIS
45.Fd #include <string.h>
46.Ft size_t
47.Fn strxfrm "char *dst" "const char *src" "size_t n"
48.Sh DESCRIPTION
49The
50.Fn strxfrm
51function
52does something horrible (see
53.Tn ANSI
54standard).
55In this implementation it just copies.
56.Sh SEE ALSO
57.Xr bcmp 3 ,
58.Xr memcmp 3 ,
59.\" .Xr setlocale 3 ,
60.Xr strcasecmp 3 ,
61.Xr strcmp 3 ,
62.Xr strcoll 3
63.Sh STANDARDS
64The
65.Fn strxfrm
66function
67conforms to
68.St -ansiC .
diff --git a/src/lib/libc/string/strxfrm.c b/src/lib/libc/string/strxfrm.c
new file mode 100644
index 0000000000..6b258edecc
--- /dev/null
+++ b/src/lib/libc/string/strxfrm.c
@@ -0,0 +1,73 @@
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: strxfrm.c,v 1.2 1996/08/19 08:34:29 tholo Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <string.h>
42
43/*
44 * Transform src, storing the result in dst, such that
45 * strcmp() on transformed strings returns what strcoll()
46 * on the original untransformed strings would return.
47 */
48size_t
49strxfrm(dst, src, n)
50 register char *dst;
51 register const char *src;
52 register size_t n;
53{
54 register size_t r = 0;
55 register int c;
56
57 /*
58 * Since locales are unimplemented, this is just a copy.
59 */
60 if (n != 0) {
61 while ((c = *src++) != 0) {
62 r++;
63 if (--n == 0) {
64 while (*src++ != 0)
65 r++;
66 break;
67 }
68 *dst++ = c;
69 }
70 *dst = 0;
71 }
72 return (r);
73}
diff --git a/src/lib/libc/string/swab.3 b/src/lib/libc/string/swab.3
new file mode 100644
index 0000000000..d1bfc358fb
--- /dev/null
+++ b/src/lib/libc/string/swab.3
@@ -0,0 +1,65 @@
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" $OpenBSD: swab.3,v 1.3 1998/02/10 02:19:48 deraadt Exp $
33.\"
34.Dd May 1, 1991
35.Dt SWAB 3
36.Os
37.Sh NAME
38.Nm swab
39.Nd swap adjacent bytes
40.Sh SYNOPSIS
41.Fd #include <unistd.h>
42.Ft void
43.Fn swab "const void *src" "void *dst" "size_t len"
44.Sh DESCRIPTION
45The function
46.Fn swab
47copies
48.Fa len
49bytes from the location referenced by
50.Fa src
51to the location referenced by
52.Fa dst ,
53swapping adjacent bytes.
54.Pp
55The argument
56.Fa len
57must be even number.
58.Sh SEE ALSO
59.Xr bzero 3 ,
60.Xr memset 3
61.Sh HISTORY
62A
63.Fn swab
64function appeared in
65.At v7 .
diff --git a/src/lib/libc/string/swab.c b/src/lib/libc/string/swab.c
new file mode 100644
index 0000000000..311cf13a53
--- /dev/null
+++ b/src/lib/libc/string/swab.c
@@ -0,0 +1,65 @@
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Jeffrey Mogul.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(LIBC_SCCS) && !defined(lint)
38static char *rcsid = "$OpenBSD: swab.c,v 1.3 1998/02/10 02:19:48 deraadt Exp $";
39#endif /* LIBC_SCCS and not lint */
40
41#include <unistd.h>
42
43void
44swab(from, to, len)
45 const void *from;
46 void *to;
47 size_t len;
48{
49 register unsigned long temp;
50 register int n;
51 register char *fp, *tp;
52
53 n = (len >> 1) + 1;
54 fp = (char *)from;
55 tp = (char *)to;
56#define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp
57 /* round to multiple of 8 */
58 while ((--n) & 07)
59 STEP;
60 n >>= 3;
61 while (--n >= 0) {
62 STEP; STEP; STEP; STEP;
63 STEP; STEP; STEP; STEP;
64 }
65}
diff --git a/src/lib/libcrypto/Makefile.ssl b/src/lib/libcrypto/Makefile.ssl
new file mode 100644
index 0000000000..efdbba38ac
--- /dev/null
+++ b/src/lib/libcrypto/Makefile.ssl
@@ -0,0 +1,161 @@
1#
2# SSLeay/crypto/Makefile
3#
4
5DIR= crypto
6TOP= ..
7CC= cc
8INCLUDE= -I. -I../include
9INCLUDES= -I.. -I../../include
10CFLAG= -g
11INSTALLTOP= /usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15RM= /bin/rm -f
16AR= ar r
17
18MAKE= make -f Makefile.ssl
19MAKEDEPEND= makedepend -f Makefile.ssl
20MAKEFILE= Makefile.ssl
21
22PEX_LIBS=
23EX_LIBS=
24
25CFLAGS= $(INCLUDE) $(CFLAG) -DCFLAGS=" \"$(CC) $(CFLAG)\" "
26
27ERR=crypto
28ERRC=cpt_err
29
30LIBS=
31
32SDIRS= md2 md5 sha mdc2 hmac ripemd \
33 des rc2 rc4 rc5 idea bf cast \
34 bn rsa dsa dh \
35 buffer bio stack lhash rand err objects \
36 evp pem x509 \
37 asn1 conf txt_db pkcs7
38
39GENERAL=Makefile README
40
41LIB= $(TOP)/libcrypto.a
42LIBSRC= cryptlib.c mem.c cversion.c ex_data.c $(ERRC).c
43LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o $(ERRC).o
44
45SRC= $(LIBSRC)
46
47EXHEADER= crypto.h cryptall.h
48HEADER= cryptlib.h date.h $(EXHEADER)
49
50ALL= $(GENERAL) $(SRC) $(HEADER)
51
52top:
53 @(cd ..; $(MAKE) DIRS=$(DIR) all)
54
55all: date.h lib subdirs
56
57date.h: ../Makefile.ssl ../VERSION
58 echo "#define DATE \"`date`\"" >date.h
59
60subdirs:
61 @for i in $(SDIRS) ;\
62 do \
63 (cd $$i; echo "making all in $$i..."; \
64 $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' all ); \
65 done;
66
67files:
68 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
69 @for i in $(SDIRS) ;\
70 do \
71 (cd $$i; echo "making 'files' in $$i..."; \
72 $(MAKE) files ); \
73 done;
74
75links:
76 /bin/rm -f Makefile
77 $(TOP)/util/point.sh Makefile.ssl Makefile ;
78 $(TOP)/util/mklink.sh ../include $(HEADER) ;
79 $(TOP)/util/mklink.sh ../test $(TEST) ;
80 $(TOP)/util/mklink.sh ../apps $(APPS) ;
81 $(TOP)/util/point.sh Makefile.ssl Makefile;
82 @for i in $(SDIRS) ;\
83 do \
84 (cd $$i; echo "making links in $$i..."; \
85 $(MAKE) links ); \
86 done;
87
88lib: $(LIBOBJ)
89 $(AR) $(LIB) $(LIBOBJ)
90 sh $(TOP)/util/ranlib.sh $(LIB)
91 @touch lib
92
93libs:
94 @for i in $(SDIRS) ;\
95 do \
96 (cd $$i; echo "making libs in $$i..."; \
97 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' lib ); \
98 done;
99
100tests:
101 @for i in $(SDIRS) ;\
102 do \
103 (cd $$i; echo "making tests in $$i..."; \
104 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' tests ); \
105 done;
106
107install:
108 @for i in $(EXHEADER) ;\
109 do \
110 (cp $$i $(INSTALLTOP)/include/$$i; \
111 chmod 644 $(INSTALLTOP)/include/$$i ); \
112 done;
113 @for i in $(SDIRS) ;\
114 do \
115 (cd $$i; echo "making install in $$i..."; \
116 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' install ); \
117 done;
118
119lint:
120 @for i in $(SDIRS) ;\
121 do \
122 (cd $$i; echo "making lint in $$i..."; \
123 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' lint ); \
124 done;
125
126depend:
127 $(MAKEDEPEND) $(INCLUDE) $(PROGS) $(LIBSRC)
128 @for i in $(SDIRS) ;\
129 do \
130 (cd $$i; echo "making depend in $$i..."; \
131 $(MAKE) MAKEFILE='${MAKEFILE}' INCLUDES='${INCLUDES}' MAKEDEPEND='${MAKEDEPEND}' depend ); \
132 done;
133
134clean:
135 /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
136 @for i in $(SDIRS) ;\
137 do \
138 (cd $$i; echo "making clean in $$i..."; \
139 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' clean ); \
140 done;
141
142dclean:
143 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
144 mv -f Makefile.new $(MAKEFILE)
145 @for i in $(SDIRS) ;\
146 do \
147 (cd $$i; echo "making dclean in $$i..."; \
148 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' dclean ); \
149 done;
150
151errors:
152 perl ./err/err_code.pl -conf err/ssleay.ec *.c */*.c ../ssl/*.c ../rsaref/*.c
153 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
154 perl err/err_genc.pl -s $(ERR).h $(ERRC).c
155 @for i in $(SDIRS) ;\
156 do \
157 (cd $$i; echo "making errors in $$i..."; \
158 $(MAKE) errors ); \
159 done;
160
161# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/asn1/Makefile.ssl b/src/lib/libcrypto/asn1/Makefile.ssl
new file mode 100644
index 0000000000..30751bd156
--- /dev/null
+++ b/src/lib/libcrypto/asn1/Makefile.ssl
@@ -0,0 +1,120 @@
1#
2# SSLeay/crypto/asn1/Makefile
3#
4
5DIR= asn1
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=asn1
19ERRC=asn1_err
20GENERAL=Makefile README
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c \
26 a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c \
27 a_sign.c a_digest.c a_verify.c \
28 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \
29 x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c \
30 d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c \
31 d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c \
32 d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\
33 t_req.c t_x509.c t_pkey.c \
34 p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c \
35 p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \
36 f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c \
37 a_hdr.c x_pkey.c a_bool.c x_exten.c \
38 asn1_par.c asn1_lib.c $(ERRC).c a_meth.c a_bytes.c \
39 evp_asn1.c
40LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_int.o a_octet.o a_print.o \
41 a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o \
42 a_sign.o a_digest.o a_verify.o \
43 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \
44 x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o \
45 d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o \
46 d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o \
47 d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \
48 t_req.o t_x509.o t_pkey.o \
49 p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o \
50 p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \
51 f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o \
52 a_hdr.o x_pkey.o a_bool.o x_exten.o \
53 asn1_par.o asn1_lib.o $(ERRC).o a_meth.o a_bytes.o \
54 evp_asn1.o
55
56SRC= $(LIBSRC)
57
58EXHEADER= asn1.h asn1_mac.h
59HEADER= $(EXHEADER)
60
61ALL= $(GENERAL) $(SRC) $(HEADER)
62
63top:
64 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
65
66test: test.c
67 cc -g -I../../include -c test.c
68 cc -g -I../../include -o test test.o -L../.. -lcrypto
69
70pk: pk.c
71 cc -g -I../../include -c pk.c
72 cc -g -I../../include -o pk pk.o -L../.. -lcrypto
73
74all: lib
75
76lib: $(LIBOBJ)
77 $(AR) $(LIB) $(LIBOBJ)
78 sh $(TOP)/util/ranlib.sh $(LIB)
79 @touch lib
80
81files:
82 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
83
84links:
85 /bin/rm -f Makefile
86 $(TOP)/util/point.sh Makefile.ssl Makefile ;
87 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
88 $(TOP)/util/mklink.sh ../../test $(TEST)
89 $(TOP)/util/mklink.sh ../../apps $(APPS)
90
91install:
92 @for i in $(EXHEADER) ; \
93 do \
94 (cp $$i $(INSTALLTOP)/include/$$i; \
95 chmod 644 $(INSTALLTOP)/include/$$i ); \
96 done;
97
98tags:
99 ctags $(SRC)
100
101tests:
102
103lint:
104 lint -DLINT $(INCLUDES) $(SRC)>fluff
105
106depend:
107 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
108
109dclean:
110 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
111 mv -f Makefile.new $(MAKEFILE)
112
113clean:
114 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
115
116errors:
117 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
118 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
119
120# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/asn1/a_bmp.c b/src/lib/libcrypto/asn1/a_bmp.c
new file mode 100644
index 0000000000..774502b1fc
--- /dev/null
+++ b/src/lib/libcrypto/asn1/a_bmp.c
@@ -0,0 +1,90 @@
1/* crypto/asn1/a_bmp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1.h"
62
63/* ASN1err(ASN1_F_D2I_ASN1_INTEGER,ASN1_R_EXPECTING_AN_INTEGER);
64 */
65
66int i2d_ASN1_BMPSTRING(a, pp)
67ASN1_BMPSTRING *a;
68unsigned char **pp;
69 {
70 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
71 V_ASN1_BMPSTRING,V_ASN1_UNIVERSAL));
72 }
73
74ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(a, pp, length)
75ASN1_BMPSTRING **a;
76unsigned char **pp;
77long length;
78 {
79 ASN1_BMPSTRING *ret=NULL;
80
81 ret=(ASN1_BMPSTRING *)d2i_ASN1_bytes((ASN1_STRING **)a,
82 pp,length,V_ASN1_BMPSTRING,V_ASN1_UNIVERSAL);
83 if (ret == NULL)
84 {
85 ASN1err(ASN1_F_D2I_ASN1_BMPSTRING,ASN1_R_ERROR_STACK);
86 return(NULL);
87 }
88 return(ret);
89 }
90
diff --git a/src/lib/libcrypto/asn1/asn1.err b/src/lib/libcrypto/asn1/asn1.err
new file mode 100644
index 0000000000..c8b7011488
--- /dev/null
+++ b/src/lib/libcrypto/asn1/asn1.err
@@ -0,0 +1,182 @@
1/* Error codes for the ASN1 functions. */
2
3/* Function codes. */
4#define ASN1_F_A2D_ASN1_OBJECT 100
5#define ASN1_F_A2I_ASN1_INTEGER 101
6#define ASN1_F_A2I_ASN1_STRING 102
7#define ASN1_F_ASN1_COLLATE_PRIMATIVE 103
8#define ASN1_F_ASN1_D2I_BIO 104
9#define ASN1_F_ASN1_D2I_FP 105
10#define ASN1_F_ASN1_DUP 106
11#define ASN1_F_ASN1_GET_OBJECT 107
12#define ASN1_F_ASN1_HEADER_NEW 108
13#define ASN1_F_ASN1_I2D_BIO 109
14#define ASN1_F_ASN1_I2D_FP 110
15#define ASN1_F_ASN1_INTEGER_SET 111
16#define ASN1_F_ASN1_INTEGER_TO_BN 112
17#define ASN1_F_ASN1_OBJECT_NEW 113
18#define ASN1_F_ASN1_SIGN 114
19#define ASN1_F_ASN1_STRING_NEW 115
20#define ASN1_F_ASN1_STRING_TYPE_NEW 116
21#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117
22#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118
23#define ASN1_F_ASN1_TYPE_NEW 119
24#define ASN1_F_ASN1_UTCTIME_NEW 120
25#define ASN1_F_ASN1_VERIFY 121
26#define ASN1_F_BN_TO_ASN1_INTEGER 122
27#define ASN1_F_D2I_ASN1_BIT_STRING 123
28#define ASN1_F_D2I_ASN1_BMPSTRING 124
29#define ASN1_F_D2I_ASN1_BOOLEAN 125
30#define ASN1_F_D2I_ASN1_BYTES 126
31#define ASN1_F_D2I_ASN1_HEADER 127
32#define ASN1_F_D2I_ASN1_INTEGER 128
33#define ASN1_F_D2I_ASN1_OBJECT 129
34#define ASN1_F_D2I_ASN1_OCTET_STRING 130
35#define ASN1_F_D2I_ASN1_PRINT_TYPE 131
36#define ASN1_F_D2I_ASN1_SET 132
37#define ASN1_F_D2I_ASN1_TYPE 133
38#define ASN1_F_D2I_ASN1_TYPE_BYTES 134
39#define ASN1_F_D2I_ASN1_UTCTIME 135
40#define ASN1_F_D2I_DHPARAMS 136
41#define ASN1_F_D2I_DSAPARAMS 137
42#define ASN1_F_D2I_DSAPRIVATEKEY 138
43#define ASN1_F_D2I_DSAPUBLICKEY 139
44#define ASN1_F_D2I_NETSCAPE_PKEY 140
45#define ASN1_F_D2I_NETSCAPE_RSA 141
46#define ASN1_F_D2I_NETSCAPE_RSA_2 142
47#define ASN1_F_D2I_NETSCAPE_SPKAC 143
48#define ASN1_F_D2I_NETSCAPE_SPKI 144
49#define ASN1_F_D2I_PKCS7 145
50#define ASN1_F_D2I_PKCS7_DIGEST 146
51#define ASN1_F_D2I_PKCS7_ENCRYPT 147
52#define ASN1_F_D2I_PKCS7_ENC_CONTENT 148
53#define ASN1_F_D2I_PKCS7_ENVELOPE 149
54#define ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL 150
55#define ASN1_F_D2I_PKCS7_RECIP_INFO 151
56#define ASN1_F_D2I_PKCS7_SIGNED 152
57#define ASN1_F_D2I_PKCS7_SIGNER_INFO 153
58#define ASN1_F_D2I_PKCS7_SIGN_ENVELOPE 154
59#define ASN1_F_D2I_PRIVATEKEY 155
60#define ASN1_F_D2I_PUBLICKEY 156
61#define ASN1_F_D2I_RSAPRIVATEKEY 157
62#define ASN1_F_D2I_RSAPUBLICKEY 158
63#define ASN1_F_D2I_X509 159
64#define ASN1_F_D2I_X509_ALGOR 160
65#define ASN1_F_D2I_X509_ATTRIBUTE 161
66#define ASN1_F_D2I_X509_CINF 162
67#define ASN1_F_D2I_X509_CRL 163
68#define ASN1_F_D2I_X509_CRL_INFO 164
69#define ASN1_F_D2I_X509_EXTENSION 165
70#define ASN1_F_D2I_X509_KEY 166
71#define ASN1_F_D2I_X509_NAME 167
72#define ASN1_F_D2I_X509_NAME_ENTRY 168
73#define ASN1_F_D2I_X509_PKEY 169
74#define ASN1_F_D2I_X509_PUBKEY 170
75#define ASN1_F_D2I_X509_REQ 171
76#define ASN1_F_D2I_X509_REQ_INFO 172
77#define ASN1_F_D2I_X509_REVOKED 173
78#define ASN1_F_D2I_X509_SIG 174
79#define ASN1_F_D2I_X509_VAL 175
80#define ASN1_F_I2D_ASN1_HEADER 176
81#define ASN1_F_I2D_DHPARAMS 177
82#define ASN1_F_I2D_DSAPARAMS 178
83#define ASN1_F_I2D_DSAPRIVATEKEY 179
84#define ASN1_F_I2D_DSAPUBLICKEY 180
85#define ASN1_F_I2D_NETSCAPE_RSA 181
86#define ASN1_F_I2D_PKCS7 182
87#define ASN1_F_I2D_PRIVATEKEY 183
88#define ASN1_F_I2D_PUBLICKEY 184
89#define ASN1_F_I2D_RSAPRIVATEKEY 185
90#define ASN1_F_I2D_RSAPUBLICKEY 186
91#define ASN1_F_I2D_X509_ATTRIBUTE 187
92#define ASN1_F_I2T_ASN1_OBJECT 188
93#define ASN1_F_NETSCAPE_PKEY_NEW 189
94#define ASN1_F_NETSCAPE_SPKAC_NEW 190
95#define ASN1_F_NETSCAPE_SPKI_NEW 191
96#define ASN1_F_PKCS7_DIGEST_NEW 192
97#define ASN1_F_PKCS7_ENCRYPT_NEW 193
98#define ASN1_F_PKCS7_ENC_CONTENT_NEW 194
99#define ASN1_F_PKCS7_ENVELOPE_NEW 195
100#define ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW 196
101#define ASN1_F_PKCS7_NEW 197
102#define ASN1_F_PKCS7_RECIP_INFO_NEW 198
103#define ASN1_F_PKCS7_SIGNED_NEW 199
104#define ASN1_F_PKCS7_SIGNER_INFO_NEW 200
105#define ASN1_F_PKCS7_SIGN_ENVELOPE_NEW 201
106#define ASN1_F_X509_ALGOR_NEW 202
107#define ASN1_F_X509_ATTRIBUTE_NEW 203
108#define ASN1_F_X509_CINF_NEW 204
109#define ASN1_F_X509_CRL_INFO_NEW 205
110#define ASN1_F_X509_CRL_NEW 206
111#define ASN1_F_X509_DHPARAMS_NEW 207
112#define ASN1_F_X509_EXTENSION_NEW 208
113#define ASN1_F_X509_INFO_NEW 209
114#define ASN1_F_X509_KEY_NEW 210
115#define ASN1_F_X509_NAME_ENTRY_NEW 211
116#define ASN1_F_X509_NAME_NEW 212
117#define ASN1_F_X509_NEW 213
118#define ASN1_F_X509_PKEY_NEW 214
119#define ASN1_F_X509_PUBKEY_NEW 215
120#define ASN1_F_X509_REQ_INFO_NEW 216
121#define ASN1_F_X509_REQ_NEW 217
122#define ASN1_F_X509_REVOKED_NEW 218
123#define ASN1_F_X509_SIG_NEW 219
124#define ASN1_F_X509_VAL_FREE 220
125#define ASN1_F_X509_VAL_NEW 221
126
127/* Reason codes. */
128#define ASN1_R_BAD_CLASS 100
129#define ASN1_R_BAD_GET_OBJECT 101
130#define ASN1_R_BAD_OBJECT_HEADER 102
131#define ASN1_R_BAD_PASSWORD_READ 103
132#define ASN1_R_BAD_PKCS7_CONTENT 104
133#define ASN1_R_BAD_PKCS7_TYPE 105
134#define ASN1_R_BAD_TAG 106
135#define ASN1_R_BAD_TYPE 107
136#define ASN1_R_BN_LIB 108
137#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 109
138#define ASN1_R_BUFFER_TOO_SMALL 110
139#define ASN1_R_DATA_IS_WRONG 111
140#define ASN1_R_DECODING_ERROR 112
141#define ASN1_R_ERROR_STACK 113
142#define ASN1_R_EXPECTING_AN_INTEGER 114
143#define ASN1_R_EXPECTING_AN_OBJECT 115
144#define ASN1_R_EXPECTING_AN_OCTET_STRING 116
145#define ASN1_R_EXPECTING_A_BIT_STRING 117
146#define ASN1_R_EXPECTING_A_BOOLEAN 118
147#define ASN1_R_EXPECTING_A_SEQUENCE 119
148#define ASN1_R_EXPECTING_A_UTCTIME 120
149#define ASN1_R_FIRST_NUM_TOO_LARGE 121
150#define ASN1_R_HEADER_TOO_LONG 122
151#define ASN1_R_INVALID_DIGIT 123
152#define ASN1_R_INVALID_SEPARATOR 124
153#define ASN1_R_INVALID_TIME_FORMAT 125
154#define ASN1_R_IV_TOO_LARGE 126
155#define ASN1_R_LENGTH_ERROR 127
156#define ASN1_R_LENGTH_MISMATCH 128
157#define ASN1_R_MISSING_EOS 129
158#define ASN1_R_MISSING_SECOND_NUMBER 130
159#define ASN1_R_NON_HEX_CHARACTERS 131
160#define ASN1_R_NOT_ENOUGH_DATA 132
161#define ASN1_R_ODD_NUMBER_OF_CHARS 133
162#define ASN1_R_PARSING 134
163#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 135
164#define ASN1_R_SECOND_NUMBER_TOO_LARGE 136
165#define ASN1_R_SHORT_LINE 137
166#define ASN1_R_STRING_TOO_SHORT 138
167#define ASN1_R_TAG_VALUE_TOO_HIGH 139
168#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 140
169#define ASN1_R_TOO_LONG 141
170#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 142
171#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 143
172#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 144
173#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 145
174#define ASN1_R_UNKNOWN_OBJECT_TYPE 146
175#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 147
176#define ASN1_R_UNSUPPORTED_CIPHER 148
177#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 149
178#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 150
179#define ASN1_R_UTCTIME_TOO_LONG 151
180#define ASN1_R_WRONG_PRINTABLE_TYPE 152
181#define ASN1_R_WRONG_TAG 153
182#define ASN1_R_WRONG_TYPE 154
diff --git a/src/lib/libcrypto/asn1/d2i_dhp.c b/src/lib/libcrypto/asn1/d2i_dhp.c
new file mode 100644
index 0000000000..616a308100
--- /dev/null
+++ b/src/lib/libcrypto/asn1/d2i_dhp.c
@@ -0,0 +1,108 @@
1/* crypto/asn1/d2i_dhp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "dh.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_DHPARAMS,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_DHPARAMS,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 */
70
71DH *d2i_DHparams(a,pp,length)
72DH **a;
73unsigned char **pp;
74long length;
75 {
76 int i=ASN1_R_ERROR_STACK;
77 ASN1_INTEGER *bs=NULL;
78 long v=0;
79 M_ASN1_D2I_vars(a,DH *,DH_new);
80
81 M_ASN1_D2I_Init();
82 M_ASN1_D2I_start_sequence();
83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
84 if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;
85 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
86 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;
87
88 if (!M_ASN1_D2I_end_sequence())
89 {
90 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
91 for (i=0; i<bs->length; i++)
92 v=(v<<8)|(bs->data[i]);
93 ret->length=(int)v;
94 }
95
96 ASN1_BIT_STRING_free(bs);
97
98 M_ASN1_D2I_Finish_2(a);
99
100err_bn:
101 i=ERR_R_BN_LIB;
102err:
103 ASN1err(ASN1_F_D2I_DHPARAMS,i);
104 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DH_free(ret);
105 if (bs != NULL) ASN1_BIT_STRING_free(bs);
106 return(NULL);
107 }
108
diff --git a/src/lib/libcrypto/asn1/d2i_dsap.c b/src/lib/libcrypto/asn1/d2i_dsap.c
new file mode 100644
index 0000000000..2c8ac7bbcf
--- /dev/null
+++ b/src/lib/libcrypto/asn1/d2i_dsap.c
@@ -0,0 +1,101 @@
1/* crypto/asn1/d2i_dsap.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "dsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_DSAPARAMS,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_DSAPARAMS,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 */
70
71DSA *d2i_DSAparams(a,pp,length)
72DSA **a;
73unsigned char **pp;
74long length;
75 {
76 int i=ASN1_R_ERROR_STACK;
77 ASN1_INTEGER *bs=NULL;
78 M_ASN1_D2I_vars(a,DSA *,DSA_new);
79
80 M_ASN1_D2I_Init();
81 M_ASN1_D2I_start_sequence();
82 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
83 if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;
84 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
85 if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn;
86 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
87 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;
88
89 ASN1_BIT_STRING_free(bs);
90
91 M_ASN1_D2I_Finish_2(a);
92
93err_bn:
94 i=ERR_R_BN_LIB;
95err:
96 ASN1err(ASN1_F_D2I_DSAPARAMS,i);
97 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
98 if (bs != NULL) ASN1_BIT_STRING_free(bs);
99 return(NULL);
100 }
101
diff --git a/src/lib/libcrypto/asn1/d2i_r_pr.c b/src/lib/libcrypto/asn1/d2i_r_pr.c
new file mode 100644
index 0000000000..0c53aa94bf
--- /dev/null
+++ b/src/lib/libcrypto/asn1/d2i_r_pr.c
@@ -0,0 +1,129 @@
1/* crypto/asn1/d2i_r_pr.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "rsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_PARSING);
70 */
71
72static ASN1_METHOD method={
73 (int (*)()) i2d_RSAPrivateKey,
74 (char *(*)())d2i_RSAPrivateKey,
75 (char *(*)())RSA_new,
76 (void (*)()) RSA_free};
77
78ASN1_METHOD *RSAPrivateKey_asn1_meth()
79 {
80 return(&method);
81 }
82
83RSA *d2i_RSAPrivateKey(a,pp,length)
84RSA **a;
85unsigned char **pp;
86long length;
87 {
88 int i=ASN1_R_PARSING;
89 ASN1_INTEGER *bs=NULL;
90 M_ASN1_D2I_vars(a,RSA *,RSA_new);
91
92 M_ASN1_D2I_Init();
93 M_ASN1_D2I_start_sequence();
94 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
95 if (bs->length == 0)
96 ret->version=0;
97 else ret->version=bs->data[0];
98 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
99 if ((ret->n=BN_bin2bn(bs->data,bs->length,ret->n)) == NULL) goto err_bn;
100 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
101 if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn;
102 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
103 if ((ret->d=BN_bin2bn(bs->data,bs->length,ret->d)) == NULL) goto err_bn;
104 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
105 if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;
106 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
107 if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn;
108 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
109 if ((ret->dmp1=BN_bin2bn(bs->data,bs->length,ret->dmp1)) == NULL)
110 goto err_bn;
111 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
112 if ((ret->dmq1=BN_bin2bn(bs->data,bs->length,ret->dmq1)) == NULL)
113 goto err_bn;
114 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
115 if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL)
116 goto err_bn;
117
118 ASN1_INTEGER_free(bs);
119
120 M_ASN1_D2I_Finish_2(a);
121err_bn:
122 i=ERR_R_BN_LIB;
123err:
124 ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i);
125 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
126 if (bs != NULL) ASN1_INTEGER_free(bs);
127 return(NULL);
128 }
129
diff --git a/src/lib/libcrypto/asn1/d2i_r_pu.c b/src/lib/libcrypto/asn1/d2i_r_pu.c
new file mode 100644
index 0000000000..778b792b1e
--- /dev/null
+++ b/src/lib/libcrypto/asn1/d2i_r_pu.c
@@ -0,0 +1,100 @@
1/* crypto/asn1/d2i_r_pu.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "rsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 */
70
71RSA *d2i_RSAPublicKey(a,pp,length)
72RSA **a;
73unsigned char **pp;
74long length;
75 {
76 int i=ASN1_R_PARSING;
77 ASN1_INTEGER *bs=NULL;
78 M_ASN1_D2I_vars(a,RSA *,RSA_new);
79
80 M_ASN1_D2I_Init();
81 M_ASN1_D2I_start_sequence();
82 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
83 if ((ret->n=BN_bin2bn(bs->data,bs->length,ret->n)) == NULL) goto err_bn;
84 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
85 if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn;
86
87 ASN1_INTEGER_free(bs);
88 bs=NULL;
89
90 M_ASN1_D2I_Finish_2(a);
91
92err_bn:
93 i=ERR_R_BN_LIB;
94err:
95 ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i);
96 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
97 if (bs != NULL) ASN1_INTEGER_free(bs);
98 return(NULL);
99 }
100
diff --git a/src/lib/libcrypto/asn1/d2i_s_pr.c b/src/lib/libcrypto/asn1/d2i_s_pr.c
new file mode 100644
index 0000000000..32ff8ba4b3
--- /dev/null
+++ b/src/lib/libcrypto/asn1/d2i_s_pr.c
@@ -0,0 +1,113 @@
1/* crypto/asn1/d2i_s_pr.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* Origional version from Steven Schoch <schoch@sheba.arc.nasa.gov> */
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "bn.h"
64#include "dsa.h"
65#include "objects.h"
66#include "asn1_mac.h"
67
68/*
69 * ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH);
70 * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
71 * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_PARSING);
72 */
73
74DSA *d2i_DSAPrivateKey(a,pp,length)
75DSA **a;
76unsigned char **pp;
77long length;
78 {
79 int i=ASN1_R_PARSING;
80 ASN1_INTEGER *bs=NULL;
81 M_ASN1_D2I_vars(a,DSA *,DSA_new);
82
83 M_ASN1_D2I_Init();
84 M_ASN1_D2I_start_sequence();
85 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
86 if (bs->length == 0)
87 ret->version=0;
88 else ret->version=bs->data[0];
89 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
90 if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;
91 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
92 if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn;
93 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
94 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;
95 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
96 if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key))
97 == NULL) goto err_bn;
98 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
99 if ((ret->priv_key=BN_bin2bn(bs->data,bs->length,ret->priv_key))
100 == NULL) goto err_bn;
101
102 ASN1_INTEGER_free(bs);
103
104 M_ASN1_D2I_Finish_2(a);
105err_bn:
106 i=ERR_R_BN_LIB;
107err:
108 ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,i);
109 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
110 if (bs != NULL) ASN1_INTEGER_free(bs);
111 return(NULL);
112 }
113
diff --git a/src/lib/libcrypto/asn1/d2i_s_pu.c b/src/lib/libcrypto/asn1/d2i_s_pu.c
new file mode 100644
index 0000000000..1002f41cd8
--- /dev/null
+++ b/src/lib/libcrypto/asn1/d2i_s_pu.c
@@ -0,0 +1,124 @@
1/* crypto/asn1/d2i_s_pu.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* Origional version from Steven Schoch <schoch@sheba.arc.nasa.gov> */
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "bn.h"
64#include "dsa.h"
65#include "objects.h"
66#include "asn1_mac.h"
67
68/*
69 * ASN1err(ASN1_F_D2I_DSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH);
70 * ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
71 */
72
73DSA *d2i_DSAPublicKey(a,pp,length)
74DSA **a;
75unsigned char **pp;
76long length;
77 {
78 int i=ASN1_R_PARSING;
79 ASN1_INTEGER *bs=NULL;
80 M_ASN1_D2I_vars(a,DSA *,DSA_new);
81
82 M_ASN1_D2I_Init();
83 if ((length != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED))
84 == (V_ASN1_UNIVERSAL|(V_ASN1_INTEGER))))
85 {
86 c.slen=length;
87 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
88 if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key))
89 == NULL)
90 goto err_bn;
91 ret->write_params=0;
92 }
93 else
94 {
95 M_ASN1_D2I_start_sequence();
96 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
97 if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key))
98 == NULL)
99 goto err_bn;
100 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
101 if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL)
102 goto err_bn;
103 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
104 if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL)
105 goto err_bn;
106 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
107 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL)
108 goto err_bn;
109
110 ret->write_params=1;
111 }
112
113 ASN1_INTEGER_free(bs);
114 bs=NULL;
115 M_ASN1_D2I_Finish_2(a);
116err_bn:
117 i=ERR_R_BN_LIB;
118err:
119 ASN1err(ASN1_F_D2I_DSAPUBLICKEY,i);
120 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
121 if (bs != NULL) ASN1_INTEGER_free(bs);
122 return(NULL);
123 }
124
diff --git a/src/lib/libcrypto/asn1/f.c b/src/lib/libcrypto/asn1/f.c
new file mode 100644
index 0000000000..2ab3a262ac
--- /dev/null
+++ b/src/lib/libcrypto/asn1/f.c
@@ -0,0 +1,80 @@
1/* crypto/asn1/f.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58#include <stdio.h>
59#include "asn1.h"
60#include "err.h"
61
62main()
63 {
64 ASN1_TYPE *at;
65 char buf[512];
66 int n;
67 long l;
68
69 at=ASN1_TYPE_new();
70
71 n=ASN1_TYPE_set_int_octetstring(at,98736,"01234567",8);
72 printf("%d\n",n);
73 n=ASN1_TYPE_get_int_octetstring(at,&l,buf,8);
74 buf[8]='\0';
75 printf("%ld %d %d\n",l,n,buf[8]);
76 buf[8]='\0';
77 printf("%s\n",buf);
78 ERR_load_crypto_strings();
79 ERR_print_errors_fp(stderr);
80 }
diff --git a/src/lib/libcrypto/asn1/i2d_dhp.c b/src/lib/libcrypto/asn1/i2d_dhp.c
new file mode 100644
index 0000000000..a454025ce3
--- /dev/null
+++ b/src/lib/libcrypto/asn1/i2d_dhp.c
@@ -0,0 +1,128 @@
1/* crypto/asn1/i2d_dhp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "asn1_mac.h"
63#include "dh.h"
64
65/*
66 * ASN1err(ASN1_F_D2I_DHPARAMS,ASN1_R_LENGTH_MISMATCH);
67 * ASN1err(ASN1_F_X509_DHPARAMS_NEW,ASN1_R_LENGTH_MISMATCH);
68 */
69
70int i2d_DHparams(a,pp)
71DH *a;
72unsigned char **pp;
73 {
74 BIGNUM *num[3];
75 ASN1_INTEGER bs;
76 unsigned int j,i,tot=0,len,max=0;
77 int t,ret= -1;
78 unsigned char *p;
79
80 if (a == NULL) return(0);
81 num[0]=a->p;
82 num[1]=a->g;
83 if (a->length != 0)
84 {
85 if ((num[2]=BN_new()) == NULL) goto err;
86 if (!BN_set_word(num[2],a->length)) goto err;
87 }
88 else
89 num[2]=NULL;
90
91 for (i=0; i<3; i++)
92 {
93 if (num[i] == NULL) continue;
94 j=BN_num_bits(num[i]);
95 len=((j == 0)?0:((j/8)+1));
96 if (len > max) max=len;
97 len=ASN1_object_size(0,len,
98 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
99 tot+=len;
100 }
101
102 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
103 if (pp == NULL) return(t);
104
105 p= *pp;
106 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
107
108 bs.type=V_ASN1_INTEGER;
109 bs.data=(unsigned char *)Malloc(max+4);
110 if (bs.data == NULL)
111 {
112 ASN1err(ASN1_F_I2D_DHPARAMS,ERR_R_MALLOC_FAILURE);
113 goto err;
114 }
115
116 for (i=0; i<3; i++)
117 {
118 if (num[i] == NULL) continue;
119 bs.length=BN_bn2bin(num[i],bs.data);
120 i2d_ASN1_INTEGER(&bs,&p);
121 }
122 Free((char *)bs.data);
123 ret=t;
124err:
125 if (num[2] != NULL) BN_free(num[2]);
126 *pp=p;
127 return(ret);
128 }
diff --git a/src/lib/libcrypto/asn1/i2d_dsap.c b/src/lib/libcrypto/asn1/i2d_dsap.c
new file mode 100644
index 0000000000..94ecff1525
--- /dev/null
+++ b/src/lib/libcrypto/asn1/i2d_dsap.c
@@ -0,0 +1,121 @@
1/* crypto/asn1/i2d_dsap.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "asn1_mac.h"
63#include "dsa.h"
64
65/*
66 * ASN1err(ASN1_F_D2I_DSAPARAMS,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_DSAparams(a,pp)
70DSA *a;
71unsigned char **pp;
72 {
73 BIGNUM *num[3];
74 ASN1_INTEGER bs;
75 unsigned int j,i,tot=0,len,max=0;
76 int t,ret= -1;
77 unsigned char *p;
78
79 if (a == NULL) return(0);
80 num[0]=a->p;
81 num[1]=a->q;
82 num[2]=a->g;
83
84 for (i=0; i<3; i++)
85 {
86 if (num[i] == NULL) continue;
87 j=BN_num_bits(num[i]);
88 len=((j == 0)?0:((j/8)+1));
89 if (len > max) max=len;
90 len=ASN1_object_size(0,len,
91 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
92 tot+=len;
93 }
94
95 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
96 if (pp == NULL) return(t);
97
98 p= *pp;
99 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
100
101 bs.type=V_ASN1_INTEGER;
102 bs.data=(unsigned char *)Malloc(max+4);
103 if (bs.data == NULL)
104 {
105 ASN1err(ASN1_F_I2D_DSAPARAMS,ERR_R_MALLOC_FAILURE);
106 goto err;
107 }
108
109 for (i=0; i<3; i++)
110 {
111 if (num[i] == NULL) continue;
112 bs.length=BN_bn2bin(num[i],bs.data);
113 i2d_ASN1_INTEGER(&bs,&p);
114 }
115 Free((char *)bs.data);
116 ret=t;
117err:
118 *pp=p;
119 return(ret);
120 }
121
diff --git a/src/lib/libcrypto/asn1/i2d_r_pr.c b/src/lib/libcrypto/asn1/i2d_r_pr.c
new file mode 100644
index 0000000000..aadbb92d8e
--- /dev/null
+++ b/src/lib/libcrypto/asn1/i2d_r_pr.c
@@ -0,0 +1,132 @@
1/* crypto/asn1/i2d_r_pr.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "rsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 */
70
71int i2d_RSAPrivateKey(a,pp)
72RSA *a;
73unsigned char **pp;
74 {
75 BIGNUM *num[9];
76 unsigned char data[1];
77 ASN1_INTEGER bs;
78 unsigned int j,i,tot,t,len,max=0;
79 unsigned char *p;
80
81 if (a == NULL) return(0);
82
83 num[1]=a->n;
84 num[2]=a->e;
85 num[3]=a->d;
86 num[4]=a->p;
87 num[5]=a->q;
88 num[6]=a->dmp1;
89 num[7]=a->dmq1;
90 num[8]=a->iqmp;
91
92 bs.length=1;
93 bs.data=data;
94 bs.type=V_ASN1_INTEGER;
95 data[0]=a->version&0x7f;
96
97 tot=i2d_ASN1_INTEGER(&(bs),NULL);
98 for (i=1; i<9; i++)
99 {
100 j=BN_num_bits(num[i]);
101 len=((j == 0)?0:((j/8)+1));
102 if (len > max) max=len;
103 len=ASN1_object_size(0,len,
104 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
105 tot+=len;
106 }
107
108 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
109 if (pp == NULL) return(t);
110
111 p= *pp;
112 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
113
114 i2d_ASN1_INTEGER(&bs,&p);
115
116 bs.data=(unsigned char *)Malloc(max+4);
117 if (bs.data == NULL)
118 {
119 ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ERR_R_MALLOC_FAILURE);
120 return(-1);
121 }
122
123 for (i=1; i<9; i++)
124 {
125 bs.length=BN_bn2bin(num[i],bs.data);
126 i2d_ASN1_INTEGER(&bs,&p);
127 }
128 Free((char *)bs.data);
129 *pp=p;
130 return(t);
131 }
132
diff --git a/src/lib/libcrypto/asn1/i2d_r_pu.c b/src/lib/libcrypto/asn1/i2d_r_pu.c
new file mode 100644
index 0000000000..3c54f6709d
--- /dev/null
+++ b/src/lib/libcrypto/asn1/i2d_r_pu.c
@@ -0,0 +1,118 @@
1/* crypto/asn1/i2d_r_pu.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "rsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 */
70
71int i2d_RSAPublicKey(a,pp)
72RSA *a;
73unsigned char **pp;
74 {
75 BIGNUM *num[2];
76 ASN1_INTEGER bs;
77 unsigned int j,i,tot=0,len,max=0,t;
78 unsigned char *p;
79
80 if (a == NULL) return(0);
81
82 num[0]=a->n;
83 num[1]=a->e;
84
85 for (i=0; i<2; i++)
86 {
87 j=BN_num_bits(num[i]);
88 len=((j == 0)?0:((j/8)+1));
89 if (len > max) max=len;
90 len=ASN1_object_size(0,len,
91 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
92 tot+=len;
93 }
94
95 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
96 if (pp == NULL) return(t);
97
98 p= *pp;
99 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
100
101 bs.type=V_ASN1_INTEGER;
102 bs.data=(unsigned char *)Malloc(max+4);
103 if (bs.data == NULL)
104 {
105 ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ERR_R_MALLOC_FAILURE);
106 return(-1);
107 }
108
109 for (i=0; i<2; i++)
110 {
111 bs.length=BN_bn2bin(num[i],bs.data);
112 i2d_ASN1_INTEGER(&bs,&p);
113 }
114 Free((char *)bs.data);
115 *pp=p;
116 return(t);
117 }
118
diff --git a/src/lib/libcrypto/asn1/i2d_s_pr.c b/src/lib/libcrypto/asn1/i2d_s_pr.c
new file mode 100644
index 0000000000..6e95305548
--- /dev/null
+++ b/src/lib/libcrypto/asn1/i2d_s_pr.c
@@ -0,0 +1,128 @@
1/* crypto/asn1/i2d_s_pr.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "dsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
68 */
69
70int i2d_DSAPrivateKey(a,pp)
71DSA *a;
72unsigned char **pp;
73 {
74 BIGNUM *num[6];
75 unsigned char data[1];
76 ASN1_INTEGER bs;
77 unsigned int j,i,tot,t,len,max=0;
78 unsigned char *p;
79
80 if (a == NULL) return(0);
81
82 num[1]=a->p;
83 num[2]=a->q;
84 num[3]=a->g;
85 num[4]=a->pub_key;
86 num[5]=a->priv_key;
87
88 bs.length=1;
89 bs.data=data;
90 bs.type=V_ASN1_INTEGER;
91 data[0]=a->version&0x7f;
92
93 tot=i2d_ASN1_INTEGER(&(bs),NULL);
94 for (i=1; i<6; i++)
95 {
96 j=BN_num_bits(num[i]);
97 len=((j == 0)?0:((j/8)+1));
98 if (len > max) max=len;
99 len=ASN1_object_size(0,len,
100 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
101 tot+=len;
102 }
103
104 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
105 if (pp == NULL) return(t);
106
107 p= *pp;
108 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
109
110 i2d_ASN1_INTEGER(&bs,&p);
111
112 bs.data=(unsigned char *)Malloc(max+4);
113 if (bs.data == NULL)
114 {
115 ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ERR_R_MALLOC_FAILURE);
116 return(-1);
117 }
118
119 for (i=1; i<6; i++)
120 {
121 bs.length=BN_bn2bin(num[i],bs.data);
122 i2d_ASN1_INTEGER(&bs,&p);
123 }
124 Free((char *)bs.data);
125 *pp=p;
126 return(t);
127 }
128
diff --git a/src/lib/libcrypto/asn1/i2d_s_pu.c b/src/lib/libcrypto/asn1/i2d_s_pu.c
new file mode 100644
index 0000000000..5cf2877069
--- /dev/null
+++ b/src/lib/libcrypto/asn1/i2d_s_pu.c
@@ -0,0 +1,133 @@
1/* crypto/asn1/i2d_s_pu.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "dsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
68 */
69
70int i2d_DSAPublicKey(a,pp)
71DSA *a;
72unsigned char **pp;
73 {
74 BIGNUM *num[4];
75 ASN1_INTEGER bs;
76 unsigned int j,i,tot=0,len,max=0,t=0,all,n=1;
77 unsigned char *p;
78
79 if (a == NULL) return(0);
80
81 all=a->write_params;
82
83 num[0]=a->pub_key;
84 if (all)
85 {
86 num[1]=a->p;
87 num[2]=a->q;
88 num[3]=a->g;
89 n=4;
90 }
91
92 for (i=0; i<n; i++)
93 {
94 j=BN_num_bits(num[i]);
95 len=((j == 0)?0:((j/8)+1));
96 if (len > max) max=len;
97 len=ASN1_object_size(0,len,
98 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
99 tot+=len;
100 }
101
102 if (all)
103 {
104 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
105 if (pp == NULL) return(t);
106 }
107 else
108 {
109 if (pp == NULL) return(tot);
110 }
111
112 p= *pp;
113 if (all)
114 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
115
116 bs.type=V_ASN1_INTEGER;
117 bs.data=(unsigned char *)Malloc(max+4);
118 if (bs.data == NULL)
119 {
120 ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ERR_R_MALLOC_FAILURE);
121 return(-1);
122 }
123
124 for (i=0; i<n; i++)
125 {
126 bs.length=BN_bn2bin(num[i],bs.data);
127 i2d_ASN1_INTEGER(&bs,&p);
128 }
129 Free((char *)bs.data);
130 *pp=p;
131 return(t);
132 }
133
diff --git a/src/lib/libcrypto/asn1/p7_dgst.c b/src/lib/libcrypto/asn1/p7_dgst.c
new file mode 100644
index 0000000000..f71ed8eb1d
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p7_dgst.c
@@ -0,0 +1,130 @@
1/* crypto/asn1/p7_dgst.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_DIGEST_NEW,ASN1_R_MISSING_EOS);
66 * ASN1err(ASN1_F_D2I_PKCS7_DIGEST,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_DIGEST(a,pp)
70PKCS7_DIGEST *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len(a->md,i2d_X509_ALGOR);
77 M_ASN1_I2D_len(a->contents,i2d_PKCS7);
78 M_ASN1_I2D_len(a->digest,i2d_ASN1_OCTET_STRING);
79
80 M_ASN1_I2D_seq_total();
81
82 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
83 M_ASN1_I2D_put(a->md,i2d_X509_ALGOR);
84 M_ASN1_I2D_put(a->contents,i2d_PKCS7);
85 M_ASN1_I2D_put(a->digest,i2d_ASN1_OCTET_STRING);
86
87 M_ASN1_I2D_finish();
88 }
89
90PKCS7_DIGEST *d2i_PKCS7_DIGEST(a,pp,length)
91PKCS7_DIGEST **a;
92unsigned char **pp;
93long length;
94 {
95 M_ASN1_D2I_vars(a,PKCS7_DIGEST *,PKCS7_DIGEST_new);
96
97 M_ASN1_D2I_Init();
98 M_ASN1_D2I_start_sequence();
99 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
100 M_ASN1_D2I_get(ret->md,d2i_X509_ALGOR);
101 M_ASN1_D2I_get(ret->contents,d2i_PKCS7);
102 M_ASN1_D2I_get(ret->digest,d2i_ASN1_OCTET_STRING);
103
104 M_ASN1_D2I_Finish(a,PKCS7_DIGEST_free,ASN1_F_D2I_PKCS7_DIGEST);
105 }
106
107PKCS7_DIGEST *PKCS7_DIGEST_new()
108 {
109 PKCS7_DIGEST *ret=NULL;
110
111 M_ASN1_New_Malloc(ret,PKCS7_DIGEST);
112 M_ASN1_New(ret->version,ASN1_INTEGER_new);
113 M_ASN1_New(ret->md,X509_ALGOR_new);
114 M_ASN1_New(ret->contents,PKCS7_new);
115 M_ASN1_New(ret->digest,ASN1_OCTET_STRING_new);
116 return(ret);
117 M_ASN1_New_Error(ASN1_F_PKCS7_DIGEST_NEW);
118 }
119
120void PKCS7_DIGEST_free(a)
121PKCS7_DIGEST *a;
122 {
123 if (a == NULL) return;
124 ASN1_INTEGER_free(a->version);
125 X509_ALGOR_free(a->md);
126 PKCS7_free(a->contents);
127 ASN1_OCTET_STRING_free(a->digest);
128 Free((char *)a);
129 }
130
diff --git a/src/lib/libcrypto/asn1/p7_enc.c b/src/lib/libcrypto/asn1/p7_enc.c
new file mode 100644
index 0000000000..874dd78389
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p7_enc.c
@@ -0,0 +1,120 @@
1/* crypto/asn1/p7_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_ENCRYPT_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_ENCRYPT,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_ENCRYPT(a,pp)
70PKCS7_ENCRYPT *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT);
77
78 M_ASN1_I2D_seq_total();
79
80 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
81 M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT);
82
83 M_ASN1_I2D_finish();
84 }
85
86PKCS7_ENCRYPT *d2i_PKCS7_ENCRYPT(a,pp,length)
87PKCS7_ENCRYPT **a;
88unsigned char **pp;
89long length;
90 {
91 M_ASN1_D2I_vars(a,PKCS7_ENCRYPT *,PKCS7_ENCRYPT_new);
92
93 M_ASN1_D2I_Init();
94 M_ASN1_D2I_start_sequence();
95 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
96 M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT);
97
98 M_ASN1_D2I_Finish(a,PKCS7_ENCRYPT_free,ASN1_F_D2I_PKCS7_ENCRYPT);
99 }
100
101PKCS7_ENCRYPT *PKCS7_ENCRYPT_new()
102 {
103 PKCS7_ENCRYPT *ret=NULL;
104
105 M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT);
106 M_ASN1_New(ret->version,ASN1_INTEGER_new);
107 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
108 return(ret);
109 M_ASN1_New_Error(ASN1_F_PKCS7_ENCRYPT_NEW);
110 }
111
112void PKCS7_ENCRYPT_free(a)
113PKCS7_ENCRYPT *a;
114 {
115 if (a == NULL) return;
116 ASN1_INTEGER_free(a->version);
117 PKCS7_ENC_CONTENT_free(a->enc_data);
118 Free((char *)a);
119 }
120
diff --git a/src/lib/libcrypto/asn1/p7_enc_c.c b/src/lib/libcrypto/asn1/p7_enc_c.c
new file mode 100644
index 0000000000..2860d3e925
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p7_enc_c.c
@@ -0,0 +1,127 @@
1/* crypto/asn1/p7_enc_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_ENC_CONTENT_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_ENC_CONTENT,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_ENC_CONTENT(a,pp)
70PKCS7_ENC_CONTENT *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->content_type,i2d_ASN1_OBJECT);
76 M_ASN1_I2D_len(a->algorithm,i2d_X509_ALGOR);
77 M_ASN1_I2D_len_IMP_opt(a->enc_data,i2d_ASN1_OCTET_STRING);
78
79 M_ASN1_I2D_seq_total();
80
81 M_ASN1_I2D_put(a->content_type,i2d_ASN1_OBJECT);
82 M_ASN1_I2D_put(a->algorithm,i2d_X509_ALGOR);
83 M_ASN1_I2D_put_IMP_opt(a->enc_data,i2d_ASN1_OCTET_STRING,0);
84
85 M_ASN1_I2D_finish();
86 }
87
88PKCS7_ENC_CONTENT *d2i_PKCS7_ENC_CONTENT(a,pp,length)
89PKCS7_ENC_CONTENT **a;
90unsigned char **pp;
91long length;
92 {
93 M_ASN1_D2I_vars(a,PKCS7_ENC_CONTENT *,PKCS7_ENC_CONTENT_new);
94
95 M_ASN1_D2I_Init();
96 M_ASN1_D2I_start_sequence();
97 M_ASN1_D2I_get(ret->content_type,d2i_ASN1_OBJECT);
98 M_ASN1_D2I_get(ret->algorithm,d2i_X509_ALGOR);
99 M_ASN1_D2I_get_IMP_opt(ret->enc_data,d2i_ASN1_OCTET_STRING,0,
100 V_ASN1_OCTET_STRING);
101
102 M_ASN1_D2I_Finish(a,PKCS7_ENC_CONTENT_free,
103 ASN1_F_D2I_PKCS7_ENC_CONTENT);
104 }
105
106PKCS7_ENC_CONTENT *PKCS7_ENC_CONTENT_new()
107 {
108 PKCS7_ENC_CONTENT *ret=NULL;
109
110 M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT);
111 M_ASN1_New(ret->content_type,ASN1_OBJECT_new);
112 M_ASN1_New(ret->algorithm,X509_ALGOR_new);
113 ret->enc_data=NULL;
114 return(ret);
115 M_ASN1_New_Error(ASN1_F_PKCS7_ENC_CONTENT_NEW);
116 }
117
118void PKCS7_ENC_CONTENT_free(a)
119PKCS7_ENC_CONTENT *a;
120 {
121 if (a == NULL) return;
122 ASN1_OBJECT_free(a->content_type);
123 X509_ALGOR_free(a->algorithm);
124 ASN1_OCTET_STRING_free(a->enc_data);
125 Free((char *)a);
126 }
127
diff --git a/src/lib/libcrypto/asn1/p7_evp.c b/src/lib/libcrypto/asn1/p7_evp.c
new file mode 100644
index 0000000000..4db0a7fe62
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p7_evp.c
@@ -0,0 +1,125 @@
1/* crypto/asn1/p7_evp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_ENVELOPE_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_ENVELOPE,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_ENVELOPE(a,pp)
70PKCS7_ENVELOPE *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO);
77 M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT);
78
79 M_ASN1_I2D_seq_total();
80
81 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
82 M_ASN1_I2D_put_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO);
83 M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT);
84
85 M_ASN1_I2D_finish();
86 }
87
88PKCS7_ENVELOPE *d2i_PKCS7_ENVELOPE(a,pp,length)
89PKCS7_ENVELOPE **a;
90unsigned char **pp;
91long length;
92 {
93 M_ASN1_D2I_vars(a,PKCS7_ENVELOPE *,PKCS7_ENVELOPE_new);
94
95 M_ASN1_D2I_Init();
96 M_ASN1_D2I_start_sequence();
97 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
98 M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO);
99 M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT);
100
101 M_ASN1_D2I_Finish(a,PKCS7_ENVELOPE_free,ASN1_F_D2I_PKCS7_ENVELOPE);
102 }
103
104PKCS7_ENVELOPE *PKCS7_ENVELOPE_new()
105 {
106 PKCS7_ENVELOPE *ret=NULL;
107
108 M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE);
109 M_ASN1_New(ret->version,ASN1_INTEGER_new);
110 M_ASN1_New(ret->recipientinfo,sk_new_null);
111 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
112 return(ret);
113 M_ASN1_New_Error(ASN1_F_PKCS7_ENVELOPE_NEW);
114 }
115
116void PKCS7_ENVELOPE_free(a)
117PKCS7_ENVELOPE *a;
118 {
119 if (a == NULL) return;
120 ASN1_INTEGER_free(a->version);
121 sk_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
122 PKCS7_ENC_CONTENT_free(a->enc_data);
123 Free((char *)a);
124 }
125
diff --git a/src/lib/libcrypto/asn1/p7_i_s.c b/src/lib/libcrypto/asn1/p7_i_s.c
new file mode 100644
index 0000000000..9b00c556d9
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p7_i_s.c
@@ -0,0 +1,120 @@
1/* crypto/asn1/p7_i_s.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_ISSUER_AND_SERIAL(a,pp)
70PKCS7_ISSUER_AND_SERIAL *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->issuer,i2d_X509_NAME);
76 M_ASN1_I2D_len(a->serial,i2d_ASN1_INTEGER);
77
78 M_ASN1_I2D_seq_total();
79
80 M_ASN1_I2D_put(a->issuer,i2d_X509_NAME);
81 M_ASN1_I2D_put(a->serial,i2d_ASN1_INTEGER);
82
83 M_ASN1_I2D_finish();
84 }
85
86PKCS7_ISSUER_AND_SERIAL *d2i_PKCS7_ISSUER_AND_SERIAL(a,pp,length)
87PKCS7_ISSUER_AND_SERIAL **a;
88unsigned char **pp;
89long length;
90 {
91 M_ASN1_D2I_vars(a,PKCS7_ISSUER_AND_SERIAL *,PKCS7_ISSUER_AND_SERIAL_new);
92
93 M_ASN1_D2I_Init();
94 M_ASN1_D2I_start_sequence();
95 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
96 M_ASN1_D2I_get(ret->serial,d2i_ASN1_INTEGER);
97 M_ASN1_D2I_Finish(a,PKCS7_ISSUER_AND_SERIAL_free,
98 ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL);
99 }
100
101PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new()
102 {
103 PKCS7_ISSUER_AND_SERIAL *ret=NULL;
104
105 M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL);
106 M_ASN1_New(ret->issuer,X509_NAME_new);
107 M_ASN1_New(ret->serial,ASN1_INTEGER_new);
108 return(ret);
109 M_ASN1_New_Error(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW);
110 }
111
112void PKCS7_ISSUER_AND_SERIAL_free(a)
113PKCS7_ISSUER_AND_SERIAL *a;
114 {
115 if (a == NULL) return;
116 X509_NAME_free(a->issuer);
117 ASN1_INTEGER_free(a->serial);
118 Free((char *)a);
119 }
120
diff --git a/src/lib/libcrypto/asn1/p7_lib.c b/src/lib/libcrypto/asn1/p7_lib.c
new file mode 100644
index 0000000000..2134e0974a
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p7_lib.c
@@ -0,0 +1,299 @@
1/* crypto/asn1/p7_lib.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "objects.h"
63
64/* ASN1err(ASN1_F_D2I_PKCS7,ASN1_R_BAD_PKCS7_CONTENT);
65 * ASN1err(ASN1_F_I2D_PKCS7,ASN1_R_BAD_PKCS7_TYPE);
66 * ASN1err(ASN1_F_PKCS7_NEW,ASN1_R_BAD_PKCS7_TYPE);
67 */
68
69int i2d_PKCS7(a,pp)
70PKCS7 *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 if (a->asn1 != NULL)
76 {
77 if (pp == NULL)
78 return((int)a->length);
79 memcpy(*pp,a->asn1,(int)a->length);
80 *pp+=a->length;
81 return((int)a->length);
82 }
83
84 ret+=4; /* sequence, BER header plus '0 0' end padding */
85 M_ASN1_I2D_len(a->type,i2d_ASN1_OBJECT);
86 if (a->d.ptr != NULL)
87 {
88 ret+=4; /* explicit tag [ 0 ] BER plus '0 0' */
89 switch (OBJ_obj2nid(a->type))
90 {
91 case NID_pkcs7_data:
92 M_ASN1_I2D_len(a->d.data,i2d_ASN1_OCTET_STRING);
93 break;
94 case NID_pkcs7_signed:
95 M_ASN1_I2D_len(a->d.sign,i2d_PKCS7_SIGNED);
96 break;
97 case NID_pkcs7_enveloped:
98 M_ASN1_I2D_len(a->d.enveloped,i2d_PKCS7_ENVELOPE);
99 break;
100 case NID_pkcs7_signedAndEnveloped:
101 M_ASN1_I2D_len(a->d.signed_and_enveloped,
102 i2d_PKCS7_SIGN_ENVELOPE);
103 break;
104 case NID_pkcs7_digest:
105 M_ASN1_I2D_len(a->d.digest,i2d_PKCS7_DIGEST);
106 break;
107 case NID_pkcs7_encrypted:
108 M_ASN1_I2D_len(a->d.encrypted,i2d_PKCS7_ENCRYPT);
109 break;
110 default:
111 break;
112 }
113 }
114 r=ret;
115 if (pp == NULL) return(r);
116 p= *pp;
117 M_ASN1_I2D_INF_seq_start(V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
118 M_ASN1_I2D_put(a->type,i2d_ASN1_OBJECT);
119
120 if (a->d.ptr != NULL)
121 {
122 M_ASN1_I2D_INF_seq_start(0,V_ASN1_CONTEXT_SPECIFIC);
123 switch (OBJ_obj2nid(a->type))
124 {
125 case NID_pkcs7_data:
126 M_ASN1_I2D_put(a->d.data,i2d_ASN1_OCTET_STRING);
127 break;
128 case NID_pkcs7_signed:
129 M_ASN1_I2D_put(a->d.sign,i2d_PKCS7_SIGNED);
130 break;
131 case NID_pkcs7_enveloped:
132 M_ASN1_I2D_put(a->d.enveloped,i2d_PKCS7_ENVELOPE);
133 break;
134 case NID_pkcs7_signedAndEnveloped:
135 M_ASN1_I2D_put(a->d.signed_and_enveloped,
136 i2d_PKCS7_SIGN_ENVELOPE);
137 break;
138 case NID_pkcs7_digest:
139 M_ASN1_I2D_put(a->d.digest,i2d_PKCS7_DIGEST);
140 break;
141 case NID_pkcs7_encrypted:
142 M_ASN1_I2D_put(a->d.encrypted,i2d_PKCS7_ENCRYPT);
143 break;
144 default:
145 break;
146 }
147 M_ASN1_I2D_INF_seq_end();
148 }
149 M_ASN1_I2D_INF_seq_end();
150 M_ASN1_I2D_finish();
151 }
152
153PKCS7 *d2i_PKCS7(a,pp,length)
154PKCS7 **a;
155unsigned char **pp;
156long length;
157 {
158 M_ASN1_D2I_vars(a,PKCS7 *,PKCS7_new);
159
160 if ((a != NULL) && ((*a) != NULL))
161 {
162 if ((*a)->asn1 != NULL)
163 {
164 Free((char *)(*a)->asn1);
165 (*a)->asn1=NULL;
166 }
167 (*a)->length=0;
168 }
169
170 M_ASN1_D2I_Init();
171 M_ASN1_D2I_start_sequence();
172 M_ASN1_D2I_get(ret->type,d2i_ASN1_OBJECT);
173 if (!M_ASN1_D2I_end_sequence())
174 {
175 int Tinf,Ttag,Tclass;
176 long Tlen;
177
178 if (M_ASN1_next != (V_ASN1_CONSTRUCTED|
179 V_ASN1_CONTEXT_SPECIFIC|0))
180 {
181 c.error=ASN1_R_BAD_PKCS7_CONTENT;
182 goto err;
183 }
184
185 ret->detached=0;
186
187 c.q=c.p;
188 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,
189 (c.inf & 1)?(length+ *pp-c.q):c.slen);
190 if (Tinf & 0x80) goto err;
191 c.slen-=(c.p-c.q);
192
193 switch (OBJ_obj2nid(ret->type))
194 {
195 case NID_pkcs7_data:
196 M_ASN1_D2I_get(ret->d.data,d2i_ASN1_OCTET_STRING);
197 break;
198 case NID_pkcs7_signed:
199 M_ASN1_D2I_get(ret->d.sign,d2i_PKCS7_SIGNED);
200 if (ret->d.sign->contents->d.ptr == NULL)
201 ret->detached=1;
202 break;
203 case NID_pkcs7_enveloped:
204 M_ASN1_D2I_get(ret->d.enveloped,d2i_PKCS7_ENVELOPE);
205 break;
206 case NID_pkcs7_signedAndEnveloped:
207 M_ASN1_D2I_get(ret->d.signed_and_enveloped,
208 d2i_PKCS7_SIGN_ENVELOPE);
209 break;
210 case NID_pkcs7_digest:
211 M_ASN1_D2I_get(ret->d.digest,d2i_PKCS7_DIGEST);
212 break;
213 case NID_pkcs7_encrypted:
214 M_ASN1_D2I_get(ret->d.encrypted,d2i_PKCS7_ENCRYPT);
215 break;
216 default:
217 c.error=ASN1_R_BAD_PKCS7_TYPE;
218 goto err;
219 break;
220 }
221 if (Tinf == (1|V_ASN1_CONSTRUCTED))
222 {
223 if (!ASN1_check_infinite_end(&c.p,c.slen))
224 {
225 c.error=ASN1_R_MISSING_EOS;
226 goto err;
227 }
228 }
229 }
230 else
231 ret->detached=1;
232
233 M_ASN1_D2I_Finish(a,PKCS7_free,ASN1_F_D2I_PKCS7);
234 }
235
236PKCS7 *PKCS7_new()
237 {
238 PKCS7 *ret=NULL;
239
240 M_ASN1_New_Malloc(ret,PKCS7);
241 ret->type=ASN1_OBJECT_new();
242 ret->asn1=NULL;
243 ret->length=0;
244 ret->detached=0;
245 ret->d.ptr=NULL;
246 return(ret);
247 M_ASN1_New_Error(ASN1_F_PKCS7_NEW);
248 }
249
250void PKCS7_free(a)
251PKCS7 *a;
252 {
253 if (a == NULL) return;
254
255 PKCS7_content_free(a);
256 if (a->type != NULL)
257 {
258 ASN1_OBJECT_free(a->type);
259 }
260 Free((char *)(char *)a);
261 }
262
263void PKCS7_content_free(a)
264PKCS7 *a;
265 {
266 if (a->asn1 != NULL) Free((char *)a->asn1);
267
268 if (a->d.ptr != NULL)
269 {
270 if (a->type == NULL) return;
271
272 switch (OBJ_obj2nid(a->type))
273 {
274 case NID_pkcs7_data:
275 ASN1_OCTET_STRING_free(a->d.data);
276 break;
277 case NID_pkcs7_signed:
278 PKCS7_SIGNED_free(a->d.sign);
279 break;
280 case NID_pkcs7_enveloped:
281 PKCS7_ENVELOPE_free(a->d.enveloped);
282 break;
283 case NID_pkcs7_signedAndEnveloped:
284 PKCS7_SIGN_ENVELOPE_free(a->d.signed_and_enveloped);
285 break;
286 case NID_pkcs7_digest:
287 PKCS7_DIGEST_free(a->d.digest);
288 break;
289 case NID_pkcs7_encrypted:
290 PKCS7_ENCRYPT_free(a->d.encrypted);
291 break;
292 default:
293 /* MEMORY LEAK */
294 break;
295 }
296 }
297 a->d.ptr=NULL;
298 }
299
diff --git a/src/lib/libcrypto/asn1/p7_recip.c b/src/lib/libcrypto/asn1/p7_recip.c
new file mode 100644
index 0000000000..f02233f5a8
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p7_recip.c
@@ -0,0 +1,132 @@
1/* crypto/asn1/p7_recip.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_RECIP_INFO_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_RECIP_INFO,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_RECIP_INFO(a,pp)
70PKCS7_RECIP_INFO *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL);
77 M_ASN1_I2D_len(a->key_enc_algor,i2d_X509_ALGOR);
78 M_ASN1_I2D_len(a->enc_key,i2d_ASN1_OCTET_STRING);
79
80 M_ASN1_I2D_seq_total();
81
82 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
83 M_ASN1_I2D_put(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL);
84 M_ASN1_I2D_put(a->key_enc_algor,i2d_X509_ALGOR);
85 M_ASN1_I2D_put(a->enc_key,i2d_ASN1_OCTET_STRING);
86
87 M_ASN1_I2D_finish();
88 }
89
90PKCS7_RECIP_INFO *d2i_PKCS7_RECIP_INFO(a,pp,length)
91PKCS7_RECIP_INFO **a;
92unsigned char **pp;
93long length;
94 {
95 M_ASN1_D2I_vars(a,PKCS7_RECIP_INFO *,PKCS7_RECIP_INFO_new);
96
97 M_ASN1_D2I_Init();
98 M_ASN1_D2I_start_sequence();
99 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
100 M_ASN1_D2I_get(ret->issuer_and_serial,d2i_PKCS7_ISSUER_AND_SERIAL);
101 M_ASN1_D2I_get(ret->key_enc_algor,d2i_X509_ALGOR);
102 M_ASN1_D2I_get(ret->enc_key,d2i_ASN1_OCTET_STRING);
103
104 M_ASN1_D2I_Finish(a,PKCS7_RECIP_INFO_free,ASN1_F_D2I_PKCS7_RECIP_INFO);
105 }
106
107PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new()
108 {
109 PKCS7_RECIP_INFO *ret=NULL;
110
111 M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO);
112 M_ASN1_New(ret->version,ASN1_INTEGER_new);
113 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new);
114 M_ASN1_New(ret->key_enc_algor,X509_ALGOR_new);
115 M_ASN1_New(ret->enc_key,ASN1_OCTET_STRING_new);
116 ret->cert=NULL;
117 return(ret);
118 M_ASN1_New_Error(ASN1_F_PKCS7_RECIP_INFO_NEW);
119 }
120
121void PKCS7_RECIP_INFO_free(a)
122PKCS7_RECIP_INFO *a;
123 {
124 if (a == NULL) return;
125 ASN1_INTEGER_free(a->version);
126 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial);
127 X509_ALGOR_free(a->key_enc_algor);
128 ASN1_OCTET_STRING_free(a->enc_key);
129 if (a->cert != NULL) X509_free(a->cert);
130 Free((char *)a);
131 }
132
diff --git a/src/lib/libcrypto/asn1/p7_s_e.c b/src/lib/libcrypto/asn1/p7_s_e.c
new file mode 100644
index 0000000000..d344211456
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p7_s_e.c
@@ -0,0 +1,146 @@
1/* crypto/asn1/p7_s_e.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_SIGN_ENVELOPE,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_SIGN_ENVELOPE(a,pp)
70PKCS7_SIGN_ENVELOPE *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO);
77 M_ASN1_I2D_len_SET(a->md_algs,i2d_X509_ALGOR);
78 M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT);
79 M_ASN1_I2D_len_IMP_set_opt(a->cert,i2d_X509,0);
80 M_ASN1_I2D_len_IMP_set_opt(a->crl,i2d_X509_CRL,1);
81 M_ASN1_I2D_len_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
82
83 M_ASN1_I2D_seq_total();
84
85 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
86 M_ASN1_I2D_put_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO);
87 M_ASN1_I2D_put_SET(a->md_algs,i2d_X509_ALGOR);
88 M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT);
89 M_ASN1_I2D_put_IMP_set_opt(a->cert,i2d_X509,0);
90 M_ASN1_I2D_put_IMP_set_opt(a->crl,i2d_X509_CRL,1);
91 M_ASN1_I2D_put_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
92
93 M_ASN1_I2D_finish();
94 }
95
96PKCS7_SIGN_ENVELOPE *d2i_PKCS7_SIGN_ENVELOPE(a,pp,length)
97PKCS7_SIGN_ENVELOPE **a;
98unsigned char **pp;
99long length;
100 {
101 M_ASN1_D2I_vars(a,PKCS7_SIGN_ENVELOPE *,PKCS7_SIGN_ENVELOPE_new);
102
103 M_ASN1_D2I_Init();
104 M_ASN1_D2I_start_sequence();
105 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
106 M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO);
107 M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR);
108 M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT);
109 M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,0);
110 M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,1);
111 M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO);
112
113 M_ASN1_D2I_Finish(a,PKCS7_SIGN_ENVELOPE_free,
114 ASN1_F_D2I_PKCS7_SIGN_ENVELOPE);
115 }
116
117PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new()
118 {
119 PKCS7_SIGN_ENVELOPE *ret=NULL;
120
121 M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE);
122 M_ASN1_New(ret->version,ASN1_INTEGER_new);
123 M_ASN1_New(ret->recipientinfo,sk_new_null);
124 M_ASN1_New(ret->md_algs,sk_new_null);
125 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
126 ret->cert=NULL;
127 ret->crl=NULL;
128 M_ASN1_New(ret->signer_info,sk_new_null);
129 return(ret);
130 M_ASN1_New_Error(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW);
131 }
132
133void PKCS7_SIGN_ENVELOPE_free(a)
134PKCS7_SIGN_ENVELOPE *a;
135 {
136 if (a == NULL) return;
137 ASN1_INTEGER_free(a->version);
138 sk_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
139 sk_pop_free(a->md_algs,X509_ALGOR_free);
140 PKCS7_ENC_CONTENT_free(a->enc_data);
141 sk_pop_free(a->cert,X509_free);
142 sk_pop_free(a->crl,X509_CRL_free);
143 sk_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free);
144 Free((char *)a);
145 }
146
diff --git a/src/lib/libcrypto/asn1/p7_signd.c b/src/lib/libcrypto/asn1/p7_signd.c
new file mode 100644
index 0000000000..40f9a44fa8
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p7_signd.c
@@ -0,0 +1,140 @@
1/* crypto/asn1/p7_signd.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_SIGNED_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_SIGNED,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_SIGNED(a,pp)
70PKCS7_SIGNED *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len_SET(a->md_algs,i2d_X509_ALGOR);
77 M_ASN1_I2D_len(a->contents,i2d_PKCS7);
78 M_ASN1_I2D_len_IMP_set_opt(a->cert,i2d_X509,0);
79 M_ASN1_I2D_len_IMP_set_opt(a->crl,i2d_X509_CRL,1);
80 M_ASN1_I2D_len_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
81
82 M_ASN1_I2D_seq_total();
83
84 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
85 M_ASN1_I2D_put_SET(a->md_algs,i2d_X509_ALGOR);
86 M_ASN1_I2D_put(a->contents,i2d_PKCS7);
87 M_ASN1_I2D_put_IMP_set_opt(a->cert,i2d_X509,0);
88 M_ASN1_I2D_put_IMP_set_opt(a->crl,i2d_X509_CRL,1);
89 M_ASN1_I2D_put_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
90
91 M_ASN1_I2D_finish();
92 }
93
94PKCS7_SIGNED *d2i_PKCS7_SIGNED(a,pp,length)
95PKCS7_SIGNED **a;
96unsigned char **pp;
97long length;
98 {
99 M_ASN1_D2I_vars(a,PKCS7_SIGNED *,PKCS7_SIGNED_new);
100
101 M_ASN1_D2I_Init();
102 M_ASN1_D2I_start_sequence();
103 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
104 M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR);
105 M_ASN1_D2I_get(ret->contents,d2i_PKCS7);
106 M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,0);
107 M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,1);
108 M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO);
109
110 M_ASN1_D2I_Finish(a,PKCS7_SIGNED_free,ASN1_F_D2I_PKCS7_SIGNED);
111 }
112
113PKCS7_SIGNED *PKCS7_SIGNED_new()
114 {
115 PKCS7_SIGNED *ret=NULL;
116
117 M_ASN1_New_Malloc(ret,PKCS7_SIGNED);
118 M_ASN1_New(ret->version,ASN1_INTEGER_new);
119 M_ASN1_New(ret->md_algs,sk_new_null);
120 M_ASN1_New(ret->contents,PKCS7_new);
121 ret->cert=NULL;
122 ret->crl=NULL;
123 M_ASN1_New(ret->signer_info,sk_new_null);
124 return(ret);
125 M_ASN1_New_Error(ASN1_F_PKCS7_SIGNED_NEW);
126 }
127
128void PKCS7_SIGNED_free(a)
129PKCS7_SIGNED *a;
130 {
131 if (a == NULL) return;
132 ASN1_INTEGER_free(a->version);
133 sk_pop_free(a->md_algs,X509_ALGOR_free);
134 PKCS7_free(a->contents);
135 sk_pop_free(a->cert,X509_free);
136 sk_pop_free(a->crl,X509_CRL_free);
137 sk_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free);
138 Free((char *)a);
139 }
140
diff --git a/src/lib/libcrypto/asn1/p7_signi.c b/src/lib/libcrypto/asn1/p7_signi.c
new file mode 100644
index 0000000000..0da92169fc
--- /dev/null
+++ b/src/lib/libcrypto/asn1/p7_signi.c
@@ -0,0 +1,149 @@
1/* crypto/asn1/p7_signi.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_SIGNER_INFO_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_SIGNER_INFO,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_SIGNER_INFO(a,pp)
70PKCS7_SIGNER_INFO *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL);
77 M_ASN1_I2D_len(a->digest_alg,i2d_X509_ALGOR);
78 M_ASN1_I2D_len_IMP_set_opt(a->auth_attr,i2d_X509_ATTRIBUTE,0);
79 M_ASN1_I2D_len(a->digest_enc_alg,i2d_X509_ALGOR);
80 M_ASN1_I2D_len(a->enc_digest,i2d_ASN1_OCTET_STRING);
81 M_ASN1_I2D_len_IMP_set_opt(a->unauth_attr,i2d_X509_ATTRIBUTE,1);
82
83 M_ASN1_I2D_seq_total();
84
85 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
86 M_ASN1_I2D_put(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL);
87 M_ASN1_I2D_put(a->digest_alg,i2d_X509_ALGOR);
88 M_ASN1_I2D_put_IMP_set_opt(a->auth_attr,i2d_X509_ATTRIBUTE,0);
89 M_ASN1_I2D_put(a->digest_enc_alg,i2d_X509_ALGOR);
90 M_ASN1_I2D_put(a->enc_digest,i2d_ASN1_OCTET_STRING);
91 M_ASN1_I2D_put_IMP_set_opt(a->unauth_attr,i2d_X509_ATTRIBUTE,1);
92
93 M_ASN1_I2D_finish();
94 }
95
96PKCS7_SIGNER_INFO *d2i_PKCS7_SIGNER_INFO(a,pp,length)
97PKCS7_SIGNER_INFO **a;
98unsigned char **pp;
99long length;
100 {
101 M_ASN1_D2I_vars(a,PKCS7_SIGNER_INFO *,PKCS7_SIGNER_INFO_new);
102
103 M_ASN1_D2I_Init();
104 M_ASN1_D2I_start_sequence();
105 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
106 M_ASN1_D2I_get(ret->issuer_and_serial,d2i_PKCS7_ISSUER_AND_SERIAL);
107 M_ASN1_D2I_get(ret->digest_alg,d2i_X509_ALGOR);
108 M_ASN1_D2I_get_IMP_set_opt(ret->auth_attr,d2i_X509_ATTRIBUTE,0);
109 M_ASN1_D2I_get(ret->digest_enc_alg,d2i_X509_ALGOR);
110 M_ASN1_D2I_get(ret->enc_digest,d2i_ASN1_OCTET_STRING);
111 M_ASN1_D2I_get_IMP_set_opt(ret->unauth_attr,d2i_X509_ATTRIBUTE,1);
112
113 M_ASN1_D2I_Finish(a,PKCS7_SIGNER_INFO_free,
114 ASN1_F_D2I_PKCS7_SIGNER_INFO);
115 }
116
117PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new()
118 {
119 PKCS7_SIGNER_INFO *ret=NULL;
120
121 M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO);
122 M_ASN1_New(ret->version,ASN1_INTEGER_new);
123 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new);
124 M_ASN1_New(ret->digest_alg,X509_ALGOR_new);
125 ret->auth_attr=NULL;
126 M_ASN1_New(ret->digest_enc_alg,X509_ALGOR_new);
127 M_ASN1_New(ret->enc_digest,ASN1_OCTET_STRING_new);
128 ret->unauth_attr=NULL;
129 ret->pkey=NULL;
130 return(ret);
131 M_ASN1_New_Error(ASN1_F_PKCS7_SIGNER_INFO_NEW);
132 }
133
134void PKCS7_SIGNER_INFO_free(a)
135PKCS7_SIGNER_INFO *a;
136 {
137 if (a == NULL) return;
138 ASN1_INTEGER_free(a->version);
139 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial);
140 X509_ALGOR_free(a->digest_alg);
141 sk_pop_free(a->auth_attr,X509_ATTRIBUTE_free);
142 X509_ALGOR_free(a->digest_enc_alg);
143 ASN1_OCTET_STRING_free(a->enc_digest);
144 sk_pop_free(a->unauth_attr,X509_ATTRIBUTE_free);
145 if (a->pkey != NULL)
146 EVP_PKEY_free(a->pkey);
147 Free((char *)a);
148 }
149
diff --git a/src/lib/libcrypto/asn1/pkcs8.c b/src/lib/libcrypto/asn1/pkcs8.c
new file mode 100644
index 0000000000..03fdadd51a
--- /dev/null
+++ b/src/lib/libcrypto/asn1/pkcs8.c
@@ -0,0 +1,142 @@
1/* crypto/asn1/pkcs8.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "objects.h"
63
64/*
65 * ASN1err(ASN1_F_D2I_X509_KEY,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_X509_KEY_NEW,ASN1_R_BAD_GET_OBJECT);
67 */
68
69int i2d_X509_KEY(a,pp)
70X509 *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
76 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
77 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
78
79 M_ASN1_I2D_seq_total();
80
81 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
82 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
83 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
84
85 M_ASN1_I2D_finish();
86 }
87
88X509 *d2i_X509_KEY(a,pp,length)
89X509 **a;
90unsigned char **pp;
91long length;
92 {
93 M_ASN1_D2I_vars(a,X509 *,X509_new);
94
95 M_ASN1_D2I_Init();
96 M_ASN1_D2I_start_sequence();
97 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
98 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
99 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
100 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
101 }
102
103X509 *X509_KEY_new()
104 {
105 X509_KEY *ret=NULL;
106
107 M_ASN1_New_Malloc(ret,X509_KEY);
108 ret->references=1;
109 ret->type=NID
110 M_ASN1_New(ret->cert_info,X509_CINF_new);
111 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
112 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
113 return(ret);
114 M_ASN1_New_Error(ASN1_F_X509_NEW);
115 }
116
117void X509_KEY_free(a)
118X509 *a;
119 {
120 int i;
121
122 if (a == NULL) return;
123
124 i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY);
125#ifdef REF_PRINT
126 REF_PRINT("X509_KEY",a);
127#endif
128 if (i > 0) return;
129#ifdef REF_CHECK
130 if (i < 0)
131 {
132 fprintf(stderr,"X509_KEY_free, bad reference count\n");
133 abort();
134 }
135#endif
136
137 X509_CINF_free(a->cert_info);
138 X509_ALGOR_free(a->sig_alg);
139 ASN1_BIT_STRING_free(a->signature);
140 Free((char *)a);
141 }
142
diff --git a/src/lib/libcrypto/asn1/x_cinf.c b/src/lib/libcrypto/asn1/x_cinf.c
new file mode 100644
index 0000000000..4fc2cc9f6e
--- /dev/null
+++ b/src/lib/libcrypto/asn1/x_cinf.c
@@ -0,0 +1,197 @@
1/* crypto/asn1/x_cinf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62
63/*
64 * ASN1err(ASN1_F_D2I_X509_CINF,ASN1_R_LENGTH_MISMATCH);
65 * ASN1err(ASN1_F_X509_CINF_NEW,ASN1_R_LENGTH_MISMATCH);
66 */
67
68int i2d_X509_CINF(a,pp)
69X509_CINF *a;
70unsigned char **pp;
71 {
72 int v1=0,v2=0;
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len_EXP_opt(a->version,i2d_ASN1_INTEGER,0,v1);
76 M_ASN1_I2D_len(a->serialNumber, i2d_ASN1_INTEGER);
77 M_ASN1_I2D_len(a->signature, i2d_X509_ALGOR);
78 M_ASN1_I2D_len(a->issuer, i2d_X509_NAME);
79 M_ASN1_I2D_len(a->validity, i2d_X509_VAL);
80 M_ASN1_I2D_len(a->subject, i2d_X509_NAME);
81 M_ASN1_I2D_len(a->key, i2d_X509_PUBKEY);
82 M_ASN1_I2D_len_IMP_opt(a->issuerUID, i2d_ASN1_BIT_STRING);
83 M_ASN1_I2D_len_IMP_opt(a->subjectUID, i2d_ASN1_BIT_STRING);
84 M_ASN1_I2D_len_EXP_set_opt(a->extensions,i2d_X509_EXTENSION,3,V_ASN1_SEQUENCE,v2);
85
86 M_ASN1_I2D_seq_total();
87
88 M_ASN1_I2D_put_EXP_opt(a->version,i2d_ASN1_INTEGER,0,v1);
89 M_ASN1_I2D_put(a->serialNumber, i2d_ASN1_INTEGER);
90 M_ASN1_I2D_put(a->signature, i2d_X509_ALGOR);
91 M_ASN1_I2D_put(a->issuer, i2d_X509_NAME);
92 M_ASN1_I2D_put(a->validity, i2d_X509_VAL);
93 M_ASN1_I2D_put(a->subject, i2d_X509_NAME);
94 M_ASN1_I2D_put(a->key, i2d_X509_PUBKEY);
95 M_ASN1_I2D_put_IMP_opt(a->issuerUID, i2d_ASN1_BIT_STRING,1);
96 M_ASN1_I2D_put_IMP_opt(a->subjectUID, i2d_ASN1_BIT_STRING,2);
97 M_ASN1_I2D_put_EXP_set_opt(a->extensions,i2d_X509_EXTENSION,3,V_ASN1_SEQUENCE,v2);
98
99 M_ASN1_I2D_finish();
100 }
101
102X509_CINF *d2i_X509_CINF(a,pp,length)
103X509_CINF **a;
104unsigned char **pp;
105long length;
106 {
107 int ver=0;
108 M_ASN1_D2I_vars(a,X509_CINF *,X509_CINF_new);
109
110 M_ASN1_D2I_Init();
111 M_ASN1_D2I_start_sequence();
112 /* we have the optional version field */
113 if (M_ASN1_next == (V_ASN1_CONTEXT_SPECIFIC | V_ASN1_CONSTRUCTED | 0))
114 {
115 M_ASN1_D2I_get_EXP_opt(ret->version,d2i_ASN1_INTEGER,0);
116 if (ret->version->data != NULL)
117 ver=ret->version->data[0];
118 }
119 else
120 {
121 if (ret->version != NULL)
122 {
123 ASN1_INTEGER_free(ret->version);
124 ret->version=NULL;
125 }
126 }
127 M_ASN1_D2I_get(ret->serialNumber,d2i_ASN1_INTEGER);
128 M_ASN1_D2I_get(ret->signature,d2i_X509_ALGOR);
129 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
130 M_ASN1_D2I_get(ret->validity,d2i_X509_VAL);
131 M_ASN1_D2I_get(ret->subject,d2i_X509_NAME);
132 M_ASN1_D2I_get(ret->key,d2i_X509_PUBKEY);
133 if (ver >= 1) /* version 2 extensions */
134 {
135 if (ret->issuerUID != NULL)
136 {
137 ASN1_BIT_STRING_free(ret->issuerUID);
138 ret->issuerUID=NULL;
139 }
140 if (ret->subjectUID != NULL)
141 {
142 ASN1_BIT_STRING_free(ret->subjectUID);
143 ret->issuerUID=NULL;
144 }
145 M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1,
146 V_ASN1_BIT_STRING);
147 M_ASN1_D2I_get_IMP_opt(ret->subjectUID,d2i_ASN1_BIT_STRING, 2,
148 V_ASN1_BIT_STRING);
149 }
150 if (ver >= 2) /* version 3 extensions */
151 {
152 if (ret->extensions != NULL)
153 while (sk_num(ret->extensions))
154 X509_EXTENSION_free((X509_EXTENSION *)
155 sk_pop(ret->extensions));
156 M_ASN1_D2I_get_EXP_set_opt(ret->extensions,d2i_X509_EXTENSION,3,
157 V_ASN1_SEQUENCE);
158 }
159 M_ASN1_D2I_Finish(a,X509_CINF_free,ASN1_F_D2I_X509_CINF);
160 }
161
162X509_CINF *X509_CINF_new()
163 {
164 X509_CINF *ret=NULL;
165
166 M_ASN1_New_Malloc(ret,X509_CINF);
167 ret->version=NULL;
168 M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new);
169 M_ASN1_New(ret->signature,X509_ALGOR_new);
170 M_ASN1_New(ret->issuer,X509_NAME_new);
171 M_ASN1_New(ret->validity,X509_VAL_new);
172 M_ASN1_New(ret->subject,X509_NAME_new);
173 M_ASN1_New(ret->key,X509_PUBKEY_new);
174 ret->issuerUID=NULL;
175 ret->subjectUID=NULL;
176 ret->extensions=NULL;
177 return(ret);
178 M_ASN1_New_Error(ASN1_F_X509_CINF_NEW);
179 }
180
181void X509_CINF_free(a)
182X509_CINF *a;
183 {
184 if (a == NULL) return;
185 ASN1_INTEGER_free(a->version);
186 ASN1_INTEGER_free(a->serialNumber);
187 X509_ALGOR_free(a->signature);
188 X509_NAME_free(a->issuer);
189 X509_VAL_free(a->validity);
190 X509_NAME_free(a->subject);
191 X509_PUBKEY_free(a->key);
192 ASN1_BIT_STRING_free(a->issuerUID);
193 ASN1_BIT_STRING_free(a->subjectUID);
194 sk_pop_free(a->extensions,X509_EXTENSION_free);
195 Free((char *)a);
196 }
197
diff --git a/src/lib/libcrypto/bf/Makefile.ssl b/src/lib/libcrypto/bf/Makefile.ssl
new file mode 100644
index 0000000000..236671f238
--- /dev/null
+++ b/src/lib/libcrypto/bf/Makefile.ssl
@@ -0,0 +1,107 @@
1#
2# SSLeay/crypto/blowfish/Makefile
3#
4
5DIR= bf
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17BF_ENC= bf_enc.o
18# or use
19#DES_ENC= bx86-elf.o
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL=Makefile
24TEST=bftest.c
25APPS=
26
27LIB=$(TOP)/libcrypto.a
28LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c
29LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= blowfish.h
34HEADER= bf_pi.h bf_locl.h $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: lib
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 sh $(TOP)/util/ranlib.sh $(LIB)
46 @touch lib
47
48# elf
49asm/bx86-elf.o: asm/bx86unix.cpp
50 $(CPP) -DELF asm/bx86unix.cpp | as -o asm/bx86-elf.o
51
52# solaris
53asm/bx86-sol.o: asm/bx86unix.cpp
54 $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
55 as -o asm/bx86-sol.o asm/bx86-sol.s
56 rm -f asm/bx86-sol.s
57
58# a.out
59asm/bx86-out.o: asm/bx86unix.cpp
60 $(CPP) -DOUT asm/bx86unix.cpp | as -o asm/bx86-out.o
61
62# bsdi
63asm/bx86bsdi.o: asm/bx86unix.cpp
64 $(CPP) -DBSDI asm/bx86unix.cpp | as -o asm/bx86bsdi.o
65
66asm/bx86unix.cpp:
67 (cd asm; perl bf-586.pl cpp >bx86unix.cpp)
68
69files:
70 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
71
72links:
73 /bin/rm -f Makefile
74 $(TOP)/util/point.sh Makefile.ssl Makefile ;
75 $(TOP)/util/point.sh ../../doc/blowfish.doc blowfish.doc ;
76 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
77 $(TOP)/util/mklink.sh ../../test $(TEST)
78 $(TOP)/util/mklink.sh ../../apps $(APPS)
79
80install:
81 @for i in $(EXHEADER) ; \
82 do \
83 (cp $$i $(INSTALLTOP)/include/$$i; \
84 chmod 644 $(INSTALLTOP)/include/$$i ); \
85 done;
86
87tags:
88 ctags $(SRC)
89
90tests:
91
92lint:
93 lint -DLINT $(INCLUDES) $(SRC)>fluff
94
95depend:
96 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
97
98dclean:
99 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
100 mv -f Makefile.new $(MAKEFILE)
101
102clean:
103 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
104
105errors:
106
107# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/bf/Makefile.uni b/src/lib/libcrypto/bf/Makefile.uni
new file mode 100644
index 0000000000..9ba5b0c854
--- /dev/null
+++ b/src/lib/libcrypto/bf/Makefile.uni
@@ -0,0 +1,169 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= bf
11TOP= .
12# use BF_PTR2 for intel boxes,
13# BF_PTR for sparc and MIPS/SGI
14# use nothing for Alpha and HP.
15
16# There are 3 possible performance options, experiment :-)
17#OPTS= -DBF_PTR # usr for sparc and MIPS/SGI
18#OPTS= -DBF_PTR2 # use for pentium
19OPTS= # use for pentium pro, Alpha and HP
20
21MAKE=make -f Makefile
22#CC=cc
23#CFLAG= -O
24
25CC=gcc
26#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
27CFLAG= -O3 -fomit-frame-pointer
28
29CFLAGS=$(OPTS) $(CFLAG)
30CPP=$(CC) -E
31AS=as
32
33# Assember version of bf_encrypt().
34BF_ENC=bf_enc.o # normal C version
35#BF_ENC=asm/bx86-elf.o # elf format x86
36#BF_ENC=asm/bx86-out.o # a.out format x86
37#BF_ENC=asm/bx86-sol.o # solaris format x86
38#BF_ENC=asm/bx86bsdi.o # bsdi format x86
39
40LIBDIR=/usr/local/lib
41BINDIR=/usr/local/bin
42INCDIR=/usr/local/include
43MANDIR=/usr/local/man
44MAN1=1
45MAN3=3
46SHELL=/bin/sh
47LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o
48LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c
49
50GENERAL=Makefile Makefile.ssl Makefile.uni asm bf_locl.org README \
51 COPYRIGHT blowfish.doc INSTALL
52
53TESTING= bftest bfspeed bf_opts
54TESTING_SRC=bftest.c bfspeed.c bf_opts.c
55HEADERS=bf_locl.h blowfish.h bf_pi.h
56
57ALL= $(GENERAL) $(TESTING_SRC) $(LIBSRC) $(HEADERS)
58
59BLIB= libblowfish.a
60
61all: $(BLIB) $(TESTING)
62
63cc:
64 $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
65
66gcc:
67 $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
68
69x86-elf:
70 $(MAKE) BF_ENC='asm/bx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
71
72x86-out:
73 $(MAKE) BF_ENC='asm/bx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
74
75x86-solaris:
76 $(MAKE) BF_ENC='asm/bx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
77
78x86-bsdi:
79 $(MAKE) BF_ENC='asm/bx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
80
81# elf
82asm/bx86-elf.o: asm/bx86unix.cpp
83 $(CPP) -DELF asm/bx86unix.cpp | $(AS) -o asm/bx86-elf.o
84
85# solaris
86asm/bx86-sol.o: asm/bx86unix.cpp
87 $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
88 as -o asm/bx86-sol.o asm/bx86-sol.s
89 rm -f asm/bx86-sol.s
90
91# a.out
92asm/bx86-out.o: asm/bx86unix.cpp
93 $(CPP) -DOUT asm/bx86unix.cpp | $(AS) -o asm/bx86-out.o
94
95# bsdi
96asm/bx86bsdi.o: asm/bx86unix.cpp
97 $(CPP) -DBSDI asm/bx86unix.cpp | $(AS) -o asm/bx86bsdi.o
98
99asm/bx86unix.cpp:
100 (cd asm; perl bf-586.pl cpp >bx86unix.cpp)
101
102test: all
103 ./bftest
104
105$(BLIB): $(LIBOBJ)
106 /bin/rm -f $(BLIB)
107 ar cr $(BLIB) $(LIBOBJ)
108 -if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \
109 else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \
110 else exit 0; fi; fi
111
112bftest: bftest.o $(BLIB)
113 $(CC) $(CFLAGS) -o bftest bftest.o $(BLIB)
114
115bfspeed: bfspeed.o $(BLIB)
116 $(CC) $(CFLAGS) -o bfspeed bfspeed.o $(BLIB)
117
118bf_opts: bf_opts.o $(BLIB)
119 $(CC) $(CFLAGS) -o bf_opts bf_opts.o $(BLIB)
120
121tags:
122 ctags $(TESTING_SRC) $(LIBBF)
123
124tar:
125 tar chf libbf.tar $(ALL)
126
127shar:
128 shar $(ALL) >libbf.shar
129
130depend:
131 makedepend $(LIBBF) $(TESTING_SRC)
132
133clean:
134 /bin/rm -f *.o tags core $(TESTING) $(BLIB) .nfs* *.old *.bak asm/*.o
135
136dclean:
137 sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
138 mv -f Makefile.new Makefile
139
140# Eric is probably going to choke when he next looks at this --tjh
141install: $(BLIB)
142 if test $(INSTALLTOP); then \
143 echo SSL style install; \
144 cp $(BLIB) $(INSTALLTOP)/lib; \
145 if test -s /bin/ranlib; then \
146 /bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \
147 else \
148 if test -s /usr/bin/ranlib; then \
149 /usr/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \
150 fi; fi; \
151 chmod 644 $(INSTALLTOP)/lib/$(BLIB); \
152 cp blowfish.h $(INSTALLTOP)/include; \
153 chmod 644 $(INSTALLTOP)/include/blowfish.h; \
154 else \
155 echo Standalone install; \
156 cp $(BLIB) $(LIBDIR)/$(BLIB); \
157 if test -s /bin/ranlib; then \
158 /bin/ranlib $(LIBDIR)/$(BLIB); \
159 else \
160 if test -s /usr/bin/ranlib; then \
161 /usr/bin/ranlib $(LIBDIR)/$(BLIB); \
162 fi; \
163 fi; \
164 chmod 644 $(LIBDIR)/$(BLIB); \
165 cp blowfish.h $(INCDIR)/blowfish.h; \
166 chmod 644 $(INCDIR)/blowfish.h; \
167 fi
168
169# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/bf/asm/b-win32.asm b/src/lib/libcrypto/bf/asm/b-win32.asm
new file mode 100644
index 0000000000..138c99d0aa
--- /dev/null
+++ b/src/lib/libcrypto/bf/asm/b-win32.asm
@@ -0,0 +1,906 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by bf-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE bf-586.asm
8 .486
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _BF_encrypt
12
13_BF_encrypt PROC NEAR
14 ;
15 push ebp
16 push ebx
17 mov ebx, DWORD PTR 12[esp]
18 mov ebp, DWORD PTR 16[esp]
19 push esi
20 push edi
21 ; Load the 2 words
22 mov edi, DWORD PTR [ebx]
23 mov esi, DWORD PTR 4[ebx]
24 xor eax, eax
25 mov ebx, DWORD PTR [ebp]
26 xor ecx, ecx
27 xor edi, ebx
28 ;
29 ; Round 0
30 mov edx, DWORD PTR 4[ebp]
31 mov ebx, edi
32 xor esi, edx
33 shr ebx, 16
34 mov edx, edi
35 mov al, bh
36 and ebx, 255
37 mov cl, dh
38 and edx, 255
39 mov eax, DWORD PTR 72[eax*4+ebp]
40 mov ebx, DWORD PTR 1096[ebx*4+ebp]
41 add ebx, eax
42 mov eax, DWORD PTR 2120[ecx*4+ebp]
43 xor ebx, eax
44 mov edx, DWORD PTR 3144[edx*4+ebp]
45 add ebx, edx
46 xor eax, eax
47 xor esi, ebx
48 ;
49 ; Round 1
50 mov edx, DWORD PTR 8[ebp]
51 mov ebx, esi
52 xor edi, edx
53 shr ebx, 16
54 mov edx, esi
55 mov al, bh
56 and ebx, 255
57 mov cl, dh
58 and edx, 255
59 mov eax, DWORD PTR 72[eax*4+ebp]
60 mov ebx, DWORD PTR 1096[ebx*4+ebp]
61 add ebx, eax
62 mov eax, DWORD PTR 2120[ecx*4+ebp]
63 xor ebx, eax
64 mov edx, DWORD PTR 3144[edx*4+ebp]
65 add ebx, edx
66 xor eax, eax
67 xor edi, ebx
68 ;
69 ; Round 2
70 mov edx, DWORD PTR 12[ebp]
71 mov ebx, edi
72 xor esi, edx
73 shr ebx, 16
74 mov edx, edi
75 mov al, bh
76 and ebx, 255
77 mov cl, dh
78 and edx, 255
79 mov eax, DWORD PTR 72[eax*4+ebp]
80 mov ebx, DWORD PTR 1096[ebx*4+ebp]
81 add ebx, eax
82 mov eax, DWORD PTR 2120[ecx*4+ebp]
83 xor ebx, eax
84 mov edx, DWORD PTR 3144[edx*4+ebp]
85 add ebx, edx
86 xor eax, eax
87 xor esi, ebx
88 ;
89 ; Round 3
90 mov edx, DWORD PTR 16[ebp]
91 mov ebx, esi
92 xor edi, edx
93 shr ebx, 16
94 mov edx, esi
95 mov al, bh
96 and ebx, 255
97 mov cl, dh
98 and edx, 255
99 mov eax, DWORD PTR 72[eax*4+ebp]
100 mov ebx, DWORD PTR 1096[ebx*4+ebp]
101 add ebx, eax
102 mov eax, DWORD PTR 2120[ecx*4+ebp]
103 xor ebx, eax
104 mov edx, DWORD PTR 3144[edx*4+ebp]
105 add ebx, edx
106 xor eax, eax
107 xor edi, ebx
108 ;
109 ; Round 4
110 mov edx, DWORD PTR 20[ebp]
111 mov ebx, edi
112 xor esi, edx
113 shr ebx, 16
114 mov edx, edi
115 mov al, bh
116 and ebx, 255
117 mov cl, dh
118 and edx, 255
119 mov eax, DWORD PTR 72[eax*4+ebp]
120 mov ebx, DWORD PTR 1096[ebx*4+ebp]
121 add ebx, eax
122 mov eax, DWORD PTR 2120[ecx*4+ebp]
123 xor ebx, eax
124 mov edx, DWORD PTR 3144[edx*4+ebp]
125 add ebx, edx
126 xor eax, eax
127 xor esi, ebx
128 ;
129 ; Round 5
130 mov edx, DWORD PTR 24[ebp]
131 mov ebx, esi
132 xor edi, edx
133 shr ebx, 16
134 mov edx, esi
135 mov al, bh
136 and ebx, 255
137 mov cl, dh
138 and edx, 255
139 mov eax, DWORD PTR 72[eax*4+ebp]
140 mov ebx, DWORD PTR 1096[ebx*4+ebp]
141 add ebx, eax
142 mov eax, DWORD PTR 2120[ecx*4+ebp]
143 xor ebx, eax
144 mov edx, DWORD PTR 3144[edx*4+ebp]
145 add ebx, edx
146 xor eax, eax
147 xor edi, ebx
148 ;
149 ; Round 6
150 mov edx, DWORD PTR 28[ebp]
151 mov ebx, edi
152 xor esi, edx
153 shr ebx, 16
154 mov edx, edi
155 mov al, bh
156 and ebx, 255
157 mov cl, dh
158 and edx, 255
159 mov eax, DWORD PTR 72[eax*4+ebp]
160 mov ebx, DWORD PTR 1096[ebx*4+ebp]
161 add ebx, eax
162 mov eax, DWORD PTR 2120[ecx*4+ebp]
163 xor ebx, eax
164 mov edx, DWORD PTR 3144[edx*4+ebp]
165 add ebx, edx
166 xor eax, eax
167 xor esi, ebx
168 ;
169 ; Round 7
170 mov edx, DWORD PTR 32[ebp]
171 mov ebx, esi
172 xor edi, edx
173 shr ebx, 16
174 mov edx, esi
175 mov al, bh
176 and ebx, 255
177 mov cl, dh
178 and edx, 255
179 mov eax, DWORD PTR 72[eax*4+ebp]
180 mov ebx, DWORD PTR 1096[ebx*4+ebp]
181 add ebx, eax
182 mov eax, DWORD PTR 2120[ecx*4+ebp]
183 xor ebx, eax
184 mov edx, DWORD PTR 3144[edx*4+ebp]
185 add ebx, edx
186 xor eax, eax
187 xor edi, ebx
188 ;
189 ; Round 8
190 mov edx, DWORD PTR 36[ebp]
191 mov ebx, edi
192 xor esi, edx
193 shr ebx, 16
194 mov edx, edi
195 mov al, bh
196 and ebx, 255
197 mov cl, dh
198 and edx, 255
199 mov eax, DWORD PTR 72[eax*4+ebp]
200 mov ebx, DWORD PTR 1096[ebx*4+ebp]
201 add ebx, eax
202 mov eax, DWORD PTR 2120[ecx*4+ebp]
203 xor ebx, eax
204 mov edx, DWORD PTR 3144[edx*4+ebp]
205 add ebx, edx
206 xor eax, eax
207 xor esi, ebx
208 ;
209 ; Round 9
210 mov edx, DWORD PTR 40[ebp]
211 mov ebx, esi
212 xor edi, edx
213 shr ebx, 16
214 mov edx, esi
215 mov al, bh
216 and ebx, 255
217 mov cl, dh
218 and edx, 255
219 mov eax, DWORD PTR 72[eax*4+ebp]
220 mov ebx, DWORD PTR 1096[ebx*4+ebp]
221 add ebx, eax
222 mov eax, DWORD PTR 2120[ecx*4+ebp]
223 xor ebx, eax
224 mov edx, DWORD PTR 3144[edx*4+ebp]
225 add ebx, edx
226 xor eax, eax
227 xor edi, ebx
228 ;
229 ; Round 10
230 mov edx, DWORD PTR 44[ebp]
231 mov ebx, edi
232 xor esi, edx
233 shr ebx, 16
234 mov edx, edi
235 mov al, bh
236 and ebx, 255
237 mov cl, dh
238 and edx, 255
239 mov eax, DWORD PTR 72[eax*4+ebp]
240 mov ebx, DWORD PTR 1096[ebx*4+ebp]
241 add ebx, eax
242 mov eax, DWORD PTR 2120[ecx*4+ebp]
243 xor ebx, eax
244 mov edx, DWORD PTR 3144[edx*4+ebp]
245 add ebx, edx
246 xor eax, eax
247 xor esi, ebx
248 ;
249 ; Round 11
250 mov edx, DWORD PTR 48[ebp]
251 mov ebx, esi
252 xor edi, edx
253 shr ebx, 16
254 mov edx, esi
255 mov al, bh
256 and ebx, 255
257 mov cl, dh
258 and edx, 255
259 mov eax, DWORD PTR 72[eax*4+ebp]
260 mov ebx, DWORD PTR 1096[ebx*4+ebp]
261 add ebx, eax
262 mov eax, DWORD PTR 2120[ecx*4+ebp]
263 xor ebx, eax
264 mov edx, DWORD PTR 3144[edx*4+ebp]
265 add ebx, edx
266 xor eax, eax
267 xor edi, ebx
268 ;
269 ; Round 12
270 mov edx, DWORD PTR 52[ebp]
271 mov ebx, edi
272 xor esi, edx
273 shr ebx, 16
274 mov edx, edi
275 mov al, bh
276 and ebx, 255
277 mov cl, dh
278 and edx, 255
279 mov eax, DWORD PTR 72[eax*4+ebp]
280 mov ebx, DWORD PTR 1096[ebx*4+ebp]
281 add ebx, eax
282 mov eax, DWORD PTR 2120[ecx*4+ebp]
283 xor ebx, eax
284 mov edx, DWORD PTR 3144[edx*4+ebp]
285 add ebx, edx
286 xor eax, eax
287 xor esi, ebx
288 ;
289 ; Round 13
290 mov edx, DWORD PTR 56[ebp]
291 mov ebx, esi
292 xor edi, edx
293 shr ebx, 16
294 mov edx, esi
295 mov al, bh
296 and ebx, 255
297 mov cl, dh
298 and edx, 255
299 mov eax, DWORD PTR 72[eax*4+ebp]
300 mov ebx, DWORD PTR 1096[ebx*4+ebp]
301 add ebx, eax
302 mov eax, DWORD PTR 2120[ecx*4+ebp]
303 xor ebx, eax
304 mov edx, DWORD PTR 3144[edx*4+ebp]
305 add ebx, edx
306 xor eax, eax
307 xor edi, ebx
308 ;
309 ; Round 14
310 mov edx, DWORD PTR 60[ebp]
311 mov ebx, edi
312 xor esi, edx
313 shr ebx, 16
314 mov edx, edi
315 mov al, bh
316 and ebx, 255
317 mov cl, dh
318 and edx, 255
319 mov eax, DWORD PTR 72[eax*4+ebp]
320 mov ebx, DWORD PTR 1096[ebx*4+ebp]
321 add ebx, eax
322 mov eax, DWORD PTR 2120[ecx*4+ebp]
323 xor ebx, eax
324 mov edx, DWORD PTR 3144[edx*4+ebp]
325 add ebx, edx
326 xor eax, eax
327 xor esi, ebx
328 ;
329 ; Round 15
330 mov edx, DWORD PTR 64[ebp]
331 mov ebx, esi
332 xor edi, edx
333 shr ebx, 16
334 mov edx, esi
335 mov al, bh
336 and ebx, 255
337 mov cl, dh
338 and edx, 255
339 mov eax, DWORD PTR 72[eax*4+ebp]
340 mov ebx, DWORD PTR 1096[ebx*4+ebp]
341 add ebx, eax
342 mov eax, DWORD PTR 2120[ecx*4+ebp]
343 xor ebx, eax
344 mov edx, DWORD PTR 3144[edx*4+ebp]
345 add ebx, edx
346 ; Load parameter 0 (16) enc=1
347 mov eax, DWORD PTR 20[esp]
348 xor edi, ebx
349 mov edx, DWORD PTR 68[ebp]
350 xor esi, edx
351 mov DWORD PTR 4[eax],edi
352 mov DWORD PTR [eax],esi
353 pop edi
354 pop esi
355 pop ebx
356 pop ebp
357 ret
358_BF_encrypt ENDP
359_TEXT ENDS
360_TEXT SEGMENT
361PUBLIC _BF_decrypt
362
363_BF_decrypt PROC NEAR
364 ;
365 push ebp
366 push ebx
367 mov ebx, DWORD PTR 12[esp]
368 mov ebp, DWORD PTR 16[esp]
369 push esi
370 push edi
371 ; Load the 2 words
372 mov edi, DWORD PTR [ebx]
373 mov esi, DWORD PTR 4[ebx]
374 xor eax, eax
375 mov ebx, DWORD PTR 68[ebp]
376 xor ecx, ecx
377 xor edi, ebx
378 ;
379 ; Round 16
380 mov edx, DWORD PTR 64[ebp]
381 mov ebx, edi
382 xor esi, edx
383 shr ebx, 16
384 mov edx, edi
385 mov al, bh
386 and ebx, 255
387 mov cl, dh
388 and edx, 255
389 mov eax, DWORD PTR 72[eax*4+ebp]
390 mov ebx, DWORD PTR 1096[ebx*4+ebp]
391 add ebx, eax
392 mov eax, DWORD PTR 2120[ecx*4+ebp]
393 xor ebx, eax
394 mov edx, DWORD PTR 3144[edx*4+ebp]
395 add ebx, edx
396 xor eax, eax
397 xor esi, ebx
398 ;
399 ; Round 15
400 mov edx, DWORD PTR 60[ebp]
401 mov ebx, esi
402 xor edi, edx
403 shr ebx, 16
404 mov edx, esi
405 mov al, bh
406 and ebx, 255
407 mov cl, dh
408 and edx, 255
409 mov eax, DWORD PTR 72[eax*4+ebp]
410 mov ebx, DWORD PTR 1096[ebx*4+ebp]
411 add ebx, eax
412 mov eax, DWORD PTR 2120[ecx*4+ebp]
413 xor ebx, eax
414 mov edx, DWORD PTR 3144[edx*4+ebp]
415 add ebx, edx
416 xor eax, eax
417 xor edi, ebx
418 ;
419 ; Round 14
420 mov edx, DWORD PTR 56[ebp]
421 mov ebx, edi
422 xor esi, edx
423 shr ebx, 16
424 mov edx, edi
425 mov al, bh
426 and ebx, 255
427 mov cl, dh
428 and edx, 255
429 mov eax, DWORD PTR 72[eax*4+ebp]
430 mov ebx, DWORD PTR 1096[ebx*4+ebp]
431 add ebx, eax
432 mov eax, DWORD PTR 2120[ecx*4+ebp]
433 xor ebx, eax
434 mov edx, DWORD PTR 3144[edx*4+ebp]
435 add ebx, edx
436 xor eax, eax
437 xor esi, ebx
438 ;
439 ; Round 13
440 mov edx, DWORD PTR 52[ebp]
441 mov ebx, esi
442 xor edi, edx
443 shr ebx, 16
444 mov edx, esi
445 mov al, bh
446 and ebx, 255
447 mov cl, dh
448 and edx, 255
449 mov eax, DWORD PTR 72[eax*4+ebp]
450 mov ebx, DWORD PTR 1096[ebx*4+ebp]
451 add ebx, eax
452 mov eax, DWORD PTR 2120[ecx*4+ebp]
453 xor ebx, eax
454 mov edx, DWORD PTR 3144[edx*4+ebp]
455 add ebx, edx
456 xor eax, eax
457 xor edi, ebx
458 ;
459 ; Round 12
460 mov edx, DWORD PTR 48[ebp]
461 mov ebx, edi
462 xor esi, edx
463 shr ebx, 16
464 mov edx, edi
465 mov al, bh
466 and ebx, 255
467 mov cl, dh
468 and edx, 255
469 mov eax, DWORD PTR 72[eax*4+ebp]
470 mov ebx, DWORD PTR 1096[ebx*4+ebp]
471 add ebx, eax
472 mov eax, DWORD PTR 2120[ecx*4+ebp]
473 xor ebx, eax
474 mov edx, DWORD PTR 3144[edx*4+ebp]
475 add ebx, edx
476 xor eax, eax
477 xor esi, ebx
478 ;
479 ; Round 11
480 mov edx, DWORD PTR 44[ebp]
481 mov ebx, esi
482 xor edi, edx
483 shr ebx, 16
484 mov edx, esi
485 mov al, bh
486 and ebx, 255
487 mov cl, dh
488 and edx, 255
489 mov eax, DWORD PTR 72[eax*4+ebp]
490 mov ebx, DWORD PTR 1096[ebx*4+ebp]
491 add ebx, eax
492 mov eax, DWORD PTR 2120[ecx*4+ebp]
493 xor ebx, eax
494 mov edx, DWORD PTR 3144[edx*4+ebp]
495 add ebx, edx
496 xor eax, eax
497 xor edi, ebx
498 ;
499 ; Round 10
500 mov edx, DWORD PTR 40[ebp]
501 mov ebx, edi
502 xor esi, edx
503 shr ebx, 16
504 mov edx, edi
505 mov al, bh
506 and ebx, 255
507 mov cl, dh
508 and edx, 255
509 mov eax, DWORD PTR 72[eax*4+ebp]
510 mov ebx, DWORD PTR 1096[ebx*4+ebp]
511 add ebx, eax
512 mov eax, DWORD PTR 2120[ecx*4+ebp]
513 xor ebx, eax
514 mov edx, DWORD PTR 3144[edx*4+ebp]
515 add ebx, edx
516 xor eax, eax
517 xor esi, ebx
518 ;
519 ; Round 9
520 mov edx, DWORD PTR 36[ebp]
521 mov ebx, esi
522 xor edi, edx
523 shr ebx, 16
524 mov edx, esi
525 mov al, bh
526 and ebx, 255
527 mov cl, dh
528 and edx, 255
529 mov eax, DWORD PTR 72[eax*4+ebp]
530 mov ebx, DWORD PTR 1096[ebx*4+ebp]
531 add ebx, eax
532 mov eax, DWORD PTR 2120[ecx*4+ebp]
533 xor ebx, eax
534 mov edx, DWORD PTR 3144[edx*4+ebp]
535 add ebx, edx
536 xor eax, eax
537 xor edi, ebx
538 ;
539 ; Round 8
540 mov edx, DWORD PTR 32[ebp]
541 mov ebx, edi
542 xor esi, edx
543 shr ebx, 16
544 mov edx, edi
545 mov al, bh
546 and ebx, 255
547 mov cl, dh
548 and edx, 255
549 mov eax, DWORD PTR 72[eax*4+ebp]
550 mov ebx, DWORD PTR 1096[ebx*4+ebp]
551 add ebx, eax
552 mov eax, DWORD PTR 2120[ecx*4+ebp]
553 xor ebx, eax
554 mov edx, DWORD PTR 3144[edx*4+ebp]
555 add ebx, edx
556 xor eax, eax
557 xor esi, ebx
558 ;
559 ; Round 7
560 mov edx, DWORD PTR 28[ebp]
561 mov ebx, esi
562 xor edi, edx
563 shr ebx, 16
564 mov edx, esi
565 mov al, bh
566 and ebx, 255
567 mov cl, dh
568 and edx, 255
569 mov eax, DWORD PTR 72[eax*4+ebp]
570 mov ebx, DWORD PTR 1096[ebx*4+ebp]
571 add ebx, eax
572 mov eax, DWORD PTR 2120[ecx*4+ebp]
573 xor ebx, eax
574 mov edx, DWORD PTR 3144[edx*4+ebp]
575 add ebx, edx
576 xor eax, eax
577 xor edi, ebx
578 ;
579 ; Round 6
580 mov edx, DWORD PTR 24[ebp]
581 mov ebx, edi
582 xor esi, edx
583 shr ebx, 16
584 mov edx, edi
585 mov al, bh
586 and ebx, 255
587 mov cl, dh
588 and edx, 255
589 mov eax, DWORD PTR 72[eax*4+ebp]
590 mov ebx, DWORD PTR 1096[ebx*4+ebp]
591 add ebx, eax
592 mov eax, DWORD PTR 2120[ecx*4+ebp]
593 xor ebx, eax
594 mov edx, DWORD PTR 3144[edx*4+ebp]
595 add ebx, edx
596 xor eax, eax
597 xor esi, ebx
598 ;
599 ; Round 5
600 mov edx, DWORD PTR 20[ebp]
601 mov ebx, esi
602 xor edi, edx
603 shr ebx, 16
604 mov edx, esi
605 mov al, bh
606 and ebx, 255
607 mov cl, dh
608 and edx, 255
609 mov eax, DWORD PTR 72[eax*4+ebp]
610 mov ebx, DWORD PTR 1096[ebx*4+ebp]
611 add ebx, eax
612 mov eax, DWORD PTR 2120[ecx*4+ebp]
613 xor ebx, eax
614 mov edx, DWORD PTR 3144[edx*4+ebp]
615 add ebx, edx
616 xor eax, eax
617 xor edi, ebx
618 ;
619 ; Round 4
620 mov edx, DWORD PTR 16[ebp]
621 mov ebx, edi
622 xor esi, edx
623 shr ebx, 16
624 mov edx, edi
625 mov al, bh
626 and ebx, 255
627 mov cl, dh
628 and edx, 255
629 mov eax, DWORD PTR 72[eax*4+ebp]
630 mov ebx, DWORD PTR 1096[ebx*4+ebp]
631 add ebx, eax
632 mov eax, DWORD PTR 2120[ecx*4+ebp]
633 xor ebx, eax
634 mov edx, DWORD PTR 3144[edx*4+ebp]
635 add ebx, edx
636 xor eax, eax
637 xor esi, ebx
638 ;
639 ; Round 3
640 mov edx, DWORD PTR 12[ebp]
641 mov ebx, esi
642 xor edi, edx
643 shr ebx, 16
644 mov edx, esi
645 mov al, bh
646 and ebx, 255
647 mov cl, dh
648 and edx, 255
649 mov eax, DWORD PTR 72[eax*4+ebp]
650 mov ebx, DWORD PTR 1096[ebx*4+ebp]
651 add ebx, eax
652 mov eax, DWORD PTR 2120[ecx*4+ebp]
653 xor ebx, eax
654 mov edx, DWORD PTR 3144[edx*4+ebp]
655 add ebx, edx
656 xor eax, eax
657 xor edi, ebx
658 ;
659 ; Round 2
660 mov edx, DWORD PTR 8[ebp]
661 mov ebx, edi
662 xor esi, edx
663 shr ebx, 16
664 mov edx, edi
665 mov al, bh
666 and ebx, 255
667 mov cl, dh
668 and edx, 255
669 mov eax, DWORD PTR 72[eax*4+ebp]
670 mov ebx, DWORD PTR 1096[ebx*4+ebp]
671 add ebx, eax
672 mov eax, DWORD PTR 2120[ecx*4+ebp]
673 xor ebx, eax
674 mov edx, DWORD PTR 3144[edx*4+ebp]
675 add ebx, edx
676 xor eax, eax
677 xor esi, ebx
678 ;
679 ; Round 1
680 mov edx, DWORD PTR 4[ebp]
681 mov ebx, esi
682 xor edi, edx
683 shr ebx, 16
684 mov edx, esi
685 mov al, bh
686 and ebx, 255
687 mov cl, dh
688 and edx, 255
689 mov eax, DWORD PTR 72[eax*4+ebp]
690 mov ebx, DWORD PTR 1096[ebx*4+ebp]
691 add ebx, eax
692 mov eax, DWORD PTR 2120[ecx*4+ebp]
693 xor ebx, eax
694 mov edx, DWORD PTR 3144[edx*4+ebp]
695 add ebx, edx
696 ; Load parameter 0 (1) enc=0
697 mov eax, DWORD PTR 20[esp]
698 xor edi, ebx
699 mov edx, DWORD PTR [ebp]
700 xor esi, edx
701 mov DWORD PTR 4[eax],edi
702 mov DWORD PTR [eax],esi
703 pop edi
704 pop esi
705 pop ebx
706 pop ebp
707 ret
708_BF_decrypt ENDP
709_TEXT ENDS
710_TEXT SEGMENT
711PUBLIC _BF_cbc_encrypt
712
713_BF_cbc_encrypt PROC NEAR
714 ;
715 push ebp
716 push ebx
717 push esi
718 push edi
719 mov ebp, DWORD PTR 28[esp]
720 ; getting iv ptr from parameter 4
721 mov ebx, DWORD PTR 36[esp]
722 mov esi, DWORD PTR [ebx]
723 mov edi, DWORD PTR 4[ebx]
724 push edi
725 push esi
726 push edi
727 push esi
728 mov ebx, esp
729 mov esi, DWORD PTR 36[esp]
730 mov edi, DWORD PTR 40[esp]
731 ; getting encrypt flag from parameter 5
732 mov ecx, DWORD PTR 56[esp]
733 ; get and push parameter 3
734 mov eax, DWORD PTR 48[esp]
735 push eax
736 push ebx
737 cmp ecx, 0
738 jz $L000decrypt
739 and ebp, 4294967288
740 mov eax, DWORD PTR 8[esp]
741 mov ebx, DWORD PTR 12[esp]
742 jz $L001encrypt_finish
743L002encrypt_loop:
744 mov ecx, DWORD PTR [esi]
745 mov edx, DWORD PTR 4[esi]
746 xor eax, ecx
747 xor ebx, edx
748 bswap eax
749 bswap ebx
750 mov DWORD PTR 8[esp],eax
751 mov DWORD PTR 12[esp],ebx
752 call _BF_encrypt
753 mov eax, DWORD PTR 8[esp]
754 mov ebx, DWORD PTR 12[esp]
755 bswap eax
756 bswap ebx
757 mov DWORD PTR [edi],eax
758 mov DWORD PTR 4[edi],ebx
759 add esi, 8
760 add edi, 8
761 sub ebp, 8
762 jnz L002encrypt_loop
763$L001encrypt_finish:
764 mov ebp, DWORD PTR 52[esp]
765 and ebp, 7
766 jz $L003finish
767 xor ecx, ecx
768 xor edx, edx
769 mov ebp, DWORD PTR $L004cbc_enc_jmp_table[ebp*4]
770 jmp ebp
771L005ej7:
772 mov dh, BYTE PTR 6[esi]
773 shl edx, 8
774L006ej6:
775 mov dh, BYTE PTR 5[esi]
776L007ej5:
777 mov dl, BYTE PTR 4[esi]
778L008ej4:
779 mov ecx, DWORD PTR [esi]
780 jmp $L009ejend
781L010ej3:
782 mov ch, BYTE PTR 2[esi]
783 shl ecx, 8
784L011ej2:
785 mov ch, BYTE PTR 1[esi]
786L012ej1:
787 mov cl, BYTE PTR [esi]
788$L009ejend:
789 xor eax, ecx
790 xor ebx, edx
791 bswap eax
792 bswap ebx
793 mov DWORD PTR 8[esp],eax
794 mov DWORD PTR 12[esp],ebx
795 call _BF_encrypt
796 mov eax, DWORD PTR 8[esp]
797 mov ebx, DWORD PTR 12[esp]
798 bswap eax
799 bswap ebx
800 mov DWORD PTR [edi],eax
801 mov DWORD PTR 4[edi],ebx
802 jmp $L003finish
803$L000decrypt:
804 and ebp, 4294967288
805 mov eax, DWORD PTR 16[esp]
806 mov ebx, DWORD PTR 20[esp]
807 jz $L013decrypt_finish
808L014decrypt_loop:
809 mov eax, DWORD PTR [esi]
810 mov ebx, DWORD PTR 4[esi]
811 bswap eax
812 bswap ebx
813 mov DWORD PTR 8[esp],eax
814 mov DWORD PTR 12[esp],ebx
815 call _BF_decrypt
816 mov eax, DWORD PTR 8[esp]
817 mov ebx, DWORD PTR 12[esp]
818 bswap eax
819 bswap ebx
820 mov ecx, DWORD PTR 16[esp]
821 mov edx, DWORD PTR 20[esp]
822 xor ecx, eax
823 xor edx, ebx
824 mov eax, DWORD PTR [esi]
825 mov ebx, DWORD PTR 4[esi]
826 mov DWORD PTR [edi],ecx
827 mov DWORD PTR 4[edi],edx
828 mov DWORD PTR 16[esp],eax
829 mov DWORD PTR 20[esp],ebx
830 add esi, 8
831 add edi, 8
832 sub ebp, 8
833 jnz L014decrypt_loop
834$L013decrypt_finish:
835 mov ebp, DWORD PTR 52[esp]
836 and ebp, 7
837 jz $L003finish
838 mov eax, DWORD PTR [esi]
839 mov ebx, DWORD PTR 4[esi]
840 bswap eax
841 bswap ebx
842 mov DWORD PTR 8[esp],eax
843 mov DWORD PTR 12[esp],ebx
844 call _BF_decrypt
845 mov eax, DWORD PTR 8[esp]
846 mov ebx, DWORD PTR 12[esp]
847 bswap eax
848 bswap ebx
849 mov ecx, DWORD PTR 16[esp]
850 mov edx, DWORD PTR 20[esp]
851 xor ecx, eax
852 xor edx, ebx
853 mov eax, DWORD PTR [esi]
854 mov ebx, DWORD PTR 4[esi]
855L015dj7:
856 ror edx, 16
857 mov BYTE PTR 6[edi],dl
858 shr edx, 16
859L016dj6:
860 mov BYTE PTR 5[edi],dh
861L017dj5:
862 mov BYTE PTR 4[edi],dl
863L018dj4:
864 mov DWORD PTR [edi],ecx
865 jmp $L019djend
866L020dj3:
867 ror ecx, 16
868 mov BYTE PTR 2[edi],cl
869 shl ecx, 16
870L021dj2:
871 mov BYTE PTR 1[esi],ch
872L022dj1:
873 mov BYTE PTR [esi], cl
874$L019djend:
875 jmp $L003finish
876$L003finish:
877 mov ecx, DWORD PTR 60[esp]
878 add esp, 24
879 mov DWORD PTR [ecx],eax
880 mov DWORD PTR 4[ecx],ebx
881 pop edi
882 pop esi
883 pop ebx
884 pop ebp
885 ret
886$L004cbc_enc_jmp_table:
887 DD 0
888 DD L012ej1
889 DD L011ej2
890 DD L010ej3
891 DD L008ej4
892 DD L007ej5
893 DD L006ej6
894 DD L005ej7
895L023cbc_dec_jmp_table:
896 DD 0
897 DD L022dj1
898 DD L021dj2
899 DD L020dj3
900 DD L018dj4
901 DD L017dj5
902 DD L016dj6
903 DD L015dj7
904_BF_cbc_encrypt ENDP
905_TEXT ENDS
906END
diff --git a/src/lib/libcrypto/bf/asm/bx86unix.cpp b/src/lib/libcrypto/bf/asm/bx86unix.cpp
new file mode 100644
index 0000000000..cdaa269378
--- /dev/null
+++ b/src/lib/libcrypto/bf/asm/bx86unix.cpp
@@ -0,0 +1,976 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define BF_encrypt _BF_encrypt
13#define BF_decrypt _BF_decrypt
14#define BF_cbc_encrypt _BF_cbc_encrypt
15
16#endif
17
18#ifdef OUT
19#define OK 1
20#define ALIGN 4
21#endif
22
23#ifdef BSDI
24#define OK 1
25#define ALIGN 4
26#undef SIZE
27#undef TYPE
28#define SIZE(a,b)
29#define TYPE(a,b)
30#endif
31
32#if defined(ELF) || defined(SOL)
33#define OK 1
34#define ALIGN 16
35#endif
36
37#ifndef OK
38You need to define one of
39ELF - elf systems - linux-elf, NetBSD and DG-UX
40OUT - a.out systems - linux-a.out and FreeBSD
41SOL - solaris systems, which are elf with strange comment lines
42BSDI - a.out with a very primative version of as.
43#endif
44
45/* Let the Assembler begin :-) */
46 /* Don't even think of reading this code */
47 /* It was automatically generated by bf-586.pl */
48 /* Which is a perl program used to generate the x86 assember for */
49 /* any of elf, a.out, BSDI,Win32, or Solaris */
50 /* eric <eay@cryptsoft.com> */
51
52 .file "bf-586.s"
53 .version "01.01"
54gcc2_compiled.:
55.text
56 .align ALIGN
57.globl BF_encrypt
58 TYPE(BF_encrypt,@function)
59BF_encrypt:
60
61 pushl %ebp
62 pushl %ebx
63 movl 12(%esp), %ebx
64 movl 16(%esp), %ebp
65 pushl %esi
66 pushl %edi
67 /* Load the 2 words */
68 movl (%ebx), %edi
69 movl 4(%ebx), %esi
70 xorl %eax, %eax
71 movl (%ebp), %ebx
72 xorl %ecx, %ecx
73 xorl %ebx, %edi
74
75 /* Round 0 */
76 movl 4(%ebp), %edx
77 movl %edi, %ebx
78 xorl %edx, %esi
79 shrl $16, %ebx
80 movl %edi, %edx
81 movb %bh, %al
82 andl $255, %ebx
83 movb %dh, %cl
84 andl $255, %edx
85 movl 72(%ebp,%eax,4),%eax
86 movl 1096(%ebp,%ebx,4),%ebx
87 addl %eax, %ebx
88 movl 2120(%ebp,%ecx,4),%eax
89 xorl %eax, %ebx
90 movl 3144(%ebp,%edx,4),%edx
91 addl %edx, %ebx
92 xorl %eax, %eax
93 xorl %ebx, %esi
94
95 /* Round 1 */
96 movl 8(%ebp), %edx
97 movl %esi, %ebx
98 xorl %edx, %edi
99 shrl $16, %ebx
100 movl %esi, %edx
101 movb %bh, %al
102 andl $255, %ebx
103 movb %dh, %cl
104 andl $255, %edx
105 movl 72(%ebp,%eax,4),%eax
106 movl 1096(%ebp,%ebx,4),%ebx
107 addl %eax, %ebx
108 movl 2120(%ebp,%ecx,4),%eax
109 xorl %eax, %ebx
110 movl 3144(%ebp,%edx,4),%edx
111 addl %edx, %ebx
112 xorl %eax, %eax
113 xorl %ebx, %edi
114
115 /* Round 2 */
116 movl 12(%ebp), %edx
117 movl %edi, %ebx
118 xorl %edx, %esi
119 shrl $16, %ebx
120 movl %edi, %edx
121 movb %bh, %al
122 andl $255, %ebx
123 movb %dh, %cl
124 andl $255, %edx
125 movl 72(%ebp,%eax,4),%eax
126 movl 1096(%ebp,%ebx,4),%ebx
127 addl %eax, %ebx
128 movl 2120(%ebp,%ecx,4),%eax
129 xorl %eax, %ebx
130 movl 3144(%ebp,%edx,4),%edx
131 addl %edx, %ebx
132 xorl %eax, %eax
133 xorl %ebx, %esi
134
135 /* Round 3 */
136 movl 16(%ebp), %edx
137 movl %esi, %ebx
138 xorl %edx, %edi
139 shrl $16, %ebx
140 movl %esi, %edx
141 movb %bh, %al
142 andl $255, %ebx
143 movb %dh, %cl
144 andl $255, %edx
145 movl 72(%ebp,%eax,4),%eax
146 movl 1096(%ebp,%ebx,4),%ebx
147 addl %eax, %ebx
148 movl 2120(%ebp,%ecx,4),%eax
149 xorl %eax, %ebx
150 movl 3144(%ebp,%edx,4),%edx
151 addl %edx, %ebx
152 xorl %eax, %eax
153 xorl %ebx, %edi
154
155 /* Round 4 */
156 movl 20(%ebp), %edx
157 movl %edi, %ebx
158 xorl %edx, %esi
159 shrl $16, %ebx
160 movl %edi, %edx
161 movb %bh, %al
162 andl $255, %ebx
163 movb %dh, %cl
164 andl $255, %edx
165 movl 72(%ebp,%eax,4),%eax
166 movl 1096(%ebp,%ebx,4),%ebx
167 addl %eax, %ebx
168 movl 2120(%ebp,%ecx,4),%eax
169 xorl %eax, %ebx
170 movl 3144(%ebp,%edx,4),%edx
171 addl %edx, %ebx
172 xorl %eax, %eax
173 xorl %ebx, %esi
174
175 /* Round 5 */
176 movl 24(%ebp), %edx
177 movl %esi, %ebx
178 xorl %edx, %edi
179 shrl $16, %ebx
180 movl %esi, %edx
181 movb %bh, %al
182 andl $255, %ebx
183 movb %dh, %cl
184 andl $255, %edx
185 movl 72(%ebp,%eax,4),%eax
186 movl 1096(%ebp,%ebx,4),%ebx
187 addl %eax, %ebx
188 movl 2120(%ebp,%ecx,4),%eax
189 xorl %eax, %ebx
190 movl 3144(%ebp,%edx,4),%edx
191 addl %edx, %ebx
192 xorl %eax, %eax
193 xorl %ebx, %edi
194
195 /* Round 6 */
196 movl 28(%ebp), %edx
197 movl %edi, %ebx
198 xorl %edx, %esi
199 shrl $16, %ebx
200 movl %edi, %edx
201 movb %bh, %al
202 andl $255, %ebx
203 movb %dh, %cl
204 andl $255, %edx
205 movl 72(%ebp,%eax,4),%eax
206 movl 1096(%ebp,%ebx,4),%ebx
207 addl %eax, %ebx
208 movl 2120(%ebp,%ecx,4),%eax
209 xorl %eax, %ebx
210 movl 3144(%ebp,%edx,4),%edx
211 addl %edx, %ebx
212 xorl %eax, %eax
213 xorl %ebx, %esi
214
215 /* Round 7 */
216 movl 32(%ebp), %edx
217 movl %esi, %ebx
218 xorl %edx, %edi
219 shrl $16, %ebx
220 movl %esi, %edx
221 movb %bh, %al
222 andl $255, %ebx
223 movb %dh, %cl
224 andl $255, %edx
225 movl 72(%ebp,%eax,4),%eax
226 movl 1096(%ebp,%ebx,4),%ebx
227 addl %eax, %ebx
228 movl 2120(%ebp,%ecx,4),%eax
229 xorl %eax, %ebx
230 movl 3144(%ebp,%edx,4),%edx
231 addl %edx, %ebx
232 xorl %eax, %eax
233 xorl %ebx, %edi
234
235 /* Round 8 */
236 movl 36(%ebp), %edx
237 movl %edi, %ebx
238 xorl %edx, %esi
239 shrl $16, %ebx
240 movl %edi, %edx
241 movb %bh, %al
242 andl $255, %ebx
243 movb %dh, %cl
244 andl $255, %edx
245 movl 72(%ebp,%eax,4),%eax
246 movl 1096(%ebp,%ebx,4),%ebx
247 addl %eax, %ebx
248 movl 2120(%ebp,%ecx,4),%eax
249 xorl %eax, %ebx
250 movl 3144(%ebp,%edx,4),%edx
251 addl %edx, %ebx
252 xorl %eax, %eax
253 xorl %ebx, %esi
254
255 /* Round 9 */
256 movl 40(%ebp), %edx
257 movl %esi, %ebx
258 xorl %edx, %edi
259 shrl $16, %ebx
260 movl %esi, %edx
261 movb %bh, %al
262 andl $255, %ebx
263 movb %dh, %cl
264 andl $255, %edx
265 movl 72(%ebp,%eax,4),%eax
266 movl 1096(%ebp,%ebx,4),%ebx
267 addl %eax, %ebx
268 movl 2120(%ebp,%ecx,4),%eax
269 xorl %eax, %ebx
270 movl 3144(%ebp,%edx,4),%edx
271 addl %edx, %ebx
272 xorl %eax, %eax
273 xorl %ebx, %edi
274
275 /* Round 10 */
276 movl 44(%ebp), %edx
277 movl %edi, %ebx
278 xorl %edx, %esi
279 shrl $16, %ebx
280 movl %edi, %edx
281 movb %bh, %al
282 andl $255, %ebx
283 movb %dh, %cl
284 andl $255, %edx
285 movl 72(%ebp,%eax,4),%eax
286 movl 1096(%ebp,%ebx,4),%ebx
287 addl %eax, %ebx
288 movl 2120(%ebp,%ecx,4),%eax
289 xorl %eax, %ebx
290 movl 3144(%ebp,%edx,4),%edx
291 addl %edx, %ebx
292 xorl %eax, %eax
293 xorl %ebx, %esi
294
295 /* Round 11 */
296 movl 48(%ebp), %edx
297 movl %esi, %ebx
298 xorl %edx, %edi
299 shrl $16, %ebx
300 movl %esi, %edx
301 movb %bh, %al
302 andl $255, %ebx
303 movb %dh, %cl
304 andl $255, %edx
305 movl 72(%ebp,%eax,4),%eax
306 movl 1096(%ebp,%ebx,4),%ebx
307 addl %eax, %ebx
308 movl 2120(%ebp,%ecx,4),%eax
309 xorl %eax, %ebx
310 movl 3144(%ebp,%edx,4),%edx
311 addl %edx, %ebx
312 xorl %eax, %eax
313 xorl %ebx, %edi
314
315 /* Round 12 */
316 movl 52(%ebp), %edx
317 movl %edi, %ebx
318 xorl %edx, %esi
319 shrl $16, %ebx
320 movl %edi, %edx
321 movb %bh, %al
322 andl $255, %ebx
323 movb %dh, %cl
324 andl $255, %edx
325 movl 72(%ebp,%eax,4),%eax
326 movl 1096(%ebp,%ebx,4),%ebx
327 addl %eax, %ebx
328 movl 2120(%ebp,%ecx,4),%eax
329 xorl %eax, %ebx
330 movl 3144(%ebp,%edx,4),%edx
331 addl %edx, %ebx
332 xorl %eax, %eax
333 xorl %ebx, %esi
334
335 /* Round 13 */
336 movl 56(%ebp), %edx
337 movl %esi, %ebx
338 xorl %edx, %edi
339 shrl $16, %ebx
340 movl %esi, %edx
341 movb %bh, %al
342 andl $255, %ebx
343 movb %dh, %cl
344 andl $255, %edx
345 movl 72(%ebp,%eax,4),%eax
346 movl 1096(%ebp,%ebx,4),%ebx
347 addl %eax, %ebx
348 movl 2120(%ebp,%ecx,4),%eax
349 xorl %eax, %ebx
350 movl 3144(%ebp,%edx,4),%edx
351 addl %edx, %ebx
352 xorl %eax, %eax
353 xorl %ebx, %edi
354
355 /* Round 14 */
356 movl 60(%ebp), %edx
357 movl %edi, %ebx
358 xorl %edx, %esi
359 shrl $16, %ebx
360 movl %edi, %edx
361 movb %bh, %al
362 andl $255, %ebx
363 movb %dh, %cl
364 andl $255, %edx
365 movl 72(%ebp,%eax,4),%eax
366 movl 1096(%ebp,%ebx,4),%ebx
367 addl %eax, %ebx
368 movl 2120(%ebp,%ecx,4),%eax
369 xorl %eax, %ebx
370 movl 3144(%ebp,%edx,4),%edx
371 addl %edx, %ebx
372 xorl %eax, %eax
373 xorl %ebx, %esi
374
375 /* Round 15 */
376 movl 64(%ebp), %edx
377 movl %esi, %ebx
378 xorl %edx, %edi
379 shrl $16, %ebx
380 movl %esi, %edx
381 movb %bh, %al
382 andl $255, %ebx
383 movb %dh, %cl
384 andl $255, %edx
385 movl 72(%ebp,%eax,4),%eax
386 movl 1096(%ebp,%ebx,4),%ebx
387 addl %eax, %ebx
388 movl 2120(%ebp,%ecx,4),%eax
389 xorl %eax, %ebx
390 movl 3144(%ebp,%edx,4),%edx
391 addl %edx, %ebx
392 /* Load parameter 0 (16) enc=1 */
393 movl 20(%esp), %eax
394 xorl %ebx, %edi
395 movl 68(%ebp), %edx
396 xorl %edx, %esi
397 movl %edi, 4(%eax)
398 movl %esi, (%eax)
399 popl %edi
400 popl %esi
401 popl %ebx
402 popl %ebp
403 ret
404.BF_encrypt_end:
405 SIZE(BF_encrypt,.BF_encrypt_end-BF_encrypt)
406.ident "BF_encrypt"
407.text
408 .align ALIGN
409.globl BF_decrypt
410 TYPE(BF_decrypt,@function)
411BF_decrypt:
412
413 pushl %ebp
414 pushl %ebx
415 movl 12(%esp), %ebx
416 movl 16(%esp), %ebp
417 pushl %esi
418 pushl %edi
419 /* Load the 2 words */
420 movl (%ebx), %edi
421 movl 4(%ebx), %esi
422 xorl %eax, %eax
423 movl 68(%ebp), %ebx
424 xorl %ecx, %ecx
425 xorl %ebx, %edi
426
427 /* Round 16 */
428 movl 64(%ebp), %edx
429 movl %edi, %ebx
430 xorl %edx, %esi
431 shrl $16, %ebx
432 movl %edi, %edx
433 movb %bh, %al
434 andl $255, %ebx
435 movb %dh, %cl
436 andl $255, %edx
437 movl 72(%ebp,%eax,4),%eax
438 movl 1096(%ebp,%ebx,4),%ebx
439 addl %eax, %ebx
440 movl 2120(%ebp,%ecx,4),%eax
441 xorl %eax, %ebx
442 movl 3144(%ebp,%edx,4),%edx
443 addl %edx, %ebx
444 xorl %eax, %eax
445 xorl %ebx, %esi
446
447 /* Round 15 */
448 movl 60(%ebp), %edx
449 movl %esi, %ebx
450 xorl %edx, %edi
451 shrl $16, %ebx
452 movl %esi, %edx
453 movb %bh, %al
454 andl $255, %ebx
455 movb %dh, %cl
456 andl $255, %edx
457 movl 72(%ebp,%eax,4),%eax
458 movl 1096(%ebp,%ebx,4),%ebx
459 addl %eax, %ebx
460 movl 2120(%ebp,%ecx,4),%eax
461 xorl %eax, %ebx
462 movl 3144(%ebp,%edx,4),%edx
463 addl %edx, %ebx
464 xorl %eax, %eax
465 xorl %ebx, %edi
466
467 /* Round 14 */
468 movl 56(%ebp), %edx
469 movl %edi, %ebx
470 xorl %edx, %esi
471 shrl $16, %ebx
472 movl %edi, %edx
473 movb %bh, %al
474 andl $255, %ebx
475 movb %dh, %cl
476 andl $255, %edx
477 movl 72(%ebp,%eax,4),%eax
478 movl 1096(%ebp,%ebx,4),%ebx
479 addl %eax, %ebx
480 movl 2120(%ebp,%ecx,4),%eax
481 xorl %eax, %ebx
482 movl 3144(%ebp,%edx,4),%edx
483 addl %edx, %ebx
484 xorl %eax, %eax
485 xorl %ebx, %esi
486
487 /* Round 13 */
488 movl 52(%ebp), %edx
489 movl %esi, %ebx
490 xorl %edx, %edi
491 shrl $16, %ebx
492 movl %esi, %edx
493 movb %bh, %al
494 andl $255, %ebx
495 movb %dh, %cl
496 andl $255, %edx
497 movl 72(%ebp,%eax,4),%eax
498 movl 1096(%ebp,%ebx,4),%ebx
499 addl %eax, %ebx
500 movl 2120(%ebp,%ecx,4),%eax
501 xorl %eax, %ebx
502 movl 3144(%ebp,%edx,4),%edx
503 addl %edx, %ebx
504 xorl %eax, %eax
505 xorl %ebx, %edi
506
507 /* Round 12 */
508 movl 48(%ebp), %edx
509 movl %edi, %ebx
510 xorl %edx, %esi
511 shrl $16, %ebx
512 movl %edi, %edx
513 movb %bh, %al
514 andl $255, %ebx
515 movb %dh, %cl
516 andl $255, %edx
517 movl 72(%ebp,%eax,4),%eax
518 movl 1096(%ebp,%ebx,4),%ebx
519 addl %eax, %ebx
520 movl 2120(%ebp,%ecx,4),%eax
521 xorl %eax, %ebx
522 movl 3144(%ebp,%edx,4),%edx
523 addl %edx, %ebx
524 xorl %eax, %eax
525 xorl %ebx, %esi
526
527 /* Round 11 */
528 movl 44(%ebp), %edx
529 movl %esi, %ebx
530 xorl %edx, %edi
531 shrl $16, %ebx
532 movl %esi, %edx
533 movb %bh, %al
534 andl $255, %ebx
535 movb %dh, %cl
536 andl $255, %edx
537 movl 72(%ebp,%eax,4),%eax
538 movl 1096(%ebp,%ebx,4),%ebx
539 addl %eax, %ebx
540 movl 2120(%ebp,%ecx,4),%eax
541 xorl %eax, %ebx
542 movl 3144(%ebp,%edx,4),%edx
543 addl %edx, %ebx
544 xorl %eax, %eax
545 xorl %ebx, %edi
546
547 /* Round 10 */
548 movl 40(%ebp), %edx
549 movl %edi, %ebx
550 xorl %edx, %esi
551 shrl $16, %ebx
552 movl %edi, %edx
553 movb %bh, %al
554 andl $255, %ebx
555 movb %dh, %cl
556 andl $255, %edx
557 movl 72(%ebp,%eax,4),%eax
558 movl 1096(%ebp,%ebx,4),%ebx
559 addl %eax, %ebx
560 movl 2120(%ebp,%ecx,4),%eax
561 xorl %eax, %ebx
562 movl 3144(%ebp,%edx,4),%edx
563 addl %edx, %ebx
564 xorl %eax, %eax
565 xorl %ebx, %esi
566
567 /* Round 9 */
568 movl 36(%ebp), %edx
569 movl %esi, %ebx
570 xorl %edx, %edi
571 shrl $16, %ebx
572 movl %esi, %edx
573 movb %bh, %al
574 andl $255, %ebx
575 movb %dh, %cl
576 andl $255, %edx
577 movl 72(%ebp,%eax,4),%eax
578 movl 1096(%ebp,%ebx,4),%ebx
579 addl %eax, %ebx
580 movl 2120(%ebp,%ecx,4),%eax
581 xorl %eax, %ebx
582 movl 3144(%ebp,%edx,4),%edx
583 addl %edx, %ebx
584 xorl %eax, %eax
585 xorl %ebx, %edi
586
587 /* Round 8 */
588 movl 32(%ebp), %edx
589 movl %edi, %ebx
590 xorl %edx, %esi
591 shrl $16, %ebx
592 movl %edi, %edx
593 movb %bh, %al
594 andl $255, %ebx
595 movb %dh, %cl
596 andl $255, %edx
597 movl 72(%ebp,%eax,4),%eax
598 movl 1096(%ebp,%ebx,4),%ebx
599 addl %eax, %ebx
600 movl 2120(%ebp,%ecx,4),%eax
601 xorl %eax, %ebx
602 movl 3144(%ebp,%edx,4),%edx
603 addl %edx, %ebx
604 xorl %eax, %eax
605 xorl %ebx, %esi
606
607 /* Round 7 */
608 movl 28(%ebp), %edx
609 movl %esi, %ebx
610 xorl %edx, %edi
611 shrl $16, %ebx
612 movl %esi, %edx
613 movb %bh, %al
614 andl $255, %ebx
615 movb %dh, %cl
616 andl $255, %edx
617 movl 72(%ebp,%eax,4),%eax
618 movl 1096(%ebp,%ebx,4),%ebx
619 addl %eax, %ebx
620 movl 2120(%ebp,%ecx,4),%eax
621 xorl %eax, %ebx
622 movl 3144(%ebp,%edx,4),%edx
623 addl %edx, %ebx
624 xorl %eax, %eax
625 xorl %ebx, %edi
626
627 /* Round 6 */
628 movl 24(%ebp), %edx
629 movl %edi, %ebx
630 xorl %edx, %esi
631 shrl $16, %ebx
632 movl %edi, %edx
633 movb %bh, %al
634 andl $255, %ebx
635 movb %dh, %cl
636 andl $255, %edx
637 movl 72(%ebp,%eax,4),%eax
638 movl 1096(%ebp,%ebx,4),%ebx
639 addl %eax, %ebx
640 movl 2120(%ebp,%ecx,4),%eax
641 xorl %eax, %ebx
642 movl 3144(%ebp,%edx,4),%edx
643 addl %edx, %ebx
644 xorl %eax, %eax
645 xorl %ebx, %esi
646
647 /* Round 5 */
648 movl 20(%ebp), %edx
649 movl %esi, %ebx
650 xorl %edx, %edi
651 shrl $16, %ebx
652 movl %esi, %edx
653 movb %bh, %al
654 andl $255, %ebx
655 movb %dh, %cl
656 andl $255, %edx
657 movl 72(%ebp,%eax,4),%eax
658 movl 1096(%ebp,%ebx,4),%ebx
659 addl %eax, %ebx
660 movl 2120(%ebp,%ecx,4),%eax
661 xorl %eax, %ebx
662 movl 3144(%ebp,%edx,4),%edx
663 addl %edx, %ebx
664 xorl %eax, %eax
665 xorl %ebx, %edi
666
667 /* Round 4 */
668 movl 16(%ebp), %edx
669 movl %edi, %ebx
670 xorl %edx, %esi
671 shrl $16, %ebx
672 movl %edi, %edx
673 movb %bh, %al
674 andl $255, %ebx
675 movb %dh, %cl
676 andl $255, %edx
677 movl 72(%ebp,%eax,4),%eax
678 movl 1096(%ebp,%ebx,4),%ebx
679 addl %eax, %ebx
680 movl 2120(%ebp,%ecx,4),%eax
681 xorl %eax, %ebx
682 movl 3144(%ebp,%edx,4),%edx
683 addl %edx, %ebx
684 xorl %eax, %eax
685 xorl %ebx, %esi
686
687 /* Round 3 */
688 movl 12(%ebp), %edx
689 movl %esi, %ebx
690 xorl %edx, %edi
691 shrl $16, %ebx
692 movl %esi, %edx
693 movb %bh, %al
694 andl $255, %ebx
695 movb %dh, %cl
696 andl $255, %edx
697 movl 72(%ebp,%eax,4),%eax
698 movl 1096(%ebp,%ebx,4),%ebx
699 addl %eax, %ebx
700 movl 2120(%ebp,%ecx,4),%eax
701 xorl %eax, %ebx
702 movl 3144(%ebp,%edx,4),%edx
703 addl %edx, %ebx
704 xorl %eax, %eax
705 xorl %ebx, %edi
706
707 /* Round 2 */
708 movl 8(%ebp), %edx
709 movl %edi, %ebx
710 xorl %edx, %esi
711 shrl $16, %ebx
712 movl %edi, %edx
713 movb %bh, %al
714 andl $255, %ebx
715 movb %dh, %cl
716 andl $255, %edx
717 movl 72(%ebp,%eax,4),%eax
718 movl 1096(%ebp,%ebx,4),%ebx
719 addl %eax, %ebx
720 movl 2120(%ebp,%ecx,4),%eax
721 xorl %eax, %ebx
722 movl 3144(%ebp,%edx,4),%edx
723 addl %edx, %ebx
724 xorl %eax, %eax
725 xorl %ebx, %esi
726
727 /* Round 1 */
728 movl 4(%ebp), %edx
729 movl %esi, %ebx
730 xorl %edx, %edi
731 shrl $16, %ebx
732 movl %esi, %edx
733 movb %bh, %al
734 andl $255, %ebx
735 movb %dh, %cl
736 andl $255, %edx
737 movl 72(%ebp,%eax,4),%eax
738 movl 1096(%ebp,%ebx,4),%ebx
739 addl %eax, %ebx
740 movl 2120(%ebp,%ecx,4),%eax
741 xorl %eax, %ebx
742 movl 3144(%ebp,%edx,4),%edx
743 addl %edx, %ebx
744 /* Load parameter 0 (1) enc=0 */
745 movl 20(%esp), %eax
746 xorl %ebx, %edi
747 movl (%ebp), %edx
748 xorl %edx, %esi
749 movl %edi, 4(%eax)
750 movl %esi, (%eax)
751 popl %edi
752 popl %esi
753 popl %ebx
754 popl %ebp
755 ret
756.BF_decrypt_end:
757 SIZE(BF_decrypt,.BF_decrypt_end-BF_decrypt)
758.ident "BF_decrypt"
759.text
760 .align ALIGN
761.globl BF_cbc_encrypt
762 TYPE(BF_cbc_encrypt,@function)
763BF_cbc_encrypt:
764
765 pushl %ebp
766 pushl %ebx
767 pushl %esi
768 pushl %edi
769 movl 28(%esp), %ebp
770 /* getting iv ptr from parameter 4 */
771 movl 36(%esp), %ebx
772 movl (%ebx), %esi
773 movl 4(%ebx), %edi
774 pushl %edi
775 pushl %esi
776 pushl %edi
777 pushl %esi
778 movl %esp, %ebx
779 movl 36(%esp), %esi
780 movl 40(%esp), %edi
781 /* getting encrypt flag from parameter 5 */
782 movl 56(%esp), %ecx
783 /* get and push parameter 3 */
784 movl 48(%esp), %eax
785 pushl %eax
786 pushl %ebx
787 cmpl $0, %ecx
788 jz .L000decrypt
789 andl $4294967288, %ebp
790 movl 8(%esp), %eax
791 movl 12(%esp), %ebx
792 jz .L001encrypt_finish
793.L002encrypt_loop:
794 movl (%esi), %ecx
795 movl 4(%esi), %edx
796 xorl %ecx, %eax
797 xorl %edx, %ebx
798.byte 15
799.byte 200 /* bswapl %eax */
800.byte 15
801.byte 203 /* bswapl %ebx */
802 movl %eax, 8(%esp)
803 movl %ebx, 12(%esp)
804 call BF_encrypt
805 movl 8(%esp), %eax
806 movl 12(%esp), %ebx
807.byte 15
808.byte 200 /* bswapl %eax */
809.byte 15
810.byte 203 /* bswapl %ebx */
811 movl %eax, (%edi)
812 movl %ebx, 4(%edi)
813 addl $8, %esi
814 addl $8, %edi
815 subl $8, %ebp
816 jnz .L002encrypt_loop
817.L001encrypt_finish:
818 movl 52(%esp), %ebp
819 andl $7, %ebp
820 jz .L003finish
821 xorl %ecx, %ecx
822 xorl %edx, %edx
823 movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp
824 jmp *%ebp
825.L005ej7:
826 movb 6(%esi), %dh
827 sall $8, %edx
828.L006ej6:
829 movb 5(%esi), %dh
830.L007ej5:
831 movb 4(%esi), %dl
832.L008ej4:
833 movl (%esi), %ecx
834 jmp .L009ejend
835.L010ej3:
836 movb 2(%esi), %ch
837 sall $8, %ecx
838.L011ej2:
839 movb 1(%esi), %ch
840.L012ej1:
841 movb (%esi), %cl
842.L009ejend:
843 xorl %ecx, %eax
844 xorl %edx, %ebx
845.byte 15
846.byte 200 /* bswapl %eax */
847.byte 15
848.byte 203 /* bswapl %ebx */
849 movl %eax, 8(%esp)
850 movl %ebx, 12(%esp)
851 call BF_encrypt
852 movl 8(%esp), %eax
853 movl 12(%esp), %ebx
854.byte 15
855.byte 200 /* bswapl %eax */
856.byte 15
857.byte 203 /* bswapl %ebx */
858 movl %eax, (%edi)
859 movl %ebx, 4(%edi)
860 jmp .L003finish
861.align ALIGN
862.L000decrypt:
863 andl $4294967288, %ebp
864 movl 16(%esp), %eax
865 movl 20(%esp), %ebx
866 jz .L013decrypt_finish
867.L014decrypt_loop:
868 movl (%esi), %eax
869 movl 4(%esi), %ebx
870.byte 15
871.byte 200 /* bswapl %eax */
872.byte 15
873.byte 203 /* bswapl %ebx */
874 movl %eax, 8(%esp)
875 movl %ebx, 12(%esp)
876 call BF_decrypt
877 movl 8(%esp), %eax
878 movl 12(%esp), %ebx
879.byte 15
880.byte 200 /* bswapl %eax */
881.byte 15
882.byte 203 /* bswapl %ebx */
883 movl 16(%esp), %ecx
884 movl 20(%esp), %edx
885 xorl %eax, %ecx
886 xorl %ebx, %edx
887 movl (%esi), %eax
888 movl 4(%esi), %ebx
889 movl %ecx, (%edi)
890 movl %edx, 4(%edi)
891 movl %eax, 16(%esp)
892 movl %ebx, 20(%esp)
893 addl $8, %esi
894 addl $8, %edi
895 subl $8, %ebp
896 jnz .L014decrypt_loop
897.L013decrypt_finish:
898 movl 52(%esp), %ebp
899 andl $7, %ebp
900 jz .L003finish
901 movl (%esi), %eax
902 movl 4(%esi), %ebx
903.byte 15
904.byte 200 /* bswapl %eax */
905.byte 15
906.byte 203 /* bswapl %ebx */
907 movl %eax, 8(%esp)
908 movl %ebx, 12(%esp)
909 call BF_decrypt
910 movl 8(%esp), %eax
911 movl 12(%esp), %ebx
912.byte 15
913.byte 200 /* bswapl %eax */
914.byte 15
915.byte 203 /* bswapl %ebx */
916 movl 16(%esp), %ecx
917 movl 20(%esp), %edx
918 xorl %eax, %ecx
919 xorl %ebx, %edx
920 movl (%esi), %eax
921 movl 4(%esi), %ebx
922.L015dj7:
923 rorl $16, %edx
924 movb %dl, 6(%edi)
925 shrl $16, %edx
926.L016dj6:
927 movb %dh, 5(%edi)
928.L017dj5:
929 movb %dl, 4(%edi)
930.L018dj4:
931 movl %ecx, (%edi)
932 jmp .L019djend
933.L020dj3:
934 rorl $16, %ecx
935 movb %cl, 2(%edi)
936 sall $16, %ecx
937.L021dj2:
938 movb %ch, 1(%esi)
939.L022dj1:
940 movb %cl, (%esi)
941.L019djend:
942 jmp .L003finish
943.align ALIGN
944.L003finish:
945 movl 60(%esp), %ecx
946 addl $24, %esp
947 movl %eax, (%ecx)
948 movl %ebx, 4(%ecx)
949 popl %edi
950 popl %esi
951 popl %ebx
952 popl %ebp
953 ret
954.align ALIGN
955.L004cbc_enc_jmp_table:
956 .long 0
957 .long .L012ej1
958 .long .L011ej2
959 .long .L010ej3
960 .long .L008ej4
961 .long .L007ej5
962 .long .L006ej6
963 .long .L005ej7
964.align ALIGN
965.L023cbc_dec_jmp_table:
966 .long 0
967 .long .L022dj1
968 .long .L021dj2
969 .long .L020dj3
970 .long .L018dj4
971 .long .L017dj5
972 .long .L016dj6
973 .long .L015dj7
974.BF_cbc_encrypt_end:
975 SIZE(BF_cbc_encrypt,.BF_cbc_encrypt_end-BF_cbc_encrypt)
976.ident "desasm.pl"
diff --git a/src/lib/libcrypto/bf/bf_locl.org b/src/lib/libcrypto/bf/bf_locl.org
new file mode 100644
index 0000000000..a5663de8ca
--- /dev/null
+++ b/src/lib/libcrypto/bf/bf_locl.org
@@ -0,0 +1,242 @@
1/* crypto/bf/bf_locl.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify bf_locl.org since bf_locl.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67/* Special defines which change the way the code is built depending on the
68 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
69 even newer MIPS CPU's, but at the moment one size fits all for
70 optimization options. Older Sparc's work better with only UNROLL, but
71 there's no way to tell at compile time what it is you're running on */
72
73#if defined( sun ) /* Newer Sparc's */
74# define BF_PTR
75#elif defined( __ultrix ) /* Older MIPS */
76# define BF_PTR
77#elif defined( __osf1__ ) /* Alpha */
78 /* None */
79#elif defined ( _AIX ) /* RS6000 */
80 /* Unknown */
81#elif defined( __hpux ) /* HP-PA */
82 /* None */
83#elif defined( __aux ) /* 68K */
84 /* Unknown */
85#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
86 /* Unknown */
87#elif defined( __sgi ) /* Newer MIPS */
88# define BF_PTR
89#elif defined( i386 ) /* x86 boxes, should be gcc */
90#elif defined( _MSC_VER ) /* x86 boxes, Visual C */
91#endif /* Systems-specific speed defines */
92
93#undef c2l
94#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
95 l|=((unsigned long)(*((c)++)))<< 8L, \
96 l|=((unsigned long)(*((c)++)))<<16L, \
97 l|=((unsigned long)(*((c)++)))<<24L)
98
99/* NOTE - c is not incremented as per c2l */
100#undef c2ln
101#define c2ln(c,l1,l2,n) { \
102 c+=n; \
103 l1=l2=0; \
104 switch (n) { \
105 case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
106 case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
107 case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
108 case 5: l2|=((unsigned long)(*(--(c)))); \
109 case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
110 case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
111 case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
112 case 1: l1|=((unsigned long)(*(--(c)))); \
113 } \
114 }
115
116#undef l2c
117#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
118 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
119 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
120 *((c)++)=(unsigned char)(((l)>>24L)&0xff))
121
122/* NOTE - c is not incremented as per l2c */
123#undef l2cn
124#define l2cn(l1,l2,c,n) { \
125 c+=n; \
126 switch (n) { \
127 case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
128 case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
129 case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
130 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
131 case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
132 case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
133 case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
134 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
135 } \
136 }
137
138/* NOTE - c is not incremented as per n2l */
139#define n2ln(c,l1,l2,n) { \
140 c+=n; \
141 l1=l2=0; \
142 switch (n) { \
143 case 8: l2 =((unsigned long)(*(--(c)))) ; \
144 case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
145 case 6: l2|=((unsigned long)(*(--(c))))<<16; \
146 case 5: l2|=((unsigned long)(*(--(c))))<<24; \
147 case 4: l1 =((unsigned long)(*(--(c)))) ; \
148 case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
149 case 2: l1|=((unsigned long)(*(--(c))))<<16; \
150 case 1: l1|=((unsigned long)(*(--(c))))<<24; \
151 } \
152 }
153
154/* NOTE - c is not incremented as per l2n */
155#define l2nn(l1,l2,c,n) { \
156 c+=n; \
157 switch (n) { \
158 case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
159 case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
160 case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
161 case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
162 case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
163 case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
164 case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
165 case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
166 } \
167 }
168
169#undef n2l
170#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
171 l|=((unsigned long)(*((c)++)))<<16L, \
172 l|=((unsigned long)(*((c)++)))<< 8L, \
173 l|=((unsigned long)(*((c)++))))
174
175#undef l2n
176#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
177 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
178 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
179 *((c)++)=(unsigned char)(((l) )&0xff))
180
181/* This is actually a big endian algorithm, the most significate byte
182 * is used to lookup array 0 */
183
184/* use BF_PTR2 for intel boxes,
185 * BF_PTR for sparc and MIPS/SGI
186 * use nothing for Alpha and HP.
187 */
188#if !defined(BF_PTR) && !defined(BF_PTR2)
189#undef BF_PTR
190#endif
191
192#define BF_M 0x3fc
193#define BF_0 22L
194#define BF_1 14L
195#define BF_2 6L
196#define BF_3 2L /* left shift */
197
198#if defined(BF_PTR2)
199
200/* This is basically a special pentium verson */
201#define BF_ENC(LL,R,S,P) \
202 { \
203 BF_LONG t,u,v; \
204 u=R>>BF_0; \
205 v=R>>BF_1; \
206 u&=BF_M; \
207 v&=BF_M; \
208 t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \
209 u=R>>BF_2; \
210 t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \
211 v=R<<BF_3; \
212 u&=BF_M; \
213 v&=BF_M; \
214 t^= *(BF_LONG *)((unsigned char *)&(S[512])+u); \
215 LL^=P; \
216 t+= *(BF_LONG *)((unsigned char *)&(S[768])+v); \
217 LL^=t; \
218 }
219
220#elif defined(BF_PTR)
221
222/* This is normally very good */
223
224#define BF_ENC(LL,R,S,P) \
225 LL^=P; \
226 LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
227 *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
228 *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
229 *(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M)));
230#else
231
232/* This will always work, even on 64 bit machines and strangly enough,
233 * on the Alpha it is faster than the pointer versions (both 32 and 64
234 * versions of BF_LONG) */
235
236#define BF_ENC(LL,R,S,P) \
237 LL^=P; \
238 LL^=((( S[ (int)(R>>24L) ] + \
239 S[0x0100+((int)(R>>16L)&0xff)])^ \
240 S[0x0200+((int)(R>> 8L)&0xff)])+ \
241 S[0x0300+((int)(R )&0xff)])&0xffffffffL;
242#endif
diff --git a/src/lib/libcrypto/bio/Makefile.ssl b/src/lib/libcrypto/bio/Makefile.ssl
new file mode 100644
index 0000000000..42e11e1c94
--- /dev/null
+++ b/src/lib/libcrypto/bio/Makefile.ssl
@@ -0,0 +1,92 @@
1#
2# SSLeay/crypto/bio/Makefile
3#
4
5DIR= bio
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=bio
19ERRC=bio_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= bio_lib.c bio_cb.c $(ERRC).c \
26 bss_mem.c bss_null.c bss_fd.c \
27 bss_file.c bss_sock.c bss_conn.c \
28 bf_null.c bf_buff.c b_print.c b_dump.c \
29 b_sock.c bss_acpt.c bf_nbio.c
30LIBOBJ= bio_lib.o bio_cb.o $(ERRC).o \
31 bss_mem.o bss_null.o bss_fd.o \
32 bss_file.o bss_sock.o bss_conn.o \
33 bf_null.o bf_buff.o b_print.o b_dump.o \
34 b_sock.o bss_acpt.o bf_nbio.o
35
36SRC= $(LIBSRC)
37
38EXHEADER= bio.h bss_file.c
39HEADER= $(EXHEADER)
40
41ALL= $(GENERAL) $(SRC) $(HEADER)
42
43top:
44 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
45
46all: lib
47
48lib: $(LIBOBJ)
49 $(AR) $(LIB) $(LIBOBJ)
50 sh $(TOP)/util/ranlib.sh $(LIB)
51 @touch lib
52
53files:
54 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
55
56links:
57 /bin/rm -f Makefile
58 $(TOP)/util/point.sh Makefile.ssl Makefile;
59 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
60 $(TOP)/util/mklink.sh ../../test $(TEST)
61 $(TOP)/util/mklink.sh ../../apps $(APPS)
62
63install:
64 @for i in $(EXHEADER) bss_file.c ; \
65 do \
66 (cp $$i $(INSTALLTOP)/include/$$i; \
67 chmod 644 $(INSTALLTOP)/include/$$i ); \
68 done;
69
70tags:
71 ctags $(SRC)
72
73tests:
74
75lint:
76 lint -DLINT $(INCLUDES) $(SRC)>fluff
77
78depend:
79 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
80
81dclean:
82 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
83 mv -f Makefile.new $(MAKEFILE)
84
85clean:
86 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
87
88errors:
89 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
90 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
91
92# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/bio/bio.err b/src/lib/libcrypto/bio/bio.err
new file mode 100644
index 0000000000..6e2f2b63ca
--- /dev/null
+++ b/src/lib/libcrypto/bio/bio.err
@@ -0,0 +1,46 @@
1/* Error codes for the BIO functions. */
2
3/* Function codes. */
4#define BIO_F_ACPT_STATE 100
5#define BIO_F_BIO_ACCEPT 101
6#define BIO_F_BIO_CTRL 102
7#define BIO_F_BIO_GETS 103
8#define BIO_F_BIO_GET_ACCEPT_SOCKET 104
9#define BIO_F_BIO_GET_HOST_IP 105
10#define BIO_F_BIO_GET_PORT 106
11#define BIO_F_BIO_NEW 107
12#define BIO_F_BIO_NEW_FILE 108
13#define BIO_F_BIO_PUTS 109
14#define BIO_F_BIO_READ 110
15#define BIO_F_BIO_SOCK_INIT 111
16#define BIO_F_BIO_WRITE 112
17#define BIO_F_BUFFER_CTRL 113
18#define BIO_F_CONN_STATE 114
19#define BIO_F_FILE_CTRL 115
20#define BIO_F_MEM_WRITE 116
21#define BIO_F_SSL_NEW 117
22#define BIO_F_WSASTARTUP 118
23
24/* Reason codes. */
25#define BIO_R_ACCEPT_ERROR 100
26#define BIO_R_BAD_FOPEN_MODE 101
27#define BIO_R_BAD_HOSTNAME_LOOKUP 102
28#define BIO_R_CONNECT_ERROR 103
29#define BIO_R_ERROR_SETTING_NBIO 104
30#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105
31#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106
32#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107
33#define BIO_R_INVALID_IP_ADDRESS 108
34#define BIO_R_KEEPALIVE 109
35#define BIO_R_NBIO_CONNECT_ERROR 110
36#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111
37#define BIO_R_NO_HOSTHNAME_SPECIFIED 112
38#define BIO_R_NO_PORT_DEFINED 113
39#define BIO_R_NO_PORT_SPECIFIED 114
40#define BIO_R_NULL_PARAMETER 115
41#define BIO_R_UNABLE_TO_BIND_SOCKET 116
42#define BIO_R_UNABLE_TO_CREATE_SOCKET 117
43#define BIO_R_UNABLE_TO_LISTEN_SOCKET 118
44#define BIO_R_UNINITALISED 119
45#define BIO_R_UNSUPPORTED_METHOD 120
46#define BIO_R_WSASTARTUP 121
diff --git a/src/lib/libcrypto/bn/Makefile.ssl b/src/lib/libcrypto/bn/Makefile.ssl
new file mode 100644
index 0000000000..9809d26cbc
--- /dev/null
+++ b/src/lib/libcrypto/bn/Makefile.ssl
@@ -0,0 +1,133 @@
1#
2# SSLeay/crypto/bn/Makefile
3#
4
5DIR= bn
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16BN_MULW= bn_mulw.o
17# or use
18#BN_MULW= bn86-elf.o
19
20CFLAGS= $(INCLUDES) $(CFLAG)
21
22ERR=bn
23ERRC=bn_err
24GENERAL=Makefile
25TEST=bntest.c exptest.c
26APPS=
27
28LIB=$(TOP)/libcrypto.a
29LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c \
30 bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c \
31 bn_gcd.c bn_prime.c $(ERRC).c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c \
32 bn_mpi.c
33
34LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_mod.o bn_mul.o \
35 bn_print.o bn_rand.o bn_shift.o bn_sub.o bn_word.o bn_blind.o \
36 bn_gcd.o bn_prime.o $(ERRC).o bn_sqr.o $(BN_MULW) bn_recp.o bn_mont.o \
37 bn_mpi.o
38
39
40SRC= $(LIBSRC)
41
42EXHEADER= bn.h
43HEADER= bn_lcl.h bn_prime.h $(EXHEADER)
44
45ALL= $(GENERAL) $(SRC) $(HEADER)
46
47top:
48 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
49
50all: lib
51
52knuth: bn_knuth.c
53 cc -pg -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a
54
55knuth.fast: bn_knuth.c
56 cc -pg -fast -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a
57
58
59lib: $(LIBOBJ)
60 $(AR) $(LIB) $(LIBOBJ)
61 sh $(TOP)/util/ranlib.sh $(LIB)
62 @touch lib
63
64# elf
65asm/bn86-elf.o: asm/bn86unix.cpp
66 $(CPP) -DELF asm/bn86unix.cpp | as -o asm/bn86-elf.o
67
68# solaris
69asm/bn86-sol.o: asm/bn86unix.cpp
70 $(CC) -E -DSOL asm/bn86unix.cpp | sed 's/^#.*//' > asm/bn86-sol.s
71 as -o asm/bn86-sol.o asm/bn86-sol.s
72 rm -f asm/bn86-sol.s
73
74# a.out
75asm/bn86-out.o: asm/bn86unix.cpp
76 $(CPP) -DOUT asm/bn86unix.cpp | as -o asm/bn86-out.o
77
78# bsdi
79asm/bn86bsdi.o: asm/bn86unix.cpp
80 $(CPP) -DBSDI asm/bn86unix.cpp | as -o asm/bn86bsdi.o
81
82asm/bn86unix.cpp:
83 (cd asm; perl bn-586.pl cpp >bn86unix.cpp )
84
85files:
86 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
87
88links:
89 /bin/rm -f Makefile
90 $(TOP)/util/point.sh Makefile.ssl Makefile ;
91 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
92 $(TOP)/util/mklink.sh ../../test $(TEST)
93 $(TOP)/util/mklink.sh ../../apps $(APPS)
94
95install:
96 @for i in $(EXHEADER) ; \
97 do \
98 (cp $$i $(INSTALLTOP)/include/$$i; \
99 chmod 644 $(INSTALLTOP)/include/$$i ); \
100 done;
101
102exptest:
103 /bin/rm -f exptest
104 gcc -I../../include -g2 -ggdb -o exptest exptest.c ../../libcrypto.a
105
106div:
107 /bin/rm -f a.out
108 gcc -I.. -g div.c ../../libcrypto.a
109
110tags:
111 ctags $(SRC)
112
113tests:
114
115lint:
116 lint -DLINT $(INCLUDES) $(SRC)>fluff
117
118depend:
119 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
120
121dclean:
122 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
123 mv -f Makefile.new $(MAKEFILE)
124
125clean:
126 /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_mulw.s
127
128errors:
129 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # special case .org
130 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
131 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
132
133# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/bn/asm/bn-win32.asm b/src/lib/libcrypto/bn/asm/bn-win32.asm
new file mode 100644
index 0000000000..017ea462b0
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/bn-win32.asm
@@ -0,0 +1,689 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by bn-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE bn-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _bn_mul_add_words
12
13_bn_mul_add_words PROC NEAR
14 push ebp
15 push ebx
16 push esi
17 push edi
18 ;
19 xor esi, esi
20 mov edi, DWORD PTR 20[esp]
21 mov ecx, DWORD PTR 28[esp]
22 mov ebx, DWORD PTR 24[esp]
23 and ecx, 4294967288
24 mov ebp, DWORD PTR 32[esp]
25 push ecx
26 jz $L000maw_finish
27L001maw_loop:
28 mov DWORD PTR [esp],ecx
29 ; Round 0
30 mov eax, DWORD PTR [ebx]
31 mul ebp
32 add eax, esi
33 mov esi, DWORD PTR [edi]
34 adc edx, 0
35 add eax, esi
36 adc edx, 0
37 mov DWORD PTR [edi],eax
38 mov esi, edx
39 ; Round 4
40 mov eax, DWORD PTR 4[ebx]
41 mul ebp
42 add eax, esi
43 mov esi, DWORD PTR 4[edi]
44 adc edx, 0
45 add eax, esi
46 adc edx, 0
47 mov DWORD PTR 4[edi],eax
48 mov esi, edx
49 ; Round 8
50 mov eax, DWORD PTR 8[ebx]
51 mul ebp
52 add eax, esi
53 mov esi, DWORD PTR 8[edi]
54 adc edx, 0
55 add eax, esi
56 adc edx, 0
57 mov DWORD PTR 8[edi],eax
58 mov esi, edx
59 ; Round 12
60 mov eax, DWORD PTR 12[ebx]
61 mul ebp
62 add eax, esi
63 mov esi, DWORD PTR 12[edi]
64 adc edx, 0
65 add eax, esi
66 adc edx, 0
67 mov DWORD PTR 12[edi],eax
68 mov esi, edx
69 ; Round 16
70 mov eax, DWORD PTR 16[ebx]
71 mul ebp
72 add eax, esi
73 mov esi, DWORD PTR 16[edi]
74 adc edx, 0
75 add eax, esi
76 adc edx, 0
77 mov DWORD PTR 16[edi],eax
78 mov esi, edx
79 ; Round 20
80 mov eax, DWORD PTR 20[ebx]
81 mul ebp
82 add eax, esi
83 mov esi, DWORD PTR 20[edi]
84 adc edx, 0
85 add eax, esi
86 adc edx, 0
87 mov DWORD PTR 20[edi],eax
88 mov esi, edx
89 ; Round 24
90 mov eax, DWORD PTR 24[ebx]
91 mul ebp
92 add eax, esi
93 mov esi, DWORD PTR 24[edi]
94 adc edx, 0
95 add eax, esi
96 adc edx, 0
97 mov DWORD PTR 24[edi],eax
98 mov esi, edx
99 ; Round 28
100 mov eax, DWORD PTR 28[ebx]
101 mul ebp
102 add eax, esi
103 mov esi, DWORD PTR 28[edi]
104 adc edx, 0
105 add eax, esi
106 adc edx, 0
107 mov DWORD PTR 28[edi],eax
108 mov esi, edx
109 ;
110 mov ecx, DWORD PTR [esp]
111 add ebx, 32
112 add edi, 32
113 sub ecx, 8
114 jnz L001maw_loop
115$L000maw_finish:
116 mov ecx, DWORD PTR 32[esp]
117 and ecx, 7
118 jnz $L002maw_finish2
119 jmp $L003maw_end
120$L002maw_finish2:
121 ; Tail Round 0
122 mov eax, DWORD PTR [ebx]
123 mul ebp
124 add eax, esi
125 mov esi, DWORD PTR [edi]
126 adc edx, 0
127 add eax, esi
128 adc edx, 0
129 dec ecx
130 mov DWORD PTR [edi],eax
131 mov esi, edx
132 jz $L003maw_end
133 ; Tail Round 1
134 mov eax, DWORD PTR 4[ebx]
135 mul ebp
136 add eax, esi
137 mov esi, DWORD PTR 4[edi]
138 adc edx, 0
139 add eax, esi
140 adc edx, 0
141 dec ecx
142 mov DWORD PTR 4[edi],eax
143 mov esi, edx
144 jz $L003maw_end
145 ; Tail Round 2
146 mov eax, DWORD PTR 8[ebx]
147 mul ebp
148 add eax, esi
149 mov esi, DWORD PTR 8[edi]
150 adc edx, 0
151 add eax, esi
152 adc edx, 0
153 dec ecx
154 mov DWORD PTR 8[edi],eax
155 mov esi, edx
156 jz $L003maw_end
157 ; Tail Round 3
158 mov eax, DWORD PTR 12[ebx]
159 mul ebp
160 add eax, esi
161 mov esi, DWORD PTR 12[edi]
162 adc edx, 0
163 add eax, esi
164 adc edx, 0
165 dec ecx
166 mov DWORD PTR 12[edi],eax
167 mov esi, edx
168 jz $L003maw_end
169 ; Tail Round 4
170 mov eax, DWORD PTR 16[ebx]
171 mul ebp
172 add eax, esi
173 mov esi, DWORD PTR 16[edi]
174 adc edx, 0
175 add eax, esi
176 adc edx, 0
177 dec ecx
178 mov DWORD PTR 16[edi],eax
179 mov esi, edx
180 jz $L003maw_end
181 ; Tail Round 5
182 mov eax, DWORD PTR 20[ebx]
183 mul ebp
184 add eax, esi
185 mov esi, DWORD PTR 20[edi]
186 adc edx, 0
187 add eax, esi
188 adc edx, 0
189 dec ecx
190 mov DWORD PTR 20[edi],eax
191 mov esi, edx
192 jz $L003maw_end
193 ; Tail Round 6
194 mov eax, DWORD PTR 24[ebx]
195 mul ebp
196 add eax, esi
197 mov esi, DWORD PTR 24[edi]
198 adc edx, 0
199 add eax, esi
200 adc edx, 0
201 mov DWORD PTR 24[edi],eax
202 mov esi, edx
203$L003maw_end:
204 mov eax, esi
205 pop ecx
206 pop edi
207 pop esi
208 pop ebx
209 pop ebp
210 ret
211_bn_mul_add_words ENDP
212_TEXT ENDS
213_TEXT SEGMENT
214PUBLIC _bn_mul_words
215
216_bn_mul_words PROC NEAR
217 push ebp
218 push ebx
219 push esi
220 push edi
221 ;
222 xor esi, esi
223 mov edi, DWORD PTR 20[esp]
224 mov ebx, DWORD PTR 24[esp]
225 mov ebp, DWORD PTR 28[esp]
226 mov ecx, DWORD PTR 32[esp]
227 and ebp, 4294967288
228 jz $L004mw_finish
229L005mw_loop:
230 ; Round 0
231 mov eax, DWORD PTR [ebx]
232 mul ecx
233 add eax, esi
234 adc edx, 0
235 mov DWORD PTR [edi],eax
236 mov esi, edx
237 ; Round 4
238 mov eax, DWORD PTR 4[ebx]
239 mul ecx
240 add eax, esi
241 adc edx, 0
242 mov DWORD PTR 4[edi],eax
243 mov esi, edx
244 ; Round 8
245 mov eax, DWORD PTR 8[ebx]
246 mul ecx
247 add eax, esi
248 adc edx, 0
249 mov DWORD PTR 8[edi],eax
250 mov esi, edx
251 ; Round 12
252 mov eax, DWORD PTR 12[ebx]
253 mul ecx
254 add eax, esi
255 adc edx, 0
256 mov DWORD PTR 12[edi],eax
257 mov esi, edx
258 ; Round 16
259 mov eax, DWORD PTR 16[ebx]
260 mul ecx
261 add eax, esi
262 adc edx, 0
263 mov DWORD PTR 16[edi],eax
264 mov esi, edx
265 ; Round 20
266 mov eax, DWORD PTR 20[ebx]
267 mul ecx
268 add eax, esi
269 adc edx, 0
270 mov DWORD PTR 20[edi],eax
271 mov esi, edx
272 ; Round 24
273 mov eax, DWORD PTR 24[ebx]
274 mul ecx
275 add eax, esi
276 adc edx, 0
277 mov DWORD PTR 24[edi],eax
278 mov esi, edx
279 ; Round 28
280 mov eax, DWORD PTR 28[ebx]
281 mul ecx
282 add eax, esi
283 adc edx, 0
284 mov DWORD PTR 28[edi],eax
285 mov esi, edx
286 ;
287 add ebx, 32
288 add edi, 32
289 sub ebp, 8
290 jz $L004mw_finish
291 jmp L005mw_loop
292$L004mw_finish:
293 mov ebp, DWORD PTR 28[esp]
294 and ebp, 7
295 jnz $L006mw_finish2
296 jmp $L007mw_end
297$L006mw_finish2:
298 ; Tail Round 0
299 mov eax, DWORD PTR [ebx]
300 mul ecx
301 add eax, esi
302 adc edx, 0
303 mov DWORD PTR [edi],eax
304 mov esi, edx
305 dec ebp
306 jz $L007mw_end
307 ; Tail Round 1
308 mov eax, DWORD PTR 4[ebx]
309 mul ecx
310 add eax, esi
311 adc edx, 0
312 mov DWORD PTR 4[edi],eax
313 mov esi, edx
314 dec ebp
315 jz $L007mw_end
316 ; Tail Round 2
317 mov eax, DWORD PTR 8[ebx]
318 mul ecx
319 add eax, esi
320 adc edx, 0
321 mov DWORD PTR 8[edi],eax
322 mov esi, edx
323 dec ebp
324 jz $L007mw_end
325 ; Tail Round 3
326 mov eax, DWORD PTR 12[ebx]
327 mul ecx
328 add eax, esi
329 adc edx, 0
330 mov DWORD PTR 12[edi],eax
331 mov esi, edx
332 dec ebp
333 jz $L007mw_end
334 ; Tail Round 4
335 mov eax, DWORD PTR 16[ebx]
336 mul ecx
337 add eax, esi
338 adc edx, 0
339 mov DWORD PTR 16[edi],eax
340 mov esi, edx
341 dec ebp
342 jz $L007mw_end
343 ; Tail Round 5
344 mov eax, DWORD PTR 20[ebx]
345 mul ecx
346 add eax, esi
347 adc edx, 0
348 mov DWORD PTR 20[edi],eax
349 mov esi, edx
350 dec ebp
351 jz $L007mw_end
352 ; Tail Round 6
353 mov eax, DWORD PTR 24[ebx]
354 mul ecx
355 add eax, esi
356 adc edx, 0
357 mov DWORD PTR 24[edi],eax
358 mov esi, edx
359$L007mw_end:
360 mov eax, esi
361 pop edi
362 pop esi
363 pop ebx
364 pop ebp
365 ret
366_bn_mul_words ENDP
367_TEXT ENDS
368_TEXT SEGMENT
369PUBLIC _bn_sqr_words
370
371_bn_sqr_words PROC NEAR
372 push ebp
373 push ebx
374 push esi
375 push edi
376 ;
377 mov esi, DWORD PTR 20[esp]
378 mov edi, DWORD PTR 24[esp]
379 mov ebx, DWORD PTR 28[esp]
380 and ebx, 4294967288
381 jz $L008sw_finish
382L009sw_loop:
383 ; Round 0
384 mov eax, DWORD PTR [edi]
385 mul eax
386 mov DWORD PTR [esi],eax
387 mov DWORD PTR 4[esi],edx
388 ; Round 4
389 mov eax, DWORD PTR 4[edi]
390 mul eax
391 mov DWORD PTR 8[esi],eax
392 mov DWORD PTR 12[esi],edx
393 ; Round 8
394 mov eax, DWORD PTR 8[edi]
395 mul eax
396 mov DWORD PTR 16[esi],eax
397 mov DWORD PTR 20[esi],edx
398 ; Round 12
399 mov eax, DWORD PTR 12[edi]
400 mul eax
401 mov DWORD PTR 24[esi],eax
402 mov DWORD PTR 28[esi],edx
403 ; Round 16
404 mov eax, DWORD PTR 16[edi]
405 mul eax
406 mov DWORD PTR 32[esi],eax
407 mov DWORD PTR 36[esi],edx
408 ; Round 20
409 mov eax, DWORD PTR 20[edi]
410 mul eax
411 mov DWORD PTR 40[esi],eax
412 mov DWORD PTR 44[esi],edx
413 ; Round 24
414 mov eax, DWORD PTR 24[edi]
415 mul eax
416 mov DWORD PTR 48[esi],eax
417 mov DWORD PTR 52[esi],edx
418 ; Round 28
419 mov eax, DWORD PTR 28[edi]
420 mul eax
421 mov DWORD PTR 56[esi],eax
422 mov DWORD PTR 60[esi],edx
423 ;
424 add edi, 32
425 add esi, 64
426 sub ebx, 8
427 jnz L009sw_loop
428$L008sw_finish:
429 mov ebx, DWORD PTR 28[esp]
430 and ebx, 7
431 jz $L010sw_end
432 ; Tail Round 0
433 mov eax, DWORD PTR [edi]
434 mul eax
435 mov DWORD PTR [esi],eax
436 dec ebx
437 mov DWORD PTR 4[esi],edx
438 jz $L010sw_end
439 ; Tail Round 1
440 mov eax, DWORD PTR 4[edi]
441 mul eax
442 mov DWORD PTR 8[esi],eax
443 dec ebx
444 mov DWORD PTR 12[esi],edx
445 jz $L010sw_end
446 ; Tail Round 2
447 mov eax, DWORD PTR 8[edi]
448 mul eax
449 mov DWORD PTR 16[esi],eax
450 dec ebx
451 mov DWORD PTR 20[esi],edx
452 jz $L010sw_end
453 ; Tail Round 3
454 mov eax, DWORD PTR 12[edi]
455 mul eax
456 mov DWORD PTR 24[esi],eax
457 dec ebx
458 mov DWORD PTR 28[esi],edx
459 jz $L010sw_end
460 ; Tail Round 4
461 mov eax, DWORD PTR 16[edi]
462 mul eax
463 mov DWORD PTR 32[esi],eax
464 dec ebx
465 mov DWORD PTR 36[esi],edx
466 jz $L010sw_end
467 ; Tail Round 5
468 mov eax, DWORD PTR 20[edi]
469 mul eax
470 mov DWORD PTR 40[esi],eax
471 dec ebx
472 mov DWORD PTR 44[esi],edx
473 jz $L010sw_end
474 ; Tail Round 6
475 mov eax, DWORD PTR 24[edi]
476 mul eax
477 mov DWORD PTR 48[esi],eax
478 mov DWORD PTR 52[esi],edx
479$L010sw_end:
480 pop edi
481 pop esi
482 pop ebx
483 pop ebp
484 ret
485_bn_sqr_words ENDP
486_TEXT ENDS
487_TEXT SEGMENT
488PUBLIC _bn_div64
489
490_bn_div64 PROC NEAR
491 push ebp
492 push ebx
493 push esi
494 push edi
495 mov edx, DWORD PTR 20[esp]
496 mov eax, DWORD PTR 24[esp]
497 mov ebx, DWORD PTR 28[esp]
498 div ebx
499 pop edi
500 pop esi
501 pop ebx
502 pop ebp
503 ret
504_bn_div64 ENDP
505_TEXT ENDS
506_TEXT SEGMENT
507PUBLIC _bn_add_words
508
509_bn_add_words PROC NEAR
510 push ebp
511 push ebx
512 push esi
513 push edi
514 ;
515 mov ebx, DWORD PTR 20[esp]
516 mov esi, DWORD PTR 24[esp]
517 mov edi, DWORD PTR 28[esp]
518 mov ebp, DWORD PTR 32[esp]
519 xor eax, eax
520 and ebp, 4294967288
521 jz $L011aw_finish
522L012aw_loop:
523 ; Round 0
524 mov ecx, DWORD PTR [esi]
525 mov edx, DWORD PTR [edi]
526 add ecx, eax
527 mov eax, 0
528 adc eax, eax
529 add ecx, edx
530 adc eax, 0
531 mov DWORD PTR [ebx],ecx
532 ; Round 1
533 mov ecx, DWORD PTR 4[esi]
534 mov edx, DWORD PTR 4[edi]
535 add ecx, eax
536 mov eax, 0
537 adc eax, eax
538 add ecx, edx
539 adc eax, 0
540 mov DWORD PTR 4[ebx],ecx
541 ; Round 2
542 mov ecx, DWORD PTR 8[esi]
543 mov edx, DWORD PTR 8[edi]
544 add ecx, eax
545 mov eax, 0
546 adc eax, eax
547 add ecx, edx
548 adc eax, 0
549 mov DWORD PTR 8[ebx],ecx
550 ; Round 3
551 mov ecx, DWORD PTR 12[esi]
552 mov edx, DWORD PTR 12[edi]
553 add ecx, eax
554 mov eax, 0
555 adc eax, eax
556 add ecx, edx
557 adc eax, 0
558 mov DWORD PTR 12[ebx],ecx
559 ; Round 4
560 mov ecx, DWORD PTR 16[esi]
561 mov edx, DWORD PTR 16[edi]
562 add ecx, eax
563 mov eax, 0
564 adc eax, eax
565 add ecx, edx
566 adc eax, 0
567 mov DWORD PTR 16[ebx],ecx
568 ; Round 5
569 mov ecx, DWORD PTR 20[esi]
570 mov edx, DWORD PTR 20[edi]
571 add ecx, eax
572 mov eax, 0
573 adc eax, eax
574 add ecx, edx
575 adc eax, 0
576 mov DWORD PTR 20[ebx],ecx
577 ; Round 6
578 mov ecx, DWORD PTR 24[esi]
579 mov edx, DWORD PTR 24[edi]
580 add ecx, eax
581 mov eax, 0
582 adc eax, eax
583 add ecx, edx
584 adc eax, 0
585 mov DWORD PTR 24[ebx],ecx
586 ; Round 7
587 mov ecx, DWORD PTR 28[esi]
588 mov edx, DWORD PTR 28[edi]
589 add ecx, eax
590 mov eax, 0
591 adc eax, eax
592 add ecx, edx
593 adc eax, 0
594 mov DWORD PTR 28[ebx],ecx
595 ;
596 add esi, 32
597 add edi, 32
598 add ebx, 32
599 sub ebp, 8
600 jnz L012aw_loop
601$L011aw_finish:
602 mov ebp, DWORD PTR 32[esp]
603 and ebp, 7
604 jz $L013aw_end
605 ; Tail Round 0
606 mov ecx, DWORD PTR [esi]
607 mov edx, DWORD PTR [edi]
608 add ecx, eax
609 mov eax, 0
610 adc eax, eax
611 add ecx, edx
612 adc eax, 0
613 dec ebp
614 mov DWORD PTR [ebx],ecx
615 jz $L013aw_end
616 ; Tail Round 1
617 mov ecx, DWORD PTR 4[esi]
618 mov edx, DWORD PTR 4[edi]
619 add ecx, eax
620 mov eax, 0
621 adc eax, eax
622 add ecx, edx
623 adc eax, 0
624 dec ebp
625 mov DWORD PTR 4[ebx],ecx
626 jz $L013aw_end
627 ; Tail Round 2
628 mov ecx, DWORD PTR 8[esi]
629 mov edx, DWORD PTR 8[edi]
630 add ecx, eax
631 mov eax, 0
632 adc eax, eax
633 add ecx, edx
634 adc eax, 0
635 dec ebp
636 mov DWORD PTR 8[ebx],ecx
637 jz $L013aw_end
638 ; Tail Round 3
639 mov ecx, DWORD PTR 12[esi]
640 mov edx, DWORD PTR 12[edi]
641 add ecx, eax
642 mov eax, 0
643 adc eax, eax
644 add ecx, edx
645 adc eax, 0
646 dec ebp
647 mov DWORD PTR 12[ebx],ecx
648 jz $L013aw_end
649 ; Tail Round 4
650 mov ecx, DWORD PTR 16[esi]
651 mov edx, DWORD PTR 16[edi]
652 add ecx, eax
653 mov eax, 0
654 adc eax, eax
655 add ecx, edx
656 adc eax, 0
657 dec ebp
658 mov DWORD PTR 16[ebx],ecx
659 jz $L013aw_end
660 ; Tail Round 5
661 mov ecx, DWORD PTR 20[esi]
662 mov edx, DWORD PTR 20[edi]
663 add ecx, eax
664 mov eax, 0
665 adc eax, eax
666 add ecx, edx
667 adc eax, 0
668 dec ebp
669 mov DWORD PTR 20[ebx],ecx
670 jz $L013aw_end
671 ; Tail Round 6
672 mov ecx, DWORD PTR 24[esi]
673 mov edx, DWORD PTR 24[edi]
674 add ecx, eax
675 mov eax, 0
676 adc eax, eax
677 add ecx, edx
678 adc eax, 0
679 mov DWORD PTR 24[ebx],ecx
680$L013aw_end:
681 mov eax, eax
682 pop edi
683 pop esi
684 pop ebx
685 pop ebp
686 ret
687_bn_add_words ENDP
688_TEXT ENDS
689END
diff --git a/src/lib/libcrypto/bn/asm/bn86unix.cpp b/src/lib/libcrypto/bn/asm/bn86unix.cpp
new file mode 100644
index 0000000000..64702201ea
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/bn86unix.cpp
@@ -0,0 +1,752 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define bn_mul_add_words _bn_mul_add_words
13#define bn_mul_words _bn_mul_words
14#define bn_sqr_words _bn_sqr_words
15#define bn_div64 _bn_div64
16#define bn_add_words _bn_add_words
17
18#endif
19
20#ifdef OUT
21#define OK 1
22#define ALIGN 4
23#endif
24
25#ifdef BSDI
26#define OK 1
27#define ALIGN 4
28#undef SIZE
29#undef TYPE
30#define SIZE(a,b)
31#define TYPE(a,b)
32#endif
33
34#if defined(ELF) || defined(SOL)
35#define OK 1
36#define ALIGN 16
37#endif
38
39#ifndef OK
40You need to define one of
41ELF - elf systems - linux-elf, NetBSD and DG-UX
42OUT - a.out systems - linux-a.out and FreeBSD
43SOL - solaris systems, which are elf with strange comment lines
44BSDI - a.out with a very primative version of as.
45#endif
46
47/* Let the Assembler begin :-) */
48 /* Don't even think of reading this code */
49 /* It was automatically generated by bn-586.pl */
50 /* Which is a perl program used to generate the x86 assember for */
51 /* any of elf, a.out, BSDI,Win32, or Solaris */
52 /* eric <eay@cryptsoft.com> */
53
54 .file "bn-586.s"
55 .version "01.01"
56gcc2_compiled.:
57.text
58 .align ALIGN
59.globl bn_mul_add_words
60 TYPE(bn_mul_add_words,@function)
61bn_mul_add_words:
62 pushl %ebp
63 pushl %ebx
64 pushl %esi
65 pushl %edi
66
67
68 xorl %esi, %esi
69 movl 20(%esp), %edi
70 movl 28(%esp), %ecx
71 movl 24(%esp), %ebx
72 andl $4294967288, %ecx
73 movl 32(%esp), %ebp
74 pushl %ecx
75 jz .L000maw_finish
76.L001maw_loop:
77 movl %ecx, (%esp)
78 /* Round 0 */
79 movl (%ebx), %eax
80 mull %ebp
81 addl %esi, %eax
82 movl (%edi), %esi
83 adcl $0, %edx
84 addl %esi, %eax
85 adcl $0, %edx
86 movl %eax, (%edi)
87 movl %edx, %esi
88 /* Round 4 */
89 movl 4(%ebx), %eax
90 mull %ebp
91 addl %esi, %eax
92 movl 4(%edi), %esi
93 adcl $0, %edx
94 addl %esi, %eax
95 adcl $0, %edx
96 movl %eax, 4(%edi)
97 movl %edx, %esi
98 /* Round 8 */
99 movl 8(%ebx), %eax
100 mull %ebp
101 addl %esi, %eax
102 movl 8(%edi), %esi
103 adcl $0, %edx
104 addl %esi, %eax
105 adcl $0, %edx
106 movl %eax, 8(%edi)
107 movl %edx, %esi
108 /* Round 12 */
109 movl 12(%ebx), %eax
110 mull %ebp
111 addl %esi, %eax
112 movl 12(%edi), %esi
113 adcl $0, %edx
114 addl %esi, %eax
115 adcl $0, %edx
116 movl %eax, 12(%edi)
117 movl %edx, %esi
118 /* Round 16 */
119 movl 16(%ebx), %eax
120 mull %ebp
121 addl %esi, %eax
122 movl 16(%edi), %esi
123 adcl $0, %edx
124 addl %esi, %eax
125 adcl $0, %edx
126 movl %eax, 16(%edi)
127 movl %edx, %esi
128 /* Round 20 */
129 movl 20(%ebx), %eax
130 mull %ebp
131 addl %esi, %eax
132 movl 20(%edi), %esi
133 adcl $0, %edx
134 addl %esi, %eax
135 adcl $0, %edx
136 movl %eax, 20(%edi)
137 movl %edx, %esi
138 /* Round 24 */
139 movl 24(%ebx), %eax
140 mull %ebp
141 addl %esi, %eax
142 movl 24(%edi), %esi
143 adcl $0, %edx
144 addl %esi, %eax
145 adcl $0, %edx
146 movl %eax, 24(%edi)
147 movl %edx, %esi
148 /* Round 28 */
149 movl 28(%ebx), %eax
150 mull %ebp
151 addl %esi, %eax
152 movl 28(%edi), %esi
153 adcl $0, %edx
154 addl %esi, %eax
155 adcl $0, %edx
156 movl %eax, 28(%edi)
157 movl %edx, %esi
158
159 movl (%esp), %ecx
160 addl $32, %ebx
161 addl $32, %edi
162 subl $8, %ecx
163 jnz .L001maw_loop
164.L000maw_finish:
165 movl 32(%esp), %ecx
166 andl $7, %ecx
167 jnz .L002maw_finish2
168 jmp .L003maw_end
169.align ALIGN
170.L002maw_finish2:
171 /* Tail Round 0 */
172 movl (%ebx), %eax
173 mull %ebp
174 addl %esi, %eax
175 movl (%edi), %esi
176 adcl $0, %edx
177 addl %esi, %eax
178 adcl $0, %edx
179 decl %ecx
180 movl %eax, (%edi)
181 movl %edx, %esi
182 jz .L003maw_end
183 /* Tail Round 1 */
184 movl 4(%ebx), %eax
185 mull %ebp
186 addl %esi, %eax
187 movl 4(%edi), %esi
188 adcl $0, %edx
189 addl %esi, %eax
190 adcl $0, %edx
191 decl %ecx
192 movl %eax, 4(%edi)
193 movl %edx, %esi
194 jz .L003maw_end
195 /* Tail Round 2 */
196 movl 8(%ebx), %eax
197 mull %ebp
198 addl %esi, %eax
199 movl 8(%edi), %esi
200 adcl $0, %edx
201 addl %esi, %eax
202 adcl $0, %edx
203 decl %ecx
204 movl %eax, 8(%edi)
205 movl %edx, %esi
206 jz .L003maw_end
207 /* Tail Round 3 */
208 movl 12(%ebx), %eax
209 mull %ebp
210 addl %esi, %eax
211 movl 12(%edi), %esi
212 adcl $0, %edx
213 addl %esi, %eax
214 adcl $0, %edx
215 decl %ecx
216 movl %eax, 12(%edi)
217 movl %edx, %esi
218 jz .L003maw_end
219 /* Tail Round 4 */
220 movl 16(%ebx), %eax
221 mull %ebp
222 addl %esi, %eax
223 movl 16(%edi), %esi
224 adcl $0, %edx
225 addl %esi, %eax
226 adcl $0, %edx
227 decl %ecx
228 movl %eax, 16(%edi)
229 movl %edx, %esi
230 jz .L003maw_end
231 /* Tail Round 5 */
232 movl 20(%ebx), %eax
233 mull %ebp
234 addl %esi, %eax
235 movl 20(%edi), %esi
236 adcl $0, %edx
237 addl %esi, %eax
238 adcl $0, %edx
239 decl %ecx
240 movl %eax, 20(%edi)
241 movl %edx, %esi
242 jz .L003maw_end
243 /* Tail Round 6 */
244 movl 24(%ebx), %eax
245 mull %ebp
246 addl %esi, %eax
247 movl 24(%edi), %esi
248 adcl $0, %edx
249 addl %esi, %eax
250 adcl $0, %edx
251 movl %eax, 24(%edi)
252 movl %edx, %esi
253.L003maw_end:
254 movl %esi, %eax
255 popl %ecx
256 popl %edi
257 popl %esi
258 popl %ebx
259 popl %ebp
260 ret
261.bn_mul_add_words_end:
262 SIZE(bn_mul_add_words,.bn_mul_add_words_end-bn_mul_add_words)
263.ident "bn_mul_add_words"
264.text
265 .align ALIGN
266.globl bn_mul_words
267 TYPE(bn_mul_words,@function)
268bn_mul_words:
269 pushl %ebp
270 pushl %ebx
271 pushl %esi
272 pushl %edi
273
274
275 xorl %esi, %esi
276 movl 20(%esp), %edi
277 movl 24(%esp), %ebx
278 movl 28(%esp), %ebp
279 movl 32(%esp), %ecx
280 andl $4294967288, %ebp
281 jz .L004mw_finish
282.L005mw_loop:
283 /* Round 0 */
284 movl (%ebx), %eax
285 mull %ecx
286 addl %esi, %eax
287 adcl $0, %edx
288 movl %eax, (%edi)
289 movl %edx, %esi
290 /* Round 4 */
291 movl 4(%ebx), %eax
292 mull %ecx
293 addl %esi, %eax
294 adcl $0, %edx
295 movl %eax, 4(%edi)
296 movl %edx, %esi
297 /* Round 8 */
298 movl 8(%ebx), %eax
299 mull %ecx
300 addl %esi, %eax
301 adcl $0, %edx
302 movl %eax, 8(%edi)
303 movl %edx, %esi
304 /* Round 12 */
305 movl 12(%ebx), %eax
306 mull %ecx
307 addl %esi, %eax
308 adcl $0, %edx
309 movl %eax, 12(%edi)
310 movl %edx, %esi
311 /* Round 16 */
312 movl 16(%ebx), %eax
313 mull %ecx
314 addl %esi, %eax
315 adcl $0, %edx
316 movl %eax, 16(%edi)
317 movl %edx, %esi
318 /* Round 20 */
319 movl 20(%ebx), %eax
320 mull %ecx
321 addl %esi, %eax
322 adcl $0, %edx
323 movl %eax, 20(%edi)
324 movl %edx, %esi
325 /* Round 24 */
326 movl 24(%ebx), %eax
327 mull %ecx
328 addl %esi, %eax
329 adcl $0, %edx
330 movl %eax, 24(%edi)
331 movl %edx, %esi
332 /* Round 28 */
333 movl 28(%ebx), %eax
334 mull %ecx
335 addl %esi, %eax
336 adcl $0, %edx
337 movl %eax, 28(%edi)
338 movl %edx, %esi
339
340 addl $32, %ebx
341 addl $32, %edi
342 subl $8, %ebp
343 jz .L004mw_finish
344 jmp .L005mw_loop
345.L004mw_finish:
346 movl 28(%esp), %ebp
347 andl $7, %ebp
348 jnz .L006mw_finish2
349 jmp .L007mw_end
350.align ALIGN
351.L006mw_finish2:
352 /* Tail Round 0 */
353 movl (%ebx), %eax
354 mull %ecx
355 addl %esi, %eax
356 adcl $0, %edx
357 movl %eax, (%edi)
358 movl %edx, %esi
359 decl %ebp
360 jz .L007mw_end
361 /* Tail Round 1 */
362 movl 4(%ebx), %eax
363 mull %ecx
364 addl %esi, %eax
365 adcl $0, %edx
366 movl %eax, 4(%edi)
367 movl %edx, %esi
368 decl %ebp
369 jz .L007mw_end
370 /* Tail Round 2 */
371 movl 8(%ebx), %eax
372 mull %ecx
373 addl %esi, %eax
374 adcl $0, %edx
375 movl %eax, 8(%edi)
376 movl %edx, %esi
377 decl %ebp
378 jz .L007mw_end
379 /* Tail Round 3 */
380 movl 12(%ebx), %eax
381 mull %ecx
382 addl %esi, %eax
383 adcl $0, %edx
384 movl %eax, 12(%edi)
385 movl %edx, %esi
386 decl %ebp
387 jz .L007mw_end
388 /* Tail Round 4 */
389 movl 16(%ebx), %eax
390 mull %ecx
391 addl %esi, %eax
392 adcl $0, %edx
393 movl %eax, 16(%edi)
394 movl %edx, %esi
395 decl %ebp
396 jz .L007mw_end
397 /* Tail Round 5 */
398 movl 20(%ebx), %eax
399 mull %ecx
400 addl %esi, %eax
401 adcl $0, %edx
402 movl %eax, 20(%edi)
403 movl %edx, %esi
404 decl %ebp
405 jz .L007mw_end
406 /* Tail Round 6 */
407 movl 24(%ebx), %eax
408 mull %ecx
409 addl %esi, %eax
410 adcl $0, %edx
411 movl %eax, 24(%edi)
412 movl %edx, %esi
413.L007mw_end:
414 movl %esi, %eax
415 popl %edi
416 popl %esi
417 popl %ebx
418 popl %ebp
419 ret
420.bn_mul_words_end:
421 SIZE(bn_mul_words,.bn_mul_words_end-bn_mul_words)
422.ident "bn_mul_words"
423.text
424 .align ALIGN
425.globl bn_sqr_words
426 TYPE(bn_sqr_words,@function)
427bn_sqr_words:
428 pushl %ebp
429 pushl %ebx
430 pushl %esi
431 pushl %edi
432
433
434 movl 20(%esp), %esi
435 movl 24(%esp), %edi
436 movl 28(%esp), %ebx
437 andl $4294967288, %ebx
438 jz .L008sw_finish
439.L009sw_loop:
440 /* Round 0 */
441 movl (%edi), %eax
442 mull %eax
443 movl %eax, (%esi)
444 movl %edx, 4(%esi)
445 /* Round 4 */
446 movl 4(%edi), %eax
447 mull %eax
448 movl %eax, 8(%esi)
449 movl %edx, 12(%esi)
450 /* Round 8 */
451 movl 8(%edi), %eax
452 mull %eax
453 movl %eax, 16(%esi)
454 movl %edx, 20(%esi)
455 /* Round 12 */
456 movl 12(%edi), %eax
457 mull %eax
458 movl %eax, 24(%esi)
459 movl %edx, 28(%esi)
460 /* Round 16 */
461 movl 16(%edi), %eax
462 mull %eax
463 movl %eax, 32(%esi)
464 movl %edx, 36(%esi)
465 /* Round 20 */
466 movl 20(%edi), %eax
467 mull %eax
468 movl %eax, 40(%esi)
469 movl %edx, 44(%esi)
470 /* Round 24 */
471 movl 24(%edi), %eax
472 mull %eax
473 movl %eax, 48(%esi)
474 movl %edx, 52(%esi)
475 /* Round 28 */
476 movl 28(%edi), %eax
477 mull %eax
478 movl %eax, 56(%esi)
479 movl %edx, 60(%esi)
480
481 addl $32, %edi
482 addl $64, %esi
483 subl $8, %ebx
484 jnz .L009sw_loop
485.L008sw_finish:
486 movl 28(%esp), %ebx
487 andl $7, %ebx
488 jz .L010sw_end
489 /* Tail Round 0 */
490 movl (%edi), %eax
491 mull %eax
492 movl %eax, (%esi)
493 decl %ebx
494 movl %edx, 4(%esi)
495 jz .L010sw_end
496 /* Tail Round 1 */
497 movl 4(%edi), %eax
498 mull %eax
499 movl %eax, 8(%esi)
500 decl %ebx
501 movl %edx, 12(%esi)
502 jz .L010sw_end
503 /* Tail Round 2 */
504 movl 8(%edi), %eax
505 mull %eax
506 movl %eax, 16(%esi)
507 decl %ebx
508 movl %edx, 20(%esi)
509 jz .L010sw_end
510 /* Tail Round 3 */
511 movl 12(%edi), %eax
512 mull %eax
513 movl %eax, 24(%esi)
514 decl %ebx
515 movl %edx, 28(%esi)
516 jz .L010sw_end
517 /* Tail Round 4 */
518 movl 16(%edi), %eax
519 mull %eax
520 movl %eax, 32(%esi)
521 decl %ebx
522 movl %edx, 36(%esi)
523 jz .L010sw_end
524 /* Tail Round 5 */
525 movl 20(%edi), %eax
526 mull %eax
527 movl %eax, 40(%esi)
528 decl %ebx
529 movl %edx, 44(%esi)
530 jz .L010sw_end
531 /* Tail Round 6 */
532 movl 24(%edi), %eax
533 mull %eax
534 movl %eax, 48(%esi)
535 movl %edx, 52(%esi)
536.L010sw_end:
537 popl %edi
538 popl %esi
539 popl %ebx
540 popl %ebp
541 ret
542.bn_sqr_words_end:
543 SIZE(bn_sqr_words,.bn_sqr_words_end-bn_sqr_words)
544.ident "bn_sqr_words"
545.text
546 .align ALIGN
547.globl bn_div64
548 TYPE(bn_div64,@function)
549bn_div64:
550 pushl %ebp
551 pushl %ebx
552 pushl %esi
553 pushl %edi
554
555 movl 20(%esp), %edx
556 movl 24(%esp), %eax
557 movl 28(%esp), %ebx
558 divl %ebx
559 popl %edi
560 popl %esi
561 popl %ebx
562 popl %ebp
563 ret
564.bn_div64_end:
565 SIZE(bn_div64,.bn_div64_end-bn_div64)
566.ident "bn_div64"
567.text
568 .align ALIGN
569.globl bn_add_words
570 TYPE(bn_add_words,@function)
571bn_add_words:
572 pushl %ebp
573 pushl %ebx
574 pushl %esi
575 pushl %edi
576
577
578 movl 20(%esp), %ebx
579 movl 24(%esp), %esi
580 movl 28(%esp), %edi
581 movl 32(%esp), %ebp
582 xorl %eax, %eax
583 andl $4294967288, %ebp
584 jz .L011aw_finish
585.L012aw_loop:
586 /* Round 0 */
587 movl (%esi), %ecx
588 movl (%edi), %edx
589 addl %eax, %ecx
590 movl $0, %eax
591 adcl %eax, %eax
592 addl %edx, %ecx
593 adcl $0, %eax
594 movl %ecx, (%ebx)
595 /* Round 1 */
596 movl 4(%esi), %ecx
597 movl 4(%edi), %edx
598 addl %eax, %ecx
599 movl $0, %eax
600 adcl %eax, %eax
601 addl %edx, %ecx
602 adcl $0, %eax
603 movl %ecx, 4(%ebx)
604 /* Round 2 */
605 movl 8(%esi), %ecx
606 movl 8(%edi), %edx
607 addl %eax, %ecx
608 movl $0, %eax
609 adcl %eax, %eax
610 addl %edx, %ecx
611 adcl $0, %eax
612 movl %ecx, 8(%ebx)
613 /* Round 3 */
614 movl 12(%esi), %ecx
615 movl 12(%edi), %edx
616 addl %eax, %ecx
617 movl $0, %eax
618 adcl %eax, %eax
619 addl %edx, %ecx
620 adcl $0, %eax
621 movl %ecx, 12(%ebx)
622 /* Round 4 */
623 movl 16(%esi), %ecx
624 movl 16(%edi), %edx
625 addl %eax, %ecx
626 movl $0, %eax
627 adcl %eax, %eax
628 addl %edx, %ecx
629 adcl $0, %eax
630 movl %ecx, 16(%ebx)
631 /* Round 5 */
632 movl 20(%esi), %ecx
633 movl 20(%edi), %edx
634 addl %eax, %ecx
635 movl $0, %eax
636 adcl %eax, %eax
637 addl %edx, %ecx
638 adcl $0, %eax
639 movl %ecx, 20(%ebx)
640 /* Round 6 */
641 movl 24(%esi), %ecx
642 movl 24(%edi), %edx
643 addl %eax, %ecx
644 movl $0, %eax
645 adcl %eax, %eax
646 addl %edx, %ecx
647 adcl $0, %eax
648 movl %ecx, 24(%ebx)
649 /* Round 7 */
650 movl 28(%esi), %ecx
651 movl 28(%edi), %edx
652 addl %eax, %ecx
653 movl $0, %eax
654 adcl %eax, %eax
655 addl %edx, %ecx
656 adcl $0, %eax
657 movl %ecx, 28(%ebx)
658
659 addl $32, %esi
660 addl $32, %edi
661 addl $32, %ebx
662 subl $8, %ebp
663 jnz .L012aw_loop
664.L011aw_finish:
665 movl 32(%esp), %ebp
666 andl $7, %ebp
667 jz .L013aw_end
668 /* Tail Round 0 */
669 movl (%esi), %ecx
670 movl (%edi), %edx
671 addl %eax, %ecx
672 movl $0, %eax
673 adcl %eax, %eax
674 addl %edx, %ecx
675 adcl $0, %eax
676 decl %ebp
677 movl %ecx, (%ebx)
678 jz .L013aw_end
679 /* Tail Round 1 */
680 movl 4(%esi), %ecx
681 movl 4(%edi), %edx
682 addl %eax, %ecx
683 movl $0, %eax
684 adcl %eax, %eax
685 addl %edx, %ecx
686 adcl $0, %eax
687 decl %ebp
688 movl %ecx, 4(%ebx)
689 jz .L013aw_end
690 /* Tail Round 2 */
691 movl 8(%esi), %ecx
692 movl 8(%edi), %edx
693 addl %eax, %ecx
694 movl $0, %eax
695 adcl %eax, %eax
696 addl %edx, %ecx
697 adcl $0, %eax
698 decl %ebp
699 movl %ecx, 8(%ebx)
700 jz .L013aw_end
701 /* Tail Round 3 */
702 movl 12(%esi), %ecx
703 movl 12(%edi), %edx
704 addl %eax, %ecx
705 movl $0, %eax
706 adcl %eax, %eax
707 addl %edx, %ecx
708 adcl $0, %eax
709 decl %ebp
710 movl %ecx, 12(%ebx)
711 jz .L013aw_end
712 /* Tail Round 4 */
713 movl 16(%esi), %ecx
714 movl 16(%edi), %edx
715 addl %eax, %ecx
716 movl $0, %eax
717 adcl %eax, %eax
718 addl %edx, %ecx
719 adcl $0, %eax
720 decl %ebp
721 movl %ecx, 16(%ebx)
722 jz .L013aw_end
723 /* Tail Round 5 */
724 movl 20(%esi), %ecx
725 movl 20(%edi), %edx
726 addl %eax, %ecx
727 movl $0, %eax
728 adcl %eax, %eax
729 addl %edx, %ecx
730 adcl $0, %eax
731 decl %ebp
732 movl %ecx, 20(%ebx)
733 jz .L013aw_end
734 /* Tail Round 6 */
735 movl 24(%esi), %ecx
736 movl 24(%edi), %edx
737 addl %eax, %ecx
738 movl $0, %eax
739 adcl %eax, %eax
740 addl %edx, %ecx
741 adcl $0, %eax
742 movl %ecx, 24(%ebx)
743.L013aw_end:
744 movl %eax, %eax
745 popl %edi
746 popl %esi
747 popl %ebx
748 popl %ebp
749 ret
750.bn_add_words_end:
751 SIZE(bn_add_words,.bn_add_words_end-bn_add_words)
752.ident "bn_add_words"
diff --git a/src/lib/libcrypto/bn/asm/sparc.s b/src/lib/libcrypto/bn/asm/sparc.s
new file mode 100644
index 0000000000..f9e533caa8
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/sparc.s
@@ -0,0 +1,462 @@
1 .file "bn_mulw.c"
2gcc2_compiled.:
3.section ".text"
4 .align 4
5 .global bn_mul_add_words
6 .type bn_mul_add_words,#function
7 .proc 016
8bn_mul_add_words:
9 !#PROLOGUE# 0
10 save %sp,-112,%sp
11 !#PROLOGUE# 1
12 mov %i0,%o0
13 mov %i1,%o2
14 mov %i2,%g1
15 mov %i3,%o1
16 mov 0,%i4
17 add %o0,12,%g4
18 add %o2,12,%o7
19.LL2:
20 mov %i4,%i3
21 mov 0,%i2
22 ld [%o0],%g2
23 mov %g2,%i1
24 ld [%o2],%g2
25 mov 0,%i0
26 umul %o1,%g2,%g3
27 rd %y,%g2
28 addcc %g3,%i1,%g3
29 addx %g2,%i0,%g2
30 addcc %g3,%i3,%g3
31 addx %g2,%i2,%g2
32 st %g3,[%o0]
33 mov %g2,%i5
34 mov 0,%i4
35 addcc %g1,-1,%g1
36 be .LL3
37 mov %i5,%i4
38 mov %i4,%i3
39 mov 0,%i2
40 ld [%g4-8],%g2
41 mov %g2,%i1
42 ld [%o7-8],%g2
43 mov 0,%i0
44 umul %o1,%g2,%g3
45 rd %y,%g2
46 addcc %g3,%i1,%g3
47 addx %g2,%i0,%g2
48 addcc %g3,%i3,%g3
49 addx %g2,%i2,%g2
50 st %g3,[%g4-8]
51 mov %g2,%i5
52 mov 0,%i4
53 addcc %g1,-1,%g1
54 be .LL3
55 mov %i5,%i4
56 mov %i4,%i3
57 mov 0,%i2
58 ld [%g4-4],%g2
59 mov %g2,%i1
60 ld [%o7-4],%g2
61 mov 0,%i0
62 umul %o1,%g2,%g3
63 rd %y,%g2
64 addcc %g3,%i1,%g3
65 addx %g2,%i0,%g2
66 addcc %g3,%i3,%g3
67 addx %g2,%i2,%g2
68 st %g3,[%g4-4]
69 mov %g2,%i5
70 mov 0,%i4
71 addcc %g1,-1,%g1
72 be .LL3
73 mov %i5,%i4
74 mov %i4,%i3
75 mov 0,%i2
76 ld [%g4],%g2
77 mov %g2,%i1
78 ld [%o7],%g2
79 mov 0,%i0
80 umul %o1,%g2,%g3
81 rd %y,%g2
82 addcc %g3,%i1,%g3
83 addx %g2,%i0,%g2
84 addcc %g3,%i3,%g3
85 addx %g2,%i2,%g2
86 st %g3,[%g4]
87 mov %g2,%i5
88 mov 0,%i4
89 addcc %g1,-1,%g1
90 be .LL3
91 mov %i5,%i4
92 add %o7,16,%o7
93 add %o2,16,%o2
94 add %g4,16,%g4
95 b .LL2
96 add %o0,16,%o0
97.LL3:
98 ret
99 restore %g0,%i4,%o0
100.LLfe1:
101 .size bn_mul_add_words,.LLfe1-bn_mul_add_words
102 .align 4
103 .global bn_mul_words
104 .type bn_mul_words,#function
105 .proc 016
106bn_mul_words:
107 !#PROLOGUE# 0
108 save %sp,-112,%sp
109 !#PROLOGUE# 1
110 mov %i0,%o7
111 mov %i1,%o0
112 mov %i2,%i4
113 mov %i3,%g4
114 mov 0,%i0
115 add %o7,12,%g1
116 add %o0,12,%i5
117.LL18:
118 mov %i0,%g3
119 mov 0,%g2
120 ld [%o0],%i2
121 umul %g4,%i2,%i3
122 rd %y,%i2
123 addcc %i3,%g3,%i3
124 addx %i2,%g2,%i2
125 st %i3,[%o7]
126 mov %i2,%i1
127 mov 0,%i0
128 addcc %i4,-1,%i4
129 be .LL19
130 mov %i1,%i0
131 mov %i0,%g3
132 mov 0,%g2
133 ld [%i5-8],%i2
134 umul %g4,%i2,%i3
135 rd %y,%i2
136 addcc %i3,%g3,%i3
137 addx %i2,%g2,%i2
138 st %i3,[%g1-8]
139 mov %i2,%i1
140 mov 0,%i0
141 addcc %i4,-1,%i4
142 be .LL19
143 mov %i1,%i0
144 mov %i0,%g3
145 mov 0,%g2
146 ld [%i5-4],%i2
147 umul %g4,%i2,%i3
148 rd %y,%i2
149 addcc %i3,%g3,%i3
150 addx %i2,%g2,%i2
151 st %i3,[%g1-4]
152 mov %i2,%i1
153 mov 0,%i0
154 addcc %i4,-1,%i4
155 be .LL19
156 mov %i1,%i0
157 mov %i0,%g3
158 mov 0,%g2
159 ld [%i5],%i2
160 umul %g4,%i2,%i3
161 rd %y,%i2
162 addcc %i3,%g3,%i3
163 addx %i2,%g2,%i2
164 st %i3,[%g1]
165 mov %i2,%i1
166 mov 0,%i0
167 addcc %i4,-1,%i4
168 be .LL19
169 mov %i1,%i0
170 add %i5,16,%i5
171 add %o0,16,%o0
172 add %g1,16,%g1
173 b .LL18
174 add %o7,16,%o7
175.LL19:
176 ret
177 restore
178.LLfe2:
179 .size bn_mul_words,.LLfe2-bn_mul_words
180 .align 4
181 .global bn_sqr_words
182 .type bn_sqr_words,#function
183 .proc 020
184bn_sqr_words:
185 !#PROLOGUE# 0
186 !#PROLOGUE# 1
187 mov %o0,%g4
188 add %g4,28,%o3
189 add %o1,12,%g1
190.LL34:
191 ld [%o1],%o0
192 addcc %o2,-1,%o2
193 umul %o0,%o0,%o5
194 rd %y,%o4
195 st %o5,[%g4]
196 mov %o4,%g3
197 mov 0,%g2
198 be .LL35
199 st %g3,[%o3-24]
200 ld [%g1-8],%o0
201 addcc %o2,-1,%o2
202 umul %o0,%o0,%o5
203 rd %y,%o4
204 st %o5,[%o3-20]
205 mov %o4,%g3
206 mov 0,%g2
207 be .LL35
208 st %g3,[%o3-16]
209 ld [%g1-4],%o0
210 addcc %o2,-1,%o2
211 umul %o0,%o0,%o5
212 rd %y,%o4
213 st %o5,[%o3-12]
214 mov %o4,%g3
215 mov 0,%g2
216 be .LL35
217 st %g3,[%o3-8]
218 ld [%g1],%o0
219 addcc %o2,-1,%o2
220 umul %o0,%o0,%o5
221 rd %y,%o4
222 st %o5,[%o3-4]
223 mov %o4,%g3
224 mov 0,%g2
225 be .LL35
226 st %g3,[%o3]
227 add %g1,16,%g1
228 add %o1,16,%o1
229 add %o3,32,%o3
230 b .LL34
231 add %g4,32,%g4
232.LL35:
233 retl
234 nop
235.LLfe3:
236 .size bn_sqr_words,.LLfe3-bn_sqr_words
237 .align 4
238 .global bn_add_words
239 .type bn_add_words,#function
240 .proc 016
241bn_add_words:
242 !#PROLOGUE# 0
243 save %sp,-112,%sp
244 !#PROLOGUE# 1
245 mov %i0,%o2
246 mov %i1,%o3
247 mov %i2,%o4
248 mov %i3,%i5
249 mov 0,%o0
250 mov 0,%o1
251 add %o2,12,%o7
252 add %o4,12,%g4
253 b .LL42
254 add %o3,12,%g1
255.LL45:
256 add %i5,-1,%i5
257 mov %i4,%g3
258 ld [%g4-8],%i4
259 mov 0,%g2
260 mov %i4,%i1
261 mov 0,%i0
262 addcc %g3,%i1,%g3
263 addx %g2,%i0,%g2
264 addcc %o1,%g3,%o1
265 addx %o0,%g2,%o0
266 st %o1,[%o7-8]
267 mov %o0,%i3
268 mov 0,%i2
269 mov %i2,%o0
270 mov %i3,%o1
271 cmp %i5,0
272 ble .LL43
273 add %i5,-1,%i5
274 ld [%g1-4],%i4
275 mov %i4,%g3
276 ld [%g4-4],%i4
277 mov 0,%g2
278 mov %i4,%i1
279 mov 0,%i0
280 addcc %g3,%i1,%g3
281 addx %g2,%i0,%g2
282 addcc %o1,%g3,%o1
283 addx %o0,%g2,%o0
284 st %o1,[%o7-4]
285 mov %o0,%i3
286 mov 0,%i2
287 mov %i2,%o0
288 mov %i3,%o1
289 cmp %i5,0
290 ble .LL43
291 add %i5,-1,%i5
292 ld [%g1],%i4
293 mov %i4,%g3
294 ld [%g4],%i4
295 mov 0,%g2
296 mov %i4,%i1
297 mov 0,%i0
298 addcc %g3,%i1,%g3
299 addx %g2,%i0,%g2
300 addcc %o1,%g3,%o1
301 addx %o0,%g2,%o0
302 st %o1,[%o7]
303 mov %o0,%i3
304 mov 0,%i2
305 mov %i2,%o0
306 mov %i3,%o1
307 cmp %i5,0
308 ble .LL43
309 add %g1,16,%g1
310 add %o3,16,%o3
311 add %g4,16,%g4
312 add %o4,16,%o4
313 add %o7,16,%o7
314 add %o2,16,%o2
315.LL42:
316 ld [%o3],%i4
317 add %i5,-1,%i5
318 mov %i4,%g3
319 ld [%o4],%i4
320 mov 0,%g2
321 mov %i4,%i1
322 mov 0,%i0
323 addcc %g3,%i1,%g3
324 addx %g2,%i0,%g2
325 addcc %o1,%g3,%o1
326 addx %o0,%g2,%o0
327 st %o1,[%o2]
328 mov %o0,%i3
329 mov 0,%i2
330 mov %i2,%o0
331 mov %i3,%o1
332 cmp %i5,0
333 bg,a .LL45
334 ld [%g1-8],%i4
335.LL43:
336 ret
337 restore %g0,%o1,%o0
338.LLfe4:
339 .size bn_add_words,.LLfe4-bn_add_words
340.section ".rodata"
341 .align 8
342.LLC0:
343 .asciz "Division would overflow (%d)\n"
344.section ".text"
345 .align 4
346 .global bn_div64
347 .type bn_div64,#function
348 .proc 016
349bn_div64:
350 !#PROLOGUE# 0
351 save %sp,-112,%sp
352 !#PROLOGUE# 1
353 mov 0,%l1
354 cmp %i2,0
355 bne .LL51
356 mov 2,%l0
357 b .LL68
358 mov -1,%i0
359.LL51:
360 call BN_num_bits_word,0
361 mov %i2,%o0
362 mov %o0,%o2
363 cmp %o2,32
364 be .LL52
365 mov 1,%o0
366 sll %o0,%o2,%o0
367 cmp %i0,%o0
368 bleu .LL69
369 mov 32,%o0
370 sethi %hi(__iob+32),%o0
371 or %o0,%lo(__iob+32),%o0
372 sethi %hi(.LLC0),%o1
373 call fprintf,0
374 or %o1,%lo(.LLC0),%o1
375 call abort,0
376 nop
377.LL52:
378 mov 32,%o0
379.LL69:
380 cmp %i0,%i2
381 blu .LL53
382 sub %o0,%o2,%o2
383 sub %i0,%i2,%i0
384.LL53:
385 cmp %o2,0
386 be .LL54
387 sll %i0,%o2,%o1
388 sll %i2,%o2,%i2
389 sub %o0,%o2,%o0
390 srl %i1,%o0,%o0
391 or %o1,%o0,%i0
392 sll %i1,%o2,%i1
393.LL54:
394 srl %i2,16,%g2
395 sethi %hi(65535),%o0
396 or %o0,%lo(65535),%o1
397 and %i2,%o1,%g3
398 mov %o0,%g4
399 sethi %hi(-65536),%o7
400 mov %o1,%g1
401.LL55:
402 srl %i0,16,%o0
403 cmp %o0,%g2
404 be .LL59
405 or %g4,%lo(65535),%o3
406 wr %g0,%g0,%y
407 nop
408 nop
409 nop
410 udiv %i0,%g2,%o3
411.LL59:
412 and %i1,%o7,%o0
413 srl %o0,16,%o5
414 smul %o3,%g3,%o4
415 smul %o3,%g2,%o2
416.LL60:
417 sub %i0,%o2,%o1
418 andcc %o1,%o7,%g0
419 bne .LL61
420 sll %o1,16,%o0
421 add %o0,%o5,%o0
422 cmp %o4,%o0
423 bleu .LL61
424 sub %o4,%g3,%o4
425 sub %o2,%g2,%o2
426 b .LL60
427 add %o3,-1,%o3
428.LL61:
429 smul %o3,%g2,%o2
430 smul %o3,%g3,%o0
431 srl %o0,16,%o1
432 sll %o0,16,%o0
433 and %o0,%o7,%o0
434 cmp %i1,%o0
435 bgeu .LL65
436 add %o2,%o1,%o2
437 add %o2,1,%o2
438.LL65:
439 cmp %i0,%o2
440 bgeu .LL66
441 sub %i1,%o0,%i1
442 add %i0,%i2,%i0
443 add %o3,-1,%o3
444.LL66:
445 addcc %l0,-1,%l0
446 be .LL56
447 sub %i0,%o2,%i0
448 sll %o3,16,%l1
449 sll %i0,16,%o0
450 srl %i1,16,%o1
451 or %o0,%o1,%i0
452 and %i1,%g1,%o0
453 b .LL55
454 sll %o0,16,%i1
455.LL56:
456 or %l1,%o3,%i0
457.LL68:
458 ret
459 restore
460.LLfe5:
461 .size bn_div64,.LLfe5-bn_div64
462 .ident "GCC: (GNU) 2.7.2.3"
diff --git a/src/lib/libcrypto/bn/asm/x86w16.asm b/src/lib/libcrypto/bn/asm/x86w16.asm
new file mode 100644
index 0000000000..74a933a8cd
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/x86w16.asm
@@ -0,0 +1,297 @@
1; Static Name Aliases
2;
3 TITLE bn_mulw.c
4 .8087
5F_TEXT SEGMENT WORD PUBLIC 'CODE'
6F_TEXT ENDS
7_DATA SEGMENT WORD PUBLIC 'DATA'
8_DATA ENDS
9CONST SEGMENT WORD PUBLIC 'CONST'
10CONST ENDS
11_BSS SEGMENT WORD PUBLIC 'BSS'
12_BSS ENDS
13DGROUP GROUP CONST, _BSS, _DATA
14 ASSUME DS: DGROUP, SS: DGROUP
15F_TEXT SEGMENT
16 ASSUME CS: F_TEXT
17 PUBLIC _bn_mul_add_words
18_bn_mul_add_words PROC FAR
19; Line 58
20 push bp
21 push bx
22 push si
23 push di
24 push ds
25 push es
26 mov bp,sp
27; w = 26
28; num = 24
29; ap = 20
30; rp = 16
31 xor si,si ;c=0;
32 mov di,WORD PTR [bp+16] ; load r
33 mov ds,WORD PTR [bp+18] ; load r
34 mov bx,WORD PTR [bp+20] ; load a
35 mov es,WORD PTR [bp+22] ; load a
36 mov cx,WORD PTR [bp+26] ; load w
37 mov bp,WORD PTR [bp+24] ; load num
38
39 shr bp,1 ; div count by 4 and do groups of 4
40 shr bp,1
41 je $L555
42
43$L546:
44 mov ax,cx
45 mul WORD PTR es:[bx] ; w* *a
46 add ax,WORD PTR ds:[di] ; + *r
47 adc dx,0
48 adc ax,si
49 adc dx,0
50 mov WORD PTR ds:[di],ax
51 mov si,dx
52 ;
53 mov ax,cx
54 mul WORD PTR es:[bx+2] ; w* *a
55 add ax,WORD PTR ds:[di+2] ; + *r
56 adc dx,0
57 adc ax,si
58 adc dx,0
59 mov WORD PTR ds:[di+2],ax
60 mov si,dx
61 ;
62 mov ax,cx
63 mul WORD PTR es:[bx+4] ; w* *a
64 add ax,WORD PTR ds:[di+4] ; + *r
65 adc dx,0
66 adc ax,si
67 adc dx,0
68 mov WORD PTR ds:[di+4],ax
69 mov si,dx
70 ;
71 mov ax,cx
72 mul WORD PTR es:[bx+6] ; w* *a
73 add ax,WORD PTR ds:[di+6] ; + *r
74 adc dx,0
75 adc ax,si
76 adc dx,0
77 mov WORD PTR ds:[di+6],ax
78 mov si,dx
79 ;
80 add bx,8
81 add di,8
82 ;
83 dec bp
84 je $L555
85 jmp $L546
86;
87;
88$L555:
89 mov bp,sp
90 mov bp,WORD PTR [bp+24] ; load num
91 and bp,3
92 dec bp
93 js $L547
94
95 mov ax,cx
96 mul WORD PTR es:[bx] ; w* *a
97 add ax,WORD PTR ds:[di] ; + *r
98 adc dx,0
99 adc ax,si
100 adc dx,0
101 mov WORD PTR ds:[di],ax
102 mov si,dx
103 dec bp
104 js $L547 ; Note that we are now testing for -1
105 ;
106 mov ax,cx
107 mul WORD PTR es:[bx+2] ; w* *a
108 add ax,WORD PTR ds:[di+2] ; + *r
109 adc dx,0
110 adc ax,si
111 adc dx,0
112 mov WORD PTR ds:[di+2],ax
113 mov si,dx
114 dec bp
115 js $L547
116 ;
117 mov ax,cx
118 mul WORD PTR es:[bx+4] ; w* *a
119 add ax,WORD PTR ds:[di+4] ; + *r
120 adc dx,0
121 adc ax,si
122 adc dx,0
123 mov WORD PTR ds:[di+4],ax
124 mov si,dx
125$L547:
126 mov ax,si
127 pop es
128 pop ds
129 pop di
130 pop si
131 pop bx
132 pop bp
133 ret
134 nop
135
136_bn_mul_add_words ENDP
137 PUBLIC _bn_mul_words
138_bn_mul_words PROC FAR
139; Line 76
140 push bp
141 push bx
142 push si
143 push di
144 push ds
145 push es
146 xor si,si
147 mov bp,sp
148 mov di,WORD PTR [bp+16] ; r
149 mov ds,WORD PTR [bp+18]
150 mov bx,WORD PTR [bp+20] ; a
151 mov es,WORD PTR [bp+22]
152 mov cx,WORD PTR [bp+26] ; w
153 mov bp,WORD PTR [bp+24] ; num
154$FC743:
155 mov ax,cx
156 mul WORD PTR es:[bx]
157 add ax,si
158 adc dx,0
159 mov WORD PTR ds:[di],ax
160 mov si,dx
161 dec bp
162 je $L764
163 ;
164 mov ax,cx
165 mul WORD PTR es:[bx+2]
166 add ax,si
167 adc dx,0
168 mov WORD PTR ds:[di+2],ax
169 mov si,dx
170 dec bp
171 je $L764
172 ;
173 mov ax,cx
174 mul WORD PTR es:[bx+4]
175 add ax,si
176 adc dx,0
177 mov WORD PTR ds:[di+4],ax
178 mov si,dx
179 dec bp
180 je $L764
181 ;
182 mov ax,cx
183 mul WORD PTR es:[bx+6]
184 add ax,si
185 adc dx,0
186 mov WORD PTR ds:[di+6],ax
187 mov si,dx
188 dec bp
189 je $L764
190 ;
191 add bx,8
192 add di,8
193 jmp $FC743
194 nop
195$L764:
196 mov ax,si
197 pop es
198 pop ds
199 pop di
200 pop si
201 pop bx
202 pop bp
203 ret
204 nop
205_bn_mul_words ENDP
206 PUBLIC _bn_sqr_words
207_bn_sqr_words PROC FAR
208; Line 92
209 push bp
210 push bx
211 push si
212 push di
213 push ds
214 push es
215 mov bp,sp
216 mov si,WORD PTR [bp+16]
217 mov ds,WORD PTR [bp+18]
218 mov di,WORD PTR [bp+20]
219 mov es,WORD PTR [bp+22]
220 mov bx,WORD PTR [bp+24]
221
222 mov bp,bx ; save a memory lookup later
223 shr bx,1 ; div count by 4 and do groups of 4
224 shr bx,1
225 je $L666
226
227$L765:
228 mov ax,WORD PTR es:[di]
229 mul ax
230 mov WORD PTR ds:[si],ax
231 mov WORD PTR ds:[si+2],dx
232 ;
233 mov ax,WORD PTR es:[di+2]
234 mul ax
235 mov WORD PTR ds:[si+4],ax
236 mov WORD PTR ds:[si+6],dx
237 ;
238 mov ax,WORD PTR es:[di+4]
239 mul ax
240 mov WORD PTR ds:[si+8],ax
241 mov WORD PTR ds:[si+10],dx
242 ;
243 mov ax,WORD PTR es:[di+6]
244 mul ax
245 mov WORD PTR ds:[si+12],ax
246 mov WORD PTR ds:[si+14],dx
247 ;
248 add di,8
249 add si,16
250 dec bx
251 je $L666
252 jmp $L765
253$L666:
254 and bp,3
255 dec bp ; The copied value of bx (num)
256 js $L645
257 ;
258 mov ax,WORD PTR es:[di]
259 mul ax
260 mov WORD PTR ds:[si],ax
261 mov WORD PTR ds:[si+2],dx
262 dec bp
263 js $L645
264 ;
265 mov ax,WORD PTR es:[di+2]
266 mul ax
267 mov WORD PTR ds:[si+4],ax
268 mov WORD PTR ds:[si+6],dx
269 dec bp
270 js $L645
271 ;
272 mov ax,WORD PTR es:[di+4]
273 mul ax
274 mov WORD PTR ds:[si+8],ax
275 mov WORD PTR ds:[si+10],dx
276$L645:
277 pop es
278 pop ds
279 pop di
280 pop si
281 pop bx
282 pop bp
283 ret
284
285_bn_sqr_words ENDP
286 PUBLIC _bn_div64
287_bn_div64 PROC FAR
288 push bp
289 mov bp,sp
290 mov dx, WORD PTR [bp+6]
291 mov ax, WORD PTR [bp+8]
292 div WORD PTR [bp+10]
293 pop bp
294 ret
295_bn_div64 ENDP
296F_TEXT ENDS
297END
diff --git a/src/lib/libcrypto/bn/asm/x86w32.asm b/src/lib/libcrypto/bn/asm/x86w32.asm
new file mode 100644
index 0000000000..fc6f917714
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/x86w32.asm
@@ -0,0 +1,362 @@
1; Static Name Aliases
2;
3 TITLE bn_mulw.c
4 .386
5F_TEXT SEGMENT WORD USE16 PUBLIC 'CODE'
6F_TEXT ENDS
7_DATA SEGMENT WORD USE16 PUBLIC 'DATA'
8_DATA ENDS
9CONST SEGMENT WORD USE16 PUBLIC 'CONST'
10CONST ENDS
11_BSS SEGMENT WORD USE16 PUBLIC 'BSS'
12_BSS ENDS
13DGROUP GROUP CONST, _BSS, _DATA
14 ASSUME DS: DGROUP, SS: DGROUP
15F_TEXT SEGMENT
16 ASSUME CS: F_TEXT
17 PUBLIC _bn_mul_add_words
18_bn_mul_add_words PROC FAR
19; Line 58
20 push bp
21 push bx
22 push esi
23 push di
24 push ds
25 push es
26 mov bp,sp
27; w = 28
28; num = 26
29; ap = 22
30; rp = 18
31 xor esi,esi ;c=0;
32 mov di,WORD PTR [bp+18] ; load r
33 mov ds,WORD PTR [bp+20] ; load r
34 mov bx,WORD PTR [bp+22] ; load a
35 mov es,WORD PTR [bp+24] ; load a
36 mov ecx,DWORD PTR [bp+28] ; load w
37 mov bp,WORD PTR [bp+26] ; load num
38 shr bp,1 ; div count by 4 and do groups of 4
39 shr bp,1
40 je $L555
41
42$L546:
43 mov eax,ecx
44 mul DWORD PTR es:[bx] ; w* *a
45 add eax,DWORD PTR ds:[di] ; + *r
46 adc edx,0
47 adc eax,esi
48 adc edx,0
49 mov DWORD PTR ds:[di],eax
50 mov esi,edx
51 ;
52 mov eax,ecx
53 mul DWORD PTR es:[bx+4] ; w* *a
54 add eax,DWORD PTR ds:[di+4] ; + *r
55 adc edx,0
56 adc eax,esi
57 adc edx,0
58 mov DWORD PTR ds:[di+4],eax
59 mov esi,edx
60 ;
61 mov eax,ecx
62 mul DWORD PTR es:[bx+8] ; w* *a
63 add eax,DWORD PTR ds:[di+8] ; + *r
64 adc edx,0
65 adc eax,esi
66 adc edx,0
67 mov DWORD PTR ds:[di+8],eax
68 mov esi,edx
69 ;
70 mov eax,ecx
71 mul DWORD PTR es:[bx+12] ; w* *a
72 add eax,DWORD PTR ds:[di+12] ; + *r
73 adc edx,0
74 adc eax,esi
75 adc edx,0
76 mov DWORD PTR ds:[di+12],eax
77 mov esi,edx
78 ;
79 add bx,16
80 add di,16
81 ;
82 dec bp
83 je $L555
84 jmp $L546
85;
86;
87$L555:
88 mov bp,sp
89 mov bp,WORD PTR [bp+26] ; load num
90 and bp,3
91 dec bp
92 js $L547
93
94 mov eax,ecx
95 mul DWORD PTR es:[bx] ; w* *a
96 add eax,DWORD PTR ds:[di] ; + *r
97 adc edx,0
98 adc eax,esi
99 adc edx,0
100 mov DWORD PTR ds:[di],eax
101 mov esi,edx
102 dec bp
103 js $L547 ; Note that we are now testing for -1
104 ;
105 mov eax,ecx
106 mul DWORD PTR es:[bx+4] ; w* *a
107 add eax,DWORD PTR ds:[di+4] ; + *r
108 adc edx,0
109 adc eax,esi
110 adc edx,0
111 mov DWORD PTR ds:[di+4],eax
112 mov esi,edx
113 dec bp
114 js $L547
115 ;
116 mov eax,ecx
117 mul DWORD PTR es:[bx+8] ; w* *a
118 add eax,DWORD PTR ds:[di+8] ; + *r
119 adc edx,0
120 adc eax,esi
121 adc edx,0
122 mov DWORD PTR ds:[di+8],eax
123 mov esi,edx
124$L547:
125 mov eax,esi
126 mov edx,esi
127 shr edx,16
128 pop es
129 pop ds
130 pop di
131 pop esi
132 pop bx
133 pop bp
134 ret
135 nop
136_bn_mul_add_words ENDP
137
138 PUBLIC _bn_mul_words
139_bn_mul_words PROC FAR
140; Line 76
141 push bp
142 push bx
143 push esi
144 push di
145 push ds
146 push es
147 xor esi,esi
148 mov bp,sp
149 mov di,WORD PTR [bp+18] ; r
150 mov ds,WORD PTR [bp+20]
151 mov bx,WORD PTR [bp+22] ; a
152 mov es,WORD PTR [bp+24]
153 mov ecx,DWORD PTR [bp+28] ; w
154 mov bp,WORD PTR [bp+26] ; num
155
156$FC743:
157 mov eax,ecx
158 mul DWORD PTR es:[bx]
159 add eax,esi
160 adc edx,0
161 mov DWORD PTR ds:[di],eax
162 mov esi,edx
163 dec bp
164 je $L764
165 ;
166 mov eax,ecx
167 mul DWORD PTR es:[bx+4]
168 add eax,esi
169 adc edx,0
170 mov DWORD PTR ds:[di+4],eax
171 mov esi,edx
172 dec bp
173 je $L764
174 ;
175 mov eax,ecx
176 mul DWORD PTR es:[bx+8]
177 add eax,esi
178 adc edx,0
179 mov DWORD PTR ds:[di+8],eax
180 mov esi,edx
181 dec bp
182 je $L764
183 ;
184 mov eax,ecx
185 mul DWORD PTR es:[bx+12]
186 add eax,esi
187 adc edx,0
188 mov DWORD PTR ds:[di+12],eax
189 mov esi,edx
190 dec bp
191 je $L764
192 ;
193 add bx,16
194 add di,16
195 jmp $FC743
196 nop
197$L764:
198 mov eax,esi
199 mov edx,esi
200 shr edx,16
201 pop es
202 pop ds
203 pop di
204 pop esi
205 pop bx
206 pop bp
207 ret
208 nop
209_bn_mul_words ENDP
210 PUBLIC _bn_sqr_words
211_bn_sqr_words PROC FAR
212; Line 92
213 push bp
214 push bx
215 push si
216 push di
217 push ds
218 push es
219 mov bp,sp
220 mov si,WORD PTR [bp+16]
221 mov ds,WORD PTR [bp+18]
222 mov di,WORD PTR [bp+20]
223 mov es,WORD PTR [bp+22]
224 mov bx,WORD PTR [bp+24]
225
226 mov bp,bx ; save a memory lookup later
227 shr bx,1 ; div count by 4 and do groups of 4
228 shr bx,1
229 je $L666
230
231$L765:
232 mov eax,DWORD PTR es:[di]
233 mul eax
234 mov DWORD PTR ds:[si],eax
235 mov DWORD PTR ds:[si+4],edx
236 ;
237 mov eax,DWORD PTR es:[di+4]
238 mul eax
239 mov DWORD PTR ds:[si+8],eax
240 mov DWORD PTR ds:[si+12],edx
241 ;
242 mov eax,DWORD PTR es:[di+8]
243 mul eax
244 mov DWORD PTR ds:[si+16],eax
245 mov DWORD PTR ds:[si+20],edx
246 ;
247 mov eax,DWORD PTR es:[di+12]
248 mul eax
249 mov DWORD PTR ds:[si+24],eax
250 mov DWORD PTR ds:[si+28],edx
251 ;
252 add di,16
253 add si,32
254 dec bx
255 je $L666
256 jmp $L765
257$L666:
258 and bp,3
259 dec bp ; The copied value of bx (num)
260 js $L645
261 ;
262 mov eax,DWORD PTR es:[di]
263 mul eax
264 mov DWORD PTR ds:[si],eax
265 mov DWORD PTR ds:[si+4],edx
266 dec bp
267 js $L645
268 ;
269 mov eax,DWORD PTR es:[di+4]
270 mul eax
271 mov DWORD PTR ds:[si+8],eax
272 mov DWORD PTR ds:[si+12],edx
273 dec bp
274 js $L645
275 ;
276 mov eax,DWORD PTR es:[di+8]
277 mul eax
278 mov DWORD PTR ds:[si+16],eax
279 mov DWORD PTR ds:[si+20],edx
280$L645:
281 pop es
282 pop ds
283 pop di
284 pop si
285 pop bx
286 pop bp
287 ret
288_bn_sqr_words ENDP
289
290 PUBLIC _bn_div64
291_bn_div64 PROC FAR
292 push bp
293 mov bp,sp
294 mov edx, DWORD PTR [bp+6]
295 mov eax, DWORD PTR [bp+10]
296 div DWORD PTR [bp+14]
297 mov edx,eax
298 shr edx,16
299 pop bp
300 ret
301_bn_div64 ENDP
302
303 PUBLIC _bn_add_words
304_bn_add_words PROC FAR
305; Line 58
306 push bp
307 push bx
308 push esi
309 push di
310 push ds
311 push es
312 mov bp,sp
313; w = 28
314; num = 26
315; ap = 22
316; rp = 18
317 xor esi,esi ;c=0;
318 mov si,WORD PTR [bp+22] ; load a
319 mov es,WORD PTR [bp+24] ; load a
320 mov di,WORD PTR [bp+26] ; load b
321 mov ds,WORD PTR [bp+28] ; load b
322
323 mov dx,WORD PTR [bp+30] ; load num
324 dec dx
325 js $L547
326 xor ecx,ecx
327
328$L5477:
329 xor ebx,ebx
330 mov eax,DWORD PTR es:[si] ; *a
331 add eax,ecx
332 adc ebx,0
333 add si,4 ; a++
334 add eax,DWORD PTR ds:[di] ; + *b
335 mov ecx,ebx
336 adc ecx,0
337 add di,4
338 mov bx,WORD PTR [bp+18]
339 mov ds,WORD PTR [bp+20]
340 mov DWORD PTR ds:[bx],eax
341 add bx,4
342 mov ds,WORD PTR [bp+28]
343 mov WORD PTR [bp+18],bx
344 dec dx
345 js $L547 ; Note that we are now testing for -1
346 jmp $L5477
347 ;
348$L547:
349 mov eax,ecx
350 mov edx,ecx
351 shr edx,16
352 pop es
353 pop ds
354 pop di
355 pop esi
356 pop bx
357 pop bp
358 ret
359 nop
360_bn_add_words ENDP
361F_TEXT ENDS
362END
diff --git a/src/lib/libcrypto/bn/bn.err b/src/lib/libcrypto/bn/bn.err
new file mode 100644
index 0000000000..7ccc247c41
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn.err
@@ -0,0 +1,27 @@
1/* Error codes for the BN functions. */
2
3/* Function codes. */
4#define BN_F_BN_BLINDING_CONVERT 100
5#define BN_F_BN_BLINDING_INVERT 101
6#define BN_F_BN_BLINDING_NEW 102
7#define BN_F_BN_BLINDING_UPDATE 103
8#define BN_F_BN_BN2DEC 104
9#define BN_F_BN_BN2HEX 105
10#define BN_F_BN_CTX_NEW 106
11#define BN_F_BN_DIV 107
12#define BN_F_BN_EXPAND2 108
13#define BN_F_BN_MOD_EXP_MONT 109
14#define BN_F_BN_MOD_INVERSE 110
15#define BN_F_BN_MOD_MUL_RECIPROCAL 111
16#define BN_F_BN_MPI2BN 112
17#define BN_F_BN_NEW 113
18#define BN_F_BN_RAND 114
19
20/* Reason codes. */
21#define BN_R_BAD_RECIPROCAL 100
22#define BN_R_CALLED_WITH_EVEN_MODULUS 101
23#define BN_R_DIV_BY_ZERO 102
24#define BN_R_ENCODING_ERROR 103
25#define BN_R_INVALID_LENGTH 104
26#define BN_R_NOT_INITALISED 105
27#define BN_R_NO_INVERSE 106
diff --git a/src/lib/libcrypto/bn/bn.org b/src/lib/libcrypto/bn/bn.org
new file mode 100644
index 0000000000..66dde285d6
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn.org
@@ -0,0 +1,502 @@
1/* crypto/bn/bn.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify bn.org since bn.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_BN_H
68#define HEADER_BN_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74#undef BN_LLONG
75
76#ifdef WIN32
77#define BN_LLONG /* This comment stops Configure mutilating things */
78#endif
79
80#define RECP_MUL_MOD
81#define MONT_MUL_MOD
82
83/* This next option uses the C libraries (2 word)/(1 word) function.
84 * If it is not defined, I use my C version (which is slower).
85 * The reason for this flag is that when the particular C compiler
86 * library routine is used, and the library is linked with a different
87 * compiler, the library is missing. This mostly happens when the
88 * library is built with gcc and then linked using nornal cc. This would
89 * be a common occurance because gcc normally produces code that is
90 * 2 times faster than system compilers for the big number stuff.
91 * For machines with only one compiler (or shared libraries), this should
92 * be on. Again this in only really a problem on machines
93 * using "long long's", are 32bit, and are not using my assember code. */
94#if defined(MSDOS) || defined(WINDOWS) || defined(linux)
95#define BN_DIV2W
96#endif
97
98/* Only one for the following should be defined */
99/* The prime number generation stuff may not work when
100 * EIGHT_BIT but I don't care since I've only used this mode
101 * for debuging the bignum libraries */
102#undef SIXTY_FOUR_BIT_LONG
103#undef SIXTY_FOUR_BIT
104#define THIRTY_TWO_BIT
105#undef SIXTEEN_BIT
106#undef EIGHT_BIT
107
108/* assuming long is 64bit - this is the DEC Alpha
109 * unsigned long long is only 64 bits :-(, don't define
110 * BN_LLONG for the DEC Alpha */
111#ifdef SIXTY_FOUR_BIT_LONG
112#define BN_ULLONG unsigned long long
113#define BN_ULONG unsigned long
114#define BN_LONG long
115#define BN_BITS 128
116#define BN_BYTES 8
117#define BN_BITS2 64
118#define BN_BITS4 32
119#define BN_MASK2 (0xffffffffffffffffL)
120#define BN_MASK2l (0xffffffffL)
121#define BN_MASK2h (0xffffffff00000000L)
122#define BN_MASK2h1 (0xffffffff80000000L)
123#define BN_TBIT (0x8000000000000000L)
124#define BN_DEC_CONV (10000000000000000000L)
125#define BN_DEC_FMT1 "%lu"
126#define BN_DEC_FMT2 "%019lu"
127#define BN_DEC_NUM 19
128#endif
129
130#ifdef SIXTY_FOUR_BIT
131#undef BN_LLONG
132/* #define BN_ULLONG unsigned long long */
133#define BN_ULONG unsigned long long
134#define BN_LONG long long
135#define BN_BITS 128
136#define BN_BYTES 8
137#define BN_BITS2 64
138#define BN_BITS4 32
139#define BN_MASK2 (0xffffffffffffffffLL)
140#define BN_MASK2l (0xffffffffL)
141#define BN_MASK2h (0xffffffff00000000LL)
142#define BN_MASK2h1 (0xffffffff80000000LL)
143#define BN_TBIT (0x8000000000000000LL)
144#define BN_DEC_CONV (10000000000000000000L)
145#define BN_DEC_FMT1 "%lu"
146#define BN_DEC_FMT2 "%019lu"
147#define BN_DEC_NUM 19
148#endif
149
150#ifdef THIRTY_TWO_BIT
151#ifdef WIN32
152#define BN_ULLONG unsigned _int64
153#else
154#define BN_ULLONG unsigned long long
155#endif
156#define BN_ULONG unsigned long
157#define BN_LONG long
158#define BN_BITS 64
159#define BN_BYTES 4
160#define BN_BITS2 32
161#define BN_BITS4 16
162#define BN_MASK2 (0xffffffffL)
163#define BN_MASK2l (0xffff)
164#define BN_MASK2h1 (0xffff8000L)
165#define BN_MASK2h (0xffff0000L)
166#define BN_TBIT (0x80000000L)
167#define BN_DEC_CONV (1000000000L)
168#define BN_DEC_FMT1 "%lu"
169#define BN_DEC_FMT2 "%09lu"
170#define BN_DEC_NUM 9
171#endif
172
173#ifdef SIXTEEN_BIT
174#ifndef BN_DIV2W
175#define BN_DIV2W
176#endif
177#define BN_ULLONG unsigned long
178#define BN_ULONG unsigned short
179#define BN_LONG short
180#define BN_BITS 32
181#define BN_BYTES 2
182#define BN_BITS2 16
183#define BN_BITS4 8
184#define BN_MASK2 (0xffff)
185#define BN_MASK2l (0xff)
186#define BN_MASK2h1 (0xff80)
187#define BN_MASK2h (0xff00)
188#define BN_TBIT (0x8000)
189#define BN_DEC_CONV (100000)
190#define BN_DEC_FMT1 "%u"
191#define BN_DEC_FMT2 "%05u"
192#define BN_DEC_NUM 5
193#endif
194
195#ifdef EIGHT_BIT
196#ifndef BN_DIV2W
197#define BN_DIV2W
198#endif
199#define BN_ULLONG unsigned short
200#define BN_ULONG unsigned char
201#define BN_LONG char
202#define BN_BITS 16
203#define BN_BYTES 1
204#define BN_BITS2 8
205#define BN_BITS4 4
206#define BN_MASK2 (0xff)
207#define BN_MASK2l (0xf)
208#define BN_MASK2h1 (0xf8)
209#define BN_MASK2h (0xf0)
210#define BN_TBIT (0x80)
211#define BN_DEC_CONV (100)
212#define BN_DEC_FMT1 "%u"
213#define BN_DEC_FMT2 "%02u"
214#define BN_DEC_NUM 2
215#endif
216
217#define BN_DEFAULT_BITS 1280
218
219#ifdef BIGNUM
220#undef BIGNUM
221#endif
222
223typedef struct bignum_st
224 {
225 BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
226 int top; /* Index of last used d +1. */
227 /* The next are internal book keeping for bn_expand. */
228 int max; /* Size of the d array. */
229 int neg; /* one if the number is negative */
230 } BIGNUM;
231
232/* Used for temp variables */
233#define BN_CTX_NUM 12
234typedef struct bignum_ctx
235 {
236 int tos;
237 BIGNUM *bn[BN_CTX_NUM+1];
238 } BN_CTX;
239
240typedef struct bn_blinding_st
241 {
242 int init;
243 BIGNUM *A;
244 BIGNUM *Ai;
245 BIGNUM *mod; /* just a reference */
246 } BN_BLINDING;
247
248/* Used for montgomery multiplication */
249typedef struct bn_mont_ctx_st
250 {
251 int ri; /* number of bits in R */
252 BIGNUM *RR; /* used to convert to montgomery form */
253 BIGNUM *N; /* The modulus */
254 BIGNUM *Ni; /* The inverse of N */
255 BN_ULONG n0; /* word form of inverse, normally only one of
256 * Ni or n0 is defined */
257 } BN_MONT_CTX;
258
259#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
260 r,a,(mont)->RR,(mont),ctx)
261
262#define BN_prime_checks (5)
263
264#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
265#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w)))
266#define BN_is_zero(a) (((a)->top <= 1) && ((a)->d[0] == (BN_ULONG)0))
267#define BN_is_one(a) (BN_is_word((a),1))
268#define BN_is_odd(a) ((a)->d[0] & 1)
269#define BN_one(a) (BN_set_word((a),1))
270#define BN_zero(a) (BN_set_word((a),0))
271
272#define BN_ascii2bn(a) BN_hex2bn(a)
273#define BN_bn2ascii(a) BN_bn2hex(a)
274
275#define bn_fix_top(a) \
276 { \
277 BN_ULONG *fix_top_l; \
278 for (fix_top_l= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
279 if (*(fix_top_l--)) break; \
280 }
281
282#define bn_expand(n,b) ((((b)/BN_BITS2) <= (n)->max)?\
283 (n):bn_expand2((n),(b)/BN_BITS2))
284#define bn_wexpand(n,b) (((b) <= (n)->max)?(n):bn_expand2((n),(b)))
285
286
287#ifndef NOPROTO
288BIGNUM *BN_value_one(void);
289char * BN_options(void);
290BN_CTX *BN_CTX_new(void);
291void BN_CTX_free(BN_CTX *c);
292int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
293int BN_num_bits(BIGNUM *a);
294int BN_num_bits_word(BN_ULONG);
295BIGNUM *BN_new(void);
296void BN_clear_free(BIGNUM *a);
297BIGNUM *BN_copy(BIGNUM *a, BIGNUM *b);
298BIGNUM *BN_bin2bn(unsigned char *s,int len,BIGNUM *ret);
299int BN_bn2bin(BIGNUM *a, unsigned char *to);
300BIGNUM *BN_mpi2bn(unsigned char *s,int len,BIGNUM *ret);
301int BN_bn2mpi(BIGNUM *a, unsigned char *to);
302int BN_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b);
303void bn_qsub(BIGNUM *r, BIGNUM *a, BIGNUM *b);
304void bn_qadd(BIGNUM *r, BIGNUM *a, BIGNUM *b);
305int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b);
306int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx);
307int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx);
308int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b);
309int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx);
310BN_ULONG BN_mod_word(BIGNUM *a, unsigned long w);
311BN_ULONG BN_div_word(BIGNUM *a, unsigned long w);
312int BN_mul_word(BIGNUM *a, unsigned long w);
313int BN_add_word(BIGNUM *a, unsigned long w);
314int BN_sub_word(BIGNUM *a, unsigned long w);
315int BN_set_word(BIGNUM *a, unsigned long w);
316unsigned long BN_get_word(BIGNUM *a);
317int BN_cmp(BIGNUM *a, BIGNUM *b);
318void BN_free(BIGNUM *a);
319int BN_is_bit_set(BIGNUM *a, int n);
320int BN_lshift(BIGNUM *r, BIGNUM *a, int n);
321int BN_lshift1(BIGNUM *r, BIGNUM *a);
322int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p,BN_CTX *ctx);
323int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx);
324int BN_mod_exp_mont(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx,
325 BN_MONT_CTX *m_ctx);
326int BN_mod_exp_recp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx);
327int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p,
328 BIGNUM *m,BN_CTX *ctx);
329int BN_mask_bits(BIGNUM *a,int n);
330int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BIGNUM *m,
331 BIGNUM *i, int nb, BN_CTX *ctx);
332int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, BIGNUM *m,
333 BN_CTX *ctx);
334#ifndef WIN16
335int BN_print_fp(FILE *fp, BIGNUM *a);
336#endif
337#ifdef HEADER_BIO_H
338int BN_print(BIO *fp, BIGNUM *a);
339#else
340int BN_print(char *fp, BIGNUM *a);
341#endif
342int BN_reciprocal(BIGNUM *r, BIGNUM *m, BN_CTX *ctx);
343int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
344int BN_rshift1(BIGNUM *r, BIGNUM *a);
345void BN_clear(BIGNUM *a);
346BIGNUM *bn_expand2(BIGNUM *b, int bits);
347BIGNUM *BN_dup(BIGNUM *a);
348int BN_ucmp(BIGNUM *a, BIGNUM *b);
349int BN_set_bit(BIGNUM *a, int n);
350int BN_clear_bit(BIGNUM *a, int n);
351char * BN_bn2hex(BIGNUM *a);
352char * BN_bn2dec(BIGNUM *a);
353int BN_hex2bn(BIGNUM **a,char *str);
354int BN_dec2bn(BIGNUM **a,char *str);
355int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx);
356BIGNUM *BN_mod_inverse(BIGNUM *a, BIGNUM *n,BN_CTX *ctx);
357BIGNUM *BN_generate_prime(int bits,int strong,BIGNUM *add,
358 BIGNUM *rem,void (*callback)(int,int,char *),char *cb_arg);
359int BN_is_prime(BIGNUM *p,int nchecks,void (*callback)(int,int,char *),
360 BN_CTX *ctx,char *cb_arg);
361void ERR_load_BN_strings(void );
362
363BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
364BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
365void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
366BN_ULONG bn_div64(BN_ULONG h, BN_ULONG l, BN_ULONG d);
367BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
368
369BN_MONT_CTX *BN_MONT_CTX_new(void );
370int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont,
371 BN_CTX *ctx);
372int BN_from_montgomery(BIGNUM *r,BIGNUM *a,BN_MONT_CTX *mont,BN_CTX *ctx);
373void BN_MONT_CTX_free(BN_MONT_CTX *mont);
374int BN_MONT_CTX_set(BN_MONT_CTX *mont,BIGNUM *modulus,BN_CTX *ctx);
375
376BN_BLINDING *BN_BLINDING_new(BIGNUM *A,BIGNUM *Ai,BIGNUM *mod);
377void BN_BLINDING_free(BN_BLINDING *b);
378int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
379int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *r, BN_CTX *ctx);
380int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
381
382#else
383
384BIGNUM *BN_value_one();
385char * BN_options();
386BN_CTX *BN_CTX_new();
387void BN_CTX_free();
388int BN_rand();
389int BN_num_bits();
390int BN_num_bits_word();
391BIGNUM *BN_new();
392void BN_clear_free();
393BIGNUM *BN_copy();
394BIGNUM *BN_bin2bn();
395int BN_bn2bin();
396BIGNUM *BN_mpi2bn();
397int BN_bn2mpi();
398int BN_sub();
399void bn_qsub();
400void bn_qadd();
401int BN_add();
402int BN_mod();
403int BN_div();
404int BN_mul();
405int BN_sqr();
406BN_ULONG BN_mod_word();
407BN_ULONG BN_div_word();
408int BN_add_word();
409int BN_sub_word();
410int BN_mul_word();
411int BN_set_word();
412unsigned long BN_get_word();
413int BN_cmp();
414void BN_free();
415int BN_is_bit_set();
416int BN_lshift();
417int BN_lshift1();
418int BN_exp();
419int BN_mod_exp();
420int BN_mod_exp_mont();
421int BN_mod_exp_recp();
422int BN_mod_exp_simple();
423int BN_mask_bits();
424int BN_mod_mul_reciprocal();
425int BN_mod_mul();
426#ifndef WIN16
427int BN_print_fp();
428#endif
429int BN_print();
430int BN_reciprocal();
431int BN_rshift();
432int BN_rshift1();
433void BN_clear();
434BIGNUM *bn_expand2();
435BIGNUM *BN_dup();
436int BN_ucmp();
437int BN_set_bit();
438int BN_clear_bit();
439char * BN_bn2hex();
440char * BN_bn2dec();
441int BN_hex2bn();
442int BN_dec2bn();
443int BN_gcd();
444BIGNUM *BN_mod_inverse();
445BIGNUM *BN_generate_prime();
446int BN_is_prime();
447void ERR_load_BN_strings();
448
449BN_ULONG bn_mul_add_words();
450BN_ULONG bn_mul_words();
451void bn_sqr_words();
452BN_ULONG bn_div64();
453BN_ULONG bn_add_words();
454
455int BN_mod_mul_montgomery();
456int BN_from_montgomery();
457BN_MONT_CTX *BN_MONT_CTX_new();
458void BN_MONT_CTX_free();
459int BN_MONT_CTX_set();
460
461BN_BLINDING *BN_BLINDING_new();
462void BN_BLINDING_free();
463int BN_BLINDING_update();
464int BN_BLINDING_convert();
465int BN_BLINDING_invert();
466
467#endif
468
469/* BEGIN ERROR CODES */
470/* Error codes for the BN functions. */
471
472/* Function codes. */
473#define BN_F_BN_BLINDING_CONVERT 100
474#define BN_F_BN_BLINDING_INVERT 101
475#define BN_F_BN_BLINDING_NEW 102
476#define BN_F_BN_BLINDING_UPDATE 103
477#define BN_F_BN_BN2DEC 104
478#define BN_F_BN_BN2HEX 105
479#define BN_F_BN_CTX_NEW 106
480#define BN_F_BN_DIV 107
481#define BN_F_BN_EXPAND2 108
482#define BN_F_BN_MOD_EXP_MONT 109
483#define BN_F_BN_MOD_INVERSE 110
484#define BN_F_BN_MOD_MUL_RECIPROCAL 111
485#define BN_F_BN_MPI2BN 112
486#define BN_F_BN_NEW 113
487#define BN_F_BN_RAND 114
488
489/* Reason codes. */
490#define BN_R_BAD_RECIPROCAL 100
491#define BN_R_CALLED_WITH_EVEN_MODULUS 101
492#define BN_R_DIV_BY_ZERO 102
493#define BN_R_ENCODING_ERROR 103
494#define BN_R_INVALID_LENGTH 104
495#define BN_R_NOT_INITALISED 105
496#define BN_R_NO_INVERSE 106
497
498#ifdef __cplusplus
499}
500#endif
501#endif
502
diff --git a/src/lib/libcrypto/bn/bn_m.c b/src/lib/libcrypto/bn/bn_m.c
new file mode 100644
index 0000000000..5166daaeec
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn_m.c
@@ -0,0 +1,169 @@
1/* crypto/bn/bn_m.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn_lcl.h"
62#include "stack.h"
63
64int limit=16;
65
66typedef struct bn_pool_st
67 {
68 int used;
69 int tos;
70 STACK *sk;
71 } BN_POOL;
72
73BIGNUM *BN_POOL_push(bp)
74BN_POOL *bp;
75 {
76 BIGNUM *ret;
77
78 if (bp->used >= bp->tos)
79 {
80 ret=BN_new();
81 sk_push(bp->sk,(char *)ret);
82 bp->tos++;
83 bp->used++;
84 }
85 else
86 {
87 ret=(BIGNUM *)sk_value(bp->sk,bp->used);
88 bp->used++;
89 }
90 return(ret);
91 }
92
93void BN_POOL_pop(bp,num)
94BN_POOL *bp;
95int num;
96 {
97 bp->used-=num;
98 }
99
100int BN_m(r,a,b)
101BIGNUM *r,*a,*b;
102 {
103 static BN_POOL bp;
104 static init=1;
105
106 if (init)
107 {
108 bp.used=0;
109 bp.tos=0;
110 bp.sk=sk_new_null();
111 init=0;
112 }
113 return(BN_mm(r,a,b,&bp));
114 }
115
116/* r must be different to a and b */
117int BN_mm(m, A, B, bp)
118BIGNUM *m,*A,*B;
119BN_POOL *bp;
120 {
121 int i,num;
122 int an,bn;
123 BIGNUM *a,*b,*c,*d,*ac,*bd;
124
125 an=A->top;
126 bn=B->top;
127 if ((an <= limit) || (bn <= limit))
128 {
129 return(BN_mul(m,A,B));
130 }
131
132 a=BN_POOL_push(bp);
133 b=BN_POOL_push(bp);
134 c=BN_POOL_push(bp);
135 d=BN_POOL_push(bp);
136 ac=BN_POOL_push(bp);
137 bd=BN_POOL_push(bp);
138
139 num=(an <= bn)?an:bn;
140 num=1<<(BN_num_bits_word(num-1)-1);
141
142 /* Are going to now chop things into 'num' word chunks. */
143 num*=BN_BITS2;
144
145 BN_copy(a,A);
146 BN_mask_bits(a,num);
147 BN_rshift(b,A,num);
148
149 BN_copy(c,B);
150 BN_mask_bits(c,num);
151 BN_rshift(d,B,num);
152
153 BN_sub(ac ,b,a);
154 BN_sub(bd,c,d);
155 BN_mm(m,ac,bd,bp);
156 BN_mm(ac,a,c,bp);
157 BN_mm(bd,b,d,bp);
158
159 BN_add(m,m,ac);
160 BN_add(m,m,bd);
161 BN_lshift(m,m,num);
162 BN_lshift(bd,bd,num*2);
163
164 BN_add(m,m,ac);
165 BN_add(m,m,bd);
166 BN_POOL_pop(bp,6);
167 return(1);
168 }
169
diff --git a/src/lib/libcrypto/bn/bn_mulw.c b/src/lib/libcrypto/bn/bn_mulw.c
new file mode 100644
index 0000000000..abfc7e4d6c
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn_mulw.c
@@ -0,0 +1,366 @@
1/* crypto/bn/bn_mulw.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn_lcl.h"
62
63#ifdef BN_LLONG
64
65BN_ULONG bn_mul_add_words(rp,ap,num,w)
66BN_ULONG *rp,*ap;
67int num;
68BN_ULONG w;
69 {
70 BN_ULONG c1=0;
71
72 for (;;)
73 {
74 mul_add(rp[0],ap[0],w,c1);
75 if (--num == 0) break;
76 mul_add(rp[1],ap[1],w,c1);
77 if (--num == 0) break;
78 mul_add(rp[2],ap[2],w,c1);
79 if (--num == 0) break;
80 mul_add(rp[3],ap[3],w,c1);
81 if (--num == 0) break;
82 ap+=4;
83 rp+=4;
84 }
85
86 return(c1);
87 }
88
89BN_ULONG bn_mul_words(rp,ap,num,w)
90BN_ULONG *rp,*ap;
91int num;
92BN_ULONG w;
93 {
94 BN_ULONG c1=0;
95
96 for (;;)
97 {
98 mul(rp[0],ap[0],w,c1);
99 if (--num == 0) break;
100 mul(rp[1],ap[1],w,c1);
101 if (--num == 0) break;
102 mul(rp[2],ap[2],w,c1);
103 if (--num == 0) break;
104 mul(rp[3],ap[3],w,c1);
105 if (--num == 0) break;
106 ap+=4;
107 rp+=4;
108 }
109 return(c1);
110 }
111
112void bn_sqr_words(r,a,n)
113BN_ULONG *r,*a;
114int n;
115 {
116 for (;;)
117 {
118 BN_ULLONG t;
119
120 t=(BN_ULLONG)(a[0])*(a[0]);
121 r[0]=Lw(t); r[1]=Hw(t);
122 if (--n == 0) break;
123
124 t=(BN_ULLONG)(a[1])*(a[1]);
125 r[2]=Lw(t); r[3]=Hw(t);
126 if (--n == 0) break;
127
128 t=(BN_ULLONG)(a[2])*(a[2]);
129 r[4]=Lw(t); r[5]=Hw(t);
130 if (--n == 0) break;
131
132 t=(BN_ULLONG)(a[3])*(a[3]);
133 r[6]=Lw(t); r[7]=Hw(t);
134 if (--n == 0) break;
135
136 a+=4;
137 r+=8;
138 }
139 }
140
141BN_ULONG bn_add_words(r,a,b,n)
142BN_ULONG *r,*a,*b;
143int n;
144 {
145 BN_ULLONG ll;
146
147 ll=0;
148 for (;;)
149 {
150 ll+= (BN_ULLONG)a[0]+b[0];
151 r[0]=(BN_ULONG)ll&BN_MASK2;
152 ll>>=BN_BITS2;
153 if (--n <= 0) break;
154
155 ll+= (BN_ULLONG)a[1]+b[1];
156 r[1]=(BN_ULONG)ll&BN_MASK2;
157 ll>>=BN_BITS2;
158 if (--n <= 0) break;
159
160 ll+= (BN_ULLONG)a[2]+b[2];
161 r[2]=(BN_ULONG)ll&BN_MASK2;
162 ll>>=BN_BITS2;
163 if (--n <= 0) break;
164
165 ll+= (BN_ULLONG)a[3]+b[3];
166 r[3]=(BN_ULONG)ll&BN_MASK2;
167 ll>>=BN_BITS2;
168 if (--n <= 0) break;
169
170 a+=4;
171 b+=4;
172 r+=4;
173 }
174 return(ll&BN_MASK2);
175 }
176
177#else
178
179BN_ULONG bn_mul_add_words(rp,ap,num,w)
180BN_ULONG *rp,*ap;
181int num;
182BN_ULONG w;
183 {
184 BN_ULONG c=0;
185 BN_ULONG bl,bh;
186
187 bl=LBITS(w);
188 bh=HBITS(w);
189
190 for (;;)
191 {
192 mul_add(rp[0],ap[0],bl,bh,c);
193 if (--num == 0) break;
194 mul_add(rp[1],ap[1],bl,bh,c);
195 if (--num == 0) break;
196 mul_add(rp[2],ap[2],bl,bh,c);
197 if (--num == 0) break;
198 mul_add(rp[3],ap[3],bl,bh,c);
199 if (--num == 0) break;
200 ap+=4;
201 rp+=4;
202 }
203 return(c);
204 }
205
206BN_ULONG bn_mul_words(rp,ap,num,w)
207BN_ULONG *rp,*ap;
208int num;
209BN_ULONG w;
210 {
211 BN_ULONG carry=0;
212 BN_ULONG bl,bh;
213
214 bl=LBITS(w);
215 bh=HBITS(w);
216
217 for (;;)
218 {
219 mul(rp[0],ap[0],bl,bh,carry);
220 if (--num == 0) break;
221 mul(rp[1],ap[1],bl,bh,carry);
222 if (--num == 0) break;
223 mul(rp[2],ap[2],bl,bh,carry);
224 if (--num == 0) break;
225 mul(rp[3],ap[3],bl,bh,carry);
226 if (--num == 0) break;
227 ap+=4;
228 rp+=4;
229 }
230 return(carry);
231 }
232
233void bn_sqr_words(r,a,n)
234BN_ULONG *r,*a;
235int n;
236 {
237 for (;;)
238 {
239 sqr64(r[0],r[1],a[0]);
240 if (--n == 0) break;
241
242 sqr64(r[2],r[3],a[1]);
243 if (--n == 0) break;
244
245 sqr64(r[4],r[5],a[2]);
246 if (--n == 0) break;
247
248 sqr64(r[6],r[7],a[3]);
249 if (--n == 0) break;
250
251 a+=4;
252 r+=8;
253 }
254 }
255
256BN_ULONG bn_add_words(r,a,b,n)
257BN_ULONG *r,*a,*b;
258int n;
259 {
260 BN_ULONG t1,t2;
261 int carry,i;
262
263 carry=0;
264 for (i=0; i<n; i++)
265 {
266 t1= *(a++);
267 t2= *(b++);
268 if (carry)
269 {
270 carry=(t2 >= ((~t1)&BN_MASK2));
271 t2=(t1+t2+1)&BN_MASK2;
272 }
273 else
274 {
275 t2=(t1+t2)&BN_MASK2;
276 carry=(t2<t1);
277 }
278 *(r++)=t2;
279 }
280 return(carry);
281 }
282
283#endif
284
285#if defined(BN_LLONG) && defined(BN_DIV2W)
286
287BN_ULONG bn_div64(h,l,d)
288BN_ULONG h,l,d;
289 {
290 return((BN_ULONG)(((((BN_ULLONG)h)<<BN_BITS2)|l)/(BN_ULLONG)d));
291 }
292
293#else
294
295/* Divide h-l by d and return the result. */
296/* I need to test this some more :-( */
297BN_ULONG bn_div64(h,l,d)
298BN_ULONG h,l,d;
299 {
300 BN_ULONG dh,dl,q,ret=0,th,tl,t;
301 int i,count=2;
302
303 if (d == 0) return(BN_MASK2);
304
305 i=BN_num_bits_word(d);
306 if ((i != BN_BITS2) && (h > (BN_ULONG)1<<i))
307 {
308#if !defined(NO_STDIO) && !defined(WIN16)
309 fprintf(stderr,"Division would overflow (%d)\n",i);
310#endif
311 abort();
312 }
313 i=BN_BITS2-i;
314 if (h >= d) h-=d;
315
316 if (i)
317 {
318 d<<=i;
319 h=(h<<i)|(l>>(BN_BITS2-i));
320 l<<=i;
321 }
322 dh=(d&BN_MASK2h)>>BN_BITS4;
323 dl=(d&BN_MASK2l);
324 for (;;)
325 {
326 if ((h>>BN_BITS4) == dh)
327 q=BN_MASK2l;
328 else
329 q=h/dh;
330
331 for (;;)
332 {
333 t=(h-q*dh);
334 if ((t&BN_MASK2h) ||
335 ((dl*q) <= (
336 (t<<BN_BITS4)+
337 ((l&BN_MASK2h)>>BN_BITS4))))
338 break;
339 q--;
340 }
341 th=q*dh;
342 tl=q*dl;
343 t=(tl>>BN_BITS4);
344 tl=(tl<<BN_BITS4)&BN_MASK2h;
345 th+=t;
346
347 if (l < tl) th++;
348 l-=tl;
349 if (h < th)
350 {
351 h+=d;
352 q--;
353 }
354 h-=th;
355
356 if (--count == 0) break;
357
358 ret=q<<BN_BITS4;
359 h=((h<<BN_BITS4)|(l>>BN_BITS4))&BN_MASK2;
360 l=(l&BN_MASK2l)<<BN_BITS4;
361 }
362 ret|=q;
363 return(ret);
364 }
365#endif
366
diff --git a/src/lib/libcrypto/bn/bn_sub.c b/src/lib/libcrypto/bn/bn_sub.c
new file mode 100644
index 0000000000..bba80f8afb
--- /dev/null
+++ b/src/lib/libcrypto/bn/bn_sub.c
@@ -0,0 +1,180 @@
1/* crypto/bn/bn_sub.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn_lcl.h"
62
63/* unsigned subtraction of b from a, a must be larger than b. */
64void bn_qsub(r, a, b)
65BIGNUM *r;
66BIGNUM *a;
67BIGNUM *b;
68 {
69 int max,min;
70 register BN_ULONG t1,t2,*ap,*bp,*rp;
71 int i,carry;
72#if defined(IRIX_CC_BUG) && !defined(LINT)
73 int dummy;
74#endif
75
76 max=a->top;
77 min=b->top;
78 ap=a->d;
79 bp=b->d;
80 rp=r->d;
81
82 carry=0;
83 for (i=0; i<min; i++)
84 {
85 t1= *(ap++);
86 t2= *(bp++);
87 if (carry)
88 {
89 carry=(t1 <= t2);
90 t1=(t1-t2-1)&BN_MASK2;
91 }
92 else
93 {
94 carry=(t1 < t2);
95 t1=(t1-t2)&BN_MASK2;
96 }
97#if defined(IRIX_CC_BUG) && !defined(LINT)
98 dummy=t1;
99#endif
100 *(rp++)=t1&BN_MASK2;
101 }
102 if (carry) /* subtracted */
103 {
104 while (i < max)
105 {
106 i++;
107 t1= *(ap++);
108 t2=(t1-1)&BN_MASK2;
109 *(rp++)=t2;
110 if (t1 > t2) break;
111 }
112 }
113#if 0
114 memcpy(rp,ap,sizeof(*rp)*(max-i));
115#else
116 for (; i<max; i++)
117 *(rp++)= *(ap++);
118#endif
119
120 r->top=max;
121 bn_fix_top(r);
122 }
123
124int BN_sub(r, a, b)
125BIGNUM *r;
126BIGNUM *a;
127BIGNUM *b;
128 {
129 int max,i;
130 int add=0,neg=0;
131 BIGNUM *tmp;
132
133 /* a - b a-b
134 * a - -b a+b
135 * -a - b -(a+b)
136 * -a - -b b-a
137 */
138 if (a->neg)
139 {
140 if (b->neg)
141 { tmp=a; a=b; b=tmp; }
142 else
143 { add=1; neg=1; }
144 }
145 else
146 {
147 if (b->neg) { add=1; neg=0; }
148 }
149
150 if (add)
151 {
152 /* As a fast max size, do a a->top | b->top */
153 i=(a->top | b->top)+1;
154 if (bn_wexpand(r,i) == NULL)
155 return(0);
156 if (i)
157 bn_qadd(r,a,b);
158 else
159 bn_qadd(r,b,a);
160 r->neg=neg;
161 return(1);
162 }
163
164 /* We are actually doing a - b :-) */
165
166 max=(a->top > b->top)?a->top:b->top;
167 if (bn_wexpand(r,max) == NULL) return(0);
168 if (BN_ucmp(a,b) < 0)
169 {
170 bn_qsub(r,b,a);
171 r->neg=1;
172 }
173 else
174 {
175 bn_qsub(r,a,b);
176 r->neg=0;
177 }
178 return(1);
179 }
180
diff --git a/src/lib/libcrypto/buffer/Makefile.ssl b/src/lib/libcrypto/buffer/Makefile.ssl
new file mode 100644
index 0000000000..a5f150e523
--- /dev/null
+++ b/src/lib/libcrypto/buffer/Makefile.ssl
@@ -0,0 +1,84 @@
1#
2# SSLeay/crypto/buffer/Makefile
3#
4
5DIR= buffer
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=buffer
19ERRC=buf_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= buffer.c $(ERRC).c
26LIBOBJ= buffer.o $(ERRC).o
27
28SRC= $(LIBSRC)
29
30EXHEADER= buffer.h
31HEADER= $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: lib
39
40lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/util/ranlib.sh $(LIB)
43 @touch lib
44
45files:
46 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
47
48links:
49 /bin/rm -f Makefile
50 $(TOP)/util/point.sh Makefile.ssl Makefile;
51 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
52 $(TOP)/util/mklink.sh ../../test $(TEST)
53 $(TOP)/util/mklink.sh ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALLTOP)/include/$$i; \
59 chmod 644 $(INSTALLTOP)/include/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
72
73dclean:
74 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80errors:
81 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
82 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
83
84# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/buffer/buffer.err b/src/lib/libcrypto/buffer/buffer.err
new file mode 100644
index 0000000000..62b775e637
--- /dev/null
+++ b/src/lib/libcrypto/buffer/buffer.err
@@ -0,0 +1,9 @@
1/* Error codes for the BUF functions. */
2
3/* Function codes. */
4#define BUF_F_BUF_MEM_GROW 100
5#define BUF_F_BUF_MEM_NEW 101
6#define BUF_F_BUF_STRDUP 102
7#define BUF_F_PXYCLNT_READ 103
8
9/* Reason codes. */
diff --git a/src/lib/libcrypto/cast/Makefile.ssl b/src/lib/libcrypto/cast/Makefile.ssl
new file mode 100644
index 0000000000..0143827ae5
--- /dev/null
+++ b/src/lib/libcrypto/cast/Makefile.ssl
@@ -0,0 +1,109 @@
1#
2# SSLeay/crypto/cast/Makefile
3#
4
5DIR= cast
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17CAST_ENC=c_enc.o
18# or use
19#CAST_ENC=asm/cx86-elf.o
20#CAST_ENC=asm/cx86-out.o
21#CAST_ENC=asm/cx86-sol.o
22#CAST_ENC=asm/cx86bdsi.o
23
24CFLAGS= $(INCLUDES) $(CFLAG)
25
26GENERAL=Makefile
27TEST=casttest.c
28APPS=
29
30LIB=$(TOP)/libcrypto.a
31LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
32LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o
33
34SRC= $(LIBSRC)
35
36EXHEADER= cast.h
37HEADER= cast_s.h cast_lcl.h $(EXHEADER)
38
39ALL= $(GENERAL) $(SRC) $(HEADER)
40
41top:
42 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
43
44all: lib
45
46lib: $(LIBOBJ)
47 $(AR) $(LIB) $(LIBOBJ)
48 sh $(TOP)/util/ranlib.sh $(LIB)
49 @touch lib
50
51# elf
52asm/cx86-elf.o: asm/cx86unix.cpp
53 $(CPP) -DELF asm/cx86unix.cpp | as -o asm/cx86-elf.o
54
55# solaris
56asm/cx86-sol.o: asm/cx86unix.cpp
57 $(CC) -E -DSOL asm/cx86unix.cpp | sed 's/^#.*//' > asm/cx86-sol.s
58 as -o asm/cx86-sol.o asm/cx86-sol.s
59 rm -f asm/cx86-sol.s
60
61# a.out
62asm/cx86-out.o: asm/cx86unix.cpp
63 $(CPP) -DOUT asm/cx86unix.cpp | as -o asm/cx86-out.o
64
65# bsdi
66asm/cx86bsdi.o: asm/cx86unix.cpp
67 $(CPP) -DBSDI asm/cx86unix.cpp | as -o asm/cx86bsdi.o
68
69asm/cx86unix.cpp:
70 (cd asm; perl cast-586.pl cpp >cx86unix.cpp)
71
72files:
73 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
74
75links:
76 /bin/rm -f Makefile
77 $(TOP)/util/point.sh Makefile.ssl Makefile ;
78 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
79 $(TOP)/util/mklink.sh ../../test $(TEST)
80 $(TOP)/util/mklink.sh ../../apps $(APPS)
81
82install:
83 @for i in $(EXHEADER) ; \
84 do \
85 (cp $$i $(INSTALLTOP)/include/$$i; \
86 chmod 644 $(INSTALLTOP)/include/$$i ); \
87 done;
88
89tags:
90 ctags $(SRC)
91
92tests:
93
94lint:
95 lint -DLINT $(INCLUDES) $(SRC)>fluff
96
97depend:
98 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
99
100dclean:
101 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
102 mv -f Makefile.new $(MAKEFILE)
103
104clean:
105 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
106
107errors:
108
109# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/cast/Makefile.uni b/src/lib/libcrypto/cast/Makefile.uni
new file mode 100644
index 0000000000..780073e75b
--- /dev/null
+++ b/src/lib/libcrypto/cast/Makefile.uni
@@ -0,0 +1,123 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10# There are 3 possible performance options, experiment :-)
11#OPTS= -DBF_PTR
12#OPTS= -DBF_PTR2
13OPTS=
14
15DIR= cast
16TOP= .
17CC= gcc
18CFLAG= -O3 -fomit-frame-pointer
19
20CPP= $(CC) -E
21INCLUDES=
22INSTALLTOP=/usr/local/lib
23MAKE= make
24MAKEDEPEND= makedepend
25MAKEFILE= Makefile.uni
26AR= ar r
27
28CAST_ENC=c_enc.o
29# or use
30#CAST_ENC=asm/cx86-elf.o
31#CAST_ENC=asm/cx86-out.o
32#CAST_ENC=asm/cx86-sol.o
33#CAST_ENC=asm/cx86bdsi.o
34
35CFLAGS= $(OPTS) $(INCLUDES) $(CFLAG) -DFULL_TEST
36
37GENERAL=Makefile
38TEST=casttest
39APP1=cast_spd
40APP2=castopts
41APPS=$(APP1) $(APP2)
42
43LIB=libcast.a
44LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
45LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o
46
47SRC= $(LIBSRC)
48
49EXHEADER= cast.h
50HEADER= cast_lcl.h $(EXHEADER)
51
52ALL= $(GENERAL) $(SRC) $(HEADER)
53
54all: $(LIB) $(TEST) $(APPS)
55
56$(LIB): $(LIBOBJ)
57 $(AR) $(LIB) $(LIBOBJ)
58 sh $(TOP)/ranlib.sh $(LIB)
59# elf
60asm/cx86-elf.o: asm/cx86unix.cpp
61 $(CPP) -DELF asm/cx86unix.cpp | as -o asm/cx86-elf.o
62
63# solaris
64asm/cx86-sol.o: asm/cx86unix.cpp
65 $(CC) -E -DSOL asm/cx86unix.cpp | sed 's/^#.*//' > asm/cx86-sol.s
66 as -o asm/cx86-sol.o asm/cx86-sol.s
67 rm -f asm/cx86-sol.s
68
69# a.out
70asm/cx86-out.o: asm/cx86unix.cpp
71 $(CPP) -DOUT asm/cx86unix.cpp | as -o asm/cx86-out.o
72
73# bsdi
74asm/cx86bsdi.o: asm/cx86unix.cpp
75 $(CPP) -DBSDI asm/cx86unix.cpp | as -o asm/cx86bsdi.o
76
77asm/cx86unix.cpp:
78 (cd asm; perl cast-586.pl cpp >cx86unix.cpp)
79
80test: $(TEST)
81 ./$(TEST)
82
83$(TEST): $(TEST).c $(LIB)
84 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
85
86$(APP1): $(APP1).c $(LIB)
87 $(CC) -o $(APP1) $(CFLAGS) $(APP1).c $(LIB)
88
89$(APP2): $(APP2).c $(LIB)
90 $(CC) -o $(APP2) $(CFLAGS) $(APP2).c $(LIB)
91
92lint:
93 lint -DLINT $(INCLUDES) $(SRC)>fluff
94
95depend:
96 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
97
98dclean:
99 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
100 mv -f Makefile.new $(MAKEFILE)
101
102clean:
103 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
104
105cc:
106 $(MAKE) CC="cc" CFLAG="-O" all
107
108gcc:
109 $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
110
111x86-elf:
112 $(MAKE) CAST_ENC="asm/cx86-elf.o" CFLAG="-DELF $(CFLAGS)" all
113
114x86-out:
115 $(MAKE) CAST_ENC="asm/cx86-out.o" CFLAG="-DOUT $(CFLAGS)" all
116
117x86-solaris:
118 $(MAKE) CAST_ENC="asm/cx86-sol.o" CFLAG="-DSOL $(CFLAGS)" all
119
120x86-bdsi:
121 $(MAKE) CAST_ENC="asm/cx86-bdsi.o" CFLAG="-DBDSI $(CFLAGS)" all
122
123# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/cast/asm/c-win32.asm b/src/lib/libcrypto/cast/asm/c-win32.asm
new file mode 100644
index 0000000000..a1d8a2671a
--- /dev/null
+++ b/src/lib/libcrypto/cast/asm/c-win32.asm
@@ -0,0 +1,940 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by cast-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE cast-586.asm
8 .486
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _CAST_encrypt
12EXTERN _CAST_S_table0:DWORD
13EXTERN _CAST_S_table1:DWORD
14EXTERN _CAST_S_table2:DWORD
15EXTERN _CAST_S_table3:DWORD
16
17_CAST_encrypt PROC NEAR
18 ;
19 push ebp
20 push ebx
21 mov ebx, DWORD PTR 12[esp]
22 mov ebp, DWORD PTR 16[esp]
23 push esi
24 push edi
25 ; Load the 2 words
26 mov edi, DWORD PTR [ebx]
27 mov esi, DWORD PTR 4[ebx]
28 xor eax, eax
29 ; round 0
30 mov edx, DWORD PTR [ebp]
31 mov ecx, DWORD PTR 4[ebp]
32 add edx, esi
33 rol edx, cl
34 mov ebx, edx
35 xor ecx, ecx
36 mov cl, dh
37 and ebx, 255
38 shr edx, 16
39 xor eax, eax
40 mov al, dh
41 and edx, 255
42 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
43 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
44 xor ecx, ebx
45 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
46 sub ecx, ebx
47 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
48 add ecx, ebx
49 xor edi, ecx
50 ; round 1
51 mov edx, DWORD PTR 8[ebp]
52 mov ecx, DWORD PTR 12[ebp]
53 xor edx, edi
54 rol edx, cl
55 mov ebx, edx
56 xor ecx, ecx
57 mov cl, dh
58 and ebx, 255
59 shr edx, 16
60 xor eax, eax
61 mov al, dh
62 and edx, 255
63 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
64 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
65 sub ecx, ebx
66 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
67 add ecx, ebx
68 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
69 xor ecx, ebx
70 xor esi, ecx
71 ; round 2
72 mov edx, DWORD PTR 16[ebp]
73 mov ecx, DWORD PTR 20[ebp]
74 sub edx, esi
75 rol edx, cl
76 mov ebx, edx
77 xor ecx, ecx
78 mov cl, dh
79 and ebx, 255
80 shr edx, 16
81 xor eax, eax
82 mov al, dh
83 and edx, 255
84 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
85 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
86 add ecx, ebx
87 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
88 xor ecx, ebx
89 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
90 sub ecx, ebx
91 xor edi, ecx
92 ; round 3
93 mov edx, DWORD PTR 24[ebp]
94 mov ecx, DWORD PTR 28[ebp]
95 add edx, edi
96 rol edx, cl
97 mov ebx, edx
98 xor ecx, ecx
99 mov cl, dh
100 and ebx, 255
101 shr edx, 16
102 xor eax, eax
103 mov al, dh
104 and edx, 255
105 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
106 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
107 xor ecx, ebx
108 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
109 sub ecx, ebx
110 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
111 add ecx, ebx
112 xor esi, ecx
113 ; round 4
114 mov edx, DWORD PTR 32[ebp]
115 mov ecx, DWORD PTR 36[ebp]
116 xor edx, esi
117 rol edx, cl
118 mov ebx, edx
119 xor ecx, ecx
120 mov cl, dh
121 and ebx, 255
122 shr edx, 16
123 xor eax, eax
124 mov al, dh
125 and edx, 255
126 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
127 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
128 sub ecx, ebx
129 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
130 add ecx, ebx
131 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
132 xor ecx, ebx
133 xor edi, ecx
134 ; round 5
135 mov edx, DWORD PTR 40[ebp]
136 mov ecx, DWORD PTR 44[ebp]
137 sub edx, edi
138 rol edx, cl
139 mov ebx, edx
140 xor ecx, ecx
141 mov cl, dh
142 and ebx, 255
143 shr edx, 16
144 xor eax, eax
145 mov al, dh
146 and edx, 255
147 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
148 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
149 add ecx, ebx
150 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
151 xor ecx, ebx
152 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
153 sub ecx, ebx
154 xor esi, ecx
155 ; round 6
156 mov edx, DWORD PTR 48[ebp]
157 mov ecx, DWORD PTR 52[ebp]
158 add edx, esi
159 rol edx, cl
160 mov ebx, edx
161 xor ecx, ecx
162 mov cl, dh
163 and ebx, 255
164 shr edx, 16
165 xor eax, eax
166 mov al, dh
167 and edx, 255
168 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
169 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
170 xor ecx, ebx
171 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
172 sub ecx, ebx
173 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
174 add ecx, ebx
175 xor edi, ecx
176 ; round 7
177 mov edx, DWORD PTR 56[ebp]
178 mov ecx, DWORD PTR 60[ebp]
179 xor edx, edi
180 rol edx, cl
181 mov ebx, edx
182 xor ecx, ecx
183 mov cl, dh
184 and ebx, 255
185 shr edx, 16
186 xor eax, eax
187 mov al, dh
188 and edx, 255
189 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
190 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
191 sub ecx, ebx
192 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
193 add ecx, ebx
194 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
195 xor ecx, ebx
196 xor esi, ecx
197 ; round 8
198 mov edx, DWORD PTR 64[ebp]
199 mov ecx, DWORD PTR 68[ebp]
200 sub edx, esi
201 rol edx, cl
202 mov ebx, edx
203 xor ecx, ecx
204 mov cl, dh
205 and ebx, 255
206 shr edx, 16
207 xor eax, eax
208 mov al, dh
209 and edx, 255
210 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
211 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
212 add ecx, ebx
213 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
214 xor ecx, ebx
215 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
216 sub ecx, ebx
217 xor edi, ecx
218 ; round 9
219 mov edx, DWORD PTR 72[ebp]
220 mov ecx, DWORD PTR 76[ebp]
221 add edx, edi
222 rol edx, cl
223 mov ebx, edx
224 xor ecx, ecx
225 mov cl, dh
226 and ebx, 255
227 shr edx, 16
228 xor eax, eax
229 mov al, dh
230 and edx, 255
231 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
232 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
233 xor ecx, ebx
234 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
235 sub ecx, ebx
236 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
237 add ecx, ebx
238 xor esi, ecx
239 ; round 10
240 mov edx, DWORD PTR 80[ebp]
241 mov ecx, DWORD PTR 84[ebp]
242 xor edx, esi
243 rol edx, cl
244 mov ebx, edx
245 xor ecx, ecx
246 mov cl, dh
247 and ebx, 255
248 shr edx, 16
249 xor eax, eax
250 mov al, dh
251 and edx, 255
252 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
253 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
254 sub ecx, ebx
255 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
256 add ecx, ebx
257 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
258 xor ecx, ebx
259 xor edi, ecx
260 ; round 11
261 mov edx, DWORD PTR 88[ebp]
262 mov ecx, DWORD PTR 92[ebp]
263 sub edx, edi
264 rol edx, cl
265 mov ebx, edx
266 xor ecx, ecx
267 mov cl, dh
268 and ebx, 255
269 shr edx, 16
270 xor eax, eax
271 mov al, dh
272 and edx, 255
273 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
274 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
275 add ecx, ebx
276 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
277 xor ecx, ebx
278 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
279 sub ecx, ebx
280 xor esi, ecx
281 ; round 12
282 mov edx, DWORD PTR 96[ebp]
283 mov ecx, DWORD PTR 100[ebp]
284 add edx, esi
285 rol edx, cl
286 mov ebx, edx
287 xor ecx, ecx
288 mov cl, dh
289 and ebx, 255
290 shr edx, 16
291 xor eax, eax
292 mov al, dh
293 and edx, 255
294 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
295 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
296 xor ecx, ebx
297 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
298 sub ecx, ebx
299 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
300 add ecx, ebx
301 xor edi, ecx
302 ; round 13
303 mov edx, DWORD PTR 104[ebp]
304 mov ecx, DWORD PTR 108[ebp]
305 xor edx, edi
306 rol edx, cl
307 mov ebx, edx
308 xor ecx, ecx
309 mov cl, dh
310 and ebx, 255
311 shr edx, 16
312 xor eax, eax
313 mov al, dh
314 and edx, 255
315 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
316 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
317 sub ecx, ebx
318 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
319 add ecx, ebx
320 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
321 xor ecx, ebx
322 xor esi, ecx
323 ; round 14
324 mov edx, DWORD PTR 112[ebp]
325 mov ecx, DWORD PTR 116[ebp]
326 sub edx, esi
327 rol edx, cl
328 mov ebx, edx
329 xor ecx, ecx
330 mov cl, dh
331 and ebx, 255
332 shr edx, 16
333 xor eax, eax
334 mov al, dh
335 and edx, 255
336 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
337 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
338 add ecx, ebx
339 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
340 xor ecx, ebx
341 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
342 sub ecx, ebx
343 xor edi, ecx
344 ; round 15
345 mov edx, DWORD PTR 120[ebp]
346 mov ecx, DWORD PTR 124[ebp]
347 add edx, edi
348 rol edx, cl
349 mov ebx, edx
350 xor ecx, ecx
351 mov cl, dh
352 and ebx, 255
353 shr edx, 16
354 xor eax, eax
355 mov al, dh
356 and edx, 255
357 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
358 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
359 xor ecx, ebx
360 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
361 sub ecx, ebx
362 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
363 add ecx, ebx
364 mov eax, DWORD PTR 20[esp]
365 xor esi, ecx
366 nop
367 mov DWORD PTR 4[eax],edi
368 mov DWORD PTR [eax],esi
369 pop edi
370 pop esi
371 pop ebx
372 pop ebp
373 ret
374_CAST_encrypt ENDP
375_TEXT ENDS
376_TEXT SEGMENT
377PUBLIC _CAST_decrypt
378EXTERN _CAST_S_table0:DWORD
379EXTERN _CAST_S_table1:DWORD
380EXTERN _CAST_S_table2:DWORD
381EXTERN _CAST_S_table3:DWORD
382
383_CAST_decrypt PROC NEAR
384 ;
385 push ebp
386 push ebx
387 mov ebx, DWORD PTR 12[esp]
388 mov ebp, DWORD PTR 16[esp]
389 push esi
390 push edi
391 ; Load the 2 words
392 mov edi, DWORD PTR [ebx]
393 mov esi, DWORD PTR 4[ebx]
394 xor eax, eax
395 ; round 15
396 mov edx, DWORD PTR 120[ebp]
397 mov ecx, DWORD PTR 124[ebp]
398 add edx, esi
399 rol edx, cl
400 mov ebx, edx
401 xor ecx, ecx
402 mov cl, dh
403 and ebx, 255
404 shr edx, 16
405 xor eax, eax
406 mov al, dh
407 and edx, 255
408 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
409 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
410 xor ecx, ebx
411 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
412 sub ecx, ebx
413 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
414 add ecx, ebx
415 xor edi, ecx
416 ; round 14
417 mov edx, DWORD PTR 112[ebp]
418 mov ecx, DWORD PTR 116[ebp]
419 sub edx, edi
420 rol edx, cl
421 mov ebx, edx
422 xor ecx, ecx
423 mov cl, dh
424 and ebx, 255
425 shr edx, 16
426 xor eax, eax
427 mov al, dh
428 and edx, 255
429 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
430 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
431 add ecx, ebx
432 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
433 xor ecx, ebx
434 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
435 sub ecx, ebx
436 xor esi, ecx
437 ; round 13
438 mov edx, DWORD PTR 104[ebp]
439 mov ecx, DWORD PTR 108[ebp]
440 xor edx, esi
441 rol edx, cl
442 mov ebx, edx
443 xor ecx, ecx
444 mov cl, dh
445 and ebx, 255
446 shr edx, 16
447 xor eax, eax
448 mov al, dh
449 and edx, 255
450 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
451 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
452 sub ecx, ebx
453 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
454 add ecx, ebx
455 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
456 xor ecx, ebx
457 xor edi, ecx
458 ; round 12
459 mov edx, DWORD PTR 96[ebp]
460 mov ecx, DWORD PTR 100[ebp]
461 add edx, edi
462 rol edx, cl
463 mov ebx, edx
464 xor ecx, ecx
465 mov cl, dh
466 and ebx, 255
467 shr edx, 16
468 xor eax, eax
469 mov al, dh
470 and edx, 255
471 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
472 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
473 xor ecx, ebx
474 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
475 sub ecx, ebx
476 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
477 add ecx, ebx
478 xor esi, ecx
479 ; round 11
480 mov edx, DWORD PTR 88[ebp]
481 mov ecx, DWORD PTR 92[ebp]
482 sub edx, esi
483 rol edx, cl
484 mov ebx, edx
485 xor ecx, ecx
486 mov cl, dh
487 and ebx, 255
488 shr edx, 16
489 xor eax, eax
490 mov al, dh
491 and edx, 255
492 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
493 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
494 add ecx, ebx
495 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
496 xor ecx, ebx
497 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
498 sub ecx, ebx
499 xor edi, ecx
500 ; round 10
501 mov edx, DWORD PTR 80[ebp]
502 mov ecx, DWORD PTR 84[ebp]
503 xor edx, edi
504 rol edx, cl
505 mov ebx, edx
506 xor ecx, ecx
507 mov cl, dh
508 and ebx, 255
509 shr edx, 16
510 xor eax, eax
511 mov al, dh
512 and edx, 255
513 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
514 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
515 sub ecx, ebx
516 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
517 add ecx, ebx
518 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
519 xor ecx, ebx
520 xor esi, ecx
521 ; round 9
522 mov edx, DWORD PTR 72[ebp]
523 mov ecx, DWORD PTR 76[ebp]
524 add edx, esi
525 rol edx, cl
526 mov ebx, edx
527 xor ecx, ecx
528 mov cl, dh
529 and ebx, 255
530 shr edx, 16
531 xor eax, eax
532 mov al, dh
533 and edx, 255
534 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
535 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
536 xor ecx, ebx
537 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
538 sub ecx, ebx
539 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
540 add ecx, ebx
541 xor edi, ecx
542 ; round 8
543 mov edx, DWORD PTR 64[ebp]
544 mov ecx, DWORD PTR 68[ebp]
545 sub edx, edi
546 rol edx, cl
547 mov ebx, edx
548 xor ecx, ecx
549 mov cl, dh
550 and ebx, 255
551 shr edx, 16
552 xor eax, eax
553 mov al, dh
554 and edx, 255
555 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
556 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
557 add ecx, ebx
558 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
559 xor ecx, ebx
560 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
561 sub ecx, ebx
562 xor esi, ecx
563 ; round 7
564 mov edx, DWORD PTR 56[ebp]
565 mov ecx, DWORD PTR 60[ebp]
566 xor edx, esi
567 rol edx, cl
568 mov ebx, edx
569 xor ecx, ecx
570 mov cl, dh
571 and ebx, 255
572 shr edx, 16
573 xor eax, eax
574 mov al, dh
575 and edx, 255
576 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
577 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
578 sub ecx, ebx
579 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
580 add ecx, ebx
581 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
582 xor ecx, ebx
583 xor edi, ecx
584 ; round 6
585 mov edx, DWORD PTR 48[ebp]
586 mov ecx, DWORD PTR 52[ebp]
587 add edx, edi
588 rol edx, cl
589 mov ebx, edx
590 xor ecx, ecx
591 mov cl, dh
592 and ebx, 255
593 shr edx, 16
594 xor eax, eax
595 mov al, dh
596 and edx, 255
597 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
598 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
599 xor ecx, ebx
600 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
601 sub ecx, ebx
602 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
603 add ecx, ebx
604 xor esi, ecx
605 ; round 5
606 mov edx, DWORD PTR 40[ebp]
607 mov ecx, DWORD PTR 44[ebp]
608 sub edx, esi
609 rol edx, cl
610 mov ebx, edx
611 xor ecx, ecx
612 mov cl, dh
613 and ebx, 255
614 shr edx, 16
615 xor eax, eax
616 mov al, dh
617 and edx, 255
618 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
619 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
620 add ecx, ebx
621 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
622 xor ecx, ebx
623 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
624 sub ecx, ebx
625 xor edi, ecx
626 ; round 4
627 mov edx, DWORD PTR 32[ebp]
628 mov ecx, DWORD PTR 36[ebp]
629 xor edx, edi
630 rol edx, cl
631 mov ebx, edx
632 xor ecx, ecx
633 mov cl, dh
634 and ebx, 255
635 shr edx, 16
636 xor eax, eax
637 mov al, dh
638 and edx, 255
639 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
640 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
641 sub ecx, ebx
642 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
643 add ecx, ebx
644 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
645 xor ecx, ebx
646 xor esi, ecx
647 ; round 3
648 mov edx, DWORD PTR 24[ebp]
649 mov ecx, DWORD PTR 28[ebp]
650 add edx, esi
651 rol edx, cl
652 mov ebx, edx
653 xor ecx, ecx
654 mov cl, dh
655 and ebx, 255
656 shr edx, 16
657 xor eax, eax
658 mov al, dh
659 and edx, 255
660 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
661 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
662 xor ecx, ebx
663 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
664 sub ecx, ebx
665 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
666 add ecx, ebx
667 xor edi, ecx
668 ; round 2
669 mov edx, DWORD PTR 16[ebp]
670 mov ecx, DWORD PTR 20[ebp]
671 sub edx, edi
672 rol edx, cl
673 mov ebx, edx
674 xor ecx, ecx
675 mov cl, dh
676 and ebx, 255
677 shr edx, 16
678 xor eax, eax
679 mov al, dh
680 and edx, 255
681 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
682 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
683 add ecx, ebx
684 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
685 xor ecx, ebx
686 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
687 sub ecx, ebx
688 xor esi, ecx
689 ; round 1
690 mov edx, DWORD PTR 8[ebp]
691 mov ecx, DWORD PTR 12[ebp]
692 xor edx, esi
693 rol edx, cl
694 mov ebx, edx
695 xor ecx, ecx
696 mov cl, dh
697 and ebx, 255
698 shr edx, 16
699 xor eax, eax
700 mov al, dh
701 and edx, 255
702 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
703 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
704 sub ecx, ebx
705 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
706 add ecx, ebx
707 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
708 xor ecx, ebx
709 xor edi, ecx
710 ; round 0
711 mov edx, DWORD PTR [ebp]
712 mov ecx, DWORD PTR 4[ebp]
713 add edx, edi
714 rol edx, cl
715 mov ebx, edx
716 xor ecx, ecx
717 mov cl, dh
718 and ebx, 255
719 shr edx, 16
720 xor eax, eax
721 mov al, dh
722 and edx, 255
723 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
724 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
725 xor ecx, ebx
726 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
727 sub ecx, ebx
728 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
729 add ecx, ebx
730 mov eax, DWORD PTR 20[esp]
731 xor esi, ecx
732 nop
733 mov DWORD PTR 4[eax],edi
734 mov DWORD PTR [eax],esi
735 pop edi
736 pop esi
737 pop ebx
738 pop ebp
739 ret
740_CAST_decrypt ENDP
741_TEXT ENDS
742_TEXT SEGMENT
743PUBLIC _CAST_cbc_encrypt
744
745_CAST_cbc_encrypt PROC NEAR
746 ;
747 push ebp
748 push ebx
749 push esi
750 push edi
751 mov ebp, DWORD PTR 28[esp]
752 ; getting iv ptr from parameter 4
753 mov ebx, DWORD PTR 36[esp]
754 mov esi, DWORD PTR [ebx]
755 mov edi, DWORD PTR 4[ebx]
756 push edi
757 push esi
758 push edi
759 push esi
760 mov ebx, esp
761 mov esi, DWORD PTR 36[esp]
762 mov edi, DWORD PTR 40[esp]
763 ; getting encrypt flag from parameter 5
764 mov ecx, DWORD PTR 56[esp]
765 ; get and push parameter 3
766 mov eax, DWORD PTR 48[esp]
767 push eax
768 push ebx
769 cmp ecx, 0
770 jz $L000decrypt
771 and ebp, 4294967288
772 mov eax, DWORD PTR 8[esp]
773 mov ebx, DWORD PTR 12[esp]
774 jz $L001encrypt_finish
775L002encrypt_loop:
776 mov ecx, DWORD PTR [esi]
777 mov edx, DWORD PTR 4[esi]
778 xor eax, ecx
779 xor ebx, edx
780 bswap eax
781 bswap ebx
782 mov DWORD PTR 8[esp],eax
783 mov DWORD PTR 12[esp],ebx
784 call _CAST_encrypt
785 mov eax, DWORD PTR 8[esp]
786 mov ebx, DWORD PTR 12[esp]
787 bswap eax
788 bswap ebx
789 mov DWORD PTR [edi],eax
790 mov DWORD PTR 4[edi],ebx
791 add esi, 8
792 add edi, 8
793 sub ebp, 8
794 jnz L002encrypt_loop
795$L001encrypt_finish:
796 mov ebp, DWORD PTR 52[esp]
797 and ebp, 7
798 jz $L003finish
799 xor ecx, ecx
800 xor edx, edx
801 mov ebp, DWORD PTR $L004cbc_enc_jmp_table[ebp*4]
802 jmp ebp
803L005ej7:
804 xor edx, edx
805 mov dh, BYTE PTR 6[esi]
806 shl edx, 8
807L006ej6:
808 mov dh, BYTE PTR 5[esi]
809L007ej5:
810 mov dl, BYTE PTR 4[esi]
811L008ej4:
812 mov ecx, DWORD PTR [esi]
813 jmp $L009ejend
814L010ej3:
815 mov ch, BYTE PTR 2[esi]
816 xor ecx, ecx
817 shl ecx, 8
818L011ej2:
819 mov ch, BYTE PTR 1[esi]
820L012ej1:
821 mov cl, BYTE PTR [esi]
822$L009ejend:
823 xor eax, ecx
824 xor ebx, edx
825 bswap eax
826 bswap ebx
827 mov DWORD PTR 8[esp],eax
828 mov DWORD PTR 12[esp],ebx
829 call _CAST_encrypt
830 mov eax, DWORD PTR 8[esp]
831 mov ebx, DWORD PTR 12[esp]
832 bswap eax
833 bswap ebx
834 mov DWORD PTR [edi],eax
835 mov DWORD PTR 4[edi],ebx
836 jmp $L003finish
837$L000decrypt:
838 and ebp, 4294967288
839 mov eax, DWORD PTR 16[esp]
840 mov ebx, DWORD PTR 20[esp]
841 jz $L013decrypt_finish
842L014decrypt_loop:
843 mov eax, DWORD PTR [esi]
844 mov ebx, DWORD PTR 4[esi]
845 bswap eax
846 bswap ebx
847 mov DWORD PTR 8[esp],eax
848 mov DWORD PTR 12[esp],ebx
849 call _CAST_decrypt
850 mov eax, DWORD PTR 8[esp]
851 mov ebx, DWORD PTR 12[esp]
852 bswap eax
853 bswap ebx
854 mov ecx, DWORD PTR 16[esp]
855 mov edx, DWORD PTR 20[esp]
856 xor ecx, eax
857 xor edx, ebx
858 mov eax, DWORD PTR [esi]
859 mov ebx, DWORD PTR 4[esi]
860 mov DWORD PTR [edi],ecx
861 mov DWORD PTR 4[edi],edx
862 mov DWORD PTR 16[esp],eax
863 mov DWORD PTR 20[esp],ebx
864 add esi, 8
865 add edi, 8
866 sub ebp, 8
867 jnz L014decrypt_loop
868$L013decrypt_finish:
869 mov ebp, DWORD PTR 52[esp]
870 and ebp, 7
871 jz $L003finish
872 mov eax, DWORD PTR [esi]
873 mov ebx, DWORD PTR 4[esi]
874 bswap eax
875 bswap ebx
876 mov DWORD PTR 8[esp],eax
877 mov DWORD PTR 12[esp],ebx
878 call _CAST_decrypt
879 mov eax, DWORD PTR 8[esp]
880 mov ebx, DWORD PTR 12[esp]
881 bswap eax
882 bswap ebx
883 mov ecx, DWORD PTR 16[esp]
884 mov edx, DWORD PTR 20[esp]
885 xor ecx, eax
886 xor edx, ebx
887 mov eax, DWORD PTR [esi]
888 mov ebx, DWORD PTR 4[esi]
889L015dj7:
890 ror edx, 16
891 mov BYTE PTR 6[edi],dl
892 shr edx, 16
893L016dj6:
894 mov BYTE PTR 5[edi],dh
895L017dj5:
896 mov BYTE PTR 4[edi],dl
897L018dj4:
898 mov DWORD PTR [edi],ecx
899 jmp $L019djend
900L020dj3:
901 ror ecx, 16
902 mov BYTE PTR 2[edi],cl
903 shl ecx, 16
904L021dj2:
905 mov BYTE PTR 1[esi],ch
906L022dj1:
907 mov BYTE PTR [esi], cl
908$L019djend:
909 jmp $L003finish
910$L003finish:
911 mov ecx, DWORD PTR 60[esp]
912 add esp, 24
913 mov DWORD PTR [ecx],eax
914 mov DWORD PTR 4[ecx],ebx
915 pop edi
916 pop esi
917 pop ebx
918 pop ebp
919 ret
920$L004cbc_enc_jmp_table:
921 DD 0
922 DD L012ej1
923 DD L011ej2
924 DD L010ej3
925 DD L008ej4
926 DD L007ej5
927 DD L006ej6
928 DD L005ej7
929L023cbc_dec_jmp_table:
930 DD 0
931 DD L022dj1
932 DD L021dj2
933 DD L020dj3
934 DD L018dj4
935 DD L017dj5
936 DD L016dj6
937 DD L015dj7
938_CAST_cbc_encrypt ENDP
939_TEXT ENDS
940END
diff --git a/src/lib/libcrypto/cast/asm/cx86unix.cpp b/src/lib/libcrypto/cast/asm/cx86unix.cpp
new file mode 100644
index 0000000000..035692a5af
--- /dev/null
+++ b/src/lib/libcrypto/cast/asm/cx86unix.cpp
@@ -0,0 +1,1010 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define CAST_S_table0 _CAST_S_table0
13#define CAST_S_table1 _CAST_S_table1
14#define CAST_S_table2 _CAST_S_table2
15#define CAST_S_table3 _CAST_S_table3
16#define CAST_encrypt _CAST_encrypt
17#define CAST_S_table0 _CAST_S_table0
18#define CAST_S_table1 _CAST_S_table1
19#define CAST_S_table2 _CAST_S_table2
20#define CAST_S_table3 _CAST_S_table3
21#define CAST_decrypt _CAST_decrypt
22#define CAST_cbc_encrypt _CAST_cbc_encrypt
23
24#endif
25
26#ifdef OUT
27#define OK 1
28#define ALIGN 4
29#endif
30
31#ifdef BSDI
32#define OK 1
33#define ALIGN 4
34#undef SIZE
35#undef TYPE
36#define SIZE(a,b)
37#define TYPE(a,b)
38#endif
39
40#if defined(ELF) || defined(SOL)
41#define OK 1
42#define ALIGN 16
43#endif
44
45#ifndef OK
46You need to define one of
47ELF - elf systems - linux-elf, NetBSD and DG-UX
48OUT - a.out systems - linux-a.out and FreeBSD
49SOL - solaris systems, which are elf with strange comment lines
50BSDI - a.out with a very primative version of as.
51#endif
52
53/* Let the Assembler begin :-) */
54 /* Don't even think of reading this code */
55 /* It was automatically generated by cast-586.pl */
56 /* Which is a perl program used to generate the x86 assember for */
57 /* any of elf, a.out, BSDI,Win32, or Solaris */
58 /* eric <eay@cryptsoft.com> */
59
60 .file "cast-586.s"
61 .version "01.01"
62gcc2_compiled.:
63.text
64 .align ALIGN
65.globl CAST_encrypt
66 TYPE(CAST_encrypt,@function)
67CAST_encrypt:
68
69 pushl %ebp
70 pushl %ebx
71 movl 12(%esp), %ebx
72 movl 16(%esp), %ebp
73 pushl %esi
74 pushl %edi
75 /* Load the 2 words */
76 movl (%ebx), %edi
77 movl 4(%ebx), %esi
78 xorl %eax, %eax
79 /* round 0 */
80 movl (%ebp), %edx
81 movl 4(%ebp), %ecx
82 addl %esi, %edx
83 roll %cl, %edx
84 movl %edx, %ebx
85 xorl %ecx, %ecx
86 movb %dh, %cl
87 andl $255, %ebx
88 shrl $16, %edx
89 xorl %eax, %eax
90 movb %dh, %al
91 andl $255, %edx
92 movl CAST_S_table0(,%ecx,4),%ecx
93 movl CAST_S_table1(,%ebx,4),%ebx
94 xorl %ebx, %ecx
95 movl CAST_S_table2(,%eax,4),%ebx
96 subl %ebx, %ecx
97 movl CAST_S_table3(,%edx,4),%ebx
98 addl %ebx, %ecx
99 xorl %ecx, %edi
100 /* round 1 */
101 movl 8(%ebp), %edx
102 movl 12(%ebp), %ecx
103 xorl %edi, %edx
104 roll %cl, %edx
105 movl %edx, %ebx
106 xorl %ecx, %ecx
107 movb %dh, %cl
108 andl $255, %ebx
109 shrl $16, %edx
110 xorl %eax, %eax
111 movb %dh, %al
112 andl $255, %edx
113 movl CAST_S_table0(,%ecx,4),%ecx
114 movl CAST_S_table1(,%ebx,4),%ebx
115 subl %ebx, %ecx
116 movl CAST_S_table2(,%eax,4),%ebx
117 addl %ebx, %ecx
118 movl CAST_S_table3(,%edx,4),%ebx
119 xorl %ebx, %ecx
120 xorl %ecx, %esi
121 /* round 2 */
122 movl 16(%ebp), %edx
123 movl 20(%ebp), %ecx
124 subl %esi, %edx
125 roll %cl, %edx
126 movl %edx, %ebx
127 xorl %ecx, %ecx
128 movb %dh, %cl
129 andl $255, %ebx
130 shrl $16, %edx
131 xorl %eax, %eax
132 movb %dh, %al
133 andl $255, %edx
134 movl CAST_S_table0(,%ecx,4),%ecx
135 movl CAST_S_table1(,%ebx,4),%ebx
136 addl %ebx, %ecx
137 movl CAST_S_table2(,%eax,4),%ebx
138 xorl %ebx, %ecx
139 movl CAST_S_table3(,%edx,4),%ebx
140 subl %ebx, %ecx
141 xorl %ecx, %edi
142 /* round 3 */
143 movl 24(%ebp), %edx
144 movl 28(%ebp), %ecx
145 addl %edi, %edx
146 roll %cl, %edx
147 movl %edx, %ebx
148 xorl %ecx, %ecx
149 movb %dh, %cl
150 andl $255, %ebx
151 shrl $16, %edx
152 xorl %eax, %eax
153 movb %dh, %al
154 andl $255, %edx
155 movl CAST_S_table0(,%ecx,4),%ecx
156 movl CAST_S_table1(,%ebx,4),%ebx
157 xorl %ebx, %ecx
158 movl CAST_S_table2(,%eax,4),%ebx
159 subl %ebx, %ecx
160 movl CAST_S_table3(,%edx,4),%ebx
161 addl %ebx, %ecx
162 xorl %ecx, %esi
163 /* round 4 */
164 movl 32(%ebp), %edx
165 movl 36(%ebp), %ecx
166 xorl %esi, %edx
167 roll %cl, %edx
168 movl %edx, %ebx
169 xorl %ecx, %ecx
170 movb %dh, %cl
171 andl $255, %ebx
172 shrl $16, %edx
173 xorl %eax, %eax
174 movb %dh, %al
175 andl $255, %edx
176 movl CAST_S_table0(,%ecx,4),%ecx
177 movl CAST_S_table1(,%ebx,4),%ebx
178 subl %ebx, %ecx
179 movl CAST_S_table2(,%eax,4),%ebx
180 addl %ebx, %ecx
181 movl CAST_S_table3(,%edx,4),%ebx
182 xorl %ebx, %ecx
183 xorl %ecx, %edi
184 /* round 5 */
185 movl 40(%ebp), %edx
186 movl 44(%ebp), %ecx
187 subl %edi, %edx
188 roll %cl, %edx
189 movl %edx, %ebx
190 xorl %ecx, %ecx
191 movb %dh, %cl
192 andl $255, %ebx
193 shrl $16, %edx
194 xorl %eax, %eax
195 movb %dh, %al
196 andl $255, %edx
197 movl CAST_S_table0(,%ecx,4),%ecx
198 movl CAST_S_table1(,%ebx,4),%ebx
199 addl %ebx, %ecx
200 movl CAST_S_table2(,%eax,4),%ebx
201 xorl %ebx, %ecx
202 movl CAST_S_table3(,%edx,4),%ebx
203 subl %ebx, %ecx
204 xorl %ecx, %esi
205 /* round 6 */
206 movl 48(%ebp), %edx
207 movl 52(%ebp), %ecx
208 addl %esi, %edx
209 roll %cl, %edx
210 movl %edx, %ebx
211 xorl %ecx, %ecx
212 movb %dh, %cl
213 andl $255, %ebx
214 shrl $16, %edx
215 xorl %eax, %eax
216 movb %dh, %al
217 andl $255, %edx
218 movl CAST_S_table0(,%ecx,4),%ecx
219 movl CAST_S_table1(,%ebx,4),%ebx
220 xorl %ebx, %ecx
221 movl CAST_S_table2(,%eax,4),%ebx
222 subl %ebx, %ecx
223 movl CAST_S_table3(,%edx,4),%ebx
224 addl %ebx, %ecx
225 xorl %ecx, %edi
226 /* round 7 */
227 movl 56(%ebp), %edx
228 movl 60(%ebp), %ecx
229 xorl %edi, %edx
230 roll %cl, %edx
231 movl %edx, %ebx
232 xorl %ecx, %ecx
233 movb %dh, %cl
234 andl $255, %ebx
235 shrl $16, %edx
236 xorl %eax, %eax
237 movb %dh, %al
238 andl $255, %edx
239 movl CAST_S_table0(,%ecx,4),%ecx
240 movl CAST_S_table1(,%ebx,4),%ebx
241 subl %ebx, %ecx
242 movl CAST_S_table2(,%eax,4),%ebx
243 addl %ebx, %ecx
244 movl CAST_S_table3(,%edx,4),%ebx
245 xorl %ebx, %ecx
246 xorl %ecx, %esi
247 /* round 8 */
248 movl 64(%ebp), %edx
249 movl 68(%ebp), %ecx
250 subl %esi, %edx
251 roll %cl, %edx
252 movl %edx, %ebx
253 xorl %ecx, %ecx
254 movb %dh, %cl
255 andl $255, %ebx
256 shrl $16, %edx
257 xorl %eax, %eax
258 movb %dh, %al
259 andl $255, %edx
260 movl CAST_S_table0(,%ecx,4),%ecx
261 movl CAST_S_table1(,%ebx,4),%ebx
262 addl %ebx, %ecx
263 movl CAST_S_table2(,%eax,4),%ebx
264 xorl %ebx, %ecx
265 movl CAST_S_table3(,%edx,4),%ebx
266 subl %ebx, %ecx
267 xorl %ecx, %edi
268 /* round 9 */
269 movl 72(%ebp), %edx
270 movl 76(%ebp), %ecx
271 addl %edi, %edx
272 roll %cl, %edx
273 movl %edx, %ebx
274 xorl %ecx, %ecx
275 movb %dh, %cl
276 andl $255, %ebx
277 shrl $16, %edx
278 xorl %eax, %eax
279 movb %dh, %al
280 andl $255, %edx
281 movl CAST_S_table0(,%ecx,4),%ecx
282 movl CAST_S_table1(,%ebx,4),%ebx
283 xorl %ebx, %ecx
284 movl CAST_S_table2(,%eax,4),%ebx
285 subl %ebx, %ecx
286 movl CAST_S_table3(,%edx,4),%ebx
287 addl %ebx, %ecx
288 xorl %ecx, %esi
289 /* round 10 */
290 movl 80(%ebp), %edx
291 movl 84(%ebp), %ecx
292 xorl %esi, %edx
293 roll %cl, %edx
294 movl %edx, %ebx
295 xorl %ecx, %ecx
296 movb %dh, %cl
297 andl $255, %ebx
298 shrl $16, %edx
299 xorl %eax, %eax
300 movb %dh, %al
301 andl $255, %edx
302 movl CAST_S_table0(,%ecx,4),%ecx
303 movl CAST_S_table1(,%ebx,4),%ebx
304 subl %ebx, %ecx
305 movl CAST_S_table2(,%eax,4),%ebx
306 addl %ebx, %ecx
307 movl CAST_S_table3(,%edx,4),%ebx
308 xorl %ebx, %ecx
309 xorl %ecx, %edi
310 /* round 11 */
311 movl 88(%ebp), %edx
312 movl 92(%ebp), %ecx
313 subl %edi, %edx
314 roll %cl, %edx
315 movl %edx, %ebx
316 xorl %ecx, %ecx
317 movb %dh, %cl
318 andl $255, %ebx
319 shrl $16, %edx
320 xorl %eax, %eax
321 movb %dh, %al
322 andl $255, %edx
323 movl CAST_S_table0(,%ecx,4),%ecx
324 movl CAST_S_table1(,%ebx,4),%ebx
325 addl %ebx, %ecx
326 movl CAST_S_table2(,%eax,4),%ebx
327 xorl %ebx, %ecx
328 movl CAST_S_table3(,%edx,4),%ebx
329 subl %ebx, %ecx
330 xorl %ecx, %esi
331 /* round 12 */
332 movl 96(%ebp), %edx
333 movl 100(%ebp), %ecx
334 addl %esi, %edx
335 roll %cl, %edx
336 movl %edx, %ebx
337 xorl %ecx, %ecx
338 movb %dh, %cl
339 andl $255, %ebx
340 shrl $16, %edx
341 xorl %eax, %eax
342 movb %dh, %al
343 andl $255, %edx
344 movl CAST_S_table0(,%ecx,4),%ecx
345 movl CAST_S_table1(,%ebx,4),%ebx
346 xorl %ebx, %ecx
347 movl CAST_S_table2(,%eax,4),%ebx
348 subl %ebx, %ecx
349 movl CAST_S_table3(,%edx,4),%ebx
350 addl %ebx, %ecx
351 xorl %ecx, %edi
352 /* round 13 */
353 movl 104(%ebp), %edx
354 movl 108(%ebp), %ecx
355 xorl %edi, %edx
356 roll %cl, %edx
357 movl %edx, %ebx
358 xorl %ecx, %ecx
359 movb %dh, %cl
360 andl $255, %ebx
361 shrl $16, %edx
362 xorl %eax, %eax
363 movb %dh, %al
364 andl $255, %edx
365 movl CAST_S_table0(,%ecx,4),%ecx
366 movl CAST_S_table1(,%ebx,4),%ebx
367 subl %ebx, %ecx
368 movl CAST_S_table2(,%eax,4),%ebx
369 addl %ebx, %ecx
370 movl CAST_S_table3(,%edx,4),%ebx
371 xorl %ebx, %ecx
372 xorl %ecx, %esi
373 /* round 14 */
374 movl 112(%ebp), %edx
375 movl 116(%ebp), %ecx
376 subl %esi, %edx
377 roll %cl, %edx
378 movl %edx, %ebx
379 xorl %ecx, %ecx
380 movb %dh, %cl
381 andl $255, %ebx
382 shrl $16, %edx
383 xorl %eax, %eax
384 movb %dh, %al
385 andl $255, %edx
386 movl CAST_S_table0(,%ecx,4),%ecx
387 movl CAST_S_table1(,%ebx,4),%ebx
388 addl %ebx, %ecx
389 movl CAST_S_table2(,%eax,4),%ebx
390 xorl %ebx, %ecx
391 movl CAST_S_table3(,%edx,4),%ebx
392 subl %ebx, %ecx
393 xorl %ecx, %edi
394 /* round 15 */
395 movl 120(%ebp), %edx
396 movl 124(%ebp), %ecx
397 addl %edi, %edx
398 roll %cl, %edx
399 movl %edx, %ebx
400 xorl %ecx, %ecx
401 movb %dh, %cl
402 andl $255, %ebx
403 shrl $16, %edx
404 xorl %eax, %eax
405 movb %dh, %al
406 andl $255, %edx
407 movl CAST_S_table0(,%ecx,4),%ecx
408 movl CAST_S_table1(,%ebx,4),%ebx
409 xorl %ebx, %ecx
410 movl CAST_S_table2(,%eax,4),%ebx
411 subl %ebx, %ecx
412 movl CAST_S_table3(,%edx,4),%ebx
413 addl %ebx, %ecx
414 movl 20(%esp), %eax
415 xorl %ecx, %esi
416 nop
417 movl %edi, 4(%eax)
418 movl %esi, (%eax)
419 popl %edi
420 popl %esi
421 popl %ebx
422 popl %ebp
423 ret
424.CAST_encrypt_end:
425 SIZE(CAST_encrypt,.CAST_encrypt_end-CAST_encrypt)
426.ident "CAST_encrypt"
427.text
428 .align ALIGN
429.globl CAST_decrypt
430 TYPE(CAST_decrypt,@function)
431CAST_decrypt:
432
433 pushl %ebp
434 pushl %ebx
435 movl 12(%esp), %ebx
436 movl 16(%esp), %ebp
437 pushl %esi
438 pushl %edi
439 /* Load the 2 words */
440 movl (%ebx), %edi
441 movl 4(%ebx), %esi
442 xorl %eax, %eax
443 /* round 15 */
444 movl 120(%ebp), %edx
445 movl 124(%ebp), %ecx
446 addl %esi, %edx
447 roll %cl, %edx
448 movl %edx, %ebx
449 xorl %ecx, %ecx
450 movb %dh, %cl
451 andl $255, %ebx
452 shrl $16, %edx
453 xorl %eax, %eax
454 movb %dh, %al
455 andl $255, %edx
456 movl CAST_S_table0(,%ecx,4),%ecx
457 movl CAST_S_table1(,%ebx,4),%ebx
458 xorl %ebx, %ecx
459 movl CAST_S_table2(,%eax,4),%ebx
460 subl %ebx, %ecx
461 movl CAST_S_table3(,%edx,4),%ebx
462 addl %ebx, %ecx
463 xorl %ecx, %edi
464 /* round 14 */
465 movl 112(%ebp), %edx
466 movl 116(%ebp), %ecx
467 subl %edi, %edx
468 roll %cl, %edx
469 movl %edx, %ebx
470 xorl %ecx, %ecx
471 movb %dh, %cl
472 andl $255, %ebx
473 shrl $16, %edx
474 xorl %eax, %eax
475 movb %dh, %al
476 andl $255, %edx
477 movl CAST_S_table0(,%ecx,4),%ecx
478 movl CAST_S_table1(,%ebx,4),%ebx
479 addl %ebx, %ecx
480 movl CAST_S_table2(,%eax,4),%ebx
481 xorl %ebx, %ecx
482 movl CAST_S_table3(,%edx,4),%ebx
483 subl %ebx, %ecx
484 xorl %ecx, %esi
485 /* round 13 */
486 movl 104(%ebp), %edx
487 movl 108(%ebp), %ecx
488 xorl %esi, %edx
489 roll %cl, %edx
490 movl %edx, %ebx
491 xorl %ecx, %ecx
492 movb %dh, %cl
493 andl $255, %ebx
494 shrl $16, %edx
495 xorl %eax, %eax
496 movb %dh, %al
497 andl $255, %edx
498 movl CAST_S_table0(,%ecx,4),%ecx
499 movl CAST_S_table1(,%ebx,4),%ebx
500 subl %ebx, %ecx
501 movl CAST_S_table2(,%eax,4),%ebx
502 addl %ebx, %ecx
503 movl CAST_S_table3(,%edx,4),%ebx
504 xorl %ebx, %ecx
505 xorl %ecx, %edi
506 /* round 12 */
507 movl 96(%ebp), %edx
508 movl 100(%ebp), %ecx
509 addl %edi, %edx
510 roll %cl, %edx
511 movl %edx, %ebx
512 xorl %ecx, %ecx
513 movb %dh, %cl
514 andl $255, %ebx
515 shrl $16, %edx
516 xorl %eax, %eax
517 movb %dh, %al
518 andl $255, %edx
519 movl CAST_S_table0(,%ecx,4),%ecx
520 movl CAST_S_table1(,%ebx,4),%ebx
521 xorl %ebx, %ecx
522 movl CAST_S_table2(,%eax,4),%ebx
523 subl %ebx, %ecx
524 movl CAST_S_table3(,%edx,4),%ebx
525 addl %ebx, %ecx
526 xorl %ecx, %esi
527 /* round 11 */
528 movl 88(%ebp), %edx
529 movl 92(%ebp), %ecx
530 subl %esi, %edx
531 roll %cl, %edx
532 movl %edx, %ebx
533 xorl %ecx, %ecx
534 movb %dh, %cl
535 andl $255, %ebx
536 shrl $16, %edx
537 xorl %eax, %eax
538 movb %dh, %al
539 andl $255, %edx
540 movl CAST_S_table0(,%ecx,4),%ecx
541 movl CAST_S_table1(,%ebx,4),%ebx
542 addl %ebx, %ecx
543 movl CAST_S_table2(,%eax,4),%ebx
544 xorl %ebx, %ecx
545 movl CAST_S_table3(,%edx,4),%ebx
546 subl %ebx, %ecx
547 xorl %ecx, %edi
548 /* round 10 */
549 movl 80(%ebp), %edx
550 movl 84(%ebp), %ecx
551 xorl %edi, %edx
552 roll %cl, %edx
553 movl %edx, %ebx
554 xorl %ecx, %ecx
555 movb %dh, %cl
556 andl $255, %ebx
557 shrl $16, %edx
558 xorl %eax, %eax
559 movb %dh, %al
560 andl $255, %edx
561 movl CAST_S_table0(,%ecx,4),%ecx
562 movl CAST_S_table1(,%ebx,4),%ebx
563 subl %ebx, %ecx
564 movl CAST_S_table2(,%eax,4),%ebx
565 addl %ebx, %ecx
566 movl CAST_S_table3(,%edx,4),%ebx
567 xorl %ebx, %ecx
568 xorl %ecx, %esi
569 /* round 9 */
570 movl 72(%ebp), %edx
571 movl 76(%ebp), %ecx
572 addl %esi, %edx
573 roll %cl, %edx
574 movl %edx, %ebx
575 xorl %ecx, %ecx
576 movb %dh, %cl
577 andl $255, %ebx
578 shrl $16, %edx
579 xorl %eax, %eax
580 movb %dh, %al
581 andl $255, %edx
582 movl CAST_S_table0(,%ecx,4),%ecx
583 movl CAST_S_table1(,%ebx,4),%ebx
584 xorl %ebx, %ecx
585 movl CAST_S_table2(,%eax,4),%ebx
586 subl %ebx, %ecx
587 movl CAST_S_table3(,%edx,4),%ebx
588 addl %ebx, %ecx
589 xorl %ecx, %edi
590 /* round 8 */
591 movl 64(%ebp), %edx
592 movl 68(%ebp), %ecx
593 subl %edi, %edx
594 roll %cl, %edx
595 movl %edx, %ebx
596 xorl %ecx, %ecx
597 movb %dh, %cl
598 andl $255, %ebx
599 shrl $16, %edx
600 xorl %eax, %eax
601 movb %dh, %al
602 andl $255, %edx
603 movl CAST_S_table0(,%ecx,4),%ecx
604 movl CAST_S_table1(,%ebx,4),%ebx
605 addl %ebx, %ecx
606 movl CAST_S_table2(,%eax,4),%ebx
607 xorl %ebx, %ecx
608 movl CAST_S_table3(,%edx,4),%ebx
609 subl %ebx, %ecx
610 xorl %ecx, %esi
611 /* round 7 */
612 movl 56(%ebp), %edx
613 movl 60(%ebp), %ecx
614 xorl %esi, %edx
615 roll %cl, %edx
616 movl %edx, %ebx
617 xorl %ecx, %ecx
618 movb %dh, %cl
619 andl $255, %ebx
620 shrl $16, %edx
621 xorl %eax, %eax
622 movb %dh, %al
623 andl $255, %edx
624 movl CAST_S_table0(,%ecx,4),%ecx
625 movl CAST_S_table1(,%ebx,4),%ebx
626 subl %ebx, %ecx
627 movl CAST_S_table2(,%eax,4),%ebx
628 addl %ebx, %ecx
629 movl CAST_S_table3(,%edx,4),%ebx
630 xorl %ebx, %ecx
631 xorl %ecx, %edi
632 /* round 6 */
633 movl 48(%ebp), %edx
634 movl 52(%ebp), %ecx
635 addl %edi, %edx
636 roll %cl, %edx
637 movl %edx, %ebx
638 xorl %ecx, %ecx
639 movb %dh, %cl
640 andl $255, %ebx
641 shrl $16, %edx
642 xorl %eax, %eax
643 movb %dh, %al
644 andl $255, %edx
645 movl CAST_S_table0(,%ecx,4),%ecx
646 movl CAST_S_table1(,%ebx,4),%ebx
647 xorl %ebx, %ecx
648 movl CAST_S_table2(,%eax,4),%ebx
649 subl %ebx, %ecx
650 movl CAST_S_table3(,%edx,4),%ebx
651 addl %ebx, %ecx
652 xorl %ecx, %esi
653 /* round 5 */
654 movl 40(%ebp), %edx
655 movl 44(%ebp), %ecx
656 subl %esi, %edx
657 roll %cl, %edx
658 movl %edx, %ebx
659 xorl %ecx, %ecx
660 movb %dh, %cl
661 andl $255, %ebx
662 shrl $16, %edx
663 xorl %eax, %eax
664 movb %dh, %al
665 andl $255, %edx
666 movl CAST_S_table0(,%ecx,4),%ecx
667 movl CAST_S_table1(,%ebx,4),%ebx
668 addl %ebx, %ecx
669 movl CAST_S_table2(,%eax,4),%ebx
670 xorl %ebx, %ecx
671 movl CAST_S_table3(,%edx,4),%ebx
672 subl %ebx, %ecx
673 xorl %ecx, %edi
674 /* round 4 */
675 movl 32(%ebp), %edx
676 movl 36(%ebp), %ecx
677 xorl %edi, %edx
678 roll %cl, %edx
679 movl %edx, %ebx
680 xorl %ecx, %ecx
681 movb %dh, %cl
682 andl $255, %ebx
683 shrl $16, %edx
684 xorl %eax, %eax
685 movb %dh, %al
686 andl $255, %edx
687 movl CAST_S_table0(,%ecx,4),%ecx
688 movl CAST_S_table1(,%ebx,4),%ebx
689 subl %ebx, %ecx
690 movl CAST_S_table2(,%eax,4),%ebx
691 addl %ebx, %ecx
692 movl CAST_S_table3(,%edx,4),%ebx
693 xorl %ebx, %ecx
694 xorl %ecx, %esi
695 /* round 3 */
696 movl 24(%ebp), %edx
697 movl 28(%ebp), %ecx
698 addl %esi, %edx
699 roll %cl, %edx
700 movl %edx, %ebx
701 xorl %ecx, %ecx
702 movb %dh, %cl
703 andl $255, %ebx
704 shrl $16, %edx
705 xorl %eax, %eax
706 movb %dh, %al
707 andl $255, %edx
708 movl CAST_S_table0(,%ecx,4),%ecx
709 movl CAST_S_table1(,%ebx,4),%ebx
710 xorl %ebx, %ecx
711 movl CAST_S_table2(,%eax,4),%ebx
712 subl %ebx, %ecx
713 movl CAST_S_table3(,%edx,4),%ebx
714 addl %ebx, %ecx
715 xorl %ecx, %edi
716 /* round 2 */
717 movl 16(%ebp), %edx
718 movl 20(%ebp), %ecx
719 subl %edi, %edx
720 roll %cl, %edx
721 movl %edx, %ebx
722 xorl %ecx, %ecx
723 movb %dh, %cl
724 andl $255, %ebx
725 shrl $16, %edx
726 xorl %eax, %eax
727 movb %dh, %al
728 andl $255, %edx
729 movl CAST_S_table0(,%ecx,4),%ecx
730 movl CAST_S_table1(,%ebx,4),%ebx
731 addl %ebx, %ecx
732 movl CAST_S_table2(,%eax,4),%ebx
733 xorl %ebx, %ecx
734 movl CAST_S_table3(,%edx,4),%ebx
735 subl %ebx, %ecx
736 xorl %ecx, %esi
737 /* round 1 */
738 movl 8(%ebp), %edx
739 movl 12(%ebp), %ecx
740 xorl %esi, %edx
741 roll %cl, %edx
742 movl %edx, %ebx
743 xorl %ecx, %ecx
744 movb %dh, %cl
745 andl $255, %ebx
746 shrl $16, %edx
747 xorl %eax, %eax
748 movb %dh, %al
749 andl $255, %edx
750 movl CAST_S_table0(,%ecx,4),%ecx
751 movl CAST_S_table1(,%ebx,4),%ebx
752 subl %ebx, %ecx
753 movl CAST_S_table2(,%eax,4),%ebx
754 addl %ebx, %ecx
755 movl CAST_S_table3(,%edx,4),%ebx
756 xorl %ebx, %ecx
757 xorl %ecx, %edi
758 /* round 0 */
759 movl (%ebp), %edx
760 movl 4(%ebp), %ecx
761 addl %edi, %edx
762 roll %cl, %edx
763 movl %edx, %ebx
764 xorl %ecx, %ecx
765 movb %dh, %cl
766 andl $255, %ebx
767 shrl $16, %edx
768 xorl %eax, %eax
769 movb %dh, %al
770 andl $255, %edx
771 movl CAST_S_table0(,%ecx,4),%ecx
772 movl CAST_S_table1(,%ebx,4),%ebx
773 xorl %ebx, %ecx
774 movl CAST_S_table2(,%eax,4),%ebx
775 subl %ebx, %ecx
776 movl CAST_S_table3(,%edx,4),%ebx
777 addl %ebx, %ecx
778 movl 20(%esp), %eax
779 xorl %ecx, %esi
780 nop
781 movl %edi, 4(%eax)
782 movl %esi, (%eax)
783 popl %edi
784 popl %esi
785 popl %ebx
786 popl %ebp
787 ret
788.CAST_decrypt_end:
789 SIZE(CAST_decrypt,.CAST_decrypt_end-CAST_decrypt)
790.ident "CAST_decrypt"
791.text
792 .align ALIGN
793.globl CAST_cbc_encrypt
794 TYPE(CAST_cbc_encrypt,@function)
795CAST_cbc_encrypt:
796
797 pushl %ebp
798 pushl %ebx
799 pushl %esi
800 pushl %edi
801 movl 28(%esp), %ebp
802 /* getting iv ptr from parameter 4 */
803 movl 36(%esp), %ebx
804 movl (%ebx), %esi
805 movl 4(%ebx), %edi
806 pushl %edi
807 pushl %esi
808 pushl %edi
809 pushl %esi
810 movl %esp, %ebx
811 movl 36(%esp), %esi
812 movl 40(%esp), %edi
813 /* getting encrypt flag from parameter 5 */
814 movl 56(%esp), %ecx
815 /* get and push parameter 3 */
816 movl 48(%esp), %eax
817 pushl %eax
818 pushl %ebx
819 cmpl $0, %ecx
820 jz .L000decrypt
821 andl $4294967288, %ebp
822 movl 8(%esp), %eax
823 movl 12(%esp), %ebx
824 jz .L001encrypt_finish
825.L002encrypt_loop:
826 movl (%esi), %ecx
827 movl 4(%esi), %edx
828 xorl %ecx, %eax
829 xorl %edx, %ebx
830.byte 15
831.byte 200 /* bswapl %eax */
832.byte 15
833.byte 203 /* bswapl %ebx */
834 movl %eax, 8(%esp)
835 movl %ebx, 12(%esp)
836 call CAST_encrypt
837 movl 8(%esp), %eax
838 movl 12(%esp), %ebx
839.byte 15
840.byte 200 /* bswapl %eax */
841.byte 15
842.byte 203 /* bswapl %ebx */
843 movl %eax, (%edi)
844 movl %ebx, 4(%edi)
845 addl $8, %esi
846 addl $8, %edi
847 subl $8, %ebp
848 jnz .L002encrypt_loop
849.L001encrypt_finish:
850 movl 52(%esp), %ebp
851 andl $7, %ebp
852 jz .L003finish
853 xorl %ecx, %ecx
854 xorl %edx, %edx
855 movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp
856 jmp *%ebp
857.L005ej7:
858 xorl %edx, %edx
859 movb 6(%esi), %dh
860 sall $8, %edx
861.L006ej6:
862 movb 5(%esi), %dh
863.L007ej5:
864 movb 4(%esi), %dl
865.L008ej4:
866 movl (%esi), %ecx
867 jmp .L009ejend
868.L010ej3:
869 movb 2(%esi), %ch
870 xorl %ecx, %ecx
871 sall $8, %ecx
872.L011ej2:
873 movb 1(%esi), %ch
874.L012ej1:
875 movb (%esi), %cl
876.L009ejend:
877 xorl %ecx, %eax
878 xorl %edx, %ebx
879.byte 15
880.byte 200 /* bswapl %eax */
881.byte 15
882.byte 203 /* bswapl %ebx */
883 movl %eax, 8(%esp)
884 movl %ebx, 12(%esp)
885 call CAST_encrypt
886 movl 8(%esp), %eax
887 movl 12(%esp), %ebx
888.byte 15
889.byte 200 /* bswapl %eax */
890.byte 15
891.byte 203 /* bswapl %ebx */
892 movl %eax, (%edi)
893 movl %ebx, 4(%edi)
894 jmp .L003finish
895.align ALIGN
896.L000decrypt:
897 andl $4294967288, %ebp
898 movl 16(%esp), %eax
899 movl 20(%esp), %ebx
900 jz .L013decrypt_finish
901.L014decrypt_loop:
902 movl (%esi), %eax
903 movl 4(%esi), %ebx
904.byte 15
905.byte 200 /* bswapl %eax */
906.byte 15
907.byte 203 /* bswapl %ebx */
908 movl %eax, 8(%esp)
909 movl %ebx, 12(%esp)
910 call CAST_decrypt
911 movl 8(%esp), %eax
912 movl 12(%esp), %ebx
913.byte 15
914.byte 200 /* bswapl %eax */
915.byte 15
916.byte 203 /* bswapl %ebx */
917 movl 16(%esp), %ecx
918 movl 20(%esp), %edx
919 xorl %eax, %ecx
920 xorl %ebx, %edx
921 movl (%esi), %eax
922 movl 4(%esi), %ebx
923 movl %ecx, (%edi)
924 movl %edx, 4(%edi)
925 movl %eax, 16(%esp)
926 movl %ebx, 20(%esp)
927 addl $8, %esi
928 addl $8, %edi
929 subl $8, %ebp
930 jnz .L014decrypt_loop
931.L013decrypt_finish:
932 movl 52(%esp), %ebp
933 andl $7, %ebp
934 jz .L003finish
935 movl (%esi), %eax
936 movl 4(%esi), %ebx
937.byte 15
938.byte 200 /* bswapl %eax */
939.byte 15
940.byte 203 /* bswapl %ebx */
941 movl %eax, 8(%esp)
942 movl %ebx, 12(%esp)
943 call CAST_decrypt
944 movl 8(%esp), %eax
945 movl 12(%esp), %ebx
946.byte 15
947.byte 200 /* bswapl %eax */
948.byte 15
949.byte 203 /* bswapl %ebx */
950 movl 16(%esp), %ecx
951 movl 20(%esp), %edx
952 xorl %eax, %ecx
953 xorl %ebx, %edx
954 movl (%esi), %eax
955 movl 4(%esi), %ebx
956.L015dj7:
957 rorl $16, %edx
958 movb %dl, 6(%edi)
959 shrl $16, %edx
960.L016dj6:
961 movb %dh, 5(%edi)
962.L017dj5:
963 movb %dl, 4(%edi)
964.L018dj4:
965 movl %ecx, (%edi)
966 jmp .L019djend
967.L020dj3:
968 rorl $16, %ecx
969 movb %cl, 2(%edi)
970 sall $16, %ecx
971.L021dj2:
972 movb %ch, 1(%esi)
973.L022dj1:
974 movb %cl, (%esi)
975.L019djend:
976 jmp .L003finish
977.align ALIGN
978.L003finish:
979 movl 60(%esp), %ecx
980 addl $24, %esp
981 movl %eax, (%ecx)
982 movl %ebx, 4(%ecx)
983 popl %edi
984 popl %esi
985 popl %ebx
986 popl %ebp
987 ret
988.align ALIGN
989.L004cbc_enc_jmp_table:
990 .long 0
991 .long .L012ej1
992 .long .L011ej2
993 .long .L010ej3
994 .long .L008ej4
995 .long .L007ej5
996 .long .L006ej6
997 .long .L005ej7
998.align ALIGN
999.L023cbc_dec_jmp_table:
1000 .long 0
1001 .long .L022dj1
1002 .long .L021dj2
1003 .long .L020dj3
1004 .long .L018dj4
1005 .long .L017dj5
1006 .long .L016dj6
1007 .long .L015dj7
1008.CAST_cbc_encrypt_end:
1009 SIZE(CAST_cbc_encrypt,.CAST_cbc_encrypt_end-CAST_cbc_encrypt)
1010.ident "desasm.pl"
diff --git a/src/lib/libcrypto/conf/Makefile.ssl b/src/lib/libcrypto/conf/Makefile.ssl
new file mode 100644
index 0000000000..00e917aa44
--- /dev/null
+++ b/src/lib/libcrypto/conf/Makefile.ssl
@@ -0,0 +1,85 @@
1#
2# SSLeay/crypto/conf/Makefile
3#
4
5DIR= conf
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=conf
19ERRC=conf_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= conf.c $(ERRC).c
26
27LIBOBJ= conf.o $(ERRC).o
28
29SRC= $(LIBSRC)
30
31EXHEADER= conf.h
32HEADER= conf_lcl.h $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 sh $(TOP)/util/ranlib.sh $(LIB)
44 @touch lib
45
46files:
47 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 /bin/rm -f Makefile
51 $(TOP)/util/point.sh Makefile.ssl Makefile ;
52 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
53 $(TOP)/util/mklink.sh ../../test $(TEST)
54 $(TOP)/util/mklink.sh ../../apps $(APPS)
55
56install:
57 @for i in $(EXHEADER) ; \
58 do \
59 (cp $$i $(INSTALLTOP)/include/$$i; \
60 chmod 644 $(INSTALLTOP)/include/$$i ); \
61 done;
62
63tags:
64 ctags $(SRC)
65
66tests:
67
68lint:
69 lint -DLINT $(INCLUDES) $(SRC)>fluff
70
71depend:
72 $(MAKEDEPEND) $(INCLUDES) $(LIBSRC)
73
74dclean:
75 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
76 mv -f Makefile.new $(MAKEFILE)
77
78clean:
79 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
80
81errors:
82 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
83 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
84
85# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/conf/conf.c b/src/lib/libcrypto/conf/conf.c
new file mode 100644
index 0000000000..9e84300c5e
--- /dev/null
+++ b/src/lib/libcrypto/conf/conf.c
@@ -0,0 +1,727 @@
1/* crypto/conf/conf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <errno.h>
61#include "cryptlib.h"
62#include "stack.h"
63#include "lhash.h"
64#include "conf.h"
65#include "buffer.h"
66#include "err.h"
67
68#include "conf_lcl.h"
69
70#ifndef NOPROTO
71static void value_free_hash(CONF_VALUE *a, LHASH *conf);
72static void value_free_stack(CONF_VALUE *a,LHASH *conf);
73static unsigned long hash(CONF_VALUE *v);
74static int cmp(CONF_VALUE *a,CONF_VALUE *b);
75static char *eat_ws(char *p);
76static char *eat_alpha_numeric(char *p);
77static void clear_comments(char *p);
78static int str_copy(LHASH *conf,char *section,char **to, char *from);
79static char *scan_quote(char *p);
80static CONF_VALUE *new_section(LHASH *conf,char *section);
81static CONF_VALUE *get_section(LHASH *conf,char *section);
82#else
83static void value_free_hash();
84static void value_free_stack();
85static unsigned long hash();
86static int cmp();
87static char *eat_ws();
88static char *eat_alpha_numeric();
89static void clear_comments();
90static int str_copy();
91static char *scan_quote();
92static CONF_VALUE *new_section();
93static CONF_VALUE *get_section();
94#endif
95
96#define scan_esc(p) ((*(++p) == '\0')?(p):(++p))
97
98char *CONF_version="CONF part of SSLeay 0.9.0b 29-Jun-1998";
99
100LHASH *CONF_load(h,file,line)
101LHASH *h;
102char *file;
103long *line;
104 {
105 LHASH *ret=NULL;
106 FILE *in=NULL;
107#define BUFSIZE 512
108 int bufnum=0,i,ii;
109 BUF_MEM *buff=NULL;
110 char *s,*p,*end;
111 int again,n,eline=0;
112 CONF_VALUE *v=NULL,*vv,*tv;
113 CONF_VALUE *sv=NULL;
114 char *section=NULL,*buf;
115 STACK *section_sk=NULL,*ts;
116 char *start,*psection,*pname;
117
118 if ((buff=BUF_MEM_new()) == NULL)
119 {
120 CONFerr(CONF_F_CONF_LOAD,ERR_R_BUF_LIB);
121 goto err;
122 }
123
124 in=fopen(file,"rb");
125 if (in == NULL)
126 {
127 SYSerr(SYS_F_FOPEN,get_last_sys_error());
128 ERR_set_error_data(BUF_strdup(file),
129 ERR_TXT_MALLOCED|ERR_TXT_STRING);
130 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
131 goto err;
132 }
133
134 section=(char *)Malloc(10);
135 if (section == NULL)
136 {
137 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE);
138 goto err;
139 }
140 strcpy(section,"default");
141
142 if (h == NULL)
143 {
144 if ((ret=lh_new(hash,cmp)) == NULL)
145 {
146 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE);
147 goto err;
148 }
149 }
150 else
151 ret=h;
152
153 sv=new_section(ret,section);
154 if (sv == NULL)
155 {
156 CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
157 goto err;
158 }
159 section_sk=(STACK *)sv->value;
160
161 bufnum=0;
162 for (;;)
163 {
164 again=0;
165 if (!BUF_MEM_grow(buff,bufnum+BUFSIZE))
166 {
167 CONFerr(CONF_F_CONF_LOAD,ERR_R_BUF_LIB);
168 goto err;
169 }
170 p= &(buff->data[bufnum]);
171 *p='\0';
172 fgets(p,BUFSIZE-1,in);
173 p[BUFSIZE-1]='\0';
174 ii=i=strlen(p);
175 if (i == 0) break;
176 while (i > 0)
177 {
178 if ((p[i-1] != '\r') && (p[i-1] != '\n'))
179 break;
180 else
181 i--;
182 }
183 /* we removed some trailing stuff so there is a new
184 * line on the end. */
185 if (i == ii)
186 again=1; /* long line */
187 else
188 {
189 p[i]='\0';
190 eline++; /* another input line */
191 }
192
193 /* we now have a line with trailing \r\n removed */
194
195 /* i is the number of bytes */
196 bufnum+=i;
197
198 v=NULL;
199 /* check for line continuation */
200 if (bufnum >= 1)
201 {
202 /* If we have bytes and the last char '\\' and
203 * second last char is not '\\' */
204 p= &(buff->data[bufnum-1]);
205 if ( IS_ESC(p[0]) &&
206 ((bufnum <= 1) || !IS_ESC(p[-1])))
207 {
208 bufnum--;
209 again=1;
210 }
211 }
212 if (again) continue;
213 bufnum=0;
214 buf=buff->data;
215
216 clear_comments(buf);
217 n=strlen(buf);
218 s=eat_ws(buf);
219 if (IS_EOF(*s)) continue; /* blank line */
220 if (*s == '[')
221 {
222 s++;
223 start=eat_ws(s);
224 end=eat_alpha_numeric(start);
225 p=eat_ws(end);
226 if (*p != ']')
227 {
228 CONFerr(CONF_F_CONF_LOAD,CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
229 goto err;
230 }
231 *end='\0';
232 if (!str_copy(ret,NULL,&section,start)) goto err;
233 if ((sv=get_section(ret,section)) == NULL)
234 sv=new_section(ret,section);
235 if (sv == NULL)
236 {
237 CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
238 goto err;
239 }
240 section_sk=(STACK *)sv->value;
241 continue;
242 }
243 else
244 {
245 pname=s;
246 psection=NULL;
247 end=eat_alpha_numeric(s);
248 if ((end[0] == ':') && (end[1] == ':'))
249 {
250 *end='\0';
251 end+=2;
252 psection=pname;
253 pname=end;
254 end=eat_alpha_numeric(end);
255 }
256 p=eat_ws(end);
257 if (*p != '=')
258 {
259 CONFerr(CONF_F_CONF_LOAD,CONF_R_MISSING_EQUAL_SIGN);
260 goto err;
261 }
262 *end='\0';
263 p++;
264 start=eat_ws(p);
265 while (!IS_EOF(*p))
266 p++;
267 p--;
268 while ((p != start) && (IS_WS(*p)))
269 p--;
270 p++;
271 *p='\0';
272
273 if ((v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))) == NULL)
274 {
275 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE);
276 goto err;
277 }
278 if (psection == NULL) psection=section;
279 v->name=(char *)Malloc(strlen(pname)+1);
280 v->value=NULL;
281 if (v->name == NULL)
282 {
283 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE);
284 goto err;
285 }
286 strcpy(v->name,pname);
287 if (!str_copy(ret,psection,&(v->value),start)) goto err;
288
289 if (strcmp(psection,section) != 0)
290 {
291 if ((tv=get_section(ret,psection))
292 == NULL)
293 tv=new_section(ret,psection);
294 if (tv == NULL)
295 {
296 CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
297 goto err;
298 }
299 ts=(STACK *)tv->value;
300 }
301 else
302 {
303 tv=sv;
304 ts=section_sk;
305 }
306 v->section=tv->section;
307 if (!sk_push(ts,(char *)v))
308 {
309 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE);
310 goto err;
311 }
312 vv=(CONF_VALUE *)lh_insert(ret,(char *)v);
313 if (vv != NULL)
314 {
315 sk_delete_ptr(ts,(char *)vv);
316 Free(vv->name);
317 Free(vv->value);
318 Free(vv);
319 }
320 v=NULL;
321 }
322 }
323 if (buff != NULL) BUF_MEM_free(buff);
324 if (section != NULL) Free(section);
325 if (in != NULL) fclose(in);
326 return(ret);
327err:
328 if (buff != NULL) BUF_MEM_free(buff);
329 if (section != NULL) Free(section);
330 if (line != NULL) *line=eline;
331 if (in != NULL) fclose(in);
332 if ((h != ret) && (ret != NULL)) CONF_free(ret);
333 if (v != NULL)
334 {
335 if (v->name != NULL) Free(v->name);
336 if (v->value != NULL) Free(v->value);
337 if (v != NULL) Free(v);
338 }
339 return(NULL);
340 }
341
342char *CONF_get_string(conf,section,name)
343LHASH *conf;
344char *section;
345char *name;
346 {
347 CONF_VALUE *v,vv;
348 char *p;
349
350 if (name == NULL) return(NULL);
351 if (conf != NULL)
352 {
353 if (section != NULL)
354 {
355 vv.name=name;
356 vv.section=section;
357 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv);
358 if (v != NULL) return(v->value);
359 if (strcmp(section,"ENV") == 0)
360 {
361 p=Getenv(name);
362 if (p != NULL) return(p);
363 }
364 }
365 vv.section="default";
366 vv.name=name;
367 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv);
368 if (v != NULL)
369 return(v->value);
370 else
371 return(NULL);
372 }
373 else
374 return(Getenv(name));
375 }
376
377static CONF_VALUE *get_section(conf,section)
378LHASH *conf;
379char *section;
380 {
381 CONF_VALUE *v,vv;
382
383 if ((conf == NULL) || (section == NULL)) return(NULL);
384 vv.name=NULL;
385 vv.section=section;
386 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv);
387 return(v);
388 }
389
390STACK *CONF_get_section(conf,section)
391LHASH *conf;
392char *section;
393 {
394 CONF_VALUE *v;
395
396 v=get_section(conf,section);
397 if (v != NULL)
398 return((STACK *)v->value);
399 else
400 return(NULL);
401 }
402
403long CONF_get_number(conf,section,name)
404LHASH *conf;
405char *section;
406char *name;
407 {
408 char *str;
409 long ret=0;
410
411 str=CONF_get_string(conf,section,name);
412 if (str == NULL) return(0);
413 for (;;)
414 {
415 if (IS_NUMER(*str))
416 ret=ret*10+(*str -'0');
417 else
418 return(ret);
419 str++;
420 }
421 }
422
423void CONF_free(conf)
424LHASH *conf;
425 {
426 if (conf == NULL) return;
427
428 conf->down_load=0; /* evil thing to make sure the 'Free()'
429 * works as expected */
430 lh_doall_arg(conf,(void (*)())value_free_hash,(char *)conf);
431
432 /* We now have only 'section' entries in the hash table.
433 * Due to problems with */
434
435 lh_doall_arg(conf,(void (*)())value_free_stack,(char *)conf);
436 lh_free(conf);
437 }
438
439static void value_free_hash(a,conf)
440CONF_VALUE *a;
441LHASH *conf;
442 {
443 if (a->name != NULL)
444 {
445 a=(CONF_VALUE *)lh_delete(conf,(char *)a);
446 }
447 }
448
449static void value_free_stack(a,conf)
450CONF_VALUE *a;
451LHASH *conf;
452 {
453 CONF_VALUE *vv;
454 STACK *sk;
455 int i;
456
457 if (a->name != NULL) return;
458
459 sk=(STACK *)a->value;
460 for (i=sk_num(sk)-1; i>=0; i--)
461 {
462 vv=(CONF_VALUE *)sk_value(sk,i);
463 Free(vv->value);
464 Free(vv->name);
465 Free(vv);
466 }
467 if (sk != NULL) sk_free(sk);
468 Free(a->section);
469 Free(a);
470 }
471
472static void clear_comments(p)
473char *p;
474 {
475 char *to;
476
477 to=p;
478 for (;;)
479 {
480 if (IS_COMMENT(*p))
481 {
482 *p='\0';
483 return;
484 }
485 if (IS_QUOTE(*p))
486 {
487 p=scan_quote(p);
488 continue;
489 }
490 if (IS_ESC(*p))
491 {
492 p=scan_esc(p);
493 continue;
494 }
495 if (IS_EOF(*p))
496 return;
497 else
498 p++;
499 }
500 }
501
502static int str_copy(conf,section,pto,from)
503LHASH *conf;
504char *section;
505char **pto,*from;
506 {
507 int q,r,rr=0,to=0,len=0;
508 char *s,*e,*rp,*p,*rrp,*np,*cp,v;
509 BUF_MEM *buf;
510
511 if ((buf=BUF_MEM_new()) == NULL) return(0);
512
513 len=strlen(from)+1;
514 if (!BUF_MEM_grow(buf,len)) goto err;
515
516 for (;;)
517 {
518 if (IS_QUOTE(*from))
519 {
520 q= *from;
521 from++;
522 while ((*from != '\0') && (*from != q))
523 {
524 if (*from == '\\')
525 {
526 from++;
527 if (*from == '\0') break;
528 }
529 buf->data[to++]= *(from++);
530 }
531 }
532 else if (*from == '\\')
533 {
534 from++;
535 v= *(from++);
536 if (v == '\0') break;
537 else if (v == 'r') v='\r';
538 else if (v == 'n') v='\n';
539 else if (v == 'b') v='\b';
540 else if (v == 't') v='\t';
541 buf->data[to++]= v;
542 }
543 else if (*from == '\0')
544 break;
545 else if (*from == '$')
546 {
547 /* try to expand it */
548 rrp=NULL;
549 s= &(from[1]);
550 if (*s == '{')
551 q='}';
552 else if (*s == '(')
553 q=')';
554 else q=0;
555
556 if (q) s++;
557 cp=section;
558 e=np=s;
559 while (IS_ALPHA_NUMERIC(*e))
560 e++;
561 if ((e[0] == ':') && (e[1] == ':'))
562 {
563 cp=np;
564 rrp=e;
565 rr= *e;
566 *rrp='\0';
567 e+=2;
568 np=e;
569 while (IS_ALPHA_NUMERIC(*e))
570 e++;
571 }
572 r= *e;
573 *e='\0';
574 rp=e;
575 if (q)
576 {
577 if (r != q)
578 {
579 CONFerr(CONF_F_STR_COPY,CONF_R_NO_CLOSE_BRACE);
580 goto err;
581 }
582 e++;
583 }
584 /* So at this point we have
585 * ns which is the start of the name string which is
586 * '\0' terminated.
587 * cs which is the start of the section string which is
588 * '\0' terminated.
589 * e is the 'next point after'.
590 * r and s are the chars replaced by the '\0'
591 * rp and sp is where 'r' and 's' came from.
592 */
593 p=CONF_get_string(conf,cp,np);
594 if (rrp != NULL) *rrp=rr;
595 *rp=r;
596 if (p == NULL)
597 {
598 CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE);
599 goto err;
600 }
601 BUF_MEM_grow(buf,(strlen(p)+len-(e-from)));
602 while (*p)
603 buf->data[to++]= *(p++);
604 from=e;
605 }
606 else
607 buf->data[to++]= *(from++);
608 }
609 buf->data[to]='\0';
610 if (*pto != NULL) Free(*pto);
611 *pto=buf->data;
612 Free(buf);
613 return(1);
614err:
615 if (buf != NULL) BUF_MEM_free(buf);
616 return(0);
617 }
618
619static char *eat_ws(p)
620char *p;
621 {
622 while (IS_WS(*p) && (!IS_EOF(*p)))
623 p++;
624 return(p);
625 }
626
627static char *eat_alpha_numeric(p)
628char *p;
629 {
630 for (;;)
631 {
632 if (IS_ESC(*p))
633 {
634 p=scan_esc(p);
635 continue;
636 }
637 if (!IS_ALPHA_NUMERIC_PUNCT(*p))
638 return(p);
639 p++;
640 }
641 }
642
643static unsigned long hash(v)
644CONF_VALUE *v;
645 {
646 return((lh_strhash(v->section)<<2)^lh_strhash(v->name));
647 }
648
649static int cmp(a,b)
650CONF_VALUE *a,*b;
651 {
652 int i;
653
654 if (a->section != b->section)
655 {
656 i=strcmp(a->section,b->section);
657 if (i) return(i);
658 }
659
660 if ((a->name != NULL) && (b->name != NULL))
661 {
662 i=strcmp(a->name,b->name);
663 return(i);
664 }
665 else if (a->name == b->name)
666 return(0);
667 else
668 return((a->name == NULL)?-1:1);
669 }
670
671static char *scan_quote(p)
672char *p;
673 {
674 int q= *p;
675
676 p++;
677 while (!(IS_EOF(*p)) && (*p != q))
678 {
679 if (IS_ESC(*p))
680 {
681 p++;
682 if (IS_EOF(*p)) return(p);
683 }
684 p++;
685 }
686 if (*p == q) p++;
687 return(p);
688 }
689
690static CONF_VALUE *new_section(conf,section)
691LHASH *conf;
692char *section;
693 {
694 STACK *sk=NULL;
695 int ok=0,i;
696 CONF_VALUE *v=NULL,*vv;
697
698 if ((sk=sk_new_null()) == NULL)
699 goto err;
700 if ((v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))) == NULL)
701 goto err;
702 i=strlen(section)+1;
703 if ((v->section=(char *)Malloc(i)) == NULL)
704 goto err;
705
706 memcpy(v->section,section,i);
707 v->name=NULL;
708 v->value=(char *)sk;
709
710 vv=(CONF_VALUE *)lh_insert(conf,(char *)v);
711 if (vv != NULL)
712 {
713#if !defined(NO_STDIO) && !defined(WIN16)
714 fprintf(stderr,"internal fault\n");
715#endif
716 abort();
717 }
718 ok=1;
719err:
720 if (!ok)
721 {
722 if (sk != NULL) sk_free(sk);
723 if (v != NULL) Free(v);
724 v=NULL;
725 }
726 return(v);
727 }
diff --git a/src/lib/libcrypto/conf/conf.err b/src/lib/libcrypto/conf/conf.err
new file mode 100644
index 0000000000..933d3d692a
--- /dev/null
+++ b/src/lib/libcrypto/conf/conf.err
@@ -0,0 +1,12 @@
1/* Error codes for the CONF functions. */
2
3/* Function codes. */
4#define CONF_F_CONF_LOAD 100
5#define CONF_F_STR_COPY 101
6
7/* Reason codes. */
8#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100
9#define CONF_R_MISSING_EQUAL_SIGN 101
10#define CONF_R_NO_CLOSE_BRACE 102
11#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103
12#define CONF_R_VARIABLE_HAS_NO_VALUE 104
diff --git a/src/lib/libcrypto/conf/conf_lcl.h b/src/lib/libcrypto/conf/conf_lcl.h
new file mode 100644
index 0000000000..4e5644ed79
--- /dev/null
+++ b/src/lib/libcrypto/conf/conf_lcl.h
@@ -0,0 +1,102 @@
1/* crypto/conf/conf_lcl.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#define CONF_NUMBER 1
60#define CONF_UPPER 2
61#define CONF_LOWER 4
62#define CONF_UNDER 256
63#define CONF_PUNCTUATION 512
64#define CONF_WS 16
65#define CONF_ESC 32
66#define CONF_QUOTE 64
67#define CONF_COMMENT 128
68#define CONF_EOF 8
69#define CONF_ALPHA (CONF_UPPER|CONF_LOWER)
70#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
71#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \
72 CONF_PUNCTUATION)
73
74#define IS_COMMENT(a) (CONF_COMMENT&(CONF_type[(a)&0x7f]))
75#define IS_EOF(a) ((a) == '\0')
76#define IS_ESC(a) ((a) == '\\')
77#define IS_NUMER(a) (CONF_type[(a)&0x7f]&CONF_NUMBER)
78#define IS_WS(a) (CONF_type[(a)&0x7f]&CONF_WS)
79#define IS_ALPHA_NUMERIC(a) (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC)
80#define IS_ALPHA_NUMERIC_PUNCT(a) \
81 (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC_PUNCT)
82#define IS_QUOTE(a) (CONF_type[(a)&0x7f]&CONF_QUOTE)
83
84static unsigned short CONF_type[128]={
85 0x008,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
86 0x000,0x010,0x010,0x000,0x000,0x010,0x000,0x000,
87 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
88 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
89 0x010,0x200,0x040,0x080,0x000,0x200,0x200,0x040,
90 0x000,0x000,0x200,0x200,0x200,0x200,0x200,0x200,
91 0x001,0x001,0x001,0x001,0x001,0x001,0x001,0x001,
92 0x001,0x001,0x000,0x200,0x000,0x000,0x000,0x200,
93 0x200,0x002,0x002,0x002,0x002,0x002,0x002,0x002,
94 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002,
95 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002,
96 0x002,0x002,0x002,0x000,0x020,0x000,0x200,0x100,
97 0x040,0x004,0x004,0x004,0x004,0x004,0x004,0x004,
98 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004,
99 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004,
100 0x004,0x004,0x004,0x000,0x200,0x000,0x200,0x000,
101 };
102
diff --git a/src/lib/libcrypto/cryptall.h b/src/lib/libcrypto/cryptall.h
new file mode 100644
index 0000000000..65a46452a8
--- /dev/null
+++ b/src/lib/libcrypto/cryptall.h
@@ -0,0 +1,110 @@
1/* crypto/cryptall.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef HEADER_CRYPTOALL_H
60#define HEADER_CRYPTOALL_H
61
62#include "buffer.h"
63#include "stack.h"
64#include "lhash.h"
65
66#include "err.h"
67
68#ifdef NO_MD2
69#include <md2.h>
70#else
71#include "md2.h"
72#endif
73#ifdef NO_MD5
74#include <md5.h>
75#else
76#include "md5.h"
77#endif
78#include "sha.h"
79
80#ifdef NO_DES
81#include <des.h>
82#else
83#include "des.h"
84#endif
85#include "rc2.h"
86#include "rc4.h"
87#include "idea.h"
88
89#include "bn.h"
90#include "dh.h"
91#include "rsa.h"
92#include "dsa.h"
93
94#include "rand.h"
95#include "conf.h"
96#include "txt_db.h"
97
98#include "err.h"
99#include "evp.h"
100
101#include "meth.h"
102#include "x509.h"
103#include "pkcs7.h"
104#include "pem.h"
105#include "asn1.h"
106#include "objects.h"
107
108#include "crypto.h"
109
110#endif
diff --git a/src/lib/libcrypto/crypto.c b/src/lib/libcrypto/crypto.c
new file mode 100644
index 0000000000..366e25c939
--- /dev/null
+++ b/src/lib/libcrypto/crypto.c
@@ -0,0 +1,575 @@
1/* crypto/crypto.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* If you are happy to use the assmbler version of bn/bn_mulw.c, define
60 * BN_ASM */
61#ifndef BN_ASM
62#undef BN_ASM
63#define X86_ASM
64#endif
65
66#ifndef DES_ASM
67#undef DES_ASM
68#endif
69
70#ifndef BF_ASM
71#undef BF_ASM
72#endif
73
74/* The following defines are only to break the compiles into chunks.
75 * If you wish to not compile some sections, use the 'NO_XXX' macros
76 */
77#ifndef CRYPTO_SUBSET
78/* Define all subset symbols. */
79#define CRYPTO_LIB_SUBSET
80#define CRYPTO_ASN1_SUBSET
81#define CRYPTO_BN_SUBSET
82#define CRYPTO_BUFFER_SUBSET
83#define CRYPTO_BIO_SUBSET
84#define CRYPTO_CONF_SUBSET
85#define CRYPTO_DES_SUBSET
86#define CRYPTO_DH_SUBSET
87#define CRYPTO_DSA_SUBSET
88#define CRYPTO_ERROR_SUBSET
89#define CRYPTO_EVP_SUBSET
90#define CRYPTO_IDEA_SUBSET
91#define CRYPTO_LHASH_SUBSET
92#define CRYPTO_MD_SUBSET
93#define CRYPTO_MDC2_SUBSET
94#define CRYPTO_METH_SUBSET
95#define CRYPTO_OBJECTS_SUBSET
96#define CRYPTO_PEM_SUBSET
97#define CRYPTO_RAND_SUBSET
98#define CRYPTO_RC_SUBSET
99#define CRYPTO_BLOWFISH_SUBSET
100#define CRYPTO_CAST_SUBSET
101#define CRYPTO_RSA_SUBSET
102#define CRYPTO_SHA_SUBSET
103#define CRYPTO_HMAC_SUBSET
104#define CRYPTO_SHA1_SUBSET
105#define CRYPTO_STACK_SUBSET
106#define CRYPTO_TXT_DB_SUBSET
107#define CRYPTO_X509_SUBSET
108#define CRYPTO_PKCS7_SUBSET
109#endif
110
111#include <stdio.h>
112#include <stdlib.h>
113#include <string.h>
114
115#define USE_SOCKETS
116#include "../e_os.h"
117
118#include "buffer.h"
119#include "bio.h"
120#include "stack.h"
121#include "lhash.h"
122
123#include "err.h"
124
125#include "bn.h"
126#include "evp.h"
127
128#include "rand.h"
129#include "conf.h"
130#include "txt_db.h"
131
132#include "x509.h"
133#include "pkcs7.h"
134#include "pem.h"
135#include "asn1.h"
136#include "objects.h"
137
138#ifdef CRYPTO_LIB_SUBSET
139#include "cryptlib.c"
140#include "mem.c"
141#include "cversion.c"
142#endif
143
144#ifdef CRYPTO_ASN1_SUBSET
145#include "asn1/a_meth.c"
146#include "asn1/a_bitstr.c"
147#include "asn1/a_d2i_fp.c"
148#include "asn1/a_dup.c"
149#include "asn1/a_hdr.c"
150#include "asn1/a_i2d_fp.c"
151#include "asn1/a_int.c"
152#include "asn1/a_bool.c"
153#include "asn1/a_bytes.c"
154#include "asn1/a_object.c"
155#include "asn1/a_octet.c"
156#include "asn1/a_print.c"
157#include "asn1/a_set.c"
158#include "asn1/a_sign.c"
159#include "asn1/a_type.c"
160#include "asn1/a_utctm.c"
161#include "asn1/a_verify.c"
162#include "asn1/a_digest.c"
163#include "asn1/asn1_err.c"
164#include "asn1/asn1_lib.c"
165#include "asn1/asn1_par.c"
166#ifndef NO_DH
167#include "asn1/d2i_dhp.c"
168#include "asn1/i2d_dhp.c"
169#endif
170#ifndef NO_DSA
171#include "asn1/d2i_dsap.c"
172#include "asn1/i2d_dsap.c"
173#include "asn1/d2i_s_pr.c"
174#include "asn1/i2d_s_pr.c"
175#include "asn1/d2i_s_pu.c"
176#include "asn1/i2d_s_pu.c"
177#endif
178#ifndef NO_RSA
179#include "asn1/d2i_r_pr.c"
180#include "asn1/i2d_r_pr.c"
181#include "asn1/d2i_r_pu.c"
182#include "asn1/i2d_r_pu.c"
183#include "asn1/n_pkey.c"
184#endif
185#include "asn1/d2i_pr.c"
186#include "asn1/d2i_pu.c"
187#include "asn1/i2d_pr.c"
188#include "asn1/i2d_pu.c"
189#include "asn1/f_int.c"
190#include "asn1/f_string.c"
191#include "asn1/p7_dgst.c"
192#include "asn1/p7_enc.c"
193#include "asn1/p7_enc_c.c"
194#include "asn1/p7_evp.c"
195#include "asn1/p7_i_s.c"
196#include "asn1/p7_lib.c"
197#include "asn1/p7_recip.c"
198#include "asn1/p7_s_e.c"
199#include "asn1/p7_signd.c"
200#include "asn1/p7_signi.c"
201#include "asn1/t_pkey.c"
202#include "asn1/t_req.c"
203#include "asn1/t_x509.c"
204#include "asn1/x_algor.c"
205#include "asn1/x_attrib.c"
206#include "asn1/x_exten.c"
207#include "asn1/x_cinf.c"
208#include "asn1/x_crl.c"
209#include "asn1/x_info.c"
210#include "asn1/x_name.c"
211#include "asn1/x_pkey.c"
212#include "asn1/x_pubkey.c"
213#include "asn1/x_req.c"
214#include "asn1/x_sig.c"
215#include "asn1/x_spki.c"
216#include "asn1/x_val.c"
217#include "asn1/x_x509.c"
218#endif
219
220#ifdef CRYPTO_BN_SUBSET
221#include "bn/bn_add.c"
222#include "bn/bn_div.c"
223#include "bn/bn_exp.c"
224#include "bn/bn_mont.c"
225#include "bn/bn_recp.c"
226#include "bn/bn_gcd.c"
227#include "bn/bn_lib.c"
228#include "bn/bn_mod.c"
229#include "bn/bn_mul.c"
230#ifndef BN_ASM
231#include "bn/bn_mulw.c"
232#endif
233#include "bn/bn_prime.c"
234#include "bn/bn_rand.c"
235#include "bn/bn_shift.c"
236#include "bn/bn_sqr.c"
237#include "bn/bn_sub.c"
238#include "bn/bn_word.c"
239#include "bn/bn_print.c"
240#include "bn/bn_err.c"
241#include "bn/bn_blind.c"
242#endif
243
244#ifdef CRYPTO_BIO_SUBSET
245#include "bio/bf_buff.c"
246#include "bio/bf_null.c"
247#include "bio/bf_nbio.c"
248#include "bio/bio_cb.c"
249#include "bio/bio_lib.c"
250#include "bio/bss_fd.c"
251#include "bio/bss_file.c"
252#include "bio/bss_mem.c"
253#include "bio/bss_null.c"
254#ifdef VMS
255#include "bio/bss_rtcp.c"
256#endif
257#include "bio/bss_sock.c"
258#include "bio/bss_conn.c"
259#include "bio/bss_acpt.c"
260#include "bio/b_sock.c"
261#include "bio/b_print.c"
262#include "bio/b_dump.c"
263#include "bio/bio_err.c"
264#endif
265
266#ifdef CRYPTO_BUFFER_SUBSET
267#include "buffer/buf_err.c"
268#include "buffer/buffer.c"
269#endif
270
271#ifdef CRYPTO_CONF_SUBSET
272#include "conf/conf.c"
273#include "conf/conf_err.c"
274#endif
275
276#ifdef CRYPTO_DES_SUBSET
277#include "des/read_pwd.c"
278#ifndef NO_DES
279#ifndef DES_ASM
280#include "des/fcrypt_b.c"
281#include "des/des_enc.c"
282#endif
283#include "des/cbc_cksm.c"
284#include "des/xcbc_enc.c"
285#include "des/cbc_enc.c"
286#include "des/cfb64ede.c"
287#include "des/cfb64enc.c"
288#include "des/cfb_enc.c"
289#include "des/ecb3_enc.c"
290#include "des/ecb_enc.c"
291#include "des/enc_read.c"
292#include "des/enc_writ.c"
293#include "des/fcrypt.c"
294#include "des/ofb64ede.c"
295#include "des/ofb64enc.c"
296#include "des/ofb_enc.c"
297#include "des/pcbc_enc.c"
298#include "des/qud_cksm.c"
299#include "des/rand_key.c"
300#include "des/read2pwd.c"
301#include "des/rpc_enc.c"
302#include "des/set_key.c"
303#include "des/str2key.c"
304#include "des/supp.c"
305#endif
306#endif
307
308#ifdef CRYPTO_DH_SUBSET
309#ifndef NO_DH
310#include "dh/dh_check.c"
311#include "dh/dh_err.c"
312#include "dh/dh_gen.c"
313#include "dh/dh_key.c"
314#include "dh/dh_lib.c"
315#endif
316#endif
317
318#ifdef CRYPTO_DSA_SUBSET
319#ifndef NO_DSA
320#include "dsa/dsa_gen.c"
321#include "dsa/dsa_key.c"
322#include "dsa/dsa_lib.c"
323#include "dsa/dsa_sign.c"
324#include "dsa/dsa_vrf.c"
325#include "dsa/dsa_err.c"
326#endif
327#endif
328
329#ifdef CRYPTO_ERROR_SUBSET
330#include "err/err.c"
331#include "err/err_all.c"
332#include "err/err_prn.c"
333#endif
334
335#ifdef CRYPTO_EVP_SUBSET
336#include "evp/bio_md.c"
337#include "evp/bio_b64.c"
338#include "evp/bio_enc.c"
339#include "evp/c_all.c"
340#include "evp/digest.c"
341#ifndef NO_DES
342#include "evp/e_cbc_3d.c"
343#include "evp/e_cfb_3d.c"
344#include "evp/e_ecb_3d.c"
345#include "evp/e_ofb_3d.c"
346#include "evp/e_cbc_d.c"
347#include "evp/e_cfb_d.c"
348#include "evp/e_xcbc_d.c"
349#include "evp/e_ecb_d.c"
350#include "evp/e_ofb_d.c"
351#endif
352#ifndef NO_IDEA
353#include "evp/e_cbc_i.c"
354#include "evp/e_cfb_i.c"
355#include "evp/e_ecb_i.c"
356#include "evp/e_ofb_i.c"
357#endif
358#ifndef NO_RC2
359#include "evp/e_cbc_r2.c"
360#include "evp/e_cfb_r2.c"
361#include "evp/e_ecb_r2.c"
362#include "evp/e_ofb_r2.c"
363#endif
364#ifndef NO_BLOWFISH
365#include "evp/e_cbc_bf.c"
366#include "evp/e_cfb_bf.c"
367#include "evp/e_ecb_bf.c"
368#include "evp/e_ofb_bf.c"
369#endif
370#ifndef NO_CAST
371#include "evp/e_cbc_c.c"
372#include "evp/e_cfb_c.c"
373#include "evp/e_ecb_c.c"
374#include "evp/e_ofb_c.c"
375#endif
376#ifndef NO_RC4
377#include "evp/e_rc4.c"
378#endif
379#include "rc5/rc5_enc.c"
380#include "rc5/rc5cfb64.c"
381#include "rc5/rc5_ecb.c"
382#include "rc5/rc5_skey.c"
383#include "rc5/rc5ofb64.c"
384#include "ripemd/rmd160.c"
385#include "ripemd/rmd_dgst.c"
386#include "ripemd/rmd_one.c"
387#include "evp/evp_lib.c"
388
389#include "evp/names.c"
390#include "evp/e_null.c"
391#include "evp/encode.c"
392#include "evp/evp_enc.c"
393#include "evp/evp_err.c"
394#include "evp/evp_key.c"
395#include "evp/m_null.c"
396#include "evp/p_lib.c"
397#ifndef NO_RSA
398#include "evp/p_open.c"
399#include "evp/p_seal.c"
400#endif
401#include "evp/p_sign.c"
402#include "evp/p_verify.c"
403#endif
404
405#ifdef CRYPTO_IDEA_SUBSET
406#ifndef NO_IDEA
407#include "idea/i_cbc.c"
408#include "idea/i_cfb64.c"
409#include "idea/i_ecb.c"
410#include "idea/i_ofb64.c"
411#include "idea/i_skey.c"
412#endif
413#endif
414
415#ifdef CRYPTO_BLOWFISH_SUBSET
416#ifndef NO_BLOWFISH
417#include "bf/bf_cfb64.c"
418#include "bf/bf_ecb.c"
419#ifndef BF_ASM
420#include "bf/bf_enc.c"
421#endif
422#include "bf/bf_ofb64.c"
423#include "bf/bf_skey.c"
424#endif
425#endif
426
427#ifdef CRYPTO_CAST_SUBSET
428#ifndef NO_CAST
429#include "cast/c_cfb64.c"
430#include "cast/c_ecb.c"
431#ifndef CAST_ASM
432#include "cast/c_enc.c"
433#endif
434#include "cast/c_ofb64.c"
435#include "cast/c_skey.c"
436#endif
437#endif
438
439#ifdef CRYPTO_LHASH_SUBSET
440#include "lhash/lh_stats.c"
441#include "lhash/lhash.c"
442#endif
443
444#ifdef CRYPTO_MD_SUBSET
445#ifndef NO_MD2
446#include "md2/md2_dgst.c"
447#include "md2/md2_one.c"
448#include "evp/m_md2.c"
449#endif
450#ifndef NO_MD5
451#include "md5/md5_dgst.c"
452#include "md5/md5_one.c"
453#include "evp/m_md5.c"
454#endif
455#endif
456
457#ifdef CRYPTO_MDC2_SUBSET
458#ifndef NO_MDC2
459#include "mdc2/mdc2dgst.c"
460#include "mdc2/mdc2_one.c"
461#include "evp/m_mdc2.c"
462#endif
463#endif
464
465#ifdef CRYPTO_OBJECTS_SUBSET
466#include "objects/obj_dat.c"
467#include "objects/obj_err.c"
468#include "objects/obj_lib.c"
469#endif
470
471#ifdef CRYPTO_PEM_SUBSET
472#include "pem/pem_err.c"
473#include "pem/pem_info.c"
474#include "pem/pem_lib.c"
475#include "pem/pem_all.c"
476#ifndef NO_RSA
477#include "pem/pem_seal.c"
478#include "pem/pem_sign.c"
479#endif
480#endif
481
482#ifdef CRYPTO_RAND_SUBSET
483#include "rand/md_rand.c"
484#include "rand/randfile.c"
485#endif
486
487#ifdef CRYPTO_RC_SUBSET
488#ifndef NO_RC2
489#include "rc2/rc2_cbc.c"
490#include "rc2/rc2_ecb.c"
491#include "rc2/rc2_skey.c"
492#include "rc2/rc2cfb64.c"
493#include "rc2/rc2ofb64.c"
494#endif
495#ifndef NO_RC4
496#include "rc4/rc4_skey.c"
497#ifndef RC4_ASM
498#include "rc4/rc4_enc.c"
499#endif
500#endif
501#endif
502
503#ifdef CRYPTO_HMAC_SUBSET
504#include "hmac/hmac.c"
505#endif
506
507#ifdef CRYPTO_RSA_SUBSET
508#ifndef NO_RSA
509#include "rsa/rsa_eay.c"
510#include "rsa/rsa_err.c"
511#include "rsa/rsa_gen.c"
512#include "rsa/rsa_lib.c"
513#include "rsa/rsa_sign.c"
514#include "rsa/rsa_saos.c"
515#endif
516#endif
517
518#ifdef CRYPTO_SHA1_SUBSET
519#ifndef NO_SHA1
520#include "sha/sha1_one.c"
521#include "sha/sha1dgst.c"
522#include "evp/m_dss1.c"
523#include "evp/m_sha1.c"
524#endif
525#endif
526
527#ifdef CRYPTO_SHA_SUBSET
528#ifndef NO_SHA
529#include "evp/m_dss.c"
530#include "sha/sha_dgst.c"
531#include "sha/sha_one.c"
532#include "evp/m_sha.c"
533#endif
534#endif
535
536#ifdef CRYPTO_STACK_SUBSET
537#include "stack/stack.c"
538#endif
539
540#ifdef CRYPTO_TXT_DB_SUBSET
541#include "txt_db/txt_db.c"
542#endif
543
544#ifdef CRYPTO_X509_SUBSET
545#include "x509/x509_cmp.c"
546#include "x509/x509_d2.c"
547#include "x509/x509_def.c"
548#include "x509/x509_err.c"
549#include "x509/x509_ext.c"
550#include "x509/x509_lu.c"
551#include "x509/x509_obj.c"
552#include "x509/x509_r2x.c"
553#include "x509/x509_req.c"
554#include "x509/x509_set.c"
555#include "x509/x509_v3.c"
556#include "x509/x509_vfy.c"
557#include "x509/x509name.c"
558#include "x509/x509pack.c"
559#include "x509/x509rset.c"
560#include "x509/x509type.c"
561#include "x509/x_all.c"
562#include "x509/x509_txt.c"
563#include "x509/by_dir.c"
564#include "x509/by_file.c"
565#include "x509/v3_net.c"
566#include "x509/v3_x509.c"
567#endif
568
569
570#ifdef CRYPTO_PKCS7_SUBSET /* I have an explicit removal of 7 lines */
571#include "pkcs7/pk7_lib.c"
572#include "pkcs7/pkcs7err.c"
573#include "pkcs7/pk7_doit.c"
574#endif /* CRYPTO_PKCS7_SUBSET */
575
diff --git a/src/lib/libcrypto/crypto.err b/src/lib/libcrypto/crypto.err
new file mode 100644
index 0000000000..4ea3385e73
--- /dev/null
+++ b/src/lib/libcrypto/crypto.err
@@ -0,0 +1,8 @@
1/* Error codes for the CRYPTO functions. */
2
3/* Function codes. */
4#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
5#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101
6#define CRYPTO_F_CRYPTO_SET_EX_DATA 102
7
8/* Reason codes. */
diff --git a/src/lib/libcrypto/date.h b/src/lib/libcrypto/date.h
new file mode 100644
index 0000000000..dbb71bd1b7
--- /dev/null
+++ b/src/lib/libcrypto/date.h
@@ -0,0 +1 @@
#define DATE "Sun Jul 12 21:04:32 MDT 1998"
diff --git a/src/lib/libcrypto/des/DES.pod b/src/lib/libcrypto/des/DES.pod
new file mode 100644
index 0000000000..8a739e7ca0
--- /dev/null
+++ b/src/lib/libcrypto/des/DES.pod
@@ -0,0 +1,16 @@
1crypt <= crypt(buf,salt)
2key <= set_odd_parity(key)
3int <= is_weak_key(key)
4keysched<= set_key(key)
5key <= ecb_encrypt(string8,ks,enc)
6key <= ecb3_encrypt(input,ks1,ks2,enc)
7string <= cbc_encrypt(input,ks,ivec,enc) => ivec
8string <= cbc3_encrypt(input,ks1,ks2,ivec1,ivec2,enc) => ivec1&ivec2
9ck1,ck2 <= cbc_cksum(input,ks,ivec) => ivec
10string <= pcbc_encrypt(input,ks,ivec,enc) => ivec
11string <= ofb_encrypt(input,numbits,ks,ivec) => ivec
12string <= cfb_encrypt(input,numbits,ks,ivec,enc) => ivec
13key <= random_key()
14key <= string_to_key(string)
15key1,key2<= string_to_2keys(string)
16
diff --git a/src/lib/libcrypto/des/FILES b/src/lib/libcrypto/des/FILES
new file mode 100644
index 0000000000..4c7ea2de7a
--- /dev/null
+++ b/src/lib/libcrypto/des/FILES
@@ -0,0 +1,96 @@
1/* General stuff */
2COPYRIGHT - Copyright info.
3MODES.DES - A description of the features of the different modes of DES.
4FILES - This file.
5INSTALL - How to make things compile.
6Imakefile - For use with kerberos.
7README - What this package is.
8VERSION - Which version this is and what was changed.
9KERBEROS - Kerberos version 4 notes.
10Makefile.PL - An old makefile to build with perl5, not current.
11Makefile.ssl - The SSLeay makefile
12Makefile.uni - The normal unix makefile.
13GNUmakefile - The makefile for use with glibc.
14makefile.bc - A Borland C makefile
15times - Some outputs from 'speed' on some machines.
16vms.com - For use when compiling under VMS
17
18/* My SunOS des(1) replacement */
19des.c - des(1) source code.
20des.man - des(1) manual.
21
22/* Testing and timing programs. */
23destest.c - Source for libdes.a test program.
24speed.c - Source for libdes.a timing program.
25rpw.c - Source for libdes.a testing password reading routines.
26
27/* libdes.a source code */
28des_crypt.man - libdes.a manual page.
29des.h - Public libdes.a header file.
30ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code.
31ecb3_enc.c - des_ecb3_encrypt() source.
32cbc_ckm.c - des_cbc_cksum() source.
33cbc_enc.c - des_cbc_encrypt() source.
34ncbc_enc.c - des_cbc_encrypt() that is 'normal' in that it copies
35 the new iv values back in the passed iv vector.
36ede_enc.c - des_ede3_cbc_encrypt() cbc mode des using triple DES.
37cbc3_enc.c - des_3cbc_encrypt() source, don't use this function.
38cfb_enc.c - des_cfb_encrypt() source.
39cfb64enc.c - des_cfb64_encrypt() cfb in 64 bit mode but setup to be
40 used as a stream cipher.
41cfb64ede.c - des_ede3_cfb64_encrypt() cfb in 64 bit mode but setup to be
42 used as a stream cipher and using triple DES.
43ofb_enc.c - des_cfb_encrypt() source.
44ofb64_enc.c - des_ofb_encrypt() ofb in 64 bit mode but setup to be
45 used as a stream cipher.
46ofb64ede.c - des_ede3_ofb64_encrypt() ofb in 64 bit mode but setup to be
47 used as a stream cipher and using triple DES.
48enc_read.c - des_enc_read() source.
49enc_writ.c - des_enc_write() source.
50pcbc_enc.c - des_pcbc_encrypt() source.
51qud_cksm.c - quad_cksum() source.
52rand_key.c - des_random_key() source.
53read_pwd.c - Source for des_read_password() plus related functions.
54set_key.c - Source for des_set_key().
55str2key.c - Covert a string of any length into a key.
56fcrypt.c - A small, fast version of crypt(3).
57des_locl.h - Internal libdes.a header file.
58podd.h - Odd parity tables - used in des_set_key().
59sk.h - Lookup tables used in des_set_key().
60spr.h - What is left of the S tables - used in ecb_encrypt().
61des_ver.h - header file for the external definition of the
62 version string.
63des.doc - SSLeay documentation for the library.
64
65/* The perl scripts - you can ignore these files they are only
66 * included for the curious */
67des.pl - des in perl anyone? des_set_key and des_ecb_encrypt
68 both done in a perl library.
69testdes.pl - Testing program for des.pl
70doIP - Perl script used to develop IP xor/shift code.
71doPC1 - Perl script used to develop PC1 xor/shift code.
72doPC2 - Generates sk.h.
73PC1 - Output of doPC1 should be the same as output from PC1.
74PC2 - used in development of doPC2.
75shifts.pl - Perl library used by my perl scripts.
76
77/* I started making a perl5 dynamic library for libdes
78 * but did not fully finish, these files are part of that effort. */
79DES.pm
80DES.pod
81DES.xs
82t
83typemap
84
85/* The following are for use with sun RPC implementaions. */
86rpc_des.h
87rpc_enc.c
88
89/* The following are contibuted by Mark Murray <mark@grondar.za>. They
90 * are not normally built into libdes due to machine specific routines
91 * contained in them. They are for use in the most recent incarnation of
92 * export kerberos v 4 (eBones). */
93supp.c
94new_rkey.c
95
96
diff --git a/src/lib/libcrypto/des/MODES.DES b/src/lib/libcrypto/des/MODES.DES
new file mode 100644
index 0000000000..0cbc44f51d
--- /dev/null
+++ b/src/lib/libcrypto/des/MODES.DES
@@ -0,0 +1,84 @@
1Modes of DES
2Quite a bit of the following information has been taken from
3 AS 2805.5.2
4 Australian Standard
5 Electronic funds transfer - Requirements for interfaces,
6 Part 5.2: Modes of operation for an n-bit block cipher algorithm
7 Appendix A
8
9There are several different modes in which DES can be used, they are
10as follows.
11
12Electronic Codebook Mode (ECB) (des_ecb_encrypt())
13- 64 bits are enciphered at a time.
14- The order of the blocks can be rearranged without detection.
15- The same plaintext block always produces the same ciphertext block
16 (for the same key) making it vulnerable to a 'dictionary attack'.
17- An error will only affect one ciphertext block.
18
19Cipher Block Chaining Mode (CBC) (des_cbc_encrypt())
20- a multiple of 64 bits are enciphered at a time.
21- The CBC mode produces the same ciphertext whenever the same
22 plaintext is encrypted using the same key and starting variable.
23- The chaining operation makes the ciphertext blocks dependent on the
24 current and all preceding plaintext blocks and therefore blocks can not
25 be rearranged.
26- The use of different starting variables prevents the same plaintext
27 enciphering to the same ciphertext.
28- An error will affect the current and the following ciphertext blocks.
29
30Cipher Feedback Mode (CFB) (des_cfb_encrypt())
31- a number of bits (j) <= 64 are enciphered at a time.
32- The CFB mode produces the same ciphertext whenever the same
33 plaintext is encrypted using the same key and starting variable.
34- The chaining operation makes the ciphertext variables dependent on the
35 current and all preceding variables and therefore j-bit variables are
36 chained together and con not be rearranged.
37- The use of different starting variables prevents the same plaintext
38 enciphering to the same ciphertext.
39- The strength of the CFB mode depends on the size of k (maximal if
40 j == k). In my implementation this is always the case.
41- Selection of a small value for j will require more cycles through
42 the encipherment algorithm per unit of plaintext and thus cause
43 greater processing overheads.
44- Only multiples of j bits can be enciphered.
45- An error will affect the current and the following ciphertext variables.
46
47Output Feedback Mode (OFB) (des_ofb_encrypt())
48- a number of bits (j) <= 64 are enciphered at a time.
49- The OFB mode produces the same ciphertext whenever the same
50 plaintext enciphered using the same key and starting variable. More
51 over, in the OFB mode the same key stream is produced when the same
52 key and start variable are used. Consequently, for security reasons
53 a specific start variable should be used only once for a given key.
54- The absence of chaining makes the OFB more vulnerable to specific attacks.
55- The use of different start variables values prevents the same
56 plaintext enciphering to the same ciphertext, by producing different
57 key streams.
58- Selection of a small value for j will require more cycles through
59 the encipherment algorithm per unit of plaintext and thus cause
60 greater processing overheads.
61- Only multiples of j bits can be enciphered.
62- OFB mode of operation does not extend ciphertext errors in the
63 resultant plaintext output. Every bit error in the ciphertext causes
64 only one bit to be in error in the deciphered plaintext.
65- OFB mode is not self-synchronising. If the two operation of
66 encipherment and decipherment get out of synchronism, the system needs
67 to be re-initialised.
68- Each re-initialisation should use a value of the start variable
69different from the start variable values used before with the same
70key. The reason for this is that an identical bit stream would be
71produced each time from the same parameters. This would be
72susceptible to a 'known plaintext' attack.
73
74Triple ECB Mode (des_ecb3_encrypt())
75- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
76- As for ECB encryption but increases the effective key length to 112 bits.
77- If both keys are the same it is equivalent to encrypting once with
78 just one key.
79
80Triple CBC Mode (des_3cbc_encrypt())
81- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
82- As for CBC encryption but increases the effective key length to 112 bits.
83- If both keys are the same it is equivalent to encrypting once with
84 just one key.
diff --git a/src/lib/libcrypto/des/Makefile.PL b/src/lib/libcrypto/des/Makefile.PL
new file mode 100644
index 0000000000..b54a24387c
--- /dev/null
+++ b/src/lib/libcrypto/des/Makefile.PL
@@ -0,0 +1,14 @@
1use ExtUtils::MakeMaker;
2# See lib/ExtUtils/MakeMaker.pm for details of how to influence
3# the contents of the Makefile being created.
4&writeMakefile(
5 'potential_libs' => '', # e.g., '-lm'
6 'INC' => '', # e.g., '-I/usr/include/other'
7 'DISTNAME' => 'DES',
8 'VERSION' => '0.1',
9 'DEFINE' => '-DPERL5',
10 'OBJECT' => 'DES.o cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \
11 rand_key.o set_key.o str2key.o \
12 enc_read.o enc_writ.o fcrypt.o cfb_enc.o \
13 ecb3_enc.o ofb_enc.o cbc3_enc.o des_enc.o',
14 );
diff --git a/src/lib/libcrypto/des/Makefile.lit b/src/lib/libcrypto/des/Makefile.lit
new file mode 100644
index 0000000000..c09f6969da
--- /dev/null
+++ b/src/lib/libcrypto/des/Makefile.lit
@@ -0,0 +1,250 @@
1# You must select the correct terminal control system to be used to
2# turn character echo off when reading passwords. There a 5 systems
3# SGTTY - the old BSD system
4# TERMIO - most system V boxes
5# TERMIOS - SGI (ala IRIX).
6# VMS - the DEC operating system
7# MSDOS - we all know what it is :-)
8# read_pwd.c makes a reasonable guess at what is correct.
9
10# Targets
11# make - twidle the options yourself :-)
12# make cc - standard cc options
13# make gcc - standard gcc options
14# make x86-elf - linux-elf etc
15# make x86-out - linux-a.out, FreeBSD etc
16# make x86-solaris
17# make x86-bdsi
18
19# If you are on a DEC Alpha, edit des.h and change the DES_LONG
20# define to 'unsigned int'. I have seen this give a %20 speedup.
21
22OPTS0= -DLIBDES_LIT -DRAND -DTERMIO #-DNOCONST
23
24# Version 1.94 has changed the strings_to_key function so that it is
25# now compatible with MITs when the string is longer than 8 characters.
26# If you wish to keep the old version, uncomment the following line.
27# This will affect the -E/-D options on des(1).
28#OPTS1= -DOLD_STR_TO_KEY
29
30# There are 4 possible performance options
31# -DDES_PTR
32# -DDES_RISC1
33# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2)
34# -DDES_UNROLL
35# after the initial build, run 'des_opts' to see which options are best
36# for your platform. There are some listed in options.txt
37#OPTS2= -DDES_PTR
38#OPTS3= -DDES_RISC1 # or DES_RISC2
39#OPTS4= -DDES_UNROLL
40
41OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4)
42
43MAKE=make -f Makefile
44#CC=cc
45#CFLAG= -O
46
47CC=gcc
48#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
49CFLAG= -O3 -fomit-frame-pointer
50
51CFLAGS=$(OPTS) $(CFLAG)
52CPP=$(CC) -E
53AS=as
54
55# Assember version of des_encrypt*().
56DES_ENC=des_enc.o fcrypt_b.o # normal C version
57#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86
58#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86
59#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86
60#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86
61
62LIBDIR=/usr/local/lib
63BINDIR=/usr/local/bin
64INCDIR=/usr/local/include
65MANDIR=/usr/local/man
66MAN1=1
67MAN3=3
68SHELL=/bin/sh
69OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o
70OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \
71 xcbc_enc.o qud_cksm.o \
72 cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \
73 enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \
74 rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o
75
76GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \
77 des.doc options.txt asm
78GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \
79 des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \
80 Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \
81 des.org des_locl.org
82TESTING_LIT= destest speed des_opts
83TESTING_FULL= rpw $(TESTING_LIT)
84TESTING_SRC_LIT=destest.c speed.c des_opts.c
85TESTING_SRC_FULL=rpw.c $(TESTING_SRC_LIT)
86HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h
87HEADERS_FULL= $(HEADERS_LIT) rpc_des.h
88LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c
89LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c \
90 cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \
91 enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \
92 rand_key.c rpc_enc.c str2key.c supp.c \
93 xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c
94
95PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
96
97OBJ= $(OBJ_LIT)
98GENERAL=$(GENERAL_LIT)
99TESTING=$(TESTING_LIT)
100TESTING_SRC=$(TESTING_SRC_LIT)
101HEADERS=$(HEADERS_LIT)
102LIBDES= $(LIBDES_LIT)
103
104ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS)
105
106DLIB= libdes.a
107
108all: $(DLIB) $(TESTING)
109
110cc:
111 $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
112
113gcc:
114 $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
115
116x86-elf:
117 $(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
118
119x86-out:
120 $(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
121
122x86-solaris:
123 $(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
124
125x86-bsdi:
126 $(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
127
128# elf
129asm/dx86-elf.o: asm/dx86unix.cpp
130 $(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o
131
132asm/yx86-elf.o: asm/yx86unix.cpp
133 $(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o
134
135# solaris
136asm/dx86-sol.o: asm/dx86unix.cpp
137 $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
138 as -o asm/dx86-sol.o asm/dx86-sol.s
139 rm -f asm/dx86-sol.s
140
141asm/yx86-sol.o: asm/yx86unix.cpp
142 $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
143 as -o asm/yx86-sol.o asm/yx86-sol.s
144 rm -f asm/yx86-sol.s
145
146# a.out
147asm/dx86-out.o: asm/dx86unix.cpp
148 $(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o
149
150asm/yx86-out.o: asm/yx86unix.cpp
151 $(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o
152
153# bsdi
154asm/dx86bsdi.o: asm/dx86unix.cpp
155 $(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o
156
157asm/yx86bsdi.o: asm/yx86unix.cpp
158 $(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o
159
160asm/dx86unix.cpp:
161 (cd asm; perl des-586.pl cpp >dx86unix.cpp)
162
163asm/yx86unix.cpp:
164 (cd asm; perl crypt586.pl cpp >yx86unix.cpp)
165
166test: all
167 ./destest
168
169$(DLIB): $(OBJ)
170 /bin/rm -f $(DLIB)
171 ar cr $(DLIB) $(OBJ)
172 -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \
173 else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \
174 else exit 0; fi; fi
175
176des_opts: des_opts.o $(DLIB)
177 $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB)
178
179destest: destest.o $(DLIB)
180 $(CC) $(CFLAGS) -o destest destest.o $(DLIB)
181
182rpw: rpw.o $(DLIB)
183 $(CC) $(CFLAGS) -o rpw rpw.o $(DLIB)
184
185speed: speed.o $(DLIB)
186 $(CC) $(CFLAGS) -o speed speed.o $(DLIB)
187
188des: des.o $(DLIB)
189 $(CC) $(CFLAGS) -o des des.o $(DLIB)
190
191tags:
192 ctags $(TESTING_SRC) $(LIBDES)
193
194tar_lit:
195 /bin/mv Makefile Makefile.tmp
196 /bin/cp Makefile.lit Makefile
197 tar chf libdes-l.tar $(LIBDES_LIT) $(HEADERS_LIT) \
198 $(GENERAL_LIT) $(TESTING_SRC_LIT)
199 /bin/rm -f Makefile
200 /bin/mv Makefile.tmp Makefile
201
202tar:
203 tar chf libdes.tar $(ALL)
204
205shar:
206 shar $(ALL) >libdes.shar
207
208depend:
209 makedepend $(LIBDES) $(TESTING_SRC)
210
211clean:
212 /bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o
213
214dclean:
215 sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
216 mv -f Makefile.new Makefile
217
218# Eric is probably going to choke when he next looks at this --tjh
219install:
220 if test $(INSTALLTOP); then \
221 echo SSL style install; \
222 cp $(DLIB) $(INSTALLTOP)/lib; \
223 if test -s /bin/ranlib; then \
224 /bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
225 else \
226 if test -s /usr/bin/ranlib; then \
227 /usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
228 fi; fi; \
229 chmod 644 $(INSTALLTOP)/lib/$(DLIB); \
230 cp des.h $(INSTALLTOP)/include; \
231 chmod 644 $(INSTALLTOP)/include/des.h; \
232 else \
233 echo Standalone install; \
234 cp $(DLIB) $(LIBDIR)/$(DLIB); \
235 if test -s /bin/ranlib; then \
236 /bin/ranlib $(LIBDIR)/$(DLIB); \
237 else \
238 if test -s /usr/bin/ranlib; then \
239 /usr/bin/ranlib $(LIBDIR)/$(DLIB); \
240 fi; \
241 fi; \
242 chmod 644 $(LIBDIR)/$(DLIB); \
243 cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
244 chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
245 cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \
246 chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \
247 cp des.h $(INCDIR)/des.h; \
248 chmod 644 $(INCDIR)/des.h; \
249 fi
250# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl
new file mode 100644
index 0000000000..78b5189ee3
--- /dev/null
+++ b/src/lib/libcrypto/des/Makefile.ssl
@@ -0,0 +1,140 @@
1#
2# SSLeay/crypto/des/Makefile
3#
4
5DIR= des
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16DES_ENC= des_enc.o fcrypt_b.o
17# or use
18#DES_ENC= dx86-elf.o yx86-elf.o
19
20CFLAGS= $(INCLUDES) $(CFLAG)
21
22GENERAL=Makefile des.org des_locl.org
23TEST=destest.c
24APPS=
25
26LIB=$(TOP)/libcrypto.a
27LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
28 ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \
29 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
30 qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
31 des_enc.c fcrypt_b.c read2pwd.c \
32 fcrypt.c xcbc_enc.c \
33 str2key.c cfb64ede.c ofb64ede.c supp.c
34
35LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
36 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
37 enc_read.o enc_writ.o ofb64enc.o \
38 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
39 ${DES_ENC} read2pwd.o \
40 fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o
41
42SRC= $(LIBSRC)
43
44EXHEADER= des.h
45HEADER= des_locl.h rpc_des.h podd.h sk.h spr.h des_ver.h $(EXHEADER)
46
47ALL= $(GENERAL) $(SRC) $(HEADER)
48
49top:
50 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
51
52all: lib
53
54lib: $(LIBOBJ)
55 $(AR) $(LIB) $(LIBOBJ)
56 sh $(TOP)/util/ranlib.sh $(LIB)
57 @touch lib
58
59# elf
60asm/dx86-elf.o: asm/dx86unix.cpp
61 $(CPP) -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o
62
63asm/yx86-elf.o: asm/yx86unix.cpp
64 $(CPP) -DELF asm/yx86unix.cpp | as -o asm/yx86-elf.o
65
66# solaris
67asm/dx86-sol.o: asm/dx86unix.cpp
68 $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
69 as -o asm/dx86-sol.o asm/dx86-sol.s
70 rm -f asm/dx86-sol.s
71
72asm/yx86-sol.o: asm/yx86unix.cpp
73 $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
74 as -o asm/yx86-sol.o asm/yx86-sol.s
75 rm -f asm/yx86-sol.s
76
77# a.out
78asm/dx86-out.o: asm/dx86unix.cpp
79 $(CPP) -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o
80
81asm/yx86-out.o: asm/yx86unix.cpp
82 $(CPP) -DOUT asm/yx86unix.cpp | as -o asm/yx86-out.o
83
84# bsdi
85asm/dx86bsdi.o: asm/dx86unix.cpp
86 $(CPP) -DBSDI asm/dx86unix.cpp | as -o asm/dx86bsdi.o
87
88asm/yx86bsdi.o: asm/yx86unix.cpp
89 $(CPP) -DBSDI asm/yx86unix.cpp | as -o asm/yx86bsdi.o
90
91asm/dx86unix.cpp:
92 (cd asm; perl des-586.pl cpp >dx86unix.cpp)
93
94asm/yx86unix.cpp:
95 (cd asm; perl crypt586.pl cpp >yx86unix.cpp)
96
97files:
98 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
99
100links:
101 /bin/rm -f Makefile
102 $(TOP)/util/point.sh Makefile.ssl Makefile
103 /bin/rm -f des.doc
104 /bin/rm -fr asm/perlasm
105 $(TOP)/util/point.sh ../../perlasm asm/perlasm
106 $(TOP)/util/point.sh ../../doc/des.doc des.doc
107 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
108 $(TOP)/util/mklink.sh ../../test $(TEST)
109 $(TOP)/util/mklink.sh ../../apps $(APPS)
110
111install: installs
112
113installs:
114 @for i in $(EXHEADER) ; \
115 do \
116 (cp $$i $(INSTALLTOP)/include/$$i; \
117 chmod 644 $(INSTALLTOP)/include/$$i ); \
118 done;
119
120tags:
121 ctags $(SRC)
122
123tests:
124
125lint:
126 lint -DLINT $(INCLUDES) $(SRC)>fluff
127
128depend:
129 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
130
131dclean:
132 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
133 mv -f Makefile.new $(MAKEFILE)
134
135clean:
136 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
137
138errors:
139
140# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/des/Makefile.uni b/src/lib/libcrypto/des/Makefile.uni
new file mode 100644
index 0000000000..8f1759748a
--- /dev/null
+++ b/src/lib/libcrypto/des/Makefile.uni
@@ -0,0 +1,263 @@
1# You must select the correct terminal control system to be used to
2# turn character echo off when reading passwords. There a 5 systems
3# SGTTY - the old BSD system
4# TERMIO - most system V boxes
5# TERMIOS - SGI (ala IRIX).
6# VMS - the DEC operating system
7# MSDOS - we all know what it is :-)
8# read_pwd.c makes a reasonable guess at what is correct.
9
10# Targets
11# make - twidle the options yourself :-)
12# make cc - standard cc options
13# make gcc - standard gcc options
14# make x86-elf - linux-elf etc
15# make x86-out - linux-a.out, FreeBSD etc
16# make x86-solaris
17# make x86-bdsi
18
19# If you are on a DEC Alpha, edit des.h and change the DES_LONG
20# define to 'unsigned int'. I have seen this give a %20 speedup.
21
22OPTS0= -DRAND -DTERMIO #-DNOCONST
23
24# Version 1.94 has changed the strings_to_key function so that it is
25# now compatible with MITs when the string is longer than 8 characters.
26# If you wish to keep the old version, uncomment the following line.
27# This will affect the -E/-D options on des(1).
28#OPTS1= -DOLD_STR_TO_KEY
29
30# There are 4 possible performance options
31# -DDES_PTR
32# -DDES_RISC1
33# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2)
34# -DDES_UNROLL
35# after the initial build, run 'des_opts' to see which options are best
36# for your platform. There are some listed in options.txt
37#OPTS2= -DDES_PTR
38#OPTS3= -DDES_RISC1 # or DES_RISC2
39#OPTS4= -DDES_UNROLL
40
41OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4)
42
43MAKE=make -f Makefile
44#CC=cc
45#CFLAG= -O
46
47CC=gcc
48#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
49CFLAG= -O3 -fomit-frame-pointer
50
51CFLAGS=$(OPTS) $(CFLAG)
52CPP=$(CC) -E
53AS=as
54
55# Assember version of des_encrypt*().
56DES_ENC=des_enc.o fcrypt_b.o # normal C version
57#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86
58#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86
59#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86
60#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86
61
62LIBDIR=/usr/local/lib
63BINDIR=/usr/local/bin
64INCDIR=/usr/local/include
65MANDIR=/usr/local/man
66MAN1=1
67MAN3=3
68SHELL=/bin/sh
69OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o
70OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \
71 xcbc_enc.o qud_cksm.o cbc3_enc.o \
72 cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \
73 enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \
74 rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o
75
76GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \
77 des.doc options.txt asm
78GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \
79 des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \
80 Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \
81 des.org des_locl.org
82TESTING_LIT= destest speed des_opts
83TESTING_FULL= rpw des $(TESTING_LIT)
84TESTING_SRC_LIT=destest.c speed.c des_opts.c
85TESTING_SRC_FULL=rpw.c des.c $(TESTING_SRC_LIT)
86HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h
87HEADERS_FULL= $(HEADERS_LIT) rpc_des.h
88LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c
89LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c cbc3_enc.c \
90 cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \
91 enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \
92 rand_key.c rpc_enc.c str2key.c supp.c \
93 xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c
94
95PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
96
97OBJ= $(OBJ_FULL)
98GENERAL=$(GENERAL_FULL)
99TESTING=$(TESTING_FULL)
100TESTING_SRC=$(TESTING_SRC_FULL)
101HEADERS=$(HEADERS_FULL)
102LIBDES= $(LIBDES_FULL)
103
104ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS)
105
106DLIB= libdes.a
107
108all: $(DLIB) $(TESTING)
109
110cc:
111 $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
112
113gcc:
114 $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
115
116x86-elf:
117 $(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
118
119x86-out:
120 $(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
121
122x86-solaris:
123 $(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
124
125x86-bsdi:
126 $(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
127
128# elf
129asm/dx86-elf.o: asm/dx86unix.cpp
130 $(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o
131
132asm/yx86-elf.o: asm/yx86unix.cpp
133 $(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o
134
135# solaris
136asm/dx86-sol.o: asm/dx86unix.cpp
137 $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
138 as -o asm/dx86-sol.o asm/dx86-sol.s
139 rm -f asm/dx86-sol.s
140
141asm/yx86-sol.o: asm/yx86unix.cpp
142 $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
143 as -o asm/yx86-sol.o asm/yx86-sol.s
144 rm -f asm/yx86-sol.s
145
146# a.out
147asm/dx86-out.o: asm/dx86unix.cpp
148 $(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o
149
150asm/yx86-out.o: asm/yx86unix.cpp
151 $(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o
152
153# bsdi
154asm/dx86bsdi.o: asm/dx86unix.cpp
155 $(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o
156
157asm/yx86bsdi.o: asm/yx86unix.cpp
158 $(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o
159
160asm/dx86unix.cpp:
161 (cd asm; perl des-586.pl cpp >dx86unix.cpp)
162
163asm/yx86unix.cpp:
164 (cd asm; perl crypt586.pl cpp >yx86unix.cpp)
165
166test: all
167 ./destest
168
169$(DLIB): $(OBJ)
170 /bin/rm -f $(DLIB)
171 ar cr $(DLIB) $(OBJ)
172 -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \
173 else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \
174 else exit 0; fi; fi
175
176des_opts: des_opts.o $(DLIB)
177 $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB)
178
179destest: destest.o $(DLIB)
180 $(CC) $(CFLAGS) -o destest destest.o $(DLIB)
181
182rpw: rpw.o $(DLIB)
183 $(CC) $(CFLAGS) -o rpw rpw.o $(DLIB)
184
185speed: speed.o $(DLIB)
186 $(CC) $(CFLAGS) -o speed speed.o $(DLIB)
187
188des: des.o $(DLIB)
189 $(CC) $(CFLAGS) -o des des.o $(DLIB)
190
191tags:
192 ctags $(TESTING_SRC) $(LIBDES)
193
194tar_lit:
195 /bin/mv Makefile Makefile.tmp
196 /bin/cp Makefile.lit Makefile
197 for i in $(HEADERS_LIT) $(LIBDES_LIT) $(GENERAL_LIT) $(TESTING_SRC_LIT) ;\
198 do \
199 n="$$n des/$$i"; \
200 done; \
201 ( cd .. ; tar chf - $$n )| gzip > libdes-l.tgz
202 /bin/rm -f Makefile
203 /bin/mv Makefile.tmp Makefile
204
205tar:
206 mv Makefile Makefile.tmp
207 /bin/cp Makefile.uni Makefile
208 for i in $(ALL) ;\
209 do \
210 n="$$n des/$$i"; \
211 done; \
212 ( cd .. ; tar chf - $$n )| gzip > libdes.tgz
213 /bin/rm -f Makefile
214 /bin/mv Makefile.tmp Makefile
215
216shar:
217 shar $(ALL) >libdes.shar
218
219depend:
220 makedepend $(LIBDES) $(TESTING_SRC)
221
222clean:
223 /bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o
224
225dclean:
226 sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
227 mv -f Makefile.new Makefile
228
229# Eric is probably going to choke when he next looks at this --tjh
230install: des
231 if test $(INSTALLTOP); then \
232 echo SSL style install; \
233 cp $(DLIB) $(INSTALLTOP)/lib; \
234 if test -s /bin/ranlib; then \
235 /bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
236 else \
237 if test -s /usr/bin/ranlib; then \
238 /usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
239 fi; fi; \
240 chmod 644 $(INSTALLTOP)/lib/$(DLIB); \
241 cp des.h $(INSTALLTOP)/include; \
242 chmod 644 $(INSTALLTOP)/include/des.h; \
243 else \
244 echo Standalone install; \
245 cp $(DLIB) $(LIBDIR)/$(DLIB); \
246 if test -s /bin/ranlib; then \
247 /bin/ranlib $(LIBDIR)/$(DLIB); \
248 else \
249 if test -s /usr/bin/ranlib; then \
250 /usr/bin/ranlib $(LIBDIR)/$(DLIB); \
251 fi; \
252 fi; \
253 chmod 644 $(LIBDIR)/$(DLIB); \
254 cp des $(BINDIR)/des; \
255 chmod 711 $(BINDIR)/des; \
256 cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
257 chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
258 cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \
259 chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \
260 cp des.h $(INCDIR)/des.h; \
261 chmod 644 $(INCDIR)/des.h; \
262 fi
263# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/des/PC1 b/src/lib/libcrypto/des/PC1
new file mode 100644
index 0000000000..efb8348b72
--- /dev/null
+++ b/src/lib/libcrypto/des/PC1
@@ -0,0 +1,28 @@
1#!/usr/local/bin/perl
2
3@PC1=( 57,49,41,33,25,17, 9,
4 1,58,50,42,34,26,18,
5 10, 2,59,51,43,35,27,
6 19,11, 3,60,52,44,36,
7 "-","-","-","-",
8 63,55,47,39,31,23,15,
9 7,62,54,46,38,30,22,
10 14, 6,61,53,45,37,29,
11 21,13, 5,28,20,12, 4,
12 "-","-","-","-",
13 );
14
15foreach (@PC1)
16 {
17 if ($_ ne "-")
18 {
19 $_--;
20 $_=int($_/8)*8+7-($_%8);
21 printf "%2d ",$_;
22 }
23 else
24 { print "-- "; }
25 print "\n" if (((++$i) % 8) == 0);
26 print "\n" if ((($i) % 32) == 0);
27 }
28
diff --git a/src/lib/libcrypto/des/PC2 b/src/lib/libcrypto/des/PC2
new file mode 100644
index 0000000000..2d560270ec
--- /dev/null
+++ b/src/lib/libcrypto/des/PC2
@@ -0,0 +1,57 @@
1#!/usr/local/bin/perl
2
3@PC2_C=(14,17,11,24, 1, 5,
4 3,28,15, 6,21,10,
5 23,19,12, 4,26, 8,
6 16, 7,27,20,13, 2,
7 );
8
9@PC2_D=(41,52,31,37,47,55,
10 30,40,51,45,33,48,
11 44,49,39,56,34,53,
12 46,42,50,36,29,32,
13 );
14
15foreach (@PC2_C) {
16 if ($_ ne "-")
17 {
18 $_--;
19 printf "%2d ",$_; }
20 else { print "-- "; }
21 $C{$_}=1;
22 print "\n" if (((++$i) % 8) == 0);
23 }
24$i=0;
25print "\n";
26foreach (@PC2_D) {
27 if ($_ ne "-")
28 {
29 $_-=29;
30 printf "%2d ",$_; }
31 else { print "-- "; }
32 $D{$_}=1;
33 print "\n" if (((++$i) % 8) == 0); }
34
35print "\n";
36foreach $i (0 .. 27)
37 {
38 $_=$C{$i};
39 if ($_ ne "-") {printf "%2d ",$_;}
40 else { print "-- "; }
41 print "\n" if (((++$i) % 8) == 0);
42 }
43print "\n";
44
45print "\n";
46foreach $i (0 .. 27)
47 {
48 $_=$D{$i};
49 if ($_ ne "-") {printf "%2d ",$_;}
50 else { print "-- "; }
51 print "\n" if (((++$i) % 8) == 0);
52 }
53print "\n";
54sub numsort
55 {
56 $a-$b;
57 }
diff --git a/src/lib/libcrypto/des/asm/d-win32.asm b/src/lib/libcrypto/des/asm/d-win32.asm
new file mode 100644
index 0000000000..9e3dc9cd87
--- /dev/null
+++ b/src/lib/libcrypto/des/asm/d-win32.asm
@@ -0,0 +1,3132 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by des-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE des-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _des_encrypt
12EXTRN _des_SPtrans:DWORD
13_des_encrypt PROC NEAR
14 push esi
15 push edi
16 ;
17 ; Load the 2 words
18 mov esi, DWORD PTR 12[esp]
19 xor ecx, ecx
20 push ebx
21 push ebp
22 mov eax, DWORD PTR [esi]
23 mov ebx, DWORD PTR 28[esp]
24 mov edi, DWORD PTR 4[esi]
25 ;
26 ; IP
27 rol eax, 4
28 mov esi, eax
29 xor eax, edi
30 and eax, 0f0f0f0f0h
31 xor esi, eax
32 xor edi, eax
33 ;
34 rol edi, 20
35 mov eax, edi
36 xor edi, esi
37 and edi, 0fff0000fh
38 xor eax, edi
39 xor esi, edi
40 ;
41 rol eax, 14
42 mov edi, eax
43 xor eax, esi
44 and eax, 033333333h
45 xor edi, eax
46 xor esi, eax
47 ;
48 rol esi, 22
49 mov eax, esi
50 xor esi, edi
51 and esi, 003fc03fch
52 xor eax, esi
53 xor edi, esi
54 ;
55 rol eax, 9
56 mov esi, eax
57 xor eax, edi
58 and eax, 0aaaaaaaah
59 xor esi, eax
60 xor edi, eax
61 ;
62 rol edi, 1
63 mov ebp, DWORD PTR 24[esp]
64 cmp ebx, 0
65 je $L000start_decrypt
66 ;
67 ; Round 0
68 mov eax, DWORD PTR [ebp]
69 xor ebx, ebx
70 mov edx, DWORD PTR 4[ebp]
71 xor eax, esi
72 xor edx, esi
73 and eax, 0fcfcfcfch
74 and edx, 0cfcfcfcfh
75 mov bl, al
76 mov cl, ah
77 ror edx, 4
78 mov ebp, DWORD PTR _des_SPtrans[ebx]
79 mov bl, dl
80 xor edi, ebp
81 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
82 xor edi, ebp
83 mov cl, dh
84 shr eax, 16
85 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
86 xor edi, ebp
87 mov bl, ah
88 shr edx, 16
89 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
90 xor edi, ebp
91 mov ebp, DWORD PTR 24[esp]
92 mov cl, dh
93 and eax, 0ffh
94 and edx, 0ffh
95 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
96 xor edi, ebx
97 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
98 xor edi, ebx
99 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
100 xor edi, ebx
101 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
102 xor edi, ebx
103 ;
104 ; Round 1
105 mov eax, DWORD PTR 8[ebp]
106 xor ebx, ebx
107 mov edx, DWORD PTR 12[ebp]
108 xor eax, edi
109 xor edx, edi
110 and eax, 0fcfcfcfch
111 and edx, 0cfcfcfcfh
112 mov bl, al
113 mov cl, ah
114 ror edx, 4
115 mov ebp, DWORD PTR _des_SPtrans[ebx]
116 mov bl, dl
117 xor esi, ebp
118 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
119 xor esi, ebp
120 mov cl, dh
121 shr eax, 16
122 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
123 xor esi, ebp
124 mov bl, ah
125 shr edx, 16
126 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
127 xor esi, ebp
128 mov ebp, DWORD PTR 24[esp]
129 mov cl, dh
130 and eax, 0ffh
131 and edx, 0ffh
132 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
133 xor esi, ebx
134 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
135 xor esi, ebx
136 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
137 xor esi, ebx
138 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
139 xor esi, ebx
140 ;
141 ; Round 2
142 mov eax, DWORD PTR 16[ebp]
143 xor ebx, ebx
144 mov edx, DWORD PTR 20[ebp]
145 xor eax, esi
146 xor edx, esi
147 and eax, 0fcfcfcfch
148 and edx, 0cfcfcfcfh
149 mov bl, al
150 mov cl, ah
151 ror edx, 4
152 mov ebp, DWORD PTR _des_SPtrans[ebx]
153 mov bl, dl
154 xor edi, ebp
155 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
156 xor edi, ebp
157 mov cl, dh
158 shr eax, 16
159 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
160 xor edi, ebp
161 mov bl, ah
162 shr edx, 16
163 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
164 xor edi, ebp
165 mov ebp, DWORD PTR 24[esp]
166 mov cl, dh
167 and eax, 0ffh
168 and edx, 0ffh
169 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
170 xor edi, ebx
171 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
172 xor edi, ebx
173 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
174 xor edi, ebx
175 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
176 xor edi, ebx
177 ;
178 ; Round 3
179 mov eax, DWORD PTR 24[ebp]
180 xor ebx, ebx
181 mov edx, DWORD PTR 28[ebp]
182 xor eax, edi
183 xor edx, edi
184 and eax, 0fcfcfcfch
185 and edx, 0cfcfcfcfh
186 mov bl, al
187 mov cl, ah
188 ror edx, 4
189 mov ebp, DWORD PTR _des_SPtrans[ebx]
190 mov bl, dl
191 xor esi, ebp
192 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
193 xor esi, ebp
194 mov cl, dh
195 shr eax, 16
196 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
197 xor esi, ebp
198 mov bl, ah
199 shr edx, 16
200 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
201 xor esi, ebp
202 mov ebp, DWORD PTR 24[esp]
203 mov cl, dh
204 and eax, 0ffh
205 and edx, 0ffh
206 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
207 xor esi, ebx
208 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
209 xor esi, ebx
210 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
211 xor esi, ebx
212 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
213 xor esi, ebx
214 ;
215 ; Round 4
216 mov eax, DWORD PTR 32[ebp]
217 xor ebx, ebx
218 mov edx, DWORD PTR 36[ebp]
219 xor eax, esi
220 xor edx, esi
221 and eax, 0fcfcfcfch
222 and edx, 0cfcfcfcfh
223 mov bl, al
224 mov cl, ah
225 ror edx, 4
226 mov ebp, DWORD PTR _des_SPtrans[ebx]
227 mov bl, dl
228 xor edi, ebp
229 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
230 xor edi, ebp
231 mov cl, dh
232 shr eax, 16
233 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
234 xor edi, ebp
235 mov bl, ah
236 shr edx, 16
237 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
238 xor edi, ebp
239 mov ebp, DWORD PTR 24[esp]
240 mov cl, dh
241 and eax, 0ffh
242 and edx, 0ffh
243 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
244 xor edi, ebx
245 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
246 xor edi, ebx
247 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
248 xor edi, ebx
249 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
250 xor edi, ebx
251 ;
252 ; Round 5
253 mov eax, DWORD PTR 40[ebp]
254 xor ebx, ebx
255 mov edx, DWORD PTR 44[ebp]
256 xor eax, edi
257 xor edx, edi
258 and eax, 0fcfcfcfch
259 and edx, 0cfcfcfcfh
260 mov bl, al
261 mov cl, ah
262 ror edx, 4
263 mov ebp, DWORD PTR _des_SPtrans[ebx]
264 mov bl, dl
265 xor esi, ebp
266 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
267 xor esi, ebp
268 mov cl, dh
269 shr eax, 16
270 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
271 xor esi, ebp
272 mov bl, ah
273 shr edx, 16
274 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
275 xor esi, ebp
276 mov ebp, DWORD PTR 24[esp]
277 mov cl, dh
278 and eax, 0ffh
279 and edx, 0ffh
280 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
281 xor esi, ebx
282 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
283 xor esi, ebx
284 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
285 xor esi, ebx
286 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
287 xor esi, ebx
288 ;
289 ; Round 6
290 mov eax, DWORD PTR 48[ebp]
291 xor ebx, ebx
292 mov edx, DWORD PTR 52[ebp]
293 xor eax, esi
294 xor edx, esi
295 and eax, 0fcfcfcfch
296 and edx, 0cfcfcfcfh
297 mov bl, al
298 mov cl, ah
299 ror edx, 4
300 mov ebp, DWORD PTR _des_SPtrans[ebx]
301 mov bl, dl
302 xor edi, ebp
303 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
304 xor edi, ebp
305 mov cl, dh
306 shr eax, 16
307 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
308 xor edi, ebp
309 mov bl, ah
310 shr edx, 16
311 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
312 xor edi, ebp
313 mov ebp, DWORD PTR 24[esp]
314 mov cl, dh
315 and eax, 0ffh
316 and edx, 0ffh
317 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
318 xor edi, ebx
319 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
320 xor edi, ebx
321 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
322 xor edi, ebx
323 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
324 xor edi, ebx
325 ;
326 ; Round 7
327 mov eax, DWORD PTR 56[ebp]
328 xor ebx, ebx
329 mov edx, DWORD PTR 60[ebp]
330 xor eax, edi
331 xor edx, edi
332 and eax, 0fcfcfcfch
333 and edx, 0cfcfcfcfh
334 mov bl, al
335 mov cl, ah
336 ror edx, 4
337 mov ebp, DWORD PTR _des_SPtrans[ebx]
338 mov bl, dl
339 xor esi, ebp
340 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
341 xor esi, ebp
342 mov cl, dh
343 shr eax, 16
344 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
345 xor esi, ebp
346 mov bl, ah
347 shr edx, 16
348 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
349 xor esi, ebp
350 mov ebp, DWORD PTR 24[esp]
351 mov cl, dh
352 and eax, 0ffh
353 and edx, 0ffh
354 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
355 xor esi, ebx
356 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
357 xor esi, ebx
358 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
359 xor esi, ebx
360 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
361 xor esi, ebx
362 ;
363 ; Round 8
364 mov eax, DWORD PTR 64[ebp]
365 xor ebx, ebx
366 mov edx, DWORD PTR 68[ebp]
367 xor eax, esi
368 xor edx, esi
369 and eax, 0fcfcfcfch
370 and edx, 0cfcfcfcfh
371 mov bl, al
372 mov cl, ah
373 ror edx, 4
374 mov ebp, DWORD PTR _des_SPtrans[ebx]
375 mov bl, dl
376 xor edi, ebp
377 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
378 xor edi, ebp
379 mov cl, dh
380 shr eax, 16
381 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
382 xor edi, ebp
383 mov bl, ah
384 shr edx, 16
385 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
386 xor edi, ebp
387 mov ebp, DWORD PTR 24[esp]
388 mov cl, dh
389 and eax, 0ffh
390 and edx, 0ffh
391 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
392 xor edi, ebx
393 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
394 xor edi, ebx
395 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
396 xor edi, ebx
397 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
398 xor edi, ebx
399 ;
400 ; Round 9
401 mov eax, DWORD PTR 72[ebp]
402 xor ebx, ebx
403 mov edx, DWORD PTR 76[ebp]
404 xor eax, edi
405 xor edx, edi
406 and eax, 0fcfcfcfch
407 and edx, 0cfcfcfcfh
408 mov bl, al
409 mov cl, ah
410 ror edx, 4
411 mov ebp, DWORD PTR _des_SPtrans[ebx]
412 mov bl, dl
413 xor esi, ebp
414 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
415 xor esi, ebp
416 mov cl, dh
417 shr eax, 16
418 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
419 xor esi, ebp
420 mov bl, ah
421 shr edx, 16
422 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
423 xor esi, ebp
424 mov ebp, DWORD PTR 24[esp]
425 mov cl, dh
426 and eax, 0ffh
427 and edx, 0ffh
428 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
429 xor esi, ebx
430 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
431 xor esi, ebx
432 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
433 xor esi, ebx
434 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
435 xor esi, ebx
436 ;
437 ; Round 10
438 mov eax, DWORD PTR 80[ebp]
439 xor ebx, ebx
440 mov edx, DWORD PTR 84[ebp]
441 xor eax, esi
442 xor edx, esi
443 and eax, 0fcfcfcfch
444 and edx, 0cfcfcfcfh
445 mov bl, al
446 mov cl, ah
447 ror edx, 4
448 mov ebp, DWORD PTR _des_SPtrans[ebx]
449 mov bl, dl
450 xor edi, ebp
451 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
452 xor edi, ebp
453 mov cl, dh
454 shr eax, 16
455 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
456 xor edi, ebp
457 mov bl, ah
458 shr edx, 16
459 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
460 xor edi, ebp
461 mov ebp, DWORD PTR 24[esp]
462 mov cl, dh
463 and eax, 0ffh
464 and edx, 0ffh
465 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
466 xor edi, ebx
467 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
468 xor edi, ebx
469 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
470 xor edi, ebx
471 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
472 xor edi, ebx
473 ;
474 ; Round 11
475 mov eax, DWORD PTR 88[ebp]
476 xor ebx, ebx
477 mov edx, DWORD PTR 92[ebp]
478 xor eax, edi
479 xor edx, edi
480 and eax, 0fcfcfcfch
481 and edx, 0cfcfcfcfh
482 mov bl, al
483 mov cl, ah
484 ror edx, 4
485 mov ebp, DWORD PTR _des_SPtrans[ebx]
486 mov bl, dl
487 xor esi, ebp
488 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
489 xor esi, ebp
490 mov cl, dh
491 shr eax, 16
492 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
493 xor esi, ebp
494 mov bl, ah
495 shr edx, 16
496 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
497 xor esi, ebp
498 mov ebp, DWORD PTR 24[esp]
499 mov cl, dh
500 and eax, 0ffh
501 and edx, 0ffh
502 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
503 xor esi, ebx
504 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
505 xor esi, ebx
506 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
507 xor esi, ebx
508 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
509 xor esi, ebx
510 ;
511 ; Round 12
512 mov eax, DWORD PTR 96[ebp]
513 xor ebx, ebx
514 mov edx, DWORD PTR 100[ebp]
515 xor eax, esi
516 xor edx, esi
517 and eax, 0fcfcfcfch
518 and edx, 0cfcfcfcfh
519 mov bl, al
520 mov cl, ah
521 ror edx, 4
522 mov ebp, DWORD PTR _des_SPtrans[ebx]
523 mov bl, dl
524 xor edi, ebp
525 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
526 xor edi, ebp
527 mov cl, dh
528 shr eax, 16
529 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
530 xor edi, ebp
531 mov bl, ah
532 shr edx, 16
533 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
534 xor edi, ebp
535 mov ebp, DWORD PTR 24[esp]
536 mov cl, dh
537 and eax, 0ffh
538 and edx, 0ffh
539 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
540 xor edi, ebx
541 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
542 xor edi, ebx
543 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
544 xor edi, ebx
545 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
546 xor edi, ebx
547 ;
548 ; Round 13
549 mov eax, DWORD PTR 104[ebp]
550 xor ebx, ebx
551 mov edx, DWORD PTR 108[ebp]
552 xor eax, edi
553 xor edx, edi
554 and eax, 0fcfcfcfch
555 and edx, 0cfcfcfcfh
556 mov bl, al
557 mov cl, ah
558 ror edx, 4
559 mov ebp, DWORD PTR _des_SPtrans[ebx]
560 mov bl, dl
561 xor esi, ebp
562 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
563 xor esi, ebp
564 mov cl, dh
565 shr eax, 16
566 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
567 xor esi, ebp
568 mov bl, ah
569 shr edx, 16
570 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
571 xor esi, ebp
572 mov ebp, DWORD PTR 24[esp]
573 mov cl, dh
574 and eax, 0ffh
575 and edx, 0ffh
576 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
577 xor esi, ebx
578 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
579 xor esi, ebx
580 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
581 xor esi, ebx
582 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
583 xor esi, ebx
584 ;
585 ; Round 14
586 mov eax, DWORD PTR 112[ebp]
587 xor ebx, ebx
588 mov edx, DWORD PTR 116[ebp]
589 xor eax, esi
590 xor edx, esi
591 and eax, 0fcfcfcfch
592 and edx, 0cfcfcfcfh
593 mov bl, al
594 mov cl, ah
595 ror edx, 4
596 mov ebp, DWORD PTR _des_SPtrans[ebx]
597 mov bl, dl
598 xor edi, ebp
599 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
600 xor edi, ebp
601 mov cl, dh
602 shr eax, 16
603 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
604 xor edi, ebp
605 mov bl, ah
606 shr edx, 16
607 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
608 xor edi, ebp
609 mov ebp, DWORD PTR 24[esp]
610 mov cl, dh
611 and eax, 0ffh
612 and edx, 0ffh
613 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
614 xor edi, ebx
615 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
616 xor edi, ebx
617 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
618 xor edi, ebx
619 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
620 xor edi, ebx
621 ;
622 ; Round 15
623 mov eax, DWORD PTR 120[ebp]
624 xor ebx, ebx
625 mov edx, DWORD PTR 124[ebp]
626 xor eax, edi
627 xor edx, edi
628 and eax, 0fcfcfcfch
629 and edx, 0cfcfcfcfh
630 mov bl, al
631 mov cl, ah
632 ror edx, 4
633 mov ebp, DWORD PTR _des_SPtrans[ebx]
634 mov bl, dl
635 xor esi, ebp
636 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
637 xor esi, ebp
638 mov cl, dh
639 shr eax, 16
640 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
641 xor esi, ebp
642 mov bl, ah
643 shr edx, 16
644 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
645 xor esi, ebp
646 mov ebp, DWORD PTR 24[esp]
647 mov cl, dh
648 and eax, 0ffh
649 and edx, 0ffh
650 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
651 xor esi, ebx
652 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
653 xor esi, ebx
654 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
655 xor esi, ebx
656 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
657 xor esi, ebx
658 jmp $L001end
659$L000start_decrypt:
660 ;
661 ; Round 15
662 mov eax, DWORD PTR 120[ebp]
663 xor ebx, ebx
664 mov edx, DWORD PTR 124[ebp]
665 xor eax, esi
666 xor edx, esi
667 and eax, 0fcfcfcfch
668 and edx, 0cfcfcfcfh
669 mov bl, al
670 mov cl, ah
671 ror edx, 4
672 mov ebp, DWORD PTR _des_SPtrans[ebx]
673 mov bl, dl
674 xor edi, ebp
675 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
676 xor edi, ebp
677 mov cl, dh
678 shr eax, 16
679 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
680 xor edi, ebp
681 mov bl, ah
682 shr edx, 16
683 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
684 xor edi, ebp
685 mov ebp, DWORD PTR 24[esp]
686 mov cl, dh
687 and eax, 0ffh
688 and edx, 0ffh
689 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
690 xor edi, ebx
691 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
692 xor edi, ebx
693 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
694 xor edi, ebx
695 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
696 xor edi, ebx
697 ;
698 ; Round 14
699 mov eax, DWORD PTR 112[ebp]
700 xor ebx, ebx
701 mov edx, DWORD PTR 116[ebp]
702 xor eax, edi
703 xor edx, edi
704 and eax, 0fcfcfcfch
705 and edx, 0cfcfcfcfh
706 mov bl, al
707 mov cl, ah
708 ror edx, 4
709 mov ebp, DWORD PTR _des_SPtrans[ebx]
710 mov bl, dl
711 xor esi, ebp
712 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
713 xor esi, ebp
714 mov cl, dh
715 shr eax, 16
716 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
717 xor esi, ebp
718 mov bl, ah
719 shr edx, 16
720 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
721 xor esi, ebp
722 mov ebp, DWORD PTR 24[esp]
723 mov cl, dh
724 and eax, 0ffh
725 and edx, 0ffh
726 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
727 xor esi, ebx
728 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
729 xor esi, ebx
730 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
731 xor esi, ebx
732 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
733 xor esi, ebx
734 ;
735 ; Round 13
736 mov eax, DWORD PTR 104[ebp]
737 xor ebx, ebx
738 mov edx, DWORD PTR 108[ebp]
739 xor eax, esi
740 xor edx, esi
741 and eax, 0fcfcfcfch
742 and edx, 0cfcfcfcfh
743 mov bl, al
744 mov cl, ah
745 ror edx, 4
746 mov ebp, DWORD PTR _des_SPtrans[ebx]
747 mov bl, dl
748 xor edi, ebp
749 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
750 xor edi, ebp
751 mov cl, dh
752 shr eax, 16
753 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
754 xor edi, ebp
755 mov bl, ah
756 shr edx, 16
757 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
758 xor edi, ebp
759 mov ebp, DWORD PTR 24[esp]
760 mov cl, dh
761 and eax, 0ffh
762 and edx, 0ffh
763 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
764 xor edi, ebx
765 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
766 xor edi, ebx
767 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
768 xor edi, ebx
769 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
770 xor edi, ebx
771 ;
772 ; Round 12
773 mov eax, DWORD PTR 96[ebp]
774 xor ebx, ebx
775 mov edx, DWORD PTR 100[ebp]
776 xor eax, edi
777 xor edx, edi
778 and eax, 0fcfcfcfch
779 and edx, 0cfcfcfcfh
780 mov bl, al
781 mov cl, ah
782 ror edx, 4
783 mov ebp, DWORD PTR _des_SPtrans[ebx]
784 mov bl, dl
785 xor esi, ebp
786 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
787 xor esi, ebp
788 mov cl, dh
789 shr eax, 16
790 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
791 xor esi, ebp
792 mov bl, ah
793 shr edx, 16
794 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
795 xor esi, ebp
796 mov ebp, DWORD PTR 24[esp]
797 mov cl, dh
798 and eax, 0ffh
799 and edx, 0ffh
800 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
801 xor esi, ebx
802 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
803 xor esi, ebx
804 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
805 xor esi, ebx
806 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
807 xor esi, ebx
808 ;
809 ; Round 11
810 mov eax, DWORD PTR 88[ebp]
811 xor ebx, ebx
812 mov edx, DWORD PTR 92[ebp]
813 xor eax, esi
814 xor edx, esi
815 and eax, 0fcfcfcfch
816 and edx, 0cfcfcfcfh
817 mov bl, al
818 mov cl, ah
819 ror edx, 4
820 mov ebp, DWORD PTR _des_SPtrans[ebx]
821 mov bl, dl
822 xor edi, ebp
823 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
824 xor edi, ebp
825 mov cl, dh
826 shr eax, 16
827 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
828 xor edi, ebp
829 mov bl, ah
830 shr edx, 16
831 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
832 xor edi, ebp
833 mov ebp, DWORD PTR 24[esp]
834 mov cl, dh
835 and eax, 0ffh
836 and edx, 0ffh
837 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
838 xor edi, ebx
839 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
840 xor edi, ebx
841 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
842 xor edi, ebx
843 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
844 xor edi, ebx
845 ;
846 ; Round 10
847 mov eax, DWORD PTR 80[ebp]
848 xor ebx, ebx
849 mov edx, DWORD PTR 84[ebp]
850 xor eax, edi
851 xor edx, edi
852 and eax, 0fcfcfcfch
853 and edx, 0cfcfcfcfh
854 mov bl, al
855 mov cl, ah
856 ror edx, 4
857 mov ebp, DWORD PTR _des_SPtrans[ebx]
858 mov bl, dl
859 xor esi, ebp
860 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
861 xor esi, ebp
862 mov cl, dh
863 shr eax, 16
864 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
865 xor esi, ebp
866 mov bl, ah
867 shr edx, 16
868 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
869 xor esi, ebp
870 mov ebp, DWORD PTR 24[esp]
871 mov cl, dh
872 and eax, 0ffh
873 and edx, 0ffh
874 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
875 xor esi, ebx
876 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
877 xor esi, ebx
878 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
879 xor esi, ebx
880 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
881 xor esi, ebx
882 ;
883 ; Round 9
884 mov eax, DWORD PTR 72[ebp]
885 xor ebx, ebx
886 mov edx, DWORD PTR 76[ebp]
887 xor eax, esi
888 xor edx, esi
889 and eax, 0fcfcfcfch
890 and edx, 0cfcfcfcfh
891 mov bl, al
892 mov cl, ah
893 ror edx, 4
894 mov ebp, DWORD PTR _des_SPtrans[ebx]
895 mov bl, dl
896 xor edi, ebp
897 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
898 xor edi, ebp
899 mov cl, dh
900 shr eax, 16
901 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
902 xor edi, ebp
903 mov bl, ah
904 shr edx, 16
905 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
906 xor edi, ebp
907 mov ebp, DWORD PTR 24[esp]
908 mov cl, dh
909 and eax, 0ffh
910 and edx, 0ffh
911 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
912 xor edi, ebx
913 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
914 xor edi, ebx
915 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
916 xor edi, ebx
917 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
918 xor edi, ebx
919 ;
920 ; Round 8
921 mov eax, DWORD PTR 64[ebp]
922 xor ebx, ebx
923 mov edx, DWORD PTR 68[ebp]
924 xor eax, edi
925 xor edx, edi
926 and eax, 0fcfcfcfch
927 and edx, 0cfcfcfcfh
928 mov bl, al
929 mov cl, ah
930 ror edx, 4
931 mov ebp, DWORD PTR _des_SPtrans[ebx]
932 mov bl, dl
933 xor esi, ebp
934 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
935 xor esi, ebp
936 mov cl, dh
937 shr eax, 16
938 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
939 xor esi, ebp
940 mov bl, ah
941 shr edx, 16
942 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
943 xor esi, ebp
944 mov ebp, DWORD PTR 24[esp]
945 mov cl, dh
946 and eax, 0ffh
947 and edx, 0ffh
948 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
949 xor esi, ebx
950 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
951 xor esi, ebx
952 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
953 xor esi, ebx
954 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
955 xor esi, ebx
956 ;
957 ; Round 7
958 mov eax, DWORD PTR 56[ebp]
959 xor ebx, ebx
960 mov edx, DWORD PTR 60[ebp]
961 xor eax, esi
962 xor edx, esi
963 and eax, 0fcfcfcfch
964 and edx, 0cfcfcfcfh
965 mov bl, al
966 mov cl, ah
967 ror edx, 4
968 mov ebp, DWORD PTR _des_SPtrans[ebx]
969 mov bl, dl
970 xor edi, ebp
971 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
972 xor edi, ebp
973 mov cl, dh
974 shr eax, 16
975 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
976 xor edi, ebp
977 mov bl, ah
978 shr edx, 16
979 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
980 xor edi, ebp
981 mov ebp, DWORD PTR 24[esp]
982 mov cl, dh
983 and eax, 0ffh
984 and edx, 0ffh
985 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
986 xor edi, ebx
987 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
988 xor edi, ebx
989 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
990 xor edi, ebx
991 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
992 xor edi, ebx
993 ;
994 ; Round 6
995 mov eax, DWORD PTR 48[ebp]
996 xor ebx, ebx
997 mov edx, DWORD PTR 52[ebp]
998 xor eax, edi
999 xor edx, edi
1000 and eax, 0fcfcfcfch
1001 and edx, 0cfcfcfcfh
1002 mov bl, al
1003 mov cl, ah
1004 ror edx, 4
1005 mov ebp, DWORD PTR _des_SPtrans[ebx]
1006 mov bl, dl
1007 xor esi, ebp
1008 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1009 xor esi, ebp
1010 mov cl, dh
1011 shr eax, 16
1012 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1013 xor esi, ebp
1014 mov bl, ah
1015 shr edx, 16
1016 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1017 xor esi, ebp
1018 mov ebp, DWORD PTR 24[esp]
1019 mov cl, dh
1020 and eax, 0ffh
1021 and edx, 0ffh
1022 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1023 xor esi, ebx
1024 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1025 xor esi, ebx
1026 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1027 xor esi, ebx
1028 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1029 xor esi, ebx
1030 ;
1031 ; Round 5
1032 mov eax, DWORD PTR 40[ebp]
1033 xor ebx, ebx
1034 mov edx, DWORD PTR 44[ebp]
1035 xor eax, esi
1036 xor edx, esi
1037 and eax, 0fcfcfcfch
1038 and edx, 0cfcfcfcfh
1039 mov bl, al
1040 mov cl, ah
1041 ror edx, 4
1042 mov ebp, DWORD PTR _des_SPtrans[ebx]
1043 mov bl, dl
1044 xor edi, ebp
1045 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1046 xor edi, ebp
1047 mov cl, dh
1048 shr eax, 16
1049 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1050 xor edi, ebp
1051 mov bl, ah
1052 shr edx, 16
1053 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1054 xor edi, ebp
1055 mov ebp, DWORD PTR 24[esp]
1056 mov cl, dh
1057 and eax, 0ffh
1058 and edx, 0ffh
1059 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1060 xor edi, ebx
1061 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1062 xor edi, ebx
1063 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1064 xor edi, ebx
1065 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1066 xor edi, ebx
1067 ;
1068 ; Round 4
1069 mov eax, DWORD PTR 32[ebp]
1070 xor ebx, ebx
1071 mov edx, DWORD PTR 36[ebp]
1072 xor eax, edi
1073 xor edx, edi
1074 and eax, 0fcfcfcfch
1075 and edx, 0cfcfcfcfh
1076 mov bl, al
1077 mov cl, ah
1078 ror edx, 4
1079 mov ebp, DWORD PTR _des_SPtrans[ebx]
1080 mov bl, dl
1081 xor esi, ebp
1082 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1083 xor esi, ebp
1084 mov cl, dh
1085 shr eax, 16
1086 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1087 xor esi, ebp
1088 mov bl, ah
1089 shr edx, 16
1090 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1091 xor esi, ebp
1092 mov ebp, DWORD PTR 24[esp]
1093 mov cl, dh
1094 and eax, 0ffh
1095 and edx, 0ffh
1096 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1097 xor esi, ebx
1098 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1099 xor esi, ebx
1100 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1101 xor esi, ebx
1102 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1103 xor esi, ebx
1104 ;
1105 ; Round 3
1106 mov eax, DWORD PTR 24[ebp]
1107 xor ebx, ebx
1108 mov edx, DWORD PTR 28[ebp]
1109 xor eax, esi
1110 xor edx, esi
1111 and eax, 0fcfcfcfch
1112 and edx, 0cfcfcfcfh
1113 mov bl, al
1114 mov cl, ah
1115 ror edx, 4
1116 mov ebp, DWORD PTR _des_SPtrans[ebx]
1117 mov bl, dl
1118 xor edi, ebp
1119 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1120 xor edi, ebp
1121 mov cl, dh
1122 shr eax, 16
1123 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1124 xor edi, ebp
1125 mov bl, ah
1126 shr edx, 16
1127 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1128 xor edi, ebp
1129 mov ebp, DWORD PTR 24[esp]
1130 mov cl, dh
1131 and eax, 0ffh
1132 and edx, 0ffh
1133 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1134 xor edi, ebx
1135 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1136 xor edi, ebx
1137 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1138 xor edi, ebx
1139 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1140 xor edi, ebx
1141 ;
1142 ; Round 2
1143 mov eax, DWORD PTR 16[ebp]
1144 xor ebx, ebx
1145 mov edx, DWORD PTR 20[ebp]
1146 xor eax, edi
1147 xor edx, edi
1148 and eax, 0fcfcfcfch
1149 and edx, 0cfcfcfcfh
1150 mov bl, al
1151 mov cl, ah
1152 ror edx, 4
1153 mov ebp, DWORD PTR _des_SPtrans[ebx]
1154 mov bl, dl
1155 xor esi, ebp
1156 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1157 xor esi, ebp
1158 mov cl, dh
1159 shr eax, 16
1160 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1161 xor esi, ebp
1162 mov bl, ah
1163 shr edx, 16
1164 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1165 xor esi, ebp
1166 mov ebp, DWORD PTR 24[esp]
1167 mov cl, dh
1168 and eax, 0ffh
1169 and edx, 0ffh
1170 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1171 xor esi, ebx
1172 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1173 xor esi, ebx
1174 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1175 xor esi, ebx
1176 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1177 xor esi, ebx
1178 ;
1179 ; Round 1
1180 mov eax, DWORD PTR 8[ebp]
1181 xor ebx, ebx
1182 mov edx, DWORD PTR 12[ebp]
1183 xor eax, esi
1184 xor edx, esi
1185 and eax, 0fcfcfcfch
1186 and edx, 0cfcfcfcfh
1187 mov bl, al
1188 mov cl, ah
1189 ror edx, 4
1190 mov ebp, DWORD PTR _des_SPtrans[ebx]
1191 mov bl, dl
1192 xor edi, ebp
1193 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1194 xor edi, ebp
1195 mov cl, dh
1196 shr eax, 16
1197 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1198 xor edi, ebp
1199 mov bl, ah
1200 shr edx, 16
1201 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1202 xor edi, ebp
1203 mov ebp, DWORD PTR 24[esp]
1204 mov cl, dh
1205 and eax, 0ffh
1206 and edx, 0ffh
1207 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1208 xor edi, ebx
1209 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1210 xor edi, ebx
1211 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1212 xor edi, ebx
1213 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1214 xor edi, ebx
1215 ;
1216 ; Round 0
1217 mov eax, DWORD PTR [ebp]
1218 xor ebx, ebx
1219 mov edx, DWORD PTR 4[ebp]
1220 xor eax, edi
1221 xor edx, edi
1222 and eax, 0fcfcfcfch
1223 and edx, 0cfcfcfcfh
1224 mov bl, al
1225 mov cl, ah
1226 ror edx, 4
1227 mov ebp, DWORD PTR _des_SPtrans[ebx]
1228 mov bl, dl
1229 xor esi, ebp
1230 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1231 xor esi, ebp
1232 mov cl, dh
1233 shr eax, 16
1234 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1235 xor esi, ebp
1236 mov bl, ah
1237 shr edx, 16
1238 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1239 xor esi, ebp
1240 mov ebp, DWORD PTR 24[esp]
1241 mov cl, dh
1242 and eax, 0ffh
1243 and edx, 0ffh
1244 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1245 xor esi, ebx
1246 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1247 xor esi, ebx
1248 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1249 xor esi, ebx
1250 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1251 xor esi, ebx
1252$L001end:
1253 ;
1254 ; FP
1255 mov edx, DWORD PTR 20[esp]
1256 ror esi, 1
1257 mov eax, edi
1258 xor edi, esi
1259 and edi, 0aaaaaaaah
1260 xor eax, edi
1261 xor esi, edi
1262 ;
1263 rol eax, 23
1264 mov edi, eax
1265 xor eax, esi
1266 and eax, 003fc03fch
1267 xor edi, eax
1268 xor esi, eax
1269 ;
1270 rol edi, 10
1271 mov eax, edi
1272 xor edi, esi
1273 and edi, 033333333h
1274 xor eax, edi
1275 xor esi, edi
1276 ;
1277 rol esi, 18
1278 mov edi, esi
1279 xor esi, eax
1280 and esi, 0fff0000fh
1281 xor edi, esi
1282 xor eax, esi
1283 ;
1284 rol edi, 12
1285 mov esi, edi
1286 xor edi, eax
1287 and edi, 0f0f0f0f0h
1288 xor esi, edi
1289 xor eax, edi
1290 ;
1291 ror eax, 4
1292 mov DWORD PTR [edx],eax
1293 mov DWORD PTR 4[edx],esi
1294 pop ebp
1295 pop ebx
1296 pop edi
1297 pop esi
1298 ret
1299_des_encrypt ENDP
1300_TEXT ENDS
1301_TEXT SEGMENT
1302PUBLIC _des_encrypt2
1303EXTRN _des_SPtrans:DWORD
1304_des_encrypt2 PROC NEAR
1305 push esi
1306 push edi
1307 ;
1308 ; Load the 2 words
1309 mov eax, DWORD PTR 12[esp]
1310 xor ecx, ecx
1311 push ebx
1312 push ebp
1313 mov esi, DWORD PTR [eax]
1314 mov ebx, DWORD PTR 28[esp]
1315 rol esi, 3
1316 mov edi, DWORD PTR 4[eax]
1317 rol edi, 3
1318 mov ebp, DWORD PTR 24[esp]
1319 cmp ebx, 0
1320 je $L002start_decrypt
1321 ;
1322 ; Round 0
1323 mov eax, DWORD PTR [ebp]
1324 xor ebx, ebx
1325 mov edx, DWORD PTR 4[ebp]
1326 xor eax, esi
1327 xor edx, esi
1328 and eax, 0fcfcfcfch
1329 and edx, 0cfcfcfcfh
1330 mov bl, al
1331 mov cl, ah
1332 ror edx, 4
1333 mov ebp, DWORD PTR _des_SPtrans[ebx]
1334 mov bl, dl
1335 xor edi, ebp
1336 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1337 xor edi, ebp
1338 mov cl, dh
1339 shr eax, 16
1340 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1341 xor edi, ebp
1342 mov bl, ah
1343 shr edx, 16
1344 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1345 xor edi, ebp
1346 mov ebp, DWORD PTR 24[esp]
1347 mov cl, dh
1348 and eax, 0ffh
1349 and edx, 0ffh
1350 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1351 xor edi, ebx
1352 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1353 xor edi, ebx
1354 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1355 xor edi, ebx
1356 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1357 xor edi, ebx
1358 ;
1359 ; Round 1
1360 mov eax, DWORD PTR 8[ebp]
1361 xor ebx, ebx
1362 mov edx, DWORD PTR 12[ebp]
1363 xor eax, edi
1364 xor edx, edi
1365 and eax, 0fcfcfcfch
1366 and edx, 0cfcfcfcfh
1367 mov bl, al
1368 mov cl, ah
1369 ror edx, 4
1370 mov ebp, DWORD PTR _des_SPtrans[ebx]
1371 mov bl, dl
1372 xor esi, ebp
1373 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1374 xor esi, ebp
1375 mov cl, dh
1376 shr eax, 16
1377 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1378 xor esi, ebp
1379 mov bl, ah
1380 shr edx, 16
1381 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1382 xor esi, ebp
1383 mov ebp, DWORD PTR 24[esp]
1384 mov cl, dh
1385 and eax, 0ffh
1386 and edx, 0ffh
1387 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1388 xor esi, ebx
1389 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1390 xor esi, ebx
1391 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1392 xor esi, ebx
1393 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1394 xor esi, ebx
1395 ;
1396 ; Round 2
1397 mov eax, DWORD PTR 16[ebp]
1398 xor ebx, ebx
1399 mov edx, DWORD PTR 20[ebp]
1400 xor eax, esi
1401 xor edx, esi
1402 and eax, 0fcfcfcfch
1403 and edx, 0cfcfcfcfh
1404 mov bl, al
1405 mov cl, ah
1406 ror edx, 4
1407 mov ebp, DWORD PTR _des_SPtrans[ebx]
1408 mov bl, dl
1409 xor edi, ebp
1410 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1411 xor edi, ebp
1412 mov cl, dh
1413 shr eax, 16
1414 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1415 xor edi, ebp
1416 mov bl, ah
1417 shr edx, 16
1418 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1419 xor edi, ebp
1420 mov ebp, DWORD PTR 24[esp]
1421 mov cl, dh
1422 and eax, 0ffh
1423 and edx, 0ffh
1424 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1425 xor edi, ebx
1426 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1427 xor edi, ebx
1428 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1429 xor edi, ebx
1430 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1431 xor edi, ebx
1432 ;
1433 ; Round 3
1434 mov eax, DWORD PTR 24[ebp]
1435 xor ebx, ebx
1436 mov edx, DWORD PTR 28[ebp]
1437 xor eax, edi
1438 xor edx, edi
1439 and eax, 0fcfcfcfch
1440 and edx, 0cfcfcfcfh
1441 mov bl, al
1442 mov cl, ah
1443 ror edx, 4
1444 mov ebp, DWORD PTR _des_SPtrans[ebx]
1445 mov bl, dl
1446 xor esi, ebp
1447 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1448 xor esi, ebp
1449 mov cl, dh
1450 shr eax, 16
1451 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1452 xor esi, ebp
1453 mov bl, ah
1454 shr edx, 16
1455 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1456 xor esi, ebp
1457 mov ebp, DWORD PTR 24[esp]
1458 mov cl, dh
1459 and eax, 0ffh
1460 and edx, 0ffh
1461 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1462 xor esi, ebx
1463 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1464 xor esi, ebx
1465 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1466 xor esi, ebx
1467 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1468 xor esi, ebx
1469 ;
1470 ; Round 4
1471 mov eax, DWORD PTR 32[ebp]
1472 xor ebx, ebx
1473 mov edx, DWORD PTR 36[ebp]
1474 xor eax, esi
1475 xor edx, esi
1476 and eax, 0fcfcfcfch
1477 and edx, 0cfcfcfcfh
1478 mov bl, al
1479 mov cl, ah
1480 ror edx, 4
1481 mov ebp, DWORD PTR _des_SPtrans[ebx]
1482 mov bl, dl
1483 xor edi, ebp
1484 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1485 xor edi, ebp
1486 mov cl, dh
1487 shr eax, 16
1488 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1489 xor edi, ebp
1490 mov bl, ah
1491 shr edx, 16
1492 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1493 xor edi, ebp
1494 mov ebp, DWORD PTR 24[esp]
1495 mov cl, dh
1496 and eax, 0ffh
1497 and edx, 0ffh
1498 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1499 xor edi, ebx
1500 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1501 xor edi, ebx
1502 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1503 xor edi, ebx
1504 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1505 xor edi, ebx
1506 ;
1507 ; Round 5
1508 mov eax, DWORD PTR 40[ebp]
1509 xor ebx, ebx
1510 mov edx, DWORD PTR 44[ebp]
1511 xor eax, edi
1512 xor edx, edi
1513 and eax, 0fcfcfcfch
1514 and edx, 0cfcfcfcfh
1515 mov bl, al
1516 mov cl, ah
1517 ror edx, 4
1518 mov ebp, DWORD PTR _des_SPtrans[ebx]
1519 mov bl, dl
1520 xor esi, ebp
1521 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1522 xor esi, ebp
1523 mov cl, dh
1524 shr eax, 16
1525 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1526 xor esi, ebp
1527 mov bl, ah
1528 shr edx, 16
1529 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1530 xor esi, ebp
1531 mov ebp, DWORD PTR 24[esp]
1532 mov cl, dh
1533 and eax, 0ffh
1534 and edx, 0ffh
1535 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1536 xor esi, ebx
1537 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1538 xor esi, ebx
1539 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1540 xor esi, ebx
1541 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1542 xor esi, ebx
1543 ;
1544 ; Round 6
1545 mov eax, DWORD PTR 48[ebp]
1546 xor ebx, ebx
1547 mov edx, DWORD PTR 52[ebp]
1548 xor eax, esi
1549 xor edx, esi
1550 and eax, 0fcfcfcfch
1551 and edx, 0cfcfcfcfh
1552 mov bl, al
1553 mov cl, ah
1554 ror edx, 4
1555 mov ebp, DWORD PTR _des_SPtrans[ebx]
1556 mov bl, dl
1557 xor edi, ebp
1558 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1559 xor edi, ebp
1560 mov cl, dh
1561 shr eax, 16
1562 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1563 xor edi, ebp
1564 mov bl, ah
1565 shr edx, 16
1566 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1567 xor edi, ebp
1568 mov ebp, DWORD PTR 24[esp]
1569 mov cl, dh
1570 and eax, 0ffh
1571 and edx, 0ffh
1572 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1573 xor edi, ebx
1574 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1575 xor edi, ebx
1576 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1577 xor edi, ebx
1578 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1579 xor edi, ebx
1580 ;
1581 ; Round 7
1582 mov eax, DWORD PTR 56[ebp]
1583 xor ebx, ebx
1584 mov edx, DWORD PTR 60[ebp]
1585 xor eax, edi
1586 xor edx, edi
1587 and eax, 0fcfcfcfch
1588 and edx, 0cfcfcfcfh
1589 mov bl, al
1590 mov cl, ah
1591 ror edx, 4
1592 mov ebp, DWORD PTR _des_SPtrans[ebx]
1593 mov bl, dl
1594 xor esi, ebp
1595 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1596 xor esi, ebp
1597 mov cl, dh
1598 shr eax, 16
1599 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1600 xor esi, ebp
1601 mov bl, ah
1602 shr edx, 16
1603 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1604 xor esi, ebp
1605 mov ebp, DWORD PTR 24[esp]
1606 mov cl, dh
1607 and eax, 0ffh
1608 and edx, 0ffh
1609 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1610 xor esi, ebx
1611 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1612 xor esi, ebx
1613 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1614 xor esi, ebx
1615 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1616 xor esi, ebx
1617 ;
1618 ; Round 8
1619 mov eax, DWORD PTR 64[ebp]
1620 xor ebx, ebx
1621 mov edx, DWORD PTR 68[ebp]
1622 xor eax, esi
1623 xor edx, esi
1624 and eax, 0fcfcfcfch
1625 and edx, 0cfcfcfcfh
1626 mov bl, al
1627 mov cl, ah
1628 ror edx, 4
1629 mov ebp, DWORD PTR _des_SPtrans[ebx]
1630 mov bl, dl
1631 xor edi, ebp
1632 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1633 xor edi, ebp
1634 mov cl, dh
1635 shr eax, 16
1636 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1637 xor edi, ebp
1638 mov bl, ah
1639 shr edx, 16
1640 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1641 xor edi, ebp
1642 mov ebp, DWORD PTR 24[esp]
1643 mov cl, dh
1644 and eax, 0ffh
1645 and edx, 0ffh
1646 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1647 xor edi, ebx
1648 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1649 xor edi, ebx
1650 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1651 xor edi, ebx
1652 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1653 xor edi, ebx
1654 ;
1655 ; Round 9
1656 mov eax, DWORD PTR 72[ebp]
1657 xor ebx, ebx
1658 mov edx, DWORD PTR 76[ebp]
1659 xor eax, edi
1660 xor edx, edi
1661 and eax, 0fcfcfcfch
1662 and edx, 0cfcfcfcfh
1663 mov bl, al
1664 mov cl, ah
1665 ror edx, 4
1666 mov ebp, DWORD PTR _des_SPtrans[ebx]
1667 mov bl, dl
1668 xor esi, ebp
1669 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1670 xor esi, ebp
1671 mov cl, dh
1672 shr eax, 16
1673 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1674 xor esi, ebp
1675 mov bl, ah
1676 shr edx, 16
1677 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1678 xor esi, ebp
1679 mov ebp, DWORD PTR 24[esp]
1680 mov cl, dh
1681 and eax, 0ffh
1682 and edx, 0ffh
1683 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1684 xor esi, ebx
1685 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1686 xor esi, ebx
1687 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1688 xor esi, ebx
1689 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1690 xor esi, ebx
1691 ;
1692 ; Round 10
1693 mov eax, DWORD PTR 80[ebp]
1694 xor ebx, ebx
1695 mov edx, DWORD PTR 84[ebp]
1696 xor eax, esi
1697 xor edx, esi
1698 and eax, 0fcfcfcfch
1699 and edx, 0cfcfcfcfh
1700 mov bl, al
1701 mov cl, ah
1702 ror edx, 4
1703 mov ebp, DWORD PTR _des_SPtrans[ebx]
1704 mov bl, dl
1705 xor edi, ebp
1706 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1707 xor edi, ebp
1708 mov cl, dh
1709 shr eax, 16
1710 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1711 xor edi, ebp
1712 mov bl, ah
1713 shr edx, 16
1714 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1715 xor edi, ebp
1716 mov ebp, DWORD PTR 24[esp]
1717 mov cl, dh
1718 and eax, 0ffh
1719 and edx, 0ffh
1720 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1721 xor edi, ebx
1722 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1723 xor edi, ebx
1724 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1725 xor edi, ebx
1726 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1727 xor edi, ebx
1728 ;
1729 ; Round 11
1730 mov eax, DWORD PTR 88[ebp]
1731 xor ebx, ebx
1732 mov edx, DWORD PTR 92[ebp]
1733 xor eax, edi
1734 xor edx, edi
1735 and eax, 0fcfcfcfch
1736 and edx, 0cfcfcfcfh
1737 mov bl, al
1738 mov cl, ah
1739 ror edx, 4
1740 mov ebp, DWORD PTR _des_SPtrans[ebx]
1741 mov bl, dl
1742 xor esi, ebp
1743 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1744 xor esi, ebp
1745 mov cl, dh
1746 shr eax, 16
1747 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1748 xor esi, ebp
1749 mov bl, ah
1750 shr edx, 16
1751 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1752 xor esi, ebp
1753 mov ebp, DWORD PTR 24[esp]
1754 mov cl, dh
1755 and eax, 0ffh
1756 and edx, 0ffh
1757 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1758 xor esi, ebx
1759 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1760 xor esi, ebx
1761 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1762 xor esi, ebx
1763 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1764 xor esi, ebx
1765 ;
1766 ; Round 12
1767 mov eax, DWORD PTR 96[ebp]
1768 xor ebx, ebx
1769 mov edx, DWORD PTR 100[ebp]
1770 xor eax, esi
1771 xor edx, esi
1772 and eax, 0fcfcfcfch
1773 and edx, 0cfcfcfcfh
1774 mov bl, al
1775 mov cl, ah
1776 ror edx, 4
1777 mov ebp, DWORD PTR _des_SPtrans[ebx]
1778 mov bl, dl
1779 xor edi, ebp
1780 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1781 xor edi, ebp
1782 mov cl, dh
1783 shr eax, 16
1784 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1785 xor edi, ebp
1786 mov bl, ah
1787 shr edx, 16
1788 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1789 xor edi, ebp
1790 mov ebp, DWORD PTR 24[esp]
1791 mov cl, dh
1792 and eax, 0ffh
1793 and edx, 0ffh
1794 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1795 xor edi, ebx
1796 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1797 xor edi, ebx
1798 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1799 xor edi, ebx
1800 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1801 xor edi, ebx
1802 ;
1803 ; Round 13
1804 mov eax, DWORD PTR 104[ebp]
1805 xor ebx, ebx
1806 mov edx, DWORD PTR 108[ebp]
1807 xor eax, edi
1808 xor edx, edi
1809 and eax, 0fcfcfcfch
1810 and edx, 0cfcfcfcfh
1811 mov bl, al
1812 mov cl, ah
1813 ror edx, 4
1814 mov ebp, DWORD PTR _des_SPtrans[ebx]
1815 mov bl, dl
1816 xor esi, ebp
1817 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1818 xor esi, ebp
1819 mov cl, dh
1820 shr eax, 16
1821 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1822 xor esi, ebp
1823 mov bl, ah
1824 shr edx, 16
1825 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1826 xor esi, ebp
1827 mov ebp, DWORD PTR 24[esp]
1828 mov cl, dh
1829 and eax, 0ffh
1830 and edx, 0ffh
1831 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1832 xor esi, ebx
1833 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1834 xor esi, ebx
1835 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1836 xor esi, ebx
1837 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1838 xor esi, ebx
1839 ;
1840 ; Round 14
1841 mov eax, DWORD PTR 112[ebp]
1842 xor ebx, ebx
1843 mov edx, DWORD PTR 116[ebp]
1844 xor eax, esi
1845 xor edx, esi
1846 and eax, 0fcfcfcfch
1847 and edx, 0cfcfcfcfh
1848 mov bl, al
1849 mov cl, ah
1850 ror edx, 4
1851 mov ebp, DWORD PTR _des_SPtrans[ebx]
1852 mov bl, dl
1853 xor edi, ebp
1854 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1855 xor edi, ebp
1856 mov cl, dh
1857 shr eax, 16
1858 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1859 xor edi, ebp
1860 mov bl, ah
1861 shr edx, 16
1862 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1863 xor edi, ebp
1864 mov ebp, DWORD PTR 24[esp]
1865 mov cl, dh
1866 and eax, 0ffh
1867 and edx, 0ffh
1868 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1869 xor edi, ebx
1870 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1871 xor edi, ebx
1872 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1873 xor edi, ebx
1874 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1875 xor edi, ebx
1876 ;
1877 ; Round 15
1878 mov eax, DWORD PTR 120[ebp]
1879 xor ebx, ebx
1880 mov edx, DWORD PTR 124[ebp]
1881 xor eax, edi
1882 xor edx, edi
1883 and eax, 0fcfcfcfch
1884 and edx, 0cfcfcfcfh
1885 mov bl, al
1886 mov cl, ah
1887 ror edx, 4
1888 mov ebp, DWORD PTR _des_SPtrans[ebx]
1889 mov bl, dl
1890 xor esi, ebp
1891 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1892 xor esi, ebp
1893 mov cl, dh
1894 shr eax, 16
1895 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1896 xor esi, ebp
1897 mov bl, ah
1898 shr edx, 16
1899 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1900 xor esi, ebp
1901 mov ebp, DWORD PTR 24[esp]
1902 mov cl, dh
1903 and eax, 0ffh
1904 and edx, 0ffh
1905 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1906 xor esi, ebx
1907 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1908 xor esi, ebx
1909 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1910 xor esi, ebx
1911 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1912 xor esi, ebx
1913 jmp $L003end
1914$L002start_decrypt:
1915 ;
1916 ; Round 15
1917 mov eax, DWORD PTR 120[ebp]
1918 xor ebx, ebx
1919 mov edx, DWORD PTR 124[ebp]
1920 xor eax, esi
1921 xor edx, esi
1922 and eax, 0fcfcfcfch
1923 and edx, 0cfcfcfcfh
1924 mov bl, al
1925 mov cl, ah
1926 ror edx, 4
1927 mov ebp, DWORD PTR _des_SPtrans[ebx]
1928 mov bl, dl
1929 xor edi, ebp
1930 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1931 xor edi, ebp
1932 mov cl, dh
1933 shr eax, 16
1934 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1935 xor edi, ebp
1936 mov bl, ah
1937 shr edx, 16
1938 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1939 xor edi, ebp
1940 mov ebp, DWORD PTR 24[esp]
1941 mov cl, dh
1942 and eax, 0ffh
1943 and edx, 0ffh
1944 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1945 xor edi, ebx
1946 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1947 xor edi, ebx
1948 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1949 xor edi, ebx
1950 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1951 xor edi, ebx
1952 ;
1953 ; Round 14
1954 mov eax, DWORD PTR 112[ebp]
1955 xor ebx, ebx
1956 mov edx, DWORD PTR 116[ebp]
1957 xor eax, edi
1958 xor edx, edi
1959 and eax, 0fcfcfcfch
1960 and edx, 0cfcfcfcfh
1961 mov bl, al
1962 mov cl, ah
1963 ror edx, 4
1964 mov ebp, DWORD PTR _des_SPtrans[ebx]
1965 mov bl, dl
1966 xor esi, ebp
1967 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1968 xor esi, ebp
1969 mov cl, dh
1970 shr eax, 16
1971 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1972 xor esi, ebp
1973 mov bl, ah
1974 shr edx, 16
1975 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1976 xor esi, ebp
1977 mov ebp, DWORD PTR 24[esp]
1978 mov cl, dh
1979 and eax, 0ffh
1980 and edx, 0ffh
1981 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1982 xor esi, ebx
1983 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1984 xor esi, ebx
1985 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1986 xor esi, ebx
1987 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1988 xor esi, ebx
1989 ;
1990 ; Round 13
1991 mov eax, DWORD PTR 104[ebp]
1992 xor ebx, ebx
1993 mov edx, DWORD PTR 108[ebp]
1994 xor eax, esi
1995 xor edx, esi
1996 and eax, 0fcfcfcfch
1997 and edx, 0cfcfcfcfh
1998 mov bl, al
1999 mov cl, ah
2000 ror edx, 4
2001 mov ebp, DWORD PTR _des_SPtrans[ebx]
2002 mov bl, dl
2003 xor edi, ebp
2004 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2005 xor edi, ebp
2006 mov cl, dh
2007 shr eax, 16
2008 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2009 xor edi, ebp
2010 mov bl, ah
2011 shr edx, 16
2012 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2013 xor edi, ebp
2014 mov ebp, DWORD PTR 24[esp]
2015 mov cl, dh
2016 and eax, 0ffh
2017 and edx, 0ffh
2018 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2019 xor edi, ebx
2020 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2021 xor edi, ebx
2022 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2023 xor edi, ebx
2024 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2025 xor edi, ebx
2026 ;
2027 ; Round 12
2028 mov eax, DWORD PTR 96[ebp]
2029 xor ebx, ebx
2030 mov edx, DWORD PTR 100[ebp]
2031 xor eax, edi
2032 xor edx, edi
2033 and eax, 0fcfcfcfch
2034 and edx, 0cfcfcfcfh
2035 mov bl, al
2036 mov cl, ah
2037 ror edx, 4
2038 mov ebp, DWORD PTR _des_SPtrans[ebx]
2039 mov bl, dl
2040 xor esi, ebp
2041 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2042 xor esi, ebp
2043 mov cl, dh
2044 shr eax, 16
2045 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2046 xor esi, ebp
2047 mov bl, ah
2048 shr edx, 16
2049 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2050 xor esi, ebp
2051 mov ebp, DWORD PTR 24[esp]
2052 mov cl, dh
2053 and eax, 0ffh
2054 and edx, 0ffh
2055 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2056 xor esi, ebx
2057 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2058 xor esi, ebx
2059 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2060 xor esi, ebx
2061 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2062 xor esi, ebx
2063 ;
2064 ; Round 11
2065 mov eax, DWORD PTR 88[ebp]
2066 xor ebx, ebx
2067 mov edx, DWORD PTR 92[ebp]
2068 xor eax, esi
2069 xor edx, esi
2070 and eax, 0fcfcfcfch
2071 and edx, 0cfcfcfcfh
2072 mov bl, al
2073 mov cl, ah
2074 ror edx, 4
2075 mov ebp, DWORD PTR _des_SPtrans[ebx]
2076 mov bl, dl
2077 xor edi, ebp
2078 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2079 xor edi, ebp
2080 mov cl, dh
2081 shr eax, 16
2082 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2083 xor edi, ebp
2084 mov bl, ah
2085 shr edx, 16
2086 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2087 xor edi, ebp
2088 mov ebp, DWORD PTR 24[esp]
2089 mov cl, dh
2090 and eax, 0ffh
2091 and edx, 0ffh
2092 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2093 xor edi, ebx
2094 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2095 xor edi, ebx
2096 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2097 xor edi, ebx
2098 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2099 xor edi, ebx
2100 ;
2101 ; Round 10
2102 mov eax, DWORD PTR 80[ebp]
2103 xor ebx, ebx
2104 mov edx, DWORD PTR 84[ebp]
2105 xor eax, edi
2106 xor edx, edi
2107 and eax, 0fcfcfcfch
2108 and edx, 0cfcfcfcfh
2109 mov bl, al
2110 mov cl, ah
2111 ror edx, 4
2112 mov ebp, DWORD PTR _des_SPtrans[ebx]
2113 mov bl, dl
2114 xor esi, ebp
2115 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2116 xor esi, ebp
2117 mov cl, dh
2118 shr eax, 16
2119 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2120 xor esi, ebp
2121 mov bl, ah
2122 shr edx, 16
2123 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2124 xor esi, ebp
2125 mov ebp, DWORD PTR 24[esp]
2126 mov cl, dh
2127 and eax, 0ffh
2128 and edx, 0ffh
2129 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2130 xor esi, ebx
2131 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2132 xor esi, ebx
2133 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2134 xor esi, ebx
2135 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2136 xor esi, ebx
2137 ;
2138 ; Round 9
2139 mov eax, DWORD PTR 72[ebp]
2140 xor ebx, ebx
2141 mov edx, DWORD PTR 76[ebp]
2142 xor eax, esi
2143 xor edx, esi
2144 and eax, 0fcfcfcfch
2145 and edx, 0cfcfcfcfh
2146 mov bl, al
2147 mov cl, ah
2148 ror edx, 4
2149 mov ebp, DWORD PTR _des_SPtrans[ebx]
2150 mov bl, dl
2151 xor edi, ebp
2152 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2153 xor edi, ebp
2154 mov cl, dh
2155 shr eax, 16
2156 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2157 xor edi, ebp
2158 mov bl, ah
2159 shr edx, 16
2160 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2161 xor edi, ebp
2162 mov ebp, DWORD PTR 24[esp]
2163 mov cl, dh
2164 and eax, 0ffh
2165 and edx, 0ffh
2166 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2167 xor edi, ebx
2168 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2169 xor edi, ebx
2170 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2171 xor edi, ebx
2172 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2173 xor edi, ebx
2174 ;
2175 ; Round 8
2176 mov eax, DWORD PTR 64[ebp]
2177 xor ebx, ebx
2178 mov edx, DWORD PTR 68[ebp]
2179 xor eax, edi
2180 xor edx, edi
2181 and eax, 0fcfcfcfch
2182 and edx, 0cfcfcfcfh
2183 mov bl, al
2184 mov cl, ah
2185 ror edx, 4
2186 mov ebp, DWORD PTR _des_SPtrans[ebx]
2187 mov bl, dl
2188 xor esi, ebp
2189 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2190 xor esi, ebp
2191 mov cl, dh
2192 shr eax, 16
2193 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2194 xor esi, ebp
2195 mov bl, ah
2196 shr edx, 16
2197 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2198 xor esi, ebp
2199 mov ebp, DWORD PTR 24[esp]
2200 mov cl, dh
2201 and eax, 0ffh
2202 and edx, 0ffh
2203 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2204 xor esi, ebx
2205 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2206 xor esi, ebx
2207 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2208 xor esi, ebx
2209 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2210 xor esi, ebx
2211 ;
2212 ; Round 7
2213 mov eax, DWORD PTR 56[ebp]
2214 xor ebx, ebx
2215 mov edx, DWORD PTR 60[ebp]
2216 xor eax, esi
2217 xor edx, esi
2218 and eax, 0fcfcfcfch
2219 and edx, 0cfcfcfcfh
2220 mov bl, al
2221 mov cl, ah
2222 ror edx, 4
2223 mov ebp, DWORD PTR _des_SPtrans[ebx]
2224 mov bl, dl
2225 xor edi, ebp
2226 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2227 xor edi, ebp
2228 mov cl, dh
2229 shr eax, 16
2230 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2231 xor edi, ebp
2232 mov bl, ah
2233 shr edx, 16
2234 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2235 xor edi, ebp
2236 mov ebp, DWORD PTR 24[esp]
2237 mov cl, dh
2238 and eax, 0ffh
2239 and edx, 0ffh
2240 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2241 xor edi, ebx
2242 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2243 xor edi, ebx
2244 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2245 xor edi, ebx
2246 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2247 xor edi, ebx
2248 ;
2249 ; Round 6
2250 mov eax, DWORD PTR 48[ebp]
2251 xor ebx, ebx
2252 mov edx, DWORD PTR 52[ebp]
2253 xor eax, edi
2254 xor edx, edi
2255 and eax, 0fcfcfcfch
2256 and edx, 0cfcfcfcfh
2257 mov bl, al
2258 mov cl, ah
2259 ror edx, 4
2260 mov ebp, DWORD PTR _des_SPtrans[ebx]
2261 mov bl, dl
2262 xor esi, ebp
2263 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2264 xor esi, ebp
2265 mov cl, dh
2266 shr eax, 16
2267 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2268 xor esi, ebp
2269 mov bl, ah
2270 shr edx, 16
2271 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2272 xor esi, ebp
2273 mov ebp, DWORD PTR 24[esp]
2274 mov cl, dh
2275 and eax, 0ffh
2276 and edx, 0ffh
2277 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2278 xor esi, ebx
2279 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2280 xor esi, ebx
2281 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2282 xor esi, ebx
2283 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2284 xor esi, ebx
2285 ;
2286 ; Round 5
2287 mov eax, DWORD PTR 40[ebp]
2288 xor ebx, ebx
2289 mov edx, DWORD PTR 44[ebp]
2290 xor eax, esi
2291 xor edx, esi
2292 and eax, 0fcfcfcfch
2293 and edx, 0cfcfcfcfh
2294 mov bl, al
2295 mov cl, ah
2296 ror edx, 4
2297 mov ebp, DWORD PTR _des_SPtrans[ebx]
2298 mov bl, dl
2299 xor edi, ebp
2300 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2301 xor edi, ebp
2302 mov cl, dh
2303 shr eax, 16
2304 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2305 xor edi, ebp
2306 mov bl, ah
2307 shr edx, 16
2308 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2309 xor edi, ebp
2310 mov ebp, DWORD PTR 24[esp]
2311 mov cl, dh
2312 and eax, 0ffh
2313 and edx, 0ffh
2314 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2315 xor edi, ebx
2316 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2317 xor edi, ebx
2318 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2319 xor edi, ebx
2320 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2321 xor edi, ebx
2322 ;
2323 ; Round 4
2324 mov eax, DWORD PTR 32[ebp]
2325 xor ebx, ebx
2326 mov edx, DWORD PTR 36[ebp]
2327 xor eax, edi
2328 xor edx, edi
2329 and eax, 0fcfcfcfch
2330 and edx, 0cfcfcfcfh
2331 mov bl, al
2332 mov cl, ah
2333 ror edx, 4
2334 mov ebp, DWORD PTR _des_SPtrans[ebx]
2335 mov bl, dl
2336 xor esi, ebp
2337 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2338 xor esi, ebp
2339 mov cl, dh
2340 shr eax, 16
2341 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2342 xor esi, ebp
2343 mov bl, ah
2344 shr edx, 16
2345 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2346 xor esi, ebp
2347 mov ebp, DWORD PTR 24[esp]
2348 mov cl, dh
2349 and eax, 0ffh
2350 and edx, 0ffh
2351 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2352 xor esi, ebx
2353 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2354 xor esi, ebx
2355 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2356 xor esi, ebx
2357 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2358 xor esi, ebx
2359 ;
2360 ; Round 3
2361 mov eax, DWORD PTR 24[ebp]
2362 xor ebx, ebx
2363 mov edx, DWORD PTR 28[ebp]
2364 xor eax, esi
2365 xor edx, esi
2366 and eax, 0fcfcfcfch
2367 and edx, 0cfcfcfcfh
2368 mov bl, al
2369 mov cl, ah
2370 ror edx, 4
2371 mov ebp, DWORD PTR _des_SPtrans[ebx]
2372 mov bl, dl
2373 xor edi, ebp
2374 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2375 xor edi, ebp
2376 mov cl, dh
2377 shr eax, 16
2378 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2379 xor edi, ebp
2380 mov bl, ah
2381 shr edx, 16
2382 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2383 xor edi, ebp
2384 mov ebp, DWORD PTR 24[esp]
2385 mov cl, dh
2386 and eax, 0ffh
2387 and edx, 0ffh
2388 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2389 xor edi, ebx
2390 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2391 xor edi, ebx
2392 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2393 xor edi, ebx
2394 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2395 xor edi, ebx
2396 ;
2397 ; Round 2
2398 mov eax, DWORD PTR 16[ebp]
2399 xor ebx, ebx
2400 mov edx, DWORD PTR 20[ebp]
2401 xor eax, edi
2402 xor edx, edi
2403 and eax, 0fcfcfcfch
2404 and edx, 0cfcfcfcfh
2405 mov bl, al
2406 mov cl, ah
2407 ror edx, 4
2408 mov ebp, DWORD PTR _des_SPtrans[ebx]
2409 mov bl, dl
2410 xor esi, ebp
2411 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2412 xor esi, ebp
2413 mov cl, dh
2414 shr eax, 16
2415 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2416 xor esi, ebp
2417 mov bl, ah
2418 shr edx, 16
2419 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2420 xor esi, ebp
2421 mov ebp, DWORD PTR 24[esp]
2422 mov cl, dh
2423 and eax, 0ffh
2424 and edx, 0ffh
2425 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2426 xor esi, ebx
2427 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2428 xor esi, ebx
2429 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2430 xor esi, ebx
2431 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2432 xor esi, ebx
2433 ;
2434 ; Round 1
2435 mov eax, DWORD PTR 8[ebp]
2436 xor ebx, ebx
2437 mov edx, DWORD PTR 12[ebp]
2438 xor eax, esi
2439 xor edx, esi
2440 and eax, 0fcfcfcfch
2441 and edx, 0cfcfcfcfh
2442 mov bl, al
2443 mov cl, ah
2444 ror edx, 4
2445 mov ebp, DWORD PTR _des_SPtrans[ebx]
2446 mov bl, dl
2447 xor edi, ebp
2448 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2449 xor edi, ebp
2450 mov cl, dh
2451 shr eax, 16
2452 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2453 xor edi, ebp
2454 mov bl, ah
2455 shr edx, 16
2456 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2457 xor edi, ebp
2458 mov ebp, DWORD PTR 24[esp]
2459 mov cl, dh
2460 and eax, 0ffh
2461 and edx, 0ffh
2462 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2463 xor edi, ebx
2464 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2465 xor edi, ebx
2466 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2467 xor edi, ebx
2468 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2469 xor edi, ebx
2470 ;
2471 ; Round 0
2472 mov eax, DWORD PTR [ebp]
2473 xor ebx, ebx
2474 mov edx, DWORD PTR 4[ebp]
2475 xor eax, edi
2476 xor edx, edi
2477 and eax, 0fcfcfcfch
2478 and edx, 0cfcfcfcfh
2479 mov bl, al
2480 mov cl, ah
2481 ror edx, 4
2482 mov ebp, DWORD PTR _des_SPtrans[ebx]
2483 mov bl, dl
2484 xor esi, ebp
2485 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2486 xor esi, ebp
2487 mov cl, dh
2488 shr eax, 16
2489 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2490 xor esi, ebp
2491 mov bl, ah
2492 shr edx, 16
2493 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2494 xor esi, ebp
2495 mov ebp, DWORD PTR 24[esp]
2496 mov cl, dh
2497 and eax, 0ffh
2498 and edx, 0ffh
2499 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2500 xor esi, ebx
2501 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2502 xor esi, ebx
2503 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2504 xor esi, ebx
2505 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2506 xor esi, ebx
2507$L003end:
2508 ;
2509 ; Fixup
2510 ror edi, 3
2511 mov eax, DWORD PTR 20[esp]
2512 ror esi, 3
2513 mov DWORD PTR [eax],edi
2514 mov DWORD PTR 4[eax],esi
2515 pop ebp
2516 pop ebx
2517 pop edi
2518 pop esi
2519 ret
2520_des_encrypt2 ENDP
2521_TEXT ENDS
2522_TEXT SEGMENT
2523PUBLIC _des_encrypt3
2524
2525_des_encrypt3 PROC NEAR
2526 push ebx
2527 mov ebx, DWORD PTR 8[esp]
2528 push ebp
2529 push esi
2530 push edi
2531 ;
2532 ; Load the data words
2533 mov edi, DWORD PTR [ebx]
2534 mov esi, DWORD PTR 4[ebx]
2535 sub esp, 12
2536 ;
2537 ; IP
2538 rol edi, 4
2539 mov edx, edi
2540 xor edi, esi
2541 and edi, 0f0f0f0f0h
2542 xor edx, edi
2543 xor esi, edi
2544 ;
2545 rol esi, 20
2546 mov edi, esi
2547 xor esi, edx
2548 and esi, 0fff0000fh
2549 xor edi, esi
2550 xor edx, esi
2551 ;
2552 rol edi, 14
2553 mov esi, edi
2554 xor edi, edx
2555 and edi, 033333333h
2556 xor esi, edi
2557 xor edx, edi
2558 ;
2559 rol edx, 22
2560 mov edi, edx
2561 xor edx, esi
2562 and edx, 003fc03fch
2563 xor edi, edx
2564 xor esi, edx
2565 ;
2566 rol edi, 9
2567 mov edx, edi
2568 xor edi, esi
2569 and edi, 0aaaaaaaah
2570 xor edx, edi
2571 xor esi, edi
2572 ;
2573 ror edx, 3
2574 ror esi, 2
2575 mov DWORD PTR 4[ebx],esi
2576 mov eax, DWORD PTR 36[esp]
2577 mov DWORD PTR [ebx],edx
2578 mov edi, DWORD PTR 40[esp]
2579 mov esi, DWORD PTR 44[esp]
2580 mov DWORD PTR 8[esp],1
2581 mov DWORD PTR 4[esp],eax
2582 mov DWORD PTR [esp],ebx
2583 call _des_encrypt2
2584 mov DWORD PTR 8[esp],0
2585 mov DWORD PTR 4[esp],edi
2586 mov DWORD PTR [esp],ebx
2587 call _des_encrypt2
2588 mov DWORD PTR 8[esp],1
2589 mov DWORD PTR 4[esp],esi
2590 mov DWORD PTR [esp],ebx
2591 call _des_encrypt2
2592 add esp, 12
2593 mov edi, DWORD PTR [ebx]
2594 mov esi, DWORD PTR 4[ebx]
2595 ;
2596 ; FP
2597 rol esi, 2
2598 rol edi, 3
2599 mov eax, edi
2600 xor edi, esi
2601 and edi, 0aaaaaaaah
2602 xor eax, edi
2603 xor esi, edi
2604 ;
2605 rol eax, 23
2606 mov edi, eax
2607 xor eax, esi
2608 and eax, 003fc03fch
2609 xor edi, eax
2610 xor esi, eax
2611 ;
2612 rol edi, 10
2613 mov eax, edi
2614 xor edi, esi
2615 and edi, 033333333h
2616 xor eax, edi
2617 xor esi, edi
2618 ;
2619 rol esi, 18
2620 mov edi, esi
2621 xor esi, eax
2622 and esi, 0fff0000fh
2623 xor edi, esi
2624 xor eax, esi
2625 ;
2626 rol edi, 12
2627 mov esi, edi
2628 xor edi, eax
2629 and edi, 0f0f0f0f0h
2630 xor esi, edi
2631 xor eax, edi
2632 ;
2633 ror eax, 4
2634 mov DWORD PTR [ebx],eax
2635 mov DWORD PTR 4[ebx],esi
2636 pop edi
2637 pop esi
2638 pop ebp
2639 pop ebx
2640 ret
2641_des_encrypt3 ENDP
2642_TEXT ENDS
2643_TEXT SEGMENT
2644PUBLIC _des_decrypt3
2645
2646_des_decrypt3 PROC NEAR
2647 push ebx
2648 mov ebx, DWORD PTR 8[esp]
2649 push ebp
2650 push esi
2651 push edi
2652 ;
2653 ; Load the data words
2654 mov edi, DWORD PTR [ebx]
2655 mov esi, DWORD PTR 4[ebx]
2656 sub esp, 12
2657 ;
2658 ; IP
2659 rol edi, 4
2660 mov edx, edi
2661 xor edi, esi
2662 and edi, 0f0f0f0f0h
2663 xor edx, edi
2664 xor esi, edi
2665 ;
2666 rol esi, 20
2667 mov edi, esi
2668 xor esi, edx
2669 and esi, 0fff0000fh
2670 xor edi, esi
2671 xor edx, esi
2672 ;
2673 rol edi, 14
2674 mov esi, edi
2675 xor edi, edx
2676 and edi, 033333333h
2677 xor esi, edi
2678 xor edx, edi
2679 ;
2680 rol edx, 22
2681 mov edi, edx
2682 xor edx, esi
2683 and edx, 003fc03fch
2684 xor edi, edx
2685 xor esi, edx
2686 ;
2687 rol edi, 9
2688 mov edx, edi
2689 xor edi, esi
2690 and edi, 0aaaaaaaah
2691 xor edx, edi
2692 xor esi, edi
2693 ;
2694 ror edx, 3
2695 ror esi, 2
2696 mov DWORD PTR 4[ebx],esi
2697 mov esi, DWORD PTR 36[esp]
2698 mov DWORD PTR [ebx],edx
2699 mov edi, DWORD PTR 40[esp]
2700 mov eax, DWORD PTR 44[esp]
2701 mov DWORD PTR 8[esp],0
2702 mov DWORD PTR 4[esp],eax
2703 mov DWORD PTR [esp],ebx
2704 call _des_encrypt2
2705 mov DWORD PTR 8[esp],1
2706 mov DWORD PTR 4[esp],edi
2707 mov DWORD PTR [esp],ebx
2708 call _des_encrypt2
2709 mov DWORD PTR 8[esp],0
2710 mov DWORD PTR 4[esp],esi
2711 mov DWORD PTR [esp],ebx
2712 call _des_encrypt2
2713 add esp, 12
2714 mov edi, DWORD PTR [ebx]
2715 mov esi, DWORD PTR 4[ebx]
2716 ;
2717 ; FP
2718 rol esi, 2
2719 rol edi, 3
2720 mov eax, edi
2721 xor edi, esi
2722 and edi, 0aaaaaaaah
2723 xor eax, edi
2724 xor esi, edi
2725 ;
2726 rol eax, 23
2727 mov edi, eax
2728 xor eax, esi
2729 and eax, 003fc03fch
2730 xor edi, eax
2731 xor esi, eax
2732 ;
2733 rol edi, 10
2734 mov eax, edi
2735 xor edi, esi
2736 and edi, 033333333h
2737 xor eax, edi
2738 xor esi, edi
2739 ;
2740 rol esi, 18
2741 mov edi, esi
2742 xor esi, eax
2743 and esi, 0fff0000fh
2744 xor edi, esi
2745 xor eax, esi
2746 ;
2747 rol edi, 12
2748 mov esi, edi
2749 xor edi, eax
2750 and edi, 0f0f0f0f0h
2751 xor esi, edi
2752 xor eax, edi
2753 ;
2754 ror eax, 4
2755 mov DWORD PTR [ebx],eax
2756 mov DWORD PTR 4[ebx],esi
2757 pop edi
2758 pop esi
2759 pop ebp
2760 pop ebx
2761 ret
2762_des_decrypt3 ENDP
2763_TEXT ENDS
2764_TEXT SEGMENT
2765PUBLIC _des_ncbc_encrypt
2766
2767_des_ncbc_encrypt PROC NEAR
2768 ;
2769 push ebp
2770 push ebx
2771 push esi
2772 push edi
2773 mov ebp, DWORD PTR 28[esp]
2774 ; getting iv ptr from parameter 4
2775 mov ebx, DWORD PTR 36[esp]
2776 mov esi, DWORD PTR [ebx]
2777 mov edi, DWORD PTR 4[ebx]
2778 push edi
2779 push esi
2780 push edi
2781 push esi
2782 mov ebx, esp
2783 mov esi, DWORD PTR 36[esp]
2784 mov edi, DWORD PTR 40[esp]
2785 ; getting encrypt flag from parameter 5
2786 mov ecx, DWORD PTR 56[esp]
2787 ; get and push parameter 5
2788 push ecx
2789 ; get and push parameter 3
2790 mov eax, DWORD PTR 52[esp]
2791 push eax
2792 push ebx
2793 cmp ecx, 0
2794 jz $L004decrypt
2795 and ebp, 4294967288
2796 mov eax, DWORD PTR 12[esp]
2797 mov ebx, DWORD PTR 16[esp]
2798 jz $L005encrypt_finish
2799L006encrypt_loop:
2800 mov ecx, DWORD PTR [esi]
2801 mov edx, DWORD PTR 4[esi]
2802 xor eax, ecx
2803 xor ebx, edx
2804 mov DWORD PTR 12[esp],eax
2805 mov DWORD PTR 16[esp],ebx
2806 call _des_encrypt
2807 mov eax, DWORD PTR 12[esp]
2808 mov ebx, DWORD PTR 16[esp]
2809 mov DWORD PTR [edi],eax
2810 mov DWORD PTR 4[edi],ebx
2811 add esi, 8
2812 add edi, 8
2813 sub ebp, 8
2814 jnz L006encrypt_loop
2815$L005encrypt_finish:
2816 mov ebp, DWORD PTR 56[esp]
2817 and ebp, 7
2818 jz $L007finish
2819 xor ecx, ecx
2820 xor edx, edx
2821 mov ebp, DWORD PTR $L008cbc_enc_jmp_table[ebp*4]
2822 jmp ebp
2823L009ej7:
2824 mov dh, BYTE PTR 6[esi]
2825 shl edx, 8
2826L010ej6:
2827 mov dh, BYTE PTR 5[esi]
2828L011ej5:
2829 mov dl, BYTE PTR 4[esi]
2830L012ej4:
2831 mov ecx, DWORD PTR [esi]
2832 jmp $L013ejend
2833L014ej3:
2834 mov ch, BYTE PTR 2[esi]
2835 shl ecx, 8
2836L015ej2:
2837 mov ch, BYTE PTR 1[esi]
2838L016ej1:
2839 mov cl, BYTE PTR [esi]
2840$L013ejend:
2841 xor eax, ecx
2842 xor ebx, edx
2843 mov DWORD PTR 12[esp],eax
2844 mov DWORD PTR 16[esp],ebx
2845 call _des_encrypt
2846 mov eax, DWORD PTR 12[esp]
2847 mov ebx, DWORD PTR 16[esp]
2848 mov DWORD PTR [edi],eax
2849 mov DWORD PTR 4[edi],ebx
2850 jmp $L007finish
2851$L004decrypt:
2852 and ebp, 4294967288
2853 mov eax, DWORD PTR 20[esp]
2854 mov ebx, DWORD PTR 24[esp]
2855 jz $L017decrypt_finish
2856L018decrypt_loop:
2857 mov eax, DWORD PTR [esi]
2858 mov ebx, DWORD PTR 4[esi]
2859 mov DWORD PTR 12[esp],eax
2860 mov DWORD PTR 16[esp],ebx
2861 call _des_encrypt
2862 mov eax, DWORD PTR 12[esp]
2863 mov ebx, DWORD PTR 16[esp]
2864 mov ecx, DWORD PTR 20[esp]
2865 mov edx, DWORD PTR 24[esp]
2866 xor ecx, eax
2867 xor edx, ebx
2868 mov eax, DWORD PTR [esi]
2869 mov ebx, DWORD PTR 4[esi]
2870 mov DWORD PTR [edi],ecx
2871 mov DWORD PTR 4[edi],edx
2872 mov DWORD PTR 20[esp],eax
2873 mov DWORD PTR 24[esp],ebx
2874 add esi, 8
2875 add edi, 8
2876 sub ebp, 8
2877 jnz L018decrypt_loop
2878$L017decrypt_finish:
2879 mov ebp, DWORD PTR 56[esp]
2880 and ebp, 7
2881 jz $L007finish
2882 mov eax, DWORD PTR [esi]
2883 mov ebx, DWORD PTR 4[esi]
2884 mov DWORD PTR 12[esp],eax
2885 mov DWORD PTR 16[esp],ebx
2886 call _des_encrypt
2887 mov eax, DWORD PTR 12[esp]
2888 mov ebx, DWORD PTR 16[esp]
2889 mov ecx, DWORD PTR 20[esp]
2890 mov edx, DWORD PTR 24[esp]
2891 xor ecx, eax
2892 xor edx, ebx
2893 mov eax, DWORD PTR [esi]
2894 mov ebx, DWORD PTR 4[esi]
2895L019dj7:
2896 ror edx, 16
2897 mov BYTE PTR 6[edi],dl
2898 shr edx, 16
2899L020dj6:
2900 mov BYTE PTR 5[edi],dh
2901L021dj5:
2902 mov BYTE PTR 4[edi],dl
2903L022dj4:
2904 mov DWORD PTR [edi],ecx
2905 jmp $L023djend
2906L024dj3:
2907 ror ecx, 16
2908 mov BYTE PTR 2[edi],cl
2909 shl ecx, 16
2910L025dj2:
2911 mov BYTE PTR 1[esi],ch
2912L026dj1:
2913 mov BYTE PTR [esi], cl
2914$L023djend:
2915 jmp $L007finish
2916$L007finish:
2917 mov ecx, DWORD PTR 64[esp]
2918 add esp, 28
2919 mov DWORD PTR [ecx],eax
2920 mov DWORD PTR 4[ecx],ebx
2921 pop edi
2922 pop esi
2923 pop ebx
2924 pop ebp
2925 ret
2926$L008cbc_enc_jmp_table:
2927 DD 0
2928 DD L016ej1
2929 DD L015ej2
2930 DD L014ej3
2931 DD L012ej4
2932 DD L011ej5
2933 DD L010ej6
2934 DD L009ej7
2935L027cbc_dec_jmp_table:
2936 DD 0
2937 DD L026dj1
2938 DD L025dj2
2939 DD L024dj3
2940 DD L022dj4
2941 DD L021dj5
2942 DD L020dj6
2943 DD L019dj7
2944_des_ncbc_encrypt ENDP
2945_TEXT ENDS
2946_TEXT SEGMENT
2947PUBLIC _des_ede3_cbc_encrypt
2948
2949_des_ede3_cbc_encrypt PROC NEAR
2950 ;
2951 push ebp
2952 push ebx
2953 push esi
2954 push edi
2955 mov ebp, DWORD PTR 28[esp]
2956 ; getting iv ptr from parameter 6
2957 mov ebx, DWORD PTR 44[esp]
2958 mov esi, DWORD PTR [ebx]
2959 mov edi, DWORD PTR 4[ebx]
2960 push edi
2961 push esi
2962 push edi
2963 push esi
2964 mov ebx, esp
2965 mov esi, DWORD PTR 36[esp]
2966 mov edi, DWORD PTR 40[esp]
2967 ; getting encrypt flag from parameter 7
2968 mov ecx, DWORD PTR 64[esp]
2969 ; get and push parameter 5
2970 mov eax, DWORD PTR 56[esp]
2971 push eax
2972 ; get and push parameter 4
2973 mov eax, DWORD PTR 56[esp]
2974 push eax
2975 ; get and push parameter 3
2976 mov eax, DWORD PTR 56[esp]
2977 push eax
2978 push ebx
2979 cmp ecx, 0
2980 jz $L028decrypt
2981 and ebp, 4294967288
2982 mov eax, DWORD PTR 16[esp]
2983 mov ebx, DWORD PTR 20[esp]
2984 jz $L029encrypt_finish
2985L030encrypt_loop:
2986 mov ecx, DWORD PTR [esi]
2987 mov edx, DWORD PTR 4[esi]
2988 xor eax, ecx
2989 xor ebx, edx
2990 mov DWORD PTR 16[esp],eax
2991 mov DWORD PTR 20[esp],ebx
2992 call _des_encrypt3
2993 mov eax, DWORD PTR 16[esp]
2994 mov ebx, DWORD PTR 20[esp]
2995 mov DWORD PTR [edi],eax
2996 mov DWORD PTR 4[edi],ebx
2997 add esi, 8
2998 add edi, 8
2999 sub ebp, 8
3000 jnz L030encrypt_loop
3001$L029encrypt_finish:
3002 mov ebp, DWORD PTR 60[esp]
3003 and ebp, 7
3004 jz $L031finish
3005 xor ecx, ecx
3006 xor edx, edx
3007 mov ebp, DWORD PTR $L032cbc_enc_jmp_table[ebp*4]
3008 jmp ebp
3009L033ej7:
3010 mov dh, BYTE PTR 6[esi]
3011 shl edx, 8
3012L034ej6:
3013 mov dh, BYTE PTR 5[esi]
3014L035ej5:
3015 mov dl, BYTE PTR 4[esi]
3016L036ej4:
3017 mov ecx, DWORD PTR [esi]
3018 jmp $L037ejend
3019L038ej3:
3020 mov ch, BYTE PTR 2[esi]
3021 shl ecx, 8
3022L039ej2:
3023 mov ch, BYTE PTR 1[esi]
3024L040ej1:
3025 mov cl, BYTE PTR [esi]
3026$L037ejend:
3027 xor eax, ecx
3028 xor ebx, edx
3029 mov DWORD PTR 16[esp],eax
3030 mov DWORD PTR 20[esp],ebx
3031 call _des_encrypt3
3032 mov eax, DWORD PTR 16[esp]
3033 mov ebx, DWORD PTR 20[esp]
3034 mov DWORD PTR [edi],eax
3035 mov DWORD PTR 4[edi],ebx
3036 jmp $L031finish
3037$L028decrypt:
3038 and ebp, 4294967288
3039 mov eax, DWORD PTR 24[esp]
3040 mov ebx, DWORD PTR 28[esp]
3041 jz $L041decrypt_finish
3042L042decrypt_loop:
3043 mov eax, DWORD PTR [esi]
3044 mov ebx, DWORD PTR 4[esi]
3045 mov DWORD PTR 16[esp],eax
3046 mov DWORD PTR 20[esp],ebx
3047 call _des_decrypt3
3048 mov eax, DWORD PTR 16[esp]
3049 mov ebx, DWORD PTR 20[esp]
3050 mov ecx, DWORD PTR 24[esp]
3051 mov edx, DWORD PTR 28[esp]
3052 xor ecx, eax
3053 xor edx, ebx
3054 mov eax, DWORD PTR [esi]
3055 mov ebx, DWORD PTR 4[esi]
3056 mov DWORD PTR [edi],ecx
3057 mov DWORD PTR 4[edi],edx
3058 mov DWORD PTR 24[esp],eax
3059 mov DWORD PTR 28[esp],ebx
3060 add esi, 8
3061 add edi, 8
3062 sub ebp, 8
3063 jnz L042decrypt_loop
3064$L041decrypt_finish:
3065 mov ebp, DWORD PTR 60[esp]
3066 and ebp, 7
3067 jz $L031finish
3068 mov eax, DWORD PTR [esi]
3069 mov ebx, DWORD PTR 4[esi]
3070 mov DWORD PTR 16[esp],eax
3071 mov DWORD PTR 20[esp],ebx
3072 call _des_decrypt3
3073 mov eax, DWORD PTR 16[esp]
3074 mov ebx, DWORD PTR 20[esp]
3075 mov ecx, DWORD PTR 24[esp]
3076 mov edx, DWORD PTR 28[esp]
3077 xor ecx, eax
3078 xor edx, ebx
3079 mov eax, DWORD PTR [esi]
3080 mov ebx, DWORD PTR 4[esi]
3081L043dj7:
3082 ror edx, 16
3083 mov BYTE PTR 6[edi],dl
3084 shr edx, 16
3085L044dj6:
3086 mov BYTE PTR 5[edi],dh
3087L045dj5:
3088 mov BYTE PTR 4[edi],dl
3089L046dj4:
3090 mov DWORD PTR [edi],ecx
3091 jmp $L047djend
3092L048dj3:
3093 ror ecx, 16
3094 mov BYTE PTR 2[edi],cl
3095 shl ecx, 16
3096L049dj2:
3097 mov BYTE PTR 1[esi],ch
3098L050dj1:
3099 mov BYTE PTR [esi], cl
3100$L047djend:
3101 jmp $L031finish
3102$L031finish:
3103 mov ecx, DWORD PTR 76[esp]
3104 add esp, 32
3105 mov DWORD PTR [ecx],eax
3106 mov DWORD PTR 4[ecx],ebx
3107 pop edi
3108 pop esi
3109 pop ebx
3110 pop ebp
3111 ret
3112$L032cbc_enc_jmp_table:
3113 DD 0
3114 DD L040ej1
3115 DD L039ej2
3116 DD L038ej3
3117 DD L036ej4
3118 DD L035ej5
3119 DD L034ej6
3120 DD L033ej7
3121L051cbc_dec_jmp_table:
3122 DD 0
3123 DD L050dj1
3124 DD L049dj2
3125 DD L048dj3
3126 DD L046dj4
3127 DD L045dj5
3128 DD L044dj6
3129 DD L043dj7
3130_des_ede3_cbc_encrypt ENDP
3131_TEXT ENDS
3132END
diff --git a/src/lib/libcrypto/des/asm/dx86unix.cpp b/src/lib/libcrypto/des/asm/dx86unix.cpp
new file mode 100644
index 0000000000..6fca9afa16
--- /dev/null
+++ b/src/lib/libcrypto/des/asm/dx86unix.cpp
@@ -0,0 +1,3202 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define des_SPtrans _des_SPtrans
13#define des_encrypt _des_encrypt
14#define des_encrypt2 _des_encrypt2
15#define des_encrypt3 _des_encrypt3
16#define des_decrypt3 _des_decrypt3
17#define des_ncbc_encrypt _des_ncbc_encrypt
18#define des_ede3_cbc_encrypt _des_ede3_cbc_encrypt
19
20#endif
21
22#ifdef OUT
23#define OK 1
24#define ALIGN 4
25#endif
26
27#ifdef BSDI
28#define OK 1
29#define ALIGN 4
30#undef SIZE
31#undef TYPE
32#define SIZE(a,b)
33#define TYPE(a,b)
34#endif
35
36#if defined(ELF) || defined(SOL)
37#define OK 1
38#define ALIGN 16
39#endif
40
41#ifndef OK
42You need to define one of
43ELF - elf systems - linux-elf, NetBSD and DG-UX
44OUT - a.out systems - linux-a.out and FreeBSD
45SOL - solaris systems, which are elf with strange comment lines
46BSDI - a.out with a very primative version of as.
47#endif
48
49/* Let the Assembler begin :-) */
50 /* Don't even think of reading this code */
51 /* It was automatically generated by des-586.pl */
52 /* Which is a perl program used to generate the x86 assember for */
53 /* any of elf, a.out, BSDI,Win32, or Solaris */
54 /* eric <eay@cryptsoft.com> */
55
56 .file "des-586.s"
57 .version "01.01"
58gcc2_compiled.:
59.text
60 .align ALIGN
61.globl des_encrypt
62 TYPE(des_encrypt,@function)
63des_encrypt:
64 pushl %esi
65 pushl %edi
66
67 /* Load the 2 words */
68 movl 12(%esp), %esi
69 xorl %ecx, %ecx
70 pushl %ebx
71 pushl %ebp
72 movl (%esi), %eax
73 movl 28(%esp), %ebx
74 movl 4(%esi), %edi
75
76 /* IP */
77 roll $4, %eax
78 movl %eax, %esi
79 xorl %edi, %eax
80 andl $0xf0f0f0f0, %eax
81 xorl %eax, %esi
82 xorl %eax, %edi
83
84 roll $20, %edi
85 movl %edi, %eax
86 xorl %esi, %edi
87 andl $0xfff0000f, %edi
88 xorl %edi, %eax
89 xorl %edi, %esi
90
91 roll $14, %eax
92 movl %eax, %edi
93 xorl %esi, %eax
94 andl $0x33333333, %eax
95 xorl %eax, %edi
96 xorl %eax, %esi
97
98 roll $22, %esi
99 movl %esi, %eax
100 xorl %edi, %esi
101 andl $0x03fc03fc, %esi
102 xorl %esi, %eax
103 xorl %esi, %edi
104
105 roll $9, %eax
106 movl %eax, %esi
107 xorl %edi, %eax
108 andl $0xaaaaaaaa, %eax
109 xorl %eax, %esi
110 xorl %eax, %edi
111
112.byte 209
113.byte 199 /* roll $1 %edi */
114 movl 24(%esp), %ebp
115 cmpl $0, %ebx
116 je .L000start_decrypt
117
118 /* Round 0 */
119 movl (%ebp), %eax
120 xorl %ebx, %ebx
121 movl 4(%ebp), %edx
122 xorl %esi, %eax
123 xorl %esi, %edx
124 andl $0xfcfcfcfc, %eax
125 andl $0xcfcfcfcf, %edx
126 movb %al, %bl
127 movb %ah, %cl
128 rorl $4, %edx
129 movl des_SPtrans(%ebx),%ebp
130 movb %dl, %bl
131 xorl %ebp, %edi
132 movl 0x200+des_SPtrans(%ecx),%ebp
133 xorl %ebp, %edi
134 movb %dh, %cl
135 shrl $16, %eax
136 movl 0x100+des_SPtrans(%ebx),%ebp
137 xorl %ebp, %edi
138 movb %ah, %bl
139 shrl $16, %edx
140 movl 0x300+des_SPtrans(%ecx),%ebp
141 xorl %ebp, %edi
142 movl 24(%esp), %ebp
143 movb %dh, %cl
144 andl $0xff, %eax
145 andl $0xff, %edx
146 movl 0x600+des_SPtrans(%ebx),%ebx
147 xorl %ebx, %edi
148 movl 0x700+des_SPtrans(%ecx),%ebx
149 xorl %ebx, %edi
150 movl 0x400+des_SPtrans(%eax),%ebx
151 xorl %ebx, %edi
152 movl 0x500+des_SPtrans(%edx),%ebx
153 xorl %ebx, %edi
154
155 /* Round 1 */
156 movl 8(%ebp), %eax
157 xorl %ebx, %ebx
158 movl 12(%ebp), %edx
159 xorl %edi, %eax
160 xorl %edi, %edx
161 andl $0xfcfcfcfc, %eax
162 andl $0xcfcfcfcf, %edx
163 movb %al, %bl
164 movb %ah, %cl
165 rorl $4, %edx
166 movl des_SPtrans(%ebx),%ebp
167 movb %dl, %bl
168 xorl %ebp, %esi
169 movl 0x200+des_SPtrans(%ecx),%ebp
170 xorl %ebp, %esi
171 movb %dh, %cl
172 shrl $16, %eax
173 movl 0x100+des_SPtrans(%ebx),%ebp
174 xorl %ebp, %esi
175 movb %ah, %bl
176 shrl $16, %edx
177 movl 0x300+des_SPtrans(%ecx),%ebp
178 xorl %ebp, %esi
179 movl 24(%esp), %ebp
180 movb %dh, %cl
181 andl $0xff, %eax
182 andl $0xff, %edx
183 movl 0x600+des_SPtrans(%ebx),%ebx
184 xorl %ebx, %esi
185 movl 0x700+des_SPtrans(%ecx),%ebx
186 xorl %ebx, %esi
187 movl 0x400+des_SPtrans(%eax),%ebx
188 xorl %ebx, %esi
189 movl 0x500+des_SPtrans(%edx),%ebx
190 xorl %ebx, %esi
191
192 /* Round 2 */
193 movl 16(%ebp), %eax
194 xorl %ebx, %ebx
195 movl 20(%ebp), %edx
196 xorl %esi, %eax
197 xorl %esi, %edx
198 andl $0xfcfcfcfc, %eax
199 andl $0xcfcfcfcf, %edx
200 movb %al, %bl
201 movb %ah, %cl
202 rorl $4, %edx
203 movl des_SPtrans(%ebx),%ebp
204 movb %dl, %bl
205 xorl %ebp, %edi
206 movl 0x200+des_SPtrans(%ecx),%ebp
207 xorl %ebp, %edi
208 movb %dh, %cl
209 shrl $16, %eax
210 movl 0x100+des_SPtrans(%ebx),%ebp
211 xorl %ebp, %edi
212 movb %ah, %bl
213 shrl $16, %edx
214 movl 0x300+des_SPtrans(%ecx),%ebp
215 xorl %ebp, %edi
216 movl 24(%esp), %ebp
217 movb %dh, %cl
218 andl $0xff, %eax
219 andl $0xff, %edx
220 movl 0x600+des_SPtrans(%ebx),%ebx
221 xorl %ebx, %edi
222 movl 0x700+des_SPtrans(%ecx),%ebx
223 xorl %ebx, %edi
224 movl 0x400+des_SPtrans(%eax),%ebx
225 xorl %ebx, %edi
226 movl 0x500+des_SPtrans(%edx),%ebx
227 xorl %ebx, %edi
228
229 /* Round 3 */
230 movl 24(%ebp), %eax
231 xorl %ebx, %ebx
232 movl 28(%ebp), %edx
233 xorl %edi, %eax
234 xorl %edi, %edx
235 andl $0xfcfcfcfc, %eax
236 andl $0xcfcfcfcf, %edx
237 movb %al, %bl
238 movb %ah, %cl
239 rorl $4, %edx
240 movl des_SPtrans(%ebx),%ebp
241 movb %dl, %bl
242 xorl %ebp, %esi
243 movl 0x200+des_SPtrans(%ecx),%ebp
244 xorl %ebp, %esi
245 movb %dh, %cl
246 shrl $16, %eax
247 movl 0x100+des_SPtrans(%ebx),%ebp
248 xorl %ebp, %esi
249 movb %ah, %bl
250 shrl $16, %edx
251 movl 0x300+des_SPtrans(%ecx),%ebp
252 xorl %ebp, %esi
253 movl 24(%esp), %ebp
254 movb %dh, %cl
255 andl $0xff, %eax
256 andl $0xff, %edx
257 movl 0x600+des_SPtrans(%ebx),%ebx
258 xorl %ebx, %esi
259 movl 0x700+des_SPtrans(%ecx),%ebx
260 xorl %ebx, %esi
261 movl 0x400+des_SPtrans(%eax),%ebx
262 xorl %ebx, %esi
263 movl 0x500+des_SPtrans(%edx),%ebx
264 xorl %ebx, %esi
265
266 /* Round 4 */
267 movl 32(%ebp), %eax
268 xorl %ebx, %ebx
269 movl 36(%ebp), %edx
270 xorl %esi, %eax
271 xorl %esi, %edx
272 andl $0xfcfcfcfc, %eax
273 andl $0xcfcfcfcf, %edx
274 movb %al, %bl
275 movb %ah, %cl
276 rorl $4, %edx
277 movl des_SPtrans(%ebx),%ebp
278 movb %dl, %bl
279 xorl %ebp, %edi
280 movl 0x200+des_SPtrans(%ecx),%ebp
281 xorl %ebp, %edi
282 movb %dh, %cl
283 shrl $16, %eax
284 movl 0x100+des_SPtrans(%ebx),%ebp
285 xorl %ebp, %edi
286 movb %ah, %bl
287 shrl $16, %edx
288 movl 0x300+des_SPtrans(%ecx),%ebp
289 xorl %ebp, %edi
290 movl 24(%esp), %ebp
291 movb %dh, %cl
292 andl $0xff, %eax
293 andl $0xff, %edx
294 movl 0x600+des_SPtrans(%ebx),%ebx
295 xorl %ebx, %edi
296 movl 0x700+des_SPtrans(%ecx),%ebx
297 xorl %ebx, %edi
298 movl 0x400+des_SPtrans(%eax),%ebx
299 xorl %ebx, %edi
300 movl 0x500+des_SPtrans(%edx),%ebx
301 xorl %ebx, %edi
302
303 /* Round 5 */
304 movl 40(%ebp), %eax
305 xorl %ebx, %ebx
306 movl 44(%ebp), %edx
307 xorl %edi, %eax
308 xorl %edi, %edx
309 andl $0xfcfcfcfc, %eax
310 andl $0xcfcfcfcf, %edx
311 movb %al, %bl
312 movb %ah, %cl
313 rorl $4, %edx
314 movl des_SPtrans(%ebx),%ebp
315 movb %dl, %bl
316 xorl %ebp, %esi
317 movl 0x200+des_SPtrans(%ecx),%ebp
318 xorl %ebp, %esi
319 movb %dh, %cl
320 shrl $16, %eax
321 movl 0x100+des_SPtrans(%ebx),%ebp
322 xorl %ebp, %esi
323 movb %ah, %bl
324 shrl $16, %edx
325 movl 0x300+des_SPtrans(%ecx),%ebp
326 xorl %ebp, %esi
327 movl 24(%esp), %ebp
328 movb %dh, %cl
329 andl $0xff, %eax
330 andl $0xff, %edx
331 movl 0x600+des_SPtrans(%ebx),%ebx
332 xorl %ebx, %esi
333 movl 0x700+des_SPtrans(%ecx),%ebx
334 xorl %ebx, %esi
335 movl 0x400+des_SPtrans(%eax),%ebx
336 xorl %ebx, %esi
337 movl 0x500+des_SPtrans(%edx),%ebx
338 xorl %ebx, %esi
339
340 /* Round 6 */
341 movl 48(%ebp), %eax
342 xorl %ebx, %ebx
343 movl 52(%ebp), %edx
344 xorl %esi, %eax
345 xorl %esi, %edx
346 andl $0xfcfcfcfc, %eax
347 andl $0xcfcfcfcf, %edx
348 movb %al, %bl
349 movb %ah, %cl
350 rorl $4, %edx
351 movl des_SPtrans(%ebx),%ebp
352 movb %dl, %bl
353 xorl %ebp, %edi
354 movl 0x200+des_SPtrans(%ecx),%ebp
355 xorl %ebp, %edi
356 movb %dh, %cl
357 shrl $16, %eax
358 movl 0x100+des_SPtrans(%ebx),%ebp
359 xorl %ebp, %edi
360 movb %ah, %bl
361 shrl $16, %edx
362 movl 0x300+des_SPtrans(%ecx),%ebp
363 xorl %ebp, %edi
364 movl 24(%esp), %ebp
365 movb %dh, %cl
366 andl $0xff, %eax
367 andl $0xff, %edx
368 movl 0x600+des_SPtrans(%ebx),%ebx
369 xorl %ebx, %edi
370 movl 0x700+des_SPtrans(%ecx),%ebx
371 xorl %ebx, %edi
372 movl 0x400+des_SPtrans(%eax),%ebx
373 xorl %ebx, %edi
374 movl 0x500+des_SPtrans(%edx),%ebx
375 xorl %ebx, %edi
376
377 /* Round 7 */
378 movl 56(%ebp), %eax
379 xorl %ebx, %ebx
380 movl 60(%ebp), %edx
381 xorl %edi, %eax
382 xorl %edi, %edx
383 andl $0xfcfcfcfc, %eax
384 andl $0xcfcfcfcf, %edx
385 movb %al, %bl
386 movb %ah, %cl
387 rorl $4, %edx
388 movl des_SPtrans(%ebx),%ebp
389 movb %dl, %bl
390 xorl %ebp, %esi
391 movl 0x200+des_SPtrans(%ecx),%ebp
392 xorl %ebp, %esi
393 movb %dh, %cl
394 shrl $16, %eax
395 movl 0x100+des_SPtrans(%ebx),%ebp
396 xorl %ebp, %esi
397 movb %ah, %bl
398 shrl $16, %edx
399 movl 0x300+des_SPtrans(%ecx),%ebp
400 xorl %ebp, %esi
401 movl 24(%esp), %ebp
402 movb %dh, %cl
403 andl $0xff, %eax
404 andl $0xff, %edx
405 movl 0x600+des_SPtrans(%ebx),%ebx
406 xorl %ebx, %esi
407 movl 0x700+des_SPtrans(%ecx),%ebx
408 xorl %ebx, %esi
409 movl 0x400+des_SPtrans(%eax),%ebx
410 xorl %ebx, %esi
411 movl 0x500+des_SPtrans(%edx),%ebx
412 xorl %ebx, %esi
413
414 /* Round 8 */
415 movl 64(%ebp), %eax
416 xorl %ebx, %ebx
417 movl 68(%ebp), %edx
418 xorl %esi, %eax
419 xorl %esi, %edx
420 andl $0xfcfcfcfc, %eax
421 andl $0xcfcfcfcf, %edx
422 movb %al, %bl
423 movb %ah, %cl
424 rorl $4, %edx
425 movl des_SPtrans(%ebx),%ebp
426 movb %dl, %bl
427 xorl %ebp, %edi
428 movl 0x200+des_SPtrans(%ecx),%ebp
429 xorl %ebp, %edi
430 movb %dh, %cl
431 shrl $16, %eax
432 movl 0x100+des_SPtrans(%ebx),%ebp
433 xorl %ebp, %edi
434 movb %ah, %bl
435 shrl $16, %edx
436 movl 0x300+des_SPtrans(%ecx),%ebp
437 xorl %ebp, %edi
438 movl 24(%esp), %ebp
439 movb %dh, %cl
440 andl $0xff, %eax
441 andl $0xff, %edx
442 movl 0x600+des_SPtrans(%ebx),%ebx
443 xorl %ebx, %edi
444 movl 0x700+des_SPtrans(%ecx),%ebx
445 xorl %ebx, %edi
446 movl 0x400+des_SPtrans(%eax),%ebx
447 xorl %ebx, %edi
448 movl 0x500+des_SPtrans(%edx),%ebx
449 xorl %ebx, %edi
450
451 /* Round 9 */
452 movl 72(%ebp), %eax
453 xorl %ebx, %ebx
454 movl 76(%ebp), %edx
455 xorl %edi, %eax
456 xorl %edi, %edx
457 andl $0xfcfcfcfc, %eax
458 andl $0xcfcfcfcf, %edx
459 movb %al, %bl
460 movb %ah, %cl
461 rorl $4, %edx
462 movl des_SPtrans(%ebx),%ebp
463 movb %dl, %bl
464 xorl %ebp, %esi
465 movl 0x200+des_SPtrans(%ecx),%ebp
466 xorl %ebp, %esi
467 movb %dh, %cl
468 shrl $16, %eax
469 movl 0x100+des_SPtrans(%ebx),%ebp
470 xorl %ebp, %esi
471 movb %ah, %bl
472 shrl $16, %edx
473 movl 0x300+des_SPtrans(%ecx),%ebp
474 xorl %ebp, %esi
475 movl 24(%esp), %ebp
476 movb %dh, %cl
477 andl $0xff, %eax
478 andl $0xff, %edx
479 movl 0x600+des_SPtrans(%ebx),%ebx
480 xorl %ebx, %esi
481 movl 0x700+des_SPtrans(%ecx),%ebx
482 xorl %ebx, %esi
483 movl 0x400+des_SPtrans(%eax),%ebx
484 xorl %ebx, %esi
485 movl 0x500+des_SPtrans(%edx),%ebx
486 xorl %ebx, %esi
487
488 /* Round 10 */
489 movl 80(%ebp), %eax
490 xorl %ebx, %ebx
491 movl 84(%ebp), %edx
492 xorl %esi, %eax
493 xorl %esi, %edx
494 andl $0xfcfcfcfc, %eax
495 andl $0xcfcfcfcf, %edx
496 movb %al, %bl
497 movb %ah, %cl
498 rorl $4, %edx
499 movl des_SPtrans(%ebx),%ebp
500 movb %dl, %bl
501 xorl %ebp, %edi
502 movl 0x200+des_SPtrans(%ecx),%ebp
503 xorl %ebp, %edi
504 movb %dh, %cl
505 shrl $16, %eax
506 movl 0x100+des_SPtrans(%ebx),%ebp
507 xorl %ebp, %edi
508 movb %ah, %bl
509 shrl $16, %edx
510 movl 0x300+des_SPtrans(%ecx),%ebp
511 xorl %ebp, %edi
512 movl 24(%esp), %ebp
513 movb %dh, %cl
514 andl $0xff, %eax
515 andl $0xff, %edx
516 movl 0x600+des_SPtrans(%ebx),%ebx
517 xorl %ebx, %edi
518 movl 0x700+des_SPtrans(%ecx),%ebx
519 xorl %ebx, %edi
520 movl 0x400+des_SPtrans(%eax),%ebx
521 xorl %ebx, %edi
522 movl 0x500+des_SPtrans(%edx),%ebx
523 xorl %ebx, %edi
524
525 /* Round 11 */
526 movl 88(%ebp), %eax
527 xorl %ebx, %ebx
528 movl 92(%ebp), %edx
529 xorl %edi, %eax
530 xorl %edi, %edx
531 andl $0xfcfcfcfc, %eax
532 andl $0xcfcfcfcf, %edx
533 movb %al, %bl
534 movb %ah, %cl
535 rorl $4, %edx
536 movl des_SPtrans(%ebx),%ebp
537 movb %dl, %bl
538 xorl %ebp, %esi
539 movl 0x200+des_SPtrans(%ecx),%ebp
540 xorl %ebp, %esi
541 movb %dh, %cl
542 shrl $16, %eax
543 movl 0x100+des_SPtrans(%ebx),%ebp
544 xorl %ebp, %esi
545 movb %ah, %bl
546 shrl $16, %edx
547 movl 0x300+des_SPtrans(%ecx),%ebp
548 xorl %ebp, %esi
549 movl 24(%esp), %ebp
550 movb %dh, %cl
551 andl $0xff, %eax
552 andl $0xff, %edx
553 movl 0x600+des_SPtrans(%ebx),%ebx
554 xorl %ebx, %esi
555 movl 0x700+des_SPtrans(%ecx),%ebx
556 xorl %ebx, %esi
557 movl 0x400+des_SPtrans(%eax),%ebx
558 xorl %ebx, %esi
559 movl 0x500+des_SPtrans(%edx),%ebx
560 xorl %ebx, %esi
561
562 /* Round 12 */
563 movl 96(%ebp), %eax
564 xorl %ebx, %ebx
565 movl 100(%ebp), %edx
566 xorl %esi, %eax
567 xorl %esi, %edx
568 andl $0xfcfcfcfc, %eax
569 andl $0xcfcfcfcf, %edx
570 movb %al, %bl
571 movb %ah, %cl
572 rorl $4, %edx
573 movl des_SPtrans(%ebx),%ebp
574 movb %dl, %bl
575 xorl %ebp, %edi
576 movl 0x200+des_SPtrans(%ecx),%ebp
577 xorl %ebp, %edi
578 movb %dh, %cl
579 shrl $16, %eax
580 movl 0x100+des_SPtrans(%ebx),%ebp
581 xorl %ebp, %edi
582 movb %ah, %bl
583 shrl $16, %edx
584 movl 0x300+des_SPtrans(%ecx),%ebp
585 xorl %ebp, %edi
586 movl 24(%esp), %ebp
587 movb %dh, %cl
588 andl $0xff, %eax
589 andl $0xff, %edx
590 movl 0x600+des_SPtrans(%ebx),%ebx
591 xorl %ebx, %edi
592 movl 0x700+des_SPtrans(%ecx),%ebx
593 xorl %ebx, %edi
594 movl 0x400+des_SPtrans(%eax),%ebx
595 xorl %ebx, %edi
596 movl 0x500+des_SPtrans(%edx),%ebx
597 xorl %ebx, %edi
598
599 /* Round 13 */
600 movl 104(%ebp), %eax
601 xorl %ebx, %ebx
602 movl 108(%ebp), %edx
603 xorl %edi, %eax
604 xorl %edi, %edx
605 andl $0xfcfcfcfc, %eax
606 andl $0xcfcfcfcf, %edx
607 movb %al, %bl
608 movb %ah, %cl
609 rorl $4, %edx
610 movl des_SPtrans(%ebx),%ebp
611 movb %dl, %bl
612 xorl %ebp, %esi
613 movl 0x200+des_SPtrans(%ecx),%ebp
614 xorl %ebp, %esi
615 movb %dh, %cl
616 shrl $16, %eax
617 movl 0x100+des_SPtrans(%ebx),%ebp
618 xorl %ebp, %esi
619 movb %ah, %bl
620 shrl $16, %edx
621 movl 0x300+des_SPtrans(%ecx),%ebp
622 xorl %ebp, %esi
623 movl 24(%esp), %ebp
624 movb %dh, %cl
625 andl $0xff, %eax
626 andl $0xff, %edx
627 movl 0x600+des_SPtrans(%ebx),%ebx
628 xorl %ebx, %esi
629 movl 0x700+des_SPtrans(%ecx),%ebx
630 xorl %ebx, %esi
631 movl 0x400+des_SPtrans(%eax),%ebx
632 xorl %ebx, %esi
633 movl 0x500+des_SPtrans(%edx),%ebx
634 xorl %ebx, %esi
635
636 /* Round 14 */
637 movl 112(%ebp), %eax
638 xorl %ebx, %ebx
639 movl 116(%ebp), %edx
640 xorl %esi, %eax
641 xorl %esi, %edx
642 andl $0xfcfcfcfc, %eax
643 andl $0xcfcfcfcf, %edx
644 movb %al, %bl
645 movb %ah, %cl
646 rorl $4, %edx
647 movl des_SPtrans(%ebx),%ebp
648 movb %dl, %bl
649 xorl %ebp, %edi
650 movl 0x200+des_SPtrans(%ecx),%ebp
651 xorl %ebp, %edi
652 movb %dh, %cl
653 shrl $16, %eax
654 movl 0x100+des_SPtrans(%ebx),%ebp
655 xorl %ebp, %edi
656 movb %ah, %bl
657 shrl $16, %edx
658 movl 0x300+des_SPtrans(%ecx),%ebp
659 xorl %ebp, %edi
660 movl 24(%esp), %ebp
661 movb %dh, %cl
662 andl $0xff, %eax
663 andl $0xff, %edx
664 movl 0x600+des_SPtrans(%ebx),%ebx
665 xorl %ebx, %edi
666 movl 0x700+des_SPtrans(%ecx),%ebx
667 xorl %ebx, %edi
668 movl 0x400+des_SPtrans(%eax),%ebx
669 xorl %ebx, %edi
670 movl 0x500+des_SPtrans(%edx),%ebx
671 xorl %ebx, %edi
672
673 /* Round 15 */
674 movl 120(%ebp), %eax
675 xorl %ebx, %ebx
676 movl 124(%ebp), %edx
677 xorl %edi, %eax
678 xorl %edi, %edx
679 andl $0xfcfcfcfc, %eax
680 andl $0xcfcfcfcf, %edx
681 movb %al, %bl
682 movb %ah, %cl
683 rorl $4, %edx
684 movl des_SPtrans(%ebx),%ebp
685 movb %dl, %bl
686 xorl %ebp, %esi
687 movl 0x200+des_SPtrans(%ecx),%ebp
688 xorl %ebp, %esi
689 movb %dh, %cl
690 shrl $16, %eax
691 movl 0x100+des_SPtrans(%ebx),%ebp
692 xorl %ebp, %esi
693 movb %ah, %bl
694 shrl $16, %edx
695 movl 0x300+des_SPtrans(%ecx),%ebp
696 xorl %ebp, %esi
697 movl 24(%esp), %ebp
698 movb %dh, %cl
699 andl $0xff, %eax
700 andl $0xff, %edx
701 movl 0x600+des_SPtrans(%ebx),%ebx
702 xorl %ebx, %esi
703 movl 0x700+des_SPtrans(%ecx),%ebx
704 xorl %ebx, %esi
705 movl 0x400+des_SPtrans(%eax),%ebx
706 xorl %ebx, %esi
707 movl 0x500+des_SPtrans(%edx),%ebx
708 xorl %ebx, %esi
709 jmp .L001end
710.L000start_decrypt:
711
712 /* Round 15 */
713 movl 120(%ebp), %eax
714 xorl %ebx, %ebx
715 movl 124(%ebp), %edx
716 xorl %esi, %eax
717 xorl %esi, %edx
718 andl $0xfcfcfcfc, %eax
719 andl $0xcfcfcfcf, %edx
720 movb %al, %bl
721 movb %ah, %cl
722 rorl $4, %edx
723 movl des_SPtrans(%ebx),%ebp
724 movb %dl, %bl
725 xorl %ebp, %edi
726 movl 0x200+des_SPtrans(%ecx),%ebp
727 xorl %ebp, %edi
728 movb %dh, %cl
729 shrl $16, %eax
730 movl 0x100+des_SPtrans(%ebx),%ebp
731 xorl %ebp, %edi
732 movb %ah, %bl
733 shrl $16, %edx
734 movl 0x300+des_SPtrans(%ecx),%ebp
735 xorl %ebp, %edi
736 movl 24(%esp), %ebp
737 movb %dh, %cl
738 andl $0xff, %eax
739 andl $0xff, %edx
740 movl 0x600+des_SPtrans(%ebx),%ebx
741 xorl %ebx, %edi
742 movl 0x700+des_SPtrans(%ecx),%ebx
743 xorl %ebx, %edi
744 movl 0x400+des_SPtrans(%eax),%ebx
745 xorl %ebx, %edi
746 movl 0x500+des_SPtrans(%edx),%ebx
747 xorl %ebx, %edi
748
749 /* Round 14 */
750 movl 112(%ebp), %eax
751 xorl %ebx, %ebx
752 movl 116(%ebp), %edx
753 xorl %edi, %eax
754 xorl %edi, %edx
755 andl $0xfcfcfcfc, %eax
756 andl $0xcfcfcfcf, %edx
757 movb %al, %bl
758 movb %ah, %cl
759 rorl $4, %edx
760 movl des_SPtrans(%ebx),%ebp
761 movb %dl, %bl
762 xorl %ebp, %esi
763 movl 0x200+des_SPtrans(%ecx),%ebp
764 xorl %ebp, %esi
765 movb %dh, %cl
766 shrl $16, %eax
767 movl 0x100+des_SPtrans(%ebx),%ebp
768 xorl %ebp, %esi
769 movb %ah, %bl
770 shrl $16, %edx
771 movl 0x300+des_SPtrans(%ecx),%ebp
772 xorl %ebp, %esi
773 movl 24(%esp), %ebp
774 movb %dh, %cl
775 andl $0xff, %eax
776 andl $0xff, %edx
777 movl 0x600+des_SPtrans(%ebx),%ebx
778 xorl %ebx, %esi
779 movl 0x700+des_SPtrans(%ecx),%ebx
780 xorl %ebx, %esi
781 movl 0x400+des_SPtrans(%eax),%ebx
782 xorl %ebx, %esi
783 movl 0x500+des_SPtrans(%edx),%ebx
784 xorl %ebx, %esi
785
786 /* Round 13 */
787 movl 104(%ebp), %eax
788 xorl %ebx, %ebx
789 movl 108(%ebp), %edx
790 xorl %esi, %eax
791 xorl %esi, %edx
792 andl $0xfcfcfcfc, %eax
793 andl $0xcfcfcfcf, %edx
794 movb %al, %bl
795 movb %ah, %cl
796 rorl $4, %edx
797 movl des_SPtrans(%ebx),%ebp
798 movb %dl, %bl
799 xorl %ebp, %edi
800 movl 0x200+des_SPtrans(%ecx),%ebp
801 xorl %ebp, %edi
802 movb %dh, %cl
803 shrl $16, %eax
804 movl 0x100+des_SPtrans(%ebx),%ebp
805 xorl %ebp, %edi
806 movb %ah, %bl
807 shrl $16, %edx
808 movl 0x300+des_SPtrans(%ecx),%ebp
809 xorl %ebp, %edi
810 movl 24(%esp), %ebp
811 movb %dh, %cl
812 andl $0xff, %eax
813 andl $0xff, %edx
814 movl 0x600+des_SPtrans(%ebx),%ebx
815 xorl %ebx, %edi
816 movl 0x700+des_SPtrans(%ecx),%ebx
817 xorl %ebx, %edi
818 movl 0x400+des_SPtrans(%eax),%ebx
819 xorl %ebx, %edi
820 movl 0x500+des_SPtrans(%edx),%ebx
821 xorl %ebx, %edi
822
823 /* Round 12 */
824 movl 96(%ebp), %eax
825 xorl %ebx, %ebx
826 movl 100(%ebp), %edx
827 xorl %edi, %eax
828 xorl %edi, %edx
829 andl $0xfcfcfcfc, %eax
830 andl $0xcfcfcfcf, %edx
831 movb %al, %bl
832 movb %ah, %cl
833 rorl $4, %edx
834 movl des_SPtrans(%ebx),%ebp
835 movb %dl, %bl
836 xorl %ebp, %esi
837 movl 0x200+des_SPtrans(%ecx),%ebp
838 xorl %ebp, %esi
839 movb %dh, %cl
840 shrl $16, %eax
841 movl 0x100+des_SPtrans(%ebx),%ebp
842 xorl %ebp, %esi
843 movb %ah, %bl
844 shrl $16, %edx
845 movl 0x300+des_SPtrans(%ecx),%ebp
846 xorl %ebp, %esi
847 movl 24(%esp), %ebp
848 movb %dh, %cl
849 andl $0xff, %eax
850 andl $0xff, %edx
851 movl 0x600+des_SPtrans(%ebx),%ebx
852 xorl %ebx, %esi
853 movl 0x700+des_SPtrans(%ecx),%ebx
854 xorl %ebx, %esi
855 movl 0x400+des_SPtrans(%eax),%ebx
856 xorl %ebx, %esi
857 movl 0x500+des_SPtrans(%edx),%ebx
858 xorl %ebx, %esi
859
860 /* Round 11 */
861 movl 88(%ebp), %eax
862 xorl %ebx, %ebx
863 movl 92(%ebp), %edx
864 xorl %esi, %eax
865 xorl %esi, %edx
866 andl $0xfcfcfcfc, %eax
867 andl $0xcfcfcfcf, %edx
868 movb %al, %bl
869 movb %ah, %cl
870 rorl $4, %edx
871 movl des_SPtrans(%ebx),%ebp
872 movb %dl, %bl
873 xorl %ebp, %edi
874 movl 0x200+des_SPtrans(%ecx),%ebp
875 xorl %ebp, %edi
876 movb %dh, %cl
877 shrl $16, %eax
878 movl 0x100+des_SPtrans(%ebx),%ebp
879 xorl %ebp, %edi
880 movb %ah, %bl
881 shrl $16, %edx
882 movl 0x300+des_SPtrans(%ecx),%ebp
883 xorl %ebp, %edi
884 movl 24(%esp), %ebp
885 movb %dh, %cl
886 andl $0xff, %eax
887 andl $0xff, %edx
888 movl 0x600+des_SPtrans(%ebx),%ebx
889 xorl %ebx, %edi
890 movl 0x700+des_SPtrans(%ecx),%ebx
891 xorl %ebx, %edi
892 movl 0x400+des_SPtrans(%eax),%ebx
893 xorl %ebx, %edi
894 movl 0x500+des_SPtrans(%edx),%ebx
895 xorl %ebx, %edi
896
897 /* Round 10 */
898 movl 80(%ebp), %eax
899 xorl %ebx, %ebx
900 movl 84(%ebp), %edx
901 xorl %edi, %eax
902 xorl %edi, %edx
903 andl $0xfcfcfcfc, %eax
904 andl $0xcfcfcfcf, %edx
905 movb %al, %bl
906 movb %ah, %cl
907 rorl $4, %edx
908 movl des_SPtrans(%ebx),%ebp
909 movb %dl, %bl
910 xorl %ebp, %esi
911 movl 0x200+des_SPtrans(%ecx),%ebp
912 xorl %ebp, %esi
913 movb %dh, %cl
914 shrl $16, %eax
915 movl 0x100+des_SPtrans(%ebx),%ebp
916 xorl %ebp, %esi
917 movb %ah, %bl
918 shrl $16, %edx
919 movl 0x300+des_SPtrans(%ecx),%ebp
920 xorl %ebp, %esi
921 movl 24(%esp), %ebp
922 movb %dh, %cl
923 andl $0xff, %eax
924 andl $0xff, %edx
925 movl 0x600+des_SPtrans(%ebx),%ebx
926 xorl %ebx, %esi
927 movl 0x700+des_SPtrans(%ecx),%ebx
928 xorl %ebx, %esi
929 movl 0x400+des_SPtrans(%eax),%ebx
930 xorl %ebx, %esi
931 movl 0x500+des_SPtrans(%edx),%ebx
932 xorl %ebx, %esi
933
934 /* Round 9 */
935 movl 72(%ebp), %eax
936 xorl %ebx, %ebx
937 movl 76(%ebp), %edx
938 xorl %esi, %eax
939 xorl %esi, %edx
940 andl $0xfcfcfcfc, %eax
941 andl $0xcfcfcfcf, %edx
942 movb %al, %bl
943 movb %ah, %cl
944 rorl $4, %edx
945 movl des_SPtrans(%ebx),%ebp
946 movb %dl, %bl
947 xorl %ebp, %edi
948 movl 0x200+des_SPtrans(%ecx),%ebp
949 xorl %ebp, %edi
950 movb %dh, %cl
951 shrl $16, %eax
952 movl 0x100+des_SPtrans(%ebx),%ebp
953 xorl %ebp, %edi
954 movb %ah, %bl
955 shrl $16, %edx
956 movl 0x300+des_SPtrans(%ecx),%ebp
957 xorl %ebp, %edi
958 movl 24(%esp), %ebp
959 movb %dh, %cl
960 andl $0xff, %eax
961 andl $0xff, %edx
962 movl 0x600+des_SPtrans(%ebx),%ebx
963 xorl %ebx, %edi
964 movl 0x700+des_SPtrans(%ecx),%ebx
965 xorl %ebx, %edi
966 movl 0x400+des_SPtrans(%eax),%ebx
967 xorl %ebx, %edi
968 movl 0x500+des_SPtrans(%edx),%ebx
969 xorl %ebx, %edi
970
971 /* Round 8 */
972 movl 64(%ebp), %eax
973 xorl %ebx, %ebx
974 movl 68(%ebp), %edx
975 xorl %edi, %eax
976 xorl %edi, %edx
977 andl $0xfcfcfcfc, %eax
978 andl $0xcfcfcfcf, %edx
979 movb %al, %bl
980 movb %ah, %cl
981 rorl $4, %edx
982 movl des_SPtrans(%ebx),%ebp
983 movb %dl, %bl
984 xorl %ebp, %esi
985 movl 0x200+des_SPtrans(%ecx),%ebp
986 xorl %ebp, %esi
987 movb %dh, %cl
988 shrl $16, %eax
989 movl 0x100+des_SPtrans(%ebx),%ebp
990 xorl %ebp, %esi
991 movb %ah, %bl
992 shrl $16, %edx
993 movl 0x300+des_SPtrans(%ecx),%ebp
994 xorl %ebp, %esi
995 movl 24(%esp), %ebp
996 movb %dh, %cl
997 andl $0xff, %eax
998 andl $0xff, %edx
999 movl 0x600+des_SPtrans(%ebx),%ebx
1000 xorl %ebx, %esi
1001 movl 0x700+des_SPtrans(%ecx),%ebx
1002 xorl %ebx, %esi
1003 movl 0x400+des_SPtrans(%eax),%ebx
1004 xorl %ebx, %esi
1005 movl 0x500+des_SPtrans(%edx),%ebx
1006 xorl %ebx, %esi
1007
1008 /* Round 7 */
1009 movl 56(%ebp), %eax
1010 xorl %ebx, %ebx
1011 movl 60(%ebp), %edx
1012 xorl %esi, %eax
1013 xorl %esi, %edx
1014 andl $0xfcfcfcfc, %eax
1015 andl $0xcfcfcfcf, %edx
1016 movb %al, %bl
1017 movb %ah, %cl
1018 rorl $4, %edx
1019 movl des_SPtrans(%ebx),%ebp
1020 movb %dl, %bl
1021 xorl %ebp, %edi
1022 movl 0x200+des_SPtrans(%ecx),%ebp
1023 xorl %ebp, %edi
1024 movb %dh, %cl
1025 shrl $16, %eax
1026 movl 0x100+des_SPtrans(%ebx),%ebp
1027 xorl %ebp, %edi
1028 movb %ah, %bl
1029 shrl $16, %edx
1030 movl 0x300+des_SPtrans(%ecx),%ebp
1031 xorl %ebp, %edi
1032 movl 24(%esp), %ebp
1033 movb %dh, %cl
1034 andl $0xff, %eax
1035 andl $0xff, %edx
1036 movl 0x600+des_SPtrans(%ebx),%ebx
1037 xorl %ebx, %edi
1038 movl 0x700+des_SPtrans(%ecx),%ebx
1039 xorl %ebx, %edi
1040 movl 0x400+des_SPtrans(%eax),%ebx
1041 xorl %ebx, %edi
1042 movl 0x500+des_SPtrans(%edx),%ebx
1043 xorl %ebx, %edi
1044
1045 /* Round 6 */
1046 movl 48(%ebp), %eax
1047 xorl %ebx, %ebx
1048 movl 52(%ebp), %edx
1049 xorl %edi, %eax
1050 xorl %edi, %edx
1051 andl $0xfcfcfcfc, %eax
1052 andl $0xcfcfcfcf, %edx
1053 movb %al, %bl
1054 movb %ah, %cl
1055 rorl $4, %edx
1056 movl des_SPtrans(%ebx),%ebp
1057 movb %dl, %bl
1058 xorl %ebp, %esi
1059 movl 0x200+des_SPtrans(%ecx),%ebp
1060 xorl %ebp, %esi
1061 movb %dh, %cl
1062 shrl $16, %eax
1063 movl 0x100+des_SPtrans(%ebx),%ebp
1064 xorl %ebp, %esi
1065 movb %ah, %bl
1066 shrl $16, %edx
1067 movl 0x300+des_SPtrans(%ecx),%ebp
1068 xorl %ebp, %esi
1069 movl 24(%esp), %ebp
1070 movb %dh, %cl
1071 andl $0xff, %eax
1072 andl $0xff, %edx
1073 movl 0x600+des_SPtrans(%ebx),%ebx
1074 xorl %ebx, %esi
1075 movl 0x700+des_SPtrans(%ecx),%ebx
1076 xorl %ebx, %esi
1077 movl 0x400+des_SPtrans(%eax),%ebx
1078 xorl %ebx, %esi
1079 movl 0x500+des_SPtrans(%edx),%ebx
1080 xorl %ebx, %esi
1081
1082 /* Round 5 */
1083 movl 40(%ebp), %eax
1084 xorl %ebx, %ebx
1085 movl 44(%ebp), %edx
1086 xorl %esi, %eax
1087 xorl %esi, %edx
1088 andl $0xfcfcfcfc, %eax
1089 andl $0xcfcfcfcf, %edx
1090 movb %al, %bl
1091 movb %ah, %cl
1092 rorl $4, %edx
1093 movl des_SPtrans(%ebx),%ebp
1094 movb %dl, %bl
1095 xorl %ebp, %edi
1096 movl 0x200+des_SPtrans(%ecx),%ebp
1097 xorl %ebp, %edi
1098 movb %dh, %cl
1099 shrl $16, %eax
1100 movl 0x100+des_SPtrans(%ebx),%ebp
1101 xorl %ebp, %edi
1102 movb %ah, %bl
1103 shrl $16, %edx
1104 movl 0x300+des_SPtrans(%ecx),%ebp
1105 xorl %ebp, %edi
1106 movl 24(%esp), %ebp
1107 movb %dh, %cl
1108 andl $0xff, %eax
1109 andl $0xff, %edx
1110 movl 0x600+des_SPtrans(%ebx),%ebx
1111 xorl %ebx, %edi
1112 movl 0x700+des_SPtrans(%ecx),%ebx
1113 xorl %ebx, %edi
1114 movl 0x400+des_SPtrans(%eax),%ebx
1115 xorl %ebx, %edi
1116 movl 0x500+des_SPtrans(%edx),%ebx
1117 xorl %ebx, %edi
1118
1119 /* Round 4 */
1120 movl 32(%ebp), %eax
1121 xorl %ebx, %ebx
1122 movl 36(%ebp), %edx
1123 xorl %edi, %eax
1124 xorl %edi, %edx
1125 andl $0xfcfcfcfc, %eax
1126 andl $0xcfcfcfcf, %edx
1127 movb %al, %bl
1128 movb %ah, %cl
1129 rorl $4, %edx
1130 movl des_SPtrans(%ebx),%ebp
1131 movb %dl, %bl
1132 xorl %ebp, %esi
1133 movl 0x200+des_SPtrans(%ecx),%ebp
1134 xorl %ebp, %esi
1135 movb %dh, %cl
1136 shrl $16, %eax
1137 movl 0x100+des_SPtrans(%ebx),%ebp
1138 xorl %ebp, %esi
1139 movb %ah, %bl
1140 shrl $16, %edx
1141 movl 0x300+des_SPtrans(%ecx),%ebp
1142 xorl %ebp, %esi
1143 movl 24(%esp), %ebp
1144 movb %dh, %cl
1145 andl $0xff, %eax
1146 andl $0xff, %edx
1147 movl 0x600+des_SPtrans(%ebx),%ebx
1148 xorl %ebx, %esi
1149 movl 0x700+des_SPtrans(%ecx),%ebx
1150 xorl %ebx, %esi
1151 movl 0x400+des_SPtrans(%eax),%ebx
1152 xorl %ebx, %esi
1153 movl 0x500+des_SPtrans(%edx),%ebx
1154 xorl %ebx, %esi
1155
1156 /* Round 3 */
1157 movl 24(%ebp), %eax
1158 xorl %ebx, %ebx
1159 movl 28(%ebp), %edx
1160 xorl %esi, %eax
1161 xorl %esi, %edx
1162 andl $0xfcfcfcfc, %eax
1163 andl $0xcfcfcfcf, %edx
1164 movb %al, %bl
1165 movb %ah, %cl
1166 rorl $4, %edx
1167 movl des_SPtrans(%ebx),%ebp
1168 movb %dl, %bl
1169 xorl %ebp, %edi
1170 movl 0x200+des_SPtrans(%ecx),%ebp
1171 xorl %ebp, %edi
1172 movb %dh, %cl
1173 shrl $16, %eax
1174 movl 0x100+des_SPtrans(%ebx),%ebp
1175 xorl %ebp, %edi
1176 movb %ah, %bl
1177 shrl $16, %edx
1178 movl 0x300+des_SPtrans(%ecx),%ebp
1179 xorl %ebp, %edi
1180 movl 24(%esp), %ebp
1181 movb %dh, %cl
1182 andl $0xff, %eax
1183 andl $0xff, %edx
1184 movl 0x600+des_SPtrans(%ebx),%ebx
1185 xorl %ebx, %edi
1186 movl 0x700+des_SPtrans(%ecx),%ebx
1187 xorl %ebx, %edi
1188 movl 0x400+des_SPtrans(%eax),%ebx
1189 xorl %ebx, %edi
1190 movl 0x500+des_SPtrans(%edx),%ebx
1191 xorl %ebx, %edi
1192
1193 /* Round 2 */
1194 movl 16(%ebp), %eax
1195 xorl %ebx, %ebx
1196 movl 20(%ebp), %edx
1197 xorl %edi, %eax
1198 xorl %edi, %edx
1199 andl $0xfcfcfcfc, %eax
1200 andl $0xcfcfcfcf, %edx
1201 movb %al, %bl
1202 movb %ah, %cl
1203 rorl $4, %edx
1204 movl des_SPtrans(%ebx),%ebp
1205 movb %dl, %bl
1206 xorl %ebp, %esi
1207 movl 0x200+des_SPtrans(%ecx),%ebp
1208 xorl %ebp, %esi
1209 movb %dh, %cl
1210 shrl $16, %eax
1211 movl 0x100+des_SPtrans(%ebx),%ebp
1212 xorl %ebp, %esi
1213 movb %ah, %bl
1214 shrl $16, %edx
1215 movl 0x300+des_SPtrans(%ecx),%ebp
1216 xorl %ebp, %esi
1217 movl 24(%esp), %ebp
1218 movb %dh, %cl
1219 andl $0xff, %eax
1220 andl $0xff, %edx
1221 movl 0x600+des_SPtrans(%ebx),%ebx
1222 xorl %ebx, %esi
1223 movl 0x700+des_SPtrans(%ecx),%ebx
1224 xorl %ebx, %esi
1225 movl 0x400+des_SPtrans(%eax),%ebx
1226 xorl %ebx, %esi
1227 movl 0x500+des_SPtrans(%edx),%ebx
1228 xorl %ebx, %esi
1229
1230 /* Round 1 */
1231 movl 8(%ebp), %eax
1232 xorl %ebx, %ebx
1233 movl 12(%ebp), %edx
1234 xorl %esi, %eax
1235 xorl %esi, %edx
1236 andl $0xfcfcfcfc, %eax
1237 andl $0xcfcfcfcf, %edx
1238 movb %al, %bl
1239 movb %ah, %cl
1240 rorl $4, %edx
1241 movl des_SPtrans(%ebx),%ebp
1242 movb %dl, %bl
1243 xorl %ebp, %edi
1244 movl 0x200+des_SPtrans(%ecx),%ebp
1245 xorl %ebp, %edi
1246 movb %dh, %cl
1247 shrl $16, %eax
1248 movl 0x100+des_SPtrans(%ebx),%ebp
1249 xorl %ebp, %edi
1250 movb %ah, %bl
1251 shrl $16, %edx
1252 movl 0x300+des_SPtrans(%ecx),%ebp
1253 xorl %ebp, %edi
1254 movl 24(%esp), %ebp
1255 movb %dh, %cl
1256 andl $0xff, %eax
1257 andl $0xff, %edx
1258 movl 0x600+des_SPtrans(%ebx),%ebx
1259 xorl %ebx, %edi
1260 movl 0x700+des_SPtrans(%ecx),%ebx
1261 xorl %ebx, %edi
1262 movl 0x400+des_SPtrans(%eax),%ebx
1263 xorl %ebx, %edi
1264 movl 0x500+des_SPtrans(%edx),%ebx
1265 xorl %ebx, %edi
1266
1267 /* Round 0 */
1268 movl (%ebp), %eax
1269 xorl %ebx, %ebx
1270 movl 4(%ebp), %edx
1271 xorl %edi, %eax
1272 xorl %edi, %edx
1273 andl $0xfcfcfcfc, %eax
1274 andl $0xcfcfcfcf, %edx
1275 movb %al, %bl
1276 movb %ah, %cl
1277 rorl $4, %edx
1278 movl des_SPtrans(%ebx),%ebp
1279 movb %dl, %bl
1280 xorl %ebp, %esi
1281 movl 0x200+des_SPtrans(%ecx),%ebp
1282 xorl %ebp, %esi
1283 movb %dh, %cl
1284 shrl $16, %eax
1285 movl 0x100+des_SPtrans(%ebx),%ebp
1286 xorl %ebp, %esi
1287 movb %ah, %bl
1288 shrl $16, %edx
1289 movl 0x300+des_SPtrans(%ecx),%ebp
1290 xorl %ebp, %esi
1291 movl 24(%esp), %ebp
1292 movb %dh, %cl
1293 andl $0xff, %eax
1294 andl $0xff, %edx
1295 movl 0x600+des_SPtrans(%ebx),%ebx
1296 xorl %ebx, %esi
1297 movl 0x700+des_SPtrans(%ecx),%ebx
1298 xorl %ebx, %esi
1299 movl 0x400+des_SPtrans(%eax),%ebx
1300 xorl %ebx, %esi
1301 movl 0x500+des_SPtrans(%edx),%ebx
1302 xorl %ebx, %esi
1303.L001end:
1304
1305 /* FP */
1306 movl 20(%esp), %edx
1307.byte 209
1308.byte 206 /* rorl $1 %esi */
1309 movl %edi, %eax
1310 xorl %esi, %edi
1311 andl $0xaaaaaaaa, %edi
1312 xorl %edi, %eax
1313 xorl %edi, %esi
1314
1315 roll $23, %eax
1316 movl %eax, %edi
1317 xorl %esi, %eax
1318 andl $0x03fc03fc, %eax
1319 xorl %eax, %edi
1320 xorl %eax, %esi
1321
1322 roll $10, %edi
1323 movl %edi, %eax
1324 xorl %esi, %edi
1325 andl $0x33333333, %edi
1326 xorl %edi, %eax
1327 xorl %edi, %esi
1328
1329 roll $18, %esi
1330 movl %esi, %edi
1331 xorl %eax, %esi
1332 andl $0xfff0000f, %esi
1333 xorl %esi, %edi
1334 xorl %esi, %eax
1335
1336 roll $12, %edi
1337 movl %edi, %esi
1338 xorl %eax, %edi
1339 andl $0xf0f0f0f0, %edi
1340 xorl %edi, %esi
1341 xorl %edi, %eax
1342
1343 rorl $4, %eax
1344 movl %eax, (%edx)
1345 movl %esi, 4(%edx)
1346 popl %ebp
1347 popl %ebx
1348 popl %edi
1349 popl %esi
1350 ret
1351.des_encrypt_end:
1352 SIZE(des_encrypt,.des_encrypt_end-des_encrypt)
1353.ident "desasm.pl"
1354.text
1355 .align ALIGN
1356.globl des_encrypt2
1357 TYPE(des_encrypt2,@function)
1358des_encrypt2:
1359 pushl %esi
1360 pushl %edi
1361
1362 /* Load the 2 words */
1363 movl 12(%esp), %eax
1364 xorl %ecx, %ecx
1365 pushl %ebx
1366 pushl %ebp
1367 movl (%eax), %esi
1368 movl 28(%esp), %ebx
1369 roll $3, %esi
1370 movl 4(%eax), %edi
1371 roll $3, %edi
1372 movl 24(%esp), %ebp
1373 cmpl $0, %ebx
1374 je .L002start_decrypt
1375
1376 /* Round 0 */
1377 movl (%ebp), %eax
1378 xorl %ebx, %ebx
1379 movl 4(%ebp), %edx
1380 xorl %esi, %eax
1381 xorl %esi, %edx
1382 andl $0xfcfcfcfc, %eax
1383 andl $0xcfcfcfcf, %edx
1384 movb %al, %bl
1385 movb %ah, %cl
1386 rorl $4, %edx
1387 movl des_SPtrans(%ebx),%ebp
1388 movb %dl, %bl
1389 xorl %ebp, %edi
1390 movl 0x200+des_SPtrans(%ecx),%ebp
1391 xorl %ebp, %edi
1392 movb %dh, %cl
1393 shrl $16, %eax
1394 movl 0x100+des_SPtrans(%ebx),%ebp
1395 xorl %ebp, %edi
1396 movb %ah, %bl
1397 shrl $16, %edx
1398 movl 0x300+des_SPtrans(%ecx),%ebp
1399 xorl %ebp, %edi
1400 movl 24(%esp), %ebp
1401 movb %dh, %cl
1402 andl $0xff, %eax
1403 andl $0xff, %edx
1404 movl 0x600+des_SPtrans(%ebx),%ebx
1405 xorl %ebx, %edi
1406 movl 0x700+des_SPtrans(%ecx),%ebx
1407 xorl %ebx, %edi
1408 movl 0x400+des_SPtrans(%eax),%ebx
1409 xorl %ebx, %edi
1410 movl 0x500+des_SPtrans(%edx),%ebx
1411 xorl %ebx, %edi
1412
1413 /* Round 1 */
1414 movl 8(%ebp), %eax
1415 xorl %ebx, %ebx
1416 movl 12(%ebp), %edx
1417 xorl %edi, %eax
1418 xorl %edi, %edx
1419 andl $0xfcfcfcfc, %eax
1420 andl $0xcfcfcfcf, %edx
1421 movb %al, %bl
1422 movb %ah, %cl
1423 rorl $4, %edx
1424 movl des_SPtrans(%ebx),%ebp
1425 movb %dl, %bl
1426 xorl %ebp, %esi
1427 movl 0x200+des_SPtrans(%ecx),%ebp
1428 xorl %ebp, %esi
1429 movb %dh, %cl
1430 shrl $16, %eax
1431 movl 0x100+des_SPtrans(%ebx),%ebp
1432 xorl %ebp, %esi
1433 movb %ah, %bl
1434 shrl $16, %edx
1435 movl 0x300+des_SPtrans(%ecx),%ebp
1436 xorl %ebp, %esi
1437 movl 24(%esp), %ebp
1438 movb %dh, %cl
1439 andl $0xff, %eax
1440 andl $0xff, %edx
1441 movl 0x600+des_SPtrans(%ebx),%ebx
1442 xorl %ebx, %esi
1443 movl 0x700+des_SPtrans(%ecx),%ebx
1444 xorl %ebx, %esi
1445 movl 0x400+des_SPtrans(%eax),%ebx
1446 xorl %ebx, %esi
1447 movl 0x500+des_SPtrans(%edx),%ebx
1448 xorl %ebx, %esi
1449
1450 /* Round 2 */
1451 movl 16(%ebp), %eax
1452 xorl %ebx, %ebx
1453 movl 20(%ebp), %edx
1454 xorl %esi, %eax
1455 xorl %esi, %edx
1456 andl $0xfcfcfcfc, %eax
1457 andl $0xcfcfcfcf, %edx
1458 movb %al, %bl
1459 movb %ah, %cl
1460 rorl $4, %edx
1461 movl des_SPtrans(%ebx),%ebp
1462 movb %dl, %bl
1463 xorl %ebp, %edi
1464 movl 0x200+des_SPtrans(%ecx),%ebp
1465 xorl %ebp, %edi
1466 movb %dh, %cl
1467 shrl $16, %eax
1468 movl 0x100+des_SPtrans(%ebx),%ebp
1469 xorl %ebp, %edi
1470 movb %ah, %bl
1471 shrl $16, %edx
1472 movl 0x300+des_SPtrans(%ecx),%ebp
1473 xorl %ebp, %edi
1474 movl 24(%esp), %ebp
1475 movb %dh, %cl
1476 andl $0xff, %eax
1477 andl $0xff, %edx
1478 movl 0x600+des_SPtrans(%ebx),%ebx
1479 xorl %ebx, %edi
1480 movl 0x700+des_SPtrans(%ecx),%ebx
1481 xorl %ebx, %edi
1482 movl 0x400+des_SPtrans(%eax),%ebx
1483 xorl %ebx, %edi
1484 movl 0x500+des_SPtrans(%edx),%ebx
1485 xorl %ebx, %edi
1486
1487 /* Round 3 */
1488 movl 24(%ebp), %eax
1489 xorl %ebx, %ebx
1490 movl 28(%ebp), %edx
1491 xorl %edi, %eax
1492 xorl %edi, %edx
1493 andl $0xfcfcfcfc, %eax
1494 andl $0xcfcfcfcf, %edx
1495 movb %al, %bl
1496 movb %ah, %cl
1497 rorl $4, %edx
1498 movl des_SPtrans(%ebx),%ebp
1499 movb %dl, %bl
1500 xorl %ebp, %esi
1501 movl 0x200+des_SPtrans(%ecx),%ebp
1502 xorl %ebp, %esi
1503 movb %dh, %cl
1504 shrl $16, %eax
1505 movl 0x100+des_SPtrans(%ebx),%ebp
1506 xorl %ebp, %esi
1507 movb %ah, %bl
1508 shrl $16, %edx
1509 movl 0x300+des_SPtrans(%ecx),%ebp
1510 xorl %ebp, %esi
1511 movl 24(%esp), %ebp
1512 movb %dh, %cl
1513 andl $0xff, %eax
1514 andl $0xff, %edx
1515 movl 0x600+des_SPtrans(%ebx),%ebx
1516 xorl %ebx, %esi
1517 movl 0x700+des_SPtrans(%ecx),%ebx
1518 xorl %ebx, %esi
1519 movl 0x400+des_SPtrans(%eax),%ebx
1520 xorl %ebx, %esi
1521 movl 0x500+des_SPtrans(%edx),%ebx
1522 xorl %ebx, %esi
1523
1524 /* Round 4 */
1525 movl 32(%ebp), %eax
1526 xorl %ebx, %ebx
1527 movl 36(%ebp), %edx
1528 xorl %esi, %eax
1529 xorl %esi, %edx
1530 andl $0xfcfcfcfc, %eax
1531 andl $0xcfcfcfcf, %edx
1532 movb %al, %bl
1533 movb %ah, %cl
1534 rorl $4, %edx
1535 movl des_SPtrans(%ebx),%ebp
1536 movb %dl, %bl
1537 xorl %ebp, %edi
1538 movl 0x200+des_SPtrans(%ecx),%ebp
1539 xorl %ebp, %edi
1540 movb %dh, %cl
1541 shrl $16, %eax
1542 movl 0x100+des_SPtrans(%ebx),%ebp
1543 xorl %ebp, %edi
1544 movb %ah, %bl
1545 shrl $16, %edx
1546 movl 0x300+des_SPtrans(%ecx),%ebp
1547 xorl %ebp, %edi
1548 movl 24(%esp), %ebp
1549 movb %dh, %cl
1550 andl $0xff, %eax
1551 andl $0xff, %edx
1552 movl 0x600+des_SPtrans(%ebx),%ebx
1553 xorl %ebx, %edi
1554 movl 0x700+des_SPtrans(%ecx),%ebx
1555 xorl %ebx, %edi
1556 movl 0x400+des_SPtrans(%eax),%ebx
1557 xorl %ebx, %edi
1558 movl 0x500+des_SPtrans(%edx),%ebx
1559 xorl %ebx, %edi
1560
1561 /* Round 5 */
1562 movl 40(%ebp), %eax
1563 xorl %ebx, %ebx
1564 movl 44(%ebp), %edx
1565 xorl %edi, %eax
1566 xorl %edi, %edx
1567 andl $0xfcfcfcfc, %eax
1568 andl $0xcfcfcfcf, %edx
1569 movb %al, %bl
1570 movb %ah, %cl
1571 rorl $4, %edx
1572 movl des_SPtrans(%ebx),%ebp
1573 movb %dl, %bl
1574 xorl %ebp, %esi
1575 movl 0x200+des_SPtrans(%ecx),%ebp
1576 xorl %ebp, %esi
1577 movb %dh, %cl
1578 shrl $16, %eax
1579 movl 0x100+des_SPtrans(%ebx),%ebp
1580 xorl %ebp, %esi
1581 movb %ah, %bl
1582 shrl $16, %edx
1583 movl 0x300+des_SPtrans(%ecx),%ebp
1584 xorl %ebp, %esi
1585 movl 24(%esp), %ebp
1586 movb %dh, %cl
1587 andl $0xff, %eax
1588 andl $0xff, %edx
1589 movl 0x600+des_SPtrans(%ebx),%ebx
1590 xorl %ebx, %esi
1591 movl 0x700+des_SPtrans(%ecx),%ebx
1592 xorl %ebx, %esi
1593 movl 0x400+des_SPtrans(%eax),%ebx
1594 xorl %ebx, %esi
1595 movl 0x500+des_SPtrans(%edx),%ebx
1596 xorl %ebx, %esi
1597
1598 /* Round 6 */
1599 movl 48(%ebp), %eax
1600 xorl %ebx, %ebx
1601 movl 52(%ebp), %edx
1602 xorl %esi, %eax
1603 xorl %esi, %edx
1604 andl $0xfcfcfcfc, %eax
1605 andl $0xcfcfcfcf, %edx
1606 movb %al, %bl
1607 movb %ah, %cl
1608 rorl $4, %edx
1609 movl des_SPtrans(%ebx),%ebp
1610 movb %dl, %bl
1611 xorl %ebp, %edi
1612 movl 0x200+des_SPtrans(%ecx),%ebp
1613 xorl %ebp, %edi
1614 movb %dh, %cl
1615 shrl $16, %eax
1616 movl 0x100+des_SPtrans(%ebx),%ebp
1617 xorl %ebp, %edi
1618 movb %ah, %bl
1619 shrl $16, %edx
1620 movl 0x300+des_SPtrans(%ecx),%ebp
1621 xorl %ebp, %edi
1622 movl 24(%esp), %ebp
1623 movb %dh, %cl
1624 andl $0xff, %eax
1625 andl $0xff, %edx
1626 movl 0x600+des_SPtrans(%ebx),%ebx
1627 xorl %ebx, %edi
1628 movl 0x700+des_SPtrans(%ecx),%ebx
1629 xorl %ebx, %edi
1630 movl 0x400+des_SPtrans(%eax),%ebx
1631 xorl %ebx, %edi
1632 movl 0x500+des_SPtrans(%edx),%ebx
1633 xorl %ebx, %edi
1634
1635 /* Round 7 */
1636 movl 56(%ebp), %eax
1637 xorl %ebx, %ebx
1638 movl 60(%ebp), %edx
1639 xorl %edi, %eax
1640 xorl %edi, %edx
1641 andl $0xfcfcfcfc, %eax
1642 andl $0xcfcfcfcf, %edx
1643 movb %al, %bl
1644 movb %ah, %cl
1645 rorl $4, %edx
1646 movl des_SPtrans(%ebx),%ebp
1647 movb %dl, %bl
1648 xorl %ebp, %esi
1649 movl 0x200+des_SPtrans(%ecx),%ebp
1650 xorl %ebp, %esi
1651 movb %dh, %cl
1652 shrl $16, %eax
1653 movl 0x100+des_SPtrans(%ebx),%ebp
1654 xorl %ebp, %esi
1655 movb %ah, %bl
1656 shrl $16, %edx
1657 movl 0x300+des_SPtrans(%ecx),%ebp
1658 xorl %ebp, %esi
1659 movl 24(%esp), %ebp
1660 movb %dh, %cl
1661 andl $0xff, %eax
1662 andl $0xff, %edx
1663 movl 0x600+des_SPtrans(%ebx),%ebx
1664 xorl %ebx, %esi
1665 movl 0x700+des_SPtrans(%ecx),%ebx
1666 xorl %ebx, %esi
1667 movl 0x400+des_SPtrans(%eax),%ebx
1668 xorl %ebx, %esi
1669 movl 0x500+des_SPtrans(%edx),%ebx
1670 xorl %ebx, %esi
1671
1672 /* Round 8 */
1673 movl 64(%ebp), %eax
1674 xorl %ebx, %ebx
1675 movl 68(%ebp), %edx
1676 xorl %esi, %eax
1677 xorl %esi, %edx
1678 andl $0xfcfcfcfc, %eax
1679 andl $0xcfcfcfcf, %edx
1680 movb %al, %bl
1681 movb %ah, %cl
1682 rorl $4, %edx
1683 movl des_SPtrans(%ebx),%ebp
1684 movb %dl, %bl
1685 xorl %ebp, %edi
1686 movl 0x200+des_SPtrans(%ecx),%ebp
1687 xorl %ebp, %edi
1688 movb %dh, %cl
1689 shrl $16, %eax
1690 movl 0x100+des_SPtrans(%ebx),%ebp
1691 xorl %ebp, %edi
1692 movb %ah, %bl
1693 shrl $16, %edx
1694 movl 0x300+des_SPtrans(%ecx),%ebp
1695 xorl %ebp, %edi
1696 movl 24(%esp), %ebp
1697 movb %dh, %cl
1698 andl $0xff, %eax
1699 andl $0xff, %edx
1700 movl 0x600+des_SPtrans(%ebx),%ebx
1701 xorl %ebx, %edi
1702 movl 0x700+des_SPtrans(%ecx),%ebx
1703 xorl %ebx, %edi
1704 movl 0x400+des_SPtrans(%eax),%ebx
1705 xorl %ebx, %edi
1706 movl 0x500+des_SPtrans(%edx),%ebx
1707 xorl %ebx, %edi
1708
1709 /* Round 9 */
1710 movl 72(%ebp), %eax
1711 xorl %ebx, %ebx
1712 movl 76(%ebp), %edx
1713 xorl %edi, %eax
1714 xorl %edi, %edx
1715 andl $0xfcfcfcfc, %eax
1716 andl $0xcfcfcfcf, %edx
1717 movb %al, %bl
1718 movb %ah, %cl
1719 rorl $4, %edx
1720 movl des_SPtrans(%ebx),%ebp
1721 movb %dl, %bl
1722 xorl %ebp, %esi
1723 movl 0x200+des_SPtrans(%ecx),%ebp
1724 xorl %ebp, %esi
1725 movb %dh, %cl
1726 shrl $16, %eax
1727 movl 0x100+des_SPtrans(%ebx),%ebp
1728 xorl %ebp, %esi
1729 movb %ah, %bl
1730 shrl $16, %edx
1731 movl 0x300+des_SPtrans(%ecx),%ebp
1732 xorl %ebp, %esi
1733 movl 24(%esp), %ebp
1734 movb %dh, %cl
1735 andl $0xff, %eax
1736 andl $0xff, %edx
1737 movl 0x600+des_SPtrans(%ebx),%ebx
1738 xorl %ebx, %esi
1739 movl 0x700+des_SPtrans(%ecx),%ebx
1740 xorl %ebx, %esi
1741 movl 0x400+des_SPtrans(%eax),%ebx
1742 xorl %ebx, %esi
1743 movl 0x500+des_SPtrans(%edx),%ebx
1744 xorl %ebx, %esi
1745
1746 /* Round 10 */
1747 movl 80(%ebp), %eax
1748 xorl %ebx, %ebx
1749 movl 84(%ebp), %edx
1750 xorl %esi, %eax
1751 xorl %esi, %edx
1752 andl $0xfcfcfcfc, %eax
1753 andl $0xcfcfcfcf, %edx
1754 movb %al, %bl
1755 movb %ah, %cl
1756 rorl $4, %edx
1757 movl des_SPtrans(%ebx),%ebp
1758 movb %dl, %bl
1759 xorl %ebp, %edi
1760 movl 0x200+des_SPtrans(%ecx),%ebp
1761 xorl %ebp, %edi
1762 movb %dh, %cl
1763 shrl $16, %eax
1764 movl 0x100+des_SPtrans(%ebx),%ebp
1765 xorl %ebp, %edi
1766 movb %ah, %bl
1767 shrl $16, %edx
1768 movl 0x300+des_SPtrans(%ecx),%ebp
1769 xorl %ebp, %edi
1770 movl 24(%esp), %ebp
1771 movb %dh, %cl
1772 andl $0xff, %eax
1773 andl $0xff, %edx
1774 movl 0x600+des_SPtrans(%ebx),%ebx
1775 xorl %ebx, %edi
1776 movl 0x700+des_SPtrans(%ecx),%ebx
1777 xorl %ebx, %edi
1778 movl 0x400+des_SPtrans(%eax),%ebx
1779 xorl %ebx, %edi
1780 movl 0x500+des_SPtrans(%edx),%ebx
1781 xorl %ebx, %edi
1782
1783 /* Round 11 */
1784 movl 88(%ebp), %eax
1785 xorl %ebx, %ebx
1786 movl 92(%ebp), %edx
1787 xorl %edi, %eax
1788 xorl %edi, %edx
1789 andl $0xfcfcfcfc, %eax
1790 andl $0xcfcfcfcf, %edx
1791 movb %al, %bl
1792 movb %ah, %cl
1793 rorl $4, %edx
1794 movl des_SPtrans(%ebx),%ebp
1795 movb %dl, %bl
1796 xorl %ebp, %esi
1797 movl 0x200+des_SPtrans(%ecx),%ebp
1798 xorl %ebp, %esi
1799 movb %dh, %cl
1800 shrl $16, %eax
1801 movl 0x100+des_SPtrans(%ebx),%ebp
1802 xorl %ebp, %esi
1803 movb %ah, %bl
1804 shrl $16, %edx
1805 movl 0x300+des_SPtrans(%ecx),%ebp
1806 xorl %ebp, %esi
1807 movl 24(%esp), %ebp
1808 movb %dh, %cl
1809 andl $0xff, %eax
1810 andl $0xff, %edx
1811 movl 0x600+des_SPtrans(%ebx),%ebx
1812 xorl %ebx, %esi
1813 movl 0x700+des_SPtrans(%ecx),%ebx
1814 xorl %ebx, %esi
1815 movl 0x400+des_SPtrans(%eax),%ebx
1816 xorl %ebx, %esi
1817 movl 0x500+des_SPtrans(%edx),%ebx
1818 xorl %ebx, %esi
1819
1820 /* Round 12 */
1821 movl 96(%ebp), %eax
1822 xorl %ebx, %ebx
1823 movl 100(%ebp), %edx
1824 xorl %esi, %eax
1825 xorl %esi, %edx
1826 andl $0xfcfcfcfc, %eax
1827 andl $0xcfcfcfcf, %edx
1828 movb %al, %bl
1829 movb %ah, %cl
1830 rorl $4, %edx
1831 movl des_SPtrans(%ebx),%ebp
1832 movb %dl, %bl
1833 xorl %ebp, %edi
1834 movl 0x200+des_SPtrans(%ecx),%ebp
1835 xorl %ebp, %edi
1836 movb %dh, %cl
1837 shrl $16, %eax
1838 movl 0x100+des_SPtrans(%ebx),%ebp
1839 xorl %ebp, %edi
1840 movb %ah, %bl
1841 shrl $16, %edx
1842 movl 0x300+des_SPtrans(%ecx),%ebp
1843 xorl %ebp, %edi
1844 movl 24(%esp), %ebp
1845 movb %dh, %cl
1846 andl $0xff, %eax
1847 andl $0xff, %edx
1848 movl 0x600+des_SPtrans(%ebx),%ebx
1849 xorl %ebx, %edi
1850 movl 0x700+des_SPtrans(%ecx),%ebx
1851 xorl %ebx, %edi
1852 movl 0x400+des_SPtrans(%eax),%ebx
1853 xorl %ebx, %edi
1854 movl 0x500+des_SPtrans(%edx),%ebx
1855 xorl %ebx, %edi
1856
1857 /* Round 13 */
1858 movl 104(%ebp), %eax
1859 xorl %ebx, %ebx
1860 movl 108(%ebp), %edx
1861 xorl %edi, %eax
1862 xorl %edi, %edx
1863 andl $0xfcfcfcfc, %eax
1864 andl $0xcfcfcfcf, %edx
1865 movb %al, %bl
1866 movb %ah, %cl
1867 rorl $4, %edx
1868 movl des_SPtrans(%ebx),%ebp
1869 movb %dl, %bl
1870 xorl %ebp, %esi
1871 movl 0x200+des_SPtrans(%ecx),%ebp
1872 xorl %ebp, %esi
1873 movb %dh, %cl
1874 shrl $16, %eax
1875 movl 0x100+des_SPtrans(%ebx),%ebp
1876 xorl %ebp, %esi
1877 movb %ah, %bl
1878 shrl $16, %edx
1879 movl 0x300+des_SPtrans(%ecx),%ebp
1880 xorl %ebp, %esi
1881 movl 24(%esp), %ebp
1882 movb %dh, %cl
1883 andl $0xff, %eax
1884 andl $0xff, %edx
1885 movl 0x600+des_SPtrans(%ebx),%ebx
1886 xorl %ebx, %esi
1887 movl 0x700+des_SPtrans(%ecx),%ebx
1888 xorl %ebx, %esi
1889 movl 0x400+des_SPtrans(%eax),%ebx
1890 xorl %ebx, %esi
1891 movl 0x500+des_SPtrans(%edx),%ebx
1892 xorl %ebx, %esi
1893
1894 /* Round 14 */
1895 movl 112(%ebp), %eax
1896 xorl %ebx, %ebx
1897 movl 116(%ebp), %edx
1898 xorl %esi, %eax
1899 xorl %esi, %edx
1900 andl $0xfcfcfcfc, %eax
1901 andl $0xcfcfcfcf, %edx
1902 movb %al, %bl
1903 movb %ah, %cl
1904 rorl $4, %edx
1905 movl des_SPtrans(%ebx),%ebp
1906 movb %dl, %bl
1907 xorl %ebp, %edi
1908 movl 0x200+des_SPtrans(%ecx),%ebp
1909 xorl %ebp, %edi
1910 movb %dh, %cl
1911 shrl $16, %eax
1912 movl 0x100+des_SPtrans(%ebx),%ebp
1913 xorl %ebp, %edi
1914 movb %ah, %bl
1915 shrl $16, %edx
1916 movl 0x300+des_SPtrans(%ecx),%ebp
1917 xorl %ebp, %edi
1918 movl 24(%esp), %ebp
1919 movb %dh, %cl
1920 andl $0xff, %eax
1921 andl $0xff, %edx
1922 movl 0x600+des_SPtrans(%ebx),%ebx
1923 xorl %ebx, %edi
1924 movl 0x700+des_SPtrans(%ecx),%ebx
1925 xorl %ebx, %edi
1926 movl 0x400+des_SPtrans(%eax),%ebx
1927 xorl %ebx, %edi
1928 movl 0x500+des_SPtrans(%edx),%ebx
1929 xorl %ebx, %edi
1930
1931 /* Round 15 */
1932 movl 120(%ebp), %eax
1933 xorl %ebx, %ebx
1934 movl 124(%ebp), %edx
1935 xorl %edi, %eax
1936 xorl %edi, %edx
1937 andl $0xfcfcfcfc, %eax
1938 andl $0xcfcfcfcf, %edx
1939 movb %al, %bl
1940 movb %ah, %cl
1941 rorl $4, %edx
1942 movl des_SPtrans(%ebx),%ebp
1943 movb %dl, %bl
1944 xorl %ebp, %esi
1945 movl 0x200+des_SPtrans(%ecx),%ebp
1946 xorl %ebp, %esi
1947 movb %dh, %cl
1948 shrl $16, %eax
1949 movl 0x100+des_SPtrans(%ebx),%ebp
1950 xorl %ebp, %esi
1951 movb %ah, %bl
1952 shrl $16, %edx
1953 movl 0x300+des_SPtrans(%ecx),%ebp
1954 xorl %ebp, %esi
1955 movl 24(%esp), %ebp
1956 movb %dh, %cl
1957 andl $0xff, %eax
1958 andl $0xff, %edx
1959 movl 0x600+des_SPtrans(%ebx),%ebx
1960 xorl %ebx, %esi
1961 movl 0x700+des_SPtrans(%ecx),%ebx
1962 xorl %ebx, %esi
1963 movl 0x400+des_SPtrans(%eax),%ebx
1964 xorl %ebx, %esi
1965 movl 0x500+des_SPtrans(%edx),%ebx
1966 xorl %ebx, %esi
1967 jmp .L003end
1968.L002start_decrypt:
1969
1970 /* Round 15 */
1971 movl 120(%ebp), %eax
1972 xorl %ebx, %ebx
1973 movl 124(%ebp), %edx
1974 xorl %esi, %eax
1975 xorl %esi, %edx
1976 andl $0xfcfcfcfc, %eax
1977 andl $0xcfcfcfcf, %edx
1978 movb %al, %bl
1979 movb %ah, %cl
1980 rorl $4, %edx
1981 movl des_SPtrans(%ebx),%ebp
1982 movb %dl, %bl
1983 xorl %ebp, %edi
1984 movl 0x200+des_SPtrans(%ecx),%ebp
1985 xorl %ebp, %edi
1986 movb %dh, %cl
1987 shrl $16, %eax
1988 movl 0x100+des_SPtrans(%ebx),%ebp
1989 xorl %ebp, %edi
1990 movb %ah, %bl
1991 shrl $16, %edx
1992 movl 0x300+des_SPtrans(%ecx),%ebp
1993 xorl %ebp, %edi
1994 movl 24(%esp), %ebp
1995 movb %dh, %cl
1996 andl $0xff, %eax
1997 andl $0xff, %edx
1998 movl 0x600+des_SPtrans(%ebx),%ebx
1999 xorl %ebx, %edi
2000 movl 0x700+des_SPtrans(%ecx),%ebx
2001 xorl %ebx, %edi
2002 movl 0x400+des_SPtrans(%eax),%ebx
2003 xorl %ebx, %edi
2004 movl 0x500+des_SPtrans(%edx),%ebx
2005 xorl %ebx, %edi
2006
2007 /* Round 14 */
2008 movl 112(%ebp), %eax
2009 xorl %ebx, %ebx
2010 movl 116(%ebp), %edx
2011 xorl %edi, %eax
2012 xorl %edi, %edx
2013 andl $0xfcfcfcfc, %eax
2014 andl $0xcfcfcfcf, %edx
2015 movb %al, %bl
2016 movb %ah, %cl
2017 rorl $4, %edx
2018 movl des_SPtrans(%ebx),%ebp
2019 movb %dl, %bl
2020 xorl %ebp, %esi
2021 movl 0x200+des_SPtrans(%ecx),%ebp
2022 xorl %ebp, %esi
2023 movb %dh, %cl
2024 shrl $16, %eax
2025 movl 0x100+des_SPtrans(%ebx),%ebp
2026 xorl %ebp, %esi
2027 movb %ah, %bl
2028 shrl $16, %edx
2029 movl 0x300+des_SPtrans(%ecx),%ebp
2030 xorl %ebp, %esi
2031 movl 24(%esp), %ebp
2032 movb %dh, %cl
2033 andl $0xff, %eax
2034 andl $0xff, %edx
2035 movl 0x600+des_SPtrans(%ebx),%ebx
2036 xorl %ebx, %esi
2037 movl 0x700+des_SPtrans(%ecx),%ebx
2038 xorl %ebx, %esi
2039 movl 0x400+des_SPtrans(%eax),%ebx
2040 xorl %ebx, %esi
2041 movl 0x500+des_SPtrans(%edx),%ebx
2042 xorl %ebx, %esi
2043
2044 /* Round 13 */
2045 movl 104(%ebp), %eax
2046 xorl %ebx, %ebx
2047 movl 108(%ebp), %edx
2048 xorl %esi, %eax
2049 xorl %esi, %edx
2050 andl $0xfcfcfcfc, %eax
2051 andl $0xcfcfcfcf, %edx
2052 movb %al, %bl
2053 movb %ah, %cl
2054 rorl $4, %edx
2055 movl des_SPtrans(%ebx),%ebp
2056 movb %dl, %bl
2057 xorl %ebp, %edi
2058 movl 0x200+des_SPtrans(%ecx),%ebp
2059 xorl %ebp, %edi
2060 movb %dh, %cl
2061 shrl $16, %eax
2062 movl 0x100+des_SPtrans(%ebx),%ebp
2063 xorl %ebp, %edi
2064 movb %ah, %bl
2065 shrl $16, %edx
2066 movl 0x300+des_SPtrans(%ecx),%ebp
2067 xorl %ebp, %edi
2068 movl 24(%esp), %ebp
2069 movb %dh, %cl
2070 andl $0xff, %eax
2071 andl $0xff, %edx
2072 movl 0x600+des_SPtrans(%ebx),%ebx
2073 xorl %ebx, %edi
2074 movl 0x700+des_SPtrans(%ecx),%ebx
2075 xorl %ebx, %edi
2076 movl 0x400+des_SPtrans(%eax),%ebx
2077 xorl %ebx, %edi
2078 movl 0x500+des_SPtrans(%edx),%ebx
2079 xorl %ebx, %edi
2080
2081 /* Round 12 */
2082 movl 96(%ebp), %eax
2083 xorl %ebx, %ebx
2084 movl 100(%ebp), %edx
2085 xorl %edi, %eax
2086 xorl %edi, %edx
2087 andl $0xfcfcfcfc, %eax
2088 andl $0xcfcfcfcf, %edx
2089 movb %al, %bl
2090 movb %ah, %cl
2091 rorl $4, %edx
2092 movl des_SPtrans(%ebx),%ebp
2093 movb %dl, %bl
2094 xorl %ebp, %esi
2095 movl 0x200+des_SPtrans(%ecx),%ebp
2096 xorl %ebp, %esi
2097 movb %dh, %cl
2098 shrl $16, %eax
2099 movl 0x100+des_SPtrans(%ebx),%ebp
2100 xorl %ebp, %esi
2101 movb %ah, %bl
2102 shrl $16, %edx
2103 movl 0x300+des_SPtrans(%ecx),%ebp
2104 xorl %ebp, %esi
2105 movl 24(%esp), %ebp
2106 movb %dh, %cl
2107 andl $0xff, %eax
2108 andl $0xff, %edx
2109 movl 0x600+des_SPtrans(%ebx),%ebx
2110 xorl %ebx, %esi
2111 movl 0x700+des_SPtrans(%ecx),%ebx
2112 xorl %ebx, %esi
2113 movl 0x400+des_SPtrans(%eax),%ebx
2114 xorl %ebx, %esi
2115 movl 0x500+des_SPtrans(%edx),%ebx
2116 xorl %ebx, %esi
2117
2118 /* Round 11 */
2119 movl 88(%ebp), %eax
2120 xorl %ebx, %ebx
2121 movl 92(%ebp), %edx
2122 xorl %esi, %eax
2123 xorl %esi, %edx
2124 andl $0xfcfcfcfc, %eax
2125 andl $0xcfcfcfcf, %edx
2126 movb %al, %bl
2127 movb %ah, %cl
2128 rorl $4, %edx
2129 movl des_SPtrans(%ebx),%ebp
2130 movb %dl, %bl
2131 xorl %ebp, %edi
2132 movl 0x200+des_SPtrans(%ecx),%ebp
2133 xorl %ebp, %edi
2134 movb %dh, %cl
2135 shrl $16, %eax
2136 movl 0x100+des_SPtrans(%ebx),%ebp
2137 xorl %ebp, %edi
2138 movb %ah, %bl
2139 shrl $16, %edx
2140 movl 0x300+des_SPtrans(%ecx),%ebp
2141 xorl %ebp, %edi
2142 movl 24(%esp), %ebp
2143 movb %dh, %cl
2144 andl $0xff, %eax
2145 andl $0xff, %edx
2146 movl 0x600+des_SPtrans(%ebx),%ebx
2147 xorl %ebx, %edi
2148 movl 0x700+des_SPtrans(%ecx),%ebx
2149 xorl %ebx, %edi
2150 movl 0x400+des_SPtrans(%eax),%ebx
2151 xorl %ebx, %edi
2152 movl 0x500+des_SPtrans(%edx),%ebx
2153 xorl %ebx, %edi
2154
2155 /* Round 10 */
2156 movl 80(%ebp), %eax
2157 xorl %ebx, %ebx
2158 movl 84(%ebp), %edx
2159 xorl %edi, %eax
2160 xorl %edi, %edx
2161 andl $0xfcfcfcfc, %eax
2162 andl $0xcfcfcfcf, %edx
2163 movb %al, %bl
2164 movb %ah, %cl
2165 rorl $4, %edx
2166 movl des_SPtrans(%ebx),%ebp
2167 movb %dl, %bl
2168 xorl %ebp, %esi
2169 movl 0x200+des_SPtrans(%ecx),%ebp
2170 xorl %ebp, %esi
2171 movb %dh, %cl
2172 shrl $16, %eax
2173 movl 0x100+des_SPtrans(%ebx),%ebp
2174 xorl %ebp, %esi
2175 movb %ah, %bl
2176 shrl $16, %edx
2177 movl 0x300+des_SPtrans(%ecx),%ebp
2178 xorl %ebp, %esi
2179 movl 24(%esp), %ebp
2180 movb %dh, %cl
2181 andl $0xff, %eax
2182 andl $0xff, %edx
2183 movl 0x600+des_SPtrans(%ebx),%ebx
2184 xorl %ebx, %esi
2185 movl 0x700+des_SPtrans(%ecx),%ebx
2186 xorl %ebx, %esi
2187 movl 0x400+des_SPtrans(%eax),%ebx
2188 xorl %ebx, %esi
2189 movl 0x500+des_SPtrans(%edx),%ebx
2190 xorl %ebx, %esi
2191
2192 /* Round 9 */
2193 movl 72(%ebp), %eax
2194 xorl %ebx, %ebx
2195 movl 76(%ebp), %edx
2196 xorl %esi, %eax
2197 xorl %esi, %edx
2198 andl $0xfcfcfcfc, %eax
2199 andl $0xcfcfcfcf, %edx
2200 movb %al, %bl
2201 movb %ah, %cl
2202 rorl $4, %edx
2203 movl des_SPtrans(%ebx),%ebp
2204 movb %dl, %bl
2205 xorl %ebp, %edi
2206 movl 0x200+des_SPtrans(%ecx),%ebp
2207 xorl %ebp, %edi
2208 movb %dh, %cl
2209 shrl $16, %eax
2210 movl 0x100+des_SPtrans(%ebx),%ebp
2211 xorl %ebp, %edi
2212 movb %ah, %bl
2213 shrl $16, %edx
2214 movl 0x300+des_SPtrans(%ecx),%ebp
2215 xorl %ebp, %edi
2216 movl 24(%esp), %ebp
2217 movb %dh, %cl
2218 andl $0xff, %eax
2219 andl $0xff, %edx
2220 movl 0x600+des_SPtrans(%ebx),%ebx
2221 xorl %ebx, %edi
2222 movl 0x700+des_SPtrans(%ecx),%ebx
2223 xorl %ebx, %edi
2224 movl 0x400+des_SPtrans(%eax),%ebx
2225 xorl %ebx, %edi
2226 movl 0x500+des_SPtrans(%edx),%ebx
2227 xorl %ebx, %edi
2228
2229 /* Round 8 */
2230 movl 64(%ebp), %eax
2231 xorl %ebx, %ebx
2232 movl 68(%ebp), %edx
2233 xorl %edi, %eax
2234 xorl %edi, %edx
2235 andl $0xfcfcfcfc, %eax
2236 andl $0xcfcfcfcf, %edx
2237 movb %al, %bl
2238 movb %ah, %cl
2239 rorl $4, %edx
2240 movl des_SPtrans(%ebx),%ebp
2241 movb %dl, %bl
2242 xorl %ebp, %esi
2243 movl 0x200+des_SPtrans(%ecx),%ebp
2244 xorl %ebp, %esi
2245 movb %dh, %cl
2246 shrl $16, %eax
2247 movl 0x100+des_SPtrans(%ebx),%ebp
2248 xorl %ebp, %esi
2249 movb %ah, %bl
2250 shrl $16, %edx
2251 movl 0x300+des_SPtrans(%ecx),%ebp
2252 xorl %ebp, %esi
2253 movl 24(%esp), %ebp
2254 movb %dh, %cl
2255 andl $0xff, %eax
2256 andl $0xff, %edx
2257 movl 0x600+des_SPtrans(%ebx),%ebx
2258 xorl %ebx, %esi
2259 movl 0x700+des_SPtrans(%ecx),%ebx
2260 xorl %ebx, %esi
2261 movl 0x400+des_SPtrans(%eax),%ebx
2262 xorl %ebx, %esi
2263 movl 0x500+des_SPtrans(%edx),%ebx
2264 xorl %ebx, %esi
2265
2266 /* Round 7 */
2267 movl 56(%ebp), %eax
2268 xorl %ebx, %ebx
2269 movl 60(%ebp), %edx
2270 xorl %esi, %eax
2271 xorl %esi, %edx
2272 andl $0xfcfcfcfc, %eax
2273 andl $0xcfcfcfcf, %edx
2274 movb %al, %bl
2275 movb %ah, %cl
2276 rorl $4, %edx
2277 movl des_SPtrans(%ebx),%ebp
2278 movb %dl, %bl
2279 xorl %ebp, %edi
2280 movl 0x200+des_SPtrans(%ecx),%ebp
2281 xorl %ebp, %edi
2282 movb %dh, %cl
2283 shrl $16, %eax
2284 movl 0x100+des_SPtrans(%ebx),%ebp
2285 xorl %ebp, %edi
2286 movb %ah, %bl
2287 shrl $16, %edx
2288 movl 0x300+des_SPtrans(%ecx),%ebp
2289 xorl %ebp, %edi
2290 movl 24(%esp), %ebp
2291 movb %dh, %cl
2292 andl $0xff, %eax
2293 andl $0xff, %edx
2294 movl 0x600+des_SPtrans(%ebx),%ebx
2295 xorl %ebx, %edi
2296 movl 0x700+des_SPtrans(%ecx),%ebx
2297 xorl %ebx, %edi
2298 movl 0x400+des_SPtrans(%eax),%ebx
2299 xorl %ebx, %edi
2300 movl 0x500+des_SPtrans(%edx),%ebx
2301 xorl %ebx, %edi
2302
2303 /* Round 6 */
2304 movl 48(%ebp), %eax
2305 xorl %ebx, %ebx
2306 movl 52(%ebp), %edx
2307 xorl %edi, %eax
2308 xorl %edi, %edx
2309 andl $0xfcfcfcfc, %eax
2310 andl $0xcfcfcfcf, %edx
2311 movb %al, %bl
2312 movb %ah, %cl
2313 rorl $4, %edx
2314 movl des_SPtrans(%ebx),%ebp
2315 movb %dl, %bl
2316 xorl %ebp, %esi
2317 movl 0x200+des_SPtrans(%ecx),%ebp
2318 xorl %ebp, %esi
2319 movb %dh, %cl
2320 shrl $16, %eax
2321 movl 0x100+des_SPtrans(%ebx),%ebp
2322 xorl %ebp, %esi
2323 movb %ah, %bl
2324 shrl $16, %edx
2325 movl 0x300+des_SPtrans(%ecx),%ebp
2326 xorl %ebp, %esi
2327 movl 24(%esp), %ebp
2328 movb %dh, %cl
2329 andl $0xff, %eax
2330 andl $0xff, %edx
2331 movl 0x600+des_SPtrans(%ebx),%ebx
2332 xorl %ebx, %esi
2333 movl 0x700+des_SPtrans(%ecx),%ebx
2334 xorl %ebx, %esi
2335 movl 0x400+des_SPtrans(%eax),%ebx
2336 xorl %ebx, %esi
2337 movl 0x500+des_SPtrans(%edx),%ebx
2338 xorl %ebx, %esi
2339
2340 /* Round 5 */
2341 movl 40(%ebp), %eax
2342 xorl %ebx, %ebx
2343 movl 44(%ebp), %edx
2344 xorl %esi, %eax
2345 xorl %esi, %edx
2346 andl $0xfcfcfcfc, %eax
2347 andl $0xcfcfcfcf, %edx
2348 movb %al, %bl
2349 movb %ah, %cl
2350 rorl $4, %edx
2351 movl des_SPtrans(%ebx),%ebp
2352 movb %dl, %bl
2353 xorl %ebp, %edi
2354 movl 0x200+des_SPtrans(%ecx),%ebp
2355 xorl %ebp, %edi
2356 movb %dh, %cl
2357 shrl $16, %eax
2358 movl 0x100+des_SPtrans(%ebx),%ebp
2359 xorl %ebp, %edi
2360 movb %ah, %bl
2361 shrl $16, %edx
2362 movl 0x300+des_SPtrans(%ecx),%ebp
2363 xorl %ebp, %edi
2364 movl 24(%esp), %ebp
2365 movb %dh, %cl
2366 andl $0xff, %eax
2367 andl $0xff, %edx
2368 movl 0x600+des_SPtrans(%ebx),%ebx
2369 xorl %ebx, %edi
2370 movl 0x700+des_SPtrans(%ecx),%ebx
2371 xorl %ebx, %edi
2372 movl 0x400+des_SPtrans(%eax),%ebx
2373 xorl %ebx, %edi
2374 movl 0x500+des_SPtrans(%edx),%ebx
2375 xorl %ebx, %edi
2376
2377 /* Round 4 */
2378 movl 32(%ebp), %eax
2379 xorl %ebx, %ebx
2380 movl 36(%ebp), %edx
2381 xorl %edi, %eax
2382 xorl %edi, %edx
2383 andl $0xfcfcfcfc, %eax
2384 andl $0xcfcfcfcf, %edx
2385 movb %al, %bl
2386 movb %ah, %cl
2387 rorl $4, %edx
2388 movl des_SPtrans(%ebx),%ebp
2389 movb %dl, %bl
2390 xorl %ebp, %esi
2391 movl 0x200+des_SPtrans(%ecx),%ebp
2392 xorl %ebp, %esi
2393 movb %dh, %cl
2394 shrl $16, %eax
2395 movl 0x100+des_SPtrans(%ebx),%ebp
2396 xorl %ebp, %esi
2397 movb %ah, %bl
2398 shrl $16, %edx
2399 movl 0x300+des_SPtrans(%ecx),%ebp
2400 xorl %ebp, %esi
2401 movl 24(%esp), %ebp
2402 movb %dh, %cl
2403 andl $0xff, %eax
2404 andl $0xff, %edx
2405 movl 0x600+des_SPtrans(%ebx),%ebx
2406 xorl %ebx, %esi
2407 movl 0x700+des_SPtrans(%ecx),%ebx
2408 xorl %ebx, %esi
2409 movl 0x400+des_SPtrans(%eax),%ebx
2410 xorl %ebx, %esi
2411 movl 0x500+des_SPtrans(%edx),%ebx
2412 xorl %ebx, %esi
2413
2414 /* Round 3 */
2415 movl 24(%ebp), %eax
2416 xorl %ebx, %ebx
2417 movl 28(%ebp), %edx
2418 xorl %esi, %eax
2419 xorl %esi, %edx
2420 andl $0xfcfcfcfc, %eax
2421 andl $0xcfcfcfcf, %edx
2422 movb %al, %bl
2423 movb %ah, %cl
2424 rorl $4, %edx
2425 movl des_SPtrans(%ebx),%ebp
2426 movb %dl, %bl
2427 xorl %ebp, %edi
2428 movl 0x200+des_SPtrans(%ecx),%ebp
2429 xorl %ebp, %edi
2430 movb %dh, %cl
2431 shrl $16, %eax
2432 movl 0x100+des_SPtrans(%ebx),%ebp
2433 xorl %ebp, %edi
2434 movb %ah, %bl
2435 shrl $16, %edx
2436 movl 0x300+des_SPtrans(%ecx),%ebp
2437 xorl %ebp, %edi
2438 movl 24(%esp), %ebp
2439 movb %dh, %cl
2440 andl $0xff, %eax
2441 andl $0xff, %edx
2442 movl 0x600+des_SPtrans(%ebx),%ebx
2443 xorl %ebx, %edi
2444 movl 0x700+des_SPtrans(%ecx),%ebx
2445 xorl %ebx, %edi
2446 movl 0x400+des_SPtrans(%eax),%ebx
2447 xorl %ebx, %edi
2448 movl 0x500+des_SPtrans(%edx),%ebx
2449 xorl %ebx, %edi
2450
2451 /* Round 2 */
2452 movl 16(%ebp), %eax
2453 xorl %ebx, %ebx
2454 movl 20(%ebp), %edx
2455 xorl %edi, %eax
2456 xorl %edi, %edx
2457 andl $0xfcfcfcfc, %eax
2458 andl $0xcfcfcfcf, %edx
2459 movb %al, %bl
2460 movb %ah, %cl
2461 rorl $4, %edx
2462 movl des_SPtrans(%ebx),%ebp
2463 movb %dl, %bl
2464 xorl %ebp, %esi
2465 movl 0x200+des_SPtrans(%ecx),%ebp
2466 xorl %ebp, %esi
2467 movb %dh, %cl
2468 shrl $16, %eax
2469 movl 0x100+des_SPtrans(%ebx),%ebp
2470 xorl %ebp, %esi
2471 movb %ah, %bl
2472 shrl $16, %edx
2473 movl 0x300+des_SPtrans(%ecx),%ebp
2474 xorl %ebp, %esi
2475 movl 24(%esp), %ebp
2476 movb %dh, %cl
2477 andl $0xff, %eax
2478 andl $0xff, %edx
2479 movl 0x600+des_SPtrans(%ebx),%ebx
2480 xorl %ebx, %esi
2481 movl 0x700+des_SPtrans(%ecx),%ebx
2482 xorl %ebx, %esi
2483 movl 0x400+des_SPtrans(%eax),%ebx
2484 xorl %ebx, %esi
2485 movl 0x500+des_SPtrans(%edx),%ebx
2486 xorl %ebx, %esi
2487
2488 /* Round 1 */
2489 movl 8(%ebp), %eax
2490 xorl %ebx, %ebx
2491 movl 12(%ebp), %edx
2492 xorl %esi, %eax
2493 xorl %esi, %edx
2494 andl $0xfcfcfcfc, %eax
2495 andl $0xcfcfcfcf, %edx
2496 movb %al, %bl
2497 movb %ah, %cl
2498 rorl $4, %edx
2499 movl des_SPtrans(%ebx),%ebp
2500 movb %dl, %bl
2501 xorl %ebp, %edi
2502 movl 0x200+des_SPtrans(%ecx),%ebp
2503 xorl %ebp, %edi
2504 movb %dh, %cl
2505 shrl $16, %eax
2506 movl 0x100+des_SPtrans(%ebx),%ebp
2507 xorl %ebp, %edi
2508 movb %ah, %bl
2509 shrl $16, %edx
2510 movl 0x300+des_SPtrans(%ecx),%ebp
2511 xorl %ebp, %edi
2512 movl 24(%esp), %ebp
2513 movb %dh, %cl
2514 andl $0xff, %eax
2515 andl $0xff, %edx
2516 movl 0x600+des_SPtrans(%ebx),%ebx
2517 xorl %ebx, %edi
2518 movl 0x700+des_SPtrans(%ecx),%ebx
2519 xorl %ebx, %edi
2520 movl 0x400+des_SPtrans(%eax),%ebx
2521 xorl %ebx, %edi
2522 movl 0x500+des_SPtrans(%edx),%ebx
2523 xorl %ebx, %edi
2524
2525 /* Round 0 */
2526 movl (%ebp), %eax
2527 xorl %ebx, %ebx
2528 movl 4(%ebp), %edx
2529 xorl %edi, %eax
2530 xorl %edi, %edx
2531 andl $0xfcfcfcfc, %eax
2532 andl $0xcfcfcfcf, %edx
2533 movb %al, %bl
2534 movb %ah, %cl
2535 rorl $4, %edx
2536 movl des_SPtrans(%ebx),%ebp
2537 movb %dl, %bl
2538 xorl %ebp, %esi
2539 movl 0x200+des_SPtrans(%ecx),%ebp
2540 xorl %ebp, %esi
2541 movb %dh, %cl
2542 shrl $16, %eax
2543 movl 0x100+des_SPtrans(%ebx),%ebp
2544 xorl %ebp, %esi
2545 movb %ah, %bl
2546 shrl $16, %edx
2547 movl 0x300+des_SPtrans(%ecx),%ebp
2548 xorl %ebp, %esi
2549 movl 24(%esp), %ebp
2550 movb %dh, %cl
2551 andl $0xff, %eax
2552 andl $0xff, %edx
2553 movl 0x600+des_SPtrans(%ebx),%ebx
2554 xorl %ebx, %esi
2555 movl 0x700+des_SPtrans(%ecx),%ebx
2556 xorl %ebx, %esi
2557 movl 0x400+des_SPtrans(%eax),%ebx
2558 xorl %ebx, %esi
2559 movl 0x500+des_SPtrans(%edx),%ebx
2560 xorl %ebx, %esi
2561.L003end:
2562
2563 /* Fixup */
2564 rorl $3, %edi
2565 movl 20(%esp), %eax
2566 rorl $3, %esi
2567 movl %edi, (%eax)
2568 movl %esi, 4(%eax)
2569 popl %ebp
2570 popl %ebx
2571 popl %edi
2572 popl %esi
2573 ret
2574.des_encrypt2_end:
2575 SIZE(des_encrypt2,.des_encrypt2_end-des_encrypt2)
2576.ident "desasm.pl"
2577.text
2578 .align ALIGN
2579.globl des_encrypt3
2580 TYPE(des_encrypt3,@function)
2581des_encrypt3:
2582 pushl %ebx
2583 movl 8(%esp), %ebx
2584 pushl %ebp
2585 pushl %esi
2586 pushl %edi
2587
2588 /* Load the data words */
2589 movl (%ebx), %edi
2590 movl 4(%ebx), %esi
2591 subl $12, %esp
2592
2593 /* IP */
2594 roll $4, %edi
2595 movl %edi, %edx
2596 xorl %esi, %edi
2597 andl $0xf0f0f0f0, %edi
2598 xorl %edi, %edx
2599 xorl %edi, %esi
2600
2601 roll $20, %esi
2602 movl %esi, %edi
2603 xorl %edx, %esi
2604 andl $0xfff0000f, %esi
2605 xorl %esi, %edi
2606 xorl %esi, %edx
2607
2608 roll $14, %edi
2609 movl %edi, %esi
2610 xorl %edx, %edi
2611 andl $0x33333333, %edi
2612 xorl %edi, %esi
2613 xorl %edi, %edx
2614
2615 roll $22, %edx
2616 movl %edx, %edi
2617 xorl %esi, %edx
2618 andl $0x03fc03fc, %edx
2619 xorl %edx, %edi
2620 xorl %edx, %esi
2621
2622 roll $9, %edi
2623 movl %edi, %edx
2624 xorl %esi, %edi
2625 andl $0xaaaaaaaa, %edi
2626 xorl %edi, %edx
2627 xorl %edi, %esi
2628
2629 rorl $3, %edx
2630 rorl $2, %esi
2631 movl %esi, 4(%ebx)
2632 movl 36(%esp), %eax
2633 movl %edx, (%ebx)
2634 movl 40(%esp), %edi
2635 movl 44(%esp), %esi
2636 movl $1, 8(%esp)
2637 movl %eax, 4(%esp)
2638 movl %ebx, (%esp)
2639 call des_encrypt2
2640 movl $0, 8(%esp)
2641 movl %edi, 4(%esp)
2642 movl %ebx, (%esp)
2643 call des_encrypt2
2644 movl $1, 8(%esp)
2645 movl %esi, 4(%esp)
2646 movl %ebx, (%esp)
2647 call des_encrypt2
2648 addl $12, %esp
2649 movl (%ebx), %edi
2650 movl 4(%ebx), %esi
2651
2652 /* FP */
2653 roll $2, %esi
2654 roll $3, %edi
2655 movl %edi, %eax
2656 xorl %esi, %edi
2657 andl $0xaaaaaaaa, %edi
2658 xorl %edi, %eax
2659 xorl %edi, %esi
2660
2661 roll $23, %eax
2662 movl %eax, %edi
2663 xorl %esi, %eax
2664 andl $0x03fc03fc, %eax
2665 xorl %eax, %edi
2666 xorl %eax, %esi
2667
2668 roll $10, %edi
2669 movl %edi, %eax
2670 xorl %esi, %edi
2671 andl $0x33333333, %edi
2672 xorl %edi, %eax
2673 xorl %edi, %esi
2674
2675 roll $18, %esi
2676 movl %esi, %edi
2677 xorl %eax, %esi
2678 andl $0xfff0000f, %esi
2679 xorl %esi, %edi
2680 xorl %esi, %eax
2681
2682 roll $12, %edi
2683 movl %edi, %esi
2684 xorl %eax, %edi
2685 andl $0xf0f0f0f0, %edi
2686 xorl %edi, %esi
2687 xorl %edi, %eax
2688
2689 rorl $4, %eax
2690 movl %eax, (%ebx)
2691 movl %esi, 4(%ebx)
2692 popl %edi
2693 popl %esi
2694 popl %ebp
2695 popl %ebx
2696 ret
2697.des_encrypt3_end:
2698 SIZE(des_encrypt3,.des_encrypt3_end-des_encrypt3)
2699.ident "desasm.pl"
2700.text
2701 .align ALIGN
2702.globl des_decrypt3
2703 TYPE(des_decrypt3,@function)
2704des_decrypt3:
2705 pushl %ebx
2706 movl 8(%esp), %ebx
2707 pushl %ebp
2708 pushl %esi
2709 pushl %edi
2710
2711 /* Load the data words */
2712 movl (%ebx), %edi
2713 movl 4(%ebx), %esi
2714 subl $12, %esp
2715
2716 /* IP */
2717 roll $4, %edi
2718 movl %edi, %edx
2719 xorl %esi, %edi
2720 andl $0xf0f0f0f0, %edi
2721 xorl %edi, %edx
2722 xorl %edi, %esi
2723
2724 roll $20, %esi
2725 movl %esi, %edi
2726 xorl %edx, %esi
2727 andl $0xfff0000f, %esi
2728 xorl %esi, %edi
2729 xorl %esi, %edx
2730
2731 roll $14, %edi
2732 movl %edi, %esi
2733 xorl %edx, %edi
2734 andl $0x33333333, %edi
2735 xorl %edi, %esi
2736 xorl %edi, %edx
2737
2738 roll $22, %edx
2739 movl %edx, %edi
2740 xorl %esi, %edx
2741 andl $0x03fc03fc, %edx
2742 xorl %edx, %edi
2743 xorl %edx, %esi
2744
2745 roll $9, %edi
2746 movl %edi, %edx
2747 xorl %esi, %edi
2748 andl $0xaaaaaaaa, %edi
2749 xorl %edi, %edx
2750 xorl %edi, %esi
2751
2752 rorl $3, %edx
2753 rorl $2, %esi
2754 movl %esi, 4(%ebx)
2755 movl 36(%esp), %esi
2756 movl %edx, (%ebx)
2757 movl 40(%esp), %edi
2758 movl 44(%esp), %eax
2759 movl $0, 8(%esp)
2760 movl %eax, 4(%esp)
2761 movl %ebx, (%esp)
2762 call des_encrypt2
2763 movl $1, 8(%esp)
2764 movl %edi, 4(%esp)
2765 movl %ebx, (%esp)
2766 call des_encrypt2
2767 movl $0, 8(%esp)
2768 movl %esi, 4(%esp)
2769 movl %ebx, (%esp)
2770 call des_encrypt2
2771 addl $12, %esp
2772 movl (%ebx), %edi
2773 movl 4(%ebx), %esi
2774
2775 /* FP */
2776 roll $2, %esi
2777 roll $3, %edi
2778 movl %edi, %eax
2779 xorl %esi, %edi
2780 andl $0xaaaaaaaa, %edi
2781 xorl %edi, %eax
2782 xorl %edi, %esi
2783
2784 roll $23, %eax
2785 movl %eax, %edi
2786 xorl %esi, %eax
2787 andl $0x03fc03fc, %eax
2788 xorl %eax, %edi
2789 xorl %eax, %esi
2790
2791 roll $10, %edi
2792 movl %edi, %eax
2793 xorl %esi, %edi
2794 andl $0x33333333, %edi
2795 xorl %edi, %eax
2796 xorl %edi, %esi
2797
2798 roll $18, %esi
2799 movl %esi, %edi
2800 xorl %eax, %esi
2801 andl $0xfff0000f, %esi
2802 xorl %esi, %edi
2803 xorl %esi, %eax
2804
2805 roll $12, %edi
2806 movl %edi, %esi
2807 xorl %eax, %edi
2808 andl $0xf0f0f0f0, %edi
2809 xorl %edi, %esi
2810 xorl %edi, %eax
2811
2812 rorl $4, %eax
2813 movl %eax, (%ebx)
2814 movl %esi, 4(%ebx)
2815 popl %edi
2816 popl %esi
2817 popl %ebp
2818 popl %ebx
2819 ret
2820.des_decrypt3_end:
2821 SIZE(des_decrypt3,.des_decrypt3_end-des_decrypt3)
2822.ident "desasm.pl"
2823.text
2824 .align ALIGN
2825.globl des_ncbc_encrypt
2826 TYPE(des_ncbc_encrypt,@function)
2827des_ncbc_encrypt:
2828
2829 pushl %ebp
2830 pushl %ebx
2831 pushl %esi
2832 pushl %edi
2833 movl 28(%esp), %ebp
2834 /* getting iv ptr from parameter 4 */
2835 movl 36(%esp), %ebx
2836 movl (%ebx), %esi
2837 movl 4(%ebx), %edi
2838 pushl %edi
2839 pushl %esi
2840 pushl %edi
2841 pushl %esi
2842 movl %esp, %ebx
2843 movl 36(%esp), %esi
2844 movl 40(%esp), %edi
2845 /* getting encrypt flag from parameter 5 */
2846 movl 56(%esp), %ecx
2847 /* get and push parameter 5 */
2848 pushl %ecx
2849 /* get and push parameter 3 */
2850 movl 52(%esp), %eax
2851 pushl %eax
2852 pushl %ebx
2853 cmpl $0, %ecx
2854 jz .L004decrypt
2855 andl $4294967288, %ebp
2856 movl 12(%esp), %eax
2857 movl 16(%esp), %ebx
2858 jz .L005encrypt_finish
2859.L006encrypt_loop:
2860 movl (%esi), %ecx
2861 movl 4(%esi), %edx
2862 xorl %ecx, %eax
2863 xorl %edx, %ebx
2864 movl %eax, 12(%esp)
2865 movl %ebx, 16(%esp)
2866 call des_encrypt
2867 movl 12(%esp), %eax
2868 movl 16(%esp), %ebx
2869 movl %eax, (%edi)
2870 movl %ebx, 4(%edi)
2871 addl $8, %esi
2872 addl $8, %edi
2873 subl $8, %ebp
2874 jnz .L006encrypt_loop
2875.L005encrypt_finish:
2876 movl 56(%esp), %ebp
2877 andl $7, %ebp
2878 jz .L007finish
2879 xorl %ecx, %ecx
2880 xorl %edx, %edx
2881 movl .L008cbc_enc_jmp_table(,%ebp,4),%ebp
2882 jmp *%ebp
2883.L009ej7:
2884 movb 6(%esi), %dh
2885 sall $8, %edx
2886.L010ej6:
2887 movb 5(%esi), %dh
2888.L011ej5:
2889 movb 4(%esi), %dl
2890.L012ej4:
2891 movl (%esi), %ecx
2892 jmp .L013ejend
2893.L014ej3:
2894 movb 2(%esi), %ch
2895 sall $8, %ecx
2896.L015ej2:
2897 movb 1(%esi), %ch
2898.L016ej1:
2899 movb (%esi), %cl
2900.L013ejend:
2901 xorl %ecx, %eax
2902 xorl %edx, %ebx
2903 movl %eax, 12(%esp)
2904 movl %ebx, 16(%esp)
2905 call des_encrypt
2906 movl 12(%esp), %eax
2907 movl 16(%esp), %ebx
2908 movl %eax, (%edi)
2909 movl %ebx, 4(%edi)
2910 jmp .L007finish
2911.align ALIGN
2912.L004decrypt:
2913 andl $4294967288, %ebp
2914 movl 20(%esp), %eax
2915 movl 24(%esp), %ebx
2916 jz .L017decrypt_finish
2917.L018decrypt_loop:
2918 movl (%esi), %eax
2919 movl 4(%esi), %ebx
2920 movl %eax, 12(%esp)
2921 movl %ebx, 16(%esp)
2922 call des_encrypt
2923 movl 12(%esp), %eax
2924 movl 16(%esp), %ebx
2925 movl 20(%esp), %ecx
2926 movl 24(%esp), %edx
2927 xorl %eax, %ecx
2928 xorl %ebx, %edx
2929 movl (%esi), %eax
2930 movl 4(%esi), %ebx
2931 movl %ecx, (%edi)
2932 movl %edx, 4(%edi)
2933 movl %eax, 20(%esp)
2934 movl %ebx, 24(%esp)
2935 addl $8, %esi
2936 addl $8, %edi
2937 subl $8, %ebp
2938 jnz .L018decrypt_loop
2939.L017decrypt_finish:
2940 movl 56(%esp), %ebp
2941 andl $7, %ebp
2942 jz .L007finish
2943 movl (%esi), %eax
2944 movl 4(%esi), %ebx
2945 movl %eax, 12(%esp)
2946 movl %ebx, 16(%esp)
2947 call des_encrypt
2948 movl 12(%esp), %eax
2949 movl 16(%esp), %ebx
2950 movl 20(%esp), %ecx
2951 movl 24(%esp), %edx
2952 xorl %eax, %ecx
2953 xorl %ebx, %edx
2954 movl (%esi), %eax
2955 movl 4(%esi), %ebx
2956.L019dj7:
2957 rorl $16, %edx
2958 movb %dl, 6(%edi)
2959 shrl $16, %edx
2960.L020dj6:
2961 movb %dh, 5(%edi)
2962.L021dj5:
2963 movb %dl, 4(%edi)
2964.L022dj4:
2965 movl %ecx, (%edi)
2966 jmp .L023djend
2967.L024dj3:
2968 rorl $16, %ecx
2969 movb %cl, 2(%edi)
2970 sall $16, %ecx
2971.L025dj2:
2972 movb %ch, 1(%esi)
2973.L026dj1:
2974 movb %cl, (%esi)
2975.L023djend:
2976 jmp .L007finish
2977.align ALIGN
2978.L007finish:
2979 movl 64(%esp), %ecx
2980 addl $28, %esp
2981 movl %eax, (%ecx)
2982 movl %ebx, 4(%ecx)
2983 popl %edi
2984 popl %esi
2985 popl %ebx
2986 popl %ebp
2987 ret
2988.align ALIGN
2989.L008cbc_enc_jmp_table:
2990 .long 0
2991 .long .L016ej1
2992 .long .L015ej2
2993 .long .L014ej3
2994 .long .L012ej4
2995 .long .L011ej5
2996 .long .L010ej6
2997 .long .L009ej7
2998.align ALIGN
2999.L027cbc_dec_jmp_table:
3000 .long 0
3001 .long .L026dj1
3002 .long .L025dj2
3003 .long .L024dj3
3004 .long .L022dj4
3005 .long .L021dj5
3006 .long .L020dj6
3007 .long .L019dj7
3008.des_ncbc_encrypt_end:
3009 SIZE(des_ncbc_encrypt,.des_ncbc_encrypt_end-des_ncbc_encrypt)
3010.ident "desasm.pl"
3011.text
3012 .align ALIGN
3013.globl des_ede3_cbc_encrypt
3014 TYPE(des_ede3_cbc_encrypt,@function)
3015des_ede3_cbc_encrypt:
3016
3017 pushl %ebp
3018 pushl %ebx
3019 pushl %esi
3020 pushl %edi
3021 movl 28(%esp), %ebp
3022 /* getting iv ptr from parameter 6 */
3023 movl 44(%esp), %ebx
3024 movl (%ebx), %esi
3025 movl 4(%ebx), %edi
3026 pushl %edi
3027 pushl %esi
3028 pushl %edi
3029 pushl %esi
3030 movl %esp, %ebx
3031 movl 36(%esp), %esi
3032 movl 40(%esp), %edi
3033 /* getting encrypt flag from parameter 7 */
3034 movl 64(%esp), %ecx
3035 /* get and push parameter 5 */
3036 movl 56(%esp), %eax
3037 pushl %eax
3038 /* get and push parameter 4 */
3039 movl 56(%esp), %eax
3040 pushl %eax
3041 /* get and push parameter 3 */
3042 movl 56(%esp), %eax
3043 pushl %eax
3044 pushl %ebx
3045 cmpl $0, %ecx
3046 jz .L028decrypt
3047 andl $4294967288, %ebp
3048 movl 16(%esp), %eax
3049 movl 20(%esp), %ebx
3050 jz .L029encrypt_finish
3051.L030encrypt_loop:
3052 movl (%esi), %ecx
3053 movl 4(%esi), %edx
3054 xorl %ecx, %eax
3055 xorl %edx, %ebx
3056 movl %eax, 16(%esp)
3057 movl %ebx, 20(%esp)
3058 call des_encrypt3
3059 movl 16(%esp), %eax
3060 movl 20(%esp), %ebx
3061 movl %eax, (%edi)
3062 movl %ebx, 4(%edi)
3063 addl $8, %esi
3064 addl $8, %edi
3065 subl $8, %ebp
3066 jnz .L030encrypt_loop
3067.L029encrypt_finish:
3068 movl 60(%esp), %ebp
3069 andl $7, %ebp
3070 jz .L031finish
3071 xorl %ecx, %ecx
3072 xorl %edx, %edx
3073 movl .L032cbc_enc_jmp_table(,%ebp,4),%ebp
3074 jmp *%ebp
3075.L033ej7:
3076 movb 6(%esi), %dh
3077 sall $8, %edx
3078.L034ej6:
3079 movb 5(%esi), %dh
3080.L035ej5:
3081 movb 4(%esi), %dl
3082.L036ej4:
3083 movl (%esi), %ecx
3084 jmp .L037ejend
3085.L038ej3:
3086 movb 2(%esi), %ch
3087 sall $8, %ecx
3088.L039ej2:
3089 movb 1(%esi), %ch
3090.L040ej1:
3091 movb (%esi), %cl
3092.L037ejend:
3093 xorl %ecx, %eax
3094 xorl %edx, %ebx
3095 movl %eax, 16(%esp)
3096 movl %ebx, 20(%esp)
3097 call des_encrypt3
3098 movl 16(%esp), %eax
3099 movl 20(%esp), %ebx
3100 movl %eax, (%edi)
3101 movl %ebx, 4(%edi)
3102 jmp .L031finish
3103.align ALIGN
3104.L028decrypt:
3105 andl $4294967288, %ebp
3106 movl 24(%esp), %eax
3107 movl 28(%esp), %ebx
3108 jz .L041decrypt_finish
3109.L042decrypt_loop:
3110 movl (%esi), %eax
3111 movl 4(%esi), %ebx
3112 movl %eax, 16(%esp)
3113 movl %ebx, 20(%esp)
3114 call des_decrypt3
3115 movl 16(%esp), %eax
3116 movl 20(%esp), %ebx
3117 movl 24(%esp), %ecx
3118 movl 28(%esp), %edx
3119 xorl %eax, %ecx
3120 xorl %ebx, %edx
3121 movl (%esi), %eax
3122 movl 4(%esi), %ebx
3123 movl %ecx, (%edi)
3124 movl %edx, 4(%edi)
3125 movl %eax, 24(%esp)
3126 movl %ebx, 28(%esp)
3127 addl $8, %esi
3128 addl $8, %edi
3129 subl $8, %ebp
3130 jnz .L042decrypt_loop
3131.L041decrypt_finish:
3132 movl 60(%esp), %ebp
3133 andl $7, %ebp
3134 jz .L031finish
3135 movl (%esi), %eax
3136 movl 4(%esi), %ebx
3137 movl %eax, 16(%esp)
3138 movl %ebx, 20(%esp)
3139 call des_decrypt3
3140 movl 16(%esp), %eax
3141 movl 20(%esp), %ebx
3142 movl 24(%esp), %ecx
3143 movl 28(%esp), %edx
3144 xorl %eax, %ecx
3145 xorl %ebx, %edx
3146 movl (%esi), %eax
3147 movl 4(%esi), %ebx
3148.L043dj7:
3149 rorl $16, %edx
3150 movb %dl, 6(%edi)
3151 shrl $16, %edx
3152.L044dj6:
3153 movb %dh, 5(%edi)
3154.L045dj5:
3155 movb %dl, 4(%edi)
3156.L046dj4:
3157 movl %ecx, (%edi)
3158 jmp .L047djend
3159.L048dj3:
3160 rorl $16, %ecx
3161 movb %cl, 2(%edi)
3162 sall $16, %ecx
3163.L049dj2:
3164 movb %ch, 1(%esi)
3165.L050dj1:
3166 movb %cl, (%esi)
3167.L047djend:
3168 jmp .L031finish
3169.align ALIGN
3170.L031finish:
3171 movl 76(%esp), %ecx
3172 addl $32, %esp
3173 movl %eax, (%ecx)
3174 movl %ebx, 4(%ecx)
3175 popl %edi
3176 popl %esi
3177 popl %ebx
3178 popl %ebp
3179 ret
3180.align ALIGN
3181.L032cbc_enc_jmp_table:
3182 .long 0
3183 .long .L040ej1
3184 .long .L039ej2
3185 .long .L038ej3
3186 .long .L036ej4
3187 .long .L035ej5
3188 .long .L034ej6
3189 .long .L033ej7
3190.align ALIGN
3191.L051cbc_dec_jmp_table:
3192 .long 0
3193 .long .L050dj1
3194 .long .L049dj2
3195 .long .L048dj3
3196 .long .L046dj4
3197 .long .L045dj5
3198 .long .L044dj6
3199 .long .L043dj7
3200.des_ede3_cbc_encrypt_end:
3201 SIZE(des_ede3_cbc_encrypt,.des_ede3_cbc_encrypt_end-des_ede3_cbc_encrypt)
3202.ident "desasm.pl"
diff --git a/src/lib/libcrypto/des/asm/y-win32.asm b/src/lib/libcrypto/des/asm/y-win32.asm
new file mode 100644
index 0000000000..af5c102422
--- /dev/null
+++ b/src/lib/libcrypto/des/asm/y-win32.asm
@@ -0,0 +1,929 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by crypt586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE crypt586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _fcrypt_body
12EXTRN _des_SPtrans:DWORD
13_fcrypt_body PROC NEAR
14 push ebp
15 push ebx
16 push esi
17 push edi
18 ;
19 ; Load the 2 words
20 xor edi, edi
21 xor esi, esi
22 mov ebp, DWORD PTR 24[esp]
23 push 25
24L000start:
25 ;
26 ; Round 0
27 mov eax, DWORD PTR 32[esp]
28 mov edx, esi
29 shr edx, 16
30 mov ecx, DWORD PTR 36[esp]
31 xor edx, esi
32 and eax, edx
33 and edx, ecx
34 mov ebx, eax
35 shl ebx, 16
36 mov ecx, edx
37 shl ecx, 16
38 xor eax, ebx
39 xor edx, ecx
40 mov ebx, DWORD PTR [ebp]
41 xor eax, ebx
42 mov ecx, DWORD PTR 4[ebp]
43 xor eax, esi
44 xor edx, esi
45 xor edx, ecx
46 and eax, 0fcfcfcfch
47 xor ebx, ebx
48 and edx, 0cfcfcfcfh
49 xor ecx, ecx
50 mov bl, al
51 mov cl, ah
52 ror edx, 4
53 mov ebp, DWORD PTR _des_SPtrans[ebx]
54 mov bl, dl
55 xor edi, ebp
56 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
57 xor edi, ebp
58 mov cl, dh
59 shr eax, 16
60 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
61 xor edi, ebp
62 mov bl, ah
63 shr edx, 16
64 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
65 xor edi, ebp
66 mov ebp, DWORD PTR 28[esp]
67 mov cl, dh
68 and eax, 0ffh
69 and edx, 0ffh
70 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
71 xor edi, ebx
72 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
73 xor edi, ebx
74 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
75 xor edi, ebx
76 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
77 xor edi, ebx
78 ;
79 ; Round 1
80 mov eax, DWORD PTR 32[esp]
81 mov edx, edi
82 shr edx, 16
83 mov ecx, DWORD PTR 36[esp]
84 xor edx, edi
85 and eax, edx
86 and edx, ecx
87 mov ebx, eax
88 shl ebx, 16
89 mov ecx, edx
90 shl ecx, 16
91 xor eax, ebx
92 xor edx, ecx
93 mov ebx, DWORD PTR 8[ebp]
94 xor eax, ebx
95 mov ecx, DWORD PTR 12[ebp]
96 xor eax, edi
97 xor edx, edi
98 xor edx, ecx
99 and eax, 0fcfcfcfch
100 xor ebx, ebx
101 and edx, 0cfcfcfcfh
102 xor ecx, ecx
103 mov bl, al
104 mov cl, ah
105 ror edx, 4
106 mov ebp, DWORD PTR _des_SPtrans[ebx]
107 mov bl, dl
108 xor esi, ebp
109 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
110 xor esi, ebp
111 mov cl, dh
112 shr eax, 16
113 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
114 xor esi, ebp
115 mov bl, ah
116 shr edx, 16
117 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
118 xor esi, ebp
119 mov ebp, DWORD PTR 28[esp]
120 mov cl, dh
121 and eax, 0ffh
122 and edx, 0ffh
123 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
124 xor esi, ebx
125 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
126 xor esi, ebx
127 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
128 xor esi, ebx
129 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
130 xor esi, ebx
131 ;
132 ; Round 2
133 mov eax, DWORD PTR 32[esp]
134 mov edx, esi
135 shr edx, 16
136 mov ecx, DWORD PTR 36[esp]
137 xor edx, esi
138 and eax, edx
139 and edx, ecx
140 mov ebx, eax
141 shl ebx, 16
142 mov ecx, edx
143 shl ecx, 16
144 xor eax, ebx
145 xor edx, ecx
146 mov ebx, DWORD PTR 16[ebp]
147 xor eax, ebx
148 mov ecx, DWORD PTR 20[ebp]
149 xor eax, esi
150 xor edx, esi
151 xor edx, ecx
152 and eax, 0fcfcfcfch
153 xor ebx, ebx
154 and edx, 0cfcfcfcfh
155 xor ecx, ecx
156 mov bl, al
157 mov cl, ah
158 ror edx, 4
159 mov ebp, DWORD PTR _des_SPtrans[ebx]
160 mov bl, dl
161 xor edi, ebp
162 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
163 xor edi, ebp
164 mov cl, dh
165 shr eax, 16
166 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
167 xor edi, ebp
168 mov bl, ah
169 shr edx, 16
170 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
171 xor edi, ebp
172 mov ebp, DWORD PTR 28[esp]
173 mov cl, dh
174 and eax, 0ffh
175 and edx, 0ffh
176 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
177 xor edi, ebx
178 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
179 xor edi, ebx
180 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
181 xor edi, ebx
182 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
183 xor edi, ebx
184 ;
185 ; Round 3
186 mov eax, DWORD PTR 32[esp]
187 mov edx, edi
188 shr edx, 16
189 mov ecx, DWORD PTR 36[esp]
190 xor edx, edi
191 and eax, edx
192 and edx, ecx
193 mov ebx, eax
194 shl ebx, 16
195 mov ecx, edx
196 shl ecx, 16
197 xor eax, ebx
198 xor edx, ecx
199 mov ebx, DWORD PTR 24[ebp]
200 xor eax, ebx
201 mov ecx, DWORD PTR 28[ebp]
202 xor eax, edi
203 xor edx, edi
204 xor edx, ecx
205 and eax, 0fcfcfcfch
206 xor ebx, ebx
207 and edx, 0cfcfcfcfh
208 xor ecx, ecx
209 mov bl, al
210 mov cl, ah
211 ror edx, 4
212 mov ebp, DWORD PTR _des_SPtrans[ebx]
213 mov bl, dl
214 xor esi, ebp
215 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
216 xor esi, ebp
217 mov cl, dh
218 shr eax, 16
219 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
220 xor esi, ebp
221 mov bl, ah
222 shr edx, 16
223 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
224 xor esi, ebp
225 mov ebp, DWORD PTR 28[esp]
226 mov cl, dh
227 and eax, 0ffh
228 and edx, 0ffh
229 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
230 xor esi, ebx
231 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
232 xor esi, ebx
233 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
234 xor esi, ebx
235 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
236 xor esi, ebx
237 ;
238 ; Round 4
239 mov eax, DWORD PTR 32[esp]
240 mov edx, esi
241 shr edx, 16
242 mov ecx, DWORD PTR 36[esp]
243 xor edx, esi
244 and eax, edx
245 and edx, ecx
246 mov ebx, eax
247 shl ebx, 16
248 mov ecx, edx
249 shl ecx, 16
250 xor eax, ebx
251 xor edx, ecx
252 mov ebx, DWORD PTR 32[ebp]
253 xor eax, ebx
254 mov ecx, DWORD PTR 36[ebp]
255 xor eax, esi
256 xor edx, esi
257 xor edx, ecx
258 and eax, 0fcfcfcfch
259 xor ebx, ebx
260 and edx, 0cfcfcfcfh
261 xor ecx, ecx
262 mov bl, al
263 mov cl, ah
264 ror edx, 4
265 mov ebp, DWORD PTR _des_SPtrans[ebx]
266 mov bl, dl
267 xor edi, ebp
268 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
269 xor edi, ebp
270 mov cl, dh
271 shr eax, 16
272 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
273 xor edi, ebp
274 mov bl, ah
275 shr edx, 16
276 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
277 xor edi, ebp
278 mov ebp, DWORD PTR 28[esp]
279 mov cl, dh
280 and eax, 0ffh
281 and edx, 0ffh
282 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
283 xor edi, ebx
284 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
285 xor edi, ebx
286 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
287 xor edi, ebx
288 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
289 xor edi, ebx
290 ;
291 ; Round 5
292 mov eax, DWORD PTR 32[esp]
293 mov edx, edi
294 shr edx, 16
295 mov ecx, DWORD PTR 36[esp]
296 xor edx, edi
297 and eax, edx
298 and edx, ecx
299 mov ebx, eax
300 shl ebx, 16
301 mov ecx, edx
302 shl ecx, 16
303 xor eax, ebx
304 xor edx, ecx
305 mov ebx, DWORD PTR 40[ebp]
306 xor eax, ebx
307 mov ecx, DWORD PTR 44[ebp]
308 xor eax, edi
309 xor edx, edi
310 xor edx, ecx
311 and eax, 0fcfcfcfch
312 xor ebx, ebx
313 and edx, 0cfcfcfcfh
314 xor ecx, ecx
315 mov bl, al
316 mov cl, ah
317 ror edx, 4
318 mov ebp, DWORD PTR _des_SPtrans[ebx]
319 mov bl, dl
320 xor esi, ebp
321 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
322 xor esi, ebp
323 mov cl, dh
324 shr eax, 16
325 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
326 xor esi, ebp
327 mov bl, ah
328 shr edx, 16
329 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
330 xor esi, ebp
331 mov ebp, DWORD PTR 28[esp]
332 mov cl, dh
333 and eax, 0ffh
334 and edx, 0ffh
335 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
336 xor esi, ebx
337 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
338 xor esi, ebx
339 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
340 xor esi, ebx
341 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
342 xor esi, ebx
343 ;
344 ; Round 6
345 mov eax, DWORD PTR 32[esp]
346 mov edx, esi
347 shr edx, 16
348 mov ecx, DWORD PTR 36[esp]
349 xor edx, esi
350 and eax, edx
351 and edx, ecx
352 mov ebx, eax
353 shl ebx, 16
354 mov ecx, edx
355 shl ecx, 16
356 xor eax, ebx
357 xor edx, ecx
358 mov ebx, DWORD PTR 48[ebp]
359 xor eax, ebx
360 mov ecx, DWORD PTR 52[ebp]
361 xor eax, esi
362 xor edx, esi
363 xor edx, ecx
364 and eax, 0fcfcfcfch
365 xor ebx, ebx
366 and edx, 0cfcfcfcfh
367 xor ecx, ecx
368 mov bl, al
369 mov cl, ah
370 ror edx, 4
371 mov ebp, DWORD PTR _des_SPtrans[ebx]
372 mov bl, dl
373 xor edi, ebp
374 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
375 xor edi, ebp
376 mov cl, dh
377 shr eax, 16
378 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
379 xor edi, ebp
380 mov bl, ah
381 shr edx, 16
382 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
383 xor edi, ebp
384 mov ebp, DWORD PTR 28[esp]
385 mov cl, dh
386 and eax, 0ffh
387 and edx, 0ffh
388 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
389 xor edi, ebx
390 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
391 xor edi, ebx
392 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
393 xor edi, ebx
394 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
395 xor edi, ebx
396 ;
397 ; Round 7
398 mov eax, DWORD PTR 32[esp]
399 mov edx, edi
400 shr edx, 16
401 mov ecx, DWORD PTR 36[esp]
402 xor edx, edi
403 and eax, edx
404 and edx, ecx
405 mov ebx, eax
406 shl ebx, 16
407 mov ecx, edx
408 shl ecx, 16
409 xor eax, ebx
410 xor edx, ecx
411 mov ebx, DWORD PTR 56[ebp]
412 xor eax, ebx
413 mov ecx, DWORD PTR 60[ebp]
414 xor eax, edi
415 xor edx, edi
416 xor edx, ecx
417 and eax, 0fcfcfcfch
418 xor ebx, ebx
419 and edx, 0cfcfcfcfh
420 xor ecx, ecx
421 mov bl, al
422 mov cl, ah
423 ror edx, 4
424 mov ebp, DWORD PTR _des_SPtrans[ebx]
425 mov bl, dl
426 xor esi, ebp
427 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
428 xor esi, ebp
429 mov cl, dh
430 shr eax, 16
431 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
432 xor esi, ebp
433 mov bl, ah
434 shr edx, 16
435 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
436 xor esi, ebp
437 mov ebp, DWORD PTR 28[esp]
438 mov cl, dh
439 and eax, 0ffh
440 and edx, 0ffh
441 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
442 xor esi, ebx
443 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
444 xor esi, ebx
445 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
446 xor esi, ebx
447 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
448 xor esi, ebx
449 ;
450 ; Round 8
451 mov eax, DWORD PTR 32[esp]
452 mov edx, esi
453 shr edx, 16
454 mov ecx, DWORD PTR 36[esp]
455 xor edx, esi
456 and eax, edx
457 and edx, ecx
458 mov ebx, eax
459 shl ebx, 16
460 mov ecx, edx
461 shl ecx, 16
462 xor eax, ebx
463 xor edx, ecx
464 mov ebx, DWORD PTR 64[ebp]
465 xor eax, ebx
466 mov ecx, DWORD PTR 68[ebp]
467 xor eax, esi
468 xor edx, esi
469 xor edx, ecx
470 and eax, 0fcfcfcfch
471 xor ebx, ebx
472 and edx, 0cfcfcfcfh
473 xor ecx, ecx
474 mov bl, al
475 mov cl, ah
476 ror edx, 4
477 mov ebp, DWORD PTR _des_SPtrans[ebx]
478 mov bl, dl
479 xor edi, ebp
480 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
481 xor edi, ebp
482 mov cl, dh
483 shr eax, 16
484 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
485 xor edi, ebp
486 mov bl, ah
487 shr edx, 16
488 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
489 xor edi, ebp
490 mov ebp, DWORD PTR 28[esp]
491 mov cl, dh
492 and eax, 0ffh
493 and edx, 0ffh
494 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
495 xor edi, ebx
496 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
497 xor edi, ebx
498 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
499 xor edi, ebx
500 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
501 xor edi, ebx
502 ;
503 ; Round 9
504 mov eax, DWORD PTR 32[esp]
505 mov edx, edi
506 shr edx, 16
507 mov ecx, DWORD PTR 36[esp]
508 xor edx, edi
509 and eax, edx
510 and edx, ecx
511 mov ebx, eax
512 shl ebx, 16
513 mov ecx, edx
514 shl ecx, 16
515 xor eax, ebx
516 xor edx, ecx
517 mov ebx, DWORD PTR 72[ebp]
518 xor eax, ebx
519 mov ecx, DWORD PTR 76[ebp]
520 xor eax, edi
521 xor edx, edi
522 xor edx, ecx
523 and eax, 0fcfcfcfch
524 xor ebx, ebx
525 and edx, 0cfcfcfcfh
526 xor ecx, ecx
527 mov bl, al
528 mov cl, ah
529 ror edx, 4
530 mov ebp, DWORD PTR _des_SPtrans[ebx]
531 mov bl, dl
532 xor esi, ebp
533 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
534 xor esi, ebp
535 mov cl, dh
536 shr eax, 16
537 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
538 xor esi, ebp
539 mov bl, ah
540 shr edx, 16
541 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
542 xor esi, ebp
543 mov ebp, DWORD PTR 28[esp]
544 mov cl, dh
545 and eax, 0ffh
546 and edx, 0ffh
547 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
548 xor esi, ebx
549 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
550 xor esi, ebx
551 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
552 xor esi, ebx
553 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
554 xor esi, ebx
555 ;
556 ; Round 10
557 mov eax, DWORD PTR 32[esp]
558 mov edx, esi
559 shr edx, 16
560 mov ecx, DWORD PTR 36[esp]
561 xor edx, esi
562 and eax, edx
563 and edx, ecx
564 mov ebx, eax
565 shl ebx, 16
566 mov ecx, edx
567 shl ecx, 16
568 xor eax, ebx
569 xor edx, ecx
570 mov ebx, DWORD PTR 80[ebp]
571 xor eax, ebx
572 mov ecx, DWORD PTR 84[ebp]
573 xor eax, esi
574 xor edx, esi
575 xor edx, ecx
576 and eax, 0fcfcfcfch
577 xor ebx, ebx
578 and edx, 0cfcfcfcfh
579 xor ecx, ecx
580 mov bl, al
581 mov cl, ah
582 ror edx, 4
583 mov ebp, DWORD PTR _des_SPtrans[ebx]
584 mov bl, dl
585 xor edi, ebp
586 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
587 xor edi, ebp
588 mov cl, dh
589 shr eax, 16
590 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
591 xor edi, ebp
592 mov bl, ah
593 shr edx, 16
594 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
595 xor edi, ebp
596 mov ebp, DWORD PTR 28[esp]
597 mov cl, dh
598 and eax, 0ffh
599 and edx, 0ffh
600 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
601 xor edi, ebx
602 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
603 xor edi, ebx
604 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
605 xor edi, ebx
606 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
607 xor edi, ebx
608 ;
609 ; Round 11
610 mov eax, DWORD PTR 32[esp]
611 mov edx, edi
612 shr edx, 16
613 mov ecx, DWORD PTR 36[esp]
614 xor edx, edi
615 and eax, edx
616 and edx, ecx
617 mov ebx, eax
618 shl ebx, 16
619 mov ecx, edx
620 shl ecx, 16
621 xor eax, ebx
622 xor edx, ecx
623 mov ebx, DWORD PTR 88[ebp]
624 xor eax, ebx
625 mov ecx, DWORD PTR 92[ebp]
626 xor eax, edi
627 xor edx, edi
628 xor edx, ecx
629 and eax, 0fcfcfcfch
630 xor ebx, ebx
631 and edx, 0cfcfcfcfh
632 xor ecx, ecx
633 mov bl, al
634 mov cl, ah
635 ror edx, 4
636 mov ebp, DWORD PTR _des_SPtrans[ebx]
637 mov bl, dl
638 xor esi, ebp
639 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
640 xor esi, ebp
641 mov cl, dh
642 shr eax, 16
643 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
644 xor esi, ebp
645 mov bl, ah
646 shr edx, 16
647 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
648 xor esi, ebp
649 mov ebp, DWORD PTR 28[esp]
650 mov cl, dh
651 and eax, 0ffh
652 and edx, 0ffh
653 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
654 xor esi, ebx
655 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
656 xor esi, ebx
657 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
658 xor esi, ebx
659 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
660 xor esi, ebx
661 ;
662 ; Round 12
663 mov eax, DWORD PTR 32[esp]
664 mov edx, esi
665 shr edx, 16
666 mov ecx, DWORD PTR 36[esp]
667 xor edx, esi
668 and eax, edx
669 and edx, ecx
670 mov ebx, eax
671 shl ebx, 16
672 mov ecx, edx
673 shl ecx, 16
674 xor eax, ebx
675 xor edx, ecx
676 mov ebx, DWORD PTR 96[ebp]
677 xor eax, ebx
678 mov ecx, DWORD PTR 100[ebp]
679 xor eax, esi
680 xor edx, esi
681 xor edx, ecx
682 and eax, 0fcfcfcfch
683 xor ebx, ebx
684 and edx, 0cfcfcfcfh
685 xor ecx, ecx
686 mov bl, al
687 mov cl, ah
688 ror edx, 4
689 mov ebp, DWORD PTR _des_SPtrans[ebx]
690 mov bl, dl
691 xor edi, ebp
692 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
693 xor edi, ebp
694 mov cl, dh
695 shr eax, 16
696 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
697 xor edi, ebp
698 mov bl, ah
699 shr edx, 16
700 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
701 xor edi, ebp
702 mov ebp, DWORD PTR 28[esp]
703 mov cl, dh
704 and eax, 0ffh
705 and edx, 0ffh
706 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
707 xor edi, ebx
708 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
709 xor edi, ebx
710 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
711 xor edi, ebx
712 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
713 xor edi, ebx
714 ;
715 ; Round 13
716 mov eax, DWORD PTR 32[esp]
717 mov edx, edi
718 shr edx, 16
719 mov ecx, DWORD PTR 36[esp]
720 xor edx, edi
721 and eax, edx
722 and edx, ecx
723 mov ebx, eax
724 shl ebx, 16
725 mov ecx, edx
726 shl ecx, 16
727 xor eax, ebx
728 xor edx, ecx
729 mov ebx, DWORD PTR 104[ebp]
730 xor eax, ebx
731 mov ecx, DWORD PTR 108[ebp]
732 xor eax, edi
733 xor edx, edi
734 xor edx, ecx
735 and eax, 0fcfcfcfch
736 xor ebx, ebx
737 and edx, 0cfcfcfcfh
738 xor ecx, ecx
739 mov bl, al
740 mov cl, ah
741 ror edx, 4
742 mov ebp, DWORD PTR _des_SPtrans[ebx]
743 mov bl, dl
744 xor esi, ebp
745 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
746 xor esi, ebp
747 mov cl, dh
748 shr eax, 16
749 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
750 xor esi, ebp
751 mov bl, ah
752 shr edx, 16
753 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
754 xor esi, ebp
755 mov ebp, DWORD PTR 28[esp]
756 mov cl, dh
757 and eax, 0ffh
758 and edx, 0ffh
759 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
760 xor esi, ebx
761 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
762 xor esi, ebx
763 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
764 xor esi, ebx
765 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
766 xor esi, ebx
767 ;
768 ; Round 14
769 mov eax, DWORD PTR 32[esp]
770 mov edx, esi
771 shr edx, 16
772 mov ecx, DWORD PTR 36[esp]
773 xor edx, esi
774 and eax, edx
775 and edx, ecx
776 mov ebx, eax
777 shl ebx, 16
778 mov ecx, edx
779 shl ecx, 16
780 xor eax, ebx
781 xor edx, ecx
782 mov ebx, DWORD PTR 112[ebp]
783 xor eax, ebx
784 mov ecx, DWORD PTR 116[ebp]
785 xor eax, esi
786 xor edx, esi
787 xor edx, ecx
788 and eax, 0fcfcfcfch
789 xor ebx, ebx
790 and edx, 0cfcfcfcfh
791 xor ecx, ecx
792 mov bl, al
793 mov cl, ah
794 ror edx, 4
795 mov ebp, DWORD PTR _des_SPtrans[ebx]
796 mov bl, dl
797 xor edi, ebp
798 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
799 xor edi, ebp
800 mov cl, dh
801 shr eax, 16
802 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
803 xor edi, ebp
804 mov bl, ah
805 shr edx, 16
806 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
807 xor edi, ebp
808 mov ebp, DWORD PTR 28[esp]
809 mov cl, dh
810 and eax, 0ffh
811 and edx, 0ffh
812 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
813 xor edi, ebx
814 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
815 xor edi, ebx
816 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
817 xor edi, ebx
818 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
819 xor edi, ebx
820 ;
821 ; Round 15
822 mov eax, DWORD PTR 32[esp]
823 mov edx, edi
824 shr edx, 16
825 mov ecx, DWORD PTR 36[esp]
826 xor edx, edi
827 and eax, edx
828 and edx, ecx
829 mov ebx, eax
830 shl ebx, 16
831 mov ecx, edx
832 shl ecx, 16
833 xor eax, ebx
834 xor edx, ecx
835 mov ebx, DWORD PTR 120[ebp]
836 xor eax, ebx
837 mov ecx, DWORD PTR 124[ebp]
838 xor eax, edi
839 xor edx, edi
840 xor edx, ecx
841 and eax, 0fcfcfcfch
842 xor ebx, ebx
843 and edx, 0cfcfcfcfh
844 xor ecx, ecx
845 mov bl, al
846 mov cl, ah
847 ror edx, 4
848 mov ebp, DWORD PTR _des_SPtrans[ebx]
849 mov bl, dl
850 xor esi, ebp
851 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
852 xor esi, ebp
853 mov cl, dh
854 shr eax, 16
855 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
856 xor esi, ebp
857 mov bl, ah
858 shr edx, 16
859 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
860 xor esi, ebp
861 mov ebp, DWORD PTR 28[esp]
862 mov cl, dh
863 and eax, 0ffh
864 and edx, 0ffh
865 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
866 xor esi, ebx
867 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
868 xor esi, ebx
869 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
870 xor esi, ebx
871 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
872 xor esi, ebx
873 mov ebx, DWORD PTR [esp]
874 mov eax, edi
875 dec ebx
876 mov edi, esi
877 mov esi, eax
878 mov DWORD PTR [esp],ebx
879 jnz L000start
880 ;
881 ; FP
882 mov edx, DWORD PTR 24[esp]
883 ror edi, 1
884 mov eax, esi
885 xor esi, edi
886 and esi, 0aaaaaaaah
887 xor eax, esi
888 xor edi, esi
889 ;
890 rol eax, 23
891 mov esi, eax
892 xor eax, edi
893 and eax, 003fc03fch
894 xor esi, eax
895 xor edi, eax
896 ;
897 rol esi, 10
898 mov eax, esi
899 xor esi, edi
900 and esi, 033333333h
901 xor eax, esi
902 xor edi, esi
903 ;
904 rol edi, 18
905 mov esi, edi
906 xor edi, eax
907 and edi, 0fff0000fh
908 xor esi, edi
909 xor eax, edi
910 ;
911 rol esi, 12
912 mov edi, esi
913 xor esi, eax
914 and esi, 0f0f0f0f0h
915 xor edi, esi
916 xor eax, esi
917 ;
918 ror eax, 4
919 mov DWORD PTR [edx],eax
920 mov DWORD PTR 4[edx],edi
921 pop ecx
922 pop edi
923 pop esi
924 pop ebx
925 pop ebp
926 ret
927_fcrypt_body ENDP
928_TEXT ENDS
929END
diff --git a/src/lib/libcrypto/des/asm/yx86unix.cpp b/src/lib/libcrypto/des/asm/yx86unix.cpp
new file mode 100644
index 0000000000..8719e38607
--- /dev/null
+++ b/src/lib/libcrypto/des/asm/yx86unix.cpp
@@ -0,0 +1,976 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define des_SPtrans _des_SPtrans
13#define fcrypt_body _fcrypt_body
14
15#endif
16
17#ifdef OUT
18#define OK 1
19#define ALIGN 4
20#endif
21
22#ifdef BSDI
23#define OK 1
24#define ALIGN 4
25#undef SIZE
26#undef TYPE
27#define SIZE(a,b)
28#define TYPE(a,b)
29#endif
30
31#if defined(ELF) || defined(SOL)
32#define OK 1
33#define ALIGN 16
34#endif
35
36#ifndef OK
37You need to define one of
38ELF - elf systems - linux-elf, NetBSD and DG-UX
39OUT - a.out systems - linux-a.out and FreeBSD
40SOL - solaris systems, which are elf with strange comment lines
41BSDI - a.out with a very primative version of as.
42#endif
43
44/* Let the Assembler begin :-) */
45 /* Don't even think of reading this code */
46 /* It was automatically generated by crypt586.pl */
47 /* Which is a perl program used to generate the x86 assember for */
48 /* any of elf, a.out, BSDI,Win32, or Solaris */
49 /* eric <eay@cryptsoft.com> */
50
51 .file "crypt586.s"
52 .version "01.01"
53gcc2_compiled.:
54.text
55 .align ALIGN
56.globl fcrypt_body
57 TYPE(fcrypt_body,@function)
58fcrypt_body:
59 pushl %ebp
60 pushl %ebx
61 pushl %esi
62 pushl %edi
63
64
65 /* Load the 2 words */
66 xorl %edi, %edi
67 xorl %esi, %esi
68 movl 24(%esp), %ebp
69 pushl $25
70.L000start:
71
72 /* Round 0 */
73 movl 32(%esp), %eax
74 movl %esi, %edx
75 shrl $16, %edx
76 movl 36(%esp), %ecx
77 xorl %esi, %edx
78 andl %edx, %eax
79 andl %ecx, %edx
80 movl %eax, %ebx
81 sall $16, %ebx
82 movl %edx, %ecx
83 sall $16, %ecx
84 xorl %ebx, %eax
85 xorl %ecx, %edx
86 movl (%ebp), %ebx
87 xorl %ebx, %eax
88 movl 4(%ebp), %ecx
89 xorl %esi, %eax
90 xorl %esi, %edx
91 xorl %ecx, %edx
92 andl $0xfcfcfcfc, %eax
93 xorl %ebx, %ebx
94 andl $0xcfcfcfcf, %edx
95 xorl %ecx, %ecx
96 movb %al, %bl
97 movb %ah, %cl
98 rorl $4, %edx
99 movl des_SPtrans(%ebx),%ebp
100 movb %dl, %bl
101 xorl %ebp, %edi
102 movl 0x200+des_SPtrans(%ecx),%ebp
103 xorl %ebp, %edi
104 movb %dh, %cl
105 shrl $16, %eax
106 movl 0x100+des_SPtrans(%ebx),%ebp
107 xorl %ebp, %edi
108 movb %ah, %bl
109 shrl $16, %edx
110 movl 0x300+des_SPtrans(%ecx),%ebp
111 xorl %ebp, %edi
112 movl 28(%esp), %ebp
113 movb %dh, %cl
114 andl $0xff, %eax
115 andl $0xff, %edx
116 movl 0x600+des_SPtrans(%ebx),%ebx
117 xorl %ebx, %edi
118 movl 0x700+des_SPtrans(%ecx),%ebx
119 xorl %ebx, %edi
120 movl 0x400+des_SPtrans(%eax),%ebx
121 xorl %ebx, %edi
122 movl 0x500+des_SPtrans(%edx),%ebx
123 xorl %ebx, %edi
124
125 /* Round 1 */
126 movl 32(%esp), %eax
127 movl %edi, %edx
128 shrl $16, %edx
129 movl 36(%esp), %ecx
130 xorl %edi, %edx
131 andl %edx, %eax
132 andl %ecx, %edx
133 movl %eax, %ebx
134 sall $16, %ebx
135 movl %edx, %ecx
136 sall $16, %ecx
137 xorl %ebx, %eax
138 xorl %ecx, %edx
139 movl 8(%ebp), %ebx
140 xorl %ebx, %eax
141 movl 12(%ebp), %ecx
142 xorl %edi, %eax
143 xorl %edi, %edx
144 xorl %ecx, %edx
145 andl $0xfcfcfcfc, %eax
146 xorl %ebx, %ebx
147 andl $0xcfcfcfcf, %edx
148 xorl %ecx, %ecx
149 movb %al, %bl
150 movb %ah, %cl
151 rorl $4, %edx
152 movl des_SPtrans(%ebx),%ebp
153 movb %dl, %bl
154 xorl %ebp, %esi
155 movl 0x200+des_SPtrans(%ecx),%ebp
156 xorl %ebp, %esi
157 movb %dh, %cl
158 shrl $16, %eax
159 movl 0x100+des_SPtrans(%ebx),%ebp
160 xorl %ebp, %esi
161 movb %ah, %bl
162 shrl $16, %edx
163 movl 0x300+des_SPtrans(%ecx),%ebp
164 xorl %ebp, %esi
165 movl 28(%esp), %ebp
166 movb %dh, %cl
167 andl $0xff, %eax
168 andl $0xff, %edx
169 movl 0x600+des_SPtrans(%ebx),%ebx
170 xorl %ebx, %esi
171 movl 0x700+des_SPtrans(%ecx),%ebx
172 xorl %ebx, %esi
173 movl 0x400+des_SPtrans(%eax),%ebx
174 xorl %ebx, %esi
175 movl 0x500+des_SPtrans(%edx),%ebx
176 xorl %ebx, %esi
177
178 /* Round 2 */
179 movl 32(%esp), %eax
180 movl %esi, %edx
181 shrl $16, %edx
182 movl 36(%esp), %ecx
183 xorl %esi, %edx
184 andl %edx, %eax
185 andl %ecx, %edx
186 movl %eax, %ebx
187 sall $16, %ebx
188 movl %edx, %ecx
189 sall $16, %ecx
190 xorl %ebx, %eax
191 xorl %ecx, %edx
192 movl 16(%ebp), %ebx
193 xorl %ebx, %eax
194 movl 20(%ebp), %ecx
195 xorl %esi, %eax
196 xorl %esi, %edx
197 xorl %ecx, %edx
198 andl $0xfcfcfcfc, %eax
199 xorl %ebx, %ebx
200 andl $0xcfcfcfcf, %edx
201 xorl %ecx, %ecx
202 movb %al, %bl
203 movb %ah, %cl
204 rorl $4, %edx
205 movl des_SPtrans(%ebx),%ebp
206 movb %dl, %bl
207 xorl %ebp, %edi
208 movl 0x200+des_SPtrans(%ecx),%ebp
209 xorl %ebp, %edi
210 movb %dh, %cl
211 shrl $16, %eax
212 movl 0x100+des_SPtrans(%ebx),%ebp
213 xorl %ebp, %edi
214 movb %ah, %bl
215 shrl $16, %edx
216 movl 0x300+des_SPtrans(%ecx),%ebp
217 xorl %ebp, %edi
218 movl 28(%esp), %ebp
219 movb %dh, %cl
220 andl $0xff, %eax
221 andl $0xff, %edx
222 movl 0x600+des_SPtrans(%ebx),%ebx
223 xorl %ebx, %edi
224 movl 0x700+des_SPtrans(%ecx),%ebx
225 xorl %ebx, %edi
226 movl 0x400+des_SPtrans(%eax),%ebx
227 xorl %ebx, %edi
228 movl 0x500+des_SPtrans(%edx),%ebx
229 xorl %ebx, %edi
230
231 /* Round 3 */
232 movl 32(%esp), %eax
233 movl %edi, %edx
234 shrl $16, %edx
235 movl 36(%esp), %ecx
236 xorl %edi, %edx
237 andl %edx, %eax
238 andl %ecx, %edx
239 movl %eax, %ebx
240 sall $16, %ebx
241 movl %edx, %ecx
242 sall $16, %ecx
243 xorl %ebx, %eax
244 xorl %ecx, %edx
245 movl 24(%ebp), %ebx
246 xorl %ebx, %eax
247 movl 28(%ebp), %ecx
248 xorl %edi, %eax
249 xorl %edi, %edx
250 xorl %ecx, %edx
251 andl $0xfcfcfcfc, %eax
252 xorl %ebx, %ebx
253 andl $0xcfcfcfcf, %edx
254 xorl %ecx, %ecx
255 movb %al, %bl
256 movb %ah, %cl
257 rorl $4, %edx
258 movl des_SPtrans(%ebx),%ebp
259 movb %dl, %bl
260 xorl %ebp, %esi
261 movl 0x200+des_SPtrans(%ecx),%ebp
262 xorl %ebp, %esi
263 movb %dh, %cl
264 shrl $16, %eax
265 movl 0x100+des_SPtrans(%ebx),%ebp
266 xorl %ebp, %esi
267 movb %ah, %bl
268 shrl $16, %edx
269 movl 0x300+des_SPtrans(%ecx),%ebp
270 xorl %ebp, %esi
271 movl 28(%esp), %ebp
272 movb %dh, %cl
273 andl $0xff, %eax
274 andl $0xff, %edx
275 movl 0x600+des_SPtrans(%ebx),%ebx
276 xorl %ebx, %esi
277 movl 0x700+des_SPtrans(%ecx),%ebx
278 xorl %ebx, %esi
279 movl 0x400+des_SPtrans(%eax),%ebx
280 xorl %ebx, %esi
281 movl 0x500+des_SPtrans(%edx),%ebx
282 xorl %ebx, %esi
283
284 /* Round 4 */
285 movl 32(%esp), %eax
286 movl %esi, %edx
287 shrl $16, %edx
288 movl 36(%esp), %ecx
289 xorl %esi, %edx
290 andl %edx, %eax
291 andl %ecx, %edx
292 movl %eax, %ebx
293 sall $16, %ebx
294 movl %edx, %ecx
295 sall $16, %ecx
296 xorl %ebx, %eax
297 xorl %ecx, %edx
298 movl 32(%ebp), %ebx
299 xorl %ebx, %eax
300 movl 36(%ebp), %ecx
301 xorl %esi, %eax
302 xorl %esi, %edx
303 xorl %ecx, %edx
304 andl $0xfcfcfcfc, %eax
305 xorl %ebx, %ebx
306 andl $0xcfcfcfcf, %edx
307 xorl %ecx, %ecx
308 movb %al, %bl
309 movb %ah, %cl
310 rorl $4, %edx
311 movl des_SPtrans(%ebx),%ebp
312 movb %dl, %bl
313 xorl %ebp, %edi
314 movl 0x200+des_SPtrans(%ecx),%ebp
315 xorl %ebp, %edi
316 movb %dh, %cl
317 shrl $16, %eax
318 movl 0x100+des_SPtrans(%ebx),%ebp
319 xorl %ebp, %edi
320 movb %ah, %bl
321 shrl $16, %edx
322 movl 0x300+des_SPtrans(%ecx),%ebp
323 xorl %ebp, %edi
324 movl 28(%esp), %ebp
325 movb %dh, %cl
326 andl $0xff, %eax
327 andl $0xff, %edx
328 movl 0x600+des_SPtrans(%ebx),%ebx
329 xorl %ebx, %edi
330 movl 0x700+des_SPtrans(%ecx),%ebx
331 xorl %ebx, %edi
332 movl 0x400+des_SPtrans(%eax),%ebx
333 xorl %ebx, %edi
334 movl 0x500+des_SPtrans(%edx),%ebx
335 xorl %ebx, %edi
336
337 /* Round 5 */
338 movl 32(%esp), %eax
339 movl %edi, %edx
340 shrl $16, %edx
341 movl 36(%esp), %ecx
342 xorl %edi, %edx
343 andl %edx, %eax
344 andl %ecx, %edx
345 movl %eax, %ebx
346 sall $16, %ebx
347 movl %edx, %ecx
348 sall $16, %ecx
349 xorl %ebx, %eax
350 xorl %ecx, %edx
351 movl 40(%ebp), %ebx
352 xorl %ebx, %eax
353 movl 44(%ebp), %ecx
354 xorl %edi, %eax
355 xorl %edi, %edx
356 xorl %ecx, %edx
357 andl $0xfcfcfcfc, %eax
358 xorl %ebx, %ebx
359 andl $0xcfcfcfcf, %edx
360 xorl %ecx, %ecx
361 movb %al, %bl
362 movb %ah, %cl
363 rorl $4, %edx
364 movl des_SPtrans(%ebx),%ebp
365 movb %dl, %bl
366 xorl %ebp, %esi
367 movl 0x200+des_SPtrans(%ecx),%ebp
368 xorl %ebp, %esi
369 movb %dh, %cl
370 shrl $16, %eax
371 movl 0x100+des_SPtrans(%ebx),%ebp
372 xorl %ebp, %esi
373 movb %ah, %bl
374 shrl $16, %edx
375 movl 0x300+des_SPtrans(%ecx),%ebp
376 xorl %ebp, %esi
377 movl 28(%esp), %ebp
378 movb %dh, %cl
379 andl $0xff, %eax
380 andl $0xff, %edx
381 movl 0x600+des_SPtrans(%ebx),%ebx
382 xorl %ebx, %esi
383 movl 0x700+des_SPtrans(%ecx),%ebx
384 xorl %ebx, %esi
385 movl 0x400+des_SPtrans(%eax),%ebx
386 xorl %ebx, %esi
387 movl 0x500+des_SPtrans(%edx),%ebx
388 xorl %ebx, %esi
389
390 /* Round 6 */
391 movl 32(%esp), %eax
392 movl %esi, %edx
393 shrl $16, %edx
394 movl 36(%esp), %ecx
395 xorl %esi, %edx
396 andl %edx, %eax
397 andl %ecx, %edx
398 movl %eax, %ebx
399 sall $16, %ebx
400 movl %edx, %ecx
401 sall $16, %ecx
402 xorl %ebx, %eax
403 xorl %ecx, %edx
404 movl 48(%ebp), %ebx
405 xorl %ebx, %eax
406 movl 52(%ebp), %ecx
407 xorl %esi, %eax
408 xorl %esi, %edx
409 xorl %ecx, %edx
410 andl $0xfcfcfcfc, %eax
411 xorl %ebx, %ebx
412 andl $0xcfcfcfcf, %edx
413 xorl %ecx, %ecx
414 movb %al, %bl
415 movb %ah, %cl
416 rorl $4, %edx
417 movl des_SPtrans(%ebx),%ebp
418 movb %dl, %bl
419 xorl %ebp, %edi
420 movl 0x200+des_SPtrans(%ecx),%ebp
421 xorl %ebp, %edi
422 movb %dh, %cl
423 shrl $16, %eax
424 movl 0x100+des_SPtrans(%ebx),%ebp
425 xorl %ebp, %edi
426 movb %ah, %bl
427 shrl $16, %edx
428 movl 0x300+des_SPtrans(%ecx),%ebp
429 xorl %ebp, %edi
430 movl 28(%esp), %ebp
431 movb %dh, %cl
432 andl $0xff, %eax
433 andl $0xff, %edx
434 movl 0x600+des_SPtrans(%ebx),%ebx
435 xorl %ebx, %edi
436 movl 0x700+des_SPtrans(%ecx),%ebx
437 xorl %ebx, %edi
438 movl 0x400+des_SPtrans(%eax),%ebx
439 xorl %ebx, %edi
440 movl 0x500+des_SPtrans(%edx),%ebx
441 xorl %ebx, %edi
442
443 /* Round 7 */
444 movl 32(%esp), %eax
445 movl %edi, %edx
446 shrl $16, %edx
447 movl 36(%esp), %ecx
448 xorl %edi, %edx
449 andl %edx, %eax
450 andl %ecx, %edx
451 movl %eax, %ebx
452 sall $16, %ebx
453 movl %edx, %ecx
454 sall $16, %ecx
455 xorl %ebx, %eax
456 xorl %ecx, %edx
457 movl 56(%ebp), %ebx
458 xorl %ebx, %eax
459 movl 60(%ebp), %ecx
460 xorl %edi, %eax
461 xorl %edi, %edx
462 xorl %ecx, %edx
463 andl $0xfcfcfcfc, %eax
464 xorl %ebx, %ebx
465 andl $0xcfcfcfcf, %edx
466 xorl %ecx, %ecx
467 movb %al, %bl
468 movb %ah, %cl
469 rorl $4, %edx
470 movl des_SPtrans(%ebx),%ebp
471 movb %dl, %bl
472 xorl %ebp, %esi
473 movl 0x200+des_SPtrans(%ecx),%ebp
474 xorl %ebp, %esi
475 movb %dh, %cl
476 shrl $16, %eax
477 movl 0x100+des_SPtrans(%ebx),%ebp
478 xorl %ebp, %esi
479 movb %ah, %bl
480 shrl $16, %edx
481 movl 0x300+des_SPtrans(%ecx),%ebp
482 xorl %ebp, %esi
483 movl 28(%esp), %ebp
484 movb %dh, %cl
485 andl $0xff, %eax
486 andl $0xff, %edx
487 movl 0x600+des_SPtrans(%ebx),%ebx
488 xorl %ebx, %esi
489 movl 0x700+des_SPtrans(%ecx),%ebx
490 xorl %ebx, %esi
491 movl 0x400+des_SPtrans(%eax),%ebx
492 xorl %ebx, %esi
493 movl 0x500+des_SPtrans(%edx),%ebx
494 xorl %ebx, %esi
495
496 /* Round 8 */
497 movl 32(%esp), %eax
498 movl %esi, %edx
499 shrl $16, %edx
500 movl 36(%esp), %ecx
501 xorl %esi, %edx
502 andl %edx, %eax
503 andl %ecx, %edx
504 movl %eax, %ebx
505 sall $16, %ebx
506 movl %edx, %ecx
507 sall $16, %ecx
508 xorl %ebx, %eax
509 xorl %ecx, %edx
510 movl 64(%ebp), %ebx
511 xorl %ebx, %eax
512 movl 68(%ebp), %ecx
513 xorl %esi, %eax
514 xorl %esi, %edx
515 xorl %ecx, %edx
516 andl $0xfcfcfcfc, %eax
517 xorl %ebx, %ebx
518 andl $0xcfcfcfcf, %edx
519 xorl %ecx, %ecx
520 movb %al, %bl
521 movb %ah, %cl
522 rorl $4, %edx
523 movl des_SPtrans(%ebx),%ebp
524 movb %dl, %bl
525 xorl %ebp, %edi
526 movl 0x200+des_SPtrans(%ecx),%ebp
527 xorl %ebp, %edi
528 movb %dh, %cl
529 shrl $16, %eax
530 movl 0x100+des_SPtrans(%ebx),%ebp
531 xorl %ebp, %edi
532 movb %ah, %bl
533 shrl $16, %edx
534 movl 0x300+des_SPtrans(%ecx),%ebp
535 xorl %ebp, %edi
536 movl 28(%esp), %ebp
537 movb %dh, %cl
538 andl $0xff, %eax
539 andl $0xff, %edx
540 movl 0x600+des_SPtrans(%ebx),%ebx
541 xorl %ebx, %edi
542 movl 0x700+des_SPtrans(%ecx),%ebx
543 xorl %ebx, %edi
544 movl 0x400+des_SPtrans(%eax),%ebx
545 xorl %ebx, %edi
546 movl 0x500+des_SPtrans(%edx),%ebx
547 xorl %ebx, %edi
548
549 /* Round 9 */
550 movl 32(%esp), %eax
551 movl %edi, %edx
552 shrl $16, %edx
553 movl 36(%esp), %ecx
554 xorl %edi, %edx
555 andl %edx, %eax
556 andl %ecx, %edx
557 movl %eax, %ebx
558 sall $16, %ebx
559 movl %edx, %ecx
560 sall $16, %ecx
561 xorl %ebx, %eax
562 xorl %ecx, %edx
563 movl 72(%ebp), %ebx
564 xorl %ebx, %eax
565 movl 76(%ebp), %ecx
566 xorl %edi, %eax
567 xorl %edi, %edx
568 xorl %ecx, %edx
569 andl $0xfcfcfcfc, %eax
570 xorl %ebx, %ebx
571 andl $0xcfcfcfcf, %edx
572 xorl %ecx, %ecx
573 movb %al, %bl
574 movb %ah, %cl
575 rorl $4, %edx
576 movl des_SPtrans(%ebx),%ebp
577 movb %dl, %bl
578 xorl %ebp, %esi
579 movl 0x200+des_SPtrans(%ecx),%ebp
580 xorl %ebp, %esi
581 movb %dh, %cl
582 shrl $16, %eax
583 movl 0x100+des_SPtrans(%ebx),%ebp
584 xorl %ebp, %esi
585 movb %ah, %bl
586 shrl $16, %edx
587 movl 0x300+des_SPtrans(%ecx),%ebp
588 xorl %ebp, %esi
589 movl 28(%esp), %ebp
590 movb %dh, %cl
591 andl $0xff, %eax
592 andl $0xff, %edx
593 movl 0x600+des_SPtrans(%ebx),%ebx
594 xorl %ebx, %esi
595 movl 0x700+des_SPtrans(%ecx),%ebx
596 xorl %ebx, %esi
597 movl 0x400+des_SPtrans(%eax),%ebx
598 xorl %ebx, %esi
599 movl 0x500+des_SPtrans(%edx),%ebx
600 xorl %ebx, %esi
601
602 /* Round 10 */
603 movl 32(%esp), %eax
604 movl %esi, %edx
605 shrl $16, %edx
606 movl 36(%esp), %ecx
607 xorl %esi, %edx
608 andl %edx, %eax
609 andl %ecx, %edx
610 movl %eax, %ebx
611 sall $16, %ebx
612 movl %edx, %ecx
613 sall $16, %ecx
614 xorl %ebx, %eax
615 xorl %ecx, %edx
616 movl 80(%ebp), %ebx
617 xorl %ebx, %eax
618 movl 84(%ebp), %ecx
619 xorl %esi, %eax
620 xorl %esi, %edx
621 xorl %ecx, %edx
622 andl $0xfcfcfcfc, %eax
623 xorl %ebx, %ebx
624 andl $0xcfcfcfcf, %edx
625 xorl %ecx, %ecx
626 movb %al, %bl
627 movb %ah, %cl
628 rorl $4, %edx
629 movl des_SPtrans(%ebx),%ebp
630 movb %dl, %bl
631 xorl %ebp, %edi
632 movl 0x200+des_SPtrans(%ecx),%ebp
633 xorl %ebp, %edi
634 movb %dh, %cl
635 shrl $16, %eax
636 movl 0x100+des_SPtrans(%ebx),%ebp
637 xorl %ebp, %edi
638 movb %ah, %bl
639 shrl $16, %edx
640 movl 0x300+des_SPtrans(%ecx),%ebp
641 xorl %ebp, %edi
642 movl 28(%esp), %ebp
643 movb %dh, %cl
644 andl $0xff, %eax
645 andl $0xff, %edx
646 movl 0x600+des_SPtrans(%ebx),%ebx
647 xorl %ebx, %edi
648 movl 0x700+des_SPtrans(%ecx),%ebx
649 xorl %ebx, %edi
650 movl 0x400+des_SPtrans(%eax),%ebx
651 xorl %ebx, %edi
652 movl 0x500+des_SPtrans(%edx),%ebx
653 xorl %ebx, %edi
654
655 /* Round 11 */
656 movl 32(%esp), %eax
657 movl %edi, %edx
658 shrl $16, %edx
659 movl 36(%esp), %ecx
660 xorl %edi, %edx
661 andl %edx, %eax
662 andl %ecx, %edx
663 movl %eax, %ebx
664 sall $16, %ebx
665 movl %edx, %ecx
666 sall $16, %ecx
667 xorl %ebx, %eax
668 xorl %ecx, %edx
669 movl 88(%ebp), %ebx
670 xorl %ebx, %eax
671 movl 92(%ebp), %ecx
672 xorl %edi, %eax
673 xorl %edi, %edx
674 xorl %ecx, %edx
675 andl $0xfcfcfcfc, %eax
676 xorl %ebx, %ebx
677 andl $0xcfcfcfcf, %edx
678 xorl %ecx, %ecx
679 movb %al, %bl
680 movb %ah, %cl
681 rorl $4, %edx
682 movl des_SPtrans(%ebx),%ebp
683 movb %dl, %bl
684 xorl %ebp, %esi
685 movl 0x200+des_SPtrans(%ecx),%ebp
686 xorl %ebp, %esi
687 movb %dh, %cl
688 shrl $16, %eax
689 movl 0x100+des_SPtrans(%ebx),%ebp
690 xorl %ebp, %esi
691 movb %ah, %bl
692 shrl $16, %edx
693 movl 0x300+des_SPtrans(%ecx),%ebp
694 xorl %ebp, %esi
695 movl 28(%esp), %ebp
696 movb %dh, %cl
697 andl $0xff, %eax
698 andl $0xff, %edx
699 movl 0x600+des_SPtrans(%ebx),%ebx
700 xorl %ebx, %esi
701 movl 0x700+des_SPtrans(%ecx),%ebx
702 xorl %ebx, %esi
703 movl 0x400+des_SPtrans(%eax),%ebx
704 xorl %ebx, %esi
705 movl 0x500+des_SPtrans(%edx),%ebx
706 xorl %ebx, %esi
707
708 /* Round 12 */
709 movl 32(%esp), %eax
710 movl %esi, %edx
711 shrl $16, %edx
712 movl 36(%esp), %ecx
713 xorl %esi, %edx
714 andl %edx, %eax
715 andl %ecx, %edx
716 movl %eax, %ebx
717 sall $16, %ebx
718 movl %edx, %ecx
719 sall $16, %ecx
720 xorl %ebx, %eax
721 xorl %ecx, %edx
722 movl 96(%ebp), %ebx
723 xorl %ebx, %eax
724 movl 100(%ebp), %ecx
725 xorl %esi, %eax
726 xorl %esi, %edx
727 xorl %ecx, %edx
728 andl $0xfcfcfcfc, %eax
729 xorl %ebx, %ebx
730 andl $0xcfcfcfcf, %edx
731 xorl %ecx, %ecx
732 movb %al, %bl
733 movb %ah, %cl
734 rorl $4, %edx
735 movl des_SPtrans(%ebx),%ebp
736 movb %dl, %bl
737 xorl %ebp, %edi
738 movl 0x200+des_SPtrans(%ecx),%ebp
739 xorl %ebp, %edi
740 movb %dh, %cl
741 shrl $16, %eax
742 movl 0x100+des_SPtrans(%ebx),%ebp
743 xorl %ebp, %edi
744 movb %ah, %bl
745 shrl $16, %edx
746 movl 0x300+des_SPtrans(%ecx),%ebp
747 xorl %ebp, %edi
748 movl 28(%esp), %ebp
749 movb %dh, %cl
750 andl $0xff, %eax
751 andl $0xff, %edx
752 movl 0x600+des_SPtrans(%ebx),%ebx
753 xorl %ebx, %edi
754 movl 0x700+des_SPtrans(%ecx),%ebx
755 xorl %ebx, %edi
756 movl 0x400+des_SPtrans(%eax),%ebx
757 xorl %ebx, %edi
758 movl 0x500+des_SPtrans(%edx),%ebx
759 xorl %ebx, %edi
760
761 /* Round 13 */
762 movl 32(%esp), %eax
763 movl %edi, %edx
764 shrl $16, %edx
765 movl 36(%esp), %ecx
766 xorl %edi, %edx
767 andl %edx, %eax
768 andl %ecx, %edx
769 movl %eax, %ebx
770 sall $16, %ebx
771 movl %edx, %ecx
772 sall $16, %ecx
773 xorl %ebx, %eax
774 xorl %ecx, %edx
775 movl 104(%ebp), %ebx
776 xorl %ebx, %eax
777 movl 108(%ebp), %ecx
778 xorl %edi, %eax
779 xorl %edi, %edx
780 xorl %ecx, %edx
781 andl $0xfcfcfcfc, %eax
782 xorl %ebx, %ebx
783 andl $0xcfcfcfcf, %edx
784 xorl %ecx, %ecx
785 movb %al, %bl
786 movb %ah, %cl
787 rorl $4, %edx
788 movl des_SPtrans(%ebx),%ebp
789 movb %dl, %bl
790 xorl %ebp, %esi
791 movl 0x200+des_SPtrans(%ecx),%ebp
792 xorl %ebp, %esi
793 movb %dh, %cl
794 shrl $16, %eax
795 movl 0x100+des_SPtrans(%ebx),%ebp
796 xorl %ebp, %esi
797 movb %ah, %bl
798 shrl $16, %edx
799 movl 0x300+des_SPtrans(%ecx),%ebp
800 xorl %ebp, %esi
801 movl 28(%esp), %ebp
802 movb %dh, %cl
803 andl $0xff, %eax
804 andl $0xff, %edx
805 movl 0x600+des_SPtrans(%ebx),%ebx
806 xorl %ebx, %esi
807 movl 0x700+des_SPtrans(%ecx),%ebx
808 xorl %ebx, %esi
809 movl 0x400+des_SPtrans(%eax),%ebx
810 xorl %ebx, %esi
811 movl 0x500+des_SPtrans(%edx),%ebx
812 xorl %ebx, %esi
813
814 /* Round 14 */
815 movl 32(%esp), %eax
816 movl %esi, %edx
817 shrl $16, %edx
818 movl 36(%esp), %ecx
819 xorl %esi, %edx
820 andl %edx, %eax
821 andl %ecx, %edx
822 movl %eax, %ebx
823 sall $16, %ebx
824 movl %edx, %ecx
825 sall $16, %ecx
826 xorl %ebx, %eax
827 xorl %ecx, %edx
828 movl 112(%ebp), %ebx
829 xorl %ebx, %eax
830 movl 116(%ebp), %ecx
831 xorl %esi, %eax
832 xorl %esi, %edx
833 xorl %ecx, %edx
834 andl $0xfcfcfcfc, %eax
835 xorl %ebx, %ebx
836 andl $0xcfcfcfcf, %edx
837 xorl %ecx, %ecx
838 movb %al, %bl
839 movb %ah, %cl
840 rorl $4, %edx
841 movl des_SPtrans(%ebx),%ebp
842 movb %dl, %bl
843 xorl %ebp, %edi
844 movl 0x200+des_SPtrans(%ecx),%ebp
845 xorl %ebp, %edi
846 movb %dh, %cl
847 shrl $16, %eax
848 movl 0x100+des_SPtrans(%ebx),%ebp
849 xorl %ebp, %edi
850 movb %ah, %bl
851 shrl $16, %edx
852 movl 0x300+des_SPtrans(%ecx),%ebp
853 xorl %ebp, %edi
854 movl 28(%esp), %ebp
855 movb %dh, %cl
856 andl $0xff, %eax
857 andl $0xff, %edx
858 movl 0x600+des_SPtrans(%ebx),%ebx
859 xorl %ebx, %edi
860 movl 0x700+des_SPtrans(%ecx),%ebx
861 xorl %ebx, %edi
862 movl 0x400+des_SPtrans(%eax),%ebx
863 xorl %ebx, %edi
864 movl 0x500+des_SPtrans(%edx),%ebx
865 xorl %ebx, %edi
866
867 /* Round 15 */
868 movl 32(%esp), %eax
869 movl %edi, %edx
870 shrl $16, %edx
871 movl 36(%esp), %ecx
872 xorl %edi, %edx
873 andl %edx, %eax
874 andl %ecx, %edx
875 movl %eax, %ebx
876 sall $16, %ebx
877 movl %edx, %ecx
878 sall $16, %ecx
879 xorl %ebx, %eax
880 xorl %ecx, %edx
881 movl 120(%ebp), %ebx
882 xorl %ebx, %eax
883 movl 124(%ebp), %ecx
884 xorl %edi, %eax
885 xorl %edi, %edx
886 xorl %ecx, %edx
887 andl $0xfcfcfcfc, %eax
888 xorl %ebx, %ebx
889 andl $0xcfcfcfcf, %edx
890 xorl %ecx, %ecx
891 movb %al, %bl
892 movb %ah, %cl
893 rorl $4, %edx
894 movl des_SPtrans(%ebx),%ebp
895 movb %dl, %bl
896 xorl %ebp, %esi
897 movl 0x200+des_SPtrans(%ecx),%ebp
898 xorl %ebp, %esi
899 movb %dh, %cl
900 shrl $16, %eax
901 movl 0x100+des_SPtrans(%ebx),%ebp
902 xorl %ebp, %esi
903 movb %ah, %bl
904 shrl $16, %edx
905 movl 0x300+des_SPtrans(%ecx),%ebp
906 xorl %ebp, %esi
907 movl 28(%esp), %ebp
908 movb %dh, %cl
909 andl $0xff, %eax
910 andl $0xff, %edx
911 movl 0x600+des_SPtrans(%ebx),%ebx
912 xorl %ebx, %esi
913 movl 0x700+des_SPtrans(%ecx),%ebx
914 xorl %ebx, %esi
915 movl 0x400+des_SPtrans(%eax),%ebx
916 xorl %ebx, %esi
917 movl 0x500+des_SPtrans(%edx),%ebx
918 xorl %ebx, %esi
919 movl (%esp), %ebx
920 movl %edi, %eax
921 decl %ebx
922 movl %esi, %edi
923 movl %eax, %esi
924 movl %ebx, (%esp)
925 jnz .L000start
926
927 /* FP */
928 movl 24(%esp), %edx
929.byte 209
930.byte 207 /* rorl $1 %edi */
931 movl %esi, %eax
932 xorl %edi, %esi
933 andl $0xaaaaaaaa, %esi
934 xorl %esi, %eax
935 xorl %esi, %edi
936
937 roll $23, %eax
938 movl %eax, %esi
939 xorl %edi, %eax
940 andl $0x03fc03fc, %eax
941 xorl %eax, %esi
942 xorl %eax, %edi
943
944 roll $10, %esi
945 movl %esi, %eax
946 xorl %edi, %esi
947 andl $0x33333333, %esi
948 xorl %esi, %eax
949 xorl %esi, %edi
950
951 roll $18, %edi
952 movl %edi, %esi
953 xorl %eax, %edi
954 andl $0xfff0000f, %edi
955 xorl %edi, %esi
956 xorl %edi, %eax
957
958 roll $12, %esi
959 movl %esi, %edi
960 xorl %eax, %esi
961 andl $0xf0f0f0f0, %esi
962 xorl %esi, %edi
963 xorl %esi, %eax
964
965 rorl $4, %eax
966 movl %eax, (%edx)
967 movl %edi, 4(%edx)
968 popl %ecx
969 popl %edi
970 popl %esi
971 popl %ebx
972 popl %ebp
973 ret
974.fcrypt_body_end:
975 SIZE(fcrypt_body,.fcrypt_body_end-fcrypt_body)
976.ident "fcrypt_body"
diff --git a/src/lib/libcrypto/des/des.man b/src/lib/libcrypto/des/des.man
new file mode 100644
index 0000000000..7e06a1851a
--- /dev/null
+++ b/src/lib/libcrypto/des/des.man
@@ -0,0 +1,186 @@
1.TH DES 1
2.SH NAME
3des - encrypt or decrypt data using Data Encryption Standard
4.SH SYNOPSIS
5.B des
6(
7.B \-e
8|
9.B \-E
10) | (
11.B \-d
12|
13.B \-D
14) | (
15.B \-\fR[\fPcC\fR][\fPckname\fR]\fP
16) |
17[
18.B \-b3hfs
19] [
20.B \-k
21.I key
22]
23] [
24.B \-u\fR[\fIuuname\fR]
25[
26.I input-file
27[
28.I output-file
29] ]
30.SH DESCRIPTION
31.B des
32encrypts and decrypts data using the
33Data Encryption Standard algorithm.
34One of
35.B \-e, \-E
36(for encrypt) or
37.B \-d, \-D
38(for decrypt) must be specified.
39It is also possible to use
40.B \-c
41or
42.B \-C
43in conjunction or instead of the a encrypt/decrypt option to generate
44a 16 character hexadecimal checksum, generated via the
45.I des_cbc_cksum.
46.LP
47Two standard encryption modes are supported by the
48.B des
49program, Cipher Block Chaining (the default) and Electronic Code Book
50(specified with
51.B \-b
52).
53.LP
54The key used for the DES
55algorithm is obtained by prompting the user unless the
56.B `\-k
57.I key'
58option is given.
59If the key is an argument to the
60.B des
61command, it is potentially visible to users executing
62.BR ps (1)
63or a derivative. To minimise this possibility,
64.B des
65takes care to destroy the key argument immediately upon entry.
66If your shell keeps a history file be careful to make sure it is not
67world readable.
68.LP
69Since this program attempts to maintain compatability with sunOS's
70des(1) command, there are 2 different methods used to convert the user
71supplied key to a des key.
72Whenever and one or more of
73.B \-E, \-D, \-C
74or
75.B \-3
76options are used, the key conversion procedure will not be compatible
77with the sunOS des(1) version but will use all the user supplied
78character to generate the des key.
79.B des
80command reads from standard input unless
81.I input-file
82is specified and writes to standard output unless
83.I output-file
84is given.
85.SH OPTIONS
86.TP
87.B \-b
88Select ECB
89(eight bytes at a time) encryption mode.
90.TP
91.B \-3
92Encrypt using triple encryption.
93By default triple cbc encryption is used but if the
94.B \-b
95option is used then triple ecb encryption is performed.
96If the key is less than 8 characters long, the flag has no effect.
97.TP
98.B \-e
99Encrypt data using an 8 byte key in a manner compatible with sunOS
100des(1).
101.TP
102.B \-E
103Encrypt data using a key of nearly unlimited length (1024 bytes).
104This will product a more secure encryption.
105.TP
106.B \-d
107Decrypt data that was encrypted with the \-e option.
108.TP
109.B \-D
110Decrypt data that was encrypted with the \-E option.
111.TP
112.B \-c
113Generate a 16 character hexadecimal cbc checksum and output this to
114stderr.
115If a filename was specified after the
116.B \-c
117option, the checksum is output to that file.
118The checksum is generated using a key generated in a sunOS compatible
119manner.
120.TP
121.B \-C
122A cbc checksum is generated in the same manner as described for the
123.B \-c
124option but the DES key is generated in the same manner as used for the
125.B \-E
126and
127.B \-D
128options
129.TP
130.B \-f
131Does nothing - allowed for compatibility with sunOS des(1) command.
132.TP
133.B \-s
134Does nothing - allowed for compatibility with sunOS des(1) command.
135.TP
136.B "\-k \fIkey\fP"
137Use the encryption
138.I key
139specified.
140.TP
141.B "\-h"
142The
143.I key
144is assumed to be a 16 character hexadecimal number.
145If the
146.B "\-3"
147option is used the key is assumed to be a 32 character hexadecimal
148number.
149.TP
150.B \-u
151This flag is used to read and write uuencoded files. If decrypting,
152the input file is assumed to contain uuencoded, DES encrypted data.
153If encrypting, the characters following the -u are used as the name of
154the uuencoded file to embed in the begin line of the uuencoded
155output. If there is no name specified after the -u, the name text.des
156will be embedded in the header.
157.SH SEE ALSO
158.B ps (1)
159.B des_crypt(3)
160.SH BUGS
161.LP
162The problem with using the
163.B -e
164option is the short key length.
165It would be better to use a real 56-bit key rather than an
166ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII
167radically reduces the time necessary for a brute-force cryptographic attack.
168My attempt to remove this problem is to add an alternative text-key to
169DES-key function. This alternative function (accessed via
170.B -E, -D, -S
171and
172.B -3
173)
174uses DES to help generate the key.
175.LP
176Be carefully when using the -u option. Doing des -ud <filename> will
177not decrypt filename (the -u option will gobble the d option).
178.LP
179The VMS operating system operates in a world where files are always a
180multiple of 512 bytes. This causes problems when encrypted data is
181send from unix to VMS since a 88 byte file will suddenly be padded
182with 424 null bytes. To get around this problem, use the -u option
183to uuencode the data before it is send to the VMS system.
184.SH AUTHOR
185.LP
186Eric Young (eay@cryptsoft.com)
diff --git a/src/lib/libcrypto/des/des.org b/src/lib/libcrypto/des/des.org
new file mode 100644
index 0000000000..a4cf5c8770
--- /dev/null
+++ b/src/lib/libcrypto/des/des.org
@@ -0,0 +1,301 @@
1/* crypto/des/des.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify des.org since des.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_DES_H
68#define HEADER_DES_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74#include <stdio.h>
75
76/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
77 * %20 speed up (longs are 8 bytes, int's are 4). */
78#ifndef DES_LONG
79#define DES_LONG unsigned long
80#endif
81
82typedef unsigned char des_cblock[8];
83typedef struct des_ks_struct
84 {
85 union {
86 des_cblock _;
87 /* make sure things are correct size on machines with
88 * 8 byte longs */
89 DES_LONG pad[2];
90 } ks;
91#undef _
92#define _ ks._
93 } des_key_schedule[16];
94
95#define DES_KEY_SZ (sizeof(des_cblock))
96#define DES_SCHEDULE_SZ (sizeof(des_key_schedule))
97
98#define DES_ENCRYPT 1
99#define DES_DECRYPT 0
100
101#define DES_CBC_MODE 0
102#define DES_PCBC_MODE 1
103
104#define des_ecb2_encrypt(i,o,k1,k2,e) \
105 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
106
107#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
108 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
109
110#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
111 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
112
113#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
114 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
115
116#define C_Block des_cblock
117#define Key_schedule des_key_schedule
118#ifdef KERBEROS
119#define ENCRYPT DES_ENCRYPT
120#define DECRYPT DES_DECRYPT
121#endif
122#define KEY_SZ DES_KEY_SZ
123#define string_to_key des_string_to_key
124#define read_pw_string des_read_pw_string
125#define random_key des_random_key
126#define pcbc_encrypt des_pcbc_encrypt
127#define set_key des_set_key
128#define key_sched des_key_sched
129#define ecb_encrypt des_ecb_encrypt
130#define cbc_encrypt des_cbc_encrypt
131#define ncbc_encrypt des_ncbc_encrypt
132#define xcbc_encrypt des_xcbc_encrypt
133#define cbc_cksum des_cbc_cksum
134#define quad_cksum des_quad_cksum
135
136/* For compatibility with the MIT lib - eay 20/05/92 */
137typedef des_key_schedule bit_64;
138#define des_fixup_key_parity des_set_odd_parity
139#define des_check_key_parity check_parity
140
141extern int des_check_key; /* defaults to false */
142extern int des_rw_mode; /* defaults to DES_PCBC_MODE */
143
144/* The next line is used to disable full ANSI prototypes, if your
145 * compiler has problems with the prototypes, make sure this line always
146 * evaluates to true :-) */
147#if defined(MSDOS) || defined(__STDC__)
148#undef NOPROTO
149#endif
150#ifndef NOPROTO
151char *des_options(void);
152void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
153 des_key_schedule ks1,des_key_schedule ks2,
154 des_key_schedule ks3, int enc);
155DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output,
156 long length,des_key_schedule schedule,des_cblock *ivec);
157void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
158 des_key_schedule schedule,des_cblock *ivec,int enc);
159void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
160 des_key_schedule schedule,des_cblock *ivec,int enc);
161void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
162 des_key_schedule schedule,des_cblock *ivec,
163 des_cblock *inw,des_cblock *outw,int enc);
164void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
165 long length,des_key_schedule schedule,des_cblock *ivec,int enc);
166void des_ecb_encrypt(des_cblock *input,des_cblock *output,
167 des_key_schedule ks,int enc);
168void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
169void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
170void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
171 des_key_schedule ks2, des_key_schedule ks3);
172void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
173 des_key_schedule ks2, des_key_schedule ks3);
174void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
175 long length, des_key_schedule ks1, des_key_schedule ks2,
176 des_key_schedule ks3, des_cblock *ivec, int enc);
177void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
178 long length, des_key_schedule ks1, des_key_schedule ks2,
179 des_key_schedule ks3, des_cblock *ivec, int *num, int enc);
180void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
181 long length, des_key_schedule ks1, des_key_schedule ks2,
182 des_key_schedule ks3, des_cblock *ivec, int *num);
183
184void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white),
185 des_cblock (*out_white));
186
187int des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
188 des_cblock *iv);
189int des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
190 des_cblock *iv);
191char *des_fcrypt(const char *buf,const char *salt, char *ret);
192#ifdef PERL5
193char *des_crypt(const char *buf,const char *salt);
194#else
195/* some stupid compilers complain because I have declared char instead
196 * of const char */
197#ifdef HEADER_DES_LOCL_H
198char *crypt(const char *buf,const char *salt);
199#else
200char *crypt();
201#endif
202#endif
203void des_ofb_encrypt(unsigned char *in,unsigned char *out,
204 int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
205void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
206 des_key_schedule schedule,des_cblock *ivec,int enc);
207DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output,
208 long length,int out_count,des_cblock *seed);
209void des_random_seed(des_cblock key);
210void des_random_key(des_cblock ret);
211int des_read_password(des_cblock *key,char *prompt,int verify);
212int des_read_2passwords(des_cblock *key1,des_cblock *key2,
213 char *prompt,int verify);
214int des_read_pw_string(char *buf,int length,char *prompt,int verify);
215void des_set_odd_parity(des_cblock *key);
216int des_is_weak_key(des_cblock *key);
217int des_set_key(des_cblock *key,des_key_schedule schedule);
218int des_key_sched(des_cblock *key,des_key_schedule schedule);
219void des_string_to_key(char *str,des_cblock *key);
220void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
221void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
222 des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
223void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
224 des_key_schedule schedule, des_cblock *ivec, int *num);
225int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify);
226
227/* Extra functions from Mark Murray <mark@grondar.za> */
228void des_cblock_print_file(des_cblock *cb, FILE *fp);
229/* The following functions are not in the normal unix build or the
230 * SSLeay build. When using the SSLeay build, use RAND_seed()
231 * and RAND_bytes() instead. */
232int des_new_random_key(des_cblock *key);
233void des_init_random_number_generator(des_cblock *key);
234void des_set_random_generator_seed(des_cblock *key);
235void des_set_sequence_number(des_cblock new_sequence_number);
236void des_generate_random_block(des_cblock *block);
237
238#else
239
240char *des_options();
241void des_ecb3_encrypt();
242DES_LONG des_cbc_cksum();
243void des_cbc_encrypt();
244void des_ncbc_encrypt();
245void des_xcbc_encrypt();
246void des_cfb_encrypt();
247void des_ede3_cfb64_encrypt();
248void des_ede3_ofb64_encrypt();
249void des_ecb_encrypt();
250void des_encrypt();
251void des_encrypt2();
252void des_encrypt3();
253void des_decrypt3();
254void des_ede3_cbc_encrypt();
255int des_enc_read();
256int des_enc_write();
257char *des_fcrypt();
258#ifdef PERL5
259char *des_crypt();
260#else
261char *crypt();
262#endif
263void des_ofb_encrypt();
264void des_pcbc_encrypt();
265DES_LONG des_quad_cksum();
266void des_random_seed();
267void des_random_key();
268int des_read_password();
269int des_read_2passwords();
270int des_read_pw_string();
271void des_set_odd_parity();
272int des_is_weak_key();
273int des_set_key();
274int des_key_sched();
275void des_string_to_key();
276void des_string_to_2keys();
277void des_cfb64_encrypt();
278void des_ofb64_encrypt();
279int des_read_pw();
280void des_xwhite_in2out();
281
282/* Extra functions from Mark Murray <mark@grondar.za> */
283void des_cblock_print_file();
284/* The following functions are not in the normal unix build or the
285 * SSLeay build. When using the SSLeay build, use RAND_seed()
286 * and RAND_bytes() instead. */
287#ifdef FreeBSD
288int des_new_random_key();
289void des_init_random_number_generator();
290void des_set_random_generator_seed();
291void des_set_sequence_number();
292void des_generate_random_block();
293#endif
294
295#endif
296
297#ifdef __cplusplus
298}
299#endif
300
301#endif
diff --git a/src/lib/libcrypto/des/des.pl b/src/lib/libcrypto/des/des.pl
new file mode 100644
index 0000000000..935eacb504
--- /dev/null
+++ b/src/lib/libcrypto/des/des.pl
@@ -0,0 +1,552 @@
1#!/usr/bin/perl
2# des.pl - eric young 22/11/1991 eay@cryptsoft.com
3#
4# Copyright (C) 1993 Eric Young
5#
6# 11 April 1996 - patched to circumvent Perl 5 (through 5.002) problem
7# with sign-extension on right shift operations.
8# Ed Kubaitis - ejk@uiuc.edu
9#
10# eay - 92/08/31 - I think I have fixed all problems for 64bit
11# versions of perl but I could be wrong since I have not tested it yet :-).
12#
13# This is an implementation of DES in perl.
14# The two routines (des_set_key and des_ecb_encrypt)
15# take 8 byte objects as arguments.
16#
17# des_set_key takes an 8 byte string as a key and returns a key schedule
18# for use in calls to des_ecb_encrypt.
19# des_ecb_encrypt takes three arguments, the first is a key schedule
20# (make sure to pass it by reference with the *), the second is 1
21# to encrypt, 0 to decrypt. The third argument is an 8 byte object
22# to encrypt. The function returns an 8 byte object that has been
23# DES encrypted.
24#
25# example:
26# require 'des.pl'
27#
28# $key =pack("C8",0x12,0x23,0x45,0x67,0x89,0xab,0xcd,0xef);
29# @ks= &des_set_key($key);
30#
31# $outbytes= &des_ecb_encrypt(*ks,1,$data);
32# @enc =unpack("C8",$outbytes);
33#
34
35package des;
36
37eval("use integer;") if (int($]) > 4);
38
39# The following 8 arrays are used in des_set_key
40@skb0=(
41# for C bits (numbered as per FIPS 46) 1 2 3 4 5 6
420x00000000,0x00000010,0x20000000,0x20000010,
430x00010000,0x00010010,0x20010000,0x20010010,
440x00000800,0x00000810,0x20000800,0x20000810,
450x00010800,0x00010810,0x20010800,0x20010810,
460x00000020,0x00000030,0x20000020,0x20000030,
470x00010020,0x00010030,0x20010020,0x20010030,
480x00000820,0x00000830,0x20000820,0x20000830,
490x00010820,0x00010830,0x20010820,0x20010830,
500x00080000,0x00080010,0x20080000,0x20080010,
510x00090000,0x00090010,0x20090000,0x20090010,
520x00080800,0x00080810,0x20080800,0x20080810,
530x00090800,0x00090810,0x20090800,0x20090810,
540x00080020,0x00080030,0x20080020,0x20080030,
550x00090020,0x00090030,0x20090020,0x20090030,
560x00080820,0x00080830,0x20080820,0x20080830,
570x00090820,0x00090830,0x20090820,0x20090830,
58);
59@skb1=(
60# for C bits (numbered as per FIPS 46) 7 8 10 11 12 13
610x00000000,0x02000000,0x00002000,0x02002000,
620x00200000,0x02200000,0x00202000,0x02202000,
630x00000004,0x02000004,0x00002004,0x02002004,
640x00200004,0x02200004,0x00202004,0x02202004,
650x00000400,0x02000400,0x00002400,0x02002400,
660x00200400,0x02200400,0x00202400,0x02202400,
670x00000404,0x02000404,0x00002404,0x02002404,
680x00200404,0x02200404,0x00202404,0x02202404,
690x10000000,0x12000000,0x10002000,0x12002000,
700x10200000,0x12200000,0x10202000,0x12202000,
710x10000004,0x12000004,0x10002004,0x12002004,
720x10200004,0x12200004,0x10202004,0x12202004,
730x10000400,0x12000400,0x10002400,0x12002400,
740x10200400,0x12200400,0x10202400,0x12202400,
750x10000404,0x12000404,0x10002404,0x12002404,
760x10200404,0x12200404,0x10202404,0x12202404,
77);
78@skb2=(
79# for C bits (numbered as per FIPS 46) 14 15 16 17 19 20
800x00000000,0x00000001,0x00040000,0x00040001,
810x01000000,0x01000001,0x01040000,0x01040001,
820x00000002,0x00000003,0x00040002,0x00040003,
830x01000002,0x01000003,0x01040002,0x01040003,
840x00000200,0x00000201,0x00040200,0x00040201,
850x01000200,0x01000201,0x01040200,0x01040201,
860x00000202,0x00000203,0x00040202,0x00040203,
870x01000202,0x01000203,0x01040202,0x01040203,
880x08000000,0x08000001,0x08040000,0x08040001,
890x09000000,0x09000001,0x09040000,0x09040001,
900x08000002,0x08000003,0x08040002,0x08040003,
910x09000002,0x09000003,0x09040002,0x09040003,
920x08000200,0x08000201,0x08040200,0x08040201,
930x09000200,0x09000201,0x09040200,0x09040201,
940x08000202,0x08000203,0x08040202,0x08040203,
950x09000202,0x09000203,0x09040202,0x09040203,
96);
97@skb3=(
98# for C bits (numbered as per FIPS 46) 21 23 24 26 27 28
990x00000000,0x00100000,0x00000100,0x00100100,
1000x00000008,0x00100008,0x00000108,0x00100108,
1010x00001000,0x00101000,0x00001100,0x00101100,
1020x00001008,0x00101008,0x00001108,0x00101108,
1030x04000000,0x04100000,0x04000100,0x04100100,
1040x04000008,0x04100008,0x04000108,0x04100108,
1050x04001000,0x04101000,0x04001100,0x04101100,
1060x04001008,0x04101008,0x04001108,0x04101108,
1070x00020000,0x00120000,0x00020100,0x00120100,
1080x00020008,0x00120008,0x00020108,0x00120108,
1090x00021000,0x00121000,0x00021100,0x00121100,
1100x00021008,0x00121008,0x00021108,0x00121108,
1110x04020000,0x04120000,0x04020100,0x04120100,
1120x04020008,0x04120008,0x04020108,0x04120108,
1130x04021000,0x04121000,0x04021100,0x04121100,
1140x04021008,0x04121008,0x04021108,0x04121108,
115);
116@skb4=(
117# for D bits (numbered as per FIPS 46) 1 2 3 4 5 6
1180x00000000,0x10000000,0x00010000,0x10010000,
1190x00000004,0x10000004,0x00010004,0x10010004,
1200x20000000,0x30000000,0x20010000,0x30010000,
1210x20000004,0x30000004,0x20010004,0x30010004,
1220x00100000,0x10100000,0x00110000,0x10110000,
1230x00100004,0x10100004,0x00110004,0x10110004,
1240x20100000,0x30100000,0x20110000,0x30110000,
1250x20100004,0x30100004,0x20110004,0x30110004,
1260x00001000,0x10001000,0x00011000,0x10011000,
1270x00001004,0x10001004,0x00011004,0x10011004,
1280x20001000,0x30001000,0x20011000,0x30011000,
1290x20001004,0x30001004,0x20011004,0x30011004,
1300x00101000,0x10101000,0x00111000,0x10111000,
1310x00101004,0x10101004,0x00111004,0x10111004,
1320x20101000,0x30101000,0x20111000,0x30111000,
1330x20101004,0x30101004,0x20111004,0x30111004,
134);
135@skb5=(
136# for D bits (numbered as per FIPS 46) 8 9 11 12 13 14
1370x00000000,0x08000000,0x00000008,0x08000008,
1380x00000400,0x08000400,0x00000408,0x08000408,
1390x00020000,0x08020000,0x00020008,0x08020008,
1400x00020400,0x08020400,0x00020408,0x08020408,
1410x00000001,0x08000001,0x00000009,0x08000009,
1420x00000401,0x08000401,0x00000409,0x08000409,
1430x00020001,0x08020001,0x00020009,0x08020009,
1440x00020401,0x08020401,0x00020409,0x08020409,
1450x02000000,0x0A000000,0x02000008,0x0A000008,
1460x02000400,0x0A000400,0x02000408,0x0A000408,
1470x02020000,0x0A020000,0x02020008,0x0A020008,
1480x02020400,0x0A020400,0x02020408,0x0A020408,
1490x02000001,0x0A000001,0x02000009,0x0A000009,
1500x02000401,0x0A000401,0x02000409,0x0A000409,
1510x02020001,0x0A020001,0x02020009,0x0A020009,
1520x02020401,0x0A020401,0x02020409,0x0A020409,
153);
154@skb6=(
155# for D bits (numbered as per FIPS 46) 16 17 18 19 20 21
1560x00000000,0x00000100,0x00080000,0x00080100,
1570x01000000,0x01000100,0x01080000,0x01080100,
1580x00000010,0x00000110,0x00080010,0x00080110,
1590x01000010,0x01000110,0x01080010,0x01080110,
1600x00200000,0x00200100,0x00280000,0x00280100,
1610x01200000,0x01200100,0x01280000,0x01280100,
1620x00200010,0x00200110,0x00280010,0x00280110,
1630x01200010,0x01200110,0x01280010,0x01280110,
1640x00000200,0x00000300,0x00080200,0x00080300,
1650x01000200,0x01000300,0x01080200,0x01080300,
1660x00000210,0x00000310,0x00080210,0x00080310,
1670x01000210,0x01000310,0x01080210,0x01080310,
1680x00200200,0x00200300,0x00280200,0x00280300,
1690x01200200,0x01200300,0x01280200,0x01280300,
1700x00200210,0x00200310,0x00280210,0x00280310,
1710x01200210,0x01200310,0x01280210,0x01280310,
172);
173@skb7=(
174# for D bits (numbered as per FIPS 46) 22 23 24 25 27 28
1750x00000000,0x04000000,0x00040000,0x04040000,
1760x00000002,0x04000002,0x00040002,0x04040002,
1770x00002000,0x04002000,0x00042000,0x04042000,
1780x00002002,0x04002002,0x00042002,0x04042002,
1790x00000020,0x04000020,0x00040020,0x04040020,
1800x00000022,0x04000022,0x00040022,0x04040022,
1810x00002020,0x04002020,0x00042020,0x04042020,
1820x00002022,0x04002022,0x00042022,0x04042022,
1830x00000800,0x04000800,0x00040800,0x04040800,
1840x00000802,0x04000802,0x00040802,0x04040802,
1850x00002800,0x04002800,0x00042800,0x04042800,
1860x00002802,0x04002802,0x00042802,0x04042802,
1870x00000820,0x04000820,0x00040820,0x04040820,
1880x00000822,0x04000822,0x00040822,0x04040822,
1890x00002820,0x04002820,0x00042820,0x04042820,
1900x00002822,0x04002822,0x00042822,0x04042822,
191);
192
193@shifts2=(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0);
194
195# used in ecb_encrypt
196@SP0=(
1970x00410100, 0x00010000, 0x40400000, 0x40410100,
1980x00400000, 0x40010100, 0x40010000, 0x40400000,
1990x40010100, 0x00410100, 0x00410000, 0x40000100,
2000x40400100, 0x00400000, 0x00000000, 0x40010000,
2010x00010000, 0x40000000, 0x00400100, 0x00010100,
2020x40410100, 0x00410000, 0x40000100, 0x00400100,
2030x40000000, 0x00000100, 0x00010100, 0x40410000,
2040x00000100, 0x40400100, 0x40410000, 0x00000000,
2050x00000000, 0x40410100, 0x00400100, 0x40010000,
2060x00410100, 0x00010000, 0x40000100, 0x00400100,
2070x40410000, 0x00000100, 0x00010100, 0x40400000,
2080x40010100, 0x40000000, 0x40400000, 0x00410000,
2090x40410100, 0x00010100, 0x00410000, 0x40400100,
2100x00400000, 0x40000100, 0x40010000, 0x00000000,
2110x00010000, 0x00400000, 0x40400100, 0x00410100,
2120x40000000, 0x40410000, 0x00000100, 0x40010100,
213);
214@SP1=(
2150x08021002, 0x00000000, 0x00021000, 0x08020000,
2160x08000002, 0x00001002, 0x08001000, 0x00021000,
2170x00001000, 0x08020002, 0x00000002, 0x08001000,
2180x00020002, 0x08021000, 0x08020000, 0x00000002,
2190x00020000, 0x08001002, 0x08020002, 0x00001000,
2200x00021002, 0x08000000, 0x00000000, 0x00020002,
2210x08001002, 0x00021002, 0x08021000, 0x08000002,
2220x08000000, 0x00020000, 0x00001002, 0x08021002,
2230x00020002, 0x08021000, 0x08001000, 0x00021002,
2240x08021002, 0x00020002, 0x08000002, 0x00000000,
2250x08000000, 0x00001002, 0x00020000, 0x08020002,
2260x00001000, 0x08000000, 0x00021002, 0x08001002,
2270x08021000, 0x00001000, 0x00000000, 0x08000002,
2280x00000002, 0x08021002, 0x00021000, 0x08020000,
2290x08020002, 0x00020000, 0x00001002, 0x08001000,
2300x08001002, 0x00000002, 0x08020000, 0x00021000,
231);
232@SP2=(
2330x20800000, 0x00808020, 0x00000020, 0x20800020,
2340x20008000, 0x00800000, 0x20800020, 0x00008020,
2350x00800020, 0x00008000, 0x00808000, 0x20000000,
2360x20808020, 0x20000020, 0x20000000, 0x20808000,
2370x00000000, 0x20008000, 0x00808020, 0x00000020,
2380x20000020, 0x20808020, 0x00008000, 0x20800000,
2390x20808000, 0x00800020, 0x20008020, 0x00808000,
2400x00008020, 0x00000000, 0x00800000, 0x20008020,
2410x00808020, 0x00000020, 0x20000000, 0x00008000,
2420x20000020, 0x20008000, 0x00808000, 0x20800020,
2430x00000000, 0x00808020, 0x00008020, 0x20808000,
2440x20008000, 0x00800000, 0x20808020, 0x20000000,
2450x20008020, 0x20800000, 0x00800000, 0x20808020,
2460x00008000, 0x00800020, 0x20800020, 0x00008020,
2470x00800020, 0x00000000, 0x20808000, 0x20000020,
2480x20800000, 0x20008020, 0x00000020, 0x00808000,
249);
250@SP3=(
2510x00080201, 0x02000200, 0x00000001, 0x02080201,
2520x00000000, 0x02080000, 0x02000201, 0x00080001,
2530x02080200, 0x02000001, 0x02000000, 0x00000201,
2540x02000001, 0x00080201, 0x00080000, 0x02000000,
2550x02080001, 0x00080200, 0x00000200, 0x00000001,
2560x00080200, 0x02000201, 0x02080000, 0x00000200,
2570x00000201, 0x00000000, 0x00080001, 0x02080200,
2580x02000200, 0x02080001, 0x02080201, 0x00080000,
2590x02080001, 0x00000201, 0x00080000, 0x02000001,
2600x00080200, 0x02000200, 0x00000001, 0x02080000,
2610x02000201, 0x00000000, 0x00000200, 0x00080001,
2620x00000000, 0x02080001, 0x02080200, 0x00000200,
2630x02000000, 0x02080201, 0x00080201, 0x00080000,
2640x02080201, 0x00000001, 0x02000200, 0x00080201,
2650x00080001, 0x00080200, 0x02080000, 0x02000201,
2660x00000201, 0x02000000, 0x02000001, 0x02080200,
267);
268@SP4=(
2690x01000000, 0x00002000, 0x00000080, 0x01002084,
2700x01002004, 0x01000080, 0x00002084, 0x01002000,
2710x00002000, 0x00000004, 0x01000004, 0x00002080,
2720x01000084, 0x01002004, 0x01002080, 0x00000000,
2730x00002080, 0x01000000, 0x00002004, 0x00000084,
2740x01000080, 0x00002084, 0x00000000, 0x01000004,
2750x00000004, 0x01000084, 0x01002084, 0x00002004,
2760x01002000, 0x00000080, 0x00000084, 0x01002080,
2770x01002080, 0x01000084, 0x00002004, 0x01002000,
2780x00002000, 0x00000004, 0x01000004, 0x01000080,
2790x01000000, 0x00002080, 0x01002084, 0x00000000,
2800x00002084, 0x01000000, 0x00000080, 0x00002004,
2810x01000084, 0x00000080, 0x00000000, 0x01002084,
2820x01002004, 0x01002080, 0x00000084, 0x00002000,
2830x00002080, 0x01002004, 0x01000080, 0x00000084,
2840x00000004, 0x00002084, 0x01002000, 0x01000004,
285);
286@SP5=(
2870x10000008, 0x00040008, 0x00000000, 0x10040400,
2880x00040008, 0x00000400, 0x10000408, 0x00040000,
2890x00000408, 0x10040408, 0x00040400, 0x10000000,
2900x10000400, 0x10000008, 0x10040000, 0x00040408,
2910x00040000, 0x10000408, 0x10040008, 0x00000000,
2920x00000400, 0x00000008, 0x10040400, 0x10040008,
2930x10040408, 0x10040000, 0x10000000, 0x00000408,
2940x00000008, 0x00040400, 0x00040408, 0x10000400,
2950x00000408, 0x10000000, 0x10000400, 0x00040408,
2960x10040400, 0x00040008, 0x00000000, 0x10000400,
2970x10000000, 0x00000400, 0x10040008, 0x00040000,
2980x00040008, 0x10040408, 0x00040400, 0x00000008,
2990x10040408, 0x00040400, 0x00040000, 0x10000408,
3000x10000008, 0x10040000, 0x00040408, 0x00000000,
3010x00000400, 0x10000008, 0x10000408, 0x10040400,
3020x10040000, 0x00000408, 0x00000008, 0x10040008,
303);
304@SP6=(
3050x00000800, 0x00000040, 0x00200040, 0x80200000,
3060x80200840, 0x80000800, 0x00000840, 0x00000000,
3070x00200000, 0x80200040, 0x80000040, 0x00200800,
3080x80000000, 0x00200840, 0x00200800, 0x80000040,
3090x80200040, 0x00000800, 0x80000800, 0x80200840,
3100x00000000, 0x00200040, 0x80200000, 0x00000840,
3110x80200800, 0x80000840, 0x00200840, 0x80000000,
3120x80000840, 0x80200800, 0x00000040, 0x00200000,
3130x80000840, 0x00200800, 0x80200800, 0x80000040,
3140x00000800, 0x00000040, 0x00200000, 0x80200800,
3150x80200040, 0x80000840, 0x00000840, 0x00000000,
3160x00000040, 0x80200000, 0x80000000, 0x00200040,
3170x00000000, 0x80200040, 0x00200040, 0x00000840,
3180x80000040, 0x00000800, 0x80200840, 0x00200000,
3190x00200840, 0x80000000, 0x80000800, 0x80200840,
3200x80200000, 0x00200840, 0x00200800, 0x80000800,
321);
322@SP7=(
3230x04100010, 0x04104000, 0x00004010, 0x00000000,
3240x04004000, 0x00100010, 0x04100000, 0x04104010,
3250x00000010, 0x04000000, 0x00104000, 0x00004010,
3260x00104010, 0x04004010, 0x04000010, 0x04100000,
3270x00004000, 0x00104010, 0x00100010, 0x04004000,
3280x04104010, 0x04000010, 0x00000000, 0x00104000,
3290x04000000, 0x00100000, 0x04004010, 0x04100010,
3300x00100000, 0x00004000, 0x04104000, 0x00000010,
3310x00100000, 0x00004000, 0x04000010, 0x04104010,
3320x00004010, 0x04000000, 0x00000000, 0x00104000,
3330x04100010, 0x04004010, 0x04004000, 0x00100010,
3340x04104000, 0x00000010, 0x00100010, 0x04004000,
3350x04104010, 0x00100000, 0x04100000, 0x04000010,
3360x00104000, 0x00004010, 0x04004010, 0x04100000,
3370x00000010, 0x04104000, 0x00104010, 0x00000000,
3380x04000000, 0x04100010, 0x00004000, 0x00104010,
339);
340
341sub main'des_set_key
342 {
343 local($param)=@_;
344 local(@key);
345 local($c,$d,$i,$s,$t);
346 local(@ks)=();
347
348 # Get the bytes in the order we want.
349 @key=unpack("C8",$param);
350
351 $c= ($key[0] )|
352 ($key[1]<< 8)|
353 ($key[2]<<16)|
354 ($key[3]<<24);
355 $d= ($key[4] )|
356 ($key[5]<< 8)|
357 ($key[6]<<16)|
358 ($key[7]<<24);
359
360 &doPC1(*c,*d);
361
362 for $i (@shifts2)
363 {
364 if ($i)
365 {
366 $c=($c>>2)|($c<<26);
367 $d=($d>>2)|($d<<26);
368 }
369 else
370 {
371 $c=($c>>1)|($c<<27);
372 $d=($d>>1)|($d<<27);
373 }
374 $c&=0x0fffffff;
375 $d&=0x0fffffff;
376 $s= $skb0[ ($c )&0x3f ]|
377 $skb1[(($c>> 6)&0x03)|(($c>> 7)&0x3c)]|
378 $skb2[(($c>>13)&0x0f)|(($c>>14)&0x30)]|
379 $skb3[(($c>>20)&0x01)|(($c>>21)&0x06) |
380 (($c>>22)&0x38)];
381 $t= $skb4[ ($d )&0x3f ]|
382 $skb5[(($d>> 7)&0x03)|(($d>> 8)&0x3c)]|
383 $skb6[ ($d>>15)&0x3f ]|
384 $skb7[(($d>>21)&0x0f)|(($d>>22)&0x30)];
385 push(@ks,(($t<<16)|($s&0x0000ffff))&0xffffffff);
386 $s= (($s>>16)&0x0000ffff)|($t&0xffff0000) ;
387 push(@ks,(($s<<4)|(($s>>28)&0xf))&0xffffffff);
388 }
389 @ks;
390 }
391
392sub doPC1
393 {
394 local(*a,*b)=@_;
395 local($t);
396
397 $t=(($b>>4)^$a)&0x0f0f0f0f;
398 $b^=($t<<4); $a^=$t;
399 # do $a first
400 $t=(($a<<18)^$a)&0xcccc0000;
401 $a=$a^$t^(($t>>18)&0x00003fff);
402 $t=(($a<<17)^$a)&0xaaaa0000;
403 $a=$a^$t^(($t>>17)&0x00007fff);
404 $t=(($a<< 8)^$a)&0x00ff0000;
405 $a=$a^$t^(($t>> 8)&0x00ffffff);
406 $t=(($a<<17)^$a)&0xaaaa0000;
407 $a=$a^$t^(($t>>17)&0x00007fff);
408
409 # now do $b
410 $t=(($b<<24)^$b)&0xff000000;
411 $b=$b^$t^(($t>>24)&0x000000ff);
412 $t=(($b<< 8)^$b)&0x00ff0000;
413 $b=$b^$t^(($t>> 8)&0x00ffffff);
414 $t=(($b<<14)^$b)&0x33330000;
415 $b=$b^$t^(($t>>14)&0x0003ffff);
416 $b=(($b&0x00aa00aa)<<7)|(($b&0x55005500)>>7)|($b&0xaa55aa55);
417 $b=(($b>>8)&0x00ffffff)|((($a&0xf0000000)>>4)&0x0fffffff);
418 $a&=0x0fffffff;
419 }
420
421sub doIP
422 {
423 local(*a,*b)=@_;
424 local($t);
425
426 $t=(($b>> 4)^$a)&0x0f0f0f0f;
427 $b^=($t<< 4); $a^=$t;
428 $t=(($a>>16)^$b)&0x0000ffff;
429 $a^=($t<<16); $b^=$t;
430 $t=(($b>> 2)^$a)&0x33333333;
431 $b^=($t<< 2); $a^=$t;
432 $t=(($a>> 8)^$b)&0x00ff00ff;
433 $a^=($t<< 8); $b^=$t;
434 $t=(($b>> 1)^$a)&0x55555555;
435 $b^=($t<< 1); $a^=$t;
436 $t=$a;
437 $a=$b&0xffffffff;
438 $b=$t&0xffffffff;
439 }
440
441sub doFP
442 {
443 local(*a,*b)=@_;
444 local($t);
445
446 $t=(($b>> 1)^$a)&0x55555555;
447 $b^=($t<< 1); $a^=$t;
448 $t=(($a>> 8)^$b)&0x00ff00ff;
449 $a^=($t<< 8); $b^=$t;
450 $t=(($b>> 2)^$a)&0x33333333;
451 $b^=($t<< 2); $a^=$t;
452 $t=(($a>>16)^$b)&0x0000ffff;
453 $a^=($t<<16); $b^=$t;
454 $t=(($b>> 4)^$a)&0x0f0f0f0f;
455 $b^=($t<< 4); $a^=$t;
456 $a&=0xffffffff;
457 $b&=0xffffffff;
458 }
459
460sub main'des_ecb_encrypt
461 {
462 local(*ks,$encrypt,$in)=@_;
463 local($l,$r,$i,$t,$u,@input);
464
465 @input=unpack("C8",$in);
466 # Get the bytes in the order we want.
467 $l= ($input[0] )|
468 ($input[1]<< 8)|
469 ($input[2]<<16)|
470 ($input[3]<<24);
471 $r= ($input[4] )|
472 ($input[5]<< 8)|
473 ($input[6]<<16)|
474 ($input[7]<<24);
475
476 $l&=0xffffffff;
477 $r&=0xffffffff;
478 &doIP(*l,*r);
479 if ($encrypt)
480 {
481 for ($i=0; $i<32; $i+=4)
482 {
483 $t=((($r&0x7fffffff)<<1)|(($r>>31)&0x00000001));
484 $u=$t^$ks[$i ];
485 $t=$t^$ks[$i+1];
486 $t2=(($t&0x0000000f)<<28);
487
488 $t=((($t>>4)&0x0fffffff)|(($t&0x0000000f)<<28));
489 $l^= $SP1[ $t &0x3f]|
490 $SP3[($t>> 8)&0x3f]|
491 $SP5[($t>>16)&0x3f]|
492 $SP7[($t>>24)&0x3f]|
493 $SP0[ $u &0x3f]|
494 $SP2[($u>> 8)&0x3f]|
495 $SP4[($u>>16)&0x3f]|
496 $SP6[($u>>24)&0x3f];
497
498 $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff;
499 $u=$t^$ks[$i+2];
500 $t=$t^$ks[$i+3];
501 $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
502 $r^= $SP1[ $t &0x3f]|
503 $SP3[($t>> 8)&0x3f]|
504 $SP5[($t>>16)&0x3f]|
505 $SP7[($t>>24)&0x3f]|
506 $SP0[ $u &0x3f]|
507 $SP2[($u>> 8)&0x3f]|
508 $SP4[($u>>16)&0x3f]|
509 $SP6[($u>>24)&0x3f];
510 }
511 }
512 else
513 {
514 for ($i=30; $i>0; $i-=4)
515 {
516 $t=(($r<<1)|(($r>>31)&0x1))&0xffffffff;
517 $u=$t^$ks[$i ];
518 $t=$t^$ks[$i+1];
519 $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
520 $l^= $SP1[ $t &0x3f]|
521 $SP3[($t>> 8)&0x3f]|
522 $SP5[($t>>16)&0x3f]|
523 $SP7[($t>>24)&0x3f]|
524 $SP0[ $u &0x3f]|
525 $SP2[($u>> 8)&0x3f]|
526 $SP4[($u>>16)&0x3f]|
527 $SP6[($u>>24)&0x3f];
528
529 $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff;
530 $u=$t^$ks[$i-2];
531 $t=$t^$ks[$i-1];
532 $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
533 $r^= $SP1[ $t &0x3f]|
534 $SP3[($t>> 8)&0x3f]|
535 $SP5[($t>>16)&0x3f]|
536 $SP7[($t>>24)&0x3f]|
537 $SP0[ $u &0x3f]|
538 $SP2[($u>> 8)&0x3f]|
539 $SP4[($u>>16)&0x3f]|
540 $SP6[($u>>24)&0x3f];
541 }
542 }
543 &doFP(*l,*r);
544 pack("C8",$l&0xff,
545 ($l>> 8)&0x00ffffff,
546 ($l>>16)&0x0000ffff,
547 ($l>>24)&0x000000ff,
548 $r&0xff,
549 ($r>> 8)&0x00ffffff,
550 ($r>>16)&0x0000ffff,
551 ($r>>24)&0x000000ff);
552 }
diff --git a/src/lib/libcrypto/des/des_crypt.man b/src/lib/libcrypto/des/des_crypt.man
new file mode 100644
index 0000000000..0ecc416877
--- /dev/null
+++ b/src/lib/libcrypto/des/des_crypt.man
@@ -0,0 +1,508 @@
1.TH DES_CRYPT 3
2.SH NAME
3des_read_password, des_read_2password,
4des_string_to_key, des_string_to_2key, des_read_pw_string,
5des_random_key, des_set_key,
6des_key_sched, des_ecb_encrypt, des_ecb3_encrypt, des_cbc_encrypt,
7des_3cbc_encrypt,
8des_pcbc_encrypt, des_cfb_encrypt, des_ofb_encrypt,
9des_cbc_cksum, des_quad_cksum,
10des_enc_read, des_enc_write, des_set_odd_parity,
11des_is_weak_key, crypt \- (non USA) DES encryption
12.SH SYNOPSIS
13.nf
14.nj
15.ft B
16#include <des.h>
17.PP
18.B int des_read_password(key,prompt,verify)
19des_cblock *key;
20char *prompt;
21int verify;
22.PP
23.B int des_read_2password(key1,key2,prompt,verify)
24des_cblock *key1,*key2;
25char *prompt;
26int verify;
27.PP
28.B int des_string_to_key(str,key)
29char *str;
30des_cblock *key;
31.PP
32.B int des_string_to_2keys(str,key1,key2)
33char *str;
34des_cblock *key1,*key2;
35.PP
36.B int des_read_pw_string(buf,length,prompt,verify)
37char *buf;
38int length;
39char *prompt;
40int verify;
41.PP
42.B int des_random_key(key)
43des_cblock *key;
44.PP
45.B int des_set_key(key,schedule)
46des_cblock *key;
47des_key_schedule schedule;
48.PP
49.B int des_key_sched(key,schedule)
50des_cblock *key;
51des_key_schedule schedule;
52.PP
53.B int des_ecb_encrypt(input,output,schedule,encrypt)
54des_cblock *input;
55des_cblock *output;
56des_key_schedule schedule;
57int encrypt;
58.PP
59.B int des_ecb3_encrypt(input,output,ks1,ks2,encrypt)
60des_cblock *input;
61des_cblock *output;
62des_key_schedule ks1,ks2;
63int encrypt;
64.PP
65.B int des_cbc_encrypt(input,output,length,schedule,ivec,encrypt)
66des_cblock *input;
67des_cblock *output;
68long length;
69des_key_schedule schedule;
70des_cblock *ivec;
71int encrypt;
72.PP
73.B int des_3cbc_encrypt(input,output,length,sk1,sk2,ivec1,ivec2,encrypt)
74des_cblock *input;
75des_cblock *output;
76long length;
77des_key_schedule sk1;
78des_key_schedule sk2;
79des_cblock *ivec1;
80des_cblock *ivec2;
81int encrypt;
82.PP
83.B int des_pcbc_encrypt(input,output,length,schedule,ivec,encrypt)
84des_cblock *input;
85des_cblock *output;
86long length;
87des_key_schedule schedule;
88des_cblock *ivec;
89int encrypt;
90.PP
91.B int des_cfb_encrypt(input,output,numbits,length,schedule,ivec,encrypt)
92unsigned char *input;
93unsigned char *output;
94int numbits;
95long length;
96des_key_schedule schedule;
97des_cblock *ivec;
98int encrypt;
99.PP
100.B int des_ofb_encrypt(input,output,numbits,length,schedule,ivec)
101unsigned char *input,*output;
102int numbits;
103long length;
104des_key_schedule schedule;
105des_cblock *ivec;
106.PP
107.B unsigned long des_cbc_cksum(input,output,length,schedule,ivec)
108des_cblock *input;
109des_cblock *output;
110long length;
111des_key_schedule schedule;
112des_cblock *ivec;
113.PP
114.B unsigned long des_quad_cksum(input,output,length,out_count,seed)
115des_cblock *input;
116des_cblock *output;
117long length;
118int out_count;
119des_cblock *seed;
120.PP
121.B int des_check_key;
122.PP
123.B int des_enc_read(fd,buf,len,sched,iv)
124int fd;
125char *buf;
126int len;
127des_key_schedule sched;
128des_cblock *iv;
129.PP
130.B int des_enc_write(fd,buf,len,sched,iv)
131int fd;
132char *buf;
133int len;
134des_key_schedule sched;
135des_cblock *iv;
136.PP
137.B extern int des_rw_mode;
138.PP
139.B void des_set_odd_parity(key)
140des_cblock *key;
141.PP
142.B int des_is_weak_key(key)
143des_cblock *key;
144.PP
145.B char *crypt(passwd,salt)
146char *passwd;
147char *salt;
148.PP
149.fi
150.SH DESCRIPTION
151This library contains a fast implementation of the DES encryption
152algorithm.
153.PP
154There are two phases to the use of DES encryption.
155The first is the generation of a
156.I des_key_schedule
157from a key,
158the second is the actual encryption.
159A des key is of type
160.I des_cblock.
161This type is made from 8 characters with odd parity.
162The least significant bit in the character is the parity bit.
163The key schedule is an expanded form of the key; it is used to speed the
164encryption process.
165.PP
166.I des_read_password
167writes the string specified by prompt to the standard output,
168turns off echo and reads an input string from standard input
169until terminated with a newline.
170If verify is non-zero, it prompts and reads the input again and verifies
171that both entered passwords are the same.
172The entered string is converted into a des key by using the
173.I des_string_to_key
174routine.
175The new key is placed in the
176.I des_cblock
177that was passed (by reference) to the routine.
178If there were no errors,
179.I des_read_password
180returns 0,
181-1 is returned if there was a terminal error and 1 is returned for
182any other error.
183.PP
184.I des_read_2password
185operates in the same way as
186.I des_read_password
187except that it generates 2 keys by using the
188.I des_string_to_2key
189function.
190.PP
191.I des_read_pw_string
192is called by
193.I des_read_password
194to read and verify a string from a terminal device.
195The string is returned in
196.I buf.
197The size of
198.I buf
199is passed to the routine via the
200.I length
201parameter.
202.PP
203.I des_string_to_key
204converts a string into a valid des key.
205.PP
206.I des_string_to_2key
207converts a string into 2 valid des keys.
208This routine is best suited for used to generate keys for use with
209.I des_ecb3_encrypt.
210.PP
211.I des_random_key
212returns a random key that is made of a combination of process id,
213time and an increasing counter.
214.PP
215Before a des key can be used it is converted into a
216.I des_key_schedule
217via the
218.I des_set_key
219routine.
220If the
221.I des_check_key
222flag is non-zero,
223.I des_set_key
224will check that the key passed is of odd parity and is not a week or
225semi-weak key.
226If the parity is wrong,
227then -1 is returned.
228If the key is a weak key,
229then -2 is returned.
230If an error is returned,
231the key schedule is not generated.
232.PP
233.I des_key_sched
234is another name for the
235.I des_set_key
236function.
237.PP
238The following routines mostly operate on an input and output stream of
239.I des_cblock's.
240.PP
241.I des_ecb_encrypt
242is the basic DES encryption routine that encrypts or decrypts a single 8-byte
243.I des_cblock
244in
245.I electronic code book
246mode.
247It always transforms the input data, pointed to by
248.I input,
249into the output data,
250pointed to by the
251.I output
252argument.
253If the
254.I encrypt
255argument is non-zero (DES_ENCRYPT),
256the
257.I input
258(cleartext) is encrypted in to the
259.I output
260(ciphertext) using the key_schedule specified by the
261.I schedule
262argument,
263previously set via
264.I des_set_key.
265If
266.I encrypt
267is zero (DES_DECRYPT),
268the
269.I input
270(now ciphertext)
271is decrypted into the
272.I output
273(now cleartext).
274Input and output may overlap.
275No meaningful value is returned.
276.PP
277.I des_ecb3_encrypt
278encrypts/decrypts the
279.I input
280block by using triple ecb DES encryption.
281This involves encrypting the input with
282.I ks1,
283decryption with the key schedule
284.I ks2,
285and then encryption with the first again.
286This routine greatly reduces the chances of brute force breaking of
287DES and has the advantage of if
288.I ks1
289and
290.I ks2
291are the same, it is equivalent to just encryption using ecb mode and
292.I ks1
293as the key.
294.PP
295.I des_cbc_encrypt
296encrypts/decrypts using the
297.I cipher-block-chaining
298mode of DES.
299If the
300.I encrypt
301argument is non-zero,
302the routine cipher-block-chain encrypts the cleartext data pointed to by the
303.I input
304argument into the ciphertext pointed to by the
305.I output
306argument,
307using the key schedule provided by the
308.I schedule
309argument,
310and initialisation vector provided by the
311.I ivec
312argument.
313If the
314.I length
315argument is not an integral multiple of eight bytes,
316the last block is copied to a temporary area and zero filled.
317The output is always
318an integral multiple of eight bytes.
319To make multiple cbc encrypt calls on a large amount of data appear to
320be one
321.I des_cbc_encrypt
322call, the
323.I ivec
324of subsequent calls should be the last 8 bytes of the output.
325.PP
326.I des_3cbc_encrypt
327encrypts/decrypts the
328.I input
329block by using triple cbc DES encryption.
330This involves encrypting the input with key schedule
331.I ks1,
332decryption with the key schedule
333.I ks2,
334and then encryption with the first again.
3352 initialisation vectors are required,
336.I ivec1
337and
338.I ivec2.
339Unlike
340.I des_cbc_encrypt,
341these initialisation vectors are modified by the subroutine.
342This routine greatly reduces the chances of brute force breaking of
343DES and has the advantage of if
344.I ks1
345and
346.I ks2
347are the same, it is equivalent to just encryption using cbc mode and
348.I ks1
349as the key.
350.PP
351.I des_pcbc_encrypt
352encrypt/decrypts using a modified block chaining mode.
353It provides better error propagation characteristics than cbc
354encryption.
355.PP
356.I des_cfb_encrypt
357encrypt/decrypts using cipher feedback mode. This method takes an
358array of characters as input and outputs and array of characters. It
359does not require any padding to 8 character groups. Note: the ivec
360variable is changed and the new changed value needs to be passed to
361the next call to this function. Since this function runs a complete
362DES ecb encryption per numbits, this function is only suggested for
363use when sending small numbers of characters.
364.PP
365.I des_ofb_encrypt
366encrypt using output feedback mode. This method takes an
367array of characters as input and outputs and array of characters. It
368does not require any padding to 8 character groups. Note: the ivec
369variable is changed and the new changed value needs to be passed to
370the next call to this function. Since this function runs a complete
371DES ecb encryption per numbits, this function is only suggested for
372use when sending small numbers of characters.
373.PP
374.I des_cbc_cksum
375produces an 8 byte checksum based on the input stream (via cbc encryption).
376The last 4 bytes of the checksum is returned and the complete 8 bytes is
377placed in
378.I output.
379.PP
380.I des_quad_cksum
381returns a 4 byte checksum from the input bytes.
382The algorithm can be iterated over the input,
383depending on
384.I out_count,
3851, 2, 3 or 4 times.
386If
387.I output
388is non-NULL,
389the 8 bytes generated by each pass are written into
390.I output.
391.PP
392.I des_enc_write
393is used to write
394.I len
395bytes
396to file descriptor
397.I fd
398from buffer
399.I buf.
400The data is encrypted via
401.I pcbc_encrypt
402(default) using
403.I sched
404for the key and
405.I iv
406as a starting vector.
407The actual data send down
408.I fd
409consists of 4 bytes (in network byte order) containing the length of the
410following encrypted data. The encrypted data then follows, padded with random
411data out to a multiple of 8 bytes.
412.PP
413.I des_enc_read
414is used to read
415.I len
416bytes
417from file descriptor
418.I fd
419into buffer
420.I buf.
421The data being read from
422.I fd
423is assumed to have come from
424.I des_enc_write
425and is decrypted using
426.I sched
427for the key schedule and
428.I iv
429for the initial vector.
430The
431.I des_enc_read/des_enc_write
432pair can be used to read/write to files, pipes and sockets.
433I have used them in implementing a version of rlogin in which all
434data is encrypted.
435.PP
436.I des_rw_mode
437is used to specify the encryption mode to use with
438.I des_enc_read
439and
440.I des_end_write.
441If set to
442.I DES_PCBC_MODE
443(the default), des_pcbc_encrypt is used.
444If set to
445.I DES_CBC_MODE
446des_cbc_encrypt is used.
447These two routines and the variable are not part of the normal MIT library.
448.PP
449.I des_set_odd_parity
450sets the parity of the passed
451.I key
452to odd. This routine is not part of the standard MIT library.
453.PP
454.I des_is_weak_key
455returns 1 is the passed key is a weak key (pick again :-),
4560 if it is ok.
457This routine is not part of the standard MIT library.
458.PP
459.I crypt
460is a replacement for the normal system crypt.
461It is much faster than the system crypt.
462.PP
463.SH FILES
464/usr/include/des.h
465.br
466/usr/lib/libdes.a
467.PP
468The encryption routines have been tested on 16bit, 32bit and 64bit
469machines of various endian and even works under VMS.
470.PP
471.SH BUGS
472.PP
473If you think this manual is sparse,
474read the des_crypt(3) manual from the MIT kerberos (or bones outside
475of the USA) distribution.
476.PP
477.I des_cfb_encrypt
478and
479.I des_ofb_encrypt
480operates on input of 8 bits. What this means is that if you set
481numbits to 12, and length to 2, the first 12 bits will come from the 1st
482input byte and the low half of the second input byte. The second 12
483bits will have the low 8 bits taken from the 3rd input byte and the
484top 4 bits taken from the 4th input byte. The same holds for output.
485This function has been implemented this way because most people will
486be using a multiple of 8 and because once you get into pulling bytes input
487bytes apart things get ugly!
488.PP
489.I des_read_pw_string
490is the most machine/OS dependent function and normally generates the
491most problems when porting this code.
492.PP
493.I des_string_to_key
494is probably different from the MIT version since there are lots
495of fun ways to implement one-way encryption of a text string.
496.PP
497The routines are optimised for 32 bit machines and so are not efficient
498on IBM PCs.
499.PP
500NOTE: extensive work has been done on this library since this document
501was origionally written. Please try to read des.doc from the libdes
502distribution since it is far more upto date and documents more of the
503functions. Libdes is now also being shipped as part of SSLeay, a
504general cryptographic library that amonst other things implements
505netscapes SSL protocoll. The most recent version can be found in
506SSLeay distributions.
507.SH AUTHOR
508Eric Young (eay@cryptsoft.com)
diff --git a/src/lib/libcrypto/des/des_locl.org b/src/lib/libcrypto/des/des_locl.org
new file mode 100644
index 0000000000..e2e503cbed
--- /dev/null
+++ b/src/lib/libcrypto/des/des_locl.org
@@ -0,0 +1,516 @@
1/* crypto/des/des_locl.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify des_locl.org since des_locl.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_DES_LOCL_H
68#define HEADER_DES_LOCL_H
69
70#if defined(WIN32) || defined(WIN16)
71#ifndef MSDOS
72#define MSDOS
73#endif
74#endif
75
76#include <stdio.h>
77#include <stdlib.h>
78#ifndef MSDOS
79#include <unistd.h>
80#endif
81#include "des.h"
82
83#ifndef DES_DEFAULT_OPTIONS
84/* the following is tweaked from a config script, that is why it is a
85 * protected undef/define */
86#ifndef DES_PTR
87#undef DES_PTR
88#endif
89
90/* This helps C compiler generate the correct code for multiple functional
91 * units. It reduces register dependancies at the expense of 2 more
92 * registers */
93#ifndef DES_RISC1
94#undef DES_RISC1
95#endif
96
97#ifndef DES_RISC2
98#undef DES_RISC2
99#endif
100
101#if defined(DES_RISC1) && defined(DES_RISC2)
102YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
103#endif
104
105/* Unroll the inner loop, this sometimes helps, sometimes hinders.
106 * Very mucy CPU dependant */
107#ifndef DES_UNROLL
108#undef DES_UNROLL
109#endif
110
111/* These default values were supplied by
112 * Peter Gutman <pgut001@cs.auckland.ac.nz>
113 * They are only used if nothing else has been defined */
114#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
115/* Special defines which change the way the code is built depending on the
116 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
117 even newer MIPS CPU's, but at the moment one size fits all for
118 optimization options. Older Sparc's work better with only UNROLL, but
119 there's no way to tell at compile time what it is you're running on */
120
121#if defined( sun ) /* Newer Sparc's */
122 #define DES_PTR
123 #define DES_RISC1
124 #define DES_UNROLL
125#elif defined( __ultrix ) /* Older MIPS */
126 #define DES_PTR
127 #define DES_RISC2
128 #define DES_UNROLL
129#elif defined( __osf1__ ) /* Alpha */
130 #define DES_PTR
131 #define DES_RISC2
132#elif defined ( _AIX ) /* RS6000 */
133 /* Unknown */
134#elif defined( __hpux ) /* HP-PA */
135 /* Unknown */
136#elif defined( __aux ) /* 68K */
137 /* Unknown */
138#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
139 #define DES_UNROLL
140#elif defined( __sgi ) /* Newer MIPS */
141 #define DES_PTR
142 #define DES_RISC2
143 #define DES_UNROLL
144#elif defined( i386 ) /* x86 boxes, should be gcc */
145 #define DES_PTR
146 #define DES_RISC1
147 #define DES_UNROLL
148#endif /* Systems-specific speed defines */
149#endif
150
151#endif /* DES_DEFAULT_OPTIONS */
152
153#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */
154#include <stdlib.h>
155#include <errno.h>
156#include <time.h>
157#include <io.h>
158#ifndef RAND
159#define RAND
160#endif
161#undef NOPROTO
162#endif
163
164#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
165#include <string.h>
166#endif
167
168#ifndef RAND
169#define RAND
170#endif
171
172#ifdef linux
173#undef RAND
174#endif
175
176#ifdef MSDOS
177#define getpid() 2
178#define RAND
179#undef NOPROTO
180#endif
181
182#if defined(NOCONST)
183#define const
184#endif
185
186#ifdef __STDC__
187#undef NOPROTO
188#endif
189
190#ifdef RAND
191#define srandom(s) srand(s)
192#define random rand
193#endif
194
195#define ITERATIONS 16
196#define HALF_ITERATIONS 8
197
198/* used in des_read and des_write */
199#define MAXWRITE (1024*16)
200#define BSIZE (MAXWRITE+4)
201
202#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
203 l|=((DES_LONG)(*((c)++)))<< 8L, \
204 l|=((DES_LONG)(*((c)++)))<<16L, \
205 l|=((DES_LONG)(*((c)++)))<<24L)
206
207/* NOTE - c is not incremented as per c2l */
208#define c2ln(c,l1,l2,n) { \
209 c+=n; \
210 l1=l2=0; \
211 switch (n) { \
212 case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \
213 case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \
214 case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \
215 case 5: l2|=((DES_LONG)(*(--(c)))); \
216 case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \
217 case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \
218 case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \
219 case 1: l1|=((DES_LONG)(*(--(c)))); \
220 } \
221 }
222
223#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
224 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
225 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
226 *((c)++)=(unsigned char)(((l)>>24L)&0xff))
227
228/* replacements for htonl and ntohl since I have no idea what to do
229 * when faced with machines with 8 byte longs. */
230#define HDRSIZE 4
231
232#define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \
233 l|=((DES_LONG)(*((c)++)))<<16L, \
234 l|=((DES_LONG)(*((c)++)))<< 8L, \
235 l|=((DES_LONG)(*((c)++))))
236
237#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
238 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
239 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
240 *((c)++)=(unsigned char)(((l) )&0xff))
241
242/* NOTE - c is not incremented as per l2c */
243#define l2cn(l1,l2,c,n) { \
244 c+=n; \
245 switch (n) { \
246 case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
247 case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
248 case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
249 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
250 case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
251 case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
252 case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
253 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
254 } \
255 }
256
257#if defined(WIN32)
258#define ROTATE(a,n) (_lrotr(a,n))
259#else
260#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
261#endif
262
263/* Don't worry about the LOAD_DATA() stuff, that is used by
264 * fcrypt() to add it's little bit to the front */
265
266#ifdef DES_FCRYPT
267
268#define LOAD_DATA_tmp(R,S,u,t,E0,E1) \
269 { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); }
270
271#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
272 t=R^(R>>16L); \
273 u=t&E0; t&=E1; \
274 tmp=(u<<16); u^=R^s[S ]; u^=tmp; \
275 tmp=(t<<16); t^=R^s[S+1]; t^=tmp
276#else
277#define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g)
278#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
279 u=R^s[S ]; \
280 t=R^s[S+1]
281#endif
282
283/* The changes to this macro may help or hinder, depending on the
284 * compiler and the achitecture. gcc2 always seems to do well :-).
285 * Inspired by Dana How <how@isl.stanford.edu>
286 * DO NOT use the alternative version on machines with 8 byte longs.
287 * It does not seem to work on the Alpha, even when DES_LONG is 4
288 * bytes, probably an issue of accessing non-word aligned objects :-( */
289#ifdef DES_PTR
290
291/* It recently occured to me that 0^0^0^0^0^0^0 == 0, so there
292 * is no reason to not xor all the sub items together. This potentially
293 * saves a register since things can be xored directly into L */
294
295#if defined(DES_RISC1) || defined(DES_RISC2)
296#ifdef DES_RISC1
297#define D_ENCRYPT(LL,R,S) { \
298 unsigned int u1,u2,u3; \
299 LOAD_DATA(R,S,u,t,E0,E1,u1); \
300 u2=(int)u>>8L; \
301 u1=(int)u&0xfc; \
302 u2&=0xfc; \
303 t=ROTATE(t,4); \
304 u>>=16L; \
305 LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \
306 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \
307 u3=(int)(u>>8L); \
308 u1=(int)u&0xfc; \
309 u3&=0xfc; \
310 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+u1); \
311 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+u3); \
312 u2=(int)t>>8L; \
313 u1=(int)t&0xfc; \
314 u2&=0xfc; \
315 t>>=16L; \
316 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \
317 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \
318 u3=(int)t>>8L; \
319 u1=(int)t&0xfc; \
320 u3&=0xfc; \
321 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+u1); \
322 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+u3); }
323#endif
324#ifdef DES_RISC2
325#define D_ENCRYPT(LL,R,S) { \
326 unsigned int u1,u2,s1,s2; \
327 LOAD_DATA(R,S,u,t,E0,E1,u1); \
328 u2=(int)u>>8L; \
329 u1=(int)u&0xfc; \
330 u2&=0xfc; \
331 t=ROTATE(t,4); \
332 LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \
333 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \
334 s1=(int)(u>>16L); \
335 s2=(int)(u>>24L); \
336 s1&=0xfc; \
337 s2&=0xfc; \
338 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+s1); \
339 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+s2); \
340 u2=(int)t>>8L; \
341 u1=(int)t&0xfc; \
342 u2&=0xfc; \
343 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \
344 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \
345 s1=(int)(t>>16L); \
346 s2=(int)(t>>24L); \
347 s1&=0xfc; \
348 s2&=0xfc; \
349 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+s1); \
350 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+s2); }
351#endif
352#else
353#define D_ENCRYPT(LL,R,S) { \
354 LOAD_DATA_tmp(R,S,u,t,E0,E1); \
355 t=ROTATE(t,4); \
356 LL^= \
357 *(DES_LONG *)((unsigned char *)des_SP +((u )&0xfc))^ \
358 *(DES_LONG *)((unsigned char *)des_SP+0x200+((u>> 8L)&0xfc))^ \
359 *(DES_LONG *)((unsigned char *)des_SP+0x400+((u>>16L)&0xfc))^ \
360 *(DES_LONG *)((unsigned char *)des_SP+0x600+((u>>24L)&0xfc))^ \
361 *(DES_LONG *)((unsigned char *)des_SP+0x100+((t )&0xfc))^ \
362 *(DES_LONG *)((unsigned char *)des_SP+0x300+((t>> 8L)&0xfc))^ \
363 *(DES_LONG *)((unsigned char *)des_SP+0x500+((t>>16L)&0xfc))^ \
364 *(DES_LONG *)((unsigned char *)des_SP+0x700+((t>>24L)&0xfc)); }
365#endif
366
367#else /* original version */
368
369#if defined(DES_RISC1) || defined(DES_RISC2)
370#ifdef DES_RISC1
371#define D_ENCRYPT(LL,R,S) {\
372 unsigned int u1,u2,u3; \
373 LOAD_DATA(R,S,u,t,E0,E1,u1); \
374 u>>=2L; \
375 t=ROTATE(t,6); \
376 u2=(int)u>>8L; \
377 u1=(int)u&0x3f; \
378 u2&=0x3f; \
379 u>>=16L; \
380 LL^=des_SPtrans[0][u1]; \
381 LL^=des_SPtrans[2][u2]; \
382 u3=(int)u>>8L; \
383 u1=(int)u&0x3f; \
384 u3&=0x3f; \
385 LL^=des_SPtrans[4][u1]; \
386 LL^=des_SPtrans[6][u3]; \
387 u2=(int)t>>8L; \
388 u1=(int)t&0x3f; \
389 u2&=0x3f; \
390 t>>=16L; \
391 LL^=des_SPtrans[1][u1]; \
392 LL^=des_SPtrans[3][u2]; \
393 u3=(int)t>>8L; \
394 u1=(int)t&0x3f; \
395 u3&=0x3f; \
396 LL^=des_SPtrans[5][u1]; \
397 LL^=des_SPtrans[7][u3]; }
398#endif
399#ifdef DES_RISC2
400#define D_ENCRYPT(LL,R,S) {\
401 unsigned int u1,u2,s1,s2; \
402 LOAD_DATA(R,S,u,t,E0,E1,u1); \
403 u>>=2L; \
404 t=ROTATE(t,6); \
405 u2=(int)u>>8L; \
406 u1=(int)u&0x3f; \
407 u2&=0x3f; \
408 LL^=des_SPtrans[0][u1]; \
409 LL^=des_SPtrans[2][u2]; \
410 s1=(int)u>>16L; \
411 s2=(int)u>>24L; \
412 s1&=0x3f; \
413 s2&=0x3f; \
414 LL^=des_SPtrans[4][s1]; \
415 LL^=des_SPtrans[6][s2]; \
416 u2=(int)t>>8L; \
417 u1=(int)t&0x3f; \
418 u2&=0x3f; \
419 LL^=des_SPtrans[1][u1]; \
420 LL^=des_SPtrans[3][u2]; \
421 s1=(int)t>>16; \
422 s2=(int)t>>24L; \
423 s1&=0x3f; \
424 s2&=0x3f; \
425 LL^=des_SPtrans[5][s1]; \
426 LL^=des_SPtrans[7][s2]; }
427#endif
428
429#else
430
431#define D_ENCRYPT(LL,R,S) {\
432 LOAD_DATA_tmp(R,S,u,t,E0,E1); \
433 t=ROTATE(t,4); \
434 LL^=\
435 des_SPtrans[0][(u>> 2L)&0x3f]^ \
436 des_SPtrans[2][(u>>10L)&0x3f]^ \
437 des_SPtrans[4][(u>>18L)&0x3f]^ \
438 des_SPtrans[6][(u>>26L)&0x3f]^ \
439 des_SPtrans[1][(t>> 2L)&0x3f]^ \
440 des_SPtrans[3][(t>>10L)&0x3f]^ \
441 des_SPtrans[5][(t>>18L)&0x3f]^ \
442 des_SPtrans[7][(t>>26L)&0x3f]; }
443#endif
444#endif
445
446 /* IP and FP
447 * The problem is more of a geometric problem that random bit fiddling.
448 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6
449 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4
450 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2
451 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0
452
453 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7
454 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5
455 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3
456 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1
457
458 The output has been subject to swaps of the form
459 0 1 -> 3 1 but the odd and even bits have been put into
460 2 3 2 0
461 different words. The main trick is to remember that
462 t=((l>>size)^r)&(mask);
463 r^=t;
464 l^=(t<<size);
465 can be used to swap and move bits between words.
466
467 So l = 0 1 2 3 r = 16 17 18 19
468 4 5 6 7 20 21 22 23
469 8 9 10 11 24 25 26 27
470 12 13 14 15 28 29 30 31
471 becomes (for size == 2 and mask == 0x3333)
472 t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19
473 6^20 7^21 -- -- 4 5 20 21 6 7 22 23
474 10^24 11^25 -- -- 8 9 24 25 10 11 24 25
475 14^28 15^29 -- -- 12 13 28 29 14 15 28 29
476
477 Thanks for hints from Richard Outerbridge - he told me IP&FP
478 could be done in 15 xor, 10 shifts and 5 ands.
479 When I finally started to think of the problem in 2D
480 I first got ~42 operations without xors. When I remembered
481 how to use xors :-) I got it to its final state.
482 */
483#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
484 (b)^=(t),\
485 (a)^=((t)<<(n)))
486
487#define IP(l,r) \
488 { \
489 register DES_LONG tt; \
490 PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \
491 PERM_OP(l,r,tt,16,0x0000ffffL); \
492 PERM_OP(r,l,tt, 2,0x33333333L); \
493 PERM_OP(l,r,tt, 8,0x00ff00ffL); \
494 PERM_OP(r,l,tt, 1,0x55555555L); \
495 }
496
497#define FP(l,r) \
498 { \
499 register DES_LONG tt; \
500 PERM_OP(l,r,tt, 1,0x55555555L); \
501 PERM_OP(r,l,tt, 8,0x00ff00ffL); \
502 PERM_OP(l,r,tt, 2,0x33333333L); \
503 PERM_OP(r,l,tt,16,0x0000ffffL); \
504 PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
505 }
506
507extern const DES_LONG des_SPtrans[8][64];
508
509#ifndef NOPROTO
510void fcrypt_body(DES_LONG *out,des_key_schedule ks,
511 DES_LONG Eswap0, DES_LONG Eswap1);
512#else
513void fcrypt_body();
514#endif
515
516#endif
diff --git a/src/lib/libcrypto/des/doIP b/src/lib/libcrypto/des/doIP
new file mode 100644
index 0000000000..18cf231303
--- /dev/null
+++ b/src/lib/libcrypto/des/doIP
@@ -0,0 +1,46 @@
1#!/usr/local/bin/perl
2
3@l=(
4 0, 1, 2, 3, 4, 5, 6, 7,
5 8, 9,10,11,12,13,14,15,
6 16,17,18,19,20,21,22,23,
7 24,25,26,27,28,29,30,31
8 );
9@r=(
10 32,33,34,35,36,37,38,39,
11 40,41,42,43,44,45,46,47,
12 48,49,50,51,52,53,54,55,
13 56,57,58,59,60,61,62,63
14 );
15
16require 'shifts.pl';
17
18sub PERM_OP
19 {
20 local(*a,*b,*t,$n,$m)=@_;
21
22 @z=&shift(*a,-$n);
23 @z=&xor(*b,*z);
24 @z=&and(*z,$m);
25 @b=&xor(*b,*z);
26 @z=&shift(*z,$n);
27 @a=&xor(*a,*z);
28 }
29
30
31@L=@l;
32@R=@r;
33&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
34&PERM_OP(*L,*R,*T,16,0x0000ffff);
35&PERM_OP(*R,*L,*T,2,0x33333333);
36&PERM_OP(*L,*R,*T,8,0x00ff00ff);
37&PERM_OP(*R,*L,*T,1,0x55555555);
38 &printit(@L);
39 &printit(@R);
40&PERM_OP(*R,*L,*T,1,0x55555555);
41&PERM_OP(*L,*R,*T,8,0x00ff00ff);
42&PERM_OP(*R,*L,*T,2,0x33333333);
43&PERM_OP(*L,*R,*T,16,0x0000ffff);
44&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
45 &printit(@L);
46 &printit(@R);
diff --git a/src/lib/libcrypto/des/doPC1 b/src/lib/libcrypto/des/doPC1
new file mode 100644
index 0000000000..096afd8c46
--- /dev/null
+++ b/src/lib/libcrypto/des/doPC1
@@ -0,0 +1,110 @@
1#!/usr/local/bin/perl
2
3@l=(
4 0, 1, 2, 3, 4, 5, 6, 7,
5 8, 9,10,11,12,13,14,15,
6 16,17,18,19,20,21,22,23,
7 24,25,26,27,28,29,30,31
8 );
9@r=(
10 32,33,34,35,36,37,38,39,
11 40,41,42,43,44,45,46,47,
12 48,49,50,51,52,53,54,55,
13 56,57,58,59,60,61,62,63
14 );
15
16require 'shifts.pl';
17
18sub PERM_OP
19 {
20 local(*a,*b,*t,$n,$m)=@_;
21
22 @z=&shift(*a,-$n);
23 @z=&xor(*b,*z);
24 @z=&and(*z,$m);
25 @b=&xor(*b,*z);
26 @z=&shift(*z,$n);
27 @a=&xor(*a,*z);
28 }
29
30sub HPERM_OP2
31 {
32 local(*a,*t,$n,$m)=@_;
33 local(@x,@y,$i);
34
35 @z=&shift(*a,16-$n);
36 @z=&xor(*a,*z);
37 @z=&and(*z,$m);
38 @a=&xor(*a,*z);
39 @z=&shift(*z,$n-16);
40 @a=&xor(*a,*z);
41 }
42
43sub HPERM_OP
44 {
45 local(*a,*t,$n,$m)=@_;
46 local(@x,@y,$i);
47
48 for ($i=0; $i<16; $i++)
49 {
50 $x[$i]=$a[$i];
51 $y[$i]=$a[16+$i];
52 }
53 @z=&shift(*x,-$n);
54 @z=&xor(*y,*z);
55 @z=&and(*z,$m);
56 @y=&xor(*y,*z);
57 @z=&shift(*z,$n);
58 @x=&xor(*x,*z);
59 for ($i=0; $i<16; $i++)
60 {
61 $a[$i]=$x[$i];
62 $a[16+$i]=$y[$i];
63 }
64 }
65
66@L=@l;
67@R=@r;
68
69 print "---\n"; &printit(@R);
70&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
71 print "---\n"; &printit(@R);
72&HPERM_OP2(*L,*T,-2,0xcccc0000);
73&HPERM_OP2(*R,*T,-2,0xcccc0000);
74 print "---\n"; &printit(@R);
75&PERM_OP(*R,*L,*T,1,0x55555555);
76 print "---\n"; &printit(@R);
77&PERM_OP(*L,*R,*T,8,0x00ff00ff);
78 print "---\n"; &printit(@R);
79&PERM_OP(*R,*L,*T,1,0x55555555);
80 print "---\n"; &printit(@R);
81# &printit(@L);
82 &printit(@R);
83print <<"EOF";
84==============================
8563 55 47 39 31 23 15 7
8662 54 46 38 30 22 14 6
8761 53 45 37 29 21 13 5
8860 52 44 36 -- -- -- --
89
9057 49 41 33 25 17 9 1
9158 50 42 34 26 18 10 2
9259 51 43 35 27 19 11 3
9328 20 12 4 -- -- -- --
94EOF
95exit(1);
96@A=&and(*R,0x000000ff);
97@A=&shift(*A,16);
98@B=&and(*R,0x0000ff00);
99@C=&and(*R,0x00ff0000);
100@C=&shift(*C,-16);
101@D=&and(*L,0xf0000000);
102@D=&shift(*D,-4);
103@A=&or(*A,*B);
104@B=&or(*D,*C);
105@R=&or(*A,*B);
106@L=&and(*L,0x0fffffff);
107
108 &printit(@L);
109 &printit(@R);
110
diff --git a/src/lib/libcrypto/des/doPC2 b/src/lib/libcrypto/des/doPC2
new file mode 100644
index 0000000000..fa5cf74cf7
--- /dev/null
+++ b/src/lib/libcrypto/des/doPC2
@@ -0,0 +1,94 @@
1#!/usr/local/bin/perl
2
3@PC2_C=(14,17,11,24, 1, 5,
4 3,28,15, 6,21,10,
5 23,19,12, 4,26, 8,
6 16, 7,27,20,13, 2,
7 );
8
9@PC2_D=(41,52,31,37,47,55,
10 30,40,51,45,33,48,
11 44,49,39,56,34,53,
12 46,42,50,36,29,32,
13 );
14
15$i=0;
16foreach (@PC2_C) {
17 $_--;
18# printf "%2d,",$_;
19 $C{$_}=$i;
20 ++$i;
21# print "\n" if ((($i) % 8) == 0);
22 }
23$i=0;
24#print "\n";
25foreach (@PC2_D) {
26 $_-=28;
27 $_--;
28# printf "%2d,",$_;
29 $D{$_}=$i;
30 $i++;
31# print "\n" if ((($i) % 8) == 0);
32 }
33
34#print "\n";
35foreach $i (0 .. 27)
36 {
37 $_=$C{$i};
38# printf "%2d,",$_;
39 $i++;
40# print "\n" if ((($i) % 8) == 0);
41 }
42#print "\n";
43
44#print "\n";
45foreach $i (0 .. 27)
46 {
47 $_=$D{$i};
48# printf "%2d,",$_;
49 $i++;
50# print "\n" if ((($i) % 8) == 0);
51 }
52#print "\n";
53
54print "static ulong skb[8][64]={\n";
55&doit("C",*C, 0, 1, 2, 3, 4, 5);
56&doit("C",*C, 6, 7, 9,10,11,12);
57&doit("C",*C,13,14,15,16,18,19);
58&doit("C",*C,20,22,23,25,26,27);
59
60&doit("D",*D, 0, 1, 2, 3, 4, 5);
61&doit("D",*D, 7, 8,10,11,12,13);
62&doit("D",*D,15,16,17,18,19,20);
63&doit("D",*D,21,22,23,24,26,27);
64print "};\n";
65
66sub doit
67 {
68 local($l,*A,@b)=@_;
69 local(@out);
70
71 printf("/* for $l bits (numbered as per FIPS 46) %d %d %d %d %d %d */\n",
72 $b[0]+1, $b[1]+1, $b[2]+1, $b[3]+1, $b[4]+1, $b[5]+1);
73 for ($i=0; $i<64; $i++)
74 {
75 $out[$i]=0;
76 $j=1;
77#print "\n";
78 for ($k=0; $k<6; $k++)
79 {
80 $l=$A{$b[$k]};
81#print"$l - ";
82 if ((1<<$k) & $i)
83 {
84 $ll=int($l/6)*8+($l%6);
85 $out[$i]|=1<<($ll);
86 }
87 }
88 $pp=$out[$i];
89 $pp=($pp&0xff0000ff)| (($pp&0x00ff0000)>>8)|
90 (($pp&0x0000ff00)<<8);
91 printf("0x%08X,",$pp);
92 print "\n" if (($i+1) % 4 == 0);
93 }
94 }
diff --git a/src/lib/libcrypto/des/ede_enc.c b/src/lib/libcrypto/des/ede_enc.c
new file mode 100644
index 0000000000..9f75dd1037
--- /dev/null
+++ b/src/lib/libcrypto/des/ede_enc.c
@@ -0,0 +1,190 @@
1/* crypto/des/ede_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61void des_ede3_cbc_encrypt(input, output, length, ks1, ks2, ks3, ivec, enc)
62des_cblock (*input);
63des_cblock (*output);
64long length;
65des_key_schedule ks1;
66des_key_schedule ks2;
67des_key_schedule ks3;
68des_cblock (*ivec);
69int enc;
70 {
71 register DES_LONG tin0,tin1;
72 register DES_LONG tout0,tout1,xor0,xor1;
73 register unsigned char *in,*out;
74 register long l=length;
75 DES_LONG tin[2];
76 unsigned char *iv;
77
78 in=(unsigned char *)input;
79 out=(unsigned char *)output;
80 iv=(unsigned char *)ivec;
81
82 if (enc)
83 {
84 c2l(iv,tout0);
85 c2l(iv,tout1);
86 for (l-=8; l>=0; l-=8)
87 {
88 c2l(in,tin0);
89 c2l(in,tin1);
90 tin0^=tout0;
91 tin1^=tout1;
92
93 tin[0]=tin0;
94 tin[1]=tin1;
95 des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
96 tout0=tin[0];
97 tout1=tin[1];
98
99 l2c(tout0,out);
100 l2c(tout1,out);
101 }
102 if (l != -8)
103 {
104 c2ln(in,tin0,tin1,l+8);
105 tin0^=tout0;
106 tin1^=tout1;
107
108 tin[0]=tin0;
109 tin[1]=tin1;
110 des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
111 tout0=tin[0];
112 tout1=tin[1];
113
114 l2c(tout0,out);
115 l2c(tout1,out);
116 }
117 iv=(unsigned char *)ivec;
118 l2c(tout0,iv);
119 l2c(tout1,iv);
120 }
121 else
122 {
123 register DES_LONG t0,t1;
124
125 c2l(iv,xor0);
126 c2l(iv,xor1);
127 for (l-=8; l>=0; l-=8)
128 {
129 c2l(in,tin0);
130 c2l(in,tin1);
131
132 t0=tin0;
133 t1=tin1;
134
135 tin[0]=tin0;
136 tin[1]=tin1;
137 des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
138 tout0=tin[0];
139 tout1=tin[1];
140
141 tout0^=xor0;
142 tout1^=xor1;
143 l2c(tout0,out);
144 l2c(tout1,out);
145 xor0=t0;
146 xor1=t1;
147 }
148 if (l != -8)
149 {
150 c2l(in,tin0);
151 c2l(in,tin1);
152
153 t0=tin0;
154 t1=tin1;
155
156 tin[0]=tin0;
157 tin[1]=tin1;
158 des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
159 tout0=tin[0];
160 tout1=tin[1];
161
162 tout0^=xor0;
163 tout1^=xor1;
164 l2cn(tout0,tout1,out,l+8);
165 xor0=t0;
166 xor1=t1;
167 }
168
169 iv=(unsigned char *)ivec;
170 l2c(xor0,iv);
171 l2c(xor1,iv);
172 }
173 tin0=tin1=tout0=tout1=xor0=xor1=0;
174 tin[0]=tin[1]=0;
175 }
176
177#ifdef undef /* MACRO */
178void des_ede2_cbc_encrypt(input, output, length, ks1, ks2, ivec, enc)
179des_cblock (*input);
180des_cblock (*output);
181long length;
182des_key_schedule ks1;
183des_key_schedule ks2;
184des_cblock (*ivec);
185int enc;
186 {
187 des_ede3_cbc_encrypt(input,output,length,ks1,ks2,ks1,ivec,enc);
188 }
189#endif
190
diff --git a/src/lib/libcrypto/des/podd.h b/src/lib/libcrypto/des/podd.h
new file mode 100644
index 0000000000..1b2bfe0843
--- /dev/null
+++ b/src/lib/libcrypto/des/podd.h
@@ -0,0 +1,75 @@
1/* crypto/des/podd.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59static const unsigned char odd_parity[256]={
60 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
61 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31,
62 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47,
63 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62,
64 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79,
65 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94,
66 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110,
67112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127,
68128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143,
69145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158,
70161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174,
71176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191,
72193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206,
73208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223,
74224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239,
75241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254};
diff --git a/src/lib/libcrypto/des/ranlib.sh b/src/lib/libcrypto/des/ranlib.sh
new file mode 100644
index 0000000000..543f712c6b
--- /dev/null
+++ b/src/lib/libcrypto/des/ranlib.sh
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3cwd=`pwd`
4cd /tmp
5
6if [ -s /bin/ranlib ] ; then
7 RL=/bin/ranlib
8else if [ -s /usr/bin/ranlib ] ; then
9 RL=/usr/bin/ranlib
10fi
11fi
12
13if [ "x$RL" != "x" ]
14then
15 case "$1" in
16 /*)
17 $RL "$1"
18 ;;
19 *)
20 $RL "$cwd/$1"
21 ;;
22 esac
23fi
diff --git a/src/lib/libcrypto/des/shifts.pl b/src/lib/libcrypto/des/shifts.pl
new file mode 100644
index 0000000000..d8a240c1ba
--- /dev/null
+++ b/src/lib/libcrypto/des/shifts.pl
@@ -0,0 +1,198 @@
1#!/usr/bin/perl
2
3sub lab_shift
4 {
5 local(*a,$n)=@_;
6 local(@r,$i,$j,$k,$d,@z);
7
8 @r=&shift(*a,$n);
9 foreach $i (0 .. 31)
10 {
11 @z=split(/\^/,$r[$i]);
12 for ($j=0; $j <= $#z; $j++)
13 {
14 ($d)=($z[$j] =~ /^(..)/);
15 ($k)=($z[$j] =~ /\[(.*)\]$/);
16 $k.=",$n" if ($k ne "");
17 $k="$n" if ($k eq "");
18 $d="$d[$k]";
19 $z[$j]=$d;
20 }
21 $r[$i]=join('^',@z);
22 }
23 return(@r);
24 }
25
26sub shift
27 {
28 local(*a,$n)=@_;
29 local(@f);
30
31 if ($n > 0)
32 {
33 @f=&shiftl(*a,$n);
34 }
35 else
36 {
37 @f=&shiftr(*a,-$n);
38 }
39 return(@f);
40 }
41
42sub rotate
43 {
44 local(*a,$n)=@_;
45 local(@f);
46
47 if ($n > 0)
48 { @f=&rotatel(*a,$n); }
49 else
50 { @f=&rotater(*a,-$n); }
51 return(@f);
52 }
53
54sub rotater
55 {
56 local(*a,$n)=@_;
57 local(@f,@g);
58
59 @f=&shiftr(*a,$n);
60 @g=&shiftl(*a,32-$n);
61 $#f=31;
62 $#g=31;
63 return(&or(*f,*g));
64 }
65
66sub rotatel
67 {
68 local(*a,$n)=@_;
69 local(@f,@g);
70
71 @f=&shiftl(*a,$n);
72 @g=&shiftr(*a,32-$n);
73 $#f=31;
74 $#g=31;
75 return(&or(*f,*g));
76 }
77
78sub shiftr
79 {
80 local(*a,$n)=@_;
81 local(@r,$i);
82
83 $#r=31;
84 foreach $i (0 .. 31)
85 {
86 if (($i+$n) > 31)
87 {
88 $r[$i]="--";
89 }
90 else
91 {
92 $r[$i]=$a[$i+$n];
93 }
94 }
95 return(@r);
96 }
97
98sub shiftl
99 {
100 local(*a,$n)=@_;
101 local(@r,$i);
102
103 $#r=31;
104 foreach $i (0 .. 31)
105 {
106 if ($i < $n)
107 {
108 $r[$i]="--";
109 }
110 else
111 {
112 $r[$i]=$a[$i-$n];
113 }
114 }
115 return(@r);
116 }
117
118sub printit
119 {
120 local(@a)=@_;
121 local($i);
122
123 foreach $i (0 .. 31)
124 {
125 printf "%2s ",$a[$i];
126 print "\n" if (($i%8) == 7);
127 }
128 print "\n";
129 }
130
131sub xor
132 {
133 local(*a,*b)=@_;
134 local(@r,$i);
135
136 $#r=31;
137 foreach $i (0 .. 31)
138 {
139 $r[$i]=&compress($a[$i].'^'.$b[$i]);
140# $r[$i]=$a[$i]."^".$b[$i];
141 }
142 return(@r);
143 }
144
145sub and
146 {
147 local(*a,$m)=@_;
148 local(@r,$i);
149
150 $#r=31;
151 foreach $i (0 .. 31)
152 {
153 $r[$i]=(($m & (1<<$i))?($a[$i]):('--'));
154 }
155 return(@r);
156 }
157
158sub or
159 {
160 local(*a,*b)=@_;
161 local(@r,$i);
162
163 $#r=31;
164 foreach $i (0 .. 31)
165 {
166 $r[$i]='--' if (($a[$i] eq '--') && ($b[$i] eq '--'));
167 $r[$i]=$a[$i] if (($a[$i] ne '--') && ($b[$i] eq '--'));
168 $r[$i]=$b[$i] if (($a[$i] eq '--') && ($b[$i] ne '--'));
169 $r[$i]='++' if (($a[$i] ne '--') && ($b[$i] ne '--'));
170 }
171 return(@r);
172 }
173
174sub compress
175 {
176 local($s)=@_;
177 local($_,$i,@a,%a,$r);
178
179 $s =~ s/\^\^/\^/g;
180 $s =~ s/^\^//;
181 $s =~ s/\^$//;
182 @a=split(/\^/,$s);
183
184 while ($#a >= 0)
185 {
186 $_=shift(@a);
187 next unless /\d/;
188 $a{$_}++;
189 }
190 foreach $i (sort keys %a)
191 {
192 next if ($a{$i}%2 == 0);
193 $r.="$i^";
194 }
195 chop($r);
196 return($r);
197 }
1981;
diff --git a/src/lib/libcrypto/des/sk.h b/src/lib/libcrypto/des/sk.h
new file mode 100644
index 0000000000..f2ade88c7c
--- /dev/null
+++ b/src/lib/libcrypto/des/sk.h
@@ -0,0 +1,204 @@
1/* crypto/des/sk.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59static const DES_LONG des_skb[8][64]={
60{
61/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
620x00000000L,0x00000010L,0x20000000L,0x20000010L,
630x00010000L,0x00010010L,0x20010000L,0x20010010L,
640x00000800L,0x00000810L,0x20000800L,0x20000810L,
650x00010800L,0x00010810L,0x20010800L,0x20010810L,
660x00000020L,0x00000030L,0x20000020L,0x20000030L,
670x00010020L,0x00010030L,0x20010020L,0x20010030L,
680x00000820L,0x00000830L,0x20000820L,0x20000830L,
690x00010820L,0x00010830L,0x20010820L,0x20010830L,
700x00080000L,0x00080010L,0x20080000L,0x20080010L,
710x00090000L,0x00090010L,0x20090000L,0x20090010L,
720x00080800L,0x00080810L,0x20080800L,0x20080810L,
730x00090800L,0x00090810L,0x20090800L,0x20090810L,
740x00080020L,0x00080030L,0x20080020L,0x20080030L,
750x00090020L,0x00090030L,0x20090020L,0x20090030L,
760x00080820L,0x00080830L,0x20080820L,0x20080830L,
770x00090820L,0x00090830L,0x20090820L,0x20090830L,
78},{
79/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
800x00000000L,0x02000000L,0x00002000L,0x02002000L,
810x00200000L,0x02200000L,0x00202000L,0x02202000L,
820x00000004L,0x02000004L,0x00002004L,0x02002004L,
830x00200004L,0x02200004L,0x00202004L,0x02202004L,
840x00000400L,0x02000400L,0x00002400L,0x02002400L,
850x00200400L,0x02200400L,0x00202400L,0x02202400L,
860x00000404L,0x02000404L,0x00002404L,0x02002404L,
870x00200404L,0x02200404L,0x00202404L,0x02202404L,
880x10000000L,0x12000000L,0x10002000L,0x12002000L,
890x10200000L,0x12200000L,0x10202000L,0x12202000L,
900x10000004L,0x12000004L,0x10002004L,0x12002004L,
910x10200004L,0x12200004L,0x10202004L,0x12202004L,
920x10000400L,0x12000400L,0x10002400L,0x12002400L,
930x10200400L,0x12200400L,0x10202400L,0x12202400L,
940x10000404L,0x12000404L,0x10002404L,0x12002404L,
950x10200404L,0x12200404L,0x10202404L,0x12202404L,
96},{
97/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
980x00000000L,0x00000001L,0x00040000L,0x00040001L,
990x01000000L,0x01000001L,0x01040000L,0x01040001L,
1000x00000002L,0x00000003L,0x00040002L,0x00040003L,
1010x01000002L,0x01000003L,0x01040002L,0x01040003L,
1020x00000200L,0x00000201L,0x00040200L,0x00040201L,
1030x01000200L,0x01000201L,0x01040200L,0x01040201L,
1040x00000202L,0x00000203L,0x00040202L,0x00040203L,
1050x01000202L,0x01000203L,0x01040202L,0x01040203L,
1060x08000000L,0x08000001L,0x08040000L,0x08040001L,
1070x09000000L,0x09000001L,0x09040000L,0x09040001L,
1080x08000002L,0x08000003L,0x08040002L,0x08040003L,
1090x09000002L,0x09000003L,0x09040002L,0x09040003L,
1100x08000200L,0x08000201L,0x08040200L,0x08040201L,
1110x09000200L,0x09000201L,0x09040200L,0x09040201L,
1120x08000202L,0x08000203L,0x08040202L,0x08040203L,
1130x09000202L,0x09000203L,0x09040202L,0x09040203L,
114},{
115/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
1160x00000000L,0x00100000L,0x00000100L,0x00100100L,
1170x00000008L,0x00100008L,0x00000108L,0x00100108L,
1180x00001000L,0x00101000L,0x00001100L,0x00101100L,
1190x00001008L,0x00101008L,0x00001108L,0x00101108L,
1200x04000000L,0x04100000L,0x04000100L,0x04100100L,
1210x04000008L,0x04100008L,0x04000108L,0x04100108L,
1220x04001000L,0x04101000L,0x04001100L,0x04101100L,
1230x04001008L,0x04101008L,0x04001108L,0x04101108L,
1240x00020000L,0x00120000L,0x00020100L,0x00120100L,
1250x00020008L,0x00120008L,0x00020108L,0x00120108L,
1260x00021000L,0x00121000L,0x00021100L,0x00121100L,
1270x00021008L,0x00121008L,0x00021108L,0x00121108L,
1280x04020000L,0x04120000L,0x04020100L,0x04120100L,
1290x04020008L,0x04120008L,0x04020108L,0x04120108L,
1300x04021000L,0x04121000L,0x04021100L,0x04121100L,
1310x04021008L,0x04121008L,0x04021108L,0x04121108L,
132},{
133/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
1340x00000000L,0x10000000L,0x00010000L,0x10010000L,
1350x00000004L,0x10000004L,0x00010004L,0x10010004L,
1360x20000000L,0x30000000L,0x20010000L,0x30010000L,
1370x20000004L,0x30000004L,0x20010004L,0x30010004L,
1380x00100000L,0x10100000L,0x00110000L,0x10110000L,
1390x00100004L,0x10100004L,0x00110004L,0x10110004L,
1400x20100000L,0x30100000L,0x20110000L,0x30110000L,
1410x20100004L,0x30100004L,0x20110004L,0x30110004L,
1420x00001000L,0x10001000L,0x00011000L,0x10011000L,
1430x00001004L,0x10001004L,0x00011004L,0x10011004L,
1440x20001000L,0x30001000L,0x20011000L,0x30011000L,
1450x20001004L,0x30001004L,0x20011004L,0x30011004L,
1460x00101000L,0x10101000L,0x00111000L,0x10111000L,
1470x00101004L,0x10101004L,0x00111004L,0x10111004L,
1480x20101000L,0x30101000L,0x20111000L,0x30111000L,
1490x20101004L,0x30101004L,0x20111004L,0x30111004L,
150},{
151/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
1520x00000000L,0x08000000L,0x00000008L,0x08000008L,
1530x00000400L,0x08000400L,0x00000408L,0x08000408L,
1540x00020000L,0x08020000L,0x00020008L,0x08020008L,
1550x00020400L,0x08020400L,0x00020408L,0x08020408L,
1560x00000001L,0x08000001L,0x00000009L,0x08000009L,
1570x00000401L,0x08000401L,0x00000409L,0x08000409L,
1580x00020001L,0x08020001L,0x00020009L,0x08020009L,
1590x00020401L,0x08020401L,0x00020409L,0x08020409L,
1600x02000000L,0x0A000000L,0x02000008L,0x0A000008L,
1610x02000400L,0x0A000400L,0x02000408L,0x0A000408L,
1620x02020000L,0x0A020000L,0x02020008L,0x0A020008L,
1630x02020400L,0x0A020400L,0x02020408L,0x0A020408L,
1640x02000001L,0x0A000001L,0x02000009L,0x0A000009L,
1650x02000401L,0x0A000401L,0x02000409L,0x0A000409L,
1660x02020001L,0x0A020001L,0x02020009L,0x0A020009L,
1670x02020401L,0x0A020401L,0x02020409L,0x0A020409L,
168},{
169/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
1700x00000000L,0x00000100L,0x00080000L,0x00080100L,
1710x01000000L,0x01000100L,0x01080000L,0x01080100L,
1720x00000010L,0x00000110L,0x00080010L,0x00080110L,
1730x01000010L,0x01000110L,0x01080010L,0x01080110L,
1740x00200000L,0x00200100L,0x00280000L,0x00280100L,
1750x01200000L,0x01200100L,0x01280000L,0x01280100L,
1760x00200010L,0x00200110L,0x00280010L,0x00280110L,
1770x01200010L,0x01200110L,0x01280010L,0x01280110L,
1780x00000200L,0x00000300L,0x00080200L,0x00080300L,
1790x01000200L,0x01000300L,0x01080200L,0x01080300L,
1800x00000210L,0x00000310L,0x00080210L,0x00080310L,
1810x01000210L,0x01000310L,0x01080210L,0x01080310L,
1820x00200200L,0x00200300L,0x00280200L,0x00280300L,
1830x01200200L,0x01200300L,0x01280200L,0x01280300L,
1840x00200210L,0x00200310L,0x00280210L,0x00280310L,
1850x01200210L,0x01200310L,0x01280210L,0x01280310L,
186},{
187/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
1880x00000000L,0x04000000L,0x00040000L,0x04040000L,
1890x00000002L,0x04000002L,0x00040002L,0x04040002L,
1900x00002000L,0x04002000L,0x00042000L,0x04042000L,
1910x00002002L,0x04002002L,0x00042002L,0x04042002L,
1920x00000020L,0x04000020L,0x00040020L,0x04040020L,
1930x00000022L,0x04000022L,0x00040022L,0x04040022L,
1940x00002020L,0x04002020L,0x00042020L,0x04042020L,
1950x00002022L,0x04002022L,0x00042022L,0x04042022L,
1960x00000800L,0x04000800L,0x00040800L,0x04040800L,
1970x00000802L,0x04000802L,0x00040802L,0x04040802L,
1980x00002800L,0x04002800L,0x00042800L,0x04042800L,
1990x00002802L,0x04002802L,0x00042802L,0x04042802L,
2000x00000820L,0x04000820L,0x00040820L,0x04040820L,
2010x00000822L,0x04000822L,0x00040822L,0x04040822L,
2020x00002820L,0x04002820L,0x00042820L,0x04042820L,
2030x00002822L,0x04002822L,0x00042822L,0x04042822L,
204}};
diff --git a/src/lib/libcrypto/des/supp.c b/src/lib/libcrypto/des/supp.c
new file mode 100644
index 0000000000..f8e5833f69
--- /dev/null
+++ b/src/lib/libcrypto/des/supp.c
@@ -0,0 +1,109 @@
1/* crypto/des/supp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/*
60 * Copyright (c) 1995
61 * Mark Murray. All rights reserved.
62 *
63 * Redistribution and use in source and binary forms, with or without
64 * modification, are permitted provided that the following conditions
65 * are met:
66 * 1. Redistributions of source code must retain the above copyright
67 * notice, this list of conditions and the following disclaimer.
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in the
70 * documentation and/or other materials provided with the distribution.
71 * 3. All advertising materials mentioning features or use of this software
72 * must display the following acknowledgement:
73 * This product includes software developed by Mark Murray
74 * 4. Neither the name of the author nor the names of any co-contributors
75 * may be used to endorse or promote products derived from this software
76 * without specific prior written permission.
77 *
78 * THIS SOFTWARE IS PROVIDED BY MARK MURRAY AND CONTRIBUTORS ``AS IS'' AND
79 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
80 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
81 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
82 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
83 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
84 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
85 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
86 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88 * SUCH DAMAGE.
89 *
90 * $Id: supp.c,v 1.1.1.1 1998/10/05 20:12:45 ryker Exp $
91 */
92
93#include <stdio.h>
94#include "des_locl.h"
95
96void des_cblock_print_file(cb, fp)
97 des_cblock *cb;
98 FILE *fp;
99{
100 int i;
101 unsigned int *p = (unsigned int *)cb;
102
103 fprintf(fp, " 0x { ");
104 for (i = 0; i < 8; i++) {
105 fprintf(fp, "%x", p[i]);
106 if (i != 7) fprintf(fp, ", ");
107 }
108 fprintf(fp, " }");
109}
diff --git a/src/lib/libcrypto/des/testdes.pl b/src/lib/libcrypto/des/testdes.pl
new file mode 100644
index 0000000000..67fbd47f36
--- /dev/null
+++ b/src/lib/libcrypto/des/testdes.pl
@@ -0,0 +1,167 @@
1#!/usr/bin/perl
2
3# des.pl tesing code
4
5require 'des.pl';
6
7$num_tests=34;
8@key_data=(
9 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
10 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
11 0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
12 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
13 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
14 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
15 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
16 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10,
17 0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57,
18 0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E,
19 0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86,
20 0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E,
21 0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6,
22 0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE,
23 0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6,
24 0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE,
25 0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16,
26 0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F,
27 0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46,
28 0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E,
29 0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76,
30 0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07,
31 0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F,
32 0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7,
33 0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF,
34 0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6,
35 0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF,
36 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
37 0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E,
38 0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE,
39 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
40 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
41 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
42 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10,
43 );
44
45@plain_data=(
46 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
47 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
48 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
49 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
50 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
51 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
52 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
53 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
54 0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42,
55 0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA,
56 0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72,
57 0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A,
58 0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2,
59 0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A,
60 0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2,
61 0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A,
62 0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02,
63 0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A,
64 0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32,
65 0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA,
66 0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62,
67 0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2,
68 0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA,
69 0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92,
70 0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A,
71 0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2,
72 0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A,
73 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
74 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
75 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
76 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
78 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
79 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF);
80
81@cipher_data=(
82 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7,
83 0x73,0x59,0xB2,0x16,0x3E,0x4E,0xDC,0x58,
84 0x95,0x8E,0x6E,0x62,0x7A,0x05,0x55,0x7B,
85 0xF4,0x03,0x79,0xAB,0x9E,0x0E,0xC5,0x33,
86 0x17,0x66,0x8D,0xFC,0x72,0x92,0x53,0x2D,
87 0x8A,0x5A,0xE1,0xF8,0x1A,0xB8,0xF2,0xDD,
88 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7,
89 0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4,
90 0x69,0x0F,0x5B,0x0D,0x9A,0x26,0x93,0x9B,
91 0x7A,0x38,0x9D,0x10,0x35,0x4B,0xD2,0x71,
92 0x86,0x8E,0xBB,0x51,0xCA,0xB4,0x59,0x9A,
93 0x71,0x78,0x87,0x6E,0x01,0xF1,0x9B,0x2A,
94 0xAF,0x37,0xFB,0x42,0x1F,0x8C,0x40,0x95,
95 0x86,0xA5,0x60,0xF1,0x0E,0xC6,0xD8,0x5B,
96 0x0C,0xD3,0xDA,0x02,0x00,0x21,0xDC,0x09,
97 0xEA,0x67,0x6B,0x2C,0xB7,0xDB,0x2B,0x7A,
98 0xDF,0xD6,0x4A,0x81,0x5C,0xAF,0x1A,0x0F,
99 0x5C,0x51,0x3C,0x9C,0x48,0x86,0xC0,0x88,
100 0x0A,0x2A,0xEE,0xAE,0x3F,0xF4,0xAB,0x77,
101 0xEF,0x1B,0xF0,0x3E,0x5D,0xFA,0x57,0x5A,
102 0x88,0xBF,0x0D,0xB6,0xD7,0x0D,0xEE,0x56,
103 0xA1,0xF9,0x91,0x55,0x41,0x02,0x0B,0x56,
104 0x6F,0xBF,0x1C,0xAF,0xCF,0xFD,0x05,0x56,
105 0x2F,0x22,0xE4,0x9B,0xAB,0x7C,0xA1,0xAC,
106 0x5A,0x6B,0x61,0x2C,0xC2,0x6C,0xCE,0x4A,
107 0x5F,0x4C,0x03,0x8E,0xD1,0x2B,0x2E,0x41,
108 0x63,0xFA,0xC0,0xD0,0x34,0xD9,0xF7,0x93,
109 0x61,0x7B,0x3A,0x0C,0xE8,0xF0,0x71,0x00,
110 0xDB,0x95,0x86,0x05,0xF8,0xC8,0xC6,0x06,
111 0xED,0xBF,0xD1,0xC6,0x6C,0x29,0xCC,0xC7,
112 0x35,0x55,0x50,0xB2,0x15,0x0E,0x24,0x51,
113 0xCA,0xAA,0xAF,0x4D,0xEA,0xF1,0xDB,0xAE,
114 0xD5,0xD4,0x4F,0xF7,0x20,0x68,0x3D,0x0D,
115 0x2A,0x2B,0xB0,0x08,0xDF,0x97,0xC2,0xF2);
116
117print "Doing ecb tests\n";
118for ($i=0; $i<$num_tests; $i++)
119 {
120 printf "Doing test $i\n";
121 $key =pack("C8",splice(@key_data ,0,8));
122 $data=pack("C8",splice(@plain_data ,0,8));
123 $res =pack("C8",splice(@cipher_data,0,8));
124
125 @ks= &des_set_key($key);
126 $out1= &des_ecb_encrypt(*ks,1,$data);
127 $out2= &des_ecb_encrypt(*ks,0,$out1);
128 $out3= &des_ecb_encrypt(*ks,0,$res);
129 &eprint("encryption failure",$res,$out1)
130 if ($out1 ne $res);
131 &eprint("encryption/decryption failure",$data,$out2)
132 if ($out2 ne $data);
133 &eprint("decryption failure",$data,$out3)
134 if ($data ne $out3);
135 }
136print "Done\n";
137
138print "doing speed test over 30 seconds\n";
139$SIG{'ALRM'}='done';
140sub done {$done=1;}
141$done=0;
142
143$count=0;
144$d=pack("C8",0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef);
145@ks= &des_set_key($d);
146alarm(30);
147$start=(times)[0];
148while (!$done)
149 {
150 $count++;
151 $d=&des_ecb_encrypt(*ks,1,$d);
152 }
153$end=(times)[0];
154$t=$end-$start;
155printf "$count DESs in %.2f seconds is %.2f DESs/sec or %.2f bytes/sec\n",
156 1.0*$t,1.0*$count/$t,$count*8.0/$t;
157
158sub eprint
159 {
160 local($s,$c,$e)=@_;
161 local(@k);
162
163 @k=unpack("C8",$c);
164 printf "%02x%02x%02x%02x %02x%02x%02x%02x - ",unpack("C8",$c);
165 printf "%02x%02x%02x%02x %02x%02x%02x%02x :",unpack("C8",$e);
166 print " $s\n";
167 }
diff --git a/src/lib/libcrypto/des/vms.com b/src/lib/libcrypto/des/vms.com
new file mode 100644
index 0000000000..62ca1fbda4
--- /dev/null
+++ b/src/lib/libcrypto/des/vms.com
@@ -0,0 +1,90 @@
1$! --- VMS.com ---
2$!
3$ GoSub defines
4$ GoSub linker_options
5$ If (P1 .nes. "")
6$ Then
7$ GoSub 'P1'
8$ Else
9$ GoSub lib
10$ GoSub destest
11$ GoSub rpw
12$ GoSub speed
13$ GoSub des
14$ EndIF
15$!
16$ Exit
17$!
18$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
19$!
20$DEFINES:
21$ OPT_FILE := "VAX_LINKER_OPTIONS.OPT"
22$!
23$ CC_OPTS := "/NODebug/OPTimize/NOWarn"
24$!
25$ LINK_OPTS := "/NODebug/NOTraceback/Contiguous"
26$!
27$ OBJS = "cbc_cksm.obj,cbc_enc.obj,ecb_enc.obj,pcbc_enc.obj," + -
28 "qud_cksm.obj,rand_key.obj,read_pwd.obj,set_key.obj," + -
29 "str2key.obj,enc_read.obj,enc_writ.obj,fcrypt.obj," + -
30 "cfb_enc.obj,ecb3_enc.obj,ofb_enc.obj"
31
32
33$!
34$ LIBDES = "cbc_cksm.c,cbc_enc.c,ecb_enc.c,enc_read.c," + -
35 "enc_writ.c,pcbc_enc.c,qud_cksm.c,rand_key.c," + -
36 "read_pwd.c,set_key.c,str2key.c,fcrypt.c," + -
37 "cfb_enc.c,ecb3_enc.c,ofb_enc.c"
38$ Return
39$!
40$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41$!
42$LINKER_OPTIONS:
43$ If (f$search(OPT_FILE) .eqs. "")
44$ Then
45$ Create 'OPT_FILE'
46$DECK
47! Default system options file to link against the sharable C runtime library
48!
49Sys$Share:VAXcRTL.exe/Share
50$EOD
51$ EndIF
52$ Return
53$!
54$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
55$!
56$LIB:
57$ CC 'CC_OPTS' 'LIBDES'
58$ If (f$search("LIBDES.OLB") .nes. "")
59$ Then Library /Object /Replace libdes 'OBJS'
60$ Else Library /Create /Object libdes 'OBJS'
61$ EndIF
62$ Return
63$!
64$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
65$!
66$DESTEST:
67$ CC 'CC_OPTS' destest
68$ Link 'link_opts' /Exec=destest destest.obj,libdes/LIBRARY,'opt_file'/Option
69$ Return
70$!
71$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
72$!
73$RPW:
74$ CC 'CC_OPTS' rpw
75$ Link 'link_opts' /Exec=rpw rpw.obj,libdes/LIBRARY,'opt_file'/Option
76$ Return
77$!
78$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
79$!
80$SPEED:
81$ CC 'CC_OPTS' speed
82$ Link 'link_opts' /Exec=speed speed.obj,libdes/LIBRARY,'opt_file'/Option
83$ Return
84$!
85$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86$!
87$DES:
88$ CC 'CC_OPTS' des
89$ Link 'link_opts' /Exec=des des.obj,libdes/LIBRARY,'opt_file'/Option
90$ Return
diff --git a/src/lib/libcrypto/dh/Makefile.ssl b/src/lib/libcrypto/dh/Makefile.ssl
new file mode 100644
index 0000000000..dfa7e4525d
--- /dev/null
+++ b/src/lib/libcrypto/dh/Makefile.ssl
@@ -0,0 +1,84 @@
1#
2# SSLeay/crypto/dh/Makefile
3#
4
5DIR= dh
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=dh
19ERRC=dh_err
20GENERAL=Makefile
21TEST= dhtest.c
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= dh_gen.c dh_key.c dh_lib.c dh_check.c $(ERRC).c
26LIBOBJ= dh_gen.o dh_key.o dh_lib.o dh_check.o $(ERRC).o
27
28SRC= $(LIBSRC)
29
30EXHEADER= dh.h
31HEADER= $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: lib
39
40lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/util/ranlib.sh $(LIB)
43 @touch lib
44
45files:
46 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
47
48links:
49 /bin/rm -f Makefile
50 $(TOP)/util/point.sh Makefile.ssl Makefile ;
51 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
52 $(TOP)/util/mklink.sh ../../test $(TEST)
53 $(TOP)/util/mklink.sh ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALLTOP)/include/$$i; \
59 chmod 644 $(INSTALLTOP)/include/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
72
73dclean:
74 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80errors:
81 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
82 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
83
84# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/dh/dh.err b/src/lib/libcrypto/dh/dh.err
new file mode 100644
index 0000000000..a4fe746985
--- /dev/null
+++ b/src/lib/libcrypto/dh/dh.err
@@ -0,0 +1,12 @@
1/* Error codes for the DH functions. */
2
3/* Function codes. */
4#define DH_F_DHPARAMS_PRINT 100
5#define DH_F_DHPARAMS_PRINT_FP 101
6#define DH_F_DH_COMPUTE_KEY 102
7#define DH_F_DH_GENERATE_KEY 103
8#define DH_F_DH_GENERATE_PARAMETERS 104
9#define DH_F_DH_NEW 105
10
11/* Reason codes. */
12#define DH_R_NO_PRIVATE_VALUE 100
diff --git a/src/lib/libcrypto/dsa/Makefile.ssl b/src/lib/libcrypto/dsa/Makefile.ssl
new file mode 100644
index 0000000000..2cc4ddb39e
--- /dev/null
+++ b/src/lib/libcrypto/dsa/Makefile.ssl
@@ -0,0 +1,84 @@
1#
2# SSLeay/crypto/dsa/Makefile
3#
4
5DIR= dsa
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=dsa
19ERRC=dsa_err
20GENERAL=Makefile
21TEST=dsatest.c
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c $(ERRC).c
26LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_vrf.o dsa_sign.o $(ERRC).o
27
28SRC= $(LIBSRC)
29
30EXHEADER= dsa.h
31HEADER= $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: lib
39
40lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/util/ranlib.sh $(LIB)
43 @touch lib
44
45files:
46 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
47
48links:
49 /bin/rm -f Makefile
50 $(TOP)/util/point.sh Makefile.ssl Makefile ;
51 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
52 $(TOP)/util/mklink.sh ../../test $(TEST)
53 $(TOP)/util/mklink.sh ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALLTOP)/include/$$i; \
59 chmod 644 $(INSTALLTOP)/include/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
72
73dclean:
74 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80errors:
81 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
82 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
83
84# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/dsa/dsa.err b/src/lib/libcrypto/dsa/dsa.err
new file mode 100644
index 0000000000..1131e9fa74
--- /dev/null
+++ b/src/lib/libcrypto/dsa/dsa.err
@@ -0,0 +1,15 @@
1/* Error codes for the DSA functions. */
2
3/* Function codes. */
4#define DSA_F_DSAPARAMS_PRINT 100
5#define DSA_F_DSAPARAMS_PRINT_FP 101
6#define DSA_F_DSA_IS_PRIME 102
7#define DSA_F_DSA_NEW 103
8#define DSA_F_DSA_PRINT 104
9#define DSA_F_DSA_PRINT_FP 105
10#define DSA_F_DSA_SIGN 106
11#define DSA_F_DSA_SIGN_SETUP 107
12#define DSA_F_DSA_VERIFY 108
13
14/* Reason codes. */
15#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
diff --git a/src/lib/libcrypto/err/Makefile.ssl b/src/lib/libcrypto/err/Makefile.ssl
new file mode 100644
index 0000000000..57c87eb041
--- /dev/null
+++ b/src/lib/libcrypto/err/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/err/Makefile
3#
4
5DIR= err
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=err.c err_all.c err_prn.c
24LIBOBJ=err.o err_all.o err_prn.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= err.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/err/err_code.pl b/src/lib/libcrypto/err/err_code.pl
new file mode 100644
index 0000000000..ebc8eef913
--- /dev/null
+++ b/src/lib/libcrypto/err/err_code.pl
@@ -0,0 +1,105 @@
1#!/usr/bin/perl
2
3while (@ARGV)
4 {
5 $in=shift(@ARGV);
6 if ($in =~ /^-conf$/)
7 {
8 $in=shift(@ARGV);
9 open(IN,"<$in") || die "unable to open '$in'\n";
10 while (<IN>)
11 {
12 s/#.*$//;
13 s/\s+$//;
14 next if (/^$/);
15 if (/^L\s+(\S+)\s+(\S+)$/)
16 { $errfile{$1}=$2; }
17 elsif (/^F\s+(\S+)$/)
18 { $function{$1}=1; }
19 elsif (/^R\s+(\S+)\s+(\S+)$/)
20 { $r_value{$1}=$2; }
21 else { die "bad input line: $in:$.\n"; }
22 }
23 close(IN);
24 next;
25 }
26
27 open(IN,"<$in") || die "unable to open '$in'\n";
28 $last="";
29 while (<IN>)
30 {
31 if (/err\(([A-Z0-9]+_F_[0-9A-Z_]+)\s*,\s*([0-9A-Z]+_R_[0-9A-Z_]+)\s*\)/)
32 {
33 if ($1 != $last)
34 {
35 if ($function{$1} == 0)
36 {
37 printf STDERR "$. $1 is bad\n";
38 }
39 }
40 $function{$1}++;
41 $last=$1;
42 $reason{$2}++;
43 }
44 }
45 close(IN);
46 }
47
48foreach (keys %function,keys %reason)
49 {
50 /^([A-Z0-9]+)_/;
51 $prefix{$1}++;
52 }
53
54@F=sort keys %function;
55@R=sort keys %reason;
56foreach $j (sort keys %prefix)
57 {
58 next if $errfile{$j} eq "NONE";
59 printf STDERR "doing %-6s - ",$j;
60 if (defined($errfile{$j}))
61 {
62 open(OUT,">$errfile{$j}") ||
63 die "unable to open '$errfile{$j}':$!\n";
64 $close_file=1;
65 }
66 else
67 {
68 *OUT=*STDOUT;
69 $close=0;
70 }
71 @f=grep(/^${j}_/,@F);
72 @r=grep(/^${j}_/,@R);
73 $num=100;
74 print OUT "/* Error codes for the $j functions. */\n\n";
75 print OUT "/* Function codes. */\n";
76 $f_count=0;
77 foreach $i (@f)
78 {
79 $z=6-int(length($i)/8);
80 printf OUT "#define $i%s $num\n","\t" x $z;
81 $num++;
82 $f_count++;
83 }
84 $num=100;
85 print OUT "\n/* Reason codes. */\n";
86 $r_count=0;
87 foreach $i (@r)
88 {
89 $z=6-int(length($i)/8);
90 if (defined($r_value{$i}))
91 {
92 printf OUT "#define $i%s $r_value{$i}\n","\t" x $z;
93 }
94 else
95 {
96 printf OUT "#define $i%s $num\n","\t" x $z;
97 $num++;
98 }
99 $r_count++;
100 }
101 close(OUT) if $close_file;
102
103 printf STDERR "%3d functions, %3d reasons\n",$f_count,$r_count;
104 }
105
diff --git a/src/lib/libcrypto/err/err_genc.pl b/src/lib/libcrypto/err/err_genc.pl
new file mode 100644
index 0000000000..a8e36c2f0c
--- /dev/null
+++ b/src/lib/libcrypto/err/err_genc.pl
@@ -0,0 +1,198 @@
1#!/usr/bin/perl
2
3if ($ARGV[0] eq "-s") { $static=1; shift @ARGV; }
4
5($#ARGV == 1) || die "usage: $0 [-s] <header file> <output C file>\n";
6open(IN,"<$ARGV[0]") || die "unable to open $ARGV[0]:$!\n";
7open(STDOUT,">$ARGV[1]") || die "unable to open $ARGV[1]:$!\n";
8
9$Func=0;
10$Reas=0;
11$fuction{'FOPEN'}='fopen';
12while (<IN>)
13 {
14 if (/(\S+)\s*\(\);/)
15 {
16 $t=$1;
17 $t =~ s/\*//;
18 ($upper=$t) =~ tr/a-z/A-Z/;
19 $fuction{$upper}=$t;
20 }
21 next unless (/^#define\s+(\S+)\s/);
22
23 $o=$1;
24 if ($o =~ /^([^_]+)_F_(.*)/)
25 {
26 $type=$1;
27 $Func++;
28 $n=$2;
29 $n=$fuction{$n} if (defined($fuction{$n}));
30 $out{$1."_str_functs"}.=
31 sprintf("{ERR_PACK(0,%s,0),\t\"$n\"},\n",$o);
32 }
33 elsif ($o =~ /^([^_]+)_R_(.*)/)
34 {
35 $type=$1;
36 $Reas++;
37 $r=$2;
38 $r =~ tr/A-Z_/a-z /;
39 $pkg{$type."_str_reasons"}=$type;
40 $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o);
41 }
42 elsif ($ARGV[0] =~ /rsaref/ && $o =~ /^RE_(.*)/)
43 {
44 $type="RSAREF";
45 $Reas++;
46 $r=$1;
47 $r =~ tr/A-Z_/a-z /;
48 $pkg{$type."_str_reasons"}=$type;
49 $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o);
50 }
51 }
52close(IN);
53
54&header($type,$ARGV[0]);
55
56foreach (sort keys %out)
57 {
58 print "static ERR_STRING_DATA ${_}[]=\n\t{\n";
59 print $out{$_};
60 print "{0,NULL},\n";
61 print "\t};\n\n";
62 }
63print "#endif\n";
64
65if ($static)
66 { $lib="ERR_LIB_$type"; }
67else
68 { $lib="${type}_lib_error_code"; }
69
70$str="";
71$str.="#ifndef NO_ERR\n";
72$str.="\t\tERR_load_strings($lib,${type}_str_functs);\n" if $Func;
73$str.="\t\tERR_load_strings($lib,${type}_str_reasons);\n" if $Reas;
74$str.="#endif\n";
75
76if (!$static)
77 {
78print <<"EOF";
79
80static int ${type}_lib_error_code=0;
81
82void ERR_load_${type}_strings()
83 {
84 static int init=1;
85
86 if (${type}_lib_error_code == 0)
87 ${type}_lib_error_code=ERR_get_next_error_library();
88
89 if (init);
90 {;
91 init=0;
92$str
93 }
94 }
95
96void ERR_${type}_error(function,reason,file,line)
97int function;
98int reason;
99char *file;
100int line;
101 {
102 if (${type}_lib_error_code == 0)
103 ${type}_lib_error_code=ERR_get_next_error_library();
104 ERR_PUT_error(${type}_lib_error_code,function,reason,file,line);
105 }
106EOF
107 }
108else # $static
109 {
110 print <<"EOF";
111
112void ERR_load_${type}_strings()
113 {
114 static int init=1;
115
116 if (init);
117 {;
118 init=0;
119$str
120 }
121 }
122EOF
123 }
124
125sub header
126 {
127 ($type,$header)=@_;
128
129 ($lc=$type) =~ tr/A-Z/a-z/;
130 $header =~ s/^.*\///;
131
132 print "/* lib/$lc/${lc}\_err.c */\n";
133 print <<'EOF';
134/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
135 * All rights reserved.
136 *
137 * This package is an SSL implementation written
138 * by Eric Young (eay@cryptsoft.com).
139 * The implementation was written so as to conform with Netscapes SSL.
140 *
141 * This library is free for commercial and non-commercial use as long as
142 * the following conditions are aheared to. The following conditions
143 * apply to all code found in this distribution, be it the RC4, RSA,
144 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
145 * included with this distribution is covered by the same copyright terms
146 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
147 *
148 * Copyright remains Eric Young's, and as such any Copyright notices in
149 * the code are not to be removed.
150 * If this package is used in a product, Eric Young should be given attribution
151 * as the author of the parts of the library used.
152 * This can be in the form of a textual message at program startup or
153 * in documentation (online or textual) provided with the package.
154 *
155 * Redistribution and use in source and binary forms, with or without
156 * modification, are permitted provided that the following conditions
157 * are met:
158 * 1. Redistributions of source code must retain the copyright
159 * notice, this list of conditions and the following disclaimer.
160 * 2. Redistributions in binary form must reproduce the above copyright
161 * notice, this list of conditions and the following disclaimer in the
162 * documentation and/or other materials provided with the distribution.
163 * 3. All advertising materials mentioning features or use of this software
164 * must display the following acknowledgement:
165 * "This product includes cryptographic software written by
166 * Eric Young (eay@cryptsoft.com)"
167 * The word 'cryptographic' can be left out if the rouines from the library
168 * being used are not cryptographic related :-).
169 * 4. If you include any Windows specific code (or a derivative thereof) from
170 * the apps directory (application code) you must include an acknowledgement:
171 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
172 *
173 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
174 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
175 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
176 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
177 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
178 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
179 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
180 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
181 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
182 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
183 * SUCH DAMAGE.
184 *
185 * The licence and distribution terms for any publically available version or
186 * derivative of this code cannot be changed. i.e. this code cannot simply be
187 * copied and put under another distribution licence
188 * [including the GNU Public Licence.]
189 */
190EOF
191
192 print "#include <stdio.h>\n";
193 print "#include \"err.h\"\n";
194 print "#include \"$header\"\n";
195 print "\n/* BEGIN ERROR CODES */\n";
196 print "#ifndef NO_ERR\n";
197 }
198
diff --git a/src/lib/libcrypto/err/error.err b/src/lib/libcrypto/err/error.err
new file mode 100644
index 0000000000..f09557d8d9
--- /dev/null
+++ b/src/lib/libcrypto/err/error.err
@@ -0,0 +1,13 @@
1/* Error codes for the ERR functions. */
2
3/* Function codes. */
4
5/* Reason codes. */
6#define ERR_R_BN_LIB 100
7#define ERR_R_DER_LIB 101
8#define ERR_R_MALLOC_FAILURE 102
9#define ERR_R_PEM_LIB 103
10#define ERR_R_RSA_LIB 104
11#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED 105
12#define ERR_R_SYS_LIB 106
13#define ERR_R_X509_LIB 107
diff --git a/src/lib/libcrypto/err/ssleay.ec b/src/lib/libcrypto/err/ssleay.ec
new file mode 100644
index 0000000000..10b5dbb59d
--- /dev/null
+++ b/src/lib/libcrypto/err/ssleay.ec
@@ -0,0 +1,57 @@
1L ERR NONE
2L CRYPTO crypto.err
3L BN bn/bn.err
4L RSA rsa/rsa.err
5L DSA dsa/dsa.err
6L DH dh/dh.err
7L EVP evp/evp.err
8L BUF buffer/buffer.err
9L BIO bio/bio.err
10L OBJ objects/objects.err
11L PEM pem/pem.err
12L X509 x509/x509.err
13L METH meth/meth.err
14L ASN1 asn1/asn1.err
15L CONF conf/conf.err
16L PROXY proxy/proxy.err
17L PKCS7 pkcs7/pkcs7.err
18L RSAREF ../rsaref/rsaref.err
19L SSL ../ssl/ssl.err
20L SSL2 ../ssl/ssl2.err
21L SSL3 ../ssl/ssl3.err
22L SSL23 ../ssl/ssl23.err
23
24F RSAREF_F_RSA_BN2BIN
25F RSAREF_F_RSA_PRIVATE_DECRYPT
26F RSAREF_F_RSA_PRIVATE_ENCRYPT
27F RSAREF_F_RSA_PUBLIC_DECRYPT
28F RSAREF_F_RSA_PUBLIC_ENCRYPT
29#F SSL_F_CLIENT_CERTIFICATE
30
31R SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010
32R SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020
33R SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030
34R SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040
35R SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041
36R SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042
37R SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043
38R SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044
39R SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045
40R SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046
41R SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047
42
43R RSAREF_R_CONTENT_ENCODING 0x0400
44R RSAREF_R_DATA 0x0401
45R RSAREF_R_DIGEST_ALGORITHM 0x0402
46R RSAREF_R_ENCODING 0x0403
47R RSAREF_R_KEY 0x0404
48R RSAREF_R_KEY_ENCODING 0x0405
49R RSAREF_R_LEN 0x0406
50R RSAREF_R_MODULUS_LEN 0x0407
51R RSAREF_R_NEED_RANDOM 0x0408
52R RSAREF_R_PRIVATE_KEY 0x0409
53R RSAREF_R_PUBLIC_KEY 0x040a
54R RSAREF_R_SIGNATURE 0x040b
55R RSAREF_R_SIGNATURE_ENCODING 0x040c
56R RSAREF_R_ENCRYPTION_ALGORITHM 0x040d
57
diff --git a/src/lib/libcrypto/evp/Makefile.ssl b/src/lib/libcrypto/evp/Makefile.ssl
new file mode 100644
index 0000000000..8bf2516458
--- /dev/null
+++ b/src/lib/libcrypto/evp/Makefile.ssl
@@ -0,0 +1,111 @@
1#
2# SSLeay/crypto/evp/Makefile
3#
4
5DIR= evp
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=evp
19ERRC=evp_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= encode.c digest.c evp_enc.c evp_key.c \
26 e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c \
27 e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c \
28 e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c \
29 e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c \
30 e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c \
31 e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c \
32 e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c \
33 e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c \
34 m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c \
35 m_ripemd.c \
36 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \
37 bio_md.c bio_b64.c bio_enc.c $(ERRC).c e_null.c \
38 c_all.c evp_lib.c
39
40LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \
41 e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o \
42 e_ecb_i.o e_cbc_i.o e_cfb_i.o e_ofb_i.o \
43 e_ecb_3d.o e_cbc_3d.o e_rc4.o names.o \
44 e_cfb_3d.o e_ofb_3d.o e_xcbc_d.o \
45 e_ecb_r2.o e_cbc_r2.o e_cfb_r2.o e_ofb_r2.o \
46 e_ecb_bf.o e_cbc_bf.o e_cfb_bf.o e_ofb_bf.o \
47 e_ecb_c.o e_cbc_c.o e_cfb_c.o e_ofb_c.o \
48 e_ecb_r5.o e_cbc_r5.o e_cfb_r5.o e_ofb_r5.o \
49 m_null.o m_md2.o m_md5.o m_sha.o m_sha1.o m_dss.o m_dss1.o m_mdc2.o \
50 m_ripemd.o \
51 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \
52 bio_md.o bio_b64.o bio_enc.o $(ERRC).o e_null.o \
53 c_all.o evp_lib.o
54
55SRC= $(LIBSRC)
56
57EXHEADER= evp.h
58HEADER= $(EXHEADER)
59
60ALL= $(GENERAL) $(SRC) $(HEADER)
61
62top:
63 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
64
65all: lib
66
67lib: $(LIBOBJ)
68 $(AR) $(LIB) $(LIBOBJ)
69 sh $(TOP)/util/ranlib.sh $(LIB)
70 @touch lib
71
72files:
73 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
74
75links:
76 /bin/rm -f Makefile
77 $(TOP)/util/point.sh Makefile.ssl Makefile ;
78 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
79 $(TOP)/util/mklink.sh ../../test $(TEST)
80 $(TOP)/util/mklink.sh ../../apps $(APPS)
81
82install:
83 @for i in $(EXHEADER) ; \
84 do \
85 (cp $$i $(INSTALLTOP)/include/$$i; \
86 chmod 644 $(INSTALLTOP)/include/$$i ); \
87 done;
88
89tags:
90 ctags $(SRC)
91
92tests:
93
94lint:
95 lint -DLINT $(INCLUDES) $(SRC)>fluff
96
97depend:
98 $(MAKEDEPEND) $(INCLUDES) $(LIBSRC)
99
100dclean:
101 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
102 mv -f Makefile.new $(MAKEFILE)
103
104clean:
105 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
106
107errors:
108 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
109 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
110
111# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/evp/e_cbc_3d.c b/src/lib/libcrypto/evp/e_cbc_3d.c
new file mode 100644
index 0000000000..5761bf186a
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_3d.c
@@ -0,0 +1,163 @@
1/* crypto/evp/e_cbc_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_cbc_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_cbc_ede_init_key();
73static void des_cbc_ede3_init_key();
74static void des_cbc_ede_cipher();
75#endif
76
77static EVP_CIPHER d_cbc_ede_cipher2=
78 {
79 NID_des_ede_cbc,
80 8,16,8,
81 des_cbc_ede_init_key,
82 des_cbc_ede_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 EVP_CIPHER_get_asn1_iv,
87 EVP_CIPHER_set_asn1_iv,
88 };
89
90static EVP_CIPHER d_cbc_ede_cipher3=
91 {
92 NID_des_ede3_cbc,
93 8,24,8,
94 des_cbc_ede3_init_key,
95 des_cbc_ede_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 EVP_CIPHER_set_asn1_iv,
100 EVP_CIPHER_get_asn1_iv,
101 };
102
103EVP_CIPHER *EVP_des_ede_cbc()
104 {
105 return(&d_cbc_ede_cipher2);
106 }
107
108EVP_CIPHER *EVP_des_ede3_cbc()
109 {
110 return(&d_cbc_ede_cipher3);
111 }
112
113static void des_cbc_ede_init_key(ctx,key,iv,enc)
114EVP_CIPHER_CTX *ctx;
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 {
119 if (iv != NULL)
120 memcpy(&(ctx->oiv[0]),iv,8);
121 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
122
123 if (key != NULL)
124 {
125 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
126 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
127 memcpy( (char *)ctx->c.des_ede.ks3,
128 (char *)ctx->c.des_ede.ks1,
129 sizeof(ctx->c.des_ede.ks1));
130 }
131 }
132
133static void des_cbc_ede3_init_key(ctx,key,iv,enc)
134EVP_CIPHER_CTX *ctx;
135unsigned char *key;
136unsigned char *iv;
137int enc;
138 {
139 if (iv != NULL)
140 memcpy(&(ctx->oiv[0]),iv,8);
141 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
142
143 if (key != NULL)
144 {
145 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
146 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
147 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
148 }
149 }
150
151static void des_cbc_ede_cipher(ctx,out,in,inl)
152EVP_CIPHER_CTX *ctx;
153unsigned char *out;
154unsigned char *in;
155unsigned int inl;
156 {
157 des_ede3_cbc_encrypt(
158 (des_cblock *)in,(des_cblock *)out,
159 (long)inl, ctx->c.des_ede.ks1,
160 ctx->c.des_ede.ks2,ctx->c.des_ede.ks3,
161 (des_cblock *)&(ctx->iv[0]),
162 ctx->encrypt);
163 }
diff --git a/src/lib/libcrypto/evp/e_cbc_bf.c b/src/lib/libcrypto/evp/e_cbc_bf.c
new file mode 100644
index 0000000000..be605f4a13
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_bf.c
@@ -0,0 +1,119 @@
1/* crypto/evp/e_cbc_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_cbc_init_key();
73static void bf_cbc_cipher();
74#endif
75
76static EVP_CIPHER bfish_cbc_cipher=
77 {
78 NID_bf_cbc,
79 8,EVP_BLOWFISH_KEY_SIZE,8,
80 bf_cbc_init_key,
81 bf_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_bf_cbc()
90 {
91 return(&bfish_cbc_cipher);
92 }
93
94static void bf_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
105 }
106
107static void bf_cbc_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 BF_cbc_encrypt(
114 in,out,(long)inl,
115 &(ctx->c.bf_ks),&(ctx->iv[0]),
116 ctx->encrypt);
117 }
118
119#endif
diff --git a/src/lib/libcrypto/evp/e_cbc_c.c b/src/lib/libcrypto/evp/e_cbc_c.c
new file mode 100644
index 0000000000..b50c7874b3
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_c.c
@@ -0,0 +1,119 @@
1/* crypto/evp/e_cbc_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_cbc_init_key();
73static void cast_cbc_cipher();
74#endif
75
76static EVP_CIPHER cast5_cbc_cipher=
77 {
78 NID_cast5_cbc,
79 8,EVP_CAST5_KEY_SIZE,8,
80 cast_cbc_init_key,
81 cast_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_cast5_cbc()
90 {
91 return(&cast5_cbc_cipher);
92 }
93
94static void cast_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
105 }
106
107static void cast_cbc_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 CAST_cbc_encrypt(
114 in,out,(long)inl,
115 &(ctx->c.cast_ks),&(ctx->iv[0]),
116 ctx->encrypt);
117 }
118
119#endif
diff --git a/src/lib/libcrypto/evp/e_cbc_d.c b/src/lib/libcrypto/evp/e_cbc_d.c
new file mode 100644
index 0000000000..c67706e3a0
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_d.c
@@ -0,0 +1,116 @@
1/* crypto/evp/e_cbc_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_cbc_init_key();
71static void des_cbc_cipher();
72#endif
73
74static EVP_CIPHER d_cbc_cipher=
75 {
76 NID_des_cbc,
77 8,8,8,
78 des_cbc_init_key,
79 des_cbc_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 EVP_CIPHER_get_asn1_iv,
84 EVP_CIPHER_set_asn1_iv,
85 };
86
87EVP_CIPHER *EVP_des_cbc()
88 {
89 return(&d_cbc_cipher);
90 }
91
92static void des_cbc_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 if (iv != NULL)
99 memcpy(&(ctx->oiv[0]),iv,8);
100 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
101 if (key != NULL)
102 des_set_key((des_cblock *)key,ctx->c.des_ks);
103 }
104
105static void des_cbc_cipher(ctx,out,in,inl)
106EVP_CIPHER_CTX *ctx;
107unsigned char *out;
108unsigned char *in;
109unsigned int inl;
110 {
111 des_ncbc_encrypt(
112 (des_cblock *)in,(des_cblock *)out,
113 (long)inl, ctx->c.des_ks,
114 (des_cblock *)&(ctx->iv[0]),
115 ctx->encrypt);
116 }
diff --git a/src/lib/libcrypto/evp/e_cbc_i.c b/src/lib/libcrypto/evp/e_cbc_i.c
new file mode 100644
index 0000000000..312ffcb721
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_i.c
@@ -0,0 +1,131 @@
1/* crypto/evp/e_cbc_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_cbc_init_key();
73static void idea_cbc_cipher();
74#endif
75
76static EVP_CIPHER i_cbc_cipher=
77 {
78 NID_idea_cbc,
79 8,16,8,
80 idea_cbc_init_key,
81 idea_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_idea_cbc()
90 {
91 return(&i_cbc_cipher);
92 }
93
94static void idea_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 {
105 if (enc)
106 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
107 else
108 {
109 IDEA_KEY_SCHEDULE tmp;
110
111 idea_set_encrypt_key(key,&tmp);
112 idea_set_decrypt_key(&tmp,&(ctx->c.idea_ks));
113 memset((unsigned char *)&tmp,0,
114 sizeof(IDEA_KEY_SCHEDULE));
115 }
116 }
117 }
118
119static void idea_cbc_cipher(ctx,out,in,inl)
120EVP_CIPHER_CTX *ctx;
121unsigned char *out;
122unsigned char *in;
123unsigned int inl;
124 {
125 idea_cbc_encrypt(
126 in,out,(long)inl,
127 &(ctx->c.idea_ks),&(ctx->iv[0]),
128 ctx->encrypt);
129 }
130
131#endif
diff --git a/src/lib/libcrypto/evp/e_cbc_r2.c b/src/lib/libcrypto/evp/e_cbc_r2.c
new file mode 100644
index 0000000000..4f8002f16d
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_r2.c
@@ -0,0 +1,136 @@
1/* crypto/evp/e_cbc_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_cbc_init_key();
73static void rc2_cbc_cipher();
74#endif
75
76static EVP_CIPHER r2_cbc_cipher=
77 {
78 NID_rc2_cbc,
79 8,EVP_RC2_KEY_SIZE,8,
80 rc2_cbc_init_key,
81 rc2_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89static EVP_CIPHER r2_40_cbc_cipher=
90 {
91 NID_rc2_40_cbc,
92 8,5 /* 40 bit */,8,
93 rc2_cbc_init_key,
94 rc2_cbc_cipher,
95 NULL,
96 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
97 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
98 };
99
100EVP_CIPHER *EVP_rc2_cbc()
101 {
102 return(&r2_cbc_cipher);
103 }
104
105EVP_CIPHER *EVP_rc2_40_cbc()
106 {
107 return(&r2_40_cbc_cipher);
108 }
109
110static void rc2_cbc_init_key(ctx,key,iv,enc)
111EVP_CIPHER_CTX *ctx;
112unsigned char *key;
113unsigned char *iv;
114int enc;
115 {
116 if (iv != NULL)
117 memcpy(&(ctx->oiv[0]),iv,8);
118 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
119 if (key != NULL)
120 RC2_set_key(&(ctx->c.rc2_ks),EVP_CIPHER_CTX_key_length(ctx),
121 key,EVP_CIPHER_CTX_key_length(ctx)*8);
122 }
123
124static void rc2_cbc_cipher(ctx,out,in,inl)
125EVP_CIPHER_CTX *ctx;
126unsigned char *out;
127unsigned char *in;
128unsigned int inl;
129 {
130 RC2_cbc_encrypt(
131 in,out,(long)inl,
132 &(ctx->c.rc2_ks),&(ctx->iv[0]),
133 ctx->encrypt);
134 }
135
136#endif
diff --git a/src/lib/libcrypto/evp/e_cbc_r5.c b/src/lib/libcrypto/evp/e_cbc_r5.c
new file mode 100644
index 0000000000..f7d46ca91f
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cbc_r5.c
@@ -0,0 +1,120 @@
1/* crypto/evp/e_cbc_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void r_32_12_16_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void r_32_12_16_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void r_32_12_16_cbc_init_key();
73static void r_32_12_16_cbc_cipher();
74#endif
75
76static EVP_CIPHER rc5_32_12_16_cbc_cipher=
77 {
78 NID_rc5_cbc,
79 8,EVP_RC5_32_12_16_KEY_SIZE,8,
80 r_32_12_16_cbc_init_key,
81 r_32_12_16_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_cbc()
90 {
91 return(&rc5_32_12_16_cbc_cipher);
92 }
93
94static void r_32_12_16_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,
105 key,RC5_12_ROUNDS);
106 }
107
108static void r_32_12_16_cbc_cipher(ctx,out,in,inl)
109EVP_CIPHER_CTX *ctx;
110unsigned char *out;
111unsigned char *in;
112unsigned int inl;
113 {
114 RC5_32_cbc_encrypt(
115 in,out,(long)inl,
116 &(ctx->c.rc5_ks),&(ctx->iv[0]),
117 ctx->encrypt);
118 }
119
120#endif
diff --git a/src/lib/libcrypto/evp/e_cfb_3d.c b/src/lib/libcrypto/evp/e_cfb_3d.c
new file mode 100644
index 0000000000..e7e3419411
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_3d.c
@@ -0,0 +1,166 @@
1/* crypto/evp/e_cfb_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_cfb_init_key();
73static void des_ede3_cfb_init_key();
74static void des_ede_cfb_cipher();
75#endif
76
77static EVP_CIPHER d_ede_cfb_cipher2=
78 {
79 NID_des_ede_cfb64,
80 1,16,8,
81 des_ede_cfb_init_key,
82 des_ede_cfb_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 EVP_CIPHER_set_asn1_iv,
87 EVP_CIPHER_get_asn1_iv,
88 };
89
90static EVP_CIPHER d_ede3_cfb_cipher3=
91 {
92 NID_des_ede3_cfb64,
93 1,24,8,
94 des_ede3_cfb_init_key,
95 des_ede_cfb_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 EVP_CIPHER_set_asn1_iv,
100 EVP_CIPHER_get_asn1_iv,
101 };
102
103EVP_CIPHER *EVP_des_ede_cfb()
104 {
105 return(&d_ede_cfb_cipher2);
106 }
107
108EVP_CIPHER *EVP_des_ede3_cfb()
109 {
110 return(&d_ede3_cfb_cipher3);
111 }
112
113static void des_ede_cfb_init_key(ctx,key,iv,enc)
114EVP_CIPHER_CTX *ctx;
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 {
119 ctx->num=0;
120
121 if (iv != NULL)
122 memcpy(&(ctx->oiv[0]),iv,8);
123 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
124 if (key != NULL)
125 {
126 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
127 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
128 memcpy( (char *)ctx->c.des_ede.ks3,
129 (char *)ctx->c.des_ede.ks1,
130 sizeof(ctx->c.des_ede.ks1));
131 }
132 }
133
134static void des_ede3_cfb_init_key(ctx,key,iv,enc)
135EVP_CIPHER_CTX *ctx;
136unsigned char *key;
137unsigned char *iv;
138int enc;
139 {
140 ctx->num=0;
141
142 if (iv != NULL)
143 memcpy(&(ctx->oiv[0]),iv,8);
144 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
145 if (key != NULL)
146 {
147 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
148 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
149 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
150 }
151 }
152
153static void des_ede_cfb_cipher(ctx,out,in,inl)
154EVP_CIPHER_CTX *ctx;
155unsigned char *out;
156unsigned char *in;
157unsigned int inl;
158 {
159 des_ede3_cfb64_encrypt(
160 in,out,(long)inl,
161 ctx->c.des_ede.ks1,
162 ctx->c.des_ede.ks2,
163 ctx->c.des_ede.ks3,
164 (des_cblock *)&(ctx->iv[0]),
165 &ctx->num,ctx->encrypt);
166 }
diff --git a/src/lib/libcrypto/evp/e_cfb_bf.c b/src/lib/libcrypto/evp/e_cfb_bf.c
new file mode 100644
index 0000000000..8aba2564b8
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_bf.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_cfb_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_cfb_init_key();
73static void bf_cfb_cipher();
74#endif
75
76static EVP_CIPHER bfish_cfb_cipher=
77 {
78 NID_bf_cfb64,
79 1,EVP_BLOWFISH_KEY_SIZE,8,
80 bf_cfb_init_key,
81 bf_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_bf_cfb()
90 {
91 return(&bfish_cfb_cipher);
92 }
93
94static void bf_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
107 }
108
109static void bf_cfb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 BF_cfb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.bf_ks),
118 &(ctx->iv[0]),
119 &ctx->num,ctx->encrypt);
120 }
121#endif
diff --git a/src/lib/libcrypto/evp/e_cfb_c.c b/src/lib/libcrypto/evp/e_cfb_c.c
new file mode 100644
index 0000000000..936df55fd8
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_c.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_cfb_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_cfb_init_key();
73static void cast_cfb_cipher();
74#endif
75
76static EVP_CIPHER cast5_cfb_cipher=
77 {
78 NID_cast5_cfb64,
79 1,EVP_CAST5_KEY_SIZE,8,
80 cast_cfb_init_key,
81 cast_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_cast5_cfb()
90 {
91 return(&cast5_cfb_cipher);
92 }
93
94static void cast_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
107 }
108
109static void cast_cfb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 CAST_cfb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.cast_ks),
118 &(ctx->iv[0]),
119 &ctx->num,ctx->encrypt);
120 }
121#endif
diff --git a/src/lib/libcrypto/evp/e_cfb_d.c b/src/lib/libcrypto/evp/e_cfb_d.c
new file mode 100644
index 0000000000..9ae4558f51
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_d.c
@@ -0,0 +1,118 @@
1/* crypto/evp/e_cfb_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_cfb_init_key();
71static void des_cfb_cipher();
72#endif
73
74static EVP_CIPHER d_cfb_cipher=
75 {
76 NID_des_cfb64,
77 1,8,8,
78 des_cfb_init_key,
79 des_cfb_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 EVP_CIPHER_set_asn1_iv,
84 EVP_CIPHER_get_asn1_iv,
85 };
86
87EVP_CIPHER *EVP_des_cfb()
88 {
89 return(&d_cfb_cipher);
90 }
91
92static void des_cfb_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 ctx->num=0;
99
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 des_set_key((des_cblock *)key,ctx->c.des_ks);
105 }
106
107static void des_cfb_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 des_cfb64_encrypt(
114 in,out,
115 (long)inl, ctx->c.des_ks,
116 (des_cblock *)&(ctx->iv[0]),
117 &ctx->num,ctx->encrypt);
118 }
diff --git a/src/lib/libcrypto/evp/e_cfb_i.c b/src/lib/libcrypto/evp/e_cfb_i.c
new file mode 100644
index 0000000000..9225efaa86
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_i.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_cfb_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_cfb_init_key();
73static void idea_cfb_cipher();
74#endif
75
76static EVP_CIPHER i_cfb_cipher=
77 {
78 NID_idea_cfb64,
79 1,IDEA_KEY_LENGTH,IDEA_BLOCK,
80 idea_cfb_init_key,
81 idea_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_idea_cfb()
90 {
91 return(&i_cfb_cipher);
92 }
93
94static void idea_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
107 }
108
109static void idea_cfb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 idea_cfb64_encrypt(
116 in,out,(long)inl,
117 &(ctx->c.idea_ks),&(ctx->iv[0]),
118 &ctx->num,ctx->encrypt);
119 }
120
121#endif
diff --git a/src/lib/libcrypto/evp/e_cfb_r2.c b/src/lib/libcrypto/evp/e_cfb_r2.c
new file mode 100644
index 0000000000..af5a39d1f4
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_r2.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_cfb_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_cfb_init_key();
73static void rc2_cfb_cipher();
74#endif
75
76static EVP_CIPHER r2_cfb_cipher=
77 {
78 NID_rc2_cfb64,
79 1,EVP_RC2_KEY_SIZE,8,
80 rc2_cfb_init_key,
81 rc2_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc2_cfb()
90 {
91 return(&r2_cfb_cipher);
92 }
93
94static void rc2_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
107 EVP_RC2_KEY_SIZE*8);
108 }
109
110static void rc2_cfb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC2_cfb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc2_ks),
119 &(ctx->iv[0]),
120 &ctx->num,ctx->encrypt);
121 }
122#endif
diff --git a/src/lib/libcrypto/evp/e_cfb_r5.c b/src/lib/libcrypto/evp/e_cfb_r5.c
new file mode 100644
index 0000000000..a2fddaedc0
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_cfb_r5.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_cfb_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc5_32_12_16_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc5_32_12_16_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc5_32_12_16_cfb_init_key();
73static void rc5_32_12_16_cfb_cipher();
74#endif
75
76static EVP_CIPHER rc5_cfb_cipher=
77 {
78 NID_rc5_cfb64,
79 1,EVP_RC5_32_12_16_KEY_SIZE,8,
80 rc5_32_12_16_cfb_init_key,
81 rc5_32_12_16_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_cfb()
90 {
91 return(&rc5_cfb_cipher);
92 }
93
94static void rc5_32_12_16_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
107 RC5_12_ROUNDS);
108 }
109
110static void rc5_32_12_16_cfb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC5_32_cfb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc5_ks),
119 &(ctx->iv[0]),
120 &ctx->num,ctx->encrypt);
121 }
122#endif
diff --git a/src/lib/libcrypto/evp/e_ecb_3d.c b/src/lib/libcrypto/evp/e_ecb_3d.c
new file mode 100644
index 0000000000..908fc0760a
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_3d.c
@@ -0,0 +1,161 @@
1/* crypto/evp/e_ecb_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_init_key();
73static void des_ede3_init_key();
74static void des_ede_cipher();
75#endif
76
77static EVP_CIPHER d_ede_cipher2=
78 {
79 NID_des_ede,
80 8,16,0,
81 des_ede_init_key,
82 des_ede_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 NULL,
87 NULL,
88 };
89
90static EVP_CIPHER d_ede3_cipher3=
91 {
92 NID_des_ede3,
93 8,24,0,
94 des_ede3_init_key,
95 des_ede_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 NULL,
100 };
101
102EVP_CIPHER *EVP_des_ede()
103 {
104 return(&d_ede_cipher2);
105 }
106
107EVP_CIPHER *EVP_des_ede3()
108 {
109 return(&d_ede3_cipher3);
110 }
111
112static void des_ede_init_key(ctx,key,iv,enc)
113EVP_CIPHER_CTX *ctx;
114unsigned char *key;
115unsigned char *iv;
116int enc;
117 {
118 if (key != NULL)
119 {
120 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
121 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
122 memcpy( (char *)ctx->c.des_ede.ks3,
123 (char *)ctx->c.des_ede.ks1,
124 sizeof(ctx->c.des_ede.ks1));
125 }
126 }
127
128static void des_ede3_init_key(ctx,key,iv,enc)
129EVP_CIPHER_CTX *ctx;
130unsigned char *key;
131unsigned char *iv;
132int enc;
133 {
134 if (key != NULL)
135 {
136 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
137 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
138 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
139 }
140 }
141
142static void des_ede_cipher(ctx,out,in,inl)
143EVP_CIPHER_CTX *ctx;
144unsigned char *out;
145unsigned char *in;
146unsigned int inl;
147 {
148 unsigned int i;
149
150 if (inl < 8) return;
151 inl-=8;
152 for (i=0; i<=inl; i+=8)
153 {
154 des_ecb3_encrypt(
155 (des_cblock *)&(in[i]),(des_cblock *)&(out[i]),
156 ctx->c.des_ede.ks1,
157 ctx->c.des_ede.ks2,
158 ctx->c.des_ede.ks3,
159 ctx->encrypt);
160 }
161 }
diff --git a/src/lib/libcrypto/evp/e_ecb_bf.c b/src/lib/libcrypto/evp/e_ecb_bf.c
new file mode 100644
index 0000000000..142a9d3123
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_bf.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ecb_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_ecb_init_key();
73static void bf_ecb_cipher();
74#endif
75
76static EVP_CIPHER bfish_ecb_cipher=
77 {
78 NID_bf_ecb,
79 8,EVP_BLOWFISH_KEY_SIZE,0,
80 bf_ecb_init_key,
81 bf_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_bf_ecb()
90 {
91 return(&bfish_ecb_cipher);
92 }
93
94static void bf_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
102 }
103
104static void bf_ecb_cipher(ctx,out,in,inl)
105EVP_CIPHER_CTX *ctx;
106unsigned char *out;
107unsigned char *in;
108unsigned int inl;
109 {
110 unsigned int i;
111
112 if (inl < 8) return;
113 inl-=8;
114 for (i=0; i<=inl; i+=8)
115 {
116 BF_ecb_encrypt(
117 &(in[i]),&(out[i]),
118 &(ctx->c.bf_ks),ctx->encrypt);
119 }
120 }
121
122#endif
diff --git a/src/lib/libcrypto/evp/e_ecb_c.c b/src/lib/libcrypto/evp/e_ecb_c.c
new file mode 100644
index 0000000000..34e0c18296
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_c.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ecb_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_ecb_init_key();
73static void cast_ecb_cipher();
74#endif
75
76static EVP_CIPHER cast5_ecb_cipher=
77 {
78 NID_cast5_ecb,
79 8,EVP_CAST5_KEY_SIZE,0,
80 cast_ecb_init_key,
81 cast_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_cast5_ecb()
90 {
91 return(&cast5_ecb_cipher);
92 }
93
94static void cast_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
102 }
103
104static void cast_ecb_cipher(ctx,out,in,inl)
105EVP_CIPHER_CTX *ctx;
106unsigned char *out;
107unsigned char *in;
108unsigned int inl;
109 {
110 unsigned int i;
111
112 if (inl < 8) return;
113 inl-=8;
114 for (i=0; i<=inl; i+=8)
115 {
116 CAST_ecb_encrypt(
117 &(in[i]),&(out[i]),
118 &(ctx->c.cast_ks),ctx->encrypt);
119 }
120 }
121
122#endif
diff --git a/src/lib/libcrypto/evp/e_ecb_d.c b/src/lib/libcrypto/evp/e_ecb_d.c
new file mode 100644
index 0000000000..7a409d6459
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_d.c
@@ -0,0 +1,118 @@
1/* crypto/evp/e_ecb_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_ecb_init_key();
71static void des_ecb_cipher();
72#endif
73
74static EVP_CIPHER d_ecb_cipher=
75 {
76 NID_des_ecb,
77 8,8,0,
78 des_ecb_init_key,
79 des_ecb_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 NULL,
84 NULL,
85 };
86
87EVP_CIPHER *EVP_des_ecb()
88 {
89 return(&d_ecb_cipher);
90 }
91
92static void des_ecb_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 if (key != NULL)
99 des_set_key((des_cblock *)key,ctx->c.des_ks);
100 }
101
102static void des_ecb_cipher(ctx,out,in,inl)
103EVP_CIPHER_CTX *ctx;
104unsigned char *out;
105unsigned char *in;
106unsigned int inl;
107 {
108 unsigned int i;
109
110 if (inl < 8) return;
111 inl-=8;
112 for (i=0; i<=inl; i+=8)
113 {
114 des_ecb_encrypt(
115 (des_cblock *)&(in[i]),(des_cblock *)&(out[i]),
116 ctx->c.des_ks,ctx->encrypt);
117 }
118 }
diff --git a/src/lib/libcrypto/evp/e_ecb_i.c b/src/lib/libcrypto/evp/e_ecb_i.c
new file mode 100644
index 0000000000..e24022a12c
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_i.c
@@ -0,0 +1,133 @@
1/* crypto/evp/e_ecb_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_ecb_init_key();
73static void idea_ecb_cipher();
74#endif
75
76static EVP_CIPHER i_ecb_cipher=
77 {
78 NID_idea_ecb,
79 8,16,0,
80 idea_ecb_init_key,
81 idea_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_idea_ecb()
90 {
91 return(&i_ecb_cipher);
92 }
93
94static void idea_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 {
102 if (enc)
103 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
104 else
105 {
106 IDEA_KEY_SCHEDULE tmp;
107
108 idea_set_encrypt_key(key,&tmp);
109 idea_set_decrypt_key(&tmp, &(ctx->c.idea_ks));
110 memset((unsigned char *)&tmp,0,
111 sizeof(IDEA_KEY_SCHEDULE));
112 }
113 }
114 }
115
116static void idea_ecb_cipher(ctx,out,in,inl)
117EVP_CIPHER_CTX *ctx;
118unsigned char *out;
119unsigned char *in;
120unsigned int inl;
121 {
122 unsigned int i;
123
124 if (inl < 8) return;
125 inl-=8;
126 for (i=0; i<=inl; i+=8)
127 {
128 idea_ecb_encrypt(
129 &(in[i]),&(out[i]),&(ctx->c.idea_ks));
130 }
131 }
132
133#endif
diff --git a/src/lib/libcrypto/evp/e_ecb_r2.c b/src/lib/libcrypto/evp/e_ecb_r2.c
new file mode 100644
index 0000000000..e35b06dc6d
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_r2.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ecb_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_ecb_init_key();
73static void rc2_ecb_cipher();
74#endif
75
76static EVP_CIPHER r2_ecb_cipher=
77 {
78 NID_rc2_ecb,
79 8,EVP_RC2_KEY_SIZE,0,
80 rc2_ecb_init_key,
81 rc2_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_rc2_ecb()
90 {
91 return(&r2_ecb_cipher);
92 }
93
94static void rc2_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
102 EVP_RC2_KEY_SIZE*8);
103 }
104
105static void rc2_ecb_cipher(ctx,out,in,inl)
106EVP_CIPHER_CTX *ctx;
107unsigned char *out;
108unsigned char *in;
109unsigned int inl;
110 {
111 unsigned int i;
112
113 if (inl < 8) return;
114 inl-=8;
115 for (i=0; i<=inl; i+=8)
116 {
117 RC2_ecb_encrypt(
118 &(in[i]),&(out[i]),
119 &(ctx->c.rc2_ks),ctx->encrypt);
120 }
121 }
122
123#endif
diff --git a/src/lib/libcrypto/evp/e_ecb_r5.c b/src/lib/libcrypto/evp/e_ecb_r5.c
new file mode 100644
index 0000000000..08f4a82651
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ecb_r5.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ecb_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc5_32_12_16_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc5_32_12_16_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc5_32_12_16_ecb_init_key();
73static void rc5_32_12_16_ecb_cipher();
74#endif
75
76static EVP_CIPHER rc5_ecb_cipher=
77 {
78 NID_rc5_ecb,
79 8,EVP_RC5_32_12_16_KEY_SIZE,0,
80 rc5_32_12_16_ecb_init_key,
81 rc5_32_12_16_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_ecb()
90 {
91 return(&rc5_ecb_cipher);
92 }
93
94static void rc5_32_12_16_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
102 RC5_12_ROUNDS);
103 }
104
105static void rc5_32_12_16_ecb_cipher(ctx,out,in,inl)
106EVP_CIPHER_CTX *ctx;
107unsigned char *out;
108unsigned char *in;
109unsigned int inl;
110 {
111 unsigned int i;
112
113 if (inl < 8) return;
114 inl-=8;
115 for (i=0; i<=inl; i+=8)
116 {
117 RC5_32_ecb_encrypt(
118 &(in[i]),&(out[i]),
119 &(ctx->c.rc5_ks),ctx->encrypt);
120 }
121 }
122
123#endif
diff --git a/src/lib/libcrypto/evp/e_ofb_3d.c b/src/lib/libcrypto/evp/e_ofb_3d.c
new file mode 100644
index 0000000000..c3add18e93
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_3d.c
@@ -0,0 +1,165 @@
1/* crypto/evp/e_ofb_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_ofb_init_key();
73static void des_ede3_ofb_init_key();
74static void des_ede_ofb_cipher();
75#endif
76
77static EVP_CIPHER d_ede_ofb_cipher2=
78 {
79 NID_des_ede_ofb64,
80 1,16,8,
81 des_ede_ofb_init_key,
82 des_ede_ofb_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 EVP_CIPHER_set_asn1_iv,
87 EVP_CIPHER_get_asn1_iv,
88 };
89
90static EVP_CIPHER d_ede3_ofb_cipher3=
91 {
92 NID_des_ede3_ofb64,
93 1,24,8,
94 des_ede3_ofb_init_key,
95 des_ede_ofb_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 EVP_CIPHER_set_asn1_iv,
100 EVP_CIPHER_get_asn1_iv,
101 };
102
103EVP_CIPHER *EVP_des_ede_ofb()
104 {
105 return(&d_ede_ofb_cipher2);
106 }
107
108EVP_CIPHER *EVP_des_ede3_ofb()
109 {
110 return(&d_ede3_ofb_cipher3);
111 }
112
113static void des_ede_ofb_init_key(ctx,key,iv,enc)
114EVP_CIPHER_CTX *ctx;
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 {
119 ctx->num=0;
120
121 if (iv != NULL)
122 memcpy(&(ctx->oiv[0]),iv,8);
123 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
124 if (key != NULL)
125 {
126 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
127 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
128 memcpy( (char *)ctx->c.des_ede.ks3,
129 (char *)ctx->c.des_ede.ks1,
130 sizeof(ctx->c.des_ede.ks1));
131 }
132 }
133
134static void des_ede3_ofb_init_key(ctx,key,iv,enc)
135EVP_CIPHER_CTX *ctx;
136unsigned char *key;
137unsigned char *iv;
138int enc;
139 {
140 ctx->num=0;
141
142 if (iv != NULL)
143 memcpy(&(ctx->oiv[0]),iv,8);
144 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
145 if (key != NULL)
146 {
147 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
148 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
149 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
150 }
151 }
152
153static void des_ede_ofb_cipher(ctx,out,in,inl)
154EVP_CIPHER_CTX *ctx;
155unsigned char *out;
156unsigned char *in;
157unsigned int inl;
158 {
159 des_ede3_ofb64_encrypt(
160 in,out,
161 (long)inl,
162 ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
163 (des_cblock *)&(ctx->iv[0]),
164 &ctx->num);
165 }
diff --git a/src/lib/libcrypto/evp/e_ofb_bf.c b/src/lib/libcrypto/evp/e_ofb_bf.c
new file mode 100644
index 0000000000..492f9b9082
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_bf.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ofb_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_ofb_init_key();
73static void bf_ofb_cipher();
74#endif
75
76static EVP_CIPHER bfish_ofb_cipher=
77 {
78 NID_bf_ofb64,
79 1,EVP_BLOWFISH_KEY_SIZE,8,
80 bf_ofb_init_key,
81 bf_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_bf_ofb()
90 {
91 return(&bfish_ofb_cipher);
92 }
93
94static void bf_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
107 }
108
109static void bf_ofb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 BF_ofb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.bf_ks),
118 &(ctx->iv[0]),
119 &ctx->num);
120 }
121
122#endif
diff --git a/src/lib/libcrypto/evp/e_ofb_c.c b/src/lib/libcrypto/evp/e_ofb_c.c
new file mode 100644
index 0000000000..f1eef4469c
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_c.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ofb_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_ofb_init_key();
73static void cast_ofb_cipher();
74#endif
75
76static EVP_CIPHER cast5_ofb_cipher=
77 {
78 NID_cast5_ofb64,
79 1,EVP_CAST5_KEY_SIZE,8,
80 cast_ofb_init_key,
81 cast_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_cast5_ofb()
90 {
91 return(&cast5_ofb_cipher);
92 }
93
94static void cast_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
107 }
108
109static void cast_ofb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 CAST_ofb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.cast_ks),
118 &(ctx->iv[0]),
119 &ctx->num);
120 }
121
122#endif
diff --git a/src/lib/libcrypto/evp/e_ofb_d.c b/src/lib/libcrypto/evp/e_ofb_d.c
new file mode 100644
index 0000000000..09d4b4139d
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_d.c
@@ -0,0 +1,118 @@
1/* crypto/evp/e_ofb_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_ofb_init_key();
71static void des_ofb_cipher();
72#endif
73
74static EVP_CIPHER d_ofb_cipher=
75 {
76 NID_des_ofb64,
77 1,8,8,
78 des_ofb_init_key,
79 des_ofb_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 EVP_CIPHER_set_asn1_iv,
84 EVP_CIPHER_get_asn1_iv,
85 };
86
87EVP_CIPHER *EVP_des_ofb()
88 {
89 return(&d_ofb_cipher);
90 }
91
92static void des_ofb_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 ctx->num=0;
99
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 des_set_key((des_cblock *)key,ctx->c.des_ks);
105 }
106
107static void des_ofb_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 des_ofb64_encrypt(
114 in,out,
115 (long)inl, ctx->c.des_ks,
116 (des_cblock *)&(ctx->iv[0]),
117 &ctx->num);
118 }
diff --git a/src/lib/libcrypto/evp/e_ofb_i.c b/src/lib/libcrypto/evp/e_ofb_i.c
new file mode 100644
index 0000000000..96c8afd9c8
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_i.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_ofb_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_ofb_init_key();
73static void idea_ofb_cipher();
74#endif
75
76static EVP_CIPHER i_ofb_cipher=
77 {
78 NID_idea_ofb64,
79 1,IDEA_KEY_LENGTH,IDEA_BLOCK,
80 idea_ofb_init_key,
81 idea_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_idea_ofb()
90 {
91 return(&i_ofb_cipher);
92 }
93
94static void idea_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
107 }
108
109static void idea_ofb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 idea_ofb64_encrypt(
116 in,out,(long)inl,
117 &(ctx->c.idea_ks),&(ctx->iv[0]),
118 &ctx->num);
119 }
120
121#endif
diff --git a/src/lib/libcrypto/evp/e_ofb_r2.c b/src/lib/libcrypto/evp/e_ofb_r2.c
new file mode 100644
index 0000000000..0f6d729988
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_r2.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ofb_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_ofb_init_key();
73static void rc2_ofb_cipher();
74#endif
75
76static EVP_CIPHER r2_ofb_cipher=
77 {
78 NID_rc2_ofb64,
79 1,EVP_RC2_KEY_SIZE,8,
80 rc2_ofb_init_key,
81 rc2_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc2_ofb()
90 {
91 return(&r2_ofb_cipher);
92 }
93
94static void rc2_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
107 EVP_RC2_KEY_SIZE*8);
108 }
109
110static void rc2_ofb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC2_ofb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc2_ks),
119 &(ctx->iv[0]),
120 &ctx->num);
121 }
122
123#endif
diff --git a/src/lib/libcrypto/evp/e_ofb_r5.c b/src/lib/libcrypto/evp/e_ofb_r5.c
new file mode 100644
index 0000000000..db28d6c317
--- /dev/null
+++ b/src/lib/libcrypto/evp/e_ofb_r5.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ofb_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc5_32_12_16_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc5_32_12_16_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc5_32_12_16_ofb_init_key();
73static void rc5_32_12_16_ofb_cipher();
74#endif
75
76static EVP_CIPHER rc5_ofb_cipher=
77 {
78 NID_rc5_ofb64,
79 1,EVP_RC5_32_12_16_KEY_SIZE,8,
80 rc5_32_12_16_ofb_init_key,
81 rc5_32_12_16_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_ofb()
90 {
91 return(&rc5_ofb_cipher);
92 }
93
94static void rc5_32_12_16_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
107 RC5_12_ROUNDS);
108 }
109
110static void rc5_32_12_16_ofb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC5_32_ofb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc5_ks),
119 &(ctx->iv[0]),
120 &ctx->num);
121 }
122
123#endif
diff --git a/src/lib/libcrypto/evp/evp.err b/src/lib/libcrypto/evp/evp.err
new file mode 100644
index 0000000000..cfc17437bc
--- /dev/null
+++ b/src/lib/libcrypto/evp/evp.err
@@ -0,0 +1,24 @@
1/* Error codes for the EVP functions. */
2
3/* Function codes. */
4#define EVP_F_D2I_PKEY 100
5#define EVP_F_EVP_DECRYPTFINAL 101
6#define EVP_F_EVP_OPENINIT 102
7#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
8#define EVP_F_EVP_PKEY_DECRYPT 104
9#define EVP_F_EVP_PKEY_ENCRYPT 105
10#define EVP_F_EVP_PKEY_NEW 106
11#define EVP_F_EVP_SIGNFINAL 107
12#define EVP_F_EVP_VERIFYFINAL 108
13
14/* Reason codes. */
15#define EVP_R_BAD_DECRYPT 100
16#define EVP_R_DIFFERENT_KEY_TYPES 101
17#define EVP_R_IV_TOO_LARGE 102
18#define EVP_R_MISSING_PARMATERS 103
19#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
20#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
21#define EVP_R_PUBLIC_KEY_NOT_RSA 106
22#define EVP_R_UNSUPPORTED_CIPHER 107
23#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 108
24#define EVP_R_WRONG_PUBLIC_KEY_TYPE 109
diff --git a/src/lib/libcrypto/evp/pk_lib.c b/src/lib/libcrypto/evp/pk_lib.c
new file mode 100644
index 0000000000..08f9fabbae
--- /dev/null
+++ b/src/lib/libcrypto/evp/pk_lib.c
@@ -0,0 +1,82 @@
1/* crypto/evp/pk_lib.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64static LHASH *pk_md=NULL;
65
66static LHASH *pk_md=NULL;
67
68int EVP_add_pkey_md(oid,pkm,md)
69int oid;
70EVP_PKEY_METHOD *pkm;
71EVP_MD *md;
72 {
73 }
74
75EVP_add_pkey(pkm)
76EVP_PKEY_METHOD *pkm;
77 {
78 }
79
80EVP_PKEY_METHOD:q
81
82
diff --git a/src/lib/libcrypto/hmac/Makefile.ssl b/src/lib/libcrypto/hmac/Makefile.ssl
new file mode 100644
index 0000000000..7a042b7261
--- /dev/null
+++ b/src/lib/libcrypto/hmac/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/md/Makefile
3#
4
5DIR= hmac
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=hmactest.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=hmac.c
24LIBOBJ=hmac.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= hmac.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/idea/Makefile.ssl b/src/lib/libcrypto/idea/Makefile.ssl
new file mode 100644
index 0000000000..41b42ce03b
--- /dev/null
+++ b/src/lib/libcrypto/idea/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/idea/Makefile
3#
4
5DIR= idea
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=ideatest.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c
24LIBOBJ=i_cbc.o i_cfb64.o i_ofb64.o i_ecb.o i_skey.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= idea.h
29HEADER= idea_lcl.h $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/lhash/Makefile.ssl b/src/lib/libcrypto/lhash/Makefile.ssl
new file mode 100644
index 0000000000..cb08547b4f
--- /dev/null
+++ b/src/lib/libcrypto/lhash/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/lhash/Makefile
3#
4
5DIR= lhash
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=lhash.c lh_stats.c
24LIBOBJ=lhash.o lh_stats.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= lhash.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/libvms.com b/src/lib/libcrypto/libvms.com
new file mode 100644
index 0000000000..44f90c65b0
--- /dev/null
+++ b/src/lib/libcrypto/libvms.com
@@ -0,0 +1,31 @@
1$!
2$! Compile crypto.c as several subset modules and insert in crypto-xxx.olb.
3$! If P1 is specifed, it specifies alternate list of subsets to compile.
4$!
5$ libname = "CRYPTO-AXP.OLB"
6$ subset_list = "LIB,ASN1,BN,BUFFER,CONF,DES,DH,DSA,ERROR,EVP,IDEA,LHASH,MD," + -
7 "METH,OBJECTS,PEM,RAND,RC,RSA,SHA,STACK,TXT_DB,X509"
8$ if p1 .nes. "" then subset_list = p1
9$!
10$ if f$getsyi("CPU") .lt. 128 then libname = "CRYPTO-VAX.OLB"
11$ if f$search(libname) .eqs. "" then library/create/object/log 'libname'
12$!
13$ cc = "cc/include=[-.include]/prefix=all" + P2
14$!
15$ i = 0
16$ next_subset:
17$ subset = f$element(i,",",subset_list)
18$ if subset .eqs. "," then goto done
19$ i = i + 1
20$ create crypto_'subset'.subset
21#include "crypto.c"
22$ ofile = "sys$disk:[]crypto_" + subset + ".obj"
23$ on warning then goto next_subset
24$ write sys$output "Compiling ", ofile
25$ cc /object='ofile' crypto_'subset'.subset -
26 /define=(CRYPTO_SUBSET,CRYPTO_'subset'_SUBSET)
27$ library/replace/log 'libname'/module=CRYPTO_'subset' 'ofile'
28$ goto next_subset
29$!
30$ done:
31$ exit
diff --git a/src/lib/libcrypto/md2/Makefile.ssl b/src/lib/libcrypto/md2/Makefile.ssl
new file mode 100644
index 0000000000..d8e7200c83
--- /dev/null
+++ b/src/lib/libcrypto/md2/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/md/Makefile
3#
4
5DIR= md
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=md2test.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=md2_dgst.c md5_one.c
24LIBOBJ=md2_dgst.o md2_one.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= md2.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/md2/md2.org b/src/lib/libcrypto/md2/md2.org
new file mode 100644
index 0000000000..9f39933790
--- /dev/null
+++ b/src/lib/libcrypto/md2/md2.org
@@ -0,0 +1,106 @@
1/* crypto/md/md2.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify md2.org since md2.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67
68#ifndef HEADER_MD2_H
69#define HEADER_MD2_H
70
71#ifdef __cplusplus
72extern "C" {
73#endif
74
75#define MD2_DIGEST_LENGTH 16
76#define MD2_BLOCK 16
77
78#define MD2_INT unsigned int
79
80typedef struct MD2state_st
81 {
82 int num;
83 unsigned char data[MD2_BLOCK];
84 MD2_INT cksm[MD2_BLOCK];
85 MD2_INT state[MD2_BLOCK];
86 } MD2_CTX;
87
88#ifndef NOPROTO
89char *MD2_options(void);
90void MD2_Init(MD2_CTX *c);
91void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len);
92void MD2_Final(unsigned char *md, MD2_CTX *c);
93unsigned char *MD2(unsigned char *d, unsigned long n,unsigned char *md);
94#else
95char *MD2_options();
96void MD2_Init();
97void MD2_Update();
98void MD2_Final();
99unsigned char *MD2();
100#endif
101
102#ifdef __cplusplus
103}
104#endif
105
106#endif
diff --git a/src/lib/libcrypto/md5/Makefile.ssl b/src/lib/libcrypto/md5/Makefile.ssl
new file mode 100644
index 0000000000..47e1ce05ca
--- /dev/null
+++ b/src/lib/libcrypto/md5/Makefile.ssl
@@ -0,0 +1,104 @@
1#
2# SSLeay/crypto/md5/Makefile
3#
4
5DIR= md5
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17MD5_ASM_OBJ=
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=md5test.c
23APPS=md5.c
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=md5_dgst.c md5_one.c
27LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
28
29SRC= $(LIBSRC)
30
31EXHEADER= md5.h
32HEADER= md5_locl.h $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 sh $(TOP)/util/ranlib.sh $(LIB)
44 @touch lib
45
46# elf
47asm/mx86-elf.o: asm/mx86unix.cpp
48 $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o
49
50# solaris
51asm/mx86-sol.o: asm/mx86unix.cpp
52 $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s
53 as -o asm/mx86-sol.o asm/mx86-sol.s
54 rm -f asm/mx86-sol.s
55
56# a.out
57asm/mx86-out.o: asm/mx86unix.cpp
58 $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o
59
60# bsdi
61asm/mx86bsdi.o: asm/mx86unix.cpp
62 $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o
63
64asm/mx86unix.cpp:
65 (cd asm; perl md5-586.pl cpp >mx86unix.cpp)
66
67files:
68 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
69
70links:
71 /bin/rm -f Makefile
72 $(TOP)/util/point.sh Makefile.ssl Makefile ;
73 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
74 $(TOP)/util/mklink.sh ../../test $(TEST)
75 $(TOP)/util/mklink.sh ../../apps $(APPS)
76
77install:
78 @for i in $(EXHEADER) ; \
79 do \
80 (cp $$i $(INSTALLTOP)/include/$$i; \
81 chmod 644 $(INSTALLTOP)/include/$$i ); \
82 done;
83
84tags:
85 ctags $(SRC)
86
87tests:
88
89lint:
90 lint -DLINT $(INCLUDES) $(SRC)>fluff
91
92depend:
93 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
94
95dclean:
96 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
97 mv -f Makefile.new $(MAKEFILE)
98
99clean:
100 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
101
102errors:
103
104# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/md5/Makefile.uni b/src/lib/libcrypto/md5/Makefile.uni
new file mode 100644
index 0000000000..54685712db
--- /dev/null
+++ b/src/lib/libcrypto/md5/Makefile.uni
@@ -0,0 +1,109 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= md5
11TOP= .
12CC= gcc
13CFLAG= -O3 -fomit-frame-pointer
14
15CPP= $(CC) -E
16INCLUDES=
17INSTALLTOP=/usr/local/lib
18MAKE= make
19MAKEDEPEND= makedepend
20MAKEFILE= Makefile.uni
21AR= ar r
22
23MD5_ASM_OBJ=
24
25CFLAGS= $(INCLUDES) $(CFLAG)
26
27GENERAL=Makefile
28TEST=md5test
29APPS=md5
30
31LIB=libmd5.a
32LIBSRC=md5_dgst.c md5_one.c
33LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
34
35SRC= $(LIBSRC)
36
37EXHEADER= md5.h
38HEADER= md5_locl.h $(EXHEADER)
39
40ALL= $(GENERAL) $(SRC) $(HEADER)
41
42all: $(LIB) $(TEST) $(APPS)
43
44$(LIB): $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 sh $(TOP)/ranlib.sh $(LIB)
47
48# elf
49asm/mx86-elf.o: asm/mx86unix.cpp
50 $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o
51
52# solaris
53asm/mx86-sol.o: asm/mx86unix.cpp
54 $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s
55 as -o asm/mx86-sol.o asm/mx86-sol.s
56 rm -f asm/mx86-sol.s
57
58# a.out
59asm/mx86-out.o: asm/mx86unix.cpp
60 $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o
61
62# bsdi
63asm/mx86bsdi.o: asm/mx86unix.cpp
64 $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o
65
66asm/mx86unix.cpp:
67 (cd asm; perl md5-586.pl cpp >mx86unix.cpp)
68
69test: $(TEST)
70 ./$(TEST)
71
72$(TEST): $(TEST).c $(LIB)
73 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
74
75$(APPS): $(APPS).c $(LIB)
76 $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
77
78lint:
79 lint -DLINT $(INCLUDES) $(SRC)>fluff
80
81depend:
82 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
83
84dclean:
85 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
86 mv -f Makefile.new $(MAKEFILE)
87
88clean:
89 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
90
91cc:
92 $(MAKE) MD5_ASM_OBJ="" CC="cc" CFLAG="-O" all
93
94gcc:
95 $(MAKE) MD5_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
96
97x86-elf:
98 $(MAKE) MD5_ASM_OBJ="asm/mx86-elf.o" CFLAG="-DELF -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
99
100x86-out:
101 $(MAKE) MD5_ASM_OBJ="asm/mx86-out.o" CFLAG="-DOUT -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
102
103x86-solaris:
104 $(MAKE) MD5_ASM_OBJ="asm/mx86-sol.o" CFLAG="-DSOL -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
105
106x86-bdsi:
107 $(MAKE) MD5_ASM_OBJ="asm/mx86-bdsi.o" CFLAG="-DBDSI -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
108
109# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/md5/asm/m5-win32.asm b/src/lib/libcrypto/md5/asm/m5-win32.asm
new file mode 100644
index 0000000000..c2081da746
--- /dev/null
+++ b/src/lib/libcrypto/md5/asm/m5-win32.asm
@@ -0,0 +1,686 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by md5-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE md5-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _md5_block_x86
12
13_md5_block_x86 PROC NEAR
14 push esi
15 push edi
16 mov edi, DWORD PTR 12[esp]
17 mov esi, DWORD PTR 16[esp]
18 mov ecx, DWORD PTR 20[esp]
19 push ebp
20 push ebx
21 add ecx, esi
22 sub ecx, 64
23 mov eax, DWORD PTR [edi]
24 push ecx
25 mov ebx, DWORD PTR 4[edi]
26 mov ecx, DWORD PTR 8[edi]
27 mov edx, DWORD PTR 12[edi]
28L000start:
29 ;
30 ; R0 section
31 mov edi, ecx
32 mov ebp, DWORD PTR [esi]
33 ; R0 0
34 xor edi, edx
35 and edi, ebx
36 lea eax, DWORD PTR 3614090360[ebp*1+eax]
37 mov ebp, DWORD PTR 4[esi]
38 xor edi, edx
39 add eax, edi
40 mov edi, ebx
41 rol eax, 7
42 add eax, ebx
43 ; R0 1
44 xor edi, ecx
45 and edi, eax
46 lea edx, DWORD PTR 3905402710[ebp*1+edx]
47 mov ebp, DWORD PTR 8[esi]
48 xor edi, ecx
49 add edx, edi
50 mov edi, eax
51 rol edx, 12
52 add edx, eax
53 ; R0 2
54 xor edi, ebx
55 and edi, edx
56 lea ecx, DWORD PTR 606105819[ebp*1+ecx]
57 mov ebp, DWORD PTR 12[esi]
58 xor edi, ebx
59 add ecx, edi
60 mov edi, edx
61 rol ecx, 17
62 add ecx, edx
63 ; R0 3
64 xor edi, eax
65 and edi, ecx
66 lea ebx, DWORD PTR 3250441966[ebp*1+ebx]
67 mov ebp, DWORD PTR 16[esi]
68 xor edi, eax
69 add ebx, edi
70 mov edi, ecx
71 rol ebx, 22
72 add ebx, ecx
73 ; R0 4
74 xor edi, edx
75 and edi, ebx
76 lea eax, DWORD PTR 4118548399[ebp*1+eax]
77 mov ebp, DWORD PTR 20[esi]
78 xor edi, edx
79 add eax, edi
80 mov edi, ebx
81 rol eax, 7
82 add eax, ebx
83 ; R0 5
84 xor edi, ecx
85 and edi, eax
86 lea edx, DWORD PTR 1200080426[ebp*1+edx]
87 mov ebp, DWORD PTR 24[esi]
88 xor edi, ecx
89 add edx, edi
90 mov edi, eax
91 rol edx, 12
92 add edx, eax
93 ; R0 6
94 xor edi, ebx
95 and edi, edx
96 lea ecx, DWORD PTR 2821735955[ebp*1+ecx]
97 mov ebp, DWORD PTR 28[esi]
98 xor edi, ebx
99 add ecx, edi
100 mov edi, edx
101 rol ecx, 17
102 add ecx, edx
103 ; R0 7
104 xor edi, eax
105 and edi, ecx
106 lea ebx, DWORD PTR 4249261313[ebp*1+ebx]
107 mov ebp, DWORD PTR 32[esi]
108 xor edi, eax
109 add ebx, edi
110 mov edi, ecx
111 rol ebx, 22
112 add ebx, ecx
113 ; R0 8
114 xor edi, edx
115 and edi, ebx
116 lea eax, DWORD PTR 1770035416[ebp*1+eax]
117 mov ebp, DWORD PTR 36[esi]
118 xor edi, edx
119 add eax, edi
120 mov edi, ebx
121 rol eax, 7
122 add eax, ebx
123 ; R0 9
124 xor edi, ecx
125 and edi, eax
126 lea edx, DWORD PTR 2336552879[ebp*1+edx]
127 mov ebp, DWORD PTR 40[esi]
128 xor edi, ecx
129 add edx, edi
130 mov edi, eax
131 rol edx, 12
132 add edx, eax
133 ; R0 10
134 xor edi, ebx
135 and edi, edx
136 lea ecx, DWORD PTR 4294925233[ebp*1+ecx]
137 mov ebp, DWORD PTR 44[esi]
138 xor edi, ebx
139 add ecx, edi
140 mov edi, edx
141 rol ecx, 17
142 add ecx, edx
143 ; R0 11
144 xor edi, eax
145 and edi, ecx
146 lea ebx, DWORD PTR 2304563134[ebp*1+ebx]
147 mov ebp, DWORD PTR 48[esi]
148 xor edi, eax
149 add ebx, edi
150 mov edi, ecx
151 rol ebx, 22
152 add ebx, ecx
153 ; R0 12
154 xor edi, edx
155 and edi, ebx
156 lea eax, DWORD PTR 1804603682[ebp*1+eax]
157 mov ebp, DWORD PTR 52[esi]
158 xor edi, edx
159 add eax, edi
160 mov edi, ebx
161 rol eax, 7
162 add eax, ebx
163 ; R0 13
164 xor edi, ecx
165 and edi, eax
166 lea edx, DWORD PTR 4254626195[ebp*1+edx]
167 mov ebp, DWORD PTR 56[esi]
168 xor edi, ecx
169 add edx, edi
170 mov edi, eax
171 rol edx, 12
172 add edx, eax
173 ; R0 14
174 xor edi, ebx
175 and edi, edx
176 lea ecx, DWORD PTR 2792965006[ebp*1+ecx]
177 mov ebp, DWORD PTR 60[esi]
178 xor edi, ebx
179 add ecx, edi
180 mov edi, edx
181 rol ecx, 17
182 add ecx, edx
183 ; R0 15
184 xor edi, eax
185 and edi, ecx
186 lea ebx, DWORD PTR 1236535329[ebp*1+ebx]
187 mov ebp, DWORD PTR 4[esi]
188 xor edi, eax
189 add ebx, edi
190 mov edi, ecx
191 rol ebx, 22
192 add ebx, ecx
193 ;
194 ; R1 section
195 ; R1 16
196 lea eax, DWORD PTR 4129170786[ebp*1+eax]
197 xor edi, ebx
198 and edi, edx
199 mov ebp, DWORD PTR 24[esi]
200 xor edi, ecx
201 add eax, edi
202 mov edi, ebx
203 rol eax, 5
204 add eax, ebx
205 ; R1 17
206 lea edx, DWORD PTR 3225465664[ebp*1+edx]
207 xor edi, eax
208 and edi, ecx
209 mov ebp, DWORD PTR 44[esi]
210 xor edi, ebx
211 add edx, edi
212 mov edi, eax
213 rol edx, 9
214 add edx, eax
215 ; R1 18
216 lea ecx, DWORD PTR 643717713[ebp*1+ecx]
217 xor edi, edx
218 and edi, ebx
219 mov ebp, DWORD PTR [esi]
220 xor edi, eax
221 add ecx, edi
222 mov edi, edx
223 rol ecx, 14
224 add ecx, edx
225 ; R1 19
226 lea ebx, DWORD PTR 3921069994[ebp*1+ebx]
227 xor edi, ecx
228 and edi, eax
229 mov ebp, DWORD PTR 20[esi]
230 xor edi, edx
231 add ebx, edi
232 mov edi, ecx
233 rol ebx, 20
234 add ebx, ecx
235 ; R1 20
236 lea eax, DWORD PTR 3593408605[ebp*1+eax]
237 xor edi, ebx
238 and edi, edx
239 mov ebp, DWORD PTR 40[esi]
240 xor edi, ecx
241 add eax, edi
242 mov edi, ebx
243 rol eax, 5
244 add eax, ebx
245 ; R1 21
246 lea edx, DWORD PTR 38016083[ebp*1+edx]
247 xor edi, eax
248 and edi, ecx
249 mov ebp, DWORD PTR 60[esi]
250 xor edi, ebx
251 add edx, edi
252 mov edi, eax
253 rol edx, 9
254 add edx, eax
255 ; R1 22
256 lea ecx, DWORD PTR 3634488961[ebp*1+ecx]
257 xor edi, edx
258 and edi, ebx
259 mov ebp, DWORD PTR 16[esi]
260 xor edi, eax
261 add ecx, edi
262 mov edi, edx
263 rol ecx, 14
264 add ecx, edx
265 ; R1 23
266 lea ebx, DWORD PTR 3889429448[ebp*1+ebx]
267 xor edi, ecx
268 and edi, eax
269 mov ebp, DWORD PTR 36[esi]
270 xor edi, edx
271 add ebx, edi
272 mov edi, ecx
273 rol ebx, 20
274 add ebx, ecx
275 ; R1 24
276 lea eax, DWORD PTR 568446438[ebp*1+eax]
277 xor edi, ebx
278 and edi, edx
279 mov ebp, DWORD PTR 56[esi]
280 xor edi, ecx
281 add eax, edi
282 mov edi, ebx
283 rol eax, 5
284 add eax, ebx
285 ; R1 25
286 lea edx, DWORD PTR 3275163606[ebp*1+edx]
287 xor edi, eax
288 and edi, ecx
289 mov ebp, DWORD PTR 12[esi]
290 xor edi, ebx
291 add edx, edi
292 mov edi, eax
293 rol edx, 9
294 add edx, eax
295 ; R1 26
296 lea ecx, DWORD PTR 4107603335[ebp*1+ecx]
297 xor edi, edx
298 and edi, ebx
299 mov ebp, DWORD PTR 32[esi]
300 xor edi, eax
301 add ecx, edi
302 mov edi, edx
303 rol ecx, 14
304 add ecx, edx
305 ; R1 27
306 lea ebx, DWORD PTR 1163531501[ebp*1+ebx]
307 xor edi, ecx
308 and edi, eax
309 mov ebp, DWORD PTR 52[esi]
310 xor edi, edx
311 add ebx, edi
312 mov edi, ecx
313 rol ebx, 20
314 add ebx, ecx
315 ; R1 28
316 lea eax, DWORD PTR 2850285829[ebp*1+eax]
317 xor edi, ebx
318 and edi, edx
319 mov ebp, DWORD PTR 8[esi]
320 xor edi, ecx
321 add eax, edi
322 mov edi, ebx
323 rol eax, 5
324 add eax, ebx
325 ; R1 29
326 lea edx, DWORD PTR 4243563512[ebp*1+edx]
327 xor edi, eax
328 and edi, ecx
329 mov ebp, DWORD PTR 28[esi]
330 xor edi, ebx
331 add edx, edi
332 mov edi, eax
333 rol edx, 9
334 add edx, eax
335 ; R1 30
336 lea ecx, DWORD PTR 1735328473[ebp*1+ecx]
337 xor edi, edx
338 and edi, ebx
339 mov ebp, DWORD PTR 48[esi]
340 xor edi, eax
341 add ecx, edi
342 mov edi, edx
343 rol ecx, 14
344 add ecx, edx
345 ; R1 31
346 lea ebx, DWORD PTR 2368359562[ebp*1+ebx]
347 xor edi, ecx
348 and edi, eax
349 mov ebp, DWORD PTR 20[esi]
350 xor edi, edx
351 add ebx, edi
352 mov edi, ecx
353 rol ebx, 20
354 add ebx, ecx
355 ;
356 ; R2 section
357 ; R2 32
358 xor edi, edx
359 xor edi, ebx
360 lea eax, DWORD PTR 4294588738[ebp*1+eax]
361 add eax, edi
362 mov ebp, DWORD PTR 32[esi]
363 rol eax, 4
364 mov edi, ebx
365 ; R2 33
366 lea edx, DWORD PTR 2272392833[ebp*1+edx]
367 add eax, ebx
368 xor edi, ecx
369 xor edi, eax
370 mov ebp, DWORD PTR 44[esi]
371 add edx, edi
372 mov edi, eax
373 rol edx, 11
374 add edx, eax
375 ; R2 34
376 xor edi, ebx
377 xor edi, edx
378 lea ecx, DWORD PTR 1839030562[ebp*1+ecx]
379 add ecx, edi
380 mov ebp, DWORD PTR 56[esi]
381 rol ecx, 16
382 mov edi, edx
383 ; R2 35
384 lea ebx, DWORD PTR 4259657740[ebp*1+ebx]
385 add ecx, edx
386 xor edi, eax
387 xor edi, ecx
388 mov ebp, DWORD PTR 4[esi]
389 add ebx, edi
390 mov edi, ecx
391 rol ebx, 23
392 add ebx, ecx
393 ; R2 36
394 xor edi, edx
395 xor edi, ebx
396 lea eax, DWORD PTR 2763975236[ebp*1+eax]
397 add eax, edi
398 mov ebp, DWORD PTR 16[esi]
399 rol eax, 4
400 mov edi, ebx
401 ; R2 37
402 lea edx, DWORD PTR 1272893353[ebp*1+edx]
403 add eax, ebx
404 xor edi, ecx
405 xor edi, eax
406 mov ebp, DWORD PTR 28[esi]
407 add edx, edi
408 mov edi, eax
409 rol edx, 11
410 add edx, eax
411 ; R2 38
412 xor edi, ebx
413 xor edi, edx
414 lea ecx, DWORD PTR 4139469664[ebp*1+ecx]
415 add ecx, edi
416 mov ebp, DWORD PTR 40[esi]
417 rol ecx, 16
418 mov edi, edx
419 ; R2 39
420 lea ebx, DWORD PTR 3200236656[ebp*1+ebx]
421 add ecx, edx
422 xor edi, eax
423 xor edi, ecx
424 mov ebp, DWORD PTR 52[esi]
425 add ebx, edi
426 mov edi, ecx
427 rol ebx, 23
428 add ebx, ecx
429 ; R2 40
430 xor edi, edx
431 xor edi, ebx
432 lea eax, DWORD PTR 681279174[ebp*1+eax]
433 add eax, edi
434 mov ebp, DWORD PTR [esi]
435 rol eax, 4
436 mov edi, ebx
437 ; R2 41
438 lea edx, DWORD PTR 3936430074[ebp*1+edx]
439 add eax, ebx
440 xor edi, ecx
441 xor edi, eax
442 mov ebp, DWORD PTR 12[esi]
443 add edx, edi
444 mov edi, eax
445 rol edx, 11
446 add edx, eax
447 ; R2 42
448 xor edi, ebx
449 xor edi, edx
450 lea ecx, DWORD PTR 3572445317[ebp*1+ecx]
451 add ecx, edi
452 mov ebp, DWORD PTR 24[esi]
453 rol ecx, 16
454 mov edi, edx
455 ; R2 43
456 lea ebx, DWORD PTR 76029189[ebp*1+ebx]
457 add ecx, edx
458 xor edi, eax
459 xor edi, ecx
460 mov ebp, DWORD PTR 36[esi]
461 add ebx, edi
462 mov edi, ecx
463 rol ebx, 23
464 add ebx, ecx
465 ; R2 44
466 xor edi, edx
467 xor edi, ebx
468 lea eax, DWORD PTR 3654602809[ebp*1+eax]
469 add eax, edi
470 mov ebp, DWORD PTR 48[esi]
471 rol eax, 4
472 mov edi, ebx
473 ; R2 45
474 lea edx, DWORD PTR 3873151461[ebp*1+edx]
475 add eax, ebx
476 xor edi, ecx
477 xor edi, eax
478 mov ebp, DWORD PTR 60[esi]
479 add edx, edi
480 mov edi, eax
481 rol edx, 11
482 add edx, eax
483 ; R2 46
484 xor edi, ebx
485 xor edi, edx
486 lea ecx, DWORD PTR 530742520[ebp*1+ecx]
487 add ecx, edi
488 mov ebp, DWORD PTR 8[esi]
489 rol ecx, 16
490 mov edi, edx
491 ; R2 47
492 lea ebx, DWORD PTR 3299628645[ebp*1+ebx]
493 add ecx, edx
494 xor edi, eax
495 xor edi, ecx
496 mov ebp, DWORD PTR [esi]
497 add ebx, edi
498 mov edi, -1
499 rol ebx, 23
500 add ebx, ecx
501 ;
502 ; R3 section
503 ; R3 48
504 xor edi, edx
505 or edi, ebx
506 lea eax, DWORD PTR 4096336452[ebp*1+eax]
507 xor edi, ecx
508 mov ebp, DWORD PTR 28[esi]
509 add eax, edi
510 mov edi, -1
511 rol eax, 6
512 xor edi, ecx
513 add eax, ebx
514 ; R3 49
515 or edi, eax
516 lea edx, DWORD PTR 1126891415[ebp*1+edx]
517 xor edi, ebx
518 mov ebp, DWORD PTR 56[esi]
519 add edx, edi
520 mov edi, -1
521 rol edx, 10
522 xor edi, ebx
523 add edx, eax
524 ; R3 50
525 or edi, edx
526 lea ecx, DWORD PTR 2878612391[ebp*1+ecx]
527 xor edi, eax
528 mov ebp, DWORD PTR 20[esi]
529 add ecx, edi
530 mov edi, -1
531 rol ecx, 15
532 xor edi, eax
533 add ecx, edx
534 ; R3 51
535 or edi, ecx
536 lea ebx, DWORD PTR 4237533241[ebp*1+ebx]
537 xor edi, edx
538 mov ebp, DWORD PTR 48[esi]
539 add ebx, edi
540 mov edi, -1
541 rol ebx, 21
542 xor edi, edx
543 add ebx, ecx
544 ; R3 52
545 or edi, ebx
546 lea eax, DWORD PTR 1700485571[ebp*1+eax]
547 xor edi, ecx
548 mov ebp, DWORD PTR 12[esi]
549 add eax, edi
550 mov edi, -1
551 rol eax, 6
552 xor edi, ecx
553 add eax, ebx
554 ; R3 53
555 or edi, eax
556 lea edx, DWORD PTR 2399980690[ebp*1+edx]
557 xor edi, ebx
558 mov ebp, DWORD PTR 40[esi]
559 add edx, edi
560 mov edi, -1
561 rol edx, 10
562 xor edi, ebx
563 add edx, eax
564 ; R3 54
565 or edi, edx
566 lea ecx, DWORD PTR 4293915773[ebp*1+ecx]
567 xor edi, eax
568 mov ebp, DWORD PTR 4[esi]
569 add ecx, edi
570 mov edi, -1
571 rol ecx, 15
572 xor edi, eax
573 add ecx, edx
574 ; R3 55
575 or edi, ecx
576 lea ebx, DWORD PTR 2240044497[ebp*1+ebx]
577 xor edi, edx
578 mov ebp, DWORD PTR 32[esi]
579 add ebx, edi
580 mov edi, -1
581 rol ebx, 21
582 xor edi, edx
583 add ebx, ecx
584 ; R3 56
585 or edi, ebx
586 lea eax, DWORD PTR 1873313359[ebp*1+eax]
587 xor edi, ecx
588 mov ebp, DWORD PTR 60[esi]
589 add eax, edi
590 mov edi, -1
591 rol eax, 6
592 xor edi, ecx
593 add eax, ebx
594 ; R3 57
595 or edi, eax
596 lea edx, DWORD PTR 4264355552[ebp*1+edx]
597 xor edi, ebx
598 mov ebp, DWORD PTR 24[esi]
599 add edx, edi
600 mov edi, -1
601 rol edx, 10
602 xor edi, ebx
603 add edx, eax
604 ; R3 58
605 or edi, edx
606 lea ecx, DWORD PTR 2734768916[ebp*1+ecx]
607 xor edi, eax
608 mov ebp, DWORD PTR 52[esi]
609 add ecx, edi
610 mov edi, -1
611 rol ecx, 15
612 xor edi, eax
613 add ecx, edx
614 ; R3 59
615 or edi, ecx
616 lea ebx, DWORD PTR 1309151649[ebp*1+ebx]
617 xor edi, edx
618 mov ebp, DWORD PTR 16[esi]
619 add ebx, edi
620 mov edi, -1
621 rol ebx, 21
622 xor edi, edx
623 add ebx, ecx
624 ; R3 60
625 or edi, ebx
626 lea eax, DWORD PTR 4149444226[ebp*1+eax]
627 xor edi, ecx
628 mov ebp, DWORD PTR 44[esi]
629 add eax, edi
630 mov edi, -1
631 rol eax, 6
632 xor edi, ecx
633 add eax, ebx
634 ; R3 61
635 or edi, eax
636 lea edx, DWORD PTR 3174756917[ebp*1+edx]
637 xor edi, ebx
638 mov ebp, DWORD PTR 8[esi]
639 add edx, edi
640 mov edi, -1
641 rol edx, 10
642 xor edi, ebx
643 add edx, eax
644 ; R3 62
645 or edi, edx
646 lea ecx, DWORD PTR 718787259[ebp*1+ecx]
647 xor edi, eax
648 mov ebp, DWORD PTR 36[esi]
649 add ecx, edi
650 mov edi, -1
651 rol ecx, 15
652 xor edi, eax
653 add ecx, edx
654 ; R3 63
655 or edi, ecx
656 lea ebx, DWORD PTR 3951481745[ebp*1+ebx]
657 xor edi, edx
658 mov ebp, DWORD PTR 24[esp]
659 add ebx, edi
660 add esi, 64
661 rol ebx, 21
662 mov edi, DWORD PTR [ebp]
663 add ebx, ecx
664 add eax, edi
665 mov edi, DWORD PTR 4[ebp]
666 add ebx, edi
667 mov edi, DWORD PTR 8[ebp]
668 add ecx, edi
669 mov edi, DWORD PTR 12[ebp]
670 add edx, edi
671 mov DWORD PTR [ebp],eax
672 mov DWORD PTR 4[ebp],ebx
673 mov edi, DWORD PTR [esp]
674 mov DWORD PTR 8[ebp],ecx
675 mov DWORD PTR 12[ebp],edx
676 cmp edi, esi
677 jge L000start
678 pop eax
679 pop ebx
680 pop ebp
681 pop edi
682 pop esi
683 ret
684_md5_block_x86 ENDP
685_TEXT ENDS
686END
diff --git a/src/lib/libcrypto/md5/asm/mx86unix.cpp b/src/lib/libcrypto/md5/asm/mx86unix.cpp
new file mode 100644
index 0000000000..5d399122b6
--- /dev/null
+++ b/src/lib/libcrypto/md5/asm/mx86unix.cpp
@@ -0,0 +1,730 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define md5_block_x86 _md5_block_x86
13
14#endif
15
16#ifdef OUT
17#define OK 1
18#define ALIGN 4
19#endif
20
21#ifdef BSDI
22#define OK 1
23#define ALIGN 4
24#undef SIZE
25#undef TYPE
26#define SIZE(a,b)
27#define TYPE(a,b)
28#endif
29
30#if defined(ELF) || defined(SOL)
31#define OK 1
32#define ALIGN 16
33#endif
34
35#ifndef OK
36You need to define one of
37ELF - elf systems - linux-elf, NetBSD and DG-UX
38OUT - a.out systems - linux-a.out and FreeBSD
39SOL - solaris systems, which are elf with strange comment lines
40BSDI - a.out with a very primative version of as.
41#endif
42
43/* Let the Assembler begin :-) */
44 /* Don't even think of reading this code */
45 /* It was automatically generated by md5-586.pl */
46 /* Which is a perl program used to generate the x86 assember for */
47 /* any of elf, a.out, BSDI,Win32, or Solaris */
48 /* eric <eay@cryptsoft.com> */
49
50 .file "md5-586.s"
51 .version "01.01"
52gcc2_compiled.:
53.text
54 .align ALIGN
55.globl md5_block_x86
56 TYPE(md5_block_x86,@function)
57md5_block_x86:
58 pushl %esi
59 pushl %edi
60 movl 12(%esp), %edi
61 movl 16(%esp), %esi
62 movl 20(%esp), %ecx
63 pushl %ebp
64 pushl %ebx
65 addl %esi, %ecx
66 subl $64, %ecx
67 movl (%edi), %eax
68 pushl %ecx
69 movl 4(%edi), %ebx
70 movl 8(%edi), %ecx
71 movl 12(%edi), %edx
72.L000start:
73
74 /* R0 section */
75 movl %ecx, %edi
76 movl (%esi), %ebp
77 /* R0 0 */
78 xorl %edx, %edi
79 andl %ebx, %edi
80 leal 3614090360(%eax,%ebp,1),%eax
81 movl 4(%esi), %ebp
82 xorl %edx, %edi
83 addl %edi, %eax
84 movl %ebx, %edi
85 roll $7, %eax
86 addl %ebx, %eax
87 /* R0 1 */
88 xorl %ecx, %edi
89 andl %eax, %edi
90 leal 3905402710(%edx,%ebp,1),%edx
91 movl 8(%esi), %ebp
92 xorl %ecx, %edi
93 addl %edi, %edx
94 movl %eax, %edi
95 roll $12, %edx
96 addl %eax, %edx
97 /* R0 2 */
98 xorl %ebx, %edi
99 andl %edx, %edi
100 leal 606105819(%ecx,%ebp,1),%ecx
101 movl 12(%esi), %ebp
102 xorl %ebx, %edi
103 addl %edi, %ecx
104 movl %edx, %edi
105 roll $17, %ecx
106 addl %edx, %ecx
107 /* R0 3 */
108 xorl %eax, %edi
109 andl %ecx, %edi
110 leal 3250441966(%ebx,%ebp,1),%ebx
111 movl 16(%esi), %ebp
112 xorl %eax, %edi
113 addl %edi, %ebx
114 movl %ecx, %edi
115 roll $22, %ebx
116 addl %ecx, %ebx
117 /* R0 4 */
118 xorl %edx, %edi
119 andl %ebx, %edi
120 leal 4118548399(%eax,%ebp,1),%eax
121 movl 20(%esi), %ebp
122 xorl %edx, %edi
123 addl %edi, %eax
124 movl %ebx, %edi
125 roll $7, %eax
126 addl %ebx, %eax
127 /* R0 5 */
128 xorl %ecx, %edi
129 andl %eax, %edi
130 leal 1200080426(%edx,%ebp,1),%edx
131 movl 24(%esi), %ebp
132 xorl %ecx, %edi
133 addl %edi, %edx
134 movl %eax, %edi
135 roll $12, %edx
136 addl %eax, %edx
137 /* R0 6 */
138 xorl %ebx, %edi
139 andl %edx, %edi
140 leal 2821735955(%ecx,%ebp,1),%ecx
141 movl 28(%esi), %ebp
142 xorl %ebx, %edi
143 addl %edi, %ecx
144 movl %edx, %edi
145 roll $17, %ecx
146 addl %edx, %ecx
147 /* R0 7 */
148 xorl %eax, %edi
149 andl %ecx, %edi
150 leal 4249261313(%ebx,%ebp,1),%ebx
151 movl 32(%esi), %ebp
152 xorl %eax, %edi
153 addl %edi, %ebx
154 movl %ecx, %edi
155 roll $22, %ebx
156 addl %ecx, %ebx
157 /* R0 8 */
158 xorl %edx, %edi
159 andl %ebx, %edi
160 leal 1770035416(%eax,%ebp,1),%eax
161 movl 36(%esi), %ebp
162 xorl %edx, %edi
163 addl %edi, %eax
164 movl %ebx, %edi
165 roll $7, %eax
166 addl %ebx, %eax
167 /* R0 9 */
168 xorl %ecx, %edi
169 andl %eax, %edi
170 leal 2336552879(%edx,%ebp,1),%edx
171 movl 40(%esi), %ebp
172 xorl %ecx, %edi
173 addl %edi, %edx
174 movl %eax, %edi
175 roll $12, %edx
176 addl %eax, %edx
177 /* R0 10 */
178 xorl %ebx, %edi
179 andl %edx, %edi
180 leal 4294925233(%ecx,%ebp,1),%ecx
181 movl 44(%esi), %ebp
182 xorl %ebx, %edi
183 addl %edi, %ecx
184 movl %edx, %edi
185 roll $17, %ecx
186 addl %edx, %ecx
187 /* R0 11 */
188 xorl %eax, %edi
189 andl %ecx, %edi
190 leal 2304563134(%ebx,%ebp,1),%ebx
191 movl 48(%esi), %ebp
192 xorl %eax, %edi
193 addl %edi, %ebx
194 movl %ecx, %edi
195 roll $22, %ebx
196 addl %ecx, %ebx
197 /* R0 12 */
198 xorl %edx, %edi
199 andl %ebx, %edi
200 leal 1804603682(%eax,%ebp,1),%eax
201 movl 52(%esi), %ebp
202 xorl %edx, %edi
203 addl %edi, %eax
204 movl %ebx, %edi
205 roll $7, %eax
206 addl %ebx, %eax
207 /* R0 13 */
208 xorl %ecx, %edi
209 andl %eax, %edi
210 leal 4254626195(%edx,%ebp,1),%edx
211 movl 56(%esi), %ebp
212 xorl %ecx, %edi
213 addl %edi, %edx
214 movl %eax, %edi
215 roll $12, %edx
216 addl %eax, %edx
217 /* R0 14 */
218 xorl %ebx, %edi
219 andl %edx, %edi
220 leal 2792965006(%ecx,%ebp,1),%ecx
221 movl 60(%esi), %ebp
222 xorl %ebx, %edi
223 addl %edi, %ecx
224 movl %edx, %edi
225 roll $17, %ecx
226 addl %edx, %ecx
227 /* R0 15 */
228 xorl %eax, %edi
229 andl %ecx, %edi
230 leal 1236535329(%ebx,%ebp,1),%ebx
231 movl 4(%esi), %ebp
232 xorl %eax, %edi
233 addl %edi, %ebx
234 movl %ecx, %edi
235 roll $22, %ebx
236 addl %ecx, %ebx
237
238 /* R1 section */
239 /* R1 16 */
240 leal 4129170786(%eax,%ebp,1),%eax
241 xorl %ebx, %edi
242 andl %edx, %edi
243 movl 24(%esi), %ebp
244 xorl %ecx, %edi
245 addl %edi, %eax
246 movl %ebx, %edi
247 roll $5, %eax
248 addl %ebx, %eax
249 /* R1 17 */
250 leal 3225465664(%edx,%ebp,1),%edx
251 xorl %eax, %edi
252 andl %ecx, %edi
253 movl 44(%esi), %ebp
254 xorl %ebx, %edi
255 addl %edi, %edx
256 movl %eax, %edi
257 roll $9, %edx
258 addl %eax, %edx
259 /* R1 18 */
260 leal 643717713(%ecx,%ebp,1),%ecx
261 xorl %edx, %edi
262 andl %ebx, %edi
263 movl (%esi), %ebp
264 xorl %eax, %edi
265 addl %edi, %ecx
266 movl %edx, %edi
267 roll $14, %ecx
268 addl %edx, %ecx
269 /* R1 19 */
270 leal 3921069994(%ebx,%ebp,1),%ebx
271 xorl %ecx, %edi
272 andl %eax, %edi
273 movl 20(%esi), %ebp
274 xorl %edx, %edi
275 addl %edi, %ebx
276 movl %ecx, %edi
277 roll $20, %ebx
278 addl %ecx, %ebx
279 /* R1 20 */
280 leal 3593408605(%eax,%ebp,1),%eax
281 xorl %ebx, %edi
282 andl %edx, %edi
283 movl 40(%esi), %ebp
284 xorl %ecx, %edi
285 addl %edi, %eax
286 movl %ebx, %edi
287 roll $5, %eax
288 addl %ebx, %eax
289 /* R1 21 */
290 leal 38016083(%edx,%ebp,1),%edx
291 xorl %eax, %edi
292 andl %ecx, %edi
293 movl 60(%esi), %ebp
294 xorl %ebx, %edi
295 addl %edi, %edx
296 movl %eax, %edi
297 roll $9, %edx
298 addl %eax, %edx
299 /* R1 22 */
300 leal 3634488961(%ecx,%ebp,1),%ecx
301 xorl %edx, %edi
302 andl %ebx, %edi
303 movl 16(%esi), %ebp
304 xorl %eax, %edi
305 addl %edi, %ecx
306 movl %edx, %edi
307 roll $14, %ecx
308 addl %edx, %ecx
309 /* R1 23 */
310 leal 3889429448(%ebx,%ebp,1),%ebx
311 xorl %ecx, %edi
312 andl %eax, %edi
313 movl 36(%esi), %ebp
314 xorl %edx, %edi
315 addl %edi, %ebx
316 movl %ecx, %edi
317 roll $20, %ebx
318 addl %ecx, %ebx
319 /* R1 24 */
320 leal 568446438(%eax,%ebp,1),%eax
321 xorl %ebx, %edi
322 andl %edx, %edi
323 movl 56(%esi), %ebp
324 xorl %ecx, %edi
325 addl %edi, %eax
326 movl %ebx, %edi
327 roll $5, %eax
328 addl %ebx, %eax
329 /* R1 25 */
330 leal 3275163606(%edx,%ebp,1),%edx
331 xorl %eax, %edi
332 andl %ecx, %edi
333 movl 12(%esi), %ebp
334 xorl %ebx, %edi
335 addl %edi, %edx
336 movl %eax, %edi
337 roll $9, %edx
338 addl %eax, %edx
339 /* R1 26 */
340 leal 4107603335(%ecx,%ebp,1),%ecx
341 xorl %edx, %edi
342 andl %ebx, %edi
343 movl 32(%esi), %ebp
344 xorl %eax, %edi
345 addl %edi, %ecx
346 movl %edx, %edi
347 roll $14, %ecx
348 addl %edx, %ecx
349 /* R1 27 */
350 leal 1163531501(%ebx,%ebp,1),%ebx
351 xorl %ecx, %edi
352 andl %eax, %edi
353 movl 52(%esi), %ebp
354 xorl %edx, %edi
355 addl %edi, %ebx
356 movl %ecx, %edi
357 roll $20, %ebx
358 addl %ecx, %ebx
359 /* R1 28 */
360 leal 2850285829(%eax,%ebp,1),%eax
361 xorl %ebx, %edi
362 andl %edx, %edi
363 movl 8(%esi), %ebp
364 xorl %ecx, %edi
365 addl %edi, %eax
366 movl %ebx, %edi
367 roll $5, %eax
368 addl %ebx, %eax
369 /* R1 29 */
370 leal 4243563512(%edx,%ebp,1),%edx
371 xorl %eax, %edi
372 andl %ecx, %edi
373 movl 28(%esi), %ebp
374 xorl %ebx, %edi
375 addl %edi, %edx
376 movl %eax, %edi
377 roll $9, %edx
378 addl %eax, %edx
379 /* R1 30 */
380 leal 1735328473(%ecx,%ebp,1),%ecx
381 xorl %edx, %edi
382 andl %ebx, %edi
383 movl 48(%esi), %ebp
384 xorl %eax, %edi
385 addl %edi, %ecx
386 movl %edx, %edi
387 roll $14, %ecx
388 addl %edx, %ecx
389 /* R1 31 */
390 leal 2368359562(%ebx,%ebp,1),%ebx
391 xorl %ecx, %edi
392 andl %eax, %edi
393 movl 20(%esi), %ebp
394 xorl %edx, %edi
395 addl %edi, %ebx
396 movl %ecx, %edi
397 roll $20, %ebx
398 addl %ecx, %ebx
399
400 /* R2 section */
401 /* R2 32 */
402 xorl %edx, %edi
403 xorl %ebx, %edi
404 leal 4294588738(%eax,%ebp,1),%eax
405 addl %edi, %eax
406 movl 32(%esi), %ebp
407 roll $4, %eax
408 movl %ebx, %edi
409 /* R2 33 */
410 leal 2272392833(%edx,%ebp,1),%edx
411 addl %ebx, %eax
412 xorl %ecx, %edi
413 xorl %eax, %edi
414 movl 44(%esi), %ebp
415 addl %edi, %edx
416 movl %eax, %edi
417 roll $11, %edx
418 addl %eax, %edx
419 /* R2 34 */
420 xorl %ebx, %edi
421 xorl %edx, %edi
422 leal 1839030562(%ecx,%ebp,1),%ecx
423 addl %edi, %ecx
424 movl 56(%esi), %ebp
425 roll $16, %ecx
426 movl %edx, %edi
427 /* R2 35 */
428 leal 4259657740(%ebx,%ebp,1),%ebx
429 addl %edx, %ecx
430 xorl %eax, %edi
431 xorl %ecx, %edi
432 movl 4(%esi), %ebp
433 addl %edi, %ebx
434 movl %ecx, %edi
435 roll $23, %ebx
436 addl %ecx, %ebx
437 /* R2 36 */
438 xorl %edx, %edi
439 xorl %ebx, %edi
440 leal 2763975236(%eax,%ebp,1),%eax
441 addl %edi, %eax
442 movl 16(%esi), %ebp
443 roll $4, %eax
444 movl %ebx, %edi
445 /* R2 37 */
446 leal 1272893353(%edx,%ebp,1),%edx
447 addl %ebx, %eax
448 xorl %ecx, %edi
449 xorl %eax, %edi
450 movl 28(%esi), %ebp
451 addl %edi, %edx
452 movl %eax, %edi
453 roll $11, %edx
454 addl %eax, %edx
455 /* R2 38 */
456 xorl %ebx, %edi
457 xorl %edx, %edi
458 leal 4139469664(%ecx,%ebp,1),%ecx
459 addl %edi, %ecx
460 movl 40(%esi), %ebp
461 roll $16, %ecx
462 movl %edx, %edi
463 /* R2 39 */
464 leal 3200236656(%ebx,%ebp,1),%ebx
465 addl %edx, %ecx
466 xorl %eax, %edi
467 xorl %ecx, %edi
468 movl 52(%esi), %ebp
469 addl %edi, %ebx
470 movl %ecx, %edi
471 roll $23, %ebx
472 addl %ecx, %ebx
473 /* R2 40 */
474 xorl %edx, %edi
475 xorl %ebx, %edi
476 leal 681279174(%eax,%ebp,1),%eax
477 addl %edi, %eax
478 movl (%esi), %ebp
479 roll $4, %eax
480 movl %ebx, %edi
481 /* R2 41 */
482 leal 3936430074(%edx,%ebp,1),%edx
483 addl %ebx, %eax
484 xorl %ecx, %edi
485 xorl %eax, %edi
486 movl 12(%esi), %ebp
487 addl %edi, %edx
488 movl %eax, %edi
489 roll $11, %edx
490 addl %eax, %edx
491 /* R2 42 */
492 xorl %ebx, %edi
493 xorl %edx, %edi
494 leal 3572445317(%ecx,%ebp,1),%ecx
495 addl %edi, %ecx
496 movl 24(%esi), %ebp
497 roll $16, %ecx
498 movl %edx, %edi
499 /* R2 43 */
500 leal 76029189(%ebx,%ebp,1),%ebx
501 addl %edx, %ecx
502 xorl %eax, %edi
503 xorl %ecx, %edi
504 movl 36(%esi), %ebp
505 addl %edi, %ebx
506 movl %ecx, %edi
507 roll $23, %ebx
508 addl %ecx, %ebx
509 /* R2 44 */
510 xorl %edx, %edi
511 xorl %ebx, %edi
512 leal 3654602809(%eax,%ebp,1),%eax
513 addl %edi, %eax
514 movl 48(%esi), %ebp
515 roll $4, %eax
516 movl %ebx, %edi
517 /* R2 45 */
518 leal 3873151461(%edx,%ebp,1),%edx
519 addl %ebx, %eax
520 xorl %ecx, %edi
521 xorl %eax, %edi
522 movl 60(%esi), %ebp
523 addl %edi, %edx
524 movl %eax, %edi
525 roll $11, %edx
526 addl %eax, %edx
527 /* R2 46 */
528 xorl %ebx, %edi
529 xorl %edx, %edi
530 leal 530742520(%ecx,%ebp,1),%ecx
531 addl %edi, %ecx
532 movl 8(%esi), %ebp
533 roll $16, %ecx
534 movl %edx, %edi
535 /* R2 47 */
536 leal 3299628645(%ebx,%ebp,1),%ebx
537 addl %edx, %ecx
538 xorl %eax, %edi
539 xorl %ecx, %edi
540 movl (%esi), %ebp
541 addl %edi, %ebx
542 movl $-1, %edi
543 roll $23, %ebx
544 addl %ecx, %ebx
545
546 /* R3 section */
547 /* R3 48 */
548 xorl %edx, %edi
549 orl %ebx, %edi
550 leal 4096336452(%eax,%ebp,1),%eax
551 xorl %ecx, %edi
552 movl 28(%esi), %ebp
553 addl %edi, %eax
554 movl $-1, %edi
555 roll $6, %eax
556 xorl %ecx, %edi
557 addl %ebx, %eax
558 /* R3 49 */
559 orl %eax, %edi
560 leal 1126891415(%edx,%ebp,1),%edx
561 xorl %ebx, %edi
562 movl 56(%esi), %ebp
563 addl %edi, %edx
564 movl $-1, %edi
565 roll $10, %edx
566 xorl %ebx, %edi
567 addl %eax, %edx
568 /* R3 50 */
569 orl %edx, %edi
570 leal 2878612391(%ecx,%ebp,1),%ecx
571 xorl %eax, %edi
572 movl 20(%esi), %ebp
573 addl %edi, %ecx
574 movl $-1, %edi
575 roll $15, %ecx
576 xorl %eax, %edi
577 addl %edx, %ecx
578 /* R3 51 */
579 orl %ecx, %edi
580 leal 4237533241(%ebx,%ebp,1),%ebx
581 xorl %edx, %edi
582 movl 48(%esi), %ebp
583 addl %edi, %ebx
584 movl $-1, %edi
585 roll $21, %ebx
586 xorl %edx, %edi
587 addl %ecx, %ebx
588 /* R3 52 */
589 orl %ebx, %edi
590 leal 1700485571(%eax,%ebp,1),%eax
591 xorl %ecx, %edi
592 movl 12(%esi), %ebp
593 addl %edi, %eax
594 movl $-1, %edi
595 roll $6, %eax
596 xorl %ecx, %edi
597 addl %ebx, %eax
598 /* R3 53 */
599 orl %eax, %edi
600 leal 2399980690(%edx,%ebp,1),%edx
601 xorl %ebx, %edi
602 movl 40(%esi), %ebp
603 addl %edi, %edx
604 movl $-1, %edi
605 roll $10, %edx
606 xorl %ebx, %edi
607 addl %eax, %edx
608 /* R3 54 */
609 orl %edx, %edi
610 leal 4293915773(%ecx,%ebp,1),%ecx
611 xorl %eax, %edi
612 movl 4(%esi), %ebp
613 addl %edi, %ecx
614 movl $-1, %edi
615 roll $15, %ecx
616 xorl %eax, %edi
617 addl %edx, %ecx
618 /* R3 55 */
619 orl %ecx, %edi
620 leal 2240044497(%ebx,%ebp,1),%ebx
621 xorl %edx, %edi
622 movl 32(%esi), %ebp
623 addl %edi, %ebx
624 movl $-1, %edi
625 roll $21, %ebx
626 xorl %edx, %edi
627 addl %ecx, %ebx
628 /* R3 56 */
629 orl %ebx, %edi
630 leal 1873313359(%eax,%ebp,1),%eax
631 xorl %ecx, %edi
632 movl 60(%esi), %ebp
633 addl %edi, %eax
634 movl $-1, %edi
635 roll $6, %eax
636 xorl %ecx, %edi
637 addl %ebx, %eax
638 /* R3 57 */
639 orl %eax, %edi
640 leal 4264355552(%edx,%ebp,1),%edx
641 xorl %ebx, %edi
642 movl 24(%esi), %ebp
643 addl %edi, %edx
644 movl $-1, %edi
645 roll $10, %edx
646 xorl %ebx, %edi
647 addl %eax, %edx
648 /* R3 58 */
649 orl %edx, %edi
650 leal 2734768916(%ecx,%ebp,1),%ecx
651 xorl %eax, %edi
652 movl 52(%esi), %ebp
653 addl %edi, %ecx
654 movl $-1, %edi
655 roll $15, %ecx
656 xorl %eax, %edi
657 addl %edx, %ecx
658 /* R3 59 */
659 orl %ecx, %edi
660 leal 1309151649(%ebx,%ebp,1),%ebx
661 xorl %edx, %edi
662 movl 16(%esi), %ebp
663 addl %edi, %ebx
664 movl $-1, %edi
665 roll $21, %ebx
666 xorl %edx, %edi
667 addl %ecx, %ebx
668 /* R3 60 */
669 orl %ebx, %edi
670 leal 4149444226(%eax,%ebp,1),%eax
671 xorl %ecx, %edi
672 movl 44(%esi), %ebp
673 addl %edi, %eax
674 movl $-1, %edi
675 roll $6, %eax
676 xorl %ecx, %edi
677 addl %ebx, %eax
678 /* R3 61 */
679 orl %eax, %edi
680 leal 3174756917(%edx,%ebp,1),%edx
681 xorl %ebx, %edi
682 movl 8(%esi), %ebp
683 addl %edi, %edx
684 movl $-1, %edi
685 roll $10, %edx
686 xorl %ebx, %edi
687 addl %eax, %edx
688 /* R3 62 */
689 orl %edx, %edi
690 leal 718787259(%ecx,%ebp,1),%ecx
691 xorl %eax, %edi
692 movl 36(%esi), %ebp
693 addl %edi, %ecx
694 movl $-1, %edi
695 roll $15, %ecx
696 xorl %eax, %edi
697 addl %edx, %ecx
698 /* R3 63 */
699 orl %ecx, %edi
700 leal 3951481745(%ebx,%ebp,1),%ebx
701 xorl %edx, %edi
702 movl 24(%esp), %ebp
703 addl %edi, %ebx
704 addl $64, %esi
705 roll $21, %ebx
706 movl (%ebp), %edi
707 addl %ecx, %ebx
708 addl %edi, %eax
709 movl 4(%ebp), %edi
710 addl %edi, %ebx
711 movl 8(%ebp), %edi
712 addl %edi, %ecx
713 movl 12(%ebp), %edi
714 addl %edi, %edx
715 movl %eax, (%ebp)
716 movl %ebx, 4(%ebp)
717 movl (%esp), %edi
718 movl %ecx, 8(%ebp)
719 movl %edx, 12(%ebp)
720 cmpl %esi, %edi
721 jge .L000start
722 popl %eax
723 popl %ebx
724 popl %ebp
725 popl %edi
726 popl %esi
727 ret
728.md5_block_x86_end:
729 SIZE(md5_block_x86,.md5_block_x86_end-md5_block_x86)
730.ident "desasm.pl"
diff --git a/src/lib/libcrypto/mdc2/Makefile.ssl b/src/lib/libcrypto/mdc2/Makefile.ssl
new file mode 100644
index 0000000000..495a2789a0
--- /dev/null
+++ b/src/lib/libcrypto/mdc2/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/mdc2/Makefile
3#
4
5DIR= mdc2
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST= mdc2test.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=mdc2dgst.c mdc2_one.c
24LIBOBJ=mdc2dgst.o mdc2_one.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= mdc2.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/objects/Makefile.ssl b/src/lib/libcrypto/objects/Makefile.ssl
new file mode 100644
index 0000000000..320523cea1
--- /dev/null
+++ b/src/lib/libcrypto/objects/Makefile.ssl
@@ -0,0 +1,87 @@
1#
2# SSLeay/crypto/objects/Makefile
3#
4
5DIR= objects
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=objects
19ERRC=obj_err
20GENERAL=Makefile README
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= obj_dat.c obj_lib.c $(ERRC).c
26LIBOBJ= obj_dat.o obj_lib.o $(ERRC).o
27
28SRC= $(LIBSRC)
29
30EXHEADER= objects.h
31HEADER= $(EXHEADER) obj_dat.h
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: obj_dat.h lib
39
40obj_dat.h: objects.h obj_dat.pl
41 perl ./obj_dat.pl < objects.h > obj_dat.h
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 sh $(TOP)/util/ranlib.sh $(LIB)
46 @touch lib
47
48files:
49 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
50
51links:
52 /bin/rm -f Makefile
53 $(TOP)/util/point.sh Makefile.ssl Makefile ;
54 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
55 $(TOP)/util/mklink.sh ../../test $(TEST)
56 $(TOP)/util/mklink.sh ../../apps $(APPS)
57
58install:
59 @for i in $(EXHEADER) ; \
60 do \
61 (cp $$i $(INSTALLTOP)/include/$$i; \
62 chmod 644 $(INSTALLTOP)/include/$$i ); \
63 done;
64
65tags:
66 ctags $(SRC)
67
68tests:
69
70lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72
73depend:
74 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
75
76dclean:
77 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
78 mv -f Makefile.new $(MAKEFILE)
79
80clean:
81 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
82
83errors:
84 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
85 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
86
87# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/objects/objects.err b/src/lib/libcrypto/objects/objects.err
new file mode 100644
index 0000000000..8bec3eaea2
--- /dev/null
+++ b/src/lib/libcrypto/objects/objects.err
@@ -0,0 +1,12 @@
1/* Error codes for the OBJ functions. */
2
3/* Function codes. */
4#define OBJ_F_OBJ_CREATE 100
5#define OBJ_F_OBJ_DUP 101
6#define OBJ_F_OBJ_NID2LN 102
7#define OBJ_F_OBJ_NID2OBJ 103
8#define OBJ_F_OBJ_NID2SN 104
9
10/* Reason codes. */
11#define OBJ_R_MALLOC_FAILURE 100
12#define OBJ_R_UNKNOWN_NID 101
diff --git a/src/lib/libcrypto/pem/Makefile.ssl b/src/lib/libcrypto/pem/Makefile.ssl
new file mode 100644
index 0000000000..fc04a88fd9
--- /dev/null
+++ b/src/lib/libcrypto/pem/Makefile.ssl
@@ -0,0 +1,96 @@
1#
2# SSLeay/crypto/pem/Makefile
3#
4
5DIR= pem
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=pem
19ERRC=pem_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24CTX_SIZE= ctx_size
25
26LIB=$(TOP)/libcrypto.a
27LIBSRC= pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c $(ERRC).c
28
29LIBOBJ= pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o $(ERRC).o
30
31SRC= $(LIBSRC)
32
33EXHEADER= pem.h
34HEADER= $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: pem.h lib
42
43pem.h: $(CTX_SIZE)
44 ./$(CTX_SIZE) <pem.org >pem.new
45 if [ -f pem.h ]; then mv -f pem.h pem.old; fi
46 mv -f pem.new pem.h
47
48$(CTX_SIZE): $(CTX_SIZE).o
49 $(CC) $(CFLAGS) -o $(CTX_SIZE) $(CTX_SIZE).o
50
51lib: $(LIBOBJ)
52 $(AR) $(LIB) $(LIBOBJ)
53 sh $(TOP)/util/ranlib.sh $(LIB)
54 @touch lib
55
56files:
57 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
58
59links:
60 /bin/rm -f Makefile
61 $(TOP)/util/point.sh Makefile.ssl Makefile ;
62 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
63 $(TOP)/util/mklink.sh ../../test $(TEST)
64 $(TOP)/util/mklink.sh ../../apps $(APPS)
65
66install:
67 @for i in $(EXHEADER) ; \
68 do \
69 (cp $$i $(INSTALLTOP)/include/$$i; \
70 chmod 644 $(INSTALLTOP)/include/$$i ); \
71 done;
72
73tags:
74 ctags $(SRC)
75
76tests:
77
78lint:
79 lint -DLINT $(INCLUDES) $(SRC)>fluff
80
81depend:
82 $(MAKEDEPEND) $(INCLUDES) $(CTX_SIZE).c $(LIBSRC)
83
84dclean:
85 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
86 mv -f Makefile.new $(MAKEFILE)
87
88clean:
89 /bin/rm -f $(CTX_SIZE) *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
90
91errors:
92 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # SPECIAL CASE .org
93 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
94 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
95
96# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/pem/ctx_size.c b/src/lib/libcrypto/pem/ctx_size.c
new file mode 100644
index 0000000000..87469bc4af
--- /dev/null
+++ b/src/lib/libcrypto/pem/ctx_size.c
@@ -0,0 +1,122 @@
1/* crypto/pem/ctx_size.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62
63int main(argc,argv)
64int argc;
65char *argv[];
66 {
67 int i,j;
68 char buf[256];
69
70 for (;;)
71 {
72 char *str;
73 buf[0]='\0';
74 fgets(buf,256,stdin);
75 if (buf[0] == '\0') break;
76
77 str="#define EVP_ENCODE_CTX_SIZE ";
78 if (strncmp(buf,str,strlen(str)) == 0)
79 {
80 printf("%s %d\n",str,(int)sizeof(EVP_ENCODE_CTX));
81 continue;
82 }
83 str="#define EVP_MD_SIZE ";
84 if (strncmp(buf,str,strlen(str)) == 0)
85 {
86 printf("%s %d\n",str,(int)sizeof(EVP_MD));
87 continue;
88 }
89 str="#define EVP_MD_CTX_SIZE ";
90 if (strncmp(buf,str,strlen(str)) == 0)
91 {
92 printf("%s %d\n",str,(int)sizeof(EVP_MD_CTX));
93 continue;
94 }
95 str="#define EVP_CIPHER_SIZE ";
96 if (strncmp(buf,str,strlen(str)) == 0)
97 {
98 printf("%s %d\n",str,(int)sizeof(EVP_CIPHER));
99 continue;
100 }
101 str="#define EVP_CIPHER_CTX_SIZE ";
102 if (strncmp(buf,str,strlen(str)) == 0)
103 {
104 printf("%s %d\n",str,(int)sizeof(EVP_CIPHER_CTX));
105 continue;
106 }
107
108 str="#define EVP_MAX_MD_SIZE ";
109 if (strncmp(buf,str,strlen(str)) == 0)
110 {
111 i=MD2_DIGEST_LENGTH;
112 j=MD5_DIGEST_LENGTH;
113 if (j > i) i=j;
114 j=SHA_DIGEST_LENGTH;
115 if (j > i) i=j;
116 printf("%s %d\n",str,i);
117 continue;
118 }
119 fputs(buf,stdout);
120 }
121 exit(0);
122 }
diff --git a/src/lib/libcrypto/pem/pem.err b/src/lib/libcrypto/pem/pem.err
new file mode 100644
index 0000000000..0e523abf82
--- /dev/null
+++ b/src/lib/libcrypto/pem/pem.err
@@ -0,0 +1,38 @@
1/* Error codes for the PEM functions. */
2
3/* Function codes. */
4#define PEM_F_DEF_CALLBACK 100
5#define PEM_F_LOAD_IV 101
6#define PEM_F_PEM_ASN1_READ 102
7#define PEM_F_PEM_ASN1_READ_BIO 103
8#define PEM_F_PEM_ASN1_WRITE 104
9#define PEM_F_PEM_ASN1_WRITE_BIO 105
10#define PEM_F_PEM_DO_HEADER 106
11#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
12#define PEM_F_PEM_READ 108
13#define PEM_F_PEM_READ_BIO 109
14#define PEM_F_PEM_SEALFINAL 110
15#define PEM_F_PEM_SEALINIT 111
16#define PEM_F_PEM_SIGNFINAL 112
17#define PEM_F_PEM_WRITE 113
18#define PEM_F_PEM_WRITE_BIO 114
19#define PEM_F_PEM_X509_INFO_READ 115
20#define PEM_F_PEM_X509_INFO_READ_BIO 116
21#define PEM_F_PEM_X509_INFO_WRITE_BIO 117
22
23/* Reason codes. */
24#define PEM_R_BAD_BASE64_DECODE 100
25#define PEM_R_BAD_DECRYPT 101
26#define PEM_R_BAD_END_LINE 102
27#define PEM_R_BAD_IV_CHARS 103
28#define PEM_R_BAD_PASSWORD_READ 104
29#define PEM_R_NOT_DEK_INFO 105
30#define PEM_R_NOT_ENCRYPTED 106
31#define PEM_R_NOT_PROC_TYPE 107
32#define PEM_R_NO_START_LINE 108
33#define PEM_R_PROBLEMS_GETTING_PASSWORD 109
34#define PEM_R_PUBLIC_KEY_NO_RSA 110
35#define PEM_R_READ_KEY 111
36#define PEM_R_SHORT_HEADER 112
37#define PEM_R_UNSUPPORTED_CIPHER 113
38#define PEM_R_UNSUPPORTED_ENCRYPTION 114
diff --git a/src/lib/libcrypto/pem/pem.org b/src/lib/libcrypto/pem/pem.org
new file mode 100644
index 0000000000..38952509dd
--- /dev/null
+++ b/src/lib/libcrypto/pem/pem.org
@@ -0,0 +1,562 @@
1/* crypto/pem/pem.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify pem.org since pem.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_PEM_H
68#define HEADER_PEM_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74#include "evp.h"
75#include "x509.h"
76
77#define PEM_OBJ_UNDEF 0
78#define PEM_OBJ_X509 1
79#define PEM_OBJ_X509_REQ 2
80#define PEM_OBJ_CRL 3
81#define PEM_OBJ_SSL_SESSION 4
82#define PEM_OBJ_PRIV_KEY 10
83#define PEM_OBJ_PRIV_RSA 11
84#define PEM_OBJ_PRIV_DSA 12
85#define PEM_OBJ_PRIV_DH 13
86#define PEM_OBJ_PUB_RSA 14
87#define PEM_OBJ_PUB_DSA 15
88#define PEM_OBJ_PUB_DH 16
89#define PEM_OBJ_DHPARAMS 17
90#define PEM_OBJ_DSAPARAMS 18
91#define PEM_OBJ_PRIV_RSA_PUBLIC 19
92
93#define PEM_ERROR 30
94#define PEM_DEK_DES_CBC 40
95#define PEM_DEK_IDEA_CBC 45
96#define PEM_DEK_DES_EDE 50
97#define PEM_DEK_DES_ECB 60
98#define PEM_DEK_RSA 70
99#define PEM_DEK_RSA_MD2 80
100#define PEM_DEK_RSA_MD5 90
101
102#define PEM_MD_MD2 NID_md2
103#define PEM_MD_MD5 NID_md5
104#define PEM_MD_SHA NID_sha
105#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption
106#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption
107#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption
108
109#define PEM_STRING_X509_OLD "X509 CERTIFICATE"
110#define PEM_STRING_X509 "CERTIFICATE"
111#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
112#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
113#define PEM_STRING_X509_CRL "X509 CRL"
114#define PEM_STRING_EVP_PKEY "PRIVATE KEY"
115#define PEM_STRING_RSA "RSA PRIVATE KEY"
116#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
117#define PEM_STRING_DSA "DSA PRIVATE KEY"
118#define PEM_STRING_PKCS7 "PKCS7"
119#define PEM_STRING_DHPARAMS "DH PARAMETERS"
120#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
121#define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
122
123#ifndef HEADER_ENVELOPE_H
124
125#define EVP_ENCODE_CTX_SIZE 92
126#define EVP_MD_SIZE 48
127#define EVP_MD_CTX_SIZE 152
128#define EVP_CIPHER_SIZE 28
129#define EVP_CIPHER_CTX_SIZE 4212
130#define EVP_MAX_MD_SIZE 20
131
132typedef struct evp_encode_ctx_st
133 {
134 char data[EVP_ENCODE_CTX_SIZE];
135 } EVP_ENCODE_CTX;
136
137typedef struct env_md_ctx_st
138 {
139 char data[EVP_MD_CTX_SIZE];
140 } EVP_MD_CTX;
141
142typedef struct evp_cipher_st
143 {
144 char data[EVP_CIPHER_SIZE];
145 } EVP_CIPHER;
146
147typedef struct evp_cipher_ctx_st
148 {
149 char data[EVP_CIPHER_CTX_SIZE];
150 } EVP_CIPHER_CTX;
151#endif
152
153
154typedef struct PEM_Encode_Seal_st
155 {
156 EVP_ENCODE_CTX encode;
157 EVP_MD_CTX md;
158 EVP_CIPHER_CTX cipher;
159 } PEM_ENCODE_SEAL_CTX;
160
161/* enc_type is one off */
162#define PEM_TYPE_ENCRYPTED 10
163#define PEM_TYPE_MIC_ONLY 20
164#define PEM_TYPE_MIC_CLEAR 30
165#define PEM_TYPE_CLEAR 40
166
167typedef struct pem_recip_st
168 {
169 char *name;
170 X509_NAME *dn;
171
172 int cipher;
173 int key_enc;
174 char iv[8];
175 } PEM_USER;
176
177typedef struct pem_ctx_st
178 {
179 int type; /* what type of object */
180
181 struct {
182 int version;
183 int mode;
184 } proc_type;
185
186 char *domain;
187
188 struct {
189 int cipher;
190 unsigned char iv[8];
191 } DEK_info;
192
193 PEM_USER *originator;
194
195 int num_recipient;
196 PEM_USER **recipient;
197
198#ifdef HEADER_STACK_H
199 STACK *x509_chain; /* certificate chain */
200#else
201 char *x509_chain; /* certificate chain */
202#endif
203 EVP_MD *md; /* signature type */
204
205 int md_enc; /* is the md encrypted or not? */
206 int md_len; /* length of md_data */
207 char *md_data; /* message digest, could be pkey encrypted */
208
209 EVP_CIPHER *dec; /* date encryption cipher */
210 int key_len; /* key length */
211 unsigned char *key; /* key */
212 unsigned char iv[8]; /* the iv */
213
214
215 int data_enc; /* is the data encrypted */
216 int data_len;
217 unsigned char *data;
218 } PEM_CTX;
219
220#ifdef SSLEAY_MACROS
221
222#define PEM_write_SSL_SESSION(fp,x) \
223 PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
224 PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL)
225#define PEM_write_X509(fp,x) \
226 PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
227 (char *)x, NULL,NULL,0,NULL)
228#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \
229 (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \
230 NULL,NULL,0,NULL)
231#define PEM_write_X509_CRL(fp,x) \
232 PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \
233 fp,(char *)x, NULL,NULL,0,NULL)
234#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb) \
235 PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\
236 (char *)x,enc,kstr,klen,cb)
237#define PEM_write_RSAPublicKey(fp,x) \
238 PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\
239 PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL)
240#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb) \
241 PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\
242 (char *)x,enc,kstr,klen,cb)
243#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb) \
244 PEM_ASN1_write((int (*)())i2d_PrivateKey,\
245 (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
246 bp,(char *)x,enc,kstr,klen,cb)
247#define PEM_write_PKCS7(fp,x) \
248 PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \
249 (char *)x, NULL,NULL,0,NULL)
250#define PEM_write_DHparams(fp,x) \
251 PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\
252 (char *)x,NULL,NULL,0,NULL)
253
254#define PEM_read_SSL_SESSION(fp,x,cb) (SSL_SESSION *)PEM_ASN1_read( \
255 (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb)
256#define PEM_read_X509(fp,x,cb) (X509 *)PEM_ASN1_read( \
257 (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb)
258#define PEM_read_X509_REQ(fp,x,cb) (X509_REQ *)PEM_ASN1_read( \
259 (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb)
260#define PEM_read_X509_CRL(fp,x,cb) (X509_CRL *)PEM_ASN1_read( \
261 (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb)
262#define PEM_read_RSAPrivateKey(fp,x,cb) (RSA *)PEM_ASN1_read( \
263 (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb)
264#define PEM_read_RSAPublicKey(fp,x,cb) (RSA *)PEM_ASN1_read( \
265 (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb)
266#define PEM_read_DSAPrivateKey(fp,x,cb) (DSA *)PEM_ASN1_read( \
267 (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb)
268#define PEM_read_PrivateKey(fp,x,cb) (EVP_PKEY *)PEM_ASN1_read( \
269 (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb)
270#define PEM_read_PKCS7(fp,x,cb) (PKCS7 *)PEM_ASN1_read( \
271 (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb)
272#define PEM_read_DHparams(fp,x,cb) (DH *)PEM_ASN1_read( \
273 (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb)
274
275#define PEM_write_bio_SSL_SESSION(bp,x) \
276 PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \
277 PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL)
278#define PEM_write_bio_X509(bp,x) \
279 PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
280 (char *)x, NULL,NULL,0,NULL)
281#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \
282 (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \
283 NULL,NULL,0,NULL)
284#define PEM_write_bio_X509_CRL(bp,x) \
285 PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\
286 bp,(char *)x, NULL,NULL,0,NULL)
287#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb) \
288 PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\
289 bp,(char *)x,enc,kstr,klen,cb)
290#define PEM_write_bio_RSAPublicKey(bp,x) \
291 PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \
292 PEM_STRING_RSA_PUBLIC,\
293 bp,(char *)x,NULL,NULL,0,NULL)
294#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb) \
295 PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\
296 bp,(char *)x,enc,kstr,klen,cb)
297#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb) \
298 PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\
299 (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
300 bp,(char *)x,enc,kstr,klen,cb)
301#define PEM_write_bio_PKCS7(bp,x) \
302 PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \
303 (char *)x, NULL,NULL,0,NULL)
304#define PEM_write_bio_DHparams(bp,x) \
305 PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\
306 bp,(char *)x,NULL,NULL,0,NULL)
307#define PEM_write_bio_DSAparams(bp,x) \
308 PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \
309 PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL)
310
311#define PEM_read_bio_SSL_SESSION(bp,x,cb) (SSL_SESSION *)PEM_ASN1_read_bio( \
312 (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb)
313#define PEM_read_bio_X509(bp,x,cb) (X509 *)PEM_ASN1_read_bio( \
314 (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb)
315#define PEM_read_bio_X509_REQ(bp,x,cb) (X509_REQ *)PEM_ASN1_read_bio( \
316 (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb)
317#define PEM_read_bio_X509_CRL(bp,x,cb) (X509_CRL *)PEM_ASN1_read_bio( \
318 (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb)
319#define PEM_read_bio_RSAPrivateKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \
320 (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb)
321#define PEM_read_bio_RSAPublicKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \
322 (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb)
323#define PEM_read_bio_DSAPrivateKey(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \
324 (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb)
325#define PEM_read_bio_PrivateKey(bp,x,cb) (EVP_PKEY *)PEM_ASN1_read_bio( \
326 (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb)
327
328#define PEM_read_bio_PKCS7(bp,x,cb) (PKCS7 *)PEM_ASN1_read_bio( \
329 (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb)
330#define PEM_read_bio_DHparams(bp,x,cb) (DH *)PEM_ASN1_read_bio( \
331 (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb)
332#define PEM_read_bio_DSAparams(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \
333 (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb)
334
335#endif
336
337#ifndef NOPROTO
338int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
339int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
340 int (*callback)());
341
342#ifdef HEADER_BIO_H
343int PEM_read_bio(BIO *bp, char **name, char **header,
344 unsigned char **data,long *len);
345int PEM_write_bio(BIO *bp,char *name,char *hdr,unsigned char *data,
346 long len);
347char * PEM_ASN1_read_bio(char *(*d2i)(),char *name,BIO *bp,char **x,
348 int (*cb)());
349int PEM_ASN1_write_bio(int (*i2d)(),char *name,BIO *bp,char *x,
350 EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)());
351STACK * PEM_X509_INFO_read_bio(BIO *bp, STACK *sk, int (*cb)());
352int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
353 unsigned char *kstr, int klen, int (*cb)());
354#endif
355
356#ifndef WIN16
357int PEM_read(FILE *fp, char **name, char **header,
358 unsigned char **data,long *len);
359int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
360char * PEM_ASN1_read(char *(*d2i)(),char *name,FILE *fp,char **x,
361 int (*cb)());
362int PEM_ASN1_write(int (*i2d)(),char *name,FILE *fp,char *x,
363 EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)());
364STACK * PEM_X509_INFO_read(FILE *fp, STACK *sk, int (*cb)());
365#endif
366
367int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
368 EVP_MD *md_type, unsigned char **ek, int *ekl,
369 unsigned char *iv, EVP_PKEY **pubk, int npubk);
370void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
371 unsigned char *in, int inl);
372int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl,
373 unsigned char *out, int *outl, EVP_PKEY *priv);
374
375void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
376void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
377int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
378 unsigned int *siglen, EVP_PKEY *pkey);
379
380void ERR_load_PEM_strings(void);
381
382void PEM_proc_type(char *buf, int type);
383void PEM_dek_info(char *buf, char *type, int len, char *str);
384
385#ifndef SSLEAY_MACROS
386
387#ifndef WIN16
388X509 *PEM_read_X509(FILE *fp,X509 **x,int (*cb)());
389X509_REQ *PEM_read_X509_REQ(FILE *fp,X509_REQ **x,int (*cb)());
390X509_CRL *PEM_read_X509_CRL(FILE *fp,X509_CRL **x,int (*cb)());
391RSA *PEM_read_RSAPrivateKey(FILE *fp,RSA **x,int (*cb)());
392RSA *PEM_read_RSAPublicKey(FILE *fp,RSA **x,int (*cb)());
393DSA *PEM_read_DSAPrivateKey(FILE *fp,DSA **x,int (*cb)());
394EVP_PKEY *PEM_read_PrivateKey(FILE *fp,EVP_PKEY **x,int (*cb)());
395PKCS7 *PEM_read_PKCS7(FILE *fp,PKCS7 **x,int (*cb)());
396DH *PEM_read_DHparams(FILE *fp,DH **x,int (*cb)());
397DSA *PEM_read_DSAparams(FILE *fp,DSA **x,int (*cb)());
398int PEM_write_X509(FILE *fp,X509 *x);
399int PEM_write_X509_REQ(FILE *fp,X509_REQ *x);
400int PEM_write_X509_CRL(FILE *fp,X509_CRL *x);
401int PEM_write_RSAPrivateKey(FILE *fp,RSA *x,EVP_CIPHER *enc,unsigned char *kstr,
402 int klen,int (*cb)());
403int PEM_write_RSAPublicKey(FILE *fp,RSA *x);
404int PEM_write_DSAPrivateKey(FILE *fp,DSA *x,EVP_CIPHER *enc,unsigned char *kstr,
405 int klen,int (*cb)());
406int PEM_write_PrivateKey(FILE *fp,EVP_PKEY *x,EVP_CIPHER *enc,
407 unsigned char *kstr,int klen,int (*cb)());
408int PEM_write_PKCS7(FILE *fp,PKCS7 *x);
409int PEM_write_DHparams(FILE *fp,DH *x);
410int PEM_write_DSAparams(FILE *fp,DSA *x);
411#endif
412
413#ifdef HEADER_BIO_H
414X509 *PEM_read_bio_X509(BIO *bp,X509 **x,int (*cb)());
415X509_REQ *PEM_read_bio_X509_REQ(BIO *bp,X509_REQ **x,int (*cb)());
416X509_CRL *PEM_read_bio_X509_CRL(BIO *bp,X509_CRL **x,int (*cb)());
417RSA *PEM_read_bio_RSAPrivateKey(BIO *bp,RSA **x,int (*cb)());
418RSA *PEM_read_bio_RSAPublicKey(BIO *bp,RSA **x,int (*cb)());
419DSA *PEM_read_bio_DSAPrivateKey(BIO *bp,DSA **x,int (*cb)());
420EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp,EVP_PKEY **x,int (*cb)());
421PKCS7 *PEM_read_bio_PKCS7(BIO *bp,PKCS7 **x,int (*cb)());
422DH *PEM_read_bio_DHparams(BIO *bp,DH **x,int (*cb)());
423DSA *PEM_read_bio_DSAparams(BIO *bp,DSA **x,int (*cb)());
424int PEM_write_bio_X509(BIO *bp,X509 *x);
425int PEM_write_bio_X509_REQ(BIO *bp,X509_REQ *x);
426int PEM_write_bio_X509_CRL(BIO *bp,X509_CRL *x);
427int PEM_write_bio_RSAPrivateKey(BIO *fp,RSA *x,EVP_CIPHER *enc,
428 unsigned char *kstr,int klen,int (*cb)());
429int PEM_write_bio_RSAPublicKey(BIO *fp,RSA *x);
430int PEM_write_bio_DSAPrivateKey(BIO *fp,DSA *x,EVP_CIPHER *enc,
431 unsigned char *kstr,int klen,int (*cb)());
432int PEM_write_bio_PrivateKey(BIO *fp,EVP_PKEY *x,EVP_CIPHER *enc,
433 unsigned char *kstr,int klen,int (*cb)());
434int PEM_write_bio_PKCS7(BIO *bp,PKCS7 *x);
435int PEM_write_bio_DHparams(BIO *bp,DH *x);
436int PEM_write_bio_DSAparams(BIO *bp,DSA *x);
437#endif
438
439#endif /* SSLEAY_MACROS */
440
441
442#else
443
444int PEM_get_EVP_CIPHER_INFO();
445int PEM_do_header();
446int PEM_read_bio();
447int PEM_write_bio();
448#ifndef WIN16
449int PEM_read();
450int PEM_write();
451STACK * PEM_X509_INFO_read();
452char * PEM_ASN1_read();
453int PEM_ASN1_write();
454#endif
455STACK * PEM_X509_INFO_read_bio();
456int PEM_X509_INFO_write_bio();
457char * PEM_ASN1_read_bio();
458int PEM_ASN1_write_bio();
459int PEM_SealInit();
460void PEM_SealUpdate();
461int PEM_SealFinal();
462int PEM_SignFinal();
463
464void ERR_load_PEM_strings();
465
466void PEM_proc_type();
467void PEM_dek_info();
468
469#ifndef SSLEAY_MACROS
470#ifndef WIN16
471X509 *PEM_read_X509();
472X509_REQ *PEM_read_X509_REQ();
473X509_CRL *PEM_read_X509_CRL();
474RSA *PEM_read_RSAPrivateKey();
475RSA *PEM_read_RSAPublicKey();
476DSA *PEM_read_DSAPrivateKey();
477EVP_PKEY *PEM_read_PrivateKey();
478PKCS7 *PEM_read_PKCS7();
479DH *PEM_read_DHparams();
480DSA *PEM_read_DSAparams();
481int PEM_write_X509();
482int PEM_write_X509_REQ();
483int PEM_write_X509_CRL();
484int PEM_write_RSAPrivateKey();
485int PEM_write_RSAPublicKey();
486int PEM_write_DSAPrivateKey();
487int PEM_write_PrivateKey();
488int PEM_write_PKCS7();
489int PEM_write_DHparams();
490int PEM_write_DSAparams();
491#endif
492
493X509 *PEM_read_bio_X509();
494X509_REQ *PEM_read_bio_X509_REQ();
495X509_CRL *PEM_read_bio_X509_CRL();
496RSA *PEM_read_bio_RSAPrivateKey();
497RSA *PEM_read_bio_RSAPublicKey();
498DSA *PEM_read_bio_DSAPrivateKey();
499EVP_PKEY *PEM_read_bio_PrivateKey();
500PKCS7 *PEM_read_bio_PKCS7();
501DH *PEM_read_bio_DHparams();
502DSA *PEM_read_bio_DSAparams();
503int PEM_write_bio_X509();
504int PEM_write_bio_X509_REQ();
505int PEM_write_bio_X509_CRL();
506int PEM_write_bio_RSAPrivateKey();
507int PEM_write_bio_RSAPublicKey();
508int PEM_write_bio_DSAPrivateKey();
509int PEM_write_bio_PrivateKey();
510int PEM_write_bio_PKCS7();
511int PEM_write_bio_DHparams();
512int PEM_write_bio_DSAparams();
513
514#endif /* SSLEAY_MACROS */
515
516#endif
517
518/* BEGIN ERROR CODES */
519/* Error codes for the PEM functions. */
520
521/* Function codes. */
522#define PEM_F_DEF_CALLBACK 100
523#define PEM_F_LOAD_IV 101
524#define PEM_F_PEM_ASN1_READ 102
525#define PEM_F_PEM_ASN1_READ_BIO 103
526#define PEM_F_PEM_ASN1_WRITE 104
527#define PEM_F_PEM_ASN1_WRITE_BIO 105
528#define PEM_F_PEM_DO_HEADER 106
529#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
530#define PEM_F_PEM_READ 108
531#define PEM_F_PEM_READ_BIO 109
532#define PEM_F_PEM_SEALFINAL 110
533#define PEM_F_PEM_SEALINIT 111
534#define PEM_F_PEM_SIGNFINAL 112
535#define PEM_F_PEM_WRITE 113
536#define PEM_F_PEM_WRITE_BIO 114
537#define PEM_F_PEM_X509_INFO_READ 115
538#define PEM_F_PEM_X509_INFO_READ_BIO 116
539#define PEM_F_PEM_X509_INFO_WRITE_BIO 117
540
541/* Reason codes. */
542#define PEM_R_BAD_BASE64_DECODE 100
543#define PEM_R_BAD_DECRYPT 101
544#define PEM_R_BAD_END_LINE 102
545#define PEM_R_BAD_IV_CHARS 103
546#define PEM_R_BAD_PASSWORD_READ 104
547#define PEM_R_NOT_DEK_INFO 105
548#define PEM_R_NOT_ENCRYPTED 106
549#define PEM_R_NOT_PROC_TYPE 107
550#define PEM_R_NO_START_LINE 108
551#define PEM_R_PROBLEMS_GETTING_PASSWORD 109
552#define PEM_R_PUBLIC_KEY_NO_RSA 110
553#define PEM_R_READ_KEY 111
554#define PEM_R_SHORT_HEADER 112
555#define PEM_R_UNSUPPORTED_CIPHER 113
556#define PEM_R_UNSUPPORTED_ENCRYPTION 114
557
558#ifdef __cplusplus
559}
560#endif
561#endif
562
diff --git a/src/lib/libcrypto/pkcs7/Makefile.ssl b/src/lib/libcrypto/pkcs7/Makefile.ssl
new file mode 100644
index 0000000000..a88359b320
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/Makefile.ssl
@@ -0,0 +1,86 @@
1#
2# SSLeay/crypto/asn1/Makefile
3#
4
5DIR= pkcs7
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=pkcs7
19ERRC=pkcs7err
20GENERAL=Makefile README
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= pk7_lib.c pkcs7err.c pk7_doit.c
26LIBOBJ= pk7_lib.o pkcs7err.o pk7_doit.o
27
28SRC= $(LIBSRC)
29
30EXHEADER= pkcs7.h
31HEADER= $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38test:
39
40all: lib
41
42lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ)
44 sh $(TOP)/util/ranlib.sh $(LIB)
45 @touch lib
46
47files:
48 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
49
50links:
51 /bin/rm -f Makefile
52 $(TOP)/util/point.sh Makefile.ssl Makefile ;
53 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
54 $(TOP)/util/mklink.sh ../../test $(TEST)
55 $(TOP)/util/mklink.sh ../../apps $(APPS)
56
57install:
58 @for i in $(EXHEADER) ; \
59 do \
60 (cp $$i $(INSTALLTOP)/include/$$i; \
61 chmod 644 $(INSTALLTOP)/include/$$i ); \
62 done;
63
64tags:
65 ctags $(SRC)
66
67tests:
68
69lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71
72depend:
73 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
74
75dclean:
76 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
77 mv -f Makefile.new $(MAKEFILE)
78
79clean:
80 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
81
82errors:
83 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
84 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
85
86# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/pkcs7/README b/src/lib/libcrypto/pkcs7/README
new file mode 100644
index 0000000000..27001c6970
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/README
@@ -0,0 +1,5 @@
1WARNING
2
3Everything in this directory is experimental and is subject to change.
4
5Do not rely on the stuff in here not changing in the next release
diff --git a/src/lib/libcrypto/pkcs7/mf.p7 b/src/lib/libcrypto/pkcs7/mf.p7
new file mode 100644
index 0000000000..524335b4b3
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/mf.p7
@@ -0,0 +1,18 @@
1-----BEGIN PKCS7-----
2MIAGCSqGSIb3DQEHAqCAMIIC2QIBATEMMAoGCCqGSIb3DQIFMIAGCSqGSIb3DQEH
3AQAAoIIB7TCCAekwggFSAgEAMA0GCSqGSIb3DQEBBAUAMFsxCzAJBgNVBAYTAkFV
4MRMwEQYDVQQIEwpRdWVlbnNsYW5kMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0
5ZDEbMBkGA1UEAxMSVGVzdCBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0NloX
6DTk4MDYwOTEzNTc0NlowYzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xh
7bmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMSMwIQYDVQQDExpTZXJ2ZXIg
8dGVzdCBjZXJ0ICg1MTIgYml0KTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCfs8OE
9J5X/EjFSDxXvRhHErYDmNlsP3YDXYY3g/HJFCTT+VWZFQ0xol2r+qKCl3194/+7X
10ZLg/BMtv/yr+/rntAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAeEzEdgr2nChPcALL
11vY8gl/GIlpoAjPmKD+pLeGZI9s+SEX5u1q8nCrJ6ZzkfrRnqgI5Anmev9+qPZfdU
12bz5zdVSf4sUL9nX9ChXjK9NCJA3UzQHSFqhZErGUwGNkAHYHp2+zAdY6Ho6rmMzt
13g0CDu/sKR4qzm6REsQGS8kgpjz4xgcUwgcICAQEwYDBbMQswCQYDVQQGEwJBVTET
14MBEGA1UECBMKUXVlZW5zbGFuZDEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQx
15GzAZBgNVBAMTElRlc3QgQ0EgKDEwMjQgYml0KQIBADAKBggqhkiG9w0CBTANBgkq
16hkiG9w0BAQQFAARALnrxJiOX9XZf2D+3vL8SKMQmMq55LltomwOLGUru/q1uVXzi
17ARg7FSCegOpA1nunsTURMUGgrPXKK4XmL4IseQAAAAA=
18-----END PKCS7-----
diff --git a/src/lib/libcrypto/pkcs7/p7.tst b/src/lib/libcrypto/pkcs7/p7.tst
new file mode 100644
index 0000000000..6d14dce163
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/p7.tst
@@ -0,0 +1,33 @@
1-----BEGIN PKCS7-----
2MIAGCSqGSIb3DQEHAqCAMIIFsQIBATELMAkGBSsOAwIaBQAwgAYJKoZIhvcNAQcB
3AACgggQdMIICJTCCAc+gAwIBAgIBIjANBgkqhkiG9w0BAQQFADCBgjELMAkGA1UE
4BhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5lMRow
5GAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDEUMBIGA1UECxMLZGV2ZWxvcG1lbnQx
6GTAXBgNVBAMTEENyeXB0U29mdCBEZXYgQ0EwHhcNOTcwNjEzMTgxMDE3WhcNOTgw
7NjEzMTgxMDE3WjCBiDELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx
8ETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDEU
9MBIGA1UECxMLSUlTIHRlc3RpbmcxDjAMBgNVBAMTBXRlc3QxMQ8wDQYJKoZIhvcN
10AQkBFgAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAxtWiv59VH42+rotrmFAyDxTc
11J2osFt5uy/zEllx3vvjtwewqQxGUOwf6cjqFOTrnpEdVvwywpEhIQ5364bJqIwID
12AQABoygwJjAkBglghkgBhvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0G
13CSqGSIb3DQEBBAUAA0EAMnYkNV2AdpeHPy/qlcdZx6MDGIJgrLhklhcn6Or6KiAP
14t9+nv9XdOGHyMyQr9ufsweuQfAgJ9yjKPZR2/adTjTCCAfAwggGaAgEAMA0GCSqG
15SIb3DQEBBAUAMIGCMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDER
16MA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRQw
17EgYDVQQLEwtkZXZlbG9wbWVudDEZMBcGA1UEAxMQQ3J5cHRTb2Z0IERldiBDQTAe
18Fw05NzAzMjIxMzM0MDRaFw05ODAzMjIxMzM0MDRaMIGCMQswCQYDVQQGEwJBVTET
19MBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoT
20EUNyeXB0U29mdCBQdHkgTHRkMRQwEgYDVQQLEwtkZXZlbG9wbWVudDEZMBcGA1UE
21AxMQQ3J5cHRTb2Z0IERldiBDQTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDgDgKq
22IBuUMAJi4c8juAqEZ8f8FcuDWT+HcScvNztRJy9K8DnbGpiSrzzix4El6N4A7vbl
23crwn/0CZmQJguZpfAgMBAAEwDQYJKoZIhvcNAQEEBQADQQA0UUvxlXXe6wKkVukn
24ZoCyXbjlNsqt2rwbvfZEam6fQP3S7uq+o1Pnj+KDgE33WxWbQAA9h8fY1LWN7X3a
25yTm/MYIBbTCCAWkCAQEwgYgwgYIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVl
26bnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0
27eSBMdGQxFDASBgNVBAsTC2RldmVsb3BtZW50MRkwFwYDVQQDExBDcnlwdFNvZnQg
28RGV2IENBAgEiMAkGBSsOAwIaBQCgfTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcB
29MCMGCSqGSIb3DQEJBDEWBBSUVhbGkNE+KGqpOK13+FkfOkaoizAcBgkqhkiG9w0B
30CQUxDxcNOTcwNzAxMDE0MzM0WjAeBgkqhkiG9w0BCQ8xETAPMA0GCCqGSIb3DQMC
31AgEoMA0GCSqGSIb3DQEBAQUABECa9Jpo4w/fZOc3Vy78wZFAVF8kvpn7il99Ldsr
32AQ4JiBmcfiSwEBBY6WuKT+/SYtFwZl1oXkTwB5AVCFIC/IFNAAAAAA==
33-----END PKCS7-----
diff --git a/src/lib/libcrypto/pkcs7/pkcs7.err b/src/lib/libcrypto/pkcs7/pkcs7.err
new file mode 100644
index 0000000000..91413aae43
--- /dev/null
+++ b/src/lib/libcrypto/pkcs7/pkcs7.err
@@ -0,0 +1,26 @@
1/* Error codes for the PKCS7 functions. */
2
3/* Function codes. */
4#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100
5#define PKCS7_F_PKCS7_ADD_CRL 101
6#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102
7#define PKCS7_F_PKCS7_ADD_SIGNER 103
8#define PKCS7_F_PKCS7_CTRL 104
9#define PKCS7_F_PKCS7_DATAINIT 105
10#define PKCS7_F_PKCS7_DATASIGN 106
11#define PKCS7_F_PKCS7_DATAVERIFY 107
12#define PKCS7_F_PKCS7_SET_CIPHER 108
13#define PKCS7_F_PKCS7_SET_CONTENT 109
14#define PKCS7_F_PKCS7_SET_TYPE 110
15
16/* Reason codes. */
17#define PKCS7_R_INTERNAL_ERROR 100
18#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 101
19#define PKCS7_R_SIGNATURE_FAILURE 102
20#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 103
21#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 104
22#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 105
23#define PKCS7_R_UNKNOWN_DIGEST_TYPE 106
24#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 107
25#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 108
26#define PKCS7_R_WRONG_CONTENT_TYPE 109
diff --git a/src/lib/libcrypto/rand/Makefile.ssl b/src/lib/libcrypto/rand/Makefile.ssl
new file mode 100644
index 0000000000..d04f0a9b43
--- /dev/null
+++ b/src/lib/libcrypto/rand/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/rand/Makefile
3#
4
5DIR= rand
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST= randtest.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=md_rand.c randfile.c
24LIBOBJ=md_rand.o randfile.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= rand.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/ranlib.sh b/src/lib/libcrypto/ranlib.sh
new file mode 100644
index 0000000000..543f712c6b
--- /dev/null
+++ b/src/lib/libcrypto/ranlib.sh
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3cwd=`pwd`
4cd /tmp
5
6if [ -s /bin/ranlib ] ; then
7 RL=/bin/ranlib
8else if [ -s /usr/bin/ranlib ] ; then
9 RL=/usr/bin/ranlib
10fi
11fi
12
13if [ "x$RL" != "x" ]
14then
15 case "$1" in
16 /*)
17 $RL "$1"
18 ;;
19 *)
20 $RL "$cwd/$1"
21 ;;
22 esac
23fi
diff --git a/src/lib/libcrypto/rc2/Makefile.ssl b/src/lib/libcrypto/rc2/Makefile.ssl
new file mode 100644
index 0000000000..c5138f13e2
--- /dev/null
+++ b/src/lib/libcrypto/rc2/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/rc2/Makefile
3#
4
5DIR= rc2
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=rc2test.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c
24LIBOBJ=rc2_ecb.o rc2_skey.o rc2_cbc.o rc2cfb64.o rc2ofb64.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= rc2.h
29HEADER= rc2_locl.h $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/rc2/Makefile.uni b/src/lib/libcrypto/rc2/Makefile.uni
new file mode 100644
index 0000000000..e50b3f2d19
--- /dev/null
+++ b/src/lib/libcrypto/rc2/Makefile.uni
@@ -0,0 +1,72 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5
6DIR= rc2
7TOP= .
8CC= gcc
9CFLAG= -O3 -fomit-frame-pointer
10
11CPP= $(CC) -E
12INCLUDES=
13INSTALLTOP=/usr/local/lib
14MAKE= make
15MAKEDEPEND= makedepend
16MAKEFILE= Makefile.uni
17AR= ar r
18
19IDEA_ENC=rc2_cbc.o
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL=Makefile
24TEST=rc2test
25APPS=rc2speed
26
27LIB=librc2.a
28LIBSRC=rc2_skey.c rc2_ecb.c rc2_cbc.c rc2cfb64.c rc2ofb64.c
29LIBOBJ=rc2_skey.o rc2_ecb.o $(IDEA_ENC) rc2cfb64.o rc2ofb64.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= rc2.h
34HEADER= rc2_locl.h $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38all: $(LIB) $(TEST) $(APPS)
39
40$(LIB): $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/ranlib.sh $(LIB)
43
44test: $(TEST)
45 ./$(TEST)
46
47$(TEST): $(TEST).c $(LIB)
48 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
49
50$(APPS): $(APPS).c $(LIB)
51 $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
52
53lint:
54 lint -DLINT $(INCLUDES) $(SRC)>fluff
55
56depend:
57 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
58
59dclean:
60 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
61 mv -f Makefile.new $(MAKEFILE)
62
63clean:
64 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
65
66cc:
67 $(MAKE) CC="cc" CFLAG="-O" all
68
69gcc:
70 $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
71
72# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/rc2/rc2.org b/src/lib/libcrypto/rc2/rc2.org
new file mode 100644
index 0000000000..37354cfa62
--- /dev/null
+++ b/src/lib/libcrypto/rc2/rc2.org
@@ -0,0 +1,118 @@
1/* crypto/rc2/rc2.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify rc2.org since rc2.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_RC2_H
68#define HEADER_RC2_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74#define RC2_ENCRYPT 1
75#define RC2_DECRYPT 0
76
77/* I need to put in a mod for the alpha - eay */
78#define RC2_INT unsigned short
79
80#define RC2_BLOCK 8
81#define RC2_KEY_LENGTH 16
82
83typedef struct rc2_key_st
84 {
85 RC2_INT data[64];
86 } RC2_KEY;
87
88#ifndef NOPROTO
89
90void RC2_set_key(RC2_KEY *key, int len, unsigned char *data,int bits);
91void RC2_ecb_encrypt(unsigned char *in,unsigned char *out,RC2_KEY *key,
92 int enc);
93void RC2_encrypt(unsigned long *data,RC2_KEY *key);
94void RC2_decrypt(unsigned long *data,RC2_KEY *key);
95void RC2_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
96 RC2_KEY *ks, unsigned char *iv, int enc);
97void RC2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
98 RC2_KEY *schedule, unsigned char *ivec, int *num, int enc);
99void RC2_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
100 RC2_KEY *schedule, unsigned char *ivec, int *num);
101
102#else
103
104void RC2_set_key();
105void RC2_ecb_encrypt();
106void RC2_encrypt();
107void RC2_decrypt();
108void RC2_cbc_encrypt();
109void RC2_cfb64_encrypt();
110void RC2_ofb64_encrypt();
111
112#endif
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif
diff --git a/src/lib/libcrypto/rc4/Makefile.ssl b/src/lib/libcrypto/rc4/Makefile.ssl
new file mode 100644
index 0000000000..19c1e980f3
--- /dev/null
+++ b/src/lib/libcrypto/rc4/Makefile.ssl
@@ -0,0 +1,108 @@
1#
2# SSLeay/crypto/rc4/Makefile
3#
4
5DIR= rc4
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16RC4_ENC=rc4_enc.o
17# or use
18#RC4_ENC=asm/rx86-elf.o
19#RC4_ENC=asm/rx86-out.o
20#RC4_ENC=asm/rx86-sol.o
21#RC4_ENC=asm/rx86bdsi.o
22
23CFLAGS= $(INCLUDES) $(CFLAG)
24
25GENERAL=Makefile
26TEST=rc4test.c
27APPS=
28
29LIB=$(TOP)/libcrypto.a
30LIBSRC=rc4_skey.c rc4_enc.c
31LIBOBJ=rc4_skey.o $(RC4_ENC)
32
33SRC= $(LIBSRC)
34
35EXHEADER= rc4.h
36HEADER= $(EXHEADER) rc4_locl.h
37
38ALL= $(GENERAL) $(SRC) $(HEADER)
39
40top:
41 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
42
43all: lib
44
45lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ)
47 sh $(TOP)/util/ranlib.sh $(LIB)
48 @touch lib
49
50# elf
51asm/rx86-elf.o: asm/rx86unix.cpp
52 $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o
53
54# solaris
55asm/rx86-sol.o: asm/rx86unix.cpp
56 $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s
57 as -o asm/rx86-sol.o asm/rx86-sol.s
58 rm -f asm/rx86-sol.s
59
60# a.out
61asm/rx86-out.o: asm/rx86unix.cpp
62 $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o
63
64# bsdi
65asm/rx86bsdi.o: asm/rx86unix.cpp
66 $(CPP) -DBSDI asm/rx86unix.cpp | as -o asm/rx86bsdi.o
67
68asm/rx86unix.cpp:
69 (cd asm; perl rc4-586.pl cpp >rx86unix.cpp)
70
71files:
72 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
73
74links:
75 /bin/rm -f Makefile
76 $(TOP)/util/point.sh Makefile.ssl Makefile ;
77 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
78 $(TOP)/util/mklink.sh ../../test $(TEST)
79 $(TOP)/util/mklink.sh ../../apps $(APPS)
80
81install:
82 @for i in $(EXHEADER) ; \
83 do \
84 (cp $$i $(INSTALLTOP)/include/$$i; \
85 chmod 644 $(INSTALLTOP)/include/$$i ); \
86 done;
87
88tags:
89 ctags $(SRC)
90
91tests:
92
93lint:
94 lint -DLINT $(INCLUDES) $(SRC)>fluff
95
96depend:
97 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
98
99dclean:
100 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
101 mv -f Makefile.new $(MAKEFILE)
102
103clean:
104 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o
105
106errors:
107
108# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/rc4/Makefile.uni b/src/lib/libcrypto/rc4/Makefile.uni
new file mode 100644
index 0000000000..79dc17b8d1
--- /dev/null
+++ b/src/lib/libcrypto/rc4/Makefile.uni
@@ -0,0 +1,102 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= rc4
11TOP= .
12CC= gcc
13CFLAG= -O3 -fomit-frame-pointer
14
15CPP= $(CC) -E
16INCLUDES=
17INSTALLTOP=/usr/local/lib
18MAKE= make
19MAKEDEPEND= makedepend
20MAKEFILE= Makefile.uni
21AR= ar r
22
23RC4_ENC=rc4_enc.o
24# or use
25#RC4_ENC=asm/rx86-elf.o
26#RC4_ENC=asm/rx86-out.o
27#RC4_ENC=asm/rx86-sol.o
28#RC4_ENC=asm/rx86bdsi.o
29
30CFLAGS= $(INCLUDES) $(CFLAG)
31
32GENERAL=Makefile
33TEST=rc4test
34APPS=rc4speed
35
36LIB=librc4.a
37LIBSRC=rc4_skey.c rc4_enc.c
38LIBOBJ=rc4_skey.o $(RC4_ENC)
39
40SRC= $(LIBSRC)
41
42EXHEADER= rc4.h
43HEADER= $(EXHEADER) rc4_locl.h
44
45ALL= $(GENERAL) $(SRC) $(HEADER)
46
47all: $(LIB) $(TEST) $(APPS)
48
49$(LIB): $(LIBOBJ)
50 $(AR) $(LIB) $(LIBOBJ)
51 sh $(TOP)/ranlib.sh $(LIB)
52
53# elf
54asm/rx86-elf.o: asm/rx86unix.cpp
55 $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o
56
57# solaris
58asm/rx86-sol.o: asm/rx86unix.cpp
59 $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s
60 as -o asm/rx86-sol.o asm/rx86-sol.s
61 rm -f asm/rx86-sol.s
62
63# a.out
64asm/rx86-out.o: asm/rx86unix.cpp
65 $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o
66
67# bsdi
68asm/rx86bsdi.o: asm/rx86unix.cpp
69 $(CPP) -DBSDI asm/rx86unix.cpp | as -o asm/rx86bsdi.o
70
71asm/rx86unix.cpp:
72 (cd asm; perl rc4-586.pl cpp >rx86unix.cpp)
73
74test: $(TEST)
75 ./$(TEST)
76
77$(TEST): $(TEST).c $(LIB)
78 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
79
80$(APPS): $(APPS).c $(LIB)
81 $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
82
83lint:
84 lint -DLINT $(INCLUDES) $(SRC)>fluff
85
86depend:
87 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
88
89dclean:
90 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
91 mv -f Makefile.new $(MAKEFILE)
92
93clean:
94 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
95
96cc:
97 $(MAKE) CC="cc" CFLAG="-O" all
98
99gcc:
100 $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
101
102# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/rc4/asm/r4-win32.asm b/src/lib/libcrypto/rc4/asm/r4-win32.asm
new file mode 100644
index 0000000000..70b0f7484c
--- /dev/null
+++ b/src/lib/libcrypto/rc4/asm/r4-win32.asm
@@ -0,0 +1,314 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by rc4-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE rc4-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _RC4
12
13_RC4 PROC NEAR
14 ;
15 push ebp
16 push ebx
17 mov ebp, DWORD PTR 12[esp]
18 mov ebx, DWORD PTR 16[esp]
19 push esi
20 push edi
21 mov ecx, DWORD PTR [ebp]
22 mov edx, DWORD PTR 4[ebp]
23 mov esi, DWORD PTR 28[esp]
24 inc ecx
25 sub esp, 12
26 add ebp, 8
27 and ecx, 255
28 lea ebx, DWORD PTR [esi+ebx-8]
29 mov edi, DWORD PTR 44[esp]
30 mov DWORD PTR 8[esp],ebx
31 mov eax, DWORD PTR [ecx*4+ebp]
32 cmp ebx, esi
33 jl $L000end
34L001start:
35 add esi, 8
36 ; Round 0
37 add edx, eax
38 and edx, 255
39 inc ecx
40 mov ebx, DWORD PTR [edx*4+ebp]
41 mov DWORD PTR [ecx*4+ebp-4],ebx
42 add ebx, eax
43 and ecx, 255
44 and ebx, 255
45 mov DWORD PTR [edx*4+ebp],eax
46 nop
47 mov ebx, DWORD PTR [ebx*4+ebp]
48 mov eax, DWORD PTR [ecx*4+ebp]
49 mov BYTE PTR [esp], bl
50 ; Round 1
51 add edx, eax
52 and edx, 255
53 inc ecx
54 mov ebx, DWORD PTR [edx*4+ebp]
55 mov DWORD PTR [ecx*4+ebp-4],ebx
56 add ebx, eax
57 and ecx, 255
58 and ebx, 255
59 mov DWORD PTR [edx*4+ebp],eax
60 nop
61 mov ebx, DWORD PTR [ebx*4+ebp]
62 mov eax, DWORD PTR [ecx*4+ebp]
63 mov BYTE PTR 1[esp],bl
64 ; Round 2
65 add edx, eax
66 and edx, 255
67 inc ecx
68 mov ebx, DWORD PTR [edx*4+ebp]
69 mov DWORD PTR [ecx*4+ebp-4],ebx
70 add ebx, eax
71 and ecx, 255
72 and ebx, 255
73 mov DWORD PTR [edx*4+ebp],eax
74 nop
75 mov ebx, DWORD PTR [ebx*4+ebp]
76 mov eax, DWORD PTR [ecx*4+ebp]
77 mov BYTE PTR 2[esp],bl
78 ; Round 3
79 add edx, eax
80 and edx, 255
81 inc ecx
82 mov ebx, DWORD PTR [edx*4+ebp]
83 mov DWORD PTR [ecx*4+ebp-4],ebx
84 add ebx, eax
85 and ecx, 255
86 and ebx, 255
87 mov DWORD PTR [edx*4+ebp],eax
88 nop
89 mov ebx, DWORD PTR [ebx*4+ebp]
90 mov eax, DWORD PTR [ecx*4+ebp]
91 mov BYTE PTR 3[esp],bl
92 ; Round 4
93 add edx, eax
94 and edx, 255
95 inc ecx
96 mov ebx, DWORD PTR [edx*4+ebp]
97 mov DWORD PTR [ecx*4+ebp-4],ebx
98 add ebx, eax
99 and ecx, 255
100 and ebx, 255
101 mov DWORD PTR [edx*4+ebp],eax
102 nop
103 mov ebx, DWORD PTR [ebx*4+ebp]
104 mov eax, DWORD PTR [ecx*4+ebp]
105 mov BYTE PTR 4[esp],bl
106 ; Round 5
107 add edx, eax
108 and edx, 255
109 inc ecx
110 mov ebx, DWORD PTR [edx*4+ebp]
111 mov DWORD PTR [ecx*4+ebp-4],ebx
112 add ebx, eax
113 and ecx, 255
114 and ebx, 255
115 mov DWORD PTR [edx*4+ebp],eax
116 nop
117 mov ebx, DWORD PTR [ebx*4+ebp]
118 mov eax, DWORD PTR [ecx*4+ebp]
119 mov BYTE PTR 5[esp],bl
120 ; Round 6
121 add edx, eax
122 and edx, 255
123 inc ecx
124 mov ebx, DWORD PTR [edx*4+ebp]
125 mov DWORD PTR [ecx*4+ebp-4],ebx
126 add ebx, eax
127 and ecx, 255
128 and ebx, 255
129 mov DWORD PTR [edx*4+ebp],eax
130 nop
131 mov ebx, DWORD PTR [ebx*4+ebp]
132 mov eax, DWORD PTR [ecx*4+ebp]
133 mov BYTE PTR 6[esp],bl
134 ; Round 7
135 add edx, eax
136 and edx, 255
137 inc ecx
138 mov ebx, DWORD PTR [edx*4+ebp]
139 mov DWORD PTR [ecx*4+ebp-4],ebx
140 add ebx, eax
141 and ecx, 255
142 and ebx, 255
143 mov DWORD PTR [edx*4+ebp],eax
144 nop
145 mov ebx, DWORD PTR [ebx*4+ebp]
146 add edi, 8
147 mov BYTE PTR 7[esp],bl
148 ; apply the cipher text
149 mov eax, DWORD PTR [esp]
150 mov ebx, DWORD PTR [esi-8]
151 xor eax, ebx
152 mov ebx, DWORD PTR [esi-4]
153 mov DWORD PTR [edi-8],eax
154 mov eax, DWORD PTR 4[esp]
155 xor eax, ebx
156 mov ebx, DWORD PTR 8[esp]
157 mov DWORD PTR [edi-4],eax
158 mov eax, DWORD PTR [ecx*4+ebp]
159 cmp esi, ebx
160 jle L001start
161$L000end:
162 ; Round 0
163 add ebx, 8
164 inc esi
165 cmp ebx, esi
166 jl $L002finished
167 mov DWORD PTR 8[esp],ebx
168 add edx, eax
169 and edx, 255
170 inc ecx
171 mov ebx, DWORD PTR [edx*4+ebp]
172 mov DWORD PTR [ecx*4+ebp-4],ebx
173 add ebx, eax
174 and ecx, 255
175 and ebx, 255
176 mov DWORD PTR [edx*4+ebp],eax
177 nop
178 mov ebx, DWORD PTR [ebx*4+ebp]
179 mov eax, DWORD PTR [ecx*4+ebp]
180 mov bh, BYTE PTR [esi-1]
181 xor bl, bh
182 mov BYTE PTR [edi], bl
183 ; Round 1
184 mov ebx, DWORD PTR 8[esp]
185 cmp ebx, esi
186 jle $L002finished
187 inc esi
188 add edx, eax
189 and edx, 255
190 inc ecx
191 mov ebx, DWORD PTR [edx*4+ebp]
192 mov DWORD PTR [ecx*4+ebp-4],ebx
193 add ebx, eax
194 and ecx, 255
195 and ebx, 255
196 mov DWORD PTR [edx*4+ebp],eax
197 nop
198 mov ebx, DWORD PTR [ebx*4+ebp]
199 mov eax, DWORD PTR [ecx*4+ebp]
200 mov bh, BYTE PTR [esi-1]
201 xor bl, bh
202 mov BYTE PTR 1[edi],bl
203 ; Round 2
204 mov ebx, DWORD PTR 8[esp]
205 cmp ebx, esi
206 jle $L002finished
207 inc esi
208 add edx, eax
209 and edx, 255
210 inc ecx
211 mov ebx, DWORD PTR [edx*4+ebp]
212 mov DWORD PTR [ecx*4+ebp-4],ebx
213 add ebx, eax
214 and ecx, 255
215 and ebx, 255
216 mov DWORD PTR [edx*4+ebp],eax
217 nop
218 mov ebx, DWORD PTR [ebx*4+ebp]
219 mov eax, DWORD PTR [ecx*4+ebp]
220 mov bh, BYTE PTR [esi-1]
221 xor bl, bh
222 mov BYTE PTR 2[edi],bl
223 ; Round 3
224 mov ebx, DWORD PTR 8[esp]
225 cmp ebx, esi
226 jle $L002finished
227 inc esi
228 add edx, eax
229 and edx, 255
230 inc ecx
231 mov ebx, DWORD PTR [edx*4+ebp]
232 mov DWORD PTR [ecx*4+ebp-4],ebx
233 add ebx, eax
234 and ecx, 255
235 and ebx, 255
236 mov DWORD PTR [edx*4+ebp],eax
237 nop
238 mov ebx, DWORD PTR [ebx*4+ebp]
239 mov eax, DWORD PTR [ecx*4+ebp]
240 mov bh, BYTE PTR [esi-1]
241 xor bl, bh
242 mov BYTE PTR 3[edi],bl
243 ; Round 4
244 mov ebx, DWORD PTR 8[esp]
245 cmp ebx, esi
246 jle $L002finished
247 inc esi
248 add edx, eax
249 and edx, 255
250 inc ecx
251 mov ebx, DWORD PTR [edx*4+ebp]
252 mov DWORD PTR [ecx*4+ebp-4],ebx
253 add ebx, eax
254 and ecx, 255
255 and ebx, 255
256 mov DWORD PTR [edx*4+ebp],eax
257 nop
258 mov ebx, DWORD PTR [ebx*4+ebp]
259 mov eax, DWORD PTR [ecx*4+ebp]
260 mov bh, BYTE PTR [esi-1]
261 xor bl, bh
262 mov BYTE PTR 4[edi],bl
263 ; Round 5
264 mov ebx, DWORD PTR 8[esp]
265 cmp ebx, esi
266 jle $L002finished
267 inc esi
268 add edx, eax
269 and edx, 255
270 inc ecx
271 mov ebx, DWORD PTR [edx*4+ebp]
272 mov DWORD PTR [ecx*4+ebp-4],ebx
273 add ebx, eax
274 and ecx, 255
275 and ebx, 255
276 mov DWORD PTR [edx*4+ebp],eax
277 nop
278 mov ebx, DWORD PTR [ebx*4+ebp]
279 mov eax, DWORD PTR [ecx*4+ebp]
280 mov bh, BYTE PTR [esi-1]
281 xor bl, bh
282 mov BYTE PTR 5[edi],bl
283 ; Round 6
284 mov ebx, DWORD PTR 8[esp]
285 cmp ebx, esi
286 jle $L002finished
287 inc esi
288 add edx, eax
289 and edx, 255
290 inc ecx
291 mov ebx, DWORD PTR [edx*4+ebp]
292 mov DWORD PTR [ecx*4+ebp-4],ebx
293 add ebx, eax
294 and ecx, 255
295 and ebx, 255
296 mov DWORD PTR [edx*4+ebp],eax
297 nop
298 mov ebx, DWORD PTR [ebx*4+ebp]
299 mov bh, BYTE PTR [esi-1]
300 xor bl, bh
301 mov BYTE PTR 6[edi],bl
302$L002finished:
303 dec ecx
304 add esp, 12
305 mov DWORD PTR [ebp-4],edx
306 mov BYTE PTR [ebp-8],cl
307 pop edi
308 pop esi
309 pop ebx
310 pop ebp
311 ret
312_RC4 ENDP
313_TEXT ENDS
314END
diff --git a/src/lib/libcrypto/rc4/asm/rx86unix.cpp b/src/lib/libcrypto/rc4/asm/rx86unix.cpp
new file mode 100644
index 0000000000..ec1d72a110
--- /dev/null
+++ b/src/lib/libcrypto/rc4/asm/rx86unix.cpp
@@ -0,0 +1,358 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define RC4 _RC4
13
14#endif
15
16#ifdef OUT
17#define OK 1
18#define ALIGN 4
19#endif
20
21#ifdef BSDI
22#define OK 1
23#define ALIGN 4
24#undef SIZE
25#undef TYPE
26#define SIZE(a,b)
27#define TYPE(a,b)
28#endif
29
30#if defined(ELF) || defined(SOL)
31#define OK 1
32#define ALIGN 16
33#endif
34
35#ifndef OK
36You need to define one of
37ELF - elf systems - linux-elf, NetBSD and DG-UX
38OUT - a.out systems - linux-a.out and FreeBSD
39SOL - solaris systems, which are elf with strange comment lines
40BSDI - a.out with a very primative version of as.
41#endif
42
43/* Let the Assembler begin :-) */
44 /* Don't even think of reading this code */
45 /* It was automatically generated by rc4-586.pl */
46 /* Which is a perl program used to generate the x86 assember for */
47 /* any of elf, a.out, BSDI,Win32, or Solaris */
48 /* eric <eay@cryptsoft.com> */
49
50 .file "rc4-586.s"
51 .version "01.01"
52gcc2_compiled.:
53.text
54 .align ALIGN
55.globl RC4
56 TYPE(RC4,@function)
57RC4:
58
59 pushl %ebp
60 pushl %ebx
61 movl 12(%esp), %ebp
62 movl 16(%esp), %ebx
63 pushl %esi
64 pushl %edi
65 movl (%ebp), %ecx
66 movl 4(%ebp), %edx
67 movl 28(%esp), %esi
68 incl %ecx
69 subl $12, %esp
70 addl $8, %ebp
71 andl $255, %ecx
72 leal -8(%ebx,%esi,), %ebx
73 movl 44(%esp), %edi
74 movl %ebx, 8(%esp)
75 movl (%ebp,%ecx,4), %eax
76 cmpl %esi, %ebx
77 jl .L000end
78.L001start:
79 addl $8, %esi
80 /* Round 0 */
81 addl %eax, %edx
82 andl $255, %edx
83 incl %ecx
84 movl (%ebp,%edx,4), %ebx
85 movl %ebx, -4(%ebp,%ecx,4)
86 addl %eax, %ebx
87 andl $255, %ecx
88 andl $255, %ebx
89 movl %eax, (%ebp,%edx,4)
90 nop
91 movl (%ebp,%ebx,4), %ebx
92 movl (%ebp,%ecx,4), %eax
93 movb %bl, (%esp)
94 /* Round 1 */
95 addl %eax, %edx
96 andl $255, %edx
97 incl %ecx
98 movl (%ebp,%edx,4), %ebx
99 movl %ebx, -4(%ebp,%ecx,4)
100 addl %eax, %ebx
101 andl $255, %ecx
102 andl $255, %ebx
103 movl %eax, (%ebp,%edx,4)
104 nop
105 movl (%ebp,%ebx,4), %ebx
106 movl (%ebp,%ecx,4), %eax
107 movb %bl, 1(%esp)
108 /* Round 2 */
109 addl %eax, %edx
110 andl $255, %edx
111 incl %ecx
112 movl (%ebp,%edx,4), %ebx
113 movl %ebx, -4(%ebp,%ecx,4)
114 addl %eax, %ebx
115 andl $255, %ecx
116 andl $255, %ebx
117 movl %eax, (%ebp,%edx,4)
118 nop
119 movl (%ebp,%ebx,4), %ebx
120 movl (%ebp,%ecx,4), %eax
121 movb %bl, 2(%esp)
122 /* Round 3 */
123 addl %eax, %edx
124 andl $255, %edx
125 incl %ecx
126 movl (%ebp,%edx,4), %ebx
127 movl %ebx, -4(%ebp,%ecx,4)
128 addl %eax, %ebx
129 andl $255, %ecx
130 andl $255, %ebx
131 movl %eax, (%ebp,%edx,4)
132 nop
133 movl (%ebp,%ebx,4), %ebx
134 movl (%ebp,%ecx,4), %eax
135 movb %bl, 3(%esp)
136 /* Round 4 */
137 addl %eax, %edx
138 andl $255, %edx
139 incl %ecx
140 movl (%ebp,%edx,4), %ebx
141 movl %ebx, -4(%ebp,%ecx,4)
142 addl %eax, %ebx
143 andl $255, %ecx
144 andl $255, %ebx
145 movl %eax, (%ebp,%edx,4)
146 nop
147 movl (%ebp,%ebx,4), %ebx
148 movl (%ebp,%ecx,4), %eax
149 movb %bl, 4(%esp)
150 /* Round 5 */
151 addl %eax, %edx
152 andl $255, %edx
153 incl %ecx
154 movl (%ebp,%edx,4), %ebx
155 movl %ebx, -4(%ebp,%ecx,4)
156 addl %eax, %ebx
157 andl $255, %ecx
158 andl $255, %ebx
159 movl %eax, (%ebp,%edx,4)
160 nop
161 movl (%ebp,%ebx,4), %ebx
162 movl (%ebp,%ecx,4), %eax
163 movb %bl, 5(%esp)
164 /* Round 6 */
165 addl %eax, %edx
166 andl $255, %edx
167 incl %ecx
168 movl (%ebp,%edx,4), %ebx
169 movl %ebx, -4(%ebp,%ecx,4)
170 addl %eax, %ebx
171 andl $255, %ecx
172 andl $255, %ebx
173 movl %eax, (%ebp,%edx,4)
174 nop
175 movl (%ebp,%ebx,4), %ebx
176 movl (%ebp,%ecx,4), %eax
177 movb %bl, 6(%esp)
178 /* Round 7 */
179 addl %eax, %edx
180 andl $255, %edx
181 incl %ecx
182 movl (%ebp,%edx,4), %ebx
183 movl %ebx, -4(%ebp,%ecx,4)
184 addl %eax, %ebx
185 andl $255, %ecx
186 andl $255, %ebx
187 movl %eax, (%ebp,%edx,4)
188 nop
189 movl (%ebp,%ebx,4), %ebx
190 addl $8, %edi
191 movb %bl, 7(%esp)
192 /* apply the cipher text */
193 movl (%esp), %eax
194 movl -8(%esi), %ebx
195 xorl %ebx, %eax
196 movl -4(%esi), %ebx
197 movl %eax, -8(%edi)
198 movl 4(%esp), %eax
199 xorl %ebx, %eax
200 movl 8(%esp), %ebx
201 movl %eax, -4(%edi)
202 movl (%ebp,%ecx,4), %eax
203 cmpl %ebx, %esi
204 jle .L001start
205.L000end:
206 /* Round 0 */
207 addl $8, %ebx
208 incl %esi
209 cmpl %esi, %ebx
210 jl .L002finished
211 movl %ebx, 8(%esp)
212 addl %eax, %edx
213 andl $255, %edx
214 incl %ecx
215 movl (%ebp,%edx,4), %ebx
216 movl %ebx, -4(%ebp,%ecx,4)
217 addl %eax, %ebx
218 andl $255, %ecx
219 andl $255, %ebx
220 movl %eax, (%ebp,%edx,4)
221 nop
222 movl (%ebp,%ebx,4), %ebx
223 movl (%ebp,%ecx,4), %eax
224 movb -1(%esi), %bh
225 xorb %bh, %bl
226 movb %bl, (%edi)
227 /* Round 1 */
228 movl 8(%esp), %ebx
229 cmpl %esi, %ebx
230 jle .L002finished
231 incl %esi
232 addl %eax, %edx
233 andl $255, %edx
234 incl %ecx
235 movl (%ebp,%edx,4), %ebx
236 movl %ebx, -4(%ebp,%ecx,4)
237 addl %eax, %ebx
238 andl $255, %ecx
239 andl $255, %ebx
240 movl %eax, (%ebp,%edx,4)
241 nop
242 movl (%ebp,%ebx,4), %ebx
243 movl (%ebp,%ecx,4), %eax
244 movb -1(%esi), %bh
245 xorb %bh, %bl
246 movb %bl, 1(%edi)
247 /* Round 2 */
248 movl 8(%esp), %ebx
249 cmpl %esi, %ebx
250 jle .L002finished
251 incl %esi
252 addl %eax, %edx
253 andl $255, %edx
254 incl %ecx
255 movl (%ebp,%edx,4), %ebx
256 movl %ebx, -4(%ebp,%ecx,4)
257 addl %eax, %ebx
258 andl $255, %ecx
259 andl $255, %ebx
260 movl %eax, (%ebp,%edx,4)
261 nop
262 movl (%ebp,%ebx,4), %ebx
263 movl (%ebp,%ecx,4), %eax
264 movb -1(%esi), %bh
265 xorb %bh, %bl
266 movb %bl, 2(%edi)
267 /* Round 3 */
268 movl 8(%esp), %ebx
269 cmpl %esi, %ebx
270 jle .L002finished
271 incl %esi
272 addl %eax, %edx
273 andl $255, %edx
274 incl %ecx
275 movl (%ebp,%edx,4), %ebx
276 movl %ebx, -4(%ebp,%ecx,4)
277 addl %eax, %ebx
278 andl $255, %ecx
279 andl $255, %ebx
280 movl %eax, (%ebp,%edx,4)
281 nop
282 movl (%ebp,%ebx,4), %ebx
283 movl (%ebp,%ecx,4), %eax
284 movb -1(%esi), %bh
285 xorb %bh, %bl
286 movb %bl, 3(%edi)
287 /* Round 4 */
288 movl 8(%esp), %ebx
289 cmpl %esi, %ebx
290 jle .L002finished
291 incl %esi
292 addl %eax, %edx
293 andl $255, %edx
294 incl %ecx
295 movl (%ebp,%edx,4), %ebx
296 movl %ebx, -4(%ebp,%ecx,4)
297 addl %eax, %ebx
298 andl $255, %ecx
299 andl $255, %ebx
300 movl %eax, (%ebp,%edx,4)
301 nop
302 movl (%ebp,%ebx,4), %ebx
303 movl (%ebp,%ecx,4), %eax
304 movb -1(%esi), %bh
305 xorb %bh, %bl
306 movb %bl, 4(%edi)
307 /* Round 5 */
308 movl 8(%esp), %ebx
309 cmpl %esi, %ebx
310 jle .L002finished
311 incl %esi
312 addl %eax, %edx
313 andl $255, %edx
314 incl %ecx
315 movl (%ebp,%edx,4), %ebx
316 movl %ebx, -4(%ebp,%ecx,4)
317 addl %eax, %ebx
318 andl $255, %ecx
319 andl $255, %ebx
320 movl %eax, (%ebp,%edx,4)
321 nop
322 movl (%ebp,%ebx,4), %ebx
323 movl (%ebp,%ecx,4), %eax
324 movb -1(%esi), %bh
325 xorb %bh, %bl
326 movb %bl, 5(%edi)
327 /* Round 6 */
328 movl 8(%esp), %ebx
329 cmpl %esi, %ebx
330 jle .L002finished
331 incl %esi
332 addl %eax, %edx
333 andl $255, %edx
334 incl %ecx
335 movl (%ebp,%edx,4), %ebx
336 movl %ebx, -4(%ebp,%ecx,4)
337 addl %eax, %ebx
338 andl $255, %ecx
339 andl $255, %ebx
340 movl %eax, (%ebp,%edx,4)
341 nop
342 movl (%ebp,%ebx,4), %ebx
343 movb -1(%esi), %bh
344 xorb %bh, %bl
345 movb %bl, 6(%edi)
346.L002finished:
347 decl %ecx
348 addl $12, %esp
349 movl %edx, -4(%ebp)
350 movb %cl, -8(%ebp)
351 popl %edi
352 popl %esi
353 popl %ebx
354 popl %ebp
355 ret
356.RC4_end:
357 SIZE(RC4,.RC4_end-RC4)
358.ident "RC4"
diff --git a/src/lib/libcrypto/rc4/rc4.org b/src/lib/libcrypto/rc4/rc4.org
new file mode 100644
index 0000000000..c558651af8
--- /dev/null
+++ b/src/lib/libcrypto/rc4/rc4.org
@@ -0,0 +1,103 @@
1/* crypto/rc4/rc4.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify rc4.org since rc4.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_RC4_H
68#define HEADER_RC4_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74/* using int types make the structure larger but make the code faster
75 * on most boxes I have tested - up to %20 faster. */
76#define RC4_INT unsigned int
77
78typedef struct rc4_key_st
79 {
80 RC4_INT x,y;
81 RC4_INT data[256];
82 } RC4_KEY;
83
84#ifndef NOPROTO
85
86char *RC4_options(void);
87void RC4_set_key(RC4_KEY *key, int len, unsigned char *data);
88void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata,
89 unsigned char *outdata);
90
91#else
92
93char *RC4_options();
94void RC4_set_key();
95void RC4();
96
97#endif
98
99#ifdef __cplusplus
100}
101#endif
102
103#endif
diff --git a/src/lib/libcrypto/rc4/rc4_locl.org b/src/lib/libcrypto/rc4/rc4_locl.org
new file mode 100644
index 0000000000..1ef4455fb7
--- /dev/null
+++ b/src/lib/libcrypto/rc4/rc4_locl.org
@@ -0,0 +1,70 @@
1/* crypto/rc4/rc4_locl.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify bf_locl.org since bf_locl.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67/* if this is defined data[i] is used instead of *data, this is a %20
68 * speedup on x86 */
69#undef RC4_INDEX
70
diff --git a/src/lib/libcrypto/rc5/Makefile.ssl b/src/lib/libcrypto/rc5/Makefile.ssl
new file mode 100644
index 0000000000..5e98ee2348
--- /dev/null
+++ b/src/lib/libcrypto/rc5/Makefile.ssl
@@ -0,0 +1,107 @@
1#
2# SSLeay/crypto/rc5/Makefile
3#
4
5DIR= rc5
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17RC5_ENC= rc5_enc.o
18# or use
19#DES_ENC= r586-elf.o
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL=Makefile
24TEST=rc5test.c
25APPS=
26
27LIB=$(TOP)/libcrypto.a
28LIBSRC=rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c
29LIBOBJ=rc5_skey.o rc5_ecb.o $(RC5_ENC) rc5cfb64.o rc5ofb64.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= rc5.h
34HEADER= rc5_locl.h $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: lib
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 sh $(TOP)/util/ranlib.sh $(LIB)
46 @touch lib
47
48# elf
49asm/r586-elf.o: asm/r586unix.cpp
50 $(CPP) -DELF asm/r586unix.cpp | as -o asm/r586-elf.o
51
52# solaris
53asm/r586-sol.o: asm/r586unix.cpp
54 $(CC) -E -DSOL asm/r586unix.cpp | sed 's/^#.*//' > asm/r586-sol.s
55 as -o asm/r586-sol.o asm/r586-sol.s
56 rm -f asm/r586-sol.s
57
58# a.out
59asm/r586-out.o: asm/r586unix.cpp
60 $(CPP) -DOUT asm/r586unix.cpp | as -o asm/r586-out.o
61
62# bsdi
63asm/r586bsdi.o: asm/r586unix.cpp
64 $(CPP) -DBSDI asm/r586unix.cpp | as -o asm/r586bsdi.o
65
66asm/r586unix.cpp:
67 (cd asm; perl rc5-586.pl cpp >r586unix.cpp)
68
69files:
70 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
71
72links:
73 /bin/rm -f Makefile
74 $(TOP)/util/point.sh Makefile.ssl Makefile ;
75 $(TOP)/util/point.sh ../../doc/rc5.doc rc5.doc ;
76 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
77 $(TOP)/util/mklink.sh ../../test $(TEST)
78 $(TOP)/util/mklink.sh ../../apps $(APPS)
79
80install:
81 @for i in $(EXHEADER) ; \
82 do \
83 (cp $$i $(INSTALLTOP)/include/$$i; \
84 chmod 644 $(INSTALLTOP)/include/$$i ); \
85 done;
86
87tags:
88 ctags $(SRC)
89
90tests:
91
92lint:
93 lint -DLINT $(INCLUDES) $(SRC)>fluff
94
95depend:
96 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
97
98dclean:
99 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
100 mv -f Makefile.new $(MAKEFILE)
101
102clean:
103 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
104
105errors:
106
107# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/rc5/Makefile.uni b/src/lib/libcrypto/rc5/Makefile.uni
new file mode 100644
index 0000000000..e50b3f2d19
--- /dev/null
+++ b/src/lib/libcrypto/rc5/Makefile.uni
@@ -0,0 +1,72 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5
6DIR= rc2
7TOP= .
8CC= gcc
9CFLAG= -O3 -fomit-frame-pointer
10
11CPP= $(CC) -E
12INCLUDES=
13INSTALLTOP=/usr/local/lib
14MAKE= make
15MAKEDEPEND= makedepend
16MAKEFILE= Makefile.uni
17AR= ar r
18
19IDEA_ENC=rc2_cbc.o
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL=Makefile
24TEST=rc2test
25APPS=rc2speed
26
27LIB=librc2.a
28LIBSRC=rc2_skey.c rc2_ecb.c rc2_cbc.c rc2cfb64.c rc2ofb64.c
29LIBOBJ=rc2_skey.o rc2_ecb.o $(IDEA_ENC) rc2cfb64.o rc2ofb64.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= rc2.h
34HEADER= rc2_locl.h $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38all: $(LIB) $(TEST) $(APPS)
39
40$(LIB): $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/ranlib.sh $(LIB)
43
44test: $(TEST)
45 ./$(TEST)
46
47$(TEST): $(TEST).c $(LIB)
48 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
49
50$(APPS): $(APPS).c $(LIB)
51 $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
52
53lint:
54 lint -DLINT $(INCLUDES) $(SRC)>fluff
55
56depend:
57 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
58
59dclean:
60 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
61 mv -f Makefile.new $(MAKEFILE)
62
63clean:
64 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
65
66cc:
67 $(MAKE) CC="cc" CFLAG="-O" all
68
69gcc:
70 $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
71
72# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/rc5/asm/r5-win32.asm b/src/lib/libcrypto/rc5/asm/r5-win32.asm
new file mode 100644
index 0000000000..f43d3711f0
--- /dev/null
+++ b/src/lib/libcrypto/rc5/asm/r5-win32.asm
@@ -0,0 +1,574 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by rc5-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE rc5-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _RC5_32_encrypt
12
13_RC5_32_encrypt PROC NEAR
14 ;
15 push ebp
16 push esi
17 push edi
18 mov edx, DWORD PTR 16[esp]
19 mov ebp, DWORD PTR 20[esp]
20 ; Load the 2 words
21 mov edi, DWORD PTR [edx]
22 mov esi, DWORD PTR 4[edx]
23 push ebx
24 mov ebx, DWORD PTR [ebp]
25 add edi, DWORD PTR 4[ebp]
26 add esi, DWORD PTR 8[ebp]
27 xor edi, esi
28 mov eax, DWORD PTR 12[ebp]
29 mov ecx, esi
30 rol edi, cl
31 add edi, eax
32 xor esi, edi
33 mov eax, DWORD PTR 16[ebp]
34 mov ecx, edi
35 rol esi, cl
36 add esi, eax
37 xor edi, esi
38 mov eax, DWORD PTR 20[ebp]
39 mov ecx, esi
40 rol edi, cl
41 add edi, eax
42 xor esi, edi
43 mov eax, DWORD PTR 24[ebp]
44 mov ecx, edi
45 rol esi, cl
46 add esi, eax
47 xor edi, esi
48 mov eax, DWORD PTR 28[ebp]
49 mov ecx, esi
50 rol edi, cl
51 add edi, eax
52 xor esi, edi
53 mov eax, DWORD PTR 32[ebp]
54 mov ecx, edi
55 rol esi, cl
56 add esi, eax
57 xor edi, esi
58 mov eax, DWORD PTR 36[ebp]
59 mov ecx, esi
60 rol edi, cl
61 add edi, eax
62 xor esi, edi
63 mov eax, DWORD PTR 40[ebp]
64 mov ecx, edi
65 rol esi, cl
66 add esi, eax
67 xor edi, esi
68 mov eax, DWORD PTR 44[ebp]
69 mov ecx, esi
70 rol edi, cl
71 add edi, eax
72 xor esi, edi
73 mov eax, DWORD PTR 48[ebp]
74 mov ecx, edi
75 rol esi, cl
76 add esi, eax
77 xor edi, esi
78 mov eax, DWORD PTR 52[ebp]
79 mov ecx, esi
80 rol edi, cl
81 add edi, eax
82 xor esi, edi
83 mov eax, DWORD PTR 56[ebp]
84 mov ecx, edi
85 rol esi, cl
86 add esi, eax
87 xor edi, esi
88 mov eax, DWORD PTR 60[ebp]
89 mov ecx, esi
90 rol edi, cl
91 add edi, eax
92 xor esi, edi
93 mov eax, DWORD PTR 64[ebp]
94 mov ecx, edi
95 rol esi, cl
96 add esi, eax
97 xor edi, esi
98 mov eax, DWORD PTR 68[ebp]
99 mov ecx, esi
100 rol edi, cl
101 add edi, eax
102 xor esi, edi
103 mov eax, DWORD PTR 72[ebp]
104 mov ecx, edi
105 rol esi, cl
106 add esi, eax
107 cmp ebx, 8
108 je $L000rc5_exit
109 xor edi, esi
110 mov eax, DWORD PTR 76[ebp]
111 mov ecx, esi
112 rol edi, cl
113 add edi, eax
114 xor esi, edi
115 mov eax, DWORD PTR 80[ebp]
116 mov ecx, edi
117 rol esi, cl
118 add esi, eax
119 xor edi, esi
120 mov eax, DWORD PTR 84[ebp]
121 mov ecx, esi
122 rol edi, cl
123 add edi, eax
124 xor esi, edi
125 mov eax, DWORD PTR 88[ebp]
126 mov ecx, edi
127 rol esi, cl
128 add esi, eax
129 xor edi, esi
130 mov eax, DWORD PTR 92[ebp]
131 mov ecx, esi
132 rol edi, cl
133 add edi, eax
134 xor esi, edi
135 mov eax, DWORD PTR 96[ebp]
136 mov ecx, edi
137 rol esi, cl
138 add esi, eax
139 xor edi, esi
140 mov eax, DWORD PTR 100[ebp]
141 mov ecx, esi
142 rol edi, cl
143 add edi, eax
144 xor esi, edi
145 mov eax, DWORD PTR 104[ebp]
146 mov ecx, edi
147 rol esi, cl
148 add esi, eax
149 cmp ebx, 12
150 je $L000rc5_exit
151 xor edi, esi
152 mov eax, DWORD PTR 108[ebp]
153 mov ecx, esi
154 rol edi, cl
155 add edi, eax
156 xor esi, edi
157 mov eax, DWORD PTR 112[ebp]
158 mov ecx, edi
159 rol esi, cl
160 add esi, eax
161 xor edi, esi
162 mov eax, DWORD PTR 116[ebp]
163 mov ecx, esi
164 rol edi, cl
165 add edi, eax
166 xor esi, edi
167 mov eax, DWORD PTR 120[ebp]
168 mov ecx, edi
169 rol esi, cl
170 add esi, eax
171 xor edi, esi
172 mov eax, DWORD PTR 124[ebp]
173 mov ecx, esi
174 rol edi, cl
175 add edi, eax
176 xor esi, edi
177 mov eax, DWORD PTR 128[ebp]
178 mov ecx, edi
179 rol esi, cl
180 add esi, eax
181 xor edi, esi
182 mov eax, DWORD PTR 132[ebp]
183 mov ecx, esi
184 rol edi, cl
185 add edi, eax
186 xor esi, edi
187 mov eax, DWORD PTR 136[ebp]
188 mov ecx, edi
189 rol esi, cl
190 add esi, eax
191$L000rc5_exit:
192 mov DWORD PTR [edx],edi
193 mov DWORD PTR 4[edx],esi
194 pop ebx
195 pop edi
196 pop esi
197 pop ebp
198 ret
199_RC5_32_encrypt ENDP
200_TEXT ENDS
201_TEXT SEGMENT
202PUBLIC _RC5_32_decrypt
203
204_RC5_32_decrypt PROC NEAR
205 ;
206 push ebp
207 push esi
208 push edi
209 mov edx, DWORD PTR 16[esp]
210 mov ebp, DWORD PTR 20[esp]
211 ; Load the 2 words
212 mov edi, DWORD PTR [edx]
213 mov esi, DWORD PTR 4[edx]
214 push ebx
215 mov ebx, DWORD PTR [ebp]
216 cmp ebx, 12
217 je $L001rc5_dec_12
218 cmp ebx, 8
219 je $L002rc5_dec_8
220 mov eax, DWORD PTR 136[ebp]
221 sub esi, eax
222 mov ecx, edi
223 ror esi, cl
224 xor esi, edi
225 mov eax, DWORD PTR 132[ebp]
226 sub edi, eax
227 mov ecx, esi
228 ror edi, cl
229 xor edi, esi
230 mov eax, DWORD PTR 128[ebp]
231 sub esi, eax
232 mov ecx, edi
233 ror esi, cl
234 xor esi, edi
235 mov eax, DWORD PTR 124[ebp]
236 sub edi, eax
237 mov ecx, esi
238 ror edi, cl
239 xor edi, esi
240 mov eax, DWORD PTR 120[ebp]
241 sub esi, eax
242 mov ecx, edi
243 ror esi, cl
244 xor esi, edi
245 mov eax, DWORD PTR 116[ebp]
246 sub edi, eax
247 mov ecx, esi
248 ror edi, cl
249 xor edi, esi
250 mov eax, DWORD PTR 112[ebp]
251 sub esi, eax
252 mov ecx, edi
253 ror esi, cl
254 xor esi, edi
255 mov eax, DWORD PTR 108[ebp]
256 sub edi, eax
257 mov ecx, esi
258 ror edi, cl
259 xor edi, esi
260$L001rc5_dec_12:
261 mov eax, DWORD PTR 104[ebp]
262 sub esi, eax
263 mov ecx, edi
264 ror esi, cl
265 xor esi, edi
266 mov eax, DWORD PTR 100[ebp]
267 sub edi, eax
268 mov ecx, esi
269 ror edi, cl
270 xor edi, esi
271 mov eax, DWORD PTR 96[ebp]
272 sub esi, eax
273 mov ecx, edi
274 ror esi, cl
275 xor esi, edi
276 mov eax, DWORD PTR 92[ebp]
277 sub edi, eax
278 mov ecx, esi
279 ror edi, cl
280 xor edi, esi
281 mov eax, DWORD PTR 88[ebp]
282 sub esi, eax
283 mov ecx, edi
284 ror esi, cl
285 xor esi, edi
286 mov eax, DWORD PTR 84[ebp]
287 sub edi, eax
288 mov ecx, esi
289 ror edi, cl
290 xor edi, esi
291 mov eax, DWORD PTR 80[ebp]
292 sub esi, eax
293 mov ecx, edi
294 ror esi, cl
295 xor esi, edi
296 mov eax, DWORD PTR 76[ebp]
297 sub edi, eax
298 mov ecx, esi
299 ror edi, cl
300 xor edi, esi
301$L002rc5_dec_8:
302 mov eax, DWORD PTR 72[ebp]
303 sub esi, eax
304 mov ecx, edi
305 ror esi, cl
306 xor esi, edi
307 mov eax, DWORD PTR 68[ebp]
308 sub edi, eax
309 mov ecx, esi
310 ror edi, cl
311 xor edi, esi
312 mov eax, DWORD PTR 64[ebp]
313 sub esi, eax
314 mov ecx, edi
315 ror esi, cl
316 xor esi, edi
317 mov eax, DWORD PTR 60[ebp]
318 sub edi, eax
319 mov ecx, esi
320 ror edi, cl
321 xor edi, esi
322 mov eax, DWORD PTR 56[ebp]
323 sub esi, eax
324 mov ecx, edi
325 ror esi, cl
326 xor esi, edi
327 mov eax, DWORD PTR 52[ebp]
328 sub edi, eax
329 mov ecx, esi
330 ror edi, cl
331 xor edi, esi
332 mov eax, DWORD PTR 48[ebp]
333 sub esi, eax
334 mov ecx, edi
335 ror esi, cl
336 xor esi, edi
337 mov eax, DWORD PTR 44[ebp]
338 sub edi, eax
339 mov ecx, esi
340 ror edi, cl
341 xor edi, esi
342 mov eax, DWORD PTR 40[ebp]
343 sub esi, eax
344 mov ecx, edi
345 ror esi, cl
346 xor esi, edi
347 mov eax, DWORD PTR 36[ebp]
348 sub edi, eax
349 mov ecx, esi
350 ror edi, cl
351 xor edi, esi
352 mov eax, DWORD PTR 32[ebp]
353 sub esi, eax
354 mov ecx, edi
355 ror esi, cl
356 xor esi, edi
357 mov eax, DWORD PTR 28[ebp]
358 sub edi, eax
359 mov ecx, esi
360 ror edi, cl
361 xor edi, esi
362 mov eax, DWORD PTR 24[ebp]
363 sub esi, eax
364 mov ecx, edi
365 ror esi, cl
366 xor esi, edi
367 mov eax, DWORD PTR 20[ebp]
368 sub edi, eax
369 mov ecx, esi
370 ror edi, cl
371 xor edi, esi
372 mov eax, DWORD PTR 16[ebp]
373 sub esi, eax
374 mov ecx, edi
375 ror esi, cl
376 xor esi, edi
377 mov eax, DWORD PTR 12[ebp]
378 sub edi, eax
379 mov ecx, esi
380 ror edi, cl
381 xor edi, esi
382 sub esi, DWORD PTR 8[ebp]
383 sub edi, DWORD PTR 4[ebp]
384L003rc5_exit:
385 mov DWORD PTR [edx],edi
386 mov DWORD PTR 4[edx],esi
387 pop ebx
388 pop edi
389 pop esi
390 pop ebp
391 ret
392_RC5_32_decrypt ENDP
393_TEXT ENDS
394_TEXT SEGMENT
395PUBLIC _RC5_32_cbc_encrypt
396
397_RC5_32_cbc_encrypt PROC NEAR
398 ;
399 push ebp
400 push ebx
401 push esi
402 push edi
403 mov ebp, DWORD PTR 28[esp]
404 ; getting iv ptr from parameter 4
405 mov ebx, DWORD PTR 36[esp]
406 mov esi, DWORD PTR [ebx]
407 mov edi, DWORD PTR 4[ebx]
408 push edi
409 push esi
410 push edi
411 push esi
412 mov ebx, esp
413 mov esi, DWORD PTR 36[esp]
414 mov edi, DWORD PTR 40[esp]
415 ; getting encrypt flag from parameter 5
416 mov ecx, DWORD PTR 56[esp]
417 ; get and push parameter 3
418 mov eax, DWORD PTR 48[esp]
419 push eax
420 push ebx
421 cmp ecx, 0
422 jz $L004decrypt
423 and ebp, 4294967288
424 mov eax, DWORD PTR 8[esp]
425 mov ebx, DWORD PTR 12[esp]
426 jz $L005encrypt_finish
427L006encrypt_loop:
428 mov ecx, DWORD PTR [esi]
429 mov edx, DWORD PTR 4[esi]
430 xor eax, ecx
431 xor ebx, edx
432 mov DWORD PTR 8[esp],eax
433 mov DWORD PTR 12[esp],ebx
434 call _RC5_32_encrypt
435 mov eax, DWORD PTR 8[esp]
436 mov ebx, DWORD PTR 12[esp]
437 mov DWORD PTR [edi],eax
438 mov DWORD PTR 4[edi],ebx
439 add esi, 8
440 add edi, 8
441 sub ebp, 8
442 jnz L006encrypt_loop
443$L005encrypt_finish:
444 mov ebp, DWORD PTR 52[esp]
445 and ebp, 7
446 jz $L007finish
447 xor ecx, ecx
448 xor edx, edx
449 mov ebp, DWORD PTR $L008cbc_enc_jmp_table[ebp*4]
450 jmp ebp
451L009ej7:
452 mov dh, BYTE PTR 6[esi]
453 shl edx, 8
454L010ej6:
455 mov dh, BYTE PTR 5[esi]
456L011ej5:
457 mov dl, BYTE PTR 4[esi]
458L012ej4:
459 mov ecx, DWORD PTR [esi]
460 jmp $L013ejend
461L014ej3:
462 mov ch, BYTE PTR 2[esi]
463 shl ecx, 8
464L015ej2:
465 mov ch, BYTE PTR 1[esi]
466L016ej1:
467 mov cl, BYTE PTR [esi]
468$L013ejend:
469 xor eax, ecx
470 xor ebx, edx
471 mov DWORD PTR 8[esp],eax
472 mov DWORD PTR 12[esp],ebx
473 call _RC5_32_encrypt
474 mov eax, DWORD PTR 8[esp]
475 mov ebx, DWORD PTR 12[esp]
476 mov DWORD PTR [edi],eax
477 mov DWORD PTR 4[edi],ebx
478 jmp $L007finish
479$L004decrypt:
480 and ebp, 4294967288
481 mov eax, DWORD PTR 16[esp]
482 mov ebx, DWORD PTR 20[esp]
483 jz $L017decrypt_finish
484L018decrypt_loop:
485 mov eax, DWORD PTR [esi]
486 mov ebx, DWORD PTR 4[esi]
487 mov DWORD PTR 8[esp],eax
488 mov DWORD PTR 12[esp],ebx
489 call _RC5_32_decrypt
490 mov eax, DWORD PTR 8[esp]
491 mov ebx, DWORD PTR 12[esp]
492 mov ecx, DWORD PTR 16[esp]
493 mov edx, DWORD PTR 20[esp]
494 xor ecx, eax
495 xor edx, ebx
496 mov eax, DWORD PTR [esi]
497 mov ebx, DWORD PTR 4[esi]
498 mov DWORD PTR [edi],ecx
499 mov DWORD PTR 4[edi],edx
500 mov DWORD PTR 16[esp],eax
501 mov DWORD PTR 20[esp],ebx
502 add esi, 8
503 add edi, 8
504 sub ebp, 8
505 jnz L018decrypt_loop
506$L017decrypt_finish:
507 mov ebp, DWORD PTR 52[esp]
508 and ebp, 7
509 jz $L007finish
510 mov eax, DWORD PTR [esi]
511 mov ebx, DWORD PTR 4[esi]
512 mov DWORD PTR 8[esp],eax
513 mov DWORD PTR 12[esp],ebx
514 call _RC5_32_decrypt
515 mov eax, DWORD PTR 8[esp]
516 mov ebx, DWORD PTR 12[esp]
517 mov ecx, DWORD PTR 16[esp]
518 mov edx, DWORD PTR 20[esp]
519 xor ecx, eax
520 xor edx, ebx
521 mov eax, DWORD PTR [esi]
522 mov ebx, DWORD PTR 4[esi]
523L019dj7:
524 ror edx, 16
525 mov BYTE PTR 6[edi],dl
526 shr edx, 16
527L020dj6:
528 mov BYTE PTR 5[edi],dh
529L021dj5:
530 mov BYTE PTR 4[edi],dl
531L022dj4:
532 mov DWORD PTR [edi],ecx
533 jmp $L023djend
534L024dj3:
535 ror ecx, 16
536 mov BYTE PTR 2[edi],cl
537 shl ecx, 16
538L025dj2:
539 mov BYTE PTR 1[esi],ch
540L026dj1:
541 mov BYTE PTR [esi], cl
542$L023djend:
543 jmp $L007finish
544$L007finish:
545 mov ecx, DWORD PTR 60[esp]
546 add esp, 24
547 mov DWORD PTR [ecx],eax
548 mov DWORD PTR 4[ecx],ebx
549 pop edi
550 pop esi
551 pop ebx
552 pop ebp
553 ret
554$L008cbc_enc_jmp_table:
555 DD 0
556 DD L016ej1
557 DD L015ej2
558 DD L014ej3
559 DD L012ej4
560 DD L011ej5
561 DD L010ej6
562 DD L009ej7
563L027cbc_dec_jmp_table:
564 DD 0
565 DD L026dj1
566 DD L025dj2
567 DD L024dj3
568 DD L022dj4
569 DD L021dj5
570 DD L020dj6
571 DD L019dj7
572_RC5_32_cbc_encrypt ENDP
573_TEXT ENDS
574END
diff --git a/src/lib/libcrypto/rc5/asm/r586unix.cpp b/src/lib/libcrypto/rc5/asm/r586unix.cpp
new file mode 100644
index 0000000000..a25dd5a9a4
--- /dev/null
+++ b/src/lib/libcrypto/rc5/asm/r586unix.cpp
@@ -0,0 +1,628 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define RC5_32_encrypt _RC5_32_encrypt
13#define RC5_32_decrypt _RC5_32_decrypt
14#define RC5_32_cbc_encrypt _RC5_32_cbc_encrypt
15
16#endif
17
18#ifdef OUT
19#define OK 1
20#define ALIGN 4
21#endif
22
23#ifdef BSDI
24#define OK 1
25#define ALIGN 4
26#undef SIZE
27#undef TYPE
28#define SIZE(a,b)
29#define TYPE(a,b)
30#endif
31
32#if defined(ELF) || defined(SOL)
33#define OK 1
34#define ALIGN 16
35#endif
36
37#ifndef OK
38You need to define one of
39ELF - elf systems - linux-elf, NetBSD and DG-UX
40OUT - a.out systems - linux-a.out and FreeBSD
41SOL - solaris systems, which are elf with strange comment lines
42BSDI - a.out with a very primative version of as.
43#endif
44
45/* Let the Assembler begin :-) */
46 /* Don't even think of reading this code */
47 /* It was automatically generated by rc5-586.pl */
48 /* Which is a perl program used to generate the x86 assember for */
49 /* any of elf, a.out, BSDI,Win32, or Solaris */
50 /* eric <eay@cryptsoft.com> */
51
52 .file "rc5-586.s"
53 .version "01.01"
54gcc2_compiled.:
55.text
56 .align ALIGN
57.globl RC5_32_encrypt
58 TYPE(RC5_32_encrypt,@function)
59RC5_32_encrypt:
60
61 pushl %ebp
62 pushl %esi
63 pushl %edi
64 movl 16(%esp), %edx
65 movl 20(%esp), %ebp
66 /* Load the 2 words */
67 movl (%edx), %edi
68 movl 4(%edx), %esi
69 pushl %ebx
70 movl (%ebp), %ebx
71 addl 4(%ebp), %edi
72 addl 8(%ebp), %esi
73 xorl %esi, %edi
74 movl 12(%ebp), %eax
75 movl %esi, %ecx
76 roll %cl, %edi
77 addl %eax, %edi
78 xorl %edi, %esi
79 movl 16(%ebp), %eax
80 movl %edi, %ecx
81 roll %cl, %esi
82 addl %eax, %esi
83 xorl %esi, %edi
84 movl 20(%ebp), %eax
85 movl %esi, %ecx
86 roll %cl, %edi
87 addl %eax, %edi
88 xorl %edi, %esi
89 movl 24(%ebp), %eax
90 movl %edi, %ecx
91 roll %cl, %esi
92 addl %eax, %esi
93 xorl %esi, %edi
94 movl 28(%ebp), %eax
95 movl %esi, %ecx
96 roll %cl, %edi
97 addl %eax, %edi
98 xorl %edi, %esi
99 movl 32(%ebp), %eax
100 movl %edi, %ecx
101 roll %cl, %esi
102 addl %eax, %esi
103 xorl %esi, %edi
104 movl 36(%ebp), %eax
105 movl %esi, %ecx
106 roll %cl, %edi
107 addl %eax, %edi
108 xorl %edi, %esi
109 movl 40(%ebp), %eax
110 movl %edi, %ecx
111 roll %cl, %esi
112 addl %eax, %esi
113 xorl %esi, %edi
114 movl 44(%ebp), %eax
115 movl %esi, %ecx
116 roll %cl, %edi
117 addl %eax, %edi
118 xorl %edi, %esi
119 movl 48(%ebp), %eax
120 movl %edi, %ecx
121 roll %cl, %esi
122 addl %eax, %esi
123 xorl %esi, %edi
124 movl 52(%ebp), %eax
125 movl %esi, %ecx
126 roll %cl, %edi
127 addl %eax, %edi
128 xorl %edi, %esi
129 movl 56(%ebp), %eax
130 movl %edi, %ecx
131 roll %cl, %esi
132 addl %eax, %esi
133 xorl %esi, %edi
134 movl 60(%ebp), %eax
135 movl %esi, %ecx
136 roll %cl, %edi
137 addl %eax, %edi
138 xorl %edi, %esi
139 movl 64(%ebp), %eax
140 movl %edi, %ecx
141 roll %cl, %esi
142 addl %eax, %esi
143 xorl %esi, %edi
144 movl 68(%ebp), %eax
145 movl %esi, %ecx
146 roll %cl, %edi
147 addl %eax, %edi
148 xorl %edi, %esi
149 movl 72(%ebp), %eax
150 movl %edi, %ecx
151 roll %cl, %esi
152 addl %eax, %esi
153 cmpl $8, %ebx
154 je .L000rc5_exit
155 xorl %esi, %edi
156 movl 76(%ebp), %eax
157 movl %esi, %ecx
158 roll %cl, %edi
159 addl %eax, %edi
160 xorl %edi, %esi
161 movl 80(%ebp), %eax
162 movl %edi, %ecx
163 roll %cl, %esi
164 addl %eax, %esi
165 xorl %esi, %edi
166 movl 84(%ebp), %eax
167 movl %esi, %ecx
168 roll %cl, %edi
169 addl %eax, %edi
170 xorl %edi, %esi
171 movl 88(%ebp), %eax
172 movl %edi, %ecx
173 roll %cl, %esi
174 addl %eax, %esi
175 xorl %esi, %edi
176 movl 92(%ebp), %eax
177 movl %esi, %ecx
178 roll %cl, %edi
179 addl %eax, %edi
180 xorl %edi, %esi
181 movl 96(%ebp), %eax
182 movl %edi, %ecx
183 roll %cl, %esi
184 addl %eax, %esi
185 xorl %esi, %edi
186 movl 100(%ebp), %eax
187 movl %esi, %ecx
188 roll %cl, %edi
189 addl %eax, %edi
190 xorl %edi, %esi
191 movl 104(%ebp), %eax
192 movl %edi, %ecx
193 roll %cl, %esi
194 addl %eax, %esi
195 cmpl $12, %ebx
196 je .L000rc5_exit
197 xorl %esi, %edi
198 movl 108(%ebp), %eax
199 movl %esi, %ecx
200 roll %cl, %edi
201 addl %eax, %edi
202 xorl %edi, %esi
203 movl 112(%ebp), %eax
204 movl %edi, %ecx
205 roll %cl, %esi
206 addl %eax, %esi
207 xorl %esi, %edi
208 movl 116(%ebp), %eax
209 movl %esi, %ecx
210 roll %cl, %edi
211 addl %eax, %edi
212 xorl %edi, %esi
213 movl 120(%ebp), %eax
214 movl %edi, %ecx
215 roll %cl, %esi
216 addl %eax, %esi
217 xorl %esi, %edi
218 movl 124(%ebp), %eax
219 movl %esi, %ecx
220 roll %cl, %edi
221 addl %eax, %edi
222 xorl %edi, %esi
223 movl 128(%ebp), %eax
224 movl %edi, %ecx
225 roll %cl, %esi
226 addl %eax, %esi
227 xorl %esi, %edi
228 movl 132(%ebp), %eax
229 movl %esi, %ecx
230 roll %cl, %edi
231 addl %eax, %edi
232 xorl %edi, %esi
233 movl 136(%ebp), %eax
234 movl %edi, %ecx
235 roll %cl, %esi
236 addl %eax, %esi
237.L000rc5_exit:
238 movl %edi, (%edx)
239 movl %esi, 4(%edx)
240 popl %ebx
241 popl %edi
242 popl %esi
243 popl %ebp
244 ret
245.RC5_32_encrypt_end:
246 SIZE(RC5_32_encrypt,.RC5_32_encrypt_end-RC5_32_encrypt)
247.ident "desasm.pl"
248.text
249 .align ALIGN
250.globl RC5_32_decrypt
251 TYPE(RC5_32_decrypt,@function)
252RC5_32_decrypt:
253
254 pushl %ebp
255 pushl %esi
256 pushl %edi
257 movl 16(%esp), %edx
258 movl 20(%esp), %ebp
259 /* Load the 2 words */
260 movl (%edx), %edi
261 movl 4(%edx), %esi
262 pushl %ebx
263 movl (%ebp), %ebx
264 cmpl $12, %ebx
265 je .L001rc5_dec_12
266 cmpl $8, %ebx
267 je .L002rc5_dec_8
268 movl 136(%ebp), %eax
269 subl %eax, %esi
270 movl %edi, %ecx
271 rorl %cl, %esi
272 xorl %edi, %esi
273 movl 132(%ebp), %eax
274 subl %eax, %edi
275 movl %esi, %ecx
276 rorl %cl, %edi
277 xorl %esi, %edi
278 movl 128(%ebp), %eax
279 subl %eax, %esi
280 movl %edi, %ecx
281 rorl %cl, %esi
282 xorl %edi, %esi
283 movl 124(%ebp), %eax
284 subl %eax, %edi
285 movl %esi, %ecx
286 rorl %cl, %edi
287 xorl %esi, %edi
288 movl 120(%ebp), %eax
289 subl %eax, %esi
290 movl %edi, %ecx
291 rorl %cl, %esi
292 xorl %edi, %esi
293 movl 116(%ebp), %eax
294 subl %eax, %edi
295 movl %esi, %ecx
296 rorl %cl, %edi
297 xorl %esi, %edi
298 movl 112(%ebp), %eax
299 subl %eax, %esi
300 movl %edi, %ecx
301 rorl %cl, %esi
302 xorl %edi, %esi
303 movl 108(%ebp), %eax
304 subl %eax, %edi
305 movl %esi, %ecx
306 rorl %cl, %edi
307 xorl %esi, %edi
308.L001rc5_dec_12:
309 movl 104(%ebp), %eax
310 subl %eax, %esi
311 movl %edi, %ecx
312 rorl %cl, %esi
313 xorl %edi, %esi
314 movl 100(%ebp), %eax
315 subl %eax, %edi
316 movl %esi, %ecx
317 rorl %cl, %edi
318 xorl %esi, %edi
319 movl 96(%ebp), %eax
320 subl %eax, %esi
321 movl %edi, %ecx
322 rorl %cl, %esi
323 xorl %edi, %esi
324 movl 92(%ebp), %eax
325 subl %eax, %edi
326 movl %esi, %ecx
327 rorl %cl, %edi
328 xorl %esi, %edi
329 movl 88(%ebp), %eax
330 subl %eax, %esi
331 movl %edi, %ecx
332 rorl %cl, %esi
333 xorl %edi, %esi
334 movl 84(%ebp), %eax
335 subl %eax, %edi
336 movl %esi, %ecx
337 rorl %cl, %edi
338 xorl %esi, %edi
339 movl 80(%ebp), %eax
340 subl %eax, %esi
341 movl %edi, %ecx
342 rorl %cl, %esi
343 xorl %edi, %esi
344 movl 76(%ebp), %eax
345 subl %eax, %edi
346 movl %esi, %ecx
347 rorl %cl, %edi
348 xorl %esi, %edi
349.L002rc5_dec_8:
350 movl 72(%ebp), %eax
351 subl %eax, %esi
352 movl %edi, %ecx
353 rorl %cl, %esi
354 xorl %edi, %esi
355 movl 68(%ebp), %eax
356 subl %eax, %edi
357 movl %esi, %ecx
358 rorl %cl, %edi
359 xorl %esi, %edi
360 movl 64(%ebp), %eax
361 subl %eax, %esi
362 movl %edi, %ecx
363 rorl %cl, %esi
364 xorl %edi, %esi
365 movl 60(%ebp), %eax
366 subl %eax, %edi
367 movl %esi, %ecx
368 rorl %cl, %edi
369 xorl %esi, %edi
370 movl 56(%ebp), %eax
371 subl %eax, %esi
372 movl %edi, %ecx
373 rorl %cl, %esi
374 xorl %edi, %esi
375 movl 52(%ebp), %eax
376 subl %eax, %edi
377 movl %esi, %ecx
378 rorl %cl, %edi
379 xorl %esi, %edi
380 movl 48(%ebp), %eax
381 subl %eax, %esi
382 movl %edi, %ecx
383 rorl %cl, %esi
384 xorl %edi, %esi
385 movl 44(%ebp), %eax
386 subl %eax, %edi
387 movl %esi, %ecx
388 rorl %cl, %edi
389 xorl %esi, %edi
390 movl 40(%ebp), %eax
391 subl %eax, %esi
392 movl %edi, %ecx
393 rorl %cl, %esi
394 xorl %edi, %esi
395 movl 36(%ebp), %eax
396 subl %eax, %edi
397 movl %esi, %ecx
398 rorl %cl, %edi
399 xorl %esi, %edi
400 movl 32(%ebp), %eax
401 subl %eax, %esi
402 movl %edi, %ecx
403 rorl %cl, %esi
404 xorl %edi, %esi
405 movl 28(%ebp), %eax
406 subl %eax, %edi
407 movl %esi, %ecx
408 rorl %cl, %edi
409 xorl %esi, %edi
410 movl 24(%ebp), %eax
411 subl %eax, %esi
412 movl %edi, %ecx
413 rorl %cl, %esi
414 xorl %edi, %esi
415 movl 20(%ebp), %eax
416 subl %eax, %edi
417 movl %esi, %ecx
418 rorl %cl, %edi
419 xorl %esi, %edi
420 movl 16(%ebp), %eax
421 subl %eax, %esi
422 movl %edi, %ecx
423 rorl %cl, %esi
424 xorl %edi, %esi
425 movl 12(%ebp), %eax
426 subl %eax, %edi
427 movl %esi, %ecx
428 rorl %cl, %edi
429 xorl %esi, %edi
430 subl 8(%ebp), %esi
431 subl 4(%ebp), %edi
432.L003rc5_exit:
433 movl %edi, (%edx)
434 movl %esi, 4(%edx)
435 popl %ebx
436 popl %edi
437 popl %esi
438 popl %ebp
439 ret
440.RC5_32_decrypt_end:
441 SIZE(RC5_32_decrypt,.RC5_32_decrypt_end-RC5_32_decrypt)
442.ident "desasm.pl"
443.text
444 .align ALIGN
445.globl RC5_32_cbc_encrypt
446 TYPE(RC5_32_cbc_encrypt,@function)
447RC5_32_cbc_encrypt:
448
449 pushl %ebp
450 pushl %ebx
451 pushl %esi
452 pushl %edi
453 movl 28(%esp), %ebp
454 /* getting iv ptr from parameter 4 */
455 movl 36(%esp), %ebx
456 movl (%ebx), %esi
457 movl 4(%ebx), %edi
458 pushl %edi
459 pushl %esi
460 pushl %edi
461 pushl %esi
462 movl %esp, %ebx
463 movl 36(%esp), %esi
464 movl 40(%esp), %edi
465 /* getting encrypt flag from parameter 5 */
466 movl 56(%esp), %ecx
467 /* get and push parameter 3 */
468 movl 48(%esp), %eax
469 pushl %eax
470 pushl %ebx
471 cmpl $0, %ecx
472 jz .L004decrypt
473 andl $4294967288, %ebp
474 movl 8(%esp), %eax
475 movl 12(%esp), %ebx
476 jz .L005encrypt_finish
477.L006encrypt_loop:
478 movl (%esi), %ecx
479 movl 4(%esi), %edx
480 xorl %ecx, %eax
481 xorl %edx, %ebx
482 movl %eax, 8(%esp)
483 movl %ebx, 12(%esp)
484 call RC5_32_encrypt
485 movl 8(%esp), %eax
486 movl 12(%esp), %ebx
487 movl %eax, (%edi)
488 movl %ebx, 4(%edi)
489 addl $8, %esi
490 addl $8, %edi
491 subl $8, %ebp
492 jnz .L006encrypt_loop
493.L005encrypt_finish:
494 movl 52(%esp), %ebp
495 andl $7, %ebp
496 jz .L007finish
497 xorl %ecx, %ecx
498 xorl %edx, %edx
499 movl .L008cbc_enc_jmp_table(,%ebp,4),%ebp
500 jmp *%ebp
501.L009ej7:
502 movb 6(%esi), %dh
503 sall $8, %edx
504.L010ej6:
505 movb 5(%esi), %dh
506.L011ej5:
507 movb 4(%esi), %dl
508.L012ej4:
509 movl (%esi), %ecx
510 jmp .L013ejend
511.L014ej3:
512 movb 2(%esi), %ch
513 sall $8, %ecx
514.L015ej2:
515 movb 1(%esi), %ch
516.L016ej1:
517 movb (%esi), %cl
518.L013ejend:
519 xorl %ecx, %eax
520 xorl %edx, %ebx
521 movl %eax, 8(%esp)
522 movl %ebx, 12(%esp)
523 call RC5_32_encrypt
524 movl 8(%esp), %eax
525 movl 12(%esp), %ebx
526 movl %eax, (%edi)
527 movl %ebx, 4(%edi)
528 jmp .L007finish
529.align ALIGN
530.L004decrypt:
531 andl $4294967288, %ebp
532 movl 16(%esp), %eax
533 movl 20(%esp), %ebx
534 jz .L017decrypt_finish
535.L018decrypt_loop:
536 movl (%esi), %eax
537 movl 4(%esi), %ebx
538 movl %eax, 8(%esp)
539 movl %ebx, 12(%esp)
540 call RC5_32_decrypt
541 movl 8(%esp), %eax
542 movl 12(%esp), %ebx
543 movl 16(%esp), %ecx
544 movl 20(%esp), %edx
545 xorl %eax, %ecx
546 xorl %ebx, %edx
547 movl (%esi), %eax
548 movl 4(%esi), %ebx
549 movl %ecx, (%edi)
550 movl %edx, 4(%edi)
551 movl %eax, 16(%esp)
552 movl %ebx, 20(%esp)
553 addl $8, %esi
554 addl $8, %edi
555 subl $8, %ebp
556 jnz .L018decrypt_loop
557.L017decrypt_finish:
558 movl 52(%esp), %ebp
559 andl $7, %ebp
560 jz .L007finish
561 movl (%esi), %eax
562 movl 4(%esi), %ebx
563 movl %eax, 8(%esp)
564 movl %ebx, 12(%esp)
565 call RC5_32_decrypt
566 movl 8(%esp), %eax
567 movl 12(%esp), %ebx
568 movl 16(%esp), %ecx
569 movl 20(%esp), %edx
570 xorl %eax, %ecx
571 xorl %ebx, %edx
572 movl (%esi), %eax
573 movl 4(%esi), %ebx
574.L019dj7:
575 rorl $16, %edx
576 movb %dl, 6(%edi)
577 shrl $16, %edx
578.L020dj6:
579 movb %dh, 5(%edi)
580.L021dj5:
581 movb %dl, 4(%edi)
582.L022dj4:
583 movl %ecx, (%edi)
584 jmp .L023djend
585.L024dj3:
586 rorl $16, %ecx
587 movb %cl, 2(%edi)
588 sall $16, %ecx
589.L025dj2:
590 movb %ch, 1(%esi)
591.L026dj1:
592 movb %cl, (%esi)
593.L023djend:
594 jmp .L007finish
595.align ALIGN
596.L007finish:
597 movl 60(%esp), %ecx
598 addl $24, %esp
599 movl %eax, (%ecx)
600 movl %ebx, 4(%ecx)
601 popl %edi
602 popl %esi
603 popl %ebx
604 popl %ebp
605 ret
606.align ALIGN
607.L008cbc_enc_jmp_table:
608 .long 0
609 .long .L016ej1
610 .long .L015ej2
611 .long .L014ej3
612 .long .L012ej4
613 .long .L011ej5
614 .long .L010ej6
615 .long .L009ej7
616.align ALIGN
617.L027cbc_dec_jmp_table:
618 .long 0
619 .long .L026dj1
620 .long .L025dj2
621 .long .L024dj3
622 .long .L022dj4
623 .long .L021dj5
624 .long .L020dj6
625 .long .L019dj7
626.RC5_32_cbc_encrypt_end:
627 SIZE(RC5_32_cbc_encrypt,.RC5_32_cbc_encrypt_end-RC5_32_cbc_encrypt)
628.ident "desasm.pl"
diff --git a/src/lib/libcrypto/rc5/asm/rc5-586.pl b/src/lib/libcrypto/rc5/asm/rc5-586.pl
new file mode 100644
index 0000000000..172bd9ee1b
--- /dev/null
+++ b/src/lib/libcrypto/rc5/asm/rc5-586.pl
@@ -0,0 +1,109 @@
1#!/usr/bin/perl
2
3push(@INC,"perlasm","../../perlasm");
4require "x86asm.pl";
5require "cbc.pl";
6
7&asm_init($ARGV[0],"rc5-586.pl");
8
9$RC5_MAX_ROUNDS=16;
10$RC5_32_OFF=($RC5_MAX_ROUNDS+2)*4;
11$A="edi";
12$B="esi";
13$S="ebp";
14$tmp1="eax";
15$r="ebx";
16$tmpc="ecx";
17$tmp4="edx";
18
19&RC5_32_encrypt("RC5_32_encrypt",1);
20&RC5_32_encrypt("RC5_32_decrypt",0);
21&cbc("RC5_32_cbc_encrypt","RC5_32_encrypt","RC5_32_decrypt",0,4,5,3,-1,-1);
22&asm_finish();
23
24sub RC5_32_encrypt
25 {
26 local($name,$enc)=@_;
27
28 &function_begin_B($name,"");
29
30 &comment("");
31
32 &push("ebp");
33 &push("esi");
34 &push("edi");
35 &mov($tmp4,&wparam(0));
36 &mov($S,&wparam(1));
37
38 &comment("Load the 2 words");
39 &mov($A,&DWP(0,$tmp4,"",0));
40 &mov($B,&DWP(4,$tmp4,"",0));
41
42 &push($r);
43 &mov($r, &DWP(0,$S,"",0));
44
45 # encrypting part
46
47 if ($enc)
48 {
49 &add($A, &DWP(4+0,$S,"",0));
50 &add($B, &DWP(4+4,$S,"",0));
51
52 for ($i=0; $i<$RC5_MAX_ROUNDS; $i++)
53 {
54 &xor($A, $B);
55 &mov($tmp1, &DWP(12+$i*8,$S,"",0));
56 &mov($tmpc, $B);
57 &rotl($A, &LB("ecx"));
58 &add($A, $tmp1);
59
60 &xor($B, $A);
61 &mov($tmp1, &DWP(16+$i*8,$S,"",0));
62 &mov($tmpc, $A);
63 &rotl($B, &LB("ecx"));
64 &add($B, $tmp1);
65 if (($i == 7) || ($i == 11))
66 {
67 &cmp($r, $i+1);
68 &je(&label("rc5_exit"));
69 }
70 }
71 }
72 else
73 {
74 &cmp($r, 12);
75 &je(&label("rc5_dec_12"));
76 &cmp($r, 8);
77 &je(&label("rc5_dec_8"));
78 for ($i=$RC5_MAX_ROUNDS; $i > 0; $i--)
79 {
80 &set_label("rc5_dec_$i") if ($i == 12) || ($i == 8);
81 &mov($tmp1, &DWP($i*8+8,$S,"",0));
82 &sub($B, $tmp1);
83 &mov($tmpc, $A);
84 &rotr($B, &LB("ecx"));
85 &xor($B, $A);
86
87 &mov($tmp1, &DWP($i*8+4,$S,"",0));
88 &sub($A, $tmp1);
89 &mov($tmpc, $B);
90 &rotr($A, &LB("ecx"));
91 &xor($A, $B);
92 }
93 &sub($B, &DWP(4+4,$S,"",0));
94 &sub($A, &DWP(4+0,$S,"",0));
95 }
96
97 &set_label("rc5_exit");
98 &mov(&DWP(0,$tmp4,"",0),$A);
99 &mov(&DWP(4,$tmp4,"",0),$B);
100
101 &pop("ebx");
102 &pop("edi");
103 &pop("esi");
104 &pop("ebp");
105 &ret();
106 &function_end_B($name);
107 }
108
109
diff --git a/src/lib/libcrypto/ripemd/Makefile.ssl b/src/lib/libcrypto/ripemd/Makefile.ssl
new file mode 100644
index 0000000000..67d47ceb2c
--- /dev/null
+++ b/src/lib/libcrypto/ripemd/Makefile.ssl
@@ -0,0 +1,104 @@
1#
2# SSLeay/crypto/ripemd/Makefile
3#
4
5DIR= ripemd
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17RIP_ASM_OBJ=
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=rmdtest.c
23APPS=rmd160.c
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=rmd_dgst.c rmd_one.c
27LIBOBJ=rmd_dgst.o rmd_one.o $(RMD160_ASM_OBJ)
28
29SRC= $(LIBSRC)
30
31EXHEADER= ripemd.h
32HEADER= rmd_locl.h rmdconst.h $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 sh $(TOP)/util/ranlib.sh $(LIB)
44 @touch lib
45
46# elf
47asm/rm86-elf.o: asm/rm86unix.cpp
48 $(CPP) -DELF asm/rm86unix.cpp | as -o asm/rm86-elf.o
49
50# solaris
51asm/rm86-sol.o: asm/rm86unix.cpp
52 $(CC) -E -DSOL asm/rm86unix.cpp | sed 's/^#.*//' > asm/rm86-sol.s
53 as -o asm/rm86-sol.o asm/rm86-sol.s
54 rm -f asm/rm86-sol.s
55
56# a.out
57asm/rm86-out.o: asm/rm86unix.cpp
58 $(CPP) -DOUT asm/rm86unix.cpp | as -o asm/rm86-out.o
59
60# bsdi
61asm/rm86bsdi.o: asm/rm86unix.cpp
62 $(CPP) -DBSDI asm/rm86unix.cpp | as -o asm/rm86bsdi.o
63
64asm/rm86unix.cpp:
65 (cd asm; perl rmd-586.pl cpp >rm86unix.cpp)
66
67files:
68 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
69
70links:
71 /bin/rm -f Makefile
72 $(TOP)/util/point.sh Makefile.ssl Makefile ;
73 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
74 $(TOP)/util/mklink.sh ../../test $(TEST)
75 $(TOP)/util/mklink.sh ../../apps $(APPS)
76
77install:
78 @for i in $(EXHEADER) ; \
79 do \
80 (cp $$i $(INSTALLTOP)/include/$$i; \
81 chmod 644 $(INSTALLTOP)/include/$$i ); \
82 done;
83
84tags:
85 ctags $(SRC)
86
87tests:
88
89lint:
90 lint -DLINT $(INCLUDES) $(SRC)>fluff
91
92depend:
93 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
94
95dclean:
96 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
97 mv -f Makefile.new $(MAKEFILE)
98
99clean:
100 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
101
102errors:
103
104# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/ripemd/Makefile.uni b/src/lib/libcrypto/ripemd/Makefile.uni
new file mode 100644
index 0000000000..54685712db
--- /dev/null
+++ b/src/lib/libcrypto/ripemd/Makefile.uni
@@ -0,0 +1,109 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= md5
11TOP= .
12CC= gcc
13CFLAG= -O3 -fomit-frame-pointer
14
15CPP= $(CC) -E
16INCLUDES=
17INSTALLTOP=/usr/local/lib
18MAKE= make
19MAKEDEPEND= makedepend
20MAKEFILE= Makefile.uni
21AR= ar r
22
23MD5_ASM_OBJ=
24
25CFLAGS= $(INCLUDES) $(CFLAG)
26
27GENERAL=Makefile
28TEST=md5test
29APPS=md5
30
31LIB=libmd5.a
32LIBSRC=md5_dgst.c md5_one.c
33LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
34
35SRC= $(LIBSRC)
36
37EXHEADER= md5.h
38HEADER= md5_locl.h $(EXHEADER)
39
40ALL= $(GENERAL) $(SRC) $(HEADER)
41
42all: $(LIB) $(TEST) $(APPS)
43
44$(LIB): $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 sh $(TOP)/ranlib.sh $(LIB)
47
48# elf
49asm/mx86-elf.o: asm/mx86unix.cpp
50 $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o
51
52# solaris
53asm/mx86-sol.o: asm/mx86unix.cpp
54 $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s
55 as -o asm/mx86-sol.o asm/mx86-sol.s
56 rm -f asm/mx86-sol.s
57
58# a.out
59asm/mx86-out.o: asm/mx86unix.cpp
60 $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o
61
62# bsdi
63asm/mx86bsdi.o: asm/mx86unix.cpp
64 $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o
65
66asm/mx86unix.cpp:
67 (cd asm; perl md5-586.pl cpp >mx86unix.cpp)
68
69test: $(TEST)
70 ./$(TEST)
71
72$(TEST): $(TEST).c $(LIB)
73 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
74
75$(APPS): $(APPS).c $(LIB)
76 $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
77
78lint:
79 lint -DLINT $(INCLUDES) $(SRC)>fluff
80
81depend:
82 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
83
84dclean:
85 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
86 mv -f Makefile.new $(MAKEFILE)
87
88clean:
89 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
90
91cc:
92 $(MAKE) MD5_ASM_OBJ="" CC="cc" CFLAG="-O" all
93
94gcc:
95 $(MAKE) MD5_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
96
97x86-elf:
98 $(MAKE) MD5_ASM_OBJ="asm/mx86-elf.o" CFLAG="-DELF -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
99
100x86-out:
101 $(MAKE) MD5_ASM_OBJ="asm/mx86-out.o" CFLAG="-DOUT -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
102
103x86-solaris:
104 $(MAKE) MD5_ASM_OBJ="asm/mx86-sol.o" CFLAG="-DSOL -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
105
106x86-bdsi:
107 $(MAKE) MD5_ASM_OBJ="asm/mx86-bdsi.o" CFLAG="-DBDSI -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
108
109# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/ripemd/asm/rm-win32.asm b/src/lib/libcrypto/ripemd/asm/rm-win32.asm
new file mode 100644
index 0000000000..bd38791c13
--- /dev/null
+++ b/src/lib/libcrypto/ripemd/asm/rm-win32.asm
@@ -0,0 +1,1972 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by rmd-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE rmd-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _ripemd160_block_x86
12
13_ripemd160_block_x86 PROC NEAR
14 push esi
15 mov ecx, DWORD PTR 16[esp]
16 push edi
17 mov esi, DWORD PTR 16[esp]
18 push ebp
19 add ecx, esi
20 push ebx
21 sub ecx, 64
22 sub esp, 88
23 mov DWORD PTR [esp],ecx
24 mov edi, DWORD PTR 108[esp]
25L000start:
26 ;
27 mov eax, DWORD PTR [esi]
28 mov ebx, DWORD PTR 4[esi]
29 mov DWORD PTR 4[esp],eax
30 mov DWORD PTR 8[esp],ebx
31 mov eax, DWORD PTR 8[esi]
32 mov ebx, DWORD PTR 12[esi]
33 mov DWORD PTR 12[esp],eax
34 mov DWORD PTR 16[esp],ebx
35 mov eax, DWORD PTR 16[esi]
36 mov ebx, DWORD PTR 20[esi]
37 mov DWORD PTR 20[esp],eax
38 mov DWORD PTR 24[esp],ebx
39 mov eax, DWORD PTR 24[esi]
40 mov ebx, DWORD PTR 28[esi]
41 mov DWORD PTR 28[esp],eax
42 mov DWORD PTR 32[esp],ebx
43 mov eax, DWORD PTR 32[esi]
44 mov ebx, DWORD PTR 36[esi]
45 mov DWORD PTR 36[esp],eax
46 mov DWORD PTR 40[esp],ebx
47 mov eax, DWORD PTR 40[esi]
48 mov ebx, DWORD PTR 44[esi]
49 mov DWORD PTR 44[esp],eax
50 mov DWORD PTR 48[esp],ebx
51 mov eax, DWORD PTR 48[esi]
52 mov ebx, DWORD PTR 52[esi]
53 mov DWORD PTR 52[esp],eax
54 mov DWORD PTR 56[esp],ebx
55 mov eax, DWORD PTR 56[esi]
56 mov ebx, DWORD PTR 60[esi]
57 mov DWORD PTR 60[esp],eax
58 mov DWORD PTR 64[esp],ebx
59 add esi, 64
60 mov eax, DWORD PTR [edi]
61 mov DWORD PTR 112[esp],esi
62 mov ebx, DWORD PTR 4[edi]
63 mov ecx, DWORD PTR 8[edi]
64 mov edx, DWORD PTR 12[edi]
65 mov ebp, DWORD PTR 16[edi]
66 ; 0
67 mov esi, ecx
68 xor esi, edx
69 mov edi, DWORD PTR 4[esp]
70 xor esi, ebx
71 add eax, edi
72 rol ecx, 10
73 add eax, esi
74 mov esi, ebx
75 rol eax, 11
76 add eax, ebp
77 ; 1
78 xor esi, ecx
79 mov edi, DWORD PTR 8[esp]
80 xor esi, eax
81 add ebp, esi
82 mov esi, eax
83 rol ebx, 10
84 add ebp, edi
85 xor esi, ebx
86 rol ebp, 14
87 add ebp, edx
88 ; 2
89 mov edi, DWORD PTR 12[esp]
90 xor esi, ebp
91 add edx, edi
92 rol eax, 10
93 add edx, esi
94 mov esi, ebp
95 rol edx, 15
96 add edx, ecx
97 ; 3
98 xor esi, eax
99 mov edi, DWORD PTR 16[esp]
100 xor esi, edx
101 add ecx, esi
102 mov esi, edx
103 rol ebp, 10
104 add ecx, edi
105 xor esi, ebp
106 rol ecx, 12
107 add ecx, ebx
108 ; 4
109 mov edi, DWORD PTR 20[esp]
110 xor esi, ecx
111 add ebx, edi
112 rol edx, 10
113 add ebx, esi
114 mov esi, ecx
115 rol ebx, 5
116 add ebx, eax
117 ; 5
118 xor esi, edx
119 mov edi, DWORD PTR 24[esp]
120 xor esi, ebx
121 add eax, esi
122 mov esi, ebx
123 rol ecx, 10
124 add eax, edi
125 xor esi, ecx
126 rol eax, 8
127 add eax, ebp
128 ; 6
129 mov edi, DWORD PTR 28[esp]
130 xor esi, eax
131 add ebp, edi
132 rol ebx, 10
133 add ebp, esi
134 mov esi, eax
135 rol ebp, 7
136 add ebp, edx
137 ; 7
138 xor esi, ebx
139 mov edi, DWORD PTR 32[esp]
140 xor esi, ebp
141 add edx, esi
142 mov esi, ebp
143 rol eax, 10
144 add edx, edi
145 xor esi, eax
146 rol edx, 9
147 add edx, ecx
148 ; 8
149 mov edi, DWORD PTR 36[esp]
150 xor esi, edx
151 add ecx, edi
152 rol ebp, 10
153 add ecx, esi
154 mov esi, edx
155 rol ecx, 11
156 add ecx, ebx
157 ; 9
158 xor esi, ebp
159 mov edi, DWORD PTR 40[esp]
160 xor esi, ecx
161 add ebx, esi
162 mov esi, ecx
163 rol edx, 10
164 add ebx, edi
165 xor esi, edx
166 rol ebx, 13
167 add ebx, eax
168 ; 10
169 mov edi, DWORD PTR 44[esp]
170 xor esi, ebx
171 add eax, edi
172 rol ecx, 10
173 add eax, esi
174 mov esi, ebx
175 rol eax, 14
176 add eax, ebp
177 ; 11
178 xor esi, ecx
179 mov edi, DWORD PTR 48[esp]
180 xor esi, eax
181 add ebp, esi
182 mov esi, eax
183 rol ebx, 10
184 add ebp, edi
185 xor esi, ebx
186 rol ebp, 15
187 add ebp, edx
188 ; 12
189 mov edi, DWORD PTR 52[esp]
190 xor esi, ebp
191 add edx, edi
192 rol eax, 10
193 add edx, esi
194 mov esi, ebp
195 rol edx, 6
196 add edx, ecx
197 ; 13
198 xor esi, eax
199 mov edi, DWORD PTR 56[esp]
200 xor esi, edx
201 add ecx, esi
202 mov esi, edx
203 rol ebp, 10
204 add ecx, edi
205 xor esi, ebp
206 rol ecx, 7
207 add ecx, ebx
208 ; 14
209 mov edi, DWORD PTR 60[esp]
210 xor esi, ecx
211 add ebx, edi
212 rol edx, 10
213 add ebx, esi
214 mov esi, ecx
215 rol ebx, 9
216 add ebx, eax
217 ; 15
218 xor esi, edx
219 mov edi, DWORD PTR 64[esp]
220 xor esi, ebx
221 add eax, esi
222 mov esi, -1
223 rol ecx, 10
224 add eax, edi
225 mov edi, DWORD PTR 32[esp]
226 rol eax, 8
227 add eax, ebp
228 ; 16
229 add ebp, edi
230 mov edi, ebx
231 sub esi, eax
232 and edi, eax
233 and esi, ecx
234 or edi, esi
235 mov esi, DWORD PTR 20[esp]
236 rol ebx, 10
237 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
238 mov edi, -1
239 rol ebp, 7
240 add ebp, edx
241 ; 17
242 add edx, esi
243 mov esi, eax
244 sub edi, ebp
245 and esi, ebp
246 and edi, ebx
247 or esi, edi
248 mov edi, DWORD PTR 56[esp]
249 rol eax, 10
250 lea edx, DWORD PTR 1518500249[esi*1+edx]
251 mov esi, -1
252 rol edx, 6
253 add edx, ecx
254 ; 18
255 add ecx, edi
256 mov edi, ebp
257 sub esi, edx
258 and edi, edx
259 and esi, eax
260 or edi, esi
261 mov esi, DWORD PTR 8[esp]
262 rol ebp, 10
263 lea ecx, DWORD PTR 1518500249[edi*1+ecx]
264 mov edi, -1
265 rol ecx, 8
266 add ecx, ebx
267 ; 19
268 add ebx, esi
269 mov esi, edx
270 sub edi, ecx
271 and esi, ecx
272 and edi, ebp
273 or esi, edi
274 mov edi, DWORD PTR 44[esp]
275 rol edx, 10
276 lea ebx, DWORD PTR 1518500249[esi*1+ebx]
277 mov esi, -1
278 rol ebx, 13
279 add ebx, eax
280 ; 20
281 add eax, edi
282 mov edi, ecx
283 sub esi, ebx
284 and edi, ebx
285 and esi, edx
286 or edi, esi
287 mov esi, DWORD PTR 28[esp]
288 rol ecx, 10
289 lea eax, DWORD PTR 1518500249[edi*1+eax]
290 mov edi, -1
291 rol eax, 11
292 add eax, ebp
293 ; 21
294 add ebp, esi
295 mov esi, ebx
296 sub edi, eax
297 and esi, eax
298 and edi, ecx
299 or esi, edi
300 mov edi, DWORD PTR 64[esp]
301 rol ebx, 10
302 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
303 mov esi, -1
304 rol ebp, 9
305 add ebp, edx
306 ; 22
307 add edx, edi
308 mov edi, eax
309 sub esi, ebp
310 and edi, ebp
311 and esi, ebx
312 or edi, esi
313 mov esi, DWORD PTR 16[esp]
314 rol eax, 10
315 lea edx, DWORD PTR 1518500249[edi*1+edx]
316 mov edi, -1
317 rol edx, 7
318 add edx, ecx
319 ; 23
320 add ecx, esi
321 mov esi, ebp
322 sub edi, edx
323 and esi, edx
324 and edi, eax
325 or esi, edi
326 mov edi, DWORD PTR 52[esp]
327 rol ebp, 10
328 lea ecx, DWORD PTR 1518500249[esi*1+ecx]
329 mov esi, -1
330 rol ecx, 15
331 add ecx, ebx
332 ; 24
333 add ebx, edi
334 mov edi, edx
335 sub esi, ecx
336 and edi, ecx
337 and esi, ebp
338 or edi, esi
339 mov esi, DWORD PTR 4[esp]
340 rol edx, 10
341 lea ebx, DWORD PTR 1518500249[edi*1+ebx]
342 mov edi, -1
343 rol ebx, 7
344 add ebx, eax
345 ; 25
346 add eax, esi
347 mov esi, ecx
348 sub edi, ebx
349 and esi, ebx
350 and edi, edx
351 or esi, edi
352 mov edi, DWORD PTR 40[esp]
353 rol ecx, 10
354 lea eax, DWORD PTR 1518500249[esi*1+eax]
355 mov esi, -1
356 rol eax, 12
357 add eax, ebp
358 ; 26
359 add ebp, edi
360 mov edi, ebx
361 sub esi, eax
362 and edi, eax
363 and esi, ecx
364 or edi, esi
365 mov esi, DWORD PTR 24[esp]
366 rol ebx, 10
367 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
368 mov edi, -1
369 rol ebp, 15
370 add ebp, edx
371 ; 27
372 add edx, esi
373 mov esi, eax
374 sub edi, ebp
375 and esi, ebp
376 and edi, ebx
377 or esi, edi
378 mov edi, DWORD PTR 12[esp]
379 rol eax, 10
380 lea edx, DWORD PTR 1518500249[esi*1+edx]
381 mov esi, -1
382 rol edx, 9
383 add edx, ecx
384 ; 28
385 add ecx, edi
386 mov edi, ebp
387 sub esi, edx
388 and edi, edx
389 and esi, eax
390 or edi, esi
391 mov esi, DWORD PTR 60[esp]
392 rol ebp, 10
393 lea ecx, DWORD PTR 1518500249[edi*1+ecx]
394 mov edi, -1
395 rol ecx, 11
396 add ecx, ebx
397 ; 29
398 add ebx, esi
399 mov esi, edx
400 sub edi, ecx
401 and esi, ecx
402 and edi, ebp
403 or esi, edi
404 mov edi, DWORD PTR 48[esp]
405 rol edx, 10
406 lea ebx, DWORD PTR 1518500249[esi*1+ebx]
407 mov esi, -1
408 rol ebx, 7
409 add ebx, eax
410 ; 30
411 add eax, edi
412 mov edi, ecx
413 sub esi, ebx
414 and edi, ebx
415 and esi, edx
416 or edi, esi
417 mov esi, DWORD PTR 36[esp]
418 rol ecx, 10
419 lea eax, DWORD PTR 1518500249[edi*1+eax]
420 mov edi, -1
421 rol eax, 13
422 add eax, ebp
423 ; 31
424 add ebp, esi
425 mov esi, ebx
426 sub edi, eax
427 and esi, eax
428 and edi, ecx
429 or esi, edi
430 mov edi, -1
431 rol ebx, 10
432 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
433 sub edi, eax
434 rol ebp, 12
435 add ebp, edx
436 ; 32
437 mov esi, DWORD PTR 16[esp]
438 or edi, ebp
439 add edx, esi
440 xor edi, ebx
441 mov esi, -1
442 rol eax, 10
443 lea edx, DWORD PTR 1859775393[edi*1+edx]
444 sub esi, ebp
445 rol edx, 11
446 add edx, ecx
447 ; 33
448 mov edi, DWORD PTR 44[esp]
449 or esi, edx
450 add ecx, edi
451 xor esi, eax
452 mov edi, -1
453 rol ebp, 10
454 lea ecx, DWORD PTR 1859775393[esi*1+ecx]
455 sub edi, edx
456 rol ecx, 13
457 add ecx, ebx
458 ; 34
459 mov esi, DWORD PTR 60[esp]
460 or edi, ecx
461 add ebx, esi
462 xor edi, ebp
463 mov esi, -1
464 rol edx, 10
465 lea ebx, DWORD PTR 1859775393[edi*1+ebx]
466 sub esi, ecx
467 rol ebx, 6
468 add ebx, eax
469 ; 35
470 mov edi, DWORD PTR 20[esp]
471 or esi, ebx
472 add eax, edi
473 xor esi, edx
474 mov edi, -1
475 rol ecx, 10
476 lea eax, DWORD PTR 1859775393[esi*1+eax]
477 sub edi, ebx
478 rol eax, 7
479 add eax, ebp
480 ; 36
481 mov esi, DWORD PTR 40[esp]
482 or edi, eax
483 add ebp, esi
484 xor edi, ecx
485 mov esi, -1
486 rol ebx, 10
487 lea ebp, DWORD PTR 1859775393[edi*1+ebp]
488 sub esi, eax
489 rol ebp, 14
490 add ebp, edx
491 ; 37
492 mov edi, DWORD PTR 64[esp]
493 or esi, ebp
494 add edx, edi
495 xor esi, ebx
496 mov edi, -1
497 rol eax, 10
498 lea edx, DWORD PTR 1859775393[esi*1+edx]
499 sub edi, ebp
500 rol edx, 9
501 add edx, ecx
502 ; 38
503 mov esi, DWORD PTR 36[esp]
504 or edi, edx
505 add ecx, esi
506 xor edi, eax
507 mov esi, -1
508 rol ebp, 10
509 lea ecx, DWORD PTR 1859775393[edi*1+ecx]
510 sub esi, edx
511 rol ecx, 13
512 add ecx, ebx
513 ; 39
514 mov edi, DWORD PTR 8[esp]
515 or esi, ecx
516 add ebx, edi
517 xor esi, ebp
518 mov edi, -1
519 rol edx, 10
520 lea ebx, DWORD PTR 1859775393[esi*1+ebx]
521 sub edi, ecx
522 rol ebx, 15
523 add ebx, eax
524 ; 40
525 mov esi, DWORD PTR 12[esp]
526 or edi, ebx
527 add eax, esi
528 xor edi, edx
529 mov esi, -1
530 rol ecx, 10
531 lea eax, DWORD PTR 1859775393[edi*1+eax]
532 sub esi, ebx
533 rol eax, 14
534 add eax, ebp
535 ; 41
536 mov edi, DWORD PTR 32[esp]
537 or esi, eax
538 add ebp, edi
539 xor esi, ecx
540 mov edi, -1
541 rol ebx, 10
542 lea ebp, DWORD PTR 1859775393[esi*1+ebp]
543 sub edi, eax
544 rol ebp, 8
545 add ebp, edx
546 ; 42
547 mov esi, DWORD PTR 4[esp]
548 or edi, ebp
549 add edx, esi
550 xor edi, ebx
551 mov esi, -1
552 rol eax, 10
553 lea edx, DWORD PTR 1859775393[edi*1+edx]
554 sub esi, ebp
555 rol edx, 13
556 add edx, ecx
557 ; 43
558 mov edi, DWORD PTR 28[esp]
559 or esi, edx
560 add ecx, edi
561 xor esi, eax
562 mov edi, -1
563 rol ebp, 10
564 lea ecx, DWORD PTR 1859775393[esi*1+ecx]
565 sub edi, edx
566 rol ecx, 6
567 add ecx, ebx
568 ; 44
569 mov esi, DWORD PTR 56[esp]
570 or edi, ecx
571 add ebx, esi
572 xor edi, ebp
573 mov esi, -1
574 rol edx, 10
575 lea ebx, DWORD PTR 1859775393[edi*1+ebx]
576 sub esi, ecx
577 rol ebx, 5
578 add ebx, eax
579 ; 45
580 mov edi, DWORD PTR 48[esp]
581 or esi, ebx
582 add eax, edi
583 xor esi, edx
584 mov edi, -1
585 rol ecx, 10
586 lea eax, DWORD PTR 1859775393[esi*1+eax]
587 sub edi, ebx
588 rol eax, 12
589 add eax, ebp
590 ; 46
591 mov esi, DWORD PTR 24[esp]
592 or edi, eax
593 add ebp, esi
594 xor edi, ecx
595 mov esi, -1
596 rol ebx, 10
597 lea ebp, DWORD PTR 1859775393[edi*1+ebp]
598 sub esi, eax
599 rol ebp, 7
600 add ebp, edx
601 ; 47
602 mov edi, DWORD PTR 52[esp]
603 or esi, ebp
604 add edx, edi
605 xor esi, ebx
606 mov edi, -1
607 rol eax, 10
608 lea edx, DWORD PTR 1859775393[esi*1+edx]
609 mov esi, eax
610 rol edx, 5
611 add edx, ecx
612 ; 48
613 sub edi, eax
614 and esi, edx
615 and edi, ebp
616 or edi, esi
617 mov esi, DWORD PTR 8[esp]
618 rol ebp, 10
619 lea ecx, DWORD PTR 2400959708[edi+ecx]
620 mov edi, -1
621 add ecx, esi
622 mov esi, ebp
623 rol ecx, 11
624 add ecx, ebx
625 ; 49
626 sub edi, ebp
627 and esi, ecx
628 and edi, edx
629 or edi, esi
630 mov esi, DWORD PTR 40[esp]
631 rol edx, 10
632 lea ebx, DWORD PTR 2400959708[edi+ebx]
633 mov edi, -1
634 add ebx, esi
635 mov esi, edx
636 rol ebx, 12
637 add ebx, eax
638 ; 50
639 sub edi, edx
640 and esi, ebx
641 and edi, ecx
642 or edi, esi
643 mov esi, DWORD PTR 48[esp]
644 rol ecx, 10
645 lea eax, DWORD PTR 2400959708[edi+eax]
646 mov edi, -1
647 add eax, esi
648 mov esi, ecx
649 rol eax, 14
650 add eax, ebp
651 ; 51
652 sub edi, ecx
653 and esi, eax
654 and edi, ebx
655 or edi, esi
656 mov esi, DWORD PTR 44[esp]
657 rol ebx, 10
658 lea ebp, DWORD PTR 2400959708[edi+ebp]
659 mov edi, -1
660 add ebp, esi
661 mov esi, ebx
662 rol ebp, 15
663 add ebp, edx
664 ; 52
665 sub edi, ebx
666 and esi, ebp
667 and edi, eax
668 or edi, esi
669 mov esi, DWORD PTR 4[esp]
670 rol eax, 10
671 lea edx, DWORD PTR 2400959708[edi+edx]
672 mov edi, -1
673 add edx, esi
674 mov esi, eax
675 rol edx, 14
676 add edx, ecx
677 ; 53
678 sub edi, eax
679 and esi, edx
680 and edi, ebp
681 or edi, esi
682 mov esi, DWORD PTR 36[esp]
683 rol ebp, 10
684 lea ecx, DWORD PTR 2400959708[edi+ecx]
685 mov edi, -1
686 add ecx, esi
687 mov esi, ebp
688 rol ecx, 15
689 add ecx, ebx
690 ; 54
691 sub edi, ebp
692 and esi, ecx
693 and edi, edx
694 or edi, esi
695 mov esi, DWORD PTR 52[esp]
696 rol edx, 10
697 lea ebx, DWORD PTR 2400959708[edi+ebx]
698 mov edi, -1
699 add ebx, esi
700 mov esi, edx
701 rol ebx, 9
702 add ebx, eax
703 ; 55
704 sub edi, edx
705 and esi, ebx
706 and edi, ecx
707 or edi, esi
708 mov esi, DWORD PTR 20[esp]
709 rol ecx, 10
710 lea eax, DWORD PTR 2400959708[edi+eax]
711 mov edi, -1
712 add eax, esi
713 mov esi, ecx
714 rol eax, 8
715 add eax, ebp
716 ; 56
717 sub edi, ecx
718 and esi, eax
719 and edi, ebx
720 or edi, esi
721 mov esi, DWORD PTR 56[esp]
722 rol ebx, 10
723 lea ebp, DWORD PTR 2400959708[edi+ebp]
724 mov edi, -1
725 add ebp, esi
726 mov esi, ebx
727 rol ebp, 9
728 add ebp, edx
729 ; 57
730 sub edi, ebx
731 and esi, ebp
732 and edi, eax
733 or edi, esi
734 mov esi, DWORD PTR 16[esp]
735 rol eax, 10
736 lea edx, DWORD PTR 2400959708[edi+edx]
737 mov edi, -1
738 add edx, esi
739 mov esi, eax
740 rol edx, 14
741 add edx, ecx
742 ; 58
743 sub edi, eax
744 and esi, edx
745 and edi, ebp
746 or edi, esi
747 mov esi, DWORD PTR 32[esp]
748 rol ebp, 10
749 lea ecx, DWORD PTR 2400959708[edi+ecx]
750 mov edi, -1
751 add ecx, esi
752 mov esi, ebp
753 rol ecx, 5
754 add ecx, ebx
755 ; 59
756 sub edi, ebp
757 and esi, ecx
758 and edi, edx
759 or edi, esi
760 mov esi, DWORD PTR 64[esp]
761 rol edx, 10
762 lea ebx, DWORD PTR 2400959708[edi+ebx]
763 mov edi, -1
764 add ebx, esi
765 mov esi, edx
766 rol ebx, 6
767 add ebx, eax
768 ; 60
769 sub edi, edx
770 and esi, ebx
771 and edi, ecx
772 or edi, esi
773 mov esi, DWORD PTR 60[esp]
774 rol ecx, 10
775 lea eax, DWORD PTR 2400959708[edi+eax]
776 mov edi, -1
777 add eax, esi
778 mov esi, ecx
779 rol eax, 8
780 add eax, ebp
781 ; 61
782 sub edi, ecx
783 and esi, eax
784 and edi, ebx
785 or edi, esi
786 mov esi, DWORD PTR 24[esp]
787 rol ebx, 10
788 lea ebp, DWORD PTR 2400959708[edi+ebp]
789 mov edi, -1
790 add ebp, esi
791 mov esi, ebx
792 rol ebp, 6
793 add ebp, edx
794 ; 62
795 sub edi, ebx
796 and esi, ebp
797 and edi, eax
798 or edi, esi
799 mov esi, DWORD PTR 28[esp]
800 rol eax, 10
801 lea edx, DWORD PTR 2400959708[edi+edx]
802 mov edi, -1
803 add edx, esi
804 mov esi, eax
805 rol edx, 5
806 add edx, ecx
807 ; 63
808 sub edi, eax
809 and esi, edx
810 and edi, ebp
811 or edi, esi
812 mov esi, DWORD PTR 12[esp]
813 rol ebp, 10
814 lea ecx, DWORD PTR 2400959708[edi+ecx]
815 mov edi, -1
816 add ecx, esi
817 sub edi, ebp
818 rol ecx, 12
819 add ecx, ebx
820 ; 64
821 mov esi, DWORD PTR 20[esp]
822 or edi, edx
823 add ebx, esi
824 xor edi, ecx
825 mov esi, -1
826 rol edx, 10
827 lea ebx, DWORD PTR 2840853838[edi*1+ebx]
828 sub esi, edx
829 rol ebx, 9
830 add ebx, eax
831 ; 65
832 mov edi, DWORD PTR 4[esp]
833 or esi, ecx
834 add eax, edi
835 xor esi, ebx
836 mov edi, -1
837 rol ecx, 10
838 lea eax, DWORD PTR 2840853838[esi*1+eax]
839 sub edi, ecx
840 rol eax, 15
841 add eax, ebp
842 ; 66
843 mov esi, DWORD PTR 24[esp]
844 or edi, ebx
845 add ebp, esi
846 xor edi, eax
847 mov esi, -1
848 rol ebx, 10
849 lea ebp, DWORD PTR 2840853838[edi*1+ebp]
850 sub esi, ebx
851 rol ebp, 5
852 add ebp, edx
853 ; 67
854 mov edi, DWORD PTR 40[esp]
855 or esi, eax
856 add edx, edi
857 xor esi, ebp
858 mov edi, -1
859 rol eax, 10
860 lea edx, DWORD PTR 2840853838[esi*1+edx]
861 sub edi, eax
862 rol edx, 11
863 add edx, ecx
864 ; 68
865 mov esi, DWORD PTR 32[esp]
866 or edi, ebp
867 add ecx, esi
868 xor edi, edx
869 mov esi, -1
870 rol ebp, 10
871 lea ecx, DWORD PTR 2840853838[edi*1+ecx]
872 sub esi, ebp
873 rol ecx, 6
874 add ecx, ebx
875 ; 69
876 mov edi, DWORD PTR 52[esp]
877 or esi, edx
878 add ebx, edi
879 xor esi, ecx
880 mov edi, -1
881 rol edx, 10
882 lea ebx, DWORD PTR 2840853838[esi*1+ebx]
883 sub edi, edx
884 rol ebx, 8
885 add ebx, eax
886 ; 70
887 mov esi, DWORD PTR 12[esp]
888 or edi, ecx
889 add eax, esi
890 xor edi, ebx
891 mov esi, -1
892 rol ecx, 10
893 lea eax, DWORD PTR 2840853838[edi*1+eax]
894 sub esi, ecx
895 rol eax, 13
896 add eax, ebp
897 ; 71
898 mov edi, DWORD PTR 44[esp]
899 or esi, ebx
900 add ebp, edi
901 xor esi, eax
902 mov edi, -1
903 rol ebx, 10
904 lea ebp, DWORD PTR 2840853838[esi*1+ebp]
905 sub edi, ebx
906 rol ebp, 12
907 add ebp, edx
908 ; 72
909 mov esi, DWORD PTR 60[esp]
910 or edi, eax
911 add edx, esi
912 xor edi, ebp
913 mov esi, -1
914 rol eax, 10
915 lea edx, DWORD PTR 2840853838[edi*1+edx]
916 sub esi, eax
917 rol edx, 5
918 add edx, ecx
919 ; 73
920 mov edi, DWORD PTR 8[esp]
921 or esi, ebp
922 add ecx, edi
923 xor esi, edx
924 mov edi, -1
925 rol ebp, 10
926 lea ecx, DWORD PTR 2840853838[esi*1+ecx]
927 sub edi, ebp
928 rol ecx, 12
929 add ecx, ebx
930 ; 74
931 mov esi, DWORD PTR 16[esp]
932 or edi, edx
933 add ebx, esi
934 xor edi, ecx
935 mov esi, -1
936 rol edx, 10
937 lea ebx, DWORD PTR 2840853838[edi*1+ebx]
938 sub esi, edx
939 rol ebx, 13
940 add ebx, eax
941 ; 75
942 mov edi, DWORD PTR 36[esp]
943 or esi, ecx
944 add eax, edi
945 xor esi, ebx
946 mov edi, -1
947 rol ecx, 10
948 lea eax, DWORD PTR 2840853838[esi*1+eax]
949 sub edi, ecx
950 rol eax, 14
951 add eax, ebp
952 ; 76
953 mov esi, DWORD PTR 48[esp]
954 or edi, ebx
955 add ebp, esi
956 xor edi, eax
957 mov esi, -1
958 rol ebx, 10
959 lea ebp, DWORD PTR 2840853838[edi*1+ebp]
960 sub esi, ebx
961 rol ebp, 11
962 add ebp, edx
963 ; 77
964 mov edi, DWORD PTR 28[esp]
965 or esi, eax
966 add edx, edi
967 xor esi, ebp
968 mov edi, -1
969 rol eax, 10
970 lea edx, DWORD PTR 2840853838[esi*1+edx]
971 sub edi, eax
972 rol edx, 8
973 add edx, ecx
974 ; 78
975 mov esi, DWORD PTR 64[esp]
976 or edi, ebp
977 add ecx, esi
978 xor edi, edx
979 mov esi, -1
980 rol ebp, 10
981 lea ecx, DWORD PTR 2840853838[edi*1+ecx]
982 sub esi, ebp
983 rol ecx, 5
984 add ecx, ebx
985 ; 79
986 mov edi, DWORD PTR 56[esp]
987 or esi, edx
988 add ebx, edi
989 xor esi, ecx
990 mov edi, DWORD PTR 108[esp]
991 rol edx, 10
992 lea ebx, DWORD PTR 2840853838[esi*1+ebx]
993 mov DWORD PTR 68[esp],eax
994 rol ebx, 6
995 add ebx, eax
996 mov eax, DWORD PTR [edi]
997 mov DWORD PTR 72[esp],ebx
998 mov DWORD PTR 76[esp],ecx
999 mov ebx, DWORD PTR 4[edi]
1000 mov DWORD PTR 80[esp],edx
1001 mov ecx, DWORD PTR 8[edi]
1002 mov DWORD PTR 84[esp],ebp
1003 mov edx, DWORD PTR 12[edi]
1004 mov ebp, DWORD PTR 16[edi]
1005 ; 80
1006 mov edi, -1
1007 sub edi, edx
1008 mov esi, DWORD PTR 24[esp]
1009 or edi, ecx
1010 add eax, esi
1011 xor edi, ebx
1012 mov esi, -1
1013 rol ecx, 10
1014 lea eax, DWORD PTR 1352829926[edi*1+eax]
1015 sub esi, ecx
1016 rol eax, 8
1017 add eax, ebp
1018 ; 81
1019 mov edi, DWORD PTR 60[esp]
1020 or esi, ebx
1021 add ebp, edi
1022 xor esi, eax
1023 mov edi, -1
1024 rol ebx, 10
1025 lea ebp, DWORD PTR 1352829926[esi*1+ebp]
1026 sub edi, ebx
1027 rol ebp, 9
1028 add ebp, edx
1029 ; 82
1030 mov esi, DWORD PTR 32[esp]
1031 or edi, eax
1032 add edx, esi
1033 xor edi, ebp
1034 mov esi, -1
1035 rol eax, 10
1036 lea edx, DWORD PTR 1352829926[edi*1+edx]
1037 sub esi, eax
1038 rol edx, 9
1039 add edx, ecx
1040 ; 83
1041 mov edi, DWORD PTR 4[esp]
1042 or esi, ebp
1043 add ecx, edi
1044 xor esi, edx
1045 mov edi, -1
1046 rol ebp, 10
1047 lea ecx, DWORD PTR 1352829926[esi*1+ecx]
1048 sub edi, ebp
1049 rol ecx, 11
1050 add ecx, ebx
1051 ; 84
1052 mov esi, DWORD PTR 40[esp]
1053 or edi, edx
1054 add ebx, esi
1055 xor edi, ecx
1056 mov esi, -1
1057 rol edx, 10
1058 lea ebx, DWORD PTR 1352829926[edi*1+ebx]
1059 sub esi, edx
1060 rol ebx, 13
1061 add ebx, eax
1062 ; 85
1063 mov edi, DWORD PTR 12[esp]
1064 or esi, ecx
1065 add eax, edi
1066 xor esi, ebx
1067 mov edi, -1
1068 rol ecx, 10
1069 lea eax, DWORD PTR 1352829926[esi*1+eax]
1070 sub edi, ecx
1071 rol eax, 15
1072 add eax, ebp
1073 ; 86
1074 mov esi, DWORD PTR 48[esp]
1075 or edi, ebx
1076 add ebp, esi
1077 xor edi, eax
1078 mov esi, -1
1079 rol ebx, 10
1080 lea ebp, DWORD PTR 1352829926[edi*1+ebp]
1081 sub esi, ebx
1082 rol ebp, 15
1083 add ebp, edx
1084 ; 87
1085 mov edi, DWORD PTR 20[esp]
1086 or esi, eax
1087 add edx, edi
1088 xor esi, ebp
1089 mov edi, -1
1090 rol eax, 10
1091 lea edx, DWORD PTR 1352829926[esi*1+edx]
1092 sub edi, eax
1093 rol edx, 5
1094 add edx, ecx
1095 ; 88
1096 mov esi, DWORD PTR 56[esp]
1097 or edi, ebp
1098 add ecx, esi
1099 xor edi, edx
1100 mov esi, -1
1101 rol ebp, 10
1102 lea ecx, DWORD PTR 1352829926[edi*1+ecx]
1103 sub esi, ebp
1104 rol ecx, 7
1105 add ecx, ebx
1106 ; 89
1107 mov edi, DWORD PTR 28[esp]
1108 or esi, edx
1109 add ebx, edi
1110 xor esi, ecx
1111 mov edi, -1
1112 rol edx, 10
1113 lea ebx, DWORD PTR 1352829926[esi*1+ebx]
1114 sub edi, edx
1115 rol ebx, 7
1116 add ebx, eax
1117 ; 90
1118 mov esi, DWORD PTR 64[esp]
1119 or edi, ecx
1120 add eax, esi
1121 xor edi, ebx
1122 mov esi, -1
1123 rol ecx, 10
1124 lea eax, DWORD PTR 1352829926[edi*1+eax]
1125 sub esi, ecx
1126 rol eax, 8
1127 add eax, ebp
1128 ; 91
1129 mov edi, DWORD PTR 36[esp]
1130 or esi, ebx
1131 add ebp, edi
1132 xor esi, eax
1133 mov edi, -1
1134 rol ebx, 10
1135 lea ebp, DWORD PTR 1352829926[esi*1+ebp]
1136 sub edi, ebx
1137 rol ebp, 11
1138 add ebp, edx
1139 ; 92
1140 mov esi, DWORD PTR 8[esp]
1141 or edi, eax
1142 add edx, esi
1143 xor edi, ebp
1144 mov esi, -1
1145 rol eax, 10
1146 lea edx, DWORD PTR 1352829926[edi*1+edx]
1147 sub esi, eax
1148 rol edx, 14
1149 add edx, ecx
1150 ; 93
1151 mov edi, DWORD PTR 44[esp]
1152 or esi, ebp
1153 add ecx, edi
1154 xor esi, edx
1155 mov edi, -1
1156 rol ebp, 10
1157 lea ecx, DWORD PTR 1352829926[esi*1+ecx]
1158 sub edi, ebp
1159 rol ecx, 14
1160 add ecx, ebx
1161 ; 94
1162 mov esi, DWORD PTR 16[esp]
1163 or edi, edx
1164 add ebx, esi
1165 xor edi, ecx
1166 mov esi, -1
1167 rol edx, 10
1168 lea ebx, DWORD PTR 1352829926[edi*1+ebx]
1169 sub esi, edx
1170 rol ebx, 12
1171 add ebx, eax
1172 ; 95
1173 mov edi, DWORD PTR 52[esp]
1174 or esi, ecx
1175 add eax, edi
1176 xor esi, ebx
1177 mov edi, -1
1178 rol ecx, 10
1179 lea eax, DWORD PTR 1352829926[esi*1+eax]
1180 mov esi, ecx
1181 rol eax, 6
1182 add eax, ebp
1183 ; 96
1184 sub edi, ecx
1185 and esi, eax
1186 and edi, ebx
1187 or edi, esi
1188 mov esi, DWORD PTR 28[esp]
1189 rol ebx, 10
1190 lea ebp, DWORD PTR 1548603684[edi+ebp]
1191 mov edi, -1
1192 add ebp, esi
1193 mov esi, ebx
1194 rol ebp, 9
1195 add ebp, edx
1196 ; 97
1197 sub edi, ebx
1198 and esi, ebp
1199 and edi, eax
1200 or edi, esi
1201 mov esi, DWORD PTR 48[esp]
1202 rol eax, 10
1203 lea edx, DWORD PTR 1548603684[edi+edx]
1204 mov edi, -1
1205 add edx, esi
1206 mov esi, eax
1207 rol edx, 13
1208 add edx, ecx
1209 ; 98
1210 sub edi, eax
1211 and esi, edx
1212 and edi, ebp
1213 or edi, esi
1214 mov esi, DWORD PTR 16[esp]
1215 rol ebp, 10
1216 lea ecx, DWORD PTR 1548603684[edi+ecx]
1217 mov edi, -1
1218 add ecx, esi
1219 mov esi, ebp
1220 rol ecx, 15
1221 add ecx, ebx
1222 ; 99
1223 sub edi, ebp
1224 and esi, ecx
1225 and edi, edx
1226 or edi, esi
1227 mov esi, DWORD PTR 32[esp]
1228 rol edx, 10
1229 lea ebx, DWORD PTR 1548603684[edi+ebx]
1230 mov edi, -1
1231 add ebx, esi
1232 mov esi, edx
1233 rol ebx, 7
1234 add ebx, eax
1235 ; 100
1236 sub edi, edx
1237 and esi, ebx
1238 and edi, ecx
1239 or edi, esi
1240 mov esi, DWORD PTR 4[esp]
1241 rol ecx, 10
1242 lea eax, DWORD PTR 1548603684[edi+eax]
1243 mov edi, -1
1244 add eax, esi
1245 mov esi, ecx
1246 rol eax, 12
1247 add eax, ebp
1248 ; 101
1249 sub edi, ecx
1250 and esi, eax
1251 and edi, ebx
1252 or edi, esi
1253 mov esi, DWORD PTR 56[esp]
1254 rol ebx, 10
1255 lea ebp, DWORD PTR 1548603684[edi+ebp]
1256 mov edi, -1
1257 add ebp, esi
1258 mov esi, ebx
1259 rol ebp, 8
1260 add ebp, edx
1261 ; 102
1262 sub edi, ebx
1263 and esi, ebp
1264 and edi, eax
1265 or edi, esi
1266 mov esi, DWORD PTR 24[esp]
1267 rol eax, 10
1268 lea edx, DWORD PTR 1548603684[edi+edx]
1269 mov edi, -1
1270 add edx, esi
1271 mov esi, eax
1272 rol edx, 9
1273 add edx, ecx
1274 ; 103
1275 sub edi, eax
1276 and esi, edx
1277 and edi, ebp
1278 or edi, esi
1279 mov esi, DWORD PTR 44[esp]
1280 rol ebp, 10
1281 lea ecx, DWORD PTR 1548603684[edi+ecx]
1282 mov edi, -1
1283 add ecx, esi
1284 mov esi, ebp
1285 rol ecx, 11
1286 add ecx, ebx
1287 ; 104
1288 sub edi, ebp
1289 and esi, ecx
1290 and edi, edx
1291 or edi, esi
1292 mov esi, DWORD PTR 60[esp]
1293 rol edx, 10
1294 lea ebx, DWORD PTR 1548603684[edi+ebx]
1295 mov edi, -1
1296 add ebx, esi
1297 mov esi, edx
1298 rol ebx, 7
1299 add ebx, eax
1300 ; 105
1301 sub edi, edx
1302 and esi, ebx
1303 and edi, ecx
1304 or edi, esi
1305 mov esi, DWORD PTR 64[esp]
1306 rol ecx, 10
1307 lea eax, DWORD PTR 1548603684[edi+eax]
1308 mov edi, -1
1309 add eax, esi
1310 mov esi, ecx
1311 rol eax, 7
1312 add eax, ebp
1313 ; 106
1314 sub edi, ecx
1315 and esi, eax
1316 and edi, ebx
1317 or edi, esi
1318 mov esi, DWORD PTR 36[esp]
1319 rol ebx, 10
1320 lea ebp, DWORD PTR 1548603684[edi+ebp]
1321 mov edi, -1
1322 add ebp, esi
1323 mov esi, ebx
1324 rol ebp, 12
1325 add ebp, edx
1326 ; 107
1327 sub edi, ebx
1328 and esi, ebp
1329 and edi, eax
1330 or edi, esi
1331 mov esi, DWORD PTR 52[esp]
1332 rol eax, 10
1333 lea edx, DWORD PTR 1548603684[edi+edx]
1334 mov edi, -1
1335 add edx, esi
1336 mov esi, eax
1337 rol edx, 7
1338 add edx, ecx
1339 ; 108
1340 sub edi, eax
1341 and esi, edx
1342 and edi, ebp
1343 or edi, esi
1344 mov esi, DWORD PTR 20[esp]
1345 rol ebp, 10
1346 lea ecx, DWORD PTR 1548603684[edi+ecx]
1347 mov edi, -1
1348 add ecx, esi
1349 mov esi, ebp
1350 rol ecx, 6
1351 add ecx, ebx
1352 ; 109
1353 sub edi, ebp
1354 and esi, ecx
1355 and edi, edx
1356 or edi, esi
1357 mov esi, DWORD PTR 40[esp]
1358 rol edx, 10
1359 lea ebx, DWORD PTR 1548603684[edi+ebx]
1360 mov edi, -1
1361 add ebx, esi
1362 mov esi, edx
1363 rol ebx, 15
1364 add ebx, eax
1365 ; 110
1366 sub edi, edx
1367 and esi, ebx
1368 and edi, ecx
1369 or edi, esi
1370 mov esi, DWORD PTR 8[esp]
1371 rol ecx, 10
1372 lea eax, DWORD PTR 1548603684[edi+eax]
1373 mov edi, -1
1374 add eax, esi
1375 mov esi, ecx
1376 rol eax, 13
1377 add eax, ebp
1378 ; 111
1379 sub edi, ecx
1380 and esi, eax
1381 and edi, ebx
1382 or edi, esi
1383 mov esi, DWORD PTR 12[esp]
1384 rol ebx, 10
1385 lea ebp, DWORD PTR 1548603684[edi+ebp]
1386 mov edi, -1
1387 add ebp, esi
1388 sub edi, eax
1389 rol ebp, 11
1390 add ebp, edx
1391 ; 112
1392 mov esi, DWORD PTR 64[esp]
1393 or edi, ebp
1394 add edx, esi
1395 xor edi, ebx
1396 mov esi, -1
1397 rol eax, 10
1398 lea edx, DWORD PTR 1836072691[edi*1+edx]
1399 sub esi, ebp
1400 rol edx, 9
1401 add edx, ecx
1402 ; 113
1403 mov edi, DWORD PTR 24[esp]
1404 or esi, edx
1405 add ecx, edi
1406 xor esi, eax
1407 mov edi, -1
1408 rol ebp, 10
1409 lea ecx, DWORD PTR 1836072691[esi*1+ecx]
1410 sub edi, edx
1411 rol ecx, 7
1412 add ecx, ebx
1413 ; 114
1414 mov esi, DWORD PTR 8[esp]
1415 or edi, ecx
1416 add ebx, esi
1417 xor edi, ebp
1418 mov esi, -1
1419 rol edx, 10
1420 lea ebx, DWORD PTR 1836072691[edi*1+ebx]
1421 sub esi, ecx
1422 rol ebx, 15
1423 add ebx, eax
1424 ; 115
1425 mov edi, DWORD PTR 16[esp]
1426 or esi, ebx
1427 add eax, edi
1428 xor esi, edx
1429 mov edi, -1
1430 rol ecx, 10
1431 lea eax, DWORD PTR 1836072691[esi*1+eax]
1432 sub edi, ebx
1433 rol eax, 11
1434 add eax, ebp
1435 ; 116
1436 mov esi, DWORD PTR 32[esp]
1437 or edi, eax
1438 add ebp, esi
1439 xor edi, ecx
1440 mov esi, -1
1441 rol ebx, 10
1442 lea ebp, DWORD PTR 1836072691[edi*1+ebp]
1443 sub esi, eax
1444 rol ebp, 8
1445 add ebp, edx
1446 ; 117
1447 mov edi, DWORD PTR 60[esp]
1448 or esi, ebp
1449 add edx, edi
1450 xor esi, ebx
1451 mov edi, -1
1452 rol eax, 10
1453 lea edx, DWORD PTR 1836072691[esi*1+edx]
1454 sub edi, ebp
1455 rol edx, 6
1456 add edx, ecx
1457 ; 118
1458 mov esi, DWORD PTR 28[esp]
1459 or edi, edx
1460 add ecx, esi
1461 xor edi, eax
1462 mov esi, -1
1463 rol ebp, 10
1464 lea ecx, DWORD PTR 1836072691[edi*1+ecx]
1465 sub esi, edx
1466 rol ecx, 6
1467 add ecx, ebx
1468 ; 119
1469 mov edi, DWORD PTR 40[esp]
1470 or esi, ecx
1471 add ebx, edi
1472 xor esi, ebp
1473 mov edi, -1
1474 rol edx, 10
1475 lea ebx, DWORD PTR 1836072691[esi*1+ebx]
1476 sub edi, ecx
1477 rol ebx, 14
1478 add ebx, eax
1479 ; 120
1480 mov esi, DWORD PTR 48[esp]
1481 or edi, ebx
1482 add eax, esi
1483 xor edi, edx
1484 mov esi, -1
1485 rol ecx, 10
1486 lea eax, DWORD PTR 1836072691[edi*1+eax]
1487 sub esi, ebx
1488 rol eax, 12
1489 add eax, ebp
1490 ; 121
1491 mov edi, DWORD PTR 36[esp]
1492 or esi, eax
1493 add ebp, edi
1494 xor esi, ecx
1495 mov edi, -1
1496 rol ebx, 10
1497 lea ebp, DWORD PTR 1836072691[esi*1+ebp]
1498 sub edi, eax
1499 rol ebp, 13
1500 add ebp, edx
1501 ; 122
1502 mov esi, DWORD PTR 52[esp]
1503 or edi, ebp
1504 add edx, esi
1505 xor edi, ebx
1506 mov esi, -1
1507 rol eax, 10
1508 lea edx, DWORD PTR 1836072691[edi*1+edx]
1509 sub esi, ebp
1510 rol edx, 5
1511 add edx, ecx
1512 ; 123
1513 mov edi, DWORD PTR 12[esp]
1514 or esi, edx
1515 add ecx, edi
1516 xor esi, eax
1517 mov edi, -1
1518 rol ebp, 10
1519 lea ecx, DWORD PTR 1836072691[esi*1+ecx]
1520 sub edi, edx
1521 rol ecx, 14
1522 add ecx, ebx
1523 ; 124
1524 mov esi, DWORD PTR 44[esp]
1525 or edi, ecx
1526 add ebx, esi
1527 xor edi, ebp
1528 mov esi, -1
1529 rol edx, 10
1530 lea ebx, DWORD PTR 1836072691[edi*1+ebx]
1531 sub esi, ecx
1532 rol ebx, 13
1533 add ebx, eax
1534 ; 125
1535 mov edi, DWORD PTR 4[esp]
1536 or esi, ebx
1537 add eax, edi
1538 xor esi, edx
1539 mov edi, -1
1540 rol ecx, 10
1541 lea eax, DWORD PTR 1836072691[esi*1+eax]
1542 sub edi, ebx
1543 rol eax, 13
1544 add eax, ebp
1545 ; 126
1546 mov esi, DWORD PTR 20[esp]
1547 or edi, eax
1548 add ebp, esi
1549 xor edi, ecx
1550 mov esi, -1
1551 rol ebx, 10
1552 lea ebp, DWORD PTR 1836072691[edi*1+ebp]
1553 sub esi, eax
1554 rol ebp, 7
1555 add ebp, edx
1556 ; 127
1557 mov edi, DWORD PTR 56[esp]
1558 or esi, ebp
1559 add edx, edi
1560 xor esi, ebx
1561 mov edi, DWORD PTR 36[esp]
1562 rol eax, 10
1563 lea edx, DWORD PTR 1836072691[esi*1+edx]
1564 mov esi, -1
1565 rol edx, 5
1566 add edx, ecx
1567 ; 128
1568 add ecx, edi
1569 mov edi, ebp
1570 sub esi, edx
1571 and edi, edx
1572 and esi, eax
1573 or edi, esi
1574 mov esi, DWORD PTR 28[esp]
1575 rol ebp, 10
1576 lea ecx, DWORD PTR 2053994217[edi*1+ecx]
1577 mov edi, -1
1578 rol ecx, 15
1579 add ecx, ebx
1580 ; 129
1581 add ebx, esi
1582 mov esi, edx
1583 sub edi, ecx
1584 and esi, ecx
1585 and edi, ebp
1586 or esi, edi
1587 mov edi, DWORD PTR 20[esp]
1588 rol edx, 10
1589 lea ebx, DWORD PTR 2053994217[esi*1+ebx]
1590 mov esi, -1
1591 rol ebx, 5
1592 add ebx, eax
1593 ; 130
1594 add eax, edi
1595 mov edi, ecx
1596 sub esi, ebx
1597 and edi, ebx
1598 and esi, edx
1599 or edi, esi
1600 mov esi, DWORD PTR 8[esp]
1601 rol ecx, 10
1602 lea eax, DWORD PTR 2053994217[edi*1+eax]
1603 mov edi, -1
1604 rol eax, 8
1605 add eax, ebp
1606 ; 131
1607 add ebp, esi
1608 mov esi, ebx
1609 sub edi, eax
1610 and esi, eax
1611 and edi, ecx
1612 or esi, edi
1613 mov edi, DWORD PTR 16[esp]
1614 rol ebx, 10
1615 lea ebp, DWORD PTR 2053994217[esi*1+ebp]
1616 mov esi, -1
1617 rol ebp, 11
1618 add ebp, edx
1619 ; 132
1620 add edx, edi
1621 mov edi, eax
1622 sub esi, ebp
1623 and edi, ebp
1624 and esi, ebx
1625 or edi, esi
1626 mov esi, DWORD PTR 48[esp]
1627 rol eax, 10
1628 lea edx, DWORD PTR 2053994217[edi*1+edx]
1629 mov edi, -1
1630 rol edx, 14
1631 add edx, ecx
1632 ; 133
1633 add ecx, esi
1634 mov esi, ebp
1635 sub edi, edx
1636 and esi, edx
1637 and edi, eax
1638 or esi, edi
1639 mov edi, DWORD PTR 64[esp]
1640 rol ebp, 10
1641 lea ecx, DWORD PTR 2053994217[esi*1+ecx]
1642 mov esi, -1
1643 rol ecx, 14
1644 add ecx, ebx
1645 ; 134
1646 add ebx, edi
1647 mov edi, edx
1648 sub esi, ecx
1649 and edi, ecx
1650 and esi, ebp
1651 or edi, esi
1652 mov esi, DWORD PTR 4[esp]
1653 rol edx, 10
1654 lea ebx, DWORD PTR 2053994217[edi*1+ebx]
1655 mov edi, -1
1656 rol ebx, 6
1657 add ebx, eax
1658 ; 135
1659 add eax, esi
1660 mov esi, ecx
1661 sub edi, ebx
1662 and esi, ebx
1663 and edi, edx
1664 or esi, edi
1665 mov edi, DWORD PTR 24[esp]
1666 rol ecx, 10
1667 lea eax, DWORD PTR 2053994217[esi*1+eax]
1668 mov esi, -1
1669 rol eax, 14
1670 add eax, ebp
1671 ; 136
1672 add ebp, edi
1673 mov edi, ebx
1674 sub esi, eax
1675 and edi, eax
1676 and esi, ecx
1677 or edi, esi
1678 mov esi, DWORD PTR 52[esp]
1679 rol ebx, 10
1680 lea ebp, DWORD PTR 2053994217[edi*1+ebp]
1681 mov edi, -1
1682 rol ebp, 6
1683 add ebp, edx
1684 ; 137
1685 add edx, esi
1686 mov esi, eax
1687 sub edi, ebp
1688 and esi, ebp
1689 and edi, ebx
1690 or esi, edi
1691 mov edi, DWORD PTR 12[esp]
1692 rol eax, 10
1693 lea edx, DWORD PTR 2053994217[esi*1+edx]
1694 mov esi, -1
1695 rol edx, 9
1696 add edx, ecx
1697 ; 138
1698 add ecx, edi
1699 mov edi, ebp
1700 sub esi, edx
1701 and edi, edx
1702 and esi, eax
1703 or edi, esi
1704 mov esi, DWORD PTR 56[esp]
1705 rol ebp, 10
1706 lea ecx, DWORD PTR 2053994217[edi*1+ecx]
1707 mov edi, -1
1708 rol ecx, 12
1709 add ecx, ebx
1710 ; 139
1711 add ebx, esi
1712 mov esi, edx
1713 sub edi, ecx
1714 and esi, ecx
1715 and edi, ebp
1716 or esi, edi
1717 mov edi, DWORD PTR 40[esp]
1718 rol edx, 10
1719 lea ebx, DWORD PTR 2053994217[esi*1+ebx]
1720 mov esi, -1
1721 rol ebx, 9
1722 add ebx, eax
1723 ; 140
1724 add eax, edi
1725 mov edi, ecx
1726 sub esi, ebx
1727 and edi, ebx
1728 and esi, edx
1729 or edi, esi
1730 mov esi, DWORD PTR 32[esp]
1731 rol ecx, 10
1732 lea eax, DWORD PTR 2053994217[edi*1+eax]
1733 mov edi, -1
1734 rol eax, 12
1735 add eax, ebp
1736 ; 141
1737 add ebp, esi
1738 mov esi, ebx
1739 sub edi, eax
1740 and esi, eax
1741 and edi, ecx
1742 or esi, edi
1743 mov edi, DWORD PTR 44[esp]
1744 rol ebx, 10
1745 lea ebp, DWORD PTR 2053994217[esi*1+ebp]
1746 mov esi, -1
1747 rol ebp, 5
1748 add ebp, edx
1749 ; 142
1750 add edx, edi
1751 mov edi, eax
1752 sub esi, ebp
1753 and edi, ebp
1754 and esi, ebx
1755 or edi, esi
1756 mov esi, DWORD PTR 60[esp]
1757 rol eax, 10
1758 lea edx, DWORD PTR 2053994217[edi*1+edx]
1759 mov edi, -1
1760 rol edx, 15
1761 add edx, ecx
1762 ; 143
1763 add ecx, esi
1764 mov esi, ebp
1765 sub edi, edx
1766 and esi, edx
1767 and edi, eax
1768 or edi, esi
1769 mov esi, edx
1770 rol ebp, 10
1771 lea ecx, DWORD PTR 2053994217[edi*1+ecx]
1772 xor esi, ebp
1773 rol ecx, 8
1774 add ecx, ebx
1775 ; 144
1776 mov edi, DWORD PTR 52[esp]
1777 xor esi, ecx
1778 add ebx, edi
1779 rol edx, 10
1780 add ebx, esi
1781 mov esi, ecx
1782 rol ebx, 8
1783 add ebx, eax
1784 ; 145
1785 xor esi, edx
1786 mov edi, DWORD PTR 64[esp]
1787 xor esi, ebx
1788 add eax, esi
1789 mov esi, ebx
1790 rol ecx, 10
1791 add eax, edi
1792 xor esi, ecx
1793 rol eax, 5
1794 add eax, ebp
1795 ; 146
1796 mov edi, DWORD PTR 44[esp]
1797 xor esi, eax
1798 add ebp, edi
1799 rol ebx, 10
1800 add ebp, esi
1801 mov esi, eax
1802 rol ebp, 12
1803 add ebp, edx
1804 ; 147
1805 xor esi, ebx
1806 mov edi, DWORD PTR 20[esp]
1807 xor esi, ebp
1808 add edx, esi
1809 mov esi, ebp
1810 rol eax, 10
1811 add edx, edi
1812 xor esi, eax
1813 rol edx, 9
1814 add edx, ecx
1815 ; 148
1816 mov edi, DWORD PTR 8[esp]
1817 xor esi, edx
1818 add ecx, edi
1819 rol ebp, 10
1820 add ecx, esi
1821 mov esi, edx
1822 rol ecx, 12
1823 add ecx, ebx
1824 ; 149
1825 xor esi, ebp
1826 mov edi, DWORD PTR 24[esp]
1827 xor esi, ecx
1828 add ebx, esi
1829 mov esi, ecx
1830 rol edx, 10
1831 add ebx, edi
1832 xor esi, edx
1833 rol ebx, 5
1834 add ebx, eax
1835 ; 150
1836 mov edi, DWORD PTR 36[esp]
1837 xor esi, ebx
1838 add eax, edi
1839 rol ecx, 10
1840 add eax, esi
1841 mov esi, ebx
1842 rol eax, 14
1843 add eax, ebp
1844 ; 151
1845 xor esi, ecx
1846 mov edi, DWORD PTR 32[esp]
1847 xor esi, eax
1848 add ebp, esi
1849 mov esi, eax
1850 rol ebx, 10
1851 add ebp, edi
1852 xor esi, ebx
1853 rol ebp, 6
1854 add ebp, edx
1855 ; 152
1856 mov edi, DWORD PTR 28[esp]
1857 xor esi, ebp
1858 add edx, edi
1859 rol eax, 10
1860 add edx, esi
1861 mov esi, ebp
1862 rol edx, 8
1863 add edx, ecx
1864 ; 153
1865 xor esi, eax
1866 mov edi, DWORD PTR 12[esp]
1867 xor esi, edx
1868 add ecx, esi
1869 mov esi, edx
1870 rol ebp, 10
1871 add ecx, edi
1872 xor esi, ebp
1873 rol ecx, 13
1874 add ecx, ebx
1875 ; 154
1876 mov edi, DWORD PTR 56[esp]
1877 xor esi, ecx
1878 add ebx, edi
1879 rol edx, 10
1880 add ebx, esi
1881 mov esi, ecx
1882 rol ebx, 6
1883 add ebx, eax
1884 ; 155
1885 xor esi, edx
1886 mov edi, DWORD PTR 60[esp]
1887 xor esi, ebx
1888 add eax, esi
1889 mov esi, ebx
1890 rol ecx, 10
1891 add eax, edi
1892 xor esi, ecx
1893 rol eax, 5
1894 add eax, ebp
1895 ; 156
1896 mov edi, DWORD PTR 4[esp]
1897 xor esi, eax
1898 add ebp, edi
1899 rol ebx, 10
1900 add ebp, esi
1901 mov esi, eax
1902 rol ebp, 15
1903 add ebp, edx
1904 ; 157
1905 xor esi, ebx
1906 mov edi, DWORD PTR 16[esp]
1907 xor esi, ebp
1908 add edx, esi
1909 mov esi, ebp
1910 rol eax, 10
1911 add edx, edi
1912 xor esi, eax
1913 rol edx, 13
1914 add edx, ecx
1915 ; 158
1916 mov edi, DWORD PTR 40[esp]
1917 xor esi, edx
1918 add ecx, edi
1919 rol ebp, 10
1920 add ecx, esi
1921 mov esi, edx
1922 rol ecx, 11
1923 add ecx, ebx
1924 ; 159
1925 xor esi, ebp
1926 mov edi, DWORD PTR 48[esp]
1927 xor esi, ecx
1928 add ebx, esi
1929 rol edx, 10
1930 add ebx, edi
1931 mov edi, DWORD PTR 108[esp]
1932 rol ebx, 11
1933 add ebx, eax
1934 mov esi, DWORD PTR 4[edi]
1935 add edx, esi
1936 mov esi, DWORD PTR 76[esp]
1937 add edx, esi
1938 mov esi, DWORD PTR 8[edi]
1939 add ebp, esi
1940 mov esi, DWORD PTR 80[esp]
1941 add ebp, esi
1942 mov esi, DWORD PTR 12[edi]
1943 add eax, esi
1944 mov esi, DWORD PTR 84[esp]
1945 add eax, esi
1946 mov esi, DWORD PTR 16[edi]
1947 add ebx, esi
1948 mov esi, DWORD PTR 68[esp]
1949 add ebx, esi
1950 mov esi, DWORD PTR [edi]
1951 add ecx, esi
1952 mov esi, DWORD PTR 72[esp]
1953 add ecx, esi
1954 mov DWORD PTR [edi],edx
1955 mov DWORD PTR 4[edi],ebp
1956 mov DWORD PTR 8[edi],eax
1957 mov DWORD PTR 12[edi],ebx
1958 mov DWORD PTR 16[edi],ecx
1959 mov edi, DWORD PTR [esp]
1960 mov esi, DWORD PTR 112[esp]
1961 cmp edi, esi
1962 mov edi, DWORD PTR 108[esp]
1963 jge L000start
1964 add esp, 88
1965 pop ebx
1966 pop ebp
1967 pop edi
1968 pop esi
1969 ret
1970_ripemd160_block_x86 ENDP
1971_TEXT ENDS
1972END
diff --git a/src/lib/libcrypto/ripemd/asm/rm86unix.cpp b/src/lib/libcrypto/ripemd/asm/rm86unix.cpp
new file mode 100644
index 0000000000..f90f6f2fd6
--- /dev/null
+++ b/src/lib/libcrypto/ripemd/asm/rm86unix.cpp
@@ -0,0 +1,2016 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define ripemd160_block_x86 _ripemd160_block_x86
13
14#endif
15
16#ifdef OUT
17#define OK 1
18#define ALIGN 4
19#endif
20
21#ifdef BSDI
22#define OK 1
23#define ALIGN 4
24#undef SIZE
25#undef TYPE
26#define SIZE(a,b)
27#define TYPE(a,b)
28#endif
29
30#if defined(ELF) || defined(SOL)
31#define OK 1
32#define ALIGN 16
33#endif
34
35#ifndef OK
36You need to define one of
37ELF - elf systems - linux-elf, NetBSD and DG-UX
38OUT - a.out systems - linux-a.out and FreeBSD
39SOL - solaris systems, which are elf with strange comment lines
40BSDI - a.out with a very primative version of as.
41#endif
42
43/* Let the Assembler begin :-) */
44 /* Don't even think of reading this code */
45 /* It was automatically generated by rmd-586.pl */
46 /* Which is a perl program used to generate the x86 assember for */
47 /* any of elf, a.out, BSDI,Win32, or Solaris */
48 /* eric <eay@cryptsoft.com> */
49
50 .file "rmd-586.s"
51 .version "01.01"
52gcc2_compiled.:
53.text
54 .align ALIGN
55.globl ripemd160_block_x86
56 TYPE(ripemd160_block_x86,@function)
57ripemd160_block_x86:
58 pushl %esi
59 movl 16(%esp), %ecx
60 pushl %edi
61 movl 16(%esp), %esi
62 pushl %ebp
63 addl %esi, %ecx
64 pushl %ebx
65 subl $64, %ecx
66 subl $88, %esp
67 movl %ecx, (%esp)
68 movl 108(%esp), %edi
69.L000start:
70
71 movl (%esi), %eax
72 movl 4(%esi), %ebx
73 movl %eax, 4(%esp)
74 movl %ebx, 8(%esp)
75 movl 8(%esi), %eax
76 movl 12(%esi), %ebx
77 movl %eax, 12(%esp)
78 movl %ebx, 16(%esp)
79 movl 16(%esi), %eax
80 movl 20(%esi), %ebx
81 movl %eax, 20(%esp)
82 movl %ebx, 24(%esp)
83 movl 24(%esi), %eax
84 movl 28(%esi), %ebx
85 movl %eax, 28(%esp)
86 movl %ebx, 32(%esp)
87 movl 32(%esi), %eax
88 movl 36(%esi), %ebx
89 movl %eax, 36(%esp)
90 movl %ebx, 40(%esp)
91 movl 40(%esi), %eax
92 movl 44(%esi), %ebx
93 movl %eax, 44(%esp)
94 movl %ebx, 48(%esp)
95 movl 48(%esi), %eax
96 movl 52(%esi), %ebx
97 movl %eax, 52(%esp)
98 movl %ebx, 56(%esp)
99 movl 56(%esi), %eax
100 movl 60(%esi), %ebx
101 movl %eax, 60(%esp)
102 movl %ebx, 64(%esp)
103 addl $64, %esi
104 movl (%edi), %eax
105 movl %esi, 112(%esp)
106 movl 4(%edi), %ebx
107 movl 8(%edi), %ecx
108 movl 12(%edi), %edx
109 movl 16(%edi), %ebp
110 /* 0 */
111 movl %ecx, %esi
112 xorl %edx, %esi
113 movl 4(%esp), %edi
114 xorl %ebx, %esi
115 addl %edi, %eax
116 roll $10, %ecx
117 addl %esi, %eax
118 movl %ebx, %esi
119 roll $11, %eax
120 addl %ebp, %eax
121 /* 1 */
122 xorl %ecx, %esi
123 movl 8(%esp), %edi
124 xorl %eax, %esi
125 addl %esi, %ebp
126 movl %eax, %esi
127 roll $10, %ebx
128 addl %edi, %ebp
129 xorl %ebx, %esi
130 roll $14, %ebp
131 addl %edx, %ebp
132 /* 2 */
133 movl 12(%esp), %edi
134 xorl %ebp, %esi
135 addl %edi, %edx
136 roll $10, %eax
137 addl %esi, %edx
138 movl %ebp, %esi
139 roll $15, %edx
140 addl %ecx, %edx
141 /* 3 */
142 xorl %eax, %esi
143 movl 16(%esp), %edi
144 xorl %edx, %esi
145 addl %esi, %ecx
146 movl %edx, %esi
147 roll $10, %ebp
148 addl %edi, %ecx
149 xorl %ebp, %esi
150 roll $12, %ecx
151 addl %ebx, %ecx
152 /* 4 */
153 movl 20(%esp), %edi
154 xorl %ecx, %esi
155 addl %edi, %ebx
156 roll $10, %edx
157 addl %esi, %ebx
158 movl %ecx, %esi
159 roll $5, %ebx
160 addl %eax, %ebx
161 /* 5 */
162 xorl %edx, %esi
163 movl 24(%esp), %edi
164 xorl %ebx, %esi
165 addl %esi, %eax
166 movl %ebx, %esi
167 roll $10, %ecx
168 addl %edi, %eax
169 xorl %ecx, %esi
170 roll $8, %eax
171 addl %ebp, %eax
172 /* 6 */
173 movl 28(%esp), %edi
174 xorl %eax, %esi
175 addl %edi, %ebp
176 roll $10, %ebx
177 addl %esi, %ebp
178 movl %eax, %esi
179 roll $7, %ebp
180 addl %edx, %ebp
181 /* 7 */
182 xorl %ebx, %esi
183 movl 32(%esp), %edi
184 xorl %ebp, %esi
185 addl %esi, %edx
186 movl %ebp, %esi
187 roll $10, %eax
188 addl %edi, %edx
189 xorl %eax, %esi
190 roll $9, %edx
191 addl %ecx, %edx
192 /* 8 */
193 movl 36(%esp), %edi
194 xorl %edx, %esi
195 addl %edi, %ecx
196 roll $10, %ebp
197 addl %esi, %ecx
198 movl %edx, %esi
199 roll $11, %ecx
200 addl %ebx, %ecx
201 /* 9 */
202 xorl %ebp, %esi
203 movl 40(%esp), %edi
204 xorl %ecx, %esi
205 addl %esi, %ebx
206 movl %ecx, %esi
207 roll $10, %edx
208 addl %edi, %ebx
209 xorl %edx, %esi
210 roll $13, %ebx
211 addl %eax, %ebx
212 /* 10 */
213 movl 44(%esp), %edi
214 xorl %ebx, %esi
215 addl %edi, %eax
216 roll $10, %ecx
217 addl %esi, %eax
218 movl %ebx, %esi
219 roll $14, %eax
220 addl %ebp, %eax
221 /* 11 */
222 xorl %ecx, %esi
223 movl 48(%esp), %edi
224 xorl %eax, %esi
225 addl %esi, %ebp
226 movl %eax, %esi
227 roll $10, %ebx
228 addl %edi, %ebp
229 xorl %ebx, %esi
230 roll $15, %ebp
231 addl %edx, %ebp
232 /* 12 */
233 movl 52(%esp), %edi
234 xorl %ebp, %esi
235 addl %edi, %edx
236 roll $10, %eax
237 addl %esi, %edx
238 movl %ebp, %esi
239 roll $6, %edx
240 addl %ecx, %edx
241 /* 13 */
242 xorl %eax, %esi
243 movl 56(%esp), %edi
244 xorl %edx, %esi
245 addl %esi, %ecx
246 movl %edx, %esi
247 roll $10, %ebp
248 addl %edi, %ecx
249 xorl %ebp, %esi
250 roll $7, %ecx
251 addl %ebx, %ecx
252 /* 14 */
253 movl 60(%esp), %edi
254 xorl %ecx, %esi
255 addl %edi, %ebx
256 roll $10, %edx
257 addl %esi, %ebx
258 movl %ecx, %esi
259 roll $9, %ebx
260 addl %eax, %ebx
261 /* 15 */
262 xorl %edx, %esi
263 movl 64(%esp), %edi
264 xorl %ebx, %esi
265 addl %esi, %eax
266 movl $-1, %esi
267 roll $10, %ecx
268 addl %edi, %eax
269 movl 32(%esp), %edi
270 roll $8, %eax
271 addl %ebp, %eax
272 /* 16 */
273 addl %edi, %ebp
274 movl %ebx, %edi
275 subl %eax, %esi
276 andl %eax, %edi
277 andl %ecx, %esi
278 orl %esi, %edi
279 movl 20(%esp), %esi
280 roll $10, %ebx
281 leal 1518500249(%ebp,%edi,1),%ebp
282 movl $-1, %edi
283 roll $7, %ebp
284 addl %edx, %ebp
285 /* 17 */
286 addl %esi, %edx
287 movl %eax, %esi
288 subl %ebp, %edi
289 andl %ebp, %esi
290 andl %ebx, %edi
291 orl %edi, %esi
292 movl 56(%esp), %edi
293 roll $10, %eax
294 leal 1518500249(%edx,%esi,1),%edx
295 movl $-1, %esi
296 roll $6, %edx
297 addl %ecx, %edx
298 /* 18 */
299 addl %edi, %ecx
300 movl %ebp, %edi
301 subl %edx, %esi
302 andl %edx, %edi
303 andl %eax, %esi
304 orl %esi, %edi
305 movl 8(%esp), %esi
306 roll $10, %ebp
307 leal 1518500249(%ecx,%edi,1),%ecx
308 movl $-1, %edi
309 roll $8, %ecx
310 addl %ebx, %ecx
311 /* 19 */
312 addl %esi, %ebx
313 movl %edx, %esi
314 subl %ecx, %edi
315 andl %ecx, %esi
316 andl %ebp, %edi
317 orl %edi, %esi
318 movl 44(%esp), %edi
319 roll $10, %edx
320 leal 1518500249(%ebx,%esi,1),%ebx
321 movl $-1, %esi
322 roll $13, %ebx
323 addl %eax, %ebx
324 /* 20 */
325 addl %edi, %eax
326 movl %ecx, %edi
327 subl %ebx, %esi
328 andl %ebx, %edi
329 andl %edx, %esi
330 orl %esi, %edi
331 movl 28(%esp), %esi
332 roll $10, %ecx
333 leal 1518500249(%eax,%edi,1),%eax
334 movl $-1, %edi
335 roll $11, %eax
336 addl %ebp, %eax
337 /* 21 */
338 addl %esi, %ebp
339 movl %ebx, %esi
340 subl %eax, %edi
341 andl %eax, %esi
342 andl %ecx, %edi
343 orl %edi, %esi
344 movl 64(%esp), %edi
345 roll $10, %ebx
346 leal 1518500249(%ebp,%esi,1),%ebp
347 movl $-1, %esi
348 roll $9, %ebp
349 addl %edx, %ebp
350 /* 22 */
351 addl %edi, %edx
352 movl %eax, %edi
353 subl %ebp, %esi
354 andl %ebp, %edi
355 andl %ebx, %esi
356 orl %esi, %edi
357 movl 16(%esp), %esi
358 roll $10, %eax
359 leal 1518500249(%edx,%edi,1),%edx
360 movl $-1, %edi
361 roll $7, %edx
362 addl %ecx, %edx
363 /* 23 */
364 addl %esi, %ecx
365 movl %ebp, %esi
366 subl %edx, %edi
367 andl %edx, %esi
368 andl %eax, %edi
369 orl %edi, %esi
370 movl 52(%esp), %edi
371 roll $10, %ebp
372 leal 1518500249(%ecx,%esi,1),%ecx
373 movl $-1, %esi
374 roll $15, %ecx
375 addl %ebx, %ecx
376 /* 24 */
377 addl %edi, %ebx
378 movl %edx, %edi
379 subl %ecx, %esi
380 andl %ecx, %edi
381 andl %ebp, %esi
382 orl %esi, %edi
383 movl 4(%esp), %esi
384 roll $10, %edx
385 leal 1518500249(%ebx,%edi,1),%ebx
386 movl $-1, %edi
387 roll $7, %ebx
388 addl %eax, %ebx
389 /* 25 */
390 addl %esi, %eax
391 movl %ecx, %esi
392 subl %ebx, %edi
393 andl %ebx, %esi
394 andl %edx, %edi
395 orl %edi, %esi
396 movl 40(%esp), %edi
397 roll $10, %ecx
398 leal 1518500249(%eax,%esi,1),%eax
399 movl $-1, %esi
400 roll $12, %eax
401 addl %ebp, %eax
402 /* 26 */
403 addl %edi, %ebp
404 movl %ebx, %edi
405 subl %eax, %esi
406 andl %eax, %edi
407 andl %ecx, %esi
408 orl %esi, %edi
409 movl 24(%esp), %esi
410 roll $10, %ebx
411 leal 1518500249(%ebp,%edi,1),%ebp
412 movl $-1, %edi
413 roll $15, %ebp
414 addl %edx, %ebp
415 /* 27 */
416 addl %esi, %edx
417 movl %eax, %esi
418 subl %ebp, %edi
419 andl %ebp, %esi
420 andl %ebx, %edi
421 orl %edi, %esi
422 movl 12(%esp), %edi
423 roll $10, %eax
424 leal 1518500249(%edx,%esi,1),%edx
425 movl $-1, %esi
426 roll $9, %edx
427 addl %ecx, %edx
428 /* 28 */
429 addl %edi, %ecx
430 movl %ebp, %edi
431 subl %edx, %esi
432 andl %edx, %edi
433 andl %eax, %esi
434 orl %esi, %edi
435 movl 60(%esp), %esi
436 roll $10, %ebp
437 leal 1518500249(%ecx,%edi,1),%ecx
438 movl $-1, %edi
439 roll $11, %ecx
440 addl %ebx, %ecx
441 /* 29 */
442 addl %esi, %ebx
443 movl %edx, %esi
444 subl %ecx, %edi
445 andl %ecx, %esi
446 andl %ebp, %edi
447 orl %edi, %esi
448 movl 48(%esp), %edi
449 roll $10, %edx
450 leal 1518500249(%ebx,%esi,1),%ebx
451 movl $-1, %esi
452 roll $7, %ebx
453 addl %eax, %ebx
454 /* 30 */
455 addl %edi, %eax
456 movl %ecx, %edi
457 subl %ebx, %esi
458 andl %ebx, %edi
459 andl %edx, %esi
460 orl %esi, %edi
461 movl 36(%esp), %esi
462 roll $10, %ecx
463 leal 1518500249(%eax,%edi,1),%eax
464 movl $-1, %edi
465 roll $13, %eax
466 addl %ebp, %eax
467 /* 31 */
468 addl %esi, %ebp
469 movl %ebx, %esi
470 subl %eax, %edi
471 andl %eax, %esi
472 andl %ecx, %edi
473 orl %edi, %esi
474 movl $-1, %edi
475 roll $10, %ebx
476 leal 1518500249(%ebp,%esi,1),%ebp
477 subl %eax, %edi
478 roll $12, %ebp
479 addl %edx, %ebp
480 /* 32 */
481 movl 16(%esp), %esi
482 orl %ebp, %edi
483 addl %esi, %edx
484 xorl %ebx, %edi
485 movl $-1, %esi
486 roll $10, %eax
487 leal 1859775393(%edx,%edi,1),%edx
488 subl %ebp, %esi
489 roll $11, %edx
490 addl %ecx, %edx
491 /* 33 */
492 movl 44(%esp), %edi
493 orl %edx, %esi
494 addl %edi, %ecx
495 xorl %eax, %esi
496 movl $-1, %edi
497 roll $10, %ebp
498 leal 1859775393(%ecx,%esi,1),%ecx
499 subl %edx, %edi
500 roll $13, %ecx
501 addl %ebx, %ecx
502 /* 34 */
503 movl 60(%esp), %esi
504 orl %ecx, %edi
505 addl %esi, %ebx
506 xorl %ebp, %edi
507 movl $-1, %esi
508 roll $10, %edx
509 leal 1859775393(%ebx,%edi,1),%ebx
510 subl %ecx, %esi
511 roll $6, %ebx
512 addl %eax, %ebx
513 /* 35 */
514 movl 20(%esp), %edi
515 orl %ebx, %esi
516 addl %edi, %eax
517 xorl %edx, %esi
518 movl $-1, %edi
519 roll $10, %ecx
520 leal 1859775393(%eax,%esi,1),%eax
521 subl %ebx, %edi
522 roll $7, %eax
523 addl %ebp, %eax
524 /* 36 */
525 movl 40(%esp), %esi
526 orl %eax, %edi
527 addl %esi, %ebp
528 xorl %ecx, %edi
529 movl $-1, %esi
530 roll $10, %ebx
531 leal 1859775393(%ebp,%edi,1),%ebp
532 subl %eax, %esi
533 roll $14, %ebp
534 addl %edx, %ebp
535 /* 37 */
536 movl 64(%esp), %edi
537 orl %ebp, %esi
538 addl %edi, %edx
539 xorl %ebx, %esi
540 movl $-1, %edi
541 roll $10, %eax
542 leal 1859775393(%edx,%esi,1),%edx
543 subl %ebp, %edi
544 roll $9, %edx
545 addl %ecx, %edx
546 /* 38 */
547 movl 36(%esp), %esi
548 orl %edx, %edi
549 addl %esi, %ecx
550 xorl %eax, %edi
551 movl $-1, %esi
552 roll $10, %ebp
553 leal 1859775393(%ecx,%edi,1),%ecx
554 subl %edx, %esi
555 roll $13, %ecx
556 addl %ebx, %ecx
557 /* 39 */
558 movl 8(%esp), %edi
559 orl %ecx, %esi
560 addl %edi, %ebx
561 xorl %ebp, %esi
562 movl $-1, %edi
563 roll $10, %edx
564 leal 1859775393(%ebx,%esi,1),%ebx
565 subl %ecx, %edi
566 roll $15, %ebx
567 addl %eax, %ebx
568 /* 40 */
569 movl 12(%esp), %esi
570 orl %ebx, %edi
571 addl %esi, %eax
572 xorl %edx, %edi
573 movl $-1, %esi
574 roll $10, %ecx
575 leal 1859775393(%eax,%edi,1),%eax
576 subl %ebx, %esi
577 roll $14, %eax
578 addl %ebp, %eax
579 /* 41 */
580 movl 32(%esp), %edi
581 orl %eax, %esi
582 addl %edi, %ebp
583 xorl %ecx, %esi
584 movl $-1, %edi
585 roll $10, %ebx
586 leal 1859775393(%ebp,%esi,1),%ebp
587 subl %eax, %edi
588 roll $8, %ebp
589 addl %edx, %ebp
590 /* 42 */
591 movl 4(%esp), %esi
592 orl %ebp, %edi
593 addl %esi, %edx
594 xorl %ebx, %edi
595 movl $-1, %esi
596 roll $10, %eax
597 leal 1859775393(%edx,%edi,1),%edx
598 subl %ebp, %esi
599 roll $13, %edx
600 addl %ecx, %edx
601 /* 43 */
602 movl 28(%esp), %edi
603 orl %edx, %esi
604 addl %edi, %ecx
605 xorl %eax, %esi
606 movl $-1, %edi
607 roll $10, %ebp
608 leal 1859775393(%ecx,%esi,1),%ecx
609 subl %edx, %edi
610 roll $6, %ecx
611 addl %ebx, %ecx
612 /* 44 */
613 movl 56(%esp), %esi
614 orl %ecx, %edi
615 addl %esi, %ebx
616 xorl %ebp, %edi
617 movl $-1, %esi
618 roll $10, %edx
619 leal 1859775393(%ebx,%edi,1),%ebx
620 subl %ecx, %esi
621 roll $5, %ebx
622 addl %eax, %ebx
623 /* 45 */
624 movl 48(%esp), %edi
625 orl %ebx, %esi
626 addl %edi, %eax
627 xorl %edx, %esi
628 movl $-1, %edi
629 roll $10, %ecx
630 leal 1859775393(%eax,%esi,1),%eax
631 subl %ebx, %edi
632 roll $12, %eax
633 addl %ebp, %eax
634 /* 46 */
635 movl 24(%esp), %esi
636 orl %eax, %edi
637 addl %esi, %ebp
638 xorl %ecx, %edi
639 movl $-1, %esi
640 roll $10, %ebx
641 leal 1859775393(%ebp,%edi,1),%ebp
642 subl %eax, %esi
643 roll $7, %ebp
644 addl %edx, %ebp
645 /* 47 */
646 movl 52(%esp), %edi
647 orl %ebp, %esi
648 addl %edi, %edx
649 xorl %ebx, %esi
650 movl $-1, %edi
651 roll $10, %eax
652 leal 1859775393(%edx,%esi,1),%edx
653 movl %eax, %esi
654 roll $5, %edx
655 addl %ecx, %edx
656 /* 48 */
657 subl %eax, %edi
658 andl %edx, %esi
659 andl %ebp, %edi
660 orl %esi, %edi
661 movl 8(%esp), %esi
662 roll $10, %ebp
663 leal 2400959708(%ecx,%edi,),%ecx
664 movl $-1, %edi
665 addl %esi, %ecx
666 movl %ebp, %esi
667 roll $11, %ecx
668 addl %ebx, %ecx
669 /* 49 */
670 subl %ebp, %edi
671 andl %ecx, %esi
672 andl %edx, %edi
673 orl %esi, %edi
674 movl 40(%esp), %esi
675 roll $10, %edx
676 leal 2400959708(%ebx,%edi,),%ebx
677 movl $-1, %edi
678 addl %esi, %ebx
679 movl %edx, %esi
680 roll $12, %ebx
681 addl %eax, %ebx
682 /* 50 */
683 subl %edx, %edi
684 andl %ebx, %esi
685 andl %ecx, %edi
686 orl %esi, %edi
687 movl 48(%esp), %esi
688 roll $10, %ecx
689 leal 2400959708(%eax,%edi,),%eax
690 movl $-1, %edi
691 addl %esi, %eax
692 movl %ecx, %esi
693 roll $14, %eax
694 addl %ebp, %eax
695 /* 51 */
696 subl %ecx, %edi
697 andl %eax, %esi
698 andl %ebx, %edi
699 orl %esi, %edi
700 movl 44(%esp), %esi
701 roll $10, %ebx
702 leal 2400959708(%ebp,%edi,),%ebp
703 movl $-1, %edi
704 addl %esi, %ebp
705 movl %ebx, %esi
706 roll $15, %ebp
707 addl %edx, %ebp
708 /* 52 */
709 subl %ebx, %edi
710 andl %ebp, %esi
711 andl %eax, %edi
712 orl %esi, %edi
713 movl 4(%esp), %esi
714 roll $10, %eax
715 leal 2400959708(%edx,%edi,),%edx
716 movl $-1, %edi
717 addl %esi, %edx
718 movl %eax, %esi
719 roll $14, %edx
720 addl %ecx, %edx
721 /* 53 */
722 subl %eax, %edi
723 andl %edx, %esi
724 andl %ebp, %edi
725 orl %esi, %edi
726 movl 36(%esp), %esi
727 roll $10, %ebp
728 leal 2400959708(%ecx,%edi,),%ecx
729 movl $-1, %edi
730 addl %esi, %ecx
731 movl %ebp, %esi
732 roll $15, %ecx
733 addl %ebx, %ecx
734 /* 54 */
735 subl %ebp, %edi
736 andl %ecx, %esi
737 andl %edx, %edi
738 orl %esi, %edi
739 movl 52(%esp), %esi
740 roll $10, %edx
741 leal 2400959708(%ebx,%edi,),%ebx
742 movl $-1, %edi
743 addl %esi, %ebx
744 movl %edx, %esi
745 roll $9, %ebx
746 addl %eax, %ebx
747 /* 55 */
748 subl %edx, %edi
749 andl %ebx, %esi
750 andl %ecx, %edi
751 orl %esi, %edi
752 movl 20(%esp), %esi
753 roll $10, %ecx
754 leal 2400959708(%eax,%edi,),%eax
755 movl $-1, %edi
756 addl %esi, %eax
757 movl %ecx, %esi
758 roll $8, %eax
759 addl %ebp, %eax
760 /* 56 */
761 subl %ecx, %edi
762 andl %eax, %esi
763 andl %ebx, %edi
764 orl %esi, %edi
765 movl 56(%esp), %esi
766 roll $10, %ebx
767 leal 2400959708(%ebp,%edi,),%ebp
768 movl $-1, %edi
769 addl %esi, %ebp
770 movl %ebx, %esi
771 roll $9, %ebp
772 addl %edx, %ebp
773 /* 57 */
774 subl %ebx, %edi
775 andl %ebp, %esi
776 andl %eax, %edi
777 orl %esi, %edi
778 movl 16(%esp), %esi
779 roll $10, %eax
780 leal 2400959708(%edx,%edi,),%edx
781 movl $-1, %edi
782 addl %esi, %edx
783 movl %eax, %esi
784 roll $14, %edx
785 addl %ecx, %edx
786 /* 58 */
787 subl %eax, %edi
788 andl %edx, %esi
789 andl %ebp, %edi
790 orl %esi, %edi
791 movl 32(%esp), %esi
792 roll $10, %ebp
793 leal 2400959708(%ecx,%edi,),%ecx
794 movl $-1, %edi
795 addl %esi, %ecx
796 movl %ebp, %esi
797 roll $5, %ecx
798 addl %ebx, %ecx
799 /* 59 */
800 subl %ebp, %edi
801 andl %ecx, %esi
802 andl %edx, %edi
803 orl %esi, %edi
804 movl 64(%esp), %esi
805 roll $10, %edx
806 leal 2400959708(%ebx,%edi,),%ebx
807 movl $-1, %edi
808 addl %esi, %ebx
809 movl %edx, %esi
810 roll $6, %ebx
811 addl %eax, %ebx
812 /* 60 */
813 subl %edx, %edi
814 andl %ebx, %esi
815 andl %ecx, %edi
816 orl %esi, %edi
817 movl 60(%esp), %esi
818 roll $10, %ecx
819 leal 2400959708(%eax,%edi,),%eax
820 movl $-1, %edi
821 addl %esi, %eax
822 movl %ecx, %esi
823 roll $8, %eax
824 addl %ebp, %eax
825 /* 61 */
826 subl %ecx, %edi
827 andl %eax, %esi
828 andl %ebx, %edi
829 orl %esi, %edi
830 movl 24(%esp), %esi
831 roll $10, %ebx
832 leal 2400959708(%ebp,%edi,),%ebp
833 movl $-1, %edi
834 addl %esi, %ebp
835 movl %ebx, %esi
836 roll $6, %ebp
837 addl %edx, %ebp
838 /* 62 */
839 subl %ebx, %edi
840 andl %ebp, %esi
841 andl %eax, %edi
842 orl %esi, %edi
843 movl 28(%esp), %esi
844 roll $10, %eax
845 leal 2400959708(%edx,%edi,),%edx
846 movl $-1, %edi
847 addl %esi, %edx
848 movl %eax, %esi
849 roll $5, %edx
850 addl %ecx, %edx
851 /* 63 */
852 subl %eax, %edi
853 andl %edx, %esi
854 andl %ebp, %edi
855 orl %esi, %edi
856 movl 12(%esp), %esi
857 roll $10, %ebp
858 leal 2400959708(%ecx,%edi,),%ecx
859 movl $-1, %edi
860 addl %esi, %ecx
861 subl %ebp, %edi
862 roll $12, %ecx
863 addl %ebx, %ecx
864 /* 64 */
865 movl 20(%esp), %esi
866 orl %edx, %edi
867 addl %esi, %ebx
868 xorl %ecx, %edi
869 movl $-1, %esi
870 roll $10, %edx
871 leal 2840853838(%ebx,%edi,1),%ebx
872 subl %edx, %esi
873 roll $9, %ebx
874 addl %eax, %ebx
875 /* 65 */
876 movl 4(%esp), %edi
877 orl %ecx, %esi
878 addl %edi, %eax
879 xorl %ebx, %esi
880 movl $-1, %edi
881 roll $10, %ecx
882 leal 2840853838(%eax,%esi,1),%eax
883 subl %ecx, %edi
884 roll $15, %eax
885 addl %ebp, %eax
886 /* 66 */
887 movl 24(%esp), %esi
888 orl %ebx, %edi
889 addl %esi, %ebp
890 xorl %eax, %edi
891 movl $-1, %esi
892 roll $10, %ebx
893 leal 2840853838(%ebp,%edi,1),%ebp
894 subl %ebx, %esi
895 roll $5, %ebp
896 addl %edx, %ebp
897 /* 67 */
898 movl 40(%esp), %edi
899 orl %eax, %esi
900 addl %edi, %edx
901 xorl %ebp, %esi
902 movl $-1, %edi
903 roll $10, %eax
904 leal 2840853838(%edx,%esi,1),%edx
905 subl %eax, %edi
906 roll $11, %edx
907 addl %ecx, %edx
908 /* 68 */
909 movl 32(%esp), %esi
910 orl %ebp, %edi
911 addl %esi, %ecx
912 xorl %edx, %edi
913 movl $-1, %esi
914 roll $10, %ebp
915 leal 2840853838(%ecx,%edi,1),%ecx
916 subl %ebp, %esi
917 roll $6, %ecx
918 addl %ebx, %ecx
919 /* 69 */
920 movl 52(%esp), %edi
921 orl %edx, %esi
922 addl %edi, %ebx
923 xorl %ecx, %esi
924 movl $-1, %edi
925 roll $10, %edx
926 leal 2840853838(%ebx,%esi,1),%ebx
927 subl %edx, %edi
928 roll $8, %ebx
929 addl %eax, %ebx
930 /* 70 */
931 movl 12(%esp), %esi
932 orl %ecx, %edi
933 addl %esi, %eax
934 xorl %ebx, %edi
935 movl $-1, %esi
936 roll $10, %ecx
937 leal 2840853838(%eax,%edi,1),%eax
938 subl %ecx, %esi
939 roll $13, %eax
940 addl %ebp, %eax
941 /* 71 */
942 movl 44(%esp), %edi
943 orl %ebx, %esi
944 addl %edi, %ebp
945 xorl %eax, %esi
946 movl $-1, %edi
947 roll $10, %ebx
948 leal 2840853838(%ebp,%esi,1),%ebp
949 subl %ebx, %edi
950 roll $12, %ebp
951 addl %edx, %ebp
952 /* 72 */
953 movl 60(%esp), %esi
954 orl %eax, %edi
955 addl %esi, %edx
956 xorl %ebp, %edi
957 movl $-1, %esi
958 roll $10, %eax
959 leal 2840853838(%edx,%edi,1),%edx
960 subl %eax, %esi
961 roll $5, %edx
962 addl %ecx, %edx
963 /* 73 */
964 movl 8(%esp), %edi
965 orl %ebp, %esi
966 addl %edi, %ecx
967 xorl %edx, %esi
968 movl $-1, %edi
969 roll $10, %ebp
970 leal 2840853838(%ecx,%esi,1),%ecx
971 subl %ebp, %edi
972 roll $12, %ecx
973 addl %ebx, %ecx
974 /* 74 */
975 movl 16(%esp), %esi
976 orl %edx, %edi
977 addl %esi, %ebx
978 xorl %ecx, %edi
979 movl $-1, %esi
980 roll $10, %edx
981 leal 2840853838(%ebx,%edi,1),%ebx
982 subl %edx, %esi
983 roll $13, %ebx
984 addl %eax, %ebx
985 /* 75 */
986 movl 36(%esp), %edi
987 orl %ecx, %esi
988 addl %edi, %eax
989 xorl %ebx, %esi
990 movl $-1, %edi
991 roll $10, %ecx
992 leal 2840853838(%eax,%esi,1),%eax
993 subl %ecx, %edi
994 roll $14, %eax
995 addl %ebp, %eax
996 /* 76 */
997 movl 48(%esp), %esi
998 orl %ebx, %edi
999 addl %esi, %ebp
1000 xorl %eax, %edi
1001 movl $-1, %esi
1002 roll $10, %ebx
1003 leal 2840853838(%ebp,%edi,1),%ebp
1004 subl %ebx, %esi
1005 roll $11, %ebp
1006 addl %edx, %ebp
1007 /* 77 */
1008 movl 28(%esp), %edi
1009 orl %eax, %esi
1010 addl %edi, %edx
1011 xorl %ebp, %esi
1012 movl $-1, %edi
1013 roll $10, %eax
1014 leal 2840853838(%edx,%esi,1),%edx
1015 subl %eax, %edi
1016 roll $8, %edx
1017 addl %ecx, %edx
1018 /* 78 */
1019 movl 64(%esp), %esi
1020 orl %ebp, %edi
1021 addl %esi, %ecx
1022 xorl %edx, %edi
1023 movl $-1, %esi
1024 roll $10, %ebp
1025 leal 2840853838(%ecx,%edi,1),%ecx
1026 subl %ebp, %esi
1027 roll $5, %ecx
1028 addl %ebx, %ecx
1029 /* 79 */
1030 movl 56(%esp), %edi
1031 orl %edx, %esi
1032 addl %edi, %ebx
1033 xorl %ecx, %esi
1034 movl 108(%esp), %edi
1035 roll $10, %edx
1036 leal 2840853838(%ebx,%esi,1),%ebx
1037 movl %eax, 68(%esp)
1038 roll $6, %ebx
1039 addl %eax, %ebx
1040 movl (%edi), %eax
1041 movl %ebx, 72(%esp)
1042 movl %ecx, 76(%esp)
1043 movl 4(%edi), %ebx
1044 movl %edx, 80(%esp)
1045 movl 8(%edi), %ecx
1046 movl %ebp, 84(%esp)
1047 movl 12(%edi), %edx
1048 movl 16(%edi), %ebp
1049 /* 80 */
1050 movl $-1, %edi
1051 subl %edx, %edi
1052 movl 24(%esp), %esi
1053 orl %ecx, %edi
1054 addl %esi, %eax
1055 xorl %ebx, %edi
1056 movl $-1, %esi
1057 roll $10, %ecx
1058 leal 1352829926(%eax,%edi,1),%eax
1059 subl %ecx, %esi
1060 roll $8, %eax
1061 addl %ebp, %eax
1062 /* 81 */
1063 movl 60(%esp), %edi
1064 orl %ebx, %esi
1065 addl %edi, %ebp
1066 xorl %eax, %esi
1067 movl $-1, %edi
1068 roll $10, %ebx
1069 leal 1352829926(%ebp,%esi,1),%ebp
1070 subl %ebx, %edi
1071 roll $9, %ebp
1072 addl %edx, %ebp
1073 /* 82 */
1074 movl 32(%esp), %esi
1075 orl %eax, %edi
1076 addl %esi, %edx
1077 xorl %ebp, %edi
1078 movl $-1, %esi
1079 roll $10, %eax
1080 leal 1352829926(%edx,%edi,1),%edx
1081 subl %eax, %esi
1082 roll $9, %edx
1083 addl %ecx, %edx
1084 /* 83 */
1085 movl 4(%esp), %edi
1086 orl %ebp, %esi
1087 addl %edi, %ecx
1088 xorl %edx, %esi
1089 movl $-1, %edi
1090 roll $10, %ebp
1091 leal 1352829926(%ecx,%esi,1),%ecx
1092 subl %ebp, %edi
1093 roll $11, %ecx
1094 addl %ebx, %ecx
1095 /* 84 */
1096 movl 40(%esp), %esi
1097 orl %edx, %edi
1098 addl %esi, %ebx
1099 xorl %ecx, %edi
1100 movl $-1, %esi
1101 roll $10, %edx
1102 leal 1352829926(%ebx,%edi,1),%ebx
1103 subl %edx, %esi
1104 roll $13, %ebx
1105 addl %eax, %ebx
1106 /* 85 */
1107 movl 12(%esp), %edi
1108 orl %ecx, %esi
1109 addl %edi, %eax
1110 xorl %ebx, %esi
1111 movl $-1, %edi
1112 roll $10, %ecx
1113 leal 1352829926(%eax,%esi,1),%eax
1114 subl %ecx, %edi
1115 roll $15, %eax
1116 addl %ebp, %eax
1117 /* 86 */
1118 movl 48(%esp), %esi
1119 orl %ebx, %edi
1120 addl %esi, %ebp
1121 xorl %eax, %edi
1122 movl $-1, %esi
1123 roll $10, %ebx
1124 leal 1352829926(%ebp,%edi,1),%ebp
1125 subl %ebx, %esi
1126 roll $15, %ebp
1127 addl %edx, %ebp
1128 /* 87 */
1129 movl 20(%esp), %edi
1130 orl %eax, %esi
1131 addl %edi, %edx
1132 xorl %ebp, %esi
1133 movl $-1, %edi
1134 roll $10, %eax
1135 leal 1352829926(%edx,%esi,1),%edx
1136 subl %eax, %edi
1137 roll $5, %edx
1138 addl %ecx, %edx
1139 /* 88 */
1140 movl 56(%esp), %esi
1141 orl %ebp, %edi
1142 addl %esi, %ecx
1143 xorl %edx, %edi
1144 movl $-1, %esi
1145 roll $10, %ebp
1146 leal 1352829926(%ecx,%edi,1),%ecx
1147 subl %ebp, %esi
1148 roll $7, %ecx
1149 addl %ebx, %ecx
1150 /* 89 */
1151 movl 28(%esp), %edi
1152 orl %edx, %esi
1153 addl %edi, %ebx
1154 xorl %ecx, %esi
1155 movl $-1, %edi
1156 roll $10, %edx
1157 leal 1352829926(%ebx,%esi,1),%ebx
1158 subl %edx, %edi
1159 roll $7, %ebx
1160 addl %eax, %ebx
1161 /* 90 */
1162 movl 64(%esp), %esi
1163 orl %ecx, %edi
1164 addl %esi, %eax
1165 xorl %ebx, %edi
1166 movl $-1, %esi
1167 roll $10, %ecx
1168 leal 1352829926(%eax,%edi,1),%eax
1169 subl %ecx, %esi
1170 roll $8, %eax
1171 addl %ebp, %eax
1172 /* 91 */
1173 movl 36(%esp), %edi
1174 orl %ebx, %esi
1175 addl %edi, %ebp
1176 xorl %eax, %esi
1177 movl $-1, %edi
1178 roll $10, %ebx
1179 leal 1352829926(%ebp,%esi,1),%ebp
1180 subl %ebx, %edi
1181 roll $11, %ebp
1182 addl %edx, %ebp
1183 /* 92 */
1184 movl 8(%esp), %esi
1185 orl %eax, %edi
1186 addl %esi, %edx
1187 xorl %ebp, %edi
1188 movl $-1, %esi
1189 roll $10, %eax
1190 leal 1352829926(%edx,%edi,1),%edx
1191 subl %eax, %esi
1192 roll $14, %edx
1193 addl %ecx, %edx
1194 /* 93 */
1195 movl 44(%esp), %edi
1196 orl %ebp, %esi
1197 addl %edi, %ecx
1198 xorl %edx, %esi
1199 movl $-1, %edi
1200 roll $10, %ebp
1201 leal 1352829926(%ecx,%esi,1),%ecx
1202 subl %ebp, %edi
1203 roll $14, %ecx
1204 addl %ebx, %ecx
1205 /* 94 */
1206 movl 16(%esp), %esi
1207 orl %edx, %edi
1208 addl %esi, %ebx
1209 xorl %ecx, %edi
1210 movl $-1, %esi
1211 roll $10, %edx
1212 leal 1352829926(%ebx,%edi,1),%ebx
1213 subl %edx, %esi
1214 roll $12, %ebx
1215 addl %eax, %ebx
1216 /* 95 */
1217 movl 52(%esp), %edi
1218 orl %ecx, %esi
1219 addl %edi, %eax
1220 xorl %ebx, %esi
1221 movl $-1, %edi
1222 roll $10, %ecx
1223 leal 1352829926(%eax,%esi,1),%eax
1224 movl %ecx, %esi
1225 roll $6, %eax
1226 addl %ebp, %eax
1227 /* 96 */
1228 subl %ecx, %edi
1229 andl %eax, %esi
1230 andl %ebx, %edi
1231 orl %esi, %edi
1232 movl 28(%esp), %esi
1233 roll $10, %ebx
1234 leal 1548603684(%ebp,%edi,),%ebp
1235 movl $-1, %edi
1236 addl %esi, %ebp
1237 movl %ebx, %esi
1238 roll $9, %ebp
1239 addl %edx, %ebp
1240 /* 97 */
1241 subl %ebx, %edi
1242 andl %ebp, %esi
1243 andl %eax, %edi
1244 orl %esi, %edi
1245 movl 48(%esp), %esi
1246 roll $10, %eax
1247 leal 1548603684(%edx,%edi,),%edx
1248 movl $-1, %edi
1249 addl %esi, %edx
1250 movl %eax, %esi
1251 roll $13, %edx
1252 addl %ecx, %edx
1253 /* 98 */
1254 subl %eax, %edi
1255 andl %edx, %esi
1256 andl %ebp, %edi
1257 orl %esi, %edi
1258 movl 16(%esp), %esi
1259 roll $10, %ebp
1260 leal 1548603684(%ecx,%edi,),%ecx
1261 movl $-1, %edi
1262 addl %esi, %ecx
1263 movl %ebp, %esi
1264 roll $15, %ecx
1265 addl %ebx, %ecx
1266 /* 99 */
1267 subl %ebp, %edi
1268 andl %ecx, %esi
1269 andl %edx, %edi
1270 orl %esi, %edi
1271 movl 32(%esp), %esi
1272 roll $10, %edx
1273 leal 1548603684(%ebx,%edi,),%ebx
1274 movl $-1, %edi
1275 addl %esi, %ebx
1276 movl %edx, %esi
1277 roll $7, %ebx
1278 addl %eax, %ebx
1279 /* 100 */
1280 subl %edx, %edi
1281 andl %ebx, %esi
1282 andl %ecx, %edi
1283 orl %esi, %edi
1284 movl 4(%esp), %esi
1285 roll $10, %ecx
1286 leal 1548603684(%eax,%edi,),%eax
1287 movl $-1, %edi
1288 addl %esi, %eax
1289 movl %ecx, %esi
1290 roll $12, %eax
1291 addl %ebp, %eax
1292 /* 101 */
1293 subl %ecx, %edi
1294 andl %eax, %esi
1295 andl %ebx, %edi
1296 orl %esi, %edi
1297 movl 56(%esp), %esi
1298 roll $10, %ebx
1299 leal 1548603684(%ebp,%edi,),%ebp
1300 movl $-1, %edi
1301 addl %esi, %ebp
1302 movl %ebx, %esi
1303 roll $8, %ebp
1304 addl %edx, %ebp
1305 /* 102 */
1306 subl %ebx, %edi
1307 andl %ebp, %esi
1308 andl %eax, %edi
1309 orl %esi, %edi
1310 movl 24(%esp), %esi
1311 roll $10, %eax
1312 leal 1548603684(%edx,%edi,),%edx
1313 movl $-1, %edi
1314 addl %esi, %edx
1315 movl %eax, %esi
1316 roll $9, %edx
1317 addl %ecx, %edx
1318 /* 103 */
1319 subl %eax, %edi
1320 andl %edx, %esi
1321 andl %ebp, %edi
1322 orl %esi, %edi
1323 movl 44(%esp), %esi
1324 roll $10, %ebp
1325 leal 1548603684(%ecx,%edi,),%ecx
1326 movl $-1, %edi
1327 addl %esi, %ecx
1328 movl %ebp, %esi
1329 roll $11, %ecx
1330 addl %ebx, %ecx
1331 /* 104 */
1332 subl %ebp, %edi
1333 andl %ecx, %esi
1334 andl %edx, %edi
1335 orl %esi, %edi
1336 movl 60(%esp), %esi
1337 roll $10, %edx
1338 leal 1548603684(%ebx,%edi,),%ebx
1339 movl $-1, %edi
1340 addl %esi, %ebx
1341 movl %edx, %esi
1342 roll $7, %ebx
1343 addl %eax, %ebx
1344 /* 105 */
1345 subl %edx, %edi
1346 andl %ebx, %esi
1347 andl %ecx, %edi
1348 orl %esi, %edi
1349 movl 64(%esp), %esi
1350 roll $10, %ecx
1351 leal 1548603684(%eax,%edi,),%eax
1352 movl $-1, %edi
1353 addl %esi, %eax
1354 movl %ecx, %esi
1355 roll $7, %eax
1356 addl %ebp, %eax
1357 /* 106 */
1358 subl %ecx, %edi
1359 andl %eax, %esi
1360 andl %ebx, %edi
1361 orl %esi, %edi
1362 movl 36(%esp), %esi
1363 roll $10, %ebx
1364 leal 1548603684(%ebp,%edi,),%ebp
1365 movl $-1, %edi
1366 addl %esi, %ebp
1367 movl %ebx, %esi
1368 roll $12, %ebp
1369 addl %edx, %ebp
1370 /* 107 */
1371 subl %ebx, %edi
1372 andl %ebp, %esi
1373 andl %eax, %edi
1374 orl %esi, %edi
1375 movl 52(%esp), %esi
1376 roll $10, %eax
1377 leal 1548603684(%edx,%edi,),%edx
1378 movl $-1, %edi
1379 addl %esi, %edx
1380 movl %eax, %esi
1381 roll $7, %edx
1382 addl %ecx, %edx
1383 /* 108 */
1384 subl %eax, %edi
1385 andl %edx, %esi
1386 andl %ebp, %edi
1387 orl %esi, %edi
1388 movl 20(%esp), %esi
1389 roll $10, %ebp
1390 leal 1548603684(%ecx,%edi,),%ecx
1391 movl $-1, %edi
1392 addl %esi, %ecx
1393 movl %ebp, %esi
1394 roll $6, %ecx
1395 addl %ebx, %ecx
1396 /* 109 */
1397 subl %ebp, %edi
1398 andl %ecx, %esi
1399 andl %edx, %edi
1400 orl %esi, %edi
1401 movl 40(%esp), %esi
1402 roll $10, %edx
1403 leal 1548603684(%ebx,%edi,),%ebx
1404 movl $-1, %edi
1405 addl %esi, %ebx
1406 movl %edx, %esi
1407 roll $15, %ebx
1408 addl %eax, %ebx
1409 /* 110 */
1410 subl %edx, %edi
1411 andl %ebx, %esi
1412 andl %ecx, %edi
1413 orl %esi, %edi
1414 movl 8(%esp), %esi
1415 roll $10, %ecx
1416 leal 1548603684(%eax,%edi,),%eax
1417 movl $-1, %edi
1418 addl %esi, %eax
1419 movl %ecx, %esi
1420 roll $13, %eax
1421 addl %ebp, %eax
1422 /* 111 */
1423 subl %ecx, %edi
1424 andl %eax, %esi
1425 andl %ebx, %edi
1426 orl %esi, %edi
1427 movl 12(%esp), %esi
1428 roll $10, %ebx
1429 leal 1548603684(%ebp,%edi,),%ebp
1430 movl $-1, %edi
1431 addl %esi, %ebp
1432 subl %eax, %edi
1433 roll $11, %ebp
1434 addl %edx, %ebp
1435 /* 112 */
1436 movl 64(%esp), %esi
1437 orl %ebp, %edi
1438 addl %esi, %edx
1439 xorl %ebx, %edi
1440 movl $-1, %esi
1441 roll $10, %eax
1442 leal 1836072691(%edx,%edi,1),%edx
1443 subl %ebp, %esi
1444 roll $9, %edx
1445 addl %ecx, %edx
1446 /* 113 */
1447 movl 24(%esp), %edi
1448 orl %edx, %esi
1449 addl %edi, %ecx
1450 xorl %eax, %esi
1451 movl $-1, %edi
1452 roll $10, %ebp
1453 leal 1836072691(%ecx,%esi,1),%ecx
1454 subl %edx, %edi
1455 roll $7, %ecx
1456 addl %ebx, %ecx
1457 /* 114 */
1458 movl 8(%esp), %esi
1459 orl %ecx, %edi
1460 addl %esi, %ebx
1461 xorl %ebp, %edi
1462 movl $-1, %esi
1463 roll $10, %edx
1464 leal 1836072691(%ebx,%edi,1),%ebx
1465 subl %ecx, %esi
1466 roll $15, %ebx
1467 addl %eax, %ebx
1468 /* 115 */
1469 movl 16(%esp), %edi
1470 orl %ebx, %esi
1471 addl %edi, %eax
1472 xorl %edx, %esi
1473 movl $-1, %edi
1474 roll $10, %ecx
1475 leal 1836072691(%eax,%esi,1),%eax
1476 subl %ebx, %edi
1477 roll $11, %eax
1478 addl %ebp, %eax
1479 /* 116 */
1480 movl 32(%esp), %esi
1481 orl %eax, %edi
1482 addl %esi, %ebp
1483 xorl %ecx, %edi
1484 movl $-1, %esi
1485 roll $10, %ebx
1486 leal 1836072691(%ebp,%edi,1),%ebp
1487 subl %eax, %esi
1488 roll $8, %ebp
1489 addl %edx, %ebp
1490 /* 117 */
1491 movl 60(%esp), %edi
1492 orl %ebp, %esi
1493 addl %edi, %edx
1494 xorl %ebx, %esi
1495 movl $-1, %edi
1496 roll $10, %eax
1497 leal 1836072691(%edx,%esi,1),%edx
1498 subl %ebp, %edi
1499 roll $6, %edx
1500 addl %ecx, %edx
1501 /* 118 */
1502 movl 28(%esp), %esi
1503 orl %edx, %edi
1504 addl %esi, %ecx
1505 xorl %eax, %edi
1506 movl $-1, %esi
1507 roll $10, %ebp
1508 leal 1836072691(%ecx,%edi,1),%ecx
1509 subl %edx, %esi
1510 roll $6, %ecx
1511 addl %ebx, %ecx
1512 /* 119 */
1513 movl 40(%esp), %edi
1514 orl %ecx, %esi
1515 addl %edi, %ebx
1516 xorl %ebp, %esi
1517 movl $-1, %edi
1518 roll $10, %edx
1519 leal 1836072691(%ebx,%esi,1),%ebx
1520 subl %ecx, %edi
1521 roll $14, %ebx
1522 addl %eax, %ebx
1523 /* 120 */
1524 movl 48(%esp), %esi
1525 orl %ebx, %edi
1526 addl %esi, %eax
1527 xorl %edx, %edi
1528 movl $-1, %esi
1529 roll $10, %ecx
1530 leal 1836072691(%eax,%edi,1),%eax
1531 subl %ebx, %esi
1532 roll $12, %eax
1533 addl %ebp, %eax
1534 /* 121 */
1535 movl 36(%esp), %edi
1536 orl %eax, %esi
1537 addl %edi, %ebp
1538 xorl %ecx, %esi
1539 movl $-1, %edi
1540 roll $10, %ebx
1541 leal 1836072691(%ebp,%esi,1),%ebp
1542 subl %eax, %edi
1543 roll $13, %ebp
1544 addl %edx, %ebp
1545 /* 122 */
1546 movl 52(%esp), %esi
1547 orl %ebp, %edi
1548 addl %esi, %edx
1549 xorl %ebx, %edi
1550 movl $-1, %esi
1551 roll $10, %eax
1552 leal 1836072691(%edx,%edi,1),%edx
1553 subl %ebp, %esi
1554 roll $5, %edx
1555 addl %ecx, %edx
1556 /* 123 */
1557 movl 12(%esp), %edi
1558 orl %edx, %esi
1559 addl %edi, %ecx
1560 xorl %eax, %esi
1561 movl $-1, %edi
1562 roll $10, %ebp
1563 leal 1836072691(%ecx,%esi,1),%ecx
1564 subl %edx, %edi
1565 roll $14, %ecx
1566 addl %ebx, %ecx
1567 /* 124 */
1568 movl 44(%esp), %esi
1569 orl %ecx, %edi
1570 addl %esi, %ebx
1571 xorl %ebp, %edi
1572 movl $-1, %esi
1573 roll $10, %edx
1574 leal 1836072691(%ebx,%edi,1),%ebx
1575 subl %ecx, %esi
1576 roll $13, %ebx
1577 addl %eax, %ebx
1578 /* 125 */
1579 movl 4(%esp), %edi
1580 orl %ebx, %esi
1581 addl %edi, %eax
1582 xorl %edx, %esi
1583 movl $-1, %edi
1584 roll $10, %ecx
1585 leal 1836072691(%eax,%esi,1),%eax
1586 subl %ebx, %edi
1587 roll $13, %eax
1588 addl %ebp, %eax
1589 /* 126 */
1590 movl 20(%esp), %esi
1591 orl %eax, %edi
1592 addl %esi, %ebp
1593 xorl %ecx, %edi
1594 movl $-1, %esi
1595 roll $10, %ebx
1596 leal 1836072691(%ebp,%edi,1),%ebp
1597 subl %eax, %esi
1598 roll $7, %ebp
1599 addl %edx, %ebp
1600 /* 127 */
1601 movl 56(%esp), %edi
1602 orl %ebp, %esi
1603 addl %edi, %edx
1604 xorl %ebx, %esi
1605 movl 36(%esp), %edi
1606 roll $10, %eax
1607 leal 1836072691(%edx,%esi,1),%edx
1608 movl $-1, %esi
1609 roll $5, %edx
1610 addl %ecx, %edx
1611 /* 128 */
1612 addl %edi, %ecx
1613 movl %ebp, %edi
1614 subl %edx, %esi
1615 andl %edx, %edi
1616 andl %eax, %esi
1617 orl %esi, %edi
1618 movl 28(%esp), %esi
1619 roll $10, %ebp
1620 leal 2053994217(%ecx,%edi,1),%ecx
1621 movl $-1, %edi
1622 roll $15, %ecx
1623 addl %ebx, %ecx
1624 /* 129 */
1625 addl %esi, %ebx
1626 movl %edx, %esi
1627 subl %ecx, %edi
1628 andl %ecx, %esi
1629 andl %ebp, %edi
1630 orl %edi, %esi
1631 movl 20(%esp), %edi
1632 roll $10, %edx
1633 leal 2053994217(%ebx,%esi,1),%ebx
1634 movl $-1, %esi
1635 roll $5, %ebx
1636 addl %eax, %ebx
1637 /* 130 */
1638 addl %edi, %eax
1639 movl %ecx, %edi
1640 subl %ebx, %esi
1641 andl %ebx, %edi
1642 andl %edx, %esi
1643 orl %esi, %edi
1644 movl 8(%esp), %esi
1645 roll $10, %ecx
1646 leal 2053994217(%eax,%edi,1),%eax
1647 movl $-1, %edi
1648 roll $8, %eax
1649 addl %ebp, %eax
1650 /* 131 */
1651 addl %esi, %ebp
1652 movl %ebx, %esi
1653 subl %eax, %edi
1654 andl %eax, %esi
1655 andl %ecx, %edi
1656 orl %edi, %esi
1657 movl 16(%esp), %edi
1658 roll $10, %ebx
1659 leal 2053994217(%ebp,%esi,1),%ebp
1660 movl $-1, %esi
1661 roll $11, %ebp
1662 addl %edx, %ebp
1663 /* 132 */
1664 addl %edi, %edx
1665 movl %eax, %edi
1666 subl %ebp, %esi
1667 andl %ebp, %edi
1668 andl %ebx, %esi
1669 orl %esi, %edi
1670 movl 48(%esp), %esi
1671 roll $10, %eax
1672 leal 2053994217(%edx,%edi,1),%edx
1673 movl $-1, %edi
1674 roll $14, %edx
1675 addl %ecx, %edx
1676 /* 133 */
1677 addl %esi, %ecx
1678 movl %ebp, %esi
1679 subl %edx, %edi
1680 andl %edx, %esi
1681 andl %eax, %edi
1682 orl %edi, %esi
1683 movl 64(%esp), %edi
1684 roll $10, %ebp
1685 leal 2053994217(%ecx,%esi,1),%ecx
1686 movl $-1, %esi
1687 roll $14, %ecx
1688 addl %ebx, %ecx
1689 /* 134 */
1690 addl %edi, %ebx
1691 movl %edx, %edi
1692 subl %ecx, %esi
1693 andl %ecx, %edi
1694 andl %ebp, %esi
1695 orl %esi, %edi
1696 movl 4(%esp), %esi
1697 roll $10, %edx
1698 leal 2053994217(%ebx,%edi,1),%ebx
1699 movl $-1, %edi
1700 roll $6, %ebx
1701 addl %eax, %ebx
1702 /* 135 */
1703 addl %esi, %eax
1704 movl %ecx, %esi
1705 subl %ebx, %edi
1706 andl %ebx, %esi
1707 andl %edx, %edi
1708 orl %edi, %esi
1709 movl 24(%esp), %edi
1710 roll $10, %ecx
1711 leal 2053994217(%eax,%esi,1),%eax
1712 movl $-1, %esi
1713 roll $14, %eax
1714 addl %ebp, %eax
1715 /* 136 */
1716 addl %edi, %ebp
1717 movl %ebx, %edi
1718 subl %eax, %esi
1719 andl %eax, %edi
1720 andl %ecx, %esi
1721 orl %esi, %edi
1722 movl 52(%esp), %esi
1723 roll $10, %ebx
1724 leal 2053994217(%ebp,%edi,1),%ebp
1725 movl $-1, %edi
1726 roll $6, %ebp
1727 addl %edx, %ebp
1728 /* 137 */
1729 addl %esi, %edx
1730 movl %eax, %esi
1731 subl %ebp, %edi
1732 andl %ebp, %esi
1733 andl %ebx, %edi
1734 orl %edi, %esi
1735 movl 12(%esp), %edi
1736 roll $10, %eax
1737 leal 2053994217(%edx,%esi,1),%edx
1738 movl $-1, %esi
1739 roll $9, %edx
1740 addl %ecx, %edx
1741 /* 138 */
1742 addl %edi, %ecx
1743 movl %ebp, %edi
1744 subl %edx, %esi
1745 andl %edx, %edi
1746 andl %eax, %esi
1747 orl %esi, %edi
1748 movl 56(%esp), %esi
1749 roll $10, %ebp
1750 leal 2053994217(%ecx,%edi,1),%ecx
1751 movl $-1, %edi
1752 roll $12, %ecx
1753 addl %ebx, %ecx
1754 /* 139 */
1755 addl %esi, %ebx
1756 movl %edx, %esi
1757 subl %ecx, %edi
1758 andl %ecx, %esi
1759 andl %ebp, %edi
1760 orl %edi, %esi
1761 movl 40(%esp), %edi
1762 roll $10, %edx
1763 leal 2053994217(%ebx,%esi,1),%ebx
1764 movl $-1, %esi
1765 roll $9, %ebx
1766 addl %eax, %ebx
1767 /* 140 */
1768 addl %edi, %eax
1769 movl %ecx, %edi
1770 subl %ebx, %esi
1771 andl %ebx, %edi
1772 andl %edx, %esi
1773 orl %esi, %edi
1774 movl 32(%esp), %esi
1775 roll $10, %ecx
1776 leal 2053994217(%eax,%edi,1),%eax
1777 movl $-1, %edi
1778 roll $12, %eax
1779 addl %ebp, %eax
1780 /* 141 */
1781 addl %esi, %ebp
1782 movl %ebx, %esi
1783 subl %eax, %edi
1784 andl %eax, %esi
1785 andl %ecx, %edi
1786 orl %edi, %esi
1787 movl 44(%esp), %edi
1788 roll $10, %ebx
1789 leal 2053994217(%ebp,%esi,1),%ebp
1790 movl $-1, %esi
1791 roll $5, %ebp
1792 addl %edx, %ebp
1793 /* 142 */
1794 addl %edi, %edx
1795 movl %eax, %edi
1796 subl %ebp, %esi
1797 andl %ebp, %edi
1798 andl %ebx, %esi
1799 orl %esi, %edi
1800 movl 60(%esp), %esi
1801 roll $10, %eax
1802 leal 2053994217(%edx,%edi,1),%edx
1803 movl $-1, %edi
1804 roll $15, %edx
1805 addl %ecx, %edx
1806 /* 143 */
1807 addl %esi, %ecx
1808 movl %ebp, %esi
1809 subl %edx, %edi
1810 andl %edx, %esi
1811 andl %eax, %edi
1812 orl %esi, %edi
1813 movl %edx, %esi
1814 roll $10, %ebp
1815 leal 2053994217(%ecx,%edi,1),%ecx
1816 xorl %ebp, %esi
1817 roll $8, %ecx
1818 addl %ebx, %ecx
1819 /* 144 */
1820 movl 52(%esp), %edi
1821 xorl %ecx, %esi
1822 addl %edi, %ebx
1823 roll $10, %edx
1824 addl %esi, %ebx
1825 movl %ecx, %esi
1826 roll $8, %ebx
1827 addl %eax, %ebx
1828 /* 145 */
1829 xorl %edx, %esi
1830 movl 64(%esp), %edi
1831 xorl %ebx, %esi
1832 addl %esi, %eax
1833 movl %ebx, %esi
1834 roll $10, %ecx
1835 addl %edi, %eax
1836 xorl %ecx, %esi
1837 roll $5, %eax
1838 addl %ebp, %eax
1839 /* 146 */
1840 movl 44(%esp), %edi
1841 xorl %eax, %esi
1842 addl %edi, %ebp
1843 roll $10, %ebx
1844 addl %esi, %ebp
1845 movl %eax, %esi
1846 roll $12, %ebp
1847 addl %edx, %ebp
1848 /* 147 */
1849 xorl %ebx, %esi
1850 movl 20(%esp), %edi
1851 xorl %ebp, %esi
1852 addl %esi, %edx
1853 movl %ebp, %esi
1854 roll $10, %eax
1855 addl %edi, %edx
1856 xorl %eax, %esi
1857 roll $9, %edx
1858 addl %ecx, %edx
1859 /* 148 */
1860 movl 8(%esp), %edi
1861 xorl %edx, %esi
1862 addl %edi, %ecx
1863 roll $10, %ebp
1864 addl %esi, %ecx
1865 movl %edx, %esi
1866 roll $12, %ecx
1867 addl %ebx, %ecx
1868 /* 149 */
1869 xorl %ebp, %esi
1870 movl 24(%esp), %edi
1871 xorl %ecx, %esi
1872 addl %esi, %ebx
1873 movl %ecx, %esi
1874 roll $10, %edx
1875 addl %edi, %ebx
1876 xorl %edx, %esi
1877 roll $5, %ebx
1878 addl %eax, %ebx
1879 /* 150 */
1880 movl 36(%esp), %edi
1881 xorl %ebx, %esi
1882 addl %edi, %eax
1883 roll $10, %ecx
1884 addl %esi, %eax
1885 movl %ebx, %esi
1886 roll $14, %eax
1887 addl %ebp, %eax
1888 /* 151 */
1889 xorl %ecx, %esi
1890 movl 32(%esp), %edi
1891 xorl %eax, %esi
1892 addl %esi, %ebp
1893 movl %eax, %esi
1894 roll $10, %ebx
1895 addl %edi, %ebp
1896 xorl %ebx, %esi
1897 roll $6, %ebp
1898 addl %edx, %ebp
1899 /* 152 */
1900 movl 28(%esp), %edi
1901 xorl %ebp, %esi
1902 addl %edi, %edx
1903 roll $10, %eax
1904 addl %esi, %edx
1905 movl %ebp, %esi
1906 roll $8, %edx
1907 addl %ecx, %edx
1908 /* 153 */
1909 xorl %eax, %esi
1910 movl 12(%esp), %edi
1911 xorl %edx, %esi
1912 addl %esi, %ecx
1913 movl %edx, %esi
1914 roll $10, %ebp
1915 addl %edi, %ecx
1916 xorl %ebp, %esi
1917 roll $13, %ecx
1918 addl %ebx, %ecx
1919 /* 154 */
1920 movl 56(%esp), %edi
1921 xorl %ecx, %esi
1922 addl %edi, %ebx
1923 roll $10, %edx
1924 addl %esi, %ebx
1925 movl %ecx, %esi
1926 roll $6, %ebx
1927 addl %eax, %ebx
1928 /* 155 */
1929 xorl %edx, %esi
1930 movl 60(%esp), %edi
1931 xorl %ebx, %esi
1932 addl %esi, %eax
1933 movl %ebx, %esi
1934 roll $10, %ecx
1935 addl %edi, %eax
1936 xorl %ecx, %esi
1937 roll $5, %eax
1938 addl %ebp, %eax
1939 /* 156 */
1940 movl 4(%esp), %edi
1941 xorl %eax, %esi
1942 addl %edi, %ebp
1943 roll $10, %ebx
1944 addl %esi, %ebp
1945 movl %eax, %esi
1946 roll $15, %ebp
1947 addl %edx, %ebp
1948 /* 157 */
1949 xorl %ebx, %esi
1950 movl 16(%esp), %edi
1951 xorl %ebp, %esi
1952 addl %esi, %edx
1953 movl %ebp, %esi
1954 roll $10, %eax
1955 addl %edi, %edx
1956 xorl %eax, %esi
1957 roll $13, %edx
1958 addl %ecx, %edx
1959 /* 158 */
1960 movl 40(%esp), %edi
1961 xorl %edx, %esi
1962 addl %edi, %ecx
1963 roll $10, %ebp
1964 addl %esi, %ecx
1965 movl %edx, %esi
1966 roll $11, %ecx
1967 addl %ebx, %ecx
1968 /* 159 */
1969 xorl %ebp, %esi
1970 movl 48(%esp), %edi
1971 xorl %ecx, %esi
1972 addl %esi, %ebx
1973 roll $10, %edx
1974 addl %edi, %ebx
1975 movl 108(%esp), %edi
1976 roll $11, %ebx
1977 addl %eax, %ebx
1978 movl 4(%edi), %esi
1979 addl %esi, %edx
1980 movl 76(%esp), %esi
1981 addl %esi, %edx
1982 movl 8(%edi), %esi
1983 addl %esi, %ebp
1984 movl 80(%esp), %esi
1985 addl %esi, %ebp
1986 movl 12(%edi), %esi
1987 addl %esi, %eax
1988 movl 84(%esp), %esi
1989 addl %esi, %eax
1990 movl 16(%edi), %esi
1991 addl %esi, %ebx
1992 movl 68(%esp), %esi
1993 addl %esi, %ebx
1994 movl (%edi), %esi
1995 addl %esi, %ecx
1996 movl 72(%esp), %esi
1997 addl %esi, %ecx
1998 movl %edx, (%edi)
1999 movl %ebp, 4(%edi)
2000 movl %eax, 8(%edi)
2001 movl %ebx, 12(%edi)
2002 movl %ecx, 16(%edi)
2003 movl (%esp), %edi
2004 movl 112(%esp), %esi
2005 cmpl %esi, %edi
2006 movl 108(%esp), %edi
2007 jge .L000start
2008 addl $88, %esp
2009 popl %ebx
2010 popl %ebp
2011 popl %edi
2012 popl %esi
2013 ret
2014.ripemd160_block_x86_end:
2015 SIZE(ripemd160_block_x86,.ripemd160_block_x86_end-ripemd160_block_x86)
2016.ident "desasm.pl"
diff --git a/src/lib/libcrypto/rsa/Makefile.ssl b/src/lib/libcrypto/rsa/Makefile.ssl
new file mode 100644
index 0000000000..d52f2e609e
--- /dev/null
+++ b/src/lib/libcrypto/rsa/Makefile.ssl
@@ -0,0 +1,86 @@
1#
2# SSLeay/crypto/rsa/Makefile
3#
4
5DIR= rsa
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=rsa
19ERRC=rsa_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c $(ERRC).c \
26 rsa_pk1.c rsa_ssl.c rsa_none.c
27LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o $(ERRC).o \
28 rsa_pk1.o rsa_ssl.o rsa_none.o
29
30SRC= $(LIBSRC)
31
32EXHEADER= rsa.h
33HEADER= $(EXHEADER)
34
35ALL= $(GENERAL) $(SRC) $(HEADER)
36
37top:
38 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
39
40all: lib
41
42lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ)
44 sh $(TOP)/util/ranlib.sh $(LIB)
45 @touch lib
46
47files:
48 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
49
50links:
51 /bin/rm -f Makefile
52 $(TOP)/util/point.sh Makefile.ssl Makefile ;
53 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
54 $(TOP)/util/mklink.sh ../../test $(TEST)
55 $(TOP)/util/mklink.sh ../../apps $(APPS)
56
57install:
58 @for i in $(EXHEADER) ; \
59 do \
60 (cp $$i $(INSTALLTOP)/include/$$i; \
61 chmod 644 $(INSTALLTOP)/include/$$i ); \
62 done;
63
64tags:
65 ctags $(SRC)
66
67tests:
68
69lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71
72depend:
73 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
74
75dclean:
76 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
77 mv -f Makefile.new $(MAKEFILE)
78
79clean:
80 /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
81
82errors:
83 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
84 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
85
86# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/rsa/rsa.err b/src/lib/libcrypto/rsa/rsa.err
new file mode 100644
index 0000000000..5ded1b5fa2
--- /dev/null
+++ b/src/lib/libcrypto/rsa/rsa.err
@@ -0,0 +1,45 @@
1/* Error codes for the RSA functions. */
2
3/* Function codes. */
4#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 100
5#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 101
6#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 102
7#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 103
8#define RSA_F_RSA_GENERATE_KEY 104
9#define RSA_F_RSA_NEW_METHOD 105
10#define RSA_F_RSA_PADDING_ADD_NONE 106
11#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 107
12#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 108
13#define RSA_F_RSA_PADDING_ADD_SSLV23 109
14#define RSA_F_RSA_PADDING_CHECK_NONE 110
15#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 111
16#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 112
17#define RSA_F_RSA_PADDING_CHECK_SSLV23 113
18#define RSA_F_RSA_PRINT 114
19#define RSA_F_RSA_PRINT_FP 115
20#define RSA_F_RSA_SIGN 116
21#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 117
22#define RSA_F_RSA_VERIFY 118
23#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 119
24
25/* Reason codes. */
26#define RSA_R_ALGORITHM_MISMATCH 100
27#define RSA_R_BAD_E_VALUE 101
28#define RSA_R_BAD_FIXED_HEADER_DECRYPT 102
29#define RSA_R_BAD_PAD_BYTE_COUNT 103
30#define RSA_R_BAD_SIGNATURE 104
31#define RSA_R_BAD_ZERO_BYTE 105
32#define RSA_R_BLOCK_TYPE_IS_NOT_01 106
33#define RSA_R_BLOCK_TYPE_IS_NOT_02 107
34#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108
35#define RSA_R_DATA_TOO_LARGE 109
36#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110
37#define RSA_R_DATA_TOO_SMALL 111
38#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112
39#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
40#define RSA_R_PADDING_CHECK_FAILED 114
41#define RSA_R_SSLV3_ROLLBACK_ATTACK 115
42#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
43#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
44#define RSA_R_UNKNOWN_PADDING_TYPE 118
45#define RSA_R_WRONG_SIGNATURE_LENGTH 119
diff --git a/src/lib/libcrypto/sha/Makefile.ssl b/src/lib/libcrypto/sha/Makefile.ssl
new file mode 100644
index 0000000000..eeb545d140
--- /dev/null
+++ b/src/lib/libcrypto/sha/Makefile.ssl
@@ -0,0 +1,103 @@
1#
2# SSLeay/crypto/sha/Makefile
3#
4
5DIR= sha
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16SHA1_ASM_OBJ=
17
18CFLAGS= $(INCLUDES) $(CFLAG)
19
20GENERAL=Makefile
21TEST=shatest.c sha1test.c
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c
26LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o $(SHA1_ASM_OBJ)
27
28SRC= $(LIBSRC)
29
30EXHEADER= sha.h
31HEADER= sha_locl.h $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: lib
39
40lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/util/ranlib.sh $(LIB)
43 @touch lib
44
45# elf
46asm/sx86-elf.o: asm/sx86unix.cpp
47 $(CPP) -DELF asm/sx86unix.cpp | as -o asm/sx86-elf.o
48
49# solaris
50asm/sx86-sol.o: asm/sx86unix.cpp
51 $(CC) -E -DSOL asm/sx86unix.cpp | sed 's/^#.*//' > asm/sx86-sol.s
52 as -o asm/sx86-sol.o asm/sx86-sol.s
53 rm -f asm/sx86-sol.s
54
55# a.out
56asm/sx86-out.o: asm/sx86unix.cpp
57 $(CPP) -DOUT asm/sx86unix.cpp | as -o asm/sx86-out.o
58
59# bsdi
60asm/sx86bsdi.o: asm/sx86unix.cpp
61 $(CPP) -DBSDI asm/sx86unix.cpp | as -o asm/sx86bsdi.o
62
63asm/sx86unix.cpp:
64 (cd asm; perl sha1-586.pl cpp >sx86unix.cpp)
65
66files:
67 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
68
69links:
70 /bin/rm -f Makefile
71 $(TOP)/util/point.sh Makefile.ssl Makefile ;
72 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
73 $(TOP)/util/mklink.sh ../../test $(TEST)
74 $(TOP)/util/mklink.sh ../../apps $(APPS)
75
76install:
77 @for i in $(EXHEADER) ; \
78 do \
79 (cp $$i $(INSTALLTOP)/include/$$i; \
80 chmod 644 $(INSTALLTOP)/include/$$i ); \
81 done;
82
83tags:
84 ctags $(SRC)
85
86tests:
87
88lint:
89 lint -DLINT $(INCLUDES) $(SRC)>fluff
90
91depend:
92 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
93
94dclean:
95 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
96 mv -f Makefile.new $(MAKEFILE)
97
98clean:
99 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o
100
101errors:
102
103# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/sha/Makefile.uni b/src/lib/libcrypto/sha/Makefile.uni
new file mode 100644
index 0000000000..f3236755b2
--- /dev/null
+++ b/src/lib/libcrypto/sha/Makefile.uni
@@ -0,0 +1,122 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= sha
11TOP= .
12CC= gcc
13CFLAG= -O3 -fomit-frame-pointer
14
15CPP= $(CC) -E
16INCLUDES=
17INSTALLTOP=/usr/local/lib
18MAKE= make
19MAKEDEPEND= makedepend
20MAKEFILE= Makefile.uni
21AR= ar r
22
23SHA_ASM_OBJ=
24
25CFLAGS= $(INCLUDES) $(CFLAG)
26
27GENERAL=Makefile
28
29TEST1=shatest
30TEST2=sha1test
31APP1=sha
32APP2=sha1
33
34TEST=$(TEST1) $(TEST2)
35APPS=$(APP1) $(APP2)
36
37LIB=libsha.a
38LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c
39LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o $(SHA_ASM_OBJ)
40
41SRC= $(LIBSRC)
42
43EXHEADER= sha.h
44HEADER= sha_locl.h $(EXHEADER)
45
46ALL= $(GENERAL) $(SRC) $(HEADER)
47
48all: $(LIB) $(TEST) $(APPS)
49
50$(LIB): $(LIBOBJ)
51 $(AR) $(LIB) $(LIBOBJ)
52 sh $(TOP)/ranlib.sh $(LIB)
53
54# elf
55asm/sx86-elf.o: asm/sx86unix.cpp
56 $(CPP) -DELF asm/sx86unix.cpp | as -o asm/sx86-elf.o
57
58# solaris
59asm/sx86-sol.o: asm/sx86unix.cpp
60 $(CC) -E -DSOL asm/sx86unix.cpp | sed 's/^#.*//' > asm/sx86-sol.s
61 as -o asm/sx86-sol.o asm/sx86-sol.s
62 rm -f asm/sx86-sol.s
63
64# a.out
65asm/sx86-out.o: asm/sx86unix.cpp
66 $(CPP) -DOUT asm/sx86unix.cpp | as -o asm/sx86-out.o
67
68# bsdi
69asm/sx86bsdi.o: asm/sx86unix.cpp
70 $(CPP) -DBSDI asm/sx86unix.cpp | as -o asm/sx86bsdi.o
71
72asm/sx86unix.cpp:
73 (cd asm; perl sha1-586.pl cpp >sx86unix.cpp)
74
75test: $(TEST)
76 ./$(TEST1)
77 ./$(TEST2)
78
79$(TEST1): $(TEST1).c $(LIB)
80 $(CC) -o $(TEST1) $(CFLAGS) $(TEST1).c $(LIB)
81
82$(TEST2): $(TEST2).c $(LIB)
83 $(CC) -o $(TEST2) $(CFLAGS) $(TEST2).c $(LIB)
84
85$(APP1): $(APP1).c $(LIB)
86 $(CC) -o $(APP1) $(CFLAGS) $(APP1).c $(LIB)
87
88$(APP2): $(APP2).c $(LIB)
89 $(CC) -o $(APP2) $(CFLAGS) $(APP2).c $(LIB)
90
91lint:
92 lint -DLINT $(INCLUDES) $(SRC)>fluff
93
94depend:
95 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
96
97dclean:
98 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
99 mv -f Makefile.new $(MAKEFILE)
100
101clean:
102 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
103
104cc:
105 $(MAKE) SHA_ASM_OBJ="" CC="cc" CFLAG="-O" all
106
107gcc:
108 $(MAKE) SHA_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
109
110x86-elf:
111 $(MAKE) SHA_ASM_OBJ="asm/sx86-elf.o" CFLAG="-DELF -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all
112
113x86-out:
114 $(MAKE) SHA_ASM_OBJ="asm/sx86-out.o" CFLAG="-DOUT -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all
115
116x86-solaris:
117 $(MAKE) SHA_ASM_OBJ="asm/sx86-sol.o" CFLAG="-DSOL -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all
118
119x86-bdsi:
120 $(MAKE) SHA_ASM_OBJ="asm/sx86-bdsi.o" CFLAG="-DBDSI -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all
121
122# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/sha/asm/s1-win32.asm b/src/lib/libcrypto/sha/asm/s1-win32.asm
new file mode 100644
index 0000000000..61335666b9
--- /dev/null
+++ b/src/lib/libcrypto/sha/asm/s1-win32.asm
@@ -0,0 +1,1664 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by sha1-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE sha1-586.asm
8 .486
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _sha1_block_x86
12
13_sha1_block_x86 PROC NEAR
14 push esi
15 push ebp
16 mov eax, DWORD PTR 20[esp]
17 mov esi, DWORD PTR 16[esp]
18 add eax, esi
19 mov ebp, DWORD PTR 12[esp]
20 push ebx
21 sub eax, 64
22 push edi
23 mov ebx, DWORD PTR 4[ebp]
24 sub esp, 72
25 mov edx, DWORD PTR 12[ebp]
26 mov edi, DWORD PTR 16[ebp]
27 mov ecx, DWORD PTR 8[ebp]
28 mov DWORD PTR 68[esp],eax
29 ; First we need to setup the X array
30 mov eax, DWORD PTR [esi]
31L000start:
32 ; First, load the words onto the stack in network byte order
33 bswap eax
34 mov DWORD PTR [esp],eax
35 mov eax, DWORD PTR 4[esi]
36 bswap eax
37 mov DWORD PTR 4[esp],eax
38 mov eax, DWORD PTR 8[esi]
39 bswap eax
40 mov DWORD PTR 8[esp],eax
41 mov eax, DWORD PTR 12[esi]
42 bswap eax
43 mov DWORD PTR 12[esp],eax
44 mov eax, DWORD PTR 16[esi]
45 bswap eax
46 mov DWORD PTR 16[esp],eax
47 mov eax, DWORD PTR 20[esi]
48 bswap eax
49 mov DWORD PTR 20[esp],eax
50 mov eax, DWORD PTR 24[esi]
51 bswap eax
52 mov DWORD PTR 24[esp],eax
53 mov eax, DWORD PTR 28[esi]
54 bswap eax
55 mov DWORD PTR 28[esp],eax
56 mov eax, DWORD PTR 32[esi]
57 bswap eax
58 mov DWORD PTR 32[esp],eax
59 mov eax, DWORD PTR 36[esi]
60 bswap eax
61 mov DWORD PTR 36[esp],eax
62 mov eax, DWORD PTR 40[esi]
63 bswap eax
64 mov DWORD PTR 40[esp],eax
65 mov eax, DWORD PTR 44[esi]
66 bswap eax
67 mov DWORD PTR 44[esp],eax
68 mov eax, DWORD PTR 48[esi]
69 bswap eax
70 mov DWORD PTR 48[esp],eax
71 mov eax, DWORD PTR 52[esi]
72 bswap eax
73 mov DWORD PTR 52[esp],eax
74 mov eax, DWORD PTR 56[esi]
75 bswap eax
76 mov DWORD PTR 56[esp],eax
77 mov eax, DWORD PTR 60[esi]
78 bswap eax
79 mov DWORD PTR 60[esp],eax
80 ; We now have the X array on the stack
81 ; starting at sp-4
82 mov DWORD PTR 64[esp],esi
83 ;
84 ; Start processing
85 mov eax, DWORD PTR [ebp]
86 ; 00_15 0
87 mov esi, ecx
88 mov ebp, eax
89 xor esi, edx
90 rol ebp, 5
91 and esi, ebx
92 add ebp, edi
93 ror ebx, 1
94 mov edi, DWORD PTR [esp]
95 ror ebx, 1
96 xor esi, edx
97 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
98 mov edi, ebx
99 add esi, ebp
100 xor edi, ecx
101 mov ebp, esi
102 and edi, eax
103 rol ebp, 5
104 add ebp, edx
105 mov edx, DWORD PTR 4[esp]
106 ror eax, 1
107 xor edi, ecx
108 ror eax, 1
109 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
110 add edi, ebp
111 ; 00_15 2
112 mov edx, eax
113 mov ebp, edi
114 xor edx, ebx
115 rol ebp, 5
116 and edx, esi
117 add ebp, ecx
118 ror esi, 1
119 mov ecx, DWORD PTR 8[esp]
120 ror esi, 1
121 xor edx, ebx
122 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
123 mov ecx, esi
124 add edx, ebp
125 xor ecx, eax
126 mov ebp, edx
127 and ecx, edi
128 rol ebp, 5
129 add ebp, ebx
130 mov ebx, DWORD PTR 12[esp]
131 ror edi, 1
132 xor ecx, eax
133 ror edi, 1
134 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
135 add ecx, ebp
136 ; 00_15 4
137 mov ebx, edi
138 mov ebp, ecx
139 xor ebx, esi
140 rol ebp, 5
141 and ebx, edx
142 add ebp, eax
143 ror edx, 1
144 mov eax, DWORD PTR 16[esp]
145 ror edx, 1
146 xor ebx, esi
147 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
148 mov eax, edx
149 add ebx, ebp
150 xor eax, edi
151 mov ebp, ebx
152 and eax, ecx
153 rol ebp, 5
154 add ebp, esi
155 mov esi, DWORD PTR 20[esp]
156 ror ecx, 1
157 xor eax, edi
158 ror ecx, 1
159 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
160 add eax, ebp
161 ; 00_15 6
162 mov esi, ecx
163 mov ebp, eax
164 xor esi, edx
165 rol ebp, 5
166 and esi, ebx
167 add ebp, edi
168 ror ebx, 1
169 mov edi, DWORD PTR 24[esp]
170 ror ebx, 1
171 xor esi, edx
172 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
173 mov edi, ebx
174 add esi, ebp
175 xor edi, ecx
176 mov ebp, esi
177 and edi, eax
178 rol ebp, 5
179 add ebp, edx
180 mov edx, DWORD PTR 28[esp]
181 ror eax, 1
182 xor edi, ecx
183 ror eax, 1
184 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
185 add edi, ebp
186 ; 00_15 8
187 mov edx, eax
188 mov ebp, edi
189 xor edx, ebx
190 rol ebp, 5
191 and edx, esi
192 add ebp, ecx
193 ror esi, 1
194 mov ecx, DWORD PTR 32[esp]
195 ror esi, 1
196 xor edx, ebx
197 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
198 mov ecx, esi
199 add edx, ebp
200 xor ecx, eax
201 mov ebp, edx
202 and ecx, edi
203 rol ebp, 5
204 add ebp, ebx
205 mov ebx, DWORD PTR 36[esp]
206 ror edi, 1
207 xor ecx, eax
208 ror edi, 1
209 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
210 add ecx, ebp
211 ; 00_15 10
212 mov ebx, edi
213 mov ebp, ecx
214 xor ebx, esi
215 rol ebp, 5
216 and ebx, edx
217 add ebp, eax
218 ror edx, 1
219 mov eax, DWORD PTR 40[esp]
220 ror edx, 1
221 xor ebx, esi
222 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
223 mov eax, edx
224 add ebx, ebp
225 xor eax, edi
226 mov ebp, ebx
227 and eax, ecx
228 rol ebp, 5
229 add ebp, esi
230 mov esi, DWORD PTR 44[esp]
231 ror ecx, 1
232 xor eax, edi
233 ror ecx, 1
234 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
235 add eax, ebp
236 ; 00_15 12
237 mov esi, ecx
238 mov ebp, eax
239 xor esi, edx
240 rol ebp, 5
241 and esi, ebx
242 add ebp, edi
243 ror ebx, 1
244 mov edi, DWORD PTR 48[esp]
245 ror ebx, 1
246 xor esi, edx
247 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
248 mov edi, ebx
249 add esi, ebp
250 xor edi, ecx
251 mov ebp, esi
252 and edi, eax
253 rol ebp, 5
254 add ebp, edx
255 mov edx, DWORD PTR 52[esp]
256 ror eax, 1
257 xor edi, ecx
258 ror eax, 1
259 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
260 add edi, ebp
261 ; 00_15 14
262 mov edx, eax
263 mov ebp, edi
264 xor edx, ebx
265 rol ebp, 5
266 and edx, esi
267 add ebp, ecx
268 ror esi, 1
269 mov ecx, DWORD PTR 56[esp]
270 ror esi, 1
271 xor edx, ebx
272 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
273 mov ecx, esi
274 add edx, ebp
275 xor ecx, eax
276 mov ebp, edx
277 and ecx, edi
278 rol ebp, 5
279 add ebp, ebx
280 mov ebx, DWORD PTR 60[esp]
281 ror edi, 1
282 xor ecx, eax
283 ror edi, 1
284 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
285 add ecx, ebp
286 ; 16_19 16
287 nop
288 mov ebp, DWORD PTR [esp]
289 mov ebx, DWORD PTR 8[esp]
290 xor ebx, ebp
291 mov ebp, DWORD PTR 32[esp]
292 xor ebx, ebp
293 mov ebp, DWORD PTR 52[esp]
294 xor ebx, ebp
295 mov ebp, edi
296 rol ebx, 1
297 xor ebp, esi
298 mov DWORD PTR [esp],ebx
299 and ebp, edx
300 lea ebx, DWORD PTR 1518500249[eax*1+ebx]
301 xor ebp, esi
302 mov eax, ecx
303 add ebx, ebp
304 rol eax, 5
305 ror edx, 1
306 add ebx, eax
307 mov eax, DWORD PTR 4[esp]
308 mov ebp, DWORD PTR 12[esp]
309 xor eax, ebp
310 mov ebp, DWORD PTR 36[esp]
311 xor eax, ebp
312 mov ebp, DWORD PTR 56[esp]
313 ror edx, 1
314 xor eax, ebp
315 rol eax, 1
316 mov ebp, edx
317 xor ebp, edi
318 mov DWORD PTR 4[esp],eax
319 and ebp, ecx
320 lea eax, DWORD PTR 1518500249[esi*1+eax]
321 xor ebp, edi
322 mov esi, ebx
323 rol esi, 5
324 ror ecx, 1
325 add eax, esi
326 ror ecx, 1
327 add eax, ebp
328 ; 16_19 18
329 mov ebp, DWORD PTR 8[esp]
330 mov esi, DWORD PTR 16[esp]
331 xor esi, ebp
332 mov ebp, DWORD PTR 40[esp]
333 xor esi, ebp
334 mov ebp, DWORD PTR 60[esp]
335 xor esi, ebp
336 mov ebp, ecx
337 rol esi, 1
338 xor ebp, edx
339 mov DWORD PTR 8[esp],esi
340 and ebp, ebx
341 lea esi, DWORD PTR 1518500249[edi*1+esi]
342 xor ebp, edx
343 mov edi, eax
344 add esi, ebp
345 rol edi, 5
346 ror ebx, 1
347 add esi, edi
348 mov edi, DWORD PTR 12[esp]
349 mov ebp, DWORD PTR 20[esp]
350 xor edi, ebp
351 mov ebp, DWORD PTR 44[esp]
352 xor edi, ebp
353 mov ebp, DWORD PTR [esp]
354 ror ebx, 1
355 xor edi, ebp
356 rol edi, 1
357 mov ebp, ebx
358 xor ebp, ecx
359 mov DWORD PTR 12[esp],edi
360 and ebp, eax
361 lea edi, DWORD PTR 1518500249[edx*1+edi]
362 xor ebp, ecx
363 mov edx, esi
364 rol edx, 5
365 ror eax, 1
366 add edi, edx
367 ror eax, 1
368 add edi, ebp
369 ; 20_39 20
370 mov edx, DWORD PTR 16[esp]
371 mov ebp, DWORD PTR 24[esp]
372 xor edx, ebp
373 mov ebp, DWORD PTR 48[esp]
374 xor edx, ebp
375 mov ebp, DWORD PTR 4[esp]
376 xor edx, ebp
377 mov ebp, esi
378 rol edx, 1
379 xor ebp, eax
380 mov DWORD PTR 16[esp],edx
381 xor ebp, ebx
382 lea edx, DWORD PTR 1859775393[ecx*1+edx]
383 mov ecx, edi
384 rol ecx, 5
385 ror esi, 1
386 add ecx, ebp
387 ror esi, 1
388 add edx, ecx
389 ; 20_39 21
390 mov ecx, DWORD PTR 20[esp]
391 mov ebp, DWORD PTR 28[esp]
392 xor ecx, ebp
393 mov ebp, DWORD PTR 52[esp]
394 xor ecx, ebp
395 mov ebp, DWORD PTR 8[esp]
396 xor ecx, ebp
397 mov ebp, edi
398 rol ecx, 1
399 xor ebp, esi
400 mov DWORD PTR 20[esp],ecx
401 xor ebp, eax
402 lea ecx, DWORD PTR 1859775393[ebx*1+ecx]
403 mov ebx, edx
404 rol ebx, 5
405 ror edi, 1
406 add ebx, ebp
407 ror edi, 1
408 add ecx, ebx
409 ; 20_39 22
410 mov ebx, DWORD PTR 24[esp]
411 mov ebp, DWORD PTR 32[esp]
412 xor ebx, ebp
413 mov ebp, DWORD PTR 56[esp]
414 xor ebx, ebp
415 mov ebp, DWORD PTR 12[esp]
416 xor ebx, ebp
417 mov ebp, edx
418 rol ebx, 1
419 xor ebp, edi
420 mov DWORD PTR 24[esp],ebx
421 xor ebp, esi
422 lea ebx, DWORD PTR 1859775393[eax*1+ebx]
423 mov eax, ecx
424 rol eax, 5
425 ror edx, 1
426 add eax, ebp
427 ror edx, 1
428 add ebx, eax
429 ; 20_39 23
430 mov eax, DWORD PTR 28[esp]
431 mov ebp, DWORD PTR 36[esp]
432 xor eax, ebp
433 mov ebp, DWORD PTR 60[esp]
434 xor eax, ebp
435 mov ebp, DWORD PTR 16[esp]
436 xor eax, ebp
437 mov ebp, ecx
438 rol eax, 1
439 xor ebp, edx
440 mov DWORD PTR 28[esp],eax
441 xor ebp, edi
442 lea eax, DWORD PTR 1859775393[esi*1+eax]
443 mov esi, ebx
444 rol esi, 5
445 ror ecx, 1
446 add esi, ebp
447 ror ecx, 1
448 add eax, esi
449 ; 20_39 24
450 mov esi, DWORD PTR 32[esp]
451 mov ebp, DWORD PTR 40[esp]
452 xor esi, ebp
453 mov ebp, DWORD PTR [esp]
454 xor esi, ebp
455 mov ebp, DWORD PTR 20[esp]
456 xor esi, ebp
457 mov ebp, ebx
458 rol esi, 1
459 xor ebp, ecx
460 mov DWORD PTR 32[esp],esi
461 xor ebp, edx
462 lea esi, DWORD PTR 1859775393[edi*1+esi]
463 mov edi, eax
464 rol edi, 5
465 ror ebx, 1
466 add edi, ebp
467 ror ebx, 1
468 add esi, edi
469 ; 20_39 25
470 mov edi, DWORD PTR 36[esp]
471 mov ebp, DWORD PTR 44[esp]
472 xor edi, ebp
473 mov ebp, DWORD PTR 4[esp]
474 xor edi, ebp
475 mov ebp, DWORD PTR 24[esp]
476 xor edi, ebp
477 mov ebp, eax
478 rol edi, 1
479 xor ebp, ebx
480 mov DWORD PTR 36[esp],edi
481 xor ebp, ecx
482 lea edi, DWORD PTR 1859775393[edx*1+edi]
483 mov edx, esi
484 rol edx, 5
485 ror eax, 1
486 add edx, ebp
487 ror eax, 1
488 add edi, edx
489 ; 20_39 26
490 mov edx, DWORD PTR 40[esp]
491 mov ebp, DWORD PTR 48[esp]
492 xor edx, ebp
493 mov ebp, DWORD PTR 8[esp]
494 xor edx, ebp
495 mov ebp, DWORD PTR 28[esp]
496 xor edx, ebp
497 mov ebp, esi
498 rol edx, 1
499 xor ebp, eax
500 mov DWORD PTR 40[esp],edx
501 xor ebp, ebx
502 lea edx, DWORD PTR 1859775393[ecx*1+edx]
503 mov ecx, edi
504 rol ecx, 5
505 ror esi, 1
506 add ecx, ebp
507 ror esi, 1
508 add edx, ecx
509 ; 20_39 27
510 mov ecx, DWORD PTR 44[esp]
511 mov ebp, DWORD PTR 52[esp]
512 xor ecx, ebp
513 mov ebp, DWORD PTR 12[esp]
514 xor ecx, ebp
515 mov ebp, DWORD PTR 32[esp]
516 xor ecx, ebp
517 mov ebp, edi
518 rol ecx, 1
519 xor ebp, esi
520 mov DWORD PTR 44[esp],ecx
521 xor ebp, eax
522 lea ecx, DWORD PTR 1859775393[ebx*1+ecx]
523 mov ebx, edx
524 rol ebx, 5
525 ror edi, 1
526 add ebx, ebp
527 ror edi, 1
528 add ecx, ebx
529 ; 20_39 28
530 mov ebx, DWORD PTR 48[esp]
531 mov ebp, DWORD PTR 56[esp]
532 xor ebx, ebp
533 mov ebp, DWORD PTR 16[esp]
534 xor ebx, ebp
535 mov ebp, DWORD PTR 36[esp]
536 xor ebx, ebp
537 mov ebp, edx
538 rol ebx, 1
539 xor ebp, edi
540 mov DWORD PTR 48[esp],ebx
541 xor ebp, esi
542 lea ebx, DWORD PTR 1859775393[eax*1+ebx]
543 mov eax, ecx
544 rol eax, 5
545 ror edx, 1
546 add eax, ebp
547 ror edx, 1
548 add ebx, eax
549 ; 20_39 29
550 mov eax, DWORD PTR 52[esp]
551 mov ebp, DWORD PTR 60[esp]
552 xor eax, ebp
553 mov ebp, DWORD PTR 20[esp]
554 xor eax, ebp
555 mov ebp, DWORD PTR 40[esp]
556 xor eax, ebp
557 mov ebp, ecx
558 rol eax, 1
559 xor ebp, edx
560 mov DWORD PTR 52[esp],eax
561 xor ebp, edi
562 lea eax, DWORD PTR 1859775393[esi*1+eax]
563 mov esi, ebx
564 rol esi, 5
565 ror ecx, 1
566 add esi, ebp
567 ror ecx, 1
568 add eax, esi
569 ; 20_39 30
570 mov esi, DWORD PTR 56[esp]
571 mov ebp, DWORD PTR [esp]
572 xor esi, ebp
573 mov ebp, DWORD PTR 24[esp]
574 xor esi, ebp
575 mov ebp, DWORD PTR 44[esp]
576 xor esi, ebp
577 mov ebp, ebx
578 rol esi, 1
579 xor ebp, ecx
580 mov DWORD PTR 56[esp],esi
581 xor ebp, edx
582 lea esi, DWORD PTR 1859775393[edi*1+esi]
583 mov edi, eax
584 rol edi, 5
585 ror ebx, 1
586 add edi, ebp
587 ror ebx, 1
588 add esi, edi
589 ; 20_39 31
590 mov edi, DWORD PTR 60[esp]
591 mov ebp, DWORD PTR 4[esp]
592 xor edi, ebp
593 mov ebp, DWORD PTR 28[esp]
594 xor edi, ebp
595 mov ebp, DWORD PTR 48[esp]
596 xor edi, ebp
597 mov ebp, eax
598 rol edi, 1
599 xor ebp, ebx
600 mov DWORD PTR 60[esp],edi
601 xor ebp, ecx
602 lea edi, DWORD PTR 1859775393[edx*1+edi]
603 mov edx, esi
604 rol edx, 5
605 ror eax, 1
606 add edx, ebp
607 ror eax, 1
608 add edi, edx
609 ; 20_39 32
610 mov edx, DWORD PTR [esp]
611 mov ebp, DWORD PTR 8[esp]
612 xor edx, ebp
613 mov ebp, DWORD PTR 32[esp]
614 xor edx, ebp
615 mov ebp, DWORD PTR 52[esp]
616 xor edx, ebp
617 mov ebp, esi
618 rol edx, 1
619 xor ebp, eax
620 mov DWORD PTR [esp],edx
621 xor ebp, ebx
622 lea edx, DWORD PTR 1859775393[ecx*1+edx]
623 mov ecx, edi
624 rol ecx, 5
625 ror esi, 1
626 add ecx, ebp
627 ror esi, 1
628 add edx, ecx
629 ; 20_39 33
630 mov ecx, DWORD PTR 4[esp]
631 mov ebp, DWORD PTR 12[esp]
632 xor ecx, ebp
633 mov ebp, DWORD PTR 36[esp]
634 xor ecx, ebp
635 mov ebp, DWORD PTR 56[esp]
636 xor ecx, ebp
637 mov ebp, edi
638 rol ecx, 1
639 xor ebp, esi
640 mov DWORD PTR 4[esp],ecx
641 xor ebp, eax
642 lea ecx, DWORD PTR 1859775393[ebx*1+ecx]
643 mov ebx, edx
644 rol ebx, 5
645 ror edi, 1
646 add ebx, ebp
647 ror edi, 1
648 add ecx, ebx
649 ; 20_39 34
650 mov ebx, DWORD PTR 8[esp]
651 mov ebp, DWORD PTR 16[esp]
652 xor ebx, ebp
653 mov ebp, DWORD PTR 40[esp]
654 xor ebx, ebp
655 mov ebp, DWORD PTR 60[esp]
656 xor ebx, ebp
657 mov ebp, edx
658 rol ebx, 1
659 xor ebp, edi
660 mov DWORD PTR 8[esp],ebx
661 xor ebp, esi
662 lea ebx, DWORD PTR 1859775393[eax*1+ebx]
663 mov eax, ecx
664 rol eax, 5
665 ror edx, 1
666 add eax, ebp
667 ror edx, 1
668 add ebx, eax
669 ; 20_39 35
670 mov eax, DWORD PTR 12[esp]
671 mov ebp, DWORD PTR 20[esp]
672 xor eax, ebp
673 mov ebp, DWORD PTR 44[esp]
674 xor eax, ebp
675 mov ebp, DWORD PTR [esp]
676 xor eax, ebp
677 mov ebp, ecx
678 rol eax, 1
679 xor ebp, edx
680 mov DWORD PTR 12[esp],eax
681 xor ebp, edi
682 lea eax, DWORD PTR 1859775393[esi*1+eax]
683 mov esi, ebx
684 rol esi, 5
685 ror ecx, 1
686 add esi, ebp
687 ror ecx, 1
688 add eax, esi
689 ; 20_39 36
690 mov esi, DWORD PTR 16[esp]
691 mov ebp, DWORD PTR 24[esp]
692 xor esi, ebp
693 mov ebp, DWORD PTR 48[esp]
694 xor esi, ebp
695 mov ebp, DWORD PTR 4[esp]
696 xor esi, ebp
697 mov ebp, ebx
698 rol esi, 1
699 xor ebp, ecx
700 mov DWORD PTR 16[esp],esi
701 xor ebp, edx
702 lea esi, DWORD PTR 1859775393[edi*1+esi]
703 mov edi, eax
704 rol edi, 5
705 ror ebx, 1
706 add edi, ebp
707 ror ebx, 1
708 add esi, edi
709 ; 20_39 37
710 mov edi, DWORD PTR 20[esp]
711 mov ebp, DWORD PTR 28[esp]
712 xor edi, ebp
713 mov ebp, DWORD PTR 52[esp]
714 xor edi, ebp
715 mov ebp, DWORD PTR 8[esp]
716 xor edi, ebp
717 mov ebp, eax
718 rol edi, 1
719 xor ebp, ebx
720 mov DWORD PTR 20[esp],edi
721 xor ebp, ecx
722 lea edi, DWORD PTR 1859775393[edx*1+edi]
723 mov edx, esi
724 rol edx, 5
725 ror eax, 1
726 add edx, ebp
727 ror eax, 1
728 add edi, edx
729 ; 20_39 38
730 mov edx, DWORD PTR 24[esp]
731 mov ebp, DWORD PTR 32[esp]
732 xor edx, ebp
733 mov ebp, DWORD PTR 56[esp]
734 xor edx, ebp
735 mov ebp, DWORD PTR 12[esp]
736 xor edx, ebp
737 mov ebp, esi
738 rol edx, 1
739 xor ebp, eax
740 mov DWORD PTR 24[esp],edx
741 xor ebp, ebx
742 lea edx, DWORD PTR 1859775393[ecx*1+edx]
743 mov ecx, edi
744 rol ecx, 5
745 ror esi, 1
746 add ecx, ebp
747 ror esi, 1
748 add edx, ecx
749 ; 20_39 39
750 mov ecx, DWORD PTR 28[esp]
751 mov ebp, DWORD PTR 36[esp]
752 xor ecx, ebp
753 mov ebp, DWORD PTR 60[esp]
754 xor ecx, ebp
755 mov ebp, DWORD PTR 16[esp]
756 xor ecx, ebp
757 mov ebp, edi
758 rol ecx, 1
759 xor ebp, esi
760 mov DWORD PTR 28[esp],ecx
761 xor ebp, eax
762 lea ecx, DWORD PTR 1859775393[ebx*1+ecx]
763 mov ebx, edx
764 rol ebx, 5
765 ror edi, 1
766 add ebx, ebp
767 ror edi, 1
768 add ecx, ebx
769 ; 40_59 40
770 mov ebx, DWORD PTR 32[esp]
771 mov ebp, DWORD PTR 40[esp]
772 xor ebx, ebp
773 mov ebp, DWORD PTR [esp]
774 xor ebx, ebp
775 mov ebp, DWORD PTR 20[esp]
776 xor ebx, ebp
777 mov ebp, edx
778 rol ebx, 1
779 or ebp, edi
780 mov DWORD PTR 32[esp],ebx
781 and ebp, esi
782 lea ebx, DWORD PTR 2400959708[eax*1+ebx]
783 mov eax, edx
784 ror edx, 1
785 and eax, edi
786 or ebp, eax
787 mov eax, ecx
788 rol eax, 5
789 add ebp, eax
790 mov eax, DWORD PTR 36[esp]
791 add ebx, ebp
792 mov ebp, DWORD PTR 44[esp]
793 xor eax, ebp
794 mov ebp, DWORD PTR 4[esp]
795 xor eax, ebp
796 mov ebp, DWORD PTR 24[esp]
797 ror edx, 1
798 xor eax, ebp
799 rol eax, 1
800 mov ebp, ecx
801 mov DWORD PTR 36[esp],eax
802 or ebp, edx
803 lea eax, DWORD PTR 2400959708[esi*1+eax]
804 mov esi, ecx
805 and ebp, edi
806 and esi, edx
807 or ebp, esi
808 mov esi, ebx
809 rol esi, 5
810 ror ecx, 1
811 add ebp, esi
812 ror ecx, 1
813 add eax, ebp
814 ; 40_59 41
815 ; 40_59 42
816 mov esi, DWORD PTR 40[esp]
817 mov ebp, DWORD PTR 48[esp]
818 xor esi, ebp
819 mov ebp, DWORD PTR 8[esp]
820 xor esi, ebp
821 mov ebp, DWORD PTR 28[esp]
822 xor esi, ebp
823 mov ebp, ebx
824 rol esi, 1
825 or ebp, ecx
826 mov DWORD PTR 40[esp],esi
827 and ebp, edx
828 lea esi, DWORD PTR 2400959708[edi*1+esi]
829 mov edi, ebx
830 ror ebx, 1
831 and edi, ecx
832 or ebp, edi
833 mov edi, eax
834 rol edi, 5
835 add ebp, edi
836 mov edi, DWORD PTR 44[esp]
837 add esi, ebp
838 mov ebp, DWORD PTR 52[esp]
839 xor edi, ebp
840 mov ebp, DWORD PTR 12[esp]
841 xor edi, ebp
842 mov ebp, DWORD PTR 32[esp]
843 ror ebx, 1
844 xor edi, ebp
845 rol edi, 1
846 mov ebp, eax
847 mov DWORD PTR 44[esp],edi
848 or ebp, ebx
849 lea edi, DWORD PTR 2400959708[edx*1+edi]
850 mov edx, eax
851 and ebp, ecx
852 and edx, ebx
853 or ebp, edx
854 mov edx, esi
855 rol edx, 5
856 ror eax, 1
857 add ebp, edx
858 ror eax, 1
859 add edi, ebp
860 ; 40_59 43
861 ; 40_59 44
862 mov edx, DWORD PTR 48[esp]
863 mov ebp, DWORD PTR 56[esp]
864 xor edx, ebp
865 mov ebp, DWORD PTR 16[esp]
866 xor edx, ebp
867 mov ebp, DWORD PTR 36[esp]
868 xor edx, ebp
869 mov ebp, esi
870 rol edx, 1
871 or ebp, eax
872 mov DWORD PTR 48[esp],edx
873 and ebp, ebx
874 lea edx, DWORD PTR 2400959708[ecx*1+edx]
875 mov ecx, esi
876 ror esi, 1
877 and ecx, eax
878 or ebp, ecx
879 mov ecx, edi
880 rol ecx, 5
881 add ebp, ecx
882 mov ecx, DWORD PTR 52[esp]
883 add edx, ebp
884 mov ebp, DWORD PTR 60[esp]
885 xor ecx, ebp
886 mov ebp, DWORD PTR 20[esp]
887 xor ecx, ebp
888 mov ebp, DWORD PTR 40[esp]
889 ror esi, 1
890 xor ecx, ebp
891 rol ecx, 1
892 mov ebp, edi
893 mov DWORD PTR 52[esp],ecx
894 or ebp, esi
895 lea ecx, DWORD PTR 2400959708[ebx*1+ecx]
896 mov ebx, edi
897 and ebp, eax
898 and ebx, esi
899 or ebp, ebx
900 mov ebx, edx
901 rol ebx, 5
902 ror edi, 1
903 add ebp, ebx
904 ror edi, 1
905 add ecx, ebp
906 ; 40_59 45
907 ; 40_59 46
908 mov ebx, DWORD PTR 56[esp]
909 mov ebp, DWORD PTR [esp]
910 xor ebx, ebp
911 mov ebp, DWORD PTR 24[esp]
912 xor ebx, ebp
913 mov ebp, DWORD PTR 44[esp]
914 xor ebx, ebp
915 mov ebp, edx
916 rol ebx, 1
917 or ebp, edi
918 mov DWORD PTR 56[esp],ebx
919 and ebp, esi
920 lea ebx, DWORD PTR 2400959708[eax*1+ebx]
921 mov eax, edx
922 ror edx, 1
923 and eax, edi
924 or ebp, eax
925 mov eax, ecx
926 rol eax, 5
927 add ebp, eax
928 mov eax, DWORD PTR 60[esp]
929 add ebx, ebp
930 mov ebp, DWORD PTR 4[esp]
931 xor eax, ebp
932 mov ebp, DWORD PTR 28[esp]
933 xor eax, ebp
934 mov ebp, DWORD PTR 48[esp]
935 ror edx, 1
936 xor eax, ebp
937 rol eax, 1
938 mov ebp, ecx
939 mov DWORD PTR 60[esp],eax
940 or ebp, edx
941 lea eax, DWORD PTR 2400959708[esi*1+eax]
942 mov esi, ecx
943 and ebp, edi
944 and esi, edx
945 or ebp, esi
946 mov esi, ebx
947 rol esi, 5
948 ror ecx, 1
949 add ebp, esi
950 ror ecx, 1
951 add eax, ebp
952 ; 40_59 47
953 ; 40_59 48
954 mov esi, DWORD PTR [esp]
955 mov ebp, DWORD PTR 8[esp]
956 xor esi, ebp
957 mov ebp, DWORD PTR 32[esp]
958 xor esi, ebp
959 mov ebp, DWORD PTR 52[esp]
960 xor esi, ebp
961 mov ebp, ebx
962 rol esi, 1
963 or ebp, ecx
964 mov DWORD PTR [esp],esi
965 and ebp, edx
966 lea esi, DWORD PTR 2400959708[edi*1+esi]
967 mov edi, ebx
968 ror ebx, 1
969 and edi, ecx
970 or ebp, edi
971 mov edi, eax
972 rol edi, 5
973 add ebp, edi
974 mov edi, DWORD PTR 4[esp]
975 add esi, ebp
976 mov ebp, DWORD PTR 12[esp]
977 xor edi, ebp
978 mov ebp, DWORD PTR 36[esp]
979 xor edi, ebp
980 mov ebp, DWORD PTR 56[esp]
981 ror ebx, 1
982 xor edi, ebp
983 rol edi, 1
984 mov ebp, eax
985 mov DWORD PTR 4[esp],edi
986 or ebp, ebx
987 lea edi, DWORD PTR 2400959708[edx*1+edi]
988 mov edx, eax
989 and ebp, ecx
990 and edx, ebx
991 or ebp, edx
992 mov edx, esi
993 rol edx, 5
994 ror eax, 1
995 add ebp, edx
996 ror eax, 1
997 add edi, ebp
998 ; 40_59 49
999 ; 40_59 50
1000 mov edx, DWORD PTR 8[esp]
1001 mov ebp, DWORD PTR 16[esp]
1002 xor edx, ebp
1003 mov ebp, DWORD PTR 40[esp]
1004 xor edx, ebp
1005 mov ebp, DWORD PTR 60[esp]
1006 xor edx, ebp
1007 mov ebp, esi
1008 rol edx, 1
1009 or ebp, eax
1010 mov DWORD PTR 8[esp],edx
1011 and ebp, ebx
1012 lea edx, DWORD PTR 2400959708[ecx*1+edx]
1013 mov ecx, esi
1014 ror esi, 1
1015 and ecx, eax
1016 or ebp, ecx
1017 mov ecx, edi
1018 rol ecx, 5
1019 add ebp, ecx
1020 mov ecx, DWORD PTR 12[esp]
1021 add edx, ebp
1022 mov ebp, DWORD PTR 20[esp]
1023 xor ecx, ebp
1024 mov ebp, DWORD PTR 44[esp]
1025 xor ecx, ebp
1026 mov ebp, DWORD PTR [esp]
1027 ror esi, 1
1028 xor ecx, ebp
1029 rol ecx, 1
1030 mov ebp, edi
1031 mov DWORD PTR 12[esp],ecx
1032 or ebp, esi
1033 lea ecx, DWORD PTR 2400959708[ebx*1+ecx]
1034 mov ebx, edi
1035 and ebp, eax
1036 and ebx, esi
1037 or ebp, ebx
1038 mov ebx, edx
1039 rol ebx, 5
1040 ror edi, 1
1041 add ebp, ebx
1042 ror edi, 1
1043 add ecx, ebp
1044 ; 40_59 51
1045 ; 40_59 52
1046 mov ebx, DWORD PTR 16[esp]
1047 mov ebp, DWORD PTR 24[esp]
1048 xor ebx, ebp
1049 mov ebp, DWORD PTR 48[esp]
1050 xor ebx, ebp
1051 mov ebp, DWORD PTR 4[esp]
1052 xor ebx, ebp
1053 mov ebp, edx
1054 rol ebx, 1
1055 or ebp, edi
1056 mov DWORD PTR 16[esp],ebx
1057 and ebp, esi
1058 lea ebx, DWORD PTR 2400959708[eax*1+ebx]
1059 mov eax, edx
1060 ror edx, 1
1061 and eax, edi
1062 or ebp, eax
1063 mov eax, ecx
1064 rol eax, 5
1065 add ebp, eax
1066 mov eax, DWORD PTR 20[esp]
1067 add ebx, ebp
1068 mov ebp, DWORD PTR 28[esp]
1069 xor eax, ebp
1070 mov ebp, DWORD PTR 52[esp]
1071 xor eax, ebp
1072 mov ebp, DWORD PTR 8[esp]
1073 ror edx, 1
1074 xor eax, ebp
1075 rol eax, 1
1076 mov ebp, ecx
1077 mov DWORD PTR 20[esp],eax
1078 or ebp, edx
1079 lea eax, DWORD PTR 2400959708[esi*1+eax]
1080 mov esi, ecx
1081 and ebp, edi
1082 and esi, edx
1083 or ebp, esi
1084 mov esi, ebx
1085 rol esi, 5
1086 ror ecx, 1
1087 add ebp, esi
1088 ror ecx, 1
1089 add eax, ebp
1090 ; 40_59 53
1091 ; 40_59 54
1092 mov esi, DWORD PTR 24[esp]
1093 mov ebp, DWORD PTR 32[esp]
1094 xor esi, ebp
1095 mov ebp, DWORD PTR 56[esp]
1096 xor esi, ebp
1097 mov ebp, DWORD PTR 12[esp]
1098 xor esi, ebp
1099 mov ebp, ebx
1100 rol esi, 1
1101 or ebp, ecx
1102 mov DWORD PTR 24[esp],esi
1103 and ebp, edx
1104 lea esi, DWORD PTR 2400959708[edi*1+esi]
1105 mov edi, ebx
1106 ror ebx, 1
1107 and edi, ecx
1108 or ebp, edi
1109 mov edi, eax
1110 rol edi, 5
1111 add ebp, edi
1112 mov edi, DWORD PTR 28[esp]
1113 add esi, ebp
1114 mov ebp, DWORD PTR 36[esp]
1115 xor edi, ebp
1116 mov ebp, DWORD PTR 60[esp]
1117 xor edi, ebp
1118 mov ebp, DWORD PTR 16[esp]
1119 ror ebx, 1
1120 xor edi, ebp
1121 rol edi, 1
1122 mov ebp, eax
1123 mov DWORD PTR 28[esp],edi
1124 or ebp, ebx
1125 lea edi, DWORD PTR 2400959708[edx*1+edi]
1126 mov edx, eax
1127 and ebp, ecx
1128 and edx, ebx
1129 or ebp, edx
1130 mov edx, esi
1131 rol edx, 5
1132 ror eax, 1
1133 add ebp, edx
1134 ror eax, 1
1135 add edi, ebp
1136 ; 40_59 55
1137 ; 40_59 56
1138 mov edx, DWORD PTR 32[esp]
1139 mov ebp, DWORD PTR 40[esp]
1140 xor edx, ebp
1141 mov ebp, DWORD PTR [esp]
1142 xor edx, ebp
1143 mov ebp, DWORD PTR 20[esp]
1144 xor edx, ebp
1145 mov ebp, esi
1146 rol edx, 1
1147 or ebp, eax
1148 mov DWORD PTR 32[esp],edx
1149 and ebp, ebx
1150 lea edx, DWORD PTR 2400959708[ecx*1+edx]
1151 mov ecx, esi
1152 ror esi, 1
1153 and ecx, eax
1154 or ebp, ecx
1155 mov ecx, edi
1156 rol ecx, 5
1157 add ebp, ecx
1158 mov ecx, DWORD PTR 36[esp]
1159 add edx, ebp
1160 mov ebp, DWORD PTR 44[esp]
1161 xor ecx, ebp
1162 mov ebp, DWORD PTR 4[esp]
1163 xor ecx, ebp
1164 mov ebp, DWORD PTR 24[esp]
1165 ror esi, 1
1166 xor ecx, ebp
1167 rol ecx, 1
1168 mov ebp, edi
1169 mov DWORD PTR 36[esp],ecx
1170 or ebp, esi
1171 lea ecx, DWORD PTR 2400959708[ebx*1+ecx]
1172 mov ebx, edi
1173 and ebp, eax
1174 and ebx, esi
1175 or ebp, ebx
1176 mov ebx, edx
1177 rol ebx, 5
1178 ror edi, 1
1179 add ebp, ebx
1180 ror edi, 1
1181 add ecx, ebp
1182 ; 40_59 57
1183 ; 40_59 58
1184 mov ebx, DWORD PTR 40[esp]
1185 mov ebp, DWORD PTR 48[esp]
1186 xor ebx, ebp
1187 mov ebp, DWORD PTR 8[esp]
1188 xor ebx, ebp
1189 mov ebp, DWORD PTR 28[esp]
1190 xor ebx, ebp
1191 mov ebp, edx
1192 rol ebx, 1
1193 or ebp, edi
1194 mov DWORD PTR 40[esp],ebx
1195 and ebp, esi
1196 lea ebx, DWORD PTR 2400959708[eax*1+ebx]
1197 mov eax, edx
1198 ror edx, 1
1199 and eax, edi
1200 or ebp, eax
1201 mov eax, ecx
1202 rol eax, 5
1203 add ebp, eax
1204 mov eax, DWORD PTR 44[esp]
1205 add ebx, ebp
1206 mov ebp, DWORD PTR 52[esp]
1207 xor eax, ebp
1208 mov ebp, DWORD PTR 12[esp]
1209 xor eax, ebp
1210 mov ebp, DWORD PTR 32[esp]
1211 ror edx, 1
1212 xor eax, ebp
1213 rol eax, 1
1214 mov ebp, ecx
1215 mov DWORD PTR 44[esp],eax
1216 or ebp, edx
1217 lea eax, DWORD PTR 2400959708[esi*1+eax]
1218 mov esi, ecx
1219 and ebp, edi
1220 and esi, edx
1221 or ebp, esi
1222 mov esi, ebx
1223 rol esi, 5
1224 ror ecx, 1
1225 add ebp, esi
1226 ror ecx, 1
1227 add eax, ebp
1228 ; 40_59 59
1229 ; 20_39 60
1230 mov esi, DWORD PTR 48[esp]
1231 mov ebp, DWORD PTR 56[esp]
1232 xor esi, ebp
1233 mov ebp, DWORD PTR 16[esp]
1234 xor esi, ebp
1235 mov ebp, DWORD PTR 36[esp]
1236 xor esi, ebp
1237 mov ebp, ebx
1238 rol esi, 1
1239 xor ebp, ecx
1240 mov DWORD PTR 48[esp],esi
1241 xor ebp, edx
1242 lea esi, DWORD PTR 3395469782[edi*1+esi]
1243 mov edi, eax
1244 rol edi, 5
1245 ror ebx, 1
1246 add edi, ebp
1247 ror ebx, 1
1248 add esi, edi
1249 ; 20_39 61
1250 mov edi, DWORD PTR 52[esp]
1251 mov ebp, DWORD PTR 60[esp]
1252 xor edi, ebp
1253 mov ebp, DWORD PTR 20[esp]
1254 xor edi, ebp
1255 mov ebp, DWORD PTR 40[esp]
1256 xor edi, ebp
1257 mov ebp, eax
1258 rol edi, 1
1259 xor ebp, ebx
1260 mov DWORD PTR 52[esp],edi
1261 xor ebp, ecx
1262 lea edi, DWORD PTR 3395469782[edx*1+edi]
1263 mov edx, esi
1264 rol edx, 5
1265 ror eax, 1
1266 add edx, ebp
1267 ror eax, 1
1268 add edi, edx
1269 ; 20_39 62
1270 mov edx, DWORD PTR 56[esp]
1271 mov ebp, DWORD PTR [esp]
1272 xor edx, ebp
1273 mov ebp, DWORD PTR 24[esp]
1274 xor edx, ebp
1275 mov ebp, DWORD PTR 44[esp]
1276 xor edx, ebp
1277 mov ebp, esi
1278 rol edx, 1
1279 xor ebp, eax
1280 mov DWORD PTR 56[esp],edx
1281 xor ebp, ebx
1282 lea edx, DWORD PTR 3395469782[ecx*1+edx]
1283 mov ecx, edi
1284 rol ecx, 5
1285 ror esi, 1
1286 add ecx, ebp
1287 ror esi, 1
1288 add edx, ecx
1289 ; 20_39 63
1290 mov ecx, DWORD PTR 60[esp]
1291 mov ebp, DWORD PTR 4[esp]
1292 xor ecx, ebp
1293 mov ebp, DWORD PTR 28[esp]
1294 xor ecx, ebp
1295 mov ebp, DWORD PTR 48[esp]
1296 xor ecx, ebp
1297 mov ebp, edi
1298 rol ecx, 1
1299 xor ebp, esi
1300 mov DWORD PTR 60[esp],ecx
1301 xor ebp, eax
1302 lea ecx, DWORD PTR 3395469782[ebx*1+ecx]
1303 mov ebx, edx
1304 rol ebx, 5
1305 ror edi, 1
1306 add ebx, ebp
1307 ror edi, 1
1308 add ecx, ebx
1309 ; 20_39 64
1310 mov ebx, DWORD PTR [esp]
1311 mov ebp, DWORD PTR 8[esp]
1312 xor ebx, ebp
1313 mov ebp, DWORD PTR 32[esp]
1314 xor ebx, ebp
1315 mov ebp, DWORD PTR 52[esp]
1316 xor ebx, ebp
1317 mov ebp, edx
1318 rol ebx, 1
1319 xor ebp, edi
1320 mov DWORD PTR [esp],ebx
1321 xor ebp, esi
1322 lea ebx, DWORD PTR 3395469782[eax*1+ebx]
1323 mov eax, ecx
1324 rol eax, 5
1325 ror edx, 1
1326 add eax, ebp
1327 ror edx, 1
1328 add ebx, eax
1329 ; 20_39 65
1330 mov eax, DWORD PTR 4[esp]
1331 mov ebp, DWORD PTR 12[esp]
1332 xor eax, ebp
1333 mov ebp, DWORD PTR 36[esp]
1334 xor eax, ebp
1335 mov ebp, DWORD PTR 56[esp]
1336 xor eax, ebp
1337 mov ebp, ecx
1338 rol eax, 1
1339 xor ebp, edx
1340 mov DWORD PTR 4[esp],eax
1341 xor ebp, edi
1342 lea eax, DWORD PTR 3395469782[esi*1+eax]
1343 mov esi, ebx
1344 rol esi, 5
1345 ror ecx, 1
1346 add esi, ebp
1347 ror ecx, 1
1348 add eax, esi
1349 ; 20_39 66
1350 mov esi, DWORD PTR 8[esp]
1351 mov ebp, DWORD PTR 16[esp]
1352 xor esi, ebp
1353 mov ebp, DWORD PTR 40[esp]
1354 xor esi, ebp
1355 mov ebp, DWORD PTR 60[esp]
1356 xor esi, ebp
1357 mov ebp, ebx
1358 rol esi, 1
1359 xor ebp, ecx
1360 mov DWORD PTR 8[esp],esi
1361 xor ebp, edx
1362 lea esi, DWORD PTR 3395469782[edi*1+esi]
1363 mov edi, eax
1364 rol edi, 5
1365 ror ebx, 1
1366 add edi, ebp
1367 ror ebx, 1
1368 add esi, edi
1369 ; 20_39 67
1370 mov edi, DWORD PTR 12[esp]
1371 mov ebp, DWORD PTR 20[esp]
1372 xor edi, ebp
1373 mov ebp, DWORD PTR 44[esp]
1374 xor edi, ebp
1375 mov ebp, DWORD PTR [esp]
1376 xor edi, ebp
1377 mov ebp, eax
1378 rol edi, 1
1379 xor ebp, ebx
1380 mov DWORD PTR 12[esp],edi
1381 xor ebp, ecx
1382 lea edi, DWORD PTR 3395469782[edx*1+edi]
1383 mov edx, esi
1384 rol edx, 5
1385 ror eax, 1
1386 add edx, ebp
1387 ror eax, 1
1388 add edi, edx
1389 ; 20_39 68
1390 mov edx, DWORD PTR 16[esp]
1391 mov ebp, DWORD PTR 24[esp]
1392 xor edx, ebp
1393 mov ebp, DWORD PTR 48[esp]
1394 xor edx, ebp
1395 mov ebp, DWORD PTR 4[esp]
1396 xor edx, ebp
1397 mov ebp, esi
1398 rol edx, 1
1399 xor ebp, eax
1400 mov DWORD PTR 16[esp],edx
1401 xor ebp, ebx
1402 lea edx, DWORD PTR 3395469782[ecx*1+edx]
1403 mov ecx, edi
1404 rol ecx, 5
1405 ror esi, 1
1406 add ecx, ebp
1407 ror esi, 1
1408 add edx, ecx
1409 ; 20_39 69
1410 mov ecx, DWORD PTR 20[esp]
1411 mov ebp, DWORD PTR 28[esp]
1412 xor ecx, ebp
1413 mov ebp, DWORD PTR 52[esp]
1414 xor ecx, ebp
1415 mov ebp, DWORD PTR 8[esp]
1416 xor ecx, ebp
1417 mov ebp, edi
1418 rol ecx, 1
1419 xor ebp, esi
1420 mov DWORD PTR 20[esp],ecx
1421 xor ebp, eax
1422 lea ecx, DWORD PTR 3395469782[ebx*1+ecx]
1423 mov ebx, edx
1424 rol ebx, 5
1425 ror edi, 1
1426 add ebx, ebp
1427 ror edi, 1
1428 add ecx, ebx
1429 ; 20_39 70
1430 mov ebx, DWORD PTR 24[esp]
1431 mov ebp, DWORD PTR 32[esp]
1432 xor ebx, ebp
1433 mov ebp, DWORD PTR 56[esp]
1434 xor ebx, ebp
1435 mov ebp, DWORD PTR 12[esp]
1436 xor ebx, ebp
1437 mov ebp, edx
1438 rol ebx, 1
1439 xor ebp, edi
1440 mov DWORD PTR 24[esp],ebx
1441 xor ebp, esi
1442 lea ebx, DWORD PTR 3395469782[eax*1+ebx]
1443 mov eax, ecx
1444 rol eax, 5
1445 ror edx, 1
1446 add eax, ebp
1447 ror edx, 1
1448 add ebx, eax
1449 ; 20_39 71
1450 mov eax, DWORD PTR 28[esp]
1451 mov ebp, DWORD PTR 36[esp]
1452 xor eax, ebp
1453 mov ebp, DWORD PTR 60[esp]
1454 xor eax, ebp
1455 mov ebp, DWORD PTR 16[esp]
1456 xor eax, ebp
1457 mov ebp, ecx
1458 rol eax, 1
1459 xor ebp, edx
1460 mov DWORD PTR 28[esp],eax
1461 xor ebp, edi
1462 lea eax, DWORD PTR 3395469782[esi*1+eax]
1463 mov esi, ebx
1464 rol esi, 5
1465 ror ecx, 1
1466 add esi, ebp
1467 ror ecx, 1
1468 add eax, esi
1469 ; 20_39 72
1470 mov esi, DWORD PTR 32[esp]
1471 mov ebp, DWORD PTR 40[esp]
1472 xor esi, ebp
1473 mov ebp, DWORD PTR [esp]
1474 xor esi, ebp
1475 mov ebp, DWORD PTR 20[esp]
1476 xor esi, ebp
1477 mov ebp, ebx
1478 rol esi, 1
1479 xor ebp, ecx
1480 mov DWORD PTR 32[esp],esi
1481 xor ebp, edx
1482 lea esi, DWORD PTR 3395469782[edi*1+esi]
1483 mov edi, eax
1484 rol edi, 5
1485 ror ebx, 1
1486 add edi, ebp
1487 ror ebx, 1
1488 add esi, edi
1489 ; 20_39 73
1490 mov edi, DWORD PTR 36[esp]
1491 mov ebp, DWORD PTR 44[esp]
1492 xor edi, ebp
1493 mov ebp, DWORD PTR 4[esp]
1494 xor edi, ebp
1495 mov ebp, DWORD PTR 24[esp]
1496 xor edi, ebp
1497 mov ebp, eax
1498 rol edi, 1
1499 xor ebp, ebx
1500 mov DWORD PTR 36[esp],edi
1501 xor ebp, ecx
1502 lea edi, DWORD PTR 3395469782[edx*1+edi]
1503 mov edx, esi
1504 rol edx, 5
1505 ror eax, 1
1506 add edx, ebp
1507 ror eax, 1
1508 add edi, edx
1509 ; 20_39 74
1510 mov edx, DWORD PTR 40[esp]
1511 mov ebp, DWORD PTR 48[esp]
1512 xor edx, ebp
1513 mov ebp, DWORD PTR 8[esp]
1514 xor edx, ebp
1515 mov ebp, DWORD PTR 28[esp]
1516 xor edx, ebp
1517 mov ebp, esi
1518 rol edx, 1
1519 xor ebp, eax
1520 mov DWORD PTR 40[esp],edx
1521 xor ebp, ebx
1522 lea edx, DWORD PTR 3395469782[ecx*1+edx]
1523 mov ecx, edi
1524 rol ecx, 5
1525 ror esi, 1
1526 add ecx, ebp
1527 ror esi, 1
1528 add edx, ecx
1529 ; 20_39 75
1530 mov ecx, DWORD PTR 44[esp]
1531 mov ebp, DWORD PTR 52[esp]
1532 xor ecx, ebp
1533 mov ebp, DWORD PTR 12[esp]
1534 xor ecx, ebp
1535 mov ebp, DWORD PTR 32[esp]
1536 xor ecx, ebp
1537 mov ebp, edi
1538 rol ecx, 1
1539 xor ebp, esi
1540 mov DWORD PTR 44[esp],ecx
1541 xor ebp, eax
1542 lea ecx, DWORD PTR 3395469782[ebx*1+ecx]
1543 mov ebx, edx
1544 rol ebx, 5
1545 ror edi, 1
1546 add ebx, ebp
1547 ror edi, 1
1548 add ecx, ebx
1549 ; 20_39 76
1550 mov ebx, DWORD PTR 48[esp]
1551 mov ebp, DWORD PTR 56[esp]
1552 xor ebx, ebp
1553 mov ebp, DWORD PTR 16[esp]
1554 xor ebx, ebp
1555 mov ebp, DWORD PTR 36[esp]
1556 xor ebx, ebp
1557 mov ebp, edx
1558 rol ebx, 1
1559 xor ebp, edi
1560 mov DWORD PTR 48[esp],ebx
1561 xor ebp, esi
1562 lea ebx, DWORD PTR 3395469782[eax*1+ebx]
1563 mov eax, ecx
1564 rol eax, 5
1565 ror edx, 1
1566 add eax, ebp
1567 ror edx, 1
1568 add ebx, eax
1569 ; 20_39 77
1570 mov eax, DWORD PTR 52[esp]
1571 mov ebp, DWORD PTR 60[esp]
1572 xor eax, ebp
1573 mov ebp, DWORD PTR 20[esp]
1574 xor eax, ebp
1575 mov ebp, DWORD PTR 40[esp]
1576 xor eax, ebp
1577 mov ebp, ecx
1578 rol eax, 1
1579 xor ebp, edx
1580 mov DWORD PTR 52[esp],eax
1581 xor ebp, edi
1582 lea eax, DWORD PTR 3395469782[esi*1+eax]
1583 mov esi, ebx
1584 rol esi, 5
1585 ror ecx, 1
1586 add esi, ebp
1587 ror ecx, 1
1588 add eax, esi
1589 ; 20_39 78
1590 mov esi, DWORD PTR 56[esp]
1591 mov ebp, DWORD PTR [esp]
1592 xor esi, ebp
1593 mov ebp, DWORD PTR 24[esp]
1594 xor esi, ebp
1595 mov ebp, DWORD PTR 44[esp]
1596 xor esi, ebp
1597 mov ebp, ebx
1598 rol esi, 1
1599 xor ebp, ecx
1600 mov DWORD PTR 56[esp],esi
1601 xor ebp, edx
1602 lea esi, DWORD PTR 3395469782[edi*1+esi]
1603 mov edi, eax
1604 rol edi, 5
1605 ror ebx, 1
1606 add edi, ebp
1607 ror ebx, 1
1608 add esi, edi
1609 ; 20_39 79
1610 mov edi, DWORD PTR 60[esp]
1611 mov ebp, DWORD PTR 4[esp]
1612 xor edi, ebp
1613 mov ebp, DWORD PTR 28[esp]
1614 xor edi, ebp
1615 mov ebp, DWORD PTR 48[esp]
1616 xor edi, ebp
1617 mov ebp, eax
1618 rol edi, 1
1619 xor ebp, ebx
1620 mov DWORD PTR 60[esp],edi
1621 xor ebp, ecx
1622 lea edi, DWORD PTR 3395469782[edx*1+edi]
1623 mov edx, esi
1624 rol edx, 5
1625 add edx, ebp
1626 mov ebp, DWORD PTR 92[esp]
1627 ror eax, 1
1628 add edi, edx
1629 ror eax, 1
1630 ; End processing
1631 ;
1632 mov edx, DWORD PTR 12[ebp]
1633 add edx, ebx
1634 mov ebx, DWORD PTR 4[ebp]
1635 add ebx, esi
1636 mov esi, eax
1637 mov eax, DWORD PTR [ebp]
1638 mov DWORD PTR 12[ebp],edx
1639 add eax, edi
1640 mov edi, DWORD PTR 16[ebp]
1641 add edi, ecx
1642 mov ecx, DWORD PTR 8[ebp]
1643 add ecx, esi
1644 mov DWORD PTR [ebp],eax
1645 mov esi, DWORD PTR 64[esp]
1646 mov DWORD PTR 8[ebp],ecx
1647 add esi, 64
1648 mov eax, DWORD PTR 68[esp]
1649 mov DWORD PTR 16[ebp],edi
1650 cmp eax, esi
1651 mov DWORD PTR 4[ebp],ebx
1652 jl $L001end
1653 mov eax, DWORD PTR [esi]
1654 jmp L000start
1655$L001end:
1656 add esp, 72
1657 pop edi
1658 pop ebx
1659 pop ebp
1660 pop esi
1661 ret
1662_sha1_block_x86 ENDP
1663_TEXT ENDS
1664END
diff --git a/src/lib/libcrypto/sha/asm/sx86unix.cpp b/src/lib/libcrypto/sha/asm/sx86unix.cpp
new file mode 100644
index 0000000000..8366664a39
--- /dev/null
+++ b/src/lib/libcrypto/sha/asm/sx86unix.cpp
@@ -0,0 +1,1948 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define sha1_block_x86 _sha1_block_x86
13
14#endif
15
16#ifdef OUT
17#define OK 1
18#define ALIGN 4
19#endif
20
21#ifdef BSDI
22#define OK 1
23#define ALIGN 4
24#undef SIZE
25#undef TYPE
26#define SIZE(a,b)
27#define TYPE(a,b)
28#endif
29
30#if defined(ELF) || defined(SOL)
31#define OK 1
32#define ALIGN 16
33#endif
34
35#ifndef OK
36You need to define one of
37ELF - elf systems - linux-elf, NetBSD and DG-UX
38OUT - a.out systems - linux-a.out and FreeBSD
39SOL - solaris systems, which are elf with strange comment lines
40BSDI - a.out with a very primative version of as.
41#endif
42
43/* Let the Assembler begin :-) */
44 /* Don't even think of reading this code */
45 /* It was automatically generated by sha1-586.pl */
46 /* Which is a perl program used to generate the x86 assember for */
47 /* any of elf, a.out, BSDI,Win32, or Solaris */
48 /* eric <eay@cryptsoft.com> */
49
50 .file "sha1-586.s"
51 .version "01.01"
52gcc2_compiled.:
53.text
54 .align ALIGN
55.globl sha1_block_x86
56 TYPE(sha1_block_x86,@function)
57sha1_block_x86:
58 pushl %esi
59 pushl %ebp
60 movl 20(%esp), %eax
61 movl 16(%esp), %esi
62 addl %esi, %eax
63 movl 12(%esp), %ebp
64 pushl %ebx
65 subl $64, %eax
66 pushl %edi
67 movl 4(%ebp), %ebx
68 subl $72, %esp
69 movl 12(%ebp), %edx
70 movl 16(%ebp), %edi
71 movl 8(%ebp), %ecx
72 movl %eax, 68(%esp)
73 /* First we need to setup the X array */
74 movl (%esi), %eax
75.L000start:
76 /* First, load the words onto the stack in network byte order */
77.byte 15
78.byte 200 /* bswapl %eax */
79 movl %eax, (%esp)
80 movl 4(%esi), %eax
81.byte 15
82.byte 200 /* bswapl %eax */
83 movl %eax, 4(%esp)
84 movl 8(%esi), %eax
85.byte 15
86.byte 200 /* bswapl %eax */
87 movl %eax, 8(%esp)
88 movl 12(%esi), %eax
89.byte 15
90.byte 200 /* bswapl %eax */
91 movl %eax, 12(%esp)
92 movl 16(%esi), %eax
93.byte 15
94.byte 200 /* bswapl %eax */
95 movl %eax, 16(%esp)
96 movl 20(%esi), %eax
97.byte 15
98.byte 200 /* bswapl %eax */
99 movl %eax, 20(%esp)
100 movl 24(%esi), %eax
101.byte 15
102.byte 200 /* bswapl %eax */
103 movl %eax, 24(%esp)
104 movl 28(%esi), %eax
105.byte 15
106.byte 200 /* bswapl %eax */
107 movl %eax, 28(%esp)
108 movl 32(%esi), %eax
109.byte 15
110.byte 200 /* bswapl %eax */
111 movl %eax, 32(%esp)
112 movl 36(%esi), %eax
113.byte 15
114.byte 200 /* bswapl %eax */
115 movl %eax, 36(%esp)
116 movl 40(%esi), %eax
117.byte 15
118.byte 200 /* bswapl %eax */
119 movl %eax, 40(%esp)
120 movl 44(%esi), %eax
121.byte 15
122.byte 200 /* bswapl %eax */
123 movl %eax, 44(%esp)
124 movl 48(%esi), %eax
125.byte 15
126.byte 200 /* bswapl %eax */
127 movl %eax, 48(%esp)
128 movl 52(%esi), %eax
129.byte 15
130.byte 200 /* bswapl %eax */
131 movl %eax, 52(%esp)
132 movl 56(%esi), %eax
133.byte 15
134.byte 200 /* bswapl %eax */
135 movl %eax, 56(%esp)
136 movl 60(%esi), %eax
137.byte 15
138.byte 200 /* bswapl %eax */
139 movl %eax, 60(%esp)
140 /* We now have the X array on the stack */
141 /* starting at sp-4 */
142 movl %esi, 64(%esp)
143
144 /* Start processing */
145 movl (%ebp), %eax
146 /* 00_15 0 */
147 movl %ecx, %esi
148 movl %eax, %ebp
149 xorl %edx, %esi
150 roll $5, %ebp
151 andl %ebx, %esi
152 addl %edi, %ebp
153.byte 209
154.byte 203 /* rorl $1 %ebx */
155 movl (%esp), %edi
156.byte 209
157.byte 203 /* rorl $1 %ebx */
158 xorl %edx, %esi
159 leal 1518500249(%ebp,%edi,1),%ebp
160 movl %ebx, %edi
161 addl %ebp, %esi
162 xorl %ecx, %edi
163 movl %esi, %ebp
164 andl %eax, %edi
165 roll $5, %ebp
166 addl %edx, %ebp
167 movl 4(%esp), %edx
168.byte 209
169.byte 200 /* rorl $1 %eax */
170 xorl %ecx, %edi
171.byte 209
172.byte 200 /* rorl $1 %eax */
173 leal 1518500249(%ebp,%edx,1),%ebp
174 addl %ebp, %edi
175 /* 00_15 2 */
176 movl %eax, %edx
177 movl %edi, %ebp
178 xorl %ebx, %edx
179 roll $5, %ebp
180 andl %esi, %edx
181 addl %ecx, %ebp
182.byte 209
183.byte 206 /* rorl $1 %esi */
184 movl 8(%esp), %ecx
185.byte 209
186.byte 206 /* rorl $1 %esi */
187 xorl %ebx, %edx
188 leal 1518500249(%ebp,%ecx,1),%ebp
189 movl %esi, %ecx
190 addl %ebp, %edx
191 xorl %eax, %ecx
192 movl %edx, %ebp
193 andl %edi, %ecx
194 roll $5, %ebp
195 addl %ebx, %ebp
196 movl 12(%esp), %ebx
197.byte 209
198.byte 207 /* rorl $1 %edi */
199 xorl %eax, %ecx
200.byte 209
201.byte 207 /* rorl $1 %edi */
202 leal 1518500249(%ebp,%ebx,1),%ebp
203 addl %ebp, %ecx
204 /* 00_15 4 */
205 movl %edi, %ebx
206 movl %ecx, %ebp
207 xorl %esi, %ebx
208 roll $5, %ebp
209 andl %edx, %ebx
210 addl %eax, %ebp
211.byte 209
212.byte 202 /* rorl $1 %edx */
213 movl 16(%esp), %eax
214.byte 209
215.byte 202 /* rorl $1 %edx */
216 xorl %esi, %ebx
217 leal 1518500249(%ebp,%eax,1),%ebp
218 movl %edx, %eax
219 addl %ebp, %ebx
220 xorl %edi, %eax
221 movl %ebx, %ebp
222 andl %ecx, %eax
223 roll $5, %ebp
224 addl %esi, %ebp
225 movl 20(%esp), %esi
226.byte 209
227.byte 201 /* rorl $1 %ecx */
228 xorl %edi, %eax
229.byte 209
230.byte 201 /* rorl $1 %ecx */
231 leal 1518500249(%ebp,%esi,1),%ebp
232 addl %ebp, %eax
233 /* 00_15 6 */
234 movl %ecx, %esi
235 movl %eax, %ebp
236 xorl %edx, %esi
237 roll $5, %ebp
238 andl %ebx, %esi
239 addl %edi, %ebp
240.byte 209
241.byte 203 /* rorl $1 %ebx */
242 movl 24(%esp), %edi
243.byte 209
244.byte 203 /* rorl $1 %ebx */
245 xorl %edx, %esi
246 leal 1518500249(%ebp,%edi,1),%ebp
247 movl %ebx, %edi
248 addl %ebp, %esi
249 xorl %ecx, %edi
250 movl %esi, %ebp
251 andl %eax, %edi
252 roll $5, %ebp
253 addl %edx, %ebp
254 movl 28(%esp), %edx
255.byte 209
256.byte 200 /* rorl $1 %eax */
257 xorl %ecx, %edi
258.byte 209
259.byte 200 /* rorl $1 %eax */
260 leal 1518500249(%ebp,%edx,1),%ebp
261 addl %ebp, %edi
262 /* 00_15 8 */
263 movl %eax, %edx
264 movl %edi, %ebp
265 xorl %ebx, %edx
266 roll $5, %ebp
267 andl %esi, %edx
268 addl %ecx, %ebp
269.byte 209
270.byte 206 /* rorl $1 %esi */
271 movl 32(%esp), %ecx
272.byte 209
273.byte 206 /* rorl $1 %esi */
274 xorl %ebx, %edx
275 leal 1518500249(%ebp,%ecx,1),%ebp
276 movl %esi, %ecx
277 addl %ebp, %edx
278 xorl %eax, %ecx
279 movl %edx, %ebp
280 andl %edi, %ecx
281 roll $5, %ebp
282 addl %ebx, %ebp
283 movl 36(%esp), %ebx
284.byte 209
285.byte 207 /* rorl $1 %edi */
286 xorl %eax, %ecx
287.byte 209
288.byte 207 /* rorl $1 %edi */
289 leal 1518500249(%ebp,%ebx,1),%ebp
290 addl %ebp, %ecx
291 /* 00_15 10 */
292 movl %edi, %ebx
293 movl %ecx, %ebp
294 xorl %esi, %ebx
295 roll $5, %ebp
296 andl %edx, %ebx
297 addl %eax, %ebp
298.byte 209
299.byte 202 /* rorl $1 %edx */
300 movl 40(%esp), %eax
301.byte 209
302.byte 202 /* rorl $1 %edx */
303 xorl %esi, %ebx
304 leal 1518500249(%ebp,%eax,1),%ebp
305 movl %edx, %eax
306 addl %ebp, %ebx
307 xorl %edi, %eax
308 movl %ebx, %ebp
309 andl %ecx, %eax
310 roll $5, %ebp
311 addl %esi, %ebp
312 movl 44(%esp), %esi
313.byte 209
314.byte 201 /* rorl $1 %ecx */
315 xorl %edi, %eax
316.byte 209
317.byte 201 /* rorl $1 %ecx */
318 leal 1518500249(%ebp,%esi,1),%ebp
319 addl %ebp, %eax
320 /* 00_15 12 */
321 movl %ecx, %esi
322 movl %eax, %ebp
323 xorl %edx, %esi
324 roll $5, %ebp
325 andl %ebx, %esi
326 addl %edi, %ebp
327.byte 209
328.byte 203 /* rorl $1 %ebx */
329 movl 48(%esp), %edi
330.byte 209
331.byte 203 /* rorl $1 %ebx */
332 xorl %edx, %esi
333 leal 1518500249(%ebp,%edi,1),%ebp
334 movl %ebx, %edi
335 addl %ebp, %esi
336 xorl %ecx, %edi
337 movl %esi, %ebp
338 andl %eax, %edi
339 roll $5, %ebp
340 addl %edx, %ebp
341 movl 52(%esp), %edx
342.byte 209
343.byte 200 /* rorl $1 %eax */
344 xorl %ecx, %edi
345.byte 209
346.byte 200 /* rorl $1 %eax */
347 leal 1518500249(%ebp,%edx,1),%ebp
348 addl %ebp, %edi
349 /* 00_15 14 */
350 movl %eax, %edx
351 movl %edi, %ebp
352 xorl %ebx, %edx
353 roll $5, %ebp
354 andl %esi, %edx
355 addl %ecx, %ebp
356.byte 209
357.byte 206 /* rorl $1 %esi */
358 movl 56(%esp), %ecx
359.byte 209
360.byte 206 /* rorl $1 %esi */
361 xorl %ebx, %edx
362 leal 1518500249(%ebp,%ecx,1),%ebp
363 movl %esi, %ecx
364 addl %ebp, %edx
365 xorl %eax, %ecx
366 movl %edx, %ebp
367 andl %edi, %ecx
368 roll $5, %ebp
369 addl %ebx, %ebp
370 movl 60(%esp), %ebx
371.byte 209
372.byte 207 /* rorl $1 %edi */
373 xorl %eax, %ecx
374.byte 209
375.byte 207 /* rorl $1 %edi */
376 leal 1518500249(%ebp,%ebx,1),%ebp
377 addl %ebp, %ecx
378 /* 16_19 16 */
379 nop
380 movl (%esp), %ebp
381 movl 8(%esp), %ebx
382 xorl %ebp, %ebx
383 movl 32(%esp), %ebp
384 xorl %ebp, %ebx
385 movl 52(%esp), %ebp
386 xorl %ebp, %ebx
387 movl %edi, %ebp
388.byte 209
389.byte 195 /* roll $1 %ebx */
390 xorl %esi, %ebp
391 movl %ebx, (%esp)
392 andl %edx, %ebp
393 leal 1518500249(%ebx,%eax,1),%ebx
394 xorl %esi, %ebp
395 movl %ecx, %eax
396 addl %ebp, %ebx
397 roll $5, %eax
398.byte 209
399.byte 202 /* rorl $1 %edx */
400 addl %eax, %ebx
401 movl 4(%esp), %eax
402 movl 12(%esp), %ebp
403 xorl %ebp, %eax
404 movl 36(%esp), %ebp
405 xorl %ebp, %eax
406 movl 56(%esp), %ebp
407.byte 209
408.byte 202 /* rorl $1 %edx */
409 xorl %ebp, %eax
410.byte 209
411.byte 192 /* roll $1 %eax */
412 movl %edx, %ebp
413 xorl %edi, %ebp
414 movl %eax, 4(%esp)
415 andl %ecx, %ebp
416 leal 1518500249(%eax,%esi,1),%eax
417 xorl %edi, %ebp
418 movl %ebx, %esi
419 roll $5, %esi
420.byte 209
421.byte 201 /* rorl $1 %ecx */
422 addl %esi, %eax
423.byte 209
424.byte 201 /* rorl $1 %ecx */
425 addl %ebp, %eax
426 /* 16_19 18 */
427 movl 8(%esp), %ebp
428 movl 16(%esp), %esi
429 xorl %ebp, %esi
430 movl 40(%esp), %ebp
431 xorl %ebp, %esi
432 movl 60(%esp), %ebp
433 xorl %ebp, %esi
434 movl %ecx, %ebp
435.byte 209
436.byte 198 /* roll $1 %esi */
437 xorl %edx, %ebp
438 movl %esi, 8(%esp)
439 andl %ebx, %ebp
440 leal 1518500249(%esi,%edi,1),%esi
441 xorl %edx, %ebp
442 movl %eax, %edi
443 addl %ebp, %esi
444 roll $5, %edi
445.byte 209
446.byte 203 /* rorl $1 %ebx */
447 addl %edi, %esi
448 movl 12(%esp), %edi
449 movl 20(%esp), %ebp
450 xorl %ebp, %edi
451 movl 44(%esp), %ebp
452 xorl %ebp, %edi
453 movl (%esp), %ebp
454.byte 209
455.byte 203 /* rorl $1 %ebx */
456 xorl %ebp, %edi
457.byte 209
458.byte 199 /* roll $1 %edi */
459 movl %ebx, %ebp
460 xorl %ecx, %ebp
461 movl %edi, 12(%esp)
462 andl %eax, %ebp
463 leal 1518500249(%edi,%edx,1),%edi
464 xorl %ecx, %ebp
465 movl %esi, %edx
466 roll $5, %edx
467.byte 209
468.byte 200 /* rorl $1 %eax */
469 addl %edx, %edi
470.byte 209
471.byte 200 /* rorl $1 %eax */
472 addl %ebp, %edi
473 /* 20_39 20 */
474 movl 16(%esp), %edx
475 movl 24(%esp), %ebp
476 xorl %ebp, %edx
477 movl 48(%esp), %ebp
478 xorl %ebp, %edx
479 movl 4(%esp), %ebp
480 xorl %ebp, %edx
481 movl %esi, %ebp
482.byte 209
483.byte 194 /* roll $1 %edx */
484 xorl %eax, %ebp
485 movl %edx, 16(%esp)
486 xorl %ebx, %ebp
487 leal 1859775393(%edx,%ecx,1),%edx
488 movl %edi, %ecx
489 roll $5, %ecx
490.byte 209
491.byte 206 /* rorl $1 %esi */
492 addl %ebp, %ecx
493.byte 209
494.byte 206 /* rorl $1 %esi */
495 addl %ecx, %edx
496 /* 20_39 21 */
497 movl 20(%esp), %ecx
498 movl 28(%esp), %ebp
499 xorl %ebp, %ecx
500 movl 52(%esp), %ebp
501 xorl %ebp, %ecx
502 movl 8(%esp), %ebp
503 xorl %ebp, %ecx
504 movl %edi, %ebp
505.byte 209
506.byte 193 /* roll $1 %ecx */
507 xorl %esi, %ebp
508 movl %ecx, 20(%esp)
509 xorl %eax, %ebp
510 leal 1859775393(%ecx,%ebx,1),%ecx
511 movl %edx, %ebx
512 roll $5, %ebx
513.byte 209
514.byte 207 /* rorl $1 %edi */
515 addl %ebp, %ebx
516.byte 209
517.byte 207 /* rorl $1 %edi */
518 addl %ebx, %ecx
519 /* 20_39 22 */
520 movl 24(%esp), %ebx
521 movl 32(%esp), %ebp
522 xorl %ebp, %ebx
523 movl 56(%esp), %ebp
524 xorl %ebp, %ebx
525 movl 12(%esp), %ebp
526 xorl %ebp, %ebx
527 movl %edx, %ebp
528.byte 209
529.byte 195 /* roll $1 %ebx */
530 xorl %edi, %ebp
531 movl %ebx, 24(%esp)
532 xorl %esi, %ebp
533 leal 1859775393(%ebx,%eax,1),%ebx
534 movl %ecx, %eax
535 roll $5, %eax
536.byte 209
537.byte 202 /* rorl $1 %edx */
538 addl %ebp, %eax
539.byte 209
540.byte 202 /* rorl $1 %edx */
541 addl %eax, %ebx
542 /* 20_39 23 */
543 movl 28(%esp), %eax
544 movl 36(%esp), %ebp
545 xorl %ebp, %eax
546 movl 60(%esp), %ebp
547 xorl %ebp, %eax
548 movl 16(%esp), %ebp
549 xorl %ebp, %eax
550 movl %ecx, %ebp
551.byte 209
552.byte 192 /* roll $1 %eax */
553 xorl %edx, %ebp
554 movl %eax, 28(%esp)
555 xorl %edi, %ebp
556 leal 1859775393(%eax,%esi,1),%eax
557 movl %ebx, %esi
558 roll $5, %esi
559.byte 209
560.byte 201 /* rorl $1 %ecx */
561 addl %ebp, %esi
562.byte 209
563.byte 201 /* rorl $1 %ecx */
564 addl %esi, %eax
565 /* 20_39 24 */
566 movl 32(%esp), %esi
567 movl 40(%esp), %ebp
568 xorl %ebp, %esi
569 movl (%esp), %ebp
570 xorl %ebp, %esi
571 movl 20(%esp), %ebp
572 xorl %ebp, %esi
573 movl %ebx, %ebp
574.byte 209
575.byte 198 /* roll $1 %esi */
576 xorl %ecx, %ebp
577 movl %esi, 32(%esp)
578 xorl %edx, %ebp
579 leal 1859775393(%esi,%edi,1),%esi
580 movl %eax, %edi
581 roll $5, %edi
582.byte 209
583.byte 203 /* rorl $1 %ebx */
584 addl %ebp, %edi
585.byte 209
586.byte 203 /* rorl $1 %ebx */
587 addl %edi, %esi
588 /* 20_39 25 */
589 movl 36(%esp), %edi
590 movl 44(%esp), %ebp
591 xorl %ebp, %edi
592 movl 4(%esp), %ebp
593 xorl %ebp, %edi
594 movl 24(%esp), %ebp
595 xorl %ebp, %edi
596 movl %eax, %ebp
597.byte 209
598.byte 199 /* roll $1 %edi */
599 xorl %ebx, %ebp
600 movl %edi, 36(%esp)
601 xorl %ecx, %ebp
602 leal 1859775393(%edi,%edx,1),%edi
603 movl %esi, %edx
604 roll $5, %edx
605.byte 209
606.byte 200 /* rorl $1 %eax */
607 addl %ebp, %edx
608.byte 209
609.byte 200 /* rorl $1 %eax */
610 addl %edx, %edi
611 /* 20_39 26 */
612 movl 40(%esp), %edx
613 movl 48(%esp), %ebp
614 xorl %ebp, %edx
615 movl 8(%esp), %ebp
616 xorl %ebp, %edx
617 movl 28(%esp), %ebp
618 xorl %ebp, %edx
619 movl %esi, %ebp
620.byte 209
621.byte 194 /* roll $1 %edx */
622 xorl %eax, %ebp
623 movl %edx, 40(%esp)
624 xorl %ebx, %ebp
625 leal 1859775393(%edx,%ecx,1),%edx
626 movl %edi, %ecx
627 roll $5, %ecx
628.byte 209
629.byte 206 /* rorl $1 %esi */
630 addl %ebp, %ecx
631.byte 209
632.byte 206 /* rorl $1 %esi */
633 addl %ecx, %edx
634 /* 20_39 27 */
635 movl 44(%esp), %ecx
636 movl 52(%esp), %ebp
637 xorl %ebp, %ecx
638 movl 12(%esp), %ebp
639 xorl %ebp, %ecx
640 movl 32(%esp), %ebp
641 xorl %ebp, %ecx
642 movl %edi, %ebp
643.byte 209
644.byte 193 /* roll $1 %ecx */
645 xorl %esi, %ebp
646 movl %ecx, 44(%esp)
647 xorl %eax, %ebp
648 leal 1859775393(%ecx,%ebx,1),%ecx
649 movl %edx, %ebx
650 roll $5, %ebx
651.byte 209
652.byte 207 /* rorl $1 %edi */
653 addl %ebp, %ebx
654.byte 209
655.byte 207 /* rorl $1 %edi */
656 addl %ebx, %ecx
657 /* 20_39 28 */
658 movl 48(%esp), %ebx
659 movl 56(%esp), %ebp
660 xorl %ebp, %ebx
661 movl 16(%esp), %ebp
662 xorl %ebp, %ebx
663 movl 36(%esp), %ebp
664 xorl %ebp, %ebx
665 movl %edx, %ebp
666.byte 209
667.byte 195 /* roll $1 %ebx */
668 xorl %edi, %ebp
669 movl %ebx, 48(%esp)
670 xorl %esi, %ebp
671 leal 1859775393(%ebx,%eax,1),%ebx
672 movl %ecx, %eax
673 roll $5, %eax
674.byte 209
675.byte 202 /* rorl $1 %edx */
676 addl %ebp, %eax
677.byte 209
678.byte 202 /* rorl $1 %edx */
679 addl %eax, %ebx
680 /* 20_39 29 */
681 movl 52(%esp), %eax
682 movl 60(%esp), %ebp
683 xorl %ebp, %eax
684 movl 20(%esp), %ebp
685 xorl %ebp, %eax
686 movl 40(%esp), %ebp
687 xorl %ebp, %eax
688 movl %ecx, %ebp
689.byte 209
690.byte 192 /* roll $1 %eax */
691 xorl %edx, %ebp
692 movl %eax, 52(%esp)
693 xorl %edi, %ebp
694 leal 1859775393(%eax,%esi,1),%eax
695 movl %ebx, %esi
696 roll $5, %esi
697.byte 209
698.byte 201 /* rorl $1 %ecx */
699 addl %ebp, %esi
700.byte 209
701.byte 201 /* rorl $1 %ecx */
702 addl %esi, %eax
703 /* 20_39 30 */
704 movl 56(%esp), %esi
705 movl (%esp), %ebp
706 xorl %ebp, %esi
707 movl 24(%esp), %ebp
708 xorl %ebp, %esi
709 movl 44(%esp), %ebp
710 xorl %ebp, %esi
711 movl %ebx, %ebp
712.byte 209
713.byte 198 /* roll $1 %esi */
714 xorl %ecx, %ebp
715 movl %esi, 56(%esp)
716 xorl %edx, %ebp
717 leal 1859775393(%esi,%edi,1),%esi
718 movl %eax, %edi
719 roll $5, %edi
720.byte 209
721.byte 203 /* rorl $1 %ebx */
722 addl %ebp, %edi
723.byte 209
724.byte 203 /* rorl $1 %ebx */
725 addl %edi, %esi
726 /* 20_39 31 */
727 movl 60(%esp), %edi
728 movl 4(%esp), %ebp
729 xorl %ebp, %edi
730 movl 28(%esp), %ebp
731 xorl %ebp, %edi
732 movl 48(%esp), %ebp
733 xorl %ebp, %edi
734 movl %eax, %ebp
735.byte 209
736.byte 199 /* roll $1 %edi */
737 xorl %ebx, %ebp
738 movl %edi, 60(%esp)
739 xorl %ecx, %ebp
740 leal 1859775393(%edi,%edx,1),%edi
741 movl %esi, %edx
742 roll $5, %edx
743.byte 209
744.byte 200 /* rorl $1 %eax */
745 addl %ebp, %edx
746.byte 209
747.byte 200 /* rorl $1 %eax */
748 addl %edx, %edi
749 /* 20_39 32 */
750 movl (%esp), %edx
751 movl 8(%esp), %ebp
752 xorl %ebp, %edx
753 movl 32(%esp), %ebp
754 xorl %ebp, %edx
755 movl 52(%esp), %ebp
756 xorl %ebp, %edx
757 movl %esi, %ebp
758.byte 209
759.byte 194 /* roll $1 %edx */
760 xorl %eax, %ebp
761 movl %edx, (%esp)
762 xorl %ebx, %ebp
763 leal 1859775393(%edx,%ecx,1),%edx
764 movl %edi, %ecx
765 roll $5, %ecx
766.byte 209
767.byte 206 /* rorl $1 %esi */
768 addl %ebp, %ecx
769.byte 209
770.byte 206 /* rorl $1 %esi */
771 addl %ecx, %edx
772 /* 20_39 33 */
773 movl 4(%esp), %ecx
774 movl 12(%esp), %ebp
775 xorl %ebp, %ecx
776 movl 36(%esp), %ebp
777 xorl %ebp, %ecx
778 movl 56(%esp), %ebp
779 xorl %ebp, %ecx
780 movl %edi, %ebp
781.byte 209
782.byte 193 /* roll $1 %ecx */
783 xorl %esi, %ebp
784 movl %ecx, 4(%esp)
785 xorl %eax, %ebp
786 leal 1859775393(%ecx,%ebx,1),%ecx
787 movl %edx, %ebx
788 roll $5, %ebx
789.byte 209
790.byte 207 /* rorl $1 %edi */
791 addl %ebp, %ebx
792.byte 209
793.byte 207 /* rorl $1 %edi */
794 addl %ebx, %ecx
795 /* 20_39 34 */
796 movl 8(%esp), %ebx
797 movl 16(%esp), %ebp
798 xorl %ebp, %ebx
799 movl 40(%esp), %ebp
800 xorl %ebp, %ebx
801 movl 60(%esp), %ebp
802 xorl %ebp, %ebx
803 movl %edx, %ebp
804.byte 209
805.byte 195 /* roll $1 %ebx */
806 xorl %edi, %ebp
807 movl %ebx, 8(%esp)
808 xorl %esi, %ebp
809 leal 1859775393(%ebx,%eax,1),%ebx
810 movl %ecx, %eax
811 roll $5, %eax
812.byte 209
813.byte 202 /* rorl $1 %edx */
814 addl %ebp, %eax
815.byte 209
816.byte 202 /* rorl $1 %edx */
817 addl %eax, %ebx
818 /* 20_39 35 */
819 movl 12(%esp), %eax
820 movl 20(%esp), %ebp
821 xorl %ebp, %eax
822 movl 44(%esp), %ebp
823 xorl %ebp, %eax
824 movl (%esp), %ebp
825 xorl %ebp, %eax
826 movl %ecx, %ebp
827.byte 209
828.byte 192 /* roll $1 %eax */
829 xorl %edx, %ebp
830 movl %eax, 12(%esp)
831 xorl %edi, %ebp
832 leal 1859775393(%eax,%esi,1),%eax
833 movl %ebx, %esi
834 roll $5, %esi
835.byte 209
836.byte 201 /* rorl $1 %ecx */
837 addl %ebp, %esi
838.byte 209
839.byte 201 /* rorl $1 %ecx */
840 addl %esi, %eax
841 /* 20_39 36 */
842 movl 16(%esp), %esi
843 movl 24(%esp), %ebp
844 xorl %ebp, %esi
845 movl 48(%esp), %ebp
846 xorl %ebp, %esi
847 movl 4(%esp), %ebp
848 xorl %ebp, %esi
849 movl %ebx, %ebp
850.byte 209
851.byte 198 /* roll $1 %esi */
852 xorl %ecx, %ebp
853 movl %esi, 16(%esp)
854 xorl %edx, %ebp
855 leal 1859775393(%esi,%edi,1),%esi
856 movl %eax, %edi
857 roll $5, %edi
858.byte 209
859.byte 203 /* rorl $1 %ebx */
860 addl %ebp, %edi
861.byte 209
862.byte 203 /* rorl $1 %ebx */
863 addl %edi, %esi
864 /* 20_39 37 */
865 movl 20(%esp), %edi
866 movl 28(%esp), %ebp
867 xorl %ebp, %edi
868 movl 52(%esp), %ebp
869 xorl %ebp, %edi
870 movl 8(%esp), %ebp
871 xorl %ebp, %edi
872 movl %eax, %ebp
873.byte 209
874.byte 199 /* roll $1 %edi */
875 xorl %ebx, %ebp
876 movl %edi, 20(%esp)
877 xorl %ecx, %ebp
878 leal 1859775393(%edi,%edx,1),%edi
879 movl %esi, %edx
880 roll $5, %edx
881.byte 209
882.byte 200 /* rorl $1 %eax */
883 addl %ebp, %edx
884.byte 209
885.byte 200 /* rorl $1 %eax */
886 addl %edx, %edi
887 /* 20_39 38 */
888 movl 24(%esp), %edx
889 movl 32(%esp), %ebp
890 xorl %ebp, %edx
891 movl 56(%esp), %ebp
892 xorl %ebp, %edx
893 movl 12(%esp), %ebp
894 xorl %ebp, %edx
895 movl %esi, %ebp
896.byte 209
897.byte 194 /* roll $1 %edx */
898 xorl %eax, %ebp
899 movl %edx, 24(%esp)
900 xorl %ebx, %ebp
901 leal 1859775393(%edx,%ecx,1),%edx
902 movl %edi, %ecx
903 roll $5, %ecx
904.byte 209
905.byte 206 /* rorl $1 %esi */
906 addl %ebp, %ecx
907.byte 209
908.byte 206 /* rorl $1 %esi */
909 addl %ecx, %edx
910 /* 20_39 39 */
911 movl 28(%esp), %ecx
912 movl 36(%esp), %ebp
913 xorl %ebp, %ecx
914 movl 60(%esp), %ebp
915 xorl %ebp, %ecx
916 movl 16(%esp), %ebp
917 xorl %ebp, %ecx
918 movl %edi, %ebp
919.byte 209
920.byte 193 /* roll $1 %ecx */
921 xorl %esi, %ebp
922 movl %ecx, 28(%esp)
923 xorl %eax, %ebp
924 leal 1859775393(%ecx,%ebx,1),%ecx
925 movl %edx, %ebx
926 roll $5, %ebx
927.byte 209
928.byte 207 /* rorl $1 %edi */
929 addl %ebp, %ebx
930.byte 209
931.byte 207 /* rorl $1 %edi */
932 addl %ebx, %ecx
933 /* 40_59 40 */
934 movl 32(%esp), %ebx
935 movl 40(%esp), %ebp
936 xorl %ebp, %ebx
937 movl (%esp), %ebp
938 xorl %ebp, %ebx
939 movl 20(%esp), %ebp
940 xorl %ebp, %ebx
941 movl %edx, %ebp
942.byte 209
943.byte 195 /* roll $1 %ebx */
944 orl %edi, %ebp
945 movl %ebx, 32(%esp)
946 andl %esi, %ebp
947 leal 2400959708(%ebx,%eax,1),%ebx
948 movl %edx, %eax
949.byte 209
950.byte 202 /* rorl $1 %edx */
951 andl %edi, %eax
952 orl %eax, %ebp
953 movl %ecx, %eax
954 roll $5, %eax
955 addl %eax, %ebp
956 movl 36(%esp), %eax
957 addl %ebp, %ebx
958 movl 44(%esp), %ebp
959 xorl %ebp, %eax
960 movl 4(%esp), %ebp
961 xorl %ebp, %eax
962 movl 24(%esp), %ebp
963.byte 209
964.byte 202 /* rorl $1 %edx */
965 xorl %ebp, %eax
966.byte 209
967.byte 192 /* roll $1 %eax */
968 movl %ecx, %ebp
969 movl %eax, 36(%esp)
970 orl %edx, %ebp
971 leal 2400959708(%eax,%esi,1),%eax
972 movl %ecx, %esi
973 andl %edi, %ebp
974 andl %edx, %esi
975 orl %esi, %ebp
976 movl %ebx, %esi
977 roll $5, %esi
978.byte 209
979.byte 201 /* rorl $1 %ecx */
980 addl %esi, %ebp
981.byte 209
982.byte 201 /* rorl $1 %ecx */
983 addl %ebp, %eax
984 /* 40_59 41 */
985 /* 40_59 42 */
986 movl 40(%esp), %esi
987 movl 48(%esp), %ebp
988 xorl %ebp, %esi
989 movl 8(%esp), %ebp
990 xorl %ebp, %esi
991 movl 28(%esp), %ebp
992 xorl %ebp, %esi
993 movl %ebx, %ebp
994.byte 209
995.byte 198 /* roll $1 %esi */
996 orl %ecx, %ebp
997 movl %esi, 40(%esp)
998 andl %edx, %ebp
999 leal 2400959708(%esi,%edi,1),%esi
1000 movl %ebx, %edi
1001.byte 209
1002.byte 203 /* rorl $1 %ebx */
1003 andl %ecx, %edi
1004 orl %edi, %ebp
1005 movl %eax, %edi
1006 roll $5, %edi
1007 addl %edi, %ebp
1008 movl 44(%esp), %edi
1009 addl %ebp, %esi
1010 movl 52(%esp), %ebp
1011 xorl %ebp, %edi
1012 movl 12(%esp), %ebp
1013 xorl %ebp, %edi
1014 movl 32(%esp), %ebp
1015.byte 209
1016.byte 203 /* rorl $1 %ebx */
1017 xorl %ebp, %edi
1018.byte 209
1019.byte 199 /* roll $1 %edi */
1020 movl %eax, %ebp
1021 movl %edi, 44(%esp)
1022 orl %ebx, %ebp
1023 leal 2400959708(%edi,%edx,1),%edi
1024 movl %eax, %edx
1025 andl %ecx, %ebp
1026 andl %ebx, %edx
1027 orl %edx, %ebp
1028 movl %esi, %edx
1029 roll $5, %edx
1030.byte 209
1031.byte 200 /* rorl $1 %eax */
1032 addl %edx, %ebp
1033.byte 209
1034.byte 200 /* rorl $1 %eax */
1035 addl %ebp, %edi
1036 /* 40_59 43 */
1037 /* 40_59 44 */
1038 movl 48(%esp), %edx
1039 movl 56(%esp), %ebp
1040 xorl %ebp, %edx
1041 movl 16(%esp), %ebp
1042 xorl %ebp, %edx
1043 movl 36(%esp), %ebp
1044 xorl %ebp, %edx
1045 movl %esi, %ebp
1046.byte 209
1047.byte 194 /* roll $1 %edx */
1048 orl %eax, %ebp
1049 movl %edx, 48(%esp)
1050 andl %ebx, %ebp
1051 leal 2400959708(%edx,%ecx,1),%edx
1052 movl %esi, %ecx
1053.byte 209
1054.byte 206 /* rorl $1 %esi */
1055 andl %eax, %ecx
1056 orl %ecx, %ebp
1057 movl %edi, %ecx
1058 roll $5, %ecx
1059 addl %ecx, %ebp
1060 movl 52(%esp), %ecx
1061 addl %ebp, %edx
1062 movl 60(%esp), %ebp
1063 xorl %ebp, %ecx
1064 movl 20(%esp), %ebp
1065 xorl %ebp, %ecx
1066 movl 40(%esp), %ebp
1067.byte 209
1068.byte 206 /* rorl $1 %esi */
1069 xorl %ebp, %ecx
1070.byte 209
1071.byte 193 /* roll $1 %ecx */
1072 movl %edi, %ebp
1073 movl %ecx, 52(%esp)
1074 orl %esi, %ebp
1075 leal 2400959708(%ecx,%ebx,1),%ecx
1076 movl %edi, %ebx
1077 andl %eax, %ebp
1078 andl %esi, %ebx
1079 orl %ebx, %ebp
1080 movl %edx, %ebx
1081 roll $5, %ebx
1082.byte 209
1083.byte 207 /* rorl $1 %edi */
1084 addl %ebx, %ebp
1085.byte 209
1086.byte 207 /* rorl $1 %edi */
1087 addl %ebp, %ecx
1088 /* 40_59 45 */
1089 /* 40_59 46 */
1090 movl 56(%esp), %ebx
1091 movl (%esp), %ebp
1092 xorl %ebp, %ebx
1093 movl 24(%esp), %ebp
1094 xorl %ebp, %ebx
1095 movl 44(%esp), %ebp
1096 xorl %ebp, %ebx
1097 movl %edx, %ebp
1098.byte 209
1099.byte 195 /* roll $1 %ebx */
1100 orl %edi, %ebp
1101 movl %ebx, 56(%esp)
1102 andl %esi, %ebp
1103 leal 2400959708(%ebx,%eax,1),%ebx
1104 movl %edx, %eax
1105.byte 209
1106.byte 202 /* rorl $1 %edx */
1107 andl %edi, %eax
1108 orl %eax, %ebp
1109 movl %ecx, %eax
1110 roll $5, %eax
1111 addl %eax, %ebp
1112 movl 60(%esp), %eax
1113 addl %ebp, %ebx
1114 movl 4(%esp), %ebp
1115 xorl %ebp, %eax
1116 movl 28(%esp), %ebp
1117 xorl %ebp, %eax
1118 movl 48(%esp), %ebp
1119.byte 209
1120.byte 202 /* rorl $1 %edx */
1121 xorl %ebp, %eax
1122.byte 209
1123.byte 192 /* roll $1 %eax */
1124 movl %ecx, %ebp
1125 movl %eax, 60(%esp)
1126 orl %edx, %ebp
1127 leal 2400959708(%eax,%esi,1),%eax
1128 movl %ecx, %esi
1129 andl %edi, %ebp
1130 andl %edx, %esi
1131 orl %esi, %ebp
1132 movl %ebx, %esi
1133 roll $5, %esi
1134.byte 209
1135.byte 201 /* rorl $1 %ecx */
1136 addl %esi, %ebp
1137.byte 209
1138.byte 201 /* rorl $1 %ecx */
1139 addl %ebp, %eax
1140 /* 40_59 47 */
1141 /* 40_59 48 */
1142 movl (%esp), %esi
1143 movl 8(%esp), %ebp
1144 xorl %ebp, %esi
1145 movl 32(%esp), %ebp
1146 xorl %ebp, %esi
1147 movl 52(%esp), %ebp
1148 xorl %ebp, %esi
1149 movl %ebx, %ebp
1150.byte 209
1151.byte 198 /* roll $1 %esi */
1152 orl %ecx, %ebp
1153 movl %esi, (%esp)
1154 andl %edx, %ebp
1155 leal 2400959708(%esi,%edi,1),%esi
1156 movl %ebx, %edi
1157.byte 209
1158.byte 203 /* rorl $1 %ebx */
1159 andl %ecx, %edi
1160 orl %edi, %ebp
1161 movl %eax, %edi
1162 roll $5, %edi
1163 addl %edi, %ebp
1164 movl 4(%esp), %edi
1165 addl %ebp, %esi
1166 movl 12(%esp), %ebp
1167 xorl %ebp, %edi
1168 movl 36(%esp), %ebp
1169 xorl %ebp, %edi
1170 movl 56(%esp), %ebp
1171.byte 209
1172.byte 203 /* rorl $1 %ebx */
1173 xorl %ebp, %edi
1174.byte 209
1175.byte 199 /* roll $1 %edi */
1176 movl %eax, %ebp
1177 movl %edi, 4(%esp)
1178 orl %ebx, %ebp
1179 leal 2400959708(%edi,%edx,1),%edi
1180 movl %eax, %edx
1181 andl %ecx, %ebp
1182 andl %ebx, %edx
1183 orl %edx, %ebp
1184 movl %esi, %edx
1185 roll $5, %edx
1186.byte 209
1187.byte 200 /* rorl $1 %eax */
1188 addl %edx, %ebp
1189.byte 209
1190.byte 200 /* rorl $1 %eax */
1191 addl %ebp, %edi
1192 /* 40_59 49 */
1193 /* 40_59 50 */
1194 movl 8(%esp), %edx
1195 movl 16(%esp), %ebp
1196 xorl %ebp, %edx
1197 movl 40(%esp), %ebp
1198 xorl %ebp, %edx
1199 movl 60(%esp), %ebp
1200 xorl %ebp, %edx
1201 movl %esi, %ebp
1202.byte 209
1203.byte 194 /* roll $1 %edx */
1204 orl %eax, %ebp
1205 movl %edx, 8(%esp)
1206 andl %ebx, %ebp
1207 leal 2400959708(%edx,%ecx,1),%edx
1208 movl %esi, %ecx
1209.byte 209
1210.byte 206 /* rorl $1 %esi */
1211 andl %eax, %ecx
1212 orl %ecx, %ebp
1213 movl %edi, %ecx
1214 roll $5, %ecx
1215 addl %ecx, %ebp
1216 movl 12(%esp), %ecx
1217 addl %ebp, %edx
1218 movl 20(%esp), %ebp
1219 xorl %ebp, %ecx
1220 movl 44(%esp), %ebp
1221 xorl %ebp, %ecx
1222 movl (%esp), %ebp
1223.byte 209
1224.byte 206 /* rorl $1 %esi */
1225 xorl %ebp, %ecx
1226.byte 209
1227.byte 193 /* roll $1 %ecx */
1228 movl %edi, %ebp
1229 movl %ecx, 12(%esp)
1230 orl %esi, %ebp
1231 leal 2400959708(%ecx,%ebx,1),%ecx
1232 movl %edi, %ebx
1233 andl %eax, %ebp
1234 andl %esi, %ebx
1235 orl %ebx, %ebp
1236 movl %edx, %ebx
1237 roll $5, %ebx
1238.byte 209
1239.byte 207 /* rorl $1 %edi */
1240 addl %ebx, %ebp
1241.byte 209
1242.byte 207 /* rorl $1 %edi */
1243 addl %ebp, %ecx
1244 /* 40_59 51 */
1245 /* 40_59 52 */
1246 movl 16(%esp), %ebx
1247 movl 24(%esp), %ebp
1248 xorl %ebp, %ebx
1249 movl 48(%esp), %ebp
1250 xorl %ebp, %ebx
1251 movl 4(%esp), %ebp
1252 xorl %ebp, %ebx
1253 movl %edx, %ebp
1254.byte 209
1255.byte 195 /* roll $1 %ebx */
1256 orl %edi, %ebp
1257 movl %ebx, 16(%esp)
1258 andl %esi, %ebp
1259 leal 2400959708(%ebx,%eax,1),%ebx
1260 movl %edx, %eax
1261.byte 209
1262.byte 202 /* rorl $1 %edx */
1263 andl %edi, %eax
1264 orl %eax, %ebp
1265 movl %ecx, %eax
1266 roll $5, %eax
1267 addl %eax, %ebp
1268 movl 20(%esp), %eax
1269 addl %ebp, %ebx
1270 movl 28(%esp), %ebp
1271 xorl %ebp, %eax
1272 movl 52(%esp), %ebp
1273 xorl %ebp, %eax
1274 movl 8(%esp), %ebp
1275.byte 209
1276.byte 202 /* rorl $1 %edx */
1277 xorl %ebp, %eax
1278.byte 209
1279.byte 192 /* roll $1 %eax */
1280 movl %ecx, %ebp
1281 movl %eax, 20(%esp)
1282 orl %edx, %ebp
1283 leal 2400959708(%eax,%esi,1),%eax
1284 movl %ecx, %esi
1285 andl %edi, %ebp
1286 andl %edx, %esi
1287 orl %esi, %ebp
1288 movl %ebx, %esi
1289 roll $5, %esi
1290.byte 209
1291.byte 201 /* rorl $1 %ecx */
1292 addl %esi, %ebp
1293.byte 209
1294.byte 201 /* rorl $1 %ecx */
1295 addl %ebp, %eax
1296 /* 40_59 53 */
1297 /* 40_59 54 */
1298 movl 24(%esp), %esi
1299 movl 32(%esp), %ebp
1300 xorl %ebp, %esi
1301 movl 56(%esp), %ebp
1302 xorl %ebp, %esi
1303 movl 12(%esp), %ebp
1304 xorl %ebp, %esi
1305 movl %ebx, %ebp
1306.byte 209
1307.byte 198 /* roll $1 %esi */
1308 orl %ecx, %ebp
1309 movl %esi, 24(%esp)
1310 andl %edx, %ebp
1311 leal 2400959708(%esi,%edi,1),%esi
1312 movl %ebx, %edi
1313.byte 209
1314.byte 203 /* rorl $1 %ebx */
1315 andl %ecx, %edi
1316 orl %edi, %ebp
1317 movl %eax, %edi
1318 roll $5, %edi
1319 addl %edi, %ebp
1320 movl 28(%esp), %edi
1321 addl %ebp, %esi
1322 movl 36(%esp), %ebp
1323 xorl %ebp, %edi
1324 movl 60(%esp), %ebp
1325 xorl %ebp, %edi
1326 movl 16(%esp), %ebp
1327.byte 209
1328.byte 203 /* rorl $1 %ebx */
1329 xorl %ebp, %edi
1330.byte 209
1331.byte 199 /* roll $1 %edi */
1332 movl %eax, %ebp
1333 movl %edi, 28(%esp)
1334 orl %ebx, %ebp
1335 leal 2400959708(%edi,%edx,1),%edi
1336 movl %eax, %edx
1337 andl %ecx, %ebp
1338 andl %ebx, %edx
1339 orl %edx, %ebp
1340 movl %esi, %edx
1341 roll $5, %edx
1342.byte 209
1343.byte 200 /* rorl $1 %eax */
1344 addl %edx, %ebp
1345.byte 209
1346.byte 200 /* rorl $1 %eax */
1347 addl %ebp, %edi
1348 /* 40_59 55 */
1349 /* 40_59 56 */
1350 movl 32(%esp), %edx
1351 movl 40(%esp), %ebp
1352 xorl %ebp, %edx
1353 movl (%esp), %ebp
1354 xorl %ebp, %edx
1355 movl 20(%esp), %ebp
1356 xorl %ebp, %edx
1357 movl %esi, %ebp
1358.byte 209
1359.byte 194 /* roll $1 %edx */
1360 orl %eax, %ebp
1361 movl %edx, 32(%esp)
1362 andl %ebx, %ebp
1363 leal 2400959708(%edx,%ecx,1),%edx
1364 movl %esi, %ecx
1365.byte 209
1366.byte 206 /* rorl $1 %esi */
1367 andl %eax, %ecx
1368 orl %ecx, %ebp
1369 movl %edi, %ecx
1370 roll $5, %ecx
1371 addl %ecx, %ebp
1372 movl 36(%esp), %ecx
1373 addl %ebp, %edx
1374 movl 44(%esp), %ebp
1375 xorl %ebp, %ecx
1376 movl 4(%esp), %ebp
1377 xorl %ebp, %ecx
1378 movl 24(%esp), %ebp
1379.byte 209
1380.byte 206 /* rorl $1 %esi */
1381 xorl %ebp, %ecx
1382.byte 209
1383.byte 193 /* roll $1 %ecx */
1384 movl %edi, %ebp
1385 movl %ecx, 36(%esp)
1386 orl %esi, %ebp
1387 leal 2400959708(%ecx,%ebx,1),%ecx
1388 movl %edi, %ebx
1389 andl %eax, %ebp
1390 andl %esi, %ebx
1391 orl %ebx, %ebp
1392 movl %edx, %ebx
1393 roll $5, %ebx
1394.byte 209
1395.byte 207 /* rorl $1 %edi */
1396 addl %ebx, %ebp
1397.byte 209
1398.byte 207 /* rorl $1 %edi */
1399 addl %ebp, %ecx
1400 /* 40_59 57 */
1401 /* 40_59 58 */
1402 movl 40(%esp), %ebx
1403 movl 48(%esp), %ebp
1404 xorl %ebp, %ebx
1405 movl 8(%esp), %ebp
1406 xorl %ebp, %ebx
1407 movl 28(%esp), %ebp
1408 xorl %ebp, %ebx
1409 movl %edx, %ebp
1410.byte 209
1411.byte 195 /* roll $1 %ebx */
1412 orl %edi, %ebp
1413 movl %ebx, 40(%esp)
1414 andl %esi, %ebp
1415 leal 2400959708(%ebx,%eax,1),%ebx
1416 movl %edx, %eax
1417.byte 209
1418.byte 202 /* rorl $1 %edx */
1419 andl %edi, %eax
1420 orl %eax, %ebp
1421 movl %ecx, %eax
1422 roll $5, %eax
1423 addl %eax, %ebp
1424 movl 44(%esp), %eax
1425 addl %ebp, %ebx
1426 movl 52(%esp), %ebp
1427 xorl %ebp, %eax
1428 movl 12(%esp), %ebp
1429 xorl %ebp, %eax
1430 movl 32(%esp), %ebp
1431.byte 209
1432.byte 202 /* rorl $1 %edx */
1433 xorl %ebp, %eax
1434.byte 209
1435.byte 192 /* roll $1 %eax */
1436 movl %ecx, %ebp
1437 movl %eax, 44(%esp)
1438 orl %edx, %ebp
1439 leal 2400959708(%eax,%esi,1),%eax
1440 movl %ecx, %esi
1441 andl %edi, %ebp
1442 andl %edx, %esi
1443 orl %esi, %ebp
1444 movl %ebx, %esi
1445 roll $5, %esi
1446.byte 209
1447.byte 201 /* rorl $1 %ecx */
1448 addl %esi, %ebp
1449.byte 209
1450.byte 201 /* rorl $1 %ecx */
1451 addl %ebp, %eax
1452 /* 40_59 59 */
1453 /* 20_39 60 */
1454 movl 48(%esp), %esi
1455 movl 56(%esp), %ebp
1456 xorl %ebp, %esi
1457 movl 16(%esp), %ebp
1458 xorl %ebp, %esi
1459 movl 36(%esp), %ebp
1460 xorl %ebp, %esi
1461 movl %ebx, %ebp
1462.byte 209
1463.byte 198 /* roll $1 %esi */
1464 xorl %ecx, %ebp
1465 movl %esi, 48(%esp)
1466 xorl %edx, %ebp
1467 leal 3395469782(%esi,%edi,1),%esi
1468 movl %eax, %edi
1469 roll $5, %edi
1470.byte 209
1471.byte 203 /* rorl $1 %ebx */
1472 addl %ebp, %edi
1473.byte 209
1474.byte 203 /* rorl $1 %ebx */
1475 addl %edi, %esi
1476 /* 20_39 61 */
1477 movl 52(%esp), %edi
1478 movl 60(%esp), %ebp
1479 xorl %ebp, %edi
1480 movl 20(%esp), %ebp
1481 xorl %ebp, %edi
1482 movl 40(%esp), %ebp
1483 xorl %ebp, %edi
1484 movl %eax, %ebp
1485.byte 209
1486.byte 199 /* roll $1 %edi */
1487 xorl %ebx, %ebp
1488 movl %edi, 52(%esp)
1489 xorl %ecx, %ebp
1490 leal 3395469782(%edi,%edx,1),%edi
1491 movl %esi, %edx
1492 roll $5, %edx
1493.byte 209
1494.byte 200 /* rorl $1 %eax */
1495 addl %ebp, %edx
1496.byte 209
1497.byte 200 /* rorl $1 %eax */
1498 addl %edx, %edi
1499 /* 20_39 62 */
1500 movl 56(%esp), %edx
1501 movl (%esp), %ebp
1502 xorl %ebp, %edx
1503 movl 24(%esp), %ebp
1504 xorl %ebp, %edx
1505 movl 44(%esp), %ebp
1506 xorl %ebp, %edx
1507 movl %esi, %ebp
1508.byte 209
1509.byte 194 /* roll $1 %edx */
1510 xorl %eax, %ebp
1511 movl %edx, 56(%esp)
1512 xorl %ebx, %ebp
1513 leal 3395469782(%edx,%ecx,1),%edx
1514 movl %edi, %ecx
1515 roll $5, %ecx
1516.byte 209
1517.byte 206 /* rorl $1 %esi */
1518 addl %ebp, %ecx
1519.byte 209
1520.byte 206 /* rorl $1 %esi */
1521 addl %ecx, %edx
1522 /* 20_39 63 */
1523 movl 60(%esp), %ecx
1524 movl 4(%esp), %ebp
1525 xorl %ebp, %ecx
1526 movl 28(%esp), %ebp
1527 xorl %ebp, %ecx
1528 movl 48(%esp), %ebp
1529 xorl %ebp, %ecx
1530 movl %edi, %ebp
1531.byte 209
1532.byte 193 /* roll $1 %ecx */
1533 xorl %esi, %ebp
1534 movl %ecx, 60(%esp)
1535 xorl %eax, %ebp
1536 leal 3395469782(%ecx,%ebx,1),%ecx
1537 movl %edx, %ebx
1538 roll $5, %ebx
1539.byte 209
1540.byte 207 /* rorl $1 %edi */
1541 addl %ebp, %ebx
1542.byte 209
1543.byte 207 /* rorl $1 %edi */
1544 addl %ebx, %ecx
1545 /* 20_39 64 */
1546 movl (%esp), %ebx
1547 movl 8(%esp), %ebp
1548 xorl %ebp, %ebx
1549 movl 32(%esp), %ebp
1550 xorl %ebp, %ebx
1551 movl 52(%esp), %ebp
1552 xorl %ebp, %ebx
1553 movl %edx, %ebp
1554.byte 209
1555.byte 195 /* roll $1 %ebx */
1556 xorl %edi, %ebp
1557 movl %ebx, (%esp)
1558 xorl %esi, %ebp
1559 leal 3395469782(%ebx,%eax,1),%ebx
1560 movl %ecx, %eax
1561 roll $5, %eax
1562.byte 209
1563.byte 202 /* rorl $1 %edx */
1564 addl %ebp, %eax
1565.byte 209
1566.byte 202 /* rorl $1 %edx */
1567 addl %eax, %ebx
1568 /* 20_39 65 */
1569 movl 4(%esp), %eax
1570 movl 12(%esp), %ebp
1571 xorl %ebp, %eax
1572 movl 36(%esp), %ebp
1573 xorl %ebp, %eax
1574 movl 56(%esp), %ebp
1575 xorl %ebp, %eax
1576 movl %ecx, %ebp
1577.byte 209
1578.byte 192 /* roll $1 %eax */
1579 xorl %edx, %ebp
1580 movl %eax, 4(%esp)
1581 xorl %edi, %ebp
1582 leal 3395469782(%eax,%esi,1),%eax
1583 movl %ebx, %esi
1584 roll $5, %esi
1585.byte 209
1586.byte 201 /* rorl $1 %ecx */
1587 addl %ebp, %esi
1588.byte 209
1589.byte 201 /* rorl $1 %ecx */
1590 addl %esi, %eax
1591 /* 20_39 66 */
1592 movl 8(%esp), %esi
1593 movl 16(%esp), %ebp
1594 xorl %ebp, %esi
1595 movl 40(%esp), %ebp
1596 xorl %ebp, %esi
1597 movl 60(%esp), %ebp
1598 xorl %ebp, %esi
1599 movl %ebx, %ebp
1600.byte 209
1601.byte 198 /* roll $1 %esi */
1602 xorl %ecx, %ebp
1603 movl %esi, 8(%esp)
1604 xorl %edx, %ebp
1605 leal 3395469782(%esi,%edi,1),%esi
1606 movl %eax, %edi
1607 roll $5, %edi
1608.byte 209
1609.byte 203 /* rorl $1 %ebx */
1610 addl %ebp, %edi
1611.byte 209
1612.byte 203 /* rorl $1 %ebx */
1613 addl %edi, %esi
1614 /* 20_39 67 */
1615 movl 12(%esp), %edi
1616 movl 20(%esp), %ebp
1617 xorl %ebp, %edi
1618 movl 44(%esp), %ebp
1619 xorl %ebp, %edi
1620 movl (%esp), %ebp
1621 xorl %ebp, %edi
1622 movl %eax, %ebp
1623.byte 209
1624.byte 199 /* roll $1 %edi */
1625 xorl %ebx, %ebp
1626 movl %edi, 12(%esp)
1627 xorl %ecx, %ebp
1628 leal 3395469782(%edi,%edx,1),%edi
1629 movl %esi, %edx
1630 roll $5, %edx
1631.byte 209
1632.byte 200 /* rorl $1 %eax */
1633 addl %ebp, %edx
1634.byte 209
1635.byte 200 /* rorl $1 %eax */
1636 addl %edx, %edi
1637 /* 20_39 68 */
1638 movl 16(%esp), %edx
1639 movl 24(%esp), %ebp
1640 xorl %ebp, %edx
1641 movl 48(%esp), %ebp
1642 xorl %ebp, %edx
1643 movl 4(%esp), %ebp
1644 xorl %ebp, %edx
1645 movl %esi, %ebp
1646.byte 209
1647.byte 194 /* roll $1 %edx */
1648 xorl %eax, %ebp
1649 movl %edx, 16(%esp)
1650 xorl %ebx, %ebp
1651 leal 3395469782(%edx,%ecx,1),%edx
1652 movl %edi, %ecx
1653 roll $5, %ecx
1654.byte 209
1655.byte 206 /* rorl $1 %esi */
1656 addl %ebp, %ecx
1657.byte 209
1658.byte 206 /* rorl $1 %esi */
1659 addl %ecx, %edx
1660 /* 20_39 69 */
1661 movl 20(%esp), %ecx
1662 movl 28(%esp), %ebp
1663 xorl %ebp, %ecx
1664 movl 52(%esp), %ebp
1665 xorl %ebp, %ecx
1666 movl 8(%esp), %ebp
1667 xorl %ebp, %ecx
1668 movl %edi, %ebp
1669.byte 209
1670.byte 193 /* roll $1 %ecx */
1671 xorl %esi, %ebp
1672 movl %ecx, 20(%esp)
1673 xorl %eax, %ebp
1674 leal 3395469782(%ecx,%ebx,1),%ecx
1675 movl %edx, %ebx
1676 roll $5, %ebx
1677.byte 209
1678.byte 207 /* rorl $1 %edi */
1679 addl %ebp, %ebx
1680.byte 209
1681.byte 207 /* rorl $1 %edi */
1682 addl %ebx, %ecx
1683 /* 20_39 70 */
1684 movl 24(%esp), %ebx
1685 movl 32(%esp), %ebp
1686 xorl %ebp, %ebx
1687 movl 56(%esp), %ebp
1688 xorl %ebp, %ebx
1689 movl 12(%esp), %ebp
1690 xorl %ebp, %ebx
1691 movl %edx, %ebp
1692.byte 209
1693.byte 195 /* roll $1 %ebx */
1694 xorl %edi, %ebp
1695 movl %ebx, 24(%esp)
1696 xorl %esi, %ebp
1697 leal 3395469782(%ebx,%eax,1),%ebx
1698 movl %ecx, %eax
1699 roll $5, %eax
1700.byte 209
1701.byte 202 /* rorl $1 %edx */
1702 addl %ebp, %eax
1703.byte 209
1704.byte 202 /* rorl $1 %edx */
1705 addl %eax, %ebx
1706 /* 20_39 71 */
1707 movl 28(%esp), %eax
1708 movl 36(%esp), %ebp
1709 xorl %ebp, %eax
1710 movl 60(%esp), %ebp
1711 xorl %ebp, %eax
1712 movl 16(%esp), %ebp
1713 xorl %ebp, %eax
1714 movl %ecx, %ebp
1715.byte 209
1716.byte 192 /* roll $1 %eax */
1717 xorl %edx, %ebp
1718 movl %eax, 28(%esp)
1719 xorl %edi, %ebp
1720 leal 3395469782(%eax,%esi,1),%eax
1721 movl %ebx, %esi
1722 roll $5, %esi
1723.byte 209
1724.byte 201 /* rorl $1 %ecx */
1725 addl %ebp, %esi
1726.byte 209
1727.byte 201 /* rorl $1 %ecx */
1728 addl %esi, %eax
1729 /* 20_39 72 */
1730 movl 32(%esp), %esi
1731 movl 40(%esp), %ebp
1732 xorl %ebp, %esi
1733 movl (%esp), %ebp
1734 xorl %ebp, %esi
1735 movl 20(%esp), %ebp
1736 xorl %ebp, %esi
1737 movl %ebx, %ebp
1738.byte 209
1739.byte 198 /* roll $1 %esi */
1740 xorl %ecx, %ebp
1741 movl %esi, 32(%esp)
1742 xorl %edx, %ebp
1743 leal 3395469782(%esi,%edi,1),%esi
1744 movl %eax, %edi
1745 roll $5, %edi
1746.byte 209
1747.byte 203 /* rorl $1 %ebx */
1748 addl %ebp, %edi
1749.byte 209
1750.byte 203 /* rorl $1 %ebx */
1751 addl %edi, %esi
1752 /* 20_39 73 */
1753 movl 36(%esp), %edi
1754 movl 44(%esp), %ebp
1755 xorl %ebp, %edi
1756 movl 4(%esp), %ebp
1757 xorl %ebp, %edi
1758 movl 24(%esp), %ebp
1759 xorl %ebp, %edi
1760 movl %eax, %ebp
1761.byte 209
1762.byte 199 /* roll $1 %edi */
1763 xorl %ebx, %ebp
1764 movl %edi, 36(%esp)
1765 xorl %ecx, %ebp
1766 leal 3395469782(%edi,%edx,1),%edi
1767 movl %esi, %edx
1768 roll $5, %edx
1769.byte 209
1770.byte 200 /* rorl $1 %eax */
1771 addl %ebp, %edx
1772.byte 209
1773.byte 200 /* rorl $1 %eax */
1774 addl %edx, %edi
1775 /* 20_39 74 */
1776 movl 40(%esp), %edx
1777 movl 48(%esp), %ebp
1778 xorl %ebp, %edx
1779 movl 8(%esp), %ebp
1780 xorl %ebp, %edx
1781 movl 28(%esp), %ebp
1782 xorl %ebp, %edx
1783 movl %esi, %ebp
1784.byte 209
1785.byte 194 /* roll $1 %edx */
1786 xorl %eax, %ebp
1787 movl %edx, 40(%esp)
1788 xorl %ebx, %ebp
1789 leal 3395469782(%edx,%ecx,1),%edx
1790 movl %edi, %ecx
1791 roll $5, %ecx
1792.byte 209
1793.byte 206 /* rorl $1 %esi */
1794 addl %ebp, %ecx
1795.byte 209
1796.byte 206 /* rorl $1 %esi */
1797 addl %ecx, %edx
1798 /* 20_39 75 */
1799 movl 44(%esp), %ecx
1800 movl 52(%esp), %ebp
1801 xorl %ebp, %ecx
1802 movl 12(%esp), %ebp
1803 xorl %ebp, %ecx
1804 movl 32(%esp), %ebp
1805 xorl %ebp, %ecx
1806 movl %edi, %ebp
1807.byte 209
1808.byte 193 /* roll $1 %ecx */
1809 xorl %esi, %ebp
1810 movl %ecx, 44(%esp)
1811 xorl %eax, %ebp
1812 leal 3395469782(%ecx,%ebx,1),%ecx
1813 movl %edx, %ebx
1814 roll $5, %ebx
1815.byte 209
1816.byte 207 /* rorl $1 %edi */
1817 addl %ebp, %ebx
1818.byte 209
1819.byte 207 /* rorl $1 %edi */
1820 addl %ebx, %ecx
1821 /* 20_39 76 */
1822 movl 48(%esp), %ebx
1823 movl 56(%esp), %ebp
1824 xorl %ebp, %ebx
1825 movl 16(%esp), %ebp
1826 xorl %ebp, %ebx
1827 movl 36(%esp), %ebp
1828 xorl %ebp, %ebx
1829 movl %edx, %ebp
1830.byte 209
1831.byte 195 /* roll $1 %ebx */
1832 xorl %edi, %ebp
1833 movl %ebx, 48(%esp)
1834 xorl %esi, %ebp
1835 leal 3395469782(%ebx,%eax,1),%ebx
1836 movl %ecx, %eax
1837 roll $5, %eax
1838.byte 209
1839.byte 202 /* rorl $1 %edx */
1840 addl %ebp, %eax
1841.byte 209
1842.byte 202 /* rorl $1 %edx */
1843 addl %eax, %ebx
1844 /* 20_39 77 */
1845 movl 52(%esp), %eax
1846 movl 60(%esp), %ebp
1847 xorl %ebp, %eax
1848 movl 20(%esp), %ebp
1849 xorl %ebp, %eax
1850 movl 40(%esp), %ebp
1851 xorl %ebp, %eax
1852 movl %ecx, %ebp
1853.byte 209
1854.byte 192 /* roll $1 %eax */
1855 xorl %edx, %ebp
1856 movl %eax, 52(%esp)
1857 xorl %edi, %ebp
1858 leal 3395469782(%eax,%esi,1),%eax
1859 movl %ebx, %esi
1860 roll $5, %esi
1861.byte 209
1862.byte 201 /* rorl $1 %ecx */
1863 addl %ebp, %esi
1864.byte 209
1865.byte 201 /* rorl $1 %ecx */
1866 addl %esi, %eax
1867 /* 20_39 78 */
1868 movl 56(%esp), %esi
1869 movl (%esp), %ebp
1870 xorl %ebp, %esi
1871 movl 24(%esp), %ebp
1872 xorl %ebp, %esi
1873 movl 44(%esp), %ebp
1874 xorl %ebp, %esi
1875 movl %ebx, %ebp
1876.byte 209
1877.byte 198 /* roll $1 %esi */
1878 xorl %ecx, %ebp
1879 movl %esi, 56(%esp)
1880 xorl %edx, %ebp
1881 leal 3395469782(%esi,%edi,1),%esi
1882 movl %eax, %edi
1883 roll $5, %edi
1884.byte 209
1885.byte 203 /* rorl $1 %ebx */
1886 addl %ebp, %edi
1887.byte 209
1888.byte 203 /* rorl $1 %ebx */
1889 addl %edi, %esi
1890 /* 20_39 79 */
1891 movl 60(%esp), %edi
1892 movl 4(%esp), %ebp
1893 xorl %ebp, %edi
1894 movl 28(%esp), %ebp
1895 xorl %ebp, %edi
1896 movl 48(%esp), %ebp
1897 xorl %ebp, %edi
1898 movl %eax, %ebp
1899.byte 209
1900.byte 199 /* roll $1 %edi */
1901 xorl %ebx, %ebp
1902 movl %edi, 60(%esp)
1903 xorl %ecx, %ebp
1904 leal 3395469782(%edi,%edx,1),%edi
1905 movl %esi, %edx
1906 roll $5, %edx
1907 addl %ebp, %edx
1908 movl 92(%esp), %ebp
1909.byte 209
1910.byte 200 /* rorl $1 %eax */
1911 addl %edx, %edi
1912.byte 209
1913.byte 200 /* rorl $1 %eax */
1914 /* End processing */
1915
1916 movl 12(%ebp), %edx
1917 addl %ebx, %edx
1918 movl 4(%ebp), %ebx
1919 addl %esi, %ebx
1920 movl %eax, %esi
1921 movl (%ebp), %eax
1922 movl %edx, 12(%ebp)
1923 addl %edi, %eax
1924 movl 16(%ebp), %edi
1925 addl %ecx, %edi
1926 movl 8(%ebp), %ecx
1927 addl %esi, %ecx
1928 movl %eax, (%ebp)
1929 movl 64(%esp), %esi
1930 movl %ecx, 8(%ebp)
1931 addl $64, %esi
1932 movl 68(%esp), %eax
1933 movl %edi, 16(%ebp)
1934 cmpl %esi, %eax
1935 movl %ebx, 4(%ebp)
1936 jl .L001end
1937 movl (%esi), %eax
1938 jmp .L000start
1939.L001end:
1940 addl $72, %esp
1941 popl %edi
1942 popl %ebx
1943 popl %ebp
1944 popl %esi
1945 ret
1946.sha1_block_x86_end:
1947 SIZE(sha1_block_x86,.sha1_block_x86_end-sha1_block_x86)
1948.ident "desasm.pl"
diff --git a/src/lib/libcrypto/sha/sha_sgst.c b/src/lib/libcrypto/sha/sha_sgst.c
new file mode 100644
index 0000000000..8a16801328
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha_sgst.c
@@ -0,0 +1,246 @@
1/* crypto/sha/sha_sgst.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdlib.h>
60#include <string.h>
61
62#ifdef undef
63/* one or the other needs to be defined */
64#ifndef SHA_1 /* FIPE 180-1 */
65#define SHA_0 /* FIPS 180 */
66#endif
67#endif
68
69#define ULONG unsigned long
70#define UCHAR unsigned char
71#define UINT unsigned int
72
73#ifdef NOCONST
74#define const
75#endif
76
77#undef c2nl
78#define c2nl(c,l) (l =(((unsigned long)(*((c)++)))<<24), \
79 l|=(((unsigned long)(*((c)++)))<<16), \
80 l|=(((unsigned long)(*((c)++)))<< 8), \
81 l|=(((unsigned long)(*((c)++))) ))
82
83#undef p_c2nl
84#define p_c2nl(c,l,n) { \
85 switch (n) { \
86 case 0: l =((unsigned long)(*((c)++)))<<24; \
87 case 1: l|=((unsigned long)(*((c)++)))<<16; \
88 case 2: l|=((unsigned long)(*((c)++)))<< 8; \
89 case 3: l|=((unsigned long)(*((c)++))); \
90 } \
91 }
92
93#undef c2nl_p
94/* NOTE the pointer is not incremented at the end of this */
95#define c2nl_p(c,l,n) { \
96 l=0; \
97 (c)+=n; \
98 switch (n) { \
99 case 3: l =((unsigned long)(*(--(c))))<< 8; \
100 case 2: l|=((unsigned long)(*(--(c))))<<16; \
101 case 1: l|=((unsigned long)(*(--(c))))<<24; \
102 } \
103 }
104
105#undef p_c2nl_p
106#define p_c2nl_p(c,l,sc,len) { \
107 switch (sc) \
108 { \
109 case 0: l =((unsigned long)(*((c)++)))<<24; \
110 if (--len == 0) break; \
111 case 1: l|=((unsigned long)(*((c)++)))<<16; \
112 if (--len == 0) break; \
113 case 2: l|=((unsigned long)(*((c)++)))<< 8; \
114 } \
115 }
116
117#undef nl2c
118#define nl2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
119 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
120 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
121 *((c)++)=(unsigned char)(((l) )&0xff))
122
123#undef c2l
124#define c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
125 l|=(((unsigned long)(*((c)++)))<< 8), \
126 l|=(((unsigned long)(*((c)++)))<<16), \
127 l|=(((unsigned long)(*((c)++)))<<24))
128
129#undef p_c2l
130#define p_c2l(c,l,n) { \
131 switch (n) { \
132 case 0: l =((unsigned long)(*((c)++))); \
133 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
134 case 2: l|=((unsigned long)(*((c)++)))<<16; \
135 case 3: l|=((unsigned long)(*((c)++)))<<24; \
136 } \
137 }
138
139#undef c2l_p
140/* NOTE the pointer is not incremented at the end of this */
141#define c2l_p(c,l,n) { \
142 l=0; \
143 (c)+=n; \
144 switch (n) { \
145 case 3: l =((unsigned long)(*(--(c))))<<16; \
146 case 2: l|=((unsigned long)(*(--(c))))<< 8; \
147 case 1: l|=((unsigned long)(*(--(c)))); \
148 } \
149 }
150
151#undef p_c2l_p
152#define p_c2l_p(c,l,sc,len) { \
153 switch (sc) \
154 { \
155 case 0: l =((unsigned long)(*((c)++))); \
156 if (--len == 0) break; \
157 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
158 if (--len == 0) break; \
159 case 2: l|=((unsigned long)(*((c)++)))<<16; \
160 } \
161 }
162
163#undef l2c
164#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
165 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
166 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
167 *((c)++)=(unsigned char)(((l)>>24)&0xff))
168
169#undef ROTATE
170#if defined(WIN32)
171#define ROTATE(a,n) _lrotl(a,n)
172#else
173#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
174#endif
175
176/* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */
177#if defined(WIN32)
178/* 5 instructions with rotate instruction, else 9 */
179#define Endian_Reverse32(a) \
180 { \
181 unsigned long l=(a); \
182 (a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \
183 }
184#else
185/* 6 instructions with rotate instruction, else 8 */
186#define Endian_Reverse32(a) \
187 { \
188 unsigned long l=(a); \
189 l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \
190 (a)=ROTATE(l,16L); \
191 }
192#endif
193
194/* As pointed out by Wei Dai <weidai@eskimo.com>, F() below can be
195 * simplified to the code in F_00_19. Wei attributes these optimisations
196 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
197 * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
198 * I've just become aware of another tweak to be made, again from Wei Dai,
199 * in F_40_59, (x&a)|(y&a) -> (x|y)&a
200 */
201#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
202#define F_20_39(b,c,d) ((b) ^ (c) ^ (d))
203#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d)))
204#define F_60_79(b,c,d) F_20_39(b,c,d)
205
206#ifdef SHA_0
207#undef Xupdate
208#define Xupdate(a,i,ia,ib,ic,id) X[(i)&0x0f]=(a)=\
209 (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);
210#endif
211#ifdef SHA_1
212#undef Xupdate
213#define Xupdate(a,i,ia,ib,ic,id) (a)=\
214 (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);\
215 X[(i)&0x0f]=(a)=ROTATE((a),1);
216#endif
217
218#define BODY_00_15(i,a,b,c,d,e,f,xa) \
219 (f)=xa[i]+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
220 (b)=ROTATE((b),30);
221
222#define BODY_16_19(i,a,b,c,d,e,f,xa,xb,xc,xd) \
223 Xupdate(f,i,xa,xb,xc,xd); \
224 (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
225 (b)=ROTATE((b),30);
226
227#define BODY_20_31(i,a,b,c,d,e,f,xa,xb,xc,xd) \
228 Xupdate(f,i,xa,xb,xc,xd); \
229 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
230 (b)=ROTATE((b),30);
231
232#define BODY_32_39(i,a,b,c,d,e,f,xa) \
233 Xupdate(f,i,xa,xa,xa,xa); \
234 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
235 (b)=ROTATE((b),30);
236
237#define BODY_40_59(i,a,b,c,d,e,f,xa) \
238 Xupdate(f,i,xa,xa,xa,xa); \
239 (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \
240 (b)=ROTATE((b),30);
241
242#define BODY_60_79(i,a,b,c,d,e,f,xa) \
243 Xupdate(f,i,xa,xa,xa,xa); \
244 (f)=X[(i)&0x0f]+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \
245 (b)=ROTATE((b),30);
246
diff --git a/src/lib/libcrypto/stack/Makefile.ssl b/src/lib/libcrypto/stack/Makefile.ssl
new file mode 100644
index 0000000000..0d232c08cf
--- /dev/null
+++ b/src/lib/libcrypto/stack/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/stack/Makefile
3#
4
5DIR= stack
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=stack.c
24LIBOBJ=stack.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= stack.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/txt_db/Makefile.ssl b/src/lib/libcrypto/txt_db/Makefile.ssl
new file mode 100644
index 0000000000..76e511534f
--- /dev/null
+++ b/src/lib/libcrypto/txt_db/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/txt_db/Makefile
3#
4
5DIR= txt_db
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=txt_db.c
24LIBOBJ=txt_db.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= txt_db.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/util/mklink.sh b/src/lib/libcrypto/util/mklink.sh
new file mode 100644
index 0000000000..1e052ed6ee
--- /dev/null
+++ b/src/lib/libcrypto/util/mklink.sh
@@ -0,0 +1,35 @@
1#!/bin/sh
2#
3# A bit of an ugly shell script used to actually 'link' files.
4# Used by 'make links'
5#
6
7PATH=$PATH:.:util:../util:../../util
8export PATH
9
10from=$1
11shift
12
13here=`pwd`
14tmp=`dirname $from`
15while [ "$tmp"x != "x" -a "$tmp"x != ".x" ]
16do
17 t=`basename $here`
18 here=`dirname $here`
19 to="/$t$to"
20 tmp=`dirname $tmp`
21done
22to=..$to
23
24#echo from=$from
25#echo to =$to
26#exit 1
27
28if [ "$*"x != "x" ]; then
29 for i in $*
30 do
31 /bin/rm -f $from/$i
32 point.sh $to/$i $from/$i
33 done
34fi
35exit 0;
diff --git a/src/lib/libcrypto/util/ranlib.sh b/src/lib/libcrypto/util/ranlib.sh
new file mode 100644
index 0000000000..543f712c6b
--- /dev/null
+++ b/src/lib/libcrypto/util/ranlib.sh
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3cwd=`pwd`
4cd /tmp
5
6if [ -s /bin/ranlib ] ; then
7 RL=/bin/ranlib
8else if [ -s /usr/bin/ranlib ] ; then
9 RL=/usr/bin/ranlib
10fi
11fi
12
13if [ "x$RL" != "x" ]
14then
15 case "$1" in
16 /*)
17 $RL "$1"
18 ;;
19 *)
20 $RL "$cwd/$1"
21 ;;
22 esac
23fi
diff --git a/src/lib/libcrypto/util/sep_lib.sh b/src/lib/libcrypto/util/sep_lib.sh
new file mode 100644
index 0000000000..2348db874e
--- /dev/null
+++ b/src/lib/libcrypto/util/sep_lib.sh
@@ -0,0 +1,37 @@
1#!/bin/sh
2
3cwd=`pwd`
4/bin/rm -fr tmp/*
5
6cd crypto/des
7make -f Makefile.uni tar
8make -f Makefile.uni tar_lit
9/bin/mv libdes.tgz $cwd/tmp
10/bin/mv libdes-l.tgz $cwd/tmp
11cd $cwd
12
13for name in md5 sha cast bf idea rc4 rc2
14do
15 echo doing $name
16 (cd crypto; tar cfh - $name)|(cd tmp; tar xf -)
17 cd tmp/$name
18 /bin/rm -f Makefile
19 /bin/rm -f Makefile.ssl
20 /bin/rm -f Makefile.ssl.orig
21 /bin/rm -f *.old
22 /bin/mv Makefile.uni Makefile
23
24 cp $cwd/util/ranlib.sh .
25 chmod +x ranlib.sh
26
27 if [ -d asm ]; then
28 mkdir asm/perlasm
29 cp $cwd/crypto/perlasm/*.pl asm/perlasm
30 fi
31 cd ..
32 tar cf - $name|gzip >$name.tgz
33# /bin/rm -fr $name
34 cd $cwd
35done
36
37
diff --git a/src/lib/libcrypto/util/ssldir.pl b/src/lib/libcrypto/util/ssldir.pl
new file mode 100644
index 0000000000..10584686da
--- /dev/null
+++ b/src/lib/libcrypto/util/ssldir.pl
@@ -0,0 +1,52 @@
1#!/usr/bin/perl
2
3$#ARGV == 0 || die "usage: ssldir.pl /new/path\n";
4@files=('crypto/cryptlib.h',
5 'Makefile.ssl',
6 'tools/c_rehash',
7 'util/mk1mf.pl',
8 );
9
10%cryptlib=(
11 '\sX509_CERT_AREA\s',"#define X509_CERT_AREA\t\t".'"%s"',
12 '\sX509_CERT_DIR\s', "#define X509_CERT_DIR\t\t".'"%s/certs"',
13 '\sX509_CERT_FILE\s', "#define X509_CERT_FILE\t\t".'"%s/cert.pem"',
14 '\sX509_PRIVATE_DIR\s',"#define X509_PRIVATE_DIR\t".'"%s/private"',
15 );
16
17%Makefile_ssl=(
18 '^INSTALLTOP=','INSTALLTOP=%s',
19 );
20
21%c_rehash=(
22 '^DIR=', 'DIR=%s',
23 );
24
25%mk1mf=(
26 '^$INSTALLTOP=','$INSTALLTOP="%s";',
27 );
28
29&dofile("crypto/cryptlib.h",$ARGV[0],%cryptlib);
30&dofile("Makefile.ssl",$ARGV[0],%Makefile_ssl);
31&dofile("tools/c_rehash",$ARGV[0],%c_rehash);
32&dofile("util/mk1mf.pl",$ARGV[0],%mk1mf);
33
34sub dofile
35 {
36 ($f,$p,%m)=@_;
37
38 open(IN,"<$f") || die "unable to open $f:$!\n";
39 @a=<IN>;
40 close(IN);
41 foreach $k (keys %m)
42 {
43 grep(/$k/ && ($_=sprintf($m{$k}."\n",$p)),@a);
44 }
45 ($ff=$f) =~ s/\..*$//;
46 open(OUT,">$ff.new") || die "unable to open $f:$!\n";
47 print OUT @a;
48 close(OUT);
49 rename($f,"$ff.old") || die "unable to rename $f\n";
50 rename("$ff.new",$f) || die "unable to rename $ff.new\n";
51 }
52
diff --git a/src/lib/libcrypto/util/up_ver.pl b/src/lib/libcrypto/util/up_ver.pl
new file mode 100644
index 0000000000..32c086b2aa
--- /dev/null
+++ b/src/lib/libcrypto/util/up_ver.pl
@@ -0,0 +1,79 @@
1#!/usr/bin/perl
2#
3# Up the version numbers in the files.
4#
5
6@files=(
7 "crypto/crypto.h",
8 "crypto/des/ecb_enc.c",
9 "crypto/idea/i_ecb.c",
10 "crypto/lhash/lhash.c",
11 "crypto/conf/conf.c",
12 "crypto/md2/md2_dgst.c",
13 "crypto/md5/md5_dgst.c",
14 "crypto/ripemd/rmd_dgst.c",
15 "crypto/pem/pem_lib.c",
16 "crypto/bn/bn_lib.c",
17 "crypto/dh/dh_lib.c",
18 "crypto/rc2/rc2_ecb.c",
19 "crypto/rc4/rc4_skey.c",
20 "crypto/rc5/rc5_ecb.c",
21 "crypto/bf/bf_ecb.c",
22 "crypto/cast/c_ecb.c",
23 "crypto/rsa/rsa_lib.c",
24 "crypto/dsa/dsa_lib.c",
25 "crypto/sha/sha1dgst.c",
26 "crypto/sha/sha_dgst.c",
27 "crypto/asn1/asn1_lib.c",
28 "crypto/x509/x509_vfy.c",
29 "crypto/evp/evp_enc.c",
30 "crypto/rand/md_rand.c",
31 "crypto/stack/stack.c",
32 "crypto/txt_db/txt_db.c",
33 "crypto/cversion.c",
34 "ssl/ssl_lib.c",
35 "ssl/s2_lib.c",
36 "ssl/s3_lib.c",
37 "ssl/t1_lib.c",
38 "README",
39 );
40
41@month=('Jan','Feb','Mar','Apr','May','Jun',
42 'Jul','Aug','Sep','Oct','Nov','Dec');
43@a=localtime(time());
44$time=sprintf("%02d-%s-%04d",$a[3],$month[$a[4]],$a[5]+1900);
45
46$ver=$ARGV[0];
47($ver ne "") || die "no version number specified\n";
48($a,$b,$c,$d)=unpack('axaxac',$ver);
49$d=defined($d)?$d-96:0;
50$xver=sprintf("%x%x%x%x",$a,$b,$c,$d);
51
52foreach $file (@files)
53 {
54 open(IN,"<$file") || die "unable to open $file:$!\n";
55 open(OUT,">$file.new") || die "unable to open $file.new:$!\n";
56 $found=0;
57
58 print STDERR "$file:";
59
60 while (<IN>)
61 {
62 if ((s/SSLeay \d\.\d.\d[^"]*(\"|\s)/SSLeay $ver $time\1/) ||
63 s/^(\#define\s+SSLEAY_VERSION_NUMBER\s+0x)[0-9a-zA-Z]+(.*)$/$1$xver$2/)
64 {
65 print STDERR " Done";
66 $found++;
67 print OUT;
68 while (<IN>) { print OUT; }
69 last;
70 }
71 print OUT;
72 }
73 print STDERR "\n";
74 close(IN);
75 close(OUT);
76 (!$found) && die "unable to update the version number in $file\n";
77 rename($file,"$file.old") || die "unable to rename $file:$!\n";
78 rename("$file.new",$file) || die "unable to rename $file.new:$!\n";
79 }
diff --git a/src/lib/libcrypto/x509/Makefile.ssl b/src/lib/libcrypto/x509/Makefile.ssl
new file mode 100644
index 0000000000..1c1ca2ffa0
--- /dev/null
+++ b/src/lib/libcrypto/x509/Makefile.ssl
@@ -0,0 +1,96 @@
1#
2# SSLeay/crypto/x509/Makefile
3#
4
5DIR= x509
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=x509
19ERRC=x509_err
20GENERAL=Makefile README
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \
26 x509_obj.c x509_req.c x509_vfy.c \
27 x509_set.c x509rset.c $(ERRC).c \
28 x509name.c x509_v3.c x509_ext.c x509pack.c \
29 x509type.c x509_lu.c x_all.c x509_txt.c \
30 by_file.c by_dir.c \
31 v3_net.c v3_x509.c
32LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \
33 x509_obj.o x509_req.o x509_vfy.o \
34 x509_set.o x509rset.o $(ERRC).o \
35 x509name.o x509_v3.o x509_ext.o x509pack.o \
36 x509type.o x509_lu.o x_all.o x509_txt.o \
37 by_file.o by_dir.o \
38 v3_net.o v3_x509.o
39
40SRC= $(LIBSRC)
41
42EXHEADER= x509.h x509_vfy.h
43HEADER= $(EXHEADER)
44
45ALL= $(GENERAL) $(SRC) $(HEADER)
46
47top:
48 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
49
50all: lib
51
52lib: $(LIBOBJ)
53 $(AR) $(LIB) $(LIBOBJ)
54 sh $(TOP)/util/ranlib.sh $(LIB)
55 @touch lib
56
57files:
58 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
59
60links:
61 /bin/rm -f Makefile
62 $(TOP)/util/point.sh Makefile.ssl Makefile ;
63 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
64 $(TOP)/util/mklink.sh ../../test $(TEST)
65 $(TOP)/util/mklink.sh ../../apps $(APPS)
66
67install:
68 @for i in $(EXHEADER) ; \
69 do \
70 (cp $$i $(INSTALLTOP)/include/$$i; \
71 chmod 644 $(INSTALLTOP)/include/$$i ); \
72 done;
73
74tags:
75 ctags $(SRC)
76
77tests:
78
79lint:
80 lint -DLINT $(INCLUDES) $(SRC)>fluff
81
82depend:
83 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
84
85dclean:
86 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
87 mv -f Makefile.new $(MAKEFILE)
88
89clean:
90 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
91
92errors:
93 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
94 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
95
96# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libcrypto/x509/attrib b/src/lib/libcrypto/x509/attrib
new file mode 100644
index 0000000000..37f6cd755f
--- /dev/null
+++ b/src/lib/libcrypto/x509/attrib
@@ -0,0 +1,38 @@
1
2PKCS7
3 STACK of X509_ATTRIBUTES
4 ASN1_OBJECT
5 STACK of ASN1_TYPE
6
7So it is
8
9p7.xa[].obj
10p7.xa[].data[]
11
12get_obj_by_nid(STACK , nid)
13get_num_by_nid(STACK , nid)
14get_data_by_nid(STACK , nid, index)
15
16X509_ATTRIBUTE *X509_ATTRIBUTE_new(void );
17void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a);
18
19X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **ex,
20 int nid, STACK *value);
21
22X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **ex,
23 int nid, STACK *value);
24
25int X509_ATTRIBUTE_set_object(X509_ATTRIBUTE *ex,ASN1_OBJECT *obj);
26int X509_ATTRIBUTE_add_data(X509_ATTRIBUTE *ex, int index,
27 ASN1_TYPE *value);
28
29ASN1_OBJECT * X509_ATTRIBUTE_get_object(X509_ATTRIBUTE *ex);
30int X509_ATTRIBUTE_get_num(X509_ATTRIBUTE *ne);
31ASN1_TYPE * X509_ATTRIBUTE_get_data(X509_ATTRIBUTE *ne,int index);
32
33ASN1_TYPE * X509_ATTRIBUTE_get_data_by_NID(X509_ATTRIBUTE *ne,
34 ASN1_OBJECT *obj);
35
36X509_ATTRUBUTE *PKCS7_get_s_att_by_NID(PKCS7 *p7,int nid);
37X509_ATTRUBUTE *PKCS7_get_u_att_by_NID(PKCS7 *p7,int nid);
38
diff --git a/src/lib/libcrypto/x509/v3_net.c b/src/lib/libcrypto/x509/v3_net.c
new file mode 100644
index 0000000000..0c2d276d13
--- /dev/null
+++ b/src/lib/libcrypto/x509/v3_net.c
@@ -0,0 +1,87 @@
1/* crypto/x509/v3_net.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "stack.h"
61#include "cryptlib.h"
62#include "asn1.h"
63#include "objects.h"
64#include "x509.h"
65
66#define NETSCAPE_X509_EXT_NUM 8
67
68static X509_EXTENSION_METHOD netscape_x509_ext[NETSCAPE_X509_EXT_NUM]={
69{NID_netscape_ca_policy_url, V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
70{NID_netscape_ssl_server_name, V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
71{NID_netscape_revocation_url, V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
72{NID_netscape_base_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
73{NID_netscape_cert_type,V_ASN1_BIT_STRING,X509_EXT_PACK_STRING},
74{NID_netscape_ca_revocation_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
75{NID_netscape_renewal_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
76{NID_netscape_comment,V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
77 };
78
79int X509v3_add_netscape_extensions()
80 {
81 int i;
82
83 for (i=0; i<NETSCAPE_X509_EXT_NUM; i++)
84 if (!X509v3_add_extension(&(netscape_x509_ext[i])))
85 return(0);
86 return(1);
87 }
diff --git a/src/lib/libcrypto/x509/v3_x509.c b/src/lib/libcrypto/x509/v3_x509.c
new file mode 100644
index 0000000000..f685aa4c71
--- /dev/null
+++ b/src/lib/libcrypto/x509/v3_x509.c
@@ -0,0 +1,253 @@
1/* crypto/x509/v3_x509.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <ctype.h>
61#include "stack.h"
62#include "cryptlib.h"
63#include "bio.h"
64#include "asn1.h"
65#include "objects.h"
66#include "x509.h"
67
68#if 0
69static int i2a_key_usage(BIO *bp, X509 *x);
70static int a2i_key_usage(X509 *x, char *str, int len);
71#endif
72
73int X509v3_get_key_usage(X509 *x);
74int X509v3_set_key_usage(X509 *x,unsigned int use);
75int i2a_X509v3_key_usage(BIO *bp, unsigned int use);
76unsigned int a2i_X509v3_key_usage(char *p);
77
78#define STD_X509_EXT_NUM 9
79
80#if 0
81static X509_OBJECTS std_x509_ext[STD_X509_EXT_NUM]={
82{NID_subject_key_identifier, NULL,NULL},
83{NID_key_usage, a2i_key_usage,i2a_key_usage}, /**/
84{NID_private_key_usage_period, NULL,NULL},
85{NID_subject_alt_name, NULL,NULL},
86{NID_issuer_alt_name, NULL,NULL},
87{NID_basic_constraints, NULL,NULL},
88{NID_crl_number, NULL,NULL},
89{NID_certificate_policies, NULL,NULL},
90{NID_authority_key_identifier, NULL,NULL},
91 };
92#endif
93
94int X509v3_add_standard_extensions()
95 {
96
97#if 0
98 for (i=0; i<STD_X509_EXT_NUM; i++)
99 if (!X509v3_add_extension(&(std_x509_ext[i])))
100 return(0);
101#endif
102 return(1);
103 }
104
105int X509v3_get_key_usage(x)
106X509 *x;
107 {
108 X509_EXTENSION *ext;
109 ASN1_STRING *st;
110 char *p;
111 int i;
112
113 i=X509_get_ext_by_NID(x,NID_key_usage,-1);
114 if (i < 0) return(X509v3_KU_UNDEF);
115 ext=X509_get_ext(x,i);
116 st=X509v3_unpack_string(NULL,V_ASN1_BIT_STRING,
117 X509_EXTENSION_get_data(X509_get_ext(x,i)));
118
119 p=(char *)ASN1_STRING_data(st);
120 if (ASN1_STRING_length(st) == 1)
121 i=p[0];
122 else if (ASN1_STRING_length(st) == 2)
123 i=p[0]|(p[1]<<8);
124 else
125 i=0;
126 return(i);
127 }
128
129static struct
130 {
131 char *name;
132 unsigned int value;
133 } key_usage_data[] ={
134 {"digitalSignature", X509v3_KU_DIGITAL_SIGNATURE},
135 {"nonRepudiation", X509v3_KU_NON_REPUDIATION},
136 {"keyEncipherment", X509v3_KU_KEY_ENCIPHERMENT},
137 {"dataEncipherment", X509v3_KU_DATA_ENCIPHERMENT},
138 {"keyAgreement", X509v3_KU_KEY_AGREEMENT},
139 {"keyCertSign", X509v3_KU_KEY_CERT_SIGN},
140 {"cRLSign", X509v3_KU_CRL_SIGN},
141 {"encipherOnly", X509v3_KU_ENCIPHER_ONLY},
142 {"decipherOnly", X509v3_KU_DECIPHER_ONLY},
143 {NULL,0},
144 };
145
146#if 0
147static int a2i_key_usage(x,str,len)
148X509 *x;
149char *str;
150int len;
151 {
152 return(X509v3_set_key_usage(x,a2i_X509v3_key_usage(str)));
153 }
154
155static int i2a_key_usage(bp,x)
156BIO *bp;
157X509 *x;
158 {
159 return(i2a_X509v3_key_usage(bp,X509v3_get_key_usage(x)));
160 }
161#endif
162
163int i2a_X509v3_key_usage(bp,use)
164BIO *bp;
165unsigned int use;
166 {
167 int i=0,first=1;
168
169 for (;;)
170 {
171 if (use | key_usage_data[i].value)
172 {
173 BIO_printf(bp,"%s%s",((first)?"":" "),
174 key_usage_data[i].name);
175 first=0;
176 }
177 }
178 return(1);
179 }
180
181unsigned int a2i_X509v3_key_usage(p)
182char *p;
183 {
184 unsigned int ret=0;
185 char *q,*s;
186 int i,n;
187
188 q=p;
189 for (;;)
190 {
191 while ((*q != '\0') && isalnum(*q))
192 q++;
193 if (*q == '\0') break;
194 s=q++;
195 while (isalnum(*q))
196 q++;
197 n=q-s;
198 i=0;
199 for (;;)
200 {
201 if (strncmp(key_usage_data[i].name,s,n) == 0)
202 {
203 ret|=key_usage_data[i].value;
204 break;
205 }
206 i++;
207 if (key_usage_data[i].name == NULL)
208 return(X509v3_KU_UNDEF);
209 }
210 }
211 return(ret);
212 }
213
214int X509v3_set_key_usage(x,use)
215X509 *x;
216unsigned int use;
217 {
218 ASN1_OCTET_STRING *os;
219 X509_EXTENSION *ext;
220 int i;
221 unsigned char data[4];
222
223 i=X509_get_ext_by_NID(x,NID_key_usage,-1);
224 if (i < 0)
225 {
226 i=X509_get_ext_count(x)+1;
227 if ((ext=X509_EXTENSION_new()) == NULL) return(0);
228 if (!X509_add_ext(x,ext,i))
229 {
230 X509_EXTENSION_free(ext);
231 return(0);
232 }
233 }
234 else
235 ext=X509_get_ext(x,i);
236
237 /* fill in 'ext' */
238 os=X509_EXTENSION_get_data(ext);
239
240 i=0;
241 if (use > 0)
242 {
243 i=1;
244 data[0]=use&0xff;
245 }
246 if (use > 0xff)
247 {
248 i=2;
249 data[1]=(use>>8)&0xff;
250 }
251 return((X509v3_pack_string(&os,V_ASN1_BIT_STRING,data,i) == NULL)?0:1);
252 }
253
diff --git a/src/lib/libcrypto/x509/x509.doc b/src/lib/libcrypto/x509/x509.doc
new file mode 100644
index 0000000000..73cfc9f034
--- /dev/null
+++ b/src/lib/libcrypto/x509/x509.doc
@@ -0,0 +1,27 @@
1X509_verify()
2X509_sign()
3
4X509_get_version()
5X509_get_serialNumber()
6X509_get_issuer()
7X509_get_subject()
8X509_get_notBefore()
9X509_get_notAfter()
10X509_get_pubkey()
11
12X509_set_version()
13X509_set_serialNumber()
14X509_set_issuer()
15X509_set_subject()
16X509_set_notBefore()
17X509_set_notAfter()
18X509_set_pubkey()
19
20X509_get_extensions()
21X509_set_extensions()
22
23X509_EXTENSIONS_clear()
24X509_EXTENSIONS_retrieve()
25X509_EXTENSIONS_add()
26X509_EXTENSIONS_delete()
27
diff --git a/src/lib/libcrypto/x509/x509.err b/src/lib/libcrypto/x509/x509.err
new file mode 100644
index 0000000000..8d0862d7d1
--- /dev/null
+++ b/src/lib/libcrypto/x509/x509.err
@@ -0,0 +1,46 @@
1/* Error codes for the X509 functions. */
2
3/* Function codes. */
4#define X509_F_ADD_CERT_DIR 100
5#define X509_F_BY_FILE_CTRL 101
6#define X509_F_DIR_CTRL 102
7#define X509_F_GET_CERT_BY_SUBJECT 103
8#define X509_F_X509V3_ADD_EXT 104
9#define X509_F_X509V3_ADD_EXTENSION 105
10#define X509_F_X509V3_PACK_STRING 106
11#define X509_F_X509V3_UNPACK_STRING 107
12#define X509_F_X509_EXTENSION_CREATE_BY_NID 108
13#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109
14#define X509_F_X509_GET_PUBKEY_PARAMETERS 110
15#define X509_F_X509_LOAD_CERT_FILE 111
16#define X509_F_X509_LOAD_CRL_FILE 112
17#define X509_F_X509_NAME_ADD_ENTRY 113
18#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114
19#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115
20#define X509_F_X509_NAME_ONELINE 116
21#define X509_F_X509_NAME_PRINT 117
22#define X509_F_X509_PRINT_FP 118
23#define X509_F_X509_PUBKEY_GET 119
24#define X509_F_X509_PUBKEY_SET 120
25#define X509_F_X509_REQ_PRINT 121
26#define X509_F_X509_REQ_PRINT_FP 122
27#define X509_F_X509_REQ_TO_X509 123
28#define X509_F_X509_STORE_ADD_CERT 124
29#define X509_F_X509_STORE_ADD_CRL 125
30#define X509_F_X509_TO_X509_REQ 126
31#define X509_F_X509_VERIFY_CERT 127
32
33/* Reason codes. */
34#define X509_R_BAD_X509_FILETYPE 100
35#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101
36#define X509_R_ERR_ASN1_LIB 102
37#define X509_R_LOADING_CERT_DIR 103
38#define X509_R_LOADING_DEFAULTS 104
39#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105
40#define X509_R_SHOULD_RETRY 106
41#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107
42#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108
43#define X509_R_UNKNOWN_NID 109
44#define X509_R_UNKNOWN_STRING_TYPE 110
45#define X509_R_UNSUPPORTED_ALGORITHM 111
46#define X509_R_WRONG_LOOKUP_TYPE 112
diff --git a/src/lib/libcrypto/x509/x509pack.c b/src/lib/libcrypto/x509/x509pack.c
new file mode 100644
index 0000000000..846f125859
--- /dev/null
+++ b/src/lib/libcrypto/x509/x509pack.c
@@ -0,0 +1,157 @@
1/* crypto/x509/x509pack.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "stack.h"
61#include "cryptlib.h"
62#include "asn1.h"
63#include "objects.h"
64#include "evp.h"
65#include "x509.h"
66
67ASN1_OCTET_STRING *X509v3_pack_string(ex,type,bytes,len)
68ASN1_OCTET_STRING **ex;
69int type;
70unsigned char *bytes;
71int len;
72 {
73 ASN1_OCTET_STRING *os;
74 ASN1_STRING str;
75 unsigned char *p;
76 int i;
77
78 if ((ex == NULL) || (*ex == NULL))
79 os=ASN1_OCTET_STRING_new();
80 else
81 os= *ex;
82
83 if (len < 0) len=strlen((char *)bytes);
84 str.length=len;
85 str.type=type;
86 str.data=bytes;
87
88 /* str now holds the data, we just have to copy it into ->value */
89
90 switch (type)
91 {
92 case V_ASN1_BIT_STRING:
93 i=i2d_ASN1_BIT_STRING((ASN1_BIT_STRING *)&str,NULL);
94 if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i))
95 goto err;
96 p=(unsigned char *)os->data;
97 i2d_ASN1_BIT_STRING((ASN1_BIT_STRING *)&str,&p);
98 break;
99 case V_ASN1_OCTET_STRING:
100 i=i2d_ASN1_OCTET_STRING((ASN1_OCTET_STRING *)&str,NULL);
101 if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i))
102 goto err;
103 p=(unsigned char *)os->data;
104 i2d_ASN1_OCTET_STRING((ASN1_OCTET_STRING *)&str,&p);
105 break;
106 case V_ASN1_IA5STRING:
107 case V_ASN1_PRINTABLESTRING:
108 case V_ASN1_T61STRING:
109 i=i2d_ASN1_bytes(&str,NULL,type,V_ASN1_UNIVERSAL);
110 if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i))
111 goto err;
112 p=(unsigned char *)os->data;
113 i=i2d_ASN1_bytes(&str,&p,type,V_ASN1_UNIVERSAL);
114 break;
115 default:
116 X509err(X509_F_X509V3_PACK_STRING,X509_R_UNKNOWN_STRING_TYPE);
117 goto err;
118 }
119 os->length=i;
120
121 if ((ex != NULL) && (os != *ex))
122 *ex=os;
123 return(os);
124err:
125 return(NULL);
126 }
127
128ASN1_STRING *X509v3_unpack_string(ex,type,os)
129ASN1_STRING **ex;
130int type;
131ASN1_OCTET_STRING *os;
132 {
133 unsigned char *p;
134 ASN1_STRING *ret=NULL;
135
136 p=os->data;
137 switch (type)
138 {
139 case V_ASN1_BIT_STRING:
140 ret=(ASN1_STRING *)d2i_ASN1_BIT_STRING(
141 (ASN1_BIT_STRING **)ex,&p,os->length);
142 break;
143 case V_ASN1_OCTET_STRING:
144 ret=(ASN1_STRING *)d2i_ASN1_OCTET_STRING(
145 (ASN1_BIT_STRING **)ex,&p,os->length);
146 break;
147 case V_ASN1_IA5STRING:
148 case V_ASN1_PRINTABLESTRING:
149 case V_ASN1_T61STRING:
150 ret=(ASN1_STRING *)d2i_ASN1_PRINTABLE(ex,&p,os->length);
151 break;
152 default:
153 X509err(X509_F_X509V3_UNPACK_STRING,X509_R_UNKNOWN_STRING_TYPE);
154 }
155 return(ret);
156 }
157
diff --git a/src/lib/libcrypto/x509/x509v3.doc b/src/lib/libcrypto/x509/x509v3.doc
new file mode 100644
index 0000000000..1e760a9469
--- /dev/null
+++ b/src/lib/libcrypto/x509/x509v3.doc
@@ -0,0 +1,24 @@
1The 'new' system.
2
3The X509_EXTENSION_METHOD includes extensions and attributes and/or names.
4Basically everthing that can be added to an X509 with an OID identifying it.
5
6It operates via 2 methods per object id.
7int a2i_XXX(X509 *x,char *str,int len);
8int i2a_XXX(BIO *bp,X509 *x);
9
10The a2i_XXX function will add the object with a value converted from the
11string into the X509. Len can be -1 in which case the length is calculated
12via strlen(str). Applications can always use direct knowledge to load and
13unload the relevent objects themselves.
14
15i2a_XXX will print to the passed BIO, a text representation of the
16relevet object. Use a memory BIO if you want it printed to a buffer :-).
17
18X509_add_by_NID(X509 *x,int nid,char *str,int len);
19X509_add_by_OBJ(X509 *x,ASN1_OBJECT *obj,char *str,int len);
20
21X509_print_by_name(BIO *bp,X509 *x);
22X509_print_by_NID(BIO *bp,X509 *x);
23X509_print_by_OBJ(BIO *bp,X509 *x);
24
diff --git a/src/lib/libcrypto/x509v3/format b/src/lib/libcrypto/x509v3/format
new file mode 100644
index 0000000000..3307978121
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/format
@@ -0,0 +1,92 @@
1AuthorityKeyIdentifier
2 {
3 keyIdentifier [0] OCTET_STRING OPTIONAL
4 authorityCertIssuer [1] GeneralNames OPTIONAL
5 authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL
6 }
7
8SubjectKeyIdentifier OCTET_STRING
9
10KeyUsage
11 {
12 BIT_STRING
13 digitalSignature 0
14 nonRepudiation 1
15 keyEncipherment 2
16 dataEncipherment 3
17 keyAgreement 4
18 keyCertSign 5
19 cRLSign 6
20 encipherOnly 7
21 decipherOnly 8
22 }
23
24extKeyUsage
25 {
26 SEQUENCE of OBJECT_IDENTIFIER
27 }
28
29privateKeyUsagePeriod
30 {
31 notBefore [0] GeneralizedTime OPTIONAL
32 notAfter [1] GeneralizedTime OPTIONAL
33 }
34
35certificatePoliciesSyntax
36 SEQUENCE of PoliciesInformation
37
38PoliciesInformation XXX
39policyMappings XXX
40supportedAlgorithms XXX
41
42subjectAltName
43 GeneralNames sequence of GeneralName
44
45GeneralName
46 {
47 otherName [0] INSTANCE OF OTHER-NAME
48 rfc882Name [1] IA5String
49 dNSName [2] IA5String
50 x400Address [3] ORAddress
51 directoryName [4] Name
52 ediPartyName [5]
53 {
54 nameAssigner [0] DirectoryString OPTIONAL
55 partyName [1] DirectoryString
56 }
57 uniformResourceIdentifier [6] IA5String
58 iPAddress [7] OCTET_STRING
59 registeredID [8] OBJECT_IDENTIFIER
60 }
61
62issuerAltName
63 GeneralNames sequence of GeneralName
64
65subjectDirectoryAttribute SEQUENCE of Attribute
66
67basicConstraints
68 {
69 cA BOOLEAN default FALSE
70 pathLenConstraint INTEGER OPTIONAL
71 }
72
73nameConstraints
74 {
75 permittedSubtrees [0] sequence of GeneralSubtree OPTIONAL
76 excludedSubtrees [1] sequence of GeneralSubtree OPTIONAL
77 }
78
79GeneralSubtree
80 {
81 base GeneralName
82 minimum [0] BaseDistance DEFAULT 0
83 maximum [1] BaseDistance OPTIONAL
84 }
85
86PolicyConstraints
87 {
88 requiredExplicitPolicy [0] SkipCerts OPTIONAL
89 inhibitPolicyMapping [1] SkipCerts OPTIONAL
90 }
91SkipCerts == INTEGER
92
diff --git a/src/lib/libcrypto/x509v3/header b/src/lib/libcrypto/x509v3/header
new file mode 100644
index 0000000000..3d791ca3dd
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/header
@@ -0,0 +1,6 @@
1int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size)
2int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a)
3int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp)
4ASN1_INTEGER * d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,long length)
5
6
diff --git a/src/lib/libcrypto/x509v3/v3_ku.c b/src/lib/libcrypto/x509v3/v3_ku.c
new file mode 100644
index 0000000000..87c7402f43
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/v3_ku.c
@@ -0,0 +1,318 @@
1/* crypto/x509v3/v3_ku.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <ctype.h>
61#include "stack.h"
62#include "cryptlib.h"
63#include "bio.h"
64#include "asn1.h"
65#include "objects.h"
66#include "x509.h"
67
68X509_EXTENSION_METHOD X509v3_key_usage_method=
69 {
70 NID_key_usage,
71 ku_clear,
72 ex_get_bool,
73 ex_set_bool,
74 NULL,
75 NULL,
76 NULL,
77 NULL,
78 ku_a2i,
79 ku_i2a,
80 };
81
82static void ku_clear(a)
83X509_EXTENSION *a;
84 {
85 }
86
87static int ku_expand(a)
88X509_EXTENSION *a;
89 {
90 ASN1_BIT_STRING *bs;
91
92 if (a->argp == NULL)
93 {
94 bs=X509v3_unpack_string(NULL,V_ASN1_BIT_STRING,value);
95 if (bs == NULL) return(0);
96 a->argp=(char *)bs;
97 a->ex_free=ASN1_STRING_free;
98 }
99 return(1);
100 }
101
102static int ku_get_bool(a,num)
103X509_EXTENSION *a;
104int num;
105 {
106 int ret;
107 ASN1_BIT_STRING *bs;
108
109 if ((a->argp == NULL) && !ku_expand(a))
110 return(-1);
111 bs=(ASN1_BIT_STRING *)a->argp;
112 ret=ASN1_BIT_STRING_get_bit(bs,num);
113 return(ret);
114 }
115
116static int ku_set_bool(a,num,value)
117X509_EXTENSION *a;
118int num;
119int value;
120 {
121 ASN1_BIT_STRING *a;
122
123 if ((a->argp == NULL) && !ku_expand(a))
124 return(0);
125 bs=(ASN1_BIT_STRING *)a->argp;
126 ret=ASN1_BIT_STRING_set_bit(bs,num,value);
127 }
128
129static int ku_a2i(bio,a,buf,len)
130BIO *bio;
131X509_EXTENSION *a;
132char *buf;
133int len;
134 {
135 get token
136 }
137
138static char ku_names[X509v3_N_KU_NUM]={
139 X509v3_S_KU_digitalSignature,
140 X509v3_S_KU_nonRepudiation,
141 X509v3_S_KU_keyEncipherment,
142 X509v3_S_KU_dataEncipherment,
143 X509v3_S_KU_keyAgreement,
144 X509v3_S_KU_keyCertSign,
145 X509v3_S_KU_cRLSign,
146 X509v3_S_KU_encipherOnly,
147 X509v3_S_KU_decipherOnly,
148 };
149
150static int ku_i2a(bio,a);
151BIO *bio;
152X509_EXTENSION *a;
153 {
154 int i,first=1;
155 char *c;
156
157 for (i=0; i<X509v3_N_KU_NUM; i++)
158 {
159 if (ku_get_bool(a,i) > 0)
160 {
161 BIO_printf(bio,"%s%s",((first)?"":" "),ku_names[i]);
162 first=0;
163 }
164 }
165 }
166
167/***********************/
168
169int X509v3_get_key_usage(x,ret)
170STACK *x;
171unsigned long *ret;
172 {
173 X509_EXTENSION *ext;
174 ASN1_STRING *st;
175 char *p;
176 int i;
177
178 i=X509_get_ext_by_NID(x,NID_key_usage,-1);
179 if (i < 0) return(X509v3_KU_UNDEF);
180 ext=X509_get_ext(x,i);
181 st=X509v3_unpack_string(NULL,V_ASN1_BIT_STRING,
182 X509_EXTENSION_get_data(X509_get_ext(x,i)));
183
184 p=ASN1_STRING_data(st);
185 if (ASN1_STRING_length(st) == 1)
186 i=p[0];
187 else if (ASN1_STRING_length(st) == 2)
188 i=p[0]|(p[1]<<8);
189 else
190 i=0;
191 return(i);
192 }
193
194static struct
195 {
196 char *name;
197 unsigned int value;
198 } key_usage_data[] ={
199 {"digitalSignature", X509v3_KU_DIGITAL_SIGNATURE},
200 {"nonRepudiation", X509v3_KU_NON_REPUDIATION},
201 {"keyEncipherment", X509v3_KU_KEY_ENCIPHERMENT},
202 {"dataEncipherment", X509v3_KU_DATA_ENCIPHERMENT},
203 {"keyAgreement", X509v3_KU_KEY_AGREEMENT},
204 {"keyCertSign", X509v3_KU_KEY_CERT_SIGN},
205 {"cRLSign", X509v3_KU_CRL_SIGN},
206 {"encipherOnly", X509v3_KU_ENCIPHER_ONLY},
207 {"decipherOnly", X509v3_KU_DECIPHER_ONLY},
208 {NULL,0},
209 };
210
211#if 0
212static int a2i_key_usage(x,str,len)
213X509 *x;
214char *str;
215int len;
216 {
217 return(X509v3_set_key_usage(x,a2i_X509v3_key_usage(str)));
218 }
219
220static int i2a_key_usage(bp,x)
221BIO *bp;
222X509 *x;
223 {
224 return(i2a_X509v3_key_usage(bp,X509v3_get_key_usage(x)));
225 }
226#endif
227
228int i2a_X509v3_key_usage(bp,use)
229BIO *bp;
230unsigned int use;
231 {
232 int i=0,first=1;
233
234 for (;;)
235 {
236 if (use | key_usage_data[i].value)
237 {
238 BIO_printf(bp,"%s%s",((first)?"":" "),
239 key_usage_data[i].name);
240 first=0;
241 }
242 }
243 return(1);
244 }
245
246unsigned int a2i_X509v3_key_usage(p)
247char *p;
248 {
249 unsigned int ret=0;
250 char *q,*s;
251 int i,n;
252
253 q=p;
254 for (;;)
255 {
256 while ((*q != '\0') && isalnum(*q))
257 q++;
258 if (*q == '\0') break;
259 s=q++;
260 while (isalnum(*q))
261 q++;
262 n=q-s;
263 i=0;
264 for (;;)
265 {
266 if (strncmp(key_usage_data[i].name,s,n) == 0)
267 {
268 ret|=key_usage_data[i].value;
269 break;
270 }
271 i++;
272 if (key_usage_data[i].name == NULL)
273 return(X509v3_KU_UNDEF);
274 }
275 }
276 return(ret);
277 }
278
279int X509v3_set_key_usage(x,use)
280X509 *x;
281unsigned int use;
282 {
283 ASN1_OCTET_STRING *os;
284 X509_EXTENSION *ext;
285 int i;
286 unsigned char data[4];
287
288 i=X509_get_ext_by_NID(x,NID_key_usage,-1);
289 if (i < 0)
290 {
291 i=X509_get_ext_count(x)+1;
292 if ((ext=X509_EXTENSION_new()) == NULL) return(0);
293 if (!X509_add_ext(x,ext,i))
294 {
295 X509_EXTENSION_free(ext);
296 return(0);
297 }
298 }
299 else
300 ext=X509_get_ext(x,i);
301
302 /* fill in 'ext' */
303 os=X509_EXTENSION_get_data(ext);
304
305 i=0;
306 if (use > 0)
307 {
308 i=1;
309 data[0]=use&0xff;
310 }
311 if (use > 0xff)
312 {
313 i=2;
314 data[1]=(use>>8)&0xff;
315 }
316 return((X509v3_pack_string(&os,V_ASN1_BIT_STRING,data,i) == NULL)?0:1);
317 }
318
diff --git a/src/lib/libssl/Makefile b/src/lib/libssl/Makefile
new file mode 100644
index 0000000000..3954b2d858
--- /dev/null
+++ b/src/lib/libssl/Makefile
@@ -0,0 +1,10 @@
1.include <bsd.own.mk>
2ECHO= /bin/echo
3
4.if exists(${.OBJDIR}/src-patent)
5SUBDIR= crypto-patent ssl-patent
6.else
7SUBDIR= crypto ssl
8.endif
9
10.include <bsd.subdir.mk>
diff --git a/src/lib/libssl/Makefile.bsd-wrapper b/src/lib/libssl/Makefile.bsd-wrapper
new file mode 100644
index 0000000000..282912514d
--- /dev/null
+++ b/src/lib/libssl/Makefile.bsd-wrapper
@@ -0,0 +1,100 @@
1# Build wrapper for SSLeay.
2# $OpenBSD: Makefile.bsd-wrapper,v 1.9 1999/03/17 18:25:56 deraadt Exp $
3
4# Our lndir is hacked; specify a full path to avoid potential conflicts
5# with the one installed with X11.
6LNDIR= /usr/bin/lndir
7
8
9# Figure out what flag we use to SSLeay's configure. This
10# needs to be tested on all architectures.
11
12.if ${MACHINE_ARCH} == "i386"
13SSLCONF= OpenBSD-x86
14.else
15.if ${MACHINE_ARCH} == "pmax"
16SSLCONF= OpenBSD-pmax
17.else
18.if ${MACHINE_ARCH} == "arc"
19SSLCONF= OpenBSD-arc
20.else
21.if ${MACHINE_ARCH} == "alpha"
22SSLCONF= OpenBSD-alpha
23.else
24.if ${MACHINE_ARCH} == "sparc"
25SSLCONF= OpenBSD-bigendian
26.else
27.if ${MACHINE_ARCH} == "m88k"
28SSLCONF= OpenBSD-bigendian
29.else
30##UNTESTED!
31SSLCONF= OpenBSD-bigendian
32.endif
33.endif
34.endif
35.endif
36.endif
37.endif
38
39MUNGEDFILES = ${.OBJDIR}/${SSL_SRC}/crypto/bf/bf_locl.h \
40 ${.OBJDIR}/${SSL_SRC}/crypto/bn/bn.h \
41 ${.OBJDIR}/${SSL_SRC}/crypto/des/des.h \
42 ${.OBJDIR}/${SSL_SRC}/crypto/des/des_locl.h \
43 ${.OBJDIR}/${SSL_SRC}/crypto/idea/idea.h \
44 ${.OBJDIR}/${SSL_SRC}/crypto/md2/md2.h \
45 ${.OBJDIR}/${SSL_SRC}/crypto/rc2/rc2.h \
46 ${.OBJDIR}/${SSL_SRC}/crypto/rc4/rc4.h \
47 ${.OBJDIR}/${SSL_SRC}/crypto/rc4/rc4_locl.h
48
49
50.include <bsd.own.mk>
51
52.if exists(src-patent)
53SSL_SRC=src-patent
54.else
55SSL_SRC=src
56.endif
57
58all: prereq
59 cd ${.OBJDIR} && ${MAKE}
60
61includes: prereq
62 cd ${.OBJDIR} && ${MAKE} includes
63
64prereq: ${.OBJDIR}/${SSL_SRC}/crypto/md2/md2.h
65
66install:
67 cd ${.OBJDIR} && ${MAKE} install
68
69${.OBJDIR}/${SSL_SRC}/crypto/md2/md2.h : ${.OBJDIR}/${SSL_SRC}/Makefile.ssl
70 cd ${.OBJDIR}/${SSL_SRC} && /usr/bin/perl Configure ${SSLCONF}
71
72.if !exists(${.OBJDIR}/${SSL_SRC}/Makefile.ssl)
73${.OBJDIR}/${SSL_SRC}/Makefile.ssl: ${.CURDIR}/${SSL_SRC}/Makefile.ssl
74 ${LNDIR} -s -e obj -e obj.${MACHINE_ARCH} -e Makefile.bsd-wrapper -e Makefile.ssl ${.CURDIR} && cp ${.CURDIR}/${SSL_SRC}/Makefile.ssl ${.OBJDIR}/${SSL_SRC}
75.endif
76
77clean: ${.OBJDIR}/${SSL_SRC}/Makefile.ssl
78 cd ${.OBJDIR} && ${MAKE} clean
79
80cleandir: ${.OBJDIR}/${SSL_SRC}/Makefile.ssl
81 cd ${.OBJDIR} && rm -f ${MUNGEDFILES} && ${MAKE} cleandir
82
83test:
84 # Nothing here so far...
85
86depend:
87 # Nothing here so far...
88
89lint:
90 # Nothing here so far...
91
92tags:
93 # Nothing here so far...
94
95distribution:
96 ${INSTALL} ${INSTALL_COPY} -g ${BINGRP} -m 444 \
97 ${.CURDIR}/ssleay.cnf ${DESTDIR}/etc/ssl/lib/ssleay.cnf
98
99.include <bsd.obj.mk>
100.include <bsd.subdir.mk>
diff --git a/src/lib/libssl/README.OPENBSD b/src/lib/libssl/README.OPENBSD
new file mode 100644
index 0000000000..7cc3d0d424
--- /dev/null
+++ b/src/lib/libssl/README.OPENBSD
@@ -0,0 +1,66 @@
1
2 This is an SSLeay-0.9.0b (the b means the PKCS#1 bug is fixed) tree.
3
4 It has the following modifcations made to it.
5
6 0) util/perlpath.pl has been run to change perlpath to /usr/bin
7 util/ssldir.pl has been run to change the ssl dir to /usr/ssl
8 Null check added to crypto/err/err.c (mailed to Eric Young)
9 to avoid problems in error handling. Includes install into
10 /usr/include/ssl, certs and configs are expected to be in
11 /etc/ssl.
12
13 1) Changes for openbsd compilation to have been made to
14 config and Configure (these have been sent to Eric Young)
15
16NOTES:
17
18 Many tests will fail miserably, since most of them start
19 with SSL v2, which requires RSA, and of course, they barf.
20 idea tests will also fail. This is to be expected. Do
21 "make -k test" if you want to see the output and draw
22 your own conclusions.
23
24 Many parts of the utility programs may not work, although things
25 like client and server will provided you start them in a mode
26 that does not require RSA to operate.
27
28 Unlike an ssl library built to remove the offending routines
29 (which removes many of the things like SSL23init which many
30 packages like web servers use) this library does contain
31 stubs for everything. The patent bits will simply fail. The
32 idea is that this may be used as is for limited functionality,
33 or where possible replaced with a full function library. When
34 porting an app it is important to remember to try to use the
35 tls1 version of stuff first where possible. I.E. if you're
36 going to SSL-ize OpenBSD telnet, for example, call the tls1 init
37 functions *NOT* sslv2init or sslv23init, or you'll be dependent
38 on RSA and have a version that will only work with a full
39 function library. Use the tls versions and you'll work with
40 both - a good thing.
41
42 "crypto" and "ssl" are OpenBSD style build dirs for the
43 libraries of the same name. "ssleay" is the build dir for the
44 "ssleay" executable, used to control everything vagely ssleay
45 like, from testing to generating certificates, to playing
46 simple client server games. libraries expect to install headers
47 in "/usr/include/ssl", libraries in /usr/lib, ssleay in /usr/sbin
48
49TODO:
50 SSLeay contains just no library docs, it's all use the
51 force, read the source. This should be fixed sometime.
52
53 DSS certificate generation is a black art. This
54 needs to be properly documented and a comprehensive procedure
55 written up, at least for how to generate a cert for
56 a host to be used by multiple servers. beck@ has talked
57 to Mark Shuttleworth of Thawte, and he has agreed that
58 if we can get DSS hosts certs up and running Thawte will
59 consider providing the service (for the usual fee of course)
60 of for-real signing of OpenBSD host certs for those who
61 want a real CA for things like telnet and ftp and the like.
62
63 Apps beyond ssleay need testing - apps that use exclusively old style
64 sslv2 or sslv2/3 need to be converted/modified where possible to
65 try the tls1 stuff, so that we can handle doing things without
66 RSA.
diff --git a/src/lib/libssl/crypto-patent/Makefile b/src/lib/libssl/crypto-patent/Makefile
new file mode 100644
index 0000000000..14ceca92d7
--- /dev/null
+++ b/src/lib/libssl/crypto-patent/Makefile
@@ -0,0 +1,179 @@
1
2LIB= crypto
3
4SSLEAYDIST= src-patent
5
6LCRYPTO_SRC= ${.CURDIR}/../${SSLEAYDIST}/crypto
7
8.if ${MACHINE_ARCH} == "i386"
9CFLAGS+= -DL_ENDIAN -DBN_ASM
10.else
11.if ${MACHINE_ARCH} == "arc"
12CFLAGS+= -DL_ENDIAN
13.else
14.if ${MACHINE_ARCH} == "pmax"
15CFLAGS+= -DL_ENDIAN
16.else
17.if ${MACHINE_ARCH} == "alpha"
18# no ENDIAN stuff defined for alpha
19.else
20CFLAGS+= -DB_ENDIAN
21.endif
22.endif
23.endif
24.endif
25
26CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE
27CFLAGS+= -I${.CURDIR}/../${SSLEAYDIST}
28CFLAGS+= -I${LCRYPTO_SRC}
29SRCS+= cryptlib.c mem.c cversion.c ex_data.c cpt_err.c
30CFLAGS+= -I${LCRYPTO_SRC}/md2
31SRCS+= md2_dgst.c md2_one.c
32CFLAGS+= -I${LCRYPTO_SRC}/md5
33SRCS+= md5_dgst.c md5_one.c
34CFLAGS+= -I${LCRYPTO_SRC}/sha
35SRCS+= sha_dgst.c sha1dgst.c sha_one.c sha1_one.c
36CFLAGS+= -I${LCRYPTO_SRC}/mdc2
37SRCS+= mdc2dgst.c mdc2_one.c
38CFLAGS+= -I${LCRYPTO_SRC}/hmac
39SRCS+= hmac.c
40CFLAGS+= -I${LCRYPTO_SRC}/ripemd
41SRCS+= rmd_dgst.c rmd_one.c
42CFLAGS+= -I${LCRYPTO_SRC}/des
43SRCS+= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
44 ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \
45 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
46 qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
47 des_enc.c fcrypt_b.c read2pwd.c \
48 fcrypt.c xcbc_enc.c \
49 str2key.c cfb64ede.c ofb64ede.c supp.c
50CFLAGS+= -I${LCRYPTO_SRC}/rc2
51SRCS+= rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c
52SRCS+= rc2ofb64.c
53CFLAGS+= -I${LCRYPTO_SRC}/rc4
54SRCS+= rc4_skey.c rc4_enc.c
55CFLAGS+= -I${LCRYPTO_SRC}/rc5
56SRCS+= rc5_skey.c rc5_ecb.c rc5cfb64.c rc5cfb64.c
57SRCS+= rc5ofb64.c rc5_enc.c
58CFLAGS+= -I${LCRYPTO_SRC}/idea
59SRCS+= i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c
60SRCS+= i_skey.c
61CFLAGS+= -I${LCRYPTO_SRC}/bf
62SRCS+= bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c bf_enc.c
63CFLAGS+= -I${LCRYPTO_SRC}/cast
64SRCS+= c_skey.c c_ecb.c c_cfb64.c c_ofb64.c c_enc.c
65CFLAGS+= -I${LCRYPTO_SRC}/bn
66SRCS+= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c
67SRCS+= bn_mul.c bn_print.c bn_rand.c bn_shift.c bn_sub.c
68SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c
69SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c
70SRCS+= bn_mulw.c
71CFLAGS+= -I${LCRYPTO_SRC}/rsa
72SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c
73SRCS+= rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c
74SRCS+= rsa_none.c
75CFLAGS+= -I${LCRYPTO_SRC}/dsa
76SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c
77SRCS+= dsa_sign.c dsa_err.c
78CFLAGS+= -I${LCRYPTO_SRC}/dh
79SRCS+= dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c
80CFLAGS+= -I${LCRYPTO_SRC}/buffer
81SRCS+= buffer.c buf_err.c
82CFLAGS+= -I${LCRYPTO_SRC}/bio
83SRCS+= bio_lib.c bio_cb.c bio_err.c bss_mem.c
84SRCS+= bss_null.c bss_fd.c bss_file.c bss_sock.c
85SRCS+= bss_conn.c bf_null.c bf_buff.c
86SRCS+= b_print.c b_dump.c b_sock.c bss_acpt.c
87SRCS+= bf_nbio.c
88CFLAGS+= -I${LCRYPTO_SRC}/stack
89SRCS+= stack.c
90CFLAGS+= -I${LCRYPTO_SRC}/lhash
91SRCS+= lhash.c lh_stats.c
92CFLAGS+= -I${LCRYPTO_SRC}/rand
93SRCS+= md_rand.c randfile.c
94CFLAGS+= -I${LCRYPTO_SRC}/err
95SRCS+= err.c err_all.c err_prn.c
96CFLAGS+= -I${LCRYPTO_SRC}/objects
97SRCS+= obj_dat.c obj_lib.c obj_err.c
98CFLAGS+= -I${LCRYPTO_SRC}/evp
99SRCS+= encode.c digest.c evp_enc.c evp_key.c
100SRCS+= e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c
101SRCS+= e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c
102SRCS+= e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c
103SRCS+= e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c e_ecb_r2.c
104SRCS+= e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c e_ecb_bf.c
105SRCS+= e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c e_ecb_c.c
106SRCS+= e_cbc_c.c e_cfb_c.c e_ofb_c.c e_ecb_r5.c
107SRCS+= e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c m_null.c
108SRCS+= m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c
109SRCS+= m_dss1.c m_mdc2.c m_ripemd.c p_open.c
110SRCS+= p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c
111SRCS+= p_dec.c bio_md.c bio_b64.c bio_enc.c
112SRCS+= evp_err.c e_null.c c_all.c evp_lib.c
113CFLAGS+= -I${LCRYPTO_SRC}/pem
114SRCS+= pem_sign.c pem_seal.c pem_info.c pem_lib.c
115SRCS+= pem_all.c pem_err.c
116CFLAGS+= -I${LCRYPTO_SRC}/asn1
117SRCS+= a_object.c a_bitstr.c a_utctm.c a_int.c
118SRCS+= a_octet.c a_print.c a_type.c a_set.c
119SRCS+= a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c
120SRCS+= a_digest.c a_verify.c x_algor.c x_val.c
121SRCS+= x_pubkey.c x_sig.c x_req.c x_attrib.c
122SRCS+= x_name.c x_cinf.c x_x509.c x_crl.c
123SRCS+= x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c
124SRCS+= d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c
125SRCS+= d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c
126SRCS+= i2d_pu.c i2d_pr.c t_req.c t_x509.c
127SRCS+= t_pkey.c p7_i_s.c p7_signi.c p7_signd.c
128SRCS+= p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c
129SRCS+= p7_s_e.c p7_enc.c p7_lib.c f_int.c
130SRCS+= f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c
131SRCS+= d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c
132SRCS+= a_bool.c x_exten.c asn1_par.c asn1_lib.c
133SRCS+= asn1_err.c a_meth.c a_bytes.c evp_asn1.c
134CFLAGS+= -I${LCRYPTO_SRC}/x509
135SRCS+= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c
136SRCS+= x509_obj.c x509_req.c x509_vfy.c x509_set.c
137SRCS+= x509rset.c x509_err.c x509name.c x509_v3.c
138SRCS+= x509_ext.c x509pack.c x509type.c x509_lu.c
139SRCS+= x_all.c x509_txt.c by_file.c by_dir.c
140SRCS+= v3_net.c v3_x509.c
141CFLAGS+= -I${LCRYPTO_SRC}/conf
142SRCS+= conf.c conf_err.c
143CFLAGS+= -I${LCRYPTO_SRC}/txt_db
144SRCS+= txt_db.c
145CFLAGS+= -I${LCRYPTO_SRC}/pkcs7
146SRCS+= pk7_lib.c pkcs7err.c pk7_doit.c
147
148HDRS= asn1/asn1.h asn1/asn1_mac.h bf/blowfish.h bio/bio.h \
149 bn/bn.h buffer/buffer.h cast/cast.h conf/conf.h des/des.h dh/dh.h \
150 dsa/dsa.h err/err.h evp/evp.h hmac/hmac.h idea/idea.h lhash/lhash.h \
151 md2/md2.h md5/md5.h mdc2/mdc2.h objects/objects.h pem/pem.h \
152 pkcs7/pkcs7.h rand/rand.h rc2/rc2.h rc4/rc4.h rc5/rc5.h \
153 ripemd/ripemd.h rsa/rsa.h sha/sha.h stack/stack.h txt_db/txt_db.h \
154 x509/x509.h x509/x509_vfy.h crypto.h cryptall.h ../e_os.h
155
156.PATH: ${LCRYPTO_SRC}/md2 ${LCRYPTO_SRC}/md5 ${LCRYPTO_SRC}/sha ${LCRYPTO_SRC}/mdc2 \
157 ${LCRYPTO_SRC}/hmac ${LCRYPTO_SRC}/ripemd ${LCRYPTO_SRC}/des ${LCRYPTO_SRC}/rc2 \
158 ${LCRYPTO_SRC}/rc4 ${LCRYPTO_SRC}/rc5 ${LCRYPTO_SRC}/idea ${LCRYPTO_SRC}/bf \
159 ${LCRYPTO_SRC}/cast ${LCRYPTO_SRC}/bn ${LCRYPTO_SRC}/rsa ${LCRYPTO_SRC}/dsa \
160 ${LCRYPTO_SRC}/dh ${LCRYPTO_SRC}/buffer ${LCRYPTO_SRC}/bio ${LCRYPTO_SRC}/stack \
161 ${LCRYPTO_SRC}/lhash ${LCRYPTO_SRC}/rand ${LCRYPTO_SRC}/err ${LCRYPTO_SRC}/objects \
162 ${LCRYPTO_SRC}/evp ${LCRYPTO_SRC}/pem ${LCRYPTO_SRC}/asn1 ${LCRYPTO_SRC}/asn1 \
163 ${LCRYPTO_SRC}/x509 ${LCRYPTO_SRC}/conf txt_db/txt_db.c ${LCRYPTO_SRC}/pkcs7 \
164 ${LCRYPTO_SRC}/txt_db ${LCRYPTO_SRC}
165
166includes:
167 @test -d ${DESTDIR}/usr/include/ssl || mkdir ${DESTDIR}/usr/include/ssl
168 @cd ${LCRYPTO_SRC}; for i in $(HDRS); do \
169 j="cmp -s ${LCRYPTO_SRC}/$$i \
170 ${DESTDIR}/usr/include/ssl/`basename $$i` || \
171 ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
172 ${LCRYPTO_SRC}/$$i ${DESTDIR}/usr/include/ssl"; \
173 echo $$j; \
174 eval "$$j"; \
175 done
176
177
178.include <bsd.lib.mk>
179
diff --git a/src/lib/libssl/crypto-patent/shlib_version b/src/lib/libssl/crypto-patent/shlib_version
new file mode 100644
index 0000000000..893819d18f
--- /dev/null
+++ b/src/lib/libssl/crypto-patent/shlib_version
@@ -0,0 +1,2 @@
1major=1
2minor=1
diff --git a/src/lib/libssl/crypto/Makefile b/src/lib/libssl/crypto/Makefile
new file mode 100644
index 0000000000..9db529295b
--- /dev/null
+++ b/src/lib/libssl/crypto/Makefile
@@ -0,0 +1,183 @@
1
2LIB= crypto
3
4SSLEAYDIST= src
5
6LCRYPTO_SRC= ${.CURDIR}/../${SSLEAYDIST}/crypto
7
8.if ${MACHINE_ARCH} == "i386"
9CFLAGS+= -DL_ENDIAN -DBN_ASM
10.else
11.if ${MACHINE_ARCH} == "arc"
12CFLAGS+= -DL_ENDIAN
13.else
14.if ${MACHINE_ARCH} == "pmax"
15CFLAGS+= -DL_ENDIAN
16.else
17.if ${MACHINE_ARCH} == "alpha"
18# no ENDIAN stuff defined for alpha
19.else
20CFLAGS+= -DB_ENDIAN
21.endif
22.endif
23.endif
24.endif
25
26CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE
27CFLAGS+= -I${.CURDIR}/../${SSLEAYDIST}
28CFLAGS+= -I${LCRYPTO_SRC}
29SRCS+= cryptlib.c mem.c cversion.c ex_data.c cpt_err.c
30CFLAGS+= -I${LCRYPTO_SRC}/md2
31SRCS+= md2_dgst.c md2_one.c
32CFLAGS+= -I${LCRYPTO_SRC}/md5
33SRCS+= md5_dgst.c md5_one.c
34CFLAGS+= -I${LCRYPTO_SRC}/sha
35SRCS+= sha_dgst.c sha1dgst.c sha_one.c sha1_one.c
36CFLAGS+= -I${LCRYPTO_SRC}/mdc2
37SRCS+= mdc2dgst.c mdc2_one.c
38CFLAGS+= -I${LCRYPTO_SRC}/hmac
39SRCS+= hmac.c
40CFLAGS+= -I${LCRYPTO_SRC}/ripemd
41SRCS+= rmd_dgst.c rmd_one.c
42CFLAGS+= -I${LCRYPTO_SRC}/des
43SRCS+= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
44 ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \
45 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
46 qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
47 des_enc.c fcrypt_b.c read2pwd.c \
48 fcrypt.c xcbc_enc.c \
49 str2key.c cfb64ede.c ofb64ede.c supp.c
50CFLAGS+= -I${LCRYPTO_SRC}/rc2
51SRCS+= rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c
52SRCS+= rc2ofb64.c
53CFLAGS+= -I${LCRYPTO_SRC}/rc4
54SRCS+= rc4_skey.c rc4_enc.c
55CFLAGS+= -I${LCRYPTO_SRC}/rc5
56SRCS+= rc5_skey.c rc5_ecb.c rc5cfb64.c rc5cfb64.c
57SRCS+= rc5ofb64.c rc5_enc.c
58CFLAGS+= -I${LCRYPTO_SRC}/idea
59SRCS+= i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c
60SRCS+= i_skey.c
61CFLAGS+= -I${LCRYPTO_SRC}/bf
62SRCS+= bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c bf_enc.c
63CFLAGS+= -I${LCRYPTO_SRC}/cast
64SRCS+= c_skey.c c_ecb.c c_cfb64.c c_ofb64.c c_enc.c
65CFLAGS+= -I${LCRYPTO_SRC}/bn
66SRCS+= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c
67SRCS+= bn_mul.c bn_print.c bn_rand.c bn_shift.c bn_sub.c
68SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c
69SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c
70SRCS+= bn_mulw.c
71CFLAGS+= -I${LCRYPTO_SRC}/rsa
72SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c
73SRCS+= rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c
74SRCS+= rsa_none.c
75CFLAGS+= -I${LCRYPTO_SRC}/dsa
76SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c
77SRCS+= dsa_sign.c dsa_err.c
78CFLAGS+= -I${LCRYPTO_SRC}/dh
79SRCS+= dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c
80CFLAGS+= -I${LCRYPTO_SRC}/buffer
81SRCS+= buffer.c buf_err.c
82CFLAGS+= -I${LCRYPTO_SRC}/bio
83SRCS+= bio_lib.c bio_cb.c bio_err.c bss_mem.c
84SRCS+= bss_null.c bss_fd.c bss_file.c bss_sock.c
85SRCS+= bss_conn.c bf_null.c bf_buff.c
86SRCS+= b_print.c b_dump.c b_sock.c bss_acpt.c
87SRCS+= bf_nbio.c
88CFLAGS+= -I${LCRYPTO_SRC}/stack
89SRCS+= stack.c
90CFLAGS+= -I${LCRYPTO_SRC}/lhash
91SRCS+= lhash.c lh_stats.c
92CFLAGS+= -I${LCRYPTO_SRC}/rand
93SRCS+= md_rand.c randfile.c
94CFLAGS+= -I${LCRYPTO_SRC}/err
95SRCS+= err.c err_all.c err_prn.c
96CFLAGS+= -I${LCRYPTO_SRC}/objects
97SRCS+= obj_dat.c obj_lib.c obj_err.c
98CFLAGS+= -I${LCRYPTO_SRC}/evp
99SRCS+= encode.c digest.c evp_enc.c evp_key.c
100SRCS+= e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c
101SRCS+= e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c
102SRCS+= e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c
103SRCS+= e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c e_ecb_r2.c
104SRCS+= e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c e_ecb_bf.c
105SRCS+= e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c e_ecb_c.c
106SRCS+= e_cbc_c.c e_cfb_c.c e_ofb_c.c e_ecb_r5.c
107SRCS+= e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c m_null.c
108SRCS+= m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c
109SRCS+= m_dss1.c m_mdc2.c m_ripemd.c p_open.c
110SRCS+= p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c
111SRCS+= p_dec.c bio_md.c bio_b64.c bio_enc.c
112SRCS+= evp_err.c e_null.c c_all.c evp_lib.c
113CFLAGS+= -I${LCRYPTO_SRC}/pem
114SRCS+= pem_sign.c pem_seal.c pem_info.c pem_lib.c
115SRCS+= pem_all.c pem_err.c
116CFLAGS+= -I${LCRYPTO_SRC}/asn1
117SRCS+= a_object.c a_bitstr.c a_utctm.c a_int.c
118SRCS+= a_octet.c a_print.c a_type.c a_set.c
119SRCS+= a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c
120SRCS+= a_digest.c a_verify.c x_algor.c x_val.c
121SRCS+= x_pubkey.c x_sig.c x_req.c x_attrib.c
122SRCS+= x_name.c x_cinf.c x_x509.c x_crl.c
123SRCS+= x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c
124SRCS+= d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c
125SRCS+= d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c
126SRCS+= i2d_pu.c i2d_pr.c t_req.c t_x509.c
127SRCS+= t_pkey.c p7_i_s.c p7_signi.c p7_signd.c
128SRCS+= p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c
129SRCS+= p7_s_e.c p7_enc.c p7_lib.c f_int.c
130SRCS+= f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c
131SRCS+= d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c
132SRCS+= a_bool.c x_exten.c asn1_par.c asn1_lib.c
133SRCS+= asn1_err.c a_meth.c a_bytes.c evp_asn1.c
134CFLAGS+= -I${LCRYPTO_SRC}/x509
135SRCS+= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c
136SRCS+= x509_obj.c x509_req.c x509_vfy.c x509_set.c
137SRCS+= x509rset.c x509_err.c x509name.c x509_v3.c
138SRCS+= x509_ext.c x509pack.c x509type.c x509_lu.c
139SRCS+= x_all.c x509_txt.c by_file.c by_dir.c
140SRCS+= v3_net.c v3_x509.c
141CFLAGS+= -I${LCRYPTO_SRC}/conf
142SRCS+= conf.c conf_err.c
143CFLAGS+= -I${LCRYPTO_SRC}/txt_db
144SRCS+= txt_db.c
145CFLAGS+= -I${LCRYPTO_SRC}/pkcs7
146SRCS+= pk7_lib.c pkcs7err.c pk7_doit.c
147
148HDRS= asn1/asn1.h asn1/asn1_mac.h bf/blowfish.h bio/bio.h \
149 bn/bn.h buffer/buffer.h cast/cast.h conf/conf.h des/des.h dh/dh.h \
150 dsa/dsa.h err/err.h evp/evp.h hmac/hmac.h idea/idea.h lhash/lhash.h \
151 md2/md2.h md5/md5.h mdc2/mdc2.h objects/objects.h pem/pem.h \
152 pkcs7/pkcs7.h rand/rand.h rc2/rc2.h rc4/rc4.h rc5/rc5.h \
153 ripemd/ripemd.h rsa/rsa.h sha/sha.h stack/stack.h txt_db/txt_db.h \
154 x509/x509.h x509/x509_vfy.h crypto.h cryptall.h ../e_os.h
155
156.PATH: ${LCRYPTO_SRC}/md2 ${LCRYPTO_SRC}/md5 ${LCRYPTO_SRC}/sha ${LCRYPTO_SRC}/mdc2 \
157 ${LCRYPTO_SRC}/hmac ${LCRYPTO_SRC}/ripemd ${LCRYPTO_SRC}/des ${LCRYPTO_SRC}/rc2 \
158 ${LCRYPTO_SRC}/rc4 ${LCRYPTO_SRC}/rc5 ${LCRYPTO_SRC}/idea ${LCRYPTO_SRC}/bf \
159 ${LCRYPTO_SRC}/cast ${LCRYPTO_SRC}/bn ${LCRYPTO_SRC}/rsa ${LCRYPTO_SRC}/dsa \
160 ${LCRYPTO_SRC}/dh ${LCRYPTO_SRC}/buffer ${LCRYPTO_SRC}/bio ${LCRYPTO_SRC}/stack \
161 ${LCRYPTO_SRC}/lhash ${LCRYPTO_SRC}/rand ${LCRYPTO_SRC}/err ${LCRYPTO_SRC}/objects \
162 ${LCRYPTO_SRC}/evp ${LCRYPTO_SRC}/pem ${LCRYPTO_SRC}/asn1 ${LCRYPTO_SRC}/asn1 \
163 ${LCRYPTO_SRC}/x509 ${LCRYPTO_SRC}/conf txt_db/txt_db.c ${LCRYPTO_SRC}/pkcs7 \
164 ${LCRYPTO_SRC}/txt_db ${LCRYPTO_SRC}
165
166includes:
167 @test -d ${DESTDIR}/usr/include/ssl || mkdir ${DESTDIR}/usr/include/ssl
168 @d=`mktemp -d /tmp/libsslXXXXXXXXXX`; \
169 cd ${LCRYPTO_SRC}; for i in $(HDRS); do \
170 f=`basename $$i`; \
171 j="sed 's/#include \"\\([^\"]*\\)\"/#include <ssl\\/\\1>/' \
172 ${LCRYPTO_SRC}/$$i >$$d/$$f && \
173 (cmp -s $$d/$$f ${DESTDIR}/usr/include/ssl/$$f || \
174 ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
175 $$d/$$f ${DESTDIR}/usr/include/ssl)"; \
176 echo $$j; \
177 eval "$$j"; \
178 done; \
179 rm -rf $$d
180
181
182.include <bsd.lib.mk>
183
diff --git a/src/lib/libssl/crypto/shlib_version b/src/lib/libssl/crypto/shlib_version
new file mode 100644
index 0000000000..1edea46de9
--- /dev/null
+++ b/src/lib/libssl/crypto/shlib_version
@@ -0,0 +1,2 @@
1major=1
2minor=0
diff --git a/src/lib/libssl/src/COPYRIGHT b/src/lib/libssl/src/COPYRIGHT
new file mode 100644
index 0000000000..4faa8c0a46
--- /dev/null
+++ b/src/lib/libssl/src/COPYRIGHT
@@ -0,0 +1,65 @@
1Copyright (C) 1997 Eric Young (eay@cryptsoft.com)
2All rights reserved.
3
4This package is an SSL implementation written by Eric Young (eay@cryptsoft.com).
5The implementation was written so as to conform with Netscapes SSL.
6
7This library is free for commercial and non-commercial use as long as
8the following conditions are aheared to. The following conditions
9apply to all code found in this distribution, be it the RC4, RSA,
10lhash, DES, etc., code; not just the SSL code. The SSL documentation
11included with this distribution is covered by the same copyright terms
12except that the holder is Tim Hudson (tjh@cryptsoft.com).
13
14Please note that MD2, MD5 and IDEA are publically available standards
15that contain sample implementations, I have re-coded them in my own
16way but there is nothing special about those implementations. The DES
17library is another mater :-).
18
19Copyright remains Eric Young's, and as such any Copyright notices in
20the code are not to be removed.
21If this package is used in a product, Eric Young should be given attribution
22as the author of the parts of the library used.
23This can be in the form of a textual message at program startup or
24in documentation (online or textual) provided with the package.
25
26Redistribution and use in source and binary forms, with or without
27modification, are permitted provided that the following conditions
28are met:
291. Redistributions of source code must retain the copyright
30 notice, this list of conditions and the following disclaimer.
312. Redistributions in binary form must reproduce the above copyright
32 notice, this list of conditions and the following disclaimer in the
33 documentation and/or other materials provided with the distribution.
343. All advertising materials mentioning features or use of this software
35 must display the following acknowledgement:
36 "This product includes cryptographic software written by
37 Eric Young (eay@cryptsoft.com)"
38 The word 'cryptographic' can be left out if the rouines from the library
39 being used are not cryptographic related :-).
404. If you include any Windows specific code (or a derivative thereof) from
41 the apps directory (application code) you must include an acknowledgement:
42 "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
43
44THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
45ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
48FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
54SUCH DAMAGE.
55
56The licence and distribution terms for any publically available version or
57derivative of this code cannot be changed. i.e. this code cannot simply be
58copied and put under another distribution licence
59[including the GNU Public Licence.]
60
61The reason behind this being stated in this direct manner is past
62experience in code simply being copied and the attribution removed
63from it and then being distributed as part of other packages. This
64implementation was a non-trivial and unpaid effort.
65
diff --git a/src/lib/libssl/src/Configure b/src/lib/libssl/src/Configure
index 1dc0ed320c..8b9ecbcdef 100644
--- a/src/lib/libssl/src/Configure
+++ b/src/lib/libssl/src/Configure
@@ -135,6 +135,8 @@ $x86_bsdi_asm="asm/bn86bsdi.o:asm/dx86bsdi.o asm/yx86bsdi.o:asm/bx86bsdi.o:asm/m
135"OpenBSD-alpha","gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall::SIXTY_FOUR_BIT_LONGS DES_INT DES_PTR DES_RISC2:::", 135"OpenBSD-alpha","gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall::SIXTY_FOUR_BIT_LONGS DES_INT DES_PTR DES_RISC2:::",
136"OpenBSD-x86", "gcc:-DTERMIOS -DBN_ASM -DL_ENDIAN -D_ANSI_SOURCE -fomit-frame-pointer -O3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm", 136"OpenBSD-x86", "gcc:-DTERMIOS -DBN_ASM -DL_ENDIAN -D_ANSI_SOURCE -fomit-frame-pointer -O3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm",
137"OpenBSD-bigendian", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::", 137"OpenBSD-bigendian", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::",
138"OpenBSD-pmax", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DL_ENDIAN::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::",
139"OpenBSD-arc", "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DL_ENDIAN::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::",
138"FreeBSD", "gcc:-DTERMIOS -DBN_ASM -DL_ENDIAN -D_ANSI_SOURCE -fomit-frame-pointer -O3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm", 140"FreeBSD", "gcc:-DTERMIOS -DBN_ASM -DL_ENDIAN -D_ANSI_SOURCE -fomit-frame-pointer -O3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm",
139#"bsdi-gcc", "gcc:-O3 -ffast-math -DBN_ASM -DL_ENDIAN -DPERL5 -m486::RSA_LLONG $x86_gc_des $x86_gcc_opts:$x86_bsdi_asm", 141#"bsdi-gcc", "gcc:-O3 -ffast-math -DBN_ASM -DL_ENDIAN -DPERL5 -m486::RSA_LLONG $x86_gc_des $x86_gcc_opts:$x86_bsdi_asm",
140"nextstep", "cc:-O3 -Wall -DBN_ASM::BN_LLONG $x86_gcc_des $x86_gcc_opts:::", 142"nextstep", "cc:-O3 -Wall -DBN_ASM::BN_LLONG $x86_gcc_des $x86_gcc_opts:::",
diff --git a/src/lib/libssl/src/HISTORY b/src/lib/libssl/src/HISTORY
new file mode 100644
index 0000000000..7712100038
--- /dev/null
+++ b/src/lib/libssl/src/HISTORY
@@ -0,0 +1,316 @@
116-Mar-98
2 - Patch for Cray T90 from Wayne Schroeder <schroede@SDSC.EDU>
3 - Lots and lots of changes
4
529-Jan-98
6 - ASN1_BIT_STRING_set_bit()/ASN1_BIT_STRING_get_bit() from
7 Goetz Babin-Ebell <babinebell@trustcenter.de>.
8 - SSL_version() now returns SSL2_VERSION, SSL3_VERSION or
9 TLS1_VERSION.
10
117-Jan-98
12 - Finally reworked the cipher string to ciphers again, so it
13 works correctly
14 - All the app_data stuff is now ex_data with funcion calls to access.
15 The index is supplied by a function and 'methods' can be setup
16 for the types that are called on XXX_new/XXX_free. This lets
17 applications get notified on creation and destruction. Some of
18 the RSA methods could be implemented this way and I may do so.
19 - Oh yes, SSL under perl5 is working at the basic level.
20
2115-Dec-97
22 - Warning - the gethostbyname cache is not fully thread safe,
23 but it should work well enough.
24 - Major internal reworking of the app_data stuff. More functions
25 but if you were accessing ->app_data directly, things will
26 stop working.
27 - The perlv5 stuff is working. Currently on message digests,
28 ciphers and the bignum library.
29
309-Dec-97
31 - Modified re-negotiation so that server initated re-neg
32 will cause a SSL_read() to return -1 should retry.
33 The danger otherwise was that the server and the
34 client could end up both trying to read when using non-blocking
35 sockets.
36
374-Dec-97
38 - Lots of small changes
39 - Fix for binaray mode in Windows for the FILE BIO, thanks to
40 Bob Denny <rdenny@dc3.com>
41
4217-Nov-97
43 - Quite a few internal cleanups, (removal of errno, and using macros
44 defined in e_os.h).
45 - A bug in ca.c, pointed out by yasuyuki-ito@d-cruise.co.jp, where
46 the automactic naming out output files was being stuffed up.
47
4829-Oct-97
49 - The Cast5 cipher has been added. MD5 and SHA-1 are now in assember
50 for x86.
51
5221-Oct-97
53 - Fixed a bug in the BIO_gethostbyname() cache.
54
5515-Oct-97
56 - cbc mode for blowfish/des/3des is now in assember. Blowfish asm
57 has also been improved. At this point in time, on the pentium,
58 md5 is %80 faster, the unoptimesed sha-1 is %79 faster,
59 des-cbc is %28 faster, des-ede3-cbc is %9 faster and blowfish-cbc
60 is %62 faster.
61
6212-Oct-97
63 - MEM_BUF_grow() has been fixed so that it always sets the buf->length
64 to the value we are 'growing' to. Think of MEM_BUF_grow() as the
65 way to set the length value correctly.
66
6710-Oct-97
68 - I now hash for certificate lookup on the raw DER encoded RDN (md5).
69 This breaks things again :-(. This is efficent since I cache
70 the DER encoding of the RDN.
71 - The text DN now puts in the numeric OID instead of UNKNOWN.
72 - req can now process arbitary OIDs in the config file.
73 - I've been implementing md5 in x86 asm, much faster :-).
74 - Started sha1 in x86 asm, needs more work.
75 - Quite a few speedups in the BN stuff. RSA public operation
76 has been made faster by caching the BN_MONT_CTX structure.
77 The calulating of the Ai where A*Ai === 1 mod m was rather
78 expensive. Basically a 40-50% speedup on public operations.
79 The RSA speedup is now 15% on pentiums and %20 on pentium
80 pro.
81
8230-Sep-97
83 - After doing some profiling, I added x86 adm for bn_add_words(),
84 which just adds 2 arrays of longs together. A %10 speedup
85 for 512 and 1024 bit RSA on the pentium pro.
86
8729-Sep-97
88 - Converted the x86 bignum assembler to us the perl scripts
89 for generation.
90
9123-Sep-97
92 - If SSL_set_session() is passed a NULL session, it now clears the
93 current session-id.
94
9522-Sep-97
96 - Added a '-ss_cert file' to apps/ca.c. This will sign selfsigned
97 certificates.
98 - Bug in crypto/evp/encode.c where by decoding of 65 base64
99 encoded lines, one line at a time (via a memory BIO) would report
100 EOF after the first line was decoded.
101 - Fix in X509_find_by_issuer_and_serial() from
102 Dr Stephen Henson <shenson@bigfoot.com>
103
10419-Sep-97
105 - NO_FP_API and NO_STDIO added.
106 - Put in sh config command. It auto runs Configure with the correct
107 parameters.
108
10918-Sep-97
110 - Fix x509.c so if a DSA cert has different parameters to its parent,
111 they are left in place. Not tested yet.
112
11316-Sep-97
114 - ssl_create_cipher_list() had some bugs, fixes from
115 Patrick Eisenacher <eisenach@stud.uni-frankfurt.de>
116 - Fixed a bug in the Base64 BIO, where it would return 1 instead
117 of -1 when end of input was encountered but should retry.
118 Basically a Base64/Memory BIO interaction problem.
119 - Added a HMAC set of functions in preporarion for TLS work.
120
12115-Sep-97
122 - Top level makefile tweak - Cameron Simpson <cs@zip.com.au>
123 - Prime generation spead up %25 (512 bit prime, pentium pro linux)
124 by using montgomery multiplication in the prime number test.
125
12611-Sep-97
127 - Ugly bug in ssl3_write_bytes(). Basically if application land
128 does a SSL_write(ssl,buf,len) where len > 16k, the SSLv3 write code
129 did not check the size and tried to copy the entire buffer.
130 This would tend to cause memory overwrites since SSLv3 has
131 a maximum packet size of 16k. If your program uses
132 buffers <= 16k, you would probably never see this problem.
133 - Fixed a new errors that were cause by malloc() not returning
134 0 initialised memory..
135 - SSL_OP_NETSCAPE_CA_DN_BUG was being switched on when using
136 SSL_CTX_set_options(ssl_ctx,SSL_OP_ALL); which was a bad thing
137 since this flags stops SSLeay being able to handle client
138 cert requests correctly.
139
14008-Sep-97
141 - SSL_SESS_CACHE_NO_INTERNAL_LOOKUP option added. When switched
142 on, the SSL server routines will not use a SSL_SESSION that is
143 held in it's cache. This in intended to be used with the session-id
144 callbacks so that while the session-ids are still stored in the
145 cache, the decision to use them and how to look them up can be
146 done by the callbacks. The are the 'new', 'get' and 'remove'
147 callbacks. This can be used to determine the session-id
148 to use depending on information like which port/host the connection
149 is coming from. Since the are also SSL_SESSION_set_app_data() and
150 SSL_SESSION_get_app_data() functions, the application can hold
151 information against the session-id as well.
152
15303-Sep-97
154 - Added lookup of CRLs to the by_dir method,
155 X509_load_crl_file() also added. Basically it means you can
156 lookup CRLs via the same system used to lookup certificates.
157 - Changed things so that the X509_NAME structure can contain
158 ASN.1 BIT_STRINGS which is required for the unique
159 identifier OID.
160 - Fixed some problems with the auto flushing of the session-id
161 cache. It was not occuring on the server side.
162
16302-Sep-97
164 - Added SSL_CTX_sess_cache_size(SSL_CTX *ctx,unsigned long size)
165 which is the maximum number of entries allowed in the
166 session-id cache. This is enforced with a simple FIFO list.
167 The default size is 20*1024 entries which is rather large :-).
168 The Timeout code is still always operating.
169
17001-Sep-97
171 - Added an argument to all the 'generate private key/prime`
172 callbacks. It is the last parameter so this should not
173 break existing code but it is needed for C++.
174 - Added the BIO_FLAGS_BASE64_NO_NL flag for the BIO_f_base64()
175 BIO. This lets the BIO read and write base64 encoded data
176 without inserting or looking for '\n' characters. The '-A'
177 flag turns this on when using apps/enc.c.
178 - RSA_NO_PADDING added to help BSAFE functionality. This is a
179 very dangerous thing to use, since RSA private key
180 operations without random padding bytes (as PKCS#1 adds) can
181 be attacked such that the private key can be revealed.
182 - ASN.1 bug and rc2-40-cbc and rc4-40 added by
183 Dr Stephen Henson <shenson@bigfoot.com>
184
18531-Aug-97 (stuff added while I was away)
186 - Linux pthreads by Tim Hudson (tjh@cryptsoft.com).
187 - RSA_flags() added allowing bypass of pub/priv match check
188 in ssl/ssl_rsa.c - Tim Hudson.
189 - A few minor bugs.
190
191SSLeay 0.8.1 released.
192
19319-Jul-97
194 - Server side initated dynamic renegotiation is broken. I will fix
195 it when I get back from holidays.
196
19715-Jul-97
198 - Quite a few small changes.
199 - INVALID_SOCKET usage cleanups from Alex Kiernan <alex@hisoft.co.uk>
200
20109-Jul-97
202 - Added 2 new values to the SSL info callback.
203 SSL_CB_START which is passed when the SSL protocol is started
204 and SSL_CB_DONE when it has finished sucsessfully.
205
20608-Jul-97
207 - Fixed a few bugs problems in apps/req.c and crypto/asn1/x_pkey.c
208 that related to DSA public/private keys.
209 - Added all the relevent PEM and normal IO functions to support
210 reading and writing RSAPublic keys.
211 - Changed makefiles to use ${AR} instead of 'ar r'
212
21307-Jul-97
214 - Error in ERR_remove_state() that would leave a dangling reference
215 to a free()ed location - thanks to Alex Kiernan <alex@hisoft.co.uk>
216 - s_client now prints the X509_NAMEs passed from the server
217 when requesting a client cert.
218 - Added a ssl->type, which is one of SSL_ST_CONNECT or
219 SSL_ST_ACCEPT. I had to add it so I could tell if I was
220 a connect or an accept after the handshake had finished.
221 - SSL_get_client_CA_list(SSL *s) now returns the CA names
222 passed by the server if called by a client side SSL.
223
22405-Jul-97
225 - Bug in X509_NAME_get_text_by_OBJ(), looking starting at index
226 0, not -1 :-( Fix from Tim Hudson (tjh@cryptsoft.com).
227
22804-Jul-97
229 - Fixed some things in X509_NAME_add_entry(), thanks to
230 Matthew Donald <matthew@world.net>.
231 - I had a look at the cipher section and though that it was a
232 bit confused, so I've changed it.
233 - I was not setting up the RC4-64-MD5 cipher correctly. It is
234 a MS special that appears in exported MS Money.
235 - Error in all my DH ciphers. Section 7.6.7.3 of the SSLv3
236 spec. I was missing the two byte length header for the
237 ClientDiffieHellmanPublic value. This is a packet sent from
238 the client to the server. The SSL_OP_SSLEAY_080_CLIENT_DH_BUG
239 option will enable SSLeay server side SSLv3 accept either
240 the correct or my 080 packet format.
241 - Fixed a few typos in crypto/pem.org.
242
24302-Jul-97
244 - Alias mapping for EVP_get_(digest|cipher)byname is now
245 performed before a lookup for actual cipher. This means
246 that an alias can be used to 're-direct' a cipher or a
247 digest.
248 - ASN1_read_bio() had a bug that only showed up when using a
249 memory BIO. When EOF is reached in the memory BIO, it is
250 reported as a -1 with BIO_should_retry() set to true.
251
25201-Jul-97
253 - Fixed an error in X509_verify_cert() caused by my
254 miss-understanding how 'do { contine } while(0);' works.
255 Thanks to Emil Sit <sit@mit.edu> for educating me :-)
256
25730-Jun-97
258 - Base64 decoding error. If the last data line did not end with
259 a '=', sometimes extra data would be returned.
260 - Another 'cut and paste' bug in x509.c related to setting up the
261 STDout BIO.
262
26327-Jun-97
264 - apps/ciphers.c was not printing due to an editing error.
265 - Alex Kiernan <alex@hisoft.co.uk> send in a nice fix for
266 a library build error in util/mk1mf.pl
267
26826-Jun-97
269 - Still did not have the auto 'experimental' code removal
270 script correct.
271 - A few header tweaks for Watcom 11.0 under Win32 from
272 Rolf Lindemann <Lindemann@maz-hh.de>
273 - 0 length OCTET_STRING bug in asn1_parse
274 - A minor fix with an non-existent function in the MS .def files.
275 - A few changes to the PKCS7 stuff.
276
27725-Jun-97
278 SSLeay 0.8.0 finally it gets released.
279
28024-Jun-97
281 Added a SSL_OP_EPHEMERAL_RSA option which causes all SSLv3 RSA keys to
282 use a temporary RSA key. This is experimental and needs some more work.
283 Fixed a few Win16 build problems.
284
28523-Jun-97
286 SSLv3 bug. I was not doing the 'lookup' of the CERT structure
287 correctly. I was taking the SSL->ctx->default_cert when I should
288 have been using SSL->cert. The bug was in ssl/s3_srvr.c
289
29020-Jun-97
291 X509_ATTRIBUTES were being encoded wrongly by apps/reg.c and the
292 rest of the library. Even though I had the code required to do
293 it correctly, apps/req.c was doing the wrong thing. I have fixed
294 and tested everything.
295
296 Missing a few #ifdef FIONBIO sections in crypto/bio/bss_acpt.c.
297
29819-Jun-97
299 Fixed a bug in the SSLv2 server side first packet handling. When
300 using the non-blocking test BIO, the ssl->s2->first_packet flag
301 was being reset when a would-block failure occurred when reading
302 the first 5 bytes of the first packet. This caused the checking
303 logic to run at the wrong time and cause an error.
304
305 Fixed a problem with specifying cipher. If RC4-MD5 were used,
306 only the SSLv3 version would be picked up. Now this will pick
307 up both SSLv2 and SSLv3 versions. This required changing the
308 SSL_CIPHER->mask values so that they only mask the ciphers,
309 digests, authentication, export type and key-exchange algorithms.
310
311 I found that when a SSLv23 session is established, a reused
312 session, of type SSLv3 was attempting to write the SSLv2
313 ciphers, which were invalid. The SSL_METHOD->put_cipher_by_char
314 method has been modified so it will only write out cipher which
315 that method knows about.
316
diff --git a/src/lib/libssl/src/HISTORY.066 b/src/lib/libssl/src/HISTORY.066
new file mode 100644
index 0000000000..f85224977a
--- /dev/null
+++ b/src/lib/libssl/src/HISTORY.066
@@ -0,0 +1,443 @@
1SSLeay 0.6.5
2
3After quite some time (3 months), the new release. I have been very busy
4for the last few months and so this is mostly bug fixes and improvments.
5
6The main additions are
7
8- assember for x86 DES. For all those gcc based systems, this is a big
9 improvement. From 117,000 DES operation a second on a pentium 100,
10 I now get 191,000. I have also reworked the C version so it
11 now gives 148,000 DESs per second.
12- As mentioned above, the inner DES macros now have some more variant that
13 sometimes help, sometimes hinder performance. There are now 3 options
14 DES_PTR (ptr vs array lookup), DES_UNROLL (full vs partial loop unrolling)
15 and DES_RISC (a more register intensive version of the inner macro).
16 The crypto/des/des_opts.c program, when compiled and run, will give
17 an indication of the correct options to use.
18- The BIO stuff has been improved. Read doc/bio.doc. There are now
19 modules for encryption and base64 encoding and a BIO_printf() function.
20- The CA program will accept simple one line X509v3 extensions in the
21 ssleay.cnf file. Have a look at the example. Currently this just
22 puts the text into the certificate as an OCTET_STRING so currently
23 the more advanced X509v3 data types are not handled but this is enough
24 for the netscape extensions.
25- There is the start of a nicer higher level interface to the X509
26 strucutre.
27- Quite a lot of bug fixes.
28- CRYPTO_malloc_init() (or CRYPTO_set_mem_functions()) can be used
29 to define the malloc(), free() and realloc() routines to use
30 (look in crypto/crypto.h). This is mostly needed for Windows NT/95 when
31 using DLLs and mixing CRT libraries.
32
33In general, read the 'VERSION' file for changes and be aware that some of
34the new stuff may not have been tested quite enough yet, so don't just plonk
35in SSLeay 0.6.5 when 0.6.4 used to work and expect nothing to break.
36
37SSLeay 0.6.4 30/08/96 eay
38
39I've just finished some test builds on Windows NT, Windows 3.1, Solaris 2.3,
40Solaris 2.5, Linux, IRIX, HPUX 10 and everthing seems to work :-).
41
42The main changes in this release
43
44- Thread safe. have a read of doc/threads.doc and play in the mt directory.
45 For anyone using 0.6.3 with threads, I found 2 major errors so consider
46 moving to 0.6.4. I have a test program that builds under NT and
47 solaris.
48- The get session-id callback has changed. Have a read of doc/callback.doc.
49- The X509_cert_verify callback (the SSL_verify callback) now
50 has another argument. Have a read of doc/callback.doc
51- 'ca -preserve', sign without re-ordering the DN. Not tested much.
52- VMS support.
53- Compile time memory leak detection can now be built into SSLeay.
54 Read doc/memory.doc
55- CONF routines now understand '\', '\n', '\r' etc. What this means is that
56 the SPKAC object mentioned in doc/ns-ca.doc can be on multiple lines.
57- 'ssleay ciphers' added, lists the default cipher list for SSLeay.
58- RC2 key setup is now compatable with Netscape.
59- Modifed server side of SSL implementation, big performance difference when
60 using session-id reuse.
61
620.6.3
63
64Bug fixes and the addition of some nice stuff to the 'ca' program.
65Have a read of doc/ns-ca.doc for how hit has been modified so
66it can be driven from a CGI script. The CGI script is not provided,
67but that is just being left as an excersize for the reader :-).
68
690.6.2
70
71This is most bug fixes and functionality improvements.
72
73Additions are
74- More thread debugging patches, the thread stuff is still being
75 tested, but for those keep to play with stuff, have a look in
76 crypto/cryptlib.c. The application needs to define 1 (or optionaly
77 a second) callback that is used to implement locking. Compiling
78 with LOCK_DEBUG spits out lots of locking crud :-).
79 This is what I'm currently working on.
80- SSL_CTX_set_default_passwd_cb() can be used to define the callback
81 function used in the SSL*_file() functions used to load keys. I was
82 always of the opinion that people should call
83 PEM_read_RSAPrivateKey() and pass the callback they want to use, but
84 it appears they just want to use the SSL_*_file() function() :-(.
85- 'enc' now has a -kfile so a key can be read from a file. This is
86 mostly used so that the passwd does not appear when using 'ps',
87 which appears imposible to stop under solaris.
88- X509v3 certificates now work correctly. I even have more examples
89 in my tests :-). There is now a X509_EXTENSION type that is used in
90 X509v3 certificates and CRLv2.
91- Fixed that signature type error :-(
92- Fixed quite a few potential memory leaks and problems when reusing
93 X509, CRL and REQ structures.
94- EVP_set_pw_prompt() now sets the library wide default password
95 prompt.
96- The 'pkcs7' command will now, given the -print_certs flag, output in
97 pem format, all certificates and CRL contained within. This is more
98 of a pre-emtive thing for the new verisign distribution method. I
99 should also note, that this also gives and example in code, of how
100 to do this :-), or for that matter, what is involved in going the
101 other way (list of certs and crl -> pkcs7).
102- Added RSA's DESX to the DES library. It is also available via the
103 EVP_desx_cbc() method and via 'enc desx'.
104
105SSLeay 0.6.1
106
107The main functional changes since 0.6.0 are as follows
108- Bad news, the Microsoft 060 DLL's are not compatable, but the good news is
109 that from now on, I'll keep the .def numbers the same so they will be.
110- RSA private key operations are about 2 times faster that 0.6.0
111- The SSL_CTX now has more fields so default values can be put against
112 it. When an SSL structure is created, these default values are used
113 but can be overwritten. There are defaults for cipher, certificate,
114 private key, verify mode and callback. This means SSL session
115 creation can now be
116 ssl=SSL_new()
117 SSL_set_fd(ssl,sock);
118 SSL_accept(ssl)
119 ....
120 All the other uglyness with having to keep a global copy of the
121 private key and certificate/verify mode in the server is now gone.
122- ssl/ssltest.c - one process talking SSL to its self for testing.
123- Storage of Session-id's can be controled via a session_cache_mode
124 flag. There is also now an automatic default flushing of
125 old session-id's.
126- The X509_cert_verify() function now has another parameter, this
127 should not effect most people but it now means that the reason for
128 the failure to verify is now available via SSL_get_verify_result(ssl).
129 You don't have to use a global variable.
130- SSL_get_app_data() and SSL_set_app_data() can be used to keep some
131 application data against the SSL structure. It is upto the application
132 to free the data. I don't use it, but it is available.
133- SSL_CTX_set_cert_verify_callback() can be used to specify a
134 verify callback function that completly replaces my certificate
135 verification code. Xcert should be able to use this :-).
136 The callback is of the form int app_verify_callback(arg,ssl,cert).
137 This needs to be documented more.
138- I have started playing with shared library builds, have a look in
139 the shlib directory. It is very simple. If you need a numbered
140 list of functions, have a look at misc/crypto.num and misc/ssl.num.
141- There is some stuff to do locking to make the library thread safe.
142 I have only started this stuff and have not finished. If anyone is
143 keen to do so, please send me the patches when finished.
144
145So I have finally made most of the additions to the SSL interface that
146I thought were needed.
147
148There will probably be a pause before I make any non-bug/documentation
149related changes to SSLeay since I'm feeling like a bit of a break.
150
151eric - 12 Jul 1996
152I saw recently a comment by some-one that we now seem to be entering
153the age of perpetual Beta software.
154Pioneered by packages like linux but refined to an art form by
155netscape.
156
157I too wish to join this trend with the anouncement of SSLeay 0.6.0 :-).
158
159There are quite a large number of sections that are 'works in
160progress' in this package. I will also list the major changes and
161what files you should read.
162
163BIO - this is the new IO structure being used everywhere in SSLeay. I
164started out developing this because of microsoft, I wanted a mechanism
165to callback to the application for all IO, so Windows 3.1 DLL
166perversion could be hidden from me and the 15 different ways to write
167to a file under NT would also not be dictated by me at library build
168time. What the 'package' is is an API for a data structure containing
169functions. IO interfaces can be written to conform to the
170specification. This in not intended to hide the underlying data type
171from the application, but to hide it from SSLeay :-).
172I have only really finished testing the FILE * and socket/fd modules.
173There are also 'filter' BIO's. Currently I have only implemented
174message digests, and it is in use in the dgst application. This
175functionality will allow base64/encrypto/buffering modules to be
176'push' into a BIO without it affecting the semantics. I'm also
177working on an SSL BIO which will hide the SSL_accept()/SLL_connet()
178from an event loop which uses the interface.
179It is also possible to 'attach' callbacks to a BIO so they get called
180before and after each operation, alowing extensive debug output
181to be generated (try running dgst with -d).
182
183Unfortunaly in the conversion from 0.5.x to 0.6.0, quite a few
184functions that used to take FILE *, now take BIO *.
185The wrappers are easy to write
186
187function_fp(fp,x)
188FILE *fp;
189 {
190 BIO *b;
191 int ret;
192
193 if ((b=BIO_new(BIO_s_file())) == NULL) error.....
194 BIO_set_fp(b,fp,BIO_NOCLOSE);
195 ret=function_bio(b,x);
196 BIO_free(b);
197 return(ret);
198 }
199Remember, there are no functions that take FILE * in SSLeay when
200compiled for Windows 3.1 DLL's.
201
202--
203I have added a general EVP_PKEY type that can hold a public/private
204key. This is now what is used by the EVP_ functions and is passed
205around internally. I still have not done the PKCS#8 stuff, but
206X509_PKEY is defined and waiting :-)
207
208--
209For a full function name listings, have a look at ms/crypt32.def and
210ms/ssl32.def. These are auto-generated but are complete.
211Things like ASN1_INTEGER_get() have been added and are in here if you
212look. I have renamed a few things, again, have a look through the
213function list and you will probably find what you are after. I intend
214to at least put a one line descrition for each one.....
215
216--
217Microsoft - thats what this release is about, read the MICROSOFT file.
218
219--
220Multi-threading support. I have started hunting through the code and
221flaging where things need to be done. In a state of work but high on
222the list.
223
224--
225For random numbers, edit e_os.h and set DEVRANDOM (it's near the top)
226be be you random data device, otherwise 'RFILE' in e_os.h
227will be used, in your home directory. It will be updated
228periodically. The environment variable RANDFILE will override this
229choice and read/write to that file instead. DEVRANDOM is used in
230conjunction to the RFILE/RANDFILE. If you wish to 'seed' the random
231number generator, pick on one of these files.
232
233--
234
235The list of things to read and do
236
237dgst -d
238s_client -state (this uses a callback placed in the SSL state loop and
239 will be used else-where to help debug/monitor what
240 is happening.)
241
242doc/why.doc
243doc/bio.doc <- hmmm, needs lots of work.
244doc/bss_file.doc <- one that is working :-)
245doc/session.doc <- it has changed
246doc/speed.doc
247 also play with ssleay version -a. I have now added a SSLeay()
248 function that returns a version number, eg 0600 for this release
249 which is primarily to be used to check DLL version against the
250 application.
251util/* Quite a few will not interest people, but some may, like
252 mk1mf.pl, mkdef.pl,
253util/do_ms.sh
254
255try
256cc -Iinclude -Icrypto -c crypto/crypto.c
257cc -Iinclude -Issl -c ssl/ssl.c
258You have just built the SSLeay libraries as 2 object files :-)
259
260Have a general rummage around in the bin stall directory and look at
261what is in there, like CA.sh and c_rehash
262
263There are lots more things but it is 12:30am on a Friday night and I'm
264heading home :-).
265
266eric 22-Jun-1996
267This version has quite a few major bug fixes and improvements. It DOES NOT
268do SSLv3 yet.
269
270The main things changed
271- A Few days ago I added the s_mult application to ssleay which is
272 a demo of an SSL server running in an event loop type thing.
273 It supports non-blocking IO, I have finally gotten it right, SSL_accept()
274 can operate in non-blocking IO mode, look at the code to see how :-).
275 Have a read of doc/s_mult as well. This program leaks memory and
276 file descriptors everywhere but I have not cleaned it up yet.
277 This is a demo of how to do non-blocking IO.
278- The SSL session management has been 'worked over' and there is now
279 quite an expansive set of functions to manipulate them. Have a read of
280 doc/session.doc for some-things I quickly whipped up about how it now works.
281 This assume you know the SSLv2 protocol :-)
282- I can now read/write the netscape certificate format, use the
283 -inform/-outform 'net' options to the x509 command. I have not put support
284 for this type in the other demo programs, but it would be easy to add.
285- asn1parse and 'enc' have been modified so that when reading base64
286 encoded files (pem format), they do not require '-----BEGIN' header lines.
287 The 'enc' program had a buffering bug fixed, it can be used as a general
288 base64 -> binary -> base64 filter by doing 'enc -a -e' and 'enc -a -d'
289 respecivly. Leaving out the '-a' flag in this case makes the 'enc' command
290 into a form of 'cat'.
291- The 'x509' and 'req' programs have been fixed and modified a little so
292 that they generate self-signed certificates correctly. The test
293 script actually generates a 'CA' certificate and then 'signs' a
294 'user' certificate. Have a look at this shell script (test/sstest)
295 to see how things work, it tests most possible combinations of what can
296 be done.
297- The 'SSL_set_pref_cipher()' function has been 'fixed' and the prefered name
298 of SSL_set_cipher_list() is now the correct API (stops confusion :-).
299 If this function is used in the client, only the specified ciphers can
300 be used, with preference given to the order the ciphers were listed.
301 For the server, if this is used, only the specified ciphers will be used
302 to accept connections. If this 'option' is not used, a default set of
303 ciphers will be used. The SSL_CTX_set_cipher_list(SSL_CTX *ctx) sets this
304 list for all ciphers started against the SSL_CTX. So the order is
305 SSL cipher_list, if not present, SSL_CTX cipher list, if not
306 present, then the library default.
307 What this means is that normally ciphers like
308 NULL-MD5 will never be used. The only way this cipher can be used
309 for both ends to specify to use it.
310 To enable or disable ciphers in the library at build time, modify the
311 first field for the cipher in the ssl_ciphers array in ssl/ssl_lib.c.
312 This file also contains the 'pref_cipher' list which is the default
313 cipher preference order.
314- I'm not currently sure if the 'rsa -inform net' and the 'rsa -outform net'
315 options work. They should, and they enable loading and writing the
316 netscape rsa private key format. I will be re-working this section of
317 SSLeay for the next version. What is currently in place is a quick and
318 dirty hack.
319- I've re-written parts of the bignum library. This gives speedups
320 for all platforms. I now provide assembler for use under Windows NT.
321 I have not tested the Windows 3.1 assembler but it is quite simple code.
322 This gives RSAprivate_key operation encryption times of 0.047s (512bit key)
323 and 0.230s (1024bit key) on a pentium 100 which I consider reasonable.
324 Basically the times available under linux/solaris x86 can be achieve under
325 Windows NT. I still don't know how these times compare to RSA's BSAFE
326 library but I have been emailing with people and with their help, I should
327 be able to get my library's quite a bit faster still (more algorithm changes).
328 The object file crypto/bn/asm/x86-32.obj should be used when linking
329 under NT.
330- 'make makefile.one' in the top directory will generate a single makefile
331 called 'makefile.one' This makefile contains no perl references and
332 will build the SSLeay library into the 'tmp' and 'out' directories.
333 util/mk1mf.pl >makefile.one is how this makefile is
334 generated. The mk1mf.pl command take several option to generate the
335 makefile for use with cc, gcc, Visual C++ and Borland C++. This is
336 still under development. I have only build .lib's for NT and MSDOS
337 I will be working on this more. I still need to play with the
338 correct compiler setups for these compilers and add some more stuff but
339 basically if you just want to compile the library
340 on a 'non-unix' platform, this is a very very good file to start with :-).
341 Have a look in the 'microsoft' directory for my current makefiles.
342 I have not yet modified things to link with sockets under Windows NT.
343 You guys should be able to do this since this is actually outside of the
344 SSLeay scope :-). I will be doing it for myself soon.
345 util/mk1mf.pl takes quite a few options including no-rc, rsaref and no-sock
346 to build without RC2/RC4, to require RSAref for linking, and to
347 build with no socket code.
348
349- Oh yes, the cipher that was reported to be compatible with RSA's RC2 cipher
350 that was posted to sci.crypt has been added to the library and SSL.
351 I take the view that if RC2 is going to be included in a standard,
352 I'll include the cipher to make my package complete.
353 There are NO_RC2, NO_RC4 and NO_IDEA macros to remove these ciphers
354 at compile time. I have not tested this recently but it should all work
355 and if you are in the USA and don't want RSA threatening to sue you,
356 you could probably remove the RC4/RC2 code inside these sections.
357 I may in the future include a perl script that does this code
358 removal automatically for those in the USA :-).
359- I have removed all references to sed in the makefiles. So basically,
360 the development environment requires perl and sh. The build environment
361 does not (use the makefile.one makefile).
362 The Configure script still requires perl, this will probably stay that way
363 since I have perl for Windows NT :-).
364
365eric (03-May-1996)
366
367PS Have a look in the VERSION file for more details on the changes and
368 bug fixes.
369I have fixed a few bugs, added alpha and x86 assembler and generally cleaned
370things up. This version will be quite stable, mostly because I'm on
371holidays until 10-March-1996. For any problems in the interum, send email
372to Tim Hudson <tjh@mincom.oz.au>.
373
374SSLeay 0.5.0
375
37612-12-95
377This is going out before it should really be released.
378
379I leave for 11 weeks holidays on the 22-12-95 and so I either sit on
380this for 11 weeks or get things out. It is still going to change a
381lot in the next week so if you do grab this version, please test and
382give me feed back ASAP, inculuding questions on how to do things with
383the library. This will prompt me to write documentation so I don't
384have to answer the same question again :-).
385
386This 'pre' release version is for people who are interested in the
387library. The applications will have to be changed to use
388the new version of the SSL interface. I intend to finish more
389documentation before I leave but until then, look at the programs in
390the apps directory. As far as code goes, it is much much nicer than
391the old version.
392
393The current library works, has no memory leaks (as far as I can tell)
394and is far more bug free that 0.4.5d. There are no global variable of
395consequence (I believe) and I will produce some documentation that
396tell where to look for those people that do want to do multi-threaded
397stuff.
398
399There should be more documentation. Have a look in the
400doc directory. I'll be adding more before I leave, it is a start
401by mostly documents the crypto library. Tim Hudson will update
402the web page ASAP. The spelling and grammar are crap but
403it is better than nothing :-)
404
405Reasons to start playing with version 0.5.0
406- All the programs in the apps directory build into one ssleay binary.
407- There is a new version of the 'req' program that generates certificate
408 requests, there is even documentation for this one :-)
409- There is a demo certification authorithy program. Currently it will
410 look at the simple database and update it. It will generate CRL from
411 the data base. You need to edit the database by hand to revoke a
412 certificate, it is my aim to use perl5/Tk but I don't have time to do
413 this right now. It will generate the certificates but the management
414 scripts still need to be written. This is not a hard task.
415- Things have been cleaned up alot.
416- Have a look at the enc and dgst programs in the apps directory.
417- It supports v3 of x509 certiticates.
418
419
420Major things missing.
421- I have been working on (and thinging about) the distributed x509
422 hierachy problem. I have not had time to put my solution in place.
423 It will have to wait until I come back.
424- I have not put in CRL checking in the certificate verification but
425 it would not be hard to do. I was waiting until I could generate my
426 own CRL (which has only been in the last week) and I don't have time
427 to put it in correctly.
428- Montgomery multiplication need to be implemented. I know the
429 algorithm, just ran out of time.
430- PKCS#7. I can load and write the DER version. I need to re-work
431 things to support BER (if that means nothing, read the ASN1 spec :-).
432- Testing of the higher level digital envelope routines. I have not
433 played with the *_seal() and *_open() type functions. They are
434 written but need testing. The *_sign() and *_verify() functions are
435 rock solid.
436- PEM. Doing this and PKCS#7 have been dependant on the distributed
437 x509 heirachy problem. I started implementing my ideas, got
438 distracted writing a CA program and then ran out of time. I provide
439 the functionality of RSAref at least.
440- Re work the asm. code for the x86. I've changed by low level bignum
441 interface again, so I really need to tweak the x86 stuff. gcc is
442 good enough for the other boxes.
443
diff --git a/src/lib/libssl/src/MICROSOFT b/src/lib/libssl/src/MICROSOFT
new file mode 100644
index 0000000000..54176f0472
--- /dev/null
+++ b/src/lib/libssl/src/MICROSOFT
@@ -0,0 +1,146 @@
1The Microsoft World.
2
3The good news, to build SSLeay for the Microsft World
4
5Windows 3.1 DLL's
6perl Configure VC-WIN16
7nmake -f ms\w31dll.mak
8
9Windows NT/95 DLL's
10perl Configure VC-WIN32
11nmake -f ms\ntdll.mak
12
13Now the bad news
14All builds were done using Microsofts Visual C++ 1.52c and [45].x.
15If you are a borland person, you are probably going to have to help me
16finish the stuff in util/pl/BC*pl
17
18All builds were made under Windows NT - this means long filenames, so
19you may have problems under Windows 3.1 but probably not under 95.
20
21Because file pointers don't work in DLL's under Windows 3.1 (well at
22least stdin/stdout don't and I don't like having to differentiate
23between these and other file pointers), I now use the BIO file-pointer
24module, which needs to be linked into your application. You can either
25use the memory buffer BIO for IO, or compile bss_file.c into your
26application, it is in the apps directory and is just a copy of
27crypto/buffer/bss_file.c with #define APPS_WIN16 added.
28I have not yet automated the makefile to automatically copy it into 'out'
29for a win 3.1 build....
30
31All callbacks passed into SSLeay for Windows 3.1 need to be of type
32_far _loadds.
33
34I don't support building with the pascal calling convention.
35
36The DLL and static builds are large memory model.
37
38To build static libraries for NT/95 or win 3.1
39
40perl util/mk1mf.pl VC-WIN32 > mf-stat.nt
41perl util/mk1mf.pl VC-WIN16 > mf-stat.w31
42for DLL's
43perl util/mk1mf.pl dll VC-WIN32 > mf-dll.nt
44perl util/mk1mf.pl dll VC-WIN16 > mf-dll.w31
45
46Again you will notice that if you dont have perl, you cannot do this.
47
48Now the next importaint issue. Running Configure!
49I have small assember code files for critical big number library operation
50in crypto/bn/asm. There is, asm code, object files and uuencode
51object files. They are
52x86nt32.asm - 32bit flat memory model assember - suitable Win32
53x86w16.asm - 16bit assember - used in the msdos build.
54x86w32.asm - 32bit assember, win 3.1 segments, used for win16 build.
55
56If you feel compelled to build the 16bit maths routines in the windows 3.1
57build,
58perl Configure VC-W31-16
59perl util/mk1mf.pl dll VC-W31-16 > mf-dll.w31
60
61If you hate assember and don't want anything to do with it,
62perl util/mk1mf.pl no-asm VC-WIN16 > mf-dll.w31
63will work for any of the makefile generations.
64
65There are more options to mk1mf.pl but these all leave the temporary
66files in 'tmp' and the output files in 'out' by default.
67
68The NT build is done for console mode.
69
70The Windows 3.1 version of SSLeay uses quickwin, the interface is ugly
71but it is better than nothing. If you want ugly, try doing anything
72that involves getting a password. I decided to be ugly instead of
73echoing characters. For Windows 3.1 I would just sugest using the
74msdos version of the ssleay application for command line work.
75The QuickWin build is primarily for testing.
76
77For both NT and Windows 3.1, I have not written the code so that
78s_client, s_server can take input from the keyboard. You can happily
79start applications up in separate windows, watch them handshake, and then sit
80there for-ever. I have not had the time to get this working, and I've
81been able to test things from a unix box to the NT box :-).
82Try running ssleay s_server on the windows box
83(with either -cert ../apps/server.pem -www)
84and run ssleay s_time from another window.
85This often stuffs up on Windows 3.1, but I'm not worried since this is
86probably a problem with my demo applications, not the libraries.
87
88After a build of one of the version of microsoft SSLeay,
89'cd ms' and then run 'test'. This should check everything out and
90even does a trial run of generating certificates.
91'test.bat' requires that perl be install, you be in the ms directory
92(not the test directory, thats for unix so stay out :-) and that the
93build output directory be ../out
94
95On a last note, you will probably get division by zero errors and
96stuff after a build. This is due to your own inability to follow
97instructions :-).
98
99The reasons for the problem is probably one of the following.
100
1011) You did not run Configure. This is critical for windows 3.1 when
102 using assember. The values in crypto/bn/bn.h must match the
103 ones requred for the assember code. (remember that if you
104 edit crypto/bn/bn.h by hand, it will be clobered the next time
105 you run Configure by the contents of crypto/bn/bn.org).
106 SSLeay version -o will list the compile options.
107 For VC-WIN32 you need bn(64,32) or bn(32,32)
108 For VC-W31-32/VC-WIN16 you need bn(32,32)
109 For VC-W31-16 you need bn(32,16) or bn(16,16)
110 For VC-MSDOS you need bn(32,16) or bn(16,16).
111
112 The first number will be 2 times bigger than the second if
113 BN_LLONG is defined in bn.h and the size of the second number
114 depends on the 'bits' defined at the start of bn.h. Have a
115 look, it's all reasonably clear.
116 If you want to start messing with 8 bit builds and things like
117 that, build without the assember by re-generating a makefile
118 via 'perl util/mk1mf.pl no-asm'.
1192) You tried to build under MS-DOS or Windows 3.1 using the /G3
120 option. Don't. It is buggy (thats why you just got that
121 error) and unless you want to work out which optimising flag
122 to turn off, I'm not going to help you :-). I also noticed
123 that code often ran slower when compiled with /G3.
1243) Under NT/95, malloc goes stupid. You are probably linking with
125 the wrong library, there are problems if you mix the threaded
126 and non-threaded libraries (due to the DLL being staticly
127 linked with one and the applicaion using another.
128
129Well hopefully thats most of the MS issues handled, see you in ssl-users :-).
130
131eric 30-Aug-1996
132
133SSLeay 0.6.5
134For Windows 95/NT, add CRYPTO_malloc_init() to your program before any
135calls to the SSLeay libraries. This function will insert callbacks so that
136the SSLeay libraries will use the same malloc(), free() and realloc() as
137your application so 'problem 3)' mentioned above will go away.
138
139There is now DES assember for Windows NT/95. The file is
140crypto/des/asm/win32.asm and replaces crypto/des/des_enc.c in the build.
141
142There is also Blowfish assember for Windows NT/95. The file is
143crypto/bf/asm/win32.asm and replaces crypto/bf/bf_enc.c in the build.
144
145eric 25-Jun-1997
146
diff --git a/src/lib/libssl/src/MINFO b/src/lib/libssl/src/MINFO
new file mode 100644
index 0000000000..0509f33648
--- /dev/null
+++ b/src/lib/libssl/src/MINFO
@@ -0,0 +1,968 @@
1RELATIVE_DIRECTORY=.
2AR=ar r
3BASENAME=SSLeay
4BF_ENC=bf_enc.o
5BN_MULW=bn_mulw.o
6CAST_ENC=c_enc.o
7CC=cc
8CFLAG=-O -DNOPROTO
9DES_ENC=des_enc.o fcrypt_b.o
10DIRS=crypto ssl rsaref apps test tools
11EDIRS=times doc bugs util include certs ms shlib mt demos perl dep
12EXHEADER=e_os.h
13EX_LIBS=
14GENERAL=Makefile
15HEADER=e_os.h
16INSTALLTOP=/usr/local/ssl
17LIBS=libcrypto.a libssl.a
18MAKE=make -f Makefile.ssl
19MAKEFILE=Makefile.ssl
20MAN1=1
21MAN3=3
22MD5_ASM_OBJ=
23MISC=COPYRIGHT Configure HISTORY.066 INSTALL Makefile.ssl Makefile README TODO HISTORY README.066 README.080 README.090 VERSION PROBLEMS MINFO makefile.one e_os.h MICROSOFT makevms.com config PATENTS
24NAME=SSLeay-0.9.0
25ONEDIRS=out tmp
26PEX_LIBS=-L. -L.. -L../.. -L../../..
27RC4_ENC=rc4_enc.o
28RC5_ENC=rc5_enc.o
29RMD160_ASM_OBJ=
30SDIRS=md2 md5 sha mdc2 hmac ripemd des rc2 rc4 rc5 idea bf cast bn rsa dsa dh buffer bio stack lhash rand err objects evp pem asn1 x509 conf txt_db pkcs7
31SHA1_ASM_OBJ=
32SHELL=/bin/sh
33TARFILE=SSLeay-0.9.0.tar
34TOP=.
35VERSION=0.9.0
36WDIRS=windows
37WTARFILE=SSLeay-0.9.0-win.tar
38RELATIVE_DIRECTORY=
39RELATIVE_DIRECTORY=crypto
40ALL=Makefile README cryptlib.c mem.c cversion.c ex_data.c cpt_err.c cryptlib.h date.h crypto.h cryptall.h
41AR=ar r
42CC=cc
43CFLAG=-g
44CFLAGS=-I. -I../include -g -DCFLAGS=" \"cc -g\" "
45DIR=crypto
46ERR=crypto
47ERRC=cpt_err
48EXHEADER=crypto.h cryptall.h
49EX_LIBS=
50GENERAL=Makefile README
51HEADER=cryptlib.h date.h crypto.h cryptall.h
52INCLUDE=-I. -I../include
53INCLUDES=-I.. -I../../include
54INSTALLTOP=/usr/local/ssl
55LIB=../libcrypto.a
56LIBOBJ=cryptlib.o mem.o cversion.o ex_data.o cpt_err.o
57LIBS=
58LIBSRC=cryptlib.c mem.c cversion.c ex_data.c cpt_err.c
59MAKE=make -f Makefile.ssl
60MAKEDEPEND=makedepend -f Makefile.ssl
61MAKEFILE=Makefile.ssl
62PEX_LIBS=
63RM=/bin/rm -f
64SDIRS=md2 md5 sha mdc2 hmac ripemd des rc2 rc4 rc5 idea bf cast bn rsa dsa dh buffer bio stack lhash rand err objects evp pem x509 asn1 conf txt_db pkcs7
65SRC=cryptlib.c mem.c cversion.c ex_data.c cpt_err.c
66TOP=..
67RELATIVE_DIRECTORY=
68RELATIVE_DIRECTORY=crypto/md2
69ALL=Makefile md2_dgst.c md5_one.c md2.h
70APPS=
71AR=ar r
72CC=cc
73CFLAG=-g
74CFLAGS= -g
75DIR=md
76EXHEADER=md2.h
77GENERAL=Makefile
78HEADER=md2.h
79INCLUDES=
80INSTALLTOP=/usr/local/ssl
81LIB=../../libcrypto.a
82LIBOBJ=md2_dgst.o md2_one.o
83LIBSRC=md2_dgst.c md5_one.c
84MAKE=make -f Makefile.ssl
85MAKEDEPEND=makedepend -f Makefile.ssl
86MAKEFILE=Makefile.ssl
87SRC=md2_dgst.c md5_one.c
88TEST=md2test.c
89TOP=../..
90RELATIVE_DIRECTORY=
91RELATIVE_DIRECTORY=crypto/md5
92ALL=Makefile md5_dgst.c md5_one.c md5_locl.h md5.h
93APPS=md5.c
94AR=ar r
95CC=cc
96CFLAG=-g
97CFLAGS= -g
98CPP=cc -E
99DIR=md5
100EXHEADER=md5.h
101GENERAL=Makefile
102HEADER=md5_locl.h md5.h
103INCLUDES=
104INSTALLTOP=/usr/local/ssl
105LIB=../../libcrypto.a
106LIBOBJ=md5_dgst.o md5_one.o
107LIBSRC=md5_dgst.c md5_one.c
108MAKE=make -f Makefile.ssl
109MAKEDEPEND=makedepend -f Makefile.ssl
110MAKEFILE=Makefile.ssl
111MD5_ASM_OBJ=
112SRC=md5_dgst.c md5_one.c
113TEST=md5test.c
114TOP=../..
115RELATIVE_DIRECTORY=
116RELATIVE_DIRECTORY=crypto/sha
117ALL=Makefile sha_dgst.c sha1dgst.c sha_one.c sha1_one.c sha_locl.h sha.h
118APPS=
119AR=ar r
120CC=cc
121CFLAG=-g
122CFLAGS= -g
123DIR=sha
124EXHEADER=sha.h
125GENERAL=Makefile
126HEADER=sha_locl.h sha.h
127INCLUDES=
128INSTALLTOP=/usr/local/ssl
129LIB=../../libcrypto.a
130LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o
131LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c
132MAKE=make -f Makefile.ssl
133MAKEDEPEND=makedepend -f Makefile.ssl
134MAKEFILE=Makefile.ssl
135SHA1_ASM_OBJ=
136SRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c
137TEST=shatest.c sha1test.c
138TOP=../..
139RELATIVE_DIRECTORY=
140RELATIVE_DIRECTORY=crypto/mdc2
141ALL=Makefile mdc2dgst.c mdc2_one.c mdc2.h
142APPS=
143AR=ar r
144CC=cc
145CFLAG=-g
146CFLAGS= -g
147DIR=mdc2
148EXHEADER=mdc2.h
149GENERAL=Makefile
150HEADER=mdc2.h
151INCLUDES=
152INSTALLTOP=/usr/local/ssl
153LIB=../../libcrypto.a
154LIBOBJ=mdc2dgst.o mdc2_one.o
155LIBSRC=mdc2dgst.c mdc2_one.c
156MAKE=make -f Makefile.ssl
157MAKEDEPEND=makedepend -f Makefile.ssl
158MAKEFILE=Makefile.ssl
159SRC=mdc2dgst.c mdc2_one.c
160TEST=mdc2test.c
161TOP=../..
162RELATIVE_DIRECTORY=
163RELATIVE_DIRECTORY=crypto/hmac
164ALL=Makefile hmac.c hmac.h
165APPS=
166AR=ar r
167CC=cc
168CFLAG=-g
169CFLAGS= -g
170DIR=hmac
171EXHEADER=hmac.h
172GENERAL=Makefile
173HEADER=hmac.h
174INCLUDES=
175INSTALLTOP=/usr/local/ssl
176LIB=../../libcrypto.a
177LIBOBJ=hmac.o
178LIBSRC=hmac.c
179MAKE=make -f Makefile.ssl
180MAKEDEPEND=makedepend -f Makefile.ssl
181MAKEFILE=Makefile.ssl
182SRC=hmac.c
183TEST=hmactest.c
184TOP=../..
185RELATIVE_DIRECTORY=
186RELATIVE_DIRECTORY=crypto/ripemd
187ALL=Makefile rmd_dgst.c rmd_one.c rmd_locl.h rmdconst.h ripemd.h
188APPS=rmd160.c
189AR=ar r
190CC=cc
191CFLAG=-g
192CFLAGS= -g
193CPP=cc -E
194DIR=ripemd
195EXHEADER=ripemd.h
196GENERAL=Makefile
197HEADER=rmd_locl.h rmdconst.h ripemd.h
198INCLUDES=
199INSTALLTOP=/usr/local/ssl
200LIB=../../libcrypto.a
201LIBOBJ=rmd_dgst.o rmd_one.o
202LIBSRC=rmd_dgst.c rmd_one.c
203MAKE=make -f Makefile.ssl
204MAKEDEPEND=makedepend -f Makefile.ssl
205MAKEFILE=Makefile.ssl
206RIP_ASM_OBJ=
207SRC=rmd_dgst.c rmd_one.c
208TEST=rmdtest.c
209TOP=../..
210RELATIVE_DIRECTORY=
211RELATIVE_DIRECTORY=crypto/des
212ALL=Makefile des.org des_locl.org cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c des_enc.c fcrypt_b.c read2pwd.c fcrypt.c xcbc_enc.c str2key.c cfb64ede.c ofb64ede.c supp.c des_locl.h rpc_des.h podd.h sk.h spr.h des_ver.h des.h
213APPS=
214AR=ar r
215CC=cc
216CFLAG=-g
217CFLAGS= -g
218CPP=cc -E
219DES_ENC=des_enc.o fcrypt_b.o
220DIR=des
221EXHEADER=des.h
222GENERAL=Makefile des.org des_locl.org
223HEADER=des_locl.h rpc_des.h podd.h sk.h spr.h des_ver.h des.h
224INCLUDES=
225INSTALLTOP=/usr/local/ssl
226LIB=../../libcrypto.a
227LIBOBJ=set_key.o ecb_enc.o cbc_enc.o ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o enc_read.o enc_writ.o ofb64enc.o ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o des_enc.o fcrypt_b.o read2pwd.o fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o
228LIBSRC=cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c des_enc.c fcrypt_b.c read2pwd.c fcrypt.c xcbc_enc.c str2key.c cfb64ede.c ofb64ede.c supp.c
229MAKE=make -f Makefile.ssl
230MAKEDEPEND=makedepend -f Makefile.ssl
231MAKEFILE=Makefile.ssl
232SRC=cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c des_enc.c fcrypt_b.c read2pwd.c fcrypt.c xcbc_enc.c str2key.c cfb64ede.c ofb64ede.c supp.c
233TEST=destest.c
234TOP=../..
235RELATIVE_DIRECTORY=
236RELATIVE_DIRECTORY=crypto/rc2
237ALL=Makefile rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c rc2_locl.h rc2.h
238APPS=
239AR=ar r
240CC=cc
241CFLAG=-g
242CFLAGS= -g
243DIR=rc2
244EXHEADER=rc2.h
245GENERAL=Makefile
246HEADER=rc2_locl.h rc2.h
247INCLUDES=
248INSTALLTOP=/usr/local/ssl
249LIB=../../libcrypto.a
250LIBOBJ=rc2_ecb.o rc2_skey.o rc2_cbc.o rc2cfb64.o rc2ofb64.o
251LIBSRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c
252MAKE=make -f Makefile.ssl
253MAKEDEPEND=makedepend -f Makefile.ssl
254MAKEFILE=Makefile.ssl
255SRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c
256TEST=rc2test.c
257TOP=../..
258RELATIVE_DIRECTORY=
259RELATIVE_DIRECTORY=crypto/rc4
260ALL=Makefile rc4_skey.c rc4_enc.c rc4.h rc4_locl.h
261APPS=
262AR=ar r
263CC=cc
264CFLAG=-g
265CFLAGS= -g
266DIR=rc4
267EXHEADER=rc4.h
268GENERAL=Makefile
269HEADER=rc4.h rc4_locl.h
270INCLUDES=
271INSTALLTOP=/usr/local/ssl
272LIB=../../libcrypto.a
273LIBOBJ=rc4_skey.o rc4_enc.o
274LIBSRC=rc4_skey.c rc4_enc.c
275MAKE=make -f Makefile.ssl
276MAKEDEPEND=makedepend -f Makefile.ssl
277MAKEFILE=Makefile.ssl
278RC4_ENC=rc4_enc.o
279SRC=rc4_skey.c rc4_enc.c
280TEST=rc4test.c
281TOP=../..
282RELATIVE_DIRECTORY=
283RELATIVE_DIRECTORY=crypto/rc5
284ALL=Makefile rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c rc5_locl.h rc5.h
285APPS=
286AR=ar r
287CC=cc
288CFLAG=-g
289CFLAGS= -g
290CPP=cc -E
291DIR=rc5
292EXHEADER=rc5.h
293GENERAL=Makefile
294HEADER=rc5_locl.h rc5.h
295INCLUDES=
296INSTALLTOP=/usr/local/ssl
297LIB=../../libcrypto.a
298LIBOBJ=rc5_skey.o rc5_ecb.o rc5_enc.o rc5cfb64.o rc5ofb64.o
299LIBSRC=rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c
300MAKE=make -f Makefile.ssl
301MAKEDEPEND=makedepend -f Makefile.ssl
302MAKEFILE=Makefile.ssl
303RC5_ENC=rc5_enc.o
304SRC=rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c
305TEST=rc5test.c
306TOP=../..
307RELATIVE_DIRECTORY=
308RELATIVE_DIRECTORY=crypto/idea
309ALL=Makefile i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c idea_lcl.h idea.h
310APPS=
311AR=ar r
312CC=cc
313CFLAG=-g
314CFLAGS= -g
315DIR=idea
316EXHEADER=idea.h
317GENERAL=Makefile
318HEADER=idea_lcl.h idea.h
319INCLUDES=
320INSTALLTOP=/usr/local/ssl
321LIB=../../libcrypto.a
322LIBOBJ=i_cbc.o i_cfb64.o i_ofb64.o i_ecb.o i_skey.o
323LIBSRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c
324MAKE=make -f Makefile.ssl
325MAKEDEPEND=makedepend -f Makefile.ssl
326MAKEFILE=Makefile.ssl
327SRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c
328TEST=ideatest.c
329TOP=../..
330RELATIVE_DIRECTORY=
331RELATIVE_DIRECTORY=crypto/bf
332ALL=Makefile bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c bf_pi.h bf_locl.h blowfish.h
333APPS=
334AR=ar r
335BF_ENC=bf_enc.o
336CC=cc
337CFLAG=-g
338CFLAGS= -g
339CPP=cc -E
340DIR=bf
341EXHEADER=blowfish.h
342GENERAL=Makefile
343HEADER=bf_pi.h bf_locl.h blowfish.h
344INCLUDES=
345INSTALLTOP=/usr/local/ssl
346LIB=../../libcrypto.a
347LIBOBJ=bf_skey.o bf_ecb.o bf_enc.o bf_cfb64.o bf_ofb64.o
348LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c
349MAKE=make -f Makefile.ssl
350MAKEDEPEND=makedepend -f Makefile.ssl
351MAKEFILE=Makefile.ssl
352SRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c
353TEST=bftest.c
354TOP=../..
355RELATIVE_DIRECTORY=
356RELATIVE_DIRECTORY=crypto/cast
357ALL=Makefile c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c cast_s.h cast_lcl.h cast.h
358APPS=
359AR=ar r
360CAST_ENC=c_enc.o
361CC=cc
362CFLAG=-g
363CFLAGS= -g
364CPP=cc -E
365DIR=cast
366EXHEADER=cast.h
367GENERAL=Makefile
368HEADER=cast_s.h cast_lcl.h cast.h
369INCLUDES=
370INSTALLTOP=/usr/local/ssl
371LIB=../../libcrypto.a
372LIBOBJ=c_skey.o c_ecb.o c_enc.o c_cfb64.o c_ofb64.o
373LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
374MAKE=make -f Makefile.ssl
375MAKEDEPEND=makedepend -f Makefile.ssl
376MAKEFILE=Makefile.ssl
377SRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
378TEST=casttest.c
379TOP=../..
380RELATIVE_DIRECTORY=
381RELATIVE_DIRECTORY=crypto/bn
382ALL=Makefile bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c bn_mpi.c bn_lcl.h bn_prime.h bn.h
383APPS=
384AR=ar r
385BN_MULW=bn_mulw.o
386CC=cc
387CFLAG=-g
388CFLAGS=-I.. -I../../include -g
389DIR=bn
390ERR=bn
391ERRC=bn_err
392EXHEADER=bn.h
393GENERAL=Makefile
394HEADER=bn_lcl.h bn_prime.h bn.h
395INCLUDES=-I.. -I../../include
396INSTALLTOP=/usr/local/ssl
397LIB=../../libcrypto.a
398LIBOBJ=bn_add.o bn_div.o bn_exp.o bn_lib.o bn_mod.o bn_mul.o bn_print.o bn_rand.o bn_shift.o bn_sub.o bn_word.o bn_blind.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o bn_mulw.o bn_recp.o bn_mont.o bn_mpi.o
399LIBSRC=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c bn_mpi.c
400MAKE=make -f Makefile.ssl
401MAKEDEPEND=makedepend -f Makefile.ssl
402MAKEFILE=Makefile.ssl
403SRC=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c bn_mpi.c
404TEST=bntest.c exptest.c
405TOP=../..
406RELATIVE_DIRECTORY=
407RELATIVE_DIRECTORY=crypto/rsa
408ALL=Makefile rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c rsa_none.c rsa.h
409APPS=
410AR=ar r
411CC=cc
412CFLAG=-g
413CFLAGS=-I.. -I../../include -g
414DIR=rsa
415ERR=rsa
416ERRC=rsa_err
417EXHEADER=rsa.h
418GENERAL=Makefile
419HEADER=rsa.h
420INCLUDES=-I.. -I../../include
421INSTALLTOP=/usr/local/ssl
422LIB=../../libcrypto.a
423LIBOBJ=rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o rsa_err.o rsa_pk1.o rsa_ssl.o rsa_none.o
424LIBSRC=rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c rsa_none.c
425MAKE=make -f Makefile.ssl
426MAKEDEPEND=makedepend -f Makefile.ssl
427MAKEFILE=Makefile.ssl
428SRC=rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c rsa_err.c rsa_pk1.c rsa_ssl.c rsa_none.c
429TEST=
430TOP=../..
431RELATIVE_DIRECTORY=
432RELATIVE_DIRECTORY=crypto/dsa
433ALL=Makefile dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c dsa_err.c dsa.h
434APPS=
435AR=ar r
436CC=cc
437CFLAG=-g
438CFLAGS=-I.. -I../../include -g
439DIR=dsa
440ERR=dsa
441ERRC=dsa_err
442EXHEADER=dsa.h
443GENERAL=Makefile
444HEADER=dsa.h
445INCLUDES=-I.. -I../../include
446INSTALLTOP=/usr/local/ssl
447LIB=../../libcrypto.a
448LIBOBJ=dsa_gen.o dsa_key.o dsa_lib.o dsa_vrf.o dsa_sign.o dsa_err.o
449LIBSRC=dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c dsa_err.c
450MAKE=make -f Makefile.ssl
451MAKEDEPEND=makedepend -f Makefile.ssl
452MAKEFILE=Makefile.ssl
453SRC=dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c dsa_err.c
454TEST=dsatest.c
455TOP=../..
456RELATIVE_DIRECTORY=
457RELATIVE_DIRECTORY=crypto/dh
458ALL=Makefile dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c dh.h
459APPS=
460AR=ar r
461CC=cc
462CFLAG=-g
463CFLAGS=-I.. -I../../include -g
464DIR=dh
465ERR=dh
466ERRC=dh_err
467EXHEADER=dh.h
468GENERAL=Makefile
469HEADER=dh.h
470INCLUDES=-I.. -I../../include
471INSTALLTOP=/usr/local/ssl
472LIB=../../libcrypto.a
473LIBOBJ=dh_gen.o dh_key.o dh_lib.o dh_check.o dh_err.o
474LIBSRC=dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c
475MAKE=make -f Makefile.ssl
476MAKEDEPEND=makedepend -f Makefile.ssl
477MAKEFILE=Makefile.ssl
478SRC=dh_gen.c dh_key.c dh_lib.c dh_check.c dh_err.c
479TEST=dhtest.c
480TOP=../..
481RELATIVE_DIRECTORY=
482RELATIVE_DIRECTORY=crypto/buffer
483ALL=Makefile buffer.c buf_err.c buffer.h
484APPS=
485AR=ar r
486CC=cc
487CFLAG=-g
488CFLAGS=-I.. -I../../include -g
489DIR=buffer
490ERR=buffer
491ERRC=buf_err
492EXHEADER=buffer.h
493GENERAL=Makefile
494HEADER=buffer.h
495INCLUDES=-I.. -I../../include
496INSTALLTOP=/usr/local/ssl
497LIB=../../libcrypto.a
498LIBOBJ=buffer.o buf_err.o
499LIBSRC=buffer.c buf_err.c
500MAKE=make -f Makefile.ssl
501MAKEDEPEND=makedepend -f Makefile.ssl
502MAKEFILE=Makefile.ssl
503SRC=buffer.c buf_err.c
504TEST=
505TOP=../..
506RELATIVE_DIRECTORY=
507RELATIVE_DIRECTORY=crypto/bio
508ALL=Makefile bio_lib.c bio_cb.c bio_err.c bss_mem.c bss_null.c bss_fd.c bss_file.c bss_sock.c bss_conn.c bf_null.c bf_buff.c b_print.c b_dump.c b_sock.c bss_acpt.c bf_nbio.c bio.h bss_file.c
509APPS=
510AR=ar r
511CC=cc
512CFLAG=-g
513CFLAGS=-I.. -I../../include -g
514DIR=bio
515ERR=bio
516ERRC=bio_err
517EXHEADER=bio.h bss_file.c
518GENERAL=Makefile
519HEADER=bio.h bss_file.c
520INCLUDES=-I.. -I../../include
521INSTALLTOP=/usr/local/ssl
522LIB=../../libcrypto.a
523LIBOBJ=bio_lib.o bio_cb.o bio_err.o bss_mem.o bss_null.o bss_fd.o bss_file.o bss_sock.o bss_conn.o bf_null.o bf_buff.o b_print.o b_dump.o b_sock.o bss_acpt.o bf_nbio.o
524LIBSRC=bio_lib.c bio_cb.c bio_err.c bss_mem.c bss_null.c bss_fd.c bss_file.c bss_sock.c bss_conn.c bf_null.c bf_buff.c b_print.c b_dump.c b_sock.c bss_acpt.c bf_nbio.c
525MAKE=make -f Makefile.ssl
526MAKEDEPEND=makedepend -f Makefile.ssl
527MAKEFILE=Makefile.ssl
528SRC=bio_lib.c bio_cb.c bio_err.c bss_mem.c bss_null.c bss_fd.c bss_file.c bss_sock.c bss_conn.c bf_null.c bf_buff.c b_print.c b_dump.c b_sock.c bss_acpt.c bf_nbio.c
529TEST=
530TOP=../..
531RELATIVE_DIRECTORY=
532RELATIVE_DIRECTORY=crypto/stack
533ALL=Makefile stack.c stack.h
534APPS=
535AR=ar r
536CC=cc
537CFLAG=-g
538CFLAGS= -g
539DIR=stack
540EXHEADER=stack.h
541GENERAL=Makefile
542HEADER=stack.h
543INCLUDES=
544INSTALLTOP=/usr/local/ssl
545LIB=../../libcrypto.a
546LIBOBJ=stack.o
547LIBSRC=stack.c
548MAKE=make -f Makefile.ssl
549MAKEDEPEND=makedepend -f Makefile.ssl
550MAKEFILE=Makefile.ssl
551SRC=stack.c
552TEST=
553TOP=../..
554RELATIVE_DIRECTORY=
555RELATIVE_DIRECTORY=crypto/lhash
556ALL=Makefile lhash.c lh_stats.c lhash.h
557APPS=
558AR=ar r
559CC=cc
560CFLAG=-g
561CFLAGS= -g
562DIR=lhash
563EXHEADER=lhash.h
564GENERAL=Makefile
565HEADER=lhash.h
566INCLUDES=
567INSTALLTOP=/usr/local/ssl
568LIB=../../libcrypto.a
569LIBOBJ=lhash.o lh_stats.o
570LIBSRC=lhash.c lh_stats.c
571MAKE=make -f Makefile.ssl
572MAKEDEPEND=makedepend -f Makefile.ssl
573MAKEFILE=Makefile.ssl
574SRC=lhash.c lh_stats.c
575TEST=
576TOP=../..
577RELATIVE_DIRECTORY=
578RELATIVE_DIRECTORY=crypto/rand
579ALL=Makefile md_rand.c randfile.c rand.h
580APPS=
581AR=ar r
582CC=cc
583CFLAG=-g
584CFLAGS= -g
585DIR=rand
586EXHEADER=rand.h
587GENERAL=Makefile
588HEADER=rand.h
589INCLUDES=
590INSTALLTOP=/usr/local/ssl
591LIB=../../libcrypto.a
592LIBOBJ=md_rand.o randfile.o
593LIBSRC=md_rand.c randfile.c
594MAKE=make -f Makefile.ssl
595MAKEDEPEND=makedepend -f Makefile.ssl
596MAKEFILE=Makefile.ssl
597SRC=md_rand.c randfile.c
598TEST=randtest.c
599TOP=../..
600RELATIVE_DIRECTORY=
601RELATIVE_DIRECTORY=crypto/err
602ALL=Makefile err.c err_all.c err_prn.c err.h
603APPS=
604AR=ar r
605CC=cc
606CFLAG=-g
607CFLAGS=-I.. -I../../include -g
608DIR=err
609EXHEADER=err.h
610GENERAL=Makefile
611HEADER=err.h
612INCLUDES=-I.. -I../../include
613INSTALLTOP=/usr/local/ssl
614LIB=../../libcrypto.a
615LIBOBJ=err.o err_all.o err_prn.o
616LIBSRC=err.c err_all.c err_prn.c
617MAKE=make -f Makefile.ssl
618MAKEDEPEND=makedepend -f Makefile.ssl
619MAKEFILE=Makefile.ssl
620SRC=err.c err_all.c err_prn.c
621TEST=
622TOP=../..
623RELATIVE_DIRECTORY=
624RELATIVE_DIRECTORY=crypto/objects
625ALL=Makefile README obj_dat.c obj_lib.c obj_err.c objects.h obj_dat.h
626APPS=
627AR=ar r
628CC=cc
629CFLAG=-g
630CFLAGS=-I.. -I../../include -g
631DIR=objects
632ERR=objects
633ERRC=obj_err
634EXHEADER=objects.h
635GENERAL=Makefile README
636HEADER=objects.h obj_dat.h
637INCLUDES=-I.. -I../../include
638INSTALLTOP=/usr/local/ssl
639LIB=../../libcrypto.a
640LIBOBJ=obj_dat.o obj_lib.o obj_err.o
641LIBSRC=obj_dat.c obj_lib.c obj_err.c
642MAKE=make -f Makefile.ssl
643MAKEDEPEND=makedepend -f Makefile.ssl
644MAKEFILE=Makefile.ssl
645SRC=obj_dat.c obj_lib.c obj_err.c
646TEST=
647TOP=../..
648RELATIVE_DIRECTORY=
649RELATIVE_DIRECTORY=crypto/evp
650ALL=Makefile encode.c digest.c evp_enc.c evp_key.c e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c m_ripemd.c p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c c_all.c evp_lib.c evp.h
651APPS=
652AR=ar r
653CC=cc
654CFLAG=-g
655CFLAGS=-I.. -I../../include -g
656DIR=evp
657ERR=evp
658ERRC=evp_err
659EXHEADER=evp.h
660GENERAL=Makefile
661HEADER=evp.h
662INCLUDES=-I.. -I../../include
663INSTALLTOP=/usr/local/ssl
664LIB=../../libcrypto.a
665LIBOBJ=encode.o digest.o evp_enc.o evp_key.o e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o e_ecb_i.o e_cbc_i.o e_cfb_i.o e_ofb_i.o e_ecb_3d.o e_cbc_3d.o e_rc4.o names.o e_cfb_3d.o e_ofb_3d.o e_xcbc_d.o e_ecb_r2.o e_cbc_r2.o e_cfb_r2.o e_ofb_r2.o e_ecb_bf.o e_cbc_bf.o e_cfb_bf.o e_ofb_bf.o e_ecb_c.o e_cbc_c.o e_cfb_c.o e_ofb_c.o e_ecb_r5.o e_cbc_r5.o e_cfb_r5.o e_ofb_r5.o m_null.o m_md2.o m_md5.o m_sha.o m_sha1.o m_dss.o m_dss1.o m_mdc2.o m_ripemd.o p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o bio_md.o bio_b64.o bio_enc.o evp_err.o e_null.o c_all.o evp_lib.o
666LIBSRC=encode.c digest.c evp_enc.c evp_key.c e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c m_ripemd.c p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c c_all.c evp_lib.c
667MAKE=make -f Makefile.ssl
668MAKEDEPEND=makedepend -f Makefile.ssl
669MAKEFILE=Makefile.ssl
670SRC=encode.c digest.c evp_enc.c evp_key.c e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c m_ripemd.c p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c c_all.c evp_lib.c
671TEST=
672TOP=../..
673RELATIVE_DIRECTORY=
674RELATIVE_DIRECTORY=crypto/pem
675ALL=Makefile pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c pem.h
676APPS=
677AR=ar r
678CC=cc
679CFLAG=-g
680CFLAGS=-I.. -I../../include -g
681CTX_SIZE=ctx_size
682DIR=pem
683ERR=pem
684ERRC=pem_err
685EXHEADER=pem.h
686GENERAL=Makefile
687HEADER=pem.h
688INCLUDES=-I.. -I../../include
689INSTALLTOP=/usr/local/ssl
690LIB=../../libcrypto.a
691LIBOBJ=pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o pem_err.o
692LIBSRC=pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c
693MAKE=make -f Makefile.ssl
694MAKEDEPEND=makedepend -f Makefile.ssl
695MAKEFILE=Makefile.ssl
696SRC=pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c pem_err.c
697TEST=
698TOP=../..
699RELATIVE_DIRECTORY=
700RELATIVE_DIRECTORY=crypto/asn1
701ALL=Makefile README a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c asn1.h asn1_mac.h
702APPS=
703AR=ar r
704CC=cc
705CFLAG=-g
706CFLAGS=-I.. -I../../include -g
707DIR=asn1
708ERR=asn1
709ERRC=asn1_err
710EXHEADER=asn1.h asn1_mac.h
711GENERAL=Makefile README
712HEADER=asn1.h asn1_mac.h
713INCLUDES=-I.. -I../../include
714INSTALLTOP=/usr/local/ssl
715LIB=../../libcrypto.a
716LIBOBJ=a_object.o a_bitstr.o a_utctm.o a_int.o a_octet.o a_print.o a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o a_sign.o a_digest.o a_verify.o x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o t_req.o t_x509.o t_pkey.o p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o a_hdr.o x_pkey.o a_bool.o x_exten.o asn1_par.o asn1_lib.o asn1_err.o a_meth.o a_bytes.o evp_asn1.o
717LIBSRC=a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c
718MAKE=make -f Makefile.ssl
719MAKEDEPEND=makedepend -f Makefile.ssl
720MAKEFILE=Makefile.ssl
721SRC=a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c a_sign.c a_digest.c a_verify.c x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c t_req.c t_x509.c t_pkey.c p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c a_hdr.c x_pkey.c a_bool.c x_exten.c asn1_par.c asn1_lib.c asn1_err.c a_meth.c a_bytes.c evp_asn1.c
722TEST=
723TOP=../..
724RELATIVE_DIRECTORY=
725RELATIVE_DIRECTORY=crypto/x509
726ALL=Makefile README x509_def.c x509_d2.c x509_r2x.c x509_cmp.c x509_obj.c x509_req.c x509_vfy.c x509_set.c x509rset.c x509_err.c x509name.c x509_v3.c x509_ext.c x509pack.c x509type.c x509_lu.c x_all.c x509_txt.c by_file.c by_dir.c v3_net.c v3_x509.c x509.h x509_vfy.h
727APPS=
728AR=ar r
729CC=cc
730CFLAG=-g
731CFLAGS=-I.. -I../../include -g
732DIR=x509
733ERR=x509
734ERRC=x509_err
735EXHEADER=x509.h x509_vfy.h
736GENERAL=Makefile README
737HEADER=x509.h x509_vfy.h
738INCLUDES=-I.. -I../../include
739INSTALLTOP=/usr/local/ssl
740LIB=../../libcrypto.a
741LIBOBJ=x509_def.o x509_d2.o x509_r2x.o x509_cmp.o x509_obj.o x509_req.o x509_vfy.o x509_set.o x509rset.o x509_err.o x509name.o x509_v3.o x509_ext.o x509pack.o x509type.o x509_lu.o x_all.o x509_txt.o by_file.o by_dir.o v3_net.o v3_x509.o
742LIBSRC=x509_def.c x509_d2.c x509_r2x.c x509_cmp.c x509_obj.c x509_req.c x509_vfy.c x509_set.c x509rset.c x509_err.c x509name.c x509_v3.c x509_ext.c x509pack.c x509type.c x509_lu.c x_all.c x509_txt.c by_file.c by_dir.c v3_net.c v3_x509.c
743MAKE=make -f Makefile.ssl
744MAKEDEPEND=makedepend -f Makefile.ssl
745MAKEFILE=Makefile.ssl
746SRC=x509_def.c x509_d2.c x509_r2x.c x509_cmp.c x509_obj.c x509_req.c x509_vfy.c x509_set.c x509rset.c x509_err.c x509name.c x509_v3.c x509_ext.c x509pack.c x509type.c x509_lu.c x_all.c x509_txt.c by_file.c by_dir.c v3_net.c v3_x509.c
747TEST=
748TOP=../..
749RELATIVE_DIRECTORY=
750RELATIVE_DIRECTORY=crypto/conf
751ALL=Makefile conf.c conf_err.c conf_lcl.h conf.h
752APPS=
753AR=ar r
754CC=cc
755CFLAG=-g
756CFLAGS=-I.. -I../../include -g
757DIR=conf
758ERR=conf
759ERRC=conf_err
760EXHEADER=conf.h
761GENERAL=Makefile
762HEADER=conf_lcl.h conf.h
763INCLUDES=-I.. -I../../include
764INSTALLTOP=/usr/local/ssl
765LIB=../../libcrypto.a
766LIBOBJ=conf.o conf_err.o
767LIBSRC=conf.c conf_err.c
768MAKE=make -f Makefile.ssl
769MAKEDEPEND=makedepend -f Makefile.ssl
770MAKEFILE=Makefile.ssl
771SRC=conf.c conf_err.c
772TEST=
773TOP=../..
774RELATIVE_DIRECTORY=
775RELATIVE_DIRECTORY=crypto/txt_db
776ALL=Makefile txt_db.c txt_db.h
777APPS=
778AR=ar r
779CC=cc
780CFLAG=-g
781CFLAGS= -g
782DIR=txt_db
783EXHEADER=txt_db.h
784GENERAL=Makefile
785HEADER=txt_db.h
786INCLUDES=
787INSTALLTOP=/usr/local/ssl
788LIB=../../libcrypto.a
789LIBOBJ=txt_db.o
790LIBSRC=txt_db.c
791MAKE=make -f Makefile.ssl
792MAKEDEPEND=makedepend -f Makefile.ssl
793MAKEFILE=Makefile.ssl
794SRC=txt_db.c
795TEST=
796TOP=../..
797RELATIVE_DIRECTORY=
798RELATIVE_DIRECTORY=crypto/pkcs7
799ALL=Makefile README pk7_lib.c pkcs7err.c pk7_doit.c pkcs7.h
800APPS=
801AR=ar r
802CC=cc
803CFLAG=-g
804CFLAGS=-I.. -I../../include -g
805DIR=pkcs7
806ERR=pkcs7
807ERRC=pkcs7err
808EXHEADER=pkcs7.h
809GENERAL=Makefile README
810HEADER=pkcs7.h
811INCLUDES=-I.. -I../../include
812INSTALLTOP=/usr/local/ssl
813LIB=../../libcrypto.a
814LIBOBJ=pk7_lib.o pkcs7err.o pk7_doit.o
815LIBSRC=pk7_lib.c pkcs7err.c pk7_doit.c
816MAKE=make -f Makefile.ssl
817MAKEDEPEND=makedepend -f Makefile.ssl
818MAKEFILE=Makefile.ssl
819SRC=pk7_lib.c pkcs7err.c pk7_doit.c
820TEST=
821TOP=../..
822RELATIVE_DIRECTORY=
823RELATIVE_DIRECTORY=ssl
824ALL=Makefile README s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c bio_ssl.c ssl_err.c ssl.h ssl2.h ssl3.h ssl23.h tls1.h ssl_locl.h
825APPS=
826AR=ar r
827CC=cc
828CFLAG=-g
829CFLAGS=-I../crypto -I../include -g
830DIR=ssl
831ERR=ssl
832ERRC=ssl_err
833EXHEADER=ssl.h ssl2.h ssl3.h ssl23.h tls1.h
834GENERAL=Makefile README
835HEADER=ssl.h ssl2.h ssl3.h ssl23.h tls1.h ssl_locl.h
836INCLUDES=-I../crypto -I../include
837INSTALLTOP=/usr/local/ssl
838LIB=../libssl.a
839LIBOBJ=s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o s23_pkt.o t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o ssl_ciph.o ssl_stat.o ssl_rsa.o ssl_asn1.o ssl_txt.o ssl_algs.o bio_ssl.o ssl_err.o
840LIBSRC=s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c bio_ssl.c ssl_err.c
841MAKE=make -f Makefile.ssl
842MAKEDEPEND=makedepend -f Makefile.ssl
843MAKEFILE=Makefile.ssl
844SRC=s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c ssl_ciph.c ssl_stat.c ssl_rsa.c ssl_asn1.c ssl_txt.c ssl_algs.c bio_ssl.c ssl_err.c
845TEST=ssltest.c
846TOP=..
847RELATIVE_DIRECTORY=
848RELATIVE_DIRECTORY=rsaref
849ALL=Makefile rsaref.c rsar_err.c rsaref.h
850APPS=
851AR=ar r
852CC=cc
853CFLAG=-g
854CFLAGS=-I../crypto -I../include -g
855DIR=rsaref
856ERR=rsaref
857ERRC=rsar_err
858EXHEADER=
859GENERAL=Makefile
860HEADER= rsaref.h
861INCLUDES=-I../crypto -I../include
862INSTALLTOP=/usr/local/ssl
863LIB=../libRSAglue.a
864LIBOBJ=rsaref.o rsar_err.o
865LIBSRC=rsaref.c rsar_err.c
866MAKE=make -f Makefile.ssl
867MAKEDEPEND=makedepend -f Makefile.ssl
868MAKEFILE=Makefile.ssl
869SRC=rsaref.c rsar_err.c
870TEST=
871TOP=..
872RELATIVE_DIRECTORY=
873RELATIVE_DIRECTORY=apps
874ALL=Makefile verify.c asn1pars.c req.c dgst.c dh.c enc.c gendh.c errstr.c ca.c pkcs7.c crl2p7.c crl.c rsa.c dsa.c dsaparam.c x509.c genrsa.c s_server.c s_client.c speed.c s_time.c apps.c s_cb.c s_socket.c version.c sess_id.c ciphers.c apps.h progs.h s_apps.h testdsa.h testrsa.h
875A_OBJ=apps.o
876A_SRC=apps.c
877CC=cc
878CFLAG=-g -static
879CFLAGS=-DMONOLITH -I../include -g -static
880DIR=apps
881DLIBCRYPTO=../libcrypto.a
882DLIBSSL=../libssl.a
883EXE=ssleay
884EXHEADER=
885EX_LIBS=
886E_EXE=verify asn1pars req dgst dh enc gendh errstr ca crl rsa dsa dsaparam x509 genrsa s_server s_client speed s_time version pkcs7 crl2pkcs7 sess_id ciphers
887E_OBJ=verify.o asn1pars.o req.o dgst.o dh.o enc.o gendh.o errstr.o ca.o pkcs7.o crl2p7.o crl.o rsa.o dsa.o dsaparam.o x509.o genrsa.o s_server.o s_client.o speed.o s_time.o apps.o s_cb.o s_socket.o version.o sess_id.o ciphers.o
888E_SRC=verify.c asn1pars.c req.c dgst.c dh.c enc.c gendh.c errstr.c ca.c pkcs7.c crl2p7.c crl.c rsa.c dsa.c dsaparam.c x509.c genrsa.c s_server.c s_client.c speed.c s_time.c apps.c s_cb.c s_socket.c version.c sess_id.c ciphers.c
889GENERAL=Makefile
890HEADER=apps.h progs.h s_apps.h testdsa.h testrsa.h
891INCLUDES=-I../include
892INSTALLTOP=/usr/local/ssl
893LIBCRYPTO=-L.. -lcrypto
894LIBSSL=-L.. -lssl
895MAKE=make -f Makefile.ssl
896MAKEDEPEND=makedepend -f Makefile.ssl
897MAKEFILE=Makefile.ssl
898PEX_LIBS=
899PROGS=ssleay.c
900RM=/bin/rm -f
901SCRIPTS=CA.sh der_chop
902SRC=verify.c asn1pars.c req.c dgst.c dh.c enc.c gendh.c errstr.c ca.c pkcs7.c crl2p7.c crl.c rsa.c dsa.c dsaparam.c x509.c genrsa.c s_server.c s_client.c speed.c s_time.c apps.c s_cb.c s_socket.c version.c sess_id.c ciphers.c
903SSLEAY=ssleay
904S_OBJ=s_cb.o s_socket.o
905S_SRC=s_cb.c s_socket.c
906TOP=..
907RELATIVE_DIRECTORY=
908RELATIVE_DIRECTORY=test
909ALL=Makefile.ssl bntest.c ideatest.c md2test.c md5test.c hmactest.c rc2test.c rc4test.c rc5test.c destest.c shatest.c sha1test.c mdc2test.c rmdtest.c randtest.c dhtest.c casttest.c bftest.c ssltest.c dsatest.c exptest.c
910BFTEST=bftest
911BNTEST=bntest
912CASTTEST=casttest
913CC=cc
914CFLAG=-g
915CFLAGS=-I../include -g
916DESTEST=destest
917DHTEST=dhtest
918DIR=test
919DLIBCRYPTO=../libcrypto.a
920DLIBSSL=../libssl.a
921DSATEST=dsatest
922EXE=bntest ideatest md2test md5test hmactest rc2test rc4test rc5test destest shatest sha1test mdc2test rmdtest randtest dhtest bftest casttest ssltest exptest dsatest
923EXHEADER=
924EXPTEST=exptest
925EX_LIBS=
926GENERAL=Makefile.ssl
927HEADER=
928HMACTEST=hmactest
929IDEATEST=ideatest
930INCLUDES=-I../include
931INSTALLTOP=/usr/local/ssl
932LIBCRYPTO=-L.. -lcrypto
933LIBSSL=-L.. -lssl
934MAKE=make -f Makefile.ssl
935MAKEDEPEND=makedepend -fMakefile.ssl
936MAKEFILE=Makefile.ssl
937MD2TEST=md2test
938MD5TEST=md5test
939MDC2TEST=mdc2test
940METHTEST=methtest
941OBJ=bntest.o ideatest.o md2test.o md5test.o hmactest.o rc2test.o rc4test.o rc5test.o destest.o shatest.o sha1test.o mdc2test.o rmdtest.o randtest.o dhtest.o casttest.o bftest.o ssltest.o dsatest.o exptest.o
942PEX_LIBS=
943RANDTEST=randtest
944RC2TEST=rc2test
945RC4TEST=rc4test
946RC5TEST=rc5test
947RMDTEST=rmdtest
948SHA1TEST=sha1test
949SHATEST=shatest
950SRC=bntest.c ideatest.c md2test.c md5test.c hmactest.c rc2test.c rc4test.c rc5test.c destest.c shatest.c sha1test.c mdc2test.c rmdtest.c randtest.c dhtest.c casttest.c bftest.c ssltest.c dsatest.c exptest.c
951SSLTEST=ssltest
952TOP=..
953RELATIVE_DIRECTORY=
954RELATIVE_DIRECTORY=tools
955APPS=c_hash c_info c_issuer c_name c_rehash
956CC=cc
957CFLAG=-g
958CFLAGS=-I.. -I../../include -g
959DIR=tools
960GENERAL=Makefile.ssl
961INCLUDES=-I.. -I../../include
962INSTALLTOP=/usr/local/ssl
963MAKE=make -f Makefile.ssl
964MAKEDEPEND=makedepend -f Makefile.ssl
965MAKEFILE=Makefile.ssl
966TEST=
967TOP=..
968RELATIVE_DIRECTORY=
diff --git a/src/lib/libssl/src/Makefile.ssl b/src/lib/libssl/src/Makefile.ssl
new file mode 100644
index 0000000000..da7f885985
--- /dev/null
+++ b/src/lib/libssl/src/Makefile.ssl
@@ -0,0 +1,331 @@
1#
2# Makefile for all the SSL related library routines and utilities
3VERSION = 0.9.0a
4#
5# make install will install:
6# libraries into $INSTALLTOP/lib
7# headers into $INSTALLTOP/include
8# utilities into $INSTALLTOP/bin
9#
10# By default INSTALLTOP is set to /usr/local/ssl
11# If you want things install elsewere, consider running
12# perl util/ssldir.pl /new/path
13#
14# Interesting Mailing Lists:
15# ssl-bugs@mincom.oz.au
16# ssl-users@mincom.oz.au
17#
18# To join the Mailing Lists:
19# ssl-bugs-request@mincom.oz.au
20# ssl-users-request@mincom.oz.au
21#
22# If you must get hold of people directly (we much prefer the above
23# lists to be used if the question is of general interest!):
24# Eric Young <eay@cryptsoft.com>
25# Tim Hudson <tjh@cryptsoft.com>
26# or both <ssleay@cryptsoft.com>
27#
28# The primary distribution of SSLeay is from
29# ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL
30#
31# NOCONST - Define for C compilers that don't like the const key word.
32# NOPROTO - Define in if your compiler does not support prototypes.
33# RSAref - Define if we are to link with RSAref.
34# NO_IDEA - Define to build without the IDEA algorithm
35# NO_RC4 - Define to build without the RC4 algorithm
36# NO_RC2 - Define to build without the RC2 algorithm
37# THREADS - Define when building with threads, you will probably also need any
38# system defines as well, i.e. _REENTERANT for Solaris 2.[34]
39# TERMIO - Define the termio terminal subsystem, needed if sgtty is missing.
40# TERMIOS - Define the termios terminal subsystem, Silicon Graphics.
41# LONGCRYPT - Define to use HPUX 10.x's long password modification to crypt(3).
42# DEVRANDOM - Give this the value of the 'random device' if your OS supports
43# one. 32 bytes will be read from this when the random
44# number generator is initalised.
45# SSL_ALLOW_ADH - define if you want the server to be able to use the
46# SSLv3 anon-DH ciphers.
47# SSL_ALLOW_ENULL - define if you want the server to be able to use the
48# NULL encryption ciphers.
49#
50# LOCK_DEBUG - turns on lots of lock debug output :-)
51# REF_CHECK - turn on some xyz_free() assertions.
52# REF_PRINT - prints some stuff on structure free.
53# CRYPTO_MDEBUG - turns on my 'memory leak' detecting stuff
54# MFUNC - Make all Malloc/Free/Realloc calls call
55# CRYPTO_malloc/CRYPTO_free/CRYPTO_realloc which can be setup to
56# call application defined callbacks via CRYPTO_set_mem_functions()
57# MD5_ASM needs to be defined to use the x86 assembler for MD5
58# SHA1_ASM needs to be defined to use the x86 assembler for SHA1
59# RMD160_ASM needs to be defined to use the x86 assembler for RIPEMD160
60
61
62CC= gcc
63#CFLAG= -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall -Wuninitialized -DMD5_ASM -DSHA1_ASM -DRMD160_ASM
64CFLAG= -DNO_IDEA -DTERMIOS -DBN_ASM -DL_ENDIAN -D_ANSI_SOURCE -fomit-frame-pointer -O3 -m486 -Wall -DSHA1_ASM -DMD5_ASM -DRMD160_ASM
65PEX_LIBS= -L. -L.. -L../.. -L../../..
66EX_LIBS=
67AR=ar r
68
69# Set BN_MULW to bn_mulw.o if you want to use the C version
70BN_MULW= asm/bn86-out.o
71#BN_MULW= bn_mulw.o
72#BN_MULW= asm/bn86-elf.o # elf, linux-elf
73#BN_MULW= asm/bn86-sol.o # solaris
74#BN_MULW= asm/bn86-out.o # a.out, FreeBSD
75#BN_MULW= asm/bn86bsdi.o # bsdi
76#BN_MULW= asm/alpha.o # DEC Alpha
77#BN_MULW= asm/pa-risc2.o # HP-UX PA-RISC
78#BN_MULW= asm/r3000.o # SGI MIPS cpu
79#BN_MULW= asm/sparc.o # Sun solaris/SunOS
80#BN_MULW= asm/bn-win32.o # Windows 95/NT
81#BN_MULW= asm/x86w16.o # 16 bit code for Windows 3.1/DOS
82#BN_MULW= asm/x86w32.o # 32 bit code for Windows 3.1
83
84# Set DES_ENC to des_enc.o if you want to use the C version
85#There are 4 x86 assember options.
86DES_ENC= asm/dx86-out.o asm/yx86-out.o
87#DES_ENC= des_enc.o fcrypt_b.o # C
88#DES_ENC= asm/dx86-elf.o asm/yx86-elf.o # elf
89#DES_ENC= asm/dx86-sol.o asm/yx86-sol.o # solaris
90#DES_ENC= asm/dx86-out.o asm/yx86-out.o # a.out, FreeBSD
91#DES_ENC= asm/dx86bsdi.o asm/yx86bsdi.o # bsdi
92
93# Set BF_ENC to bf_enc.o if you want to use the C version
94#There are 4 x86 assember options.
95BF_ENC= asm/bx86-out.o
96#BF_ENC= bf_enc.o
97#BF_ENC= asm/bx86-elf.o # elf
98#BF_ENC= asm/bx86-sol.o # solaris
99#BF_ENC= asm/bx86-out.o # a.out, FreeBSD
100#BF_ENC= asm/bx86bsdi.o # bsdi
101
102# Set CAST_ENC to c_enc.o if you want to use the C version
103#There are 4 x86 assember options.
104CAST_ENC= asm/cx86-out.o
105#CAST_ENC= c_enc.o
106#CAST_ENC= asm/cx86-elf.o # elf
107#CAST_ENC= asm/cx86-sol.o # solaris
108#CAST_ENC= asm/cx86-out.o # a.out, FreeBSD
109#CAST_ENC= asm/cx86bsdi.o # bsdi
110
111# Set RC4_ENC to rc4_enc.o if you want to use the C version
112#There are 4 x86 assember options.
113RC4_ENC= asm/rx86-out.o
114#RC4_ENC= rc4_enc.o
115#RC4_ENC= asm/rx86-elf.o # elf
116#RC4_ENC= asm/rx86-sol.o # solaris
117#RC4_ENC= asm/rx86-out.o # a.out, FreeBSD
118#RC4_ENC= asm/rx86bsdi.o # bsdi
119
120# Set RC5_ENC to rc5_enc.o if you want to use the C version
121#There are 4 x86 assember options.
122RC5_ENC= asm/r586-out.o
123#RC5_ENC= rc5_enc.o
124#RC5_ENC= asm/r586-elf.o # elf
125#RC5_ENC= asm/r586-sol.o # solaris
126#RC5_ENC= asm/r586-out.o # a.out, FreeBSD
127#RC5_ENC= asm/r586bsdi.o # bsdi
128
129# Also need MD5_ASM defined
130MD5_ASM_OBJ= asm/mx86-out.o
131#MD5_ASM_OBJ= asm/mx86-elf.o # elf
132#MD5_ASM_OBJ= asm/mx86-sol.o # solaris
133#MD5_ASM_OBJ= asm/mx86-out.o # a.out, FreeBSD
134#MD5_ASM_OBJ= asm/mx86bsdi.o # bsdi
135
136# Also need SHA1_ASM defined
137SHA1_ASM_OBJ= asm/sx86-out.o
138#SHA1_ASM_OBJ= asm/sx86-elf.o # elf
139#SHA1_ASM_OBJ= asm/sx86-sol.o # solaris
140#SHA1_ASM_OBJ= asm/sx86-out.o # a.out, FreeBSD
141#SHA1_ASM_OBJ= asm/sx86bsdi.o # bsdi
142
143# Also need RMD160_ASM defined
144RMD160_ASM_OBJ= asm/rm86-out.o
145#RMD160_ASM_OBJ= asm/rm86-elf.o # elf
146#RMD160_ASM_OBJ= asm/rm86-sol.o # solaris
147#RMD160_ASM_OBJ= asm/rm86-out.o # a.out, FreeBSD
148#RMD160_ASM_OBJ= asm/rm86bsdi.o # bsdi
149
150DIRS= crypto ssl rsaref apps test tools
151# dirs in crypto to build
152SDIRS= \
153 md2 md5 sha mdc2 hmac ripemd \
154 des rc2 rc4 rc5 idea bf cast \
155 bn rsa dsa dh \
156 buffer bio stack lhash rand err objects \
157 evp pem asn1 x509 conf txt_db pkcs7
158
159# If you change the INSTALLTOP, make sure to also change the values
160# in crypto/location.h
161INSTALLTOP=/usr/ssl
162
163MAKEFILE= Makefile.ssl
164MAKE= make -f Makefile.ssl
165
166MAN1=1
167MAN3=3
168SHELL=/bin/sh
169
170TOP= .
171ONEDIRS=out tmp
172EDIRS= times doc bugs util include certs ms shlib mt demos perl dep
173MISC= COPYRIGHT Configure HISTORY.066 INSTALL Makefile.ssl Makefile \
174 README TODO HISTORY README.066 README.080 README.090 \
175 VERSION PROBLEMS MINFO makefile.one e_os.h \
176 MICROSOFT makevms.com config PATENTS
177WDIRS= windows
178LIBS= libcrypto.a libssl.a
179
180GENERAL= Makefile
181BASENAME= SSLeay
182NAME= $(BASENAME)-$(VERSION)
183TARFILE= $(NAME).tar
184WTARFILE= $(NAME)-win.tar
185EXHEADER= e_os.h
186HEADER= e_os.h
187
188all:
189 @for i in $(DIRS) ;\
190 do \
191 (cd $$i; echo "making $$i..."; \
192 $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' SDIRS='${SDIRS}' AR='${AR}' all ); \
193 done;
194
195sub_all:
196 @for i in $(DIRS) ;\
197 do \
198 (cd $$i; echo "making $$i..."; \
199 $(MAKE) CC='${CC}' CFLAG='${CFLAG}' SDIRS='$(SDIRS)' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' all ); \
200 done;
201
202clean:
203 /bin/rm -f shlib/*.o *.o core a.out fluff *.map
204 @for i in $(DIRS) ;\
205 do \
206 (cd $$i; echo "cleaning $$i..."; \
207 $(MAKE) SDIRS='${SDIRS}' clean ); \
208 /bin/rm -f $(LIBS); \
209 done;
210 /bin/rm -f *.a *.o speed.* *.map *.so .pure core
211 /bin/rm -f $(TARFILE)
212 @for i in $(ONEDIRS) ;\
213 do \
214 /bin/rm -fr $$i/*; \
215 done
216
217makefile.one: files
218 perl util/mk1mf.pl >makefile.one; \
219 sh util/do_ms.sh
220
221files: MINFO
222 perl $(TOP)/util/files.pl Makefile.ssl > $(TOP)/MINFO
223 @for i in $(DIRS) ;\
224 do \
225 (cd $$i; echo "making 'files' in $$i..."; \
226 $(MAKE) SDIRS='${SDIRS}' files ); \
227 done;
228
229links:
230 /bin/rm -f Makefile;
231 ./util/point.sh Makefile.ssl Makefile;
232 $(TOP)/util/mklink.sh include $(EXHEADER) ;
233 @for i in $(DIRS) ;\
234 do \
235 (cd $$i; echo "making links in $$i..."; \
236 $(MAKE) SDIRS='${SDIRS}' links ); \
237 done;
238 # @(cd apps; sh ./mklinks)
239 @( SSLEAY="`pwd`/apps/ssleay"; export SSLEAY; sh tools/c_rehash certs )
240
241dclean:
242 /bin/rm -f *.bak
243 @for i in $(DIRS) ;\
244 do \
245 (cd $$i; echo "undoing makedepend in $$i..."; \
246 $(MAKE) SDIRS='${SDIRS}' dclean ); \
247 done;
248
249rehash:
250 @(PATH="`pwd`/apps:${PATH}"; sh tools/c_rehash certs)
251
252test: tests
253
254tests:
255 (cd test; echo "testing $$i..."; \
256 $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' SDIRS='${SDIRS}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' AR='${AR}' tests );
257 @apps/ssleay version -a
258
259depend:
260 @for i in $(DIRS) ;\
261 do \
262 (cd $$i; echo "making dependancies $$i..."; \
263 $(MAKE) SDIRS='${SDIRS}' depend ); \
264 done;
265
266lint:
267 @for i in $(DIRS) ;\
268 do \
269 (cd $$i; echo "making lint $$i..."; \
270 $(MAKE) SDIRS='${SDIRS}' lint ); \
271 done;
272
273tags:
274 @for i in $(DIRS) ;\
275 do \
276 (cd $$i; echo "making tags $$i..."; \
277 $(MAKE) SDIRS='${SDIRS}' tags ); \
278 done;
279
280errors:
281 @for i in $(DIRS) ;\
282 do \
283 (cd $$i; echo "making errors in $$i..."; \
284 $(MAKE) SDIRS='${SDIRS}' errors ); \
285 done;
286
287tar:
288 @(cd ..;\
289 mv $(BASENAME) $(NAME); \
290 export STUFF; \
291 for i in $(MISC) $(DIRS) $(EDIRS) $(ONEDIRS) ;\
292 do \
293 STUFF="$$STUFF $(NAME)/$$i"; \
294 done; \
295 tar cf $(NAME)/$(TARFILE) $$STUFF; \
296 mv $(NAME) $(BASENAME) )
297 gzip -f $(TARFILE)
298
299dist:
300 perl Configure dist
301 perl util/up_ver.pl ${VERSION}
302 @$(MAKE) dist_pem_h
303 @$(MAKE) SDIRS='${SDIRS}' clean
304 @$(MAKE) SDIRS='${SDIRS}' dclean
305 @(cd apps; sh ./rmlinks)
306 @$(MAKE) makefile.one
307 @$(MAKE) tar
308
309dist_pem_h:
310 (cd crypto/pem; $(MAKE) SDIRS='${SDIRS}' CFLAG='${CFLAG}' pem.h; $(MAKE) clean)
311
312install: all
313 @-mkdir -p $(INSTALLTOP)/bin 2>/dev/null
314 @-mkdir -p $(INSTALLTOP)/lib 2>/dev/null
315 @-mkdir -p $(INSTALLTOP)/include 2>/dev/null
316 @-mkdir -p $(INSTALLTOP)/certs 2>/dev/null
317 @-mkdir -p $(INSTALLTOP)/private 2>/dev/null
318 @for i in $(DIRS) ;\
319 do \
320 (cd $$i; echo "installing $$i..."; \
321 $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' EX_LIBS='${EX_LIBS}' SDIRS='${SDIRS}' install ); \
322 done
323 @for i in $(LIBS) ;\
324 do \
325 ( echo installing $$i; \
326 cp $$i $(INSTALLTOP)/lib; \
327 sh util/ranlib.sh $(INSTALLTOP)/lib/$$i; \
328 chmod 644 $(INSTALLTOP)/lib/$$i ); \
329 done
330
331# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/PATENTS b/src/lib/libssl/src/PATENTS
new file mode 100644
index 0000000000..61423d03c8
--- /dev/null
+++ b/src/lib/libssl/src/PATENTS
@@ -0,0 +1,9 @@
1RSA Data Security holds software patents on the RSA and RC5 algorithms.
2If there ciphers are used used inside the USA (and Japan?), you must contact
3RSA Data Security for licencing conditions.
4
5The IDEA algorithm is patented by XXXX and they should be contacted if that
6algorithm is to be used.
7
8RC4 is a trademark of RSA Data Security, so use of this label should perhaps
9only me used with RSA Data Security's permission.
diff --git a/src/lib/libssl/src/README.066 b/src/lib/libssl/src/README.066
new file mode 100644
index 0000000000..d8e086d0b4
--- /dev/null
+++ b/src/lib/libssl/src/README.066
@@ -0,0 +1,27 @@
1
2SSLeay 0.6.6 13-Jan-1997
3
4The main additions are
5
6- assember for x86 DES improvments.
7 From 191,000 per second on a pentium 100, I now get 281,000. The inner
8 loop and the IP/FP modifications are from
9 Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>. Many thanks for his
10 contribution.
11- The 'DES macros' introduced in 0.6.5 now have 3 types.
12 DES_PTR1, DES_PTR2 and 'normal'. As per before, des_opts reports which
13 is best and there is a summery of mine in crypto/des/options.txt
14- A few bug fixes.
15- Added blowfish. It is not used by SSL but all the other stuff that
16 deals with ciphers can use it in either ecb, cbc, cfb64 or ofb64 modes.
17 There are 3 options for optimising Blowfish. BF_PTR, BF_PTR2 and 'normal'.
18 BF_PTR2 is pentium/x86 specific. The correct option is setup in
19 the 'Configure' script.
20- There is now a 'get client certificate' callback which can be
21 'non-blocking'. If more details are required, let me know. It will
22 documented more in SSLv3 when I finish it.
23- Bug fixes from 0.6.5 including the infamous 'ca' bug. The 'make test'
24 now tests the ca program.
25- Lots of little things modified and tweaked.
26
27eric
diff --git a/src/lib/libssl/src/README.080 b/src/lib/libssl/src/README.080
new file mode 100644
index 0000000000..155ce1c712
--- /dev/null
+++ b/src/lib/libssl/src/README.080
@@ -0,0 +1,147 @@
1This version of SSLeay has quite a lot of things different from the
2previous version.
3
4Basically check all callback parameters, I will be producing documentation
5about how to use things in th future. Currently I'm just getting 080 out
6the door. Please not that there are several ways to do everything, and
7most of the applications in the apps directory are hybrids, some using old
8methods and some using new methods.
9
10Have a look in demos/bio for some very simple programs and
11apps/s_client.c and apps/s_server.c for some more advanced versions.
12Notes are definitly needed but they are a week or so away.
13
14Anyway, some quick nots from Tim Hudson (tjh@cryptsoft.com)
15---
16Quick porting notes for moving from SSLeay-0.6.x to SSLeay-0.8.x to
17get those people that want to move to using the new code base off to
18a quick start.
19
20Note that Eric has tidied up a lot of the areas of the API that were
21less than desirable and renamed quite a few things (as he had to break
22the API in lots of places anyrate). There are a whole pile of additional
23functions for making dealing with (and creating) certificates a lot
24cleaner.
25
2601-Jul-97
27Tim Hudson
28tjh@cryptsoft.com
29
30---8<---
31
32To maintain code that uses both SSLeay-0.6.x and SSLeay-0.8.x you could
33use something like the following (assuming you #include "crypto.h" which
34is something that you really should be doing).
35
36#if SSLEAY_VERSION_NUMBER >= 0x0800
37#define SSLEAY8
38#endif
39
40buffer.h -> splits into buffer.h and bio.h so you need to include bio.h
41 too if you are working with BIO internal stuff (as distinct
42 from simply using the interface in an opaque manner)
43
44#include "bio.h" - required along with "buffer.h" if you write
45 your own BIO routines as the buffer and bio
46 stuff that was intermixed has been separated
47 out
48
49envelope.h -> evp.h (which should have been done ages ago)
50
51Initialisation ... don't forget these or you end up with code that
52is missing the bits required to do useful things (like ciphers):
53
54SSLeay_add_ssl_algorithms()
55(probably also want SSL_load_error_strings() too but you should have
56 already had that call in place)
57
58SSL_CTX_new() - requires an extra method parameter
59 SSL_CTX_new(SSLv23_method())
60 SSL_CTX_new(SSLv2_method())
61 SSL_CTX_new(SSLv3_method())
62
63 OR to only have the server or the client code
64 SSL_CTX_new(SSLv23_server_method())
65 SSL_CTX_new(SSLv2_server_method())
66 SSL_CTX_new(SSLv3_server_method())
67 or
68 SSL_CTX_new(SSLv23_client_method())
69 SSL_CTX_new(SSLv2_client_method())
70 SSL_CTX_new(SSLv3_client_method())
71
72SSL_set_default_verify_paths() ... renamed to the more appropriate
73SSL_CTX_set_default_verify_paths()
74
75If you want to use client certificates then you have to add in a bit
76of extra stuff in that a SSLv3 server sends a list of those CAs that
77it will accept certificates from ... so you have to provide a list to
78SSLeay otherwise certain browsers will not send client certs.
79
80SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(s_cert_file));
81
82
83X509_NAME_oneline(X) -> X509_NAME_oneline(X,NULL,0)
84 or provide a buffer and size to copy the
85 result into
86
87X509_add_cert -> X509_STORE_add_cert (and you might want to read the
88 notes on X509_NAME structure changes too)
89
90
91VERIFICATION CODE
92=================
93
94The codes have all be renamed from VERIFY_ERR_* to X509_V_ERR_* to
95more accurately reflect things.
96
97The verification callback args are now packaged differently so that
98extra fields for verification can be added easily in future without
99having to break things by adding extra parameters each release :-)
100
101X509_cert_verify_error_string -> X509_verify_cert_error_string
102
103
104BIO INTERNALS
105=============
106
107Eric has fixed things so that extra flags can be introduced in
108the BIO layer in future without having to play with all the BIO
109modules by adding in some macros.
110
111The ugly stuff using
112 b->flags ~= (BIO_FLAGS_RW|BIO_FLAGS_SHOULD_RETRY)
113becomes
114 BIO_clear_retry_flags(b)
115
116 b->flags |= (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)
117becomes
118 BIO_set_retry_read(b)
119
120Also ... BIO_get_retry_flags(b), BIO_set_flags(b)
121
122
123
124OTHER THINGS
125============
126
127X509_NAME has been altered so that it isn't just a STACK ... the STACK
128is now in the "entries" field ... and there are a pile of nice functions
129for getting at the details in a much cleaner manner.
130
131SSL_CTX has been altered ... "cert" is no longer a direct member of this
132structure ... things are now down under "cert_store" (see x509_vfy.h) and
133things are no longer in a CERTIFICATE_CTX but instead in a X509_STORE.
134If your code "knows" about this level of detail then it will need some
135surgery.
136
137If you depending on the incorrect spelling of a number of the error codes
138then you will have to change your code as these have been fixed.
139
140ENV_CIPHER "type" got renamed to "nid" and as that is what it actually
141has been all along so this makes things clearer.
142ify_cert_error_string(ctx->error));
143
144SSL_R_NO_CIPHER_WE_TRUST -> SSL_R_NO_CIPHER_LIST
145 and SSL_R_REUSE_CIPHER_LIST_NOT_ZERO
146
147
diff --git a/src/lib/libssl/src/README.090 b/src/lib/libssl/src/README.090
new file mode 100644
index 0000000000..634870d5f1
--- /dev/null
+++ b/src/lib/libssl/src/README.090
@@ -0,0 +1,71 @@
110-Apr-1998
2I said the next version would go out at easter, and so it shall.
3I expect a 0.9.1 will follow with portability fixes in the next few weeks.
4
5This is a quick, meet the deadline. Look to ssl-users for comments on what
6is new etc.
7
8The state of play
9- TLSv1 - I need to do some explaining about how the methods interact.
10 The bad news is that SSLeay 0.8.x application will not roll back to
11 SSLv3, I suffed up. 0.8.x is rather pedantic about the '3.0' version
12 number. Look at the 'no-tls' options in applications in the apps directory.
13- The perl5 stuff is very rough. The SSL part does not work due to
14 reference count hassles in the BIO stuff. I just have not had time to
15 look at it. The cipher, digest and bignum stuff works though. I just
16 need to clean up the API.
17- Lots of x86 assember. I now have it for des, 3des, rc4, rc5, blowfish,
18 cast, md5, sha1 and ripemd160. It has been tested on win32, linux (elf)
19 and FreeBSD (a.out).
20- As mentioned above, cast, rc5 and ripemd160 have been added.
21- A simple HMAC set of functions.
22- EX_DATA strucutre, which can be used by applications or other libraries
23 to tack arbitarty data against strucutures that include it.
24 You will probably have to see examples to see how to use it, and I will
25 elaberate on the ssl-users mailing list
26- RSA blinding. If you fear timing attacks on RSA, you can turn on
27 blinding which defeats it.
28- From Tim Hudson, try running 'sh config' instead of 'perl Configure'.
29 I makes an educated guess as to what you are and then runs 'perl Configure'
30- The error stuff has been modified so arbitary strings can be taged
31 against an error message. It is used in a few places to elaberate on
32 parameters that caused the error.
33
34Areas of work
35- The 16bit big-num assember needs a routine added. The WIN16 and
36 WIN32 stuff is ok, but MS-DOS or 286 builds need the update.
37- Most of the bignum assember will not work. There will be a function
38 missing, bn_add_words(). I need people to send me the C compiler output
39 for platforms I don't already have. Currently, the assember is correct for
40 x86, win32, win16(386+), linux elf, FreeBSD a.out and sparc.
41- PKCS7, I have delusions of s/MIME. I need to do a BIO interface.
42- perl5, it needs finishing
43- X509v3 extension. I have some ideas, I just need to
44 implement them :-)
45- Public key methods. I need to clean up the library internally so
46 public key methods are loaded is a similar way to symetric ciphers
47 and digests. I also need to seperate out the digests from public
48 key methods. This stuff is needed to support sortware patents, smaller
49 code size and hardware tokens.
50
51Anyway, this release gets out the bug fixes and TLS, but be warned, until
52all those old SSLeay 0.8.x based server get upgraded, you will need to
53connect with SSLv3 if TLSv1 fails.
54
55eric (about to go bushwalking for the 4 day easter break :-)
56
57PS Common problems
58- For Win32 build, use /MD to specify your libraries, or build SSLeay with
59 the same flags as your application. Visual C stuffs up the malloc routines
60 if memory allocated by one memory model is freed by another. FILE pointers
61 are a major cause of these problem.
62- If you are trying to use non-blocking IO and it is not working,
63 try 'ssleay s_client -help' and see if the -nbio option is listed.
64 For unixware, it has the non-block IO define in 'differnt' header file
65 and SSLeay will silently build without non-blocking IO calls (but for
66 unixware, the special header has been included).
67- -DL_ENDIAN. For the message digests, some code needs to be turned off
68 in the C code when assember is used. For x86, this means the L_ENDIAN
69 needs to defined when x86 -DSHA1_ASM is defined. The reasons this is
70 not automagically done is because non-x86 assember could be bigendian.
71 For pure C code builds, the B_ENDIAN/L_ENDIAN flags are optional.
diff --git a/src/lib/libssl/src/TODO b/src/lib/libssl/src/TODO
new file mode 100644
index 0000000000..1c3da41cdf
--- /dev/null
+++ b/src/lib/libssl/src/TODO
@@ -0,0 +1,28 @@
1- The loading of the netscape RC4 encrypted key is a crock of pig pellets.
2 It will be reworked along with a nice general mechanism for encrypting
3 ASN.1 stuff. [ Jun 96 ] I've cleaned up private keys internally but
4 still have not done PKCS#8 support.
5
6- Winsock support in s_client/s_server for windows nt/3.1 is a crock.
7 I will probably not get this fixed for a while, it is just there so
8 I could test things.
9
10- Be able to generate DSS certificates.
11
12- Add CRL to the X509 verification stuff, this will probably be added with
13 SSLv3.
14
15+ X509 callback. I need to callback the application to retrieve certificates
16 and CRL.
17
18*<- designates the things I'm activly working on.
19+<- designates that which I have next in the queue.
20
21====
22
23X509v3 extensions
24verify certificate chains
25X509 cert lookup methods
26RSA/DSA/DH methods mostly for smart cards
27dsa cert generation
28
diff --git a/src/lib/libssl/src/VERSION b/src/lib/libssl/src/VERSION
new file mode 100644
index 0000000000..5555e9a3af
--- /dev/null
+++ b/src/lib/libssl/src/VERSION
@@ -0,0 +1,24 @@
1SSLeay 0.8.1
2 - Mostly bug fixes. There is an Ephemeral DH cipher problem which
3 is fixed.
4
5SSLeay 0.8.0
6 - New release, for those that are wondering what happend to
7 0.7.x, call it our internal development version :-)
8 - There have been lots of changes, mostly the addition of SSLv3.
9 - There have been many additions from people and amongst
10 others, C2Net has assisted greatly.
11
12SSLeay 0.6.6
13 SSLeay 0.8.0 is not upward compatable with SSLeay 0.6.6, so
14 if your application requires 0.6.6, use it. There have been
15 lots of bug fixes to 0.8.x that have not been applied to 0.6.6
16 so use 0.8.0+ in preference.
17
18PORTING 0.6.6 to 0.8.0
19 I'll be documenting this over the next few weeks but as
20 pressures have been increasing for making SSLv3 support
21 available I'm shipping it without this documentation as I
22 basically have not had time to write it (too busy earning a
23 living :-)
24
diff --git a/src/lib/libssl/src/apps/Makefile.ssl b/src/lib/libssl/src/apps/Makefile.ssl
new file mode 100644
index 0000000000..1cace40ab7
--- /dev/null
+++ b/src/lib/libssl/src/apps/Makefile.ssl
@@ -0,0 +1,144 @@
1#
2# SSLeay/apps/Makefile.ssl
3#
4
5DIR= apps
6TOP= ..
7CC= cc
8INCLUDES= -I../include
9CFLAG= -g -static
10INSTALLTOP= /usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14RM= /bin/rm -f
15
16PEX_LIBS=
17EX_LIBS=
18
19CFLAGS= -DMONOLITH $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22
23DLIBCRYPTO=../libcrypto.a
24DLIBSSL=../libssl.a
25LIBCRYPTO=-L.. -lcrypto
26LIBSSL=-L.. -lssl
27
28SSLEAY= ssleay
29
30SCRIPTS=CA.sh der_chop
31
32EXE= $(SSLEAY)
33
34E_EXE= verify asn1pars req dgst dh enc gendh errstr ca crl \
35 rsa dsa dsaparam \
36 x509 genrsa s_server s_client speed \
37 s_time version pkcs7 crl2pkcs7 sess_id ciphers
38
39PROGS= $(SSLEAY).c
40
41A_OBJ=apps.o
42A_SRC=apps.c
43S_OBJ= s_cb.o s_socket.o
44S_SRC= s_cb.c s_socket.c
45
46E_OBJ= verify.o asn1pars.o req.o dgst.o dh.o enc.o gendh.o errstr.o ca.o \
47 pkcs7.o crl2p7.o crl.o \
48 rsa.o dsa.o dsaparam.o \
49 x509.o genrsa.o s_server.o s_client.o speed.o \
50 s_time.o $(A_OBJ) $(S_OBJ) version.o sess_id.o \
51 ciphers.o
52
53# pem_mail.o
54
55E_SRC= verify.c asn1pars.c req.c dgst.c dh.c enc.c gendh.c errstr.c ca.c \
56 pkcs7.c crl2p7.c crl.c \
57 rsa.c dsa.c dsaparam.c \
58 x509.c genrsa.c s_server.c s_client.c speed.c \
59 s_time.c $(A_SRC) $(S_SRC) version.c sess_id.c \
60 ciphers.c
61
62# pem_mail.c
63
64SRC=$(E_SRC)
65
66EXHEADER=
67HEADER= apps.h progs.h s_apps.h \
68 testdsa.h testrsa.h \
69 $(EXHEADER)
70
71ALL= $(GENERAL) $(SRC) $(HEADER)
72
73top:
74 @(cd ..; $(MAKE) DIRS=$(DIR) all)
75
76all: exe
77
78exe: $(EXE)
79
80req: sreq.o $(A_OBJ) $(DLIBCRYPTO)
81 $(CC) -o req $(CFLAG) sreq.o $(A_OBJ) $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
82
83sreq.o: req.c
84 $(CC) -c $(INCLUDES) $(CFLAG) -o sreq.o req.c
85
86files:
87 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
88
89install: mklinks
90 @for i in $(EXE) $(SCRIPTS) mklinks; \
91 do \
92 (echo installing $$i; \
93 cp $$i $(INSTALLTOP)/bin/$$i; \
94 chmod 755 $(INSTALLTOP)/bin/$$i ); \
95 done; \
96 cp ssleay.cnf $(INSTALLTOP)/lib
97 chmod 644 $(INSTALLTOP)/lib/ssleay.cnf
98 cd $(INSTALLTOP)/bin; \
99 /bin/sh ./mklinks; \
100 /bin/rm -f ./mklinks
101
102tags:
103 ctags $(SRC)
104
105tests:
106
107links:
108 /bin/rm -f Makefile
109 $(TOP)/util/point.sh Makefile.ssl Makefile ;
110
111lint:
112 lint -DLINT $(INCLUDES) $(SRC)>fluff
113
114depend:
115 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(SRC)
116
117dclean:
118 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
119 mv -f Makefile.new $(MAKEFILE)
120
121errors:
122
123clean:
124 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE)
125 /bin/rm -f req
126
127$(DLIBSSL):
128 (cd ../ssl; $(MAKE))
129
130$(DLIBCRYPTO):
131 (cd ../crypto; $(MAKE))
132
133$(SSLEAY): progs.h $(E_OBJ) $(SSLEAY).o $(DLIBCRYPTO) $(DLIBSSL)
134 $(RM) $(SSLEAY)
135 $(CC) -o $(SSLEAY) $(CFLAGS) $(SSLEAY).o $(E_OBJ) $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS)
136
137progs.h:
138 perl ./g_ssleay.pl $(E_EXE) >progs.h
139 $(RM) $(SSLEAY).o
140
141mklinks:
142 perl ./g_ssleay.pl $(E_EXE) >progs.h
143
144# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/apps/der_chop b/src/lib/libssl/src/apps/der_chop
new file mode 100644
index 0000000000..4639330c10
--- /dev/null
+++ b/src/lib/libssl/src/apps/der_chop
@@ -0,0 +1,305 @@
1#!/usr/local/bin/perl
2#
3# der_chop ... this is one total hack that Eric is really not proud of
4# so don't look at it and don't ask for support
5#
6# The "documentation" for this (i.e. all the comments) are my fault --tjh
7#
8# This program takes the "raw" output of derparse/asn1parse and
9# converts it into tokens and then runs regular expression matches
10# to try to figure out what to grab to get the things that are needed
11# and it is possible that this will do the wrong thing as it is a *hack*
12#
13# SSLeay 0.5.2+ should have direct read support for x509 (via -inform NET)
14# [I know ... promises promises :-)]
15#
16# To convert a Netscape Certificate:
17# der_chop < ServerCert.der > cert.pem
18# To convert a Netscape Key (and encrypt it again to protect it)
19# rsa -inform NET -in ServerKey.der -des > key.pem
20#
21# 23-Apr-96 eay Added the extra ASN.1 string types, I still think this
22# is an evil hack. If nothing else the parsing should
23# be relative, not absolute.
24# 19-Apr-96 tjh hacked (with eay) into 0.5.x format
25#
26# Tim Hudson
27# tjh@cryptsoft.com
28#
29
30
31require 'getopts.pl';
32
33$debug=0;
34
35# this was the 0.4.x way of doing things ...
36$cmd="derparse";
37$x509_cmd="x509";
38$crl_cmd="crl";
39$rc4_cmd="rc4";
40$md2_cmd="md2";
41$md4_cmd="md4";
42$rsa_cmd="rsa -des -inform der ";
43
44# this was the 0.5.x way of doing things ...
45$cmd="ssleay asn1parse";
46$x509_cmd="ssleay x509";
47$crl_cmd="ssleay crl";
48$rc4_cmd="ssleay rc4";
49$md2_cmd="ssleay md2";
50$md4_cmd="ssleay md4";
51$rsa_cmd="ssleay rsa -des -inform der ";
52
53&Getopts('vd:') || die "usage:$0 [-v] [-d num] file";
54$depth=($opt_d =~ /^\d+$/)?$opt_d:0;
55
56&init_der();
57
58if ($#ARGV != -1)
59 {
60 foreach $file (@ARGV)
61 {
62 print STDERR "doing $file\n";
63 &dofile($file);
64 }
65 }
66else
67 {
68 $file="/tmp/a$$.DER";
69 open(OUT,">$file") || die "unable to open $file:$!\n";
70 for (;;)
71 {
72 $i=sysread(STDIN,$b,1024*10);
73 last if ($i <= 0);
74 $i=syswrite(OUT,$b,$i);
75 }
76 &dofile($file);
77 unlink($file);
78 }
79
80sub dofile
81 {
82 local($file)=@_;
83 local(@p);
84
85 $b=&load_file($file);
86 @p=&load_file_parse($file);
87
88 foreach $_ (@p)
89 {
90 ($off,$d,$hl,$len)=&parse_line($_);
91 $d-=$depth;
92 next if ($d != 0);
93 next if ($len == 0);
94
95 $o=substr($b,$off,$len+$hl);
96 ($str,@data)=&der_str($o);
97 print "$str\n" if ($opt_v);
98 if ($str =~ /^$crl/)
99 {
100 open(OUT,"|$crl_cmd -inform d -hash -issuer") ||
101 die "unable to run $crl_cmd:$!\n";
102 print OUT $o;
103 close(OUT);
104 }
105 elsif ($str =~ /^$x509/)
106 {
107 open(OUT,"|$x509_cmd -inform d -hash -subject -issuer")
108 || die "unable to run $x509_cmd:$!\n";
109 print OUT $o;
110 close(OUT);
111 }
112 elsif ($str =~ /^$rsa/)
113 {
114 ($type)=($data[3] =~ /OBJECT_IDENTIFIER :(.*)\s*$/);
115 next unless ($type eq "rsaEncryption");
116 ($off,$d,$hl,$len)=&parse_line($data[5]);
117 $os=substr($o,$off+$hl,$len);
118 open(OUT,"|$rsa_cmd")
119 || die "unable to run $rsa_cmd:$!\n";
120 print OUT $os;
121 close(OUT);
122 }
123 elsif ($str =~ /^0G-1D-1G/)
124 {
125 ($off,$d,$hl,$len)=&parse_line($data[1]);
126 $os=substr($o,$off+$hl,$len);
127 print STDERR "<$os>\n" if $opt_v;
128 &do_certificate($o,@data)
129 if (($os eq "certificate") &&
130 ($str =! /^0G-1D-1G-2G-3F-3E-2D/));
131 &do_private_key($o,@data)
132 if (($os eq "private-key") &&
133 ($str =! /^0G-1D-1G-2G-3F-3E-2D/));
134 }
135 }
136 }
137
138sub der_str
139 {
140 local($str)=@_;
141 local(*OUT,*IN,@a,$t,$d,$ret);
142 local($file)="/tmp/b$$.DER";
143 local(@ret);
144
145 open(OUT,">$file");
146 print OUT $str;
147 close(OUT);
148 open(IN,"$cmd -inform 'd' -in $file |") ||
149 die "unable to run $cmd:$!\n";
150 $ret="";
151 while (<IN>)
152 {
153 chop;
154 push(@ret,$_);
155
156 print STDERR "$_\n" if ($debug);
157
158 @a=split(/\s*:\s*/);
159 ($d)=($a[1] =~ /d=\s*(\d+)/);
160 $a[2] =~ s/\s+$//;
161 $t=$DER_s2i{$a[2]};
162 $ret.="$d$t-";
163 }
164 close(IN);
165 unlink($file);
166 chop $ret;
167 $ret =~ s/(-3H(-4G-5F-5[IJKMQRS])+)+/-NAME/g;
168 $ret =~ s/(-3G-4B-4L)+/-RCERT/g;
169 return($ret,@ret);
170 }
171
172sub init_der
173 {
174 $crl= "0G-1G-2G-3F-3E-2G-NAME-2L-2L-2G-RCERT-1G-2F-2E-1C";
175 $x509="0G-1G-2B-2G-3F-3E-2G-NAME-2G-3L-3L-2G-NAME-2G-3G-4F-4E-3C-1G-2F-2E-1C";
176 $rsa= "0G-1B-1G-2F-2E-1D";
177
178 %DER_i2s=(
179 # SSLeay 0.4.x has this list
180 "A","EOC",
181 "B","INTEGER",
182 "C","BIT STRING",
183 "D","OCTET STRING",
184 "E","NULL",
185 "F","OBJECT",
186 "G","SEQUENCE",
187 "H","SET",
188 "I","PRINTABLESTRING",
189 "J","T61STRING",
190 "K","IA5STRING",
191 "L","UTCTIME",
192 "M","NUMERICSTRING",
193 "N","VIDEOTEXSTRING",
194 "O","GENERALIZEDTIME",
195 "P","GRAPHICSTRING",
196 "Q","ISO64STRING",
197 "R","GENERALSTRING",
198 "S","UNIVERSALSTRING",
199
200 # SSLeay 0.5.x changed some things ... and I'm
201 # leaving in the old stuff but adding in these
202 # to handle the new as well --tjh
203 # - Well I've just taken them out and added the extra new
204 # ones :-) - eay
205 );
206
207 foreach (keys %DER_i2s)
208 { $DER_s2i{$DER_i2s{$_}}=$_; }
209 }
210
211sub parse_line
212 {
213 local($_)=@_;
214
215 return(/\s*(\d+):d=\s*(\d+)\s+hl=\s*(\d+)\s+l=\s*(\d+|inf)\s/);
216 }
217
218# 0:d=0 hl=4 l=377 cons: univ: SEQUENCE
219# 4:d=1 hl=2 l= 11 prim: univ: OCTET_STRING
220# 17:d=1 hl=4 l=360 cons: univ: SEQUENCE
221# 21:d=2 hl=2 l= 12 cons: univ: SEQUENCE
222# 23:d=3 hl=2 l= 8 prim: univ: OBJECT_IDENTIFIER :rc4
223# 33:d=3 hl=2 l= 0 prim: univ: NULL
224# 35:d=2 hl=4 l=342 prim: univ: OCTET_STRING
225sub do_private_key
226 {
227 local($data,@struct)=@_;
228 local($file)="/tmp/b$$.DER";
229 local($off,$d,$hl,$len,$_,$b,@p,$s);
230
231 ($type)=($struct[4] =~ /OBJECT_IDENTIFIER :(.*)\s*$/);
232 if ($type eq "rc4")
233 {
234 ($off,$d,$hl,$len)=&parse_line($struct[6]);
235 open(OUT,"|$rc4_cmd >$file") ||
236 die "unable to run $rc4_cmd:$!\n";
237 print OUT substr($data,$off+$hl,$len);
238 close(OUT);
239
240 $b=&load_file($file);
241 unlink($file);
242
243 ($s,@p)=&der_str($b);
244 die "unknown rsa key type\n$s\n"
245 if ($s ne '0G-1B-1G-2F-2E-1D');
246 local($off,$d,$hl,$len)=&parse_line($p[5]);
247 $b=substr($b,$off+$hl,$len);
248 ($s,@p)=&der_str($b);
249 open(OUT,"|$rsa_cmd") || die "unable to run $rsa_cmd:$!\n";
250 print OUT $b;
251 close(OUT);
252 }
253 else
254 {
255 print "'$type' is unknown\n";
256 exit(1);
257 }
258 }
259
260sub do_certificate
261 {
262 local($data,@struct)=@_;
263 local($file)="/tmp/b$$.DER";
264 local($off,$d,$hl,$len,$_,$b,@p,$s);
265
266 ($off,$d,$hl,$len)=&parse_line($struct[2]);
267 $b=substr($data,$off,$len+$hl);
268
269 open(OUT,"|$x509_cmd -inform d") || die "unable to run $x509_cmd:$!\n";
270 print OUT $b;
271 close(OUT);
272 }
273
274sub load_file
275 {
276 local($file)=@_;
277 local(*IN,$r,$b,$i);
278
279 $r="";
280 open(IN,"<$file") || die "unable to open $file:$!\n";
281 for (;;)
282 {
283 $i=sysread(IN,$b,10240);
284 last if ($i <= 0);
285 $r.=$b;
286 }
287 close(IN);
288 return($r);
289 }
290
291sub load_file_parse
292 {
293 local($file)=@_;
294 local(*IN,$r,@ret,$_,$i,$n,$b);
295
296 open(IN,"$cmd -inform d -in $file|")
297 || die "unable to run der_parse\n";
298 while (<IN>)
299 {
300 chop;
301 push(@ret,$_);
302 }
303 return($r,@ret);
304 }
305
diff --git a/src/lib/libssl/src/apps/eay.c b/src/lib/libssl/src/apps/eay.c
new file mode 100644
index 0000000000..37d5dcbd30
--- /dev/null
+++ b/src/lib/libssl/src/apps/eay.c
@@ -0,0 +1,130 @@
1/* apps/eay.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62
63#define MONOLITH
64#define USE_SOCKETS
65#include "../e_os.h"
66
67#include "bio.h"
68#include "stack.h"
69#include "lhash.h"
70
71#include "err.h"
72
73#include "bn.h"
74
75#include "evp.h"
76
77#include "rand.h"
78#include "conf.h"
79#include "txt_db.h"
80
81#include "err.h"
82
83#include "x509.h"
84#include "pkcs7.h"
85#include "pem.h"
86#include "asn1.h"
87#include "objects.h"
88
89#define MONOLITH
90
91#include "ssleay.c"
92#include "apps.c"
93#include "asn1pars.c"
94#ifndef NO_RSA
95#include "ca.c"
96#include "genrsa.c"
97#include "req.c"
98#include "rsa.c"
99#endif
100#ifndef NO_DH
101#include "gendh.c"
102#include "dh.c"
103#endif
104#include "crl.c"
105#include "crl2p7.c"
106#include "dgst.c"
107#include "enc.c"
108#include "errstr.c"
109#if !defined(NO_SSL2) || !defined(NO_SSL3)
110#ifndef NO_SOCK
111#include "s_cb.c"
112#include "s_client.c"
113#include "s_server.c"
114#include "s_socket.c"
115#include "s_time.c"
116#endif
117#endif
118#include "speed.c"
119#include "verify.c"
120#include "version.c"
121#include "x509.c"
122#include "ciphers.c"
123#include "sess_id.c"
124#include "pkcs7.c"
125#ifndef NO_DSA
126#include "dsaparam.c"
127#include "dsa.c"
128#include "gendsa.c"
129#endif
130
diff --git a/src/lib/libssl/src/apps/ext.v3 b/src/lib/libssl/src/apps/ext.v3
new file mode 100644
index 0000000000..87ee8e6173
--- /dev/null
+++ b/src/lib/libssl/src/apps/ext.v3
@@ -0,0 +1,2 @@
12.99999.3 SET.ex3 SET x509v3 extension 3
2
diff --git a/src/lib/libssl/src/apps/g_ssleay.pl b/src/lib/libssl/src/apps/g_ssleay.pl
new file mode 100644
index 0000000000..bd5621dcab
--- /dev/null
+++ b/src/lib/libssl/src/apps/g_ssleay.pl
@@ -0,0 +1,114 @@
1#!/usr/bin/perl
2
3$mkprog='mklinks';
4$rmprog='rmlinks';
5
6print "#ifndef NOPROTO\n";
7
8grep(s/^asn1pars$/asn1parse/,@ARGV);
9
10foreach (@ARGV)
11 { printf "extern int %s_main(int argc,char *argv[]);\n",$_; }
12print "#else\n";
13foreach (@ARGV)
14 { printf "extern int %s_main();\n",$_; }
15print "#endif\n";
16
17
18print <<'EOF';
19
20#ifdef SSLEAY_SRC
21
22#define FUNC_TYPE_GENERAL 1
23#define FUNC_TYPE_MD 2
24#define FUNC_TYPE_CIPHER 3
25
26typedef struct {
27 int type;
28 char *name;
29 int (*func)();
30 } FUNCTION;
31
32FUNCTION functions[] = {
33EOF
34
35foreach (@ARGV)
36 {
37 push(@files,$_);
38 $str="\t{FUNC_TYPE_GENERAL,\"$_\",${_}_main},\n";
39 if (($_ =~ /^s_/) || ($_ =~ /^ciphers$/))
40 { print "#if !defined(NO_SOCK) && !(defined(NO_SSL2) && defined(O_SSL3))\n${str}#endif\n"; }
41 elsif ( ($_ =~ /^rsa$/) || ($_ =~ /^genrsa$/) ||
42 ($_ =~ /^req$/) || ($_ =~ /^ca$/) || ($_ =~ /^x509$/))
43 { print "#ifndef NO_RSA\n${str}#endif\n"; }
44 elsif ( ($_ =~ /^dsa$/) || ($_ =~ /^gendsa$/) || ($_ =~ /^dsaparam$/))
45 { print "#ifndef NO_DSA\n${str}#endif\n"; }
46 elsif ( ($_ =~ /^dh$/) || ($_ =~ /^gendh$/))
47 { print "#ifndef NO_DH\n${str}#endif\n"; }
48 else
49 { print $str; }
50 }
51
52foreach ("md2","md5","sha","sha1","mdc2")
53 {
54 push(@files,$_);
55 printf "\t{FUNC_TYPE_MD,\"%s\",dgst_main},\n",$_;
56 }
57
58foreach (
59 "base64",
60 "des", "des3", "desx", "idea", "rc4", "rc2","bf","cast","rc5",
61 "des-ecb", "des-ede", "des-ede3",
62 "des-cbc", "des-ede-cbc","des-ede3-cbc",
63 "des-cfb", "des-ede-cfb","des-ede3-cfb",
64 "des-ofb", "des-ede-ofb","des-ede3-ofb",
65 "idea-cbc","idea-ecb", "idea-cfb", "idea-ofb",
66 "rc2-cbc", "rc2-ecb", "rc2-cfb", "rc2-ofb",
67 "bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb",
68 "cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
69 "cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb")
70 {
71 push(@files,$_);
72
73 $t=sprintf("\t{FUNC_TYPE_CIPHER,\"%s\",enc_main},\n",$_);
74 if ($_ =~ /des/) { $t="#ifndef NO_DES\n${t}#endif\n"; }
75 elsif ($_ =~ /idea/) { $t="#ifndef NO_IDEA\n${t}#endif\n"; }
76 elsif ($_ =~ /rc4/) { $t="#ifndef NO_RC4\n${t}#endif\n"; }
77 elsif ($_ =~ /rc2/) { $t="#ifndef NO_RC2\n${t}#endif\n"; }
78 elsif ($_ =~ /bf/) { $t="#ifndef NO_BLOWFISH\n${t}#endif\n"; }
79 elsif ($_ =~ /cast/) { $t="#ifndef NO_CAST\n${t}#endif\n"; }
80 elsif ($_ =~ /rc5/) { $t="#ifndef NO_RC5\n${t}#endif\n"; }
81 print $t;
82 }
83
84print "\t{0,NULL,NULL}\n\t};\n";
85print "#endif\n\n";
86
87open(OUT,">$mkprog") || die "unable to open '$prog':$!\n";
88print OUT "#!/bin/sh\nfor i in ";
89foreach (@files)
90 { print OUT $_." "; }
91print OUT <<'EOF';
92
93do
94echo making symlink for $i
95/bin/rm -f $i
96ln -s ssleay $i
97done
98EOF
99close(OUT);
100chmod(0755,$mkprog);
101
102open(OUT,">$rmprog") || die "unable to open '$prog':$!\n";
103print OUT "#!/bin/sh\nfor i in ";
104foreach (@files)
105 { print OUT $_." "; }
106print OUT <<'EOF';
107
108do
109echo removing $i
110/bin/rm -f $i
111done
112EOF
113close(OUT);
114chmod(0755,$rmprog);
diff --git a/src/lib/libssl/src/apps/mklinks b/src/lib/libssl/src/apps/mklinks
new file mode 100644
index 0000000000..55a56b399e
--- /dev/null
+++ b/src/lib/libssl/src/apps/mklinks
@@ -0,0 +1,7 @@
1#!/bin/sh
2for i in verify asn1parse req dgst dh enc gendh errstr ca crl rsa dsa dsaparam x509 genrsa s_server s_client speed s_time version pkcs7 crl2pkcs7 sess_id ciphers md2 md5 sha sha1 mdc2 base64 des des3 desx idea rc4 rc2 bf cast rc5 des-ecb des-ede des-ede3 des-cbc des-ede-cbc des-ede3-cbc des-cfb des-ede-cfb des-ede3-cfb des-ofb des-ede-ofb des-ede3-ofb idea-cbc idea-ecb idea-cfb idea-ofb rc2-cbc rc2-ecb rc2-cfb rc2-ofb bf-cbc bf-ecb bf-cfb bf-ofb cast5-cbc cast5-ecb cast5-cfb cast5-ofb cast-cbc rc5-cbc rc5-ecb rc5-cfb rc5-ofb
3do
4echo making symlink for $i
5/bin/rm -f $i
6ln -s ssleay $i
7done
diff --git a/src/lib/libssl/src/apps/pem_mail.c b/src/lib/libssl/src/apps/pem_mail.c
new file mode 100644
index 0000000000..64e04acb52
--- /dev/null
+++ b/src/lib/libssl/src/apps/pem_mail.c
@@ -0,0 +1,170 @@
1/* apps/pem_mail.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "rsa.h"
61#include "evp.h"
62#include "objects.h"
63#include "x509.h"
64#include "err.h"
65#include "pem.h"
66#include "apps.h"
67
68#undef PROG
69#define PROG pem_mail_main
70
71static char *usage[]={
72"usage: pem_mail args\n",
73"\n",
74" -in arg - input file - default stdin\n",
75" -out arg - output file - default stdout\n",
76" -cert arg - the certificate to use\n",
77" -key arg - the private key to use\n",
78" -MIC - sign the message\n",
79" -enc arg - encrypt with one of cbc-des\n",
80NULL
81};
82
83
84typedef struct lines_St
85 {
86 char *line;
87 struct lines_st *next;
88 } LINES;
89
90int main(argc, argv)
91int argc;
92char **argv;
93 {
94 FILE *in;
95 RSA *rsa=NULL;
96 EVP_MD_CTX ctx;
97 unsigned int mic=0,i,n;
98 unsigned char buf[1024*15];
99 char *prog,*infile=NULL,*outfile=NULL,*key=NULL;
100 int badops=0;
101
102 apps_startup();
103
104 prog=argv[0];
105 argc--;
106 argv++;
107 while (argc >= 1)
108 {
109 if (strcmp(*argv,"-key") == 0)
110 {
111 if (--argc < 1) goto bad;
112 key= *(++argv);
113 }
114 else if (strcmp(*argv,"-in") == 0)
115 {
116 if (--argc < 1) goto bad;
117 infile= *(++argv);
118 }
119 else if (strcmp(*argv,"-out") == 0)
120 {
121 if (--argc < 1) goto bad;
122 outfile= *(++argv);
123 }
124 else if (strcmp(*argv,"-mic") == 0)
125 mic=1;
126 else
127 {
128 BIO_printf(bio_err,"unknown option %s\n",*argv);
129 badops=1;
130 break;
131 }
132 argc--;
133 argv++;
134 }
135
136 if (badops)
137 {
138bad:
139 BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
140 BIO_printf(bio_err,"where options are\n");
141 EXIT(1);
142 }
143
144 if (key == NULL)
145 { BIO_printf(bio_err,"you need to specify a key\n"); EXIT(1); }
146 in=fopen(key,"r");
147 if (in == NULL) { perror(key); EXIT(1); }
148 rsa=PEM_read_RSAPrivateKey(in,NULL,NULL);
149 if (rsa == NULL)
150 {
151 BIO_printf(bio_err,"unable to load Private Key\n");
152 ERR_print_errors(bio_err);
153 EXIT(1);
154 }
155 fclose(in);
156
157 PEM_SignInit(&ctx,EVP_md5());
158 for (;;)
159 {
160 i=fread(buf,1,1024*10,stdin);
161 if (i <= 0) break;
162 PEM_SignUpdate(&ctx,buf,i);
163 }
164 if (!PEM_SignFinal(&ctx,buf,&n,rsa)) goto err;
165 BIO_printf(bio_err,"%s\n",buf);
166 EXIT(0);
167err:
168 ERR_print_errors(bio_err);
169 EXIT(1);
170 }
diff --git a/src/lib/libssl/src/apps/rmlinks b/src/lib/libssl/src/apps/rmlinks
new file mode 100644
index 0000000000..7c4f8983ba
--- /dev/null
+++ b/src/lib/libssl/src/apps/rmlinks
@@ -0,0 +1,6 @@
1#!/bin/sh
2for i in verify asn1parse req dgst dh enc gendh errstr ca crl rsa dsa dsaparam x509 genrsa s_server s_client speed s_time version pkcs7 crl2pkcs7 sess_id ciphers md2 md5 sha sha1 mdc2 base64 des des3 desx idea rc4 rc2 bf cast rc5 des-ecb des-ede des-ede3 des-cbc des-ede-cbc des-ede3-cbc des-cfb des-ede-cfb des-ede3-cfb des-ofb des-ede-ofb des-ede3-ofb idea-cbc idea-ecb idea-cfb idea-ofb rc2-cbc rc2-ecb rc2-cfb rc2-ofb bf-cbc bf-ecb bf-cfb bf-ofb cast5-cbc cast5-ecb cast5-cfb cast5-ofb cast-cbc rc5-cbc rc5-ecb rc5-cfb rc5-ofb
3do
4echo removing $i
5/bin/rm -f $i
6done
diff --git a/src/lib/libssl/src/apps/ssleay.c b/src/lib/libssl/src/apps/ssleay.c
new file mode 100644
index 0000000000..eac411b854
--- /dev/null
+++ b/src/lib/libssl/src/apps/ssleay.c
@@ -0,0 +1,342 @@
1/* apps/ssleay.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef DEBUG
60#undef DEBUG
61#endif
62
63#include <stdio.h>
64#include <string.h>
65#include <stdlib.h>
66#include "bio.h"
67#include "crypto.h"
68#include "lhash.h"
69#include "conf.h"
70#include "x509.h"
71#include "pem.h"
72#include "ssl.h"
73#define SSLEAY /* turn off a few special case MONOLITH macros */
74#define USE_SOCKETS /* needed for the _O_BINARY defs in the MS world */
75#define SSLEAY_SRC
76#include "apps.h"
77#include "s_apps.h"
78#include "err.h"
79
80/*
81#ifdef WINDOWS
82#include "bss_file.c"
83#endif
84*/
85
86#ifndef NOPROTO
87static unsigned long MS_CALLBACK hash(FUNCTION *a);
88static int MS_CALLBACK cmp(FUNCTION *a,FUNCTION *b);
89static LHASH *prog_init(void );
90static int do_cmd(LHASH *prog,int argc,char *argv[]);
91#else
92static unsigned long MS_CALLBACK hash();
93static int MS_CALLBACK cmp();
94static LHASH *prog_init();
95static int do_cmd();
96#endif
97
98LHASH *config=NULL;
99char *default_config_file=NULL;
100
101#ifdef DEBUG
102static void sig_stop(i)
103int i;
104 {
105 char *a=NULL;
106
107 *a='\0';
108 }
109#endif
110
111/* Make sure there is only one when MONOLITH is defined */
112#ifdef MONOLITH
113BIO *bio_err=NULL;
114#endif
115
116int main(Argc,Argv)
117int Argc;
118char *Argv[];
119 {
120 ARGS arg;
121#define PROG_NAME_SIZE 16
122 char pname[PROG_NAME_SIZE];
123 FUNCTION f,*fp;
124 MS_STATIC char *prompt,buf[1024],config_name[256];
125 int n,i,ret=0;
126 int argc;
127 char **argv,*p;
128 LHASH *prog=NULL;
129 long errline;
130
131 arg.data=NULL;
132 arg.count=0;
133
134 /* SSLeay_add_ssl_algorithms(); is called in apps_startup() */
135 apps_startup();
136
137#if defined(DEBUG) && !defined(WINDOWS) && !defined(MSDOS)
138#ifdef SIGBUS
139 signal(SIGBUS,sig_stop);
140#endif
141#ifdef SIGSEGV
142 signal(SIGSEGV,sig_stop);
143#endif
144#endif
145
146 if (bio_err == NULL)
147 if ((bio_err=BIO_new(BIO_s_file())) != NULL)
148 BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
149
150 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
151
152 ERR_load_crypto_strings();
153
154 /* Lets load up our environment a little */
155 p=getenv("SSLEAY_CONF");
156 if (p == NULL)
157 {
158 strcpy(config_name,X509_get_default_cert_area());
159 strcat(config_name,"/lib/");
160 strcat(config_name,SSLEAY_CONF);
161 p=config_name;
162 }
163
164 default_config_file=p;
165
166 config=CONF_load(config,p,&errline);
167 if (config == NULL) ERR_clear_error();
168
169 prog=prog_init();
170
171 /* first check the program name */
172 program_name(Argv[0],pname,PROG_NAME_SIZE);
173
174 f.name=pname;
175 fp=(FUNCTION *)lh_retrieve(prog,(char *)&f);
176 if (fp != NULL)
177 {
178 Argv[0]=pname;
179 ret=fp->func(Argc,Argv);
180 goto end;
181 }
182
183 /* ok, now check that there are not arguments, if there are,
184 * run with them, shifting the ssleay off the front */
185 if (Argc != 1)
186 {
187 Argc--;
188 Argv++;
189 ret=do_cmd(prog,Argc,Argv);
190 if (ret < 0) ret=0;
191 goto end;
192 }
193
194 /* ok, lets enter the old 'SSLeay>' mode */
195
196 for (;;)
197 {
198 ret=0;
199 p=buf;
200 n=1024;
201 i=0;
202 for (;;)
203 {
204 p[0]='\0';
205 if (i++)
206 prompt=">";
207 else prompt="SSLeay>";
208 fputs(prompt,stdout);
209 fflush(stdout);
210 fgets(p,n,stdin);
211 if (p[0] == '\0') goto end;
212 i=strlen(p);
213 if (i <= 1) break;
214 if (p[i-2] != '\\') break;
215 i-=2;
216 p+=i;
217 n-=i;
218 }
219 if (!chopup_args(&arg,buf,&argc,&argv)) break;
220
221 ret=do_cmd(prog,argc,argv);
222 if (ret < 0)
223 {
224 ret=0;
225 goto end;
226 }
227 if (ret != 0)
228 BIO_printf(bio_err,"error in %s\n",argv[0]);
229 BIO_flush(bio_err);
230 }
231 BIO_printf(bio_err,"bad exit\n");
232 ret=1;
233end:
234 if (config != NULL)
235 {
236 CONF_free(config);
237 config=NULL;
238 }
239 if (prog != NULL) lh_free(prog);
240 if (arg.data != NULL) Free(arg.data);
241 ERR_remove_state(0);
242
243 EVP_cleanup();
244
245 CRYPTO_mem_leaks(bio_err);
246 if (bio_err != NULL)
247 {
248 BIO_free(bio_err);
249 bio_err=NULL;
250 }
251 EXIT(ret);
252 }
253
254static int do_cmd(prog,argc,argv)
255LHASH *prog;
256int argc;
257char *argv[];
258 {
259 FUNCTION f,*fp;
260 int i,ret=1,tp,nl;
261
262 if ((argc <= 0) || (argv[0] == NULL))
263 { ret=0; goto end; }
264 f.name=argv[0];
265 fp=(FUNCTION *)lh_retrieve(prog,(char *)&f);
266 if (fp != NULL)
267 {
268 ret=fp->func(argc,argv);
269 }
270 else if ((strcmp(argv[0],"quit") == 0) ||
271 (strcmp(argv[0],"q") == 0) ||
272 (strcmp(argv[0],"exit") == 0) ||
273 (strcmp(argv[0],"bye") == 0))
274 {
275 ret= -1;
276 goto end;
277 }
278 else
279 {
280 BIO_printf(bio_err,"'%s' is a bad command, valid commands are",
281 argv[0]);
282 i=0;
283 fp=functions;
284 tp=0;
285 for (fp=functions; fp->name != NULL; fp++)
286 {
287 nl=0;
288 if (((i++) % 5) == 0)
289 {
290 BIO_printf(bio_err,"\n");
291 nl=1;
292 }
293 if (fp->type != tp)
294 {
295 tp=fp->type;
296 if (!nl) BIO_printf(bio_err,"\n");
297 if (tp == FUNC_TYPE_MD)
298 {
299 i=1;
300 BIO_printf(bio_err,
301 "Message Digest commands - see the dgst command for more details\n");
302 }
303 else if (tp == FUNC_TYPE_CIPHER)
304 {
305 i=1;
306 BIO_printf(bio_err,"Cipher commands - see the enc command for more details\n");
307 }
308 }
309 BIO_printf(bio_err,"%-15s",fp->name);
310 }
311 BIO_printf(bio_err,"\nquit\n");
312 ret=0;
313 }
314end:
315 return(ret);
316 }
317
318static LHASH *prog_init()
319 {
320 LHASH *ret;
321 FUNCTION *f;
322
323 if ((ret=lh_new(hash,cmp)) == NULL) return(NULL);
324
325 for (f=functions; f->name != NULL; f++)
326 lh_insert(ret,(char *)f);
327 return(ret);
328 }
329
330static int MS_CALLBACK cmp(a,b)
331FUNCTION *a,*b;
332 {
333 return(strncmp(a->name,b->name,8));
334 }
335
336static unsigned long MS_CALLBACK hash(a)
337FUNCTION *a;
338 {
339 return(lh_strhash(a->name));
340 }
341
342#undef SSLEAY
diff --git a/src/lib/libssl/src/apps/ssleay.cnf b/src/lib/libssl/src/apps/ssleay.cnf
new file mode 100644
index 0000000000..0b3bfa64f8
--- /dev/null
+++ b/src/lib/libssl/src/apps/ssleay.cnf
@@ -0,0 +1,116 @@
1#
2# SSLeay example configuration file.
3# This is mostly being used for generation of certificate requests.
4#
5
6RANDFILE = $ENV::HOME/.rnd
7
8####################################################################
9[ ca ]
10default_ca = CA_default # The default ca section
11
12####################################################################
13[ CA_default ]
14
15dir = ./demoCA # Where everything is kept
16certs = $dir/certs # Where the issued certs are kept
17crl_dir = $dir/crl # Where the issued crl are kept
18database = $dir/index.txt # database index file.
19new_certs_dir = $dir/newcerts # default place for new certs.
20
21certificate = $dir/cacert.pem # The CA certificate
22serial = $dir/serial # The current serial number
23crl = $dir/crl.pem # The current CRL
24private_key = $dir/private/cakey.pem# The private key
25RANDFILE = $dir/private/.rand # private random number file
26
27x509_extensions = x509v3_extensions # The extentions to add to the cert
28default_days = 365 # how long to certify for
29default_crl_days= 30 # how long before next CRL
30default_md = md5 # which md to use.
31preserve = no # keep passed DN ordering
32
33# A few difference way of specifying how similar the request should look
34# For type CA, the listed attributes must be the same, and the optional
35# and supplied fields are just that :-)
36policy = policy_match
37
38# For the CA policy
39[ policy_match ]
40countryName = match
41stateOrProvinceName = match
42organizationName = match
43organizationalUnitName = optional
44commonName = supplied
45emailAddress = optional
46
47# For the 'anything' policy
48# At this point in time, you must list all acceptable 'object'
49# types.
50[ policy_anything ]
51countryName = optional
52stateOrProvinceName = optional
53localityName = optional
54organizationName = optional
55organizationalUnitName = optional
56commonName = supplied
57emailAddress = optional
58
59####################################################################
60[ req ]
61default_bits = 1024
62default_keyfile = privkey.pem
63distinguished_name = req_distinguished_name
64attributes = req_attributes
65
66[ req_distinguished_name ]
67countryName = Country Name (2 letter code)
68countryName_default = AU
69countryName_min = 2
70countryName_max = 2
71
72stateOrProvinceName = State or Province Name (full name)
73stateOrProvinceName_default = Some-State
74
75localityName = Locality Name (eg, city)
76
770.organizationName = Organization Name (eg, company)
780.organizationName_default = Internet Widgits Pty Ltd
79
80# we can do this but it is not needed normally :-)
81#1.organizationName = Second Organization Name (eg, company)
82#1.organizationName_default = CryptSoft Pty Ltd
83
84organizationalUnitName = Organizational Unit Name (eg, section)
85#organizationalUnitName_default =
86
87commonName = Common Name (eg, YOUR name)
88commonName_max = 64
89
90emailAddress = Email Address
91emailAddress_max = 40
92
93[ req_attributes ]
94challengePassword = A challenge password
95challengePassword_min = 4
96challengePassword_max = 20
97
98unstructuredName = An optional company name
99
100[ x509v3_extensions ]
101
102nsCaRevocationUrl = http://www.cryptsoft.com/ca-crl.pem
103nsComment = "This is a comment"
104
105# under ASN.1, the 0 bit would be encoded as 80
106nsCertType = 0x40
107
108#nsBaseUrl
109#nsRevocationUrl
110#nsRenewalUrl
111#nsCaPolicyUrl
112#nsSslServerName
113#nsCertSequence
114#nsCertExt
115#nsDataType
116
diff --git a/src/lib/libssl/src/apps/tkca b/src/lib/libssl/src/apps/tkca
new file mode 100644
index 0000000000..bdaf21606a
--- /dev/null
+++ b/src/lib/libssl/src/apps/tkca
@@ -0,0 +1,66 @@
1#!/usr/local/bin/perl5
2#
3# This is only something I'm playing with, it does not work :-)
4#
5
6use Tk;
7
8my $main=MainWindow->new();
9my $f=$main->Frame(-relief => "ridge", -borderwidth => 2);
10$f->pack(-fill => 'x');
11
12my $ff=$f->Frame;
13$ff->pack(-fill => 'x');
14my $l=$ff->Label(-text => "TkCA - SSLeay",
15 -relief => "ridge", -borderwidth => 2);
16$l->pack(-fill => 'x', -ipady => 5);
17
18my $l=$ff->Button(-text => "Certify");
19$l->pack(-fill => 'x', -ipady => 5);
20
21my $l=$ff->Button(-text => "Review");
22$l->pack(-fill => 'x', -ipady => 5);
23
24my $l=$ff->Button(-text => "Revoke");
25$l->pack(-fill => 'x', -ipady => 5);
26
27my $l=$ff->Button(-text => "Generate CRL");
28$l->pack(-fill => 'x', -ipady => 5);
29
30my($db)=&load_db("demoCA/index.txt");
31
32MainLoop;
33
34sub load_db
35 {
36 my(%ret);
37 my($file)=@_;
38 my(*IN);
39 my(%db_serial,%db_name,@f,@db_s);
40
41 $ret{'serial'}=\%db_serial;
42 $ret{'name'}=\%db_name;
43
44 open(IN,"<$file") || die "unable to open $file:$!\n";
45 while (<IN>)
46 {
47 chop;
48 s/([^\\])\t/\1\t\t/g;
49 my(@f)=split(/\t\t/);
50 die "wrong number of fields in $file, line $.\n"
51 if ($#f != 5);
52
53 my(%f);
54 $f{'type'}=$f[0];
55 $f{'exp'}=$f[1];
56 $f{'rev'}=$f[2];
57 $f{'serial'}=$f[3];
58 $f{'file'}=$f[4];
59 $f{'name'}=$f[5];
60 die "serial number $f{'serial'} appears twice (line $.)\n"
61 if (defined($db{$f{'serial'}}))
62 $db_serial{$f{'serial'}}=\%f;
63 $db_name{$f{'name'}}.=$f{'serial'}." ";
64 }
65 return \%ret;
66 }
diff --git a/src/lib/libssl/src/certs/ICE-CA.pem b/src/lib/libssl/src/certs/ICE-CA.pem
new file mode 100644
index 0000000000..75652366c2
--- /dev/null
+++ b/src/lib/libssl/src/certs/ICE-CA.pem
@@ -0,0 +1,59 @@
1Certificate:
2 Data:
3 Version: 3 (0x2)
4 Serial Number: 1 (0x1)
5 Signature Algorithm: md5WithRSAEncryption
6 Issuer: O=European ICE-TEL project, OU=V3-Certification Authority
7 Validity
8 Not Before: Apr 2 17:35:53 1997 GMT
9 Not After : Apr 2 17:35:53 1998 GMT
10 Subject: O=European ICE-TEL project, OU=V3-Certification Authority, L=Darmstadt
11 Subject Public Key Info:
12 Public Key Algorithm: rsa
13 RSA Public Key: (512 bit)
14 Modulus (512 bit):
15 00:82:75:ba:f6:d1:60:b5:f9:15:b3:6a:dd:29:8f:
16 8b:a4:6f:1a:88:e0:50:43:40:0b:79:41:d5:d3:16:
17 44:7d:74:65:17:42:06:52:0b:e9:50:c8:10:cd:24:
18 e2:ae:8d:22:30:73:e6:b4:b7:93:1f:e5:6e:a2:ae:
19 49:11:a5:c9:45
20 Exponent: 65537 (0x10001)
21 X509v3 extensions:
22 X509v3 Authority Key Identifier:
23 0.........z.."p......e..
24 X509v3 Subject Key Identifier:
25 ..~r..:..B.44fu......3
26 X509v3 Key Usage: critical
27 ....
28 X509v3 Certificate Policies: critical
29 0.0...*...
30 X509v3 Subject Alternative Name:
31 0!..secude-support@darmstadt.gmd.de
32 X509v3 Issuer Alternative Name:
33 0I..ice-tel-ca@darmstadt.gmd.de.*http://www.darmstadt.gmd.de/ice-tel/euroca
34 X509v3 Basic Constraints: critical
35 0....
36 X509v3 CRL Distribution Points:
37 0200...,.*http://www.darmstadt.gmd.de/ice-tel/euroca
38 Signature Algorithm: md5WithRSAEncryption
39 17:a2:88:b7:99:5a:05:41:e4:13:34:67:e6:1f:3e:26:ec:4b:
40 69:f9:3e:28:22:be:9d:1c:ab:41:6f:0c:00:85:fe:45:74:f6:
41 98:f0:ce:9b:65:53:4a:50:42:c7:d4:92:bd:d7:a2:a8:3d:98:
42 88:73:cd:60:28:79:a3:fc:48:7a
43-----BEGIN CERTIFICATE-----
44MIICzDCCAnagAwIBAgIBATANBgkqhkiG9w0BAQQFADBIMSEwHwYDVQQKExhFdXJv
45cGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24g
46QXV0aG9yaXR5MB4XDTk3MDQwMjE3MzU1M1oXDTk4MDQwMjE3MzU1M1owXDEhMB8G
47A1UEChMYRXVyb3BlYW4gSUNFLVRFTCBwcm9qZWN0MSMwIQYDVQQLExpWMy1DZXJ0
48aWZpY2F0aW9uIEF1dGhvcml0eTESMBAGA1UEBxMJRGFybXN0YWR0MFkwCgYEVQgB
49AQICAgADSwAwSAJBAIJ1uvbRYLX5FbNq3SmPi6RvGojgUENAC3lB1dMWRH10ZRdC
50BlIL6VDIEM0k4q6NIjBz5rS3kx/lbqKuSRGlyUUCAwEAAaOCATgwggE0MB8GA1Ud
51IwQYMBaAFIr3yNUOx3ro1yJw4AuJ1bbsZbzPMB0GA1UdDgQWBBR+cvL4OoacQog0
52NGZ1w9T80aIRMzAOBgNVHQ8BAf8EBAMCAfYwFAYDVR0gAQH/BAowCDAGBgQqAwQF
53MCoGA1UdEQQjMCGBH3NlY3VkZS1zdXBwb3J0QGRhcm1zdGFkdC5nbWQuZGUwUgYD
54VR0SBEswSYEbaWNlLXRlbC1jYUBkYXJtc3RhZHQuZ21kLmRlhipodHRwOi8vd3d3
55LmRhcm1zdGFkdC5nbWQuZGUvaWNlLXRlbC9ldXJvY2EwDwYDVR0TAQH/BAUwAwEB
56/zA7BgNVHR8ENDAyMDCgLqAshipodHRwOi8vd3d3LmRhcm1zdGFkdC5nbWQuZGUv
57aWNlLXRlbC9ldXJvY2EwDQYJKoZIhvcNAQEEBQADQQAXooi3mVoFQeQTNGfmHz4m
587Etp+T4oIr6dHKtBbwwAhf5FdPaY8M6bZVNKUELH1JK916KoPZiIc81gKHmj/Eh6
59-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/certs/ICE-root.pem b/src/lib/libssl/src/certs/ICE-root.pem
new file mode 100644
index 0000000000..fa991599c9
--- /dev/null
+++ b/src/lib/libssl/src/certs/ICE-root.pem
@@ -0,0 +1,48 @@
1Certificate:
2 Data:
3 Version: 3 (0x2)
4 Serial Number: 0 (0x0)
5 Signature Algorithm: md5WithRSAEncryption
6 Issuer: O=European ICE-TEL project, OU=V3-Certification Authority
7 Validity
8 Not Before: Apr 2 17:33:36 1997 GMT
9 Not After : Apr 2 17:33:36 1998 GMT
10 Subject: O=European ICE-TEL project, OU=V3-Certification Authority
11 Subject Public Key Info:
12 Public Key Algorithm: rsa
13 RSA Public Key: (512 bit)
14 Modulus (512 bit):
15 00:80:3e:eb:ae:47:a9:fe:10:54:0b:81:8b:9c:2b:
16 82:ab:3a:61:36:65:8b:f3:73:9f:ac:ac:7a:15:a7:
17 13:8f:b4:c4:ba:a3:0f:bc:a5:58:8d:cc:b1:93:31:
18 9e:81:9e:8c:19:61:86:fa:52:73:54:d1:97:76:22:
19 e7:c7:9f:41:cd
20 Exponent: 65537 (0x10001)
21 X509v3 extensions:
22 X509v3 Subject Key Identifier:
23 ........z.."p......e..
24 X509v3 Key Usage: critical
25 ....
26 X509v3 Subject Alternative Name:
27 0I.*http://www.darmstadt.gmd.de/ice-tel/euroca..ice-tel-ca@darmstadt.gmd.de
28 X509v3 Basic Constraints: critical
29 0....
30 Signature Algorithm: md5WithRSAEncryption
31 76:69:61:db:b7:cf:8b:06:9e:d8:8c:96:53:d2:4d:a8:23:a6:
32 03:44:e8:8f:24:a5:c0:84:a8:4b:77:d4:2d:2b:7d:37:91:67:
33 f2:2c:ce:02:31:4c:6b:cc:ce:f2:68:a6:11:11:ab:7d:88:b8:
34 7e:22:9f:25:06:60:bd:79:30:3d
35-----BEGIN CERTIFICATE-----
36MIICFjCCAcCgAwIBAgIBADANBgkqhkiG9w0BAQQFADBIMSEwHwYDVQQKExhFdXJv
37cGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24g
38QXV0aG9yaXR5MB4XDTk3MDQwMjE3MzMzNloXDTk4MDQwMjE3MzMzNlowSDEhMB8G
39A1UEChMYRXVyb3BlYW4gSUNFLVRFTCBwcm9qZWN0MSMwIQYDVQQLExpWMy1DZXJ0
40aWZpY2F0aW9uIEF1dGhvcml0eTBZMAoGBFUIAQECAgIAA0sAMEgCQQCAPuuuR6n+
41EFQLgYucK4KrOmE2ZYvzc5+srHoVpxOPtMS6ow+8pViNzLGTMZ6BnowZYYb6UnNU
420Zd2IufHn0HNAgMBAAGjgZcwgZQwHQYDVR0OBBYEFIr3yNUOx3ro1yJw4AuJ1bbs
43ZbzPMA4GA1UdDwEB/wQEAwIB9jBSBgNVHREESzBJhipodHRwOi8vd3d3LmRhcm1z
44dGFkdC5nbWQuZGUvaWNlLXRlbC9ldXJvY2GBG2ljZS10ZWwtY2FAZGFybXN0YWR0
45LmdtZC5kZTAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBBAUAA0EAdmlh27fP
46iwae2IyWU9JNqCOmA0TojySlwISoS3fULSt9N5Fn8izOAjFMa8zO8mimERGrfYi4
47fiKfJQZgvXkwPQ==
48-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/certs/ICE-user.pem b/src/lib/libssl/src/certs/ICE-user.pem
new file mode 100644
index 0000000000..28065fd37d
--- /dev/null
+++ b/src/lib/libssl/src/certs/ICE-user.pem
@@ -0,0 +1,63 @@
1Certificate:
2 Data:
3 Version: 3 (0x2)
4 Serial Number: 1 (0x1)
5 Signature Algorithm: md5WithRSAEncryption
6 Issuer: O=European ICE-TEL project, OU=V3-Certification Authority, L=Darmstadt
7 Validity
8 Not Before: Apr 2 17:35:59 1997 GMT
9 Not After : Apr 2 17:35:59 1998 GMT
10 Subject: O=European ICE-TEL project, OU=V3-Certification Authority, L=Darmstadt, CN=USER
11 Subject Public Key Info:
12 Public Key Algorithm: rsa
13 RSA Public Key: (512 bit)
14 Modulus (512 bit):
15 00:a8:a8:53:63:49:1b:93:c3:c3:0b:6c:88:11:55:
16 de:7e:6a:e2:f9:52:a0:dc:69:25:c4:c8:bf:55:e1:
17 31:a8:ce:e4:a9:29:85:99:8a:15:9a:de:f6:2f:e1:
18 b4:50:5f:5e:04:75:a6:f4:76:dc:3c:0e:39:dc:3a:
19 be:3e:a4:61:8b
20 Exponent: 65537 (0x10001)
21 X509v3 extensions:
22 X509v3 Authority Key Identifier:
23 0...~r..:..B.44fu......3
24 X509v3 Subject Key Identifier:
25 ...... .*...1.*.......
26 X509v3 Key Usage: critical
27 ....
28 X509v3 Certificate Policies: critical
29 0.0...*...0.......
30 X509v3 Subject Alternative Name:
31 0:..user@darmstadt.gmd.de.!http://www.darmstadt.gmd.de/~user
32 X509v3 Issuer Alternative Name:
33 0....gmdca@gmd.de..http://www.gmd.de..saturn.darmstadt.gmd.de.\1!0...U.
34..European ICE-TEL project1#0!..U....V3-Certification Authority1.0...U....Darmstadt..141.12.62.26
35 X509v3 Basic Constraints: critical
36 0.
37 X509v3 CRL Distribution Points:
38 0.0.......gmdca@gmd.de
39 Signature Algorithm: md5WithRSAEncryption
40 69:0c:e1:b7:a7:f2:d8:fb:e8:69:c0:13:cd:37:ad:21:06:22:
41 4d:e8:c6:db:f1:04:0b:b7:e0:b3:d6:0c:81:03:ce:c3:6a:3e:
42 c7:e7:24:24:a4:92:64:c2:83:83:06:42:53:0e:6f:09:1e:84:
43 9a:f7:6f:63:9b:94:99:83:d6:a4
44-----BEGIN CERTIFICATE-----
45MIIDTzCCAvmgAwIBAgIBATANBgkqhkiG9w0BAQQFADBcMSEwHwYDVQQKExhFdXJv
46cGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24g
47QXV0aG9yaXR5MRIwEAYDVQQHEwlEYXJtc3RhZHQwHhcNOTcwNDAyMTczNTU5WhcN
48OTgwNDAyMTczNTU5WjBrMSEwHwYDVQQKExhFdXJvcGVhbiBJQ0UtVEVMIHByb2pl
49Y3QxIzAhBgNVBAsTGlYzLUNlcnRpZmljYXRpb24gQXV0aG9yaXR5MRIwEAYDVQQH
50EwlEYXJtc3RhZHQxDTALBgNVBAMTBFVTRVIwWTAKBgRVCAEBAgICAANLADBIAkEA
51qKhTY0kbk8PDC2yIEVXefmri+VKg3GklxMi/VeExqM7kqSmFmYoVmt72L+G0UF9e
52BHWm9HbcPA453Dq+PqRhiwIDAQABo4IBmDCCAZQwHwYDVR0jBBgwFoAUfnLy+DqG
53nEKINDRmdcPU/NGiETMwHQYDVR0OBBYEFJfc4B8gjSoRmLUx4Sq/ucIYiMrPMA4G
54A1UdDwEB/wQEAwIB8DAcBgNVHSABAf8EEjAQMAYGBCoDBAUwBgYECQgHBjBDBgNV
55HREEPDA6gRV1c2VyQGRhcm1zdGFkdC5nbWQuZGWGIWh0dHA6Ly93d3cuZGFybXN0
56YWR0LmdtZC5kZS9+dXNlcjCBsQYDVR0SBIGpMIGmgQxnbWRjYUBnbWQuZGWGEWh0
57dHA6Ly93d3cuZ21kLmRlghdzYXR1cm4uZGFybXN0YWR0LmdtZC5kZaRcMSEwHwYD
58VQQKExhFdXJvcGVhbiBJQ0UtVEVMIHByb2plY3QxIzAhBgNVBAsTGlYzLUNlcnRp
59ZmljYXRpb24gQXV0aG9yaXR5MRIwEAYDVQQHEwlEYXJtc3RhZHSHDDE0MS4xMi42
60Mi4yNjAMBgNVHRMBAf8EAjAAMB0GA1UdHwQWMBQwEqAQoA6BDGdtZGNhQGdtZC5k
61ZTANBgkqhkiG9w0BAQQFAANBAGkM4ben8tj76GnAE803rSEGIk3oxtvxBAu34LPW
62DIEDzsNqPsfnJCSkkmTCg4MGQlMObwkehJr3b2OblJmD1qQ=
63-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/certs/ICE.crl b/src/lib/libssl/src/certs/ICE.crl
new file mode 100644
index 0000000000..21939e8cc4
--- /dev/null
+++ b/src/lib/libssl/src/certs/ICE.crl
@@ -0,0 +1,9 @@
1-----BEGIN X509 CRL-----
2MIIBNDCBnjANBgkqhkiG9w0BAQIFADBFMSEwHwYDVQQKExhFdXJvcGVhbiBJQ0Ut
3VEVMIFByb2plY3QxIDAeBgNVBAsTF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5Fw05
4NzA2MDkxNDQyNDNaFw05NzA3MDkxNDQyNDNaMCgwEgIBChcNOTcwMzAzMTQ0MjU0
5WjASAgEJFw05NjEwMDIxMjI5MjdaMA0GCSqGSIb3DQEBAgUAA4GBAH4vgWo2Tej/
6i7kbiw4Imd30If91iosjClNpBFwvwUDBclPEeMuYimHbLOk4H8Nofc0fw11+U/IO
7KSNouUDcqG7B64oY7c4SXKn+i1MWOb5OJiWeodX3TehHjBlyWzoNMWCnYA8XqFP1
8mOKp8Jla1BibEZf14+/HqCi2hnZUiEXh
9-----END X509 CRL-----
diff --git a/src/lib/libssl/src/certs/ca-cert.pem b/src/lib/libssl/src/certs/ca-cert.pem
new file mode 100644
index 0000000000..6dd974d70d
--- /dev/null
+++ b/src/lib/libssl/src/certs/ca-cert.pem
@@ -0,0 +1,31 @@
1issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit)
2subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
3-----BEGIN CERTIFICATE-----
4MIICJjCCAY8CAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV
5BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD
6VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0M1oXDTAxMDYw
7OTEzNTc0M1owWzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxGjAY
8BgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYDVQQDExJUZXN0IENBICgxMDI0
9IGJpdCkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKO7o8t116VP6cgybTsZ
10DCZhr95nYlZuya3aCi1IKoztqwWnjbmDFIriOqGFPrZQ+moMETC9D59iRW/dFXSv
111F65ka/XY2hLh9exCCo7XuUcDs53Qp3bI3AmMqHjgzE8oO3ajyJAzJkTTOUecQU2
12mw/gI4tMM0LqWMQS7luTy4+xAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAM7achv3v
13hLQJcv/65eGEpBXM40ZDVoFQFFJWaY5p883HTqLB1x4FdzsXHH0QKBTcKpWwqyu4
14YDm3fb8oDugw72bCzfyZK/zVZPR/hVlqI/fvU109Qoc+7oPvIXWky71HfcK6ZBCA
15q30KIqGM/uoM60INq97qjDmCJapagcNBGQs=
16-----END CERTIFICATE-----
17-----BEGIN RSA PRIVATE KEY-----
18MIICXQIBAAKBgQCju6PLddelT+nIMm07GQwmYa/eZ2JWbsmt2gotSCqM7asFp425
19gxSK4jqhhT62UPpqDBEwvQ+fYkVv3RV0r9ReuZGv12NoS4fXsQgqO17lHA7Od0Kd
202yNwJjKh44MxPKDt2o8iQMyZE0zlHnEFNpsP4COLTDNC6ljEEu5bk8uPsQIDAQAB
21AoGAVZmpFZsDZfr0l2S9tLLwpjRWNOlKATQkno6q2WesT0eGLQufTciY+c8ypfU6
22hyio8r5iUl/VhhdjhAtKx1mRpiotftHo/eYf8rtsrnprOnWG0bWjLjtIoMbcxGn2
23J3bN6LJmbJMjDs0eJ3KnTu646F3nDUw2oGAwmpzKXA1KAP0CQQDRvQhxk2D3Pehs
24HvG665u2pB5ipYQngEFlZO7RHJZzJOZEWSLuuMqaF/7pTfA5jiBvWqCgJeCRRInL
2521ru4dlPAkEAx9jj7BgKn5TYnMoBSSe0afjsV9oApVpN1Nacb1YDtCwy+scp3++s
26nFxlv98wxIlSdpwMUn+AUWfjiWR7Tu/G/wJBAJ/KjwZIrFVxewP0x2ILYsTRYLzz
27MS4PDsO7FB+I0i7DbBOifXS2oNSpd3I0CNMwrxFnUHzynpbOStVfN3ZL5w0CQQCa
28pwFahxBRhkJKsxhjoFJBX9yl75JoY4Wvm5Tbo9ih6UJaRx3kqfkN14L2BKYcsZgb
29KY9vmDOYy6iNfjDeWTfJAkBkfPUb8oTJ/nSP5zN6sqGxSY4krc4xLxpRmxoJ8HL2
30XfhqXkTzbU13RX9JJ/NZ8vQN9Vm2NhxRGJocQkmcdVtJ
31-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libssl/src/certs/dsa-ca.pem b/src/lib/libssl/src/certs/dsa-ca.pem
new file mode 100644
index 0000000000..9eb08f3ddd
--- /dev/null
+++ b/src/lib/libssl/src/certs/dsa-ca.pem
@@ -0,0 +1,43 @@
1-----BEGIN DSA PRIVATE KEY-----
2Proc-Type: 4,ENCRYPTED
3DEK-Info: DES-EDE3-CBC,C5B6C7CC9E1FE2C0
4
5svCXBcBRhMuU22UXOfiKZA+thmz6KYXpt1Yg5Rd+TYQcQ1MdvNy0B0tkP1SxzDq0
6Xh1eMeTML9/9/0rKakgNXXXbpi5RB8t6BmwRSyej89F7nn1mtR3qzoyPRpp15SDl
7Tn67C+2v+HDF3MFk88hiNCYkNbcmi7TWvChsl8N1r7wdZwtIox56yXdgxw6ZIpa/
8par0oUCzN7fiavPgCWz1kfPNSaBQSdxwH7TZi5tMHAr0J3C7a7QRnZfE09R59Uqr
9zslrq+ndIw1BZAxoY0SlBu+iFOVaBVlwToC4AsHkv7j7l8ITtr7f42YbBa44D9TO
10uOhONmkk/v3Fso4RaOEzdKZC+hnmmzvHs6TiTWm6yzJgSFwyOUK0eGmKEeVxpcH5
11rUOlHOwzen+FFtocZDZAfdFnb7QY7L/boQvyA5A+ZbRG4DUpmBQeQsSaICHM5Rxx
121QaLF413VNPXTLPbW0ilSc2H8x2iZTIVKfd33oSO6NhXPtSYQgfecEF4BvNHY5c4
13HovjT4mckbK95bcBzoCHu43vuSQkmZzdYo/ydSZt6zoPavbBLueTpgSbdXiDi827
14MVqOsYxGCb+kez0FoDSTgw==
15-----END DSA PRIVATE KEY-----
16-----BEGIN CERTIFICATE REQUEST-----
17MIICUjCCAhECAQAwUjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
18ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDELMAkGA1UEAxMCQ0Ew
19ggG0MIIBKQYFKw4DAgwwggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaW
20sxXgUy6P4FmCc5A+dTGZR3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5m
21rmuINvvsKNzC16W75Sw5JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHk
22cJVbUM1JAhUA9wcx7fpsBgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVo
23bzDjaeHls12YuyiGSPzemQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqR
24CZ228U2cVA9YBu5JdAfOVX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxB
25F5WS6wG1c6Vqftgy7Q4CuAOBhAACgYAapll6iqz9XrZFlk2GCVcB+KihxWnH7IuH
26vSLw9YUrJahcBHmbpvt494lF4gC5w3WPM+vXJofbusk4GoQEEsQNMDaah4m49uUq
27AylOVFJJJXuirVJ+o+0TtOFDITEAl+YZZariXOD7tdOSOl9RLMPC6+daHKS9e68u
283enxhqnDGaAAMAkGBSsOAwIbBQADMAAwLQIVAJGVuFsG/0DBuSZ0jF7ypdU0/G0v
29AhQfeF5BoMMDbX/kidUVpQ6gadPlZA==
30-----END CERTIFICATE REQUEST-----
31-----BEGIN CERTIFICATE-----
32MIIBrjCCAWwCAQswCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
33U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww
34CgYDVQQDEwNQQ0EwHhcNOTcwNjE1MDIxNDI5WhcNOTcwNzE1MDIxNDI5WjBSMQsw
35CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
36ZXQgV2lkZ2l0cyBQdHkgTHRkMQswCQYDVQQDEwJDQTCBkjAJBgUrDgMCDAUAA4GE
37AAKBgBqmWXqKrP1etkWWTYYJVwH4qKHFacfsi4e9IvD1hSslqFwEeZum+3j3iUXi
38ALnDdY8z69cmh9u6yTgahAQSxA0wNpqHibj25SoDKU5UUkkle6KtUn6j7RO04UMh
39MQCX5hllquJc4Pu105I6X1Esw8Lr51ocpL17ry7d6fGGqcMZMAkGBSsOAwIbBQAD
40MQAwLgIVAJ4wtQsANPxHo7Q4IQZYsL12SKdbAhUAjJ9n38zxT+iai2164xS+LIfa
41C1Q=
42-----END CERTIFICATE-----
43
diff --git a/src/lib/libssl/src/certs/dsa-pca.pem b/src/lib/libssl/src/certs/dsa-pca.pem
new file mode 100644
index 0000000000..e3641ad47e
--- /dev/null
+++ b/src/lib/libssl/src/certs/dsa-pca.pem
@@ -0,0 +1,49 @@
1-----BEGIN DSA PRIVATE KEY-----
2Proc-Type: 4,ENCRYPTED
3DEK-Info: DES-EDE3-CBC,F80EEEBEEA7386C4
4
5GZ9zgFcHOlnhPoiSbVi/yXc9mGoj44A6IveD4UlpSEUt6Xbse3Fr0KHIUyQ3oGnS
6mClKoAp/eOTb5Frhto85SzdsxYtac+X1v5XwdzAMy2KowHVk1N8A5jmE2OlkNPNt
7of132MNlo2cyIRYaa35PPYBGNCmUm7YcYS8O90YtkrQZZTf4+2C4kllhMcdkQwkr
8FWSWC8YOQ7w0LHb4cX1FejHHom9Nd/0PN3vn3UyySvfOqoR7nbXkrpHXmPIr0hxX
9RcF0aXcV/CzZ1/nfXWQf4o3+oD0T22SDoVcZY60IzI0oIc3pNCbDV3uKNmgekrFd
10qOUJ+QW8oWp7oefRx62iBfIeC8DZunohMXaWAQCU0sLQOR4yEdeUCnzCSywe0bG1
11diD0KYaEe+Yub1BQH4aLsBgDjardgpJRTQLq0DUvw0/QGO1irKTJzegEDNVBKrVn
12V4AHOKT1CUKqvGNRP1UnccUDTF6miOAtaj/qpzra7sSk7dkGBvIEeFoAg84kfh9h
13hVvF1YyzC9bwZepruoqoUwke/WdNIR5ymOVZ/4Liw0JdIOcq+atbdRX08niqIRkf
14dsZrUj4leo3zdefYUQ7w4N2Ns37yDFq7
15-----END DSA PRIVATE KEY-----
16-----BEGIN CERTIFICATE REQUEST-----
17MIICVTCCAhMCAQAwUzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
18ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEMMAoGA1UEAxMDUENB
19MIIBtTCCASkGBSsOAwIMMIIBHgKBgQCnP26Fv0FqKX3wn0cZMJCaCR3aajMexT2G
20lrMV4FMuj+BZgnOQPnUxmUd6UvuF5NmmezibaIqEm4fGHrV+hktTW1nPcWUZiG7O
21Zq5riDb77Cjcwtelu+UsOSZL2ppwGJU3lRBWI/YV7boEXt45T/23Qx+1pGVvzYAR
225HCVW1DNSQIVAPcHMe36bAYD1YWKHKycZedQZmVvAoGATd9MA6aRivUZb1BGJZnl
23aG8w42nh5bNdmLsohkj83pkEP1+IDJxzJA0gXbkqmj8YlifkYofBe3RiU/xhJ6h6
24kQmdtvFNnFQPWAbuSXQHzlV+I84W9srcWmEBfslxtU323DQph2j2XiCTs9v15Als
25QReVkusBtXOlan7YMu0OArgDgYUAAoGBAKbtuR5AdW+ICjCFe2ixjUiJJzM2IKwe
266NZEMXg39+HQ1UTPTmfLZLps+rZfolHDXuRKMXbGFdSF0nXYzotPCzi7GauwEJTZ
27yr27ZZjA1C6apGSQ9GzuwNvZ4rCXystVEagAS8OQ4H3D4dWS17Zg31ICb5o4E5r0
28z09o/Uz46u0VoAAwCQYFKw4DAhsFAAMxADAuAhUArRubTxsbIXy3AhtjQ943AbNB
29nSICFQCu+g1iW3jwF+gOcbroD4S/ZcvB3w==
30-----END CERTIFICATE REQUEST-----
31-----BEGIN CERTIFICATE-----
32MIIC0zCCApECAQAwCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
33U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww
34CgYDVQQDEwNQQ0EwHhcNOTcwNjE0MjI1NDQ1WhcNOTcwNzE0MjI1NDQ1WjBTMQsw
35CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
36ZXQgV2lkZ2l0cyBQdHkgTHRkMQwwCgYDVQQDEwNQQ0EwggG1MIIBKQYFKw4DAgww
37ggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaWsxXgUy6P4FmCc5A+dTGZ
38R3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5mrmuINvvsKNzC16W75Sw5
39JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHkcJVbUM1JAhUA9wcx7fps
40BgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVobzDjaeHls12YuyiGSPze
41mQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqRCZ228U2cVA9YBu5JdAfO
42VX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxBF5WS6wG1c6Vqftgy7Q4C
43uAOBhQACgYEApu25HkB1b4gKMIV7aLGNSIknMzYgrB7o1kQxeDf34dDVRM9OZ8tk
44umz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQlNnKvbtlmMDULpqkZJD0bO7A
4529nisJfKy1URqABLw5DgfcPh1ZLXtmDfUgJvmjgTmvTPT2j9TPjq7RUwCQYFKw4D
46AhsFAAMxADAuAhUAvtv6AkMolix1Jvy3UnVEIUqdCUICFQC+jq8P49mwrY9oJ24n
475rKUjNBhSg==
48-----END CERTIFICATE-----
49
diff --git a/src/lib/libssl/src/certs/factory.pem b/src/lib/libssl/src/certs/factory.pem
new file mode 100644
index 0000000000..8e28b391b2
--- /dev/null
+++ b/src/lib/libssl/src/certs/factory.pem
@@ -0,0 +1,15 @@
1-----BEGIN CERTIFICATE-----
2MIICTTCCAbagAwIBAgIBADANBgkqhkiG9w0BAQQFADBMMQswCQYDVQQGEwJHQjEM
3MAoGA1UEChMDVUNMMRgwFgYDVQQLEw9JQ0UtVEVMIFByb2plY3QxFTATBgNVBAMT
4DFRydXN0RmFjdG9yeTAeFw05NzA0MjIxNDM5MTRaFw05ODA0MjIxNDM5MTRaMEwx
5CzAJBgNVBAYTAkdCMQwwCgYDVQQKEwNVQ0wxGDAWBgNVBAsTD0lDRS1URUwgUHJv
6amVjdDEVMBMGA1UEAxMMVHJ1c3RGYWN0b3J5MIGcMAoGBFUIAQECAgQAA4GNADCB
7iQKBgQCEieR8NcXkUW1f0G6aC6u0i8q/98JqS6RxK5YmHIGKCkuTWAUjzLfUa4dt
8U9igGCjTuxaDqlzEim+t/02pmiBZT9HaX++35MjQPUWmsChcYU5WyzGErXi+rQaw
9zlwS73zM8qiPj/97lXYycWhgL0VaiDSPxRXEUdWoaGruom4mNQIDAQABo0IwQDAd
10BgNVHQ4EFgQUHal1LZr7oVg5z6lYzrhTgZRCmcUwDgYDVR0PAQH/BAQDAgH2MA8G
11A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAfaggfl6FZoioecjv0dq8
12/DXo/u11iMZvXn08gjX/zl2b4wtPbShOSY5FhkSm8GeySasz+/Nwb/uzfnIhokWi
13lfPZHtlCWtXbIy/TN51eJyq04ceDCQDWvLC2enVg9KB+GJ34b5c5VaPRzq8MBxsA
14S7ELuYGtmYgYm9NZOIr7yU0=
15-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/certs/nortelCA.pem b/src/lib/libssl/src/certs/nortelCA.pem
new file mode 100644
index 0000000000..207f34ab3a
--- /dev/null
+++ b/src/lib/libssl/src/certs/nortelCA.pem
@@ -0,0 +1,16 @@
1-----BEGIN CERTIFICATE-----
2MIICajCCAdMCBDGA0QUwDQYJKoZIhvcNAQEEBQAwfTELMAkGA1UEBhMCQ2ExDzAN
3BgNVBAcTBk5lcGVhbjEeMBwGA1UECxMVTm8gTGlhYmlsaXR5IEFjY2VwdGVkMR8w
4HQYDVQQKExZGb3IgRGVtbyBQdXJwb3NlcyBPbmx5MRwwGgYDVQQDExNFbnRydXN0
5IERlbW8gV2ViIENBMB4XDTk2MDQyNjEzMzUwMVoXDTA2MDQyNjEzMzUwMVowfTEL
6MAkGA1UEBhMCQ2ExDzANBgNVBAcTBk5lcGVhbjEeMBwGA1UECxMVTm8gTGlhYmls
7aXR5IEFjY2VwdGVkMR8wHQYDVQQKExZGb3IgRGVtbyBQdXJwb3NlcyBPbmx5MRww
8GgYDVQQDExNFbnRydXN0IERlbW8gV2ViIENBMIGdMA0GCSqGSIb3DQEBAQUAA4GL
9ADCBhwKBgQCaroS7O1DA0hm4IefNYU1cx/nqOmzEnk291d1XqznDeF4wEgakbkCc
10zTKxK791yNpXG5RmngqH7cygDRTHZJ6mfCRn0wGC+AI00F2vYTGqPGRQL1N3lZT0
11YDKFC0SQeMMjFIZ1aeQigroFQnHo0VB3zWIMpNkka8PY9lxHZAmWwQIBAzANBgkq
12hkiG9w0BAQQFAAOBgQBAx0UMVA1s54lMQyXjMX5kj99FJN5itb8bK1Rk+cegPQPF
13cWO9SEWyEjjBjIkjjzAwBkaEszFsNGxemxtXvwjIm1xEUMTVlPEWTs2qnDvAUA9W
14YqhWbhH0toGT36236QAsqCZ76rbTRVSSX2BHyJwJMG2tCRv7kRJ//NIgxj3H4w==
15-----END CERTIFICATE-----
16
diff --git a/src/lib/libssl/src/certs/pca-cert.pem b/src/lib/libssl/src/certs/pca-cert.pem
new file mode 100644
index 0000000000..140e9a6b43
--- /dev/null
+++ b/src/lib/libssl/src/certs/pca-cert.pem
@@ -0,0 +1,31 @@
1issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit)
2subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit)
3-----BEGIN CERTIFICATE-----
4MIICJzCCAZACAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV
5BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD
6VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTczN1oXDTAxMDYw
7OTEzNTczN1owXDELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxGjAY
8BgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYDVQQDExNUZXN0IFBDQSAoMTAy
9NCBiaXQpMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCdoWk/3+WcMlfjIrkg
1040ketmnQaEogQe1LLcuOJV6rKfUSAsPgwgsabJ/wn8TxA1yy3eKJbFl3OiUXMRsp
1122Jp85PmemiDzyUIStwk72qhp1imbANZvlmlCFKiQrjUyuDfu4TABmn+kkt3vR1Y
12BEOGt+IFye1UBVSATVdRJ2UVhwIDAQABMA0GCSqGSIb3DQEBBAUAA4GBABNA1u/S
13Cg/LJZWb7GliiKJsvuhxlE4E5JxQF2zMub/CSNbF97//tYSyj96sxeFQxZXbcjm9
14xt6mr/xNLA4szNQMJ4P+L7b5e/jC5DSqlwS+CUYJgaFs/SP+qJoCSu1bR3IM9XWO
15cRBpDmcBbYLkSyB92WURvsZ1LtjEcn+cdQVI
16-----END CERTIFICATE-----
17-----BEGIN RSA PRIVATE KEY-----
18MIICXAIBAAKBgQCdoWk/3+WcMlfjIrkg40ketmnQaEogQe1LLcuOJV6rKfUSAsPg
19wgsabJ/wn8TxA1yy3eKJbFl3OiUXMRsp22Jp85PmemiDzyUIStwk72qhp1imbANZ
20vlmlCFKiQrjUyuDfu4TABmn+kkt3vR1YBEOGt+IFye1UBVSATVdRJ2UVhwIDAQAB
21AoGAba4fTtuap5l7/8ZsbE7Z1O32KJY4ZcOZukLOLUUhXxXduT+FTgGWujc0/rgc
22z9qYCLlNZHOouMYTgtSfYvuMuLZ11VIt0GYH+nRioLShE59Yy+zCRyC+gPigS1kz
23xvo14AsOIPYV14Tk/SsHyq6E0eTk7VzaIE197giiINUERPECQQDSKmtPTh/lRKw7
24HSZSM0I1mFWn/1zqrAbontRQY5w98QWIOe5qmzYyFbPXYT3d9BzlsMyhgiRNoBbD
25yvohSHXJAkEAwAHx6ezAZeWWzD5yXD36nyjpkVCw7Tk7TSmOceLJMWt1QcrCfqlS
26xA5jjpQ6Z8suU5DdtWAryM2sAir1WisYzwJAd6Zcx56jvAQ3xcPXsE6scBTVFzrj
277FqZ6E+cclPzfLQ+QQsyOBE7bpI6e/FJppY26XGZXo3YGzV8IGXrt40oOQJALETG
28h86EFXo3qGOFbmsDy4pdP5nBERCu8X1xUCSfintiD4c2DInxgS5oGclnJeMcjTvL
29QjQoJCX3UJCi/OUO1QJBAKgcDHWjMvt+l1pjJBsSEZ0HX9AAIIVx0RQmbFGS+F2Q
30hhu5l77WnnZOQ9vvhV5u7NPCUF9nhU3jh60qWWO8mkc=
31-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libssl/src/certs/rsa-cca.pem b/src/lib/libssl/src/certs/rsa-cca.pem
new file mode 100644
index 0000000000..69f5c1c84c
--- /dev/null
+++ b/src/lib/libssl/src/certs/rsa-cca.pem
@@ -0,0 +1,19 @@
1subject=/C=US/O=RSA Data Security, Inc./OU=Commercial Certification Authority
2issuer= /C=US/O=RSA Data Security, Inc./OU=Commercial Certification Authority
3notBefore=941104185834Z
4notAfter =991103185834Z
5-----BEGIN X509 CERTIFICATE-----
6
7MIICIzCCAZACBQJBAAAWMA0GCSqGSIb3DQEBAgUAMFwxCzAJBgNVBAYTAlVTMSAw
8HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjErMCkGA1UECxMiQ29tbWVy
9Y2lhbCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NDExMDQxODU4MzRaFw05
10OTExMDMxODU4MzRaMFwxCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0YSBT
11ZWN1cml0eSwgSW5jLjErMCkGA1UECxMiQ29tbWVyY2lhbCBDZXJ0aWZpY2F0aW9u
12IEF1dGhvcml0eTCBmzANBgkqhkiG9w0BAQEFAAOBiQAwgYUCfgCk+4Fie84QJ93o
13975sbsZwmdu41QUDaSiCnHJ/lj+O7Kwpkj+KFPhCdr69XQO5kNTQvAayUTNfxMK/
14touPmbZiImDd298ggrTKoi8tUO2UMt7gVY3UaOLgTNLNBRYulWZcYVI4HlGogqHE
157yXpCuaLK44xZtn42f29O2nZ6wIDAQABMA0GCSqGSIb3DQEBAgUAA34AdrW2EP4j
169/dZYkuwX5zBaLxJu7NJbyFHXSudVMQAKD+YufKKg5tgf+tQx6sFEC097TgCwaVI
170v5loMC86qYjFmZsGySp8+x5NRhPJsjjr1BKx6cxa9B8GJ1Qv6km+iYrRpwUqbtb
18MJhCKLVLU7tDCZJAuqiqWqTGtotXTcU=
19-----END X509 CERTIFICATE-----
diff --git a/src/lib/libssl/src/certs/rsa-ssca.pem b/src/lib/libssl/src/certs/rsa-ssca.pem
new file mode 100644
index 0000000000..c9403212d1
--- /dev/null
+++ b/src/lib/libssl/src/certs/rsa-ssca.pem
@@ -0,0 +1,19 @@
1subject=/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority
2issuer= /C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority
3notBefore=941109235417Z
4notAfter =991231235417Z
5-----BEGIN X509 CERTIFICATE-----
6
7MIICKTCCAZYCBQJBAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw
8HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl
9IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NDExMDkyMzU0MTda
10Fw05OTEyMzEyMzU0MTdaMF8xCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0
11YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJlIFNlcnZlciBDZXJ0aWZp
12Y2F0aW9uIEF1dGhvcml0eTCBmzANBgkqhkiG9w0BAQEFAAOBiQAwgYUCfgCSznrB
13roM+WqqJg1esJQF2DK2ujiw3zus1eGRUA+WEQFHJv48I4oqCCNIWhjdV6bEhAq12
14aIGaBaJLyUslZiJWbIgHj/eBWW2EB2VwE3F2Ppt3TONQiVaYSLkdpykaEy5KEVmc
15HhXVSVQsczppgrGXOZxtcGdI5d0t1sgeewIDAQABMA0GCSqGSIb3DQEBAgUAA34A
16iNHReSHO4ovo+MF9NFM/YYPZtgs4F7boviGNjwC4i1N+RGceIr2XJ+CchcxK9oU7
17suK+ktPlDemvXA4MRpX/oRxePug2WHpzpgr4IhFrwwk4fia7c+8AvQKk8xQNMD9h
18cHsg/jKjn7P0Z1LctO6EjJY2IN6BCINxIYoPnqk=
19-----END X509 CERTIFICATE-----
diff --git a/src/lib/libssl/src/certs/timCA.pem b/src/lib/libssl/src/certs/timCA.pem
new file mode 100644
index 0000000000..9c8d5bf9c6
--- /dev/null
+++ b/src/lib/libssl/src/certs/timCA.pem
@@ -0,0 +1,16 @@
1Tims test GCI CA
2
3-----BEGIN CERTIFICATE-----
4MIIB8DCCAZoCAQAwDQYJKoZIhvcNAQEEBQAwgYIxCzAJBgNVBAYTAkFVMRMwEQYD
5VQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5
6cHRTb2Z0IFB0eSBMdGQxFDASBgNVBAsTC2RldmVsb3BtZW50MRkwFwYDVQQDExBD
7cnlwdFNvZnQgRGV2IENBMB4XDTk3MDMyMjEzMzQwNFoXDTk4MDMyMjEzMzQwNFow
8gYIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhC
9cmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxFDASBgNVBAsTC2Rl
10dmVsb3BtZW50MRkwFwYDVQQDExBDcnlwdFNvZnQgRGV2IENBMFwwDQYJKoZIhvcN
11AQEBBQADSwAwSAJBAOAOAqogG5QwAmLhzyO4CoRnx/wVy4NZP4dxJy83O1EnL0rw
12OdsamJKvPOLHgSXo3gDu9uVyvCf/QJmZAmC5ml8CAwEAATANBgkqhkiG9w0BAQQF
13AANBADRRS/GVdd7rAqRW6SdmgLJduOU2yq3avBu99kRqbp9A/dLu6r6jU+eP4oOA
14TfdbFZtAAD2Hx9jUtY3tfdrJOb8=
15-----END CERTIFICATE-----
16
diff --git a/src/lib/libssl/src/certs/tjhCA.pem b/src/lib/libssl/src/certs/tjhCA.pem
new file mode 100644
index 0000000000..67bee1b200
--- /dev/null
+++ b/src/lib/libssl/src/certs/tjhCA.pem
@@ -0,0 +1,15 @@
1-----BEGIN CERTIFICATE-----
2MIICVjCCAgACAQAwDQYJKoZIhvcNAQEEBQAwgbUxCzAJBgNVBAYTAkFVMRMwEQYD
3VQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5
4cHRTb2Z0IFB0eSBMdGQxLDAqBgNVBAsTI1dPUlRITEVTUyBDRVJUSUZJQ0FUSU9O
5IEFVVEhPUklUSUVTMTQwMgYDVQQDEytaRVJPIFZBTFVFIENBIC0gREVNT05TVFJB
6VElPTiBQVVJQT1NFUyBPTkxZMB4XDTk3MDQwMzEzMjI1NFoXDTk4MDQwMzEzMjI1
7NFowgbUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQH
8EwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxLDAqBgNVBAsT
9I1dPUlRITEVTUyBDRVJUSUZJQ0FUSU9OIEFVVEhPUklUSUVTMTQwMgYDVQQDEyta
10RVJPIFZBTFVFIENBIC0gREVNT05TVFJBVElPTiBQVVJQT1NFUyBPTkxZMFwwDQYJ
11KoZIhvcNAQEBBQADSwAwSAJBAOZ7T7yqP/tyspcko3yPY1y0Cm2EmwNvzW4QgVXR
12Fjs3HmJ4xtSpXdo6mwcGezL3Abt/aQXaxv9PU8xt+Jr0OFUCAwEAATANBgkqhkiG
139w0BAQQFAANBAOQpYmGgyCqCy1OljgJhCqQOu627oVlHzK1L+t9vBaMfn40AVUR4
14WzQVWO31KTgi5vTK1U+3h46fgUWqQ0h+6rU=
15-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/certs/vsign2.pem b/src/lib/libssl/src/certs/vsign2.pem
new file mode 100644
index 0000000000..2386e149d0
--- /dev/null
+++ b/src/lib/libssl/src/certs/vsign2.pem
@@ -0,0 +1,31 @@
1 subject=/L=Internet/O=VeriSign, Inc./OU=VeriSign Class 2 CA - Individual Subscriber
2 issuer= /L=Internet/O=VeriSign, Inc./OU=VeriSign Class 2 CA - Individual Subscriber
3
4-----BEGIN CERTIFICATE-----
5MIIEkzCCA/ygAwIBAgIRANDTUpSRL3nTFeMrMayFSPAwDQYJKoZIhvcNAQECBQAw
6YjERMA8GA1UEBxMISW50ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQw
7MgYDVQQLEytWZXJpU2lnbiBDbGFzcyAyIENBIC0gSW5kaXZpZHVhbCBTdWJzY3Jp
8YmVyMB4XDTk2MDYwNDAwMDAwMFoXDTk4MDYwNDIzNTk1OVowYjERMA8GA1UEBxMI
9SW50ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQLEytWZXJp
10U2lnbiBDbGFzcyAyIENBIC0gSW5kaXZpZHVhbCBTdWJzY3JpYmVyMIGfMA0GCSqG
11SIb3DQEBAQUAA4GNADCBiQKBgQC6A+2czKGRcYMfm8gdnk+0de99TDDzsqo0v5nb
12RsbUmMcdRQ7nsMbRWe0SAb/9QoLTZ/cJ0iOBqdrkz7UpqqKarVoTSdlSMVM92tWp
133bJncZHQD1t4xd6lQVdI1/T6R+5J0T1ukOdsI9Jmf+F28S6g3R3L1SFwiHKeZKZv
14z+793wIDAQABo4ICRzCCAkMwggIpBgNVHQMBAf8EggIdMIICGTCCAhUwggIRBgtg
15hkgBhvhFAQcBATCCAgAWggGrVGhpcyBjZXJ0aWZpY2F0ZSBpbmNvcnBvcmF0ZXMg
16YnkgcmVmZXJlbmNlLCBhbmQgaXRzIHVzZSBpcyBzdHJpY3RseSBzdWJqZWN0IHRv
17LCB0aGUgVmVyaVNpZ24gQ2VydGlmaWNhdGlvbiBQcmFjdGljZSBTdGF0ZW1lbnQg
18KENQUyksIGF2YWlsYWJsZSBhdDogaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL0NQ
19Uy0xLjA7IGJ5IEUtbWFpbCBhdCBDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29tOyBv
20ciBieSBtYWlsIGF0IFZlcmlTaWduLCBJbmMuLCAyNTkzIENvYXN0IEF2ZS4sIE1v
21dW50YWluIFZpZXcsIENBIDk0MDQzIFVTQSBUZWwuICsxICg0MTUpIDk2MS04ODMw
22IENvcHlyaWdodCAoYykgMTk5NiBWZXJpU2lnbiwgSW5jLiAgQWxsIFJpZ2h0cyBS
23ZXNlcnZlZC4gQ0VSVEFJTiBXQVJSQU5USUVTIERJU0NMQUlNRUQgYW5kIExJQUJJ
24TElUWSBMSU1JVEVELqAOBgxghkgBhvhFAQcBAQGhDgYMYIZIAYb4RQEHAQECMC8w
25LRYraHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvQ1BTLTEuMDAU
26BglghkgBhvhCAQEBAf8EBAMCAgQwDQYJKoZIhvcNAQECBQADgYEApRJRkNBqLLgs
2753IR/d18ODdLOWMTZ+QOOxBrq460iBEdUwgF8vmPRX1ku7UiDeNzaLlurE6eFqHq
282zPyK5j60zfTLVJMWKcQWwTJLjHtXrW8pxhNtFc6Fdvy5ZkHnC/9NIl7/t4U6WqB
29p4y+p7SdMIkEwIZfds0VbnQyX5MRUJY=
30-----END CERTIFICATE-----
31
diff --git a/src/lib/libssl/src/certs/vsign4.pem b/src/lib/libssl/src/certs/vsign4.pem
new file mode 100644
index 0000000000..b5bcef4d0d
--- /dev/null
+++ b/src/lib/libssl/src/certs/vsign4.pem
@@ -0,0 +1,16 @@
1 subject=/C=US/O=VeriSign, Inc./OU=Class 4 Public Primary Certification Authority
2 issuer= /C=US/O=VeriSign, Inc./OU=Class 4 Public Primary Certification Authority
3-----BEGIN CERTIFICATE-----
4MIICMTCCAZoCBQKmAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMRcw
5FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgNCBQdWJsaWMg
6UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NjAxMjkwMDAwMDBa
7Fw05OTEyMzEyMzU5NTlaMF8xCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2ln
8biwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgNCBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZp
9Y2F0aW9uIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0LJ1
109njQrlpQ9OlQqZ+M1++RlHDo0iSQdomF1t+s5gEXMoDwnZNHvJplnR+Xrr/phnVj
11IIm9gFidBAydqMEk6QvlMXi9/C0MN2qeeIDpRnX57aP7E3vIwUzSo+/1PLBij0pd
12O92VZ48TucE81qcmm+zDO3rZTbxtm+gVAePwR6kCAwEAATANBgkqhkiG9w0BAQIF
13AAOBgQBT3dPwnCR+QKri/AAa19oM/DJhuBUNlvP6Vxt/M3yv6ZiaYch6s7f/sdyZ
14g9ysEvxwyR84Qu1E9oAuW2szaayc01znX1oYx7EteQSWQZGZQbE8DbqEOcY7l/Am
15yY7uvcxClf8exwI/VAx49byqYHwCaejcrOICdmHEPgPq0ook0Q==
16-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/crypto/Makefile.ssl b/src/lib/libssl/src/crypto/Makefile.ssl
new file mode 100644
index 0000000000..efdbba38ac
--- /dev/null
+++ b/src/lib/libssl/src/crypto/Makefile.ssl
@@ -0,0 +1,161 @@
1#
2# SSLeay/crypto/Makefile
3#
4
5DIR= crypto
6TOP= ..
7CC= cc
8INCLUDE= -I. -I../include
9INCLUDES= -I.. -I../../include
10CFLAG= -g
11INSTALLTOP= /usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15RM= /bin/rm -f
16AR= ar r
17
18MAKE= make -f Makefile.ssl
19MAKEDEPEND= makedepend -f Makefile.ssl
20MAKEFILE= Makefile.ssl
21
22PEX_LIBS=
23EX_LIBS=
24
25CFLAGS= $(INCLUDE) $(CFLAG) -DCFLAGS=" \"$(CC) $(CFLAG)\" "
26
27ERR=crypto
28ERRC=cpt_err
29
30LIBS=
31
32SDIRS= md2 md5 sha mdc2 hmac ripemd \
33 des rc2 rc4 rc5 idea bf cast \
34 bn rsa dsa dh \
35 buffer bio stack lhash rand err objects \
36 evp pem x509 \
37 asn1 conf txt_db pkcs7
38
39GENERAL=Makefile README
40
41LIB= $(TOP)/libcrypto.a
42LIBSRC= cryptlib.c mem.c cversion.c ex_data.c $(ERRC).c
43LIBOBJ= cryptlib.o mem.o cversion.o ex_data.o $(ERRC).o
44
45SRC= $(LIBSRC)
46
47EXHEADER= crypto.h cryptall.h
48HEADER= cryptlib.h date.h $(EXHEADER)
49
50ALL= $(GENERAL) $(SRC) $(HEADER)
51
52top:
53 @(cd ..; $(MAKE) DIRS=$(DIR) all)
54
55all: date.h lib subdirs
56
57date.h: ../Makefile.ssl ../VERSION
58 echo "#define DATE \"`date`\"" >date.h
59
60subdirs:
61 @for i in $(SDIRS) ;\
62 do \
63 (cd $$i; echo "making all in $$i..."; \
64 $(MAKE) CC='$(CC)' INCLUDES='${INCLUDES}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' BN_MULW='${BN_MULW}' DES_ENC='${DES_ENC}' SHA1_ASM_OBJ='${SHA1_ASM_OBJ}' MD5_ASM_OBJ='${MD5_ASM_OBJ}' RMD160_ASM_OBJ='${RMD160_ASM_OBJ}' BF_ENC='${BF_ENC}' CAST_ENC='${CAST_ENC}' RC4_ENC='${RC4_ENC}' RC5_ENC='${RC5_ENC}' AR='${AR}' all ); \
65 done;
66
67files:
68 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
69 @for i in $(SDIRS) ;\
70 do \
71 (cd $$i; echo "making 'files' in $$i..."; \
72 $(MAKE) files ); \
73 done;
74
75links:
76 /bin/rm -f Makefile
77 $(TOP)/util/point.sh Makefile.ssl Makefile ;
78 $(TOP)/util/mklink.sh ../include $(HEADER) ;
79 $(TOP)/util/mklink.sh ../test $(TEST) ;
80 $(TOP)/util/mklink.sh ../apps $(APPS) ;
81 $(TOP)/util/point.sh Makefile.ssl Makefile;
82 @for i in $(SDIRS) ;\
83 do \
84 (cd $$i; echo "making links in $$i..."; \
85 $(MAKE) links ); \
86 done;
87
88lib: $(LIBOBJ)
89 $(AR) $(LIB) $(LIBOBJ)
90 sh $(TOP)/util/ranlib.sh $(LIB)
91 @touch lib
92
93libs:
94 @for i in $(SDIRS) ;\
95 do \
96 (cd $$i; echo "making libs in $$i..."; \
97 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' lib ); \
98 done;
99
100tests:
101 @for i in $(SDIRS) ;\
102 do \
103 (cd $$i; echo "making tests in $$i..."; \
104 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' AR='${AR}' tests ); \
105 done;
106
107install:
108 @for i in $(EXHEADER) ;\
109 do \
110 (cp $$i $(INSTALLTOP)/include/$$i; \
111 chmod 644 $(INSTALLTOP)/include/$$i ); \
112 done;
113 @for i in $(SDIRS) ;\
114 do \
115 (cd $$i; echo "making install in $$i..."; \
116 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' install ); \
117 done;
118
119lint:
120 @for i in $(SDIRS) ;\
121 do \
122 (cd $$i; echo "making lint in $$i..."; \
123 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' lint ); \
124 done;
125
126depend:
127 $(MAKEDEPEND) $(INCLUDE) $(PROGS) $(LIBSRC)
128 @for i in $(SDIRS) ;\
129 do \
130 (cd $$i; echo "making depend in $$i..."; \
131 $(MAKE) MAKEFILE='${MAKEFILE}' INCLUDES='${INCLUDES}' MAKEDEPEND='${MAKEDEPEND}' depend ); \
132 done;
133
134clean:
135 /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
136 @for i in $(SDIRS) ;\
137 do \
138 (cd $$i; echo "making clean in $$i..."; \
139 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' clean ); \
140 done;
141
142dclean:
143 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
144 mv -f Makefile.new $(MAKEFILE)
145 @for i in $(SDIRS) ;\
146 do \
147 (cd $$i; echo "making dclean in $$i..."; \
148 $(MAKE) CC='$(CC)' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' dclean ); \
149 done;
150
151errors:
152 perl ./err/err_code.pl -conf err/ssleay.ec *.c */*.c ../ssl/*.c ../rsaref/*.c
153 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
154 perl err/err_genc.pl -s $(ERR).h $(ERRC).c
155 @for i in $(SDIRS) ;\
156 do \
157 (cd $$i; echo "making errors in $$i..."; \
158 $(MAKE) errors ); \
159 done;
160
161# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/asn1/Makefile.ssl b/src/lib/libssl/src/crypto/asn1/Makefile.ssl
new file mode 100644
index 0000000000..30751bd156
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/Makefile.ssl
@@ -0,0 +1,120 @@
1#
2# SSLeay/crypto/asn1/Makefile
3#
4
5DIR= asn1
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=asn1
19ERRC=asn1_err
20GENERAL=Makefile README
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= a_object.c a_bitstr.c a_utctm.c a_int.c a_octet.c a_print.c \
26 a_type.c a_set.c a_dup.c a_d2i_fp.c a_i2d_fp.c \
27 a_sign.c a_digest.c a_verify.c \
28 x_algor.c x_val.c x_pubkey.c x_sig.c x_req.c x_attrib.c \
29 x_name.c x_cinf.c x_x509.c x_crl.c x_info.c x_spki.c \
30 d2i_r_pr.c i2d_r_pr.c d2i_r_pu.c i2d_r_pu.c \
31 d2i_s_pr.c i2d_s_pr.c d2i_s_pu.c i2d_s_pu.c \
32 d2i_pu.c d2i_pr.c i2d_pu.c i2d_pr.c\
33 t_req.c t_x509.c t_pkey.c \
34 p7_i_s.c p7_signi.c p7_signd.c p7_recip.c p7_enc_c.c p7_evp.c \
35 p7_dgst.c p7_s_e.c p7_enc.c p7_lib.c \
36 f_int.c f_string.c i2d_dhp.c i2d_dsap.c d2i_dhp.c d2i_dsap.c n_pkey.c \
37 a_hdr.c x_pkey.c a_bool.c x_exten.c \
38 asn1_par.c asn1_lib.c $(ERRC).c a_meth.c a_bytes.c \
39 evp_asn1.c
40LIBOBJ= a_object.o a_bitstr.o a_utctm.o a_int.o a_octet.o a_print.o \
41 a_type.o a_set.o a_dup.o a_d2i_fp.o a_i2d_fp.o \
42 a_sign.o a_digest.o a_verify.o \
43 x_algor.o x_val.o x_pubkey.o x_sig.o x_req.o x_attrib.o \
44 x_name.o x_cinf.o x_x509.o x_crl.o x_info.o x_spki.o \
45 d2i_r_pr.o i2d_r_pr.o d2i_r_pu.o i2d_r_pu.o \
46 d2i_s_pr.o i2d_s_pr.o d2i_s_pu.o i2d_s_pu.o \
47 d2i_pu.o d2i_pr.o i2d_pu.o i2d_pr.o \
48 t_req.o t_x509.o t_pkey.o \
49 p7_i_s.o p7_signi.o p7_signd.o p7_recip.o p7_enc_c.o p7_evp.o \
50 p7_dgst.o p7_s_e.o p7_enc.o p7_lib.o \
51 f_int.o f_string.o i2d_dhp.o i2d_dsap.o d2i_dhp.o d2i_dsap.o n_pkey.o \
52 a_hdr.o x_pkey.o a_bool.o x_exten.o \
53 asn1_par.o asn1_lib.o $(ERRC).o a_meth.o a_bytes.o \
54 evp_asn1.o
55
56SRC= $(LIBSRC)
57
58EXHEADER= asn1.h asn1_mac.h
59HEADER= $(EXHEADER)
60
61ALL= $(GENERAL) $(SRC) $(HEADER)
62
63top:
64 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
65
66test: test.c
67 cc -g -I../../include -c test.c
68 cc -g -I../../include -o test test.o -L../.. -lcrypto
69
70pk: pk.c
71 cc -g -I../../include -c pk.c
72 cc -g -I../../include -o pk pk.o -L../.. -lcrypto
73
74all: lib
75
76lib: $(LIBOBJ)
77 $(AR) $(LIB) $(LIBOBJ)
78 sh $(TOP)/util/ranlib.sh $(LIB)
79 @touch lib
80
81files:
82 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
83
84links:
85 /bin/rm -f Makefile
86 $(TOP)/util/point.sh Makefile.ssl Makefile ;
87 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
88 $(TOP)/util/mklink.sh ../../test $(TEST)
89 $(TOP)/util/mklink.sh ../../apps $(APPS)
90
91install:
92 @for i in $(EXHEADER) ; \
93 do \
94 (cp $$i $(INSTALLTOP)/include/$$i; \
95 chmod 644 $(INSTALLTOP)/include/$$i ); \
96 done;
97
98tags:
99 ctags $(SRC)
100
101tests:
102
103lint:
104 lint -DLINT $(INCLUDES) $(SRC)>fluff
105
106depend:
107 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
108
109dclean:
110 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
111 mv -f Makefile.new $(MAKEFILE)
112
113clean:
114 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
115
116errors:
117 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
118 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
119
120# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/asn1/a_bmp.c b/src/lib/libssl/src/crypto/asn1/a_bmp.c
new file mode 100644
index 0000000000..774502b1fc
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/a_bmp.c
@@ -0,0 +1,90 @@
1/* crypto/asn1/a_bmp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1.h"
62
63/* ASN1err(ASN1_F_D2I_ASN1_INTEGER,ASN1_R_EXPECTING_AN_INTEGER);
64 */
65
66int i2d_ASN1_BMPSTRING(a, pp)
67ASN1_BMPSTRING *a;
68unsigned char **pp;
69 {
70 return(i2d_ASN1_bytes((ASN1_STRING *)a,pp,
71 V_ASN1_BMPSTRING,V_ASN1_UNIVERSAL));
72 }
73
74ASN1_BMPSTRING *d2i_ASN1_BMPSTRING(a, pp, length)
75ASN1_BMPSTRING **a;
76unsigned char **pp;
77long length;
78 {
79 ASN1_BMPSTRING *ret=NULL;
80
81 ret=(ASN1_BMPSTRING *)d2i_ASN1_bytes((ASN1_STRING **)a,
82 pp,length,V_ASN1_BMPSTRING,V_ASN1_UNIVERSAL);
83 if (ret == NULL)
84 {
85 ASN1err(ASN1_F_D2I_ASN1_BMPSTRING,ASN1_R_ERROR_STACK);
86 return(NULL);
87 }
88 return(ret);
89 }
90
diff --git a/src/lib/libssl/src/crypto/asn1/asn1.err b/src/lib/libssl/src/crypto/asn1/asn1.err
new file mode 100644
index 0000000000..c8b7011488
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/asn1.err
@@ -0,0 +1,182 @@
1/* Error codes for the ASN1 functions. */
2
3/* Function codes. */
4#define ASN1_F_A2D_ASN1_OBJECT 100
5#define ASN1_F_A2I_ASN1_INTEGER 101
6#define ASN1_F_A2I_ASN1_STRING 102
7#define ASN1_F_ASN1_COLLATE_PRIMATIVE 103
8#define ASN1_F_ASN1_D2I_BIO 104
9#define ASN1_F_ASN1_D2I_FP 105
10#define ASN1_F_ASN1_DUP 106
11#define ASN1_F_ASN1_GET_OBJECT 107
12#define ASN1_F_ASN1_HEADER_NEW 108
13#define ASN1_F_ASN1_I2D_BIO 109
14#define ASN1_F_ASN1_I2D_FP 110
15#define ASN1_F_ASN1_INTEGER_SET 111
16#define ASN1_F_ASN1_INTEGER_TO_BN 112
17#define ASN1_F_ASN1_OBJECT_NEW 113
18#define ASN1_F_ASN1_SIGN 114
19#define ASN1_F_ASN1_STRING_NEW 115
20#define ASN1_F_ASN1_STRING_TYPE_NEW 116
21#define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 117
22#define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 118
23#define ASN1_F_ASN1_TYPE_NEW 119
24#define ASN1_F_ASN1_UTCTIME_NEW 120
25#define ASN1_F_ASN1_VERIFY 121
26#define ASN1_F_BN_TO_ASN1_INTEGER 122
27#define ASN1_F_D2I_ASN1_BIT_STRING 123
28#define ASN1_F_D2I_ASN1_BMPSTRING 124
29#define ASN1_F_D2I_ASN1_BOOLEAN 125
30#define ASN1_F_D2I_ASN1_BYTES 126
31#define ASN1_F_D2I_ASN1_HEADER 127
32#define ASN1_F_D2I_ASN1_INTEGER 128
33#define ASN1_F_D2I_ASN1_OBJECT 129
34#define ASN1_F_D2I_ASN1_OCTET_STRING 130
35#define ASN1_F_D2I_ASN1_PRINT_TYPE 131
36#define ASN1_F_D2I_ASN1_SET 132
37#define ASN1_F_D2I_ASN1_TYPE 133
38#define ASN1_F_D2I_ASN1_TYPE_BYTES 134
39#define ASN1_F_D2I_ASN1_UTCTIME 135
40#define ASN1_F_D2I_DHPARAMS 136
41#define ASN1_F_D2I_DSAPARAMS 137
42#define ASN1_F_D2I_DSAPRIVATEKEY 138
43#define ASN1_F_D2I_DSAPUBLICKEY 139
44#define ASN1_F_D2I_NETSCAPE_PKEY 140
45#define ASN1_F_D2I_NETSCAPE_RSA 141
46#define ASN1_F_D2I_NETSCAPE_RSA_2 142
47#define ASN1_F_D2I_NETSCAPE_SPKAC 143
48#define ASN1_F_D2I_NETSCAPE_SPKI 144
49#define ASN1_F_D2I_PKCS7 145
50#define ASN1_F_D2I_PKCS7_DIGEST 146
51#define ASN1_F_D2I_PKCS7_ENCRYPT 147
52#define ASN1_F_D2I_PKCS7_ENC_CONTENT 148
53#define ASN1_F_D2I_PKCS7_ENVELOPE 149
54#define ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL 150
55#define ASN1_F_D2I_PKCS7_RECIP_INFO 151
56#define ASN1_F_D2I_PKCS7_SIGNED 152
57#define ASN1_F_D2I_PKCS7_SIGNER_INFO 153
58#define ASN1_F_D2I_PKCS7_SIGN_ENVELOPE 154
59#define ASN1_F_D2I_PRIVATEKEY 155
60#define ASN1_F_D2I_PUBLICKEY 156
61#define ASN1_F_D2I_RSAPRIVATEKEY 157
62#define ASN1_F_D2I_RSAPUBLICKEY 158
63#define ASN1_F_D2I_X509 159
64#define ASN1_F_D2I_X509_ALGOR 160
65#define ASN1_F_D2I_X509_ATTRIBUTE 161
66#define ASN1_F_D2I_X509_CINF 162
67#define ASN1_F_D2I_X509_CRL 163
68#define ASN1_F_D2I_X509_CRL_INFO 164
69#define ASN1_F_D2I_X509_EXTENSION 165
70#define ASN1_F_D2I_X509_KEY 166
71#define ASN1_F_D2I_X509_NAME 167
72#define ASN1_F_D2I_X509_NAME_ENTRY 168
73#define ASN1_F_D2I_X509_PKEY 169
74#define ASN1_F_D2I_X509_PUBKEY 170
75#define ASN1_F_D2I_X509_REQ 171
76#define ASN1_F_D2I_X509_REQ_INFO 172
77#define ASN1_F_D2I_X509_REVOKED 173
78#define ASN1_F_D2I_X509_SIG 174
79#define ASN1_F_D2I_X509_VAL 175
80#define ASN1_F_I2D_ASN1_HEADER 176
81#define ASN1_F_I2D_DHPARAMS 177
82#define ASN1_F_I2D_DSAPARAMS 178
83#define ASN1_F_I2D_DSAPRIVATEKEY 179
84#define ASN1_F_I2D_DSAPUBLICKEY 180
85#define ASN1_F_I2D_NETSCAPE_RSA 181
86#define ASN1_F_I2D_PKCS7 182
87#define ASN1_F_I2D_PRIVATEKEY 183
88#define ASN1_F_I2D_PUBLICKEY 184
89#define ASN1_F_I2D_RSAPRIVATEKEY 185
90#define ASN1_F_I2D_RSAPUBLICKEY 186
91#define ASN1_F_I2D_X509_ATTRIBUTE 187
92#define ASN1_F_I2T_ASN1_OBJECT 188
93#define ASN1_F_NETSCAPE_PKEY_NEW 189
94#define ASN1_F_NETSCAPE_SPKAC_NEW 190
95#define ASN1_F_NETSCAPE_SPKI_NEW 191
96#define ASN1_F_PKCS7_DIGEST_NEW 192
97#define ASN1_F_PKCS7_ENCRYPT_NEW 193
98#define ASN1_F_PKCS7_ENC_CONTENT_NEW 194
99#define ASN1_F_PKCS7_ENVELOPE_NEW 195
100#define ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW 196
101#define ASN1_F_PKCS7_NEW 197
102#define ASN1_F_PKCS7_RECIP_INFO_NEW 198
103#define ASN1_F_PKCS7_SIGNED_NEW 199
104#define ASN1_F_PKCS7_SIGNER_INFO_NEW 200
105#define ASN1_F_PKCS7_SIGN_ENVELOPE_NEW 201
106#define ASN1_F_X509_ALGOR_NEW 202
107#define ASN1_F_X509_ATTRIBUTE_NEW 203
108#define ASN1_F_X509_CINF_NEW 204
109#define ASN1_F_X509_CRL_INFO_NEW 205
110#define ASN1_F_X509_CRL_NEW 206
111#define ASN1_F_X509_DHPARAMS_NEW 207
112#define ASN1_F_X509_EXTENSION_NEW 208
113#define ASN1_F_X509_INFO_NEW 209
114#define ASN1_F_X509_KEY_NEW 210
115#define ASN1_F_X509_NAME_ENTRY_NEW 211
116#define ASN1_F_X509_NAME_NEW 212
117#define ASN1_F_X509_NEW 213
118#define ASN1_F_X509_PKEY_NEW 214
119#define ASN1_F_X509_PUBKEY_NEW 215
120#define ASN1_F_X509_REQ_INFO_NEW 216
121#define ASN1_F_X509_REQ_NEW 217
122#define ASN1_F_X509_REVOKED_NEW 218
123#define ASN1_F_X509_SIG_NEW 219
124#define ASN1_F_X509_VAL_FREE 220
125#define ASN1_F_X509_VAL_NEW 221
126
127/* Reason codes. */
128#define ASN1_R_BAD_CLASS 100
129#define ASN1_R_BAD_GET_OBJECT 101
130#define ASN1_R_BAD_OBJECT_HEADER 102
131#define ASN1_R_BAD_PASSWORD_READ 103
132#define ASN1_R_BAD_PKCS7_CONTENT 104
133#define ASN1_R_BAD_PKCS7_TYPE 105
134#define ASN1_R_BAD_TAG 106
135#define ASN1_R_BAD_TYPE 107
136#define ASN1_R_BN_LIB 108
137#define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 109
138#define ASN1_R_BUFFER_TOO_SMALL 110
139#define ASN1_R_DATA_IS_WRONG 111
140#define ASN1_R_DECODING_ERROR 112
141#define ASN1_R_ERROR_STACK 113
142#define ASN1_R_EXPECTING_AN_INTEGER 114
143#define ASN1_R_EXPECTING_AN_OBJECT 115
144#define ASN1_R_EXPECTING_AN_OCTET_STRING 116
145#define ASN1_R_EXPECTING_A_BIT_STRING 117
146#define ASN1_R_EXPECTING_A_BOOLEAN 118
147#define ASN1_R_EXPECTING_A_SEQUENCE 119
148#define ASN1_R_EXPECTING_A_UTCTIME 120
149#define ASN1_R_FIRST_NUM_TOO_LARGE 121
150#define ASN1_R_HEADER_TOO_LONG 122
151#define ASN1_R_INVALID_DIGIT 123
152#define ASN1_R_INVALID_SEPARATOR 124
153#define ASN1_R_INVALID_TIME_FORMAT 125
154#define ASN1_R_IV_TOO_LARGE 126
155#define ASN1_R_LENGTH_ERROR 127
156#define ASN1_R_LENGTH_MISMATCH 128
157#define ASN1_R_MISSING_EOS 129
158#define ASN1_R_MISSING_SECOND_NUMBER 130
159#define ASN1_R_NON_HEX_CHARACTERS 131
160#define ASN1_R_NOT_ENOUGH_DATA 132
161#define ASN1_R_ODD_NUMBER_OF_CHARS 133
162#define ASN1_R_PARSING 134
163#define ASN1_R_PRIVATE_KEY_HEADER_MISSING 135
164#define ASN1_R_SECOND_NUMBER_TOO_LARGE 136
165#define ASN1_R_SHORT_LINE 137
166#define ASN1_R_STRING_TOO_SHORT 138
167#define ASN1_R_TAG_VALUE_TOO_HIGH 139
168#define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 140
169#define ASN1_R_TOO_LONG 141
170#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 142
171#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 143
172#define ASN1_R_UNKNOWN_ATTRIBUTE_TYPE 144
173#define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 145
174#define ASN1_R_UNKNOWN_OBJECT_TYPE 146
175#define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 147
176#define ASN1_R_UNSUPPORTED_CIPHER 148
177#define ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM 149
178#define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 150
179#define ASN1_R_UTCTIME_TOO_LONG 151
180#define ASN1_R_WRONG_PRINTABLE_TYPE 152
181#define ASN1_R_WRONG_TAG 153
182#define ASN1_R_WRONG_TYPE 154
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_dhp.c b/src/lib/libssl/src/crypto/asn1/d2i_dhp.c
new file mode 100644
index 0000000000..616a308100
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/d2i_dhp.c
@@ -0,0 +1,108 @@
1/* crypto/asn1/d2i_dhp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "dh.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_DHPARAMS,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_DHPARAMS,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 */
70
71DH *d2i_DHparams(a,pp,length)
72DH **a;
73unsigned char **pp;
74long length;
75 {
76 int i=ASN1_R_ERROR_STACK;
77 ASN1_INTEGER *bs=NULL;
78 long v=0;
79 M_ASN1_D2I_vars(a,DH *,DH_new);
80
81 M_ASN1_D2I_Init();
82 M_ASN1_D2I_start_sequence();
83 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
84 if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;
85 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
86 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;
87
88 if (!M_ASN1_D2I_end_sequence())
89 {
90 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
91 for (i=0; i<bs->length; i++)
92 v=(v<<8)|(bs->data[i]);
93 ret->length=(int)v;
94 }
95
96 ASN1_BIT_STRING_free(bs);
97
98 M_ASN1_D2I_Finish_2(a);
99
100err_bn:
101 i=ERR_R_BN_LIB;
102err:
103 ASN1err(ASN1_F_D2I_DHPARAMS,i);
104 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DH_free(ret);
105 if (bs != NULL) ASN1_BIT_STRING_free(bs);
106 return(NULL);
107 }
108
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_dsap.c b/src/lib/libssl/src/crypto/asn1/d2i_dsap.c
new file mode 100644
index 0000000000..2c8ac7bbcf
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/d2i_dsap.c
@@ -0,0 +1,101 @@
1/* crypto/asn1/d2i_dsap.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "dsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_DSAPARAMS,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_DSAPARAMS,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 */
70
71DSA *d2i_DSAparams(a,pp,length)
72DSA **a;
73unsigned char **pp;
74long length;
75 {
76 int i=ASN1_R_ERROR_STACK;
77 ASN1_INTEGER *bs=NULL;
78 M_ASN1_D2I_vars(a,DSA *,DSA_new);
79
80 M_ASN1_D2I_Init();
81 M_ASN1_D2I_start_sequence();
82 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
83 if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;
84 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
85 if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn;
86 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
87 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;
88
89 ASN1_BIT_STRING_free(bs);
90
91 M_ASN1_D2I_Finish_2(a);
92
93err_bn:
94 i=ERR_R_BN_LIB;
95err:
96 ASN1err(ASN1_F_D2I_DSAPARAMS,i);
97 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
98 if (bs != NULL) ASN1_BIT_STRING_free(bs);
99 return(NULL);
100 }
101
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_r_pr.c b/src/lib/libssl/src/crypto/asn1/d2i_r_pr.c
new file mode 100644
index 0000000000..0c53aa94bf
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/d2i_r_pr.c
@@ -0,0 +1,129 @@
1/* crypto/asn1/d2i_r_pr.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "rsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_PARSING);
70 */
71
72static ASN1_METHOD method={
73 (int (*)()) i2d_RSAPrivateKey,
74 (char *(*)())d2i_RSAPrivateKey,
75 (char *(*)())RSA_new,
76 (void (*)()) RSA_free};
77
78ASN1_METHOD *RSAPrivateKey_asn1_meth()
79 {
80 return(&method);
81 }
82
83RSA *d2i_RSAPrivateKey(a,pp,length)
84RSA **a;
85unsigned char **pp;
86long length;
87 {
88 int i=ASN1_R_PARSING;
89 ASN1_INTEGER *bs=NULL;
90 M_ASN1_D2I_vars(a,RSA *,RSA_new);
91
92 M_ASN1_D2I_Init();
93 M_ASN1_D2I_start_sequence();
94 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
95 if (bs->length == 0)
96 ret->version=0;
97 else ret->version=bs->data[0];
98 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
99 if ((ret->n=BN_bin2bn(bs->data,bs->length,ret->n)) == NULL) goto err_bn;
100 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
101 if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn;
102 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
103 if ((ret->d=BN_bin2bn(bs->data,bs->length,ret->d)) == NULL) goto err_bn;
104 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
105 if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;
106 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
107 if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn;
108 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
109 if ((ret->dmp1=BN_bin2bn(bs->data,bs->length,ret->dmp1)) == NULL)
110 goto err_bn;
111 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
112 if ((ret->dmq1=BN_bin2bn(bs->data,bs->length,ret->dmq1)) == NULL)
113 goto err_bn;
114 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
115 if ((ret->iqmp=BN_bin2bn(bs->data,bs->length,ret->iqmp)) == NULL)
116 goto err_bn;
117
118 ASN1_INTEGER_free(bs);
119
120 M_ASN1_D2I_Finish_2(a);
121err_bn:
122 i=ERR_R_BN_LIB;
123err:
124 ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,i);
125 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
126 if (bs != NULL) ASN1_INTEGER_free(bs);
127 return(NULL);
128 }
129
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_r_pu.c b/src/lib/libssl/src/crypto/asn1/d2i_r_pu.c
new file mode 100644
index 0000000000..778b792b1e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/d2i_r_pu.c
@@ -0,0 +1,100 @@
1/* crypto/asn1/d2i_r_pu.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "rsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 */
70
71RSA *d2i_RSAPublicKey(a,pp,length)
72RSA **a;
73unsigned char **pp;
74long length;
75 {
76 int i=ASN1_R_PARSING;
77 ASN1_INTEGER *bs=NULL;
78 M_ASN1_D2I_vars(a,RSA *,RSA_new);
79
80 M_ASN1_D2I_Init();
81 M_ASN1_D2I_start_sequence();
82 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
83 if ((ret->n=BN_bin2bn(bs->data,bs->length,ret->n)) == NULL) goto err_bn;
84 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
85 if ((ret->e=BN_bin2bn(bs->data,bs->length,ret->e)) == NULL) goto err_bn;
86
87 ASN1_INTEGER_free(bs);
88 bs=NULL;
89
90 M_ASN1_D2I_Finish_2(a);
91
92err_bn:
93 i=ERR_R_BN_LIB;
94err:
95 ASN1err(ASN1_F_D2I_RSAPUBLICKEY,i);
96 if ((ret != NULL) && ((a == NULL) || (*a != ret))) RSA_free(ret);
97 if (bs != NULL) ASN1_INTEGER_free(bs);
98 return(NULL);
99 }
100
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_s_pr.c b/src/lib/libssl/src/crypto/asn1/d2i_s_pr.c
new file mode 100644
index 0000000000..32ff8ba4b3
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/d2i_s_pr.c
@@ -0,0 +1,113 @@
1/* crypto/asn1/d2i_s_pr.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* Origional version from Steven Schoch <schoch@sheba.arc.nasa.gov> */
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "bn.h"
64#include "dsa.h"
65#include "objects.h"
66#include "asn1_mac.h"
67
68/*
69 * ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH);
70 * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
71 * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_PARSING);
72 */
73
74DSA *d2i_DSAPrivateKey(a,pp,length)
75DSA **a;
76unsigned char **pp;
77long length;
78 {
79 int i=ASN1_R_PARSING;
80 ASN1_INTEGER *bs=NULL;
81 M_ASN1_D2I_vars(a,DSA *,DSA_new);
82
83 M_ASN1_D2I_Init();
84 M_ASN1_D2I_start_sequence();
85 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
86 if (bs->length == 0)
87 ret->version=0;
88 else ret->version=bs->data[0];
89 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
90 if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL) goto err_bn;
91 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
92 if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL) goto err_bn;
93 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
94 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;
95 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
96 if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key))
97 == NULL) goto err_bn;
98 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
99 if ((ret->priv_key=BN_bin2bn(bs->data,bs->length,ret->priv_key))
100 == NULL) goto err_bn;
101
102 ASN1_INTEGER_free(bs);
103
104 M_ASN1_D2I_Finish_2(a);
105err_bn:
106 i=ERR_R_BN_LIB;
107err:
108 ASN1err(ASN1_F_D2I_DSAPRIVATEKEY,i);
109 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
110 if (bs != NULL) ASN1_INTEGER_free(bs);
111 return(NULL);
112 }
113
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_s_pu.c b/src/lib/libssl/src/crypto/asn1/d2i_s_pu.c
new file mode 100644
index 0000000000..1002f41cd8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/d2i_s_pu.c
@@ -0,0 +1,124 @@
1/* crypto/asn1/d2i_s_pu.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* Origional version from Steven Schoch <schoch@sheba.arc.nasa.gov> */
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "bn.h"
64#include "dsa.h"
65#include "objects.h"
66#include "asn1_mac.h"
67
68/*
69 * ASN1err(ASN1_F_D2I_DSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH);
70 * ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
71 */
72
73DSA *d2i_DSAPublicKey(a,pp,length)
74DSA **a;
75unsigned char **pp;
76long length;
77 {
78 int i=ASN1_R_PARSING;
79 ASN1_INTEGER *bs=NULL;
80 M_ASN1_D2I_vars(a,DSA *,DSA_new);
81
82 M_ASN1_D2I_Init();
83 if ((length != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED))
84 == (V_ASN1_UNIVERSAL|(V_ASN1_INTEGER))))
85 {
86 c.slen=length;
87 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
88 if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key))
89 == NULL)
90 goto err_bn;
91 ret->write_params=0;
92 }
93 else
94 {
95 M_ASN1_D2I_start_sequence();
96 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
97 if ((ret->pub_key=BN_bin2bn(bs->data,bs->length,ret->pub_key))
98 == NULL)
99 goto err_bn;
100 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
101 if ((ret->p=BN_bin2bn(bs->data,bs->length,ret->p)) == NULL)
102 goto err_bn;
103 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
104 if ((ret->q=BN_bin2bn(bs->data,bs->length,ret->q)) == NULL)
105 goto err_bn;
106 M_ASN1_D2I_get(bs,d2i_ASN1_INTEGER);
107 if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL)
108 goto err_bn;
109
110 ret->write_params=1;
111 }
112
113 ASN1_INTEGER_free(bs);
114 bs=NULL;
115 M_ASN1_D2I_Finish_2(a);
116err_bn:
117 i=ERR_R_BN_LIB;
118err:
119 ASN1err(ASN1_F_D2I_DSAPUBLICKEY,i);
120 if ((ret != NULL) && ((a == NULL) || (*a != ret))) DSA_free(ret);
121 if (bs != NULL) ASN1_INTEGER_free(bs);
122 return(NULL);
123 }
124
diff --git a/src/lib/libssl/src/crypto/asn1/f.c b/src/lib/libssl/src/crypto/asn1/f.c
new file mode 100644
index 0000000000..2ab3a262ac
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/f.c
@@ -0,0 +1,80 @@
1/* crypto/asn1/f.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58#include <stdio.h>
59#include "asn1.h"
60#include "err.h"
61
62main()
63 {
64 ASN1_TYPE *at;
65 char buf[512];
66 int n;
67 long l;
68
69 at=ASN1_TYPE_new();
70
71 n=ASN1_TYPE_set_int_octetstring(at,98736,"01234567",8);
72 printf("%d\n",n);
73 n=ASN1_TYPE_get_int_octetstring(at,&l,buf,8);
74 buf[8]='\0';
75 printf("%ld %d %d\n",l,n,buf[8]);
76 buf[8]='\0';
77 printf("%s\n",buf);
78 ERR_load_crypto_strings();
79 ERR_print_errors_fp(stderr);
80 }
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_dhp.c b/src/lib/libssl/src/crypto/asn1/i2d_dhp.c
new file mode 100644
index 0000000000..a454025ce3
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/i2d_dhp.c
@@ -0,0 +1,128 @@
1/* crypto/asn1/i2d_dhp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "asn1_mac.h"
63#include "dh.h"
64
65/*
66 * ASN1err(ASN1_F_D2I_DHPARAMS,ASN1_R_LENGTH_MISMATCH);
67 * ASN1err(ASN1_F_X509_DHPARAMS_NEW,ASN1_R_LENGTH_MISMATCH);
68 */
69
70int i2d_DHparams(a,pp)
71DH *a;
72unsigned char **pp;
73 {
74 BIGNUM *num[3];
75 ASN1_INTEGER bs;
76 unsigned int j,i,tot=0,len,max=0;
77 int t,ret= -1;
78 unsigned char *p;
79
80 if (a == NULL) return(0);
81 num[0]=a->p;
82 num[1]=a->g;
83 if (a->length != 0)
84 {
85 if ((num[2]=BN_new()) == NULL) goto err;
86 if (!BN_set_word(num[2],a->length)) goto err;
87 }
88 else
89 num[2]=NULL;
90
91 for (i=0; i<3; i++)
92 {
93 if (num[i] == NULL) continue;
94 j=BN_num_bits(num[i]);
95 len=((j == 0)?0:((j/8)+1));
96 if (len > max) max=len;
97 len=ASN1_object_size(0,len,
98 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
99 tot+=len;
100 }
101
102 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
103 if (pp == NULL) return(t);
104
105 p= *pp;
106 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
107
108 bs.type=V_ASN1_INTEGER;
109 bs.data=(unsigned char *)Malloc(max+4);
110 if (bs.data == NULL)
111 {
112 ASN1err(ASN1_F_I2D_DHPARAMS,ERR_R_MALLOC_FAILURE);
113 goto err;
114 }
115
116 for (i=0; i<3; i++)
117 {
118 if (num[i] == NULL) continue;
119 bs.length=BN_bn2bin(num[i],bs.data);
120 i2d_ASN1_INTEGER(&bs,&p);
121 }
122 Free((char *)bs.data);
123 ret=t;
124err:
125 if (num[2] != NULL) BN_free(num[2]);
126 *pp=p;
127 return(ret);
128 }
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_dsap.c b/src/lib/libssl/src/crypto/asn1/i2d_dsap.c
new file mode 100644
index 0000000000..94ecff1525
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/i2d_dsap.c
@@ -0,0 +1,121 @@
1/* crypto/asn1/i2d_dsap.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "asn1_mac.h"
63#include "dsa.h"
64
65/*
66 * ASN1err(ASN1_F_D2I_DSAPARAMS,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_DSAparams(a,pp)
70DSA *a;
71unsigned char **pp;
72 {
73 BIGNUM *num[3];
74 ASN1_INTEGER bs;
75 unsigned int j,i,tot=0,len,max=0;
76 int t,ret= -1;
77 unsigned char *p;
78
79 if (a == NULL) return(0);
80 num[0]=a->p;
81 num[1]=a->q;
82 num[2]=a->g;
83
84 for (i=0; i<3; i++)
85 {
86 if (num[i] == NULL) continue;
87 j=BN_num_bits(num[i]);
88 len=((j == 0)?0:((j/8)+1));
89 if (len > max) max=len;
90 len=ASN1_object_size(0,len,
91 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
92 tot+=len;
93 }
94
95 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
96 if (pp == NULL) return(t);
97
98 p= *pp;
99 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
100
101 bs.type=V_ASN1_INTEGER;
102 bs.data=(unsigned char *)Malloc(max+4);
103 if (bs.data == NULL)
104 {
105 ASN1err(ASN1_F_I2D_DSAPARAMS,ERR_R_MALLOC_FAILURE);
106 goto err;
107 }
108
109 for (i=0; i<3; i++)
110 {
111 if (num[i] == NULL) continue;
112 bs.length=BN_bn2bin(num[i],bs.data);
113 i2d_ASN1_INTEGER(&bs,&p);
114 }
115 Free((char *)bs.data);
116 ret=t;
117err:
118 *pp=p;
119 return(ret);
120 }
121
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_r_pr.c b/src/lib/libssl/src/crypto/asn1/i2d_r_pr.c
new file mode 100644
index 0000000000..aadbb92d8e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/i2d_r_pr.c
@@ -0,0 +1,132 @@
1/* crypto/asn1/i2d_r_pr.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "rsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_RSAPRIVATEKEY,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 */
70
71int i2d_RSAPrivateKey(a,pp)
72RSA *a;
73unsigned char **pp;
74 {
75 BIGNUM *num[9];
76 unsigned char data[1];
77 ASN1_INTEGER bs;
78 unsigned int j,i,tot,t,len,max=0;
79 unsigned char *p;
80
81 if (a == NULL) return(0);
82
83 num[1]=a->n;
84 num[2]=a->e;
85 num[3]=a->d;
86 num[4]=a->p;
87 num[5]=a->q;
88 num[6]=a->dmp1;
89 num[7]=a->dmq1;
90 num[8]=a->iqmp;
91
92 bs.length=1;
93 bs.data=data;
94 bs.type=V_ASN1_INTEGER;
95 data[0]=a->version&0x7f;
96
97 tot=i2d_ASN1_INTEGER(&(bs),NULL);
98 for (i=1; i<9; i++)
99 {
100 j=BN_num_bits(num[i]);
101 len=((j == 0)?0:((j/8)+1));
102 if (len > max) max=len;
103 len=ASN1_object_size(0,len,
104 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
105 tot+=len;
106 }
107
108 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
109 if (pp == NULL) return(t);
110
111 p= *pp;
112 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
113
114 i2d_ASN1_INTEGER(&bs,&p);
115
116 bs.data=(unsigned char *)Malloc(max+4);
117 if (bs.data == NULL)
118 {
119 ASN1err(ASN1_F_I2D_RSAPRIVATEKEY,ERR_R_MALLOC_FAILURE);
120 return(-1);
121 }
122
123 for (i=1; i<9; i++)
124 {
125 bs.length=BN_bn2bin(num[i],bs.data);
126 i2d_ASN1_INTEGER(&bs,&p);
127 }
128 Free((char *)bs.data);
129 *pp=p;
130 return(t);
131 }
132
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_r_pu.c b/src/lib/libssl/src/crypto/asn1/i2d_r_pu.c
new file mode 100644
index 0000000000..3c54f6709d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/i2d_r_pu.c
@@ -0,0 +1,118 @@
1/* crypto/asn1/i2d_r_pu.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "rsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_D2I_RSAPUBLICKEY,ASN1_R_LENGTH_MISMATCH);
68 * ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
69 */
70
71int i2d_RSAPublicKey(a,pp)
72RSA *a;
73unsigned char **pp;
74 {
75 BIGNUM *num[2];
76 ASN1_INTEGER bs;
77 unsigned int j,i,tot=0,len,max=0,t;
78 unsigned char *p;
79
80 if (a == NULL) return(0);
81
82 num[0]=a->n;
83 num[1]=a->e;
84
85 for (i=0; i<2; i++)
86 {
87 j=BN_num_bits(num[i]);
88 len=((j == 0)?0:((j/8)+1));
89 if (len > max) max=len;
90 len=ASN1_object_size(0,len,
91 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
92 tot+=len;
93 }
94
95 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
96 if (pp == NULL) return(t);
97
98 p= *pp;
99 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
100
101 bs.type=V_ASN1_INTEGER;
102 bs.data=(unsigned char *)Malloc(max+4);
103 if (bs.data == NULL)
104 {
105 ASN1err(ASN1_F_I2D_RSAPUBLICKEY,ERR_R_MALLOC_FAILURE);
106 return(-1);
107 }
108
109 for (i=0; i<2; i++)
110 {
111 bs.length=BN_bn2bin(num[i],bs.data);
112 i2d_ASN1_INTEGER(&bs,&p);
113 }
114 Free((char *)bs.data);
115 *pp=p;
116 return(t);
117 }
118
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_s_pr.c b/src/lib/libssl/src/crypto/asn1/i2d_s_pr.c
new file mode 100644
index 0000000000..6e95305548
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/i2d_s_pr.c
@@ -0,0 +1,128 @@
1/* crypto/asn1/i2d_s_pr.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "dsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
68 */
69
70int i2d_DSAPrivateKey(a,pp)
71DSA *a;
72unsigned char **pp;
73 {
74 BIGNUM *num[6];
75 unsigned char data[1];
76 ASN1_INTEGER bs;
77 unsigned int j,i,tot,t,len,max=0;
78 unsigned char *p;
79
80 if (a == NULL) return(0);
81
82 num[1]=a->p;
83 num[2]=a->q;
84 num[3]=a->g;
85 num[4]=a->pub_key;
86 num[5]=a->priv_key;
87
88 bs.length=1;
89 bs.data=data;
90 bs.type=V_ASN1_INTEGER;
91 data[0]=a->version&0x7f;
92
93 tot=i2d_ASN1_INTEGER(&(bs),NULL);
94 for (i=1; i<6; i++)
95 {
96 j=BN_num_bits(num[i]);
97 len=((j == 0)?0:((j/8)+1));
98 if (len > max) max=len;
99 len=ASN1_object_size(0,len,
100 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
101 tot+=len;
102 }
103
104 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
105 if (pp == NULL) return(t);
106
107 p= *pp;
108 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
109
110 i2d_ASN1_INTEGER(&bs,&p);
111
112 bs.data=(unsigned char *)Malloc(max+4);
113 if (bs.data == NULL)
114 {
115 ASN1err(ASN1_F_I2D_DSAPRIVATEKEY,ERR_R_MALLOC_FAILURE);
116 return(-1);
117 }
118
119 for (i=1; i<6; i++)
120 {
121 bs.length=BN_bn2bin(num[i],bs.data);
122 i2d_ASN1_INTEGER(&bs,&p);
123 }
124 Free((char *)bs.data);
125 *pp=p;
126 return(t);
127 }
128
diff --git a/src/lib/libssl/src/crypto/asn1/i2d_s_pu.c b/src/lib/libssl/src/crypto/asn1/i2d_s_pu.c
new file mode 100644
index 0000000000..5cf2877069
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/i2d_s_pu.c
@@ -0,0 +1,133 @@
1/* crypto/asn1/i2d_s_pu.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn.h"
62#include "dsa.h"
63#include "objects.h"
64#include "asn1_mac.h"
65
66/*
67 * ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ASN1_R_UNKNOWN_ATTRIBUTE_TYPE);
68 */
69
70int i2d_DSAPublicKey(a,pp)
71DSA *a;
72unsigned char **pp;
73 {
74 BIGNUM *num[4];
75 ASN1_INTEGER bs;
76 unsigned int j,i,tot=0,len,max=0,t=0,all,n=1;
77 unsigned char *p;
78
79 if (a == NULL) return(0);
80
81 all=a->write_params;
82
83 num[0]=a->pub_key;
84 if (all)
85 {
86 num[1]=a->p;
87 num[2]=a->q;
88 num[3]=a->g;
89 n=4;
90 }
91
92 for (i=0; i<n; i++)
93 {
94 j=BN_num_bits(num[i]);
95 len=((j == 0)?0:((j/8)+1));
96 if (len > max) max=len;
97 len=ASN1_object_size(0,len,
98 (num[i]->neg)?V_ASN1_NEG_INTEGER:V_ASN1_INTEGER);
99 tot+=len;
100 }
101
102 if (all)
103 {
104 t=ASN1_object_size(1,tot,V_ASN1_SEQUENCE);
105 if (pp == NULL) return(t);
106 }
107 else
108 {
109 if (pp == NULL) return(tot);
110 }
111
112 p= *pp;
113 if (all)
114 ASN1_put_object(&p,1,tot,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
115
116 bs.type=V_ASN1_INTEGER;
117 bs.data=(unsigned char *)Malloc(max+4);
118 if (bs.data == NULL)
119 {
120 ASN1err(ASN1_F_I2D_DSAPUBLICKEY,ERR_R_MALLOC_FAILURE);
121 return(-1);
122 }
123
124 for (i=0; i<n; i++)
125 {
126 bs.length=BN_bn2bin(num[i],bs.data);
127 i2d_ASN1_INTEGER(&bs,&p);
128 }
129 Free((char *)bs.data);
130 *pp=p;
131 return(t);
132 }
133
diff --git a/src/lib/libssl/src/crypto/asn1/p7_dgst.c b/src/lib/libssl/src/crypto/asn1/p7_dgst.c
new file mode 100644
index 0000000000..f71ed8eb1d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p7_dgst.c
@@ -0,0 +1,130 @@
1/* crypto/asn1/p7_dgst.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_DIGEST_NEW,ASN1_R_MISSING_EOS);
66 * ASN1err(ASN1_F_D2I_PKCS7_DIGEST,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_DIGEST(a,pp)
70PKCS7_DIGEST *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len(a->md,i2d_X509_ALGOR);
77 M_ASN1_I2D_len(a->contents,i2d_PKCS7);
78 M_ASN1_I2D_len(a->digest,i2d_ASN1_OCTET_STRING);
79
80 M_ASN1_I2D_seq_total();
81
82 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
83 M_ASN1_I2D_put(a->md,i2d_X509_ALGOR);
84 M_ASN1_I2D_put(a->contents,i2d_PKCS7);
85 M_ASN1_I2D_put(a->digest,i2d_ASN1_OCTET_STRING);
86
87 M_ASN1_I2D_finish();
88 }
89
90PKCS7_DIGEST *d2i_PKCS7_DIGEST(a,pp,length)
91PKCS7_DIGEST **a;
92unsigned char **pp;
93long length;
94 {
95 M_ASN1_D2I_vars(a,PKCS7_DIGEST *,PKCS7_DIGEST_new);
96
97 M_ASN1_D2I_Init();
98 M_ASN1_D2I_start_sequence();
99 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
100 M_ASN1_D2I_get(ret->md,d2i_X509_ALGOR);
101 M_ASN1_D2I_get(ret->contents,d2i_PKCS7);
102 M_ASN1_D2I_get(ret->digest,d2i_ASN1_OCTET_STRING);
103
104 M_ASN1_D2I_Finish(a,PKCS7_DIGEST_free,ASN1_F_D2I_PKCS7_DIGEST);
105 }
106
107PKCS7_DIGEST *PKCS7_DIGEST_new()
108 {
109 PKCS7_DIGEST *ret=NULL;
110
111 M_ASN1_New_Malloc(ret,PKCS7_DIGEST);
112 M_ASN1_New(ret->version,ASN1_INTEGER_new);
113 M_ASN1_New(ret->md,X509_ALGOR_new);
114 M_ASN1_New(ret->contents,PKCS7_new);
115 M_ASN1_New(ret->digest,ASN1_OCTET_STRING_new);
116 return(ret);
117 M_ASN1_New_Error(ASN1_F_PKCS7_DIGEST_NEW);
118 }
119
120void PKCS7_DIGEST_free(a)
121PKCS7_DIGEST *a;
122 {
123 if (a == NULL) return;
124 ASN1_INTEGER_free(a->version);
125 X509_ALGOR_free(a->md);
126 PKCS7_free(a->contents);
127 ASN1_OCTET_STRING_free(a->digest);
128 Free((char *)a);
129 }
130
diff --git a/src/lib/libssl/src/crypto/asn1/p7_enc.c b/src/lib/libssl/src/crypto/asn1/p7_enc.c
new file mode 100644
index 0000000000..874dd78389
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p7_enc.c
@@ -0,0 +1,120 @@
1/* crypto/asn1/p7_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_ENCRYPT_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_ENCRYPT,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_ENCRYPT(a,pp)
70PKCS7_ENCRYPT *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT);
77
78 M_ASN1_I2D_seq_total();
79
80 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
81 M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT);
82
83 M_ASN1_I2D_finish();
84 }
85
86PKCS7_ENCRYPT *d2i_PKCS7_ENCRYPT(a,pp,length)
87PKCS7_ENCRYPT **a;
88unsigned char **pp;
89long length;
90 {
91 M_ASN1_D2I_vars(a,PKCS7_ENCRYPT *,PKCS7_ENCRYPT_new);
92
93 M_ASN1_D2I_Init();
94 M_ASN1_D2I_start_sequence();
95 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
96 M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT);
97
98 M_ASN1_D2I_Finish(a,PKCS7_ENCRYPT_free,ASN1_F_D2I_PKCS7_ENCRYPT);
99 }
100
101PKCS7_ENCRYPT *PKCS7_ENCRYPT_new()
102 {
103 PKCS7_ENCRYPT *ret=NULL;
104
105 M_ASN1_New_Malloc(ret,PKCS7_ENCRYPT);
106 M_ASN1_New(ret->version,ASN1_INTEGER_new);
107 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
108 return(ret);
109 M_ASN1_New_Error(ASN1_F_PKCS7_ENCRYPT_NEW);
110 }
111
112void PKCS7_ENCRYPT_free(a)
113PKCS7_ENCRYPT *a;
114 {
115 if (a == NULL) return;
116 ASN1_INTEGER_free(a->version);
117 PKCS7_ENC_CONTENT_free(a->enc_data);
118 Free((char *)a);
119 }
120
diff --git a/src/lib/libssl/src/crypto/asn1/p7_enc_c.c b/src/lib/libssl/src/crypto/asn1/p7_enc_c.c
new file mode 100644
index 0000000000..2860d3e925
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p7_enc_c.c
@@ -0,0 +1,127 @@
1/* crypto/asn1/p7_enc_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_ENC_CONTENT_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_ENC_CONTENT,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_ENC_CONTENT(a,pp)
70PKCS7_ENC_CONTENT *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->content_type,i2d_ASN1_OBJECT);
76 M_ASN1_I2D_len(a->algorithm,i2d_X509_ALGOR);
77 M_ASN1_I2D_len_IMP_opt(a->enc_data,i2d_ASN1_OCTET_STRING);
78
79 M_ASN1_I2D_seq_total();
80
81 M_ASN1_I2D_put(a->content_type,i2d_ASN1_OBJECT);
82 M_ASN1_I2D_put(a->algorithm,i2d_X509_ALGOR);
83 M_ASN1_I2D_put_IMP_opt(a->enc_data,i2d_ASN1_OCTET_STRING,0);
84
85 M_ASN1_I2D_finish();
86 }
87
88PKCS7_ENC_CONTENT *d2i_PKCS7_ENC_CONTENT(a,pp,length)
89PKCS7_ENC_CONTENT **a;
90unsigned char **pp;
91long length;
92 {
93 M_ASN1_D2I_vars(a,PKCS7_ENC_CONTENT *,PKCS7_ENC_CONTENT_new);
94
95 M_ASN1_D2I_Init();
96 M_ASN1_D2I_start_sequence();
97 M_ASN1_D2I_get(ret->content_type,d2i_ASN1_OBJECT);
98 M_ASN1_D2I_get(ret->algorithm,d2i_X509_ALGOR);
99 M_ASN1_D2I_get_IMP_opt(ret->enc_data,d2i_ASN1_OCTET_STRING,0,
100 V_ASN1_OCTET_STRING);
101
102 M_ASN1_D2I_Finish(a,PKCS7_ENC_CONTENT_free,
103 ASN1_F_D2I_PKCS7_ENC_CONTENT);
104 }
105
106PKCS7_ENC_CONTENT *PKCS7_ENC_CONTENT_new()
107 {
108 PKCS7_ENC_CONTENT *ret=NULL;
109
110 M_ASN1_New_Malloc(ret,PKCS7_ENC_CONTENT);
111 M_ASN1_New(ret->content_type,ASN1_OBJECT_new);
112 M_ASN1_New(ret->algorithm,X509_ALGOR_new);
113 ret->enc_data=NULL;
114 return(ret);
115 M_ASN1_New_Error(ASN1_F_PKCS7_ENC_CONTENT_NEW);
116 }
117
118void PKCS7_ENC_CONTENT_free(a)
119PKCS7_ENC_CONTENT *a;
120 {
121 if (a == NULL) return;
122 ASN1_OBJECT_free(a->content_type);
123 X509_ALGOR_free(a->algorithm);
124 ASN1_OCTET_STRING_free(a->enc_data);
125 Free((char *)a);
126 }
127
diff --git a/src/lib/libssl/src/crypto/asn1/p7_evp.c b/src/lib/libssl/src/crypto/asn1/p7_evp.c
new file mode 100644
index 0000000000..4db0a7fe62
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p7_evp.c
@@ -0,0 +1,125 @@
1/* crypto/asn1/p7_evp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_ENVELOPE_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_ENVELOPE,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_ENVELOPE(a,pp)
70PKCS7_ENVELOPE *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO);
77 M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT);
78
79 M_ASN1_I2D_seq_total();
80
81 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
82 M_ASN1_I2D_put_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO);
83 M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT);
84
85 M_ASN1_I2D_finish();
86 }
87
88PKCS7_ENVELOPE *d2i_PKCS7_ENVELOPE(a,pp,length)
89PKCS7_ENVELOPE **a;
90unsigned char **pp;
91long length;
92 {
93 M_ASN1_D2I_vars(a,PKCS7_ENVELOPE *,PKCS7_ENVELOPE_new);
94
95 M_ASN1_D2I_Init();
96 M_ASN1_D2I_start_sequence();
97 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
98 M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO);
99 M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT);
100
101 M_ASN1_D2I_Finish(a,PKCS7_ENVELOPE_free,ASN1_F_D2I_PKCS7_ENVELOPE);
102 }
103
104PKCS7_ENVELOPE *PKCS7_ENVELOPE_new()
105 {
106 PKCS7_ENVELOPE *ret=NULL;
107
108 M_ASN1_New_Malloc(ret,PKCS7_ENVELOPE);
109 M_ASN1_New(ret->version,ASN1_INTEGER_new);
110 M_ASN1_New(ret->recipientinfo,sk_new_null);
111 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
112 return(ret);
113 M_ASN1_New_Error(ASN1_F_PKCS7_ENVELOPE_NEW);
114 }
115
116void PKCS7_ENVELOPE_free(a)
117PKCS7_ENVELOPE *a;
118 {
119 if (a == NULL) return;
120 ASN1_INTEGER_free(a->version);
121 sk_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
122 PKCS7_ENC_CONTENT_free(a->enc_data);
123 Free((char *)a);
124 }
125
diff --git a/src/lib/libssl/src/crypto/asn1/p7_i_s.c b/src/lib/libssl/src/crypto/asn1/p7_i_s.c
new file mode 100644
index 0000000000..9b00c556d9
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p7_i_s.c
@@ -0,0 +1,120 @@
1/* crypto/asn1/p7_i_s.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_ISSUER_AND_SERIAL(a,pp)
70PKCS7_ISSUER_AND_SERIAL *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->issuer,i2d_X509_NAME);
76 M_ASN1_I2D_len(a->serial,i2d_ASN1_INTEGER);
77
78 M_ASN1_I2D_seq_total();
79
80 M_ASN1_I2D_put(a->issuer,i2d_X509_NAME);
81 M_ASN1_I2D_put(a->serial,i2d_ASN1_INTEGER);
82
83 M_ASN1_I2D_finish();
84 }
85
86PKCS7_ISSUER_AND_SERIAL *d2i_PKCS7_ISSUER_AND_SERIAL(a,pp,length)
87PKCS7_ISSUER_AND_SERIAL **a;
88unsigned char **pp;
89long length;
90 {
91 M_ASN1_D2I_vars(a,PKCS7_ISSUER_AND_SERIAL *,PKCS7_ISSUER_AND_SERIAL_new);
92
93 M_ASN1_D2I_Init();
94 M_ASN1_D2I_start_sequence();
95 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
96 M_ASN1_D2I_get(ret->serial,d2i_ASN1_INTEGER);
97 M_ASN1_D2I_Finish(a,PKCS7_ISSUER_AND_SERIAL_free,
98 ASN1_F_D2I_PKCS7_ISSUER_AND_SERIAL);
99 }
100
101PKCS7_ISSUER_AND_SERIAL *PKCS7_ISSUER_AND_SERIAL_new()
102 {
103 PKCS7_ISSUER_AND_SERIAL *ret=NULL;
104
105 M_ASN1_New_Malloc(ret,PKCS7_ISSUER_AND_SERIAL);
106 M_ASN1_New(ret->issuer,X509_NAME_new);
107 M_ASN1_New(ret->serial,ASN1_INTEGER_new);
108 return(ret);
109 M_ASN1_New_Error(ASN1_F_PKCS7_ISSUER_AND_SERIAL_NEW);
110 }
111
112void PKCS7_ISSUER_AND_SERIAL_free(a)
113PKCS7_ISSUER_AND_SERIAL *a;
114 {
115 if (a == NULL) return;
116 X509_NAME_free(a->issuer);
117 ASN1_INTEGER_free(a->serial);
118 Free((char *)a);
119 }
120
diff --git a/src/lib/libssl/src/crypto/asn1/p7_lib.c b/src/lib/libssl/src/crypto/asn1/p7_lib.c
new file mode 100644
index 0000000000..2134e0974a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p7_lib.c
@@ -0,0 +1,299 @@
1/* crypto/asn1/p7_lib.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "objects.h"
63
64/* ASN1err(ASN1_F_D2I_PKCS7,ASN1_R_BAD_PKCS7_CONTENT);
65 * ASN1err(ASN1_F_I2D_PKCS7,ASN1_R_BAD_PKCS7_TYPE);
66 * ASN1err(ASN1_F_PKCS7_NEW,ASN1_R_BAD_PKCS7_TYPE);
67 */
68
69int i2d_PKCS7(a,pp)
70PKCS7 *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 if (a->asn1 != NULL)
76 {
77 if (pp == NULL)
78 return((int)a->length);
79 memcpy(*pp,a->asn1,(int)a->length);
80 *pp+=a->length;
81 return((int)a->length);
82 }
83
84 ret+=4; /* sequence, BER header plus '0 0' end padding */
85 M_ASN1_I2D_len(a->type,i2d_ASN1_OBJECT);
86 if (a->d.ptr != NULL)
87 {
88 ret+=4; /* explicit tag [ 0 ] BER plus '0 0' */
89 switch (OBJ_obj2nid(a->type))
90 {
91 case NID_pkcs7_data:
92 M_ASN1_I2D_len(a->d.data,i2d_ASN1_OCTET_STRING);
93 break;
94 case NID_pkcs7_signed:
95 M_ASN1_I2D_len(a->d.sign,i2d_PKCS7_SIGNED);
96 break;
97 case NID_pkcs7_enveloped:
98 M_ASN1_I2D_len(a->d.enveloped,i2d_PKCS7_ENVELOPE);
99 break;
100 case NID_pkcs7_signedAndEnveloped:
101 M_ASN1_I2D_len(a->d.signed_and_enveloped,
102 i2d_PKCS7_SIGN_ENVELOPE);
103 break;
104 case NID_pkcs7_digest:
105 M_ASN1_I2D_len(a->d.digest,i2d_PKCS7_DIGEST);
106 break;
107 case NID_pkcs7_encrypted:
108 M_ASN1_I2D_len(a->d.encrypted,i2d_PKCS7_ENCRYPT);
109 break;
110 default:
111 break;
112 }
113 }
114 r=ret;
115 if (pp == NULL) return(r);
116 p= *pp;
117 M_ASN1_I2D_INF_seq_start(V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
118 M_ASN1_I2D_put(a->type,i2d_ASN1_OBJECT);
119
120 if (a->d.ptr != NULL)
121 {
122 M_ASN1_I2D_INF_seq_start(0,V_ASN1_CONTEXT_SPECIFIC);
123 switch (OBJ_obj2nid(a->type))
124 {
125 case NID_pkcs7_data:
126 M_ASN1_I2D_put(a->d.data,i2d_ASN1_OCTET_STRING);
127 break;
128 case NID_pkcs7_signed:
129 M_ASN1_I2D_put(a->d.sign,i2d_PKCS7_SIGNED);
130 break;
131 case NID_pkcs7_enveloped:
132 M_ASN1_I2D_put(a->d.enveloped,i2d_PKCS7_ENVELOPE);
133 break;
134 case NID_pkcs7_signedAndEnveloped:
135 M_ASN1_I2D_put(a->d.signed_and_enveloped,
136 i2d_PKCS7_SIGN_ENVELOPE);
137 break;
138 case NID_pkcs7_digest:
139 M_ASN1_I2D_put(a->d.digest,i2d_PKCS7_DIGEST);
140 break;
141 case NID_pkcs7_encrypted:
142 M_ASN1_I2D_put(a->d.encrypted,i2d_PKCS7_ENCRYPT);
143 break;
144 default:
145 break;
146 }
147 M_ASN1_I2D_INF_seq_end();
148 }
149 M_ASN1_I2D_INF_seq_end();
150 M_ASN1_I2D_finish();
151 }
152
153PKCS7 *d2i_PKCS7(a,pp,length)
154PKCS7 **a;
155unsigned char **pp;
156long length;
157 {
158 M_ASN1_D2I_vars(a,PKCS7 *,PKCS7_new);
159
160 if ((a != NULL) && ((*a) != NULL))
161 {
162 if ((*a)->asn1 != NULL)
163 {
164 Free((char *)(*a)->asn1);
165 (*a)->asn1=NULL;
166 }
167 (*a)->length=0;
168 }
169
170 M_ASN1_D2I_Init();
171 M_ASN1_D2I_start_sequence();
172 M_ASN1_D2I_get(ret->type,d2i_ASN1_OBJECT);
173 if (!M_ASN1_D2I_end_sequence())
174 {
175 int Tinf,Ttag,Tclass;
176 long Tlen;
177
178 if (M_ASN1_next != (V_ASN1_CONSTRUCTED|
179 V_ASN1_CONTEXT_SPECIFIC|0))
180 {
181 c.error=ASN1_R_BAD_PKCS7_CONTENT;
182 goto err;
183 }
184
185 ret->detached=0;
186
187 c.q=c.p;
188 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,
189 (c.inf & 1)?(length+ *pp-c.q):c.slen);
190 if (Tinf & 0x80) goto err;
191 c.slen-=(c.p-c.q);
192
193 switch (OBJ_obj2nid(ret->type))
194 {
195 case NID_pkcs7_data:
196 M_ASN1_D2I_get(ret->d.data,d2i_ASN1_OCTET_STRING);
197 break;
198 case NID_pkcs7_signed:
199 M_ASN1_D2I_get(ret->d.sign,d2i_PKCS7_SIGNED);
200 if (ret->d.sign->contents->d.ptr == NULL)
201 ret->detached=1;
202 break;
203 case NID_pkcs7_enveloped:
204 M_ASN1_D2I_get(ret->d.enveloped,d2i_PKCS7_ENVELOPE);
205 break;
206 case NID_pkcs7_signedAndEnveloped:
207 M_ASN1_D2I_get(ret->d.signed_and_enveloped,
208 d2i_PKCS7_SIGN_ENVELOPE);
209 break;
210 case NID_pkcs7_digest:
211 M_ASN1_D2I_get(ret->d.digest,d2i_PKCS7_DIGEST);
212 break;
213 case NID_pkcs7_encrypted:
214 M_ASN1_D2I_get(ret->d.encrypted,d2i_PKCS7_ENCRYPT);
215 break;
216 default:
217 c.error=ASN1_R_BAD_PKCS7_TYPE;
218 goto err;
219 break;
220 }
221 if (Tinf == (1|V_ASN1_CONSTRUCTED))
222 {
223 if (!ASN1_check_infinite_end(&c.p,c.slen))
224 {
225 c.error=ASN1_R_MISSING_EOS;
226 goto err;
227 }
228 }
229 }
230 else
231 ret->detached=1;
232
233 M_ASN1_D2I_Finish(a,PKCS7_free,ASN1_F_D2I_PKCS7);
234 }
235
236PKCS7 *PKCS7_new()
237 {
238 PKCS7 *ret=NULL;
239
240 M_ASN1_New_Malloc(ret,PKCS7);
241 ret->type=ASN1_OBJECT_new();
242 ret->asn1=NULL;
243 ret->length=0;
244 ret->detached=0;
245 ret->d.ptr=NULL;
246 return(ret);
247 M_ASN1_New_Error(ASN1_F_PKCS7_NEW);
248 }
249
250void PKCS7_free(a)
251PKCS7 *a;
252 {
253 if (a == NULL) return;
254
255 PKCS7_content_free(a);
256 if (a->type != NULL)
257 {
258 ASN1_OBJECT_free(a->type);
259 }
260 Free((char *)(char *)a);
261 }
262
263void PKCS7_content_free(a)
264PKCS7 *a;
265 {
266 if (a->asn1 != NULL) Free((char *)a->asn1);
267
268 if (a->d.ptr != NULL)
269 {
270 if (a->type == NULL) return;
271
272 switch (OBJ_obj2nid(a->type))
273 {
274 case NID_pkcs7_data:
275 ASN1_OCTET_STRING_free(a->d.data);
276 break;
277 case NID_pkcs7_signed:
278 PKCS7_SIGNED_free(a->d.sign);
279 break;
280 case NID_pkcs7_enveloped:
281 PKCS7_ENVELOPE_free(a->d.enveloped);
282 break;
283 case NID_pkcs7_signedAndEnveloped:
284 PKCS7_SIGN_ENVELOPE_free(a->d.signed_and_enveloped);
285 break;
286 case NID_pkcs7_digest:
287 PKCS7_DIGEST_free(a->d.digest);
288 break;
289 case NID_pkcs7_encrypted:
290 PKCS7_ENCRYPT_free(a->d.encrypted);
291 break;
292 default:
293 /* MEMORY LEAK */
294 break;
295 }
296 }
297 a->d.ptr=NULL;
298 }
299
diff --git a/src/lib/libssl/src/crypto/asn1/p7_recip.c b/src/lib/libssl/src/crypto/asn1/p7_recip.c
new file mode 100644
index 0000000000..f02233f5a8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p7_recip.c
@@ -0,0 +1,132 @@
1/* crypto/asn1/p7_recip.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_RECIP_INFO_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_RECIP_INFO,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_RECIP_INFO(a,pp)
70PKCS7_RECIP_INFO *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL);
77 M_ASN1_I2D_len(a->key_enc_algor,i2d_X509_ALGOR);
78 M_ASN1_I2D_len(a->enc_key,i2d_ASN1_OCTET_STRING);
79
80 M_ASN1_I2D_seq_total();
81
82 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
83 M_ASN1_I2D_put(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL);
84 M_ASN1_I2D_put(a->key_enc_algor,i2d_X509_ALGOR);
85 M_ASN1_I2D_put(a->enc_key,i2d_ASN1_OCTET_STRING);
86
87 M_ASN1_I2D_finish();
88 }
89
90PKCS7_RECIP_INFO *d2i_PKCS7_RECIP_INFO(a,pp,length)
91PKCS7_RECIP_INFO **a;
92unsigned char **pp;
93long length;
94 {
95 M_ASN1_D2I_vars(a,PKCS7_RECIP_INFO *,PKCS7_RECIP_INFO_new);
96
97 M_ASN1_D2I_Init();
98 M_ASN1_D2I_start_sequence();
99 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
100 M_ASN1_D2I_get(ret->issuer_and_serial,d2i_PKCS7_ISSUER_AND_SERIAL);
101 M_ASN1_D2I_get(ret->key_enc_algor,d2i_X509_ALGOR);
102 M_ASN1_D2I_get(ret->enc_key,d2i_ASN1_OCTET_STRING);
103
104 M_ASN1_D2I_Finish(a,PKCS7_RECIP_INFO_free,ASN1_F_D2I_PKCS7_RECIP_INFO);
105 }
106
107PKCS7_RECIP_INFO *PKCS7_RECIP_INFO_new()
108 {
109 PKCS7_RECIP_INFO *ret=NULL;
110
111 M_ASN1_New_Malloc(ret,PKCS7_RECIP_INFO);
112 M_ASN1_New(ret->version,ASN1_INTEGER_new);
113 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new);
114 M_ASN1_New(ret->key_enc_algor,X509_ALGOR_new);
115 M_ASN1_New(ret->enc_key,ASN1_OCTET_STRING_new);
116 ret->cert=NULL;
117 return(ret);
118 M_ASN1_New_Error(ASN1_F_PKCS7_RECIP_INFO_NEW);
119 }
120
121void PKCS7_RECIP_INFO_free(a)
122PKCS7_RECIP_INFO *a;
123 {
124 if (a == NULL) return;
125 ASN1_INTEGER_free(a->version);
126 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial);
127 X509_ALGOR_free(a->key_enc_algor);
128 ASN1_OCTET_STRING_free(a->enc_key);
129 if (a->cert != NULL) X509_free(a->cert);
130 Free((char *)a);
131 }
132
diff --git a/src/lib/libssl/src/crypto/asn1/p7_s_e.c b/src/lib/libssl/src/crypto/asn1/p7_s_e.c
new file mode 100644
index 0000000000..d344211456
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p7_s_e.c
@@ -0,0 +1,146 @@
1/* crypto/asn1/p7_s_e.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_SIGN_ENVELOPE,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_SIGN_ENVELOPE(a,pp)
70PKCS7_SIGN_ENVELOPE *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO);
77 M_ASN1_I2D_len_SET(a->md_algs,i2d_X509_ALGOR);
78 M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT);
79 M_ASN1_I2D_len_IMP_set_opt(a->cert,i2d_X509,0);
80 M_ASN1_I2D_len_IMP_set_opt(a->crl,i2d_X509_CRL,1);
81 M_ASN1_I2D_len_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
82
83 M_ASN1_I2D_seq_total();
84
85 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
86 M_ASN1_I2D_put_SET(a->recipientinfo,i2d_PKCS7_RECIP_INFO);
87 M_ASN1_I2D_put_SET(a->md_algs,i2d_X509_ALGOR);
88 M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT);
89 M_ASN1_I2D_put_IMP_set_opt(a->cert,i2d_X509,0);
90 M_ASN1_I2D_put_IMP_set_opt(a->crl,i2d_X509_CRL,1);
91 M_ASN1_I2D_put_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
92
93 M_ASN1_I2D_finish();
94 }
95
96PKCS7_SIGN_ENVELOPE *d2i_PKCS7_SIGN_ENVELOPE(a,pp,length)
97PKCS7_SIGN_ENVELOPE **a;
98unsigned char **pp;
99long length;
100 {
101 M_ASN1_D2I_vars(a,PKCS7_SIGN_ENVELOPE *,PKCS7_SIGN_ENVELOPE_new);
102
103 M_ASN1_D2I_Init();
104 M_ASN1_D2I_start_sequence();
105 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
106 M_ASN1_D2I_get_set(ret->recipientinfo,d2i_PKCS7_RECIP_INFO);
107 M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR);
108 M_ASN1_D2I_get(ret->enc_data,d2i_PKCS7_ENC_CONTENT);
109 M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,0);
110 M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,1);
111 M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO);
112
113 M_ASN1_D2I_Finish(a,PKCS7_SIGN_ENVELOPE_free,
114 ASN1_F_D2I_PKCS7_SIGN_ENVELOPE);
115 }
116
117PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new()
118 {
119 PKCS7_SIGN_ENVELOPE *ret=NULL;
120
121 M_ASN1_New_Malloc(ret,PKCS7_SIGN_ENVELOPE);
122 M_ASN1_New(ret->version,ASN1_INTEGER_new);
123 M_ASN1_New(ret->recipientinfo,sk_new_null);
124 M_ASN1_New(ret->md_algs,sk_new_null);
125 M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
126 ret->cert=NULL;
127 ret->crl=NULL;
128 M_ASN1_New(ret->signer_info,sk_new_null);
129 return(ret);
130 M_ASN1_New_Error(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW);
131 }
132
133void PKCS7_SIGN_ENVELOPE_free(a)
134PKCS7_SIGN_ENVELOPE *a;
135 {
136 if (a == NULL) return;
137 ASN1_INTEGER_free(a->version);
138 sk_pop_free(a->recipientinfo,PKCS7_RECIP_INFO_free);
139 sk_pop_free(a->md_algs,X509_ALGOR_free);
140 PKCS7_ENC_CONTENT_free(a->enc_data);
141 sk_pop_free(a->cert,X509_free);
142 sk_pop_free(a->crl,X509_CRL_free);
143 sk_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free);
144 Free((char *)a);
145 }
146
diff --git a/src/lib/libssl/src/crypto/asn1/p7_signd.c b/src/lib/libssl/src/crypto/asn1/p7_signd.c
new file mode 100644
index 0000000000..40f9a44fa8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p7_signd.c
@@ -0,0 +1,140 @@
1/* crypto/asn1/p7_signd.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_SIGNED_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_SIGNED,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_SIGNED(a,pp)
70PKCS7_SIGNED *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len_SET(a->md_algs,i2d_X509_ALGOR);
77 M_ASN1_I2D_len(a->contents,i2d_PKCS7);
78 M_ASN1_I2D_len_IMP_set_opt(a->cert,i2d_X509,0);
79 M_ASN1_I2D_len_IMP_set_opt(a->crl,i2d_X509_CRL,1);
80 M_ASN1_I2D_len_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
81
82 M_ASN1_I2D_seq_total();
83
84 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
85 M_ASN1_I2D_put_SET(a->md_algs,i2d_X509_ALGOR);
86 M_ASN1_I2D_put(a->contents,i2d_PKCS7);
87 M_ASN1_I2D_put_IMP_set_opt(a->cert,i2d_X509,0);
88 M_ASN1_I2D_put_IMP_set_opt(a->crl,i2d_X509_CRL,1);
89 M_ASN1_I2D_put_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
90
91 M_ASN1_I2D_finish();
92 }
93
94PKCS7_SIGNED *d2i_PKCS7_SIGNED(a,pp,length)
95PKCS7_SIGNED **a;
96unsigned char **pp;
97long length;
98 {
99 M_ASN1_D2I_vars(a,PKCS7_SIGNED *,PKCS7_SIGNED_new);
100
101 M_ASN1_D2I_Init();
102 M_ASN1_D2I_start_sequence();
103 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
104 M_ASN1_D2I_get_set(ret->md_algs,d2i_X509_ALGOR);
105 M_ASN1_D2I_get(ret->contents,d2i_PKCS7);
106 M_ASN1_D2I_get_IMP_set_opt(ret->cert,d2i_X509,0);
107 M_ASN1_D2I_get_IMP_set_opt(ret->crl,d2i_X509_CRL,1);
108 M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO);
109
110 M_ASN1_D2I_Finish(a,PKCS7_SIGNED_free,ASN1_F_D2I_PKCS7_SIGNED);
111 }
112
113PKCS7_SIGNED *PKCS7_SIGNED_new()
114 {
115 PKCS7_SIGNED *ret=NULL;
116
117 M_ASN1_New_Malloc(ret,PKCS7_SIGNED);
118 M_ASN1_New(ret->version,ASN1_INTEGER_new);
119 M_ASN1_New(ret->md_algs,sk_new_null);
120 M_ASN1_New(ret->contents,PKCS7_new);
121 ret->cert=NULL;
122 ret->crl=NULL;
123 M_ASN1_New(ret->signer_info,sk_new_null);
124 return(ret);
125 M_ASN1_New_Error(ASN1_F_PKCS7_SIGNED_NEW);
126 }
127
128void PKCS7_SIGNED_free(a)
129PKCS7_SIGNED *a;
130 {
131 if (a == NULL) return;
132 ASN1_INTEGER_free(a->version);
133 sk_pop_free(a->md_algs,X509_ALGOR_free);
134 PKCS7_free(a->contents);
135 sk_pop_free(a->cert,X509_free);
136 sk_pop_free(a->crl,X509_CRL_free);
137 sk_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free);
138 Free((char *)a);
139 }
140
diff --git a/src/lib/libssl/src/crypto/asn1/p7_signi.c b/src/lib/libssl/src/crypto/asn1/p7_signi.c
new file mode 100644
index 0000000000..0da92169fc
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/p7_signi.c
@@ -0,0 +1,149 @@
1/* crypto/asn1/p7_signi.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "x509.h"
63
64/*
65 * ASN1err(ASN1_F_PKCS7_SIGNER_INFO_NEW,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_D2I_PKCS7_SIGNER_INFO,ASN1_R_LENGTH_MISMATCH);
67 */
68
69int i2d_PKCS7_SIGNER_INFO(a,pp)
70PKCS7_SIGNER_INFO *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->version,i2d_ASN1_INTEGER);
76 M_ASN1_I2D_len(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL);
77 M_ASN1_I2D_len(a->digest_alg,i2d_X509_ALGOR);
78 M_ASN1_I2D_len_IMP_set_opt(a->auth_attr,i2d_X509_ATTRIBUTE,0);
79 M_ASN1_I2D_len(a->digest_enc_alg,i2d_X509_ALGOR);
80 M_ASN1_I2D_len(a->enc_digest,i2d_ASN1_OCTET_STRING);
81 M_ASN1_I2D_len_IMP_set_opt(a->unauth_attr,i2d_X509_ATTRIBUTE,1);
82
83 M_ASN1_I2D_seq_total();
84
85 M_ASN1_I2D_put(a->version,i2d_ASN1_INTEGER);
86 M_ASN1_I2D_put(a->issuer_and_serial,i2d_PKCS7_ISSUER_AND_SERIAL);
87 M_ASN1_I2D_put(a->digest_alg,i2d_X509_ALGOR);
88 M_ASN1_I2D_put_IMP_set_opt(a->auth_attr,i2d_X509_ATTRIBUTE,0);
89 M_ASN1_I2D_put(a->digest_enc_alg,i2d_X509_ALGOR);
90 M_ASN1_I2D_put(a->enc_digest,i2d_ASN1_OCTET_STRING);
91 M_ASN1_I2D_put_IMP_set_opt(a->unauth_attr,i2d_X509_ATTRIBUTE,1);
92
93 M_ASN1_I2D_finish();
94 }
95
96PKCS7_SIGNER_INFO *d2i_PKCS7_SIGNER_INFO(a,pp,length)
97PKCS7_SIGNER_INFO **a;
98unsigned char **pp;
99long length;
100 {
101 M_ASN1_D2I_vars(a,PKCS7_SIGNER_INFO *,PKCS7_SIGNER_INFO_new);
102
103 M_ASN1_D2I_Init();
104 M_ASN1_D2I_start_sequence();
105 M_ASN1_D2I_get(ret->version,d2i_ASN1_INTEGER);
106 M_ASN1_D2I_get(ret->issuer_and_serial,d2i_PKCS7_ISSUER_AND_SERIAL);
107 M_ASN1_D2I_get(ret->digest_alg,d2i_X509_ALGOR);
108 M_ASN1_D2I_get_IMP_set_opt(ret->auth_attr,d2i_X509_ATTRIBUTE,0);
109 M_ASN1_D2I_get(ret->digest_enc_alg,d2i_X509_ALGOR);
110 M_ASN1_D2I_get(ret->enc_digest,d2i_ASN1_OCTET_STRING);
111 M_ASN1_D2I_get_IMP_set_opt(ret->unauth_attr,d2i_X509_ATTRIBUTE,1);
112
113 M_ASN1_D2I_Finish(a,PKCS7_SIGNER_INFO_free,
114 ASN1_F_D2I_PKCS7_SIGNER_INFO);
115 }
116
117PKCS7_SIGNER_INFO *PKCS7_SIGNER_INFO_new()
118 {
119 PKCS7_SIGNER_INFO *ret=NULL;
120
121 M_ASN1_New_Malloc(ret,PKCS7_SIGNER_INFO);
122 M_ASN1_New(ret->version,ASN1_INTEGER_new);
123 M_ASN1_New(ret->issuer_and_serial,PKCS7_ISSUER_AND_SERIAL_new);
124 M_ASN1_New(ret->digest_alg,X509_ALGOR_new);
125 ret->auth_attr=NULL;
126 M_ASN1_New(ret->digest_enc_alg,X509_ALGOR_new);
127 M_ASN1_New(ret->enc_digest,ASN1_OCTET_STRING_new);
128 ret->unauth_attr=NULL;
129 ret->pkey=NULL;
130 return(ret);
131 M_ASN1_New_Error(ASN1_F_PKCS7_SIGNER_INFO_NEW);
132 }
133
134void PKCS7_SIGNER_INFO_free(a)
135PKCS7_SIGNER_INFO *a;
136 {
137 if (a == NULL) return;
138 ASN1_INTEGER_free(a->version);
139 PKCS7_ISSUER_AND_SERIAL_free(a->issuer_and_serial);
140 X509_ALGOR_free(a->digest_alg);
141 sk_pop_free(a->auth_attr,X509_ATTRIBUTE_free);
142 X509_ALGOR_free(a->digest_enc_alg);
143 ASN1_OCTET_STRING_free(a->enc_digest);
144 sk_pop_free(a->unauth_attr,X509_ATTRIBUTE_free);
145 if (a->pkey != NULL)
146 EVP_PKEY_free(a->pkey);
147 Free((char *)a);
148 }
149
diff --git a/src/lib/libssl/src/crypto/asn1/pkcs8.c b/src/lib/libssl/src/crypto/asn1/pkcs8.c
new file mode 100644
index 0000000000..03fdadd51a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/pkcs8.c
@@ -0,0 +1,142 @@
1/* crypto/asn1/pkcs8.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62#include "objects.h"
63
64/*
65 * ASN1err(ASN1_F_D2I_X509_KEY,ASN1_R_LENGTH_MISMATCH);
66 * ASN1err(ASN1_F_X509_KEY_NEW,ASN1_R_BAD_GET_OBJECT);
67 */
68
69int i2d_X509_KEY(a,pp)
70X509 *a;
71unsigned char **pp;
72 {
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
76 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
77 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
78
79 M_ASN1_I2D_seq_total();
80
81 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
82 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
83 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
84
85 M_ASN1_I2D_finish();
86 }
87
88X509 *d2i_X509_KEY(a,pp,length)
89X509 **a;
90unsigned char **pp;
91long length;
92 {
93 M_ASN1_D2I_vars(a,X509 *,X509_new);
94
95 M_ASN1_D2I_Init();
96 M_ASN1_D2I_start_sequence();
97 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
98 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
99 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
100 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
101 }
102
103X509 *X509_KEY_new()
104 {
105 X509_KEY *ret=NULL;
106
107 M_ASN1_New_Malloc(ret,X509_KEY);
108 ret->references=1;
109 ret->type=NID
110 M_ASN1_New(ret->cert_info,X509_CINF_new);
111 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
112 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
113 return(ret);
114 M_ASN1_New_Error(ASN1_F_X509_NEW);
115 }
116
117void X509_KEY_free(a)
118X509 *a;
119 {
120 int i;
121
122 if (a == NULL) return;
123
124 i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY);
125#ifdef REF_PRINT
126 REF_PRINT("X509_KEY",a);
127#endif
128 if (i > 0) return;
129#ifdef REF_CHECK
130 if (i < 0)
131 {
132 fprintf(stderr,"X509_KEY_free, bad reference count\n");
133 abort();
134 }
135#endif
136
137 X509_CINF_free(a->cert_info);
138 X509_ALGOR_free(a->sig_alg);
139 ASN1_BIT_STRING_free(a->signature);
140 Free((char *)a);
141 }
142
diff --git a/src/lib/libssl/src/crypto/asn1/x_cinf.c b/src/lib/libssl/src/crypto/asn1/x_cinf.c
new file mode 100644
index 0000000000..4fc2cc9f6e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/asn1/x_cinf.c
@@ -0,0 +1,197 @@
1/* crypto/asn1/x_cinf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "asn1_mac.h"
62
63/*
64 * ASN1err(ASN1_F_D2I_X509_CINF,ASN1_R_LENGTH_MISMATCH);
65 * ASN1err(ASN1_F_X509_CINF_NEW,ASN1_R_LENGTH_MISMATCH);
66 */
67
68int i2d_X509_CINF(a,pp)
69X509_CINF *a;
70unsigned char **pp;
71 {
72 int v1=0,v2=0;
73 M_ASN1_I2D_vars(a);
74
75 M_ASN1_I2D_len_EXP_opt(a->version,i2d_ASN1_INTEGER,0,v1);
76 M_ASN1_I2D_len(a->serialNumber, i2d_ASN1_INTEGER);
77 M_ASN1_I2D_len(a->signature, i2d_X509_ALGOR);
78 M_ASN1_I2D_len(a->issuer, i2d_X509_NAME);
79 M_ASN1_I2D_len(a->validity, i2d_X509_VAL);
80 M_ASN1_I2D_len(a->subject, i2d_X509_NAME);
81 M_ASN1_I2D_len(a->key, i2d_X509_PUBKEY);
82 M_ASN1_I2D_len_IMP_opt(a->issuerUID, i2d_ASN1_BIT_STRING);
83 M_ASN1_I2D_len_IMP_opt(a->subjectUID, i2d_ASN1_BIT_STRING);
84 M_ASN1_I2D_len_EXP_set_opt(a->extensions,i2d_X509_EXTENSION,3,V_ASN1_SEQUENCE,v2);
85
86 M_ASN1_I2D_seq_total();
87
88 M_ASN1_I2D_put_EXP_opt(a->version,i2d_ASN1_INTEGER,0,v1);
89 M_ASN1_I2D_put(a->serialNumber, i2d_ASN1_INTEGER);
90 M_ASN1_I2D_put(a->signature, i2d_X509_ALGOR);
91 M_ASN1_I2D_put(a->issuer, i2d_X509_NAME);
92 M_ASN1_I2D_put(a->validity, i2d_X509_VAL);
93 M_ASN1_I2D_put(a->subject, i2d_X509_NAME);
94 M_ASN1_I2D_put(a->key, i2d_X509_PUBKEY);
95 M_ASN1_I2D_put_IMP_opt(a->issuerUID, i2d_ASN1_BIT_STRING,1);
96 M_ASN1_I2D_put_IMP_opt(a->subjectUID, i2d_ASN1_BIT_STRING,2);
97 M_ASN1_I2D_put_EXP_set_opt(a->extensions,i2d_X509_EXTENSION,3,V_ASN1_SEQUENCE,v2);
98
99 M_ASN1_I2D_finish();
100 }
101
102X509_CINF *d2i_X509_CINF(a,pp,length)
103X509_CINF **a;
104unsigned char **pp;
105long length;
106 {
107 int ver=0;
108 M_ASN1_D2I_vars(a,X509_CINF *,X509_CINF_new);
109
110 M_ASN1_D2I_Init();
111 M_ASN1_D2I_start_sequence();
112 /* we have the optional version field */
113 if (M_ASN1_next == (V_ASN1_CONTEXT_SPECIFIC | V_ASN1_CONSTRUCTED | 0))
114 {
115 M_ASN1_D2I_get_EXP_opt(ret->version,d2i_ASN1_INTEGER,0);
116 if (ret->version->data != NULL)
117 ver=ret->version->data[0];
118 }
119 else
120 {
121 if (ret->version != NULL)
122 {
123 ASN1_INTEGER_free(ret->version);
124 ret->version=NULL;
125 }
126 }
127 M_ASN1_D2I_get(ret->serialNumber,d2i_ASN1_INTEGER);
128 M_ASN1_D2I_get(ret->signature,d2i_X509_ALGOR);
129 M_ASN1_D2I_get(ret->issuer,d2i_X509_NAME);
130 M_ASN1_D2I_get(ret->validity,d2i_X509_VAL);
131 M_ASN1_D2I_get(ret->subject,d2i_X509_NAME);
132 M_ASN1_D2I_get(ret->key,d2i_X509_PUBKEY);
133 if (ver >= 1) /* version 2 extensions */
134 {
135 if (ret->issuerUID != NULL)
136 {
137 ASN1_BIT_STRING_free(ret->issuerUID);
138 ret->issuerUID=NULL;
139 }
140 if (ret->subjectUID != NULL)
141 {
142 ASN1_BIT_STRING_free(ret->subjectUID);
143 ret->issuerUID=NULL;
144 }
145 M_ASN1_D2I_get_IMP_opt(ret->issuerUID,d2i_ASN1_BIT_STRING, 1,
146 V_ASN1_BIT_STRING);
147 M_ASN1_D2I_get_IMP_opt(ret->subjectUID,d2i_ASN1_BIT_STRING, 2,
148 V_ASN1_BIT_STRING);
149 }
150 if (ver >= 2) /* version 3 extensions */
151 {
152 if (ret->extensions != NULL)
153 while (sk_num(ret->extensions))
154 X509_EXTENSION_free((X509_EXTENSION *)
155 sk_pop(ret->extensions));
156 M_ASN1_D2I_get_EXP_set_opt(ret->extensions,d2i_X509_EXTENSION,3,
157 V_ASN1_SEQUENCE);
158 }
159 M_ASN1_D2I_Finish(a,X509_CINF_free,ASN1_F_D2I_X509_CINF);
160 }
161
162X509_CINF *X509_CINF_new()
163 {
164 X509_CINF *ret=NULL;
165
166 M_ASN1_New_Malloc(ret,X509_CINF);
167 ret->version=NULL;
168 M_ASN1_New(ret->serialNumber,ASN1_INTEGER_new);
169 M_ASN1_New(ret->signature,X509_ALGOR_new);
170 M_ASN1_New(ret->issuer,X509_NAME_new);
171 M_ASN1_New(ret->validity,X509_VAL_new);
172 M_ASN1_New(ret->subject,X509_NAME_new);
173 M_ASN1_New(ret->key,X509_PUBKEY_new);
174 ret->issuerUID=NULL;
175 ret->subjectUID=NULL;
176 ret->extensions=NULL;
177 return(ret);
178 M_ASN1_New_Error(ASN1_F_X509_CINF_NEW);
179 }
180
181void X509_CINF_free(a)
182X509_CINF *a;
183 {
184 if (a == NULL) return;
185 ASN1_INTEGER_free(a->version);
186 ASN1_INTEGER_free(a->serialNumber);
187 X509_ALGOR_free(a->signature);
188 X509_NAME_free(a->issuer);
189 X509_VAL_free(a->validity);
190 X509_NAME_free(a->subject);
191 X509_PUBKEY_free(a->key);
192 ASN1_BIT_STRING_free(a->issuerUID);
193 ASN1_BIT_STRING_free(a->subjectUID);
194 sk_pop_free(a->extensions,X509_EXTENSION_free);
195 Free((char *)a);
196 }
197
diff --git a/src/lib/libssl/src/crypto/bf/Makefile.ssl b/src/lib/libssl/src/crypto/bf/Makefile.ssl
new file mode 100644
index 0000000000..236671f238
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bf/Makefile.ssl
@@ -0,0 +1,107 @@
1#
2# SSLeay/crypto/blowfish/Makefile
3#
4
5DIR= bf
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17BF_ENC= bf_enc.o
18# or use
19#DES_ENC= bx86-elf.o
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL=Makefile
24TEST=bftest.c
25APPS=
26
27LIB=$(TOP)/libcrypto.a
28LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c
29LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= blowfish.h
34HEADER= bf_pi.h bf_locl.h $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: lib
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 sh $(TOP)/util/ranlib.sh $(LIB)
46 @touch lib
47
48# elf
49asm/bx86-elf.o: asm/bx86unix.cpp
50 $(CPP) -DELF asm/bx86unix.cpp | as -o asm/bx86-elf.o
51
52# solaris
53asm/bx86-sol.o: asm/bx86unix.cpp
54 $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
55 as -o asm/bx86-sol.o asm/bx86-sol.s
56 rm -f asm/bx86-sol.s
57
58# a.out
59asm/bx86-out.o: asm/bx86unix.cpp
60 $(CPP) -DOUT asm/bx86unix.cpp | as -o asm/bx86-out.o
61
62# bsdi
63asm/bx86bsdi.o: asm/bx86unix.cpp
64 $(CPP) -DBSDI asm/bx86unix.cpp | as -o asm/bx86bsdi.o
65
66asm/bx86unix.cpp:
67 (cd asm; perl bf-586.pl cpp >bx86unix.cpp)
68
69files:
70 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
71
72links:
73 /bin/rm -f Makefile
74 $(TOP)/util/point.sh Makefile.ssl Makefile ;
75 $(TOP)/util/point.sh ../../doc/blowfish.doc blowfish.doc ;
76 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
77 $(TOP)/util/mklink.sh ../../test $(TEST)
78 $(TOP)/util/mklink.sh ../../apps $(APPS)
79
80install:
81 @for i in $(EXHEADER) ; \
82 do \
83 (cp $$i $(INSTALLTOP)/include/$$i; \
84 chmod 644 $(INSTALLTOP)/include/$$i ); \
85 done;
86
87tags:
88 ctags $(SRC)
89
90tests:
91
92lint:
93 lint -DLINT $(INCLUDES) $(SRC)>fluff
94
95depend:
96 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
97
98dclean:
99 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
100 mv -f Makefile.new $(MAKEFILE)
101
102clean:
103 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
104
105errors:
106
107# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/bf/Makefile.uni b/src/lib/libssl/src/crypto/bf/Makefile.uni
new file mode 100644
index 0000000000..9ba5b0c854
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bf/Makefile.uni
@@ -0,0 +1,169 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= bf
11TOP= .
12# use BF_PTR2 for intel boxes,
13# BF_PTR for sparc and MIPS/SGI
14# use nothing for Alpha and HP.
15
16# There are 3 possible performance options, experiment :-)
17#OPTS= -DBF_PTR # usr for sparc and MIPS/SGI
18#OPTS= -DBF_PTR2 # use for pentium
19OPTS= # use for pentium pro, Alpha and HP
20
21MAKE=make -f Makefile
22#CC=cc
23#CFLAG= -O
24
25CC=gcc
26#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
27CFLAG= -O3 -fomit-frame-pointer
28
29CFLAGS=$(OPTS) $(CFLAG)
30CPP=$(CC) -E
31AS=as
32
33# Assember version of bf_encrypt().
34BF_ENC=bf_enc.o # normal C version
35#BF_ENC=asm/bx86-elf.o # elf format x86
36#BF_ENC=asm/bx86-out.o # a.out format x86
37#BF_ENC=asm/bx86-sol.o # solaris format x86
38#BF_ENC=asm/bx86bsdi.o # bsdi format x86
39
40LIBDIR=/usr/local/lib
41BINDIR=/usr/local/bin
42INCDIR=/usr/local/include
43MANDIR=/usr/local/man
44MAN1=1
45MAN3=3
46SHELL=/bin/sh
47LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cfb64.o bf_ofb64.o
48LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cfb64.c bf_ofb64.c
49
50GENERAL=Makefile Makefile.ssl Makefile.uni asm bf_locl.org README \
51 COPYRIGHT blowfish.doc INSTALL
52
53TESTING= bftest bfspeed bf_opts
54TESTING_SRC=bftest.c bfspeed.c bf_opts.c
55HEADERS=bf_locl.h blowfish.h bf_pi.h
56
57ALL= $(GENERAL) $(TESTING_SRC) $(LIBSRC) $(HEADERS)
58
59BLIB= libblowfish.a
60
61all: $(BLIB) $(TESTING)
62
63cc:
64 $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
65
66gcc:
67 $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
68
69x86-elf:
70 $(MAKE) BF_ENC='asm/bx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
71
72x86-out:
73 $(MAKE) BF_ENC='asm/bx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
74
75x86-solaris:
76 $(MAKE) BF_ENC='asm/bx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
77
78x86-bsdi:
79 $(MAKE) BF_ENC='asm/bx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
80
81# elf
82asm/bx86-elf.o: asm/bx86unix.cpp
83 $(CPP) -DELF asm/bx86unix.cpp | $(AS) -o asm/bx86-elf.o
84
85# solaris
86asm/bx86-sol.o: asm/bx86unix.cpp
87 $(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
88 as -o asm/bx86-sol.o asm/bx86-sol.s
89 rm -f asm/bx86-sol.s
90
91# a.out
92asm/bx86-out.o: asm/bx86unix.cpp
93 $(CPP) -DOUT asm/bx86unix.cpp | $(AS) -o asm/bx86-out.o
94
95# bsdi
96asm/bx86bsdi.o: asm/bx86unix.cpp
97 $(CPP) -DBSDI asm/bx86unix.cpp | $(AS) -o asm/bx86bsdi.o
98
99asm/bx86unix.cpp:
100 (cd asm; perl bf-586.pl cpp >bx86unix.cpp)
101
102test: all
103 ./bftest
104
105$(BLIB): $(LIBOBJ)
106 /bin/rm -f $(BLIB)
107 ar cr $(BLIB) $(LIBOBJ)
108 -if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \
109 else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \
110 else exit 0; fi; fi
111
112bftest: bftest.o $(BLIB)
113 $(CC) $(CFLAGS) -o bftest bftest.o $(BLIB)
114
115bfspeed: bfspeed.o $(BLIB)
116 $(CC) $(CFLAGS) -o bfspeed bfspeed.o $(BLIB)
117
118bf_opts: bf_opts.o $(BLIB)
119 $(CC) $(CFLAGS) -o bf_opts bf_opts.o $(BLIB)
120
121tags:
122 ctags $(TESTING_SRC) $(LIBBF)
123
124tar:
125 tar chf libbf.tar $(ALL)
126
127shar:
128 shar $(ALL) >libbf.shar
129
130depend:
131 makedepend $(LIBBF) $(TESTING_SRC)
132
133clean:
134 /bin/rm -f *.o tags core $(TESTING) $(BLIB) .nfs* *.old *.bak asm/*.o
135
136dclean:
137 sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
138 mv -f Makefile.new Makefile
139
140# Eric is probably going to choke when he next looks at this --tjh
141install: $(BLIB)
142 if test $(INSTALLTOP); then \
143 echo SSL style install; \
144 cp $(BLIB) $(INSTALLTOP)/lib; \
145 if test -s /bin/ranlib; then \
146 /bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \
147 else \
148 if test -s /usr/bin/ranlib; then \
149 /usr/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \
150 fi; fi; \
151 chmod 644 $(INSTALLTOP)/lib/$(BLIB); \
152 cp blowfish.h $(INSTALLTOP)/include; \
153 chmod 644 $(INSTALLTOP)/include/blowfish.h; \
154 else \
155 echo Standalone install; \
156 cp $(BLIB) $(LIBDIR)/$(BLIB); \
157 if test -s /bin/ranlib; then \
158 /bin/ranlib $(LIBDIR)/$(BLIB); \
159 else \
160 if test -s /usr/bin/ranlib; then \
161 /usr/bin/ranlib $(LIBDIR)/$(BLIB); \
162 fi; \
163 fi; \
164 chmod 644 $(LIBDIR)/$(BLIB); \
165 cp blowfish.h $(INCDIR)/blowfish.h; \
166 chmod 644 $(INCDIR)/blowfish.h; \
167 fi
168
169# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/bf/asm/b-win32.asm b/src/lib/libssl/src/crypto/bf/asm/b-win32.asm
new file mode 100644
index 0000000000..138c99d0aa
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bf/asm/b-win32.asm
@@ -0,0 +1,906 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by bf-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE bf-586.asm
8 .486
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _BF_encrypt
12
13_BF_encrypt PROC NEAR
14 ;
15 push ebp
16 push ebx
17 mov ebx, DWORD PTR 12[esp]
18 mov ebp, DWORD PTR 16[esp]
19 push esi
20 push edi
21 ; Load the 2 words
22 mov edi, DWORD PTR [ebx]
23 mov esi, DWORD PTR 4[ebx]
24 xor eax, eax
25 mov ebx, DWORD PTR [ebp]
26 xor ecx, ecx
27 xor edi, ebx
28 ;
29 ; Round 0
30 mov edx, DWORD PTR 4[ebp]
31 mov ebx, edi
32 xor esi, edx
33 shr ebx, 16
34 mov edx, edi
35 mov al, bh
36 and ebx, 255
37 mov cl, dh
38 and edx, 255
39 mov eax, DWORD PTR 72[eax*4+ebp]
40 mov ebx, DWORD PTR 1096[ebx*4+ebp]
41 add ebx, eax
42 mov eax, DWORD PTR 2120[ecx*4+ebp]
43 xor ebx, eax
44 mov edx, DWORD PTR 3144[edx*4+ebp]
45 add ebx, edx
46 xor eax, eax
47 xor esi, ebx
48 ;
49 ; Round 1
50 mov edx, DWORD PTR 8[ebp]
51 mov ebx, esi
52 xor edi, edx
53 shr ebx, 16
54 mov edx, esi
55 mov al, bh
56 and ebx, 255
57 mov cl, dh
58 and edx, 255
59 mov eax, DWORD PTR 72[eax*4+ebp]
60 mov ebx, DWORD PTR 1096[ebx*4+ebp]
61 add ebx, eax
62 mov eax, DWORD PTR 2120[ecx*4+ebp]
63 xor ebx, eax
64 mov edx, DWORD PTR 3144[edx*4+ebp]
65 add ebx, edx
66 xor eax, eax
67 xor edi, ebx
68 ;
69 ; Round 2
70 mov edx, DWORD PTR 12[ebp]
71 mov ebx, edi
72 xor esi, edx
73 shr ebx, 16
74 mov edx, edi
75 mov al, bh
76 and ebx, 255
77 mov cl, dh
78 and edx, 255
79 mov eax, DWORD PTR 72[eax*4+ebp]
80 mov ebx, DWORD PTR 1096[ebx*4+ebp]
81 add ebx, eax
82 mov eax, DWORD PTR 2120[ecx*4+ebp]
83 xor ebx, eax
84 mov edx, DWORD PTR 3144[edx*4+ebp]
85 add ebx, edx
86 xor eax, eax
87 xor esi, ebx
88 ;
89 ; Round 3
90 mov edx, DWORD PTR 16[ebp]
91 mov ebx, esi
92 xor edi, edx
93 shr ebx, 16
94 mov edx, esi
95 mov al, bh
96 and ebx, 255
97 mov cl, dh
98 and edx, 255
99 mov eax, DWORD PTR 72[eax*4+ebp]
100 mov ebx, DWORD PTR 1096[ebx*4+ebp]
101 add ebx, eax
102 mov eax, DWORD PTR 2120[ecx*4+ebp]
103 xor ebx, eax
104 mov edx, DWORD PTR 3144[edx*4+ebp]
105 add ebx, edx
106 xor eax, eax
107 xor edi, ebx
108 ;
109 ; Round 4
110 mov edx, DWORD PTR 20[ebp]
111 mov ebx, edi
112 xor esi, edx
113 shr ebx, 16
114 mov edx, edi
115 mov al, bh
116 and ebx, 255
117 mov cl, dh
118 and edx, 255
119 mov eax, DWORD PTR 72[eax*4+ebp]
120 mov ebx, DWORD PTR 1096[ebx*4+ebp]
121 add ebx, eax
122 mov eax, DWORD PTR 2120[ecx*4+ebp]
123 xor ebx, eax
124 mov edx, DWORD PTR 3144[edx*4+ebp]
125 add ebx, edx
126 xor eax, eax
127 xor esi, ebx
128 ;
129 ; Round 5
130 mov edx, DWORD PTR 24[ebp]
131 mov ebx, esi
132 xor edi, edx
133 shr ebx, 16
134 mov edx, esi
135 mov al, bh
136 and ebx, 255
137 mov cl, dh
138 and edx, 255
139 mov eax, DWORD PTR 72[eax*4+ebp]
140 mov ebx, DWORD PTR 1096[ebx*4+ebp]
141 add ebx, eax
142 mov eax, DWORD PTR 2120[ecx*4+ebp]
143 xor ebx, eax
144 mov edx, DWORD PTR 3144[edx*4+ebp]
145 add ebx, edx
146 xor eax, eax
147 xor edi, ebx
148 ;
149 ; Round 6
150 mov edx, DWORD PTR 28[ebp]
151 mov ebx, edi
152 xor esi, edx
153 shr ebx, 16
154 mov edx, edi
155 mov al, bh
156 and ebx, 255
157 mov cl, dh
158 and edx, 255
159 mov eax, DWORD PTR 72[eax*4+ebp]
160 mov ebx, DWORD PTR 1096[ebx*4+ebp]
161 add ebx, eax
162 mov eax, DWORD PTR 2120[ecx*4+ebp]
163 xor ebx, eax
164 mov edx, DWORD PTR 3144[edx*4+ebp]
165 add ebx, edx
166 xor eax, eax
167 xor esi, ebx
168 ;
169 ; Round 7
170 mov edx, DWORD PTR 32[ebp]
171 mov ebx, esi
172 xor edi, edx
173 shr ebx, 16
174 mov edx, esi
175 mov al, bh
176 and ebx, 255
177 mov cl, dh
178 and edx, 255
179 mov eax, DWORD PTR 72[eax*4+ebp]
180 mov ebx, DWORD PTR 1096[ebx*4+ebp]
181 add ebx, eax
182 mov eax, DWORD PTR 2120[ecx*4+ebp]
183 xor ebx, eax
184 mov edx, DWORD PTR 3144[edx*4+ebp]
185 add ebx, edx
186 xor eax, eax
187 xor edi, ebx
188 ;
189 ; Round 8
190 mov edx, DWORD PTR 36[ebp]
191 mov ebx, edi
192 xor esi, edx
193 shr ebx, 16
194 mov edx, edi
195 mov al, bh
196 and ebx, 255
197 mov cl, dh
198 and edx, 255
199 mov eax, DWORD PTR 72[eax*4+ebp]
200 mov ebx, DWORD PTR 1096[ebx*4+ebp]
201 add ebx, eax
202 mov eax, DWORD PTR 2120[ecx*4+ebp]
203 xor ebx, eax
204 mov edx, DWORD PTR 3144[edx*4+ebp]
205 add ebx, edx
206 xor eax, eax
207 xor esi, ebx
208 ;
209 ; Round 9
210 mov edx, DWORD PTR 40[ebp]
211 mov ebx, esi
212 xor edi, edx
213 shr ebx, 16
214 mov edx, esi
215 mov al, bh
216 and ebx, 255
217 mov cl, dh
218 and edx, 255
219 mov eax, DWORD PTR 72[eax*4+ebp]
220 mov ebx, DWORD PTR 1096[ebx*4+ebp]
221 add ebx, eax
222 mov eax, DWORD PTR 2120[ecx*4+ebp]
223 xor ebx, eax
224 mov edx, DWORD PTR 3144[edx*4+ebp]
225 add ebx, edx
226 xor eax, eax
227 xor edi, ebx
228 ;
229 ; Round 10
230 mov edx, DWORD PTR 44[ebp]
231 mov ebx, edi
232 xor esi, edx
233 shr ebx, 16
234 mov edx, edi
235 mov al, bh
236 and ebx, 255
237 mov cl, dh
238 and edx, 255
239 mov eax, DWORD PTR 72[eax*4+ebp]
240 mov ebx, DWORD PTR 1096[ebx*4+ebp]
241 add ebx, eax
242 mov eax, DWORD PTR 2120[ecx*4+ebp]
243 xor ebx, eax
244 mov edx, DWORD PTR 3144[edx*4+ebp]
245 add ebx, edx
246 xor eax, eax
247 xor esi, ebx
248 ;
249 ; Round 11
250 mov edx, DWORD PTR 48[ebp]
251 mov ebx, esi
252 xor edi, edx
253 shr ebx, 16
254 mov edx, esi
255 mov al, bh
256 and ebx, 255
257 mov cl, dh
258 and edx, 255
259 mov eax, DWORD PTR 72[eax*4+ebp]
260 mov ebx, DWORD PTR 1096[ebx*4+ebp]
261 add ebx, eax
262 mov eax, DWORD PTR 2120[ecx*4+ebp]
263 xor ebx, eax
264 mov edx, DWORD PTR 3144[edx*4+ebp]
265 add ebx, edx
266 xor eax, eax
267 xor edi, ebx
268 ;
269 ; Round 12
270 mov edx, DWORD PTR 52[ebp]
271 mov ebx, edi
272 xor esi, edx
273 shr ebx, 16
274 mov edx, edi
275 mov al, bh
276 and ebx, 255
277 mov cl, dh
278 and edx, 255
279 mov eax, DWORD PTR 72[eax*4+ebp]
280 mov ebx, DWORD PTR 1096[ebx*4+ebp]
281 add ebx, eax
282 mov eax, DWORD PTR 2120[ecx*4+ebp]
283 xor ebx, eax
284 mov edx, DWORD PTR 3144[edx*4+ebp]
285 add ebx, edx
286 xor eax, eax
287 xor esi, ebx
288 ;
289 ; Round 13
290 mov edx, DWORD PTR 56[ebp]
291 mov ebx, esi
292 xor edi, edx
293 shr ebx, 16
294 mov edx, esi
295 mov al, bh
296 and ebx, 255
297 mov cl, dh
298 and edx, 255
299 mov eax, DWORD PTR 72[eax*4+ebp]
300 mov ebx, DWORD PTR 1096[ebx*4+ebp]
301 add ebx, eax
302 mov eax, DWORD PTR 2120[ecx*4+ebp]
303 xor ebx, eax
304 mov edx, DWORD PTR 3144[edx*4+ebp]
305 add ebx, edx
306 xor eax, eax
307 xor edi, ebx
308 ;
309 ; Round 14
310 mov edx, DWORD PTR 60[ebp]
311 mov ebx, edi
312 xor esi, edx
313 shr ebx, 16
314 mov edx, edi
315 mov al, bh
316 and ebx, 255
317 mov cl, dh
318 and edx, 255
319 mov eax, DWORD PTR 72[eax*4+ebp]
320 mov ebx, DWORD PTR 1096[ebx*4+ebp]
321 add ebx, eax
322 mov eax, DWORD PTR 2120[ecx*4+ebp]
323 xor ebx, eax
324 mov edx, DWORD PTR 3144[edx*4+ebp]
325 add ebx, edx
326 xor eax, eax
327 xor esi, ebx
328 ;
329 ; Round 15
330 mov edx, DWORD PTR 64[ebp]
331 mov ebx, esi
332 xor edi, edx
333 shr ebx, 16
334 mov edx, esi
335 mov al, bh
336 and ebx, 255
337 mov cl, dh
338 and edx, 255
339 mov eax, DWORD PTR 72[eax*4+ebp]
340 mov ebx, DWORD PTR 1096[ebx*4+ebp]
341 add ebx, eax
342 mov eax, DWORD PTR 2120[ecx*4+ebp]
343 xor ebx, eax
344 mov edx, DWORD PTR 3144[edx*4+ebp]
345 add ebx, edx
346 ; Load parameter 0 (16) enc=1
347 mov eax, DWORD PTR 20[esp]
348 xor edi, ebx
349 mov edx, DWORD PTR 68[ebp]
350 xor esi, edx
351 mov DWORD PTR 4[eax],edi
352 mov DWORD PTR [eax],esi
353 pop edi
354 pop esi
355 pop ebx
356 pop ebp
357 ret
358_BF_encrypt ENDP
359_TEXT ENDS
360_TEXT SEGMENT
361PUBLIC _BF_decrypt
362
363_BF_decrypt PROC NEAR
364 ;
365 push ebp
366 push ebx
367 mov ebx, DWORD PTR 12[esp]
368 mov ebp, DWORD PTR 16[esp]
369 push esi
370 push edi
371 ; Load the 2 words
372 mov edi, DWORD PTR [ebx]
373 mov esi, DWORD PTR 4[ebx]
374 xor eax, eax
375 mov ebx, DWORD PTR 68[ebp]
376 xor ecx, ecx
377 xor edi, ebx
378 ;
379 ; Round 16
380 mov edx, DWORD PTR 64[ebp]
381 mov ebx, edi
382 xor esi, edx
383 shr ebx, 16
384 mov edx, edi
385 mov al, bh
386 and ebx, 255
387 mov cl, dh
388 and edx, 255
389 mov eax, DWORD PTR 72[eax*4+ebp]
390 mov ebx, DWORD PTR 1096[ebx*4+ebp]
391 add ebx, eax
392 mov eax, DWORD PTR 2120[ecx*4+ebp]
393 xor ebx, eax
394 mov edx, DWORD PTR 3144[edx*4+ebp]
395 add ebx, edx
396 xor eax, eax
397 xor esi, ebx
398 ;
399 ; Round 15
400 mov edx, DWORD PTR 60[ebp]
401 mov ebx, esi
402 xor edi, edx
403 shr ebx, 16
404 mov edx, esi
405 mov al, bh
406 and ebx, 255
407 mov cl, dh
408 and edx, 255
409 mov eax, DWORD PTR 72[eax*4+ebp]
410 mov ebx, DWORD PTR 1096[ebx*4+ebp]
411 add ebx, eax
412 mov eax, DWORD PTR 2120[ecx*4+ebp]
413 xor ebx, eax
414 mov edx, DWORD PTR 3144[edx*4+ebp]
415 add ebx, edx
416 xor eax, eax
417 xor edi, ebx
418 ;
419 ; Round 14
420 mov edx, DWORD PTR 56[ebp]
421 mov ebx, edi
422 xor esi, edx
423 shr ebx, 16
424 mov edx, edi
425 mov al, bh
426 and ebx, 255
427 mov cl, dh
428 and edx, 255
429 mov eax, DWORD PTR 72[eax*4+ebp]
430 mov ebx, DWORD PTR 1096[ebx*4+ebp]
431 add ebx, eax
432 mov eax, DWORD PTR 2120[ecx*4+ebp]
433 xor ebx, eax
434 mov edx, DWORD PTR 3144[edx*4+ebp]
435 add ebx, edx
436 xor eax, eax
437 xor esi, ebx
438 ;
439 ; Round 13
440 mov edx, DWORD PTR 52[ebp]
441 mov ebx, esi
442 xor edi, edx
443 shr ebx, 16
444 mov edx, esi
445 mov al, bh
446 and ebx, 255
447 mov cl, dh
448 and edx, 255
449 mov eax, DWORD PTR 72[eax*4+ebp]
450 mov ebx, DWORD PTR 1096[ebx*4+ebp]
451 add ebx, eax
452 mov eax, DWORD PTR 2120[ecx*4+ebp]
453 xor ebx, eax
454 mov edx, DWORD PTR 3144[edx*4+ebp]
455 add ebx, edx
456 xor eax, eax
457 xor edi, ebx
458 ;
459 ; Round 12
460 mov edx, DWORD PTR 48[ebp]
461 mov ebx, edi
462 xor esi, edx
463 shr ebx, 16
464 mov edx, edi
465 mov al, bh
466 and ebx, 255
467 mov cl, dh
468 and edx, 255
469 mov eax, DWORD PTR 72[eax*4+ebp]
470 mov ebx, DWORD PTR 1096[ebx*4+ebp]
471 add ebx, eax
472 mov eax, DWORD PTR 2120[ecx*4+ebp]
473 xor ebx, eax
474 mov edx, DWORD PTR 3144[edx*4+ebp]
475 add ebx, edx
476 xor eax, eax
477 xor esi, ebx
478 ;
479 ; Round 11
480 mov edx, DWORD PTR 44[ebp]
481 mov ebx, esi
482 xor edi, edx
483 shr ebx, 16
484 mov edx, esi
485 mov al, bh
486 and ebx, 255
487 mov cl, dh
488 and edx, 255
489 mov eax, DWORD PTR 72[eax*4+ebp]
490 mov ebx, DWORD PTR 1096[ebx*4+ebp]
491 add ebx, eax
492 mov eax, DWORD PTR 2120[ecx*4+ebp]
493 xor ebx, eax
494 mov edx, DWORD PTR 3144[edx*4+ebp]
495 add ebx, edx
496 xor eax, eax
497 xor edi, ebx
498 ;
499 ; Round 10
500 mov edx, DWORD PTR 40[ebp]
501 mov ebx, edi
502 xor esi, edx
503 shr ebx, 16
504 mov edx, edi
505 mov al, bh
506 and ebx, 255
507 mov cl, dh
508 and edx, 255
509 mov eax, DWORD PTR 72[eax*4+ebp]
510 mov ebx, DWORD PTR 1096[ebx*4+ebp]
511 add ebx, eax
512 mov eax, DWORD PTR 2120[ecx*4+ebp]
513 xor ebx, eax
514 mov edx, DWORD PTR 3144[edx*4+ebp]
515 add ebx, edx
516 xor eax, eax
517 xor esi, ebx
518 ;
519 ; Round 9
520 mov edx, DWORD PTR 36[ebp]
521 mov ebx, esi
522 xor edi, edx
523 shr ebx, 16
524 mov edx, esi
525 mov al, bh
526 and ebx, 255
527 mov cl, dh
528 and edx, 255
529 mov eax, DWORD PTR 72[eax*4+ebp]
530 mov ebx, DWORD PTR 1096[ebx*4+ebp]
531 add ebx, eax
532 mov eax, DWORD PTR 2120[ecx*4+ebp]
533 xor ebx, eax
534 mov edx, DWORD PTR 3144[edx*4+ebp]
535 add ebx, edx
536 xor eax, eax
537 xor edi, ebx
538 ;
539 ; Round 8
540 mov edx, DWORD PTR 32[ebp]
541 mov ebx, edi
542 xor esi, edx
543 shr ebx, 16
544 mov edx, edi
545 mov al, bh
546 and ebx, 255
547 mov cl, dh
548 and edx, 255
549 mov eax, DWORD PTR 72[eax*4+ebp]
550 mov ebx, DWORD PTR 1096[ebx*4+ebp]
551 add ebx, eax
552 mov eax, DWORD PTR 2120[ecx*4+ebp]
553 xor ebx, eax
554 mov edx, DWORD PTR 3144[edx*4+ebp]
555 add ebx, edx
556 xor eax, eax
557 xor esi, ebx
558 ;
559 ; Round 7
560 mov edx, DWORD PTR 28[ebp]
561 mov ebx, esi
562 xor edi, edx
563 shr ebx, 16
564 mov edx, esi
565 mov al, bh
566 and ebx, 255
567 mov cl, dh
568 and edx, 255
569 mov eax, DWORD PTR 72[eax*4+ebp]
570 mov ebx, DWORD PTR 1096[ebx*4+ebp]
571 add ebx, eax
572 mov eax, DWORD PTR 2120[ecx*4+ebp]
573 xor ebx, eax
574 mov edx, DWORD PTR 3144[edx*4+ebp]
575 add ebx, edx
576 xor eax, eax
577 xor edi, ebx
578 ;
579 ; Round 6
580 mov edx, DWORD PTR 24[ebp]
581 mov ebx, edi
582 xor esi, edx
583 shr ebx, 16
584 mov edx, edi
585 mov al, bh
586 and ebx, 255
587 mov cl, dh
588 and edx, 255
589 mov eax, DWORD PTR 72[eax*4+ebp]
590 mov ebx, DWORD PTR 1096[ebx*4+ebp]
591 add ebx, eax
592 mov eax, DWORD PTR 2120[ecx*4+ebp]
593 xor ebx, eax
594 mov edx, DWORD PTR 3144[edx*4+ebp]
595 add ebx, edx
596 xor eax, eax
597 xor esi, ebx
598 ;
599 ; Round 5
600 mov edx, DWORD PTR 20[ebp]
601 mov ebx, esi
602 xor edi, edx
603 shr ebx, 16
604 mov edx, esi
605 mov al, bh
606 and ebx, 255
607 mov cl, dh
608 and edx, 255
609 mov eax, DWORD PTR 72[eax*4+ebp]
610 mov ebx, DWORD PTR 1096[ebx*4+ebp]
611 add ebx, eax
612 mov eax, DWORD PTR 2120[ecx*4+ebp]
613 xor ebx, eax
614 mov edx, DWORD PTR 3144[edx*4+ebp]
615 add ebx, edx
616 xor eax, eax
617 xor edi, ebx
618 ;
619 ; Round 4
620 mov edx, DWORD PTR 16[ebp]
621 mov ebx, edi
622 xor esi, edx
623 shr ebx, 16
624 mov edx, edi
625 mov al, bh
626 and ebx, 255
627 mov cl, dh
628 and edx, 255
629 mov eax, DWORD PTR 72[eax*4+ebp]
630 mov ebx, DWORD PTR 1096[ebx*4+ebp]
631 add ebx, eax
632 mov eax, DWORD PTR 2120[ecx*4+ebp]
633 xor ebx, eax
634 mov edx, DWORD PTR 3144[edx*4+ebp]
635 add ebx, edx
636 xor eax, eax
637 xor esi, ebx
638 ;
639 ; Round 3
640 mov edx, DWORD PTR 12[ebp]
641 mov ebx, esi
642 xor edi, edx
643 shr ebx, 16
644 mov edx, esi
645 mov al, bh
646 and ebx, 255
647 mov cl, dh
648 and edx, 255
649 mov eax, DWORD PTR 72[eax*4+ebp]
650 mov ebx, DWORD PTR 1096[ebx*4+ebp]
651 add ebx, eax
652 mov eax, DWORD PTR 2120[ecx*4+ebp]
653 xor ebx, eax
654 mov edx, DWORD PTR 3144[edx*4+ebp]
655 add ebx, edx
656 xor eax, eax
657 xor edi, ebx
658 ;
659 ; Round 2
660 mov edx, DWORD PTR 8[ebp]
661 mov ebx, edi
662 xor esi, edx
663 shr ebx, 16
664 mov edx, edi
665 mov al, bh
666 and ebx, 255
667 mov cl, dh
668 and edx, 255
669 mov eax, DWORD PTR 72[eax*4+ebp]
670 mov ebx, DWORD PTR 1096[ebx*4+ebp]
671 add ebx, eax
672 mov eax, DWORD PTR 2120[ecx*4+ebp]
673 xor ebx, eax
674 mov edx, DWORD PTR 3144[edx*4+ebp]
675 add ebx, edx
676 xor eax, eax
677 xor esi, ebx
678 ;
679 ; Round 1
680 mov edx, DWORD PTR 4[ebp]
681 mov ebx, esi
682 xor edi, edx
683 shr ebx, 16
684 mov edx, esi
685 mov al, bh
686 and ebx, 255
687 mov cl, dh
688 and edx, 255
689 mov eax, DWORD PTR 72[eax*4+ebp]
690 mov ebx, DWORD PTR 1096[ebx*4+ebp]
691 add ebx, eax
692 mov eax, DWORD PTR 2120[ecx*4+ebp]
693 xor ebx, eax
694 mov edx, DWORD PTR 3144[edx*4+ebp]
695 add ebx, edx
696 ; Load parameter 0 (1) enc=0
697 mov eax, DWORD PTR 20[esp]
698 xor edi, ebx
699 mov edx, DWORD PTR [ebp]
700 xor esi, edx
701 mov DWORD PTR 4[eax],edi
702 mov DWORD PTR [eax],esi
703 pop edi
704 pop esi
705 pop ebx
706 pop ebp
707 ret
708_BF_decrypt ENDP
709_TEXT ENDS
710_TEXT SEGMENT
711PUBLIC _BF_cbc_encrypt
712
713_BF_cbc_encrypt PROC NEAR
714 ;
715 push ebp
716 push ebx
717 push esi
718 push edi
719 mov ebp, DWORD PTR 28[esp]
720 ; getting iv ptr from parameter 4
721 mov ebx, DWORD PTR 36[esp]
722 mov esi, DWORD PTR [ebx]
723 mov edi, DWORD PTR 4[ebx]
724 push edi
725 push esi
726 push edi
727 push esi
728 mov ebx, esp
729 mov esi, DWORD PTR 36[esp]
730 mov edi, DWORD PTR 40[esp]
731 ; getting encrypt flag from parameter 5
732 mov ecx, DWORD PTR 56[esp]
733 ; get and push parameter 3
734 mov eax, DWORD PTR 48[esp]
735 push eax
736 push ebx
737 cmp ecx, 0
738 jz $L000decrypt
739 and ebp, 4294967288
740 mov eax, DWORD PTR 8[esp]
741 mov ebx, DWORD PTR 12[esp]
742 jz $L001encrypt_finish
743L002encrypt_loop:
744 mov ecx, DWORD PTR [esi]
745 mov edx, DWORD PTR 4[esi]
746 xor eax, ecx
747 xor ebx, edx
748 bswap eax
749 bswap ebx
750 mov DWORD PTR 8[esp],eax
751 mov DWORD PTR 12[esp],ebx
752 call _BF_encrypt
753 mov eax, DWORD PTR 8[esp]
754 mov ebx, DWORD PTR 12[esp]
755 bswap eax
756 bswap ebx
757 mov DWORD PTR [edi],eax
758 mov DWORD PTR 4[edi],ebx
759 add esi, 8
760 add edi, 8
761 sub ebp, 8
762 jnz L002encrypt_loop
763$L001encrypt_finish:
764 mov ebp, DWORD PTR 52[esp]
765 and ebp, 7
766 jz $L003finish
767 xor ecx, ecx
768 xor edx, edx
769 mov ebp, DWORD PTR $L004cbc_enc_jmp_table[ebp*4]
770 jmp ebp
771L005ej7:
772 mov dh, BYTE PTR 6[esi]
773 shl edx, 8
774L006ej6:
775 mov dh, BYTE PTR 5[esi]
776L007ej5:
777 mov dl, BYTE PTR 4[esi]
778L008ej4:
779 mov ecx, DWORD PTR [esi]
780 jmp $L009ejend
781L010ej3:
782 mov ch, BYTE PTR 2[esi]
783 shl ecx, 8
784L011ej2:
785 mov ch, BYTE PTR 1[esi]
786L012ej1:
787 mov cl, BYTE PTR [esi]
788$L009ejend:
789 xor eax, ecx
790 xor ebx, edx
791 bswap eax
792 bswap ebx
793 mov DWORD PTR 8[esp],eax
794 mov DWORD PTR 12[esp],ebx
795 call _BF_encrypt
796 mov eax, DWORD PTR 8[esp]
797 mov ebx, DWORD PTR 12[esp]
798 bswap eax
799 bswap ebx
800 mov DWORD PTR [edi],eax
801 mov DWORD PTR 4[edi],ebx
802 jmp $L003finish
803$L000decrypt:
804 and ebp, 4294967288
805 mov eax, DWORD PTR 16[esp]
806 mov ebx, DWORD PTR 20[esp]
807 jz $L013decrypt_finish
808L014decrypt_loop:
809 mov eax, DWORD PTR [esi]
810 mov ebx, DWORD PTR 4[esi]
811 bswap eax
812 bswap ebx
813 mov DWORD PTR 8[esp],eax
814 mov DWORD PTR 12[esp],ebx
815 call _BF_decrypt
816 mov eax, DWORD PTR 8[esp]
817 mov ebx, DWORD PTR 12[esp]
818 bswap eax
819 bswap ebx
820 mov ecx, DWORD PTR 16[esp]
821 mov edx, DWORD PTR 20[esp]
822 xor ecx, eax
823 xor edx, ebx
824 mov eax, DWORD PTR [esi]
825 mov ebx, DWORD PTR 4[esi]
826 mov DWORD PTR [edi],ecx
827 mov DWORD PTR 4[edi],edx
828 mov DWORD PTR 16[esp],eax
829 mov DWORD PTR 20[esp],ebx
830 add esi, 8
831 add edi, 8
832 sub ebp, 8
833 jnz L014decrypt_loop
834$L013decrypt_finish:
835 mov ebp, DWORD PTR 52[esp]
836 and ebp, 7
837 jz $L003finish
838 mov eax, DWORD PTR [esi]
839 mov ebx, DWORD PTR 4[esi]
840 bswap eax
841 bswap ebx
842 mov DWORD PTR 8[esp],eax
843 mov DWORD PTR 12[esp],ebx
844 call _BF_decrypt
845 mov eax, DWORD PTR 8[esp]
846 mov ebx, DWORD PTR 12[esp]
847 bswap eax
848 bswap ebx
849 mov ecx, DWORD PTR 16[esp]
850 mov edx, DWORD PTR 20[esp]
851 xor ecx, eax
852 xor edx, ebx
853 mov eax, DWORD PTR [esi]
854 mov ebx, DWORD PTR 4[esi]
855L015dj7:
856 ror edx, 16
857 mov BYTE PTR 6[edi],dl
858 shr edx, 16
859L016dj6:
860 mov BYTE PTR 5[edi],dh
861L017dj5:
862 mov BYTE PTR 4[edi],dl
863L018dj4:
864 mov DWORD PTR [edi],ecx
865 jmp $L019djend
866L020dj3:
867 ror ecx, 16
868 mov BYTE PTR 2[edi],cl
869 shl ecx, 16
870L021dj2:
871 mov BYTE PTR 1[esi],ch
872L022dj1:
873 mov BYTE PTR [esi], cl
874$L019djend:
875 jmp $L003finish
876$L003finish:
877 mov ecx, DWORD PTR 60[esp]
878 add esp, 24
879 mov DWORD PTR [ecx],eax
880 mov DWORD PTR 4[ecx],ebx
881 pop edi
882 pop esi
883 pop ebx
884 pop ebp
885 ret
886$L004cbc_enc_jmp_table:
887 DD 0
888 DD L012ej1
889 DD L011ej2
890 DD L010ej3
891 DD L008ej4
892 DD L007ej5
893 DD L006ej6
894 DD L005ej7
895L023cbc_dec_jmp_table:
896 DD 0
897 DD L022dj1
898 DD L021dj2
899 DD L020dj3
900 DD L018dj4
901 DD L017dj5
902 DD L016dj6
903 DD L015dj7
904_BF_cbc_encrypt ENDP
905_TEXT ENDS
906END
diff --git a/src/lib/libssl/src/crypto/bf/asm/bx86unix.cpp b/src/lib/libssl/src/crypto/bf/asm/bx86unix.cpp
new file mode 100644
index 0000000000..cdaa269378
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bf/asm/bx86unix.cpp
@@ -0,0 +1,976 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define BF_encrypt _BF_encrypt
13#define BF_decrypt _BF_decrypt
14#define BF_cbc_encrypt _BF_cbc_encrypt
15
16#endif
17
18#ifdef OUT
19#define OK 1
20#define ALIGN 4
21#endif
22
23#ifdef BSDI
24#define OK 1
25#define ALIGN 4
26#undef SIZE
27#undef TYPE
28#define SIZE(a,b)
29#define TYPE(a,b)
30#endif
31
32#if defined(ELF) || defined(SOL)
33#define OK 1
34#define ALIGN 16
35#endif
36
37#ifndef OK
38You need to define one of
39ELF - elf systems - linux-elf, NetBSD and DG-UX
40OUT - a.out systems - linux-a.out and FreeBSD
41SOL - solaris systems, which are elf with strange comment lines
42BSDI - a.out with a very primative version of as.
43#endif
44
45/* Let the Assembler begin :-) */
46 /* Don't even think of reading this code */
47 /* It was automatically generated by bf-586.pl */
48 /* Which is a perl program used to generate the x86 assember for */
49 /* any of elf, a.out, BSDI,Win32, or Solaris */
50 /* eric <eay@cryptsoft.com> */
51
52 .file "bf-586.s"
53 .version "01.01"
54gcc2_compiled.:
55.text
56 .align ALIGN
57.globl BF_encrypt
58 TYPE(BF_encrypt,@function)
59BF_encrypt:
60
61 pushl %ebp
62 pushl %ebx
63 movl 12(%esp), %ebx
64 movl 16(%esp), %ebp
65 pushl %esi
66 pushl %edi
67 /* Load the 2 words */
68 movl (%ebx), %edi
69 movl 4(%ebx), %esi
70 xorl %eax, %eax
71 movl (%ebp), %ebx
72 xorl %ecx, %ecx
73 xorl %ebx, %edi
74
75 /* Round 0 */
76 movl 4(%ebp), %edx
77 movl %edi, %ebx
78 xorl %edx, %esi
79 shrl $16, %ebx
80 movl %edi, %edx
81 movb %bh, %al
82 andl $255, %ebx
83 movb %dh, %cl
84 andl $255, %edx
85 movl 72(%ebp,%eax,4),%eax
86 movl 1096(%ebp,%ebx,4),%ebx
87 addl %eax, %ebx
88 movl 2120(%ebp,%ecx,4),%eax
89 xorl %eax, %ebx
90 movl 3144(%ebp,%edx,4),%edx
91 addl %edx, %ebx
92 xorl %eax, %eax
93 xorl %ebx, %esi
94
95 /* Round 1 */
96 movl 8(%ebp), %edx
97 movl %esi, %ebx
98 xorl %edx, %edi
99 shrl $16, %ebx
100 movl %esi, %edx
101 movb %bh, %al
102 andl $255, %ebx
103 movb %dh, %cl
104 andl $255, %edx
105 movl 72(%ebp,%eax,4),%eax
106 movl 1096(%ebp,%ebx,4),%ebx
107 addl %eax, %ebx
108 movl 2120(%ebp,%ecx,4),%eax
109 xorl %eax, %ebx
110 movl 3144(%ebp,%edx,4),%edx
111 addl %edx, %ebx
112 xorl %eax, %eax
113 xorl %ebx, %edi
114
115 /* Round 2 */
116 movl 12(%ebp), %edx
117 movl %edi, %ebx
118 xorl %edx, %esi
119 shrl $16, %ebx
120 movl %edi, %edx
121 movb %bh, %al
122 andl $255, %ebx
123 movb %dh, %cl
124 andl $255, %edx
125 movl 72(%ebp,%eax,4),%eax
126 movl 1096(%ebp,%ebx,4),%ebx
127 addl %eax, %ebx
128 movl 2120(%ebp,%ecx,4),%eax
129 xorl %eax, %ebx
130 movl 3144(%ebp,%edx,4),%edx
131 addl %edx, %ebx
132 xorl %eax, %eax
133 xorl %ebx, %esi
134
135 /* Round 3 */
136 movl 16(%ebp), %edx
137 movl %esi, %ebx
138 xorl %edx, %edi
139 shrl $16, %ebx
140 movl %esi, %edx
141 movb %bh, %al
142 andl $255, %ebx
143 movb %dh, %cl
144 andl $255, %edx
145 movl 72(%ebp,%eax,4),%eax
146 movl 1096(%ebp,%ebx,4),%ebx
147 addl %eax, %ebx
148 movl 2120(%ebp,%ecx,4),%eax
149 xorl %eax, %ebx
150 movl 3144(%ebp,%edx,4),%edx
151 addl %edx, %ebx
152 xorl %eax, %eax
153 xorl %ebx, %edi
154
155 /* Round 4 */
156 movl 20(%ebp), %edx
157 movl %edi, %ebx
158 xorl %edx, %esi
159 shrl $16, %ebx
160 movl %edi, %edx
161 movb %bh, %al
162 andl $255, %ebx
163 movb %dh, %cl
164 andl $255, %edx
165 movl 72(%ebp,%eax,4),%eax
166 movl 1096(%ebp,%ebx,4),%ebx
167 addl %eax, %ebx
168 movl 2120(%ebp,%ecx,4),%eax
169 xorl %eax, %ebx
170 movl 3144(%ebp,%edx,4),%edx
171 addl %edx, %ebx
172 xorl %eax, %eax
173 xorl %ebx, %esi
174
175 /* Round 5 */
176 movl 24(%ebp), %edx
177 movl %esi, %ebx
178 xorl %edx, %edi
179 shrl $16, %ebx
180 movl %esi, %edx
181 movb %bh, %al
182 andl $255, %ebx
183 movb %dh, %cl
184 andl $255, %edx
185 movl 72(%ebp,%eax,4),%eax
186 movl 1096(%ebp,%ebx,4),%ebx
187 addl %eax, %ebx
188 movl 2120(%ebp,%ecx,4),%eax
189 xorl %eax, %ebx
190 movl 3144(%ebp,%edx,4),%edx
191 addl %edx, %ebx
192 xorl %eax, %eax
193 xorl %ebx, %edi
194
195 /* Round 6 */
196 movl 28(%ebp), %edx
197 movl %edi, %ebx
198 xorl %edx, %esi
199 shrl $16, %ebx
200 movl %edi, %edx
201 movb %bh, %al
202 andl $255, %ebx
203 movb %dh, %cl
204 andl $255, %edx
205 movl 72(%ebp,%eax,4),%eax
206 movl 1096(%ebp,%ebx,4),%ebx
207 addl %eax, %ebx
208 movl 2120(%ebp,%ecx,4),%eax
209 xorl %eax, %ebx
210 movl 3144(%ebp,%edx,4),%edx
211 addl %edx, %ebx
212 xorl %eax, %eax
213 xorl %ebx, %esi
214
215 /* Round 7 */
216 movl 32(%ebp), %edx
217 movl %esi, %ebx
218 xorl %edx, %edi
219 shrl $16, %ebx
220 movl %esi, %edx
221 movb %bh, %al
222 andl $255, %ebx
223 movb %dh, %cl
224 andl $255, %edx
225 movl 72(%ebp,%eax,4),%eax
226 movl 1096(%ebp,%ebx,4),%ebx
227 addl %eax, %ebx
228 movl 2120(%ebp,%ecx,4),%eax
229 xorl %eax, %ebx
230 movl 3144(%ebp,%edx,4),%edx
231 addl %edx, %ebx
232 xorl %eax, %eax
233 xorl %ebx, %edi
234
235 /* Round 8 */
236 movl 36(%ebp), %edx
237 movl %edi, %ebx
238 xorl %edx, %esi
239 shrl $16, %ebx
240 movl %edi, %edx
241 movb %bh, %al
242 andl $255, %ebx
243 movb %dh, %cl
244 andl $255, %edx
245 movl 72(%ebp,%eax,4),%eax
246 movl 1096(%ebp,%ebx,4),%ebx
247 addl %eax, %ebx
248 movl 2120(%ebp,%ecx,4),%eax
249 xorl %eax, %ebx
250 movl 3144(%ebp,%edx,4),%edx
251 addl %edx, %ebx
252 xorl %eax, %eax
253 xorl %ebx, %esi
254
255 /* Round 9 */
256 movl 40(%ebp), %edx
257 movl %esi, %ebx
258 xorl %edx, %edi
259 shrl $16, %ebx
260 movl %esi, %edx
261 movb %bh, %al
262 andl $255, %ebx
263 movb %dh, %cl
264 andl $255, %edx
265 movl 72(%ebp,%eax,4),%eax
266 movl 1096(%ebp,%ebx,4),%ebx
267 addl %eax, %ebx
268 movl 2120(%ebp,%ecx,4),%eax
269 xorl %eax, %ebx
270 movl 3144(%ebp,%edx,4),%edx
271 addl %edx, %ebx
272 xorl %eax, %eax
273 xorl %ebx, %edi
274
275 /* Round 10 */
276 movl 44(%ebp), %edx
277 movl %edi, %ebx
278 xorl %edx, %esi
279 shrl $16, %ebx
280 movl %edi, %edx
281 movb %bh, %al
282 andl $255, %ebx
283 movb %dh, %cl
284 andl $255, %edx
285 movl 72(%ebp,%eax,4),%eax
286 movl 1096(%ebp,%ebx,4),%ebx
287 addl %eax, %ebx
288 movl 2120(%ebp,%ecx,4),%eax
289 xorl %eax, %ebx
290 movl 3144(%ebp,%edx,4),%edx
291 addl %edx, %ebx
292 xorl %eax, %eax
293 xorl %ebx, %esi
294
295 /* Round 11 */
296 movl 48(%ebp), %edx
297 movl %esi, %ebx
298 xorl %edx, %edi
299 shrl $16, %ebx
300 movl %esi, %edx
301 movb %bh, %al
302 andl $255, %ebx
303 movb %dh, %cl
304 andl $255, %edx
305 movl 72(%ebp,%eax,4),%eax
306 movl 1096(%ebp,%ebx,4),%ebx
307 addl %eax, %ebx
308 movl 2120(%ebp,%ecx,4),%eax
309 xorl %eax, %ebx
310 movl 3144(%ebp,%edx,4),%edx
311 addl %edx, %ebx
312 xorl %eax, %eax
313 xorl %ebx, %edi
314
315 /* Round 12 */
316 movl 52(%ebp), %edx
317 movl %edi, %ebx
318 xorl %edx, %esi
319 shrl $16, %ebx
320 movl %edi, %edx
321 movb %bh, %al
322 andl $255, %ebx
323 movb %dh, %cl
324 andl $255, %edx
325 movl 72(%ebp,%eax,4),%eax
326 movl 1096(%ebp,%ebx,4),%ebx
327 addl %eax, %ebx
328 movl 2120(%ebp,%ecx,4),%eax
329 xorl %eax, %ebx
330 movl 3144(%ebp,%edx,4),%edx
331 addl %edx, %ebx
332 xorl %eax, %eax
333 xorl %ebx, %esi
334
335 /* Round 13 */
336 movl 56(%ebp), %edx
337 movl %esi, %ebx
338 xorl %edx, %edi
339 shrl $16, %ebx
340 movl %esi, %edx
341 movb %bh, %al
342 andl $255, %ebx
343 movb %dh, %cl
344 andl $255, %edx
345 movl 72(%ebp,%eax,4),%eax
346 movl 1096(%ebp,%ebx,4),%ebx
347 addl %eax, %ebx
348 movl 2120(%ebp,%ecx,4),%eax
349 xorl %eax, %ebx
350 movl 3144(%ebp,%edx,4),%edx
351 addl %edx, %ebx
352 xorl %eax, %eax
353 xorl %ebx, %edi
354
355 /* Round 14 */
356 movl 60(%ebp), %edx
357 movl %edi, %ebx
358 xorl %edx, %esi
359 shrl $16, %ebx
360 movl %edi, %edx
361 movb %bh, %al
362 andl $255, %ebx
363 movb %dh, %cl
364 andl $255, %edx
365 movl 72(%ebp,%eax,4),%eax
366 movl 1096(%ebp,%ebx,4),%ebx
367 addl %eax, %ebx
368 movl 2120(%ebp,%ecx,4),%eax
369 xorl %eax, %ebx
370 movl 3144(%ebp,%edx,4),%edx
371 addl %edx, %ebx
372 xorl %eax, %eax
373 xorl %ebx, %esi
374
375 /* Round 15 */
376 movl 64(%ebp), %edx
377 movl %esi, %ebx
378 xorl %edx, %edi
379 shrl $16, %ebx
380 movl %esi, %edx
381 movb %bh, %al
382 andl $255, %ebx
383 movb %dh, %cl
384 andl $255, %edx
385 movl 72(%ebp,%eax,4),%eax
386 movl 1096(%ebp,%ebx,4),%ebx
387 addl %eax, %ebx
388 movl 2120(%ebp,%ecx,4),%eax
389 xorl %eax, %ebx
390 movl 3144(%ebp,%edx,4),%edx
391 addl %edx, %ebx
392 /* Load parameter 0 (16) enc=1 */
393 movl 20(%esp), %eax
394 xorl %ebx, %edi
395 movl 68(%ebp), %edx
396 xorl %edx, %esi
397 movl %edi, 4(%eax)
398 movl %esi, (%eax)
399 popl %edi
400 popl %esi
401 popl %ebx
402 popl %ebp
403 ret
404.BF_encrypt_end:
405 SIZE(BF_encrypt,.BF_encrypt_end-BF_encrypt)
406.ident "BF_encrypt"
407.text
408 .align ALIGN
409.globl BF_decrypt
410 TYPE(BF_decrypt,@function)
411BF_decrypt:
412
413 pushl %ebp
414 pushl %ebx
415 movl 12(%esp), %ebx
416 movl 16(%esp), %ebp
417 pushl %esi
418 pushl %edi
419 /* Load the 2 words */
420 movl (%ebx), %edi
421 movl 4(%ebx), %esi
422 xorl %eax, %eax
423 movl 68(%ebp), %ebx
424 xorl %ecx, %ecx
425 xorl %ebx, %edi
426
427 /* Round 16 */
428 movl 64(%ebp), %edx
429 movl %edi, %ebx
430 xorl %edx, %esi
431 shrl $16, %ebx
432 movl %edi, %edx
433 movb %bh, %al
434 andl $255, %ebx
435 movb %dh, %cl
436 andl $255, %edx
437 movl 72(%ebp,%eax,4),%eax
438 movl 1096(%ebp,%ebx,4),%ebx
439 addl %eax, %ebx
440 movl 2120(%ebp,%ecx,4),%eax
441 xorl %eax, %ebx
442 movl 3144(%ebp,%edx,4),%edx
443 addl %edx, %ebx
444 xorl %eax, %eax
445 xorl %ebx, %esi
446
447 /* Round 15 */
448 movl 60(%ebp), %edx
449 movl %esi, %ebx
450 xorl %edx, %edi
451 shrl $16, %ebx
452 movl %esi, %edx
453 movb %bh, %al
454 andl $255, %ebx
455 movb %dh, %cl
456 andl $255, %edx
457 movl 72(%ebp,%eax,4),%eax
458 movl 1096(%ebp,%ebx,4),%ebx
459 addl %eax, %ebx
460 movl 2120(%ebp,%ecx,4),%eax
461 xorl %eax, %ebx
462 movl 3144(%ebp,%edx,4),%edx
463 addl %edx, %ebx
464 xorl %eax, %eax
465 xorl %ebx, %edi
466
467 /* Round 14 */
468 movl 56(%ebp), %edx
469 movl %edi, %ebx
470 xorl %edx, %esi
471 shrl $16, %ebx
472 movl %edi, %edx
473 movb %bh, %al
474 andl $255, %ebx
475 movb %dh, %cl
476 andl $255, %edx
477 movl 72(%ebp,%eax,4),%eax
478 movl 1096(%ebp,%ebx,4),%ebx
479 addl %eax, %ebx
480 movl 2120(%ebp,%ecx,4),%eax
481 xorl %eax, %ebx
482 movl 3144(%ebp,%edx,4),%edx
483 addl %edx, %ebx
484 xorl %eax, %eax
485 xorl %ebx, %esi
486
487 /* Round 13 */
488 movl 52(%ebp), %edx
489 movl %esi, %ebx
490 xorl %edx, %edi
491 shrl $16, %ebx
492 movl %esi, %edx
493 movb %bh, %al
494 andl $255, %ebx
495 movb %dh, %cl
496 andl $255, %edx
497 movl 72(%ebp,%eax,4),%eax
498 movl 1096(%ebp,%ebx,4),%ebx
499 addl %eax, %ebx
500 movl 2120(%ebp,%ecx,4),%eax
501 xorl %eax, %ebx
502 movl 3144(%ebp,%edx,4),%edx
503 addl %edx, %ebx
504 xorl %eax, %eax
505 xorl %ebx, %edi
506
507 /* Round 12 */
508 movl 48(%ebp), %edx
509 movl %edi, %ebx
510 xorl %edx, %esi
511 shrl $16, %ebx
512 movl %edi, %edx
513 movb %bh, %al
514 andl $255, %ebx
515 movb %dh, %cl
516 andl $255, %edx
517 movl 72(%ebp,%eax,4),%eax
518 movl 1096(%ebp,%ebx,4),%ebx
519 addl %eax, %ebx
520 movl 2120(%ebp,%ecx,4),%eax
521 xorl %eax, %ebx
522 movl 3144(%ebp,%edx,4),%edx
523 addl %edx, %ebx
524 xorl %eax, %eax
525 xorl %ebx, %esi
526
527 /* Round 11 */
528 movl 44(%ebp), %edx
529 movl %esi, %ebx
530 xorl %edx, %edi
531 shrl $16, %ebx
532 movl %esi, %edx
533 movb %bh, %al
534 andl $255, %ebx
535 movb %dh, %cl
536 andl $255, %edx
537 movl 72(%ebp,%eax,4),%eax
538 movl 1096(%ebp,%ebx,4),%ebx
539 addl %eax, %ebx
540 movl 2120(%ebp,%ecx,4),%eax
541 xorl %eax, %ebx
542 movl 3144(%ebp,%edx,4),%edx
543 addl %edx, %ebx
544 xorl %eax, %eax
545 xorl %ebx, %edi
546
547 /* Round 10 */
548 movl 40(%ebp), %edx
549 movl %edi, %ebx
550 xorl %edx, %esi
551 shrl $16, %ebx
552 movl %edi, %edx
553 movb %bh, %al
554 andl $255, %ebx
555 movb %dh, %cl
556 andl $255, %edx
557 movl 72(%ebp,%eax,4),%eax
558 movl 1096(%ebp,%ebx,4),%ebx
559 addl %eax, %ebx
560 movl 2120(%ebp,%ecx,4),%eax
561 xorl %eax, %ebx
562 movl 3144(%ebp,%edx,4),%edx
563 addl %edx, %ebx
564 xorl %eax, %eax
565 xorl %ebx, %esi
566
567 /* Round 9 */
568 movl 36(%ebp), %edx
569 movl %esi, %ebx
570 xorl %edx, %edi
571 shrl $16, %ebx
572 movl %esi, %edx
573 movb %bh, %al
574 andl $255, %ebx
575 movb %dh, %cl
576 andl $255, %edx
577 movl 72(%ebp,%eax,4),%eax
578 movl 1096(%ebp,%ebx,4),%ebx
579 addl %eax, %ebx
580 movl 2120(%ebp,%ecx,4),%eax
581 xorl %eax, %ebx
582 movl 3144(%ebp,%edx,4),%edx
583 addl %edx, %ebx
584 xorl %eax, %eax
585 xorl %ebx, %edi
586
587 /* Round 8 */
588 movl 32(%ebp), %edx
589 movl %edi, %ebx
590 xorl %edx, %esi
591 shrl $16, %ebx
592 movl %edi, %edx
593 movb %bh, %al
594 andl $255, %ebx
595 movb %dh, %cl
596 andl $255, %edx
597 movl 72(%ebp,%eax,4),%eax
598 movl 1096(%ebp,%ebx,4),%ebx
599 addl %eax, %ebx
600 movl 2120(%ebp,%ecx,4),%eax
601 xorl %eax, %ebx
602 movl 3144(%ebp,%edx,4),%edx
603 addl %edx, %ebx
604 xorl %eax, %eax
605 xorl %ebx, %esi
606
607 /* Round 7 */
608 movl 28(%ebp), %edx
609 movl %esi, %ebx
610 xorl %edx, %edi
611 shrl $16, %ebx
612 movl %esi, %edx
613 movb %bh, %al
614 andl $255, %ebx
615 movb %dh, %cl
616 andl $255, %edx
617 movl 72(%ebp,%eax,4),%eax
618 movl 1096(%ebp,%ebx,4),%ebx
619 addl %eax, %ebx
620 movl 2120(%ebp,%ecx,4),%eax
621 xorl %eax, %ebx
622 movl 3144(%ebp,%edx,4),%edx
623 addl %edx, %ebx
624 xorl %eax, %eax
625 xorl %ebx, %edi
626
627 /* Round 6 */
628 movl 24(%ebp), %edx
629 movl %edi, %ebx
630 xorl %edx, %esi
631 shrl $16, %ebx
632 movl %edi, %edx
633 movb %bh, %al
634 andl $255, %ebx
635 movb %dh, %cl
636 andl $255, %edx
637 movl 72(%ebp,%eax,4),%eax
638 movl 1096(%ebp,%ebx,4),%ebx
639 addl %eax, %ebx
640 movl 2120(%ebp,%ecx,4),%eax
641 xorl %eax, %ebx
642 movl 3144(%ebp,%edx,4),%edx
643 addl %edx, %ebx
644 xorl %eax, %eax
645 xorl %ebx, %esi
646
647 /* Round 5 */
648 movl 20(%ebp), %edx
649 movl %esi, %ebx
650 xorl %edx, %edi
651 shrl $16, %ebx
652 movl %esi, %edx
653 movb %bh, %al
654 andl $255, %ebx
655 movb %dh, %cl
656 andl $255, %edx
657 movl 72(%ebp,%eax,4),%eax
658 movl 1096(%ebp,%ebx,4),%ebx
659 addl %eax, %ebx
660 movl 2120(%ebp,%ecx,4),%eax
661 xorl %eax, %ebx
662 movl 3144(%ebp,%edx,4),%edx
663 addl %edx, %ebx
664 xorl %eax, %eax
665 xorl %ebx, %edi
666
667 /* Round 4 */
668 movl 16(%ebp), %edx
669 movl %edi, %ebx
670 xorl %edx, %esi
671 shrl $16, %ebx
672 movl %edi, %edx
673 movb %bh, %al
674 andl $255, %ebx
675 movb %dh, %cl
676 andl $255, %edx
677 movl 72(%ebp,%eax,4),%eax
678 movl 1096(%ebp,%ebx,4),%ebx
679 addl %eax, %ebx
680 movl 2120(%ebp,%ecx,4),%eax
681 xorl %eax, %ebx
682 movl 3144(%ebp,%edx,4),%edx
683 addl %edx, %ebx
684 xorl %eax, %eax
685 xorl %ebx, %esi
686
687 /* Round 3 */
688 movl 12(%ebp), %edx
689 movl %esi, %ebx
690 xorl %edx, %edi
691 shrl $16, %ebx
692 movl %esi, %edx
693 movb %bh, %al
694 andl $255, %ebx
695 movb %dh, %cl
696 andl $255, %edx
697 movl 72(%ebp,%eax,4),%eax
698 movl 1096(%ebp,%ebx,4),%ebx
699 addl %eax, %ebx
700 movl 2120(%ebp,%ecx,4),%eax
701 xorl %eax, %ebx
702 movl 3144(%ebp,%edx,4),%edx
703 addl %edx, %ebx
704 xorl %eax, %eax
705 xorl %ebx, %edi
706
707 /* Round 2 */
708 movl 8(%ebp), %edx
709 movl %edi, %ebx
710 xorl %edx, %esi
711 shrl $16, %ebx
712 movl %edi, %edx
713 movb %bh, %al
714 andl $255, %ebx
715 movb %dh, %cl
716 andl $255, %edx
717 movl 72(%ebp,%eax,4),%eax
718 movl 1096(%ebp,%ebx,4),%ebx
719 addl %eax, %ebx
720 movl 2120(%ebp,%ecx,4),%eax
721 xorl %eax, %ebx
722 movl 3144(%ebp,%edx,4),%edx
723 addl %edx, %ebx
724 xorl %eax, %eax
725 xorl %ebx, %esi
726
727 /* Round 1 */
728 movl 4(%ebp), %edx
729 movl %esi, %ebx
730 xorl %edx, %edi
731 shrl $16, %ebx
732 movl %esi, %edx
733 movb %bh, %al
734 andl $255, %ebx
735 movb %dh, %cl
736 andl $255, %edx
737 movl 72(%ebp,%eax,4),%eax
738 movl 1096(%ebp,%ebx,4),%ebx
739 addl %eax, %ebx
740 movl 2120(%ebp,%ecx,4),%eax
741 xorl %eax, %ebx
742 movl 3144(%ebp,%edx,4),%edx
743 addl %edx, %ebx
744 /* Load parameter 0 (1) enc=0 */
745 movl 20(%esp), %eax
746 xorl %ebx, %edi
747 movl (%ebp), %edx
748 xorl %edx, %esi
749 movl %edi, 4(%eax)
750 movl %esi, (%eax)
751 popl %edi
752 popl %esi
753 popl %ebx
754 popl %ebp
755 ret
756.BF_decrypt_end:
757 SIZE(BF_decrypt,.BF_decrypt_end-BF_decrypt)
758.ident "BF_decrypt"
759.text
760 .align ALIGN
761.globl BF_cbc_encrypt
762 TYPE(BF_cbc_encrypt,@function)
763BF_cbc_encrypt:
764
765 pushl %ebp
766 pushl %ebx
767 pushl %esi
768 pushl %edi
769 movl 28(%esp), %ebp
770 /* getting iv ptr from parameter 4 */
771 movl 36(%esp), %ebx
772 movl (%ebx), %esi
773 movl 4(%ebx), %edi
774 pushl %edi
775 pushl %esi
776 pushl %edi
777 pushl %esi
778 movl %esp, %ebx
779 movl 36(%esp), %esi
780 movl 40(%esp), %edi
781 /* getting encrypt flag from parameter 5 */
782 movl 56(%esp), %ecx
783 /* get and push parameter 3 */
784 movl 48(%esp), %eax
785 pushl %eax
786 pushl %ebx
787 cmpl $0, %ecx
788 jz .L000decrypt
789 andl $4294967288, %ebp
790 movl 8(%esp), %eax
791 movl 12(%esp), %ebx
792 jz .L001encrypt_finish
793.L002encrypt_loop:
794 movl (%esi), %ecx
795 movl 4(%esi), %edx
796 xorl %ecx, %eax
797 xorl %edx, %ebx
798.byte 15
799.byte 200 /* bswapl %eax */
800.byte 15
801.byte 203 /* bswapl %ebx */
802 movl %eax, 8(%esp)
803 movl %ebx, 12(%esp)
804 call BF_encrypt
805 movl 8(%esp), %eax
806 movl 12(%esp), %ebx
807.byte 15
808.byte 200 /* bswapl %eax */
809.byte 15
810.byte 203 /* bswapl %ebx */
811 movl %eax, (%edi)
812 movl %ebx, 4(%edi)
813 addl $8, %esi
814 addl $8, %edi
815 subl $8, %ebp
816 jnz .L002encrypt_loop
817.L001encrypt_finish:
818 movl 52(%esp), %ebp
819 andl $7, %ebp
820 jz .L003finish
821 xorl %ecx, %ecx
822 xorl %edx, %edx
823 movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp
824 jmp *%ebp
825.L005ej7:
826 movb 6(%esi), %dh
827 sall $8, %edx
828.L006ej6:
829 movb 5(%esi), %dh
830.L007ej5:
831 movb 4(%esi), %dl
832.L008ej4:
833 movl (%esi), %ecx
834 jmp .L009ejend
835.L010ej3:
836 movb 2(%esi), %ch
837 sall $8, %ecx
838.L011ej2:
839 movb 1(%esi), %ch
840.L012ej1:
841 movb (%esi), %cl
842.L009ejend:
843 xorl %ecx, %eax
844 xorl %edx, %ebx
845.byte 15
846.byte 200 /* bswapl %eax */
847.byte 15
848.byte 203 /* bswapl %ebx */
849 movl %eax, 8(%esp)
850 movl %ebx, 12(%esp)
851 call BF_encrypt
852 movl 8(%esp), %eax
853 movl 12(%esp), %ebx
854.byte 15
855.byte 200 /* bswapl %eax */
856.byte 15
857.byte 203 /* bswapl %ebx */
858 movl %eax, (%edi)
859 movl %ebx, 4(%edi)
860 jmp .L003finish
861.align ALIGN
862.L000decrypt:
863 andl $4294967288, %ebp
864 movl 16(%esp), %eax
865 movl 20(%esp), %ebx
866 jz .L013decrypt_finish
867.L014decrypt_loop:
868 movl (%esi), %eax
869 movl 4(%esi), %ebx
870.byte 15
871.byte 200 /* bswapl %eax */
872.byte 15
873.byte 203 /* bswapl %ebx */
874 movl %eax, 8(%esp)
875 movl %ebx, 12(%esp)
876 call BF_decrypt
877 movl 8(%esp), %eax
878 movl 12(%esp), %ebx
879.byte 15
880.byte 200 /* bswapl %eax */
881.byte 15
882.byte 203 /* bswapl %ebx */
883 movl 16(%esp), %ecx
884 movl 20(%esp), %edx
885 xorl %eax, %ecx
886 xorl %ebx, %edx
887 movl (%esi), %eax
888 movl 4(%esi), %ebx
889 movl %ecx, (%edi)
890 movl %edx, 4(%edi)
891 movl %eax, 16(%esp)
892 movl %ebx, 20(%esp)
893 addl $8, %esi
894 addl $8, %edi
895 subl $8, %ebp
896 jnz .L014decrypt_loop
897.L013decrypt_finish:
898 movl 52(%esp), %ebp
899 andl $7, %ebp
900 jz .L003finish
901 movl (%esi), %eax
902 movl 4(%esi), %ebx
903.byte 15
904.byte 200 /* bswapl %eax */
905.byte 15
906.byte 203 /* bswapl %ebx */
907 movl %eax, 8(%esp)
908 movl %ebx, 12(%esp)
909 call BF_decrypt
910 movl 8(%esp), %eax
911 movl 12(%esp), %ebx
912.byte 15
913.byte 200 /* bswapl %eax */
914.byte 15
915.byte 203 /* bswapl %ebx */
916 movl 16(%esp), %ecx
917 movl 20(%esp), %edx
918 xorl %eax, %ecx
919 xorl %ebx, %edx
920 movl (%esi), %eax
921 movl 4(%esi), %ebx
922.L015dj7:
923 rorl $16, %edx
924 movb %dl, 6(%edi)
925 shrl $16, %edx
926.L016dj6:
927 movb %dh, 5(%edi)
928.L017dj5:
929 movb %dl, 4(%edi)
930.L018dj4:
931 movl %ecx, (%edi)
932 jmp .L019djend
933.L020dj3:
934 rorl $16, %ecx
935 movb %cl, 2(%edi)
936 sall $16, %ecx
937.L021dj2:
938 movb %ch, 1(%esi)
939.L022dj1:
940 movb %cl, (%esi)
941.L019djend:
942 jmp .L003finish
943.align ALIGN
944.L003finish:
945 movl 60(%esp), %ecx
946 addl $24, %esp
947 movl %eax, (%ecx)
948 movl %ebx, 4(%ecx)
949 popl %edi
950 popl %esi
951 popl %ebx
952 popl %ebp
953 ret
954.align ALIGN
955.L004cbc_enc_jmp_table:
956 .long 0
957 .long .L012ej1
958 .long .L011ej2
959 .long .L010ej3
960 .long .L008ej4
961 .long .L007ej5
962 .long .L006ej6
963 .long .L005ej7
964.align ALIGN
965.L023cbc_dec_jmp_table:
966 .long 0
967 .long .L022dj1
968 .long .L021dj2
969 .long .L020dj3
970 .long .L018dj4
971 .long .L017dj5
972 .long .L016dj6
973 .long .L015dj7
974.BF_cbc_encrypt_end:
975 SIZE(BF_cbc_encrypt,.BF_cbc_encrypt_end-BF_cbc_encrypt)
976.ident "desasm.pl"
diff --git a/src/lib/libssl/src/crypto/bf/bf_locl.org b/src/lib/libssl/src/crypto/bf/bf_locl.org
new file mode 100644
index 0000000000..a5663de8ca
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bf/bf_locl.org
@@ -0,0 +1,242 @@
1/* crypto/bf/bf_locl.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify bf_locl.org since bf_locl.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67/* Special defines which change the way the code is built depending on the
68 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
69 even newer MIPS CPU's, but at the moment one size fits all for
70 optimization options. Older Sparc's work better with only UNROLL, but
71 there's no way to tell at compile time what it is you're running on */
72
73#if defined( sun ) /* Newer Sparc's */
74# define BF_PTR
75#elif defined( __ultrix ) /* Older MIPS */
76# define BF_PTR
77#elif defined( __osf1__ ) /* Alpha */
78 /* None */
79#elif defined ( _AIX ) /* RS6000 */
80 /* Unknown */
81#elif defined( __hpux ) /* HP-PA */
82 /* None */
83#elif defined( __aux ) /* 68K */
84 /* Unknown */
85#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
86 /* Unknown */
87#elif defined( __sgi ) /* Newer MIPS */
88# define BF_PTR
89#elif defined( i386 ) /* x86 boxes, should be gcc */
90#elif defined( _MSC_VER ) /* x86 boxes, Visual C */
91#endif /* Systems-specific speed defines */
92
93#undef c2l
94#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
95 l|=((unsigned long)(*((c)++)))<< 8L, \
96 l|=((unsigned long)(*((c)++)))<<16L, \
97 l|=((unsigned long)(*((c)++)))<<24L)
98
99/* NOTE - c is not incremented as per c2l */
100#undef c2ln
101#define c2ln(c,l1,l2,n) { \
102 c+=n; \
103 l1=l2=0; \
104 switch (n) { \
105 case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
106 case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
107 case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
108 case 5: l2|=((unsigned long)(*(--(c)))); \
109 case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
110 case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
111 case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
112 case 1: l1|=((unsigned long)(*(--(c)))); \
113 } \
114 }
115
116#undef l2c
117#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
118 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
119 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
120 *((c)++)=(unsigned char)(((l)>>24L)&0xff))
121
122/* NOTE - c is not incremented as per l2c */
123#undef l2cn
124#define l2cn(l1,l2,c,n) { \
125 c+=n; \
126 switch (n) { \
127 case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
128 case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
129 case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
130 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
131 case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
132 case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
133 case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
134 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
135 } \
136 }
137
138/* NOTE - c is not incremented as per n2l */
139#define n2ln(c,l1,l2,n) { \
140 c+=n; \
141 l1=l2=0; \
142 switch (n) { \
143 case 8: l2 =((unsigned long)(*(--(c)))) ; \
144 case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
145 case 6: l2|=((unsigned long)(*(--(c))))<<16; \
146 case 5: l2|=((unsigned long)(*(--(c))))<<24; \
147 case 4: l1 =((unsigned long)(*(--(c)))) ; \
148 case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
149 case 2: l1|=((unsigned long)(*(--(c))))<<16; \
150 case 1: l1|=((unsigned long)(*(--(c))))<<24; \
151 } \
152 }
153
154/* NOTE - c is not incremented as per l2n */
155#define l2nn(l1,l2,c,n) { \
156 c+=n; \
157 switch (n) { \
158 case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
159 case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
160 case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
161 case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
162 case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
163 case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
164 case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
165 case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
166 } \
167 }
168
169#undef n2l
170#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
171 l|=((unsigned long)(*((c)++)))<<16L, \
172 l|=((unsigned long)(*((c)++)))<< 8L, \
173 l|=((unsigned long)(*((c)++))))
174
175#undef l2n
176#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
177 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
178 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
179 *((c)++)=(unsigned char)(((l) )&0xff))
180
181/* This is actually a big endian algorithm, the most significate byte
182 * is used to lookup array 0 */
183
184/* use BF_PTR2 for intel boxes,
185 * BF_PTR for sparc and MIPS/SGI
186 * use nothing for Alpha and HP.
187 */
188#if !defined(BF_PTR) && !defined(BF_PTR2)
189#undef BF_PTR
190#endif
191
192#define BF_M 0x3fc
193#define BF_0 22L
194#define BF_1 14L
195#define BF_2 6L
196#define BF_3 2L /* left shift */
197
198#if defined(BF_PTR2)
199
200/* This is basically a special pentium verson */
201#define BF_ENC(LL,R,S,P) \
202 { \
203 BF_LONG t,u,v; \
204 u=R>>BF_0; \
205 v=R>>BF_1; \
206 u&=BF_M; \
207 v&=BF_M; \
208 t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \
209 u=R>>BF_2; \
210 t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \
211 v=R<<BF_3; \
212 u&=BF_M; \
213 v&=BF_M; \
214 t^= *(BF_LONG *)((unsigned char *)&(S[512])+u); \
215 LL^=P; \
216 t+= *(BF_LONG *)((unsigned char *)&(S[768])+v); \
217 LL^=t; \
218 }
219
220#elif defined(BF_PTR)
221
222/* This is normally very good */
223
224#define BF_ENC(LL,R,S,P) \
225 LL^=P; \
226 LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
227 *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
228 *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
229 *(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M)));
230#else
231
232/* This will always work, even on 64 bit machines and strangly enough,
233 * on the Alpha it is faster than the pointer versions (both 32 and 64
234 * versions of BF_LONG) */
235
236#define BF_ENC(LL,R,S,P) \
237 LL^=P; \
238 LL^=((( S[ (int)(R>>24L) ] + \
239 S[0x0100+((int)(R>>16L)&0xff)])^ \
240 S[0x0200+((int)(R>> 8L)&0xff)])+ \
241 S[0x0300+((int)(R )&0xff)])&0xffffffffL;
242#endif
diff --git a/src/lib/libssl/src/crypto/bio/Makefile.ssl b/src/lib/libssl/src/crypto/bio/Makefile.ssl
new file mode 100644
index 0000000000..42e11e1c94
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bio/Makefile.ssl
@@ -0,0 +1,92 @@
1#
2# SSLeay/crypto/bio/Makefile
3#
4
5DIR= bio
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=bio
19ERRC=bio_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= bio_lib.c bio_cb.c $(ERRC).c \
26 bss_mem.c bss_null.c bss_fd.c \
27 bss_file.c bss_sock.c bss_conn.c \
28 bf_null.c bf_buff.c b_print.c b_dump.c \
29 b_sock.c bss_acpt.c bf_nbio.c
30LIBOBJ= bio_lib.o bio_cb.o $(ERRC).o \
31 bss_mem.o bss_null.o bss_fd.o \
32 bss_file.o bss_sock.o bss_conn.o \
33 bf_null.o bf_buff.o b_print.o b_dump.o \
34 b_sock.o bss_acpt.o bf_nbio.o
35
36SRC= $(LIBSRC)
37
38EXHEADER= bio.h bss_file.c
39HEADER= $(EXHEADER)
40
41ALL= $(GENERAL) $(SRC) $(HEADER)
42
43top:
44 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
45
46all: lib
47
48lib: $(LIBOBJ)
49 $(AR) $(LIB) $(LIBOBJ)
50 sh $(TOP)/util/ranlib.sh $(LIB)
51 @touch lib
52
53files:
54 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
55
56links:
57 /bin/rm -f Makefile
58 $(TOP)/util/point.sh Makefile.ssl Makefile;
59 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
60 $(TOP)/util/mklink.sh ../../test $(TEST)
61 $(TOP)/util/mklink.sh ../../apps $(APPS)
62
63install:
64 @for i in $(EXHEADER) bss_file.c ; \
65 do \
66 (cp $$i $(INSTALLTOP)/include/$$i; \
67 chmod 644 $(INSTALLTOP)/include/$$i ); \
68 done;
69
70tags:
71 ctags $(SRC)
72
73tests:
74
75lint:
76 lint -DLINT $(INCLUDES) $(SRC)>fluff
77
78depend:
79 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
80
81dclean:
82 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
83 mv -f Makefile.new $(MAKEFILE)
84
85clean:
86 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
87
88errors:
89 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
90 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
91
92# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/bio/bio.err b/src/lib/libssl/src/crypto/bio/bio.err
new file mode 100644
index 0000000000..6e2f2b63ca
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bio/bio.err
@@ -0,0 +1,46 @@
1/* Error codes for the BIO functions. */
2
3/* Function codes. */
4#define BIO_F_ACPT_STATE 100
5#define BIO_F_BIO_ACCEPT 101
6#define BIO_F_BIO_CTRL 102
7#define BIO_F_BIO_GETS 103
8#define BIO_F_BIO_GET_ACCEPT_SOCKET 104
9#define BIO_F_BIO_GET_HOST_IP 105
10#define BIO_F_BIO_GET_PORT 106
11#define BIO_F_BIO_NEW 107
12#define BIO_F_BIO_NEW_FILE 108
13#define BIO_F_BIO_PUTS 109
14#define BIO_F_BIO_READ 110
15#define BIO_F_BIO_SOCK_INIT 111
16#define BIO_F_BIO_WRITE 112
17#define BIO_F_BUFFER_CTRL 113
18#define BIO_F_CONN_STATE 114
19#define BIO_F_FILE_CTRL 115
20#define BIO_F_MEM_WRITE 116
21#define BIO_F_SSL_NEW 117
22#define BIO_F_WSASTARTUP 118
23
24/* Reason codes. */
25#define BIO_R_ACCEPT_ERROR 100
26#define BIO_R_BAD_FOPEN_MODE 101
27#define BIO_R_BAD_HOSTNAME_LOOKUP 102
28#define BIO_R_CONNECT_ERROR 103
29#define BIO_R_ERROR_SETTING_NBIO 104
30#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105
31#define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106
32#define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107
33#define BIO_R_INVALID_IP_ADDRESS 108
34#define BIO_R_KEEPALIVE 109
35#define BIO_R_NBIO_CONNECT_ERROR 110
36#define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111
37#define BIO_R_NO_HOSTHNAME_SPECIFIED 112
38#define BIO_R_NO_PORT_DEFINED 113
39#define BIO_R_NO_PORT_SPECIFIED 114
40#define BIO_R_NULL_PARAMETER 115
41#define BIO_R_UNABLE_TO_BIND_SOCKET 116
42#define BIO_R_UNABLE_TO_CREATE_SOCKET 117
43#define BIO_R_UNABLE_TO_LISTEN_SOCKET 118
44#define BIO_R_UNINITALISED 119
45#define BIO_R_UNSUPPORTED_METHOD 120
46#define BIO_R_WSASTARTUP 121
diff --git a/src/lib/libssl/src/crypto/bn/Makefile.ssl b/src/lib/libssl/src/crypto/bn/Makefile.ssl
new file mode 100644
index 0000000000..9809d26cbc
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/Makefile.ssl
@@ -0,0 +1,133 @@
1#
2# SSLeay/crypto/bn/Makefile
3#
4
5DIR= bn
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16BN_MULW= bn_mulw.o
17# or use
18#BN_MULW= bn86-elf.o
19
20CFLAGS= $(INCLUDES) $(CFLAG)
21
22ERR=bn
23ERRC=bn_err
24GENERAL=Makefile
25TEST=bntest.c exptest.c
26APPS=
27
28LIB=$(TOP)/libcrypto.a
29LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_mod.c bn_mul.c \
30 bn_print.c bn_rand.c bn_shift.c bn_sub.c bn_word.c bn_blind.c \
31 bn_gcd.c bn_prime.c $(ERRC).c bn_sqr.c bn_mulw.c bn_recp.c bn_mont.c \
32 bn_mpi.c
33
34LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_mod.o bn_mul.o \
35 bn_print.o bn_rand.o bn_shift.o bn_sub.o bn_word.o bn_blind.o \
36 bn_gcd.o bn_prime.o $(ERRC).o bn_sqr.o $(BN_MULW) bn_recp.o bn_mont.o \
37 bn_mpi.o
38
39
40SRC= $(LIBSRC)
41
42EXHEADER= bn.h
43HEADER= bn_lcl.h bn_prime.h $(EXHEADER)
44
45ALL= $(GENERAL) $(SRC) $(HEADER)
46
47top:
48 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
49
50all: lib
51
52knuth: bn_knuth.c
53 cc -pg -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a
54
55knuth.fast: bn_knuth.c
56 cc -pg -fast -I.. -I../../include bn_knuth.c -o knuth $(LIB) #../../../libefence.a
57
58
59lib: $(LIBOBJ)
60 $(AR) $(LIB) $(LIBOBJ)
61 sh $(TOP)/util/ranlib.sh $(LIB)
62 @touch lib
63
64# elf
65asm/bn86-elf.o: asm/bn86unix.cpp
66 $(CPP) -DELF asm/bn86unix.cpp | as -o asm/bn86-elf.o
67
68# solaris
69asm/bn86-sol.o: asm/bn86unix.cpp
70 $(CC) -E -DSOL asm/bn86unix.cpp | sed 's/^#.*//' > asm/bn86-sol.s
71 as -o asm/bn86-sol.o asm/bn86-sol.s
72 rm -f asm/bn86-sol.s
73
74# a.out
75asm/bn86-out.o: asm/bn86unix.cpp
76 $(CPP) -DOUT asm/bn86unix.cpp | as -o asm/bn86-out.o
77
78# bsdi
79asm/bn86bsdi.o: asm/bn86unix.cpp
80 $(CPP) -DBSDI asm/bn86unix.cpp | as -o asm/bn86bsdi.o
81
82asm/bn86unix.cpp:
83 (cd asm; perl bn-586.pl cpp >bn86unix.cpp )
84
85files:
86 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
87
88links:
89 /bin/rm -f Makefile
90 $(TOP)/util/point.sh Makefile.ssl Makefile ;
91 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
92 $(TOP)/util/mklink.sh ../../test $(TEST)
93 $(TOP)/util/mklink.sh ../../apps $(APPS)
94
95install:
96 @for i in $(EXHEADER) ; \
97 do \
98 (cp $$i $(INSTALLTOP)/include/$$i; \
99 chmod 644 $(INSTALLTOP)/include/$$i ); \
100 done;
101
102exptest:
103 /bin/rm -f exptest
104 gcc -I../../include -g2 -ggdb -o exptest exptest.c ../../libcrypto.a
105
106div:
107 /bin/rm -f a.out
108 gcc -I.. -g div.c ../../libcrypto.a
109
110tags:
111 ctags $(SRC)
112
113tests:
114
115lint:
116 lint -DLINT $(INCLUDES) $(SRC)>fluff
117
118depend:
119 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
120
121dclean:
122 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
123 mv -f Makefile.new $(MAKEFILE)
124
125clean:
126 /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_mulw.s
127
128errors:
129 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # special case .org
130 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
131 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
132
133# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/bn/asm/bn-win32.asm b/src/lib/libssl/src/crypto/bn/asm/bn-win32.asm
new file mode 100644
index 0000000000..017ea462b0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/asm/bn-win32.asm
@@ -0,0 +1,689 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by bn-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE bn-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _bn_mul_add_words
12
13_bn_mul_add_words PROC NEAR
14 push ebp
15 push ebx
16 push esi
17 push edi
18 ;
19 xor esi, esi
20 mov edi, DWORD PTR 20[esp]
21 mov ecx, DWORD PTR 28[esp]
22 mov ebx, DWORD PTR 24[esp]
23 and ecx, 4294967288
24 mov ebp, DWORD PTR 32[esp]
25 push ecx
26 jz $L000maw_finish
27L001maw_loop:
28 mov DWORD PTR [esp],ecx
29 ; Round 0
30 mov eax, DWORD PTR [ebx]
31 mul ebp
32 add eax, esi
33 mov esi, DWORD PTR [edi]
34 adc edx, 0
35 add eax, esi
36 adc edx, 0
37 mov DWORD PTR [edi],eax
38 mov esi, edx
39 ; Round 4
40 mov eax, DWORD PTR 4[ebx]
41 mul ebp
42 add eax, esi
43 mov esi, DWORD PTR 4[edi]
44 adc edx, 0
45 add eax, esi
46 adc edx, 0
47 mov DWORD PTR 4[edi],eax
48 mov esi, edx
49 ; Round 8
50 mov eax, DWORD PTR 8[ebx]
51 mul ebp
52 add eax, esi
53 mov esi, DWORD PTR 8[edi]
54 adc edx, 0
55 add eax, esi
56 adc edx, 0
57 mov DWORD PTR 8[edi],eax
58 mov esi, edx
59 ; Round 12
60 mov eax, DWORD PTR 12[ebx]
61 mul ebp
62 add eax, esi
63 mov esi, DWORD PTR 12[edi]
64 adc edx, 0
65 add eax, esi
66 adc edx, 0
67 mov DWORD PTR 12[edi],eax
68 mov esi, edx
69 ; Round 16
70 mov eax, DWORD PTR 16[ebx]
71 mul ebp
72 add eax, esi
73 mov esi, DWORD PTR 16[edi]
74 adc edx, 0
75 add eax, esi
76 adc edx, 0
77 mov DWORD PTR 16[edi],eax
78 mov esi, edx
79 ; Round 20
80 mov eax, DWORD PTR 20[ebx]
81 mul ebp
82 add eax, esi
83 mov esi, DWORD PTR 20[edi]
84 adc edx, 0
85 add eax, esi
86 adc edx, 0
87 mov DWORD PTR 20[edi],eax
88 mov esi, edx
89 ; Round 24
90 mov eax, DWORD PTR 24[ebx]
91 mul ebp
92 add eax, esi
93 mov esi, DWORD PTR 24[edi]
94 adc edx, 0
95 add eax, esi
96 adc edx, 0
97 mov DWORD PTR 24[edi],eax
98 mov esi, edx
99 ; Round 28
100 mov eax, DWORD PTR 28[ebx]
101 mul ebp
102 add eax, esi
103 mov esi, DWORD PTR 28[edi]
104 adc edx, 0
105 add eax, esi
106 adc edx, 0
107 mov DWORD PTR 28[edi],eax
108 mov esi, edx
109 ;
110 mov ecx, DWORD PTR [esp]
111 add ebx, 32
112 add edi, 32
113 sub ecx, 8
114 jnz L001maw_loop
115$L000maw_finish:
116 mov ecx, DWORD PTR 32[esp]
117 and ecx, 7
118 jnz $L002maw_finish2
119 jmp $L003maw_end
120$L002maw_finish2:
121 ; Tail Round 0
122 mov eax, DWORD PTR [ebx]
123 mul ebp
124 add eax, esi
125 mov esi, DWORD PTR [edi]
126 adc edx, 0
127 add eax, esi
128 adc edx, 0
129 dec ecx
130 mov DWORD PTR [edi],eax
131 mov esi, edx
132 jz $L003maw_end
133 ; Tail Round 1
134 mov eax, DWORD PTR 4[ebx]
135 mul ebp
136 add eax, esi
137 mov esi, DWORD PTR 4[edi]
138 adc edx, 0
139 add eax, esi
140 adc edx, 0
141 dec ecx
142 mov DWORD PTR 4[edi],eax
143 mov esi, edx
144 jz $L003maw_end
145 ; Tail Round 2
146 mov eax, DWORD PTR 8[ebx]
147 mul ebp
148 add eax, esi
149 mov esi, DWORD PTR 8[edi]
150 adc edx, 0
151 add eax, esi
152 adc edx, 0
153 dec ecx
154 mov DWORD PTR 8[edi],eax
155 mov esi, edx
156 jz $L003maw_end
157 ; Tail Round 3
158 mov eax, DWORD PTR 12[ebx]
159 mul ebp
160 add eax, esi
161 mov esi, DWORD PTR 12[edi]
162 adc edx, 0
163 add eax, esi
164 adc edx, 0
165 dec ecx
166 mov DWORD PTR 12[edi],eax
167 mov esi, edx
168 jz $L003maw_end
169 ; Tail Round 4
170 mov eax, DWORD PTR 16[ebx]
171 mul ebp
172 add eax, esi
173 mov esi, DWORD PTR 16[edi]
174 adc edx, 0
175 add eax, esi
176 adc edx, 0
177 dec ecx
178 mov DWORD PTR 16[edi],eax
179 mov esi, edx
180 jz $L003maw_end
181 ; Tail Round 5
182 mov eax, DWORD PTR 20[ebx]
183 mul ebp
184 add eax, esi
185 mov esi, DWORD PTR 20[edi]
186 adc edx, 0
187 add eax, esi
188 adc edx, 0
189 dec ecx
190 mov DWORD PTR 20[edi],eax
191 mov esi, edx
192 jz $L003maw_end
193 ; Tail Round 6
194 mov eax, DWORD PTR 24[ebx]
195 mul ebp
196 add eax, esi
197 mov esi, DWORD PTR 24[edi]
198 adc edx, 0
199 add eax, esi
200 adc edx, 0
201 mov DWORD PTR 24[edi],eax
202 mov esi, edx
203$L003maw_end:
204 mov eax, esi
205 pop ecx
206 pop edi
207 pop esi
208 pop ebx
209 pop ebp
210 ret
211_bn_mul_add_words ENDP
212_TEXT ENDS
213_TEXT SEGMENT
214PUBLIC _bn_mul_words
215
216_bn_mul_words PROC NEAR
217 push ebp
218 push ebx
219 push esi
220 push edi
221 ;
222 xor esi, esi
223 mov edi, DWORD PTR 20[esp]
224 mov ebx, DWORD PTR 24[esp]
225 mov ebp, DWORD PTR 28[esp]
226 mov ecx, DWORD PTR 32[esp]
227 and ebp, 4294967288
228 jz $L004mw_finish
229L005mw_loop:
230 ; Round 0
231 mov eax, DWORD PTR [ebx]
232 mul ecx
233 add eax, esi
234 adc edx, 0
235 mov DWORD PTR [edi],eax
236 mov esi, edx
237 ; Round 4
238 mov eax, DWORD PTR 4[ebx]
239 mul ecx
240 add eax, esi
241 adc edx, 0
242 mov DWORD PTR 4[edi],eax
243 mov esi, edx
244 ; Round 8
245 mov eax, DWORD PTR 8[ebx]
246 mul ecx
247 add eax, esi
248 adc edx, 0
249 mov DWORD PTR 8[edi],eax
250 mov esi, edx
251 ; Round 12
252 mov eax, DWORD PTR 12[ebx]
253 mul ecx
254 add eax, esi
255 adc edx, 0
256 mov DWORD PTR 12[edi],eax
257 mov esi, edx
258 ; Round 16
259 mov eax, DWORD PTR 16[ebx]
260 mul ecx
261 add eax, esi
262 adc edx, 0
263 mov DWORD PTR 16[edi],eax
264 mov esi, edx
265 ; Round 20
266 mov eax, DWORD PTR 20[ebx]
267 mul ecx
268 add eax, esi
269 adc edx, 0
270 mov DWORD PTR 20[edi],eax
271 mov esi, edx
272 ; Round 24
273 mov eax, DWORD PTR 24[ebx]
274 mul ecx
275 add eax, esi
276 adc edx, 0
277 mov DWORD PTR 24[edi],eax
278 mov esi, edx
279 ; Round 28
280 mov eax, DWORD PTR 28[ebx]
281 mul ecx
282 add eax, esi
283 adc edx, 0
284 mov DWORD PTR 28[edi],eax
285 mov esi, edx
286 ;
287 add ebx, 32
288 add edi, 32
289 sub ebp, 8
290 jz $L004mw_finish
291 jmp L005mw_loop
292$L004mw_finish:
293 mov ebp, DWORD PTR 28[esp]
294 and ebp, 7
295 jnz $L006mw_finish2
296 jmp $L007mw_end
297$L006mw_finish2:
298 ; Tail Round 0
299 mov eax, DWORD PTR [ebx]
300 mul ecx
301 add eax, esi
302 adc edx, 0
303 mov DWORD PTR [edi],eax
304 mov esi, edx
305 dec ebp
306 jz $L007mw_end
307 ; Tail Round 1
308 mov eax, DWORD PTR 4[ebx]
309 mul ecx
310 add eax, esi
311 adc edx, 0
312 mov DWORD PTR 4[edi],eax
313 mov esi, edx
314 dec ebp
315 jz $L007mw_end
316 ; Tail Round 2
317 mov eax, DWORD PTR 8[ebx]
318 mul ecx
319 add eax, esi
320 adc edx, 0
321 mov DWORD PTR 8[edi],eax
322 mov esi, edx
323 dec ebp
324 jz $L007mw_end
325 ; Tail Round 3
326 mov eax, DWORD PTR 12[ebx]
327 mul ecx
328 add eax, esi
329 adc edx, 0
330 mov DWORD PTR 12[edi],eax
331 mov esi, edx
332 dec ebp
333 jz $L007mw_end
334 ; Tail Round 4
335 mov eax, DWORD PTR 16[ebx]
336 mul ecx
337 add eax, esi
338 adc edx, 0
339 mov DWORD PTR 16[edi],eax
340 mov esi, edx
341 dec ebp
342 jz $L007mw_end
343 ; Tail Round 5
344 mov eax, DWORD PTR 20[ebx]
345 mul ecx
346 add eax, esi
347 adc edx, 0
348 mov DWORD PTR 20[edi],eax
349 mov esi, edx
350 dec ebp
351 jz $L007mw_end
352 ; Tail Round 6
353 mov eax, DWORD PTR 24[ebx]
354 mul ecx
355 add eax, esi
356 adc edx, 0
357 mov DWORD PTR 24[edi],eax
358 mov esi, edx
359$L007mw_end:
360 mov eax, esi
361 pop edi
362 pop esi
363 pop ebx
364 pop ebp
365 ret
366_bn_mul_words ENDP
367_TEXT ENDS
368_TEXT SEGMENT
369PUBLIC _bn_sqr_words
370
371_bn_sqr_words PROC NEAR
372 push ebp
373 push ebx
374 push esi
375 push edi
376 ;
377 mov esi, DWORD PTR 20[esp]
378 mov edi, DWORD PTR 24[esp]
379 mov ebx, DWORD PTR 28[esp]
380 and ebx, 4294967288
381 jz $L008sw_finish
382L009sw_loop:
383 ; Round 0
384 mov eax, DWORD PTR [edi]
385 mul eax
386 mov DWORD PTR [esi],eax
387 mov DWORD PTR 4[esi],edx
388 ; Round 4
389 mov eax, DWORD PTR 4[edi]
390 mul eax
391 mov DWORD PTR 8[esi],eax
392 mov DWORD PTR 12[esi],edx
393 ; Round 8
394 mov eax, DWORD PTR 8[edi]
395 mul eax
396 mov DWORD PTR 16[esi],eax
397 mov DWORD PTR 20[esi],edx
398 ; Round 12
399 mov eax, DWORD PTR 12[edi]
400 mul eax
401 mov DWORD PTR 24[esi],eax
402 mov DWORD PTR 28[esi],edx
403 ; Round 16
404 mov eax, DWORD PTR 16[edi]
405 mul eax
406 mov DWORD PTR 32[esi],eax
407 mov DWORD PTR 36[esi],edx
408 ; Round 20
409 mov eax, DWORD PTR 20[edi]
410 mul eax
411 mov DWORD PTR 40[esi],eax
412 mov DWORD PTR 44[esi],edx
413 ; Round 24
414 mov eax, DWORD PTR 24[edi]
415 mul eax
416 mov DWORD PTR 48[esi],eax
417 mov DWORD PTR 52[esi],edx
418 ; Round 28
419 mov eax, DWORD PTR 28[edi]
420 mul eax
421 mov DWORD PTR 56[esi],eax
422 mov DWORD PTR 60[esi],edx
423 ;
424 add edi, 32
425 add esi, 64
426 sub ebx, 8
427 jnz L009sw_loop
428$L008sw_finish:
429 mov ebx, DWORD PTR 28[esp]
430 and ebx, 7
431 jz $L010sw_end
432 ; Tail Round 0
433 mov eax, DWORD PTR [edi]
434 mul eax
435 mov DWORD PTR [esi],eax
436 dec ebx
437 mov DWORD PTR 4[esi],edx
438 jz $L010sw_end
439 ; Tail Round 1
440 mov eax, DWORD PTR 4[edi]
441 mul eax
442 mov DWORD PTR 8[esi],eax
443 dec ebx
444 mov DWORD PTR 12[esi],edx
445 jz $L010sw_end
446 ; Tail Round 2
447 mov eax, DWORD PTR 8[edi]
448 mul eax
449 mov DWORD PTR 16[esi],eax
450 dec ebx
451 mov DWORD PTR 20[esi],edx
452 jz $L010sw_end
453 ; Tail Round 3
454 mov eax, DWORD PTR 12[edi]
455 mul eax
456 mov DWORD PTR 24[esi],eax
457 dec ebx
458 mov DWORD PTR 28[esi],edx
459 jz $L010sw_end
460 ; Tail Round 4
461 mov eax, DWORD PTR 16[edi]
462 mul eax
463 mov DWORD PTR 32[esi],eax
464 dec ebx
465 mov DWORD PTR 36[esi],edx
466 jz $L010sw_end
467 ; Tail Round 5
468 mov eax, DWORD PTR 20[edi]
469 mul eax
470 mov DWORD PTR 40[esi],eax
471 dec ebx
472 mov DWORD PTR 44[esi],edx
473 jz $L010sw_end
474 ; Tail Round 6
475 mov eax, DWORD PTR 24[edi]
476 mul eax
477 mov DWORD PTR 48[esi],eax
478 mov DWORD PTR 52[esi],edx
479$L010sw_end:
480 pop edi
481 pop esi
482 pop ebx
483 pop ebp
484 ret
485_bn_sqr_words ENDP
486_TEXT ENDS
487_TEXT SEGMENT
488PUBLIC _bn_div64
489
490_bn_div64 PROC NEAR
491 push ebp
492 push ebx
493 push esi
494 push edi
495 mov edx, DWORD PTR 20[esp]
496 mov eax, DWORD PTR 24[esp]
497 mov ebx, DWORD PTR 28[esp]
498 div ebx
499 pop edi
500 pop esi
501 pop ebx
502 pop ebp
503 ret
504_bn_div64 ENDP
505_TEXT ENDS
506_TEXT SEGMENT
507PUBLIC _bn_add_words
508
509_bn_add_words PROC NEAR
510 push ebp
511 push ebx
512 push esi
513 push edi
514 ;
515 mov ebx, DWORD PTR 20[esp]
516 mov esi, DWORD PTR 24[esp]
517 mov edi, DWORD PTR 28[esp]
518 mov ebp, DWORD PTR 32[esp]
519 xor eax, eax
520 and ebp, 4294967288
521 jz $L011aw_finish
522L012aw_loop:
523 ; Round 0
524 mov ecx, DWORD PTR [esi]
525 mov edx, DWORD PTR [edi]
526 add ecx, eax
527 mov eax, 0
528 adc eax, eax
529 add ecx, edx
530 adc eax, 0
531 mov DWORD PTR [ebx],ecx
532 ; Round 1
533 mov ecx, DWORD PTR 4[esi]
534 mov edx, DWORD PTR 4[edi]
535 add ecx, eax
536 mov eax, 0
537 adc eax, eax
538 add ecx, edx
539 adc eax, 0
540 mov DWORD PTR 4[ebx],ecx
541 ; Round 2
542 mov ecx, DWORD PTR 8[esi]
543 mov edx, DWORD PTR 8[edi]
544 add ecx, eax
545 mov eax, 0
546 adc eax, eax
547 add ecx, edx
548 adc eax, 0
549 mov DWORD PTR 8[ebx],ecx
550 ; Round 3
551 mov ecx, DWORD PTR 12[esi]
552 mov edx, DWORD PTR 12[edi]
553 add ecx, eax
554 mov eax, 0
555 adc eax, eax
556 add ecx, edx
557 adc eax, 0
558 mov DWORD PTR 12[ebx],ecx
559 ; Round 4
560 mov ecx, DWORD PTR 16[esi]
561 mov edx, DWORD PTR 16[edi]
562 add ecx, eax
563 mov eax, 0
564 adc eax, eax
565 add ecx, edx
566 adc eax, 0
567 mov DWORD PTR 16[ebx],ecx
568 ; Round 5
569 mov ecx, DWORD PTR 20[esi]
570 mov edx, DWORD PTR 20[edi]
571 add ecx, eax
572 mov eax, 0
573 adc eax, eax
574 add ecx, edx
575 adc eax, 0
576 mov DWORD PTR 20[ebx],ecx
577 ; Round 6
578 mov ecx, DWORD PTR 24[esi]
579 mov edx, DWORD PTR 24[edi]
580 add ecx, eax
581 mov eax, 0
582 adc eax, eax
583 add ecx, edx
584 adc eax, 0
585 mov DWORD PTR 24[ebx],ecx
586 ; Round 7
587 mov ecx, DWORD PTR 28[esi]
588 mov edx, DWORD PTR 28[edi]
589 add ecx, eax
590 mov eax, 0
591 adc eax, eax
592 add ecx, edx
593 adc eax, 0
594 mov DWORD PTR 28[ebx],ecx
595 ;
596 add esi, 32
597 add edi, 32
598 add ebx, 32
599 sub ebp, 8
600 jnz L012aw_loop
601$L011aw_finish:
602 mov ebp, DWORD PTR 32[esp]
603 and ebp, 7
604 jz $L013aw_end
605 ; Tail Round 0
606 mov ecx, DWORD PTR [esi]
607 mov edx, DWORD PTR [edi]
608 add ecx, eax
609 mov eax, 0
610 adc eax, eax
611 add ecx, edx
612 adc eax, 0
613 dec ebp
614 mov DWORD PTR [ebx],ecx
615 jz $L013aw_end
616 ; Tail Round 1
617 mov ecx, DWORD PTR 4[esi]
618 mov edx, DWORD PTR 4[edi]
619 add ecx, eax
620 mov eax, 0
621 adc eax, eax
622 add ecx, edx
623 adc eax, 0
624 dec ebp
625 mov DWORD PTR 4[ebx],ecx
626 jz $L013aw_end
627 ; Tail Round 2
628 mov ecx, DWORD PTR 8[esi]
629 mov edx, DWORD PTR 8[edi]
630 add ecx, eax
631 mov eax, 0
632 adc eax, eax
633 add ecx, edx
634 adc eax, 0
635 dec ebp
636 mov DWORD PTR 8[ebx],ecx
637 jz $L013aw_end
638 ; Tail Round 3
639 mov ecx, DWORD PTR 12[esi]
640 mov edx, DWORD PTR 12[edi]
641 add ecx, eax
642 mov eax, 0
643 adc eax, eax
644 add ecx, edx
645 adc eax, 0
646 dec ebp
647 mov DWORD PTR 12[ebx],ecx
648 jz $L013aw_end
649 ; Tail Round 4
650 mov ecx, DWORD PTR 16[esi]
651 mov edx, DWORD PTR 16[edi]
652 add ecx, eax
653 mov eax, 0
654 adc eax, eax
655 add ecx, edx
656 adc eax, 0
657 dec ebp
658 mov DWORD PTR 16[ebx],ecx
659 jz $L013aw_end
660 ; Tail Round 5
661 mov ecx, DWORD PTR 20[esi]
662 mov edx, DWORD PTR 20[edi]
663 add ecx, eax
664 mov eax, 0
665 adc eax, eax
666 add ecx, edx
667 adc eax, 0
668 dec ebp
669 mov DWORD PTR 20[ebx],ecx
670 jz $L013aw_end
671 ; Tail Round 6
672 mov ecx, DWORD PTR 24[esi]
673 mov edx, DWORD PTR 24[edi]
674 add ecx, eax
675 mov eax, 0
676 adc eax, eax
677 add ecx, edx
678 adc eax, 0
679 mov DWORD PTR 24[ebx],ecx
680$L013aw_end:
681 mov eax, eax
682 pop edi
683 pop esi
684 pop ebx
685 pop ebp
686 ret
687_bn_add_words ENDP
688_TEXT ENDS
689END
diff --git a/src/lib/libssl/src/crypto/bn/asm/bn86unix.cpp b/src/lib/libssl/src/crypto/bn/asm/bn86unix.cpp
new file mode 100644
index 0000000000..64702201ea
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/asm/bn86unix.cpp
@@ -0,0 +1,752 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define bn_mul_add_words _bn_mul_add_words
13#define bn_mul_words _bn_mul_words
14#define bn_sqr_words _bn_sqr_words
15#define bn_div64 _bn_div64
16#define bn_add_words _bn_add_words
17
18#endif
19
20#ifdef OUT
21#define OK 1
22#define ALIGN 4
23#endif
24
25#ifdef BSDI
26#define OK 1
27#define ALIGN 4
28#undef SIZE
29#undef TYPE
30#define SIZE(a,b)
31#define TYPE(a,b)
32#endif
33
34#if defined(ELF) || defined(SOL)
35#define OK 1
36#define ALIGN 16
37#endif
38
39#ifndef OK
40You need to define one of
41ELF - elf systems - linux-elf, NetBSD and DG-UX
42OUT - a.out systems - linux-a.out and FreeBSD
43SOL - solaris systems, which are elf with strange comment lines
44BSDI - a.out with a very primative version of as.
45#endif
46
47/* Let the Assembler begin :-) */
48 /* Don't even think of reading this code */
49 /* It was automatically generated by bn-586.pl */
50 /* Which is a perl program used to generate the x86 assember for */
51 /* any of elf, a.out, BSDI,Win32, or Solaris */
52 /* eric <eay@cryptsoft.com> */
53
54 .file "bn-586.s"
55 .version "01.01"
56gcc2_compiled.:
57.text
58 .align ALIGN
59.globl bn_mul_add_words
60 TYPE(bn_mul_add_words,@function)
61bn_mul_add_words:
62 pushl %ebp
63 pushl %ebx
64 pushl %esi
65 pushl %edi
66
67
68 xorl %esi, %esi
69 movl 20(%esp), %edi
70 movl 28(%esp), %ecx
71 movl 24(%esp), %ebx
72 andl $4294967288, %ecx
73 movl 32(%esp), %ebp
74 pushl %ecx
75 jz .L000maw_finish
76.L001maw_loop:
77 movl %ecx, (%esp)
78 /* Round 0 */
79 movl (%ebx), %eax
80 mull %ebp
81 addl %esi, %eax
82 movl (%edi), %esi
83 adcl $0, %edx
84 addl %esi, %eax
85 adcl $0, %edx
86 movl %eax, (%edi)
87 movl %edx, %esi
88 /* Round 4 */
89 movl 4(%ebx), %eax
90 mull %ebp
91 addl %esi, %eax
92 movl 4(%edi), %esi
93 adcl $0, %edx
94 addl %esi, %eax
95 adcl $0, %edx
96 movl %eax, 4(%edi)
97 movl %edx, %esi
98 /* Round 8 */
99 movl 8(%ebx), %eax
100 mull %ebp
101 addl %esi, %eax
102 movl 8(%edi), %esi
103 adcl $0, %edx
104 addl %esi, %eax
105 adcl $0, %edx
106 movl %eax, 8(%edi)
107 movl %edx, %esi
108 /* Round 12 */
109 movl 12(%ebx), %eax
110 mull %ebp
111 addl %esi, %eax
112 movl 12(%edi), %esi
113 adcl $0, %edx
114 addl %esi, %eax
115 adcl $0, %edx
116 movl %eax, 12(%edi)
117 movl %edx, %esi
118 /* Round 16 */
119 movl 16(%ebx), %eax
120 mull %ebp
121 addl %esi, %eax
122 movl 16(%edi), %esi
123 adcl $0, %edx
124 addl %esi, %eax
125 adcl $0, %edx
126 movl %eax, 16(%edi)
127 movl %edx, %esi
128 /* Round 20 */
129 movl 20(%ebx), %eax
130 mull %ebp
131 addl %esi, %eax
132 movl 20(%edi), %esi
133 adcl $0, %edx
134 addl %esi, %eax
135 adcl $0, %edx
136 movl %eax, 20(%edi)
137 movl %edx, %esi
138 /* Round 24 */
139 movl 24(%ebx), %eax
140 mull %ebp
141 addl %esi, %eax
142 movl 24(%edi), %esi
143 adcl $0, %edx
144 addl %esi, %eax
145 adcl $0, %edx
146 movl %eax, 24(%edi)
147 movl %edx, %esi
148 /* Round 28 */
149 movl 28(%ebx), %eax
150 mull %ebp
151 addl %esi, %eax
152 movl 28(%edi), %esi
153 adcl $0, %edx
154 addl %esi, %eax
155 adcl $0, %edx
156 movl %eax, 28(%edi)
157 movl %edx, %esi
158
159 movl (%esp), %ecx
160 addl $32, %ebx
161 addl $32, %edi
162 subl $8, %ecx
163 jnz .L001maw_loop
164.L000maw_finish:
165 movl 32(%esp), %ecx
166 andl $7, %ecx
167 jnz .L002maw_finish2
168 jmp .L003maw_end
169.align ALIGN
170.L002maw_finish2:
171 /* Tail Round 0 */
172 movl (%ebx), %eax
173 mull %ebp
174 addl %esi, %eax
175 movl (%edi), %esi
176 adcl $0, %edx
177 addl %esi, %eax
178 adcl $0, %edx
179 decl %ecx
180 movl %eax, (%edi)
181 movl %edx, %esi
182 jz .L003maw_end
183 /* Tail Round 1 */
184 movl 4(%ebx), %eax
185 mull %ebp
186 addl %esi, %eax
187 movl 4(%edi), %esi
188 adcl $0, %edx
189 addl %esi, %eax
190 adcl $0, %edx
191 decl %ecx
192 movl %eax, 4(%edi)
193 movl %edx, %esi
194 jz .L003maw_end
195 /* Tail Round 2 */
196 movl 8(%ebx), %eax
197 mull %ebp
198 addl %esi, %eax
199 movl 8(%edi), %esi
200 adcl $0, %edx
201 addl %esi, %eax
202 adcl $0, %edx
203 decl %ecx
204 movl %eax, 8(%edi)
205 movl %edx, %esi
206 jz .L003maw_end
207 /* Tail Round 3 */
208 movl 12(%ebx), %eax
209 mull %ebp
210 addl %esi, %eax
211 movl 12(%edi), %esi
212 adcl $0, %edx
213 addl %esi, %eax
214 adcl $0, %edx
215 decl %ecx
216 movl %eax, 12(%edi)
217 movl %edx, %esi
218 jz .L003maw_end
219 /* Tail Round 4 */
220 movl 16(%ebx), %eax
221 mull %ebp
222 addl %esi, %eax
223 movl 16(%edi), %esi
224 adcl $0, %edx
225 addl %esi, %eax
226 adcl $0, %edx
227 decl %ecx
228 movl %eax, 16(%edi)
229 movl %edx, %esi
230 jz .L003maw_end
231 /* Tail Round 5 */
232 movl 20(%ebx), %eax
233 mull %ebp
234 addl %esi, %eax
235 movl 20(%edi), %esi
236 adcl $0, %edx
237 addl %esi, %eax
238 adcl $0, %edx
239 decl %ecx
240 movl %eax, 20(%edi)
241 movl %edx, %esi
242 jz .L003maw_end
243 /* Tail Round 6 */
244 movl 24(%ebx), %eax
245 mull %ebp
246 addl %esi, %eax
247 movl 24(%edi), %esi
248 adcl $0, %edx
249 addl %esi, %eax
250 adcl $0, %edx
251 movl %eax, 24(%edi)
252 movl %edx, %esi
253.L003maw_end:
254 movl %esi, %eax
255 popl %ecx
256 popl %edi
257 popl %esi
258 popl %ebx
259 popl %ebp
260 ret
261.bn_mul_add_words_end:
262 SIZE(bn_mul_add_words,.bn_mul_add_words_end-bn_mul_add_words)
263.ident "bn_mul_add_words"
264.text
265 .align ALIGN
266.globl bn_mul_words
267 TYPE(bn_mul_words,@function)
268bn_mul_words:
269 pushl %ebp
270 pushl %ebx
271 pushl %esi
272 pushl %edi
273
274
275 xorl %esi, %esi
276 movl 20(%esp), %edi
277 movl 24(%esp), %ebx
278 movl 28(%esp), %ebp
279 movl 32(%esp), %ecx
280 andl $4294967288, %ebp
281 jz .L004mw_finish
282.L005mw_loop:
283 /* Round 0 */
284 movl (%ebx), %eax
285 mull %ecx
286 addl %esi, %eax
287 adcl $0, %edx
288 movl %eax, (%edi)
289 movl %edx, %esi
290 /* Round 4 */
291 movl 4(%ebx), %eax
292 mull %ecx
293 addl %esi, %eax
294 adcl $0, %edx
295 movl %eax, 4(%edi)
296 movl %edx, %esi
297 /* Round 8 */
298 movl 8(%ebx), %eax
299 mull %ecx
300 addl %esi, %eax
301 adcl $0, %edx
302 movl %eax, 8(%edi)
303 movl %edx, %esi
304 /* Round 12 */
305 movl 12(%ebx), %eax
306 mull %ecx
307 addl %esi, %eax
308 adcl $0, %edx
309 movl %eax, 12(%edi)
310 movl %edx, %esi
311 /* Round 16 */
312 movl 16(%ebx), %eax
313 mull %ecx
314 addl %esi, %eax
315 adcl $0, %edx
316 movl %eax, 16(%edi)
317 movl %edx, %esi
318 /* Round 20 */
319 movl 20(%ebx), %eax
320 mull %ecx
321 addl %esi, %eax
322 adcl $0, %edx
323 movl %eax, 20(%edi)
324 movl %edx, %esi
325 /* Round 24 */
326 movl 24(%ebx), %eax
327 mull %ecx
328 addl %esi, %eax
329 adcl $0, %edx
330 movl %eax, 24(%edi)
331 movl %edx, %esi
332 /* Round 28 */
333 movl 28(%ebx), %eax
334 mull %ecx
335 addl %esi, %eax
336 adcl $0, %edx
337 movl %eax, 28(%edi)
338 movl %edx, %esi
339
340 addl $32, %ebx
341 addl $32, %edi
342 subl $8, %ebp
343 jz .L004mw_finish
344 jmp .L005mw_loop
345.L004mw_finish:
346 movl 28(%esp), %ebp
347 andl $7, %ebp
348 jnz .L006mw_finish2
349 jmp .L007mw_end
350.align ALIGN
351.L006mw_finish2:
352 /* Tail Round 0 */
353 movl (%ebx), %eax
354 mull %ecx
355 addl %esi, %eax
356 adcl $0, %edx
357 movl %eax, (%edi)
358 movl %edx, %esi
359 decl %ebp
360 jz .L007mw_end
361 /* Tail Round 1 */
362 movl 4(%ebx), %eax
363 mull %ecx
364 addl %esi, %eax
365 adcl $0, %edx
366 movl %eax, 4(%edi)
367 movl %edx, %esi
368 decl %ebp
369 jz .L007mw_end
370 /* Tail Round 2 */
371 movl 8(%ebx), %eax
372 mull %ecx
373 addl %esi, %eax
374 adcl $0, %edx
375 movl %eax, 8(%edi)
376 movl %edx, %esi
377 decl %ebp
378 jz .L007mw_end
379 /* Tail Round 3 */
380 movl 12(%ebx), %eax
381 mull %ecx
382 addl %esi, %eax
383 adcl $0, %edx
384 movl %eax, 12(%edi)
385 movl %edx, %esi
386 decl %ebp
387 jz .L007mw_end
388 /* Tail Round 4 */
389 movl 16(%ebx), %eax
390 mull %ecx
391 addl %esi, %eax
392 adcl $0, %edx
393 movl %eax, 16(%edi)
394 movl %edx, %esi
395 decl %ebp
396 jz .L007mw_end
397 /* Tail Round 5 */
398 movl 20(%ebx), %eax
399 mull %ecx
400 addl %esi, %eax
401 adcl $0, %edx
402 movl %eax, 20(%edi)
403 movl %edx, %esi
404 decl %ebp
405 jz .L007mw_end
406 /* Tail Round 6 */
407 movl 24(%ebx), %eax
408 mull %ecx
409 addl %esi, %eax
410 adcl $0, %edx
411 movl %eax, 24(%edi)
412 movl %edx, %esi
413.L007mw_end:
414 movl %esi, %eax
415 popl %edi
416 popl %esi
417 popl %ebx
418 popl %ebp
419 ret
420.bn_mul_words_end:
421 SIZE(bn_mul_words,.bn_mul_words_end-bn_mul_words)
422.ident "bn_mul_words"
423.text
424 .align ALIGN
425.globl bn_sqr_words
426 TYPE(bn_sqr_words,@function)
427bn_sqr_words:
428 pushl %ebp
429 pushl %ebx
430 pushl %esi
431 pushl %edi
432
433
434 movl 20(%esp), %esi
435 movl 24(%esp), %edi
436 movl 28(%esp), %ebx
437 andl $4294967288, %ebx
438 jz .L008sw_finish
439.L009sw_loop:
440 /* Round 0 */
441 movl (%edi), %eax
442 mull %eax
443 movl %eax, (%esi)
444 movl %edx, 4(%esi)
445 /* Round 4 */
446 movl 4(%edi), %eax
447 mull %eax
448 movl %eax, 8(%esi)
449 movl %edx, 12(%esi)
450 /* Round 8 */
451 movl 8(%edi), %eax
452 mull %eax
453 movl %eax, 16(%esi)
454 movl %edx, 20(%esi)
455 /* Round 12 */
456 movl 12(%edi), %eax
457 mull %eax
458 movl %eax, 24(%esi)
459 movl %edx, 28(%esi)
460 /* Round 16 */
461 movl 16(%edi), %eax
462 mull %eax
463 movl %eax, 32(%esi)
464 movl %edx, 36(%esi)
465 /* Round 20 */
466 movl 20(%edi), %eax
467 mull %eax
468 movl %eax, 40(%esi)
469 movl %edx, 44(%esi)
470 /* Round 24 */
471 movl 24(%edi), %eax
472 mull %eax
473 movl %eax, 48(%esi)
474 movl %edx, 52(%esi)
475 /* Round 28 */
476 movl 28(%edi), %eax
477 mull %eax
478 movl %eax, 56(%esi)
479 movl %edx, 60(%esi)
480
481 addl $32, %edi
482 addl $64, %esi
483 subl $8, %ebx
484 jnz .L009sw_loop
485.L008sw_finish:
486 movl 28(%esp), %ebx
487 andl $7, %ebx
488 jz .L010sw_end
489 /* Tail Round 0 */
490 movl (%edi), %eax
491 mull %eax
492 movl %eax, (%esi)
493 decl %ebx
494 movl %edx, 4(%esi)
495 jz .L010sw_end
496 /* Tail Round 1 */
497 movl 4(%edi), %eax
498 mull %eax
499 movl %eax, 8(%esi)
500 decl %ebx
501 movl %edx, 12(%esi)
502 jz .L010sw_end
503 /* Tail Round 2 */
504 movl 8(%edi), %eax
505 mull %eax
506 movl %eax, 16(%esi)
507 decl %ebx
508 movl %edx, 20(%esi)
509 jz .L010sw_end
510 /* Tail Round 3 */
511 movl 12(%edi), %eax
512 mull %eax
513 movl %eax, 24(%esi)
514 decl %ebx
515 movl %edx, 28(%esi)
516 jz .L010sw_end
517 /* Tail Round 4 */
518 movl 16(%edi), %eax
519 mull %eax
520 movl %eax, 32(%esi)
521 decl %ebx
522 movl %edx, 36(%esi)
523 jz .L010sw_end
524 /* Tail Round 5 */
525 movl 20(%edi), %eax
526 mull %eax
527 movl %eax, 40(%esi)
528 decl %ebx
529 movl %edx, 44(%esi)
530 jz .L010sw_end
531 /* Tail Round 6 */
532 movl 24(%edi), %eax
533 mull %eax
534 movl %eax, 48(%esi)
535 movl %edx, 52(%esi)
536.L010sw_end:
537 popl %edi
538 popl %esi
539 popl %ebx
540 popl %ebp
541 ret
542.bn_sqr_words_end:
543 SIZE(bn_sqr_words,.bn_sqr_words_end-bn_sqr_words)
544.ident "bn_sqr_words"
545.text
546 .align ALIGN
547.globl bn_div64
548 TYPE(bn_div64,@function)
549bn_div64:
550 pushl %ebp
551 pushl %ebx
552 pushl %esi
553 pushl %edi
554
555 movl 20(%esp), %edx
556 movl 24(%esp), %eax
557 movl 28(%esp), %ebx
558 divl %ebx
559 popl %edi
560 popl %esi
561 popl %ebx
562 popl %ebp
563 ret
564.bn_div64_end:
565 SIZE(bn_div64,.bn_div64_end-bn_div64)
566.ident "bn_div64"
567.text
568 .align ALIGN
569.globl bn_add_words
570 TYPE(bn_add_words,@function)
571bn_add_words:
572 pushl %ebp
573 pushl %ebx
574 pushl %esi
575 pushl %edi
576
577
578 movl 20(%esp), %ebx
579 movl 24(%esp), %esi
580 movl 28(%esp), %edi
581 movl 32(%esp), %ebp
582 xorl %eax, %eax
583 andl $4294967288, %ebp
584 jz .L011aw_finish
585.L012aw_loop:
586 /* Round 0 */
587 movl (%esi), %ecx
588 movl (%edi), %edx
589 addl %eax, %ecx
590 movl $0, %eax
591 adcl %eax, %eax
592 addl %edx, %ecx
593 adcl $0, %eax
594 movl %ecx, (%ebx)
595 /* Round 1 */
596 movl 4(%esi), %ecx
597 movl 4(%edi), %edx
598 addl %eax, %ecx
599 movl $0, %eax
600 adcl %eax, %eax
601 addl %edx, %ecx
602 adcl $0, %eax
603 movl %ecx, 4(%ebx)
604 /* Round 2 */
605 movl 8(%esi), %ecx
606 movl 8(%edi), %edx
607 addl %eax, %ecx
608 movl $0, %eax
609 adcl %eax, %eax
610 addl %edx, %ecx
611 adcl $0, %eax
612 movl %ecx, 8(%ebx)
613 /* Round 3 */
614 movl 12(%esi), %ecx
615 movl 12(%edi), %edx
616 addl %eax, %ecx
617 movl $0, %eax
618 adcl %eax, %eax
619 addl %edx, %ecx
620 adcl $0, %eax
621 movl %ecx, 12(%ebx)
622 /* Round 4 */
623 movl 16(%esi), %ecx
624 movl 16(%edi), %edx
625 addl %eax, %ecx
626 movl $0, %eax
627 adcl %eax, %eax
628 addl %edx, %ecx
629 adcl $0, %eax
630 movl %ecx, 16(%ebx)
631 /* Round 5 */
632 movl 20(%esi), %ecx
633 movl 20(%edi), %edx
634 addl %eax, %ecx
635 movl $0, %eax
636 adcl %eax, %eax
637 addl %edx, %ecx
638 adcl $0, %eax
639 movl %ecx, 20(%ebx)
640 /* Round 6 */
641 movl 24(%esi), %ecx
642 movl 24(%edi), %edx
643 addl %eax, %ecx
644 movl $0, %eax
645 adcl %eax, %eax
646 addl %edx, %ecx
647 adcl $0, %eax
648 movl %ecx, 24(%ebx)
649 /* Round 7 */
650 movl 28(%esi), %ecx
651 movl 28(%edi), %edx
652 addl %eax, %ecx
653 movl $0, %eax
654 adcl %eax, %eax
655 addl %edx, %ecx
656 adcl $0, %eax
657 movl %ecx, 28(%ebx)
658
659 addl $32, %esi
660 addl $32, %edi
661 addl $32, %ebx
662 subl $8, %ebp
663 jnz .L012aw_loop
664.L011aw_finish:
665 movl 32(%esp), %ebp
666 andl $7, %ebp
667 jz .L013aw_end
668 /* Tail Round 0 */
669 movl (%esi), %ecx
670 movl (%edi), %edx
671 addl %eax, %ecx
672 movl $0, %eax
673 adcl %eax, %eax
674 addl %edx, %ecx
675 adcl $0, %eax
676 decl %ebp
677 movl %ecx, (%ebx)
678 jz .L013aw_end
679 /* Tail Round 1 */
680 movl 4(%esi), %ecx
681 movl 4(%edi), %edx
682 addl %eax, %ecx
683 movl $0, %eax
684 adcl %eax, %eax
685 addl %edx, %ecx
686 adcl $0, %eax
687 decl %ebp
688 movl %ecx, 4(%ebx)
689 jz .L013aw_end
690 /* Tail Round 2 */
691 movl 8(%esi), %ecx
692 movl 8(%edi), %edx
693 addl %eax, %ecx
694 movl $0, %eax
695 adcl %eax, %eax
696 addl %edx, %ecx
697 adcl $0, %eax
698 decl %ebp
699 movl %ecx, 8(%ebx)
700 jz .L013aw_end
701 /* Tail Round 3 */
702 movl 12(%esi), %ecx
703 movl 12(%edi), %edx
704 addl %eax, %ecx
705 movl $0, %eax
706 adcl %eax, %eax
707 addl %edx, %ecx
708 adcl $0, %eax
709 decl %ebp
710 movl %ecx, 12(%ebx)
711 jz .L013aw_end
712 /* Tail Round 4 */
713 movl 16(%esi), %ecx
714 movl 16(%edi), %edx
715 addl %eax, %ecx
716 movl $0, %eax
717 adcl %eax, %eax
718 addl %edx, %ecx
719 adcl $0, %eax
720 decl %ebp
721 movl %ecx, 16(%ebx)
722 jz .L013aw_end
723 /* Tail Round 5 */
724 movl 20(%esi), %ecx
725 movl 20(%edi), %edx
726 addl %eax, %ecx
727 movl $0, %eax
728 adcl %eax, %eax
729 addl %edx, %ecx
730 adcl $0, %eax
731 decl %ebp
732 movl %ecx, 20(%ebx)
733 jz .L013aw_end
734 /* Tail Round 6 */
735 movl 24(%esi), %ecx
736 movl 24(%edi), %edx
737 addl %eax, %ecx
738 movl $0, %eax
739 adcl %eax, %eax
740 addl %edx, %ecx
741 adcl $0, %eax
742 movl %ecx, 24(%ebx)
743.L013aw_end:
744 movl %eax, %eax
745 popl %edi
746 popl %esi
747 popl %ebx
748 popl %ebp
749 ret
750.bn_add_words_end:
751 SIZE(bn_add_words,.bn_add_words_end-bn_add_words)
752.ident "bn_add_words"
diff --git a/src/lib/libssl/src/crypto/bn/asm/sparc.s b/src/lib/libssl/src/crypto/bn/asm/sparc.s
new file mode 100644
index 0000000000..f9e533caa8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/asm/sparc.s
@@ -0,0 +1,462 @@
1 .file "bn_mulw.c"
2gcc2_compiled.:
3.section ".text"
4 .align 4
5 .global bn_mul_add_words
6 .type bn_mul_add_words,#function
7 .proc 016
8bn_mul_add_words:
9 !#PROLOGUE# 0
10 save %sp,-112,%sp
11 !#PROLOGUE# 1
12 mov %i0,%o0
13 mov %i1,%o2
14 mov %i2,%g1
15 mov %i3,%o1
16 mov 0,%i4
17 add %o0,12,%g4
18 add %o2,12,%o7
19.LL2:
20 mov %i4,%i3
21 mov 0,%i2
22 ld [%o0],%g2
23 mov %g2,%i1
24 ld [%o2],%g2
25 mov 0,%i0
26 umul %o1,%g2,%g3
27 rd %y,%g2
28 addcc %g3,%i1,%g3
29 addx %g2,%i0,%g2
30 addcc %g3,%i3,%g3
31 addx %g2,%i2,%g2
32 st %g3,[%o0]
33 mov %g2,%i5
34 mov 0,%i4
35 addcc %g1,-1,%g1
36 be .LL3
37 mov %i5,%i4
38 mov %i4,%i3
39 mov 0,%i2
40 ld [%g4-8],%g2
41 mov %g2,%i1
42 ld [%o7-8],%g2
43 mov 0,%i0
44 umul %o1,%g2,%g3
45 rd %y,%g2
46 addcc %g3,%i1,%g3
47 addx %g2,%i0,%g2
48 addcc %g3,%i3,%g3
49 addx %g2,%i2,%g2
50 st %g3,[%g4-8]
51 mov %g2,%i5
52 mov 0,%i4
53 addcc %g1,-1,%g1
54 be .LL3
55 mov %i5,%i4
56 mov %i4,%i3
57 mov 0,%i2
58 ld [%g4-4],%g2
59 mov %g2,%i1
60 ld [%o7-4],%g2
61 mov 0,%i0
62 umul %o1,%g2,%g3
63 rd %y,%g2
64 addcc %g3,%i1,%g3
65 addx %g2,%i0,%g2
66 addcc %g3,%i3,%g3
67 addx %g2,%i2,%g2
68 st %g3,[%g4-4]
69 mov %g2,%i5
70 mov 0,%i4
71 addcc %g1,-1,%g1
72 be .LL3
73 mov %i5,%i4
74 mov %i4,%i3
75 mov 0,%i2
76 ld [%g4],%g2
77 mov %g2,%i1
78 ld [%o7],%g2
79 mov 0,%i0
80 umul %o1,%g2,%g3
81 rd %y,%g2
82 addcc %g3,%i1,%g3
83 addx %g2,%i0,%g2
84 addcc %g3,%i3,%g3
85 addx %g2,%i2,%g2
86 st %g3,[%g4]
87 mov %g2,%i5
88 mov 0,%i4
89 addcc %g1,-1,%g1
90 be .LL3
91 mov %i5,%i4
92 add %o7,16,%o7
93 add %o2,16,%o2
94 add %g4,16,%g4
95 b .LL2
96 add %o0,16,%o0
97.LL3:
98 ret
99 restore %g0,%i4,%o0
100.LLfe1:
101 .size bn_mul_add_words,.LLfe1-bn_mul_add_words
102 .align 4
103 .global bn_mul_words
104 .type bn_mul_words,#function
105 .proc 016
106bn_mul_words:
107 !#PROLOGUE# 0
108 save %sp,-112,%sp
109 !#PROLOGUE# 1
110 mov %i0,%o7
111 mov %i1,%o0
112 mov %i2,%i4
113 mov %i3,%g4
114 mov 0,%i0
115 add %o7,12,%g1
116 add %o0,12,%i5
117.LL18:
118 mov %i0,%g3
119 mov 0,%g2
120 ld [%o0],%i2
121 umul %g4,%i2,%i3
122 rd %y,%i2
123 addcc %i3,%g3,%i3
124 addx %i2,%g2,%i2
125 st %i3,[%o7]
126 mov %i2,%i1
127 mov 0,%i0
128 addcc %i4,-1,%i4
129 be .LL19
130 mov %i1,%i0
131 mov %i0,%g3
132 mov 0,%g2
133 ld [%i5-8],%i2
134 umul %g4,%i2,%i3
135 rd %y,%i2
136 addcc %i3,%g3,%i3
137 addx %i2,%g2,%i2
138 st %i3,[%g1-8]
139 mov %i2,%i1
140 mov 0,%i0
141 addcc %i4,-1,%i4
142 be .LL19
143 mov %i1,%i0
144 mov %i0,%g3
145 mov 0,%g2
146 ld [%i5-4],%i2
147 umul %g4,%i2,%i3
148 rd %y,%i2
149 addcc %i3,%g3,%i3
150 addx %i2,%g2,%i2
151 st %i3,[%g1-4]
152 mov %i2,%i1
153 mov 0,%i0
154 addcc %i4,-1,%i4
155 be .LL19
156 mov %i1,%i0
157 mov %i0,%g3
158 mov 0,%g2
159 ld [%i5],%i2
160 umul %g4,%i2,%i3
161 rd %y,%i2
162 addcc %i3,%g3,%i3
163 addx %i2,%g2,%i2
164 st %i3,[%g1]
165 mov %i2,%i1
166 mov 0,%i0
167 addcc %i4,-1,%i4
168 be .LL19
169 mov %i1,%i0
170 add %i5,16,%i5
171 add %o0,16,%o0
172 add %g1,16,%g1
173 b .LL18
174 add %o7,16,%o7
175.LL19:
176 ret
177 restore
178.LLfe2:
179 .size bn_mul_words,.LLfe2-bn_mul_words
180 .align 4
181 .global bn_sqr_words
182 .type bn_sqr_words,#function
183 .proc 020
184bn_sqr_words:
185 !#PROLOGUE# 0
186 !#PROLOGUE# 1
187 mov %o0,%g4
188 add %g4,28,%o3
189 add %o1,12,%g1
190.LL34:
191 ld [%o1],%o0
192 addcc %o2,-1,%o2
193 umul %o0,%o0,%o5
194 rd %y,%o4
195 st %o5,[%g4]
196 mov %o4,%g3
197 mov 0,%g2
198 be .LL35
199 st %g3,[%o3-24]
200 ld [%g1-8],%o0
201 addcc %o2,-1,%o2
202 umul %o0,%o0,%o5
203 rd %y,%o4
204 st %o5,[%o3-20]
205 mov %o4,%g3
206 mov 0,%g2
207 be .LL35
208 st %g3,[%o3-16]
209 ld [%g1-4],%o0
210 addcc %o2,-1,%o2
211 umul %o0,%o0,%o5
212 rd %y,%o4
213 st %o5,[%o3-12]
214 mov %o4,%g3
215 mov 0,%g2
216 be .LL35
217 st %g3,[%o3-8]
218 ld [%g1],%o0
219 addcc %o2,-1,%o2
220 umul %o0,%o0,%o5
221 rd %y,%o4
222 st %o5,[%o3-4]
223 mov %o4,%g3
224 mov 0,%g2
225 be .LL35
226 st %g3,[%o3]
227 add %g1,16,%g1
228 add %o1,16,%o1
229 add %o3,32,%o3
230 b .LL34
231 add %g4,32,%g4
232.LL35:
233 retl
234 nop
235.LLfe3:
236 .size bn_sqr_words,.LLfe3-bn_sqr_words
237 .align 4
238 .global bn_add_words
239 .type bn_add_words,#function
240 .proc 016
241bn_add_words:
242 !#PROLOGUE# 0
243 save %sp,-112,%sp
244 !#PROLOGUE# 1
245 mov %i0,%o2
246 mov %i1,%o3
247 mov %i2,%o4
248 mov %i3,%i5
249 mov 0,%o0
250 mov 0,%o1
251 add %o2,12,%o7
252 add %o4,12,%g4
253 b .LL42
254 add %o3,12,%g1
255.LL45:
256 add %i5,-1,%i5
257 mov %i4,%g3
258 ld [%g4-8],%i4
259 mov 0,%g2
260 mov %i4,%i1
261 mov 0,%i0
262 addcc %g3,%i1,%g3
263 addx %g2,%i0,%g2
264 addcc %o1,%g3,%o1
265 addx %o0,%g2,%o0
266 st %o1,[%o7-8]
267 mov %o0,%i3
268 mov 0,%i2
269 mov %i2,%o0
270 mov %i3,%o1
271 cmp %i5,0
272 ble .LL43
273 add %i5,-1,%i5
274 ld [%g1-4],%i4
275 mov %i4,%g3
276 ld [%g4-4],%i4
277 mov 0,%g2
278 mov %i4,%i1
279 mov 0,%i0
280 addcc %g3,%i1,%g3
281 addx %g2,%i0,%g2
282 addcc %o1,%g3,%o1
283 addx %o0,%g2,%o0
284 st %o1,[%o7-4]
285 mov %o0,%i3
286 mov 0,%i2
287 mov %i2,%o0
288 mov %i3,%o1
289 cmp %i5,0
290 ble .LL43
291 add %i5,-1,%i5
292 ld [%g1],%i4
293 mov %i4,%g3
294 ld [%g4],%i4
295 mov 0,%g2
296 mov %i4,%i1
297 mov 0,%i0
298 addcc %g3,%i1,%g3
299 addx %g2,%i0,%g2
300 addcc %o1,%g3,%o1
301 addx %o0,%g2,%o0
302 st %o1,[%o7]
303 mov %o0,%i3
304 mov 0,%i2
305 mov %i2,%o0
306 mov %i3,%o1
307 cmp %i5,0
308 ble .LL43
309 add %g1,16,%g1
310 add %o3,16,%o3
311 add %g4,16,%g4
312 add %o4,16,%o4
313 add %o7,16,%o7
314 add %o2,16,%o2
315.LL42:
316 ld [%o3],%i4
317 add %i5,-1,%i5
318 mov %i4,%g3
319 ld [%o4],%i4
320 mov 0,%g2
321 mov %i4,%i1
322 mov 0,%i0
323 addcc %g3,%i1,%g3
324 addx %g2,%i0,%g2
325 addcc %o1,%g3,%o1
326 addx %o0,%g2,%o0
327 st %o1,[%o2]
328 mov %o0,%i3
329 mov 0,%i2
330 mov %i2,%o0
331 mov %i3,%o1
332 cmp %i5,0
333 bg,a .LL45
334 ld [%g1-8],%i4
335.LL43:
336 ret
337 restore %g0,%o1,%o0
338.LLfe4:
339 .size bn_add_words,.LLfe4-bn_add_words
340.section ".rodata"
341 .align 8
342.LLC0:
343 .asciz "Division would overflow (%d)\n"
344.section ".text"
345 .align 4
346 .global bn_div64
347 .type bn_div64,#function
348 .proc 016
349bn_div64:
350 !#PROLOGUE# 0
351 save %sp,-112,%sp
352 !#PROLOGUE# 1
353 mov 0,%l1
354 cmp %i2,0
355 bne .LL51
356 mov 2,%l0
357 b .LL68
358 mov -1,%i0
359.LL51:
360 call BN_num_bits_word,0
361 mov %i2,%o0
362 mov %o0,%o2
363 cmp %o2,32
364 be .LL52
365 mov 1,%o0
366 sll %o0,%o2,%o0
367 cmp %i0,%o0
368 bleu .LL69
369 mov 32,%o0
370 sethi %hi(__iob+32),%o0
371 or %o0,%lo(__iob+32),%o0
372 sethi %hi(.LLC0),%o1
373 call fprintf,0
374 or %o1,%lo(.LLC0),%o1
375 call abort,0
376 nop
377.LL52:
378 mov 32,%o0
379.LL69:
380 cmp %i0,%i2
381 blu .LL53
382 sub %o0,%o2,%o2
383 sub %i0,%i2,%i0
384.LL53:
385 cmp %o2,0
386 be .LL54
387 sll %i0,%o2,%o1
388 sll %i2,%o2,%i2
389 sub %o0,%o2,%o0
390 srl %i1,%o0,%o0
391 or %o1,%o0,%i0
392 sll %i1,%o2,%i1
393.LL54:
394 srl %i2,16,%g2
395 sethi %hi(65535),%o0
396 or %o0,%lo(65535),%o1
397 and %i2,%o1,%g3
398 mov %o0,%g4
399 sethi %hi(-65536),%o7
400 mov %o1,%g1
401.LL55:
402 srl %i0,16,%o0
403 cmp %o0,%g2
404 be .LL59
405 or %g4,%lo(65535),%o3
406 wr %g0,%g0,%y
407 nop
408 nop
409 nop
410 udiv %i0,%g2,%o3
411.LL59:
412 and %i1,%o7,%o0
413 srl %o0,16,%o5
414 smul %o3,%g3,%o4
415 smul %o3,%g2,%o2
416.LL60:
417 sub %i0,%o2,%o1
418 andcc %o1,%o7,%g0
419 bne .LL61
420 sll %o1,16,%o0
421 add %o0,%o5,%o0
422 cmp %o4,%o0
423 bleu .LL61
424 sub %o4,%g3,%o4
425 sub %o2,%g2,%o2
426 b .LL60
427 add %o3,-1,%o3
428.LL61:
429 smul %o3,%g2,%o2
430 smul %o3,%g3,%o0
431 srl %o0,16,%o1
432 sll %o0,16,%o0
433 and %o0,%o7,%o0
434 cmp %i1,%o0
435 bgeu .LL65
436 add %o2,%o1,%o2
437 add %o2,1,%o2
438.LL65:
439 cmp %i0,%o2
440 bgeu .LL66
441 sub %i1,%o0,%i1
442 add %i0,%i2,%i0
443 add %o3,-1,%o3
444.LL66:
445 addcc %l0,-1,%l0
446 be .LL56
447 sub %i0,%o2,%i0
448 sll %o3,16,%l1
449 sll %i0,16,%o0
450 srl %i1,16,%o1
451 or %o0,%o1,%i0
452 and %i1,%g1,%o0
453 b .LL55
454 sll %o0,16,%i1
455.LL56:
456 or %l1,%o3,%i0
457.LL68:
458 ret
459 restore
460.LLfe5:
461 .size bn_div64,.LLfe5-bn_div64
462 .ident "GCC: (GNU) 2.7.2.3"
diff --git a/src/lib/libssl/src/crypto/bn/asm/x86w16.asm b/src/lib/libssl/src/crypto/bn/asm/x86w16.asm
new file mode 100644
index 0000000000..74a933a8cd
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/asm/x86w16.asm
@@ -0,0 +1,297 @@
1; Static Name Aliases
2;
3 TITLE bn_mulw.c
4 .8087
5F_TEXT SEGMENT WORD PUBLIC 'CODE'
6F_TEXT ENDS
7_DATA SEGMENT WORD PUBLIC 'DATA'
8_DATA ENDS
9CONST SEGMENT WORD PUBLIC 'CONST'
10CONST ENDS
11_BSS SEGMENT WORD PUBLIC 'BSS'
12_BSS ENDS
13DGROUP GROUP CONST, _BSS, _DATA
14 ASSUME DS: DGROUP, SS: DGROUP
15F_TEXT SEGMENT
16 ASSUME CS: F_TEXT
17 PUBLIC _bn_mul_add_words
18_bn_mul_add_words PROC FAR
19; Line 58
20 push bp
21 push bx
22 push si
23 push di
24 push ds
25 push es
26 mov bp,sp
27; w = 26
28; num = 24
29; ap = 20
30; rp = 16
31 xor si,si ;c=0;
32 mov di,WORD PTR [bp+16] ; load r
33 mov ds,WORD PTR [bp+18] ; load r
34 mov bx,WORD PTR [bp+20] ; load a
35 mov es,WORD PTR [bp+22] ; load a
36 mov cx,WORD PTR [bp+26] ; load w
37 mov bp,WORD PTR [bp+24] ; load num
38
39 shr bp,1 ; div count by 4 and do groups of 4
40 shr bp,1
41 je $L555
42
43$L546:
44 mov ax,cx
45 mul WORD PTR es:[bx] ; w* *a
46 add ax,WORD PTR ds:[di] ; + *r
47 adc dx,0
48 adc ax,si
49 adc dx,0
50 mov WORD PTR ds:[di],ax
51 mov si,dx
52 ;
53 mov ax,cx
54 mul WORD PTR es:[bx+2] ; w* *a
55 add ax,WORD PTR ds:[di+2] ; + *r
56 adc dx,0
57 adc ax,si
58 adc dx,0
59 mov WORD PTR ds:[di+2],ax
60 mov si,dx
61 ;
62 mov ax,cx
63 mul WORD PTR es:[bx+4] ; w* *a
64 add ax,WORD PTR ds:[di+4] ; + *r
65 adc dx,0
66 adc ax,si
67 adc dx,0
68 mov WORD PTR ds:[di+4],ax
69 mov si,dx
70 ;
71 mov ax,cx
72 mul WORD PTR es:[bx+6] ; w* *a
73 add ax,WORD PTR ds:[di+6] ; + *r
74 adc dx,0
75 adc ax,si
76 adc dx,0
77 mov WORD PTR ds:[di+6],ax
78 mov si,dx
79 ;
80 add bx,8
81 add di,8
82 ;
83 dec bp
84 je $L555
85 jmp $L546
86;
87;
88$L555:
89 mov bp,sp
90 mov bp,WORD PTR [bp+24] ; load num
91 and bp,3
92 dec bp
93 js $L547
94
95 mov ax,cx
96 mul WORD PTR es:[bx] ; w* *a
97 add ax,WORD PTR ds:[di] ; + *r
98 adc dx,0
99 adc ax,si
100 adc dx,0
101 mov WORD PTR ds:[di],ax
102 mov si,dx
103 dec bp
104 js $L547 ; Note that we are now testing for -1
105 ;
106 mov ax,cx
107 mul WORD PTR es:[bx+2] ; w* *a
108 add ax,WORD PTR ds:[di+2] ; + *r
109 adc dx,0
110 adc ax,si
111 adc dx,0
112 mov WORD PTR ds:[di+2],ax
113 mov si,dx
114 dec bp
115 js $L547
116 ;
117 mov ax,cx
118 mul WORD PTR es:[bx+4] ; w* *a
119 add ax,WORD PTR ds:[di+4] ; + *r
120 adc dx,0
121 adc ax,si
122 adc dx,0
123 mov WORD PTR ds:[di+4],ax
124 mov si,dx
125$L547:
126 mov ax,si
127 pop es
128 pop ds
129 pop di
130 pop si
131 pop bx
132 pop bp
133 ret
134 nop
135
136_bn_mul_add_words ENDP
137 PUBLIC _bn_mul_words
138_bn_mul_words PROC FAR
139; Line 76
140 push bp
141 push bx
142 push si
143 push di
144 push ds
145 push es
146 xor si,si
147 mov bp,sp
148 mov di,WORD PTR [bp+16] ; r
149 mov ds,WORD PTR [bp+18]
150 mov bx,WORD PTR [bp+20] ; a
151 mov es,WORD PTR [bp+22]
152 mov cx,WORD PTR [bp+26] ; w
153 mov bp,WORD PTR [bp+24] ; num
154$FC743:
155 mov ax,cx
156 mul WORD PTR es:[bx]
157 add ax,si
158 adc dx,0
159 mov WORD PTR ds:[di],ax
160 mov si,dx
161 dec bp
162 je $L764
163 ;
164 mov ax,cx
165 mul WORD PTR es:[bx+2]
166 add ax,si
167 adc dx,0
168 mov WORD PTR ds:[di+2],ax
169 mov si,dx
170 dec bp
171 je $L764
172 ;
173 mov ax,cx
174 mul WORD PTR es:[bx+4]
175 add ax,si
176 adc dx,0
177 mov WORD PTR ds:[di+4],ax
178 mov si,dx
179 dec bp
180 je $L764
181 ;
182 mov ax,cx
183 mul WORD PTR es:[bx+6]
184 add ax,si
185 adc dx,0
186 mov WORD PTR ds:[di+6],ax
187 mov si,dx
188 dec bp
189 je $L764
190 ;
191 add bx,8
192 add di,8
193 jmp $FC743
194 nop
195$L764:
196 mov ax,si
197 pop es
198 pop ds
199 pop di
200 pop si
201 pop bx
202 pop bp
203 ret
204 nop
205_bn_mul_words ENDP
206 PUBLIC _bn_sqr_words
207_bn_sqr_words PROC FAR
208; Line 92
209 push bp
210 push bx
211 push si
212 push di
213 push ds
214 push es
215 mov bp,sp
216 mov si,WORD PTR [bp+16]
217 mov ds,WORD PTR [bp+18]
218 mov di,WORD PTR [bp+20]
219 mov es,WORD PTR [bp+22]
220 mov bx,WORD PTR [bp+24]
221
222 mov bp,bx ; save a memory lookup later
223 shr bx,1 ; div count by 4 and do groups of 4
224 shr bx,1
225 je $L666
226
227$L765:
228 mov ax,WORD PTR es:[di]
229 mul ax
230 mov WORD PTR ds:[si],ax
231 mov WORD PTR ds:[si+2],dx
232 ;
233 mov ax,WORD PTR es:[di+2]
234 mul ax
235 mov WORD PTR ds:[si+4],ax
236 mov WORD PTR ds:[si+6],dx
237 ;
238 mov ax,WORD PTR es:[di+4]
239 mul ax
240 mov WORD PTR ds:[si+8],ax
241 mov WORD PTR ds:[si+10],dx
242 ;
243 mov ax,WORD PTR es:[di+6]
244 mul ax
245 mov WORD PTR ds:[si+12],ax
246 mov WORD PTR ds:[si+14],dx
247 ;
248 add di,8
249 add si,16
250 dec bx
251 je $L666
252 jmp $L765
253$L666:
254 and bp,3
255 dec bp ; The copied value of bx (num)
256 js $L645
257 ;
258 mov ax,WORD PTR es:[di]
259 mul ax
260 mov WORD PTR ds:[si],ax
261 mov WORD PTR ds:[si+2],dx
262 dec bp
263 js $L645
264 ;
265 mov ax,WORD PTR es:[di+2]
266 mul ax
267 mov WORD PTR ds:[si+4],ax
268 mov WORD PTR ds:[si+6],dx
269 dec bp
270 js $L645
271 ;
272 mov ax,WORD PTR es:[di+4]
273 mul ax
274 mov WORD PTR ds:[si+8],ax
275 mov WORD PTR ds:[si+10],dx
276$L645:
277 pop es
278 pop ds
279 pop di
280 pop si
281 pop bx
282 pop bp
283 ret
284
285_bn_sqr_words ENDP
286 PUBLIC _bn_div64
287_bn_div64 PROC FAR
288 push bp
289 mov bp,sp
290 mov dx, WORD PTR [bp+6]
291 mov ax, WORD PTR [bp+8]
292 div WORD PTR [bp+10]
293 pop bp
294 ret
295_bn_div64 ENDP
296F_TEXT ENDS
297END
diff --git a/src/lib/libssl/src/crypto/bn/asm/x86w32.asm b/src/lib/libssl/src/crypto/bn/asm/x86w32.asm
new file mode 100644
index 0000000000..fc6f917714
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/asm/x86w32.asm
@@ -0,0 +1,362 @@
1; Static Name Aliases
2;
3 TITLE bn_mulw.c
4 .386
5F_TEXT SEGMENT WORD USE16 PUBLIC 'CODE'
6F_TEXT ENDS
7_DATA SEGMENT WORD USE16 PUBLIC 'DATA'
8_DATA ENDS
9CONST SEGMENT WORD USE16 PUBLIC 'CONST'
10CONST ENDS
11_BSS SEGMENT WORD USE16 PUBLIC 'BSS'
12_BSS ENDS
13DGROUP GROUP CONST, _BSS, _DATA
14 ASSUME DS: DGROUP, SS: DGROUP
15F_TEXT SEGMENT
16 ASSUME CS: F_TEXT
17 PUBLIC _bn_mul_add_words
18_bn_mul_add_words PROC FAR
19; Line 58
20 push bp
21 push bx
22 push esi
23 push di
24 push ds
25 push es
26 mov bp,sp
27; w = 28
28; num = 26
29; ap = 22
30; rp = 18
31 xor esi,esi ;c=0;
32 mov di,WORD PTR [bp+18] ; load r
33 mov ds,WORD PTR [bp+20] ; load r
34 mov bx,WORD PTR [bp+22] ; load a
35 mov es,WORD PTR [bp+24] ; load a
36 mov ecx,DWORD PTR [bp+28] ; load w
37 mov bp,WORD PTR [bp+26] ; load num
38 shr bp,1 ; div count by 4 and do groups of 4
39 shr bp,1
40 je $L555
41
42$L546:
43 mov eax,ecx
44 mul DWORD PTR es:[bx] ; w* *a
45 add eax,DWORD PTR ds:[di] ; + *r
46 adc edx,0
47 adc eax,esi
48 adc edx,0
49 mov DWORD PTR ds:[di],eax
50 mov esi,edx
51 ;
52 mov eax,ecx
53 mul DWORD PTR es:[bx+4] ; w* *a
54 add eax,DWORD PTR ds:[di+4] ; + *r
55 adc edx,0
56 adc eax,esi
57 adc edx,0
58 mov DWORD PTR ds:[di+4],eax
59 mov esi,edx
60 ;
61 mov eax,ecx
62 mul DWORD PTR es:[bx+8] ; w* *a
63 add eax,DWORD PTR ds:[di+8] ; + *r
64 adc edx,0
65 adc eax,esi
66 adc edx,0
67 mov DWORD PTR ds:[di+8],eax
68 mov esi,edx
69 ;
70 mov eax,ecx
71 mul DWORD PTR es:[bx+12] ; w* *a
72 add eax,DWORD PTR ds:[di+12] ; + *r
73 adc edx,0
74 adc eax,esi
75 adc edx,0
76 mov DWORD PTR ds:[di+12],eax
77 mov esi,edx
78 ;
79 add bx,16
80 add di,16
81 ;
82 dec bp
83 je $L555
84 jmp $L546
85;
86;
87$L555:
88 mov bp,sp
89 mov bp,WORD PTR [bp+26] ; load num
90 and bp,3
91 dec bp
92 js $L547
93
94 mov eax,ecx
95 mul DWORD PTR es:[bx] ; w* *a
96 add eax,DWORD PTR ds:[di] ; + *r
97 adc edx,0
98 adc eax,esi
99 adc edx,0
100 mov DWORD PTR ds:[di],eax
101 mov esi,edx
102 dec bp
103 js $L547 ; Note that we are now testing for -1
104 ;
105 mov eax,ecx
106 mul DWORD PTR es:[bx+4] ; w* *a
107 add eax,DWORD PTR ds:[di+4] ; + *r
108 adc edx,0
109 adc eax,esi
110 adc edx,0
111 mov DWORD PTR ds:[di+4],eax
112 mov esi,edx
113 dec bp
114 js $L547
115 ;
116 mov eax,ecx
117 mul DWORD PTR es:[bx+8] ; w* *a
118 add eax,DWORD PTR ds:[di+8] ; + *r
119 adc edx,0
120 adc eax,esi
121 adc edx,0
122 mov DWORD PTR ds:[di+8],eax
123 mov esi,edx
124$L547:
125 mov eax,esi
126 mov edx,esi
127 shr edx,16
128 pop es
129 pop ds
130 pop di
131 pop esi
132 pop bx
133 pop bp
134 ret
135 nop
136_bn_mul_add_words ENDP
137
138 PUBLIC _bn_mul_words
139_bn_mul_words PROC FAR
140; Line 76
141 push bp
142 push bx
143 push esi
144 push di
145 push ds
146 push es
147 xor esi,esi
148 mov bp,sp
149 mov di,WORD PTR [bp+18] ; r
150 mov ds,WORD PTR [bp+20]
151 mov bx,WORD PTR [bp+22] ; a
152 mov es,WORD PTR [bp+24]
153 mov ecx,DWORD PTR [bp+28] ; w
154 mov bp,WORD PTR [bp+26] ; num
155
156$FC743:
157 mov eax,ecx
158 mul DWORD PTR es:[bx]
159 add eax,esi
160 adc edx,0
161 mov DWORD PTR ds:[di],eax
162 mov esi,edx
163 dec bp
164 je $L764
165 ;
166 mov eax,ecx
167 mul DWORD PTR es:[bx+4]
168 add eax,esi
169 adc edx,0
170 mov DWORD PTR ds:[di+4],eax
171 mov esi,edx
172 dec bp
173 je $L764
174 ;
175 mov eax,ecx
176 mul DWORD PTR es:[bx+8]
177 add eax,esi
178 adc edx,0
179 mov DWORD PTR ds:[di+8],eax
180 mov esi,edx
181 dec bp
182 je $L764
183 ;
184 mov eax,ecx
185 mul DWORD PTR es:[bx+12]
186 add eax,esi
187 adc edx,0
188 mov DWORD PTR ds:[di+12],eax
189 mov esi,edx
190 dec bp
191 je $L764
192 ;
193 add bx,16
194 add di,16
195 jmp $FC743
196 nop
197$L764:
198 mov eax,esi
199 mov edx,esi
200 shr edx,16
201 pop es
202 pop ds
203 pop di
204 pop esi
205 pop bx
206 pop bp
207 ret
208 nop
209_bn_mul_words ENDP
210 PUBLIC _bn_sqr_words
211_bn_sqr_words PROC FAR
212; Line 92
213 push bp
214 push bx
215 push si
216 push di
217 push ds
218 push es
219 mov bp,sp
220 mov si,WORD PTR [bp+16]
221 mov ds,WORD PTR [bp+18]
222 mov di,WORD PTR [bp+20]
223 mov es,WORD PTR [bp+22]
224 mov bx,WORD PTR [bp+24]
225
226 mov bp,bx ; save a memory lookup later
227 shr bx,1 ; div count by 4 and do groups of 4
228 shr bx,1
229 je $L666
230
231$L765:
232 mov eax,DWORD PTR es:[di]
233 mul eax
234 mov DWORD PTR ds:[si],eax
235 mov DWORD PTR ds:[si+4],edx
236 ;
237 mov eax,DWORD PTR es:[di+4]
238 mul eax
239 mov DWORD PTR ds:[si+8],eax
240 mov DWORD PTR ds:[si+12],edx
241 ;
242 mov eax,DWORD PTR es:[di+8]
243 mul eax
244 mov DWORD PTR ds:[si+16],eax
245 mov DWORD PTR ds:[si+20],edx
246 ;
247 mov eax,DWORD PTR es:[di+12]
248 mul eax
249 mov DWORD PTR ds:[si+24],eax
250 mov DWORD PTR ds:[si+28],edx
251 ;
252 add di,16
253 add si,32
254 dec bx
255 je $L666
256 jmp $L765
257$L666:
258 and bp,3
259 dec bp ; The copied value of bx (num)
260 js $L645
261 ;
262 mov eax,DWORD PTR es:[di]
263 mul eax
264 mov DWORD PTR ds:[si],eax
265 mov DWORD PTR ds:[si+4],edx
266 dec bp
267 js $L645
268 ;
269 mov eax,DWORD PTR es:[di+4]
270 mul eax
271 mov DWORD PTR ds:[si+8],eax
272 mov DWORD PTR ds:[si+12],edx
273 dec bp
274 js $L645
275 ;
276 mov eax,DWORD PTR es:[di+8]
277 mul eax
278 mov DWORD PTR ds:[si+16],eax
279 mov DWORD PTR ds:[si+20],edx
280$L645:
281 pop es
282 pop ds
283 pop di
284 pop si
285 pop bx
286 pop bp
287 ret
288_bn_sqr_words ENDP
289
290 PUBLIC _bn_div64
291_bn_div64 PROC FAR
292 push bp
293 mov bp,sp
294 mov edx, DWORD PTR [bp+6]
295 mov eax, DWORD PTR [bp+10]
296 div DWORD PTR [bp+14]
297 mov edx,eax
298 shr edx,16
299 pop bp
300 ret
301_bn_div64 ENDP
302
303 PUBLIC _bn_add_words
304_bn_add_words PROC FAR
305; Line 58
306 push bp
307 push bx
308 push esi
309 push di
310 push ds
311 push es
312 mov bp,sp
313; w = 28
314; num = 26
315; ap = 22
316; rp = 18
317 xor esi,esi ;c=0;
318 mov si,WORD PTR [bp+22] ; load a
319 mov es,WORD PTR [bp+24] ; load a
320 mov di,WORD PTR [bp+26] ; load b
321 mov ds,WORD PTR [bp+28] ; load b
322
323 mov dx,WORD PTR [bp+30] ; load num
324 dec dx
325 js $L547
326 xor ecx,ecx
327
328$L5477:
329 xor ebx,ebx
330 mov eax,DWORD PTR es:[si] ; *a
331 add eax,ecx
332 adc ebx,0
333 add si,4 ; a++
334 add eax,DWORD PTR ds:[di] ; + *b
335 mov ecx,ebx
336 adc ecx,0
337 add di,4
338 mov bx,WORD PTR [bp+18]
339 mov ds,WORD PTR [bp+20]
340 mov DWORD PTR ds:[bx],eax
341 add bx,4
342 mov ds,WORD PTR [bp+28]
343 mov WORD PTR [bp+18],bx
344 dec dx
345 js $L547 ; Note that we are now testing for -1
346 jmp $L5477
347 ;
348$L547:
349 mov eax,ecx
350 mov edx,ecx
351 shr edx,16
352 pop es
353 pop ds
354 pop di
355 pop esi
356 pop bx
357 pop bp
358 ret
359 nop
360_bn_add_words ENDP
361F_TEXT ENDS
362END
diff --git a/src/lib/libssl/src/crypto/bn/bn.err b/src/lib/libssl/src/crypto/bn/bn.err
new file mode 100644
index 0000000000..7ccc247c41
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/bn.err
@@ -0,0 +1,27 @@
1/* Error codes for the BN functions. */
2
3/* Function codes. */
4#define BN_F_BN_BLINDING_CONVERT 100
5#define BN_F_BN_BLINDING_INVERT 101
6#define BN_F_BN_BLINDING_NEW 102
7#define BN_F_BN_BLINDING_UPDATE 103
8#define BN_F_BN_BN2DEC 104
9#define BN_F_BN_BN2HEX 105
10#define BN_F_BN_CTX_NEW 106
11#define BN_F_BN_DIV 107
12#define BN_F_BN_EXPAND2 108
13#define BN_F_BN_MOD_EXP_MONT 109
14#define BN_F_BN_MOD_INVERSE 110
15#define BN_F_BN_MOD_MUL_RECIPROCAL 111
16#define BN_F_BN_MPI2BN 112
17#define BN_F_BN_NEW 113
18#define BN_F_BN_RAND 114
19
20/* Reason codes. */
21#define BN_R_BAD_RECIPROCAL 100
22#define BN_R_CALLED_WITH_EVEN_MODULUS 101
23#define BN_R_DIV_BY_ZERO 102
24#define BN_R_ENCODING_ERROR 103
25#define BN_R_INVALID_LENGTH 104
26#define BN_R_NOT_INITALISED 105
27#define BN_R_NO_INVERSE 106
diff --git a/src/lib/libssl/src/crypto/bn/bn.org b/src/lib/libssl/src/crypto/bn/bn.org
new file mode 100644
index 0000000000..66dde285d6
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/bn.org
@@ -0,0 +1,502 @@
1/* crypto/bn/bn.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify bn.org since bn.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_BN_H
68#define HEADER_BN_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74#undef BN_LLONG
75
76#ifdef WIN32
77#define BN_LLONG /* This comment stops Configure mutilating things */
78#endif
79
80#define RECP_MUL_MOD
81#define MONT_MUL_MOD
82
83/* This next option uses the C libraries (2 word)/(1 word) function.
84 * If it is not defined, I use my C version (which is slower).
85 * The reason for this flag is that when the particular C compiler
86 * library routine is used, and the library is linked with a different
87 * compiler, the library is missing. This mostly happens when the
88 * library is built with gcc and then linked using nornal cc. This would
89 * be a common occurance because gcc normally produces code that is
90 * 2 times faster than system compilers for the big number stuff.
91 * For machines with only one compiler (or shared libraries), this should
92 * be on. Again this in only really a problem on machines
93 * using "long long's", are 32bit, and are not using my assember code. */
94#if defined(MSDOS) || defined(WINDOWS) || defined(linux)
95#define BN_DIV2W
96#endif
97
98/* Only one for the following should be defined */
99/* The prime number generation stuff may not work when
100 * EIGHT_BIT but I don't care since I've only used this mode
101 * for debuging the bignum libraries */
102#undef SIXTY_FOUR_BIT_LONG
103#undef SIXTY_FOUR_BIT
104#define THIRTY_TWO_BIT
105#undef SIXTEEN_BIT
106#undef EIGHT_BIT
107
108/* assuming long is 64bit - this is the DEC Alpha
109 * unsigned long long is only 64 bits :-(, don't define
110 * BN_LLONG for the DEC Alpha */
111#ifdef SIXTY_FOUR_BIT_LONG
112#define BN_ULLONG unsigned long long
113#define BN_ULONG unsigned long
114#define BN_LONG long
115#define BN_BITS 128
116#define BN_BYTES 8
117#define BN_BITS2 64
118#define BN_BITS4 32
119#define BN_MASK2 (0xffffffffffffffffL)
120#define BN_MASK2l (0xffffffffL)
121#define BN_MASK2h (0xffffffff00000000L)
122#define BN_MASK2h1 (0xffffffff80000000L)
123#define BN_TBIT (0x8000000000000000L)
124#define BN_DEC_CONV (10000000000000000000L)
125#define BN_DEC_FMT1 "%lu"
126#define BN_DEC_FMT2 "%019lu"
127#define BN_DEC_NUM 19
128#endif
129
130#ifdef SIXTY_FOUR_BIT
131#undef BN_LLONG
132/* #define BN_ULLONG unsigned long long */
133#define BN_ULONG unsigned long long
134#define BN_LONG long long
135#define BN_BITS 128
136#define BN_BYTES 8
137#define BN_BITS2 64
138#define BN_BITS4 32
139#define BN_MASK2 (0xffffffffffffffffLL)
140#define BN_MASK2l (0xffffffffL)
141#define BN_MASK2h (0xffffffff00000000LL)
142#define BN_MASK2h1 (0xffffffff80000000LL)
143#define BN_TBIT (0x8000000000000000LL)
144#define BN_DEC_CONV (10000000000000000000L)
145#define BN_DEC_FMT1 "%lu"
146#define BN_DEC_FMT2 "%019lu"
147#define BN_DEC_NUM 19
148#endif
149
150#ifdef THIRTY_TWO_BIT
151#ifdef WIN32
152#define BN_ULLONG unsigned _int64
153#else
154#define BN_ULLONG unsigned long long
155#endif
156#define BN_ULONG unsigned long
157#define BN_LONG long
158#define BN_BITS 64
159#define BN_BYTES 4
160#define BN_BITS2 32
161#define BN_BITS4 16
162#define BN_MASK2 (0xffffffffL)
163#define BN_MASK2l (0xffff)
164#define BN_MASK2h1 (0xffff8000L)
165#define BN_MASK2h (0xffff0000L)
166#define BN_TBIT (0x80000000L)
167#define BN_DEC_CONV (1000000000L)
168#define BN_DEC_FMT1 "%lu"
169#define BN_DEC_FMT2 "%09lu"
170#define BN_DEC_NUM 9
171#endif
172
173#ifdef SIXTEEN_BIT
174#ifndef BN_DIV2W
175#define BN_DIV2W
176#endif
177#define BN_ULLONG unsigned long
178#define BN_ULONG unsigned short
179#define BN_LONG short
180#define BN_BITS 32
181#define BN_BYTES 2
182#define BN_BITS2 16
183#define BN_BITS4 8
184#define BN_MASK2 (0xffff)
185#define BN_MASK2l (0xff)
186#define BN_MASK2h1 (0xff80)
187#define BN_MASK2h (0xff00)
188#define BN_TBIT (0x8000)
189#define BN_DEC_CONV (100000)
190#define BN_DEC_FMT1 "%u"
191#define BN_DEC_FMT2 "%05u"
192#define BN_DEC_NUM 5
193#endif
194
195#ifdef EIGHT_BIT
196#ifndef BN_DIV2W
197#define BN_DIV2W
198#endif
199#define BN_ULLONG unsigned short
200#define BN_ULONG unsigned char
201#define BN_LONG char
202#define BN_BITS 16
203#define BN_BYTES 1
204#define BN_BITS2 8
205#define BN_BITS4 4
206#define BN_MASK2 (0xff)
207#define BN_MASK2l (0xf)
208#define BN_MASK2h1 (0xf8)
209#define BN_MASK2h (0xf0)
210#define BN_TBIT (0x80)
211#define BN_DEC_CONV (100)
212#define BN_DEC_FMT1 "%u"
213#define BN_DEC_FMT2 "%02u"
214#define BN_DEC_NUM 2
215#endif
216
217#define BN_DEFAULT_BITS 1280
218
219#ifdef BIGNUM
220#undef BIGNUM
221#endif
222
223typedef struct bignum_st
224 {
225 BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
226 int top; /* Index of last used d +1. */
227 /* The next are internal book keeping for bn_expand. */
228 int max; /* Size of the d array. */
229 int neg; /* one if the number is negative */
230 } BIGNUM;
231
232/* Used for temp variables */
233#define BN_CTX_NUM 12
234typedef struct bignum_ctx
235 {
236 int tos;
237 BIGNUM *bn[BN_CTX_NUM+1];
238 } BN_CTX;
239
240typedef struct bn_blinding_st
241 {
242 int init;
243 BIGNUM *A;
244 BIGNUM *Ai;
245 BIGNUM *mod; /* just a reference */
246 } BN_BLINDING;
247
248/* Used for montgomery multiplication */
249typedef struct bn_mont_ctx_st
250 {
251 int ri; /* number of bits in R */
252 BIGNUM *RR; /* used to convert to montgomery form */
253 BIGNUM *N; /* The modulus */
254 BIGNUM *Ni; /* The inverse of N */
255 BN_ULONG n0; /* word form of inverse, normally only one of
256 * Ni or n0 is defined */
257 } BN_MONT_CTX;
258
259#define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\
260 r,a,(mont)->RR,(mont),ctx)
261
262#define BN_prime_checks (5)
263
264#define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
265#define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w)))
266#define BN_is_zero(a) (((a)->top <= 1) && ((a)->d[0] == (BN_ULONG)0))
267#define BN_is_one(a) (BN_is_word((a),1))
268#define BN_is_odd(a) ((a)->d[0] & 1)
269#define BN_one(a) (BN_set_word((a),1))
270#define BN_zero(a) (BN_set_word((a),0))
271
272#define BN_ascii2bn(a) BN_hex2bn(a)
273#define BN_bn2ascii(a) BN_bn2hex(a)
274
275#define bn_fix_top(a) \
276 { \
277 BN_ULONG *fix_top_l; \
278 for (fix_top_l= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
279 if (*(fix_top_l--)) break; \
280 }
281
282#define bn_expand(n,b) ((((b)/BN_BITS2) <= (n)->max)?\
283 (n):bn_expand2((n),(b)/BN_BITS2))
284#define bn_wexpand(n,b) (((b) <= (n)->max)?(n):bn_expand2((n),(b)))
285
286
287#ifndef NOPROTO
288BIGNUM *BN_value_one(void);
289char * BN_options(void);
290BN_CTX *BN_CTX_new(void);
291void BN_CTX_free(BN_CTX *c);
292int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
293int BN_num_bits(BIGNUM *a);
294int BN_num_bits_word(BN_ULONG);
295BIGNUM *BN_new(void);
296void BN_clear_free(BIGNUM *a);
297BIGNUM *BN_copy(BIGNUM *a, BIGNUM *b);
298BIGNUM *BN_bin2bn(unsigned char *s,int len,BIGNUM *ret);
299int BN_bn2bin(BIGNUM *a, unsigned char *to);
300BIGNUM *BN_mpi2bn(unsigned char *s,int len,BIGNUM *ret);
301int BN_bn2mpi(BIGNUM *a, unsigned char *to);
302int BN_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b);
303void bn_qsub(BIGNUM *r, BIGNUM *a, BIGNUM *b);
304void bn_qadd(BIGNUM *r, BIGNUM *a, BIGNUM *b);
305int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b);
306int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx);
307int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx);
308int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b);
309int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx);
310BN_ULONG BN_mod_word(BIGNUM *a, unsigned long w);
311BN_ULONG BN_div_word(BIGNUM *a, unsigned long w);
312int BN_mul_word(BIGNUM *a, unsigned long w);
313int BN_add_word(BIGNUM *a, unsigned long w);
314int BN_sub_word(BIGNUM *a, unsigned long w);
315int BN_set_word(BIGNUM *a, unsigned long w);
316unsigned long BN_get_word(BIGNUM *a);
317int BN_cmp(BIGNUM *a, BIGNUM *b);
318void BN_free(BIGNUM *a);
319int BN_is_bit_set(BIGNUM *a, int n);
320int BN_lshift(BIGNUM *r, BIGNUM *a, int n);
321int BN_lshift1(BIGNUM *r, BIGNUM *a);
322int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p,BN_CTX *ctx);
323int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx);
324int BN_mod_exp_mont(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx,
325 BN_MONT_CTX *m_ctx);
326int BN_mod_exp_recp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx);
327int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p,
328 BIGNUM *m,BN_CTX *ctx);
329int BN_mask_bits(BIGNUM *a,int n);
330int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BIGNUM *m,
331 BIGNUM *i, int nb, BN_CTX *ctx);
332int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, BIGNUM *m,
333 BN_CTX *ctx);
334#ifndef WIN16
335int BN_print_fp(FILE *fp, BIGNUM *a);
336#endif
337#ifdef HEADER_BIO_H
338int BN_print(BIO *fp, BIGNUM *a);
339#else
340int BN_print(char *fp, BIGNUM *a);
341#endif
342int BN_reciprocal(BIGNUM *r, BIGNUM *m, BN_CTX *ctx);
343int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
344int BN_rshift1(BIGNUM *r, BIGNUM *a);
345void BN_clear(BIGNUM *a);
346BIGNUM *bn_expand2(BIGNUM *b, int bits);
347BIGNUM *BN_dup(BIGNUM *a);
348int BN_ucmp(BIGNUM *a, BIGNUM *b);
349int BN_set_bit(BIGNUM *a, int n);
350int BN_clear_bit(BIGNUM *a, int n);
351char * BN_bn2hex(BIGNUM *a);
352char * BN_bn2dec(BIGNUM *a);
353int BN_hex2bn(BIGNUM **a,char *str);
354int BN_dec2bn(BIGNUM **a,char *str);
355int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx);
356BIGNUM *BN_mod_inverse(BIGNUM *a, BIGNUM *n,BN_CTX *ctx);
357BIGNUM *BN_generate_prime(int bits,int strong,BIGNUM *add,
358 BIGNUM *rem,void (*callback)(int,int,char *),char *cb_arg);
359int BN_is_prime(BIGNUM *p,int nchecks,void (*callback)(int,int,char *),
360 BN_CTX *ctx,char *cb_arg);
361void ERR_load_BN_strings(void );
362
363BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
364BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w);
365void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num);
366BN_ULONG bn_div64(BN_ULONG h, BN_ULONG l, BN_ULONG d);
367BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num);
368
369BN_MONT_CTX *BN_MONT_CTX_new(void );
370int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont,
371 BN_CTX *ctx);
372int BN_from_montgomery(BIGNUM *r,BIGNUM *a,BN_MONT_CTX *mont,BN_CTX *ctx);
373void BN_MONT_CTX_free(BN_MONT_CTX *mont);
374int BN_MONT_CTX_set(BN_MONT_CTX *mont,BIGNUM *modulus,BN_CTX *ctx);
375
376BN_BLINDING *BN_BLINDING_new(BIGNUM *A,BIGNUM *Ai,BIGNUM *mod);
377void BN_BLINDING_free(BN_BLINDING *b);
378int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx);
379int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *r, BN_CTX *ctx);
380int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
381
382#else
383
384BIGNUM *BN_value_one();
385char * BN_options();
386BN_CTX *BN_CTX_new();
387void BN_CTX_free();
388int BN_rand();
389int BN_num_bits();
390int BN_num_bits_word();
391BIGNUM *BN_new();
392void BN_clear_free();
393BIGNUM *BN_copy();
394BIGNUM *BN_bin2bn();
395int BN_bn2bin();
396BIGNUM *BN_mpi2bn();
397int BN_bn2mpi();
398int BN_sub();
399void bn_qsub();
400void bn_qadd();
401int BN_add();
402int BN_mod();
403int BN_div();
404int BN_mul();
405int BN_sqr();
406BN_ULONG BN_mod_word();
407BN_ULONG BN_div_word();
408int BN_add_word();
409int BN_sub_word();
410int BN_mul_word();
411int BN_set_word();
412unsigned long BN_get_word();
413int BN_cmp();
414void BN_free();
415int BN_is_bit_set();
416int BN_lshift();
417int BN_lshift1();
418int BN_exp();
419int BN_mod_exp();
420int BN_mod_exp_mont();
421int BN_mod_exp_recp();
422int BN_mod_exp_simple();
423int BN_mask_bits();
424int BN_mod_mul_reciprocal();
425int BN_mod_mul();
426#ifndef WIN16
427int BN_print_fp();
428#endif
429int BN_print();
430int BN_reciprocal();
431int BN_rshift();
432int BN_rshift1();
433void BN_clear();
434BIGNUM *bn_expand2();
435BIGNUM *BN_dup();
436int BN_ucmp();
437int BN_set_bit();
438int BN_clear_bit();
439char * BN_bn2hex();
440char * BN_bn2dec();
441int BN_hex2bn();
442int BN_dec2bn();
443int BN_gcd();
444BIGNUM *BN_mod_inverse();
445BIGNUM *BN_generate_prime();
446int BN_is_prime();
447void ERR_load_BN_strings();
448
449BN_ULONG bn_mul_add_words();
450BN_ULONG bn_mul_words();
451void bn_sqr_words();
452BN_ULONG bn_div64();
453BN_ULONG bn_add_words();
454
455int BN_mod_mul_montgomery();
456int BN_from_montgomery();
457BN_MONT_CTX *BN_MONT_CTX_new();
458void BN_MONT_CTX_free();
459int BN_MONT_CTX_set();
460
461BN_BLINDING *BN_BLINDING_new();
462void BN_BLINDING_free();
463int BN_BLINDING_update();
464int BN_BLINDING_convert();
465int BN_BLINDING_invert();
466
467#endif
468
469/* BEGIN ERROR CODES */
470/* Error codes for the BN functions. */
471
472/* Function codes. */
473#define BN_F_BN_BLINDING_CONVERT 100
474#define BN_F_BN_BLINDING_INVERT 101
475#define BN_F_BN_BLINDING_NEW 102
476#define BN_F_BN_BLINDING_UPDATE 103
477#define BN_F_BN_BN2DEC 104
478#define BN_F_BN_BN2HEX 105
479#define BN_F_BN_CTX_NEW 106
480#define BN_F_BN_DIV 107
481#define BN_F_BN_EXPAND2 108
482#define BN_F_BN_MOD_EXP_MONT 109
483#define BN_F_BN_MOD_INVERSE 110
484#define BN_F_BN_MOD_MUL_RECIPROCAL 111
485#define BN_F_BN_MPI2BN 112
486#define BN_F_BN_NEW 113
487#define BN_F_BN_RAND 114
488
489/* Reason codes. */
490#define BN_R_BAD_RECIPROCAL 100
491#define BN_R_CALLED_WITH_EVEN_MODULUS 101
492#define BN_R_DIV_BY_ZERO 102
493#define BN_R_ENCODING_ERROR 103
494#define BN_R_INVALID_LENGTH 104
495#define BN_R_NOT_INITALISED 105
496#define BN_R_NO_INVERSE 106
497
498#ifdef __cplusplus
499}
500#endif
501#endif
502
diff --git a/src/lib/libssl/src/crypto/bn/bn_m.c b/src/lib/libssl/src/crypto/bn/bn_m.c
new file mode 100644
index 0000000000..5166daaeec
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/bn_m.c
@@ -0,0 +1,169 @@
1/* crypto/bn/bn_m.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn_lcl.h"
62#include "stack.h"
63
64int limit=16;
65
66typedef struct bn_pool_st
67 {
68 int used;
69 int tos;
70 STACK *sk;
71 } BN_POOL;
72
73BIGNUM *BN_POOL_push(bp)
74BN_POOL *bp;
75 {
76 BIGNUM *ret;
77
78 if (bp->used >= bp->tos)
79 {
80 ret=BN_new();
81 sk_push(bp->sk,(char *)ret);
82 bp->tos++;
83 bp->used++;
84 }
85 else
86 {
87 ret=(BIGNUM *)sk_value(bp->sk,bp->used);
88 bp->used++;
89 }
90 return(ret);
91 }
92
93void BN_POOL_pop(bp,num)
94BN_POOL *bp;
95int num;
96 {
97 bp->used-=num;
98 }
99
100int BN_m(r,a,b)
101BIGNUM *r,*a,*b;
102 {
103 static BN_POOL bp;
104 static init=1;
105
106 if (init)
107 {
108 bp.used=0;
109 bp.tos=0;
110 bp.sk=sk_new_null();
111 init=0;
112 }
113 return(BN_mm(r,a,b,&bp));
114 }
115
116/* r must be different to a and b */
117int BN_mm(m, A, B, bp)
118BIGNUM *m,*A,*B;
119BN_POOL *bp;
120 {
121 int i,num;
122 int an,bn;
123 BIGNUM *a,*b,*c,*d,*ac,*bd;
124
125 an=A->top;
126 bn=B->top;
127 if ((an <= limit) || (bn <= limit))
128 {
129 return(BN_mul(m,A,B));
130 }
131
132 a=BN_POOL_push(bp);
133 b=BN_POOL_push(bp);
134 c=BN_POOL_push(bp);
135 d=BN_POOL_push(bp);
136 ac=BN_POOL_push(bp);
137 bd=BN_POOL_push(bp);
138
139 num=(an <= bn)?an:bn;
140 num=1<<(BN_num_bits_word(num-1)-1);
141
142 /* Are going to now chop things into 'num' word chunks. */
143 num*=BN_BITS2;
144
145 BN_copy(a,A);
146 BN_mask_bits(a,num);
147 BN_rshift(b,A,num);
148
149 BN_copy(c,B);
150 BN_mask_bits(c,num);
151 BN_rshift(d,B,num);
152
153 BN_sub(ac ,b,a);
154 BN_sub(bd,c,d);
155 BN_mm(m,ac,bd,bp);
156 BN_mm(ac,a,c,bp);
157 BN_mm(bd,b,d,bp);
158
159 BN_add(m,m,ac);
160 BN_add(m,m,bd);
161 BN_lshift(m,m,num);
162 BN_lshift(bd,bd,num*2);
163
164 BN_add(m,m,ac);
165 BN_add(m,m,bd);
166 BN_POOL_pop(bp,6);
167 return(1);
168 }
169
diff --git a/src/lib/libssl/src/crypto/bn/bn_mulw.c b/src/lib/libssl/src/crypto/bn/bn_mulw.c
new file mode 100644
index 0000000000..abfc7e4d6c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/bn_mulw.c
@@ -0,0 +1,366 @@
1/* crypto/bn/bn_mulw.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn_lcl.h"
62
63#ifdef BN_LLONG
64
65BN_ULONG bn_mul_add_words(rp,ap,num,w)
66BN_ULONG *rp,*ap;
67int num;
68BN_ULONG w;
69 {
70 BN_ULONG c1=0;
71
72 for (;;)
73 {
74 mul_add(rp[0],ap[0],w,c1);
75 if (--num == 0) break;
76 mul_add(rp[1],ap[1],w,c1);
77 if (--num == 0) break;
78 mul_add(rp[2],ap[2],w,c1);
79 if (--num == 0) break;
80 mul_add(rp[3],ap[3],w,c1);
81 if (--num == 0) break;
82 ap+=4;
83 rp+=4;
84 }
85
86 return(c1);
87 }
88
89BN_ULONG bn_mul_words(rp,ap,num,w)
90BN_ULONG *rp,*ap;
91int num;
92BN_ULONG w;
93 {
94 BN_ULONG c1=0;
95
96 for (;;)
97 {
98 mul(rp[0],ap[0],w,c1);
99 if (--num == 0) break;
100 mul(rp[1],ap[1],w,c1);
101 if (--num == 0) break;
102 mul(rp[2],ap[2],w,c1);
103 if (--num == 0) break;
104 mul(rp[3],ap[3],w,c1);
105 if (--num == 0) break;
106 ap+=4;
107 rp+=4;
108 }
109 return(c1);
110 }
111
112void bn_sqr_words(r,a,n)
113BN_ULONG *r,*a;
114int n;
115 {
116 for (;;)
117 {
118 BN_ULLONG t;
119
120 t=(BN_ULLONG)(a[0])*(a[0]);
121 r[0]=Lw(t); r[1]=Hw(t);
122 if (--n == 0) break;
123
124 t=(BN_ULLONG)(a[1])*(a[1]);
125 r[2]=Lw(t); r[3]=Hw(t);
126 if (--n == 0) break;
127
128 t=(BN_ULLONG)(a[2])*(a[2]);
129 r[4]=Lw(t); r[5]=Hw(t);
130 if (--n == 0) break;
131
132 t=(BN_ULLONG)(a[3])*(a[3]);
133 r[6]=Lw(t); r[7]=Hw(t);
134 if (--n == 0) break;
135
136 a+=4;
137 r+=8;
138 }
139 }
140
141BN_ULONG bn_add_words(r,a,b,n)
142BN_ULONG *r,*a,*b;
143int n;
144 {
145 BN_ULLONG ll;
146
147 ll=0;
148 for (;;)
149 {
150 ll+= (BN_ULLONG)a[0]+b[0];
151 r[0]=(BN_ULONG)ll&BN_MASK2;
152 ll>>=BN_BITS2;
153 if (--n <= 0) break;
154
155 ll+= (BN_ULLONG)a[1]+b[1];
156 r[1]=(BN_ULONG)ll&BN_MASK2;
157 ll>>=BN_BITS2;
158 if (--n <= 0) break;
159
160 ll+= (BN_ULLONG)a[2]+b[2];
161 r[2]=(BN_ULONG)ll&BN_MASK2;
162 ll>>=BN_BITS2;
163 if (--n <= 0) break;
164
165 ll+= (BN_ULLONG)a[3]+b[3];
166 r[3]=(BN_ULONG)ll&BN_MASK2;
167 ll>>=BN_BITS2;
168 if (--n <= 0) break;
169
170 a+=4;
171 b+=4;
172 r+=4;
173 }
174 return(ll&BN_MASK2);
175 }
176
177#else
178
179BN_ULONG bn_mul_add_words(rp,ap,num,w)
180BN_ULONG *rp,*ap;
181int num;
182BN_ULONG w;
183 {
184 BN_ULONG c=0;
185 BN_ULONG bl,bh;
186
187 bl=LBITS(w);
188 bh=HBITS(w);
189
190 for (;;)
191 {
192 mul_add(rp[0],ap[0],bl,bh,c);
193 if (--num == 0) break;
194 mul_add(rp[1],ap[1],bl,bh,c);
195 if (--num == 0) break;
196 mul_add(rp[2],ap[2],bl,bh,c);
197 if (--num == 0) break;
198 mul_add(rp[3],ap[3],bl,bh,c);
199 if (--num == 0) break;
200 ap+=4;
201 rp+=4;
202 }
203 return(c);
204 }
205
206BN_ULONG bn_mul_words(rp,ap,num,w)
207BN_ULONG *rp,*ap;
208int num;
209BN_ULONG w;
210 {
211 BN_ULONG carry=0;
212 BN_ULONG bl,bh;
213
214 bl=LBITS(w);
215 bh=HBITS(w);
216
217 for (;;)
218 {
219 mul(rp[0],ap[0],bl,bh,carry);
220 if (--num == 0) break;
221 mul(rp[1],ap[1],bl,bh,carry);
222 if (--num == 0) break;
223 mul(rp[2],ap[2],bl,bh,carry);
224 if (--num == 0) break;
225 mul(rp[3],ap[3],bl,bh,carry);
226 if (--num == 0) break;
227 ap+=4;
228 rp+=4;
229 }
230 return(carry);
231 }
232
233void bn_sqr_words(r,a,n)
234BN_ULONG *r,*a;
235int n;
236 {
237 for (;;)
238 {
239 sqr64(r[0],r[1],a[0]);
240 if (--n == 0) break;
241
242 sqr64(r[2],r[3],a[1]);
243 if (--n == 0) break;
244
245 sqr64(r[4],r[5],a[2]);
246 if (--n == 0) break;
247
248 sqr64(r[6],r[7],a[3]);
249 if (--n == 0) break;
250
251 a+=4;
252 r+=8;
253 }
254 }
255
256BN_ULONG bn_add_words(r,a,b,n)
257BN_ULONG *r,*a,*b;
258int n;
259 {
260 BN_ULONG t1,t2;
261 int carry,i;
262
263 carry=0;
264 for (i=0; i<n; i++)
265 {
266 t1= *(a++);
267 t2= *(b++);
268 if (carry)
269 {
270 carry=(t2 >= ((~t1)&BN_MASK2));
271 t2=(t1+t2+1)&BN_MASK2;
272 }
273 else
274 {
275 t2=(t1+t2)&BN_MASK2;
276 carry=(t2<t1);
277 }
278 *(r++)=t2;
279 }
280 return(carry);
281 }
282
283#endif
284
285#if defined(BN_LLONG) && defined(BN_DIV2W)
286
287BN_ULONG bn_div64(h,l,d)
288BN_ULONG h,l,d;
289 {
290 return((BN_ULONG)(((((BN_ULLONG)h)<<BN_BITS2)|l)/(BN_ULLONG)d));
291 }
292
293#else
294
295/* Divide h-l by d and return the result. */
296/* I need to test this some more :-( */
297BN_ULONG bn_div64(h,l,d)
298BN_ULONG h,l,d;
299 {
300 BN_ULONG dh,dl,q,ret=0,th,tl,t;
301 int i,count=2;
302
303 if (d == 0) return(BN_MASK2);
304
305 i=BN_num_bits_word(d);
306 if ((i != BN_BITS2) && (h > (BN_ULONG)1<<i))
307 {
308#if !defined(NO_STDIO) && !defined(WIN16)
309 fprintf(stderr,"Division would overflow (%d)\n",i);
310#endif
311 abort();
312 }
313 i=BN_BITS2-i;
314 if (h >= d) h-=d;
315
316 if (i)
317 {
318 d<<=i;
319 h=(h<<i)|(l>>(BN_BITS2-i));
320 l<<=i;
321 }
322 dh=(d&BN_MASK2h)>>BN_BITS4;
323 dl=(d&BN_MASK2l);
324 for (;;)
325 {
326 if ((h>>BN_BITS4) == dh)
327 q=BN_MASK2l;
328 else
329 q=h/dh;
330
331 for (;;)
332 {
333 t=(h-q*dh);
334 if ((t&BN_MASK2h) ||
335 ((dl*q) <= (
336 (t<<BN_BITS4)+
337 ((l&BN_MASK2h)>>BN_BITS4))))
338 break;
339 q--;
340 }
341 th=q*dh;
342 tl=q*dl;
343 t=(tl>>BN_BITS4);
344 tl=(tl<<BN_BITS4)&BN_MASK2h;
345 th+=t;
346
347 if (l < tl) th++;
348 l-=tl;
349 if (h < th)
350 {
351 h+=d;
352 q--;
353 }
354 h-=th;
355
356 if (--count == 0) break;
357
358 ret=q<<BN_BITS4;
359 h=((h<<BN_BITS4)|(l>>BN_BITS4))&BN_MASK2;
360 l=(l&BN_MASK2l)<<BN_BITS4;
361 }
362 ret|=q;
363 return(ret);
364 }
365#endif
366
diff --git a/src/lib/libssl/src/crypto/bn/bn_sub.c b/src/lib/libssl/src/crypto/bn/bn_sub.c
new file mode 100644
index 0000000000..bba80f8afb
--- /dev/null
+++ b/src/lib/libssl/src/crypto/bn/bn_sub.c
@@ -0,0 +1,180 @@
1/* crypto/bn/bn_sub.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "bn_lcl.h"
62
63/* unsigned subtraction of b from a, a must be larger than b. */
64void bn_qsub(r, a, b)
65BIGNUM *r;
66BIGNUM *a;
67BIGNUM *b;
68 {
69 int max,min;
70 register BN_ULONG t1,t2,*ap,*bp,*rp;
71 int i,carry;
72#if defined(IRIX_CC_BUG) && !defined(LINT)
73 int dummy;
74#endif
75
76 max=a->top;
77 min=b->top;
78 ap=a->d;
79 bp=b->d;
80 rp=r->d;
81
82 carry=0;
83 for (i=0; i<min; i++)
84 {
85 t1= *(ap++);
86 t2= *(bp++);
87 if (carry)
88 {
89 carry=(t1 <= t2);
90 t1=(t1-t2-1)&BN_MASK2;
91 }
92 else
93 {
94 carry=(t1 < t2);
95 t1=(t1-t2)&BN_MASK2;
96 }
97#if defined(IRIX_CC_BUG) && !defined(LINT)
98 dummy=t1;
99#endif
100 *(rp++)=t1&BN_MASK2;
101 }
102 if (carry) /* subtracted */
103 {
104 while (i < max)
105 {
106 i++;
107 t1= *(ap++);
108 t2=(t1-1)&BN_MASK2;
109 *(rp++)=t2;
110 if (t1 > t2) break;
111 }
112 }
113#if 0
114 memcpy(rp,ap,sizeof(*rp)*(max-i));
115#else
116 for (; i<max; i++)
117 *(rp++)= *(ap++);
118#endif
119
120 r->top=max;
121 bn_fix_top(r);
122 }
123
124int BN_sub(r, a, b)
125BIGNUM *r;
126BIGNUM *a;
127BIGNUM *b;
128 {
129 int max,i;
130 int add=0,neg=0;
131 BIGNUM *tmp;
132
133 /* a - b a-b
134 * a - -b a+b
135 * -a - b -(a+b)
136 * -a - -b b-a
137 */
138 if (a->neg)
139 {
140 if (b->neg)
141 { tmp=a; a=b; b=tmp; }
142 else
143 { add=1; neg=1; }
144 }
145 else
146 {
147 if (b->neg) { add=1; neg=0; }
148 }
149
150 if (add)
151 {
152 /* As a fast max size, do a a->top | b->top */
153 i=(a->top | b->top)+1;
154 if (bn_wexpand(r,i) == NULL)
155 return(0);
156 if (i)
157 bn_qadd(r,a,b);
158 else
159 bn_qadd(r,b,a);
160 r->neg=neg;
161 return(1);
162 }
163
164 /* We are actually doing a - b :-) */
165
166 max=(a->top > b->top)?a->top:b->top;
167 if (bn_wexpand(r,max) == NULL) return(0);
168 if (BN_ucmp(a,b) < 0)
169 {
170 bn_qsub(r,b,a);
171 r->neg=1;
172 }
173 else
174 {
175 bn_qsub(r,a,b);
176 r->neg=0;
177 }
178 return(1);
179 }
180
diff --git a/src/lib/libssl/src/crypto/buffer/Makefile.ssl b/src/lib/libssl/src/crypto/buffer/Makefile.ssl
new file mode 100644
index 0000000000..a5f150e523
--- /dev/null
+++ b/src/lib/libssl/src/crypto/buffer/Makefile.ssl
@@ -0,0 +1,84 @@
1#
2# SSLeay/crypto/buffer/Makefile
3#
4
5DIR= buffer
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=buffer
19ERRC=buf_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= buffer.c $(ERRC).c
26LIBOBJ= buffer.o $(ERRC).o
27
28SRC= $(LIBSRC)
29
30EXHEADER= buffer.h
31HEADER= $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: lib
39
40lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/util/ranlib.sh $(LIB)
43 @touch lib
44
45files:
46 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
47
48links:
49 /bin/rm -f Makefile
50 $(TOP)/util/point.sh Makefile.ssl Makefile;
51 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
52 $(TOP)/util/mklink.sh ../../test $(TEST)
53 $(TOP)/util/mklink.sh ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALLTOP)/include/$$i; \
59 chmod 644 $(INSTALLTOP)/include/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
72
73dclean:
74 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80errors:
81 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
82 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
83
84# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/buffer/buffer.err b/src/lib/libssl/src/crypto/buffer/buffer.err
new file mode 100644
index 0000000000..62b775e637
--- /dev/null
+++ b/src/lib/libssl/src/crypto/buffer/buffer.err
@@ -0,0 +1,9 @@
1/* Error codes for the BUF functions. */
2
3/* Function codes. */
4#define BUF_F_BUF_MEM_GROW 100
5#define BUF_F_BUF_MEM_NEW 101
6#define BUF_F_BUF_STRDUP 102
7#define BUF_F_PXYCLNT_READ 103
8
9/* Reason codes. */
diff --git a/src/lib/libssl/src/crypto/cast/Makefile.ssl b/src/lib/libssl/src/crypto/cast/Makefile.ssl
new file mode 100644
index 0000000000..0143827ae5
--- /dev/null
+++ b/src/lib/libssl/src/crypto/cast/Makefile.ssl
@@ -0,0 +1,109 @@
1#
2# SSLeay/crypto/cast/Makefile
3#
4
5DIR= cast
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17CAST_ENC=c_enc.o
18# or use
19#CAST_ENC=asm/cx86-elf.o
20#CAST_ENC=asm/cx86-out.o
21#CAST_ENC=asm/cx86-sol.o
22#CAST_ENC=asm/cx86bdsi.o
23
24CFLAGS= $(INCLUDES) $(CFLAG)
25
26GENERAL=Makefile
27TEST=casttest.c
28APPS=
29
30LIB=$(TOP)/libcrypto.a
31LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
32LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o
33
34SRC= $(LIBSRC)
35
36EXHEADER= cast.h
37HEADER= cast_s.h cast_lcl.h $(EXHEADER)
38
39ALL= $(GENERAL) $(SRC) $(HEADER)
40
41top:
42 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
43
44all: lib
45
46lib: $(LIBOBJ)
47 $(AR) $(LIB) $(LIBOBJ)
48 sh $(TOP)/util/ranlib.sh $(LIB)
49 @touch lib
50
51# elf
52asm/cx86-elf.o: asm/cx86unix.cpp
53 $(CPP) -DELF asm/cx86unix.cpp | as -o asm/cx86-elf.o
54
55# solaris
56asm/cx86-sol.o: asm/cx86unix.cpp
57 $(CC) -E -DSOL asm/cx86unix.cpp | sed 's/^#.*//' > asm/cx86-sol.s
58 as -o asm/cx86-sol.o asm/cx86-sol.s
59 rm -f asm/cx86-sol.s
60
61# a.out
62asm/cx86-out.o: asm/cx86unix.cpp
63 $(CPP) -DOUT asm/cx86unix.cpp | as -o asm/cx86-out.o
64
65# bsdi
66asm/cx86bsdi.o: asm/cx86unix.cpp
67 $(CPP) -DBSDI asm/cx86unix.cpp | as -o asm/cx86bsdi.o
68
69asm/cx86unix.cpp:
70 (cd asm; perl cast-586.pl cpp >cx86unix.cpp)
71
72files:
73 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
74
75links:
76 /bin/rm -f Makefile
77 $(TOP)/util/point.sh Makefile.ssl Makefile ;
78 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
79 $(TOP)/util/mklink.sh ../../test $(TEST)
80 $(TOP)/util/mklink.sh ../../apps $(APPS)
81
82install:
83 @for i in $(EXHEADER) ; \
84 do \
85 (cp $$i $(INSTALLTOP)/include/$$i; \
86 chmod 644 $(INSTALLTOP)/include/$$i ); \
87 done;
88
89tags:
90 ctags $(SRC)
91
92tests:
93
94lint:
95 lint -DLINT $(INCLUDES) $(SRC)>fluff
96
97depend:
98 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
99
100dclean:
101 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
102 mv -f Makefile.new $(MAKEFILE)
103
104clean:
105 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
106
107errors:
108
109# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/cast/Makefile.uni b/src/lib/libssl/src/crypto/cast/Makefile.uni
new file mode 100644
index 0000000000..780073e75b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/cast/Makefile.uni
@@ -0,0 +1,123 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10# There are 3 possible performance options, experiment :-)
11#OPTS= -DBF_PTR
12#OPTS= -DBF_PTR2
13OPTS=
14
15DIR= cast
16TOP= .
17CC= gcc
18CFLAG= -O3 -fomit-frame-pointer
19
20CPP= $(CC) -E
21INCLUDES=
22INSTALLTOP=/usr/local/lib
23MAKE= make
24MAKEDEPEND= makedepend
25MAKEFILE= Makefile.uni
26AR= ar r
27
28CAST_ENC=c_enc.o
29# or use
30#CAST_ENC=asm/cx86-elf.o
31#CAST_ENC=asm/cx86-out.o
32#CAST_ENC=asm/cx86-sol.o
33#CAST_ENC=asm/cx86bdsi.o
34
35CFLAGS= $(OPTS) $(INCLUDES) $(CFLAG) -DFULL_TEST
36
37GENERAL=Makefile
38TEST=casttest
39APP1=cast_spd
40APP2=castopts
41APPS=$(APP1) $(APP2)
42
43LIB=libcast.a
44LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c
45LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o
46
47SRC= $(LIBSRC)
48
49EXHEADER= cast.h
50HEADER= cast_lcl.h $(EXHEADER)
51
52ALL= $(GENERAL) $(SRC) $(HEADER)
53
54all: $(LIB) $(TEST) $(APPS)
55
56$(LIB): $(LIBOBJ)
57 $(AR) $(LIB) $(LIBOBJ)
58 sh $(TOP)/ranlib.sh $(LIB)
59# elf
60asm/cx86-elf.o: asm/cx86unix.cpp
61 $(CPP) -DELF asm/cx86unix.cpp | as -o asm/cx86-elf.o
62
63# solaris
64asm/cx86-sol.o: asm/cx86unix.cpp
65 $(CC) -E -DSOL asm/cx86unix.cpp | sed 's/^#.*//' > asm/cx86-sol.s
66 as -o asm/cx86-sol.o asm/cx86-sol.s
67 rm -f asm/cx86-sol.s
68
69# a.out
70asm/cx86-out.o: asm/cx86unix.cpp
71 $(CPP) -DOUT asm/cx86unix.cpp | as -o asm/cx86-out.o
72
73# bsdi
74asm/cx86bsdi.o: asm/cx86unix.cpp
75 $(CPP) -DBSDI asm/cx86unix.cpp | as -o asm/cx86bsdi.o
76
77asm/cx86unix.cpp:
78 (cd asm; perl cast-586.pl cpp >cx86unix.cpp)
79
80test: $(TEST)
81 ./$(TEST)
82
83$(TEST): $(TEST).c $(LIB)
84 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
85
86$(APP1): $(APP1).c $(LIB)
87 $(CC) -o $(APP1) $(CFLAGS) $(APP1).c $(LIB)
88
89$(APP2): $(APP2).c $(LIB)
90 $(CC) -o $(APP2) $(CFLAGS) $(APP2).c $(LIB)
91
92lint:
93 lint -DLINT $(INCLUDES) $(SRC)>fluff
94
95depend:
96 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
97
98dclean:
99 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
100 mv -f Makefile.new $(MAKEFILE)
101
102clean:
103 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
104
105cc:
106 $(MAKE) CC="cc" CFLAG="-O" all
107
108gcc:
109 $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
110
111x86-elf:
112 $(MAKE) CAST_ENC="asm/cx86-elf.o" CFLAG="-DELF $(CFLAGS)" all
113
114x86-out:
115 $(MAKE) CAST_ENC="asm/cx86-out.o" CFLAG="-DOUT $(CFLAGS)" all
116
117x86-solaris:
118 $(MAKE) CAST_ENC="asm/cx86-sol.o" CFLAG="-DSOL $(CFLAGS)" all
119
120x86-bdsi:
121 $(MAKE) CAST_ENC="asm/cx86-bdsi.o" CFLAG="-DBDSI $(CFLAGS)" all
122
123# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/cast/asm/c-win32.asm b/src/lib/libssl/src/crypto/cast/asm/c-win32.asm
new file mode 100644
index 0000000000..a1d8a2671a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/cast/asm/c-win32.asm
@@ -0,0 +1,940 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by cast-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE cast-586.asm
8 .486
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _CAST_encrypt
12EXTERN _CAST_S_table0:DWORD
13EXTERN _CAST_S_table1:DWORD
14EXTERN _CAST_S_table2:DWORD
15EXTERN _CAST_S_table3:DWORD
16
17_CAST_encrypt PROC NEAR
18 ;
19 push ebp
20 push ebx
21 mov ebx, DWORD PTR 12[esp]
22 mov ebp, DWORD PTR 16[esp]
23 push esi
24 push edi
25 ; Load the 2 words
26 mov edi, DWORD PTR [ebx]
27 mov esi, DWORD PTR 4[ebx]
28 xor eax, eax
29 ; round 0
30 mov edx, DWORD PTR [ebp]
31 mov ecx, DWORD PTR 4[ebp]
32 add edx, esi
33 rol edx, cl
34 mov ebx, edx
35 xor ecx, ecx
36 mov cl, dh
37 and ebx, 255
38 shr edx, 16
39 xor eax, eax
40 mov al, dh
41 and edx, 255
42 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
43 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
44 xor ecx, ebx
45 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
46 sub ecx, ebx
47 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
48 add ecx, ebx
49 xor edi, ecx
50 ; round 1
51 mov edx, DWORD PTR 8[ebp]
52 mov ecx, DWORD PTR 12[ebp]
53 xor edx, edi
54 rol edx, cl
55 mov ebx, edx
56 xor ecx, ecx
57 mov cl, dh
58 and ebx, 255
59 shr edx, 16
60 xor eax, eax
61 mov al, dh
62 and edx, 255
63 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
64 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
65 sub ecx, ebx
66 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
67 add ecx, ebx
68 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
69 xor ecx, ebx
70 xor esi, ecx
71 ; round 2
72 mov edx, DWORD PTR 16[ebp]
73 mov ecx, DWORD PTR 20[ebp]
74 sub edx, esi
75 rol edx, cl
76 mov ebx, edx
77 xor ecx, ecx
78 mov cl, dh
79 and ebx, 255
80 shr edx, 16
81 xor eax, eax
82 mov al, dh
83 and edx, 255
84 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
85 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
86 add ecx, ebx
87 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
88 xor ecx, ebx
89 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
90 sub ecx, ebx
91 xor edi, ecx
92 ; round 3
93 mov edx, DWORD PTR 24[ebp]
94 mov ecx, DWORD PTR 28[ebp]
95 add edx, edi
96 rol edx, cl
97 mov ebx, edx
98 xor ecx, ecx
99 mov cl, dh
100 and ebx, 255
101 shr edx, 16
102 xor eax, eax
103 mov al, dh
104 and edx, 255
105 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
106 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
107 xor ecx, ebx
108 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
109 sub ecx, ebx
110 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
111 add ecx, ebx
112 xor esi, ecx
113 ; round 4
114 mov edx, DWORD PTR 32[ebp]
115 mov ecx, DWORD PTR 36[ebp]
116 xor edx, esi
117 rol edx, cl
118 mov ebx, edx
119 xor ecx, ecx
120 mov cl, dh
121 and ebx, 255
122 shr edx, 16
123 xor eax, eax
124 mov al, dh
125 and edx, 255
126 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
127 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
128 sub ecx, ebx
129 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
130 add ecx, ebx
131 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
132 xor ecx, ebx
133 xor edi, ecx
134 ; round 5
135 mov edx, DWORD PTR 40[ebp]
136 mov ecx, DWORD PTR 44[ebp]
137 sub edx, edi
138 rol edx, cl
139 mov ebx, edx
140 xor ecx, ecx
141 mov cl, dh
142 and ebx, 255
143 shr edx, 16
144 xor eax, eax
145 mov al, dh
146 and edx, 255
147 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
148 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
149 add ecx, ebx
150 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
151 xor ecx, ebx
152 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
153 sub ecx, ebx
154 xor esi, ecx
155 ; round 6
156 mov edx, DWORD PTR 48[ebp]
157 mov ecx, DWORD PTR 52[ebp]
158 add edx, esi
159 rol edx, cl
160 mov ebx, edx
161 xor ecx, ecx
162 mov cl, dh
163 and ebx, 255
164 shr edx, 16
165 xor eax, eax
166 mov al, dh
167 and edx, 255
168 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
169 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
170 xor ecx, ebx
171 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
172 sub ecx, ebx
173 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
174 add ecx, ebx
175 xor edi, ecx
176 ; round 7
177 mov edx, DWORD PTR 56[ebp]
178 mov ecx, DWORD PTR 60[ebp]
179 xor edx, edi
180 rol edx, cl
181 mov ebx, edx
182 xor ecx, ecx
183 mov cl, dh
184 and ebx, 255
185 shr edx, 16
186 xor eax, eax
187 mov al, dh
188 and edx, 255
189 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
190 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
191 sub ecx, ebx
192 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
193 add ecx, ebx
194 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
195 xor ecx, ebx
196 xor esi, ecx
197 ; round 8
198 mov edx, DWORD PTR 64[ebp]
199 mov ecx, DWORD PTR 68[ebp]
200 sub edx, esi
201 rol edx, cl
202 mov ebx, edx
203 xor ecx, ecx
204 mov cl, dh
205 and ebx, 255
206 shr edx, 16
207 xor eax, eax
208 mov al, dh
209 and edx, 255
210 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
211 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
212 add ecx, ebx
213 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
214 xor ecx, ebx
215 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
216 sub ecx, ebx
217 xor edi, ecx
218 ; round 9
219 mov edx, DWORD PTR 72[ebp]
220 mov ecx, DWORD PTR 76[ebp]
221 add edx, edi
222 rol edx, cl
223 mov ebx, edx
224 xor ecx, ecx
225 mov cl, dh
226 and ebx, 255
227 shr edx, 16
228 xor eax, eax
229 mov al, dh
230 and edx, 255
231 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
232 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
233 xor ecx, ebx
234 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
235 sub ecx, ebx
236 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
237 add ecx, ebx
238 xor esi, ecx
239 ; round 10
240 mov edx, DWORD PTR 80[ebp]
241 mov ecx, DWORD PTR 84[ebp]
242 xor edx, esi
243 rol edx, cl
244 mov ebx, edx
245 xor ecx, ecx
246 mov cl, dh
247 and ebx, 255
248 shr edx, 16
249 xor eax, eax
250 mov al, dh
251 and edx, 255
252 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
253 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
254 sub ecx, ebx
255 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
256 add ecx, ebx
257 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
258 xor ecx, ebx
259 xor edi, ecx
260 ; round 11
261 mov edx, DWORD PTR 88[ebp]
262 mov ecx, DWORD PTR 92[ebp]
263 sub edx, edi
264 rol edx, cl
265 mov ebx, edx
266 xor ecx, ecx
267 mov cl, dh
268 and ebx, 255
269 shr edx, 16
270 xor eax, eax
271 mov al, dh
272 and edx, 255
273 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
274 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
275 add ecx, ebx
276 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
277 xor ecx, ebx
278 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
279 sub ecx, ebx
280 xor esi, ecx
281 ; round 12
282 mov edx, DWORD PTR 96[ebp]
283 mov ecx, DWORD PTR 100[ebp]
284 add edx, esi
285 rol edx, cl
286 mov ebx, edx
287 xor ecx, ecx
288 mov cl, dh
289 and ebx, 255
290 shr edx, 16
291 xor eax, eax
292 mov al, dh
293 and edx, 255
294 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
295 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
296 xor ecx, ebx
297 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
298 sub ecx, ebx
299 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
300 add ecx, ebx
301 xor edi, ecx
302 ; round 13
303 mov edx, DWORD PTR 104[ebp]
304 mov ecx, DWORD PTR 108[ebp]
305 xor edx, edi
306 rol edx, cl
307 mov ebx, edx
308 xor ecx, ecx
309 mov cl, dh
310 and ebx, 255
311 shr edx, 16
312 xor eax, eax
313 mov al, dh
314 and edx, 255
315 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
316 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
317 sub ecx, ebx
318 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
319 add ecx, ebx
320 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
321 xor ecx, ebx
322 xor esi, ecx
323 ; round 14
324 mov edx, DWORD PTR 112[ebp]
325 mov ecx, DWORD PTR 116[ebp]
326 sub edx, esi
327 rol edx, cl
328 mov ebx, edx
329 xor ecx, ecx
330 mov cl, dh
331 and ebx, 255
332 shr edx, 16
333 xor eax, eax
334 mov al, dh
335 and edx, 255
336 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
337 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
338 add ecx, ebx
339 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
340 xor ecx, ebx
341 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
342 sub ecx, ebx
343 xor edi, ecx
344 ; round 15
345 mov edx, DWORD PTR 120[ebp]
346 mov ecx, DWORD PTR 124[ebp]
347 add edx, edi
348 rol edx, cl
349 mov ebx, edx
350 xor ecx, ecx
351 mov cl, dh
352 and ebx, 255
353 shr edx, 16
354 xor eax, eax
355 mov al, dh
356 and edx, 255
357 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
358 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
359 xor ecx, ebx
360 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
361 sub ecx, ebx
362 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
363 add ecx, ebx
364 mov eax, DWORD PTR 20[esp]
365 xor esi, ecx
366 nop
367 mov DWORD PTR 4[eax],edi
368 mov DWORD PTR [eax],esi
369 pop edi
370 pop esi
371 pop ebx
372 pop ebp
373 ret
374_CAST_encrypt ENDP
375_TEXT ENDS
376_TEXT SEGMENT
377PUBLIC _CAST_decrypt
378EXTERN _CAST_S_table0:DWORD
379EXTERN _CAST_S_table1:DWORD
380EXTERN _CAST_S_table2:DWORD
381EXTERN _CAST_S_table3:DWORD
382
383_CAST_decrypt PROC NEAR
384 ;
385 push ebp
386 push ebx
387 mov ebx, DWORD PTR 12[esp]
388 mov ebp, DWORD PTR 16[esp]
389 push esi
390 push edi
391 ; Load the 2 words
392 mov edi, DWORD PTR [ebx]
393 mov esi, DWORD PTR 4[ebx]
394 xor eax, eax
395 ; round 15
396 mov edx, DWORD PTR 120[ebp]
397 mov ecx, DWORD PTR 124[ebp]
398 add edx, esi
399 rol edx, cl
400 mov ebx, edx
401 xor ecx, ecx
402 mov cl, dh
403 and ebx, 255
404 shr edx, 16
405 xor eax, eax
406 mov al, dh
407 and edx, 255
408 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
409 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
410 xor ecx, ebx
411 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
412 sub ecx, ebx
413 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
414 add ecx, ebx
415 xor edi, ecx
416 ; round 14
417 mov edx, DWORD PTR 112[ebp]
418 mov ecx, DWORD PTR 116[ebp]
419 sub edx, edi
420 rol edx, cl
421 mov ebx, edx
422 xor ecx, ecx
423 mov cl, dh
424 and ebx, 255
425 shr edx, 16
426 xor eax, eax
427 mov al, dh
428 and edx, 255
429 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
430 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
431 add ecx, ebx
432 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
433 xor ecx, ebx
434 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
435 sub ecx, ebx
436 xor esi, ecx
437 ; round 13
438 mov edx, DWORD PTR 104[ebp]
439 mov ecx, DWORD PTR 108[ebp]
440 xor edx, esi
441 rol edx, cl
442 mov ebx, edx
443 xor ecx, ecx
444 mov cl, dh
445 and ebx, 255
446 shr edx, 16
447 xor eax, eax
448 mov al, dh
449 and edx, 255
450 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
451 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
452 sub ecx, ebx
453 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
454 add ecx, ebx
455 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
456 xor ecx, ebx
457 xor edi, ecx
458 ; round 12
459 mov edx, DWORD PTR 96[ebp]
460 mov ecx, DWORD PTR 100[ebp]
461 add edx, edi
462 rol edx, cl
463 mov ebx, edx
464 xor ecx, ecx
465 mov cl, dh
466 and ebx, 255
467 shr edx, 16
468 xor eax, eax
469 mov al, dh
470 and edx, 255
471 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
472 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
473 xor ecx, ebx
474 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
475 sub ecx, ebx
476 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
477 add ecx, ebx
478 xor esi, ecx
479 ; round 11
480 mov edx, DWORD PTR 88[ebp]
481 mov ecx, DWORD PTR 92[ebp]
482 sub edx, esi
483 rol edx, cl
484 mov ebx, edx
485 xor ecx, ecx
486 mov cl, dh
487 and ebx, 255
488 shr edx, 16
489 xor eax, eax
490 mov al, dh
491 and edx, 255
492 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
493 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
494 add ecx, ebx
495 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
496 xor ecx, ebx
497 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
498 sub ecx, ebx
499 xor edi, ecx
500 ; round 10
501 mov edx, DWORD PTR 80[ebp]
502 mov ecx, DWORD PTR 84[ebp]
503 xor edx, edi
504 rol edx, cl
505 mov ebx, edx
506 xor ecx, ecx
507 mov cl, dh
508 and ebx, 255
509 shr edx, 16
510 xor eax, eax
511 mov al, dh
512 and edx, 255
513 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
514 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
515 sub ecx, ebx
516 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
517 add ecx, ebx
518 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
519 xor ecx, ebx
520 xor esi, ecx
521 ; round 9
522 mov edx, DWORD PTR 72[ebp]
523 mov ecx, DWORD PTR 76[ebp]
524 add edx, esi
525 rol edx, cl
526 mov ebx, edx
527 xor ecx, ecx
528 mov cl, dh
529 and ebx, 255
530 shr edx, 16
531 xor eax, eax
532 mov al, dh
533 and edx, 255
534 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
535 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
536 xor ecx, ebx
537 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
538 sub ecx, ebx
539 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
540 add ecx, ebx
541 xor edi, ecx
542 ; round 8
543 mov edx, DWORD PTR 64[ebp]
544 mov ecx, DWORD PTR 68[ebp]
545 sub edx, edi
546 rol edx, cl
547 mov ebx, edx
548 xor ecx, ecx
549 mov cl, dh
550 and ebx, 255
551 shr edx, 16
552 xor eax, eax
553 mov al, dh
554 and edx, 255
555 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
556 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
557 add ecx, ebx
558 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
559 xor ecx, ebx
560 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
561 sub ecx, ebx
562 xor esi, ecx
563 ; round 7
564 mov edx, DWORD PTR 56[ebp]
565 mov ecx, DWORD PTR 60[ebp]
566 xor edx, esi
567 rol edx, cl
568 mov ebx, edx
569 xor ecx, ecx
570 mov cl, dh
571 and ebx, 255
572 shr edx, 16
573 xor eax, eax
574 mov al, dh
575 and edx, 255
576 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
577 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
578 sub ecx, ebx
579 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
580 add ecx, ebx
581 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
582 xor ecx, ebx
583 xor edi, ecx
584 ; round 6
585 mov edx, DWORD PTR 48[ebp]
586 mov ecx, DWORD PTR 52[ebp]
587 add edx, edi
588 rol edx, cl
589 mov ebx, edx
590 xor ecx, ecx
591 mov cl, dh
592 and ebx, 255
593 shr edx, 16
594 xor eax, eax
595 mov al, dh
596 and edx, 255
597 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
598 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
599 xor ecx, ebx
600 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
601 sub ecx, ebx
602 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
603 add ecx, ebx
604 xor esi, ecx
605 ; round 5
606 mov edx, DWORD PTR 40[ebp]
607 mov ecx, DWORD PTR 44[ebp]
608 sub edx, esi
609 rol edx, cl
610 mov ebx, edx
611 xor ecx, ecx
612 mov cl, dh
613 and ebx, 255
614 shr edx, 16
615 xor eax, eax
616 mov al, dh
617 and edx, 255
618 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
619 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
620 add ecx, ebx
621 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
622 xor ecx, ebx
623 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
624 sub ecx, ebx
625 xor edi, ecx
626 ; round 4
627 mov edx, DWORD PTR 32[ebp]
628 mov ecx, DWORD PTR 36[ebp]
629 xor edx, edi
630 rol edx, cl
631 mov ebx, edx
632 xor ecx, ecx
633 mov cl, dh
634 and ebx, 255
635 shr edx, 16
636 xor eax, eax
637 mov al, dh
638 and edx, 255
639 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
640 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
641 sub ecx, ebx
642 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
643 add ecx, ebx
644 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
645 xor ecx, ebx
646 xor esi, ecx
647 ; round 3
648 mov edx, DWORD PTR 24[ebp]
649 mov ecx, DWORD PTR 28[ebp]
650 add edx, esi
651 rol edx, cl
652 mov ebx, edx
653 xor ecx, ecx
654 mov cl, dh
655 and ebx, 255
656 shr edx, 16
657 xor eax, eax
658 mov al, dh
659 and edx, 255
660 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
661 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
662 xor ecx, ebx
663 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
664 sub ecx, ebx
665 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
666 add ecx, ebx
667 xor edi, ecx
668 ; round 2
669 mov edx, DWORD PTR 16[ebp]
670 mov ecx, DWORD PTR 20[ebp]
671 sub edx, edi
672 rol edx, cl
673 mov ebx, edx
674 xor ecx, ecx
675 mov cl, dh
676 and ebx, 255
677 shr edx, 16
678 xor eax, eax
679 mov al, dh
680 and edx, 255
681 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
682 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
683 add ecx, ebx
684 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
685 xor ecx, ebx
686 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
687 sub ecx, ebx
688 xor esi, ecx
689 ; round 1
690 mov edx, DWORD PTR 8[ebp]
691 mov ecx, DWORD PTR 12[ebp]
692 xor edx, esi
693 rol edx, cl
694 mov ebx, edx
695 xor ecx, ecx
696 mov cl, dh
697 and ebx, 255
698 shr edx, 16
699 xor eax, eax
700 mov al, dh
701 and edx, 255
702 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
703 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
704 sub ecx, ebx
705 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
706 add ecx, ebx
707 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
708 xor ecx, ebx
709 xor edi, ecx
710 ; round 0
711 mov edx, DWORD PTR [ebp]
712 mov ecx, DWORD PTR 4[ebp]
713 add edx, edi
714 rol edx, cl
715 mov ebx, edx
716 xor ecx, ecx
717 mov cl, dh
718 and ebx, 255
719 shr edx, 16
720 xor eax, eax
721 mov al, dh
722 and edx, 255
723 mov ecx, DWORD PTR _CAST_S_table0[ecx*4]
724 mov ebx, DWORD PTR _CAST_S_table1[ebx*4]
725 xor ecx, ebx
726 mov ebx, DWORD PTR _CAST_S_table2[eax*4]
727 sub ecx, ebx
728 mov ebx, DWORD PTR _CAST_S_table3[edx*4]
729 add ecx, ebx
730 mov eax, DWORD PTR 20[esp]
731 xor esi, ecx
732 nop
733 mov DWORD PTR 4[eax],edi
734 mov DWORD PTR [eax],esi
735 pop edi
736 pop esi
737 pop ebx
738 pop ebp
739 ret
740_CAST_decrypt ENDP
741_TEXT ENDS
742_TEXT SEGMENT
743PUBLIC _CAST_cbc_encrypt
744
745_CAST_cbc_encrypt PROC NEAR
746 ;
747 push ebp
748 push ebx
749 push esi
750 push edi
751 mov ebp, DWORD PTR 28[esp]
752 ; getting iv ptr from parameter 4
753 mov ebx, DWORD PTR 36[esp]
754 mov esi, DWORD PTR [ebx]
755 mov edi, DWORD PTR 4[ebx]
756 push edi
757 push esi
758 push edi
759 push esi
760 mov ebx, esp
761 mov esi, DWORD PTR 36[esp]
762 mov edi, DWORD PTR 40[esp]
763 ; getting encrypt flag from parameter 5
764 mov ecx, DWORD PTR 56[esp]
765 ; get and push parameter 3
766 mov eax, DWORD PTR 48[esp]
767 push eax
768 push ebx
769 cmp ecx, 0
770 jz $L000decrypt
771 and ebp, 4294967288
772 mov eax, DWORD PTR 8[esp]
773 mov ebx, DWORD PTR 12[esp]
774 jz $L001encrypt_finish
775L002encrypt_loop:
776 mov ecx, DWORD PTR [esi]
777 mov edx, DWORD PTR 4[esi]
778 xor eax, ecx
779 xor ebx, edx
780 bswap eax
781 bswap ebx
782 mov DWORD PTR 8[esp],eax
783 mov DWORD PTR 12[esp],ebx
784 call _CAST_encrypt
785 mov eax, DWORD PTR 8[esp]
786 mov ebx, DWORD PTR 12[esp]
787 bswap eax
788 bswap ebx
789 mov DWORD PTR [edi],eax
790 mov DWORD PTR 4[edi],ebx
791 add esi, 8
792 add edi, 8
793 sub ebp, 8
794 jnz L002encrypt_loop
795$L001encrypt_finish:
796 mov ebp, DWORD PTR 52[esp]
797 and ebp, 7
798 jz $L003finish
799 xor ecx, ecx
800 xor edx, edx
801 mov ebp, DWORD PTR $L004cbc_enc_jmp_table[ebp*4]
802 jmp ebp
803L005ej7:
804 xor edx, edx
805 mov dh, BYTE PTR 6[esi]
806 shl edx, 8
807L006ej6:
808 mov dh, BYTE PTR 5[esi]
809L007ej5:
810 mov dl, BYTE PTR 4[esi]
811L008ej4:
812 mov ecx, DWORD PTR [esi]
813 jmp $L009ejend
814L010ej3:
815 mov ch, BYTE PTR 2[esi]
816 xor ecx, ecx
817 shl ecx, 8
818L011ej2:
819 mov ch, BYTE PTR 1[esi]
820L012ej1:
821 mov cl, BYTE PTR [esi]
822$L009ejend:
823 xor eax, ecx
824 xor ebx, edx
825 bswap eax
826 bswap ebx
827 mov DWORD PTR 8[esp],eax
828 mov DWORD PTR 12[esp],ebx
829 call _CAST_encrypt
830 mov eax, DWORD PTR 8[esp]
831 mov ebx, DWORD PTR 12[esp]
832 bswap eax
833 bswap ebx
834 mov DWORD PTR [edi],eax
835 mov DWORD PTR 4[edi],ebx
836 jmp $L003finish
837$L000decrypt:
838 and ebp, 4294967288
839 mov eax, DWORD PTR 16[esp]
840 mov ebx, DWORD PTR 20[esp]
841 jz $L013decrypt_finish
842L014decrypt_loop:
843 mov eax, DWORD PTR [esi]
844 mov ebx, DWORD PTR 4[esi]
845 bswap eax
846 bswap ebx
847 mov DWORD PTR 8[esp],eax
848 mov DWORD PTR 12[esp],ebx
849 call _CAST_decrypt
850 mov eax, DWORD PTR 8[esp]
851 mov ebx, DWORD PTR 12[esp]
852 bswap eax
853 bswap ebx
854 mov ecx, DWORD PTR 16[esp]
855 mov edx, DWORD PTR 20[esp]
856 xor ecx, eax
857 xor edx, ebx
858 mov eax, DWORD PTR [esi]
859 mov ebx, DWORD PTR 4[esi]
860 mov DWORD PTR [edi],ecx
861 mov DWORD PTR 4[edi],edx
862 mov DWORD PTR 16[esp],eax
863 mov DWORD PTR 20[esp],ebx
864 add esi, 8
865 add edi, 8
866 sub ebp, 8
867 jnz L014decrypt_loop
868$L013decrypt_finish:
869 mov ebp, DWORD PTR 52[esp]
870 and ebp, 7
871 jz $L003finish
872 mov eax, DWORD PTR [esi]
873 mov ebx, DWORD PTR 4[esi]
874 bswap eax
875 bswap ebx
876 mov DWORD PTR 8[esp],eax
877 mov DWORD PTR 12[esp],ebx
878 call _CAST_decrypt
879 mov eax, DWORD PTR 8[esp]
880 mov ebx, DWORD PTR 12[esp]
881 bswap eax
882 bswap ebx
883 mov ecx, DWORD PTR 16[esp]
884 mov edx, DWORD PTR 20[esp]
885 xor ecx, eax
886 xor edx, ebx
887 mov eax, DWORD PTR [esi]
888 mov ebx, DWORD PTR 4[esi]
889L015dj7:
890 ror edx, 16
891 mov BYTE PTR 6[edi],dl
892 shr edx, 16
893L016dj6:
894 mov BYTE PTR 5[edi],dh
895L017dj5:
896 mov BYTE PTR 4[edi],dl
897L018dj4:
898 mov DWORD PTR [edi],ecx
899 jmp $L019djend
900L020dj3:
901 ror ecx, 16
902 mov BYTE PTR 2[edi],cl
903 shl ecx, 16
904L021dj2:
905 mov BYTE PTR 1[esi],ch
906L022dj1:
907 mov BYTE PTR [esi], cl
908$L019djend:
909 jmp $L003finish
910$L003finish:
911 mov ecx, DWORD PTR 60[esp]
912 add esp, 24
913 mov DWORD PTR [ecx],eax
914 mov DWORD PTR 4[ecx],ebx
915 pop edi
916 pop esi
917 pop ebx
918 pop ebp
919 ret
920$L004cbc_enc_jmp_table:
921 DD 0
922 DD L012ej1
923 DD L011ej2
924 DD L010ej3
925 DD L008ej4
926 DD L007ej5
927 DD L006ej6
928 DD L005ej7
929L023cbc_dec_jmp_table:
930 DD 0
931 DD L022dj1
932 DD L021dj2
933 DD L020dj3
934 DD L018dj4
935 DD L017dj5
936 DD L016dj6
937 DD L015dj7
938_CAST_cbc_encrypt ENDP
939_TEXT ENDS
940END
diff --git a/src/lib/libssl/src/crypto/cast/asm/cx86unix.cpp b/src/lib/libssl/src/crypto/cast/asm/cx86unix.cpp
new file mode 100644
index 0000000000..035692a5af
--- /dev/null
+++ b/src/lib/libssl/src/crypto/cast/asm/cx86unix.cpp
@@ -0,0 +1,1010 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define CAST_S_table0 _CAST_S_table0
13#define CAST_S_table1 _CAST_S_table1
14#define CAST_S_table2 _CAST_S_table2
15#define CAST_S_table3 _CAST_S_table3
16#define CAST_encrypt _CAST_encrypt
17#define CAST_S_table0 _CAST_S_table0
18#define CAST_S_table1 _CAST_S_table1
19#define CAST_S_table2 _CAST_S_table2
20#define CAST_S_table3 _CAST_S_table3
21#define CAST_decrypt _CAST_decrypt
22#define CAST_cbc_encrypt _CAST_cbc_encrypt
23
24#endif
25
26#ifdef OUT
27#define OK 1
28#define ALIGN 4
29#endif
30
31#ifdef BSDI
32#define OK 1
33#define ALIGN 4
34#undef SIZE
35#undef TYPE
36#define SIZE(a,b)
37#define TYPE(a,b)
38#endif
39
40#if defined(ELF) || defined(SOL)
41#define OK 1
42#define ALIGN 16
43#endif
44
45#ifndef OK
46You need to define one of
47ELF - elf systems - linux-elf, NetBSD and DG-UX
48OUT - a.out systems - linux-a.out and FreeBSD
49SOL - solaris systems, which are elf with strange comment lines
50BSDI - a.out with a very primative version of as.
51#endif
52
53/* Let the Assembler begin :-) */
54 /* Don't even think of reading this code */
55 /* It was automatically generated by cast-586.pl */
56 /* Which is a perl program used to generate the x86 assember for */
57 /* any of elf, a.out, BSDI,Win32, or Solaris */
58 /* eric <eay@cryptsoft.com> */
59
60 .file "cast-586.s"
61 .version "01.01"
62gcc2_compiled.:
63.text
64 .align ALIGN
65.globl CAST_encrypt
66 TYPE(CAST_encrypt,@function)
67CAST_encrypt:
68
69 pushl %ebp
70 pushl %ebx
71 movl 12(%esp), %ebx
72 movl 16(%esp), %ebp
73 pushl %esi
74 pushl %edi
75 /* Load the 2 words */
76 movl (%ebx), %edi
77 movl 4(%ebx), %esi
78 xorl %eax, %eax
79 /* round 0 */
80 movl (%ebp), %edx
81 movl 4(%ebp), %ecx
82 addl %esi, %edx
83 roll %cl, %edx
84 movl %edx, %ebx
85 xorl %ecx, %ecx
86 movb %dh, %cl
87 andl $255, %ebx
88 shrl $16, %edx
89 xorl %eax, %eax
90 movb %dh, %al
91 andl $255, %edx
92 movl CAST_S_table0(,%ecx,4),%ecx
93 movl CAST_S_table1(,%ebx,4),%ebx
94 xorl %ebx, %ecx
95 movl CAST_S_table2(,%eax,4),%ebx
96 subl %ebx, %ecx
97 movl CAST_S_table3(,%edx,4),%ebx
98 addl %ebx, %ecx
99 xorl %ecx, %edi
100 /* round 1 */
101 movl 8(%ebp), %edx
102 movl 12(%ebp), %ecx
103 xorl %edi, %edx
104 roll %cl, %edx
105 movl %edx, %ebx
106 xorl %ecx, %ecx
107 movb %dh, %cl
108 andl $255, %ebx
109 shrl $16, %edx
110 xorl %eax, %eax
111 movb %dh, %al
112 andl $255, %edx
113 movl CAST_S_table0(,%ecx,4),%ecx
114 movl CAST_S_table1(,%ebx,4),%ebx
115 subl %ebx, %ecx
116 movl CAST_S_table2(,%eax,4),%ebx
117 addl %ebx, %ecx
118 movl CAST_S_table3(,%edx,4),%ebx
119 xorl %ebx, %ecx
120 xorl %ecx, %esi
121 /* round 2 */
122 movl 16(%ebp), %edx
123 movl 20(%ebp), %ecx
124 subl %esi, %edx
125 roll %cl, %edx
126 movl %edx, %ebx
127 xorl %ecx, %ecx
128 movb %dh, %cl
129 andl $255, %ebx
130 shrl $16, %edx
131 xorl %eax, %eax
132 movb %dh, %al
133 andl $255, %edx
134 movl CAST_S_table0(,%ecx,4),%ecx
135 movl CAST_S_table1(,%ebx,4),%ebx
136 addl %ebx, %ecx
137 movl CAST_S_table2(,%eax,4),%ebx
138 xorl %ebx, %ecx
139 movl CAST_S_table3(,%edx,4),%ebx
140 subl %ebx, %ecx
141 xorl %ecx, %edi
142 /* round 3 */
143 movl 24(%ebp), %edx
144 movl 28(%ebp), %ecx
145 addl %edi, %edx
146 roll %cl, %edx
147 movl %edx, %ebx
148 xorl %ecx, %ecx
149 movb %dh, %cl
150 andl $255, %ebx
151 shrl $16, %edx
152 xorl %eax, %eax
153 movb %dh, %al
154 andl $255, %edx
155 movl CAST_S_table0(,%ecx,4),%ecx
156 movl CAST_S_table1(,%ebx,4),%ebx
157 xorl %ebx, %ecx
158 movl CAST_S_table2(,%eax,4),%ebx
159 subl %ebx, %ecx
160 movl CAST_S_table3(,%edx,4),%ebx
161 addl %ebx, %ecx
162 xorl %ecx, %esi
163 /* round 4 */
164 movl 32(%ebp), %edx
165 movl 36(%ebp), %ecx
166 xorl %esi, %edx
167 roll %cl, %edx
168 movl %edx, %ebx
169 xorl %ecx, %ecx
170 movb %dh, %cl
171 andl $255, %ebx
172 shrl $16, %edx
173 xorl %eax, %eax
174 movb %dh, %al
175 andl $255, %edx
176 movl CAST_S_table0(,%ecx,4),%ecx
177 movl CAST_S_table1(,%ebx,4),%ebx
178 subl %ebx, %ecx
179 movl CAST_S_table2(,%eax,4),%ebx
180 addl %ebx, %ecx
181 movl CAST_S_table3(,%edx,4),%ebx
182 xorl %ebx, %ecx
183 xorl %ecx, %edi
184 /* round 5 */
185 movl 40(%ebp), %edx
186 movl 44(%ebp), %ecx
187 subl %edi, %edx
188 roll %cl, %edx
189 movl %edx, %ebx
190 xorl %ecx, %ecx
191 movb %dh, %cl
192 andl $255, %ebx
193 shrl $16, %edx
194 xorl %eax, %eax
195 movb %dh, %al
196 andl $255, %edx
197 movl CAST_S_table0(,%ecx,4),%ecx
198 movl CAST_S_table1(,%ebx,4),%ebx
199 addl %ebx, %ecx
200 movl CAST_S_table2(,%eax,4),%ebx
201 xorl %ebx, %ecx
202 movl CAST_S_table3(,%edx,4),%ebx
203 subl %ebx, %ecx
204 xorl %ecx, %esi
205 /* round 6 */
206 movl 48(%ebp), %edx
207 movl 52(%ebp), %ecx
208 addl %esi, %edx
209 roll %cl, %edx
210 movl %edx, %ebx
211 xorl %ecx, %ecx
212 movb %dh, %cl
213 andl $255, %ebx
214 shrl $16, %edx
215 xorl %eax, %eax
216 movb %dh, %al
217 andl $255, %edx
218 movl CAST_S_table0(,%ecx,4),%ecx
219 movl CAST_S_table1(,%ebx,4),%ebx
220 xorl %ebx, %ecx
221 movl CAST_S_table2(,%eax,4),%ebx
222 subl %ebx, %ecx
223 movl CAST_S_table3(,%edx,4),%ebx
224 addl %ebx, %ecx
225 xorl %ecx, %edi
226 /* round 7 */
227 movl 56(%ebp), %edx
228 movl 60(%ebp), %ecx
229 xorl %edi, %edx
230 roll %cl, %edx
231 movl %edx, %ebx
232 xorl %ecx, %ecx
233 movb %dh, %cl
234 andl $255, %ebx
235 shrl $16, %edx
236 xorl %eax, %eax
237 movb %dh, %al
238 andl $255, %edx
239 movl CAST_S_table0(,%ecx,4),%ecx
240 movl CAST_S_table1(,%ebx,4),%ebx
241 subl %ebx, %ecx
242 movl CAST_S_table2(,%eax,4),%ebx
243 addl %ebx, %ecx
244 movl CAST_S_table3(,%edx,4),%ebx
245 xorl %ebx, %ecx
246 xorl %ecx, %esi
247 /* round 8 */
248 movl 64(%ebp), %edx
249 movl 68(%ebp), %ecx
250 subl %esi, %edx
251 roll %cl, %edx
252 movl %edx, %ebx
253 xorl %ecx, %ecx
254 movb %dh, %cl
255 andl $255, %ebx
256 shrl $16, %edx
257 xorl %eax, %eax
258 movb %dh, %al
259 andl $255, %edx
260 movl CAST_S_table0(,%ecx,4),%ecx
261 movl CAST_S_table1(,%ebx,4),%ebx
262 addl %ebx, %ecx
263 movl CAST_S_table2(,%eax,4),%ebx
264 xorl %ebx, %ecx
265 movl CAST_S_table3(,%edx,4),%ebx
266 subl %ebx, %ecx
267 xorl %ecx, %edi
268 /* round 9 */
269 movl 72(%ebp), %edx
270 movl 76(%ebp), %ecx
271 addl %edi, %edx
272 roll %cl, %edx
273 movl %edx, %ebx
274 xorl %ecx, %ecx
275 movb %dh, %cl
276 andl $255, %ebx
277 shrl $16, %edx
278 xorl %eax, %eax
279 movb %dh, %al
280 andl $255, %edx
281 movl CAST_S_table0(,%ecx,4),%ecx
282 movl CAST_S_table1(,%ebx,4),%ebx
283 xorl %ebx, %ecx
284 movl CAST_S_table2(,%eax,4),%ebx
285 subl %ebx, %ecx
286 movl CAST_S_table3(,%edx,4),%ebx
287 addl %ebx, %ecx
288 xorl %ecx, %esi
289 /* round 10 */
290 movl 80(%ebp), %edx
291 movl 84(%ebp), %ecx
292 xorl %esi, %edx
293 roll %cl, %edx
294 movl %edx, %ebx
295 xorl %ecx, %ecx
296 movb %dh, %cl
297 andl $255, %ebx
298 shrl $16, %edx
299 xorl %eax, %eax
300 movb %dh, %al
301 andl $255, %edx
302 movl CAST_S_table0(,%ecx,4),%ecx
303 movl CAST_S_table1(,%ebx,4),%ebx
304 subl %ebx, %ecx
305 movl CAST_S_table2(,%eax,4),%ebx
306 addl %ebx, %ecx
307 movl CAST_S_table3(,%edx,4),%ebx
308 xorl %ebx, %ecx
309 xorl %ecx, %edi
310 /* round 11 */
311 movl 88(%ebp), %edx
312 movl 92(%ebp), %ecx
313 subl %edi, %edx
314 roll %cl, %edx
315 movl %edx, %ebx
316 xorl %ecx, %ecx
317 movb %dh, %cl
318 andl $255, %ebx
319 shrl $16, %edx
320 xorl %eax, %eax
321 movb %dh, %al
322 andl $255, %edx
323 movl CAST_S_table0(,%ecx,4),%ecx
324 movl CAST_S_table1(,%ebx,4),%ebx
325 addl %ebx, %ecx
326 movl CAST_S_table2(,%eax,4),%ebx
327 xorl %ebx, %ecx
328 movl CAST_S_table3(,%edx,4),%ebx
329 subl %ebx, %ecx
330 xorl %ecx, %esi
331 /* round 12 */
332 movl 96(%ebp), %edx
333 movl 100(%ebp), %ecx
334 addl %esi, %edx
335 roll %cl, %edx
336 movl %edx, %ebx
337 xorl %ecx, %ecx
338 movb %dh, %cl
339 andl $255, %ebx
340 shrl $16, %edx
341 xorl %eax, %eax
342 movb %dh, %al
343 andl $255, %edx
344 movl CAST_S_table0(,%ecx,4),%ecx
345 movl CAST_S_table1(,%ebx,4),%ebx
346 xorl %ebx, %ecx
347 movl CAST_S_table2(,%eax,4),%ebx
348 subl %ebx, %ecx
349 movl CAST_S_table3(,%edx,4),%ebx
350 addl %ebx, %ecx
351 xorl %ecx, %edi
352 /* round 13 */
353 movl 104(%ebp), %edx
354 movl 108(%ebp), %ecx
355 xorl %edi, %edx
356 roll %cl, %edx
357 movl %edx, %ebx
358 xorl %ecx, %ecx
359 movb %dh, %cl
360 andl $255, %ebx
361 shrl $16, %edx
362 xorl %eax, %eax
363 movb %dh, %al
364 andl $255, %edx
365 movl CAST_S_table0(,%ecx,4),%ecx
366 movl CAST_S_table1(,%ebx,4),%ebx
367 subl %ebx, %ecx
368 movl CAST_S_table2(,%eax,4),%ebx
369 addl %ebx, %ecx
370 movl CAST_S_table3(,%edx,4),%ebx
371 xorl %ebx, %ecx
372 xorl %ecx, %esi
373 /* round 14 */
374 movl 112(%ebp), %edx
375 movl 116(%ebp), %ecx
376 subl %esi, %edx
377 roll %cl, %edx
378 movl %edx, %ebx
379 xorl %ecx, %ecx
380 movb %dh, %cl
381 andl $255, %ebx
382 shrl $16, %edx
383 xorl %eax, %eax
384 movb %dh, %al
385 andl $255, %edx
386 movl CAST_S_table0(,%ecx,4),%ecx
387 movl CAST_S_table1(,%ebx,4),%ebx
388 addl %ebx, %ecx
389 movl CAST_S_table2(,%eax,4),%ebx
390 xorl %ebx, %ecx
391 movl CAST_S_table3(,%edx,4),%ebx
392 subl %ebx, %ecx
393 xorl %ecx, %edi
394 /* round 15 */
395 movl 120(%ebp), %edx
396 movl 124(%ebp), %ecx
397 addl %edi, %edx
398 roll %cl, %edx
399 movl %edx, %ebx
400 xorl %ecx, %ecx
401 movb %dh, %cl
402 andl $255, %ebx
403 shrl $16, %edx
404 xorl %eax, %eax
405 movb %dh, %al
406 andl $255, %edx
407 movl CAST_S_table0(,%ecx,4),%ecx
408 movl CAST_S_table1(,%ebx,4),%ebx
409 xorl %ebx, %ecx
410 movl CAST_S_table2(,%eax,4),%ebx
411 subl %ebx, %ecx
412 movl CAST_S_table3(,%edx,4),%ebx
413 addl %ebx, %ecx
414 movl 20(%esp), %eax
415 xorl %ecx, %esi
416 nop
417 movl %edi, 4(%eax)
418 movl %esi, (%eax)
419 popl %edi
420 popl %esi
421 popl %ebx
422 popl %ebp
423 ret
424.CAST_encrypt_end:
425 SIZE(CAST_encrypt,.CAST_encrypt_end-CAST_encrypt)
426.ident "CAST_encrypt"
427.text
428 .align ALIGN
429.globl CAST_decrypt
430 TYPE(CAST_decrypt,@function)
431CAST_decrypt:
432
433 pushl %ebp
434 pushl %ebx
435 movl 12(%esp), %ebx
436 movl 16(%esp), %ebp
437 pushl %esi
438 pushl %edi
439 /* Load the 2 words */
440 movl (%ebx), %edi
441 movl 4(%ebx), %esi
442 xorl %eax, %eax
443 /* round 15 */
444 movl 120(%ebp), %edx
445 movl 124(%ebp), %ecx
446 addl %esi, %edx
447 roll %cl, %edx
448 movl %edx, %ebx
449 xorl %ecx, %ecx
450 movb %dh, %cl
451 andl $255, %ebx
452 shrl $16, %edx
453 xorl %eax, %eax
454 movb %dh, %al
455 andl $255, %edx
456 movl CAST_S_table0(,%ecx,4),%ecx
457 movl CAST_S_table1(,%ebx,4),%ebx
458 xorl %ebx, %ecx
459 movl CAST_S_table2(,%eax,4),%ebx
460 subl %ebx, %ecx
461 movl CAST_S_table3(,%edx,4),%ebx
462 addl %ebx, %ecx
463 xorl %ecx, %edi
464 /* round 14 */
465 movl 112(%ebp), %edx
466 movl 116(%ebp), %ecx
467 subl %edi, %edx
468 roll %cl, %edx
469 movl %edx, %ebx
470 xorl %ecx, %ecx
471 movb %dh, %cl
472 andl $255, %ebx
473 shrl $16, %edx
474 xorl %eax, %eax
475 movb %dh, %al
476 andl $255, %edx
477 movl CAST_S_table0(,%ecx,4),%ecx
478 movl CAST_S_table1(,%ebx,4),%ebx
479 addl %ebx, %ecx
480 movl CAST_S_table2(,%eax,4),%ebx
481 xorl %ebx, %ecx
482 movl CAST_S_table3(,%edx,4),%ebx
483 subl %ebx, %ecx
484 xorl %ecx, %esi
485 /* round 13 */
486 movl 104(%ebp), %edx
487 movl 108(%ebp), %ecx
488 xorl %esi, %edx
489 roll %cl, %edx
490 movl %edx, %ebx
491 xorl %ecx, %ecx
492 movb %dh, %cl
493 andl $255, %ebx
494 shrl $16, %edx
495 xorl %eax, %eax
496 movb %dh, %al
497 andl $255, %edx
498 movl CAST_S_table0(,%ecx,4),%ecx
499 movl CAST_S_table1(,%ebx,4),%ebx
500 subl %ebx, %ecx
501 movl CAST_S_table2(,%eax,4),%ebx
502 addl %ebx, %ecx
503 movl CAST_S_table3(,%edx,4),%ebx
504 xorl %ebx, %ecx
505 xorl %ecx, %edi
506 /* round 12 */
507 movl 96(%ebp), %edx
508 movl 100(%ebp), %ecx
509 addl %edi, %edx
510 roll %cl, %edx
511 movl %edx, %ebx
512 xorl %ecx, %ecx
513 movb %dh, %cl
514 andl $255, %ebx
515 shrl $16, %edx
516 xorl %eax, %eax
517 movb %dh, %al
518 andl $255, %edx
519 movl CAST_S_table0(,%ecx,4),%ecx
520 movl CAST_S_table1(,%ebx,4),%ebx
521 xorl %ebx, %ecx
522 movl CAST_S_table2(,%eax,4),%ebx
523 subl %ebx, %ecx
524 movl CAST_S_table3(,%edx,4),%ebx
525 addl %ebx, %ecx
526 xorl %ecx, %esi
527 /* round 11 */
528 movl 88(%ebp), %edx
529 movl 92(%ebp), %ecx
530 subl %esi, %edx
531 roll %cl, %edx
532 movl %edx, %ebx
533 xorl %ecx, %ecx
534 movb %dh, %cl
535 andl $255, %ebx
536 shrl $16, %edx
537 xorl %eax, %eax
538 movb %dh, %al
539 andl $255, %edx
540 movl CAST_S_table0(,%ecx,4),%ecx
541 movl CAST_S_table1(,%ebx,4),%ebx
542 addl %ebx, %ecx
543 movl CAST_S_table2(,%eax,4),%ebx
544 xorl %ebx, %ecx
545 movl CAST_S_table3(,%edx,4),%ebx
546 subl %ebx, %ecx
547 xorl %ecx, %edi
548 /* round 10 */
549 movl 80(%ebp), %edx
550 movl 84(%ebp), %ecx
551 xorl %edi, %edx
552 roll %cl, %edx
553 movl %edx, %ebx
554 xorl %ecx, %ecx
555 movb %dh, %cl
556 andl $255, %ebx
557 shrl $16, %edx
558 xorl %eax, %eax
559 movb %dh, %al
560 andl $255, %edx
561 movl CAST_S_table0(,%ecx,4),%ecx
562 movl CAST_S_table1(,%ebx,4),%ebx
563 subl %ebx, %ecx
564 movl CAST_S_table2(,%eax,4),%ebx
565 addl %ebx, %ecx
566 movl CAST_S_table3(,%edx,4),%ebx
567 xorl %ebx, %ecx
568 xorl %ecx, %esi
569 /* round 9 */
570 movl 72(%ebp), %edx
571 movl 76(%ebp), %ecx
572 addl %esi, %edx
573 roll %cl, %edx
574 movl %edx, %ebx
575 xorl %ecx, %ecx
576 movb %dh, %cl
577 andl $255, %ebx
578 shrl $16, %edx
579 xorl %eax, %eax
580 movb %dh, %al
581 andl $255, %edx
582 movl CAST_S_table0(,%ecx,4),%ecx
583 movl CAST_S_table1(,%ebx,4),%ebx
584 xorl %ebx, %ecx
585 movl CAST_S_table2(,%eax,4),%ebx
586 subl %ebx, %ecx
587 movl CAST_S_table3(,%edx,4),%ebx
588 addl %ebx, %ecx
589 xorl %ecx, %edi
590 /* round 8 */
591 movl 64(%ebp), %edx
592 movl 68(%ebp), %ecx
593 subl %edi, %edx
594 roll %cl, %edx
595 movl %edx, %ebx
596 xorl %ecx, %ecx
597 movb %dh, %cl
598 andl $255, %ebx
599 shrl $16, %edx
600 xorl %eax, %eax
601 movb %dh, %al
602 andl $255, %edx
603 movl CAST_S_table0(,%ecx,4),%ecx
604 movl CAST_S_table1(,%ebx,4),%ebx
605 addl %ebx, %ecx
606 movl CAST_S_table2(,%eax,4),%ebx
607 xorl %ebx, %ecx
608 movl CAST_S_table3(,%edx,4),%ebx
609 subl %ebx, %ecx
610 xorl %ecx, %esi
611 /* round 7 */
612 movl 56(%ebp), %edx
613 movl 60(%ebp), %ecx
614 xorl %esi, %edx
615 roll %cl, %edx
616 movl %edx, %ebx
617 xorl %ecx, %ecx
618 movb %dh, %cl
619 andl $255, %ebx
620 shrl $16, %edx
621 xorl %eax, %eax
622 movb %dh, %al
623 andl $255, %edx
624 movl CAST_S_table0(,%ecx,4),%ecx
625 movl CAST_S_table1(,%ebx,4),%ebx
626 subl %ebx, %ecx
627 movl CAST_S_table2(,%eax,4),%ebx
628 addl %ebx, %ecx
629 movl CAST_S_table3(,%edx,4),%ebx
630 xorl %ebx, %ecx
631 xorl %ecx, %edi
632 /* round 6 */
633 movl 48(%ebp), %edx
634 movl 52(%ebp), %ecx
635 addl %edi, %edx
636 roll %cl, %edx
637 movl %edx, %ebx
638 xorl %ecx, %ecx
639 movb %dh, %cl
640 andl $255, %ebx
641 shrl $16, %edx
642 xorl %eax, %eax
643 movb %dh, %al
644 andl $255, %edx
645 movl CAST_S_table0(,%ecx,4),%ecx
646 movl CAST_S_table1(,%ebx,4),%ebx
647 xorl %ebx, %ecx
648 movl CAST_S_table2(,%eax,4),%ebx
649 subl %ebx, %ecx
650 movl CAST_S_table3(,%edx,4),%ebx
651 addl %ebx, %ecx
652 xorl %ecx, %esi
653 /* round 5 */
654 movl 40(%ebp), %edx
655 movl 44(%ebp), %ecx
656 subl %esi, %edx
657 roll %cl, %edx
658 movl %edx, %ebx
659 xorl %ecx, %ecx
660 movb %dh, %cl
661 andl $255, %ebx
662 shrl $16, %edx
663 xorl %eax, %eax
664 movb %dh, %al
665 andl $255, %edx
666 movl CAST_S_table0(,%ecx,4),%ecx
667 movl CAST_S_table1(,%ebx,4),%ebx
668 addl %ebx, %ecx
669 movl CAST_S_table2(,%eax,4),%ebx
670 xorl %ebx, %ecx
671 movl CAST_S_table3(,%edx,4),%ebx
672 subl %ebx, %ecx
673 xorl %ecx, %edi
674 /* round 4 */
675 movl 32(%ebp), %edx
676 movl 36(%ebp), %ecx
677 xorl %edi, %edx
678 roll %cl, %edx
679 movl %edx, %ebx
680 xorl %ecx, %ecx
681 movb %dh, %cl
682 andl $255, %ebx
683 shrl $16, %edx
684 xorl %eax, %eax
685 movb %dh, %al
686 andl $255, %edx
687 movl CAST_S_table0(,%ecx,4),%ecx
688 movl CAST_S_table1(,%ebx,4),%ebx
689 subl %ebx, %ecx
690 movl CAST_S_table2(,%eax,4),%ebx
691 addl %ebx, %ecx
692 movl CAST_S_table3(,%edx,4),%ebx
693 xorl %ebx, %ecx
694 xorl %ecx, %esi
695 /* round 3 */
696 movl 24(%ebp), %edx
697 movl 28(%ebp), %ecx
698 addl %esi, %edx
699 roll %cl, %edx
700 movl %edx, %ebx
701 xorl %ecx, %ecx
702 movb %dh, %cl
703 andl $255, %ebx
704 shrl $16, %edx
705 xorl %eax, %eax
706 movb %dh, %al
707 andl $255, %edx
708 movl CAST_S_table0(,%ecx,4),%ecx
709 movl CAST_S_table1(,%ebx,4),%ebx
710 xorl %ebx, %ecx
711 movl CAST_S_table2(,%eax,4),%ebx
712 subl %ebx, %ecx
713 movl CAST_S_table3(,%edx,4),%ebx
714 addl %ebx, %ecx
715 xorl %ecx, %edi
716 /* round 2 */
717 movl 16(%ebp), %edx
718 movl 20(%ebp), %ecx
719 subl %edi, %edx
720 roll %cl, %edx
721 movl %edx, %ebx
722 xorl %ecx, %ecx
723 movb %dh, %cl
724 andl $255, %ebx
725 shrl $16, %edx
726 xorl %eax, %eax
727 movb %dh, %al
728 andl $255, %edx
729 movl CAST_S_table0(,%ecx,4),%ecx
730 movl CAST_S_table1(,%ebx,4),%ebx
731 addl %ebx, %ecx
732 movl CAST_S_table2(,%eax,4),%ebx
733 xorl %ebx, %ecx
734 movl CAST_S_table3(,%edx,4),%ebx
735 subl %ebx, %ecx
736 xorl %ecx, %esi
737 /* round 1 */
738 movl 8(%ebp), %edx
739 movl 12(%ebp), %ecx
740 xorl %esi, %edx
741 roll %cl, %edx
742 movl %edx, %ebx
743 xorl %ecx, %ecx
744 movb %dh, %cl
745 andl $255, %ebx
746 shrl $16, %edx
747 xorl %eax, %eax
748 movb %dh, %al
749 andl $255, %edx
750 movl CAST_S_table0(,%ecx,4),%ecx
751 movl CAST_S_table1(,%ebx,4),%ebx
752 subl %ebx, %ecx
753 movl CAST_S_table2(,%eax,4),%ebx
754 addl %ebx, %ecx
755 movl CAST_S_table3(,%edx,4),%ebx
756 xorl %ebx, %ecx
757 xorl %ecx, %edi
758 /* round 0 */
759 movl (%ebp), %edx
760 movl 4(%ebp), %ecx
761 addl %edi, %edx
762 roll %cl, %edx
763 movl %edx, %ebx
764 xorl %ecx, %ecx
765 movb %dh, %cl
766 andl $255, %ebx
767 shrl $16, %edx
768 xorl %eax, %eax
769 movb %dh, %al
770 andl $255, %edx
771 movl CAST_S_table0(,%ecx,4),%ecx
772 movl CAST_S_table1(,%ebx,4),%ebx
773 xorl %ebx, %ecx
774 movl CAST_S_table2(,%eax,4),%ebx
775 subl %ebx, %ecx
776 movl CAST_S_table3(,%edx,4),%ebx
777 addl %ebx, %ecx
778 movl 20(%esp), %eax
779 xorl %ecx, %esi
780 nop
781 movl %edi, 4(%eax)
782 movl %esi, (%eax)
783 popl %edi
784 popl %esi
785 popl %ebx
786 popl %ebp
787 ret
788.CAST_decrypt_end:
789 SIZE(CAST_decrypt,.CAST_decrypt_end-CAST_decrypt)
790.ident "CAST_decrypt"
791.text
792 .align ALIGN
793.globl CAST_cbc_encrypt
794 TYPE(CAST_cbc_encrypt,@function)
795CAST_cbc_encrypt:
796
797 pushl %ebp
798 pushl %ebx
799 pushl %esi
800 pushl %edi
801 movl 28(%esp), %ebp
802 /* getting iv ptr from parameter 4 */
803 movl 36(%esp), %ebx
804 movl (%ebx), %esi
805 movl 4(%ebx), %edi
806 pushl %edi
807 pushl %esi
808 pushl %edi
809 pushl %esi
810 movl %esp, %ebx
811 movl 36(%esp), %esi
812 movl 40(%esp), %edi
813 /* getting encrypt flag from parameter 5 */
814 movl 56(%esp), %ecx
815 /* get and push parameter 3 */
816 movl 48(%esp), %eax
817 pushl %eax
818 pushl %ebx
819 cmpl $0, %ecx
820 jz .L000decrypt
821 andl $4294967288, %ebp
822 movl 8(%esp), %eax
823 movl 12(%esp), %ebx
824 jz .L001encrypt_finish
825.L002encrypt_loop:
826 movl (%esi), %ecx
827 movl 4(%esi), %edx
828 xorl %ecx, %eax
829 xorl %edx, %ebx
830.byte 15
831.byte 200 /* bswapl %eax */
832.byte 15
833.byte 203 /* bswapl %ebx */
834 movl %eax, 8(%esp)
835 movl %ebx, 12(%esp)
836 call CAST_encrypt
837 movl 8(%esp), %eax
838 movl 12(%esp), %ebx
839.byte 15
840.byte 200 /* bswapl %eax */
841.byte 15
842.byte 203 /* bswapl %ebx */
843 movl %eax, (%edi)
844 movl %ebx, 4(%edi)
845 addl $8, %esi
846 addl $8, %edi
847 subl $8, %ebp
848 jnz .L002encrypt_loop
849.L001encrypt_finish:
850 movl 52(%esp), %ebp
851 andl $7, %ebp
852 jz .L003finish
853 xorl %ecx, %ecx
854 xorl %edx, %edx
855 movl .L004cbc_enc_jmp_table(,%ebp,4),%ebp
856 jmp *%ebp
857.L005ej7:
858 xorl %edx, %edx
859 movb 6(%esi), %dh
860 sall $8, %edx
861.L006ej6:
862 movb 5(%esi), %dh
863.L007ej5:
864 movb 4(%esi), %dl
865.L008ej4:
866 movl (%esi), %ecx
867 jmp .L009ejend
868.L010ej3:
869 movb 2(%esi), %ch
870 xorl %ecx, %ecx
871 sall $8, %ecx
872.L011ej2:
873 movb 1(%esi), %ch
874.L012ej1:
875 movb (%esi), %cl
876.L009ejend:
877 xorl %ecx, %eax
878 xorl %edx, %ebx
879.byte 15
880.byte 200 /* bswapl %eax */
881.byte 15
882.byte 203 /* bswapl %ebx */
883 movl %eax, 8(%esp)
884 movl %ebx, 12(%esp)
885 call CAST_encrypt
886 movl 8(%esp), %eax
887 movl 12(%esp), %ebx
888.byte 15
889.byte 200 /* bswapl %eax */
890.byte 15
891.byte 203 /* bswapl %ebx */
892 movl %eax, (%edi)
893 movl %ebx, 4(%edi)
894 jmp .L003finish
895.align ALIGN
896.L000decrypt:
897 andl $4294967288, %ebp
898 movl 16(%esp), %eax
899 movl 20(%esp), %ebx
900 jz .L013decrypt_finish
901.L014decrypt_loop:
902 movl (%esi), %eax
903 movl 4(%esi), %ebx
904.byte 15
905.byte 200 /* bswapl %eax */
906.byte 15
907.byte 203 /* bswapl %ebx */
908 movl %eax, 8(%esp)
909 movl %ebx, 12(%esp)
910 call CAST_decrypt
911 movl 8(%esp), %eax
912 movl 12(%esp), %ebx
913.byte 15
914.byte 200 /* bswapl %eax */
915.byte 15
916.byte 203 /* bswapl %ebx */
917 movl 16(%esp), %ecx
918 movl 20(%esp), %edx
919 xorl %eax, %ecx
920 xorl %ebx, %edx
921 movl (%esi), %eax
922 movl 4(%esi), %ebx
923 movl %ecx, (%edi)
924 movl %edx, 4(%edi)
925 movl %eax, 16(%esp)
926 movl %ebx, 20(%esp)
927 addl $8, %esi
928 addl $8, %edi
929 subl $8, %ebp
930 jnz .L014decrypt_loop
931.L013decrypt_finish:
932 movl 52(%esp), %ebp
933 andl $7, %ebp
934 jz .L003finish
935 movl (%esi), %eax
936 movl 4(%esi), %ebx
937.byte 15
938.byte 200 /* bswapl %eax */
939.byte 15
940.byte 203 /* bswapl %ebx */
941 movl %eax, 8(%esp)
942 movl %ebx, 12(%esp)
943 call CAST_decrypt
944 movl 8(%esp), %eax
945 movl 12(%esp), %ebx
946.byte 15
947.byte 200 /* bswapl %eax */
948.byte 15
949.byte 203 /* bswapl %ebx */
950 movl 16(%esp), %ecx
951 movl 20(%esp), %edx
952 xorl %eax, %ecx
953 xorl %ebx, %edx
954 movl (%esi), %eax
955 movl 4(%esi), %ebx
956.L015dj7:
957 rorl $16, %edx
958 movb %dl, 6(%edi)
959 shrl $16, %edx
960.L016dj6:
961 movb %dh, 5(%edi)
962.L017dj5:
963 movb %dl, 4(%edi)
964.L018dj4:
965 movl %ecx, (%edi)
966 jmp .L019djend
967.L020dj3:
968 rorl $16, %ecx
969 movb %cl, 2(%edi)
970 sall $16, %ecx
971.L021dj2:
972 movb %ch, 1(%esi)
973.L022dj1:
974 movb %cl, (%esi)
975.L019djend:
976 jmp .L003finish
977.align ALIGN
978.L003finish:
979 movl 60(%esp), %ecx
980 addl $24, %esp
981 movl %eax, (%ecx)
982 movl %ebx, 4(%ecx)
983 popl %edi
984 popl %esi
985 popl %ebx
986 popl %ebp
987 ret
988.align ALIGN
989.L004cbc_enc_jmp_table:
990 .long 0
991 .long .L012ej1
992 .long .L011ej2
993 .long .L010ej3
994 .long .L008ej4
995 .long .L007ej5
996 .long .L006ej6
997 .long .L005ej7
998.align ALIGN
999.L023cbc_dec_jmp_table:
1000 .long 0
1001 .long .L022dj1
1002 .long .L021dj2
1003 .long .L020dj3
1004 .long .L018dj4
1005 .long .L017dj5
1006 .long .L016dj6
1007 .long .L015dj7
1008.CAST_cbc_encrypt_end:
1009 SIZE(CAST_cbc_encrypt,.CAST_cbc_encrypt_end-CAST_cbc_encrypt)
1010.ident "desasm.pl"
diff --git a/src/lib/libssl/src/crypto/conf/Makefile.ssl b/src/lib/libssl/src/crypto/conf/Makefile.ssl
new file mode 100644
index 0000000000..00e917aa44
--- /dev/null
+++ b/src/lib/libssl/src/crypto/conf/Makefile.ssl
@@ -0,0 +1,85 @@
1#
2# SSLeay/crypto/conf/Makefile
3#
4
5DIR= conf
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=conf
19ERRC=conf_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= conf.c $(ERRC).c
26
27LIBOBJ= conf.o $(ERRC).o
28
29SRC= $(LIBSRC)
30
31EXHEADER= conf.h
32HEADER= conf_lcl.h $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 sh $(TOP)/util/ranlib.sh $(LIB)
44 @touch lib
45
46files:
47 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
48
49links:
50 /bin/rm -f Makefile
51 $(TOP)/util/point.sh Makefile.ssl Makefile ;
52 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
53 $(TOP)/util/mklink.sh ../../test $(TEST)
54 $(TOP)/util/mklink.sh ../../apps $(APPS)
55
56install:
57 @for i in $(EXHEADER) ; \
58 do \
59 (cp $$i $(INSTALLTOP)/include/$$i; \
60 chmod 644 $(INSTALLTOP)/include/$$i ); \
61 done;
62
63tags:
64 ctags $(SRC)
65
66tests:
67
68lint:
69 lint -DLINT $(INCLUDES) $(SRC)>fluff
70
71depend:
72 $(MAKEDEPEND) $(INCLUDES) $(LIBSRC)
73
74dclean:
75 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
76 mv -f Makefile.new $(MAKEFILE)
77
78clean:
79 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
80
81errors:
82 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
83 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
84
85# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/conf/conf.c b/src/lib/libssl/src/crypto/conf/conf.c
new file mode 100644
index 0000000000..9e84300c5e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/conf/conf.c
@@ -0,0 +1,727 @@
1/* crypto/conf/conf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <errno.h>
61#include "cryptlib.h"
62#include "stack.h"
63#include "lhash.h"
64#include "conf.h"
65#include "buffer.h"
66#include "err.h"
67
68#include "conf_lcl.h"
69
70#ifndef NOPROTO
71static void value_free_hash(CONF_VALUE *a, LHASH *conf);
72static void value_free_stack(CONF_VALUE *a,LHASH *conf);
73static unsigned long hash(CONF_VALUE *v);
74static int cmp(CONF_VALUE *a,CONF_VALUE *b);
75static char *eat_ws(char *p);
76static char *eat_alpha_numeric(char *p);
77static void clear_comments(char *p);
78static int str_copy(LHASH *conf,char *section,char **to, char *from);
79static char *scan_quote(char *p);
80static CONF_VALUE *new_section(LHASH *conf,char *section);
81static CONF_VALUE *get_section(LHASH *conf,char *section);
82#else
83static void value_free_hash();
84static void value_free_stack();
85static unsigned long hash();
86static int cmp();
87static char *eat_ws();
88static char *eat_alpha_numeric();
89static void clear_comments();
90static int str_copy();
91static char *scan_quote();
92static CONF_VALUE *new_section();
93static CONF_VALUE *get_section();
94#endif
95
96#define scan_esc(p) ((*(++p) == '\0')?(p):(++p))
97
98char *CONF_version="CONF part of SSLeay 0.9.0b 29-Jun-1998";
99
100LHASH *CONF_load(h,file,line)
101LHASH *h;
102char *file;
103long *line;
104 {
105 LHASH *ret=NULL;
106 FILE *in=NULL;
107#define BUFSIZE 512
108 int bufnum=0,i,ii;
109 BUF_MEM *buff=NULL;
110 char *s,*p,*end;
111 int again,n,eline=0;
112 CONF_VALUE *v=NULL,*vv,*tv;
113 CONF_VALUE *sv=NULL;
114 char *section=NULL,*buf;
115 STACK *section_sk=NULL,*ts;
116 char *start,*psection,*pname;
117
118 if ((buff=BUF_MEM_new()) == NULL)
119 {
120 CONFerr(CONF_F_CONF_LOAD,ERR_R_BUF_LIB);
121 goto err;
122 }
123
124 in=fopen(file,"rb");
125 if (in == NULL)
126 {
127 SYSerr(SYS_F_FOPEN,get_last_sys_error());
128 ERR_set_error_data(BUF_strdup(file),
129 ERR_TXT_MALLOCED|ERR_TXT_STRING);
130 CONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);
131 goto err;
132 }
133
134 section=(char *)Malloc(10);
135 if (section == NULL)
136 {
137 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE);
138 goto err;
139 }
140 strcpy(section,"default");
141
142 if (h == NULL)
143 {
144 if ((ret=lh_new(hash,cmp)) == NULL)
145 {
146 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE);
147 goto err;
148 }
149 }
150 else
151 ret=h;
152
153 sv=new_section(ret,section);
154 if (sv == NULL)
155 {
156 CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
157 goto err;
158 }
159 section_sk=(STACK *)sv->value;
160
161 bufnum=0;
162 for (;;)
163 {
164 again=0;
165 if (!BUF_MEM_grow(buff,bufnum+BUFSIZE))
166 {
167 CONFerr(CONF_F_CONF_LOAD,ERR_R_BUF_LIB);
168 goto err;
169 }
170 p= &(buff->data[bufnum]);
171 *p='\0';
172 fgets(p,BUFSIZE-1,in);
173 p[BUFSIZE-1]='\0';
174 ii=i=strlen(p);
175 if (i == 0) break;
176 while (i > 0)
177 {
178 if ((p[i-1] != '\r') && (p[i-1] != '\n'))
179 break;
180 else
181 i--;
182 }
183 /* we removed some trailing stuff so there is a new
184 * line on the end. */
185 if (i == ii)
186 again=1; /* long line */
187 else
188 {
189 p[i]='\0';
190 eline++; /* another input line */
191 }
192
193 /* we now have a line with trailing \r\n removed */
194
195 /* i is the number of bytes */
196 bufnum+=i;
197
198 v=NULL;
199 /* check for line continuation */
200 if (bufnum >= 1)
201 {
202 /* If we have bytes and the last char '\\' and
203 * second last char is not '\\' */
204 p= &(buff->data[bufnum-1]);
205 if ( IS_ESC(p[0]) &&
206 ((bufnum <= 1) || !IS_ESC(p[-1])))
207 {
208 bufnum--;
209 again=1;
210 }
211 }
212 if (again) continue;
213 bufnum=0;
214 buf=buff->data;
215
216 clear_comments(buf);
217 n=strlen(buf);
218 s=eat_ws(buf);
219 if (IS_EOF(*s)) continue; /* blank line */
220 if (*s == '[')
221 {
222 s++;
223 start=eat_ws(s);
224 end=eat_alpha_numeric(start);
225 p=eat_ws(end);
226 if (*p != ']')
227 {
228 CONFerr(CONF_F_CONF_LOAD,CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
229 goto err;
230 }
231 *end='\0';
232 if (!str_copy(ret,NULL,&section,start)) goto err;
233 if ((sv=get_section(ret,section)) == NULL)
234 sv=new_section(ret,section);
235 if (sv == NULL)
236 {
237 CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
238 goto err;
239 }
240 section_sk=(STACK *)sv->value;
241 continue;
242 }
243 else
244 {
245 pname=s;
246 psection=NULL;
247 end=eat_alpha_numeric(s);
248 if ((end[0] == ':') && (end[1] == ':'))
249 {
250 *end='\0';
251 end+=2;
252 psection=pname;
253 pname=end;
254 end=eat_alpha_numeric(end);
255 }
256 p=eat_ws(end);
257 if (*p != '=')
258 {
259 CONFerr(CONF_F_CONF_LOAD,CONF_R_MISSING_EQUAL_SIGN);
260 goto err;
261 }
262 *end='\0';
263 p++;
264 start=eat_ws(p);
265 while (!IS_EOF(*p))
266 p++;
267 p--;
268 while ((p != start) && (IS_WS(*p)))
269 p--;
270 p++;
271 *p='\0';
272
273 if ((v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))) == NULL)
274 {
275 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE);
276 goto err;
277 }
278 if (psection == NULL) psection=section;
279 v->name=(char *)Malloc(strlen(pname)+1);
280 v->value=NULL;
281 if (v->name == NULL)
282 {
283 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE);
284 goto err;
285 }
286 strcpy(v->name,pname);
287 if (!str_copy(ret,psection,&(v->value),start)) goto err;
288
289 if (strcmp(psection,section) != 0)
290 {
291 if ((tv=get_section(ret,psection))
292 == NULL)
293 tv=new_section(ret,psection);
294 if (tv == NULL)
295 {
296 CONFerr(CONF_F_CONF_LOAD,CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
297 goto err;
298 }
299 ts=(STACK *)tv->value;
300 }
301 else
302 {
303 tv=sv;
304 ts=section_sk;
305 }
306 v->section=tv->section;
307 if (!sk_push(ts,(char *)v))
308 {
309 CONFerr(CONF_F_CONF_LOAD,ERR_R_MALLOC_FAILURE);
310 goto err;
311 }
312 vv=(CONF_VALUE *)lh_insert(ret,(char *)v);
313 if (vv != NULL)
314 {
315 sk_delete_ptr(ts,(char *)vv);
316 Free(vv->name);
317 Free(vv->value);
318 Free(vv);
319 }
320 v=NULL;
321 }
322 }
323 if (buff != NULL) BUF_MEM_free(buff);
324 if (section != NULL) Free(section);
325 if (in != NULL) fclose(in);
326 return(ret);
327err:
328 if (buff != NULL) BUF_MEM_free(buff);
329 if (section != NULL) Free(section);
330 if (line != NULL) *line=eline;
331 if (in != NULL) fclose(in);
332 if ((h != ret) && (ret != NULL)) CONF_free(ret);
333 if (v != NULL)
334 {
335 if (v->name != NULL) Free(v->name);
336 if (v->value != NULL) Free(v->value);
337 if (v != NULL) Free(v);
338 }
339 return(NULL);
340 }
341
342char *CONF_get_string(conf,section,name)
343LHASH *conf;
344char *section;
345char *name;
346 {
347 CONF_VALUE *v,vv;
348 char *p;
349
350 if (name == NULL) return(NULL);
351 if (conf != NULL)
352 {
353 if (section != NULL)
354 {
355 vv.name=name;
356 vv.section=section;
357 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv);
358 if (v != NULL) return(v->value);
359 if (strcmp(section,"ENV") == 0)
360 {
361 p=Getenv(name);
362 if (p != NULL) return(p);
363 }
364 }
365 vv.section="default";
366 vv.name=name;
367 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv);
368 if (v != NULL)
369 return(v->value);
370 else
371 return(NULL);
372 }
373 else
374 return(Getenv(name));
375 }
376
377static CONF_VALUE *get_section(conf,section)
378LHASH *conf;
379char *section;
380 {
381 CONF_VALUE *v,vv;
382
383 if ((conf == NULL) || (section == NULL)) return(NULL);
384 vv.name=NULL;
385 vv.section=section;
386 v=(CONF_VALUE *)lh_retrieve(conf,(char *)&vv);
387 return(v);
388 }
389
390STACK *CONF_get_section(conf,section)
391LHASH *conf;
392char *section;
393 {
394 CONF_VALUE *v;
395
396 v=get_section(conf,section);
397 if (v != NULL)
398 return((STACK *)v->value);
399 else
400 return(NULL);
401 }
402
403long CONF_get_number(conf,section,name)
404LHASH *conf;
405char *section;
406char *name;
407 {
408 char *str;
409 long ret=0;
410
411 str=CONF_get_string(conf,section,name);
412 if (str == NULL) return(0);
413 for (;;)
414 {
415 if (IS_NUMER(*str))
416 ret=ret*10+(*str -'0');
417 else
418 return(ret);
419 str++;
420 }
421 }
422
423void CONF_free(conf)
424LHASH *conf;
425 {
426 if (conf == NULL) return;
427
428 conf->down_load=0; /* evil thing to make sure the 'Free()'
429 * works as expected */
430 lh_doall_arg(conf,(void (*)())value_free_hash,(char *)conf);
431
432 /* We now have only 'section' entries in the hash table.
433 * Due to problems with */
434
435 lh_doall_arg(conf,(void (*)())value_free_stack,(char *)conf);
436 lh_free(conf);
437 }
438
439static void value_free_hash(a,conf)
440CONF_VALUE *a;
441LHASH *conf;
442 {
443 if (a->name != NULL)
444 {
445 a=(CONF_VALUE *)lh_delete(conf,(char *)a);
446 }
447 }
448
449static void value_free_stack(a,conf)
450CONF_VALUE *a;
451LHASH *conf;
452 {
453 CONF_VALUE *vv;
454 STACK *sk;
455 int i;
456
457 if (a->name != NULL) return;
458
459 sk=(STACK *)a->value;
460 for (i=sk_num(sk)-1; i>=0; i--)
461 {
462 vv=(CONF_VALUE *)sk_value(sk,i);
463 Free(vv->value);
464 Free(vv->name);
465 Free(vv);
466 }
467 if (sk != NULL) sk_free(sk);
468 Free(a->section);
469 Free(a);
470 }
471
472static void clear_comments(p)
473char *p;
474 {
475 char *to;
476
477 to=p;
478 for (;;)
479 {
480 if (IS_COMMENT(*p))
481 {
482 *p='\0';
483 return;
484 }
485 if (IS_QUOTE(*p))
486 {
487 p=scan_quote(p);
488 continue;
489 }
490 if (IS_ESC(*p))
491 {
492 p=scan_esc(p);
493 continue;
494 }
495 if (IS_EOF(*p))
496 return;
497 else
498 p++;
499 }
500 }
501
502static int str_copy(conf,section,pto,from)
503LHASH *conf;
504char *section;
505char **pto,*from;
506 {
507 int q,r,rr=0,to=0,len=0;
508 char *s,*e,*rp,*p,*rrp,*np,*cp,v;
509 BUF_MEM *buf;
510
511 if ((buf=BUF_MEM_new()) == NULL) return(0);
512
513 len=strlen(from)+1;
514 if (!BUF_MEM_grow(buf,len)) goto err;
515
516 for (;;)
517 {
518 if (IS_QUOTE(*from))
519 {
520 q= *from;
521 from++;
522 while ((*from != '\0') && (*from != q))
523 {
524 if (*from == '\\')
525 {
526 from++;
527 if (*from == '\0') break;
528 }
529 buf->data[to++]= *(from++);
530 }
531 }
532 else if (*from == '\\')
533 {
534 from++;
535 v= *(from++);
536 if (v == '\0') break;
537 else if (v == 'r') v='\r';
538 else if (v == 'n') v='\n';
539 else if (v == 'b') v='\b';
540 else if (v == 't') v='\t';
541 buf->data[to++]= v;
542 }
543 else if (*from == '\0')
544 break;
545 else if (*from == '$')
546 {
547 /* try to expand it */
548 rrp=NULL;
549 s= &(from[1]);
550 if (*s == '{')
551 q='}';
552 else if (*s == '(')
553 q=')';
554 else q=0;
555
556 if (q) s++;
557 cp=section;
558 e=np=s;
559 while (IS_ALPHA_NUMERIC(*e))
560 e++;
561 if ((e[0] == ':') && (e[1] == ':'))
562 {
563 cp=np;
564 rrp=e;
565 rr= *e;
566 *rrp='\0';
567 e+=2;
568 np=e;
569 while (IS_ALPHA_NUMERIC(*e))
570 e++;
571 }
572 r= *e;
573 *e='\0';
574 rp=e;
575 if (q)
576 {
577 if (r != q)
578 {
579 CONFerr(CONF_F_STR_COPY,CONF_R_NO_CLOSE_BRACE);
580 goto err;
581 }
582 e++;
583 }
584 /* So at this point we have
585 * ns which is the start of the name string which is
586 * '\0' terminated.
587 * cs which is the start of the section string which is
588 * '\0' terminated.
589 * e is the 'next point after'.
590 * r and s are the chars replaced by the '\0'
591 * rp and sp is where 'r' and 's' came from.
592 */
593 p=CONF_get_string(conf,cp,np);
594 if (rrp != NULL) *rrp=rr;
595 *rp=r;
596 if (p == NULL)
597 {
598 CONFerr(CONF_F_STR_COPY,CONF_R_VARIABLE_HAS_NO_VALUE);
599 goto err;
600 }
601 BUF_MEM_grow(buf,(strlen(p)+len-(e-from)));
602 while (*p)
603 buf->data[to++]= *(p++);
604 from=e;
605 }
606 else
607 buf->data[to++]= *(from++);
608 }
609 buf->data[to]='\0';
610 if (*pto != NULL) Free(*pto);
611 *pto=buf->data;
612 Free(buf);
613 return(1);
614err:
615 if (buf != NULL) BUF_MEM_free(buf);
616 return(0);
617 }
618
619static char *eat_ws(p)
620char *p;
621 {
622 while (IS_WS(*p) && (!IS_EOF(*p)))
623 p++;
624 return(p);
625 }
626
627static char *eat_alpha_numeric(p)
628char *p;
629 {
630 for (;;)
631 {
632 if (IS_ESC(*p))
633 {
634 p=scan_esc(p);
635 continue;
636 }
637 if (!IS_ALPHA_NUMERIC_PUNCT(*p))
638 return(p);
639 p++;
640 }
641 }
642
643static unsigned long hash(v)
644CONF_VALUE *v;
645 {
646 return((lh_strhash(v->section)<<2)^lh_strhash(v->name));
647 }
648
649static int cmp(a,b)
650CONF_VALUE *a,*b;
651 {
652 int i;
653
654 if (a->section != b->section)
655 {
656 i=strcmp(a->section,b->section);
657 if (i) return(i);
658 }
659
660 if ((a->name != NULL) && (b->name != NULL))
661 {
662 i=strcmp(a->name,b->name);
663 return(i);
664 }
665 else if (a->name == b->name)
666 return(0);
667 else
668 return((a->name == NULL)?-1:1);
669 }
670
671static char *scan_quote(p)
672char *p;
673 {
674 int q= *p;
675
676 p++;
677 while (!(IS_EOF(*p)) && (*p != q))
678 {
679 if (IS_ESC(*p))
680 {
681 p++;
682 if (IS_EOF(*p)) return(p);
683 }
684 p++;
685 }
686 if (*p == q) p++;
687 return(p);
688 }
689
690static CONF_VALUE *new_section(conf,section)
691LHASH *conf;
692char *section;
693 {
694 STACK *sk=NULL;
695 int ok=0,i;
696 CONF_VALUE *v=NULL,*vv;
697
698 if ((sk=sk_new_null()) == NULL)
699 goto err;
700 if ((v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))) == NULL)
701 goto err;
702 i=strlen(section)+1;
703 if ((v->section=(char *)Malloc(i)) == NULL)
704 goto err;
705
706 memcpy(v->section,section,i);
707 v->name=NULL;
708 v->value=(char *)sk;
709
710 vv=(CONF_VALUE *)lh_insert(conf,(char *)v);
711 if (vv != NULL)
712 {
713#if !defined(NO_STDIO) && !defined(WIN16)
714 fprintf(stderr,"internal fault\n");
715#endif
716 abort();
717 }
718 ok=1;
719err:
720 if (!ok)
721 {
722 if (sk != NULL) sk_free(sk);
723 if (v != NULL) Free(v);
724 v=NULL;
725 }
726 return(v);
727 }
diff --git a/src/lib/libssl/src/crypto/conf/conf.err b/src/lib/libssl/src/crypto/conf/conf.err
new file mode 100644
index 0000000000..933d3d692a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/conf/conf.err
@@ -0,0 +1,12 @@
1/* Error codes for the CONF functions. */
2
3/* Function codes. */
4#define CONF_F_CONF_LOAD 100
5#define CONF_F_STR_COPY 101
6
7/* Reason codes. */
8#define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100
9#define CONF_R_MISSING_EQUAL_SIGN 101
10#define CONF_R_NO_CLOSE_BRACE 102
11#define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103
12#define CONF_R_VARIABLE_HAS_NO_VALUE 104
diff --git a/src/lib/libssl/src/crypto/conf/conf_lcl.h b/src/lib/libssl/src/crypto/conf/conf_lcl.h
new file mode 100644
index 0000000000..4e5644ed79
--- /dev/null
+++ b/src/lib/libssl/src/crypto/conf/conf_lcl.h
@@ -0,0 +1,102 @@
1/* crypto/conf/conf_lcl.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#define CONF_NUMBER 1
60#define CONF_UPPER 2
61#define CONF_LOWER 4
62#define CONF_UNDER 256
63#define CONF_PUNCTUATION 512
64#define CONF_WS 16
65#define CONF_ESC 32
66#define CONF_QUOTE 64
67#define CONF_COMMENT 128
68#define CONF_EOF 8
69#define CONF_ALPHA (CONF_UPPER|CONF_LOWER)
70#define CONF_ALPHA_NUMERIC (CONF_ALPHA|CONF_NUMBER|CONF_UNDER)
71#define CONF_ALPHA_NUMERIC_PUNCT (CONF_ALPHA|CONF_NUMBER|CONF_UNDER| \
72 CONF_PUNCTUATION)
73
74#define IS_COMMENT(a) (CONF_COMMENT&(CONF_type[(a)&0x7f]))
75#define IS_EOF(a) ((a) == '\0')
76#define IS_ESC(a) ((a) == '\\')
77#define IS_NUMER(a) (CONF_type[(a)&0x7f]&CONF_NUMBER)
78#define IS_WS(a) (CONF_type[(a)&0x7f]&CONF_WS)
79#define IS_ALPHA_NUMERIC(a) (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC)
80#define IS_ALPHA_NUMERIC_PUNCT(a) \
81 (CONF_type[(a)&0x7f]&CONF_ALPHA_NUMERIC_PUNCT)
82#define IS_QUOTE(a) (CONF_type[(a)&0x7f]&CONF_QUOTE)
83
84static unsigned short CONF_type[128]={
85 0x008,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
86 0x000,0x010,0x010,0x000,0x000,0x010,0x000,0x000,
87 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
88 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
89 0x010,0x200,0x040,0x080,0x000,0x200,0x200,0x040,
90 0x000,0x000,0x200,0x200,0x200,0x200,0x200,0x200,
91 0x001,0x001,0x001,0x001,0x001,0x001,0x001,0x001,
92 0x001,0x001,0x000,0x200,0x000,0x000,0x000,0x200,
93 0x200,0x002,0x002,0x002,0x002,0x002,0x002,0x002,
94 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002,
95 0x002,0x002,0x002,0x002,0x002,0x002,0x002,0x002,
96 0x002,0x002,0x002,0x000,0x020,0x000,0x200,0x100,
97 0x040,0x004,0x004,0x004,0x004,0x004,0x004,0x004,
98 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004,
99 0x004,0x004,0x004,0x004,0x004,0x004,0x004,0x004,
100 0x004,0x004,0x004,0x000,0x200,0x000,0x200,0x000,
101 };
102
diff --git a/src/lib/libssl/src/crypto/cryptall.h b/src/lib/libssl/src/crypto/cryptall.h
new file mode 100644
index 0000000000..65a46452a8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/cryptall.h
@@ -0,0 +1,110 @@
1/* crypto/cryptall.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef HEADER_CRYPTOALL_H
60#define HEADER_CRYPTOALL_H
61
62#include "buffer.h"
63#include "stack.h"
64#include "lhash.h"
65
66#include "err.h"
67
68#ifdef NO_MD2
69#include <md2.h>
70#else
71#include "md2.h"
72#endif
73#ifdef NO_MD5
74#include <md5.h>
75#else
76#include "md5.h"
77#endif
78#include "sha.h"
79
80#ifdef NO_DES
81#include <des.h>
82#else
83#include "des.h"
84#endif
85#include "rc2.h"
86#include "rc4.h"
87#include "idea.h"
88
89#include "bn.h"
90#include "dh.h"
91#include "rsa.h"
92#include "dsa.h"
93
94#include "rand.h"
95#include "conf.h"
96#include "txt_db.h"
97
98#include "err.h"
99#include "evp.h"
100
101#include "meth.h"
102#include "x509.h"
103#include "pkcs7.h"
104#include "pem.h"
105#include "asn1.h"
106#include "objects.h"
107
108#include "crypto.h"
109
110#endif
diff --git a/src/lib/libssl/src/crypto/crypto.c b/src/lib/libssl/src/crypto/crypto.c
new file mode 100644
index 0000000000..366e25c939
--- /dev/null
+++ b/src/lib/libssl/src/crypto/crypto.c
@@ -0,0 +1,575 @@
1/* crypto/crypto.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* If you are happy to use the assmbler version of bn/bn_mulw.c, define
60 * BN_ASM */
61#ifndef BN_ASM
62#undef BN_ASM
63#define X86_ASM
64#endif
65
66#ifndef DES_ASM
67#undef DES_ASM
68#endif
69
70#ifndef BF_ASM
71#undef BF_ASM
72#endif
73
74/* The following defines are only to break the compiles into chunks.
75 * If you wish to not compile some sections, use the 'NO_XXX' macros
76 */
77#ifndef CRYPTO_SUBSET
78/* Define all subset symbols. */
79#define CRYPTO_LIB_SUBSET
80#define CRYPTO_ASN1_SUBSET
81#define CRYPTO_BN_SUBSET
82#define CRYPTO_BUFFER_SUBSET
83#define CRYPTO_BIO_SUBSET
84#define CRYPTO_CONF_SUBSET
85#define CRYPTO_DES_SUBSET
86#define CRYPTO_DH_SUBSET
87#define CRYPTO_DSA_SUBSET
88#define CRYPTO_ERROR_SUBSET
89#define CRYPTO_EVP_SUBSET
90#define CRYPTO_IDEA_SUBSET
91#define CRYPTO_LHASH_SUBSET
92#define CRYPTO_MD_SUBSET
93#define CRYPTO_MDC2_SUBSET
94#define CRYPTO_METH_SUBSET
95#define CRYPTO_OBJECTS_SUBSET
96#define CRYPTO_PEM_SUBSET
97#define CRYPTO_RAND_SUBSET
98#define CRYPTO_RC_SUBSET
99#define CRYPTO_BLOWFISH_SUBSET
100#define CRYPTO_CAST_SUBSET
101#define CRYPTO_RSA_SUBSET
102#define CRYPTO_SHA_SUBSET
103#define CRYPTO_HMAC_SUBSET
104#define CRYPTO_SHA1_SUBSET
105#define CRYPTO_STACK_SUBSET
106#define CRYPTO_TXT_DB_SUBSET
107#define CRYPTO_X509_SUBSET
108#define CRYPTO_PKCS7_SUBSET
109#endif
110
111#include <stdio.h>
112#include <stdlib.h>
113#include <string.h>
114
115#define USE_SOCKETS
116#include "../e_os.h"
117
118#include "buffer.h"
119#include "bio.h"
120#include "stack.h"
121#include "lhash.h"
122
123#include "err.h"
124
125#include "bn.h"
126#include "evp.h"
127
128#include "rand.h"
129#include "conf.h"
130#include "txt_db.h"
131
132#include "x509.h"
133#include "pkcs7.h"
134#include "pem.h"
135#include "asn1.h"
136#include "objects.h"
137
138#ifdef CRYPTO_LIB_SUBSET
139#include "cryptlib.c"
140#include "mem.c"
141#include "cversion.c"
142#endif
143
144#ifdef CRYPTO_ASN1_SUBSET
145#include "asn1/a_meth.c"
146#include "asn1/a_bitstr.c"
147#include "asn1/a_d2i_fp.c"
148#include "asn1/a_dup.c"
149#include "asn1/a_hdr.c"
150#include "asn1/a_i2d_fp.c"
151#include "asn1/a_int.c"
152#include "asn1/a_bool.c"
153#include "asn1/a_bytes.c"
154#include "asn1/a_object.c"
155#include "asn1/a_octet.c"
156#include "asn1/a_print.c"
157#include "asn1/a_set.c"
158#include "asn1/a_sign.c"
159#include "asn1/a_type.c"
160#include "asn1/a_utctm.c"
161#include "asn1/a_verify.c"
162#include "asn1/a_digest.c"
163#include "asn1/asn1_err.c"
164#include "asn1/asn1_lib.c"
165#include "asn1/asn1_par.c"
166#ifndef NO_DH
167#include "asn1/d2i_dhp.c"
168#include "asn1/i2d_dhp.c"
169#endif
170#ifndef NO_DSA
171#include "asn1/d2i_dsap.c"
172#include "asn1/i2d_dsap.c"
173#include "asn1/d2i_s_pr.c"
174#include "asn1/i2d_s_pr.c"
175#include "asn1/d2i_s_pu.c"
176#include "asn1/i2d_s_pu.c"
177#endif
178#ifndef NO_RSA
179#include "asn1/d2i_r_pr.c"
180#include "asn1/i2d_r_pr.c"
181#include "asn1/d2i_r_pu.c"
182#include "asn1/i2d_r_pu.c"
183#include "asn1/n_pkey.c"
184#endif
185#include "asn1/d2i_pr.c"
186#include "asn1/d2i_pu.c"
187#include "asn1/i2d_pr.c"
188#include "asn1/i2d_pu.c"
189#include "asn1/f_int.c"
190#include "asn1/f_string.c"
191#include "asn1/p7_dgst.c"
192#include "asn1/p7_enc.c"
193#include "asn1/p7_enc_c.c"
194#include "asn1/p7_evp.c"
195#include "asn1/p7_i_s.c"
196#include "asn1/p7_lib.c"
197#include "asn1/p7_recip.c"
198#include "asn1/p7_s_e.c"
199#include "asn1/p7_signd.c"
200#include "asn1/p7_signi.c"
201#include "asn1/t_pkey.c"
202#include "asn1/t_req.c"
203#include "asn1/t_x509.c"
204#include "asn1/x_algor.c"
205#include "asn1/x_attrib.c"
206#include "asn1/x_exten.c"
207#include "asn1/x_cinf.c"
208#include "asn1/x_crl.c"
209#include "asn1/x_info.c"
210#include "asn1/x_name.c"
211#include "asn1/x_pkey.c"
212#include "asn1/x_pubkey.c"
213#include "asn1/x_req.c"
214#include "asn1/x_sig.c"
215#include "asn1/x_spki.c"
216#include "asn1/x_val.c"
217#include "asn1/x_x509.c"
218#endif
219
220#ifdef CRYPTO_BN_SUBSET
221#include "bn/bn_add.c"
222#include "bn/bn_div.c"
223#include "bn/bn_exp.c"
224#include "bn/bn_mont.c"
225#include "bn/bn_recp.c"
226#include "bn/bn_gcd.c"
227#include "bn/bn_lib.c"
228#include "bn/bn_mod.c"
229#include "bn/bn_mul.c"
230#ifndef BN_ASM
231#include "bn/bn_mulw.c"
232#endif
233#include "bn/bn_prime.c"
234#include "bn/bn_rand.c"
235#include "bn/bn_shift.c"
236#include "bn/bn_sqr.c"
237#include "bn/bn_sub.c"
238#include "bn/bn_word.c"
239#include "bn/bn_print.c"
240#include "bn/bn_err.c"
241#include "bn/bn_blind.c"
242#endif
243
244#ifdef CRYPTO_BIO_SUBSET
245#include "bio/bf_buff.c"
246#include "bio/bf_null.c"
247#include "bio/bf_nbio.c"
248#include "bio/bio_cb.c"
249#include "bio/bio_lib.c"
250#include "bio/bss_fd.c"
251#include "bio/bss_file.c"
252#include "bio/bss_mem.c"
253#include "bio/bss_null.c"
254#ifdef VMS
255#include "bio/bss_rtcp.c"
256#endif
257#include "bio/bss_sock.c"
258#include "bio/bss_conn.c"
259#include "bio/bss_acpt.c"
260#include "bio/b_sock.c"
261#include "bio/b_print.c"
262#include "bio/b_dump.c"
263#include "bio/bio_err.c"
264#endif
265
266#ifdef CRYPTO_BUFFER_SUBSET
267#include "buffer/buf_err.c"
268#include "buffer/buffer.c"
269#endif
270
271#ifdef CRYPTO_CONF_SUBSET
272#include "conf/conf.c"
273#include "conf/conf_err.c"
274#endif
275
276#ifdef CRYPTO_DES_SUBSET
277#include "des/read_pwd.c"
278#ifndef NO_DES
279#ifndef DES_ASM
280#include "des/fcrypt_b.c"
281#include "des/des_enc.c"
282#endif
283#include "des/cbc_cksm.c"
284#include "des/xcbc_enc.c"
285#include "des/cbc_enc.c"
286#include "des/cfb64ede.c"
287#include "des/cfb64enc.c"
288#include "des/cfb_enc.c"
289#include "des/ecb3_enc.c"
290#include "des/ecb_enc.c"
291#include "des/enc_read.c"
292#include "des/enc_writ.c"
293#include "des/fcrypt.c"
294#include "des/ofb64ede.c"
295#include "des/ofb64enc.c"
296#include "des/ofb_enc.c"
297#include "des/pcbc_enc.c"
298#include "des/qud_cksm.c"
299#include "des/rand_key.c"
300#include "des/read2pwd.c"
301#include "des/rpc_enc.c"
302#include "des/set_key.c"
303#include "des/str2key.c"
304#include "des/supp.c"
305#endif
306#endif
307
308#ifdef CRYPTO_DH_SUBSET
309#ifndef NO_DH
310#include "dh/dh_check.c"
311#include "dh/dh_err.c"
312#include "dh/dh_gen.c"
313#include "dh/dh_key.c"
314#include "dh/dh_lib.c"
315#endif
316#endif
317
318#ifdef CRYPTO_DSA_SUBSET
319#ifndef NO_DSA
320#include "dsa/dsa_gen.c"
321#include "dsa/dsa_key.c"
322#include "dsa/dsa_lib.c"
323#include "dsa/dsa_sign.c"
324#include "dsa/dsa_vrf.c"
325#include "dsa/dsa_err.c"
326#endif
327#endif
328
329#ifdef CRYPTO_ERROR_SUBSET
330#include "err/err.c"
331#include "err/err_all.c"
332#include "err/err_prn.c"
333#endif
334
335#ifdef CRYPTO_EVP_SUBSET
336#include "evp/bio_md.c"
337#include "evp/bio_b64.c"
338#include "evp/bio_enc.c"
339#include "evp/c_all.c"
340#include "evp/digest.c"
341#ifndef NO_DES
342#include "evp/e_cbc_3d.c"
343#include "evp/e_cfb_3d.c"
344#include "evp/e_ecb_3d.c"
345#include "evp/e_ofb_3d.c"
346#include "evp/e_cbc_d.c"
347#include "evp/e_cfb_d.c"
348#include "evp/e_xcbc_d.c"
349#include "evp/e_ecb_d.c"
350#include "evp/e_ofb_d.c"
351#endif
352#ifndef NO_IDEA
353#include "evp/e_cbc_i.c"
354#include "evp/e_cfb_i.c"
355#include "evp/e_ecb_i.c"
356#include "evp/e_ofb_i.c"
357#endif
358#ifndef NO_RC2
359#include "evp/e_cbc_r2.c"
360#include "evp/e_cfb_r2.c"
361#include "evp/e_ecb_r2.c"
362#include "evp/e_ofb_r2.c"
363#endif
364#ifndef NO_BLOWFISH
365#include "evp/e_cbc_bf.c"
366#include "evp/e_cfb_bf.c"
367#include "evp/e_ecb_bf.c"
368#include "evp/e_ofb_bf.c"
369#endif
370#ifndef NO_CAST
371#include "evp/e_cbc_c.c"
372#include "evp/e_cfb_c.c"
373#include "evp/e_ecb_c.c"
374#include "evp/e_ofb_c.c"
375#endif
376#ifndef NO_RC4
377#include "evp/e_rc4.c"
378#endif
379#include "rc5/rc5_enc.c"
380#include "rc5/rc5cfb64.c"
381#include "rc5/rc5_ecb.c"
382#include "rc5/rc5_skey.c"
383#include "rc5/rc5ofb64.c"
384#include "ripemd/rmd160.c"
385#include "ripemd/rmd_dgst.c"
386#include "ripemd/rmd_one.c"
387#include "evp/evp_lib.c"
388
389#include "evp/names.c"
390#include "evp/e_null.c"
391#include "evp/encode.c"
392#include "evp/evp_enc.c"
393#include "evp/evp_err.c"
394#include "evp/evp_key.c"
395#include "evp/m_null.c"
396#include "evp/p_lib.c"
397#ifndef NO_RSA
398#include "evp/p_open.c"
399#include "evp/p_seal.c"
400#endif
401#include "evp/p_sign.c"
402#include "evp/p_verify.c"
403#endif
404
405#ifdef CRYPTO_IDEA_SUBSET
406#ifndef NO_IDEA
407#include "idea/i_cbc.c"
408#include "idea/i_cfb64.c"
409#include "idea/i_ecb.c"
410#include "idea/i_ofb64.c"
411#include "idea/i_skey.c"
412#endif
413#endif
414
415#ifdef CRYPTO_BLOWFISH_SUBSET
416#ifndef NO_BLOWFISH
417#include "bf/bf_cfb64.c"
418#include "bf/bf_ecb.c"
419#ifndef BF_ASM
420#include "bf/bf_enc.c"
421#endif
422#include "bf/bf_ofb64.c"
423#include "bf/bf_skey.c"
424#endif
425#endif
426
427#ifdef CRYPTO_CAST_SUBSET
428#ifndef NO_CAST
429#include "cast/c_cfb64.c"
430#include "cast/c_ecb.c"
431#ifndef CAST_ASM
432#include "cast/c_enc.c"
433#endif
434#include "cast/c_ofb64.c"
435#include "cast/c_skey.c"
436#endif
437#endif
438
439#ifdef CRYPTO_LHASH_SUBSET
440#include "lhash/lh_stats.c"
441#include "lhash/lhash.c"
442#endif
443
444#ifdef CRYPTO_MD_SUBSET
445#ifndef NO_MD2
446#include "md2/md2_dgst.c"
447#include "md2/md2_one.c"
448#include "evp/m_md2.c"
449#endif
450#ifndef NO_MD5
451#include "md5/md5_dgst.c"
452#include "md5/md5_one.c"
453#include "evp/m_md5.c"
454#endif
455#endif
456
457#ifdef CRYPTO_MDC2_SUBSET
458#ifndef NO_MDC2
459#include "mdc2/mdc2dgst.c"
460#include "mdc2/mdc2_one.c"
461#include "evp/m_mdc2.c"
462#endif
463#endif
464
465#ifdef CRYPTO_OBJECTS_SUBSET
466#include "objects/obj_dat.c"
467#include "objects/obj_err.c"
468#include "objects/obj_lib.c"
469#endif
470
471#ifdef CRYPTO_PEM_SUBSET
472#include "pem/pem_err.c"
473#include "pem/pem_info.c"
474#include "pem/pem_lib.c"
475#include "pem/pem_all.c"
476#ifndef NO_RSA
477#include "pem/pem_seal.c"
478#include "pem/pem_sign.c"
479#endif
480#endif
481
482#ifdef CRYPTO_RAND_SUBSET
483#include "rand/md_rand.c"
484#include "rand/randfile.c"
485#endif
486
487#ifdef CRYPTO_RC_SUBSET
488#ifndef NO_RC2
489#include "rc2/rc2_cbc.c"
490#include "rc2/rc2_ecb.c"
491#include "rc2/rc2_skey.c"
492#include "rc2/rc2cfb64.c"
493#include "rc2/rc2ofb64.c"
494#endif
495#ifndef NO_RC4
496#include "rc4/rc4_skey.c"
497#ifndef RC4_ASM
498#include "rc4/rc4_enc.c"
499#endif
500#endif
501#endif
502
503#ifdef CRYPTO_HMAC_SUBSET
504#include "hmac/hmac.c"
505#endif
506
507#ifdef CRYPTO_RSA_SUBSET
508#ifndef NO_RSA
509#include "rsa/rsa_eay.c"
510#include "rsa/rsa_err.c"
511#include "rsa/rsa_gen.c"
512#include "rsa/rsa_lib.c"
513#include "rsa/rsa_sign.c"
514#include "rsa/rsa_saos.c"
515#endif
516#endif
517
518#ifdef CRYPTO_SHA1_SUBSET
519#ifndef NO_SHA1
520#include "sha/sha1_one.c"
521#include "sha/sha1dgst.c"
522#include "evp/m_dss1.c"
523#include "evp/m_sha1.c"
524#endif
525#endif
526
527#ifdef CRYPTO_SHA_SUBSET
528#ifndef NO_SHA
529#include "evp/m_dss.c"
530#include "sha/sha_dgst.c"
531#include "sha/sha_one.c"
532#include "evp/m_sha.c"
533#endif
534#endif
535
536#ifdef CRYPTO_STACK_SUBSET
537#include "stack/stack.c"
538#endif
539
540#ifdef CRYPTO_TXT_DB_SUBSET
541#include "txt_db/txt_db.c"
542#endif
543
544#ifdef CRYPTO_X509_SUBSET
545#include "x509/x509_cmp.c"
546#include "x509/x509_d2.c"
547#include "x509/x509_def.c"
548#include "x509/x509_err.c"
549#include "x509/x509_ext.c"
550#include "x509/x509_lu.c"
551#include "x509/x509_obj.c"
552#include "x509/x509_r2x.c"
553#include "x509/x509_req.c"
554#include "x509/x509_set.c"
555#include "x509/x509_v3.c"
556#include "x509/x509_vfy.c"
557#include "x509/x509name.c"
558#include "x509/x509pack.c"
559#include "x509/x509rset.c"
560#include "x509/x509type.c"
561#include "x509/x_all.c"
562#include "x509/x509_txt.c"
563#include "x509/by_dir.c"
564#include "x509/by_file.c"
565#include "x509/v3_net.c"
566#include "x509/v3_x509.c"
567#endif
568
569
570#ifdef CRYPTO_PKCS7_SUBSET /* I have an explicit removal of 7 lines */
571#include "pkcs7/pk7_lib.c"
572#include "pkcs7/pkcs7err.c"
573#include "pkcs7/pk7_doit.c"
574#endif /* CRYPTO_PKCS7_SUBSET */
575
diff --git a/src/lib/libssl/src/crypto/crypto.err b/src/lib/libssl/src/crypto/crypto.err
new file mode 100644
index 0000000000..4ea3385e73
--- /dev/null
+++ b/src/lib/libssl/src/crypto/crypto.err
@@ -0,0 +1,8 @@
1/* Error codes for the CRYPTO functions. */
2
3/* Function codes. */
4#define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
5#define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101
6#define CRYPTO_F_CRYPTO_SET_EX_DATA 102
7
8/* Reason codes. */
diff --git a/src/lib/libssl/src/crypto/date.h b/src/lib/libssl/src/crypto/date.h
new file mode 100644
index 0000000000..dbb71bd1b7
--- /dev/null
+++ b/src/lib/libssl/src/crypto/date.h
@@ -0,0 +1 @@
#define DATE "Sun Jul 12 21:04:32 MDT 1998"
diff --git a/src/lib/libssl/src/crypto/des/DES.pod b/src/lib/libssl/src/crypto/des/DES.pod
new file mode 100644
index 0000000000..8a739e7ca0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/DES.pod
@@ -0,0 +1,16 @@
1crypt <= crypt(buf,salt)
2key <= set_odd_parity(key)
3int <= is_weak_key(key)
4keysched<= set_key(key)
5key <= ecb_encrypt(string8,ks,enc)
6key <= ecb3_encrypt(input,ks1,ks2,enc)
7string <= cbc_encrypt(input,ks,ivec,enc) => ivec
8string <= cbc3_encrypt(input,ks1,ks2,ivec1,ivec2,enc) => ivec1&ivec2
9ck1,ck2 <= cbc_cksum(input,ks,ivec) => ivec
10string <= pcbc_encrypt(input,ks,ivec,enc) => ivec
11string <= ofb_encrypt(input,numbits,ks,ivec) => ivec
12string <= cfb_encrypt(input,numbits,ks,ivec,enc) => ivec
13key <= random_key()
14key <= string_to_key(string)
15key1,key2<= string_to_2keys(string)
16
diff --git a/src/lib/libssl/src/crypto/des/FILES b/src/lib/libssl/src/crypto/des/FILES
new file mode 100644
index 0000000000..4c7ea2de7a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/FILES
@@ -0,0 +1,96 @@
1/* General stuff */
2COPYRIGHT - Copyright info.
3MODES.DES - A description of the features of the different modes of DES.
4FILES - This file.
5INSTALL - How to make things compile.
6Imakefile - For use with kerberos.
7README - What this package is.
8VERSION - Which version this is and what was changed.
9KERBEROS - Kerberos version 4 notes.
10Makefile.PL - An old makefile to build with perl5, not current.
11Makefile.ssl - The SSLeay makefile
12Makefile.uni - The normal unix makefile.
13GNUmakefile - The makefile for use with glibc.
14makefile.bc - A Borland C makefile
15times - Some outputs from 'speed' on some machines.
16vms.com - For use when compiling under VMS
17
18/* My SunOS des(1) replacement */
19des.c - des(1) source code.
20des.man - des(1) manual.
21
22/* Testing and timing programs. */
23destest.c - Source for libdes.a test program.
24speed.c - Source for libdes.a timing program.
25rpw.c - Source for libdes.a testing password reading routines.
26
27/* libdes.a source code */
28des_crypt.man - libdes.a manual page.
29des.h - Public libdes.a header file.
30ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code.
31ecb3_enc.c - des_ecb3_encrypt() source.
32cbc_ckm.c - des_cbc_cksum() source.
33cbc_enc.c - des_cbc_encrypt() source.
34ncbc_enc.c - des_cbc_encrypt() that is 'normal' in that it copies
35 the new iv values back in the passed iv vector.
36ede_enc.c - des_ede3_cbc_encrypt() cbc mode des using triple DES.
37cbc3_enc.c - des_3cbc_encrypt() source, don't use this function.
38cfb_enc.c - des_cfb_encrypt() source.
39cfb64enc.c - des_cfb64_encrypt() cfb in 64 bit mode but setup to be
40 used as a stream cipher.
41cfb64ede.c - des_ede3_cfb64_encrypt() cfb in 64 bit mode but setup to be
42 used as a stream cipher and using triple DES.
43ofb_enc.c - des_cfb_encrypt() source.
44ofb64_enc.c - des_ofb_encrypt() ofb in 64 bit mode but setup to be
45 used as a stream cipher.
46ofb64ede.c - des_ede3_ofb64_encrypt() ofb in 64 bit mode but setup to be
47 used as a stream cipher and using triple DES.
48enc_read.c - des_enc_read() source.
49enc_writ.c - des_enc_write() source.
50pcbc_enc.c - des_pcbc_encrypt() source.
51qud_cksm.c - quad_cksum() source.
52rand_key.c - des_random_key() source.
53read_pwd.c - Source for des_read_password() plus related functions.
54set_key.c - Source for des_set_key().
55str2key.c - Covert a string of any length into a key.
56fcrypt.c - A small, fast version of crypt(3).
57des_locl.h - Internal libdes.a header file.
58podd.h - Odd parity tables - used in des_set_key().
59sk.h - Lookup tables used in des_set_key().
60spr.h - What is left of the S tables - used in ecb_encrypt().
61des_ver.h - header file for the external definition of the
62 version string.
63des.doc - SSLeay documentation for the library.
64
65/* The perl scripts - you can ignore these files they are only
66 * included for the curious */
67des.pl - des in perl anyone? des_set_key and des_ecb_encrypt
68 both done in a perl library.
69testdes.pl - Testing program for des.pl
70doIP - Perl script used to develop IP xor/shift code.
71doPC1 - Perl script used to develop PC1 xor/shift code.
72doPC2 - Generates sk.h.
73PC1 - Output of doPC1 should be the same as output from PC1.
74PC2 - used in development of doPC2.
75shifts.pl - Perl library used by my perl scripts.
76
77/* I started making a perl5 dynamic library for libdes
78 * but did not fully finish, these files are part of that effort. */
79DES.pm
80DES.pod
81DES.xs
82t
83typemap
84
85/* The following are for use with sun RPC implementaions. */
86rpc_des.h
87rpc_enc.c
88
89/* The following are contibuted by Mark Murray <mark@grondar.za>. They
90 * are not normally built into libdes due to machine specific routines
91 * contained in them. They are for use in the most recent incarnation of
92 * export kerberos v 4 (eBones). */
93supp.c
94new_rkey.c
95
96
diff --git a/src/lib/libssl/src/crypto/des/MODES.DES b/src/lib/libssl/src/crypto/des/MODES.DES
new file mode 100644
index 0000000000..0cbc44f51d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/MODES.DES
@@ -0,0 +1,84 @@
1Modes of DES
2Quite a bit of the following information has been taken from
3 AS 2805.5.2
4 Australian Standard
5 Electronic funds transfer - Requirements for interfaces,
6 Part 5.2: Modes of operation for an n-bit block cipher algorithm
7 Appendix A
8
9There are several different modes in which DES can be used, they are
10as follows.
11
12Electronic Codebook Mode (ECB) (des_ecb_encrypt())
13- 64 bits are enciphered at a time.
14- The order of the blocks can be rearranged without detection.
15- The same plaintext block always produces the same ciphertext block
16 (for the same key) making it vulnerable to a 'dictionary attack'.
17- An error will only affect one ciphertext block.
18
19Cipher Block Chaining Mode (CBC) (des_cbc_encrypt())
20- a multiple of 64 bits are enciphered at a time.
21- The CBC mode produces the same ciphertext whenever the same
22 plaintext is encrypted using the same key and starting variable.
23- The chaining operation makes the ciphertext blocks dependent on the
24 current and all preceding plaintext blocks and therefore blocks can not
25 be rearranged.
26- The use of different starting variables prevents the same plaintext
27 enciphering to the same ciphertext.
28- An error will affect the current and the following ciphertext blocks.
29
30Cipher Feedback Mode (CFB) (des_cfb_encrypt())
31- a number of bits (j) <= 64 are enciphered at a time.
32- The CFB mode produces the same ciphertext whenever the same
33 plaintext is encrypted using the same key and starting variable.
34- The chaining operation makes the ciphertext variables dependent on the
35 current and all preceding variables and therefore j-bit variables are
36 chained together and con not be rearranged.
37- The use of different starting variables prevents the same plaintext
38 enciphering to the same ciphertext.
39- The strength of the CFB mode depends on the size of k (maximal if
40 j == k). In my implementation this is always the case.
41- Selection of a small value for j will require more cycles through
42 the encipherment algorithm per unit of plaintext and thus cause
43 greater processing overheads.
44- Only multiples of j bits can be enciphered.
45- An error will affect the current and the following ciphertext variables.
46
47Output Feedback Mode (OFB) (des_ofb_encrypt())
48- a number of bits (j) <= 64 are enciphered at a time.
49- The OFB mode produces the same ciphertext whenever the same
50 plaintext enciphered using the same key and starting variable. More
51 over, in the OFB mode the same key stream is produced when the same
52 key and start variable are used. Consequently, for security reasons
53 a specific start variable should be used only once for a given key.
54- The absence of chaining makes the OFB more vulnerable to specific attacks.
55- The use of different start variables values prevents the same
56 plaintext enciphering to the same ciphertext, by producing different
57 key streams.
58- Selection of a small value for j will require more cycles through
59 the encipherment algorithm per unit of plaintext and thus cause
60 greater processing overheads.
61- Only multiples of j bits can be enciphered.
62- OFB mode of operation does not extend ciphertext errors in the
63 resultant plaintext output. Every bit error in the ciphertext causes
64 only one bit to be in error in the deciphered plaintext.
65- OFB mode is not self-synchronising. If the two operation of
66 encipherment and decipherment get out of synchronism, the system needs
67 to be re-initialised.
68- Each re-initialisation should use a value of the start variable
69different from the start variable values used before with the same
70key. The reason for this is that an identical bit stream would be
71produced each time from the same parameters. This would be
72susceptible to a 'known plaintext' attack.
73
74Triple ECB Mode (des_ecb3_encrypt())
75- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
76- As for ECB encryption but increases the effective key length to 112 bits.
77- If both keys are the same it is equivalent to encrypting once with
78 just one key.
79
80Triple CBC Mode (des_3cbc_encrypt())
81- Encrypt with key1, decrypt with key2 and encrypt with key1 again.
82- As for CBC encryption but increases the effective key length to 112 bits.
83- If both keys are the same it is equivalent to encrypting once with
84 just one key.
diff --git a/src/lib/libssl/src/crypto/des/Makefile.PL b/src/lib/libssl/src/crypto/des/Makefile.PL
new file mode 100644
index 0000000000..b54a24387c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/Makefile.PL
@@ -0,0 +1,14 @@
1use ExtUtils::MakeMaker;
2# See lib/ExtUtils/MakeMaker.pm for details of how to influence
3# the contents of the Makefile being created.
4&writeMakefile(
5 'potential_libs' => '', # e.g., '-lm'
6 'INC' => '', # e.g., '-I/usr/include/other'
7 'DISTNAME' => 'DES',
8 'VERSION' => '0.1',
9 'DEFINE' => '-DPERL5',
10 'OBJECT' => 'DES.o cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \
11 rand_key.o set_key.o str2key.o \
12 enc_read.o enc_writ.o fcrypt.o cfb_enc.o \
13 ecb3_enc.o ofb_enc.o cbc3_enc.o des_enc.o',
14 );
diff --git a/src/lib/libssl/src/crypto/des/Makefile.lit b/src/lib/libssl/src/crypto/des/Makefile.lit
new file mode 100644
index 0000000000..c09f6969da
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/Makefile.lit
@@ -0,0 +1,250 @@
1# You must select the correct terminal control system to be used to
2# turn character echo off when reading passwords. There a 5 systems
3# SGTTY - the old BSD system
4# TERMIO - most system V boxes
5# TERMIOS - SGI (ala IRIX).
6# VMS - the DEC operating system
7# MSDOS - we all know what it is :-)
8# read_pwd.c makes a reasonable guess at what is correct.
9
10# Targets
11# make - twidle the options yourself :-)
12# make cc - standard cc options
13# make gcc - standard gcc options
14# make x86-elf - linux-elf etc
15# make x86-out - linux-a.out, FreeBSD etc
16# make x86-solaris
17# make x86-bdsi
18
19# If you are on a DEC Alpha, edit des.h and change the DES_LONG
20# define to 'unsigned int'. I have seen this give a %20 speedup.
21
22OPTS0= -DLIBDES_LIT -DRAND -DTERMIO #-DNOCONST
23
24# Version 1.94 has changed the strings_to_key function so that it is
25# now compatible with MITs when the string is longer than 8 characters.
26# If you wish to keep the old version, uncomment the following line.
27# This will affect the -E/-D options on des(1).
28#OPTS1= -DOLD_STR_TO_KEY
29
30# There are 4 possible performance options
31# -DDES_PTR
32# -DDES_RISC1
33# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2)
34# -DDES_UNROLL
35# after the initial build, run 'des_opts' to see which options are best
36# for your platform. There are some listed in options.txt
37#OPTS2= -DDES_PTR
38#OPTS3= -DDES_RISC1 # or DES_RISC2
39#OPTS4= -DDES_UNROLL
40
41OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4)
42
43MAKE=make -f Makefile
44#CC=cc
45#CFLAG= -O
46
47CC=gcc
48#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
49CFLAG= -O3 -fomit-frame-pointer
50
51CFLAGS=$(OPTS) $(CFLAG)
52CPP=$(CC) -E
53AS=as
54
55# Assember version of des_encrypt*().
56DES_ENC=des_enc.o fcrypt_b.o # normal C version
57#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86
58#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86
59#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86
60#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86
61
62LIBDIR=/usr/local/lib
63BINDIR=/usr/local/bin
64INCDIR=/usr/local/include
65MANDIR=/usr/local/man
66MAN1=1
67MAN3=3
68SHELL=/bin/sh
69OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o
70OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \
71 xcbc_enc.o qud_cksm.o \
72 cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \
73 enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \
74 rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o
75
76GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \
77 des.doc options.txt asm
78GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \
79 des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \
80 Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \
81 des.org des_locl.org
82TESTING_LIT= destest speed des_opts
83TESTING_FULL= rpw $(TESTING_LIT)
84TESTING_SRC_LIT=destest.c speed.c des_opts.c
85TESTING_SRC_FULL=rpw.c $(TESTING_SRC_LIT)
86HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h
87HEADERS_FULL= $(HEADERS_LIT) rpc_des.h
88LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c
89LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c \
90 cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \
91 enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \
92 rand_key.c rpc_enc.c str2key.c supp.c \
93 xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c
94
95PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
96
97OBJ= $(OBJ_LIT)
98GENERAL=$(GENERAL_LIT)
99TESTING=$(TESTING_LIT)
100TESTING_SRC=$(TESTING_SRC_LIT)
101HEADERS=$(HEADERS_LIT)
102LIBDES= $(LIBDES_LIT)
103
104ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS)
105
106DLIB= libdes.a
107
108all: $(DLIB) $(TESTING)
109
110cc:
111 $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
112
113gcc:
114 $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
115
116x86-elf:
117 $(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
118
119x86-out:
120 $(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
121
122x86-solaris:
123 $(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
124
125x86-bsdi:
126 $(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
127
128# elf
129asm/dx86-elf.o: asm/dx86unix.cpp
130 $(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o
131
132asm/yx86-elf.o: asm/yx86unix.cpp
133 $(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o
134
135# solaris
136asm/dx86-sol.o: asm/dx86unix.cpp
137 $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
138 as -o asm/dx86-sol.o asm/dx86-sol.s
139 rm -f asm/dx86-sol.s
140
141asm/yx86-sol.o: asm/yx86unix.cpp
142 $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
143 as -o asm/yx86-sol.o asm/yx86-sol.s
144 rm -f asm/yx86-sol.s
145
146# a.out
147asm/dx86-out.o: asm/dx86unix.cpp
148 $(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o
149
150asm/yx86-out.o: asm/yx86unix.cpp
151 $(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o
152
153# bsdi
154asm/dx86bsdi.o: asm/dx86unix.cpp
155 $(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o
156
157asm/yx86bsdi.o: asm/yx86unix.cpp
158 $(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o
159
160asm/dx86unix.cpp:
161 (cd asm; perl des-586.pl cpp >dx86unix.cpp)
162
163asm/yx86unix.cpp:
164 (cd asm; perl crypt586.pl cpp >yx86unix.cpp)
165
166test: all
167 ./destest
168
169$(DLIB): $(OBJ)
170 /bin/rm -f $(DLIB)
171 ar cr $(DLIB) $(OBJ)
172 -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \
173 else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \
174 else exit 0; fi; fi
175
176des_opts: des_opts.o $(DLIB)
177 $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB)
178
179destest: destest.o $(DLIB)
180 $(CC) $(CFLAGS) -o destest destest.o $(DLIB)
181
182rpw: rpw.o $(DLIB)
183 $(CC) $(CFLAGS) -o rpw rpw.o $(DLIB)
184
185speed: speed.o $(DLIB)
186 $(CC) $(CFLAGS) -o speed speed.o $(DLIB)
187
188des: des.o $(DLIB)
189 $(CC) $(CFLAGS) -o des des.o $(DLIB)
190
191tags:
192 ctags $(TESTING_SRC) $(LIBDES)
193
194tar_lit:
195 /bin/mv Makefile Makefile.tmp
196 /bin/cp Makefile.lit Makefile
197 tar chf libdes-l.tar $(LIBDES_LIT) $(HEADERS_LIT) \
198 $(GENERAL_LIT) $(TESTING_SRC_LIT)
199 /bin/rm -f Makefile
200 /bin/mv Makefile.tmp Makefile
201
202tar:
203 tar chf libdes.tar $(ALL)
204
205shar:
206 shar $(ALL) >libdes.shar
207
208depend:
209 makedepend $(LIBDES) $(TESTING_SRC)
210
211clean:
212 /bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o
213
214dclean:
215 sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
216 mv -f Makefile.new Makefile
217
218# Eric is probably going to choke when he next looks at this --tjh
219install:
220 if test $(INSTALLTOP); then \
221 echo SSL style install; \
222 cp $(DLIB) $(INSTALLTOP)/lib; \
223 if test -s /bin/ranlib; then \
224 /bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
225 else \
226 if test -s /usr/bin/ranlib; then \
227 /usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
228 fi; fi; \
229 chmod 644 $(INSTALLTOP)/lib/$(DLIB); \
230 cp des.h $(INSTALLTOP)/include; \
231 chmod 644 $(INSTALLTOP)/include/des.h; \
232 else \
233 echo Standalone install; \
234 cp $(DLIB) $(LIBDIR)/$(DLIB); \
235 if test -s /bin/ranlib; then \
236 /bin/ranlib $(LIBDIR)/$(DLIB); \
237 else \
238 if test -s /usr/bin/ranlib; then \
239 /usr/bin/ranlib $(LIBDIR)/$(DLIB); \
240 fi; \
241 fi; \
242 chmod 644 $(LIBDIR)/$(DLIB); \
243 cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
244 chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
245 cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \
246 chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \
247 cp des.h $(INCDIR)/des.h; \
248 chmod 644 $(INCDIR)/des.h; \
249 fi
250# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/des/Makefile.ssl b/src/lib/libssl/src/crypto/des/Makefile.ssl
new file mode 100644
index 0000000000..78b5189ee3
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/Makefile.ssl
@@ -0,0 +1,140 @@
1#
2# SSLeay/crypto/des/Makefile
3#
4
5DIR= des
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16DES_ENC= des_enc.o fcrypt_b.o
17# or use
18#DES_ENC= dx86-elf.o yx86-elf.o
19
20CFLAGS= $(INCLUDES) $(CFLAG)
21
22GENERAL=Makefile des.org des_locl.org
23TEST=destest.c
24APPS=
25
26LIB=$(TOP)/libcrypto.a
27LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
28 ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \
29 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
30 qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \
31 des_enc.c fcrypt_b.c read2pwd.c \
32 fcrypt.c xcbc_enc.c \
33 str2key.c cfb64ede.c ofb64ede.c supp.c
34
35LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
36 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
37 enc_read.o enc_writ.o ofb64enc.o \
38 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
39 ${DES_ENC} read2pwd.o \
40 fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o supp.o
41
42SRC= $(LIBSRC)
43
44EXHEADER= des.h
45HEADER= des_locl.h rpc_des.h podd.h sk.h spr.h des_ver.h $(EXHEADER)
46
47ALL= $(GENERAL) $(SRC) $(HEADER)
48
49top:
50 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
51
52all: lib
53
54lib: $(LIBOBJ)
55 $(AR) $(LIB) $(LIBOBJ)
56 sh $(TOP)/util/ranlib.sh $(LIB)
57 @touch lib
58
59# elf
60asm/dx86-elf.o: asm/dx86unix.cpp
61 $(CPP) -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o
62
63asm/yx86-elf.o: asm/yx86unix.cpp
64 $(CPP) -DELF asm/yx86unix.cpp | as -o asm/yx86-elf.o
65
66# solaris
67asm/dx86-sol.o: asm/dx86unix.cpp
68 $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
69 as -o asm/dx86-sol.o asm/dx86-sol.s
70 rm -f asm/dx86-sol.s
71
72asm/yx86-sol.o: asm/yx86unix.cpp
73 $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
74 as -o asm/yx86-sol.o asm/yx86-sol.s
75 rm -f asm/yx86-sol.s
76
77# a.out
78asm/dx86-out.o: asm/dx86unix.cpp
79 $(CPP) -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o
80
81asm/yx86-out.o: asm/yx86unix.cpp
82 $(CPP) -DOUT asm/yx86unix.cpp | as -o asm/yx86-out.o
83
84# bsdi
85asm/dx86bsdi.o: asm/dx86unix.cpp
86 $(CPP) -DBSDI asm/dx86unix.cpp | as -o asm/dx86bsdi.o
87
88asm/yx86bsdi.o: asm/yx86unix.cpp
89 $(CPP) -DBSDI asm/yx86unix.cpp | as -o asm/yx86bsdi.o
90
91asm/dx86unix.cpp:
92 (cd asm; perl des-586.pl cpp >dx86unix.cpp)
93
94asm/yx86unix.cpp:
95 (cd asm; perl crypt586.pl cpp >yx86unix.cpp)
96
97files:
98 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
99
100links:
101 /bin/rm -f Makefile
102 $(TOP)/util/point.sh Makefile.ssl Makefile
103 /bin/rm -f des.doc
104 /bin/rm -fr asm/perlasm
105 $(TOP)/util/point.sh ../../perlasm asm/perlasm
106 $(TOP)/util/point.sh ../../doc/des.doc des.doc
107 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
108 $(TOP)/util/mklink.sh ../../test $(TEST)
109 $(TOP)/util/mklink.sh ../../apps $(APPS)
110
111install: installs
112
113installs:
114 @for i in $(EXHEADER) ; \
115 do \
116 (cp $$i $(INSTALLTOP)/include/$$i; \
117 chmod 644 $(INSTALLTOP)/include/$$i ); \
118 done;
119
120tags:
121 ctags $(SRC)
122
123tests:
124
125lint:
126 lint -DLINT $(INCLUDES) $(SRC)>fluff
127
128depend:
129 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
130
131dclean:
132 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
133 mv -f Makefile.new $(MAKEFILE)
134
135clean:
136 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
137
138errors:
139
140# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/des/Makefile.uni b/src/lib/libssl/src/crypto/des/Makefile.uni
new file mode 100644
index 0000000000..8f1759748a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/Makefile.uni
@@ -0,0 +1,263 @@
1# You must select the correct terminal control system to be used to
2# turn character echo off when reading passwords. There a 5 systems
3# SGTTY - the old BSD system
4# TERMIO - most system V boxes
5# TERMIOS - SGI (ala IRIX).
6# VMS - the DEC operating system
7# MSDOS - we all know what it is :-)
8# read_pwd.c makes a reasonable guess at what is correct.
9
10# Targets
11# make - twidle the options yourself :-)
12# make cc - standard cc options
13# make gcc - standard gcc options
14# make x86-elf - linux-elf etc
15# make x86-out - linux-a.out, FreeBSD etc
16# make x86-solaris
17# make x86-bdsi
18
19# If you are on a DEC Alpha, edit des.h and change the DES_LONG
20# define to 'unsigned int'. I have seen this give a %20 speedup.
21
22OPTS0= -DRAND -DTERMIO #-DNOCONST
23
24# Version 1.94 has changed the strings_to_key function so that it is
25# now compatible with MITs when the string is longer than 8 characters.
26# If you wish to keep the old version, uncomment the following line.
27# This will affect the -E/-D options on des(1).
28#OPTS1= -DOLD_STR_TO_KEY
29
30# There are 4 possible performance options
31# -DDES_PTR
32# -DDES_RISC1
33# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2)
34# -DDES_UNROLL
35# after the initial build, run 'des_opts' to see which options are best
36# for your platform. There are some listed in options.txt
37#OPTS2= -DDES_PTR
38#OPTS3= -DDES_RISC1 # or DES_RISC2
39#OPTS4= -DDES_UNROLL
40
41OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4)
42
43MAKE=make -f Makefile
44#CC=cc
45#CFLAG= -O
46
47CC=gcc
48#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
49CFLAG= -O3 -fomit-frame-pointer
50
51CFLAGS=$(OPTS) $(CFLAG)
52CPP=$(CC) -E
53AS=as
54
55# Assember version of des_encrypt*().
56DES_ENC=des_enc.o fcrypt_b.o # normal C version
57#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86
58#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86
59#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86
60#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86
61
62LIBDIR=/usr/local/lib
63BINDIR=/usr/local/bin
64INCDIR=/usr/local/include
65MANDIR=/usr/local/man
66MAN1=1
67MAN3=3
68SHELL=/bin/sh
69OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o
70OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \
71 xcbc_enc.o qud_cksm.o cbc3_enc.o \
72 cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \
73 enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \
74 rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o
75
76GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \
77 des.doc options.txt asm
78GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \
79 des.man DES.pm DES.pod DES.xs Makefile.PL dess.cpp des3s.cpp \
80 Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \
81 des.org des_locl.org
82TESTING_LIT= destest speed des_opts
83TESTING_FULL= rpw des $(TESTING_LIT)
84TESTING_SRC_LIT=destest.c speed.c des_opts.c
85TESTING_SRC_FULL=rpw.c des.c $(TESTING_SRC_LIT)
86HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h
87HEADERS_FULL= $(HEADERS_LIT) rpc_des.h
88LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c
89LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c cbc3_enc.c \
90 cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \
91 enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \
92 rand_key.c rpc_enc.c str2key.c supp.c \
93 xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c
94
95PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
96
97OBJ= $(OBJ_FULL)
98GENERAL=$(GENERAL_FULL)
99TESTING=$(TESTING_FULL)
100TESTING_SRC=$(TESTING_SRC_FULL)
101HEADERS=$(HEADERS_FULL)
102LIBDES= $(LIBDES_FULL)
103
104ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS)
105
106DLIB= libdes.a
107
108all: $(DLIB) $(TESTING)
109
110cc:
111 $(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
112
113gcc:
114 $(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
115
116x86-elf:
117 $(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
118
119x86-out:
120 $(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
121
122x86-solaris:
123 $(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
124
125x86-bsdi:
126 $(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
127
128# elf
129asm/dx86-elf.o: asm/dx86unix.cpp
130 $(CPP) -DELF asm/dx86unix.cpp | $(AS) -o asm/dx86-elf.o
131
132asm/yx86-elf.o: asm/yx86unix.cpp
133 $(CPP) -DELF asm/yx86unix.cpp | $(AS) -o asm/yx86-elf.o
134
135# solaris
136asm/dx86-sol.o: asm/dx86unix.cpp
137 $(CC) -E -DSOL asm/dx86unix.cpp | sed 's/^#.*//' > asm/dx86-sol.s
138 as -o asm/dx86-sol.o asm/dx86-sol.s
139 rm -f asm/dx86-sol.s
140
141asm/yx86-sol.o: asm/yx86unix.cpp
142 $(CC) -E -DSOL asm/yx86unix.cpp | sed 's/^#.*//' > asm/yx86-sol.s
143 as -o asm/yx86-sol.o asm/yx86-sol.s
144 rm -f asm/yx86-sol.s
145
146# a.out
147asm/dx86-out.o: asm/dx86unix.cpp
148 $(CPP) -DOUT asm/dx86unix.cpp | $(AS) -o asm/dx86-out.o
149
150asm/yx86-out.o: asm/yx86unix.cpp
151 $(CPP) -DOUT asm/yx86unix.cpp | $(AS) -o asm/yx86-out.o
152
153# bsdi
154asm/dx86bsdi.o: asm/dx86unix.cpp
155 $(CPP) -DBSDI asm/dx86unix.cpp | $(AS) -o asm/dx86bsdi.o
156
157asm/yx86bsdi.o: asm/yx86unix.cpp
158 $(CPP) -DBSDI asm/yx86unix.cpp | $(AS) -o asm/yx86bsdi.o
159
160asm/dx86unix.cpp:
161 (cd asm; perl des-586.pl cpp >dx86unix.cpp)
162
163asm/yx86unix.cpp:
164 (cd asm; perl crypt586.pl cpp >yx86unix.cpp)
165
166test: all
167 ./destest
168
169$(DLIB): $(OBJ)
170 /bin/rm -f $(DLIB)
171 ar cr $(DLIB) $(OBJ)
172 -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \
173 else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \
174 else exit 0; fi; fi
175
176des_opts: des_opts.o $(DLIB)
177 $(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB)
178
179destest: destest.o $(DLIB)
180 $(CC) $(CFLAGS) -o destest destest.o $(DLIB)
181
182rpw: rpw.o $(DLIB)
183 $(CC) $(CFLAGS) -o rpw rpw.o $(DLIB)
184
185speed: speed.o $(DLIB)
186 $(CC) $(CFLAGS) -o speed speed.o $(DLIB)
187
188des: des.o $(DLIB)
189 $(CC) $(CFLAGS) -o des des.o $(DLIB)
190
191tags:
192 ctags $(TESTING_SRC) $(LIBDES)
193
194tar_lit:
195 /bin/mv Makefile Makefile.tmp
196 /bin/cp Makefile.lit Makefile
197 for i in $(HEADERS_LIT) $(LIBDES_LIT) $(GENERAL_LIT) $(TESTING_SRC_LIT) ;\
198 do \
199 n="$$n des/$$i"; \
200 done; \
201 ( cd .. ; tar chf - $$n )| gzip > libdes-l.tgz
202 /bin/rm -f Makefile
203 /bin/mv Makefile.tmp Makefile
204
205tar:
206 mv Makefile Makefile.tmp
207 /bin/cp Makefile.uni Makefile
208 for i in $(ALL) ;\
209 do \
210 n="$$n des/$$i"; \
211 done; \
212 ( cd .. ; tar chf - $$n )| gzip > libdes.tgz
213 /bin/rm -f Makefile
214 /bin/mv Makefile.tmp Makefile
215
216shar:
217 shar $(ALL) >libdes.shar
218
219depend:
220 makedepend $(LIBDES) $(TESTING_SRC)
221
222clean:
223 /bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o
224
225dclean:
226 sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
227 mv -f Makefile.new Makefile
228
229# Eric is probably going to choke when he next looks at this --tjh
230install: des
231 if test $(INSTALLTOP); then \
232 echo SSL style install; \
233 cp $(DLIB) $(INSTALLTOP)/lib; \
234 if test -s /bin/ranlib; then \
235 /bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
236 else \
237 if test -s /usr/bin/ranlib; then \
238 /usr/bin/ranlib $(INSTALLTOP)/lib/$(DLIB); \
239 fi; fi; \
240 chmod 644 $(INSTALLTOP)/lib/$(DLIB); \
241 cp des.h $(INSTALLTOP)/include; \
242 chmod 644 $(INSTALLTOP)/include/des.h; \
243 else \
244 echo Standalone install; \
245 cp $(DLIB) $(LIBDIR)/$(DLIB); \
246 if test -s /bin/ranlib; then \
247 /bin/ranlib $(LIBDIR)/$(DLIB); \
248 else \
249 if test -s /usr/bin/ranlib; then \
250 /usr/bin/ranlib $(LIBDIR)/$(DLIB); \
251 fi; \
252 fi; \
253 chmod 644 $(LIBDIR)/$(DLIB); \
254 cp des $(BINDIR)/des; \
255 chmod 711 $(BINDIR)/des; \
256 cp des_crypt.man $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
257 chmod 644 $(MANDIR)/man$(MAN3)/des_crypt.$(MAN3); \
258 cp des.man $(MANDIR)/man$(MAN1)/des.$(MAN1); \
259 chmod 644 $(MANDIR)/man$(MAN1)/des.$(MAN1); \
260 cp des.h $(INCDIR)/des.h; \
261 chmod 644 $(INCDIR)/des.h; \
262 fi
263# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/des/PC1 b/src/lib/libssl/src/crypto/des/PC1
new file mode 100644
index 0000000000..efb8348b72
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/PC1
@@ -0,0 +1,28 @@
1#!/usr/local/bin/perl
2
3@PC1=( 57,49,41,33,25,17, 9,
4 1,58,50,42,34,26,18,
5 10, 2,59,51,43,35,27,
6 19,11, 3,60,52,44,36,
7 "-","-","-","-",
8 63,55,47,39,31,23,15,
9 7,62,54,46,38,30,22,
10 14, 6,61,53,45,37,29,
11 21,13, 5,28,20,12, 4,
12 "-","-","-","-",
13 );
14
15foreach (@PC1)
16 {
17 if ($_ ne "-")
18 {
19 $_--;
20 $_=int($_/8)*8+7-($_%8);
21 printf "%2d ",$_;
22 }
23 else
24 { print "-- "; }
25 print "\n" if (((++$i) % 8) == 0);
26 print "\n" if ((($i) % 32) == 0);
27 }
28
diff --git a/src/lib/libssl/src/crypto/des/PC2 b/src/lib/libssl/src/crypto/des/PC2
new file mode 100644
index 0000000000..2d560270ec
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/PC2
@@ -0,0 +1,57 @@
1#!/usr/local/bin/perl
2
3@PC2_C=(14,17,11,24, 1, 5,
4 3,28,15, 6,21,10,
5 23,19,12, 4,26, 8,
6 16, 7,27,20,13, 2,
7 );
8
9@PC2_D=(41,52,31,37,47,55,
10 30,40,51,45,33,48,
11 44,49,39,56,34,53,
12 46,42,50,36,29,32,
13 );
14
15foreach (@PC2_C) {
16 if ($_ ne "-")
17 {
18 $_--;
19 printf "%2d ",$_; }
20 else { print "-- "; }
21 $C{$_}=1;
22 print "\n" if (((++$i) % 8) == 0);
23 }
24$i=0;
25print "\n";
26foreach (@PC2_D) {
27 if ($_ ne "-")
28 {
29 $_-=29;
30 printf "%2d ",$_; }
31 else { print "-- "; }
32 $D{$_}=1;
33 print "\n" if (((++$i) % 8) == 0); }
34
35print "\n";
36foreach $i (0 .. 27)
37 {
38 $_=$C{$i};
39 if ($_ ne "-") {printf "%2d ",$_;}
40 else { print "-- "; }
41 print "\n" if (((++$i) % 8) == 0);
42 }
43print "\n";
44
45print "\n";
46foreach $i (0 .. 27)
47 {
48 $_=$D{$i};
49 if ($_ ne "-") {printf "%2d ",$_;}
50 else { print "-- "; }
51 print "\n" if (((++$i) % 8) == 0);
52 }
53print "\n";
54sub numsort
55 {
56 $a-$b;
57 }
diff --git a/src/lib/libssl/src/crypto/des/asm/d-win32.asm b/src/lib/libssl/src/crypto/des/asm/d-win32.asm
new file mode 100644
index 0000000000..9e3dc9cd87
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/asm/d-win32.asm
@@ -0,0 +1,3132 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by des-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE des-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _des_encrypt
12EXTRN _des_SPtrans:DWORD
13_des_encrypt PROC NEAR
14 push esi
15 push edi
16 ;
17 ; Load the 2 words
18 mov esi, DWORD PTR 12[esp]
19 xor ecx, ecx
20 push ebx
21 push ebp
22 mov eax, DWORD PTR [esi]
23 mov ebx, DWORD PTR 28[esp]
24 mov edi, DWORD PTR 4[esi]
25 ;
26 ; IP
27 rol eax, 4
28 mov esi, eax
29 xor eax, edi
30 and eax, 0f0f0f0f0h
31 xor esi, eax
32 xor edi, eax
33 ;
34 rol edi, 20
35 mov eax, edi
36 xor edi, esi
37 and edi, 0fff0000fh
38 xor eax, edi
39 xor esi, edi
40 ;
41 rol eax, 14
42 mov edi, eax
43 xor eax, esi
44 and eax, 033333333h
45 xor edi, eax
46 xor esi, eax
47 ;
48 rol esi, 22
49 mov eax, esi
50 xor esi, edi
51 and esi, 003fc03fch
52 xor eax, esi
53 xor edi, esi
54 ;
55 rol eax, 9
56 mov esi, eax
57 xor eax, edi
58 and eax, 0aaaaaaaah
59 xor esi, eax
60 xor edi, eax
61 ;
62 rol edi, 1
63 mov ebp, DWORD PTR 24[esp]
64 cmp ebx, 0
65 je $L000start_decrypt
66 ;
67 ; Round 0
68 mov eax, DWORD PTR [ebp]
69 xor ebx, ebx
70 mov edx, DWORD PTR 4[ebp]
71 xor eax, esi
72 xor edx, esi
73 and eax, 0fcfcfcfch
74 and edx, 0cfcfcfcfh
75 mov bl, al
76 mov cl, ah
77 ror edx, 4
78 mov ebp, DWORD PTR _des_SPtrans[ebx]
79 mov bl, dl
80 xor edi, ebp
81 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
82 xor edi, ebp
83 mov cl, dh
84 shr eax, 16
85 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
86 xor edi, ebp
87 mov bl, ah
88 shr edx, 16
89 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
90 xor edi, ebp
91 mov ebp, DWORD PTR 24[esp]
92 mov cl, dh
93 and eax, 0ffh
94 and edx, 0ffh
95 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
96 xor edi, ebx
97 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
98 xor edi, ebx
99 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
100 xor edi, ebx
101 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
102 xor edi, ebx
103 ;
104 ; Round 1
105 mov eax, DWORD PTR 8[ebp]
106 xor ebx, ebx
107 mov edx, DWORD PTR 12[ebp]
108 xor eax, edi
109 xor edx, edi
110 and eax, 0fcfcfcfch
111 and edx, 0cfcfcfcfh
112 mov bl, al
113 mov cl, ah
114 ror edx, 4
115 mov ebp, DWORD PTR _des_SPtrans[ebx]
116 mov bl, dl
117 xor esi, ebp
118 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
119 xor esi, ebp
120 mov cl, dh
121 shr eax, 16
122 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
123 xor esi, ebp
124 mov bl, ah
125 shr edx, 16
126 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
127 xor esi, ebp
128 mov ebp, DWORD PTR 24[esp]
129 mov cl, dh
130 and eax, 0ffh
131 and edx, 0ffh
132 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
133 xor esi, ebx
134 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
135 xor esi, ebx
136 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
137 xor esi, ebx
138 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
139 xor esi, ebx
140 ;
141 ; Round 2
142 mov eax, DWORD PTR 16[ebp]
143 xor ebx, ebx
144 mov edx, DWORD PTR 20[ebp]
145 xor eax, esi
146 xor edx, esi
147 and eax, 0fcfcfcfch
148 and edx, 0cfcfcfcfh
149 mov bl, al
150 mov cl, ah
151 ror edx, 4
152 mov ebp, DWORD PTR _des_SPtrans[ebx]
153 mov bl, dl
154 xor edi, ebp
155 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
156 xor edi, ebp
157 mov cl, dh
158 shr eax, 16
159 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
160 xor edi, ebp
161 mov bl, ah
162 shr edx, 16
163 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
164 xor edi, ebp
165 mov ebp, DWORD PTR 24[esp]
166 mov cl, dh
167 and eax, 0ffh
168 and edx, 0ffh
169 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
170 xor edi, ebx
171 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
172 xor edi, ebx
173 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
174 xor edi, ebx
175 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
176 xor edi, ebx
177 ;
178 ; Round 3
179 mov eax, DWORD PTR 24[ebp]
180 xor ebx, ebx
181 mov edx, DWORD PTR 28[ebp]
182 xor eax, edi
183 xor edx, edi
184 and eax, 0fcfcfcfch
185 and edx, 0cfcfcfcfh
186 mov bl, al
187 mov cl, ah
188 ror edx, 4
189 mov ebp, DWORD PTR _des_SPtrans[ebx]
190 mov bl, dl
191 xor esi, ebp
192 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
193 xor esi, ebp
194 mov cl, dh
195 shr eax, 16
196 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
197 xor esi, ebp
198 mov bl, ah
199 shr edx, 16
200 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
201 xor esi, ebp
202 mov ebp, DWORD PTR 24[esp]
203 mov cl, dh
204 and eax, 0ffh
205 and edx, 0ffh
206 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
207 xor esi, ebx
208 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
209 xor esi, ebx
210 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
211 xor esi, ebx
212 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
213 xor esi, ebx
214 ;
215 ; Round 4
216 mov eax, DWORD PTR 32[ebp]
217 xor ebx, ebx
218 mov edx, DWORD PTR 36[ebp]
219 xor eax, esi
220 xor edx, esi
221 and eax, 0fcfcfcfch
222 and edx, 0cfcfcfcfh
223 mov bl, al
224 mov cl, ah
225 ror edx, 4
226 mov ebp, DWORD PTR _des_SPtrans[ebx]
227 mov bl, dl
228 xor edi, ebp
229 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
230 xor edi, ebp
231 mov cl, dh
232 shr eax, 16
233 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
234 xor edi, ebp
235 mov bl, ah
236 shr edx, 16
237 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
238 xor edi, ebp
239 mov ebp, DWORD PTR 24[esp]
240 mov cl, dh
241 and eax, 0ffh
242 and edx, 0ffh
243 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
244 xor edi, ebx
245 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
246 xor edi, ebx
247 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
248 xor edi, ebx
249 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
250 xor edi, ebx
251 ;
252 ; Round 5
253 mov eax, DWORD PTR 40[ebp]
254 xor ebx, ebx
255 mov edx, DWORD PTR 44[ebp]
256 xor eax, edi
257 xor edx, edi
258 and eax, 0fcfcfcfch
259 and edx, 0cfcfcfcfh
260 mov bl, al
261 mov cl, ah
262 ror edx, 4
263 mov ebp, DWORD PTR _des_SPtrans[ebx]
264 mov bl, dl
265 xor esi, ebp
266 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
267 xor esi, ebp
268 mov cl, dh
269 shr eax, 16
270 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
271 xor esi, ebp
272 mov bl, ah
273 shr edx, 16
274 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
275 xor esi, ebp
276 mov ebp, DWORD PTR 24[esp]
277 mov cl, dh
278 and eax, 0ffh
279 and edx, 0ffh
280 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
281 xor esi, ebx
282 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
283 xor esi, ebx
284 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
285 xor esi, ebx
286 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
287 xor esi, ebx
288 ;
289 ; Round 6
290 mov eax, DWORD PTR 48[ebp]
291 xor ebx, ebx
292 mov edx, DWORD PTR 52[ebp]
293 xor eax, esi
294 xor edx, esi
295 and eax, 0fcfcfcfch
296 and edx, 0cfcfcfcfh
297 mov bl, al
298 mov cl, ah
299 ror edx, 4
300 mov ebp, DWORD PTR _des_SPtrans[ebx]
301 mov bl, dl
302 xor edi, ebp
303 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
304 xor edi, ebp
305 mov cl, dh
306 shr eax, 16
307 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
308 xor edi, ebp
309 mov bl, ah
310 shr edx, 16
311 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
312 xor edi, ebp
313 mov ebp, DWORD PTR 24[esp]
314 mov cl, dh
315 and eax, 0ffh
316 and edx, 0ffh
317 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
318 xor edi, ebx
319 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
320 xor edi, ebx
321 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
322 xor edi, ebx
323 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
324 xor edi, ebx
325 ;
326 ; Round 7
327 mov eax, DWORD PTR 56[ebp]
328 xor ebx, ebx
329 mov edx, DWORD PTR 60[ebp]
330 xor eax, edi
331 xor edx, edi
332 and eax, 0fcfcfcfch
333 and edx, 0cfcfcfcfh
334 mov bl, al
335 mov cl, ah
336 ror edx, 4
337 mov ebp, DWORD PTR _des_SPtrans[ebx]
338 mov bl, dl
339 xor esi, ebp
340 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
341 xor esi, ebp
342 mov cl, dh
343 shr eax, 16
344 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
345 xor esi, ebp
346 mov bl, ah
347 shr edx, 16
348 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
349 xor esi, ebp
350 mov ebp, DWORD PTR 24[esp]
351 mov cl, dh
352 and eax, 0ffh
353 and edx, 0ffh
354 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
355 xor esi, ebx
356 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
357 xor esi, ebx
358 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
359 xor esi, ebx
360 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
361 xor esi, ebx
362 ;
363 ; Round 8
364 mov eax, DWORD PTR 64[ebp]
365 xor ebx, ebx
366 mov edx, DWORD PTR 68[ebp]
367 xor eax, esi
368 xor edx, esi
369 and eax, 0fcfcfcfch
370 and edx, 0cfcfcfcfh
371 mov bl, al
372 mov cl, ah
373 ror edx, 4
374 mov ebp, DWORD PTR _des_SPtrans[ebx]
375 mov bl, dl
376 xor edi, ebp
377 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
378 xor edi, ebp
379 mov cl, dh
380 shr eax, 16
381 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
382 xor edi, ebp
383 mov bl, ah
384 shr edx, 16
385 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
386 xor edi, ebp
387 mov ebp, DWORD PTR 24[esp]
388 mov cl, dh
389 and eax, 0ffh
390 and edx, 0ffh
391 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
392 xor edi, ebx
393 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
394 xor edi, ebx
395 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
396 xor edi, ebx
397 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
398 xor edi, ebx
399 ;
400 ; Round 9
401 mov eax, DWORD PTR 72[ebp]
402 xor ebx, ebx
403 mov edx, DWORD PTR 76[ebp]
404 xor eax, edi
405 xor edx, edi
406 and eax, 0fcfcfcfch
407 and edx, 0cfcfcfcfh
408 mov bl, al
409 mov cl, ah
410 ror edx, 4
411 mov ebp, DWORD PTR _des_SPtrans[ebx]
412 mov bl, dl
413 xor esi, ebp
414 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
415 xor esi, ebp
416 mov cl, dh
417 shr eax, 16
418 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
419 xor esi, ebp
420 mov bl, ah
421 shr edx, 16
422 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
423 xor esi, ebp
424 mov ebp, DWORD PTR 24[esp]
425 mov cl, dh
426 and eax, 0ffh
427 and edx, 0ffh
428 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
429 xor esi, ebx
430 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
431 xor esi, ebx
432 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
433 xor esi, ebx
434 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
435 xor esi, ebx
436 ;
437 ; Round 10
438 mov eax, DWORD PTR 80[ebp]
439 xor ebx, ebx
440 mov edx, DWORD PTR 84[ebp]
441 xor eax, esi
442 xor edx, esi
443 and eax, 0fcfcfcfch
444 and edx, 0cfcfcfcfh
445 mov bl, al
446 mov cl, ah
447 ror edx, 4
448 mov ebp, DWORD PTR _des_SPtrans[ebx]
449 mov bl, dl
450 xor edi, ebp
451 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
452 xor edi, ebp
453 mov cl, dh
454 shr eax, 16
455 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
456 xor edi, ebp
457 mov bl, ah
458 shr edx, 16
459 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
460 xor edi, ebp
461 mov ebp, DWORD PTR 24[esp]
462 mov cl, dh
463 and eax, 0ffh
464 and edx, 0ffh
465 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
466 xor edi, ebx
467 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
468 xor edi, ebx
469 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
470 xor edi, ebx
471 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
472 xor edi, ebx
473 ;
474 ; Round 11
475 mov eax, DWORD PTR 88[ebp]
476 xor ebx, ebx
477 mov edx, DWORD PTR 92[ebp]
478 xor eax, edi
479 xor edx, edi
480 and eax, 0fcfcfcfch
481 and edx, 0cfcfcfcfh
482 mov bl, al
483 mov cl, ah
484 ror edx, 4
485 mov ebp, DWORD PTR _des_SPtrans[ebx]
486 mov bl, dl
487 xor esi, ebp
488 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
489 xor esi, ebp
490 mov cl, dh
491 shr eax, 16
492 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
493 xor esi, ebp
494 mov bl, ah
495 shr edx, 16
496 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
497 xor esi, ebp
498 mov ebp, DWORD PTR 24[esp]
499 mov cl, dh
500 and eax, 0ffh
501 and edx, 0ffh
502 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
503 xor esi, ebx
504 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
505 xor esi, ebx
506 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
507 xor esi, ebx
508 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
509 xor esi, ebx
510 ;
511 ; Round 12
512 mov eax, DWORD PTR 96[ebp]
513 xor ebx, ebx
514 mov edx, DWORD PTR 100[ebp]
515 xor eax, esi
516 xor edx, esi
517 and eax, 0fcfcfcfch
518 and edx, 0cfcfcfcfh
519 mov bl, al
520 mov cl, ah
521 ror edx, 4
522 mov ebp, DWORD PTR _des_SPtrans[ebx]
523 mov bl, dl
524 xor edi, ebp
525 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
526 xor edi, ebp
527 mov cl, dh
528 shr eax, 16
529 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
530 xor edi, ebp
531 mov bl, ah
532 shr edx, 16
533 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
534 xor edi, ebp
535 mov ebp, DWORD PTR 24[esp]
536 mov cl, dh
537 and eax, 0ffh
538 and edx, 0ffh
539 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
540 xor edi, ebx
541 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
542 xor edi, ebx
543 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
544 xor edi, ebx
545 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
546 xor edi, ebx
547 ;
548 ; Round 13
549 mov eax, DWORD PTR 104[ebp]
550 xor ebx, ebx
551 mov edx, DWORD PTR 108[ebp]
552 xor eax, edi
553 xor edx, edi
554 and eax, 0fcfcfcfch
555 and edx, 0cfcfcfcfh
556 mov bl, al
557 mov cl, ah
558 ror edx, 4
559 mov ebp, DWORD PTR _des_SPtrans[ebx]
560 mov bl, dl
561 xor esi, ebp
562 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
563 xor esi, ebp
564 mov cl, dh
565 shr eax, 16
566 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
567 xor esi, ebp
568 mov bl, ah
569 shr edx, 16
570 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
571 xor esi, ebp
572 mov ebp, DWORD PTR 24[esp]
573 mov cl, dh
574 and eax, 0ffh
575 and edx, 0ffh
576 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
577 xor esi, ebx
578 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
579 xor esi, ebx
580 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
581 xor esi, ebx
582 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
583 xor esi, ebx
584 ;
585 ; Round 14
586 mov eax, DWORD PTR 112[ebp]
587 xor ebx, ebx
588 mov edx, DWORD PTR 116[ebp]
589 xor eax, esi
590 xor edx, esi
591 and eax, 0fcfcfcfch
592 and edx, 0cfcfcfcfh
593 mov bl, al
594 mov cl, ah
595 ror edx, 4
596 mov ebp, DWORD PTR _des_SPtrans[ebx]
597 mov bl, dl
598 xor edi, ebp
599 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
600 xor edi, ebp
601 mov cl, dh
602 shr eax, 16
603 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
604 xor edi, ebp
605 mov bl, ah
606 shr edx, 16
607 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
608 xor edi, ebp
609 mov ebp, DWORD PTR 24[esp]
610 mov cl, dh
611 and eax, 0ffh
612 and edx, 0ffh
613 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
614 xor edi, ebx
615 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
616 xor edi, ebx
617 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
618 xor edi, ebx
619 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
620 xor edi, ebx
621 ;
622 ; Round 15
623 mov eax, DWORD PTR 120[ebp]
624 xor ebx, ebx
625 mov edx, DWORD PTR 124[ebp]
626 xor eax, edi
627 xor edx, edi
628 and eax, 0fcfcfcfch
629 and edx, 0cfcfcfcfh
630 mov bl, al
631 mov cl, ah
632 ror edx, 4
633 mov ebp, DWORD PTR _des_SPtrans[ebx]
634 mov bl, dl
635 xor esi, ebp
636 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
637 xor esi, ebp
638 mov cl, dh
639 shr eax, 16
640 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
641 xor esi, ebp
642 mov bl, ah
643 shr edx, 16
644 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
645 xor esi, ebp
646 mov ebp, DWORD PTR 24[esp]
647 mov cl, dh
648 and eax, 0ffh
649 and edx, 0ffh
650 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
651 xor esi, ebx
652 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
653 xor esi, ebx
654 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
655 xor esi, ebx
656 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
657 xor esi, ebx
658 jmp $L001end
659$L000start_decrypt:
660 ;
661 ; Round 15
662 mov eax, DWORD PTR 120[ebp]
663 xor ebx, ebx
664 mov edx, DWORD PTR 124[ebp]
665 xor eax, esi
666 xor edx, esi
667 and eax, 0fcfcfcfch
668 and edx, 0cfcfcfcfh
669 mov bl, al
670 mov cl, ah
671 ror edx, 4
672 mov ebp, DWORD PTR _des_SPtrans[ebx]
673 mov bl, dl
674 xor edi, ebp
675 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
676 xor edi, ebp
677 mov cl, dh
678 shr eax, 16
679 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
680 xor edi, ebp
681 mov bl, ah
682 shr edx, 16
683 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
684 xor edi, ebp
685 mov ebp, DWORD PTR 24[esp]
686 mov cl, dh
687 and eax, 0ffh
688 and edx, 0ffh
689 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
690 xor edi, ebx
691 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
692 xor edi, ebx
693 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
694 xor edi, ebx
695 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
696 xor edi, ebx
697 ;
698 ; Round 14
699 mov eax, DWORD PTR 112[ebp]
700 xor ebx, ebx
701 mov edx, DWORD PTR 116[ebp]
702 xor eax, edi
703 xor edx, edi
704 and eax, 0fcfcfcfch
705 and edx, 0cfcfcfcfh
706 mov bl, al
707 mov cl, ah
708 ror edx, 4
709 mov ebp, DWORD PTR _des_SPtrans[ebx]
710 mov bl, dl
711 xor esi, ebp
712 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
713 xor esi, ebp
714 mov cl, dh
715 shr eax, 16
716 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
717 xor esi, ebp
718 mov bl, ah
719 shr edx, 16
720 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
721 xor esi, ebp
722 mov ebp, DWORD PTR 24[esp]
723 mov cl, dh
724 and eax, 0ffh
725 and edx, 0ffh
726 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
727 xor esi, ebx
728 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
729 xor esi, ebx
730 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
731 xor esi, ebx
732 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
733 xor esi, ebx
734 ;
735 ; Round 13
736 mov eax, DWORD PTR 104[ebp]
737 xor ebx, ebx
738 mov edx, DWORD PTR 108[ebp]
739 xor eax, esi
740 xor edx, esi
741 and eax, 0fcfcfcfch
742 and edx, 0cfcfcfcfh
743 mov bl, al
744 mov cl, ah
745 ror edx, 4
746 mov ebp, DWORD PTR _des_SPtrans[ebx]
747 mov bl, dl
748 xor edi, ebp
749 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
750 xor edi, ebp
751 mov cl, dh
752 shr eax, 16
753 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
754 xor edi, ebp
755 mov bl, ah
756 shr edx, 16
757 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
758 xor edi, ebp
759 mov ebp, DWORD PTR 24[esp]
760 mov cl, dh
761 and eax, 0ffh
762 and edx, 0ffh
763 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
764 xor edi, ebx
765 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
766 xor edi, ebx
767 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
768 xor edi, ebx
769 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
770 xor edi, ebx
771 ;
772 ; Round 12
773 mov eax, DWORD PTR 96[ebp]
774 xor ebx, ebx
775 mov edx, DWORD PTR 100[ebp]
776 xor eax, edi
777 xor edx, edi
778 and eax, 0fcfcfcfch
779 and edx, 0cfcfcfcfh
780 mov bl, al
781 mov cl, ah
782 ror edx, 4
783 mov ebp, DWORD PTR _des_SPtrans[ebx]
784 mov bl, dl
785 xor esi, ebp
786 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
787 xor esi, ebp
788 mov cl, dh
789 shr eax, 16
790 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
791 xor esi, ebp
792 mov bl, ah
793 shr edx, 16
794 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
795 xor esi, ebp
796 mov ebp, DWORD PTR 24[esp]
797 mov cl, dh
798 and eax, 0ffh
799 and edx, 0ffh
800 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
801 xor esi, ebx
802 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
803 xor esi, ebx
804 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
805 xor esi, ebx
806 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
807 xor esi, ebx
808 ;
809 ; Round 11
810 mov eax, DWORD PTR 88[ebp]
811 xor ebx, ebx
812 mov edx, DWORD PTR 92[ebp]
813 xor eax, esi
814 xor edx, esi
815 and eax, 0fcfcfcfch
816 and edx, 0cfcfcfcfh
817 mov bl, al
818 mov cl, ah
819 ror edx, 4
820 mov ebp, DWORD PTR _des_SPtrans[ebx]
821 mov bl, dl
822 xor edi, ebp
823 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
824 xor edi, ebp
825 mov cl, dh
826 shr eax, 16
827 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
828 xor edi, ebp
829 mov bl, ah
830 shr edx, 16
831 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
832 xor edi, ebp
833 mov ebp, DWORD PTR 24[esp]
834 mov cl, dh
835 and eax, 0ffh
836 and edx, 0ffh
837 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
838 xor edi, ebx
839 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
840 xor edi, ebx
841 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
842 xor edi, ebx
843 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
844 xor edi, ebx
845 ;
846 ; Round 10
847 mov eax, DWORD PTR 80[ebp]
848 xor ebx, ebx
849 mov edx, DWORD PTR 84[ebp]
850 xor eax, edi
851 xor edx, edi
852 and eax, 0fcfcfcfch
853 and edx, 0cfcfcfcfh
854 mov bl, al
855 mov cl, ah
856 ror edx, 4
857 mov ebp, DWORD PTR _des_SPtrans[ebx]
858 mov bl, dl
859 xor esi, ebp
860 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
861 xor esi, ebp
862 mov cl, dh
863 shr eax, 16
864 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
865 xor esi, ebp
866 mov bl, ah
867 shr edx, 16
868 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
869 xor esi, ebp
870 mov ebp, DWORD PTR 24[esp]
871 mov cl, dh
872 and eax, 0ffh
873 and edx, 0ffh
874 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
875 xor esi, ebx
876 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
877 xor esi, ebx
878 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
879 xor esi, ebx
880 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
881 xor esi, ebx
882 ;
883 ; Round 9
884 mov eax, DWORD PTR 72[ebp]
885 xor ebx, ebx
886 mov edx, DWORD PTR 76[ebp]
887 xor eax, esi
888 xor edx, esi
889 and eax, 0fcfcfcfch
890 and edx, 0cfcfcfcfh
891 mov bl, al
892 mov cl, ah
893 ror edx, 4
894 mov ebp, DWORD PTR _des_SPtrans[ebx]
895 mov bl, dl
896 xor edi, ebp
897 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
898 xor edi, ebp
899 mov cl, dh
900 shr eax, 16
901 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
902 xor edi, ebp
903 mov bl, ah
904 shr edx, 16
905 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
906 xor edi, ebp
907 mov ebp, DWORD PTR 24[esp]
908 mov cl, dh
909 and eax, 0ffh
910 and edx, 0ffh
911 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
912 xor edi, ebx
913 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
914 xor edi, ebx
915 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
916 xor edi, ebx
917 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
918 xor edi, ebx
919 ;
920 ; Round 8
921 mov eax, DWORD PTR 64[ebp]
922 xor ebx, ebx
923 mov edx, DWORD PTR 68[ebp]
924 xor eax, edi
925 xor edx, edi
926 and eax, 0fcfcfcfch
927 and edx, 0cfcfcfcfh
928 mov bl, al
929 mov cl, ah
930 ror edx, 4
931 mov ebp, DWORD PTR _des_SPtrans[ebx]
932 mov bl, dl
933 xor esi, ebp
934 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
935 xor esi, ebp
936 mov cl, dh
937 shr eax, 16
938 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
939 xor esi, ebp
940 mov bl, ah
941 shr edx, 16
942 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
943 xor esi, ebp
944 mov ebp, DWORD PTR 24[esp]
945 mov cl, dh
946 and eax, 0ffh
947 and edx, 0ffh
948 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
949 xor esi, ebx
950 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
951 xor esi, ebx
952 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
953 xor esi, ebx
954 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
955 xor esi, ebx
956 ;
957 ; Round 7
958 mov eax, DWORD PTR 56[ebp]
959 xor ebx, ebx
960 mov edx, DWORD PTR 60[ebp]
961 xor eax, esi
962 xor edx, esi
963 and eax, 0fcfcfcfch
964 and edx, 0cfcfcfcfh
965 mov bl, al
966 mov cl, ah
967 ror edx, 4
968 mov ebp, DWORD PTR _des_SPtrans[ebx]
969 mov bl, dl
970 xor edi, ebp
971 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
972 xor edi, ebp
973 mov cl, dh
974 shr eax, 16
975 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
976 xor edi, ebp
977 mov bl, ah
978 shr edx, 16
979 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
980 xor edi, ebp
981 mov ebp, DWORD PTR 24[esp]
982 mov cl, dh
983 and eax, 0ffh
984 and edx, 0ffh
985 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
986 xor edi, ebx
987 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
988 xor edi, ebx
989 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
990 xor edi, ebx
991 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
992 xor edi, ebx
993 ;
994 ; Round 6
995 mov eax, DWORD PTR 48[ebp]
996 xor ebx, ebx
997 mov edx, DWORD PTR 52[ebp]
998 xor eax, edi
999 xor edx, edi
1000 and eax, 0fcfcfcfch
1001 and edx, 0cfcfcfcfh
1002 mov bl, al
1003 mov cl, ah
1004 ror edx, 4
1005 mov ebp, DWORD PTR _des_SPtrans[ebx]
1006 mov bl, dl
1007 xor esi, ebp
1008 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1009 xor esi, ebp
1010 mov cl, dh
1011 shr eax, 16
1012 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1013 xor esi, ebp
1014 mov bl, ah
1015 shr edx, 16
1016 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1017 xor esi, ebp
1018 mov ebp, DWORD PTR 24[esp]
1019 mov cl, dh
1020 and eax, 0ffh
1021 and edx, 0ffh
1022 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1023 xor esi, ebx
1024 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1025 xor esi, ebx
1026 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1027 xor esi, ebx
1028 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1029 xor esi, ebx
1030 ;
1031 ; Round 5
1032 mov eax, DWORD PTR 40[ebp]
1033 xor ebx, ebx
1034 mov edx, DWORD PTR 44[ebp]
1035 xor eax, esi
1036 xor edx, esi
1037 and eax, 0fcfcfcfch
1038 and edx, 0cfcfcfcfh
1039 mov bl, al
1040 mov cl, ah
1041 ror edx, 4
1042 mov ebp, DWORD PTR _des_SPtrans[ebx]
1043 mov bl, dl
1044 xor edi, ebp
1045 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1046 xor edi, ebp
1047 mov cl, dh
1048 shr eax, 16
1049 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1050 xor edi, ebp
1051 mov bl, ah
1052 shr edx, 16
1053 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1054 xor edi, ebp
1055 mov ebp, DWORD PTR 24[esp]
1056 mov cl, dh
1057 and eax, 0ffh
1058 and edx, 0ffh
1059 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1060 xor edi, ebx
1061 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1062 xor edi, ebx
1063 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1064 xor edi, ebx
1065 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1066 xor edi, ebx
1067 ;
1068 ; Round 4
1069 mov eax, DWORD PTR 32[ebp]
1070 xor ebx, ebx
1071 mov edx, DWORD PTR 36[ebp]
1072 xor eax, edi
1073 xor edx, edi
1074 and eax, 0fcfcfcfch
1075 and edx, 0cfcfcfcfh
1076 mov bl, al
1077 mov cl, ah
1078 ror edx, 4
1079 mov ebp, DWORD PTR _des_SPtrans[ebx]
1080 mov bl, dl
1081 xor esi, ebp
1082 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1083 xor esi, ebp
1084 mov cl, dh
1085 shr eax, 16
1086 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1087 xor esi, ebp
1088 mov bl, ah
1089 shr edx, 16
1090 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1091 xor esi, ebp
1092 mov ebp, DWORD PTR 24[esp]
1093 mov cl, dh
1094 and eax, 0ffh
1095 and edx, 0ffh
1096 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1097 xor esi, ebx
1098 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1099 xor esi, ebx
1100 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1101 xor esi, ebx
1102 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1103 xor esi, ebx
1104 ;
1105 ; Round 3
1106 mov eax, DWORD PTR 24[ebp]
1107 xor ebx, ebx
1108 mov edx, DWORD PTR 28[ebp]
1109 xor eax, esi
1110 xor edx, esi
1111 and eax, 0fcfcfcfch
1112 and edx, 0cfcfcfcfh
1113 mov bl, al
1114 mov cl, ah
1115 ror edx, 4
1116 mov ebp, DWORD PTR _des_SPtrans[ebx]
1117 mov bl, dl
1118 xor edi, ebp
1119 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1120 xor edi, ebp
1121 mov cl, dh
1122 shr eax, 16
1123 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1124 xor edi, ebp
1125 mov bl, ah
1126 shr edx, 16
1127 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1128 xor edi, ebp
1129 mov ebp, DWORD PTR 24[esp]
1130 mov cl, dh
1131 and eax, 0ffh
1132 and edx, 0ffh
1133 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1134 xor edi, ebx
1135 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1136 xor edi, ebx
1137 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1138 xor edi, ebx
1139 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1140 xor edi, ebx
1141 ;
1142 ; Round 2
1143 mov eax, DWORD PTR 16[ebp]
1144 xor ebx, ebx
1145 mov edx, DWORD PTR 20[ebp]
1146 xor eax, edi
1147 xor edx, edi
1148 and eax, 0fcfcfcfch
1149 and edx, 0cfcfcfcfh
1150 mov bl, al
1151 mov cl, ah
1152 ror edx, 4
1153 mov ebp, DWORD PTR _des_SPtrans[ebx]
1154 mov bl, dl
1155 xor esi, ebp
1156 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1157 xor esi, ebp
1158 mov cl, dh
1159 shr eax, 16
1160 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1161 xor esi, ebp
1162 mov bl, ah
1163 shr edx, 16
1164 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1165 xor esi, ebp
1166 mov ebp, DWORD PTR 24[esp]
1167 mov cl, dh
1168 and eax, 0ffh
1169 and edx, 0ffh
1170 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1171 xor esi, ebx
1172 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1173 xor esi, ebx
1174 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1175 xor esi, ebx
1176 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1177 xor esi, ebx
1178 ;
1179 ; Round 1
1180 mov eax, DWORD PTR 8[ebp]
1181 xor ebx, ebx
1182 mov edx, DWORD PTR 12[ebp]
1183 xor eax, esi
1184 xor edx, esi
1185 and eax, 0fcfcfcfch
1186 and edx, 0cfcfcfcfh
1187 mov bl, al
1188 mov cl, ah
1189 ror edx, 4
1190 mov ebp, DWORD PTR _des_SPtrans[ebx]
1191 mov bl, dl
1192 xor edi, ebp
1193 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1194 xor edi, ebp
1195 mov cl, dh
1196 shr eax, 16
1197 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1198 xor edi, ebp
1199 mov bl, ah
1200 shr edx, 16
1201 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1202 xor edi, ebp
1203 mov ebp, DWORD PTR 24[esp]
1204 mov cl, dh
1205 and eax, 0ffh
1206 and edx, 0ffh
1207 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1208 xor edi, ebx
1209 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1210 xor edi, ebx
1211 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1212 xor edi, ebx
1213 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1214 xor edi, ebx
1215 ;
1216 ; Round 0
1217 mov eax, DWORD PTR [ebp]
1218 xor ebx, ebx
1219 mov edx, DWORD PTR 4[ebp]
1220 xor eax, edi
1221 xor edx, edi
1222 and eax, 0fcfcfcfch
1223 and edx, 0cfcfcfcfh
1224 mov bl, al
1225 mov cl, ah
1226 ror edx, 4
1227 mov ebp, DWORD PTR _des_SPtrans[ebx]
1228 mov bl, dl
1229 xor esi, ebp
1230 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1231 xor esi, ebp
1232 mov cl, dh
1233 shr eax, 16
1234 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1235 xor esi, ebp
1236 mov bl, ah
1237 shr edx, 16
1238 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1239 xor esi, ebp
1240 mov ebp, DWORD PTR 24[esp]
1241 mov cl, dh
1242 and eax, 0ffh
1243 and edx, 0ffh
1244 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1245 xor esi, ebx
1246 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1247 xor esi, ebx
1248 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1249 xor esi, ebx
1250 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1251 xor esi, ebx
1252$L001end:
1253 ;
1254 ; FP
1255 mov edx, DWORD PTR 20[esp]
1256 ror esi, 1
1257 mov eax, edi
1258 xor edi, esi
1259 and edi, 0aaaaaaaah
1260 xor eax, edi
1261 xor esi, edi
1262 ;
1263 rol eax, 23
1264 mov edi, eax
1265 xor eax, esi
1266 and eax, 003fc03fch
1267 xor edi, eax
1268 xor esi, eax
1269 ;
1270 rol edi, 10
1271 mov eax, edi
1272 xor edi, esi
1273 and edi, 033333333h
1274 xor eax, edi
1275 xor esi, edi
1276 ;
1277 rol esi, 18
1278 mov edi, esi
1279 xor esi, eax
1280 and esi, 0fff0000fh
1281 xor edi, esi
1282 xor eax, esi
1283 ;
1284 rol edi, 12
1285 mov esi, edi
1286 xor edi, eax
1287 and edi, 0f0f0f0f0h
1288 xor esi, edi
1289 xor eax, edi
1290 ;
1291 ror eax, 4
1292 mov DWORD PTR [edx],eax
1293 mov DWORD PTR 4[edx],esi
1294 pop ebp
1295 pop ebx
1296 pop edi
1297 pop esi
1298 ret
1299_des_encrypt ENDP
1300_TEXT ENDS
1301_TEXT SEGMENT
1302PUBLIC _des_encrypt2
1303EXTRN _des_SPtrans:DWORD
1304_des_encrypt2 PROC NEAR
1305 push esi
1306 push edi
1307 ;
1308 ; Load the 2 words
1309 mov eax, DWORD PTR 12[esp]
1310 xor ecx, ecx
1311 push ebx
1312 push ebp
1313 mov esi, DWORD PTR [eax]
1314 mov ebx, DWORD PTR 28[esp]
1315 rol esi, 3
1316 mov edi, DWORD PTR 4[eax]
1317 rol edi, 3
1318 mov ebp, DWORD PTR 24[esp]
1319 cmp ebx, 0
1320 je $L002start_decrypt
1321 ;
1322 ; Round 0
1323 mov eax, DWORD PTR [ebp]
1324 xor ebx, ebx
1325 mov edx, DWORD PTR 4[ebp]
1326 xor eax, esi
1327 xor edx, esi
1328 and eax, 0fcfcfcfch
1329 and edx, 0cfcfcfcfh
1330 mov bl, al
1331 mov cl, ah
1332 ror edx, 4
1333 mov ebp, DWORD PTR _des_SPtrans[ebx]
1334 mov bl, dl
1335 xor edi, ebp
1336 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1337 xor edi, ebp
1338 mov cl, dh
1339 shr eax, 16
1340 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1341 xor edi, ebp
1342 mov bl, ah
1343 shr edx, 16
1344 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1345 xor edi, ebp
1346 mov ebp, DWORD PTR 24[esp]
1347 mov cl, dh
1348 and eax, 0ffh
1349 and edx, 0ffh
1350 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1351 xor edi, ebx
1352 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1353 xor edi, ebx
1354 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1355 xor edi, ebx
1356 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1357 xor edi, ebx
1358 ;
1359 ; Round 1
1360 mov eax, DWORD PTR 8[ebp]
1361 xor ebx, ebx
1362 mov edx, DWORD PTR 12[ebp]
1363 xor eax, edi
1364 xor edx, edi
1365 and eax, 0fcfcfcfch
1366 and edx, 0cfcfcfcfh
1367 mov bl, al
1368 mov cl, ah
1369 ror edx, 4
1370 mov ebp, DWORD PTR _des_SPtrans[ebx]
1371 mov bl, dl
1372 xor esi, ebp
1373 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1374 xor esi, ebp
1375 mov cl, dh
1376 shr eax, 16
1377 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1378 xor esi, ebp
1379 mov bl, ah
1380 shr edx, 16
1381 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1382 xor esi, ebp
1383 mov ebp, DWORD PTR 24[esp]
1384 mov cl, dh
1385 and eax, 0ffh
1386 and edx, 0ffh
1387 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1388 xor esi, ebx
1389 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1390 xor esi, ebx
1391 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1392 xor esi, ebx
1393 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1394 xor esi, ebx
1395 ;
1396 ; Round 2
1397 mov eax, DWORD PTR 16[ebp]
1398 xor ebx, ebx
1399 mov edx, DWORD PTR 20[ebp]
1400 xor eax, esi
1401 xor edx, esi
1402 and eax, 0fcfcfcfch
1403 and edx, 0cfcfcfcfh
1404 mov bl, al
1405 mov cl, ah
1406 ror edx, 4
1407 mov ebp, DWORD PTR _des_SPtrans[ebx]
1408 mov bl, dl
1409 xor edi, ebp
1410 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1411 xor edi, ebp
1412 mov cl, dh
1413 shr eax, 16
1414 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1415 xor edi, ebp
1416 mov bl, ah
1417 shr edx, 16
1418 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1419 xor edi, ebp
1420 mov ebp, DWORD PTR 24[esp]
1421 mov cl, dh
1422 and eax, 0ffh
1423 and edx, 0ffh
1424 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1425 xor edi, ebx
1426 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1427 xor edi, ebx
1428 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1429 xor edi, ebx
1430 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1431 xor edi, ebx
1432 ;
1433 ; Round 3
1434 mov eax, DWORD PTR 24[ebp]
1435 xor ebx, ebx
1436 mov edx, DWORD PTR 28[ebp]
1437 xor eax, edi
1438 xor edx, edi
1439 and eax, 0fcfcfcfch
1440 and edx, 0cfcfcfcfh
1441 mov bl, al
1442 mov cl, ah
1443 ror edx, 4
1444 mov ebp, DWORD PTR _des_SPtrans[ebx]
1445 mov bl, dl
1446 xor esi, ebp
1447 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1448 xor esi, ebp
1449 mov cl, dh
1450 shr eax, 16
1451 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1452 xor esi, ebp
1453 mov bl, ah
1454 shr edx, 16
1455 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1456 xor esi, ebp
1457 mov ebp, DWORD PTR 24[esp]
1458 mov cl, dh
1459 and eax, 0ffh
1460 and edx, 0ffh
1461 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1462 xor esi, ebx
1463 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1464 xor esi, ebx
1465 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1466 xor esi, ebx
1467 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1468 xor esi, ebx
1469 ;
1470 ; Round 4
1471 mov eax, DWORD PTR 32[ebp]
1472 xor ebx, ebx
1473 mov edx, DWORD PTR 36[ebp]
1474 xor eax, esi
1475 xor edx, esi
1476 and eax, 0fcfcfcfch
1477 and edx, 0cfcfcfcfh
1478 mov bl, al
1479 mov cl, ah
1480 ror edx, 4
1481 mov ebp, DWORD PTR _des_SPtrans[ebx]
1482 mov bl, dl
1483 xor edi, ebp
1484 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1485 xor edi, ebp
1486 mov cl, dh
1487 shr eax, 16
1488 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1489 xor edi, ebp
1490 mov bl, ah
1491 shr edx, 16
1492 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1493 xor edi, ebp
1494 mov ebp, DWORD PTR 24[esp]
1495 mov cl, dh
1496 and eax, 0ffh
1497 and edx, 0ffh
1498 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1499 xor edi, ebx
1500 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1501 xor edi, ebx
1502 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1503 xor edi, ebx
1504 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1505 xor edi, ebx
1506 ;
1507 ; Round 5
1508 mov eax, DWORD PTR 40[ebp]
1509 xor ebx, ebx
1510 mov edx, DWORD PTR 44[ebp]
1511 xor eax, edi
1512 xor edx, edi
1513 and eax, 0fcfcfcfch
1514 and edx, 0cfcfcfcfh
1515 mov bl, al
1516 mov cl, ah
1517 ror edx, 4
1518 mov ebp, DWORD PTR _des_SPtrans[ebx]
1519 mov bl, dl
1520 xor esi, ebp
1521 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1522 xor esi, ebp
1523 mov cl, dh
1524 shr eax, 16
1525 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1526 xor esi, ebp
1527 mov bl, ah
1528 shr edx, 16
1529 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1530 xor esi, ebp
1531 mov ebp, DWORD PTR 24[esp]
1532 mov cl, dh
1533 and eax, 0ffh
1534 and edx, 0ffh
1535 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1536 xor esi, ebx
1537 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1538 xor esi, ebx
1539 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1540 xor esi, ebx
1541 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1542 xor esi, ebx
1543 ;
1544 ; Round 6
1545 mov eax, DWORD PTR 48[ebp]
1546 xor ebx, ebx
1547 mov edx, DWORD PTR 52[ebp]
1548 xor eax, esi
1549 xor edx, esi
1550 and eax, 0fcfcfcfch
1551 and edx, 0cfcfcfcfh
1552 mov bl, al
1553 mov cl, ah
1554 ror edx, 4
1555 mov ebp, DWORD PTR _des_SPtrans[ebx]
1556 mov bl, dl
1557 xor edi, ebp
1558 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1559 xor edi, ebp
1560 mov cl, dh
1561 shr eax, 16
1562 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1563 xor edi, ebp
1564 mov bl, ah
1565 shr edx, 16
1566 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1567 xor edi, ebp
1568 mov ebp, DWORD PTR 24[esp]
1569 mov cl, dh
1570 and eax, 0ffh
1571 and edx, 0ffh
1572 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1573 xor edi, ebx
1574 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1575 xor edi, ebx
1576 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1577 xor edi, ebx
1578 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1579 xor edi, ebx
1580 ;
1581 ; Round 7
1582 mov eax, DWORD PTR 56[ebp]
1583 xor ebx, ebx
1584 mov edx, DWORD PTR 60[ebp]
1585 xor eax, edi
1586 xor edx, edi
1587 and eax, 0fcfcfcfch
1588 and edx, 0cfcfcfcfh
1589 mov bl, al
1590 mov cl, ah
1591 ror edx, 4
1592 mov ebp, DWORD PTR _des_SPtrans[ebx]
1593 mov bl, dl
1594 xor esi, ebp
1595 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1596 xor esi, ebp
1597 mov cl, dh
1598 shr eax, 16
1599 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1600 xor esi, ebp
1601 mov bl, ah
1602 shr edx, 16
1603 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1604 xor esi, ebp
1605 mov ebp, DWORD PTR 24[esp]
1606 mov cl, dh
1607 and eax, 0ffh
1608 and edx, 0ffh
1609 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1610 xor esi, ebx
1611 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1612 xor esi, ebx
1613 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1614 xor esi, ebx
1615 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1616 xor esi, ebx
1617 ;
1618 ; Round 8
1619 mov eax, DWORD PTR 64[ebp]
1620 xor ebx, ebx
1621 mov edx, DWORD PTR 68[ebp]
1622 xor eax, esi
1623 xor edx, esi
1624 and eax, 0fcfcfcfch
1625 and edx, 0cfcfcfcfh
1626 mov bl, al
1627 mov cl, ah
1628 ror edx, 4
1629 mov ebp, DWORD PTR _des_SPtrans[ebx]
1630 mov bl, dl
1631 xor edi, ebp
1632 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1633 xor edi, ebp
1634 mov cl, dh
1635 shr eax, 16
1636 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1637 xor edi, ebp
1638 mov bl, ah
1639 shr edx, 16
1640 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1641 xor edi, ebp
1642 mov ebp, DWORD PTR 24[esp]
1643 mov cl, dh
1644 and eax, 0ffh
1645 and edx, 0ffh
1646 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1647 xor edi, ebx
1648 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1649 xor edi, ebx
1650 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1651 xor edi, ebx
1652 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1653 xor edi, ebx
1654 ;
1655 ; Round 9
1656 mov eax, DWORD PTR 72[ebp]
1657 xor ebx, ebx
1658 mov edx, DWORD PTR 76[ebp]
1659 xor eax, edi
1660 xor edx, edi
1661 and eax, 0fcfcfcfch
1662 and edx, 0cfcfcfcfh
1663 mov bl, al
1664 mov cl, ah
1665 ror edx, 4
1666 mov ebp, DWORD PTR _des_SPtrans[ebx]
1667 mov bl, dl
1668 xor esi, ebp
1669 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1670 xor esi, ebp
1671 mov cl, dh
1672 shr eax, 16
1673 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1674 xor esi, ebp
1675 mov bl, ah
1676 shr edx, 16
1677 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1678 xor esi, ebp
1679 mov ebp, DWORD PTR 24[esp]
1680 mov cl, dh
1681 and eax, 0ffh
1682 and edx, 0ffh
1683 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1684 xor esi, ebx
1685 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1686 xor esi, ebx
1687 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1688 xor esi, ebx
1689 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1690 xor esi, ebx
1691 ;
1692 ; Round 10
1693 mov eax, DWORD PTR 80[ebp]
1694 xor ebx, ebx
1695 mov edx, DWORD PTR 84[ebp]
1696 xor eax, esi
1697 xor edx, esi
1698 and eax, 0fcfcfcfch
1699 and edx, 0cfcfcfcfh
1700 mov bl, al
1701 mov cl, ah
1702 ror edx, 4
1703 mov ebp, DWORD PTR _des_SPtrans[ebx]
1704 mov bl, dl
1705 xor edi, ebp
1706 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1707 xor edi, ebp
1708 mov cl, dh
1709 shr eax, 16
1710 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1711 xor edi, ebp
1712 mov bl, ah
1713 shr edx, 16
1714 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1715 xor edi, ebp
1716 mov ebp, DWORD PTR 24[esp]
1717 mov cl, dh
1718 and eax, 0ffh
1719 and edx, 0ffh
1720 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1721 xor edi, ebx
1722 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1723 xor edi, ebx
1724 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1725 xor edi, ebx
1726 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1727 xor edi, ebx
1728 ;
1729 ; Round 11
1730 mov eax, DWORD PTR 88[ebp]
1731 xor ebx, ebx
1732 mov edx, DWORD PTR 92[ebp]
1733 xor eax, edi
1734 xor edx, edi
1735 and eax, 0fcfcfcfch
1736 and edx, 0cfcfcfcfh
1737 mov bl, al
1738 mov cl, ah
1739 ror edx, 4
1740 mov ebp, DWORD PTR _des_SPtrans[ebx]
1741 mov bl, dl
1742 xor esi, ebp
1743 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1744 xor esi, ebp
1745 mov cl, dh
1746 shr eax, 16
1747 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1748 xor esi, ebp
1749 mov bl, ah
1750 shr edx, 16
1751 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1752 xor esi, ebp
1753 mov ebp, DWORD PTR 24[esp]
1754 mov cl, dh
1755 and eax, 0ffh
1756 and edx, 0ffh
1757 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1758 xor esi, ebx
1759 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1760 xor esi, ebx
1761 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1762 xor esi, ebx
1763 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1764 xor esi, ebx
1765 ;
1766 ; Round 12
1767 mov eax, DWORD PTR 96[ebp]
1768 xor ebx, ebx
1769 mov edx, DWORD PTR 100[ebp]
1770 xor eax, esi
1771 xor edx, esi
1772 and eax, 0fcfcfcfch
1773 and edx, 0cfcfcfcfh
1774 mov bl, al
1775 mov cl, ah
1776 ror edx, 4
1777 mov ebp, DWORD PTR _des_SPtrans[ebx]
1778 mov bl, dl
1779 xor edi, ebp
1780 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1781 xor edi, ebp
1782 mov cl, dh
1783 shr eax, 16
1784 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1785 xor edi, ebp
1786 mov bl, ah
1787 shr edx, 16
1788 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1789 xor edi, ebp
1790 mov ebp, DWORD PTR 24[esp]
1791 mov cl, dh
1792 and eax, 0ffh
1793 and edx, 0ffh
1794 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1795 xor edi, ebx
1796 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1797 xor edi, ebx
1798 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1799 xor edi, ebx
1800 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1801 xor edi, ebx
1802 ;
1803 ; Round 13
1804 mov eax, DWORD PTR 104[ebp]
1805 xor ebx, ebx
1806 mov edx, DWORD PTR 108[ebp]
1807 xor eax, edi
1808 xor edx, edi
1809 and eax, 0fcfcfcfch
1810 and edx, 0cfcfcfcfh
1811 mov bl, al
1812 mov cl, ah
1813 ror edx, 4
1814 mov ebp, DWORD PTR _des_SPtrans[ebx]
1815 mov bl, dl
1816 xor esi, ebp
1817 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1818 xor esi, ebp
1819 mov cl, dh
1820 shr eax, 16
1821 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1822 xor esi, ebp
1823 mov bl, ah
1824 shr edx, 16
1825 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1826 xor esi, ebp
1827 mov ebp, DWORD PTR 24[esp]
1828 mov cl, dh
1829 and eax, 0ffh
1830 and edx, 0ffh
1831 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1832 xor esi, ebx
1833 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1834 xor esi, ebx
1835 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1836 xor esi, ebx
1837 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1838 xor esi, ebx
1839 ;
1840 ; Round 14
1841 mov eax, DWORD PTR 112[ebp]
1842 xor ebx, ebx
1843 mov edx, DWORD PTR 116[ebp]
1844 xor eax, esi
1845 xor edx, esi
1846 and eax, 0fcfcfcfch
1847 and edx, 0cfcfcfcfh
1848 mov bl, al
1849 mov cl, ah
1850 ror edx, 4
1851 mov ebp, DWORD PTR _des_SPtrans[ebx]
1852 mov bl, dl
1853 xor edi, ebp
1854 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1855 xor edi, ebp
1856 mov cl, dh
1857 shr eax, 16
1858 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1859 xor edi, ebp
1860 mov bl, ah
1861 shr edx, 16
1862 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1863 xor edi, ebp
1864 mov ebp, DWORD PTR 24[esp]
1865 mov cl, dh
1866 and eax, 0ffh
1867 and edx, 0ffh
1868 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1869 xor edi, ebx
1870 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1871 xor edi, ebx
1872 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1873 xor edi, ebx
1874 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1875 xor edi, ebx
1876 ;
1877 ; Round 15
1878 mov eax, DWORD PTR 120[ebp]
1879 xor ebx, ebx
1880 mov edx, DWORD PTR 124[ebp]
1881 xor eax, edi
1882 xor edx, edi
1883 and eax, 0fcfcfcfch
1884 and edx, 0cfcfcfcfh
1885 mov bl, al
1886 mov cl, ah
1887 ror edx, 4
1888 mov ebp, DWORD PTR _des_SPtrans[ebx]
1889 mov bl, dl
1890 xor esi, ebp
1891 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1892 xor esi, ebp
1893 mov cl, dh
1894 shr eax, 16
1895 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1896 xor esi, ebp
1897 mov bl, ah
1898 shr edx, 16
1899 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1900 xor esi, ebp
1901 mov ebp, DWORD PTR 24[esp]
1902 mov cl, dh
1903 and eax, 0ffh
1904 and edx, 0ffh
1905 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1906 xor esi, ebx
1907 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1908 xor esi, ebx
1909 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1910 xor esi, ebx
1911 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1912 xor esi, ebx
1913 jmp $L003end
1914$L002start_decrypt:
1915 ;
1916 ; Round 15
1917 mov eax, DWORD PTR 120[ebp]
1918 xor ebx, ebx
1919 mov edx, DWORD PTR 124[ebp]
1920 xor eax, esi
1921 xor edx, esi
1922 and eax, 0fcfcfcfch
1923 and edx, 0cfcfcfcfh
1924 mov bl, al
1925 mov cl, ah
1926 ror edx, 4
1927 mov ebp, DWORD PTR _des_SPtrans[ebx]
1928 mov bl, dl
1929 xor edi, ebp
1930 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1931 xor edi, ebp
1932 mov cl, dh
1933 shr eax, 16
1934 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1935 xor edi, ebp
1936 mov bl, ah
1937 shr edx, 16
1938 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1939 xor edi, ebp
1940 mov ebp, DWORD PTR 24[esp]
1941 mov cl, dh
1942 and eax, 0ffh
1943 and edx, 0ffh
1944 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1945 xor edi, ebx
1946 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1947 xor edi, ebx
1948 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1949 xor edi, ebx
1950 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1951 xor edi, ebx
1952 ;
1953 ; Round 14
1954 mov eax, DWORD PTR 112[ebp]
1955 xor ebx, ebx
1956 mov edx, DWORD PTR 116[ebp]
1957 xor eax, edi
1958 xor edx, edi
1959 and eax, 0fcfcfcfch
1960 and edx, 0cfcfcfcfh
1961 mov bl, al
1962 mov cl, ah
1963 ror edx, 4
1964 mov ebp, DWORD PTR _des_SPtrans[ebx]
1965 mov bl, dl
1966 xor esi, ebp
1967 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
1968 xor esi, ebp
1969 mov cl, dh
1970 shr eax, 16
1971 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
1972 xor esi, ebp
1973 mov bl, ah
1974 shr edx, 16
1975 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
1976 xor esi, ebp
1977 mov ebp, DWORD PTR 24[esp]
1978 mov cl, dh
1979 and eax, 0ffh
1980 and edx, 0ffh
1981 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
1982 xor esi, ebx
1983 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
1984 xor esi, ebx
1985 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
1986 xor esi, ebx
1987 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
1988 xor esi, ebx
1989 ;
1990 ; Round 13
1991 mov eax, DWORD PTR 104[ebp]
1992 xor ebx, ebx
1993 mov edx, DWORD PTR 108[ebp]
1994 xor eax, esi
1995 xor edx, esi
1996 and eax, 0fcfcfcfch
1997 and edx, 0cfcfcfcfh
1998 mov bl, al
1999 mov cl, ah
2000 ror edx, 4
2001 mov ebp, DWORD PTR _des_SPtrans[ebx]
2002 mov bl, dl
2003 xor edi, ebp
2004 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2005 xor edi, ebp
2006 mov cl, dh
2007 shr eax, 16
2008 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2009 xor edi, ebp
2010 mov bl, ah
2011 shr edx, 16
2012 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2013 xor edi, ebp
2014 mov ebp, DWORD PTR 24[esp]
2015 mov cl, dh
2016 and eax, 0ffh
2017 and edx, 0ffh
2018 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2019 xor edi, ebx
2020 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2021 xor edi, ebx
2022 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2023 xor edi, ebx
2024 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2025 xor edi, ebx
2026 ;
2027 ; Round 12
2028 mov eax, DWORD PTR 96[ebp]
2029 xor ebx, ebx
2030 mov edx, DWORD PTR 100[ebp]
2031 xor eax, edi
2032 xor edx, edi
2033 and eax, 0fcfcfcfch
2034 and edx, 0cfcfcfcfh
2035 mov bl, al
2036 mov cl, ah
2037 ror edx, 4
2038 mov ebp, DWORD PTR _des_SPtrans[ebx]
2039 mov bl, dl
2040 xor esi, ebp
2041 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2042 xor esi, ebp
2043 mov cl, dh
2044 shr eax, 16
2045 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2046 xor esi, ebp
2047 mov bl, ah
2048 shr edx, 16
2049 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2050 xor esi, ebp
2051 mov ebp, DWORD PTR 24[esp]
2052 mov cl, dh
2053 and eax, 0ffh
2054 and edx, 0ffh
2055 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2056 xor esi, ebx
2057 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2058 xor esi, ebx
2059 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2060 xor esi, ebx
2061 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2062 xor esi, ebx
2063 ;
2064 ; Round 11
2065 mov eax, DWORD PTR 88[ebp]
2066 xor ebx, ebx
2067 mov edx, DWORD PTR 92[ebp]
2068 xor eax, esi
2069 xor edx, esi
2070 and eax, 0fcfcfcfch
2071 and edx, 0cfcfcfcfh
2072 mov bl, al
2073 mov cl, ah
2074 ror edx, 4
2075 mov ebp, DWORD PTR _des_SPtrans[ebx]
2076 mov bl, dl
2077 xor edi, ebp
2078 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2079 xor edi, ebp
2080 mov cl, dh
2081 shr eax, 16
2082 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2083 xor edi, ebp
2084 mov bl, ah
2085 shr edx, 16
2086 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2087 xor edi, ebp
2088 mov ebp, DWORD PTR 24[esp]
2089 mov cl, dh
2090 and eax, 0ffh
2091 and edx, 0ffh
2092 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2093 xor edi, ebx
2094 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2095 xor edi, ebx
2096 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2097 xor edi, ebx
2098 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2099 xor edi, ebx
2100 ;
2101 ; Round 10
2102 mov eax, DWORD PTR 80[ebp]
2103 xor ebx, ebx
2104 mov edx, DWORD PTR 84[ebp]
2105 xor eax, edi
2106 xor edx, edi
2107 and eax, 0fcfcfcfch
2108 and edx, 0cfcfcfcfh
2109 mov bl, al
2110 mov cl, ah
2111 ror edx, 4
2112 mov ebp, DWORD PTR _des_SPtrans[ebx]
2113 mov bl, dl
2114 xor esi, ebp
2115 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2116 xor esi, ebp
2117 mov cl, dh
2118 shr eax, 16
2119 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2120 xor esi, ebp
2121 mov bl, ah
2122 shr edx, 16
2123 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2124 xor esi, ebp
2125 mov ebp, DWORD PTR 24[esp]
2126 mov cl, dh
2127 and eax, 0ffh
2128 and edx, 0ffh
2129 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2130 xor esi, ebx
2131 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2132 xor esi, ebx
2133 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2134 xor esi, ebx
2135 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2136 xor esi, ebx
2137 ;
2138 ; Round 9
2139 mov eax, DWORD PTR 72[ebp]
2140 xor ebx, ebx
2141 mov edx, DWORD PTR 76[ebp]
2142 xor eax, esi
2143 xor edx, esi
2144 and eax, 0fcfcfcfch
2145 and edx, 0cfcfcfcfh
2146 mov bl, al
2147 mov cl, ah
2148 ror edx, 4
2149 mov ebp, DWORD PTR _des_SPtrans[ebx]
2150 mov bl, dl
2151 xor edi, ebp
2152 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2153 xor edi, ebp
2154 mov cl, dh
2155 shr eax, 16
2156 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2157 xor edi, ebp
2158 mov bl, ah
2159 shr edx, 16
2160 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2161 xor edi, ebp
2162 mov ebp, DWORD PTR 24[esp]
2163 mov cl, dh
2164 and eax, 0ffh
2165 and edx, 0ffh
2166 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2167 xor edi, ebx
2168 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2169 xor edi, ebx
2170 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2171 xor edi, ebx
2172 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2173 xor edi, ebx
2174 ;
2175 ; Round 8
2176 mov eax, DWORD PTR 64[ebp]
2177 xor ebx, ebx
2178 mov edx, DWORD PTR 68[ebp]
2179 xor eax, edi
2180 xor edx, edi
2181 and eax, 0fcfcfcfch
2182 and edx, 0cfcfcfcfh
2183 mov bl, al
2184 mov cl, ah
2185 ror edx, 4
2186 mov ebp, DWORD PTR _des_SPtrans[ebx]
2187 mov bl, dl
2188 xor esi, ebp
2189 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2190 xor esi, ebp
2191 mov cl, dh
2192 shr eax, 16
2193 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2194 xor esi, ebp
2195 mov bl, ah
2196 shr edx, 16
2197 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2198 xor esi, ebp
2199 mov ebp, DWORD PTR 24[esp]
2200 mov cl, dh
2201 and eax, 0ffh
2202 and edx, 0ffh
2203 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2204 xor esi, ebx
2205 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2206 xor esi, ebx
2207 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2208 xor esi, ebx
2209 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2210 xor esi, ebx
2211 ;
2212 ; Round 7
2213 mov eax, DWORD PTR 56[ebp]
2214 xor ebx, ebx
2215 mov edx, DWORD PTR 60[ebp]
2216 xor eax, esi
2217 xor edx, esi
2218 and eax, 0fcfcfcfch
2219 and edx, 0cfcfcfcfh
2220 mov bl, al
2221 mov cl, ah
2222 ror edx, 4
2223 mov ebp, DWORD PTR _des_SPtrans[ebx]
2224 mov bl, dl
2225 xor edi, ebp
2226 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2227 xor edi, ebp
2228 mov cl, dh
2229 shr eax, 16
2230 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2231 xor edi, ebp
2232 mov bl, ah
2233 shr edx, 16
2234 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2235 xor edi, ebp
2236 mov ebp, DWORD PTR 24[esp]
2237 mov cl, dh
2238 and eax, 0ffh
2239 and edx, 0ffh
2240 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2241 xor edi, ebx
2242 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2243 xor edi, ebx
2244 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2245 xor edi, ebx
2246 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2247 xor edi, ebx
2248 ;
2249 ; Round 6
2250 mov eax, DWORD PTR 48[ebp]
2251 xor ebx, ebx
2252 mov edx, DWORD PTR 52[ebp]
2253 xor eax, edi
2254 xor edx, edi
2255 and eax, 0fcfcfcfch
2256 and edx, 0cfcfcfcfh
2257 mov bl, al
2258 mov cl, ah
2259 ror edx, 4
2260 mov ebp, DWORD PTR _des_SPtrans[ebx]
2261 mov bl, dl
2262 xor esi, ebp
2263 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2264 xor esi, ebp
2265 mov cl, dh
2266 shr eax, 16
2267 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2268 xor esi, ebp
2269 mov bl, ah
2270 shr edx, 16
2271 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2272 xor esi, ebp
2273 mov ebp, DWORD PTR 24[esp]
2274 mov cl, dh
2275 and eax, 0ffh
2276 and edx, 0ffh
2277 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2278 xor esi, ebx
2279 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2280 xor esi, ebx
2281 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2282 xor esi, ebx
2283 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2284 xor esi, ebx
2285 ;
2286 ; Round 5
2287 mov eax, DWORD PTR 40[ebp]
2288 xor ebx, ebx
2289 mov edx, DWORD PTR 44[ebp]
2290 xor eax, esi
2291 xor edx, esi
2292 and eax, 0fcfcfcfch
2293 and edx, 0cfcfcfcfh
2294 mov bl, al
2295 mov cl, ah
2296 ror edx, 4
2297 mov ebp, DWORD PTR _des_SPtrans[ebx]
2298 mov bl, dl
2299 xor edi, ebp
2300 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2301 xor edi, ebp
2302 mov cl, dh
2303 shr eax, 16
2304 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2305 xor edi, ebp
2306 mov bl, ah
2307 shr edx, 16
2308 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2309 xor edi, ebp
2310 mov ebp, DWORD PTR 24[esp]
2311 mov cl, dh
2312 and eax, 0ffh
2313 and edx, 0ffh
2314 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2315 xor edi, ebx
2316 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2317 xor edi, ebx
2318 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2319 xor edi, ebx
2320 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2321 xor edi, ebx
2322 ;
2323 ; Round 4
2324 mov eax, DWORD PTR 32[ebp]
2325 xor ebx, ebx
2326 mov edx, DWORD PTR 36[ebp]
2327 xor eax, edi
2328 xor edx, edi
2329 and eax, 0fcfcfcfch
2330 and edx, 0cfcfcfcfh
2331 mov bl, al
2332 mov cl, ah
2333 ror edx, 4
2334 mov ebp, DWORD PTR _des_SPtrans[ebx]
2335 mov bl, dl
2336 xor esi, ebp
2337 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2338 xor esi, ebp
2339 mov cl, dh
2340 shr eax, 16
2341 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2342 xor esi, ebp
2343 mov bl, ah
2344 shr edx, 16
2345 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2346 xor esi, ebp
2347 mov ebp, DWORD PTR 24[esp]
2348 mov cl, dh
2349 and eax, 0ffh
2350 and edx, 0ffh
2351 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2352 xor esi, ebx
2353 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2354 xor esi, ebx
2355 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2356 xor esi, ebx
2357 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2358 xor esi, ebx
2359 ;
2360 ; Round 3
2361 mov eax, DWORD PTR 24[ebp]
2362 xor ebx, ebx
2363 mov edx, DWORD PTR 28[ebp]
2364 xor eax, esi
2365 xor edx, esi
2366 and eax, 0fcfcfcfch
2367 and edx, 0cfcfcfcfh
2368 mov bl, al
2369 mov cl, ah
2370 ror edx, 4
2371 mov ebp, DWORD PTR _des_SPtrans[ebx]
2372 mov bl, dl
2373 xor edi, ebp
2374 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2375 xor edi, ebp
2376 mov cl, dh
2377 shr eax, 16
2378 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2379 xor edi, ebp
2380 mov bl, ah
2381 shr edx, 16
2382 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2383 xor edi, ebp
2384 mov ebp, DWORD PTR 24[esp]
2385 mov cl, dh
2386 and eax, 0ffh
2387 and edx, 0ffh
2388 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2389 xor edi, ebx
2390 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2391 xor edi, ebx
2392 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2393 xor edi, ebx
2394 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2395 xor edi, ebx
2396 ;
2397 ; Round 2
2398 mov eax, DWORD PTR 16[ebp]
2399 xor ebx, ebx
2400 mov edx, DWORD PTR 20[ebp]
2401 xor eax, edi
2402 xor edx, edi
2403 and eax, 0fcfcfcfch
2404 and edx, 0cfcfcfcfh
2405 mov bl, al
2406 mov cl, ah
2407 ror edx, 4
2408 mov ebp, DWORD PTR _des_SPtrans[ebx]
2409 mov bl, dl
2410 xor esi, ebp
2411 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2412 xor esi, ebp
2413 mov cl, dh
2414 shr eax, 16
2415 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2416 xor esi, ebp
2417 mov bl, ah
2418 shr edx, 16
2419 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2420 xor esi, ebp
2421 mov ebp, DWORD PTR 24[esp]
2422 mov cl, dh
2423 and eax, 0ffh
2424 and edx, 0ffh
2425 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2426 xor esi, ebx
2427 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2428 xor esi, ebx
2429 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2430 xor esi, ebx
2431 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2432 xor esi, ebx
2433 ;
2434 ; Round 1
2435 mov eax, DWORD PTR 8[ebp]
2436 xor ebx, ebx
2437 mov edx, DWORD PTR 12[ebp]
2438 xor eax, esi
2439 xor edx, esi
2440 and eax, 0fcfcfcfch
2441 and edx, 0cfcfcfcfh
2442 mov bl, al
2443 mov cl, ah
2444 ror edx, 4
2445 mov ebp, DWORD PTR _des_SPtrans[ebx]
2446 mov bl, dl
2447 xor edi, ebp
2448 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2449 xor edi, ebp
2450 mov cl, dh
2451 shr eax, 16
2452 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2453 xor edi, ebp
2454 mov bl, ah
2455 shr edx, 16
2456 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2457 xor edi, ebp
2458 mov ebp, DWORD PTR 24[esp]
2459 mov cl, dh
2460 and eax, 0ffh
2461 and edx, 0ffh
2462 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2463 xor edi, ebx
2464 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2465 xor edi, ebx
2466 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2467 xor edi, ebx
2468 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2469 xor edi, ebx
2470 ;
2471 ; Round 0
2472 mov eax, DWORD PTR [ebp]
2473 xor ebx, ebx
2474 mov edx, DWORD PTR 4[ebp]
2475 xor eax, edi
2476 xor edx, edi
2477 and eax, 0fcfcfcfch
2478 and edx, 0cfcfcfcfh
2479 mov bl, al
2480 mov cl, ah
2481 ror edx, 4
2482 mov ebp, DWORD PTR _des_SPtrans[ebx]
2483 mov bl, dl
2484 xor esi, ebp
2485 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
2486 xor esi, ebp
2487 mov cl, dh
2488 shr eax, 16
2489 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
2490 xor esi, ebp
2491 mov bl, ah
2492 shr edx, 16
2493 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
2494 xor esi, ebp
2495 mov ebp, DWORD PTR 24[esp]
2496 mov cl, dh
2497 and eax, 0ffh
2498 and edx, 0ffh
2499 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
2500 xor esi, ebx
2501 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
2502 xor esi, ebx
2503 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
2504 xor esi, ebx
2505 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
2506 xor esi, ebx
2507$L003end:
2508 ;
2509 ; Fixup
2510 ror edi, 3
2511 mov eax, DWORD PTR 20[esp]
2512 ror esi, 3
2513 mov DWORD PTR [eax],edi
2514 mov DWORD PTR 4[eax],esi
2515 pop ebp
2516 pop ebx
2517 pop edi
2518 pop esi
2519 ret
2520_des_encrypt2 ENDP
2521_TEXT ENDS
2522_TEXT SEGMENT
2523PUBLIC _des_encrypt3
2524
2525_des_encrypt3 PROC NEAR
2526 push ebx
2527 mov ebx, DWORD PTR 8[esp]
2528 push ebp
2529 push esi
2530 push edi
2531 ;
2532 ; Load the data words
2533 mov edi, DWORD PTR [ebx]
2534 mov esi, DWORD PTR 4[ebx]
2535 sub esp, 12
2536 ;
2537 ; IP
2538 rol edi, 4
2539 mov edx, edi
2540 xor edi, esi
2541 and edi, 0f0f0f0f0h
2542 xor edx, edi
2543 xor esi, edi
2544 ;
2545 rol esi, 20
2546 mov edi, esi
2547 xor esi, edx
2548 and esi, 0fff0000fh
2549 xor edi, esi
2550 xor edx, esi
2551 ;
2552 rol edi, 14
2553 mov esi, edi
2554 xor edi, edx
2555 and edi, 033333333h
2556 xor esi, edi
2557 xor edx, edi
2558 ;
2559 rol edx, 22
2560 mov edi, edx
2561 xor edx, esi
2562 and edx, 003fc03fch
2563 xor edi, edx
2564 xor esi, edx
2565 ;
2566 rol edi, 9
2567 mov edx, edi
2568 xor edi, esi
2569 and edi, 0aaaaaaaah
2570 xor edx, edi
2571 xor esi, edi
2572 ;
2573 ror edx, 3
2574 ror esi, 2
2575 mov DWORD PTR 4[ebx],esi
2576 mov eax, DWORD PTR 36[esp]
2577 mov DWORD PTR [ebx],edx
2578 mov edi, DWORD PTR 40[esp]
2579 mov esi, DWORD PTR 44[esp]
2580 mov DWORD PTR 8[esp],1
2581 mov DWORD PTR 4[esp],eax
2582 mov DWORD PTR [esp],ebx
2583 call _des_encrypt2
2584 mov DWORD PTR 8[esp],0
2585 mov DWORD PTR 4[esp],edi
2586 mov DWORD PTR [esp],ebx
2587 call _des_encrypt2
2588 mov DWORD PTR 8[esp],1
2589 mov DWORD PTR 4[esp],esi
2590 mov DWORD PTR [esp],ebx
2591 call _des_encrypt2
2592 add esp, 12
2593 mov edi, DWORD PTR [ebx]
2594 mov esi, DWORD PTR 4[ebx]
2595 ;
2596 ; FP
2597 rol esi, 2
2598 rol edi, 3
2599 mov eax, edi
2600 xor edi, esi
2601 and edi, 0aaaaaaaah
2602 xor eax, edi
2603 xor esi, edi
2604 ;
2605 rol eax, 23
2606 mov edi, eax
2607 xor eax, esi
2608 and eax, 003fc03fch
2609 xor edi, eax
2610 xor esi, eax
2611 ;
2612 rol edi, 10
2613 mov eax, edi
2614 xor edi, esi
2615 and edi, 033333333h
2616 xor eax, edi
2617 xor esi, edi
2618 ;
2619 rol esi, 18
2620 mov edi, esi
2621 xor esi, eax
2622 and esi, 0fff0000fh
2623 xor edi, esi
2624 xor eax, esi
2625 ;
2626 rol edi, 12
2627 mov esi, edi
2628 xor edi, eax
2629 and edi, 0f0f0f0f0h
2630 xor esi, edi
2631 xor eax, edi
2632 ;
2633 ror eax, 4
2634 mov DWORD PTR [ebx],eax
2635 mov DWORD PTR 4[ebx],esi
2636 pop edi
2637 pop esi
2638 pop ebp
2639 pop ebx
2640 ret
2641_des_encrypt3 ENDP
2642_TEXT ENDS
2643_TEXT SEGMENT
2644PUBLIC _des_decrypt3
2645
2646_des_decrypt3 PROC NEAR
2647 push ebx
2648 mov ebx, DWORD PTR 8[esp]
2649 push ebp
2650 push esi
2651 push edi
2652 ;
2653 ; Load the data words
2654 mov edi, DWORD PTR [ebx]
2655 mov esi, DWORD PTR 4[ebx]
2656 sub esp, 12
2657 ;
2658 ; IP
2659 rol edi, 4
2660 mov edx, edi
2661 xor edi, esi
2662 and edi, 0f0f0f0f0h
2663 xor edx, edi
2664 xor esi, edi
2665 ;
2666 rol esi, 20
2667 mov edi, esi
2668 xor esi, edx
2669 and esi, 0fff0000fh
2670 xor edi, esi
2671 xor edx, esi
2672 ;
2673 rol edi, 14
2674 mov esi, edi
2675 xor edi, edx
2676 and edi, 033333333h
2677 xor esi, edi
2678 xor edx, edi
2679 ;
2680 rol edx, 22
2681 mov edi, edx
2682 xor edx, esi
2683 and edx, 003fc03fch
2684 xor edi, edx
2685 xor esi, edx
2686 ;
2687 rol edi, 9
2688 mov edx, edi
2689 xor edi, esi
2690 and edi, 0aaaaaaaah
2691 xor edx, edi
2692 xor esi, edi
2693 ;
2694 ror edx, 3
2695 ror esi, 2
2696 mov DWORD PTR 4[ebx],esi
2697 mov esi, DWORD PTR 36[esp]
2698 mov DWORD PTR [ebx],edx
2699 mov edi, DWORD PTR 40[esp]
2700 mov eax, DWORD PTR 44[esp]
2701 mov DWORD PTR 8[esp],0
2702 mov DWORD PTR 4[esp],eax
2703 mov DWORD PTR [esp],ebx
2704 call _des_encrypt2
2705 mov DWORD PTR 8[esp],1
2706 mov DWORD PTR 4[esp],edi
2707 mov DWORD PTR [esp],ebx
2708 call _des_encrypt2
2709 mov DWORD PTR 8[esp],0
2710 mov DWORD PTR 4[esp],esi
2711 mov DWORD PTR [esp],ebx
2712 call _des_encrypt2
2713 add esp, 12
2714 mov edi, DWORD PTR [ebx]
2715 mov esi, DWORD PTR 4[ebx]
2716 ;
2717 ; FP
2718 rol esi, 2
2719 rol edi, 3
2720 mov eax, edi
2721 xor edi, esi
2722 and edi, 0aaaaaaaah
2723 xor eax, edi
2724 xor esi, edi
2725 ;
2726 rol eax, 23
2727 mov edi, eax
2728 xor eax, esi
2729 and eax, 003fc03fch
2730 xor edi, eax
2731 xor esi, eax
2732 ;
2733 rol edi, 10
2734 mov eax, edi
2735 xor edi, esi
2736 and edi, 033333333h
2737 xor eax, edi
2738 xor esi, edi
2739 ;
2740 rol esi, 18
2741 mov edi, esi
2742 xor esi, eax
2743 and esi, 0fff0000fh
2744 xor edi, esi
2745 xor eax, esi
2746 ;
2747 rol edi, 12
2748 mov esi, edi
2749 xor edi, eax
2750 and edi, 0f0f0f0f0h
2751 xor esi, edi
2752 xor eax, edi
2753 ;
2754 ror eax, 4
2755 mov DWORD PTR [ebx],eax
2756 mov DWORD PTR 4[ebx],esi
2757 pop edi
2758 pop esi
2759 pop ebp
2760 pop ebx
2761 ret
2762_des_decrypt3 ENDP
2763_TEXT ENDS
2764_TEXT SEGMENT
2765PUBLIC _des_ncbc_encrypt
2766
2767_des_ncbc_encrypt PROC NEAR
2768 ;
2769 push ebp
2770 push ebx
2771 push esi
2772 push edi
2773 mov ebp, DWORD PTR 28[esp]
2774 ; getting iv ptr from parameter 4
2775 mov ebx, DWORD PTR 36[esp]
2776 mov esi, DWORD PTR [ebx]
2777 mov edi, DWORD PTR 4[ebx]
2778 push edi
2779 push esi
2780 push edi
2781 push esi
2782 mov ebx, esp
2783 mov esi, DWORD PTR 36[esp]
2784 mov edi, DWORD PTR 40[esp]
2785 ; getting encrypt flag from parameter 5
2786 mov ecx, DWORD PTR 56[esp]
2787 ; get and push parameter 5
2788 push ecx
2789 ; get and push parameter 3
2790 mov eax, DWORD PTR 52[esp]
2791 push eax
2792 push ebx
2793 cmp ecx, 0
2794 jz $L004decrypt
2795 and ebp, 4294967288
2796 mov eax, DWORD PTR 12[esp]
2797 mov ebx, DWORD PTR 16[esp]
2798 jz $L005encrypt_finish
2799L006encrypt_loop:
2800 mov ecx, DWORD PTR [esi]
2801 mov edx, DWORD PTR 4[esi]
2802 xor eax, ecx
2803 xor ebx, edx
2804 mov DWORD PTR 12[esp],eax
2805 mov DWORD PTR 16[esp],ebx
2806 call _des_encrypt
2807 mov eax, DWORD PTR 12[esp]
2808 mov ebx, DWORD PTR 16[esp]
2809 mov DWORD PTR [edi],eax
2810 mov DWORD PTR 4[edi],ebx
2811 add esi, 8
2812 add edi, 8
2813 sub ebp, 8
2814 jnz L006encrypt_loop
2815$L005encrypt_finish:
2816 mov ebp, DWORD PTR 56[esp]
2817 and ebp, 7
2818 jz $L007finish
2819 xor ecx, ecx
2820 xor edx, edx
2821 mov ebp, DWORD PTR $L008cbc_enc_jmp_table[ebp*4]
2822 jmp ebp
2823L009ej7:
2824 mov dh, BYTE PTR 6[esi]
2825 shl edx, 8
2826L010ej6:
2827 mov dh, BYTE PTR 5[esi]
2828L011ej5:
2829 mov dl, BYTE PTR 4[esi]
2830L012ej4:
2831 mov ecx, DWORD PTR [esi]
2832 jmp $L013ejend
2833L014ej3:
2834 mov ch, BYTE PTR 2[esi]
2835 shl ecx, 8
2836L015ej2:
2837 mov ch, BYTE PTR 1[esi]
2838L016ej1:
2839 mov cl, BYTE PTR [esi]
2840$L013ejend:
2841 xor eax, ecx
2842 xor ebx, edx
2843 mov DWORD PTR 12[esp],eax
2844 mov DWORD PTR 16[esp],ebx
2845 call _des_encrypt
2846 mov eax, DWORD PTR 12[esp]
2847 mov ebx, DWORD PTR 16[esp]
2848 mov DWORD PTR [edi],eax
2849 mov DWORD PTR 4[edi],ebx
2850 jmp $L007finish
2851$L004decrypt:
2852 and ebp, 4294967288
2853 mov eax, DWORD PTR 20[esp]
2854 mov ebx, DWORD PTR 24[esp]
2855 jz $L017decrypt_finish
2856L018decrypt_loop:
2857 mov eax, DWORD PTR [esi]
2858 mov ebx, DWORD PTR 4[esi]
2859 mov DWORD PTR 12[esp],eax
2860 mov DWORD PTR 16[esp],ebx
2861 call _des_encrypt
2862 mov eax, DWORD PTR 12[esp]
2863 mov ebx, DWORD PTR 16[esp]
2864 mov ecx, DWORD PTR 20[esp]
2865 mov edx, DWORD PTR 24[esp]
2866 xor ecx, eax
2867 xor edx, ebx
2868 mov eax, DWORD PTR [esi]
2869 mov ebx, DWORD PTR 4[esi]
2870 mov DWORD PTR [edi],ecx
2871 mov DWORD PTR 4[edi],edx
2872 mov DWORD PTR 20[esp],eax
2873 mov DWORD PTR 24[esp],ebx
2874 add esi, 8
2875 add edi, 8
2876 sub ebp, 8
2877 jnz L018decrypt_loop
2878$L017decrypt_finish:
2879 mov ebp, DWORD PTR 56[esp]
2880 and ebp, 7
2881 jz $L007finish
2882 mov eax, DWORD PTR [esi]
2883 mov ebx, DWORD PTR 4[esi]
2884 mov DWORD PTR 12[esp],eax
2885 mov DWORD PTR 16[esp],ebx
2886 call _des_encrypt
2887 mov eax, DWORD PTR 12[esp]
2888 mov ebx, DWORD PTR 16[esp]
2889 mov ecx, DWORD PTR 20[esp]
2890 mov edx, DWORD PTR 24[esp]
2891 xor ecx, eax
2892 xor edx, ebx
2893 mov eax, DWORD PTR [esi]
2894 mov ebx, DWORD PTR 4[esi]
2895L019dj7:
2896 ror edx, 16
2897 mov BYTE PTR 6[edi],dl
2898 shr edx, 16
2899L020dj6:
2900 mov BYTE PTR 5[edi],dh
2901L021dj5:
2902 mov BYTE PTR 4[edi],dl
2903L022dj4:
2904 mov DWORD PTR [edi],ecx
2905 jmp $L023djend
2906L024dj3:
2907 ror ecx, 16
2908 mov BYTE PTR 2[edi],cl
2909 shl ecx, 16
2910L025dj2:
2911 mov BYTE PTR 1[esi],ch
2912L026dj1:
2913 mov BYTE PTR [esi], cl
2914$L023djend:
2915 jmp $L007finish
2916$L007finish:
2917 mov ecx, DWORD PTR 64[esp]
2918 add esp, 28
2919 mov DWORD PTR [ecx],eax
2920 mov DWORD PTR 4[ecx],ebx
2921 pop edi
2922 pop esi
2923 pop ebx
2924 pop ebp
2925 ret
2926$L008cbc_enc_jmp_table:
2927 DD 0
2928 DD L016ej1
2929 DD L015ej2
2930 DD L014ej3
2931 DD L012ej4
2932 DD L011ej5
2933 DD L010ej6
2934 DD L009ej7
2935L027cbc_dec_jmp_table:
2936 DD 0
2937 DD L026dj1
2938 DD L025dj2
2939 DD L024dj3
2940 DD L022dj4
2941 DD L021dj5
2942 DD L020dj6
2943 DD L019dj7
2944_des_ncbc_encrypt ENDP
2945_TEXT ENDS
2946_TEXT SEGMENT
2947PUBLIC _des_ede3_cbc_encrypt
2948
2949_des_ede3_cbc_encrypt PROC NEAR
2950 ;
2951 push ebp
2952 push ebx
2953 push esi
2954 push edi
2955 mov ebp, DWORD PTR 28[esp]
2956 ; getting iv ptr from parameter 6
2957 mov ebx, DWORD PTR 44[esp]
2958 mov esi, DWORD PTR [ebx]
2959 mov edi, DWORD PTR 4[ebx]
2960 push edi
2961 push esi
2962 push edi
2963 push esi
2964 mov ebx, esp
2965 mov esi, DWORD PTR 36[esp]
2966 mov edi, DWORD PTR 40[esp]
2967 ; getting encrypt flag from parameter 7
2968 mov ecx, DWORD PTR 64[esp]
2969 ; get and push parameter 5
2970 mov eax, DWORD PTR 56[esp]
2971 push eax
2972 ; get and push parameter 4
2973 mov eax, DWORD PTR 56[esp]
2974 push eax
2975 ; get and push parameter 3
2976 mov eax, DWORD PTR 56[esp]
2977 push eax
2978 push ebx
2979 cmp ecx, 0
2980 jz $L028decrypt
2981 and ebp, 4294967288
2982 mov eax, DWORD PTR 16[esp]
2983 mov ebx, DWORD PTR 20[esp]
2984 jz $L029encrypt_finish
2985L030encrypt_loop:
2986 mov ecx, DWORD PTR [esi]
2987 mov edx, DWORD PTR 4[esi]
2988 xor eax, ecx
2989 xor ebx, edx
2990 mov DWORD PTR 16[esp],eax
2991 mov DWORD PTR 20[esp],ebx
2992 call _des_encrypt3
2993 mov eax, DWORD PTR 16[esp]
2994 mov ebx, DWORD PTR 20[esp]
2995 mov DWORD PTR [edi],eax
2996 mov DWORD PTR 4[edi],ebx
2997 add esi, 8
2998 add edi, 8
2999 sub ebp, 8
3000 jnz L030encrypt_loop
3001$L029encrypt_finish:
3002 mov ebp, DWORD PTR 60[esp]
3003 and ebp, 7
3004 jz $L031finish
3005 xor ecx, ecx
3006 xor edx, edx
3007 mov ebp, DWORD PTR $L032cbc_enc_jmp_table[ebp*4]
3008 jmp ebp
3009L033ej7:
3010 mov dh, BYTE PTR 6[esi]
3011 shl edx, 8
3012L034ej6:
3013 mov dh, BYTE PTR 5[esi]
3014L035ej5:
3015 mov dl, BYTE PTR 4[esi]
3016L036ej4:
3017 mov ecx, DWORD PTR [esi]
3018 jmp $L037ejend
3019L038ej3:
3020 mov ch, BYTE PTR 2[esi]
3021 shl ecx, 8
3022L039ej2:
3023 mov ch, BYTE PTR 1[esi]
3024L040ej1:
3025 mov cl, BYTE PTR [esi]
3026$L037ejend:
3027 xor eax, ecx
3028 xor ebx, edx
3029 mov DWORD PTR 16[esp],eax
3030 mov DWORD PTR 20[esp],ebx
3031 call _des_encrypt3
3032 mov eax, DWORD PTR 16[esp]
3033 mov ebx, DWORD PTR 20[esp]
3034 mov DWORD PTR [edi],eax
3035 mov DWORD PTR 4[edi],ebx
3036 jmp $L031finish
3037$L028decrypt:
3038 and ebp, 4294967288
3039 mov eax, DWORD PTR 24[esp]
3040 mov ebx, DWORD PTR 28[esp]
3041 jz $L041decrypt_finish
3042L042decrypt_loop:
3043 mov eax, DWORD PTR [esi]
3044 mov ebx, DWORD PTR 4[esi]
3045 mov DWORD PTR 16[esp],eax
3046 mov DWORD PTR 20[esp],ebx
3047 call _des_decrypt3
3048 mov eax, DWORD PTR 16[esp]
3049 mov ebx, DWORD PTR 20[esp]
3050 mov ecx, DWORD PTR 24[esp]
3051 mov edx, DWORD PTR 28[esp]
3052 xor ecx, eax
3053 xor edx, ebx
3054 mov eax, DWORD PTR [esi]
3055 mov ebx, DWORD PTR 4[esi]
3056 mov DWORD PTR [edi],ecx
3057 mov DWORD PTR 4[edi],edx
3058 mov DWORD PTR 24[esp],eax
3059 mov DWORD PTR 28[esp],ebx
3060 add esi, 8
3061 add edi, 8
3062 sub ebp, 8
3063 jnz L042decrypt_loop
3064$L041decrypt_finish:
3065 mov ebp, DWORD PTR 60[esp]
3066 and ebp, 7
3067 jz $L031finish
3068 mov eax, DWORD PTR [esi]
3069 mov ebx, DWORD PTR 4[esi]
3070 mov DWORD PTR 16[esp],eax
3071 mov DWORD PTR 20[esp],ebx
3072 call _des_decrypt3
3073 mov eax, DWORD PTR 16[esp]
3074 mov ebx, DWORD PTR 20[esp]
3075 mov ecx, DWORD PTR 24[esp]
3076 mov edx, DWORD PTR 28[esp]
3077 xor ecx, eax
3078 xor edx, ebx
3079 mov eax, DWORD PTR [esi]
3080 mov ebx, DWORD PTR 4[esi]
3081L043dj7:
3082 ror edx, 16
3083 mov BYTE PTR 6[edi],dl
3084 shr edx, 16
3085L044dj6:
3086 mov BYTE PTR 5[edi],dh
3087L045dj5:
3088 mov BYTE PTR 4[edi],dl
3089L046dj4:
3090 mov DWORD PTR [edi],ecx
3091 jmp $L047djend
3092L048dj3:
3093 ror ecx, 16
3094 mov BYTE PTR 2[edi],cl
3095 shl ecx, 16
3096L049dj2:
3097 mov BYTE PTR 1[esi],ch
3098L050dj1:
3099 mov BYTE PTR [esi], cl
3100$L047djend:
3101 jmp $L031finish
3102$L031finish:
3103 mov ecx, DWORD PTR 76[esp]
3104 add esp, 32
3105 mov DWORD PTR [ecx],eax
3106 mov DWORD PTR 4[ecx],ebx
3107 pop edi
3108 pop esi
3109 pop ebx
3110 pop ebp
3111 ret
3112$L032cbc_enc_jmp_table:
3113 DD 0
3114 DD L040ej1
3115 DD L039ej2
3116 DD L038ej3
3117 DD L036ej4
3118 DD L035ej5
3119 DD L034ej6
3120 DD L033ej7
3121L051cbc_dec_jmp_table:
3122 DD 0
3123 DD L050dj1
3124 DD L049dj2
3125 DD L048dj3
3126 DD L046dj4
3127 DD L045dj5
3128 DD L044dj6
3129 DD L043dj7
3130_des_ede3_cbc_encrypt ENDP
3131_TEXT ENDS
3132END
diff --git a/src/lib/libssl/src/crypto/des/asm/dx86unix.cpp b/src/lib/libssl/src/crypto/des/asm/dx86unix.cpp
new file mode 100644
index 0000000000..6fca9afa16
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/asm/dx86unix.cpp
@@ -0,0 +1,3202 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define des_SPtrans _des_SPtrans
13#define des_encrypt _des_encrypt
14#define des_encrypt2 _des_encrypt2
15#define des_encrypt3 _des_encrypt3
16#define des_decrypt3 _des_decrypt3
17#define des_ncbc_encrypt _des_ncbc_encrypt
18#define des_ede3_cbc_encrypt _des_ede3_cbc_encrypt
19
20#endif
21
22#ifdef OUT
23#define OK 1
24#define ALIGN 4
25#endif
26
27#ifdef BSDI
28#define OK 1
29#define ALIGN 4
30#undef SIZE
31#undef TYPE
32#define SIZE(a,b)
33#define TYPE(a,b)
34#endif
35
36#if defined(ELF) || defined(SOL)
37#define OK 1
38#define ALIGN 16
39#endif
40
41#ifndef OK
42You need to define one of
43ELF - elf systems - linux-elf, NetBSD and DG-UX
44OUT - a.out systems - linux-a.out and FreeBSD
45SOL - solaris systems, which are elf with strange comment lines
46BSDI - a.out with a very primative version of as.
47#endif
48
49/* Let the Assembler begin :-) */
50 /* Don't even think of reading this code */
51 /* It was automatically generated by des-586.pl */
52 /* Which is a perl program used to generate the x86 assember for */
53 /* any of elf, a.out, BSDI,Win32, or Solaris */
54 /* eric <eay@cryptsoft.com> */
55
56 .file "des-586.s"
57 .version "01.01"
58gcc2_compiled.:
59.text
60 .align ALIGN
61.globl des_encrypt
62 TYPE(des_encrypt,@function)
63des_encrypt:
64 pushl %esi
65 pushl %edi
66
67 /* Load the 2 words */
68 movl 12(%esp), %esi
69 xorl %ecx, %ecx
70 pushl %ebx
71 pushl %ebp
72 movl (%esi), %eax
73 movl 28(%esp), %ebx
74 movl 4(%esi), %edi
75
76 /* IP */
77 roll $4, %eax
78 movl %eax, %esi
79 xorl %edi, %eax
80 andl $0xf0f0f0f0, %eax
81 xorl %eax, %esi
82 xorl %eax, %edi
83
84 roll $20, %edi
85 movl %edi, %eax
86 xorl %esi, %edi
87 andl $0xfff0000f, %edi
88 xorl %edi, %eax
89 xorl %edi, %esi
90
91 roll $14, %eax
92 movl %eax, %edi
93 xorl %esi, %eax
94 andl $0x33333333, %eax
95 xorl %eax, %edi
96 xorl %eax, %esi
97
98 roll $22, %esi
99 movl %esi, %eax
100 xorl %edi, %esi
101 andl $0x03fc03fc, %esi
102 xorl %esi, %eax
103 xorl %esi, %edi
104
105 roll $9, %eax
106 movl %eax, %esi
107 xorl %edi, %eax
108 andl $0xaaaaaaaa, %eax
109 xorl %eax, %esi
110 xorl %eax, %edi
111
112.byte 209
113.byte 199 /* roll $1 %edi */
114 movl 24(%esp), %ebp
115 cmpl $0, %ebx
116 je .L000start_decrypt
117
118 /* Round 0 */
119 movl (%ebp), %eax
120 xorl %ebx, %ebx
121 movl 4(%ebp), %edx
122 xorl %esi, %eax
123 xorl %esi, %edx
124 andl $0xfcfcfcfc, %eax
125 andl $0xcfcfcfcf, %edx
126 movb %al, %bl
127 movb %ah, %cl
128 rorl $4, %edx
129 movl des_SPtrans(%ebx),%ebp
130 movb %dl, %bl
131 xorl %ebp, %edi
132 movl 0x200+des_SPtrans(%ecx),%ebp
133 xorl %ebp, %edi
134 movb %dh, %cl
135 shrl $16, %eax
136 movl 0x100+des_SPtrans(%ebx),%ebp
137 xorl %ebp, %edi
138 movb %ah, %bl
139 shrl $16, %edx
140 movl 0x300+des_SPtrans(%ecx),%ebp
141 xorl %ebp, %edi
142 movl 24(%esp), %ebp
143 movb %dh, %cl
144 andl $0xff, %eax
145 andl $0xff, %edx
146 movl 0x600+des_SPtrans(%ebx),%ebx
147 xorl %ebx, %edi
148 movl 0x700+des_SPtrans(%ecx),%ebx
149 xorl %ebx, %edi
150 movl 0x400+des_SPtrans(%eax),%ebx
151 xorl %ebx, %edi
152 movl 0x500+des_SPtrans(%edx),%ebx
153 xorl %ebx, %edi
154
155 /* Round 1 */
156 movl 8(%ebp), %eax
157 xorl %ebx, %ebx
158 movl 12(%ebp), %edx
159 xorl %edi, %eax
160 xorl %edi, %edx
161 andl $0xfcfcfcfc, %eax
162 andl $0xcfcfcfcf, %edx
163 movb %al, %bl
164 movb %ah, %cl
165 rorl $4, %edx
166 movl des_SPtrans(%ebx),%ebp
167 movb %dl, %bl
168 xorl %ebp, %esi
169 movl 0x200+des_SPtrans(%ecx),%ebp
170 xorl %ebp, %esi
171 movb %dh, %cl
172 shrl $16, %eax
173 movl 0x100+des_SPtrans(%ebx),%ebp
174 xorl %ebp, %esi
175 movb %ah, %bl
176 shrl $16, %edx
177 movl 0x300+des_SPtrans(%ecx),%ebp
178 xorl %ebp, %esi
179 movl 24(%esp), %ebp
180 movb %dh, %cl
181 andl $0xff, %eax
182 andl $0xff, %edx
183 movl 0x600+des_SPtrans(%ebx),%ebx
184 xorl %ebx, %esi
185 movl 0x700+des_SPtrans(%ecx),%ebx
186 xorl %ebx, %esi
187 movl 0x400+des_SPtrans(%eax),%ebx
188 xorl %ebx, %esi
189 movl 0x500+des_SPtrans(%edx),%ebx
190 xorl %ebx, %esi
191
192 /* Round 2 */
193 movl 16(%ebp), %eax
194 xorl %ebx, %ebx
195 movl 20(%ebp), %edx
196 xorl %esi, %eax
197 xorl %esi, %edx
198 andl $0xfcfcfcfc, %eax
199 andl $0xcfcfcfcf, %edx
200 movb %al, %bl
201 movb %ah, %cl
202 rorl $4, %edx
203 movl des_SPtrans(%ebx),%ebp
204 movb %dl, %bl
205 xorl %ebp, %edi
206 movl 0x200+des_SPtrans(%ecx),%ebp
207 xorl %ebp, %edi
208 movb %dh, %cl
209 shrl $16, %eax
210 movl 0x100+des_SPtrans(%ebx),%ebp
211 xorl %ebp, %edi
212 movb %ah, %bl
213 shrl $16, %edx
214 movl 0x300+des_SPtrans(%ecx),%ebp
215 xorl %ebp, %edi
216 movl 24(%esp), %ebp
217 movb %dh, %cl
218 andl $0xff, %eax
219 andl $0xff, %edx
220 movl 0x600+des_SPtrans(%ebx),%ebx
221 xorl %ebx, %edi
222 movl 0x700+des_SPtrans(%ecx),%ebx
223 xorl %ebx, %edi
224 movl 0x400+des_SPtrans(%eax),%ebx
225 xorl %ebx, %edi
226 movl 0x500+des_SPtrans(%edx),%ebx
227 xorl %ebx, %edi
228
229 /* Round 3 */
230 movl 24(%ebp), %eax
231 xorl %ebx, %ebx
232 movl 28(%ebp), %edx
233 xorl %edi, %eax
234 xorl %edi, %edx
235 andl $0xfcfcfcfc, %eax
236 andl $0xcfcfcfcf, %edx
237 movb %al, %bl
238 movb %ah, %cl
239 rorl $4, %edx
240 movl des_SPtrans(%ebx),%ebp
241 movb %dl, %bl
242 xorl %ebp, %esi
243 movl 0x200+des_SPtrans(%ecx),%ebp
244 xorl %ebp, %esi
245 movb %dh, %cl
246 shrl $16, %eax
247 movl 0x100+des_SPtrans(%ebx),%ebp
248 xorl %ebp, %esi
249 movb %ah, %bl
250 shrl $16, %edx
251 movl 0x300+des_SPtrans(%ecx),%ebp
252 xorl %ebp, %esi
253 movl 24(%esp), %ebp
254 movb %dh, %cl
255 andl $0xff, %eax
256 andl $0xff, %edx
257 movl 0x600+des_SPtrans(%ebx),%ebx
258 xorl %ebx, %esi
259 movl 0x700+des_SPtrans(%ecx),%ebx
260 xorl %ebx, %esi
261 movl 0x400+des_SPtrans(%eax),%ebx
262 xorl %ebx, %esi
263 movl 0x500+des_SPtrans(%edx),%ebx
264 xorl %ebx, %esi
265
266 /* Round 4 */
267 movl 32(%ebp), %eax
268 xorl %ebx, %ebx
269 movl 36(%ebp), %edx
270 xorl %esi, %eax
271 xorl %esi, %edx
272 andl $0xfcfcfcfc, %eax
273 andl $0xcfcfcfcf, %edx
274 movb %al, %bl
275 movb %ah, %cl
276 rorl $4, %edx
277 movl des_SPtrans(%ebx),%ebp
278 movb %dl, %bl
279 xorl %ebp, %edi
280 movl 0x200+des_SPtrans(%ecx),%ebp
281 xorl %ebp, %edi
282 movb %dh, %cl
283 shrl $16, %eax
284 movl 0x100+des_SPtrans(%ebx),%ebp
285 xorl %ebp, %edi
286 movb %ah, %bl
287 shrl $16, %edx
288 movl 0x300+des_SPtrans(%ecx),%ebp
289 xorl %ebp, %edi
290 movl 24(%esp), %ebp
291 movb %dh, %cl
292 andl $0xff, %eax
293 andl $0xff, %edx
294 movl 0x600+des_SPtrans(%ebx),%ebx
295 xorl %ebx, %edi
296 movl 0x700+des_SPtrans(%ecx),%ebx
297 xorl %ebx, %edi
298 movl 0x400+des_SPtrans(%eax),%ebx
299 xorl %ebx, %edi
300 movl 0x500+des_SPtrans(%edx),%ebx
301 xorl %ebx, %edi
302
303 /* Round 5 */
304 movl 40(%ebp), %eax
305 xorl %ebx, %ebx
306 movl 44(%ebp), %edx
307 xorl %edi, %eax
308 xorl %edi, %edx
309 andl $0xfcfcfcfc, %eax
310 andl $0xcfcfcfcf, %edx
311 movb %al, %bl
312 movb %ah, %cl
313 rorl $4, %edx
314 movl des_SPtrans(%ebx),%ebp
315 movb %dl, %bl
316 xorl %ebp, %esi
317 movl 0x200+des_SPtrans(%ecx),%ebp
318 xorl %ebp, %esi
319 movb %dh, %cl
320 shrl $16, %eax
321 movl 0x100+des_SPtrans(%ebx),%ebp
322 xorl %ebp, %esi
323 movb %ah, %bl
324 shrl $16, %edx
325 movl 0x300+des_SPtrans(%ecx),%ebp
326 xorl %ebp, %esi
327 movl 24(%esp), %ebp
328 movb %dh, %cl
329 andl $0xff, %eax
330 andl $0xff, %edx
331 movl 0x600+des_SPtrans(%ebx),%ebx
332 xorl %ebx, %esi
333 movl 0x700+des_SPtrans(%ecx),%ebx
334 xorl %ebx, %esi
335 movl 0x400+des_SPtrans(%eax),%ebx
336 xorl %ebx, %esi
337 movl 0x500+des_SPtrans(%edx),%ebx
338 xorl %ebx, %esi
339
340 /* Round 6 */
341 movl 48(%ebp), %eax
342 xorl %ebx, %ebx
343 movl 52(%ebp), %edx
344 xorl %esi, %eax
345 xorl %esi, %edx
346 andl $0xfcfcfcfc, %eax
347 andl $0xcfcfcfcf, %edx
348 movb %al, %bl
349 movb %ah, %cl
350 rorl $4, %edx
351 movl des_SPtrans(%ebx),%ebp
352 movb %dl, %bl
353 xorl %ebp, %edi
354 movl 0x200+des_SPtrans(%ecx),%ebp
355 xorl %ebp, %edi
356 movb %dh, %cl
357 shrl $16, %eax
358 movl 0x100+des_SPtrans(%ebx),%ebp
359 xorl %ebp, %edi
360 movb %ah, %bl
361 shrl $16, %edx
362 movl 0x300+des_SPtrans(%ecx),%ebp
363 xorl %ebp, %edi
364 movl 24(%esp), %ebp
365 movb %dh, %cl
366 andl $0xff, %eax
367 andl $0xff, %edx
368 movl 0x600+des_SPtrans(%ebx),%ebx
369 xorl %ebx, %edi
370 movl 0x700+des_SPtrans(%ecx),%ebx
371 xorl %ebx, %edi
372 movl 0x400+des_SPtrans(%eax),%ebx
373 xorl %ebx, %edi
374 movl 0x500+des_SPtrans(%edx),%ebx
375 xorl %ebx, %edi
376
377 /* Round 7 */
378 movl 56(%ebp), %eax
379 xorl %ebx, %ebx
380 movl 60(%ebp), %edx
381 xorl %edi, %eax
382 xorl %edi, %edx
383 andl $0xfcfcfcfc, %eax
384 andl $0xcfcfcfcf, %edx
385 movb %al, %bl
386 movb %ah, %cl
387 rorl $4, %edx
388 movl des_SPtrans(%ebx),%ebp
389 movb %dl, %bl
390 xorl %ebp, %esi
391 movl 0x200+des_SPtrans(%ecx),%ebp
392 xorl %ebp, %esi
393 movb %dh, %cl
394 shrl $16, %eax
395 movl 0x100+des_SPtrans(%ebx),%ebp
396 xorl %ebp, %esi
397 movb %ah, %bl
398 shrl $16, %edx
399 movl 0x300+des_SPtrans(%ecx),%ebp
400 xorl %ebp, %esi
401 movl 24(%esp), %ebp
402 movb %dh, %cl
403 andl $0xff, %eax
404 andl $0xff, %edx
405 movl 0x600+des_SPtrans(%ebx),%ebx
406 xorl %ebx, %esi
407 movl 0x700+des_SPtrans(%ecx),%ebx
408 xorl %ebx, %esi
409 movl 0x400+des_SPtrans(%eax),%ebx
410 xorl %ebx, %esi
411 movl 0x500+des_SPtrans(%edx),%ebx
412 xorl %ebx, %esi
413
414 /* Round 8 */
415 movl 64(%ebp), %eax
416 xorl %ebx, %ebx
417 movl 68(%ebp), %edx
418 xorl %esi, %eax
419 xorl %esi, %edx
420 andl $0xfcfcfcfc, %eax
421 andl $0xcfcfcfcf, %edx
422 movb %al, %bl
423 movb %ah, %cl
424 rorl $4, %edx
425 movl des_SPtrans(%ebx),%ebp
426 movb %dl, %bl
427 xorl %ebp, %edi
428 movl 0x200+des_SPtrans(%ecx),%ebp
429 xorl %ebp, %edi
430 movb %dh, %cl
431 shrl $16, %eax
432 movl 0x100+des_SPtrans(%ebx),%ebp
433 xorl %ebp, %edi
434 movb %ah, %bl
435 shrl $16, %edx
436 movl 0x300+des_SPtrans(%ecx),%ebp
437 xorl %ebp, %edi
438 movl 24(%esp), %ebp
439 movb %dh, %cl
440 andl $0xff, %eax
441 andl $0xff, %edx
442 movl 0x600+des_SPtrans(%ebx),%ebx
443 xorl %ebx, %edi
444 movl 0x700+des_SPtrans(%ecx),%ebx
445 xorl %ebx, %edi
446 movl 0x400+des_SPtrans(%eax),%ebx
447 xorl %ebx, %edi
448 movl 0x500+des_SPtrans(%edx),%ebx
449 xorl %ebx, %edi
450
451 /* Round 9 */
452 movl 72(%ebp), %eax
453 xorl %ebx, %ebx
454 movl 76(%ebp), %edx
455 xorl %edi, %eax
456 xorl %edi, %edx
457 andl $0xfcfcfcfc, %eax
458 andl $0xcfcfcfcf, %edx
459 movb %al, %bl
460 movb %ah, %cl
461 rorl $4, %edx
462 movl des_SPtrans(%ebx),%ebp
463 movb %dl, %bl
464 xorl %ebp, %esi
465 movl 0x200+des_SPtrans(%ecx),%ebp
466 xorl %ebp, %esi
467 movb %dh, %cl
468 shrl $16, %eax
469 movl 0x100+des_SPtrans(%ebx),%ebp
470 xorl %ebp, %esi
471 movb %ah, %bl
472 shrl $16, %edx
473 movl 0x300+des_SPtrans(%ecx),%ebp
474 xorl %ebp, %esi
475 movl 24(%esp), %ebp
476 movb %dh, %cl
477 andl $0xff, %eax
478 andl $0xff, %edx
479 movl 0x600+des_SPtrans(%ebx),%ebx
480 xorl %ebx, %esi
481 movl 0x700+des_SPtrans(%ecx),%ebx
482 xorl %ebx, %esi
483 movl 0x400+des_SPtrans(%eax),%ebx
484 xorl %ebx, %esi
485 movl 0x500+des_SPtrans(%edx),%ebx
486 xorl %ebx, %esi
487
488 /* Round 10 */
489 movl 80(%ebp), %eax
490 xorl %ebx, %ebx
491 movl 84(%ebp), %edx
492 xorl %esi, %eax
493 xorl %esi, %edx
494 andl $0xfcfcfcfc, %eax
495 andl $0xcfcfcfcf, %edx
496 movb %al, %bl
497 movb %ah, %cl
498 rorl $4, %edx
499 movl des_SPtrans(%ebx),%ebp
500 movb %dl, %bl
501 xorl %ebp, %edi
502 movl 0x200+des_SPtrans(%ecx),%ebp
503 xorl %ebp, %edi
504 movb %dh, %cl
505 shrl $16, %eax
506 movl 0x100+des_SPtrans(%ebx),%ebp
507 xorl %ebp, %edi
508 movb %ah, %bl
509 shrl $16, %edx
510 movl 0x300+des_SPtrans(%ecx),%ebp
511 xorl %ebp, %edi
512 movl 24(%esp), %ebp
513 movb %dh, %cl
514 andl $0xff, %eax
515 andl $0xff, %edx
516 movl 0x600+des_SPtrans(%ebx),%ebx
517 xorl %ebx, %edi
518 movl 0x700+des_SPtrans(%ecx),%ebx
519 xorl %ebx, %edi
520 movl 0x400+des_SPtrans(%eax),%ebx
521 xorl %ebx, %edi
522 movl 0x500+des_SPtrans(%edx),%ebx
523 xorl %ebx, %edi
524
525 /* Round 11 */
526 movl 88(%ebp), %eax
527 xorl %ebx, %ebx
528 movl 92(%ebp), %edx
529 xorl %edi, %eax
530 xorl %edi, %edx
531 andl $0xfcfcfcfc, %eax
532 andl $0xcfcfcfcf, %edx
533 movb %al, %bl
534 movb %ah, %cl
535 rorl $4, %edx
536 movl des_SPtrans(%ebx),%ebp
537 movb %dl, %bl
538 xorl %ebp, %esi
539 movl 0x200+des_SPtrans(%ecx),%ebp
540 xorl %ebp, %esi
541 movb %dh, %cl
542 shrl $16, %eax
543 movl 0x100+des_SPtrans(%ebx),%ebp
544 xorl %ebp, %esi
545 movb %ah, %bl
546 shrl $16, %edx
547 movl 0x300+des_SPtrans(%ecx),%ebp
548 xorl %ebp, %esi
549 movl 24(%esp), %ebp
550 movb %dh, %cl
551 andl $0xff, %eax
552 andl $0xff, %edx
553 movl 0x600+des_SPtrans(%ebx),%ebx
554 xorl %ebx, %esi
555 movl 0x700+des_SPtrans(%ecx),%ebx
556 xorl %ebx, %esi
557 movl 0x400+des_SPtrans(%eax),%ebx
558 xorl %ebx, %esi
559 movl 0x500+des_SPtrans(%edx),%ebx
560 xorl %ebx, %esi
561
562 /* Round 12 */
563 movl 96(%ebp), %eax
564 xorl %ebx, %ebx
565 movl 100(%ebp), %edx
566 xorl %esi, %eax
567 xorl %esi, %edx
568 andl $0xfcfcfcfc, %eax
569 andl $0xcfcfcfcf, %edx
570 movb %al, %bl
571 movb %ah, %cl
572 rorl $4, %edx
573 movl des_SPtrans(%ebx),%ebp
574 movb %dl, %bl
575 xorl %ebp, %edi
576 movl 0x200+des_SPtrans(%ecx),%ebp
577 xorl %ebp, %edi
578 movb %dh, %cl
579 shrl $16, %eax
580 movl 0x100+des_SPtrans(%ebx),%ebp
581 xorl %ebp, %edi
582 movb %ah, %bl
583 shrl $16, %edx
584 movl 0x300+des_SPtrans(%ecx),%ebp
585 xorl %ebp, %edi
586 movl 24(%esp), %ebp
587 movb %dh, %cl
588 andl $0xff, %eax
589 andl $0xff, %edx
590 movl 0x600+des_SPtrans(%ebx),%ebx
591 xorl %ebx, %edi
592 movl 0x700+des_SPtrans(%ecx),%ebx
593 xorl %ebx, %edi
594 movl 0x400+des_SPtrans(%eax),%ebx
595 xorl %ebx, %edi
596 movl 0x500+des_SPtrans(%edx),%ebx
597 xorl %ebx, %edi
598
599 /* Round 13 */
600 movl 104(%ebp), %eax
601 xorl %ebx, %ebx
602 movl 108(%ebp), %edx
603 xorl %edi, %eax
604 xorl %edi, %edx
605 andl $0xfcfcfcfc, %eax
606 andl $0xcfcfcfcf, %edx
607 movb %al, %bl
608 movb %ah, %cl
609 rorl $4, %edx
610 movl des_SPtrans(%ebx),%ebp
611 movb %dl, %bl
612 xorl %ebp, %esi
613 movl 0x200+des_SPtrans(%ecx),%ebp
614 xorl %ebp, %esi
615 movb %dh, %cl
616 shrl $16, %eax
617 movl 0x100+des_SPtrans(%ebx),%ebp
618 xorl %ebp, %esi
619 movb %ah, %bl
620 shrl $16, %edx
621 movl 0x300+des_SPtrans(%ecx),%ebp
622 xorl %ebp, %esi
623 movl 24(%esp), %ebp
624 movb %dh, %cl
625 andl $0xff, %eax
626 andl $0xff, %edx
627 movl 0x600+des_SPtrans(%ebx),%ebx
628 xorl %ebx, %esi
629 movl 0x700+des_SPtrans(%ecx),%ebx
630 xorl %ebx, %esi
631 movl 0x400+des_SPtrans(%eax),%ebx
632 xorl %ebx, %esi
633 movl 0x500+des_SPtrans(%edx),%ebx
634 xorl %ebx, %esi
635
636 /* Round 14 */
637 movl 112(%ebp), %eax
638 xorl %ebx, %ebx
639 movl 116(%ebp), %edx
640 xorl %esi, %eax
641 xorl %esi, %edx
642 andl $0xfcfcfcfc, %eax
643 andl $0xcfcfcfcf, %edx
644 movb %al, %bl
645 movb %ah, %cl
646 rorl $4, %edx
647 movl des_SPtrans(%ebx),%ebp
648 movb %dl, %bl
649 xorl %ebp, %edi
650 movl 0x200+des_SPtrans(%ecx),%ebp
651 xorl %ebp, %edi
652 movb %dh, %cl
653 shrl $16, %eax
654 movl 0x100+des_SPtrans(%ebx),%ebp
655 xorl %ebp, %edi
656 movb %ah, %bl
657 shrl $16, %edx
658 movl 0x300+des_SPtrans(%ecx),%ebp
659 xorl %ebp, %edi
660 movl 24(%esp), %ebp
661 movb %dh, %cl
662 andl $0xff, %eax
663 andl $0xff, %edx
664 movl 0x600+des_SPtrans(%ebx),%ebx
665 xorl %ebx, %edi
666 movl 0x700+des_SPtrans(%ecx),%ebx
667 xorl %ebx, %edi
668 movl 0x400+des_SPtrans(%eax),%ebx
669 xorl %ebx, %edi
670 movl 0x500+des_SPtrans(%edx),%ebx
671 xorl %ebx, %edi
672
673 /* Round 15 */
674 movl 120(%ebp), %eax
675 xorl %ebx, %ebx
676 movl 124(%ebp), %edx
677 xorl %edi, %eax
678 xorl %edi, %edx
679 andl $0xfcfcfcfc, %eax
680 andl $0xcfcfcfcf, %edx
681 movb %al, %bl
682 movb %ah, %cl
683 rorl $4, %edx
684 movl des_SPtrans(%ebx),%ebp
685 movb %dl, %bl
686 xorl %ebp, %esi
687 movl 0x200+des_SPtrans(%ecx),%ebp
688 xorl %ebp, %esi
689 movb %dh, %cl
690 shrl $16, %eax
691 movl 0x100+des_SPtrans(%ebx),%ebp
692 xorl %ebp, %esi
693 movb %ah, %bl
694 shrl $16, %edx
695 movl 0x300+des_SPtrans(%ecx),%ebp
696 xorl %ebp, %esi
697 movl 24(%esp), %ebp
698 movb %dh, %cl
699 andl $0xff, %eax
700 andl $0xff, %edx
701 movl 0x600+des_SPtrans(%ebx),%ebx
702 xorl %ebx, %esi
703 movl 0x700+des_SPtrans(%ecx),%ebx
704 xorl %ebx, %esi
705 movl 0x400+des_SPtrans(%eax),%ebx
706 xorl %ebx, %esi
707 movl 0x500+des_SPtrans(%edx),%ebx
708 xorl %ebx, %esi
709 jmp .L001end
710.L000start_decrypt:
711
712 /* Round 15 */
713 movl 120(%ebp), %eax
714 xorl %ebx, %ebx
715 movl 124(%ebp), %edx
716 xorl %esi, %eax
717 xorl %esi, %edx
718 andl $0xfcfcfcfc, %eax
719 andl $0xcfcfcfcf, %edx
720 movb %al, %bl
721 movb %ah, %cl
722 rorl $4, %edx
723 movl des_SPtrans(%ebx),%ebp
724 movb %dl, %bl
725 xorl %ebp, %edi
726 movl 0x200+des_SPtrans(%ecx),%ebp
727 xorl %ebp, %edi
728 movb %dh, %cl
729 shrl $16, %eax
730 movl 0x100+des_SPtrans(%ebx),%ebp
731 xorl %ebp, %edi
732 movb %ah, %bl
733 shrl $16, %edx
734 movl 0x300+des_SPtrans(%ecx),%ebp
735 xorl %ebp, %edi
736 movl 24(%esp), %ebp
737 movb %dh, %cl
738 andl $0xff, %eax
739 andl $0xff, %edx
740 movl 0x600+des_SPtrans(%ebx),%ebx
741 xorl %ebx, %edi
742 movl 0x700+des_SPtrans(%ecx),%ebx
743 xorl %ebx, %edi
744 movl 0x400+des_SPtrans(%eax),%ebx
745 xorl %ebx, %edi
746 movl 0x500+des_SPtrans(%edx),%ebx
747 xorl %ebx, %edi
748
749 /* Round 14 */
750 movl 112(%ebp), %eax
751 xorl %ebx, %ebx
752 movl 116(%ebp), %edx
753 xorl %edi, %eax
754 xorl %edi, %edx
755 andl $0xfcfcfcfc, %eax
756 andl $0xcfcfcfcf, %edx
757 movb %al, %bl
758 movb %ah, %cl
759 rorl $4, %edx
760 movl des_SPtrans(%ebx),%ebp
761 movb %dl, %bl
762 xorl %ebp, %esi
763 movl 0x200+des_SPtrans(%ecx),%ebp
764 xorl %ebp, %esi
765 movb %dh, %cl
766 shrl $16, %eax
767 movl 0x100+des_SPtrans(%ebx),%ebp
768 xorl %ebp, %esi
769 movb %ah, %bl
770 shrl $16, %edx
771 movl 0x300+des_SPtrans(%ecx),%ebp
772 xorl %ebp, %esi
773 movl 24(%esp), %ebp
774 movb %dh, %cl
775 andl $0xff, %eax
776 andl $0xff, %edx
777 movl 0x600+des_SPtrans(%ebx),%ebx
778 xorl %ebx, %esi
779 movl 0x700+des_SPtrans(%ecx),%ebx
780 xorl %ebx, %esi
781 movl 0x400+des_SPtrans(%eax),%ebx
782 xorl %ebx, %esi
783 movl 0x500+des_SPtrans(%edx),%ebx
784 xorl %ebx, %esi
785
786 /* Round 13 */
787 movl 104(%ebp), %eax
788 xorl %ebx, %ebx
789 movl 108(%ebp), %edx
790 xorl %esi, %eax
791 xorl %esi, %edx
792 andl $0xfcfcfcfc, %eax
793 andl $0xcfcfcfcf, %edx
794 movb %al, %bl
795 movb %ah, %cl
796 rorl $4, %edx
797 movl des_SPtrans(%ebx),%ebp
798 movb %dl, %bl
799 xorl %ebp, %edi
800 movl 0x200+des_SPtrans(%ecx),%ebp
801 xorl %ebp, %edi
802 movb %dh, %cl
803 shrl $16, %eax
804 movl 0x100+des_SPtrans(%ebx),%ebp
805 xorl %ebp, %edi
806 movb %ah, %bl
807 shrl $16, %edx
808 movl 0x300+des_SPtrans(%ecx),%ebp
809 xorl %ebp, %edi
810 movl 24(%esp), %ebp
811 movb %dh, %cl
812 andl $0xff, %eax
813 andl $0xff, %edx
814 movl 0x600+des_SPtrans(%ebx),%ebx
815 xorl %ebx, %edi
816 movl 0x700+des_SPtrans(%ecx),%ebx
817 xorl %ebx, %edi
818 movl 0x400+des_SPtrans(%eax),%ebx
819 xorl %ebx, %edi
820 movl 0x500+des_SPtrans(%edx),%ebx
821 xorl %ebx, %edi
822
823 /* Round 12 */
824 movl 96(%ebp), %eax
825 xorl %ebx, %ebx
826 movl 100(%ebp), %edx
827 xorl %edi, %eax
828 xorl %edi, %edx
829 andl $0xfcfcfcfc, %eax
830 andl $0xcfcfcfcf, %edx
831 movb %al, %bl
832 movb %ah, %cl
833 rorl $4, %edx
834 movl des_SPtrans(%ebx),%ebp
835 movb %dl, %bl
836 xorl %ebp, %esi
837 movl 0x200+des_SPtrans(%ecx),%ebp
838 xorl %ebp, %esi
839 movb %dh, %cl
840 shrl $16, %eax
841 movl 0x100+des_SPtrans(%ebx),%ebp
842 xorl %ebp, %esi
843 movb %ah, %bl
844 shrl $16, %edx
845 movl 0x300+des_SPtrans(%ecx),%ebp
846 xorl %ebp, %esi
847 movl 24(%esp), %ebp
848 movb %dh, %cl
849 andl $0xff, %eax
850 andl $0xff, %edx
851 movl 0x600+des_SPtrans(%ebx),%ebx
852 xorl %ebx, %esi
853 movl 0x700+des_SPtrans(%ecx),%ebx
854 xorl %ebx, %esi
855 movl 0x400+des_SPtrans(%eax),%ebx
856 xorl %ebx, %esi
857 movl 0x500+des_SPtrans(%edx),%ebx
858 xorl %ebx, %esi
859
860 /* Round 11 */
861 movl 88(%ebp), %eax
862 xorl %ebx, %ebx
863 movl 92(%ebp), %edx
864 xorl %esi, %eax
865 xorl %esi, %edx
866 andl $0xfcfcfcfc, %eax
867 andl $0xcfcfcfcf, %edx
868 movb %al, %bl
869 movb %ah, %cl
870 rorl $4, %edx
871 movl des_SPtrans(%ebx),%ebp
872 movb %dl, %bl
873 xorl %ebp, %edi
874 movl 0x200+des_SPtrans(%ecx),%ebp
875 xorl %ebp, %edi
876 movb %dh, %cl
877 shrl $16, %eax
878 movl 0x100+des_SPtrans(%ebx),%ebp
879 xorl %ebp, %edi
880 movb %ah, %bl
881 shrl $16, %edx
882 movl 0x300+des_SPtrans(%ecx),%ebp
883 xorl %ebp, %edi
884 movl 24(%esp), %ebp
885 movb %dh, %cl
886 andl $0xff, %eax
887 andl $0xff, %edx
888 movl 0x600+des_SPtrans(%ebx),%ebx
889 xorl %ebx, %edi
890 movl 0x700+des_SPtrans(%ecx),%ebx
891 xorl %ebx, %edi
892 movl 0x400+des_SPtrans(%eax),%ebx
893 xorl %ebx, %edi
894 movl 0x500+des_SPtrans(%edx),%ebx
895 xorl %ebx, %edi
896
897 /* Round 10 */
898 movl 80(%ebp), %eax
899 xorl %ebx, %ebx
900 movl 84(%ebp), %edx
901 xorl %edi, %eax
902 xorl %edi, %edx
903 andl $0xfcfcfcfc, %eax
904 andl $0xcfcfcfcf, %edx
905 movb %al, %bl
906 movb %ah, %cl
907 rorl $4, %edx
908 movl des_SPtrans(%ebx),%ebp
909 movb %dl, %bl
910 xorl %ebp, %esi
911 movl 0x200+des_SPtrans(%ecx),%ebp
912 xorl %ebp, %esi
913 movb %dh, %cl
914 shrl $16, %eax
915 movl 0x100+des_SPtrans(%ebx),%ebp
916 xorl %ebp, %esi
917 movb %ah, %bl
918 shrl $16, %edx
919 movl 0x300+des_SPtrans(%ecx),%ebp
920 xorl %ebp, %esi
921 movl 24(%esp), %ebp
922 movb %dh, %cl
923 andl $0xff, %eax
924 andl $0xff, %edx
925 movl 0x600+des_SPtrans(%ebx),%ebx
926 xorl %ebx, %esi
927 movl 0x700+des_SPtrans(%ecx),%ebx
928 xorl %ebx, %esi
929 movl 0x400+des_SPtrans(%eax),%ebx
930 xorl %ebx, %esi
931 movl 0x500+des_SPtrans(%edx),%ebx
932 xorl %ebx, %esi
933
934 /* Round 9 */
935 movl 72(%ebp), %eax
936 xorl %ebx, %ebx
937 movl 76(%ebp), %edx
938 xorl %esi, %eax
939 xorl %esi, %edx
940 andl $0xfcfcfcfc, %eax
941 andl $0xcfcfcfcf, %edx
942 movb %al, %bl
943 movb %ah, %cl
944 rorl $4, %edx
945 movl des_SPtrans(%ebx),%ebp
946 movb %dl, %bl
947 xorl %ebp, %edi
948 movl 0x200+des_SPtrans(%ecx),%ebp
949 xorl %ebp, %edi
950 movb %dh, %cl
951 shrl $16, %eax
952 movl 0x100+des_SPtrans(%ebx),%ebp
953 xorl %ebp, %edi
954 movb %ah, %bl
955 shrl $16, %edx
956 movl 0x300+des_SPtrans(%ecx),%ebp
957 xorl %ebp, %edi
958 movl 24(%esp), %ebp
959 movb %dh, %cl
960 andl $0xff, %eax
961 andl $0xff, %edx
962 movl 0x600+des_SPtrans(%ebx),%ebx
963 xorl %ebx, %edi
964 movl 0x700+des_SPtrans(%ecx),%ebx
965 xorl %ebx, %edi
966 movl 0x400+des_SPtrans(%eax),%ebx
967 xorl %ebx, %edi
968 movl 0x500+des_SPtrans(%edx),%ebx
969 xorl %ebx, %edi
970
971 /* Round 8 */
972 movl 64(%ebp), %eax
973 xorl %ebx, %ebx
974 movl 68(%ebp), %edx
975 xorl %edi, %eax
976 xorl %edi, %edx
977 andl $0xfcfcfcfc, %eax
978 andl $0xcfcfcfcf, %edx
979 movb %al, %bl
980 movb %ah, %cl
981 rorl $4, %edx
982 movl des_SPtrans(%ebx),%ebp
983 movb %dl, %bl
984 xorl %ebp, %esi
985 movl 0x200+des_SPtrans(%ecx),%ebp
986 xorl %ebp, %esi
987 movb %dh, %cl
988 shrl $16, %eax
989 movl 0x100+des_SPtrans(%ebx),%ebp
990 xorl %ebp, %esi
991 movb %ah, %bl
992 shrl $16, %edx
993 movl 0x300+des_SPtrans(%ecx),%ebp
994 xorl %ebp, %esi
995 movl 24(%esp), %ebp
996 movb %dh, %cl
997 andl $0xff, %eax
998 andl $0xff, %edx
999 movl 0x600+des_SPtrans(%ebx),%ebx
1000 xorl %ebx, %esi
1001 movl 0x700+des_SPtrans(%ecx),%ebx
1002 xorl %ebx, %esi
1003 movl 0x400+des_SPtrans(%eax),%ebx
1004 xorl %ebx, %esi
1005 movl 0x500+des_SPtrans(%edx),%ebx
1006 xorl %ebx, %esi
1007
1008 /* Round 7 */
1009 movl 56(%ebp), %eax
1010 xorl %ebx, %ebx
1011 movl 60(%ebp), %edx
1012 xorl %esi, %eax
1013 xorl %esi, %edx
1014 andl $0xfcfcfcfc, %eax
1015 andl $0xcfcfcfcf, %edx
1016 movb %al, %bl
1017 movb %ah, %cl
1018 rorl $4, %edx
1019 movl des_SPtrans(%ebx),%ebp
1020 movb %dl, %bl
1021 xorl %ebp, %edi
1022 movl 0x200+des_SPtrans(%ecx),%ebp
1023 xorl %ebp, %edi
1024 movb %dh, %cl
1025 shrl $16, %eax
1026 movl 0x100+des_SPtrans(%ebx),%ebp
1027 xorl %ebp, %edi
1028 movb %ah, %bl
1029 shrl $16, %edx
1030 movl 0x300+des_SPtrans(%ecx),%ebp
1031 xorl %ebp, %edi
1032 movl 24(%esp), %ebp
1033 movb %dh, %cl
1034 andl $0xff, %eax
1035 andl $0xff, %edx
1036 movl 0x600+des_SPtrans(%ebx),%ebx
1037 xorl %ebx, %edi
1038 movl 0x700+des_SPtrans(%ecx),%ebx
1039 xorl %ebx, %edi
1040 movl 0x400+des_SPtrans(%eax),%ebx
1041 xorl %ebx, %edi
1042 movl 0x500+des_SPtrans(%edx),%ebx
1043 xorl %ebx, %edi
1044
1045 /* Round 6 */
1046 movl 48(%ebp), %eax
1047 xorl %ebx, %ebx
1048 movl 52(%ebp), %edx
1049 xorl %edi, %eax
1050 xorl %edi, %edx
1051 andl $0xfcfcfcfc, %eax
1052 andl $0xcfcfcfcf, %edx
1053 movb %al, %bl
1054 movb %ah, %cl
1055 rorl $4, %edx
1056 movl des_SPtrans(%ebx),%ebp
1057 movb %dl, %bl
1058 xorl %ebp, %esi
1059 movl 0x200+des_SPtrans(%ecx),%ebp
1060 xorl %ebp, %esi
1061 movb %dh, %cl
1062 shrl $16, %eax
1063 movl 0x100+des_SPtrans(%ebx),%ebp
1064 xorl %ebp, %esi
1065 movb %ah, %bl
1066 shrl $16, %edx
1067 movl 0x300+des_SPtrans(%ecx),%ebp
1068 xorl %ebp, %esi
1069 movl 24(%esp), %ebp
1070 movb %dh, %cl
1071 andl $0xff, %eax
1072 andl $0xff, %edx
1073 movl 0x600+des_SPtrans(%ebx),%ebx
1074 xorl %ebx, %esi
1075 movl 0x700+des_SPtrans(%ecx),%ebx
1076 xorl %ebx, %esi
1077 movl 0x400+des_SPtrans(%eax),%ebx
1078 xorl %ebx, %esi
1079 movl 0x500+des_SPtrans(%edx),%ebx
1080 xorl %ebx, %esi
1081
1082 /* Round 5 */
1083 movl 40(%ebp), %eax
1084 xorl %ebx, %ebx
1085 movl 44(%ebp), %edx
1086 xorl %esi, %eax
1087 xorl %esi, %edx
1088 andl $0xfcfcfcfc, %eax
1089 andl $0xcfcfcfcf, %edx
1090 movb %al, %bl
1091 movb %ah, %cl
1092 rorl $4, %edx
1093 movl des_SPtrans(%ebx),%ebp
1094 movb %dl, %bl
1095 xorl %ebp, %edi
1096 movl 0x200+des_SPtrans(%ecx),%ebp
1097 xorl %ebp, %edi
1098 movb %dh, %cl
1099 shrl $16, %eax
1100 movl 0x100+des_SPtrans(%ebx),%ebp
1101 xorl %ebp, %edi
1102 movb %ah, %bl
1103 shrl $16, %edx
1104 movl 0x300+des_SPtrans(%ecx),%ebp
1105 xorl %ebp, %edi
1106 movl 24(%esp), %ebp
1107 movb %dh, %cl
1108 andl $0xff, %eax
1109 andl $0xff, %edx
1110 movl 0x600+des_SPtrans(%ebx),%ebx
1111 xorl %ebx, %edi
1112 movl 0x700+des_SPtrans(%ecx),%ebx
1113 xorl %ebx, %edi
1114 movl 0x400+des_SPtrans(%eax),%ebx
1115 xorl %ebx, %edi
1116 movl 0x500+des_SPtrans(%edx),%ebx
1117 xorl %ebx, %edi
1118
1119 /* Round 4 */
1120 movl 32(%ebp), %eax
1121 xorl %ebx, %ebx
1122 movl 36(%ebp), %edx
1123 xorl %edi, %eax
1124 xorl %edi, %edx
1125 andl $0xfcfcfcfc, %eax
1126 andl $0xcfcfcfcf, %edx
1127 movb %al, %bl
1128 movb %ah, %cl
1129 rorl $4, %edx
1130 movl des_SPtrans(%ebx),%ebp
1131 movb %dl, %bl
1132 xorl %ebp, %esi
1133 movl 0x200+des_SPtrans(%ecx),%ebp
1134 xorl %ebp, %esi
1135 movb %dh, %cl
1136 shrl $16, %eax
1137 movl 0x100+des_SPtrans(%ebx),%ebp
1138 xorl %ebp, %esi
1139 movb %ah, %bl
1140 shrl $16, %edx
1141 movl 0x300+des_SPtrans(%ecx),%ebp
1142 xorl %ebp, %esi
1143 movl 24(%esp), %ebp
1144 movb %dh, %cl
1145 andl $0xff, %eax
1146 andl $0xff, %edx
1147 movl 0x600+des_SPtrans(%ebx),%ebx
1148 xorl %ebx, %esi
1149 movl 0x700+des_SPtrans(%ecx),%ebx
1150 xorl %ebx, %esi
1151 movl 0x400+des_SPtrans(%eax),%ebx
1152 xorl %ebx, %esi
1153 movl 0x500+des_SPtrans(%edx),%ebx
1154 xorl %ebx, %esi
1155
1156 /* Round 3 */
1157 movl 24(%ebp), %eax
1158 xorl %ebx, %ebx
1159 movl 28(%ebp), %edx
1160 xorl %esi, %eax
1161 xorl %esi, %edx
1162 andl $0xfcfcfcfc, %eax
1163 andl $0xcfcfcfcf, %edx
1164 movb %al, %bl
1165 movb %ah, %cl
1166 rorl $4, %edx
1167 movl des_SPtrans(%ebx),%ebp
1168 movb %dl, %bl
1169 xorl %ebp, %edi
1170 movl 0x200+des_SPtrans(%ecx),%ebp
1171 xorl %ebp, %edi
1172 movb %dh, %cl
1173 shrl $16, %eax
1174 movl 0x100+des_SPtrans(%ebx),%ebp
1175 xorl %ebp, %edi
1176 movb %ah, %bl
1177 shrl $16, %edx
1178 movl 0x300+des_SPtrans(%ecx),%ebp
1179 xorl %ebp, %edi
1180 movl 24(%esp), %ebp
1181 movb %dh, %cl
1182 andl $0xff, %eax
1183 andl $0xff, %edx
1184 movl 0x600+des_SPtrans(%ebx),%ebx
1185 xorl %ebx, %edi
1186 movl 0x700+des_SPtrans(%ecx),%ebx
1187 xorl %ebx, %edi
1188 movl 0x400+des_SPtrans(%eax),%ebx
1189 xorl %ebx, %edi
1190 movl 0x500+des_SPtrans(%edx),%ebx
1191 xorl %ebx, %edi
1192
1193 /* Round 2 */
1194 movl 16(%ebp), %eax
1195 xorl %ebx, %ebx
1196 movl 20(%ebp), %edx
1197 xorl %edi, %eax
1198 xorl %edi, %edx
1199 andl $0xfcfcfcfc, %eax
1200 andl $0xcfcfcfcf, %edx
1201 movb %al, %bl
1202 movb %ah, %cl
1203 rorl $4, %edx
1204 movl des_SPtrans(%ebx),%ebp
1205 movb %dl, %bl
1206 xorl %ebp, %esi
1207 movl 0x200+des_SPtrans(%ecx),%ebp
1208 xorl %ebp, %esi
1209 movb %dh, %cl
1210 shrl $16, %eax
1211 movl 0x100+des_SPtrans(%ebx),%ebp
1212 xorl %ebp, %esi
1213 movb %ah, %bl
1214 shrl $16, %edx
1215 movl 0x300+des_SPtrans(%ecx),%ebp
1216 xorl %ebp, %esi
1217 movl 24(%esp), %ebp
1218 movb %dh, %cl
1219 andl $0xff, %eax
1220 andl $0xff, %edx
1221 movl 0x600+des_SPtrans(%ebx),%ebx
1222 xorl %ebx, %esi
1223 movl 0x700+des_SPtrans(%ecx),%ebx
1224 xorl %ebx, %esi
1225 movl 0x400+des_SPtrans(%eax),%ebx
1226 xorl %ebx, %esi
1227 movl 0x500+des_SPtrans(%edx),%ebx
1228 xorl %ebx, %esi
1229
1230 /* Round 1 */
1231 movl 8(%ebp), %eax
1232 xorl %ebx, %ebx
1233 movl 12(%ebp), %edx
1234 xorl %esi, %eax
1235 xorl %esi, %edx
1236 andl $0xfcfcfcfc, %eax
1237 andl $0xcfcfcfcf, %edx
1238 movb %al, %bl
1239 movb %ah, %cl
1240 rorl $4, %edx
1241 movl des_SPtrans(%ebx),%ebp
1242 movb %dl, %bl
1243 xorl %ebp, %edi
1244 movl 0x200+des_SPtrans(%ecx),%ebp
1245 xorl %ebp, %edi
1246 movb %dh, %cl
1247 shrl $16, %eax
1248 movl 0x100+des_SPtrans(%ebx),%ebp
1249 xorl %ebp, %edi
1250 movb %ah, %bl
1251 shrl $16, %edx
1252 movl 0x300+des_SPtrans(%ecx),%ebp
1253 xorl %ebp, %edi
1254 movl 24(%esp), %ebp
1255 movb %dh, %cl
1256 andl $0xff, %eax
1257 andl $0xff, %edx
1258 movl 0x600+des_SPtrans(%ebx),%ebx
1259 xorl %ebx, %edi
1260 movl 0x700+des_SPtrans(%ecx),%ebx
1261 xorl %ebx, %edi
1262 movl 0x400+des_SPtrans(%eax),%ebx
1263 xorl %ebx, %edi
1264 movl 0x500+des_SPtrans(%edx),%ebx
1265 xorl %ebx, %edi
1266
1267 /* Round 0 */
1268 movl (%ebp), %eax
1269 xorl %ebx, %ebx
1270 movl 4(%ebp), %edx
1271 xorl %edi, %eax
1272 xorl %edi, %edx
1273 andl $0xfcfcfcfc, %eax
1274 andl $0xcfcfcfcf, %edx
1275 movb %al, %bl
1276 movb %ah, %cl
1277 rorl $4, %edx
1278 movl des_SPtrans(%ebx),%ebp
1279 movb %dl, %bl
1280 xorl %ebp, %esi
1281 movl 0x200+des_SPtrans(%ecx),%ebp
1282 xorl %ebp, %esi
1283 movb %dh, %cl
1284 shrl $16, %eax
1285 movl 0x100+des_SPtrans(%ebx),%ebp
1286 xorl %ebp, %esi
1287 movb %ah, %bl
1288 shrl $16, %edx
1289 movl 0x300+des_SPtrans(%ecx),%ebp
1290 xorl %ebp, %esi
1291 movl 24(%esp), %ebp
1292 movb %dh, %cl
1293 andl $0xff, %eax
1294 andl $0xff, %edx
1295 movl 0x600+des_SPtrans(%ebx),%ebx
1296 xorl %ebx, %esi
1297 movl 0x700+des_SPtrans(%ecx),%ebx
1298 xorl %ebx, %esi
1299 movl 0x400+des_SPtrans(%eax),%ebx
1300 xorl %ebx, %esi
1301 movl 0x500+des_SPtrans(%edx),%ebx
1302 xorl %ebx, %esi
1303.L001end:
1304
1305 /* FP */
1306 movl 20(%esp), %edx
1307.byte 209
1308.byte 206 /* rorl $1 %esi */
1309 movl %edi, %eax
1310 xorl %esi, %edi
1311 andl $0xaaaaaaaa, %edi
1312 xorl %edi, %eax
1313 xorl %edi, %esi
1314
1315 roll $23, %eax
1316 movl %eax, %edi
1317 xorl %esi, %eax
1318 andl $0x03fc03fc, %eax
1319 xorl %eax, %edi
1320 xorl %eax, %esi
1321
1322 roll $10, %edi
1323 movl %edi, %eax
1324 xorl %esi, %edi
1325 andl $0x33333333, %edi
1326 xorl %edi, %eax
1327 xorl %edi, %esi
1328
1329 roll $18, %esi
1330 movl %esi, %edi
1331 xorl %eax, %esi
1332 andl $0xfff0000f, %esi
1333 xorl %esi, %edi
1334 xorl %esi, %eax
1335
1336 roll $12, %edi
1337 movl %edi, %esi
1338 xorl %eax, %edi
1339 andl $0xf0f0f0f0, %edi
1340 xorl %edi, %esi
1341 xorl %edi, %eax
1342
1343 rorl $4, %eax
1344 movl %eax, (%edx)
1345 movl %esi, 4(%edx)
1346 popl %ebp
1347 popl %ebx
1348 popl %edi
1349 popl %esi
1350 ret
1351.des_encrypt_end:
1352 SIZE(des_encrypt,.des_encrypt_end-des_encrypt)
1353.ident "desasm.pl"
1354.text
1355 .align ALIGN
1356.globl des_encrypt2
1357 TYPE(des_encrypt2,@function)
1358des_encrypt2:
1359 pushl %esi
1360 pushl %edi
1361
1362 /* Load the 2 words */
1363 movl 12(%esp), %eax
1364 xorl %ecx, %ecx
1365 pushl %ebx
1366 pushl %ebp
1367 movl (%eax), %esi
1368 movl 28(%esp), %ebx
1369 roll $3, %esi
1370 movl 4(%eax), %edi
1371 roll $3, %edi
1372 movl 24(%esp), %ebp
1373 cmpl $0, %ebx
1374 je .L002start_decrypt
1375
1376 /* Round 0 */
1377 movl (%ebp), %eax
1378 xorl %ebx, %ebx
1379 movl 4(%ebp), %edx
1380 xorl %esi, %eax
1381 xorl %esi, %edx
1382 andl $0xfcfcfcfc, %eax
1383 andl $0xcfcfcfcf, %edx
1384 movb %al, %bl
1385 movb %ah, %cl
1386 rorl $4, %edx
1387 movl des_SPtrans(%ebx),%ebp
1388 movb %dl, %bl
1389 xorl %ebp, %edi
1390 movl 0x200+des_SPtrans(%ecx),%ebp
1391 xorl %ebp, %edi
1392 movb %dh, %cl
1393 shrl $16, %eax
1394 movl 0x100+des_SPtrans(%ebx),%ebp
1395 xorl %ebp, %edi
1396 movb %ah, %bl
1397 shrl $16, %edx
1398 movl 0x300+des_SPtrans(%ecx),%ebp
1399 xorl %ebp, %edi
1400 movl 24(%esp), %ebp
1401 movb %dh, %cl
1402 andl $0xff, %eax
1403 andl $0xff, %edx
1404 movl 0x600+des_SPtrans(%ebx),%ebx
1405 xorl %ebx, %edi
1406 movl 0x700+des_SPtrans(%ecx),%ebx
1407 xorl %ebx, %edi
1408 movl 0x400+des_SPtrans(%eax),%ebx
1409 xorl %ebx, %edi
1410 movl 0x500+des_SPtrans(%edx),%ebx
1411 xorl %ebx, %edi
1412
1413 /* Round 1 */
1414 movl 8(%ebp), %eax
1415 xorl %ebx, %ebx
1416 movl 12(%ebp), %edx
1417 xorl %edi, %eax
1418 xorl %edi, %edx
1419 andl $0xfcfcfcfc, %eax
1420 andl $0xcfcfcfcf, %edx
1421 movb %al, %bl
1422 movb %ah, %cl
1423 rorl $4, %edx
1424 movl des_SPtrans(%ebx),%ebp
1425 movb %dl, %bl
1426 xorl %ebp, %esi
1427 movl 0x200+des_SPtrans(%ecx),%ebp
1428 xorl %ebp, %esi
1429 movb %dh, %cl
1430 shrl $16, %eax
1431 movl 0x100+des_SPtrans(%ebx),%ebp
1432 xorl %ebp, %esi
1433 movb %ah, %bl
1434 shrl $16, %edx
1435 movl 0x300+des_SPtrans(%ecx),%ebp
1436 xorl %ebp, %esi
1437 movl 24(%esp), %ebp
1438 movb %dh, %cl
1439 andl $0xff, %eax
1440 andl $0xff, %edx
1441 movl 0x600+des_SPtrans(%ebx),%ebx
1442 xorl %ebx, %esi
1443 movl 0x700+des_SPtrans(%ecx),%ebx
1444 xorl %ebx, %esi
1445 movl 0x400+des_SPtrans(%eax),%ebx
1446 xorl %ebx, %esi
1447 movl 0x500+des_SPtrans(%edx),%ebx
1448 xorl %ebx, %esi
1449
1450 /* Round 2 */
1451 movl 16(%ebp), %eax
1452 xorl %ebx, %ebx
1453 movl 20(%ebp), %edx
1454 xorl %esi, %eax
1455 xorl %esi, %edx
1456 andl $0xfcfcfcfc, %eax
1457 andl $0xcfcfcfcf, %edx
1458 movb %al, %bl
1459 movb %ah, %cl
1460 rorl $4, %edx
1461 movl des_SPtrans(%ebx),%ebp
1462 movb %dl, %bl
1463 xorl %ebp, %edi
1464 movl 0x200+des_SPtrans(%ecx),%ebp
1465 xorl %ebp, %edi
1466 movb %dh, %cl
1467 shrl $16, %eax
1468 movl 0x100+des_SPtrans(%ebx),%ebp
1469 xorl %ebp, %edi
1470 movb %ah, %bl
1471 shrl $16, %edx
1472 movl 0x300+des_SPtrans(%ecx),%ebp
1473 xorl %ebp, %edi
1474 movl 24(%esp), %ebp
1475 movb %dh, %cl
1476 andl $0xff, %eax
1477 andl $0xff, %edx
1478 movl 0x600+des_SPtrans(%ebx),%ebx
1479 xorl %ebx, %edi
1480 movl 0x700+des_SPtrans(%ecx),%ebx
1481 xorl %ebx, %edi
1482 movl 0x400+des_SPtrans(%eax),%ebx
1483 xorl %ebx, %edi
1484 movl 0x500+des_SPtrans(%edx),%ebx
1485 xorl %ebx, %edi
1486
1487 /* Round 3 */
1488 movl 24(%ebp), %eax
1489 xorl %ebx, %ebx
1490 movl 28(%ebp), %edx
1491 xorl %edi, %eax
1492 xorl %edi, %edx
1493 andl $0xfcfcfcfc, %eax
1494 andl $0xcfcfcfcf, %edx
1495 movb %al, %bl
1496 movb %ah, %cl
1497 rorl $4, %edx
1498 movl des_SPtrans(%ebx),%ebp
1499 movb %dl, %bl
1500 xorl %ebp, %esi
1501 movl 0x200+des_SPtrans(%ecx),%ebp
1502 xorl %ebp, %esi
1503 movb %dh, %cl
1504 shrl $16, %eax
1505 movl 0x100+des_SPtrans(%ebx),%ebp
1506 xorl %ebp, %esi
1507 movb %ah, %bl
1508 shrl $16, %edx
1509 movl 0x300+des_SPtrans(%ecx),%ebp
1510 xorl %ebp, %esi
1511 movl 24(%esp), %ebp
1512 movb %dh, %cl
1513 andl $0xff, %eax
1514 andl $0xff, %edx
1515 movl 0x600+des_SPtrans(%ebx),%ebx
1516 xorl %ebx, %esi
1517 movl 0x700+des_SPtrans(%ecx),%ebx
1518 xorl %ebx, %esi
1519 movl 0x400+des_SPtrans(%eax),%ebx
1520 xorl %ebx, %esi
1521 movl 0x500+des_SPtrans(%edx),%ebx
1522 xorl %ebx, %esi
1523
1524 /* Round 4 */
1525 movl 32(%ebp), %eax
1526 xorl %ebx, %ebx
1527 movl 36(%ebp), %edx
1528 xorl %esi, %eax
1529 xorl %esi, %edx
1530 andl $0xfcfcfcfc, %eax
1531 andl $0xcfcfcfcf, %edx
1532 movb %al, %bl
1533 movb %ah, %cl
1534 rorl $4, %edx
1535 movl des_SPtrans(%ebx),%ebp
1536 movb %dl, %bl
1537 xorl %ebp, %edi
1538 movl 0x200+des_SPtrans(%ecx),%ebp
1539 xorl %ebp, %edi
1540 movb %dh, %cl
1541 shrl $16, %eax
1542 movl 0x100+des_SPtrans(%ebx),%ebp
1543 xorl %ebp, %edi
1544 movb %ah, %bl
1545 shrl $16, %edx
1546 movl 0x300+des_SPtrans(%ecx),%ebp
1547 xorl %ebp, %edi
1548 movl 24(%esp), %ebp
1549 movb %dh, %cl
1550 andl $0xff, %eax
1551 andl $0xff, %edx
1552 movl 0x600+des_SPtrans(%ebx),%ebx
1553 xorl %ebx, %edi
1554 movl 0x700+des_SPtrans(%ecx),%ebx
1555 xorl %ebx, %edi
1556 movl 0x400+des_SPtrans(%eax),%ebx
1557 xorl %ebx, %edi
1558 movl 0x500+des_SPtrans(%edx),%ebx
1559 xorl %ebx, %edi
1560
1561 /* Round 5 */
1562 movl 40(%ebp), %eax
1563 xorl %ebx, %ebx
1564 movl 44(%ebp), %edx
1565 xorl %edi, %eax
1566 xorl %edi, %edx
1567 andl $0xfcfcfcfc, %eax
1568 andl $0xcfcfcfcf, %edx
1569 movb %al, %bl
1570 movb %ah, %cl
1571 rorl $4, %edx
1572 movl des_SPtrans(%ebx),%ebp
1573 movb %dl, %bl
1574 xorl %ebp, %esi
1575 movl 0x200+des_SPtrans(%ecx),%ebp
1576 xorl %ebp, %esi
1577 movb %dh, %cl
1578 shrl $16, %eax
1579 movl 0x100+des_SPtrans(%ebx),%ebp
1580 xorl %ebp, %esi
1581 movb %ah, %bl
1582 shrl $16, %edx
1583 movl 0x300+des_SPtrans(%ecx),%ebp
1584 xorl %ebp, %esi
1585 movl 24(%esp), %ebp
1586 movb %dh, %cl
1587 andl $0xff, %eax
1588 andl $0xff, %edx
1589 movl 0x600+des_SPtrans(%ebx),%ebx
1590 xorl %ebx, %esi
1591 movl 0x700+des_SPtrans(%ecx),%ebx
1592 xorl %ebx, %esi
1593 movl 0x400+des_SPtrans(%eax),%ebx
1594 xorl %ebx, %esi
1595 movl 0x500+des_SPtrans(%edx),%ebx
1596 xorl %ebx, %esi
1597
1598 /* Round 6 */
1599 movl 48(%ebp), %eax
1600 xorl %ebx, %ebx
1601 movl 52(%ebp), %edx
1602 xorl %esi, %eax
1603 xorl %esi, %edx
1604 andl $0xfcfcfcfc, %eax
1605 andl $0xcfcfcfcf, %edx
1606 movb %al, %bl
1607 movb %ah, %cl
1608 rorl $4, %edx
1609 movl des_SPtrans(%ebx),%ebp
1610 movb %dl, %bl
1611 xorl %ebp, %edi
1612 movl 0x200+des_SPtrans(%ecx),%ebp
1613 xorl %ebp, %edi
1614 movb %dh, %cl
1615 shrl $16, %eax
1616 movl 0x100+des_SPtrans(%ebx),%ebp
1617 xorl %ebp, %edi
1618 movb %ah, %bl
1619 shrl $16, %edx
1620 movl 0x300+des_SPtrans(%ecx),%ebp
1621 xorl %ebp, %edi
1622 movl 24(%esp), %ebp
1623 movb %dh, %cl
1624 andl $0xff, %eax
1625 andl $0xff, %edx
1626 movl 0x600+des_SPtrans(%ebx),%ebx
1627 xorl %ebx, %edi
1628 movl 0x700+des_SPtrans(%ecx),%ebx
1629 xorl %ebx, %edi
1630 movl 0x400+des_SPtrans(%eax),%ebx
1631 xorl %ebx, %edi
1632 movl 0x500+des_SPtrans(%edx),%ebx
1633 xorl %ebx, %edi
1634
1635 /* Round 7 */
1636 movl 56(%ebp), %eax
1637 xorl %ebx, %ebx
1638 movl 60(%ebp), %edx
1639 xorl %edi, %eax
1640 xorl %edi, %edx
1641 andl $0xfcfcfcfc, %eax
1642 andl $0xcfcfcfcf, %edx
1643 movb %al, %bl
1644 movb %ah, %cl
1645 rorl $4, %edx
1646 movl des_SPtrans(%ebx),%ebp
1647 movb %dl, %bl
1648 xorl %ebp, %esi
1649 movl 0x200+des_SPtrans(%ecx),%ebp
1650 xorl %ebp, %esi
1651 movb %dh, %cl
1652 shrl $16, %eax
1653 movl 0x100+des_SPtrans(%ebx),%ebp
1654 xorl %ebp, %esi
1655 movb %ah, %bl
1656 shrl $16, %edx
1657 movl 0x300+des_SPtrans(%ecx),%ebp
1658 xorl %ebp, %esi
1659 movl 24(%esp), %ebp
1660 movb %dh, %cl
1661 andl $0xff, %eax
1662 andl $0xff, %edx
1663 movl 0x600+des_SPtrans(%ebx),%ebx
1664 xorl %ebx, %esi
1665 movl 0x700+des_SPtrans(%ecx),%ebx
1666 xorl %ebx, %esi
1667 movl 0x400+des_SPtrans(%eax),%ebx
1668 xorl %ebx, %esi
1669 movl 0x500+des_SPtrans(%edx),%ebx
1670 xorl %ebx, %esi
1671
1672 /* Round 8 */
1673 movl 64(%ebp), %eax
1674 xorl %ebx, %ebx
1675 movl 68(%ebp), %edx
1676 xorl %esi, %eax
1677 xorl %esi, %edx
1678 andl $0xfcfcfcfc, %eax
1679 andl $0xcfcfcfcf, %edx
1680 movb %al, %bl
1681 movb %ah, %cl
1682 rorl $4, %edx
1683 movl des_SPtrans(%ebx),%ebp
1684 movb %dl, %bl
1685 xorl %ebp, %edi
1686 movl 0x200+des_SPtrans(%ecx),%ebp
1687 xorl %ebp, %edi
1688 movb %dh, %cl
1689 shrl $16, %eax
1690 movl 0x100+des_SPtrans(%ebx),%ebp
1691 xorl %ebp, %edi
1692 movb %ah, %bl
1693 shrl $16, %edx
1694 movl 0x300+des_SPtrans(%ecx),%ebp
1695 xorl %ebp, %edi
1696 movl 24(%esp), %ebp
1697 movb %dh, %cl
1698 andl $0xff, %eax
1699 andl $0xff, %edx
1700 movl 0x600+des_SPtrans(%ebx),%ebx
1701 xorl %ebx, %edi
1702 movl 0x700+des_SPtrans(%ecx),%ebx
1703 xorl %ebx, %edi
1704 movl 0x400+des_SPtrans(%eax),%ebx
1705 xorl %ebx, %edi
1706 movl 0x500+des_SPtrans(%edx),%ebx
1707 xorl %ebx, %edi
1708
1709 /* Round 9 */
1710 movl 72(%ebp), %eax
1711 xorl %ebx, %ebx
1712 movl 76(%ebp), %edx
1713 xorl %edi, %eax
1714 xorl %edi, %edx
1715 andl $0xfcfcfcfc, %eax
1716 andl $0xcfcfcfcf, %edx
1717 movb %al, %bl
1718 movb %ah, %cl
1719 rorl $4, %edx
1720 movl des_SPtrans(%ebx),%ebp
1721 movb %dl, %bl
1722 xorl %ebp, %esi
1723 movl 0x200+des_SPtrans(%ecx),%ebp
1724 xorl %ebp, %esi
1725 movb %dh, %cl
1726 shrl $16, %eax
1727 movl 0x100+des_SPtrans(%ebx),%ebp
1728 xorl %ebp, %esi
1729 movb %ah, %bl
1730 shrl $16, %edx
1731 movl 0x300+des_SPtrans(%ecx),%ebp
1732 xorl %ebp, %esi
1733 movl 24(%esp), %ebp
1734 movb %dh, %cl
1735 andl $0xff, %eax
1736 andl $0xff, %edx
1737 movl 0x600+des_SPtrans(%ebx),%ebx
1738 xorl %ebx, %esi
1739 movl 0x700+des_SPtrans(%ecx),%ebx
1740 xorl %ebx, %esi
1741 movl 0x400+des_SPtrans(%eax),%ebx
1742 xorl %ebx, %esi
1743 movl 0x500+des_SPtrans(%edx),%ebx
1744 xorl %ebx, %esi
1745
1746 /* Round 10 */
1747 movl 80(%ebp), %eax
1748 xorl %ebx, %ebx
1749 movl 84(%ebp), %edx
1750 xorl %esi, %eax
1751 xorl %esi, %edx
1752 andl $0xfcfcfcfc, %eax
1753 andl $0xcfcfcfcf, %edx
1754 movb %al, %bl
1755 movb %ah, %cl
1756 rorl $4, %edx
1757 movl des_SPtrans(%ebx),%ebp
1758 movb %dl, %bl
1759 xorl %ebp, %edi
1760 movl 0x200+des_SPtrans(%ecx),%ebp
1761 xorl %ebp, %edi
1762 movb %dh, %cl
1763 shrl $16, %eax
1764 movl 0x100+des_SPtrans(%ebx),%ebp
1765 xorl %ebp, %edi
1766 movb %ah, %bl
1767 shrl $16, %edx
1768 movl 0x300+des_SPtrans(%ecx),%ebp
1769 xorl %ebp, %edi
1770 movl 24(%esp), %ebp
1771 movb %dh, %cl
1772 andl $0xff, %eax
1773 andl $0xff, %edx
1774 movl 0x600+des_SPtrans(%ebx),%ebx
1775 xorl %ebx, %edi
1776 movl 0x700+des_SPtrans(%ecx),%ebx
1777 xorl %ebx, %edi
1778 movl 0x400+des_SPtrans(%eax),%ebx
1779 xorl %ebx, %edi
1780 movl 0x500+des_SPtrans(%edx),%ebx
1781 xorl %ebx, %edi
1782
1783 /* Round 11 */
1784 movl 88(%ebp), %eax
1785 xorl %ebx, %ebx
1786 movl 92(%ebp), %edx
1787 xorl %edi, %eax
1788 xorl %edi, %edx
1789 andl $0xfcfcfcfc, %eax
1790 andl $0xcfcfcfcf, %edx
1791 movb %al, %bl
1792 movb %ah, %cl
1793 rorl $4, %edx
1794 movl des_SPtrans(%ebx),%ebp
1795 movb %dl, %bl
1796 xorl %ebp, %esi
1797 movl 0x200+des_SPtrans(%ecx),%ebp
1798 xorl %ebp, %esi
1799 movb %dh, %cl
1800 shrl $16, %eax
1801 movl 0x100+des_SPtrans(%ebx),%ebp
1802 xorl %ebp, %esi
1803 movb %ah, %bl
1804 shrl $16, %edx
1805 movl 0x300+des_SPtrans(%ecx),%ebp
1806 xorl %ebp, %esi
1807 movl 24(%esp), %ebp
1808 movb %dh, %cl
1809 andl $0xff, %eax
1810 andl $0xff, %edx
1811 movl 0x600+des_SPtrans(%ebx),%ebx
1812 xorl %ebx, %esi
1813 movl 0x700+des_SPtrans(%ecx),%ebx
1814 xorl %ebx, %esi
1815 movl 0x400+des_SPtrans(%eax),%ebx
1816 xorl %ebx, %esi
1817 movl 0x500+des_SPtrans(%edx),%ebx
1818 xorl %ebx, %esi
1819
1820 /* Round 12 */
1821 movl 96(%ebp), %eax
1822 xorl %ebx, %ebx
1823 movl 100(%ebp), %edx
1824 xorl %esi, %eax
1825 xorl %esi, %edx
1826 andl $0xfcfcfcfc, %eax
1827 andl $0xcfcfcfcf, %edx
1828 movb %al, %bl
1829 movb %ah, %cl
1830 rorl $4, %edx
1831 movl des_SPtrans(%ebx),%ebp
1832 movb %dl, %bl
1833 xorl %ebp, %edi
1834 movl 0x200+des_SPtrans(%ecx),%ebp
1835 xorl %ebp, %edi
1836 movb %dh, %cl
1837 shrl $16, %eax
1838 movl 0x100+des_SPtrans(%ebx),%ebp
1839 xorl %ebp, %edi
1840 movb %ah, %bl
1841 shrl $16, %edx
1842 movl 0x300+des_SPtrans(%ecx),%ebp
1843 xorl %ebp, %edi
1844 movl 24(%esp), %ebp
1845 movb %dh, %cl
1846 andl $0xff, %eax
1847 andl $0xff, %edx
1848 movl 0x600+des_SPtrans(%ebx),%ebx
1849 xorl %ebx, %edi
1850 movl 0x700+des_SPtrans(%ecx),%ebx
1851 xorl %ebx, %edi
1852 movl 0x400+des_SPtrans(%eax),%ebx
1853 xorl %ebx, %edi
1854 movl 0x500+des_SPtrans(%edx),%ebx
1855 xorl %ebx, %edi
1856
1857 /* Round 13 */
1858 movl 104(%ebp), %eax
1859 xorl %ebx, %ebx
1860 movl 108(%ebp), %edx
1861 xorl %edi, %eax
1862 xorl %edi, %edx
1863 andl $0xfcfcfcfc, %eax
1864 andl $0xcfcfcfcf, %edx
1865 movb %al, %bl
1866 movb %ah, %cl
1867 rorl $4, %edx
1868 movl des_SPtrans(%ebx),%ebp
1869 movb %dl, %bl
1870 xorl %ebp, %esi
1871 movl 0x200+des_SPtrans(%ecx),%ebp
1872 xorl %ebp, %esi
1873 movb %dh, %cl
1874 shrl $16, %eax
1875 movl 0x100+des_SPtrans(%ebx),%ebp
1876 xorl %ebp, %esi
1877 movb %ah, %bl
1878 shrl $16, %edx
1879 movl 0x300+des_SPtrans(%ecx),%ebp
1880 xorl %ebp, %esi
1881 movl 24(%esp), %ebp
1882 movb %dh, %cl
1883 andl $0xff, %eax
1884 andl $0xff, %edx
1885 movl 0x600+des_SPtrans(%ebx),%ebx
1886 xorl %ebx, %esi
1887 movl 0x700+des_SPtrans(%ecx),%ebx
1888 xorl %ebx, %esi
1889 movl 0x400+des_SPtrans(%eax),%ebx
1890 xorl %ebx, %esi
1891 movl 0x500+des_SPtrans(%edx),%ebx
1892 xorl %ebx, %esi
1893
1894 /* Round 14 */
1895 movl 112(%ebp), %eax
1896 xorl %ebx, %ebx
1897 movl 116(%ebp), %edx
1898 xorl %esi, %eax
1899 xorl %esi, %edx
1900 andl $0xfcfcfcfc, %eax
1901 andl $0xcfcfcfcf, %edx
1902 movb %al, %bl
1903 movb %ah, %cl
1904 rorl $4, %edx
1905 movl des_SPtrans(%ebx),%ebp
1906 movb %dl, %bl
1907 xorl %ebp, %edi
1908 movl 0x200+des_SPtrans(%ecx),%ebp
1909 xorl %ebp, %edi
1910 movb %dh, %cl
1911 shrl $16, %eax
1912 movl 0x100+des_SPtrans(%ebx),%ebp
1913 xorl %ebp, %edi
1914 movb %ah, %bl
1915 shrl $16, %edx
1916 movl 0x300+des_SPtrans(%ecx),%ebp
1917 xorl %ebp, %edi
1918 movl 24(%esp), %ebp
1919 movb %dh, %cl
1920 andl $0xff, %eax
1921 andl $0xff, %edx
1922 movl 0x600+des_SPtrans(%ebx),%ebx
1923 xorl %ebx, %edi
1924 movl 0x700+des_SPtrans(%ecx),%ebx
1925 xorl %ebx, %edi
1926 movl 0x400+des_SPtrans(%eax),%ebx
1927 xorl %ebx, %edi
1928 movl 0x500+des_SPtrans(%edx),%ebx
1929 xorl %ebx, %edi
1930
1931 /* Round 15 */
1932 movl 120(%ebp), %eax
1933 xorl %ebx, %ebx
1934 movl 124(%ebp), %edx
1935 xorl %edi, %eax
1936 xorl %edi, %edx
1937 andl $0xfcfcfcfc, %eax
1938 andl $0xcfcfcfcf, %edx
1939 movb %al, %bl
1940 movb %ah, %cl
1941 rorl $4, %edx
1942 movl des_SPtrans(%ebx),%ebp
1943 movb %dl, %bl
1944 xorl %ebp, %esi
1945 movl 0x200+des_SPtrans(%ecx),%ebp
1946 xorl %ebp, %esi
1947 movb %dh, %cl
1948 shrl $16, %eax
1949 movl 0x100+des_SPtrans(%ebx),%ebp
1950 xorl %ebp, %esi
1951 movb %ah, %bl
1952 shrl $16, %edx
1953 movl 0x300+des_SPtrans(%ecx),%ebp
1954 xorl %ebp, %esi
1955 movl 24(%esp), %ebp
1956 movb %dh, %cl
1957 andl $0xff, %eax
1958 andl $0xff, %edx
1959 movl 0x600+des_SPtrans(%ebx),%ebx
1960 xorl %ebx, %esi
1961 movl 0x700+des_SPtrans(%ecx),%ebx
1962 xorl %ebx, %esi
1963 movl 0x400+des_SPtrans(%eax),%ebx
1964 xorl %ebx, %esi
1965 movl 0x500+des_SPtrans(%edx),%ebx
1966 xorl %ebx, %esi
1967 jmp .L003end
1968.L002start_decrypt:
1969
1970 /* Round 15 */
1971 movl 120(%ebp), %eax
1972 xorl %ebx, %ebx
1973 movl 124(%ebp), %edx
1974 xorl %esi, %eax
1975 xorl %esi, %edx
1976 andl $0xfcfcfcfc, %eax
1977 andl $0xcfcfcfcf, %edx
1978 movb %al, %bl
1979 movb %ah, %cl
1980 rorl $4, %edx
1981 movl des_SPtrans(%ebx),%ebp
1982 movb %dl, %bl
1983 xorl %ebp, %edi
1984 movl 0x200+des_SPtrans(%ecx),%ebp
1985 xorl %ebp, %edi
1986 movb %dh, %cl
1987 shrl $16, %eax
1988 movl 0x100+des_SPtrans(%ebx),%ebp
1989 xorl %ebp, %edi
1990 movb %ah, %bl
1991 shrl $16, %edx
1992 movl 0x300+des_SPtrans(%ecx),%ebp
1993 xorl %ebp, %edi
1994 movl 24(%esp), %ebp
1995 movb %dh, %cl
1996 andl $0xff, %eax
1997 andl $0xff, %edx
1998 movl 0x600+des_SPtrans(%ebx),%ebx
1999 xorl %ebx, %edi
2000 movl 0x700+des_SPtrans(%ecx),%ebx
2001 xorl %ebx, %edi
2002 movl 0x400+des_SPtrans(%eax),%ebx
2003 xorl %ebx, %edi
2004 movl 0x500+des_SPtrans(%edx),%ebx
2005 xorl %ebx, %edi
2006
2007 /* Round 14 */
2008 movl 112(%ebp), %eax
2009 xorl %ebx, %ebx
2010 movl 116(%ebp), %edx
2011 xorl %edi, %eax
2012 xorl %edi, %edx
2013 andl $0xfcfcfcfc, %eax
2014 andl $0xcfcfcfcf, %edx
2015 movb %al, %bl
2016 movb %ah, %cl
2017 rorl $4, %edx
2018 movl des_SPtrans(%ebx),%ebp
2019 movb %dl, %bl
2020 xorl %ebp, %esi
2021 movl 0x200+des_SPtrans(%ecx),%ebp
2022 xorl %ebp, %esi
2023 movb %dh, %cl
2024 shrl $16, %eax
2025 movl 0x100+des_SPtrans(%ebx),%ebp
2026 xorl %ebp, %esi
2027 movb %ah, %bl
2028 shrl $16, %edx
2029 movl 0x300+des_SPtrans(%ecx),%ebp
2030 xorl %ebp, %esi
2031 movl 24(%esp), %ebp
2032 movb %dh, %cl
2033 andl $0xff, %eax
2034 andl $0xff, %edx
2035 movl 0x600+des_SPtrans(%ebx),%ebx
2036 xorl %ebx, %esi
2037 movl 0x700+des_SPtrans(%ecx),%ebx
2038 xorl %ebx, %esi
2039 movl 0x400+des_SPtrans(%eax),%ebx
2040 xorl %ebx, %esi
2041 movl 0x500+des_SPtrans(%edx),%ebx
2042 xorl %ebx, %esi
2043
2044 /* Round 13 */
2045 movl 104(%ebp), %eax
2046 xorl %ebx, %ebx
2047 movl 108(%ebp), %edx
2048 xorl %esi, %eax
2049 xorl %esi, %edx
2050 andl $0xfcfcfcfc, %eax
2051 andl $0xcfcfcfcf, %edx
2052 movb %al, %bl
2053 movb %ah, %cl
2054 rorl $4, %edx
2055 movl des_SPtrans(%ebx),%ebp
2056 movb %dl, %bl
2057 xorl %ebp, %edi
2058 movl 0x200+des_SPtrans(%ecx),%ebp
2059 xorl %ebp, %edi
2060 movb %dh, %cl
2061 shrl $16, %eax
2062 movl 0x100+des_SPtrans(%ebx),%ebp
2063 xorl %ebp, %edi
2064 movb %ah, %bl
2065 shrl $16, %edx
2066 movl 0x300+des_SPtrans(%ecx),%ebp
2067 xorl %ebp, %edi
2068 movl 24(%esp), %ebp
2069 movb %dh, %cl
2070 andl $0xff, %eax
2071 andl $0xff, %edx
2072 movl 0x600+des_SPtrans(%ebx),%ebx
2073 xorl %ebx, %edi
2074 movl 0x700+des_SPtrans(%ecx),%ebx
2075 xorl %ebx, %edi
2076 movl 0x400+des_SPtrans(%eax),%ebx
2077 xorl %ebx, %edi
2078 movl 0x500+des_SPtrans(%edx),%ebx
2079 xorl %ebx, %edi
2080
2081 /* Round 12 */
2082 movl 96(%ebp), %eax
2083 xorl %ebx, %ebx
2084 movl 100(%ebp), %edx
2085 xorl %edi, %eax
2086 xorl %edi, %edx
2087 andl $0xfcfcfcfc, %eax
2088 andl $0xcfcfcfcf, %edx
2089 movb %al, %bl
2090 movb %ah, %cl
2091 rorl $4, %edx
2092 movl des_SPtrans(%ebx),%ebp
2093 movb %dl, %bl
2094 xorl %ebp, %esi
2095 movl 0x200+des_SPtrans(%ecx),%ebp
2096 xorl %ebp, %esi
2097 movb %dh, %cl
2098 shrl $16, %eax
2099 movl 0x100+des_SPtrans(%ebx),%ebp
2100 xorl %ebp, %esi
2101 movb %ah, %bl
2102 shrl $16, %edx
2103 movl 0x300+des_SPtrans(%ecx),%ebp
2104 xorl %ebp, %esi
2105 movl 24(%esp), %ebp
2106 movb %dh, %cl
2107 andl $0xff, %eax
2108 andl $0xff, %edx
2109 movl 0x600+des_SPtrans(%ebx),%ebx
2110 xorl %ebx, %esi
2111 movl 0x700+des_SPtrans(%ecx),%ebx
2112 xorl %ebx, %esi
2113 movl 0x400+des_SPtrans(%eax),%ebx
2114 xorl %ebx, %esi
2115 movl 0x500+des_SPtrans(%edx),%ebx
2116 xorl %ebx, %esi
2117
2118 /* Round 11 */
2119 movl 88(%ebp), %eax
2120 xorl %ebx, %ebx
2121 movl 92(%ebp), %edx
2122 xorl %esi, %eax
2123 xorl %esi, %edx
2124 andl $0xfcfcfcfc, %eax
2125 andl $0xcfcfcfcf, %edx
2126 movb %al, %bl
2127 movb %ah, %cl
2128 rorl $4, %edx
2129 movl des_SPtrans(%ebx),%ebp
2130 movb %dl, %bl
2131 xorl %ebp, %edi
2132 movl 0x200+des_SPtrans(%ecx),%ebp
2133 xorl %ebp, %edi
2134 movb %dh, %cl
2135 shrl $16, %eax
2136 movl 0x100+des_SPtrans(%ebx),%ebp
2137 xorl %ebp, %edi
2138 movb %ah, %bl
2139 shrl $16, %edx
2140 movl 0x300+des_SPtrans(%ecx),%ebp
2141 xorl %ebp, %edi
2142 movl 24(%esp), %ebp
2143 movb %dh, %cl
2144 andl $0xff, %eax
2145 andl $0xff, %edx
2146 movl 0x600+des_SPtrans(%ebx),%ebx
2147 xorl %ebx, %edi
2148 movl 0x700+des_SPtrans(%ecx),%ebx
2149 xorl %ebx, %edi
2150 movl 0x400+des_SPtrans(%eax),%ebx
2151 xorl %ebx, %edi
2152 movl 0x500+des_SPtrans(%edx),%ebx
2153 xorl %ebx, %edi
2154
2155 /* Round 10 */
2156 movl 80(%ebp), %eax
2157 xorl %ebx, %ebx
2158 movl 84(%ebp), %edx
2159 xorl %edi, %eax
2160 xorl %edi, %edx
2161 andl $0xfcfcfcfc, %eax
2162 andl $0xcfcfcfcf, %edx
2163 movb %al, %bl
2164 movb %ah, %cl
2165 rorl $4, %edx
2166 movl des_SPtrans(%ebx),%ebp
2167 movb %dl, %bl
2168 xorl %ebp, %esi
2169 movl 0x200+des_SPtrans(%ecx),%ebp
2170 xorl %ebp, %esi
2171 movb %dh, %cl
2172 shrl $16, %eax
2173 movl 0x100+des_SPtrans(%ebx),%ebp
2174 xorl %ebp, %esi
2175 movb %ah, %bl
2176 shrl $16, %edx
2177 movl 0x300+des_SPtrans(%ecx),%ebp
2178 xorl %ebp, %esi
2179 movl 24(%esp), %ebp
2180 movb %dh, %cl
2181 andl $0xff, %eax
2182 andl $0xff, %edx
2183 movl 0x600+des_SPtrans(%ebx),%ebx
2184 xorl %ebx, %esi
2185 movl 0x700+des_SPtrans(%ecx),%ebx
2186 xorl %ebx, %esi
2187 movl 0x400+des_SPtrans(%eax),%ebx
2188 xorl %ebx, %esi
2189 movl 0x500+des_SPtrans(%edx),%ebx
2190 xorl %ebx, %esi
2191
2192 /* Round 9 */
2193 movl 72(%ebp), %eax
2194 xorl %ebx, %ebx
2195 movl 76(%ebp), %edx
2196 xorl %esi, %eax
2197 xorl %esi, %edx
2198 andl $0xfcfcfcfc, %eax
2199 andl $0xcfcfcfcf, %edx
2200 movb %al, %bl
2201 movb %ah, %cl
2202 rorl $4, %edx
2203 movl des_SPtrans(%ebx),%ebp
2204 movb %dl, %bl
2205 xorl %ebp, %edi
2206 movl 0x200+des_SPtrans(%ecx),%ebp
2207 xorl %ebp, %edi
2208 movb %dh, %cl
2209 shrl $16, %eax
2210 movl 0x100+des_SPtrans(%ebx),%ebp
2211 xorl %ebp, %edi
2212 movb %ah, %bl
2213 shrl $16, %edx
2214 movl 0x300+des_SPtrans(%ecx),%ebp
2215 xorl %ebp, %edi
2216 movl 24(%esp), %ebp
2217 movb %dh, %cl
2218 andl $0xff, %eax
2219 andl $0xff, %edx
2220 movl 0x600+des_SPtrans(%ebx),%ebx
2221 xorl %ebx, %edi
2222 movl 0x700+des_SPtrans(%ecx),%ebx
2223 xorl %ebx, %edi
2224 movl 0x400+des_SPtrans(%eax),%ebx
2225 xorl %ebx, %edi
2226 movl 0x500+des_SPtrans(%edx),%ebx
2227 xorl %ebx, %edi
2228
2229 /* Round 8 */
2230 movl 64(%ebp), %eax
2231 xorl %ebx, %ebx
2232 movl 68(%ebp), %edx
2233 xorl %edi, %eax
2234 xorl %edi, %edx
2235 andl $0xfcfcfcfc, %eax
2236 andl $0xcfcfcfcf, %edx
2237 movb %al, %bl
2238 movb %ah, %cl
2239 rorl $4, %edx
2240 movl des_SPtrans(%ebx),%ebp
2241 movb %dl, %bl
2242 xorl %ebp, %esi
2243 movl 0x200+des_SPtrans(%ecx),%ebp
2244 xorl %ebp, %esi
2245 movb %dh, %cl
2246 shrl $16, %eax
2247 movl 0x100+des_SPtrans(%ebx),%ebp
2248 xorl %ebp, %esi
2249 movb %ah, %bl
2250 shrl $16, %edx
2251 movl 0x300+des_SPtrans(%ecx),%ebp
2252 xorl %ebp, %esi
2253 movl 24(%esp), %ebp
2254 movb %dh, %cl
2255 andl $0xff, %eax
2256 andl $0xff, %edx
2257 movl 0x600+des_SPtrans(%ebx),%ebx
2258 xorl %ebx, %esi
2259 movl 0x700+des_SPtrans(%ecx),%ebx
2260 xorl %ebx, %esi
2261 movl 0x400+des_SPtrans(%eax),%ebx
2262 xorl %ebx, %esi
2263 movl 0x500+des_SPtrans(%edx),%ebx
2264 xorl %ebx, %esi
2265
2266 /* Round 7 */
2267 movl 56(%ebp), %eax
2268 xorl %ebx, %ebx
2269 movl 60(%ebp), %edx
2270 xorl %esi, %eax
2271 xorl %esi, %edx
2272 andl $0xfcfcfcfc, %eax
2273 andl $0xcfcfcfcf, %edx
2274 movb %al, %bl
2275 movb %ah, %cl
2276 rorl $4, %edx
2277 movl des_SPtrans(%ebx),%ebp
2278 movb %dl, %bl
2279 xorl %ebp, %edi
2280 movl 0x200+des_SPtrans(%ecx),%ebp
2281 xorl %ebp, %edi
2282 movb %dh, %cl
2283 shrl $16, %eax
2284 movl 0x100+des_SPtrans(%ebx),%ebp
2285 xorl %ebp, %edi
2286 movb %ah, %bl
2287 shrl $16, %edx
2288 movl 0x300+des_SPtrans(%ecx),%ebp
2289 xorl %ebp, %edi
2290 movl 24(%esp), %ebp
2291 movb %dh, %cl
2292 andl $0xff, %eax
2293 andl $0xff, %edx
2294 movl 0x600+des_SPtrans(%ebx),%ebx
2295 xorl %ebx, %edi
2296 movl 0x700+des_SPtrans(%ecx),%ebx
2297 xorl %ebx, %edi
2298 movl 0x400+des_SPtrans(%eax),%ebx
2299 xorl %ebx, %edi
2300 movl 0x500+des_SPtrans(%edx),%ebx
2301 xorl %ebx, %edi
2302
2303 /* Round 6 */
2304 movl 48(%ebp), %eax
2305 xorl %ebx, %ebx
2306 movl 52(%ebp), %edx
2307 xorl %edi, %eax
2308 xorl %edi, %edx
2309 andl $0xfcfcfcfc, %eax
2310 andl $0xcfcfcfcf, %edx
2311 movb %al, %bl
2312 movb %ah, %cl
2313 rorl $4, %edx
2314 movl des_SPtrans(%ebx),%ebp
2315 movb %dl, %bl
2316 xorl %ebp, %esi
2317 movl 0x200+des_SPtrans(%ecx),%ebp
2318 xorl %ebp, %esi
2319 movb %dh, %cl
2320 shrl $16, %eax
2321 movl 0x100+des_SPtrans(%ebx),%ebp
2322 xorl %ebp, %esi
2323 movb %ah, %bl
2324 shrl $16, %edx
2325 movl 0x300+des_SPtrans(%ecx),%ebp
2326 xorl %ebp, %esi
2327 movl 24(%esp), %ebp
2328 movb %dh, %cl
2329 andl $0xff, %eax
2330 andl $0xff, %edx
2331 movl 0x600+des_SPtrans(%ebx),%ebx
2332 xorl %ebx, %esi
2333 movl 0x700+des_SPtrans(%ecx),%ebx
2334 xorl %ebx, %esi
2335 movl 0x400+des_SPtrans(%eax),%ebx
2336 xorl %ebx, %esi
2337 movl 0x500+des_SPtrans(%edx),%ebx
2338 xorl %ebx, %esi
2339
2340 /* Round 5 */
2341 movl 40(%ebp), %eax
2342 xorl %ebx, %ebx
2343 movl 44(%ebp), %edx
2344 xorl %esi, %eax
2345 xorl %esi, %edx
2346 andl $0xfcfcfcfc, %eax
2347 andl $0xcfcfcfcf, %edx
2348 movb %al, %bl
2349 movb %ah, %cl
2350 rorl $4, %edx
2351 movl des_SPtrans(%ebx),%ebp
2352 movb %dl, %bl
2353 xorl %ebp, %edi
2354 movl 0x200+des_SPtrans(%ecx),%ebp
2355 xorl %ebp, %edi
2356 movb %dh, %cl
2357 shrl $16, %eax
2358 movl 0x100+des_SPtrans(%ebx),%ebp
2359 xorl %ebp, %edi
2360 movb %ah, %bl
2361 shrl $16, %edx
2362 movl 0x300+des_SPtrans(%ecx),%ebp
2363 xorl %ebp, %edi
2364 movl 24(%esp), %ebp
2365 movb %dh, %cl
2366 andl $0xff, %eax
2367 andl $0xff, %edx
2368 movl 0x600+des_SPtrans(%ebx),%ebx
2369 xorl %ebx, %edi
2370 movl 0x700+des_SPtrans(%ecx),%ebx
2371 xorl %ebx, %edi
2372 movl 0x400+des_SPtrans(%eax),%ebx
2373 xorl %ebx, %edi
2374 movl 0x500+des_SPtrans(%edx),%ebx
2375 xorl %ebx, %edi
2376
2377 /* Round 4 */
2378 movl 32(%ebp), %eax
2379 xorl %ebx, %ebx
2380 movl 36(%ebp), %edx
2381 xorl %edi, %eax
2382 xorl %edi, %edx
2383 andl $0xfcfcfcfc, %eax
2384 andl $0xcfcfcfcf, %edx
2385 movb %al, %bl
2386 movb %ah, %cl
2387 rorl $4, %edx
2388 movl des_SPtrans(%ebx),%ebp
2389 movb %dl, %bl
2390 xorl %ebp, %esi
2391 movl 0x200+des_SPtrans(%ecx),%ebp
2392 xorl %ebp, %esi
2393 movb %dh, %cl
2394 shrl $16, %eax
2395 movl 0x100+des_SPtrans(%ebx),%ebp
2396 xorl %ebp, %esi
2397 movb %ah, %bl
2398 shrl $16, %edx
2399 movl 0x300+des_SPtrans(%ecx),%ebp
2400 xorl %ebp, %esi
2401 movl 24(%esp), %ebp
2402 movb %dh, %cl
2403 andl $0xff, %eax
2404 andl $0xff, %edx
2405 movl 0x600+des_SPtrans(%ebx),%ebx
2406 xorl %ebx, %esi
2407 movl 0x700+des_SPtrans(%ecx),%ebx
2408 xorl %ebx, %esi
2409 movl 0x400+des_SPtrans(%eax),%ebx
2410 xorl %ebx, %esi
2411 movl 0x500+des_SPtrans(%edx),%ebx
2412 xorl %ebx, %esi
2413
2414 /* Round 3 */
2415 movl 24(%ebp), %eax
2416 xorl %ebx, %ebx
2417 movl 28(%ebp), %edx
2418 xorl %esi, %eax
2419 xorl %esi, %edx
2420 andl $0xfcfcfcfc, %eax
2421 andl $0xcfcfcfcf, %edx
2422 movb %al, %bl
2423 movb %ah, %cl
2424 rorl $4, %edx
2425 movl des_SPtrans(%ebx),%ebp
2426 movb %dl, %bl
2427 xorl %ebp, %edi
2428 movl 0x200+des_SPtrans(%ecx),%ebp
2429 xorl %ebp, %edi
2430 movb %dh, %cl
2431 shrl $16, %eax
2432 movl 0x100+des_SPtrans(%ebx),%ebp
2433 xorl %ebp, %edi
2434 movb %ah, %bl
2435 shrl $16, %edx
2436 movl 0x300+des_SPtrans(%ecx),%ebp
2437 xorl %ebp, %edi
2438 movl 24(%esp), %ebp
2439 movb %dh, %cl
2440 andl $0xff, %eax
2441 andl $0xff, %edx
2442 movl 0x600+des_SPtrans(%ebx),%ebx
2443 xorl %ebx, %edi
2444 movl 0x700+des_SPtrans(%ecx),%ebx
2445 xorl %ebx, %edi
2446 movl 0x400+des_SPtrans(%eax),%ebx
2447 xorl %ebx, %edi
2448 movl 0x500+des_SPtrans(%edx),%ebx
2449 xorl %ebx, %edi
2450
2451 /* Round 2 */
2452 movl 16(%ebp), %eax
2453 xorl %ebx, %ebx
2454 movl 20(%ebp), %edx
2455 xorl %edi, %eax
2456 xorl %edi, %edx
2457 andl $0xfcfcfcfc, %eax
2458 andl $0xcfcfcfcf, %edx
2459 movb %al, %bl
2460 movb %ah, %cl
2461 rorl $4, %edx
2462 movl des_SPtrans(%ebx),%ebp
2463 movb %dl, %bl
2464 xorl %ebp, %esi
2465 movl 0x200+des_SPtrans(%ecx),%ebp
2466 xorl %ebp, %esi
2467 movb %dh, %cl
2468 shrl $16, %eax
2469 movl 0x100+des_SPtrans(%ebx),%ebp
2470 xorl %ebp, %esi
2471 movb %ah, %bl
2472 shrl $16, %edx
2473 movl 0x300+des_SPtrans(%ecx),%ebp
2474 xorl %ebp, %esi
2475 movl 24(%esp), %ebp
2476 movb %dh, %cl
2477 andl $0xff, %eax
2478 andl $0xff, %edx
2479 movl 0x600+des_SPtrans(%ebx),%ebx
2480 xorl %ebx, %esi
2481 movl 0x700+des_SPtrans(%ecx),%ebx
2482 xorl %ebx, %esi
2483 movl 0x400+des_SPtrans(%eax),%ebx
2484 xorl %ebx, %esi
2485 movl 0x500+des_SPtrans(%edx),%ebx
2486 xorl %ebx, %esi
2487
2488 /* Round 1 */
2489 movl 8(%ebp), %eax
2490 xorl %ebx, %ebx
2491 movl 12(%ebp), %edx
2492 xorl %esi, %eax
2493 xorl %esi, %edx
2494 andl $0xfcfcfcfc, %eax
2495 andl $0xcfcfcfcf, %edx
2496 movb %al, %bl
2497 movb %ah, %cl
2498 rorl $4, %edx
2499 movl des_SPtrans(%ebx),%ebp
2500 movb %dl, %bl
2501 xorl %ebp, %edi
2502 movl 0x200+des_SPtrans(%ecx),%ebp
2503 xorl %ebp, %edi
2504 movb %dh, %cl
2505 shrl $16, %eax
2506 movl 0x100+des_SPtrans(%ebx),%ebp
2507 xorl %ebp, %edi
2508 movb %ah, %bl
2509 shrl $16, %edx
2510 movl 0x300+des_SPtrans(%ecx),%ebp
2511 xorl %ebp, %edi
2512 movl 24(%esp), %ebp
2513 movb %dh, %cl
2514 andl $0xff, %eax
2515 andl $0xff, %edx
2516 movl 0x600+des_SPtrans(%ebx),%ebx
2517 xorl %ebx, %edi
2518 movl 0x700+des_SPtrans(%ecx),%ebx
2519 xorl %ebx, %edi
2520 movl 0x400+des_SPtrans(%eax),%ebx
2521 xorl %ebx, %edi
2522 movl 0x500+des_SPtrans(%edx),%ebx
2523 xorl %ebx, %edi
2524
2525 /* Round 0 */
2526 movl (%ebp), %eax
2527 xorl %ebx, %ebx
2528 movl 4(%ebp), %edx
2529 xorl %edi, %eax
2530 xorl %edi, %edx
2531 andl $0xfcfcfcfc, %eax
2532 andl $0xcfcfcfcf, %edx
2533 movb %al, %bl
2534 movb %ah, %cl
2535 rorl $4, %edx
2536 movl des_SPtrans(%ebx),%ebp
2537 movb %dl, %bl
2538 xorl %ebp, %esi
2539 movl 0x200+des_SPtrans(%ecx),%ebp
2540 xorl %ebp, %esi
2541 movb %dh, %cl
2542 shrl $16, %eax
2543 movl 0x100+des_SPtrans(%ebx),%ebp
2544 xorl %ebp, %esi
2545 movb %ah, %bl
2546 shrl $16, %edx
2547 movl 0x300+des_SPtrans(%ecx),%ebp
2548 xorl %ebp, %esi
2549 movl 24(%esp), %ebp
2550 movb %dh, %cl
2551 andl $0xff, %eax
2552 andl $0xff, %edx
2553 movl 0x600+des_SPtrans(%ebx),%ebx
2554 xorl %ebx, %esi
2555 movl 0x700+des_SPtrans(%ecx),%ebx
2556 xorl %ebx, %esi
2557 movl 0x400+des_SPtrans(%eax),%ebx
2558 xorl %ebx, %esi
2559 movl 0x500+des_SPtrans(%edx),%ebx
2560 xorl %ebx, %esi
2561.L003end:
2562
2563 /* Fixup */
2564 rorl $3, %edi
2565 movl 20(%esp), %eax
2566 rorl $3, %esi
2567 movl %edi, (%eax)
2568 movl %esi, 4(%eax)
2569 popl %ebp
2570 popl %ebx
2571 popl %edi
2572 popl %esi
2573 ret
2574.des_encrypt2_end:
2575 SIZE(des_encrypt2,.des_encrypt2_end-des_encrypt2)
2576.ident "desasm.pl"
2577.text
2578 .align ALIGN
2579.globl des_encrypt3
2580 TYPE(des_encrypt3,@function)
2581des_encrypt3:
2582 pushl %ebx
2583 movl 8(%esp), %ebx
2584 pushl %ebp
2585 pushl %esi
2586 pushl %edi
2587
2588 /* Load the data words */
2589 movl (%ebx), %edi
2590 movl 4(%ebx), %esi
2591 subl $12, %esp
2592
2593 /* IP */
2594 roll $4, %edi
2595 movl %edi, %edx
2596 xorl %esi, %edi
2597 andl $0xf0f0f0f0, %edi
2598 xorl %edi, %edx
2599 xorl %edi, %esi
2600
2601 roll $20, %esi
2602 movl %esi, %edi
2603 xorl %edx, %esi
2604 andl $0xfff0000f, %esi
2605 xorl %esi, %edi
2606 xorl %esi, %edx
2607
2608 roll $14, %edi
2609 movl %edi, %esi
2610 xorl %edx, %edi
2611 andl $0x33333333, %edi
2612 xorl %edi, %esi
2613 xorl %edi, %edx
2614
2615 roll $22, %edx
2616 movl %edx, %edi
2617 xorl %esi, %edx
2618 andl $0x03fc03fc, %edx
2619 xorl %edx, %edi
2620 xorl %edx, %esi
2621
2622 roll $9, %edi
2623 movl %edi, %edx
2624 xorl %esi, %edi
2625 andl $0xaaaaaaaa, %edi
2626 xorl %edi, %edx
2627 xorl %edi, %esi
2628
2629 rorl $3, %edx
2630 rorl $2, %esi
2631 movl %esi, 4(%ebx)
2632 movl 36(%esp), %eax
2633 movl %edx, (%ebx)
2634 movl 40(%esp), %edi
2635 movl 44(%esp), %esi
2636 movl $1, 8(%esp)
2637 movl %eax, 4(%esp)
2638 movl %ebx, (%esp)
2639 call des_encrypt2
2640 movl $0, 8(%esp)
2641 movl %edi, 4(%esp)
2642 movl %ebx, (%esp)
2643 call des_encrypt2
2644 movl $1, 8(%esp)
2645 movl %esi, 4(%esp)
2646 movl %ebx, (%esp)
2647 call des_encrypt2
2648 addl $12, %esp
2649 movl (%ebx), %edi
2650 movl 4(%ebx), %esi
2651
2652 /* FP */
2653 roll $2, %esi
2654 roll $3, %edi
2655 movl %edi, %eax
2656 xorl %esi, %edi
2657 andl $0xaaaaaaaa, %edi
2658 xorl %edi, %eax
2659 xorl %edi, %esi
2660
2661 roll $23, %eax
2662 movl %eax, %edi
2663 xorl %esi, %eax
2664 andl $0x03fc03fc, %eax
2665 xorl %eax, %edi
2666 xorl %eax, %esi
2667
2668 roll $10, %edi
2669 movl %edi, %eax
2670 xorl %esi, %edi
2671 andl $0x33333333, %edi
2672 xorl %edi, %eax
2673 xorl %edi, %esi
2674
2675 roll $18, %esi
2676 movl %esi, %edi
2677 xorl %eax, %esi
2678 andl $0xfff0000f, %esi
2679 xorl %esi, %edi
2680 xorl %esi, %eax
2681
2682 roll $12, %edi
2683 movl %edi, %esi
2684 xorl %eax, %edi
2685 andl $0xf0f0f0f0, %edi
2686 xorl %edi, %esi
2687 xorl %edi, %eax
2688
2689 rorl $4, %eax
2690 movl %eax, (%ebx)
2691 movl %esi, 4(%ebx)
2692 popl %edi
2693 popl %esi
2694 popl %ebp
2695 popl %ebx
2696 ret
2697.des_encrypt3_end:
2698 SIZE(des_encrypt3,.des_encrypt3_end-des_encrypt3)
2699.ident "desasm.pl"
2700.text
2701 .align ALIGN
2702.globl des_decrypt3
2703 TYPE(des_decrypt3,@function)
2704des_decrypt3:
2705 pushl %ebx
2706 movl 8(%esp), %ebx
2707 pushl %ebp
2708 pushl %esi
2709 pushl %edi
2710
2711 /* Load the data words */
2712 movl (%ebx), %edi
2713 movl 4(%ebx), %esi
2714 subl $12, %esp
2715
2716 /* IP */
2717 roll $4, %edi
2718 movl %edi, %edx
2719 xorl %esi, %edi
2720 andl $0xf0f0f0f0, %edi
2721 xorl %edi, %edx
2722 xorl %edi, %esi
2723
2724 roll $20, %esi
2725 movl %esi, %edi
2726 xorl %edx, %esi
2727 andl $0xfff0000f, %esi
2728 xorl %esi, %edi
2729 xorl %esi, %edx
2730
2731 roll $14, %edi
2732 movl %edi, %esi
2733 xorl %edx, %edi
2734 andl $0x33333333, %edi
2735 xorl %edi, %esi
2736 xorl %edi, %edx
2737
2738 roll $22, %edx
2739 movl %edx, %edi
2740 xorl %esi, %edx
2741 andl $0x03fc03fc, %edx
2742 xorl %edx, %edi
2743 xorl %edx, %esi
2744
2745 roll $9, %edi
2746 movl %edi, %edx
2747 xorl %esi, %edi
2748 andl $0xaaaaaaaa, %edi
2749 xorl %edi, %edx
2750 xorl %edi, %esi
2751
2752 rorl $3, %edx
2753 rorl $2, %esi
2754 movl %esi, 4(%ebx)
2755 movl 36(%esp), %esi
2756 movl %edx, (%ebx)
2757 movl 40(%esp), %edi
2758 movl 44(%esp), %eax
2759 movl $0, 8(%esp)
2760 movl %eax, 4(%esp)
2761 movl %ebx, (%esp)
2762 call des_encrypt2
2763 movl $1, 8(%esp)
2764 movl %edi, 4(%esp)
2765 movl %ebx, (%esp)
2766 call des_encrypt2
2767 movl $0, 8(%esp)
2768 movl %esi, 4(%esp)
2769 movl %ebx, (%esp)
2770 call des_encrypt2
2771 addl $12, %esp
2772 movl (%ebx), %edi
2773 movl 4(%ebx), %esi
2774
2775 /* FP */
2776 roll $2, %esi
2777 roll $3, %edi
2778 movl %edi, %eax
2779 xorl %esi, %edi
2780 andl $0xaaaaaaaa, %edi
2781 xorl %edi, %eax
2782 xorl %edi, %esi
2783
2784 roll $23, %eax
2785 movl %eax, %edi
2786 xorl %esi, %eax
2787 andl $0x03fc03fc, %eax
2788 xorl %eax, %edi
2789 xorl %eax, %esi
2790
2791 roll $10, %edi
2792 movl %edi, %eax
2793 xorl %esi, %edi
2794 andl $0x33333333, %edi
2795 xorl %edi, %eax
2796 xorl %edi, %esi
2797
2798 roll $18, %esi
2799 movl %esi, %edi
2800 xorl %eax, %esi
2801 andl $0xfff0000f, %esi
2802 xorl %esi, %edi
2803 xorl %esi, %eax
2804
2805 roll $12, %edi
2806 movl %edi, %esi
2807 xorl %eax, %edi
2808 andl $0xf0f0f0f0, %edi
2809 xorl %edi, %esi
2810 xorl %edi, %eax
2811
2812 rorl $4, %eax
2813 movl %eax, (%ebx)
2814 movl %esi, 4(%ebx)
2815 popl %edi
2816 popl %esi
2817 popl %ebp
2818 popl %ebx
2819 ret
2820.des_decrypt3_end:
2821 SIZE(des_decrypt3,.des_decrypt3_end-des_decrypt3)
2822.ident "desasm.pl"
2823.text
2824 .align ALIGN
2825.globl des_ncbc_encrypt
2826 TYPE(des_ncbc_encrypt,@function)
2827des_ncbc_encrypt:
2828
2829 pushl %ebp
2830 pushl %ebx
2831 pushl %esi
2832 pushl %edi
2833 movl 28(%esp), %ebp
2834 /* getting iv ptr from parameter 4 */
2835 movl 36(%esp), %ebx
2836 movl (%ebx), %esi
2837 movl 4(%ebx), %edi
2838 pushl %edi
2839 pushl %esi
2840 pushl %edi
2841 pushl %esi
2842 movl %esp, %ebx
2843 movl 36(%esp), %esi
2844 movl 40(%esp), %edi
2845 /* getting encrypt flag from parameter 5 */
2846 movl 56(%esp), %ecx
2847 /* get and push parameter 5 */
2848 pushl %ecx
2849 /* get and push parameter 3 */
2850 movl 52(%esp), %eax
2851 pushl %eax
2852 pushl %ebx
2853 cmpl $0, %ecx
2854 jz .L004decrypt
2855 andl $4294967288, %ebp
2856 movl 12(%esp), %eax
2857 movl 16(%esp), %ebx
2858 jz .L005encrypt_finish
2859.L006encrypt_loop:
2860 movl (%esi), %ecx
2861 movl 4(%esi), %edx
2862 xorl %ecx, %eax
2863 xorl %edx, %ebx
2864 movl %eax, 12(%esp)
2865 movl %ebx, 16(%esp)
2866 call des_encrypt
2867 movl 12(%esp), %eax
2868 movl 16(%esp), %ebx
2869 movl %eax, (%edi)
2870 movl %ebx, 4(%edi)
2871 addl $8, %esi
2872 addl $8, %edi
2873 subl $8, %ebp
2874 jnz .L006encrypt_loop
2875.L005encrypt_finish:
2876 movl 56(%esp), %ebp
2877 andl $7, %ebp
2878 jz .L007finish
2879 xorl %ecx, %ecx
2880 xorl %edx, %edx
2881 movl .L008cbc_enc_jmp_table(,%ebp,4),%ebp
2882 jmp *%ebp
2883.L009ej7:
2884 movb 6(%esi), %dh
2885 sall $8, %edx
2886.L010ej6:
2887 movb 5(%esi), %dh
2888.L011ej5:
2889 movb 4(%esi), %dl
2890.L012ej4:
2891 movl (%esi), %ecx
2892 jmp .L013ejend
2893.L014ej3:
2894 movb 2(%esi), %ch
2895 sall $8, %ecx
2896.L015ej2:
2897 movb 1(%esi), %ch
2898.L016ej1:
2899 movb (%esi), %cl
2900.L013ejend:
2901 xorl %ecx, %eax
2902 xorl %edx, %ebx
2903 movl %eax, 12(%esp)
2904 movl %ebx, 16(%esp)
2905 call des_encrypt
2906 movl 12(%esp), %eax
2907 movl 16(%esp), %ebx
2908 movl %eax, (%edi)
2909 movl %ebx, 4(%edi)
2910 jmp .L007finish
2911.align ALIGN
2912.L004decrypt:
2913 andl $4294967288, %ebp
2914 movl 20(%esp), %eax
2915 movl 24(%esp), %ebx
2916 jz .L017decrypt_finish
2917.L018decrypt_loop:
2918 movl (%esi), %eax
2919 movl 4(%esi), %ebx
2920 movl %eax, 12(%esp)
2921 movl %ebx, 16(%esp)
2922 call des_encrypt
2923 movl 12(%esp), %eax
2924 movl 16(%esp), %ebx
2925 movl 20(%esp), %ecx
2926 movl 24(%esp), %edx
2927 xorl %eax, %ecx
2928 xorl %ebx, %edx
2929 movl (%esi), %eax
2930 movl 4(%esi), %ebx
2931 movl %ecx, (%edi)
2932 movl %edx, 4(%edi)
2933 movl %eax, 20(%esp)
2934 movl %ebx, 24(%esp)
2935 addl $8, %esi
2936 addl $8, %edi
2937 subl $8, %ebp
2938 jnz .L018decrypt_loop
2939.L017decrypt_finish:
2940 movl 56(%esp), %ebp
2941 andl $7, %ebp
2942 jz .L007finish
2943 movl (%esi), %eax
2944 movl 4(%esi), %ebx
2945 movl %eax, 12(%esp)
2946 movl %ebx, 16(%esp)
2947 call des_encrypt
2948 movl 12(%esp), %eax
2949 movl 16(%esp), %ebx
2950 movl 20(%esp), %ecx
2951 movl 24(%esp), %edx
2952 xorl %eax, %ecx
2953 xorl %ebx, %edx
2954 movl (%esi), %eax
2955 movl 4(%esi), %ebx
2956.L019dj7:
2957 rorl $16, %edx
2958 movb %dl, 6(%edi)
2959 shrl $16, %edx
2960.L020dj6:
2961 movb %dh, 5(%edi)
2962.L021dj5:
2963 movb %dl, 4(%edi)
2964.L022dj4:
2965 movl %ecx, (%edi)
2966 jmp .L023djend
2967.L024dj3:
2968 rorl $16, %ecx
2969 movb %cl, 2(%edi)
2970 sall $16, %ecx
2971.L025dj2:
2972 movb %ch, 1(%esi)
2973.L026dj1:
2974 movb %cl, (%esi)
2975.L023djend:
2976 jmp .L007finish
2977.align ALIGN
2978.L007finish:
2979 movl 64(%esp), %ecx
2980 addl $28, %esp
2981 movl %eax, (%ecx)
2982 movl %ebx, 4(%ecx)
2983 popl %edi
2984 popl %esi
2985 popl %ebx
2986 popl %ebp
2987 ret
2988.align ALIGN
2989.L008cbc_enc_jmp_table:
2990 .long 0
2991 .long .L016ej1
2992 .long .L015ej2
2993 .long .L014ej3
2994 .long .L012ej4
2995 .long .L011ej5
2996 .long .L010ej6
2997 .long .L009ej7
2998.align ALIGN
2999.L027cbc_dec_jmp_table:
3000 .long 0
3001 .long .L026dj1
3002 .long .L025dj2
3003 .long .L024dj3
3004 .long .L022dj4
3005 .long .L021dj5
3006 .long .L020dj6
3007 .long .L019dj7
3008.des_ncbc_encrypt_end:
3009 SIZE(des_ncbc_encrypt,.des_ncbc_encrypt_end-des_ncbc_encrypt)
3010.ident "desasm.pl"
3011.text
3012 .align ALIGN
3013.globl des_ede3_cbc_encrypt
3014 TYPE(des_ede3_cbc_encrypt,@function)
3015des_ede3_cbc_encrypt:
3016
3017 pushl %ebp
3018 pushl %ebx
3019 pushl %esi
3020 pushl %edi
3021 movl 28(%esp), %ebp
3022 /* getting iv ptr from parameter 6 */
3023 movl 44(%esp), %ebx
3024 movl (%ebx), %esi
3025 movl 4(%ebx), %edi
3026 pushl %edi
3027 pushl %esi
3028 pushl %edi
3029 pushl %esi
3030 movl %esp, %ebx
3031 movl 36(%esp), %esi
3032 movl 40(%esp), %edi
3033 /* getting encrypt flag from parameter 7 */
3034 movl 64(%esp), %ecx
3035 /* get and push parameter 5 */
3036 movl 56(%esp), %eax
3037 pushl %eax
3038 /* get and push parameter 4 */
3039 movl 56(%esp), %eax
3040 pushl %eax
3041 /* get and push parameter 3 */
3042 movl 56(%esp), %eax
3043 pushl %eax
3044 pushl %ebx
3045 cmpl $0, %ecx
3046 jz .L028decrypt
3047 andl $4294967288, %ebp
3048 movl 16(%esp), %eax
3049 movl 20(%esp), %ebx
3050 jz .L029encrypt_finish
3051.L030encrypt_loop:
3052 movl (%esi), %ecx
3053 movl 4(%esi), %edx
3054 xorl %ecx, %eax
3055 xorl %edx, %ebx
3056 movl %eax, 16(%esp)
3057 movl %ebx, 20(%esp)
3058 call des_encrypt3
3059 movl 16(%esp), %eax
3060 movl 20(%esp), %ebx
3061 movl %eax, (%edi)
3062 movl %ebx, 4(%edi)
3063 addl $8, %esi
3064 addl $8, %edi
3065 subl $8, %ebp
3066 jnz .L030encrypt_loop
3067.L029encrypt_finish:
3068 movl 60(%esp), %ebp
3069 andl $7, %ebp
3070 jz .L031finish
3071 xorl %ecx, %ecx
3072 xorl %edx, %edx
3073 movl .L032cbc_enc_jmp_table(,%ebp,4),%ebp
3074 jmp *%ebp
3075.L033ej7:
3076 movb 6(%esi), %dh
3077 sall $8, %edx
3078.L034ej6:
3079 movb 5(%esi), %dh
3080.L035ej5:
3081 movb 4(%esi), %dl
3082.L036ej4:
3083 movl (%esi), %ecx
3084 jmp .L037ejend
3085.L038ej3:
3086 movb 2(%esi), %ch
3087 sall $8, %ecx
3088.L039ej2:
3089 movb 1(%esi), %ch
3090.L040ej1:
3091 movb (%esi), %cl
3092.L037ejend:
3093 xorl %ecx, %eax
3094 xorl %edx, %ebx
3095 movl %eax, 16(%esp)
3096 movl %ebx, 20(%esp)
3097 call des_encrypt3
3098 movl 16(%esp), %eax
3099 movl 20(%esp), %ebx
3100 movl %eax, (%edi)
3101 movl %ebx, 4(%edi)
3102 jmp .L031finish
3103.align ALIGN
3104.L028decrypt:
3105 andl $4294967288, %ebp
3106 movl 24(%esp), %eax
3107 movl 28(%esp), %ebx
3108 jz .L041decrypt_finish
3109.L042decrypt_loop:
3110 movl (%esi), %eax
3111 movl 4(%esi), %ebx
3112 movl %eax, 16(%esp)
3113 movl %ebx, 20(%esp)
3114 call des_decrypt3
3115 movl 16(%esp), %eax
3116 movl 20(%esp), %ebx
3117 movl 24(%esp), %ecx
3118 movl 28(%esp), %edx
3119 xorl %eax, %ecx
3120 xorl %ebx, %edx
3121 movl (%esi), %eax
3122 movl 4(%esi), %ebx
3123 movl %ecx, (%edi)
3124 movl %edx, 4(%edi)
3125 movl %eax, 24(%esp)
3126 movl %ebx, 28(%esp)
3127 addl $8, %esi
3128 addl $8, %edi
3129 subl $8, %ebp
3130 jnz .L042decrypt_loop
3131.L041decrypt_finish:
3132 movl 60(%esp), %ebp
3133 andl $7, %ebp
3134 jz .L031finish
3135 movl (%esi), %eax
3136 movl 4(%esi), %ebx
3137 movl %eax, 16(%esp)
3138 movl %ebx, 20(%esp)
3139 call des_decrypt3
3140 movl 16(%esp), %eax
3141 movl 20(%esp), %ebx
3142 movl 24(%esp), %ecx
3143 movl 28(%esp), %edx
3144 xorl %eax, %ecx
3145 xorl %ebx, %edx
3146 movl (%esi), %eax
3147 movl 4(%esi), %ebx
3148.L043dj7:
3149 rorl $16, %edx
3150 movb %dl, 6(%edi)
3151 shrl $16, %edx
3152.L044dj6:
3153 movb %dh, 5(%edi)
3154.L045dj5:
3155 movb %dl, 4(%edi)
3156.L046dj4:
3157 movl %ecx, (%edi)
3158 jmp .L047djend
3159.L048dj3:
3160 rorl $16, %ecx
3161 movb %cl, 2(%edi)
3162 sall $16, %ecx
3163.L049dj2:
3164 movb %ch, 1(%esi)
3165.L050dj1:
3166 movb %cl, (%esi)
3167.L047djend:
3168 jmp .L031finish
3169.align ALIGN
3170.L031finish:
3171 movl 76(%esp), %ecx
3172 addl $32, %esp
3173 movl %eax, (%ecx)
3174 movl %ebx, 4(%ecx)
3175 popl %edi
3176 popl %esi
3177 popl %ebx
3178 popl %ebp
3179 ret
3180.align ALIGN
3181.L032cbc_enc_jmp_table:
3182 .long 0
3183 .long .L040ej1
3184 .long .L039ej2
3185 .long .L038ej3
3186 .long .L036ej4
3187 .long .L035ej5
3188 .long .L034ej6
3189 .long .L033ej7
3190.align ALIGN
3191.L051cbc_dec_jmp_table:
3192 .long 0
3193 .long .L050dj1
3194 .long .L049dj2
3195 .long .L048dj3
3196 .long .L046dj4
3197 .long .L045dj5
3198 .long .L044dj6
3199 .long .L043dj7
3200.des_ede3_cbc_encrypt_end:
3201 SIZE(des_ede3_cbc_encrypt,.des_ede3_cbc_encrypt_end-des_ede3_cbc_encrypt)
3202.ident "desasm.pl"
diff --git a/src/lib/libssl/src/crypto/des/asm/y-win32.asm b/src/lib/libssl/src/crypto/des/asm/y-win32.asm
new file mode 100644
index 0000000000..af5c102422
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/asm/y-win32.asm
@@ -0,0 +1,929 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by crypt586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE crypt586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _fcrypt_body
12EXTRN _des_SPtrans:DWORD
13_fcrypt_body PROC NEAR
14 push ebp
15 push ebx
16 push esi
17 push edi
18 ;
19 ; Load the 2 words
20 xor edi, edi
21 xor esi, esi
22 mov ebp, DWORD PTR 24[esp]
23 push 25
24L000start:
25 ;
26 ; Round 0
27 mov eax, DWORD PTR 32[esp]
28 mov edx, esi
29 shr edx, 16
30 mov ecx, DWORD PTR 36[esp]
31 xor edx, esi
32 and eax, edx
33 and edx, ecx
34 mov ebx, eax
35 shl ebx, 16
36 mov ecx, edx
37 shl ecx, 16
38 xor eax, ebx
39 xor edx, ecx
40 mov ebx, DWORD PTR [ebp]
41 xor eax, ebx
42 mov ecx, DWORD PTR 4[ebp]
43 xor eax, esi
44 xor edx, esi
45 xor edx, ecx
46 and eax, 0fcfcfcfch
47 xor ebx, ebx
48 and edx, 0cfcfcfcfh
49 xor ecx, ecx
50 mov bl, al
51 mov cl, ah
52 ror edx, 4
53 mov ebp, DWORD PTR _des_SPtrans[ebx]
54 mov bl, dl
55 xor edi, ebp
56 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
57 xor edi, ebp
58 mov cl, dh
59 shr eax, 16
60 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
61 xor edi, ebp
62 mov bl, ah
63 shr edx, 16
64 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
65 xor edi, ebp
66 mov ebp, DWORD PTR 28[esp]
67 mov cl, dh
68 and eax, 0ffh
69 and edx, 0ffh
70 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
71 xor edi, ebx
72 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
73 xor edi, ebx
74 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
75 xor edi, ebx
76 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
77 xor edi, ebx
78 ;
79 ; Round 1
80 mov eax, DWORD PTR 32[esp]
81 mov edx, edi
82 shr edx, 16
83 mov ecx, DWORD PTR 36[esp]
84 xor edx, edi
85 and eax, edx
86 and edx, ecx
87 mov ebx, eax
88 shl ebx, 16
89 mov ecx, edx
90 shl ecx, 16
91 xor eax, ebx
92 xor edx, ecx
93 mov ebx, DWORD PTR 8[ebp]
94 xor eax, ebx
95 mov ecx, DWORD PTR 12[ebp]
96 xor eax, edi
97 xor edx, edi
98 xor edx, ecx
99 and eax, 0fcfcfcfch
100 xor ebx, ebx
101 and edx, 0cfcfcfcfh
102 xor ecx, ecx
103 mov bl, al
104 mov cl, ah
105 ror edx, 4
106 mov ebp, DWORD PTR _des_SPtrans[ebx]
107 mov bl, dl
108 xor esi, ebp
109 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
110 xor esi, ebp
111 mov cl, dh
112 shr eax, 16
113 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
114 xor esi, ebp
115 mov bl, ah
116 shr edx, 16
117 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
118 xor esi, ebp
119 mov ebp, DWORD PTR 28[esp]
120 mov cl, dh
121 and eax, 0ffh
122 and edx, 0ffh
123 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
124 xor esi, ebx
125 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
126 xor esi, ebx
127 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
128 xor esi, ebx
129 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
130 xor esi, ebx
131 ;
132 ; Round 2
133 mov eax, DWORD PTR 32[esp]
134 mov edx, esi
135 shr edx, 16
136 mov ecx, DWORD PTR 36[esp]
137 xor edx, esi
138 and eax, edx
139 and edx, ecx
140 mov ebx, eax
141 shl ebx, 16
142 mov ecx, edx
143 shl ecx, 16
144 xor eax, ebx
145 xor edx, ecx
146 mov ebx, DWORD PTR 16[ebp]
147 xor eax, ebx
148 mov ecx, DWORD PTR 20[ebp]
149 xor eax, esi
150 xor edx, esi
151 xor edx, ecx
152 and eax, 0fcfcfcfch
153 xor ebx, ebx
154 and edx, 0cfcfcfcfh
155 xor ecx, ecx
156 mov bl, al
157 mov cl, ah
158 ror edx, 4
159 mov ebp, DWORD PTR _des_SPtrans[ebx]
160 mov bl, dl
161 xor edi, ebp
162 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
163 xor edi, ebp
164 mov cl, dh
165 shr eax, 16
166 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
167 xor edi, ebp
168 mov bl, ah
169 shr edx, 16
170 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
171 xor edi, ebp
172 mov ebp, DWORD PTR 28[esp]
173 mov cl, dh
174 and eax, 0ffh
175 and edx, 0ffh
176 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
177 xor edi, ebx
178 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
179 xor edi, ebx
180 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
181 xor edi, ebx
182 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
183 xor edi, ebx
184 ;
185 ; Round 3
186 mov eax, DWORD PTR 32[esp]
187 mov edx, edi
188 shr edx, 16
189 mov ecx, DWORD PTR 36[esp]
190 xor edx, edi
191 and eax, edx
192 and edx, ecx
193 mov ebx, eax
194 shl ebx, 16
195 mov ecx, edx
196 shl ecx, 16
197 xor eax, ebx
198 xor edx, ecx
199 mov ebx, DWORD PTR 24[ebp]
200 xor eax, ebx
201 mov ecx, DWORD PTR 28[ebp]
202 xor eax, edi
203 xor edx, edi
204 xor edx, ecx
205 and eax, 0fcfcfcfch
206 xor ebx, ebx
207 and edx, 0cfcfcfcfh
208 xor ecx, ecx
209 mov bl, al
210 mov cl, ah
211 ror edx, 4
212 mov ebp, DWORD PTR _des_SPtrans[ebx]
213 mov bl, dl
214 xor esi, ebp
215 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
216 xor esi, ebp
217 mov cl, dh
218 shr eax, 16
219 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
220 xor esi, ebp
221 mov bl, ah
222 shr edx, 16
223 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
224 xor esi, ebp
225 mov ebp, DWORD PTR 28[esp]
226 mov cl, dh
227 and eax, 0ffh
228 and edx, 0ffh
229 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
230 xor esi, ebx
231 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
232 xor esi, ebx
233 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
234 xor esi, ebx
235 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
236 xor esi, ebx
237 ;
238 ; Round 4
239 mov eax, DWORD PTR 32[esp]
240 mov edx, esi
241 shr edx, 16
242 mov ecx, DWORD PTR 36[esp]
243 xor edx, esi
244 and eax, edx
245 and edx, ecx
246 mov ebx, eax
247 shl ebx, 16
248 mov ecx, edx
249 shl ecx, 16
250 xor eax, ebx
251 xor edx, ecx
252 mov ebx, DWORD PTR 32[ebp]
253 xor eax, ebx
254 mov ecx, DWORD PTR 36[ebp]
255 xor eax, esi
256 xor edx, esi
257 xor edx, ecx
258 and eax, 0fcfcfcfch
259 xor ebx, ebx
260 and edx, 0cfcfcfcfh
261 xor ecx, ecx
262 mov bl, al
263 mov cl, ah
264 ror edx, 4
265 mov ebp, DWORD PTR _des_SPtrans[ebx]
266 mov bl, dl
267 xor edi, ebp
268 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
269 xor edi, ebp
270 mov cl, dh
271 shr eax, 16
272 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
273 xor edi, ebp
274 mov bl, ah
275 shr edx, 16
276 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
277 xor edi, ebp
278 mov ebp, DWORD PTR 28[esp]
279 mov cl, dh
280 and eax, 0ffh
281 and edx, 0ffh
282 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
283 xor edi, ebx
284 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
285 xor edi, ebx
286 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
287 xor edi, ebx
288 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
289 xor edi, ebx
290 ;
291 ; Round 5
292 mov eax, DWORD PTR 32[esp]
293 mov edx, edi
294 shr edx, 16
295 mov ecx, DWORD PTR 36[esp]
296 xor edx, edi
297 and eax, edx
298 and edx, ecx
299 mov ebx, eax
300 shl ebx, 16
301 mov ecx, edx
302 shl ecx, 16
303 xor eax, ebx
304 xor edx, ecx
305 mov ebx, DWORD PTR 40[ebp]
306 xor eax, ebx
307 mov ecx, DWORD PTR 44[ebp]
308 xor eax, edi
309 xor edx, edi
310 xor edx, ecx
311 and eax, 0fcfcfcfch
312 xor ebx, ebx
313 and edx, 0cfcfcfcfh
314 xor ecx, ecx
315 mov bl, al
316 mov cl, ah
317 ror edx, 4
318 mov ebp, DWORD PTR _des_SPtrans[ebx]
319 mov bl, dl
320 xor esi, ebp
321 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
322 xor esi, ebp
323 mov cl, dh
324 shr eax, 16
325 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
326 xor esi, ebp
327 mov bl, ah
328 shr edx, 16
329 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
330 xor esi, ebp
331 mov ebp, DWORD PTR 28[esp]
332 mov cl, dh
333 and eax, 0ffh
334 and edx, 0ffh
335 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
336 xor esi, ebx
337 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
338 xor esi, ebx
339 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
340 xor esi, ebx
341 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
342 xor esi, ebx
343 ;
344 ; Round 6
345 mov eax, DWORD PTR 32[esp]
346 mov edx, esi
347 shr edx, 16
348 mov ecx, DWORD PTR 36[esp]
349 xor edx, esi
350 and eax, edx
351 and edx, ecx
352 mov ebx, eax
353 shl ebx, 16
354 mov ecx, edx
355 shl ecx, 16
356 xor eax, ebx
357 xor edx, ecx
358 mov ebx, DWORD PTR 48[ebp]
359 xor eax, ebx
360 mov ecx, DWORD PTR 52[ebp]
361 xor eax, esi
362 xor edx, esi
363 xor edx, ecx
364 and eax, 0fcfcfcfch
365 xor ebx, ebx
366 and edx, 0cfcfcfcfh
367 xor ecx, ecx
368 mov bl, al
369 mov cl, ah
370 ror edx, 4
371 mov ebp, DWORD PTR _des_SPtrans[ebx]
372 mov bl, dl
373 xor edi, ebp
374 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
375 xor edi, ebp
376 mov cl, dh
377 shr eax, 16
378 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
379 xor edi, ebp
380 mov bl, ah
381 shr edx, 16
382 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
383 xor edi, ebp
384 mov ebp, DWORD PTR 28[esp]
385 mov cl, dh
386 and eax, 0ffh
387 and edx, 0ffh
388 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
389 xor edi, ebx
390 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
391 xor edi, ebx
392 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
393 xor edi, ebx
394 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
395 xor edi, ebx
396 ;
397 ; Round 7
398 mov eax, DWORD PTR 32[esp]
399 mov edx, edi
400 shr edx, 16
401 mov ecx, DWORD PTR 36[esp]
402 xor edx, edi
403 and eax, edx
404 and edx, ecx
405 mov ebx, eax
406 shl ebx, 16
407 mov ecx, edx
408 shl ecx, 16
409 xor eax, ebx
410 xor edx, ecx
411 mov ebx, DWORD PTR 56[ebp]
412 xor eax, ebx
413 mov ecx, DWORD PTR 60[ebp]
414 xor eax, edi
415 xor edx, edi
416 xor edx, ecx
417 and eax, 0fcfcfcfch
418 xor ebx, ebx
419 and edx, 0cfcfcfcfh
420 xor ecx, ecx
421 mov bl, al
422 mov cl, ah
423 ror edx, 4
424 mov ebp, DWORD PTR _des_SPtrans[ebx]
425 mov bl, dl
426 xor esi, ebp
427 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
428 xor esi, ebp
429 mov cl, dh
430 shr eax, 16
431 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
432 xor esi, ebp
433 mov bl, ah
434 shr edx, 16
435 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
436 xor esi, ebp
437 mov ebp, DWORD PTR 28[esp]
438 mov cl, dh
439 and eax, 0ffh
440 and edx, 0ffh
441 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
442 xor esi, ebx
443 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
444 xor esi, ebx
445 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
446 xor esi, ebx
447 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
448 xor esi, ebx
449 ;
450 ; Round 8
451 mov eax, DWORD PTR 32[esp]
452 mov edx, esi
453 shr edx, 16
454 mov ecx, DWORD PTR 36[esp]
455 xor edx, esi
456 and eax, edx
457 and edx, ecx
458 mov ebx, eax
459 shl ebx, 16
460 mov ecx, edx
461 shl ecx, 16
462 xor eax, ebx
463 xor edx, ecx
464 mov ebx, DWORD PTR 64[ebp]
465 xor eax, ebx
466 mov ecx, DWORD PTR 68[ebp]
467 xor eax, esi
468 xor edx, esi
469 xor edx, ecx
470 and eax, 0fcfcfcfch
471 xor ebx, ebx
472 and edx, 0cfcfcfcfh
473 xor ecx, ecx
474 mov bl, al
475 mov cl, ah
476 ror edx, 4
477 mov ebp, DWORD PTR _des_SPtrans[ebx]
478 mov bl, dl
479 xor edi, ebp
480 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
481 xor edi, ebp
482 mov cl, dh
483 shr eax, 16
484 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
485 xor edi, ebp
486 mov bl, ah
487 shr edx, 16
488 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
489 xor edi, ebp
490 mov ebp, DWORD PTR 28[esp]
491 mov cl, dh
492 and eax, 0ffh
493 and edx, 0ffh
494 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
495 xor edi, ebx
496 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
497 xor edi, ebx
498 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
499 xor edi, ebx
500 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
501 xor edi, ebx
502 ;
503 ; Round 9
504 mov eax, DWORD PTR 32[esp]
505 mov edx, edi
506 shr edx, 16
507 mov ecx, DWORD PTR 36[esp]
508 xor edx, edi
509 and eax, edx
510 and edx, ecx
511 mov ebx, eax
512 shl ebx, 16
513 mov ecx, edx
514 shl ecx, 16
515 xor eax, ebx
516 xor edx, ecx
517 mov ebx, DWORD PTR 72[ebp]
518 xor eax, ebx
519 mov ecx, DWORD PTR 76[ebp]
520 xor eax, edi
521 xor edx, edi
522 xor edx, ecx
523 and eax, 0fcfcfcfch
524 xor ebx, ebx
525 and edx, 0cfcfcfcfh
526 xor ecx, ecx
527 mov bl, al
528 mov cl, ah
529 ror edx, 4
530 mov ebp, DWORD PTR _des_SPtrans[ebx]
531 mov bl, dl
532 xor esi, ebp
533 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
534 xor esi, ebp
535 mov cl, dh
536 shr eax, 16
537 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
538 xor esi, ebp
539 mov bl, ah
540 shr edx, 16
541 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
542 xor esi, ebp
543 mov ebp, DWORD PTR 28[esp]
544 mov cl, dh
545 and eax, 0ffh
546 and edx, 0ffh
547 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
548 xor esi, ebx
549 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
550 xor esi, ebx
551 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
552 xor esi, ebx
553 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
554 xor esi, ebx
555 ;
556 ; Round 10
557 mov eax, DWORD PTR 32[esp]
558 mov edx, esi
559 shr edx, 16
560 mov ecx, DWORD PTR 36[esp]
561 xor edx, esi
562 and eax, edx
563 and edx, ecx
564 mov ebx, eax
565 shl ebx, 16
566 mov ecx, edx
567 shl ecx, 16
568 xor eax, ebx
569 xor edx, ecx
570 mov ebx, DWORD PTR 80[ebp]
571 xor eax, ebx
572 mov ecx, DWORD PTR 84[ebp]
573 xor eax, esi
574 xor edx, esi
575 xor edx, ecx
576 and eax, 0fcfcfcfch
577 xor ebx, ebx
578 and edx, 0cfcfcfcfh
579 xor ecx, ecx
580 mov bl, al
581 mov cl, ah
582 ror edx, 4
583 mov ebp, DWORD PTR _des_SPtrans[ebx]
584 mov bl, dl
585 xor edi, ebp
586 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
587 xor edi, ebp
588 mov cl, dh
589 shr eax, 16
590 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
591 xor edi, ebp
592 mov bl, ah
593 shr edx, 16
594 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
595 xor edi, ebp
596 mov ebp, DWORD PTR 28[esp]
597 mov cl, dh
598 and eax, 0ffh
599 and edx, 0ffh
600 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
601 xor edi, ebx
602 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
603 xor edi, ebx
604 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
605 xor edi, ebx
606 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
607 xor edi, ebx
608 ;
609 ; Round 11
610 mov eax, DWORD PTR 32[esp]
611 mov edx, edi
612 shr edx, 16
613 mov ecx, DWORD PTR 36[esp]
614 xor edx, edi
615 and eax, edx
616 and edx, ecx
617 mov ebx, eax
618 shl ebx, 16
619 mov ecx, edx
620 shl ecx, 16
621 xor eax, ebx
622 xor edx, ecx
623 mov ebx, DWORD PTR 88[ebp]
624 xor eax, ebx
625 mov ecx, DWORD PTR 92[ebp]
626 xor eax, edi
627 xor edx, edi
628 xor edx, ecx
629 and eax, 0fcfcfcfch
630 xor ebx, ebx
631 and edx, 0cfcfcfcfh
632 xor ecx, ecx
633 mov bl, al
634 mov cl, ah
635 ror edx, 4
636 mov ebp, DWORD PTR _des_SPtrans[ebx]
637 mov bl, dl
638 xor esi, ebp
639 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
640 xor esi, ebp
641 mov cl, dh
642 shr eax, 16
643 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
644 xor esi, ebp
645 mov bl, ah
646 shr edx, 16
647 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
648 xor esi, ebp
649 mov ebp, DWORD PTR 28[esp]
650 mov cl, dh
651 and eax, 0ffh
652 and edx, 0ffh
653 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
654 xor esi, ebx
655 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
656 xor esi, ebx
657 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
658 xor esi, ebx
659 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
660 xor esi, ebx
661 ;
662 ; Round 12
663 mov eax, DWORD PTR 32[esp]
664 mov edx, esi
665 shr edx, 16
666 mov ecx, DWORD PTR 36[esp]
667 xor edx, esi
668 and eax, edx
669 and edx, ecx
670 mov ebx, eax
671 shl ebx, 16
672 mov ecx, edx
673 shl ecx, 16
674 xor eax, ebx
675 xor edx, ecx
676 mov ebx, DWORD PTR 96[ebp]
677 xor eax, ebx
678 mov ecx, DWORD PTR 100[ebp]
679 xor eax, esi
680 xor edx, esi
681 xor edx, ecx
682 and eax, 0fcfcfcfch
683 xor ebx, ebx
684 and edx, 0cfcfcfcfh
685 xor ecx, ecx
686 mov bl, al
687 mov cl, ah
688 ror edx, 4
689 mov ebp, DWORD PTR _des_SPtrans[ebx]
690 mov bl, dl
691 xor edi, ebp
692 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
693 xor edi, ebp
694 mov cl, dh
695 shr eax, 16
696 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
697 xor edi, ebp
698 mov bl, ah
699 shr edx, 16
700 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
701 xor edi, ebp
702 mov ebp, DWORD PTR 28[esp]
703 mov cl, dh
704 and eax, 0ffh
705 and edx, 0ffh
706 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
707 xor edi, ebx
708 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
709 xor edi, ebx
710 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
711 xor edi, ebx
712 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
713 xor edi, ebx
714 ;
715 ; Round 13
716 mov eax, DWORD PTR 32[esp]
717 mov edx, edi
718 shr edx, 16
719 mov ecx, DWORD PTR 36[esp]
720 xor edx, edi
721 and eax, edx
722 and edx, ecx
723 mov ebx, eax
724 shl ebx, 16
725 mov ecx, edx
726 shl ecx, 16
727 xor eax, ebx
728 xor edx, ecx
729 mov ebx, DWORD PTR 104[ebp]
730 xor eax, ebx
731 mov ecx, DWORD PTR 108[ebp]
732 xor eax, edi
733 xor edx, edi
734 xor edx, ecx
735 and eax, 0fcfcfcfch
736 xor ebx, ebx
737 and edx, 0cfcfcfcfh
738 xor ecx, ecx
739 mov bl, al
740 mov cl, ah
741 ror edx, 4
742 mov ebp, DWORD PTR _des_SPtrans[ebx]
743 mov bl, dl
744 xor esi, ebp
745 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
746 xor esi, ebp
747 mov cl, dh
748 shr eax, 16
749 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
750 xor esi, ebp
751 mov bl, ah
752 shr edx, 16
753 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
754 xor esi, ebp
755 mov ebp, DWORD PTR 28[esp]
756 mov cl, dh
757 and eax, 0ffh
758 and edx, 0ffh
759 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
760 xor esi, ebx
761 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
762 xor esi, ebx
763 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
764 xor esi, ebx
765 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
766 xor esi, ebx
767 ;
768 ; Round 14
769 mov eax, DWORD PTR 32[esp]
770 mov edx, esi
771 shr edx, 16
772 mov ecx, DWORD PTR 36[esp]
773 xor edx, esi
774 and eax, edx
775 and edx, ecx
776 mov ebx, eax
777 shl ebx, 16
778 mov ecx, edx
779 shl ecx, 16
780 xor eax, ebx
781 xor edx, ecx
782 mov ebx, DWORD PTR 112[ebp]
783 xor eax, ebx
784 mov ecx, DWORD PTR 116[ebp]
785 xor eax, esi
786 xor edx, esi
787 xor edx, ecx
788 and eax, 0fcfcfcfch
789 xor ebx, ebx
790 and edx, 0cfcfcfcfh
791 xor ecx, ecx
792 mov bl, al
793 mov cl, ah
794 ror edx, 4
795 mov ebp, DWORD PTR _des_SPtrans[ebx]
796 mov bl, dl
797 xor edi, ebp
798 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
799 xor edi, ebp
800 mov cl, dh
801 shr eax, 16
802 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
803 xor edi, ebp
804 mov bl, ah
805 shr edx, 16
806 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
807 xor edi, ebp
808 mov ebp, DWORD PTR 28[esp]
809 mov cl, dh
810 and eax, 0ffh
811 and edx, 0ffh
812 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
813 xor edi, ebx
814 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
815 xor edi, ebx
816 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
817 xor edi, ebx
818 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
819 xor edi, ebx
820 ;
821 ; Round 15
822 mov eax, DWORD PTR 32[esp]
823 mov edx, edi
824 shr edx, 16
825 mov ecx, DWORD PTR 36[esp]
826 xor edx, edi
827 and eax, edx
828 and edx, ecx
829 mov ebx, eax
830 shl ebx, 16
831 mov ecx, edx
832 shl ecx, 16
833 xor eax, ebx
834 xor edx, ecx
835 mov ebx, DWORD PTR 120[ebp]
836 xor eax, ebx
837 mov ecx, DWORD PTR 124[ebp]
838 xor eax, edi
839 xor edx, edi
840 xor edx, ecx
841 and eax, 0fcfcfcfch
842 xor ebx, ebx
843 and edx, 0cfcfcfcfh
844 xor ecx, ecx
845 mov bl, al
846 mov cl, ah
847 ror edx, 4
848 mov ebp, DWORD PTR _des_SPtrans[ebx]
849 mov bl, dl
850 xor esi, ebp
851 mov ebp, DWORD PTR _des_SPtrans[0200h+ecx]
852 xor esi, ebp
853 mov cl, dh
854 shr eax, 16
855 mov ebp, DWORD PTR _des_SPtrans[0100h+ebx]
856 xor esi, ebp
857 mov bl, ah
858 shr edx, 16
859 mov ebp, DWORD PTR _des_SPtrans[0300h+ecx]
860 xor esi, ebp
861 mov ebp, DWORD PTR 28[esp]
862 mov cl, dh
863 and eax, 0ffh
864 and edx, 0ffh
865 mov ebx, DWORD PTR _des_SPtrans[0600h+ebx]
866 xor esi, ebx
867 mov ebx, DWORD PTR _des_SPtrans[0700h+ecx]
868 xor esi, ebx
869 mov ebx, DWORD PTR _des_SPtrans[0400h+eax]
870 xor esi, ebx
871 mov ebx, DWORD PTR _des_SPtrans[0500h+edx]
872 xor esi, ebx
873 mov ebx, DWORD PTR [esp]
874 mov eax, edi
875 dec ebx
876 mov edi, esi
877 mov esi, eax
878 mov DWORD PTR [esp],ebx
879 jnz L000start
880 ;
881 ; FP
882 mov edx, DWORD PTR 24[esp]
883 ror edi, 1
884 mov eax, esi
885 xor esi, edi
886 and esi, 0aaaaaaaah
887 xor eax, esi
888 xor edi, esi
889 ;
890 rol eax, 23
891 mov esi, eax
892 xor eax, edi
893 and eax, 003fc03fch
894 xor esi, eax
895 xor edi, eax
896 ;
897 rol esi, 10
898 mov eax, esi
899 xor esi, edi
900 and esi, 033333333h
901 xor eax, esi
902 xor edi, esi
903 ;
904 rol edi, 18
905 mov esi, edi
906 xor edi, eax
907 and edi, 0fff0000fh
908 xor esi, edi
909 xor eax, edi
910 ;
911 rol esi, 12
912 mov edi, esi
913 xor esi, eax
914 and esi, 0f0f0f0f0h
915 xor edi, esi
916 xor eax, esi
917 ;
918 ror eax, 4
919 mov DWORD PTR [edx],eax
920 mov DWORD PTR 4[edx],edi
921 pop ecx
922 pop edi
923 pop esi
924 pop ebx
925 pop ebp
926 ret
927_fcrypt_body ENDP
928_TEXT ENDS
929END
diff --git a/src/lib/libssl/src/crypto/des/asm/yx86unix.cpp b/src/lib/libssl/src/crypto/des/asm/yx86unix.cpp
new file mode 100644
index 0000000000..8719e38607
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/asm/yx86unix.cpp
@@ -0,0 +1,976 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define des_SPtrans _des_SPtrans
13#define fcrypt_body _fcrypt_body
14
15#endif
16
17#ifdef OUT
18#define OK 1
19#define ALIGN 4
20#endif
21
22#ifdef BSDI
23#define OK 1
24#define ALIGN 4
25#undef SIZE
26#undef TYPE
27#define SIZE(a,b)
28#define TYPE(a,b)
29#endif
30
31#if defined(ELF) || defined(SOL)
32#define OK 1
33#define ALIGN 16
34#endif
35
36#ifndef OK
37You need to define one of
38ELF - elf systems - linux-elf, NetBSD and DG-UX
39OUT - a.out systems - linux-a.out and FreeBSD
40SOL - solaris systems, which are elf with strange comment lines
41BSDI - a.out with a very primative version of as.
42#endif
43
44/* Let the Assembler begin :-) */
45 /* Don't even think of reading this code */
46 /* It was automatically generated by crypt586.pl */
47 /* Which is a perl program used to generate the x86 assember for */
48 /* any of elf, a.out, BSDI,Win32, or Solaris */
49 /* eric <eay@cryptsoft.com> */
50
51 .file "crypt586.s"
52 .version "01.01"
53gcc2_compiled.:
54.text
55 .align ALIGN
56.globl fcrypt_body
57 TYPE(fcrypt_body,@function)
58fcrypt_body:
59 pushl %ebp
60 pushl %ebx
61 pushl %esi
62 pushl %edi
63
64
65 /* Load the 2 words */
66 xorl %edi, %edi
67 xorl %esi, %esi
68 movl 24(%esp), %ebp
69 pushl $25
70.L000start:
71
72 /* Round 0 */
73 movl 32(%esp), %eax
74 movl %esi, %edx
75 shrl $16, %edx
76 movl 36(%esp), %ecx
77 xorl %esi, %edx
78 andl %edx, %eax
79 andl %ecx, %edx
80 movl %eax, %ebx
81 sall $16, %ebx
82 movl %edx, %ecx
83 sall $16, %ecx
84 xorl %ebx, %eax
85 xorl %ecx, %edx
86 movl (%ebp), %ebx
87 xorl %ebx, %eax
88 movl 4(%ebp), %ecx
89 xorl %esi, %eax
90 xorl %esi, %edx
91 xorl %ecx, %edx
92 andl $0xfcfcfcfc, %eax
93 xorl %ebx, %ebx
94 andl $0xcfcfcfcf, %edx
95 xorl %ecx, %ecx
96 movb %al, %bl
97 movb %ah, %cl
98 rorl $4, %edx
99 movl des_SPtrans(%ebx),%ebp
100 movb %dl, %bl
101 xorl %ebp, %edi
102 movl 0x200+des_SPtrans(%ecx),%ebp
103 xorl %ebp, %edi
104 movb %dh, %cl
105 shrl $16, %eax
106 movl 0x100+des_SPtrans(%ebx),%ebp
107 xorl %ebp, %edi
108 movb %ah, %bl
109 shrl $16, %edx
110 movl 0x300+des_SPtrans(%ecx),%ebp
111 xorl %ebp, %edi
112 movl 28(%esp), %ebp
113 movb %dh, %cl
114 andl $0xff, %eax
115 andl $0xff, %edx
116 movl 0x600+des_SPtrans(%ebx),%ebx
117 xorl %ebx, %edi
118 movl 0x700+des_SPtrans(%ecx),%ebx
119 xorl %ebx, %edi
120 movl 0x400+des_SPtrans(%eax),%ebx
121 xorl %ebx, %edi
122 movl 0x500+des_SPtrans(%edx),%ebx
123 xorl %ebx, %edi
124
125 /* Round 1 */
126 movl 32(%esp), %eax
127 movl %edi, %edx
128 shrl $16, %edx
129 movl 36(%esp), %ecx
130 xorl %edi, %edx
131 andl %edx, %eax
132 andl %ecx, %edx
133 movl %eax, %ebx
134 sall $16, %ebx
135 movl %edx, %ecx
136 sall $16, %ecx
137 xorl %ebx, %eax
138 xorl %ecx, %edx
139 movl 8(%ebp), %ebx
140 xorl %ebx, %eax
141 movl 12(%ebp), %ecx
142 xorl %edi, %eax
143 xorl %edi, %edx
144 xorl %ecx, %edx
145 andl $0xfcfcfcfc, %eax
146 xorl %ebx, %ebx
147 andl $0xcfcfcfcf, %edx
148 xorl %ecx, %ecx
149 movb %al, %bl
150 movb %ah, %cl
151 rorl $4, %edx
152 movl des_SPtrans(%ebx),%ebp
153 movb %dl, %bl
154 xorl %ebp, %esi
155 movl 0x200+des_SPtrans(%ecx),%ebp
156 xorl %ebp, %esi
157 movb %dh, %cl
158 shrl $16, %eax
159 movl 0x100+des_SPtrans(%ebx),%ebp
160 xorl %ebp, %esi
161 movb %ah, %bl
162 shrl $16, %edx
163 movl 0x300+des_SPtrans(%ecx),%ebp
164 xorl %ebp, %esi
165 movl 28(%esp), %ebp
166 movb %dh, %cl
167 andl $0xff, %eax
168 andl $0xff, %edx
169 movl 0x600+des_SPtrans(%ebx),%ebx
170 xorl %ebx, %esi
171 movl 0x700+des_SPtrans(%ecx),%ebx
172 xorl %ebx, %esi
173 movl 0x400+des_SPtrans(%eax),%ebx
174 xorl %ebx, %esi
175 movl 0x500+des_SPtrans(%edx),%ebx
176 xorl %ebx, %esi
177
178 /* Round 2 */
179 movl 32(%esp), %eax
180 movl %esi, %edx
181 shrl $16, %edx
182 movl 36(%esp), %ecx
183 xorl %esi, %edx
184 andl %edx, %eax
185 andl %ecx, %edx
186 movl %eax, %ebx
187 sall $16, %ebx
188 movl %edx, %ecx
189 sall $16, %ecx
190 xorl %ebx, %eax
191 xorl %ecx, %edx
192 movl 16(%ebp), %ebx
193 xorl %ebx, %eax
194 movl 20(%ebp), %ecx
195 xorl %esi, %eax
196 xorl %esi, %edx
197 xorl %ecx, %edx
198 andl $0xfcfcfcfc, %eax
199 xorl %ebx, %ebx
200 andl $0xcfcfcfcf, %edx
201 xorl %ecx, %ecx
202 movb %al, %bl
203 movb %ah, %cl
204 rorl $4, %edx
205 movl des_SPtrans(%ebx),%ebp
206 movb %dl, %bl
207 xorl %ebp, %edi
208 movl 0x200+des_SPtrans(%ecx),%ebp
209 xorl %ebp, %edi
210 movb %dh, %cl
211 shrl $16, %eax
212 movl 0x100+des_SPtrans(%ebx),%ebp
213 xorl %ebp, %edi
214 movb %ah, %bl
215 shrl $16, %edx
216 movl 0x300+des_SPtrans(%ecx),%ebp
217 xorl %ebp, %edi
218 movl 28(%esp), %ebp
219 movb %dh, %cl
220 andl $0xff, %eax
221 andl $0xff, %edx
222 movl 0x600+des_SPtrans(%ebx),%ebx
223 xorl %ebx, %edi
224 movl 0x700+des_SPtrans(%ecx),%ebx
225 xorl %ebx, %edi
226 movl 0x400+des_SPtrans(%eax),%ebx
227 xorl %ebx, %edi
228 movl 0x500+des_SPtrans(%edx),%ebx
229 xorl %ebx, %edi
230
231 /* Round 3 */
232 movl 32(%esp), %eax
233 movl %edi, %edx
234 shrl $16, %edx
235 movl 36(%esp), %ecx
236 xorl %edi, %edx
237 andl %edx, %eax
238 andl %ecx, %edx
239 movl %eax, %ebx
240 sall $16, %ebx
241 movl %edx, %ecx
242 sall $16, %ecx
243 xorl %ebx, %eax
244 xorl %ecx, %edx
245 movl 24(%ebp), %ebx
246 xorl %ebx, %eax
247 movl 28(%ebp), %ecx
248 xorl %edi, %eax
249 xorl %edi, %edx
250 xorl %ecx, %edx
251 andl $0xfcfcfcfc, %eax
252 xorl %ebx, %ebx
253 andl $0xcfcfcfcf, %edx
254 xorl %ecx, %ecx
255 movb %al, %bl
256 movb %ah, %cl
257 rorl $4, %edx
258 movl des_SPtrans(%ebx),%ebp
259 movb %dl, %bl
260 xorl %ebp, %esi
261 movl 0x200+des_SPtrans(%ecx),%ebp
262 xorl %ebp, %esi
263 movb %dh, %cl
264 shrl $16, %eax
265 movl 0x100+des_SPtrans(%ebx),%ebp
266 xorl %ebp, %esi
267 movb %ah, %bl
268 shrl $16, %edx
269 movl 0x300+des_SPtrans(%ecx),%ebp
270 xorl %ebp, %esi
271 movl 28(%esp), %ebp
272 movb %dh, %cl
273 andl $0xff, %eax
274 andl $0xff, %edx
275 movl 0x600+des_SPtrans(%ebx),%ebx
276 xorl %ebx, %esi
277 movl 0x700+des_SPtrans(%ecx),%ebx
278 xorl %ebx, %esi
279 movl 0x400+des_SPtrans(%eax),%ebx
280 xorl %ebx, %esi
281 movl 0x500+des_SPtrans(%edx),%ebx
282 xorl %ebx, %esi
283
284 /* Round 4 */
285 movl 32(%esp), %eax
286 movl %esi, %edx
287 shrl $16, %edx
288 movl 36(%esp), %ecx
289 xorl %esi, %edx
290 andl %edx, %eax
291 andl %ecx, %edx
292 movl %eax, %ebx
293 sall $16, %ebx
294 movl %edx, %ecx
295 sall $16, %ecx
296 xorl %ebx, %eax
297 xorl %ecx, %edx
298 movl 32(%ebp), %ebx
299 xorl %ebx, %eax
300 movl 36(%ebp), %ecx
301 xorl %esi, %eax
302 xorl %esi, %edx
303 xorl %ecx, %edx
304 andl $0xfcfcfcfc, %eax
305 xorl %ebx, %ebx
306 andl $0xcfcfcfcf, %edx
307 xorl %ecx, %ecx
308 movb %al, %bl
309 movb %ah, %cl
310 rorl $4, %edx
311 movl des_SPtrans(%ebx),%ebp
312 movb %dl, %bl
313 xorl %ebp, %edi
314 movl 0x200+des_SPtrans(%ecx),%ebp
315 xorl %ebp, %edi
316 movb %dh, %cl
317 shrl $16, %eax
318 movl 0x100+des_SPtrans(%ebx),%ebp
319 xorl %ebp, %edi
320 movb %ah, %bl
321 shrl $16, %edx
322 movl 0x300+des_SPtrans(%ecx),%ebp
323 xorl %ebp, %edi
324 movl 28(%esp), %ebp
325 movb %dh, %cl
326 andl $0xff, %eax
327 andl $0xff, %edx
328 movl 0x600+des_SPtrans(%ebx),%ebx
329 xorl %ebx, %edi
330 movl 0x700+des_SPtrans(%ecx),%ebx
331 xorl %ebx, %edi
332 movl 0x400+des_SPtrans(%eax),%ebx
333 xorl %ebx, %edi
334 movl 0x500+des_SPtrans(%edx),%ebx
335 xorl %ebx, %edi
336
337 /* Round 5 */
338 movl 32(%esp), %eax
339 movl %edi, %edx
340 shrl $16, %edx
341 movl 36(%esp), %ecx
342 xorl %edi, %edx
343 andl %edx, %eax
344 andl %ecx, %edx
345 movl %eax, %ebx
346 sall $16, %ebx
347 movl %edx, %ecx
348 sall $16, %ecx
349 xorl %ebx, %eax
350 xorl %ecx, %edx
351 movl 40(%ebp), %ebx
352 xorl %ebx, %eax
353 movl 44(%ebp), %ecx
354 xorl %edi, %eax
355 xorl %edi, %edx
356 xorl %ecx, %edx
357 andl $0xfcfcfcfc, %eax
358 xorl %ebx, %ebx
359 andl $0xcfcfcfcf, %edx
360 xorl %ecx, %ecx
361 movb %al, %bl
362 movb %ah, %cl
363 rorl $4, %edx
364 movl des_SPtrans(%ebx),%ebp
365 movb %dl, %bl
366 xorl %ebp, %esi
367 movl 0x200+des_SPtrans(%ecx),%ebp
368 xorl %ebp, %esi
369 movb %dh, %cl
370 shrl $16, %eax
371 movl 0x100+des_SPtrans(%ebx),%ebp
372 xorl %ebp, %esi
373 movb %ah, %bl
374 shrl $16, %edx
375 movl 0x300+des_SPtrans(%ecx),%ebp
376 xorl %ebp, %esi
377 movl 28(%esp), %ebp
378 movb %dh, %cl
379 andl $0xff, %eax
380 andl $0xff, %edx
381 movl 0x600+des_SPtrans(%ebx),%ebx
382 xorl %ebx, %esi
383 movl 0x700+des_SPtrans(%ecx),%ebx
384 xorl %ebx, %esi
385 movl 0x400+des_SPtrans(%eax),%ebx
386 xorl %ebx, %esi
387 movl 0x500+des_SPtrans(%edx),%ebx
388 xorl %ebx, %esi
389
390 /* Round 6 */
391 movl 32(%esp), %eax
392 movl %esi, %edx
393 shrl $16, %edx
394 movl 36(%esp), %ecx
395 xorl %esi, %edx
396 andl %edx, %eax
397 andl %ecx, %edx
398 movl %eax, %ebx
399 sall $16, %ebx
400 movl %edx, %ecx
401 sall $16, %ecx
402 xorl %ebx, %eax
403 xorl %ecx, %edx
404 movl 48(%ebp), %ebx
405 xorl %ebx, %eax
406 movl 52(%ebp), %ecx
407 xorl %esi, %eax
408 xorl %esi, %edx
409 xorl %ecx, %edx
410 andl $0xfcfcfcfc, %eax
411 xorl %ebx, %ebx
412 andl $0xcfcfcfcf, %edx
413 xorl %ecx, %ecx
414 movb %al, %bl
415 movb %ah, %cl
416 rorl $4, %edx
417 movl des_SPtrans(%ebx),%ebp
418 movb %dl, %bl
419 xorl %ebp, %edi
420 movl 0x200+des_SPtrans(%ecx),%ebp
421 xorl %ebp, %edi
422 movb %dh, %cl
423 shrl $16, %eax
424 movl 0x100+des_SPtrans(%ebx),%ebp
425 xorl %ebp, %edi
426 movb %ah, %bl
427 shrl $16, %edx
428 movl 0x300+des_SPtrans(%ecx),%ebp
429 xorl %ebp, %edi
430 movl 28(%esp), %ebp
431 movb %dh, %cl
432 andl $0xff, %eax
433 andl $0xff, %edx
434 movl 0x600+des_SPtrans(%ebx),%ebx
435 xorl %ebx, %edi
436 movl 0x700+des_SPtrans(%ecx),%ebx
437 xorl %ebx, %edi
438 movl 0x400+des_SPtrans(%eax),%ebx
439 xorl %ebx, %edi
440 movl 0x500+des_SPtrans(%edx),%ebx
441 xorl %ebx, %edi
442
443 /* Round 7 */
444 movl 32(%esp), %eax
445 movl %edi, %edx
446 shrl $16, %edx
447 movl 36(%esp), %ecx
448 xorl %edi, %edx
449 andl %edx, %eax
450 andl %ecx, %edx
451 movl %eax, %ebx
452 sall $16, %ebx
453 movl %edx, %ecx
454 sall $16, %ecx
455 xorl %ebx, %eax
456 xorl %ecx, %edx
457 movl 56(%ebp), %ebx
458 xorl %ebx, %eax
459 movl 60(%ebp), %ecx
460 xorl %edi, %eax
461 xorl %edi, %edx
462 xorl %ecx, %edx
463 andl $0xfcfcfcfc, %eax
464 xorl %ebx, %ebx
465 andl $0xcfcfcfcf, %edx
466 xorl %ecx, %ecx
467 movb %al, %bl
468 movb %ah, %cl
469 rorl $4, %edx
470 movl des_SPtrans(%ebx),%ebp
471 movb %dl, %bl
472 xorl %ebp, %esi
473 movl 0x200+des_SPtrans(%ecx),%ebp
474 xorl %ebp, %esi
475 movb %dh, %cl
476 shrl $16, %eax
477 movl 0x100+des_SPtrans(%ebx),%ebp
478 xorl %ebp, %esi
479 movb %ah, %bl
480 shrl $16, %edx
481 movl 0x300+des_SPtrans(%ecx),%ebp
482 xorl %ebp, %esi
483 movl 28(%esp), %ebp
484 movb %dh, %cl
485 andl $0xff, %eax
486 andl $0xff, %edx
487 movl 0x600+des_SPtrans(%ebx),%ebx
488 xorl %ebx, %esi
489 movl 0x700+des_SPtrans(%ecx),%ebx
490 xorl %ebx, %esi
491 movl 0x400+des_SPtrans(%eax),%ebx
492 xorl %ebx, %esi
493 movl 0x500+des_SPtrans(%edx),%ebx
494 xorl %ebx, %esi
495
496 /* Round 8 */
497 movl 32(%esp), %eax
498 movl %esi, %edx
499 shrl $16, %edx
500 movl 36(%esp), %ecx
501 xorl %esi, %edx
502 andl %edx, %eax
503 andl %ecx, %edx
504 movl %eax, %ebx
505 sall $16, %ebx
506 movl %edx, %ecx
507 sall $16, %ecx
508 xorl %ebx, %eax
509 xorl %ecx, %edx
510 movl 64(%ebp), %ebx
511 xorl %ebx, %eax
512 movl 68(%ebp), %ecx
513 xorl %esi, %eax
514 xorl %esi, %edx
515 xorl %ecx, %edx
516 andl $0xfcfcfcfc, %eax
517 xorl %ebx, %ebx
518 andl $0xcfcfcfcf, %edx
519 xorl %ecx, %ecx
520 movb %al, %bl
521 movb %ah, %cl
522 rorl $4, %edx
523 movl des_SPtrans(%ebx),%ebp
524 movb %dl, %bl
525 xorl %ebp, %edi
526 movl 0x200+des_SPtrans(%ecx),%ebp
527 xorl %ebp, %edi
528 movb %dh, %cl
529 shrl $16, %eax
530 movl 0x100+des_SPtrans(%ebx),%ebp
531 xorl %ebp, %edi
532 movb %ah, %bl
533 shrl $16, %edx
534 movl 0x300+des_SPtrans(%ecx),%ebp
535 xorl %ebp, %edi
536 movl 28(%esp), %ebp
537 movb %dh, %cl
538 andl $0xff, %eax
539 andl $0xff, %edx
540 movl 0x600+des_SPtrans(%ebx),%ebx
541 xorl %ebx, %edi
542 movl 0x700+des_SPtrans(%ecx),%ebx
543 xorl %ebx, %edi
544 movl 0x400+des_SPtrans(%eax),%ebx
545 xorl %ebx, %edi
546 movl 0x500+des_SPtrans(%edx),%ebx
547 xorl %ebx, %edi
548
549 /* Round 9 */
550 movl 32(%esp), %eax
551 movl %edi, %edx
552 shrl $16, %edx
553 movl 36(%esp), %ecx
554 xorl %edi, %edx
555 andl %edx, %eax
556 andl %ecx, %edx
557 movl %eax, %ebx
558 sall $16, %ebx
559 movl %edx, %ecx
560 sall $16, %ecx
561 xorl %ebx, %eax
562 xorl %ecx, %edx
563 movl 72(%ebp), %ebx
564 xorl %ebx, %eax
565 movl 76(%ebp), %ecx
566 xorl %edi, %eax
567 xorl %edi, %edx
568 xorl %ecx, %edx
569 andl $0xfcfcfcfc, %eax
570 xorl %ebx, %ebx
571 andl $0xcfcfcfcf, %edx
572 xorl %ecx, %ecx
573 movb %al, %bl
574 movb %ah, %cl
575 rorl $4, %edx
576 movl des_SPtrans(%ebx),%ebp
577 movb %dl, %bl
578 xorl %ebp, %esi
579 movl 0x200+des_SPtrans(%ecx),%ebp
580 xorl %ebp, %esi
581 movb %dh, %cl
582 shrl $16, %eax
583 movl 0x100+des_SPtrans(%ebx),%ebp
584 xorl %ebp, %esi
585 movb %ah, %bl
586 shrl $16, %edx
587 movl 0x300+des_SPtrans(%ecx),%ebp
588 xorl %ebp, %esi
589 movl 28(%esp), %ebp
590 movb %dh, %cl
591 andl $0xff, %eax
592 andl $0xff, %edx
593 movl 0x600+des_SPtrans(%ebx),%ebx
594 xorl %ebx, %esi
595 movl 0x700+des_SPtrans(%ecx),%ebx
596 xorl %ebx, %esi
597 movl 0x400+des_SPtrans(%eax),%ebx
598 xorl %ebx, %esi
599 movl 0x500+des_SPtrans(%edx),%ebx
600 xorl %ebx, %esi
601
602 /* Round 10 */
603 movl 32(%esp), %eax
604 movl %esi, %edx
605 shrl $16, %edx
606 movl 36(%esp), %ecx
607 xorl %esi, %edx
608 andl %edx, %eax
609 andl %ecx, %edx
610 movl %eax, %ebx
611 sall $16, %ebx
612 movl %edx, %ecx
613 sall $16, %ecx
614 xorl %ebx, %eax
615 xorl %ecx, %edx
616 movl 80(%ebp), %ebx
617 xorl %ebx, %eax
618 movl 84(%ebp), %ecx
619 xorl %esi, %eax
620 xorl %esi, %edx
621 xorl %ecx, %edx
622 andl $0xfcfcfcfc, %eax
623 xorl %ebx, %ebx
624 andl $0xcfcfcfcf, %edx
625 xorl %ecx, %ecx
626 movb %al, %bl
627 movb %ah, %cl
628 rorl $4, %edx
629 movl des_SPtrans(%ebx),%ebp
630 movb %dl, %bl
631 xorl %ebp, %edi
632 movl 0x200+des_SPtrans(%ecx),%ebp
633 xorl %ebp, %edi
634 movb %dh, %cl
635 shrl $16, %eax
636 movl 0x100+des_SPtrans(%ebx),%ebp
637 xorl %ebp, %edi
638 movb %ah, %bl
639 shrl $16, %edx
640 movl 0x300+des_SPtrans(%ecx),%ebp
641 xorl %ebp, %edi
642 movl 28(%esp), %ebp
643 movb %dh, %cl
644 andl $0xff, %eax
645 andl $0xff, %edx
646 movl 0x600+des_SPtrans(%ebx),%ebx
647 xorl %ebx, %edi
648 movl 0x700+des_SPtrans(%ecx),%ebx
649 xorl %ebx, %edi
650 movl 0x400+des_SPtrans(%eax),%ebx
651 xorl %ebx, %edi
652 movl 0x500+des_SPtrans(%edx),%ebx
653 xorl %ebx, %edi
654
655 /* Round 11 */
656 movl 32(%esp), %eax
657 movl %edi, %edx
658 shrl $16, %edx
659 movl 36(%esp), %ecx
660 xorl %edi, %edx
661 andl %edx, %eax
662 andl %ecx, %edx
663 movl %eax, %ebx
664 sall $16, %ebx
665 movl %edx, %ecx
666 sall $16, %ecx
667 xorl %ebx, %eax
668 xorl %ecx, %edx
669 movl 88(%ebp), %ebx
670 xorl %ebx, %eax
671 movl 92(%ebp), %ecx
672 xorl %edi, %eax
673 xorl %edi, %edx
674 xorl %ecx, %edx
675 andl $0xfcfcfcfc, %eax
676 xorl %ebx, %ebx
677 andl $0xcfcfcfcf, %edx
678 xorl %ecx, %ecx
679 movb %al, %bl
680 movb %ah, %cl
681 rorl $4, %edx
682 movl des_SPtrans(%ebx),%ebp
683 movb %dl, %bl
684 xorl %ebp, %esi
685 movl 0x200+des_SPtrans(%ecx),%ebp
686 xorl %ebp, %esi
687 movb %dh, %cl
688 shrl $16, %eax
689 movl 0x100+des_SPtrans(%ebx),%ebp
690 xorl %ebp, %esi
691 movb %ah, %bl
692 shrl $16, %edx
693 movl 0x300+des_SPtrans(%ecx),%ebp
694 xorl %ebp, %esi
695 movl 28(%esp), %ebp
696 movb %dh, %cl
697 andl $0xff, %eax
698 andl $0xff, %edx
699 movl 0x600+des_SPtrans(%ebx),%ebx
700 xorl %ebx, %esi
701 movl 0x700+des_SPtrans(%ecx),%ebx
702 xorl %ebx, %esi
703 movl 0x400+des_SPtrans(%eax),%ebx
704 xorl %ebx, %esi
705 movl 0x500+des_SPtrans(%edx),%ebx
706 xorl %ebx, %esi
707
708 /* Round 12 */
709 movl 32(%esp), %eax
710 movl %esi, %edx
711 shrl $16, %edx
712 movl 36(%esp), %ecx
713 xorl %esi, %edx
714 andl %edx, %eax
715 andl %ecx, %edx
716 movl %eax, %ebx
717 sall $16, %ebx
718 movl %edx, %ecx
719 sall $16, %ecx
720 xorl %ebx, %eax
721 xorl %ecx, %edx
722 movl 96(%ebp), %ebx
723 xorl %ebx, %eax
724 movl 100(%ebp), %ecx
725 xorl %esi, %eax
726 xorl %esi, %edx
727 xorl %ecx, %edx
728 andl $0xfcfcfcfc, %eax
729 xorl %ebx, %ebx
730 andl $0xcfcfcfcf, %edx
731 xorl %ecx, %ecx
732 movb %al, %bl
733 movb %ah, %cl
734 rorl $4, %edx
735 movl des_SPtrans(%ebx),%ebp
736 movb %dl, %bl
737 xorl %ebp, %edi
738 movl 0x200+des_SPtrans(%ecx),%ebp
739 xorl %ebp, %edi
740 movb %dh, %cl
741 shrl $16, %eax
742 movl 0x100+des_SPtrans(%ebx),%ebp
743 xorl %ebp, %edi
744 movb %ah, %bl
745 shrl $16, %edx
746 movl 0x300+des_SPtrans(%ecx),%ebp
747 xorl %ebp, %edi
748 movl 28(%esp), %ebp
749 movb %dh, %cl
750 andl $0xff, %eax
751 andl $0xff, %edx
752 movl 0x600+des_SPtrans(%ebx),%ebx
753 xorl %ebx, %edi
754 movl 0x700+des_SPtrans(%ecx),%ebx
755 xorl %ebx, %edi
756 movl 0x400+des_SPtrans(%eax),%ebx
757 xorl %ebx, %edi
758 movl 0x500+des_SPtrans(%edx),%ebx
759 xorl %ebx, %edi
760
761 /* Round 13 */
762 movl 32(%esp), %eax
763 movl %edi, %edx
764 shrl $16, %edx
765 movl 36(%esp), %ecx
766 xorl %edi, %edx
767 andl %edx, %eax
768 andl %ecx, %edx
769 movl %eax, %ebx
770 sall $16, %ebx
771 movl %edx, %ecx
772 sall $16, %ecx
773 xorl %ebx, %eax
774 xorl %ecx, %edx
775 movl 104(%ebp), %ebx
776 xorl %ebx, %eax
777 movl 108(%ebp), %ecx
778 xorl %edi, %eax
779 xorl %edi, %edx
780 xorl %ecx, %edx
781 andl $0xfcfcfcfc, %eax
782 xorl %ebx, %ebx
783 andl $0xcfcfcfcf, %edx
784 xorl %ecx, %ecx
785 movb %al, %bl
786 movb %ah, %cl
787 rorl $4, %edx
788 movl des_SPtrans(%ebx),%ebp
789 movb %dl, %bl
790 xorl %ebp, %esi
791 movl 0x200+des_SPtrans(%ecx),%ebp
792 xorl %ebp, %esi
793 movb %dh, %cl
794 shrl $16, %eax
795 movl 0x100+des_SPtrans(%ebx),%ebp
796 xorl %ebp, %esi
797 movb %ah, %bl
798 shrl $16, %edx
799 movl 0x300+des_SPtrans(%ecx),%ebp
800 xorl %ebp, %esi
801 movl 28(%esp), %ebp
802 movb %dh, %cl
803 andl $0xff, %eax
804 andl $0xff, %edx
805 movl 0x600+des_SPtrans(%ebx),%ebx
806 xorl %ebx, %esi
807 movl 0x700+des_SPtrans(%ecx),%ebx
808 xorl %ebx, %esi
809 movl 0x400+des_SPtrans(%eax),%ebx
810 xorl %ebx, %esi
811 movl 0x500+des_SPtrans(%edx),%ebx
812 xorl %ebx, %esi
813
814 /* Round 14 */
815 movl 32(%esp), %eax
816 movl %esi, %edx
817 shrl $16, %edx
818 movl 36(%esp), %ecx
819 xorl %esi, %edx
820 andl %edx, %eax
821 andl %ecx, %edx
822 movl %eax, %ebx
823 sall $16, %ebx
824 movl %edx, %ecx
825 sall $16, %ecx
826 xorl %ebx, %eax
827 xorl %ecx, %edx
828 movl 112(%ebp), %ebx
829 xorl %ebx, %eax
830 movl 116(%ebp), %ecx
831 xorl %esi, %eax
832 xorl %esi, %edx
833 xorl %ecx, %edx
834 andl $0xfcfcfcfc, %eax
835 xorl %ebx, %ebx
836 andl $0xcfcfcfcf, %edx
837 xorl %ecx, %ecx
838 movb %al, %bl
839 movb %ah, %cl
840 rorl $4, %edx
841 movl des_SPtrans(%ebx),%ebp
842 movb %dl, %bl
843 xorl %ebp, %edi
844 movl 0x200+des_SPtrans(%ecx),%ebp
845 xorl %ebp, %edi
846 movb %dh, %cl
847 shrl $16, %eax
848 movl 0x100+des_SPtrans(%ebx),%ebp
849 xorl %ebp, %edi
850 movb %ah, %bl
851 shrl $16, %edx
852 movl 0x300+des_SPtrans(%ecx),%ebp
853 xorl %ebp, %edi
854 movl 28(%esp), %ebp
855 movb %dh, %cl
856 andl $0xff, %eax
857 andl $0xff, %edx
858 movl 0x600+des_SPtrans(%ebx),%ebx
859 xorl %ebx, %edi
860 movl 0x700+des_SPtrans(%ecx),%ebx
861 xorl %ebx, %edi
862 movl 0x400+des_SPtrans(%eax),%ebx
863 xorl %ebx, %edi
864 movl 0x500+des_SPtrans(%edx),%ebx
865 xorl %ebx, %edi
866
867 /* Round 15 */
868 movl 32(%esp), %eax
869 movl %edi, %edx
870 shrl $16, %edx
871 movl 36(%esp), %ecx
872 xorl %edi, %edx
873 andl %edx, %eax
874 andl %ecx, %edx
875 movl %eax, %ebx
876 sall $16, %ebx
877 movl %edx, %ecx
878 sall $16, %ecx
879 xorl %ebx, %eax
880 xorl %ecx, %edx
881 movl 120(%ebp), %ebx
882 xorl %ebx, %eax
883 movl 124(%ebp), %ecx
884 xorl %edi, %eax
885 xorl %edi, %edx
886 xorl %ecx, %edx
887 andl $0xfcfcfcfc, %eax
888 xorl %ebx, %ebx
889 andl $0xcfcfcfcf, %edx
890 xorl %ecx, %ecx
891 movb %al, %bl
892 movb %ah, %cl
893 rorl $4, %edx
894 movl des_SPtrans(%ebx),%ebp
895 movb %dl, %bl
896 xorl %ebp, %esi
897 movl 0x200+des_SPtrans(%ecx),%ebp
898 xorl %ebp, %esi
899 movb %dh, %cl
900 shrl $16, %eax
901 movl 0x100+des_SPtrans(%ebx),%ebp
902 xorl %ebp, %esi
903 movb %ah, %bl
904 shrl $16, %edx
905 movl 0x300+des_SPtrans(%ecx),%ebp
906 xorl %ebp, %esi
907 movl 28(%esp), %ebp
908 movb %dh, %cl
909 andl $0xff, %eax
910 andl $0xff, %edx
911 movl 0x600+des_SPtrans(%ebx),%ebx
912 xorl %ebx, %esi
913 movl 0x700+des_SPtrans(%ecx),%ebx
914 xorl %ebx, %esi
915 movl 0x400+des_SPtrans(%eax),%ebx
916 xorl %ebx, %esi
917 movl 0x500+des_SPtrans(%edx),%ebx
918 xorl %ebx, %esi
919 movl (%esp), %ebx
920 movl %edi, %eax
921 decl %ebx
922 movl %esi, %edi
923 movl %eax, %esi
924 movl %ebx, (%esp)
925 jnz .L000start
926
927 /* FP */
928 movl 24(%esp), %edx
929.byte 209
930.byte 207 /* rorl $1 %edi */
931 movl %esi, %eax
932 xorl %edi, %esi
933 andl $0xaaaaaaaa, %esi
934 xorl %esi, %eax
935 xorl %esi, %edi
936
937 roll $23, %eax
938 movl %eax, %esi
939 xorl %edi, %eax
940 andl $0x03fc03fc, %eax
941 xorl %eax, %esi
942 xorl %eax, %edi
943
944 roll $10, %esi
945 movl %esi, %eax
946 xorl %edi, %esi
947 andl $0x33333333, %esi
948 xorl %esi, %eax
949 xorl %esi, %edi
950
951 roll $18, %edi
952 movl %edi, %esi
953 xorl %eax, %edi
954 andl $0xfff0000f, %edi
955 xorl %edi, %esi
956 xorl %edi, %eax
957
958 roll $12, %esi
959 movl %esi, %edi
960 xorl %eax, %esi
961 andl $0xf0f0f0f0, %esi
962 xorl %esi, %edi
963 xorl %esi, %eax
964
965 rorl $4, %eax
966 movl %eax, (%edx)
967 movl %edi, 4(%edx)
968 popl %ecx
969 popl %edi
970 popl %esi
971 popl %ebx
972 popl %ebp
973 ret
974.fcrypt_body_end:
975 SIZE(fcrypt_body,.fcrypt_body_end-fcrypt_body)
976.ident "fcrypt_body"
diff --git a/src/lib/libssl/src/crypto/des/des.man b/src/lib/libssl/src/crypto/des/des.man
new file mode 100644
index 0000000000..7e06a1851a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/des.man
@@ -0,0 +1,186 @@
1.TH DES 1
2.SH NAME
3des - encrypt or decrypt data using Data Encryption Standard
4.SH SYNOPSIS
5.B des
6(
7.B \-e
8|
9.B \-E
10) | (
11.B \-d
12|
13.B \-D
14) | (
15.B \-\fR[\fPcC\fR][\fPckname\fR]\fP
16) |
17[
18.B \-b3hfs
19] [
20.B \-k
21.I key
22]
23] [
24.B \-u\fR[\fIuuname\fR]
25[
26.I input-file
27[
28.I output-file
29] ]
30.SH DESCRIPTION
31.B des
32encrypts and decrypts data using the
33Data Encryption Standard algorithm.
34One of
35.B \-e, \-E
36(for encrypt) or
37.B \-d, \-D
38(for decrypt) must be specified.
39It is also possible to use
40.B \-c
41or
42.B \-C
43in conjunction or instead of the a encrypt/decrypt option to generate
44a 16 character hexadecimal checksum, generated via the
45.I des_cbc_cksum.
46.LP
47Two standard encryption modes are supported by the
48.B des
49program, Cipher Block Chaining (the default) and Electronic Code Book
50(specified with
51.B \-b
52).
53.LP
54The key used for the DES
55algorithm is obtained by prompting the user unless the
56.B `\-k
57.I key'
58option is given.
59If the key is an argument to the
60.B des
61command, it is potentially visible to users executing
62.BR ps (1)
63or a derivative. To minimise this possibility,
64.B des
65takes care to destroy the key argument immediately upon entry.
66If your shell keeps a history file be careful to make sure it is not
67world readable.
68.LP
69Since this program attempts to maintain compatability with sunOS's
70des(1) command, there are 2 different methods used to convert the user
71supplied key to a des key.
72Whenever and one or more of
73.B \-E, \-D, \-C
74or
75.B \-3
76options are used, the key conversion procedure will not be compatible
77with the sunOS des(1) version but will use all the user supplied
78character to generate the des key.
79.B des
80command reads from standard input unless
81.I input-file
82is specified and writes to standard output unless
83.I output-file
84is given.
85.SH OPTIONS
86.TP
87.B \-b
88Select ECB
89(eight bytes at a time) encryption mode.
90.TP
91.B \-3
92Encrypt using triple encryption.
93By default triple cbc encryption is used but if the
94.B \-b
95option is used then triple ecb encryption is performed.
96If the key is less than 8 characters long, the flag has no effect.
97.TP
98.B \-e
99Encrypt data using an 8 byte key in a manner compatible with sunOS
100des(1).
101.TP
102.B \-E
103Encrypt data using a key of nearly unlimited length (1024 bytes).
104This will product a more secure encryption.
105.TP
106.B \-d
107Decrypt data that was encrypted with the \-e option.
108.TP
109.B \-D
110Decrypt data that was encrypted with the \-E option.
111.TP
112.B \-c
113Generate a 16 character hexadecimal cbc checksum and output this to
114stderr.
115If a filename was specified after the
116.B \-c
117option, the checksum is output to that file.
118The checksum is generated using a key generated in a sunOS compatible
119manner.
120.TP
121.B \-C
122A cbc checksum is generated in the same manner as described for the
123.B \-c
124option but the DES key is generated in the same manner as used for the
125.B \-E
126and
127.B \-D
128options
129.TP
130.B \-f
131Does nothing - allowed for compatibility with sunOS des(1) command.
132.TP
133.B \-s
134Does nothing - allowed for compatibility with sunOS des(1) command.
135.TP
136.B "\-k \fIkey\fP"
137Use the encryption
138.I key
139specified.
140.TP
141.B "\-h"
142The
143.I key
144is assumed to be a 16 character hexadecimal number.
145If the
146.B "\-3"
147option is used the key is assumed to be a 32 character hexadecimal
148number.
149.TP
150.B \-u
151This flag is used to read and write uuencoded files. If decrypting,
152the input file is assumed to contain uuencoded, DES encrypted data.
153If encrypting, the characters following the -u are used as the name of
154the uuencoded file to embed in the begin line of the uuencoded
155output. If there is no name specified after the -u, the name text.des
156will be embedded in the header.
157.SH SEE ALSO
158.B ps (1)
159.B des_crypt(3)
160.SH BUGS
161.LP
162The problem with using the
163.B -e
164option is the short key length.
165It would be better to use a real 56-bit key rather than an
166ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII
167radically reduces the time necessary for a brute-force cryptographic attack.
168My attempt to remove this problem is to add an alternative text-key to
169DES-key function. This alternative function (accessed via
170.B -E, -D, -S
171and
172.B -3
173)
174uses DES to help generate the key.
175.LP
176Be carefully when using the -u option. Doing des -ud <filename> will
177not decrypt filename (the -u option will gobble the d option).
178.LP
179The VMS operating system operates in a world where files are always a
180multiple of 512 bytes. This causes problems when encrypted data is
181send from unix to VMS since a 88 byte file will suddenly be padded
182with 424 null bytes. To get around this problem, use the -u option
183to uuencode the data before it is send to the VMS system.
184.SH AUTHOR
185.LP
186Eric Young (eay@cryptsoft.com)
diff --git a/src/lib/libssl/src/crypto/des/des.org b/src/lib/libssl/src/crypto/des/des.org
new file mode 100644
index 0000000000..a4cf5c8770
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/des.org
@@ -0,0 +1,301 @@
1/* crypto/des/des.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify des.org since des.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_DES_H
68#define HEADER_DES_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74#include <stdio.h>
75
76/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
77 * %20 speed up (longs are 8 bytes, int's are 4). */
78#ifndef DES_LONG
79#define DES_LONG unsigned long
80#endif
81
82typedef unsigned char des_cblock[8];
83typedef struct des_ks_struct
84 {
85 union {
86 des_cblock _;
87 /* make sure things are correct size on machines with
88 * 8 byte longs */
89 DES_LONG pad[2];
90 } ks;
91#undef _
92#define _ ks._
93 } des_key_schedule[16];
94
95#define DES_KEY_SZ (sizeof(des_cblock))
96#define DES_SCHEDULE_SZ (sizeof(des_key_schedule))
97
98#define DES_ENCRYPT 1
99#define DES_DECRYPT 0
100
101#define DES_CBC_MODE 0
102#define DES_PCBC_MODE 1
103
104#define des_ecb2_encrypt(i,o,k1,k2,e) \
105 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
106
107#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
108 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
109
110#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
111 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
112
113#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
114 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
115
116#define C_Block des_cblock
117#define Key_schedule des_key_schedule
118#ifdef KERBEROS
119#define ENCRYPT DES_ENCRYPT
120#define DECRYPT DES_DECRYPT
121#endif
122#define KEY_SZ DES_KEY_SZ
123#define string_to_key des_string_to_key
124#define read_pw_string des_read_pw_string
125#define random_key des_random_key
126#define pcbc_encrypt des_pcbc_encrypt
127#define set_key des_set_key
128#define key_sched des_key_sched
129#define ecb_encrypt des_ecb_encrypt
130#define cbc_encrypt des_cbc_encrypt
131#define ncbc_encrypt des_ncbc_encrypt
132#define xcbc_encrypt des_xcbc_encrypt
133#define cbc_cksum des_cbc_cksum
134#define quad_cksum des_quad_cksum
135
136/* For compatibility with the MIT lib - eay 20/05/92 */
137typedef des_key_schedule bit_64;
138#define des_fixup_key_parity des_set_odd_parity
139#define des_check_key_parity check_parity
140
141extern int des_check_key; /* defaults to false */
142extern int des_rw_mode; /* defaults to DES_PCBC_MODE */
143
144/* The next line is used to disable full ANSI prototypes, if your
145 * compiler has problems with the prototypes, make sure this line always
146 * evaluates to true :-) */
147#if defined(MSDOS) || defined(__STDC__)
148#undef NOPROTO
149#endif
150#ifndef NOPROTO
151char *des_options(void);
152void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
153 des_key_schedule ks1,des_key_schedule ks2,
154 des_key_schedule ks3, int enc);
155DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output,
156 long length,des_key_schedule schedule,des_cblock *ivec);
157void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
158 des_key_schedule schedule,des_cblock *ivec,int enc);
159void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
160 des_key_schedule schedule,des_cblock *ivec,int enc);
161void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
162 des_key_schedule schedule,des_cblock *ivec,
163 des_cblock *inw,des_cblock *outw,int enc);
164void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
165 long length,des_key_schedule schedule,des_cblock *ivec,int enc);
166void des_ecb_encrypt(des_cblock *input,des_cblock *output,
167 des_key_schedule ks,int enc);
168void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
169void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
170void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
171 des_key_schedule ks2, des_key_schedule ks3);
172void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
173 des_key_schedule ks2, des_key_schedule ks3);
174void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
175 long length, des_key_schedule ks1, des_key_schedule ks2,
176 des_key_schedule ks3, des_cblock *ivec, int enc);
177void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
178 long length, des_key_schedule ks1, des_key_schedule ks2,
179 des_key_schedule ks3, des_cblock *ivec, int *num, int enc);
180void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
181 long length, des_key_schedule ks1, des_key_schedule ks2,
182 des_key_schedule ks3, des_cblock *ivec, int *num);
183
184void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white),
185 des_cblock (*out_white));
186
187int des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
188 des_cblock *iv);
189int des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
190 des_cblock *iv);
191char *des_fcrypt(const char *buf,const char *salt, char *ret);
192#ifdef PERL5
193char *des_crypt(const char *buf,const char *salt);
194#else
195/* some stupid compilers complain because I have declared char instead
196 * of const char */
197#ifdef HEADER_DES_LOCL_H
198char *crypt(const char *buf,const char *salt);
199#else
200char *crypt();
201#endif
202#endif
203void des_ofb_encrypt(unsigned char *in,unsigned char *out,
204 int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
205void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
206 des_key_schedule schedule,des_cblock *ivec,int enc);
207DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output,
208 long length,int out_count,des_cblock *seed);
209void des_random_seed(des_cblock key);
210void des_random_key(des_cblock ret);
211int des_read_password(des_cblock *key,char *prompt,int verify);
212int des_read_2passwords(des_cblock *key1,des_cblock *key2,
213 char *prompt,int verify);
214int des_read_pw_string(char *buf,int length,char *prompt,int verify);
215void des_set_odd_parity(des_cblock *key);
216int des_is_weak_key(des_cblock *key);
217int des_set_key(des_cblock *key,des_key_schedule schedule);
218int des_key_sched(des_cblock *key,des_key_schedule schedule);
219void des_string_to_key(char *str,des_cblock *key);
220void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
221void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
222 des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
223void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
224 des_key_schedule schedule, des_cblock *ivec, int *num);
225int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify);
226
227/* Extra functions from Mark Murray <mark@grondar.za> */
228void des_cblock_print_file(des_cblock *cb, FILE *fp);
229/* The following functions are not in the normal unix build or the
230 * SSLeay build. When using the SSLeay build, use RAND_seed()
231 * and RAND_bytes() instead. */
232int des_new_random_key(des_cblock *key);
233void des_init_random_number_generator(des_cblock *key);
234void des_set_random_generator_seed(des_cblock *key);
235void des_set_sequence_number(des_cblock new_sequence_number);
236void des_generate_random_block(des_cblock *block);
237
238#else
239
240char *des_options();
241void des_ecb3_encrypt();
242DES_LONG des_cbc_cksum();
243void des_cbc_encrypt();
244void des_ncbc_encrypt();
245void des_xcbc_encrypt();
246void des_cfb_encrypt();
247void des_ede3_cfb64_encrypt();
248void des_ede3_ofb64_encrypt();
249void des_ecb_encrypt();
250void des_encrypt();
251void des_encrypt2();
252void des_encrypt3();
253void des_decrypt3();
254void des_ede3_cbc_encrypt();
255int des_enc_read();
256int des_enc_write();
257char *des_fcrypt();
258#ifdef PERL5
259char *des_crypt();
260#else
261char *crypt();
262#endif
263void des_ofb_encrypt();
264void des_pcbc_encrypt();
265DES_LONG des_quad_cksum();
266void des_random_seed();
267void des_random_key();
268int des_read_password();
269int des_read_2passwords();
270int des_read_pw_string();
271void des_set_odd_parity();
272int des_is_weak_key();
273int des_set_key();
274int des_key_sched();
275void des_string_to_key();
276void des_string_to_2keys();
277void des_cfb64_encrypt();
278void des_ofb64_encrypt();
279int des_read_pw();
280void des_xwhite_in2out();
281
282/* Extra functions from Mark Murray <mark@grondar.za> */
283void des_cblock_print_file();
284/* The following functions are not in the normal unix build or the
285 * SSLeay build. When using the SSLeay build, use RAND_seed()
286 * and RAND_bytes() instead. */
287#ifdef FreeBSD
288int des_new_random_key();
289void des_init_random_number_generator();
290void des_set_random_generator_seed();
291void des_set_sequence_number();
292void des_generate_random_block();
293#endif
294
295#endif
296
297#ifdef __cplusplus
298}
299#endif
300
301#endif
diff --git a/src/lib/libssl/src/crypto/des/des.pl b/src/lib/libssl/src/crypto/des/des.pl
new file mode 100644
index 0000000000..935eacb504
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/des.pl
@@ -0,0 +1,552 @@
1#!/usr/bin/perl
2# des.pl - eric young 22/11/1991 eay@cryptsoft.com
3#
4# Copyright (C) 1993 Eric Young
5#
6# 11 April 1996 - patched to circumvent Perl 5 (through 5.002) problem
7# with sign-extension on right shift operations.
8# Ed Kubaitis - ejk@uiuc.edu
9#
10# eay - 92/08/31 - I think I have fixed all problems for 64bit
11# versions of perl but I could be wrong since I have not tested it yet :-).
12#
13# This is an implementation of DES in perl.
14# The two routines (des_set_key and des_ecb_encrypt)
15# take 8 byte objects as arguments.
16#
17# des_set_key takes an 8 byte string as a key and returns a key schedule
18# for use in calls to des_ecb_encrypt.
19# des_ecb_encrypt takes three arguments, the first is a key schedule
20# (make sure to pass it by reference with the *), the second is 1
21# to encrypt, 0 to decrypt. The third argument is an 8 byte object
22# to encrypt. The function returns an 8 byte object that has been
23# DES encrypted.
24#
25# example:
26# require 'des.pl'
27#
28# $key =pack("C8",0x12,0x23,0x45,0x67,0x89,0xab,0xcd,0xef);
29# @ks= &des_set_key($key);
30#
31# $outbytes= &des_ecb_encrypt(*ks,1,$data);
32# @enc =unpack("C8",$outbytes);
33#
34
35package des;
36
37eval("use integer;") if (int($]) > 4);
38
39# The following 8 arrays are used in des_set_key
40@skb0=(
41# for C bits (numbered as per FIPS 46) 1 2 3 4 5 6
420x00000000,0x00000010,0x20000000,0x20000010,
430x00010000,0x00010010,0x20010000,0x20010010,
440x00000800,0x00000810,0x20000800,0x20000810,
450x00010800,0x00010810,0x20010800,0x20010810,
460x00000020,0x00000030,0x20000020,0x20000030,
470x00010020,0x00010030,0x20010020,0x20010030,
480x00000820,0x00000830,0x20000820,0x20000830,
490x00010820,0x00010830,0x20010820,0x20010830,
500x00080000,0x00080010,0x20080000,0x20080010,
510x00090000,0x00090010,0x20090000,0x20090010,
520x00080800,0x00080810,0x20080800,0x20080810,
530x00090800,0x00090810,0x20090800,0x20090810,
540x00080020,0x00080030,0x20080020,0x20080030,
550x00090020,0x00090030,0x20090020,0x20090030,
560x00080820,0x00080830,0x20080820,0x20080830,
570x00090820,0x00090830,0x20090820,0x20090830,
58);
59@skb1=(
60# for C bits (numbered as per FIPS 46) 7 8 10 11 12 13
610x00000000,0x02000000,0x00002000,0x02002000,
620x00200000,0x02200000,0x00202000,0x02202000,
630x00000004,0x02000004,0x00002004,0x02002004,
640x00200004,0x02200004,0x00202004,0x02202004,
650x00000400,0x02000400,0x00002400,0x02002400,
660x00200400,0x02200400,0x00202400,0x02202400,
670x00000404,0x02000404,0x00002404,0x02002404,
680x00200404,0x02200404,0x00202404,0x02202404,
690x10000000,0x12000000,0x10002000,0x12002000,
700x10200000,0x12200000,0x10202000,0x12202000,
710x10000004,0x12000004,0x10002004,0x12002004,
720x10200004,0x12200004,0x10202004,0x12202004,
730x10000400,0x12000400,0x10002400,0x12002400,
740x10200400,0x12200400,0x10202400,0x12202400,
750x10000404,0x12000404,0x10002404,0x12002404,
760x10200404,0x12200404,0x10202404,0x12202404,
77);
78@skb2=(
79# for C bits (numbered as per FIPS 46) 14 15 16 17 19 20
800x00000000,0x00000001,0x00040000,0x00040001,
810x01000000,0x01000001,0x01040000,0x01040001,
820x00000002,0x00000003,0x00040002,0x00040003,
830x01000002,0x01000003,0x01040002,0x01040003,
840x00000200,0x00000201,0x00040200,0x00040201,
850x01000200,0x01000201,0x01040200,0x01040201,
860x00000202,0x00000203,0x00040202,0x00040203,
870x01000202,0x01000203,0x01040202,0x01040203,
880x08000000,0x08000001,0x08040000,0x08040001,
890x09000000,0x09000001,0x09040000,0x09040001,
900x08000002,0x08000003,0x08040002,0x08040003,
910x09000002,0x09000003,0x09040002,0x09040003,
920x08000200,0x08000201,0x08040200,0x08040201,
930x09000200,0x09000201,0x09040200,0x09040201,
940x08000202,0x08000203,0x08040202,0x08040203,
950x09000202,0x09000203,0x09040202,0x09040203,
96);
97@skb3=(
98# for C bits (numbered as per FIPS 46) 21 23 24 26 27 28
990x00000000,0x00100000,0x00000100,0x00100100,
1000x00000008,0x00100008,0x00000108,0x00100108,
1010x00001000,0x00101000,0x00001100,0x00101100,
1020x00001008,0x00101008,0x00001108,0x00101108,
1030x04000000,0x04100000,0x04000100,0x04100100,
1040x04000008,0x04100008,0x04000108,0x04100108,
1050x04001000,0x04101000,0x04001100,0x04101100,
1060x04001008,0x04101008,0x04001108,0x04101108,
1070x00020000,0x00120000,0x00020100,0x00120100,
1080x00020008,0x00120008,0x00020108,0x00120108,
1090x00021000,0x00121000,0x00021100,0x00121100,
1100x00021008,0x00121008,0x00021108,0x00121108,
1110x04020000,0x04120000,0x04020100,0x04120100,
1120x04020008,0x04120008,0x04020108,0x04120108,
1130x04021000,0x04121000,0x04021100,0x04121100,
1140x04021008,0x04121008,0x04021108,0x04121108,
115);
116@skb4=(
117# for D bits (numbered as per FIPS 46) 1 2 3 4 5 6
1180x00000000,0x10000000,0x00010000,0x10010000,
1190x00000004,0x10000004,0x00010004,0x10010004,
1200x20000000,0x30000000,0x20010000,0x30010000,
1210x20000004,0x30000004,0x20010004,0x30010004,
1220x00100000,0x10100000,0x00110000,0x10110000,
1230x00100004,0x10100004,0x00110004,0x10110004,
1240x20100000,0x30100000,0x20110000,0x30110000,
1250x20100004,0x30100004,0x20110004,0x30110004,
1260x00001000,0x10001000,0x00011000,0x10011000,
1270x00001004,0x10001004,0x00011004,0x10011004,
1280x20001000,0x30001000,0x20011000,0x30011000,
1290x20001004,0x30001004,0x20011004,0x30011004,
1300x00101000,0x10101000,0x00111000,0x10111000,
1310x00101004,0x10101004,0x00111004,0x10111004,
1320x20101000,0x30101000,0x20111000,0x30111000,
1330x20101004,0x30101004,0x20111004,0x30111004,
134);
135@skb5=(
136# for D bits (numbered as per FIPS 46) 8 9 11 12 13 14
1370x00000000,0x08000000,0x00000008,0x08000008,
1380x00000400,0x08000400,0x00000408,0x08000408,
1390x00020000,0x08020000,0x00020008,0x08020008,
1400x00020400,0x08020400,0x00020408,0x08020408,
1410x00000001,0x08000001,0x00000009,0x08000009,
1420x00000401,0x08000401,0x00000409,0x08000409,
1430x00020001,0x08020001,0x00020009,0x08020009,
1440x00020401,0x08020401,0x00020409,0x08020409,
1450x02000000,0x0A000000,0x02000008,0x0A000008,
1460x02000400,0x0A000400,0x02000408,0x0A000408,
1470x02020000,0x0A020000,0x02020008,0x0A020008,
1480x02020400,0x0A020400,0x02020408,0x0A020408,
1490x02000001,0x0A000001,0x02000009,0x0A000009,
1500x02000401,0x0A000401,0x02000409,0x0A000409,
1510x02020001,0x0A020001,0x02020009,0x0A020009,
1520x02020401,0x0A020401,0x02020409,0x0A020409,
153);
154@skb6=(
155# for D bits (numbered as per FIPS 46) 16 17 18 19 20 21
1560x00000000,0x00000100,0x00080000,0x00080100,
1570x01000000,0x01000100,0x01080000,0x01080100,
1580x00000010,0x00000110,0x00080010,0x00080110,
1590x01000010,0x01000110,0x01080010,0x01080110,
1600x00200000,0x00200100,0x00280000,0x00280100,
1610x01200000,0x01200100,0x01280000,0x01280100,
1620x00200010,0x00200110,0x00280010,0x00280110,
1630x01200010,0x01200110,0x01280010,0x01280110,
1640x00000200,0x00000300,0x00080200,0x00080300,
1650x01000200,0x01000300,0x01080200,0x01080300,
1660x00000210,0x00000310,0x00080210,0x00080310,
1670x01000210,0x01000310,0x01080210,0x01080310,
1680x00200200,0x00200300,0x00280200,0x00280300,
1690x01200200,0x01200300,0x01280200,0x01280300,
1700x00200210,0x00200310,0x00280210,0x00280310,
1710x01200210,0x01200310,0x01280210,0x01280310,
172);
173@skb7=(
174# for D bits (numbered as per FIPS 46) 22 23 24 25 27 28
1750x00000000,0x04000000,0x00040000,0x04040000,
1760x00000002,0x04000002,0x00040002,0x04040002,
1770x00002000,0x04002000,0x00042000,0x04042000,
1780x00002002,0x04002002,0x00042002,0x04042002,
1790x00000020,0x04000020,0x00040020,0x04040020,
1800x00000022,0x04000022,0x00040022,0x04040022,
1810x00002020,0x04002020,0x00042020,0x04042020,
1820x00002022,0x04002022,0x00042022,0x04042022,
1830x00000800,0x04000800,0x00040800,0x04040800,
1840x00000802,0x04000802,0x00040802,0x04040802,
1850x00002800,0x04002800,0x00042800,0x04042800,
1860x00002802,0x04002802,0x00042802,0x04042802,
1870x00000820,0x04000820,0x00040820,0x04040820,
1880x00000822,0x04000822,0x00040822,0x04040822,
1890x00002820,0x04002820,0x00042820,0x04042820,
1900x00002822,0x04002822,0x00042822,0x04042822,
191);
192
193@shifts2=(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0);
194
195# used in ecb_encrypt
196@SP0=(
1970x00410100, 0x00010000, 0x40400000, 0x40410100,
1980x00400000, 0x40010100, 0x40010000, 0x40400000,
1990x40010100, 0x00410100, 0x00410000, 0x40000100,
2000x40400100, 0x00400000, 0x00000000, 0x40010000,
2010x00010000, 0x40000000, 0x00400100, 0x00010100,
2020x40410100, 0x00410000, 0x40000100, 0x00400100,
2030x40000000, 0x00000100, 0x00010100, 0x40410000,
2040x00000100, 0x40400100, 0x40410000, 0x00000000,
2050x00000000, 0x40410100, 0x00400100, 0x40010000,
2060x00410100, 0x00010000, 0x40000100, 0x00400100,
2070x40410000, 0x00000100, 0x00010100, 0x40400000,
2080x40010100, 0x40000000, 0x40400000, 0x00410000,
2090x40410100, 0x00010100, 0x00410000, 0x40400100,
2100x00400000, 0x40000100, 0x40010000, 0x00000000,
2110x00010000, 0x00400000, 0x40400100, 0x00410100,
2120x40000000, 0x40410000, 0x00000100, 0x40010100,
213);
214@SP1=(
2150x08021002, 0x00000000, 0x00021000, 0x08020000,
2160x08000002, 0x00001002, 0x08001000, 0x00021000,
2170x00001000, 0x08020002, 0x00000002, 0x08001000,
2180x00020002, 0x08021000, 0x08020000, 0x00000002,
2190x00020000, 0x08001002, 0x08020002, 0x00001000,
2200x00021002, 0x08000000, 0x00000000, 0x00020002,
2210x08001002, 0x00021002, 0x08021000, 0x08000002,
2220x08000000, 0x00020000, 0x00001002, 0x08021002,
2230x00020002, 0x08021000, 0x08001000, 0x00021002,
2240x08021002, 0x00020002, 0x08000002, 0x00000000,
2250x08000000, 0x00001002, 0x00020000, 0x08020002,
2260x00001000, 0x08000000, 0x00021002, 0x08001002,
2270x08021000, 0x00001000, 0x00000000, 0x08000002,
2280x00000002, 0x08021002, 0x00021000, 0x08020000,
2290x08020002, 0x00020000, 0x00001002, 0x08001000,
2300x08001002, 0x00000002, 0x08020000, 0x00021000,
231);
232@SP2=(
2330x20800000, 0x00808020, 0x00000020, 0x20800020,
2340x20008000, 0x00800000, 0x20800020, 0x00008020,
2350x00800020, 0x00008000, 0x00808000, 0x20000000,
2360x20808020, 0x20000020, 0x20000000, 0x20808000,
2370x00000000, 0x20008000, 0x00808020, 0x00000020,
2380x20000020, 0x20808020, 0x00008000, 0x20800000,
2390x20808000, 0x00800020, 0x20008020, 0x00808000,
2400x00008020, 0x00000000, 0x00800000, 0x20008020,
2410x00808020, 0x00000020, 0x20000000, 0x00008000,
2420x20000020, 0x20008000, 0x00808000, 0x20800020,
2430x00000000, 0x00808020, 0x00008020, 0x20808000,
2440x20008000, 0x00800000, 0x20808020, 0x20000000,
2450x20008020, 0x20800000, 0x00800000, 0x20808020,
2460x00008000, 0x00800020, 0x20800020, 0x00008020,
2470x00800020, 0x00000000, 0x20808000, 0x20000020,
2480x20800000, 0x20008020, 0x00000020, 0x00808000,
249);
250@SP3=(
2510x00080201, 0x02000200, 0x00000001, 0x02080201,
2520x00000000, 0x02080000, 0x02000201, 0x00080001,
2530x02080200, 0x02000001, 0x02000000, 0x00000201,
2540x02000001, 0x00080201, 0x00080000, 0x02000000,
2550x02080001, 0x00080200, 0x00000200, 0x00000001,
2560x00080200, 0x02000201, 0x02080000, 0x00000200,
2570x00000201, 0x00000000, 0x00080001, 0x02080200,
2580x02000200, 0x02080001, 0x02080201, 0x00080000,
2590x02080001, 0x00000201, 0x00080000, 0x02000001,
2600x00080200, 0x02000200, 0x00000001, 0x02080000,
2610x02000201, 0x00000000, 0x00000200, 0x00080001,
2620x00000000, 0x02080001, 0x02080200, 0x00000200,
2630x02000000, 0x02080201, 0x00080201, 0x00080000,
2640x02080201, 0x00000001, 0x02000200, 0x00080201,
2650x00080001, 0x00080200, 0x02080000, 0x02000201,
2660x00000201, 0x02000000, 0x02000001, 0x02080200,
267);
268@SP4=(
2690x01000000, 0x00002000, 0x00000080, 0x01002084,
2700x01002004, 0x01000080, 0x00002084, 0x01002000,
2710x00002000, 0x00000004, 0x01000004, 0x00002080,
2720x01000084, 0x01002004, 0x01002080, 0x00000000,
2730x00002080, 0x01000000, 0x00002004, 0x00000084,
2740x01000080, 0x00002084, 0x00000000, 0x01000004,
2750x00000004, 0x01000084, 0x01002084, 0x00002004,
2760x01002000, 0x00000080, 0x00000084, 0x01002080,
2770x01002080, 0x01000084, 0x00002004, 0x01002000,
2780x00002000, 0x00000004, 0x01000004, 0x01000080,
2790x01000000, 0x00002080, 0x01002084, 0x00000000,
2800x00002084, 0x01000000, 0x00000080, 0x00002004,
2810x01000084, 0x00000080, 0x00000000, 0x01002084,
2820x01002004, 0x01002080, 0x00000084, 0x00002000,
2830x00002080, 0x01002004, 0x01000080, 0x00000084,
2840x00000004, 0x00002084, 0x01002000, 0x01000004,
285);
286@SP5=(
2870x10000008, 0x00040008, 0x00000000, 0x10040400,
2880x00040008, 0x00000400, 0x10000408, 0x00040000,
2890x00000408, 0x10040408, 0x00040400, 0x10000000,
2900x10000400, 0x10000008, 0x10040000, 0x00040408,
2910x00040000, 0x10000408, 0x10040008, 0x00000000,
2920x00000400, 0x00000008, 0x10040400, 0x10040008,
2930x10040408, 0x10040000, 0x10000000, 0x00000408,
2940x00000008, 0x00040400, 0x00040408, 0x10000400,
2950x00000408, 0x10000000, 0x10000400, 0x00040408,
2960x10040400, 0x00040008, 0x00000000, 0x10000400,
2970x10000000, 0x00000400, 0x10040008, 0x00040000,
2980x00040008, 0x10040408, 0x00040400, 0x00000008,
2990x10040408, 0x00040400, 0x00040000, 0x10000408,
3000x10000008, 0x10040000, 0x00040408, 0x00000000,
3010x00000400, 0x10000008, 0x10000408, 0x10040400,
3020x10040000, 0x00000408, 0x00000008, 0x10040008,
303);
304@SP6=(
3050x00000800, 0x00000040, 0x00200040, 0x80200000,
3060x80200840, 0x80000800, 0x00000840, 0x00000000,
3070x00200000, 0x80200040, 0x80000040, 0x00200800,
3080x80000000, 0x00200840, 0x00200800, 0x80000040,
3090x80200040, 0x00000800, 0x80000800, 0x80200840,
3100x00000000, 0x00200040, 0x80200000, 0x00000840,
3110x80200800, 0x80000840, 0x00200840, 0x80000000,
3120x80000840, 0x80200800, 0x00000040, 0x00200000,
3130x80000840, 0x00200800, 0x80200800, 0x80000040,
3140x00000800, 0x00000040, 0x00200000, 0x80200800,
3150x80200040, 0x80000840, 0x00000840, 0x00000000,
3160x00000040, 0x80200000, 0x80000000, 0x00200040,
3170x00000000, 0x80200040, 0x00200040, 0x00000840,
3180x80000040, 0x00000800, 0x80200840, 0x00200000,
3190x00200840, 0x80000000, 0x80000800, 0x80200840,
3200x80200000, 0x00200840, 0x00200800, 0x80000800,
321);
322@SP7=(
3230x04100010, 0x04104000, 0x00004010, 0x00000000,
3240x04004000, 0x00100010, 0x04100000, 0x04104010,
3250x00000010, 0x04000000, 0x00104000, 0x00004010,
3260x00104010, 0x04004010, 0x04000010, 0x04100000,
3270x00004000, 0x00104010, 0x00100010, 0x04004000,
3280x04104010, 0x04000010, 0x00000000, 0x00104000,
3290x04000000, 0x00100000, 0x04004010, 0x04100010,
3300x00100000, 0x00004000, 0x04104000, 0x00000010,
3310x00100000, 0x00004000, 0x04000010, 0x04104010,
3320x00004010, 0x04000000, 0x00000000, 0x00104000,
3330x04100010, 0x04004010, 0x04004000, 0x00100010,
3340x04104000, 0x00000010, 0x00100010, 0x04004000,
3350x04104010, 0x00100000, 0x04100000, 0x04000010,
3360x00104000, 0x00004010, 0x04004010, 0x04100000,
3370x00000010, 0x04104000, 0x00104010, 0x00000000,
3380x04000000, 0x04100010, 0x00004000, 0x00104010,
339);
340
341sub main'des_set_key
342 {
343 local($param)=@_;
344 local(@key);
345 local($c,$d,$i,$s,$t);
346 local(@ks)=();
347
348 # Get the bytes in the order we want.
349 @key=unpack("C8",$param);
350
351 $c= ($key[0] )|
352 ($key[1]<< 8)|
353 ($key[2]<<16)|
354 ($key[3]<<24);
355 $d= ($key[4] )|
356 ($key[5]<< 8)|
357 ($key[6]<<16)|
358 ($key[7]<<24);
359
360 &doPC1(*c,*d);
361
362 for $i (@shifts2)
363 {
364 if ($i)
365 {
366 $c=($c>>2)|($c<<26);
367 $d=($d>>2)|($d<<26);
368 }
369 else
370 {
371 $c=($c>>1)|($c<<27);
372 $d=($d>>1)|($d<<27);
373 }
374 $c&=0x0fffffff;
375 $d&=0x0fffffff;
376 $s= $skb0[ ($c )&0x3f ]|
377 $skb1[(($c>> 6)&0x03)|(($c>> 7)&0x3c)]|
378 $skb2[(($c>>13)&0x0f)|(($c>>14)&0x30)]|
379 $skb3[(($c>>20)&0x01)|(($c>>21)&0x06) |
380 (($c>>22)&0x38)];
381 $t= $skb4[ ($d )&0x3f ]|
382 $skb5[(($d>> 7)&0x03)|(($d>> 8)&0x3c)]|
383 $skb6[ ($d>>15)&0x3f ]|
384 $skb7[(($d>>21)&0x0f)|(($d>>22)&0x30)];
385 push(@ks,(($t<<16)|($s&0x0000ffff))&0xffffffff);
386 $s= (($s>>16)&0x0000ffff)|($t&0xffff0000) ;
387 push(@ks,(($s<<4)|(($s>>28)&0xf))&0xffffffff);
388 }
389 @ks;
390 }
391
392sub doPC1
393 {
394 local(*a,*b)=@_;
395 local($t);
396
397 $t=(($b>>4)^$a)&0x0f0f0f0f;
398 $b^=($t<<4); $a^=$t;
399 # do $a first
400 $t=(($a<<18)^$a)&0xcccc0000;
401 $a=$a^$t^(($t>>18)&0x00003fff);
402 $t=(($a<<17)^$a)&0xaaaa0000;
403 $a=$a^$t^(($t>>17)&0x00007fff);
404 $t=(($a<< 8)^$a)&0x00ff0000;
405 $a=$a^$t^(($t>> 8)&0x00ffffff);
406 $t=(($a<<17)^$a)&0xaaaa0000;
407 $a=$a^$t^(($t>>17)&0x00007fff);
408
409 # now do $b
410 $t=(($b<<24)^$b)&0xff000000;
411 $b=$b^$t^(($t>>24)&0x000000ff);
412 $t=(($b<< 8)^$b)&0x00ff0000;
413 $b=$b^$t^(($t>> 8)&0x00ffffff);
414 $t=(($b<<14)^$b)&0x33330000;
415 $b=$b^$t^(($t>>14)&0x0003ffff);
416 $b=(($b&0x00aa00aa)<<7)|(($b&0x55005500)>>7)|($b&0xaa55aa55);
417 $b=(($b>>8)&0x00ffffff)|((($a&0xf0000000)>>4)&0x0fffffff);
418 $a&=0x0fffffff;
419 }
420
421sub doIP
422 {
423 local(*a,*b)=@_;
424 local($t);
425
426 $t=(($b>> 4)^$a)&0x0f0f0f0f;
427 $b^=($t<< 4); $a^=$t;
428 $t=(($a>>16)^$b)&0x0000ffff;
429 $a^=($t<<16); $b^=$t;
430 $t=(($b>> 2)^$a)&0x33333333;
431 $b^=($t<< 2); $a^=$t;
432 $t=(($a>> 8)^$b)&0x00ff00ff;
433 $a^=($t<< 8); $b^=$t;
434 $t=(($b>> 1)^$a)&0x55555555;
435 $b^=($t<< 1); $a^=$t;
436 $t=$a;
437 $a=$b&0xffffffff;
438 $b=$t&0xffffffff;
439 }
440
441sub doFP
442 {
443 local(*a,*b)=@_;
444 local($t);
445
446 $t=(($b>> 1)^$a)&0x55555555;
447 $b^=($t<< 1); $a^=$t;
448 $t=(($a>> 8)^$b)&0x00ff00ff;
449 $a^=($t<< 8); $b^=$t;
450 $t=(($b>> 2)^$a)&0x33333333;
451 $b^=($t<< 2); $a^=$t;
452 $t=(($a>>16)^$b)&0x0000ffff;
453 $a^=($t<<16); $b^=$t;
454 $t=(($b>> 4)^$a)&0x0f0f0f0f;
455 $b^=($t<< 4); $a^=$t;
456 $a&=0xffffffff;
457 $b&=0xffffffff;
458 }
459
460sub main'des_ecb_encrypt
461 {
462 local(*ks,$encrypt,$in)=@_;
463 local($l,$r,$i,$t,$u,@input);
464
465 @input=unpack("C8",$in);
466 # Get the bytes in the order we want.
467 $l= ($input[0] )|
468 ($input[1]<< 8)|
469 ($input[2]<<16)|
470 ($input[3]<<24);
471 $r= ($input[4] )|
472 ($input[5]<< 8)|
473 ($input[6]<<16)|
474 ($input[7]<<24);
475
476 $l&=0xffffffff;
477 $r&=0xffffffff;
478 &doIP(*l,*r);
479 if ($encrypt)
480 {
481 for ($i=0; $i<32; $i+=4)
482 {
483 $t=((($r&0x7fffffff)<<1)|(($r>>31)&0x00000001));
484 $u=$t^$ks[$i ];
485 $t=$t^$ks[$i+1];
486 $t2=(($t&0x0000000f)<<28);
487
488 $t=((($t>>4)&0x0fffffff)|(($t&0x0000000f)<<28));
489 $l^= $SP1[ $t &0x3f]|
490 $SP3[($t>> 8)&0x3f]|
491 $SP5[($t>>16)&0x3f]|
492 $SP7[($t>>24)&0x3f]|
493 $SP0[ $u &0x3f]|
494 $SP2[($u>> 8)&0x3f]|
495 $SP4[($u>>16)&0x3f]|
496 $SP6[($u>>24)&0x3f];
497
498 $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff;
499 $u=$t^$ks[$i+2];
500 $t=$t^$ks[$i+3];
501 $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
502 $r^= $SP1[ $t &0x3f]|
503 $SP3[($t>> 8)&0x3f]|
504 $SP5[($t>>16)&0x3f]|
505 $SP7[($t>>24)&0x3f]|
506 $SP0[ $u &0x3f]|
507 $SP2[($u>> 8)&0x3f]|
508 $SP4[($u>>16)&0x3f]|
509 $SP6[($u>>24)&0x3f];
510 }
511 }
512 else
513 {
514 for ($i=30; $i>0; $i-=4)
515 {
516 $t=(($r<<1)|(($r>>31)&0x1))&0xffffffff;
517 $u=$t^$ks[$i ];
518 $t=$t^$ks[$i+1];
519 $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
520 $l^= $SP1[ $t &0x3f]|
521 $SP3[($t>> 8)&0x3f]|
522 $SP5[($t>>16)&0x3f]|
523 $SP7[($t>>24)&0x3f]|
524 $SP0[ $u &0x3f]|
525 $SP2[($u>> 8)&0x3f]|
526 $SP4[($u>>16)&0x3f]|
527 $SP6[($u>>24)&0x3f];
528
529 $t=(($l<<1)|(($l>>31)&0x1))&0xffffffff;
530 $u=$t^$ks[$i-2];
531 $t=$t^$ks[$i-1];
532 $t=((($t>>4)&0x0fffffff)|($t<<28))&0xffffffff;
533 $r^= $SP1[ $t &0x3f]|
534 $SP3[($t>> 8)&0x3f]|
535 $SP5[($t>>16)&0x3f]|
536 $SP7[($t>>24)&0x3f]|
537 $SP0[ $u &0x3f]|
538 $SP2[($u>> 8)&0x3f]|
539 $SP4[($u>>16)&0x3f]|
540 $SP6[($u>>24)&0x3f];
541 }
542 }
543 &doFP(*l,*r);
544 pack("C8",$l&0xff,
545 ($l>> 8)&0x00ffffff,
546 ($l>>16)&0x0000ffff,
547 ($l>>24)&0x000000ff,
548 $r&0xff,
549 ($r>> 8)&0x00ffffff,
550 ($r>>16)&0x0000ffff,
551 ($r>>24)&0x000000ff);
552 }
diff --git a/src/lib/libssl/src/crypto/des/des_crypt.man b/src/lib/libssl/src/crypto/des/des_crypt.man
new file mode 100644
index 0000000000..0ecc416877
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/des_crypt.man
@@ -0,0 +1,508 @@
1.TH DES_CRYPT 3
2.SH NAME
3des_read_password, des_read_2password,
4des_string_to_key, des_string_to_2key, des_read_pw_string,
5des_random_key, des_set_key,
6des_key_sched, des_ecb_encrypt, des_ecb3_encrypt, des_cbc_encrypt,
7des_3cbc_encrypt,
8des_pcbc_encrypt, des_cfb_encrypt, des_ofb_encrypt,
9des_cbc_cksum, des_quad_cksum,
10des_enc_read, des_enc_write, des_set_odd_parity,
11des_is_weak_key, crypt \- (non USA) DES encryption
12.SH SYNOPSIS
13.nf
14.nj
15.ft B
16#include <des.h>
17.PP
18.B int des_read_password(key,prompt,verify)
19des_cblock *key;
20char *prompt;
21int verify;
22.PP
23.B int des_read_2password(key1,key2,prompt,verify)
24des_cblock *key1,*key2;
25char *prompt;
26int verify;
27.PP
28.B int des_string_to_key(str,key)
29char *str;
30des_cblock *key;
31.PP
32.B int des_string_to_2keys(str,key1,key2)
33char *str;
34des_cblock *key1,*key2;
35.PP
36.B int des_read_pw_string(buf,length,prompt,verify)
37char *buf;
38int length;
39char *prompt;
40int verify;
41.PP
42.B int des_random_key(key)
43des_cblock *key;
44.PP
45.B int des_set_key(key,schedule)
46des_cblock *key;
47des_key_schedule schedule;
48.PP
49.B int des_key_sched(key,schedule)
50des_cblock *key;
51des_key_schedule schedule;
52.PP
53.B int des_ecb_encrypt(input,output,schedule,encrypt)
54des_cblock *input;
55des_cblock *output;
56des_key_schedule schedule;
57int encrypt;
58.PP
59.B int des_ecb3_encrypt(input,output,ks1,ks2,encrypt)
60des_cblock *input;
61des_cblock *output;
62des_key_schedule ks1,ks2;
63int encrypt;
64.PP
65.B int des_cbc_encrypt(input,output,length,schedule,ivec,encrypt)
66des_cblock *input;
67des_cblock *output;
68long length;
69des_key_schedule schedule;
70des_cblock *ivec;
71int encrypt;
72.PP
73.B int des_3cbc_encrypt(input,output,length,sk1,sk2,ivec1,ivec2,encrypt)
74des_cblock *input;
75des_cblock *output;
76long length;
77des_key_schedule sk1;
78des_key_schedule sk2;
79des_cblock *ivec1;
80des_cblock *ivec2;
81int encrypt;
82.PP
83.B int des_pcbc_encrypt(input,output,length,schedule,ivec,encrypt)
84des_cblock *input;
85des_cblock *output;
86long length;
87des_key_schedule schedule;
88des_cblock *ivec;
89int encrypt;
90.PP
91.B int des_cfb_encrypt(input,output,numbits,length,schedule,ivec,encrypt)
92unsigned char *input;
93unsigned char *output;
94int numbits;
95long length;
96des_key_schedule schedule;
97des_cblock *ivec;
98int encrypt;
99.PP
100.B int des_ofb_encrypt(input,output,numbits,length,schedule,ivec)
101unsigned char *input,*output;
102int numbits;
103long length;
104des_key_schedule schedule;
105des_cblock *ivec;
106.PP
107.B unsigned long des_cbc_cksum(input,output,length,schedule,ivec)
108des_cblock *input;
109des_cblock *output;
110long length;
111des_key_schedule schedule;
112des_cblock *ivec;
113.PP
114.B unsigned long des_quad_cksum(input,output,length,out_count,seed)
115des_cblock *input;
116des_cblock *output;
117long length;
118int out_count;
119des_cblock *seed;
120.PP
121.B int des_check_key;
122.PP
123.B int des_enc_read(fd,buf,len,sched,iv)
124int fd;
125char *buf;
126int len;
127des_key_schedule sched;
128des_cblock *iv;
129.PP
130.B int des_enc_write(fd,buf,len,sched,iv)
131int fd;
132char *buf;
133int len;
134des_key_schedule sched;
135des_cblock *iv;
136.PP
137.B extern int des_rw_mode;
138.PP
139.B void des_set_odd_parity(key)
140des_cblock *key;
141.PP
142.B int des_is_weak_key(key)
143des_cblock *key;
144.PP
145.B char *crypt(passwd,salt)
146char *passwd;
147char *salt;
148.PP
149.fi
150.SH DESCRIPTION
151This library contains a fast implementation of the DES encryption
152algorithm.
153.PP
154There are two phases to the use of DES encryption.
155The first is the generation of a
156.I des_key_schedule
157from a key,
158the second is the actual encryption.
159A des key is of type
160.I des_cblock.
161This type is made from 8 characters with odd parity.
162The least significant bit in the character is the parity bit.
163The key schedule is an expanded form of the key; it is used to speed the
164encryption process.
165.PP
166.I des_read_password
167writes the string specified by prompt to the standard output,
168turns off echo and reads an input string from standard input
169until terminated with a newline.
170If verify is non-zero, it prompts and reads the input again and verifies
171that both entered passwords are the same.
172The entered string is converted into a des key by using the
173.I des_string_to_key
174routine.
175The new key is placed in the
176.I des_cblock
177that was passed (by reference) to the routine.
178If there were no errors,
179.I des_read_password
180returns 0,
181-1 is returned if there was a terminal error and 1 is returned for
182any other error.
183.PP
184.I des_read_2password
185operates in the same way as
186.I des_read_password
187except that it generates 2 keys by using the
188.I des_string_to_2key
189function.
190.PP
191.I des_read_pw_string
192is called by
193.I des_read_password
194to read and verify a string from a terminal device.
195The string is returned in
196.I buf.
197The size of
198.I buf
199is passed to the routine via the
200.I length
201parameter.
202.PP
203.I des_string_to_key
204converts a string into a valid des key.
205.PP
206.I des_string_to_2key
207converts a string into 2 valid des keys.
208This routine is best suited for used to generate keys for use with
209.I des_ecb3_encrypt.
210.PP
211.I des_random_key
212returns a random key that is made of a combination of process id,
213time and an increasing counter.
214.PP
215Before a des key can be used it is converted into a
216.I des_key_schedule
217via the
218.I des_set_key
219routine.
220If the
221.I des_check_key
222flag is non-zero,
223.I des_set_key
224will check that the key passed is of odd parity and is not a week or
225semi-weak key.
226If the parity is wrong,
227then -1 is returned.
228If the key is a weak key,
229then -2 is returned.
230If an error is returned,
231the key schedule is not generated.
232.PP
233.I des_key_sched
234is another name for the
235.I des_set_key
236function.
237.PP
238The following routines mostly operate on an input and output stream of
239.I des_cblock's.
240.PP
241.I des_ecb_encrypt
242is the basic DES encryption routine that encrypts or decrypts a single 8-byte
243.I des_cblock
244in
245.I electronic code book
246mode.
247It always transforms the input data, pointed to by
248.I input,
249into the output data,
250pointed to by the
251.I output
252argument.
253If the
254.I encrypt
255argument is non-zero (DES_ENCRYPT),
256the
257.I input
258(cleartext) is encrypted in to the
259.I output
260(ciphertext) using the key_schedule specified by the
261.I schedule
262argument,
263previously set via
264.I des_set_key.
265If
266.I encrypt
267is zero (DES_DECRYPT),
268the
269.I input
270(now ciphertext)
271is decrypted into the
272.I output
273(now cleartext).
274Input and output may overlap.
275No meaningful value is returned.
276.PP
277.I des_ecb3_encrypt
278encrypts/decrypts the
279.I input
280block by using triple ecb DES encryption.
281This involves encrypting the input with
282.I ks1,
283decryption with the key schedule
284.I ks2,
285and then encryption with the first again.
286This routine greatly reduces the chances of brute force breaking of
287DES and has the advantage of if
288.I ks1
289and
290.I ks2
291are the same, it is equivalent to just encryption using ecb mode and
292.I ks1
293as the key.
294.PP
295.I des_cbc_encrypt
296encrypts/decrypts using the
297.I cipher-block-chaining
298mode of DES.
299If the
300.I encrypt
301argument is non-zero,
302the routine cipher-block-chain encrypts the cleartext data pointed to by the
303.I input
304argument into the ciphertext pointed to by the
305.I output
306argument,
307using the key schedule provided by the
308.I schedule
309argument,
310and initialisation vector provided by the
311.I ivec
312argument.
313If the
314.I length
315argument is not an integral multiple of eight bytes,
316the last block is copied to a temporary area and zero filled.
317The output is always
318an integral multiple of eight bytes.
319To make multiple cbc encrypt calls on a large amount of data appear to
320be one
321.I des_cbc_encrypt
322call, the
323.I ivec
324of subsequent calls should be the last 8 bytes of the output.
325.PP
326.I des_3cbc_encrypt
327encrypts/decrypts the
328.I input
329block by using triple cbc DES encryption.
330This involves encrypting the input with key schedule
331.I ks1,
332decryption with the key schedule
333.I ks2,
334and then encryption with the first again.
3352 initialisation vectors are required,
336.I ivec1
337and
338.I ivec2.
339Unlike
340.I des_cbc_encrypt,
341these initialisation vectors are modified by the subroutine.
342This routine greatly reduces the chances of brute force breaking of
343DES and has the advantage of if
344.I ks1
345and
346.I ks2
347are the same, it is equivalent to just encryption using cbc mode and
348.I ks1
349as the key.
350.PP
351.I des_pcbc_encrypt
352encrypt/decrypts using a modified block chaining mode.
353It provides better error propagation characteristics than cbc
354encryption.
355.PP
356.I des_cfb_encrypt
357encrypt/decrypts using cipher feedback mode. This method takes an
358array of characters as input and outputs and array of characters. It
359does not require any padding to 8 character groups. Note: the ivec
360variable is changed and the new changed value needs to be passed to
361the next call to this function. Since this function runs a complete
362DES ecb encryption per numbits, this function is only suggested for
363use when sending small numbers of characters.
364.PP
365.I des_ofb_encrypt
366encrypt using output feedback mode. This method takes an
367array of characters as input and outputs and array of characters. It
368does not require any padding to 8 character groups. Note: the ivec
369variable is changed and the new changed value needs to be passed to
370the next call to this function. Since this function runs a complete
371DES ecb encryption per numbits, this function is only suggested for
372use when sending small numbers of characters.
373.PP
374.I des_cbc_cksum
375produces an 8 byte checksum based on the input stream (via cbc encryption).
376The last 4 bytes of the checksum is returned and the complete 8 bytes is
377placed in
378.I output.
379.PP
380.I des_quad_cksum
381returns a 4 byte checksum from the input bytes.
382The algorithm can be iterated over the input,
383depending on
384.I out_count,
3851, 2, 3 or 4 times.
386If
387.I output
388is non-NULL,
389the 8 bytes generated by each pass are written into
390.I output.
391.PP
392.I des_enc_write
393is used to write
394.I len
395bytes
396to file descriptor
397.I fd
398from buffer
399.I buf.
400The data is encrypted via
401.I pcbc_encrypt
402(default) using
403.I sched
404for the key and
405.I iv
406as a starting vector.
407The actual data send down
408.I fd
409consists of 4 bytes (in network byte order) containing the length of the
410following encrypted data. The encrypted data then follows, padded with random
411data out to a multiple of 8 bytes.
412.PP
413.I des_enc_read
414is used to read
415.I len
416bytes
417from file descriptor
418.I fd
419into buffer
420.I buf.
421The data being read from
422.I fd
423is assumed to have come from
424.I des_enc_write
425and is decrypted using
426.I sched
427for the key schedule and
428.I iv
429for the initial vector.
430The
431.I des_enc_read/des_enc_write
432pair can be used to read/write to files, pipes and sockets.
433I have used them in implementing a version of rlogin in which all
434data is encrypted.
435.PP
436.I des_rw_mode
437is used to specify the encryption mode to use with
438.I des_enc_read
439and
440.I des_end_write.
441If set to
442.I DES_PCBC_MODE
443(the default), des_pcbc_encrypt is used.
444If set to
445.I DES_CBC_MODE
446des_cbc_encrypt is used.
447These two routines and the variable are not part of the normal MIT library.
448.PP
449.I des_set_odd_parity
450sets the parity of the passed
451.I key
452to odd. This routine is not part of the standard MIT library.
453.PP
454.I des_is_weak_key
455returns 1 is the passed key is a weak key (pick again :-),
4560 if it is ok.
457This routine is not part of the standard MIT library.
458.PP
459.I crypt
460is a replacement for the normal system crypt.
461It is much faster than the system crypt.
462.PP
463.SH FILES
464/usr/include/des.h
465.br
466/usr/lib/libdes.a
467.PP
468The encryption routines have been tested on 16bit, 32bit and 64bit
469machines of various endian and even works under VMS.
470.PP
471.SH BUGS
472.PP
473If you think this manual is sparse,
474read the des_crypt(3) manual from the MIT kerberos (or bones outside
475of the USA) distribution.
476.PP
477.I des_cfb_encrypt
478and
479.I des_ofb_encrypt
480operates on input of 8 bits. What this means is that if you set
481numbits to 12, and length to 2, the first 12 bits will come from the 1st
482input byte and the low half of the second input byte. The second 12
483bits will have the low 8 bits taken from the 3rd input byte and the
484top 4 bits taken from the 4th input byte. The same holds for output.
485This function has been implemented this way because most people will
486be using a multiple of 8 and because once you get into pulling bytes input
487bytes apart things get ugly!
488.PP
489.I des_read_pw_string
490is the most machine/OS dependent function and normally generates the
491most problems when porting this code.
492.PP
493.I des_string_to_key
494is probably different from the MIT version since there are lots
495of fun ways to implement one-way encryption of a text string.
496.PP
497The routines are optimised for 32 bit machines and so are not efficient
498on IBM PCs.
499.PP
500NOTE: extensive work has been done on this library since this document
501was origionally written. Please try to read des.doc from the libdes
502distribution since it is far more upto date and documents more of the
503functions. Libdes is now also being shipped as part of SSLeay, a
504general cryptographic library that amonst other things implements
505netscapes SSL protocoll. The most recent version can be found in
506SSLeay distributions.
507.SH AUTHOR
508Eric Young (eay@cryptsoft.com)
diff --git a/src/lib/libssl/src/crypto/des/des_locl.org b/src/lib/libssl/src/crypto/des/des_locl.org
new file mode 100644
index 0000000000..e2e503cbed
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/des_locl.org
@@ -0,0 +1,516 @@
1/* crypto/des/des_locl.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify des_locl.org since des_locl.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_DES_LOCL_H
68#define HEADER_DES_LOCL_H
69
70#if defined(WIN32) || defined(WIN16)
71#ifndef MSDOS
72#define MSDOS
73#endif
74#endif
75
76#include <stdio.h>
77#include <stdlib.h>
78#ifndef MSDOS
79#include <unistd.h>
80#endif
81#include "des.h"
82
83#ifndef DES_DEFAULT_OPTIONS
84/* the following is tweaked from a config script, that is why it is a
85 * protected undef/define */
86#ifndef DES_PTR
87#undef DES_PTR
88#endif
89
90/* This helps C compiler generate the correct code for multiple functional
91 * units. It reduces register dependancies at the expense of 2 more
92 * registers */
93#ifndef DES_RISC1
94#undef DES_RISC1
95#endif
96
97#ifndef DES_RISC2
98#undef DES_RISC2
99#endif
100
101#if defined(DES_RISC1) && defined(DES_RISC2)
102YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
103#endif
104
105/* Unroll the inner loop, this sometimes helps, sometimes hinders.
106 * Very mucy CPU dependant */
107#ifndef DES_UNROLL
108#undef DES_UNROLL
109#endif
110
111/* These default values were supplied by
112 * Peter Gutman <pgut001@cs.auckland.ac.nz>
113 * They are only used if nothing else has been defined */
114#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
115/* Special defines which change the way the code is built depending on the
116 CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
117 even newer MIPS CPU's, but at the moment one size fits all for
118 optimization options. Older Sparc's work better with only UNROLL, but
119 there's no way to tell at compile time what it is you're running on */
120
121#if defined( sun ) /* Newer Sparc's */
122 #define DES_PTR
123 #define DES_RISC1
124 #define DES_UNROLL
125#elif defined( __ultrix ) /* Older MIPS */
126 #define DES_PTR
127 #define DES_RISC2
128 #define DES_UNROLL
129#elif defined( __osf1__ ) /* Alpha */
130 #define DES_PTR
131 #define DES_RISC2
132#elif defined ( _AIX ) /* RS6000 */
133 /* Unknown */
134#elif defined( __hpux ) /* HP-PA */
135 /* Unknown */
136#elif defined( __aux ) /* 68K */
137 /* Unknown */
138#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
139 #define DES_UNROLL
140#elif defined( __sgi ) /* Newer MIPS */
141 #define DES_PTR
142 #define DES_RISC2
143 #define DES_UNROLL
144#elif defined( i386 ) /* x86 boxes, should be gcc */
145 #define DES_PTR
146 #define DES_RISC1
147 #define DES_UNROLL
148#endif /* Systems-specific speed defines */
149#endif
150
151#endif /* DES_DEFAULT_OPTIONS */
152
153#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */
154#include <stdlib.h>
155#include <errno.h>
156#include <time.h>
157#include <io.h>
158#ifndef RAND
159#define RAND
160#endif
161#undef NOPROTO
162#endif
163
164#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
165#include <string.h>
166#endif
167
168#ifndef RAND
169#define RAND
170#endif
171
172#ifdef linux
173#undef RAND
174#endif
175
176#ifdef MSDOS
177#define getpid() 2
178#define RAND
179#undef NOPROTO
180#endif
181
182#if defined(NOCONST)
183#define const
184#endif
185
186#ifdef __STDC__
187#undef NOPROTO
188#endif
189
190#ifdef RAND
191#define srandom(s) srand(s)
192#define random rand
193#endif
194
195#define ITERATIONS 16
196#define HALF_ITERATIONS 8
197
198/* used in des_read and des_write */
199#define MAXWRITE (1024*16)
200#define BSIZE (MAXWRITE+4)
201
202#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
203 l|=((DES_LONG)(*((c)++)))<< 8L, \
204 l|=((DES_LONG)(*((c)++)))<<16L, \
205 l|=((DES_LONG)(*((c)++)))<<24L)
206
207/* NOTE - c is not incremented as per c2l */
208#define c2ln(c,l1,l2,n) { \
209 c+=n; \
210 l1=l2=0; \
211 switch (n) { \
212 case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \
213 case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \
214 case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \
215 case 5: l2|=((DES_LONG)(*(--(c)))); \
216 case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \
217 case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \
218 case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \
219 case 1: l1|=((DES_LONG)(*(--(c)))); \
220 } \
221 }
222
223#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
224 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
225 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
226 *((c)++)=(unsigned char)(((l)>>24L)&0xff))
227
228/* replacements for htonl and ntohl since I have no idea what to do
229 * when faced with machines with 8 byte longs. */
230#define HDRSIZE 4
231
232#define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \
233 l|=((DES_LONG)(*((c)++)))<<16L, \
234 l|=((DES_LONG)(*((c)++)))<< 8L, \
235 l|=((DES_LONG)(*((c)++))))
236
237#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
238 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
239 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
240 *((c)++)=(unsigned char)(((l) )&0xff))
241
242/* NOTE - c is not incremented as per l2c */
243#define l2cn(l1,l2,c,n) { \
244 c+=n; \
245 switch (n) { \
246 case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
247 case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
248 case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
249 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
250 case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
251 case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
252 case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
253 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
254 } \
255 }
256
257#if defined(WIN32)
258#define ROTATE(a,n) (_lrotr(a,n))
259#else
260#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
261#endif
262
263/* Don't worry about the LOAD_DATA() stuff, that is used by
264 * fcrypt() to add it's little bit to the front */
265
266#ifdef DES_FCRYPT
267
268#define LOAD_DATA_tmp(R,S,u,t,E0,E1) \
269 { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); }
270
271#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
272 t=R^(R>>16L); \
273 u=t&E0; t&=E1; \
274 tmp=(u<<16); u^=R^s[S ]; u^=tmp; \
275 tmp=(t<<16); t^=R^s[S+1]; t^=tmp
276#else
277#define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g)
278#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
279 u=R^s[S ]; \
280 t=R^s[S+1]
281#endif
282
283/* The changes to this macro may help or hinder, depending on the
284 * compiler and the achitecture. gcc2 always seems to do well :-).
285 * Inspired by Dana How <how@isl.stanford.edu>
286 * DO NOT use the alternative version on machines with 8 byte longs.
287 * It does not seem to work on the Alpha, even when DES_LONG is 4
288 * bytes, probably an issue of accessing non-word aligned objects :-( */
289#ifdef DES_PTR
290
291/* It recently occured to me that 0^0^0^0^0^0^0 == 0, so there
292 * is no reason to not xor all the sub items together. This potentially
293 * saves a register since things can be xored directly into L */
294
295#if defined(DES_RISC1) || defined(DES_RISC2)
296#ifdef DES_RISC1
297#define D_ENCRYPT(LL,R,S) { \
298 unsigned int u1,u2,u3; \
299 LOAD_DATA(R,S,u,t,E0,E1,u1); \
300 u2=(int)u>>8L; \
301 u1=(int)u&0xfc; \
302 u2&=0xfc; \
303 t=ROTATE(t,4); \
304 u>>=16L; \
305 LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \
306 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \
307 u3=(int)(u>>8L); \
308 u1=(int)u&0xfc; \
309 u3&=0xfc; \
310 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+u1); \
311 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+u3); \
312 u2=(int)t>>8L; \
313 u1=(int)t&0xfc; \
314 u2&=0xfc; \
315 t>>=16L; \
316 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \
317 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \
318 u3=(int)t>>8L; \
319 u1=(int)t&0xfc; \
320 u3&=0xfc; \
321 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+u1); \
322 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+u3); }
323#endif
324#ifdef DES_RISC2
325#define D_ENCRYPT(LL,R,S) { \
326 unsigned int u1,u2,s1,s2; \
327 LOAD_DATA(R,S,u,t,E0,E1,u1); \
328 u2=(int)u>>8L; \
329 u1=(int)u&0xfc; \
330 u2&=0xfc; \
331 t=ROTATE(t,4); \
332 LL^= *(DES_LONG *)((unsigned char *)des_SP +u1); \
333 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x200+u2); \
334 s1=(int)(u>>16L); \
335 s2=(int)(u>>24L); \
336 s1&=0xfc; \
337 s2&=0xfc; \
338 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x400+s1); \
339 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x600+s2); \
340 u2=(int)t>>8L; \
341 u1=(int)t&0xfc; \
342 u2&=0xfc; \
343 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x100+u1); \
344 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x300+u2); \
345 s1=(int)(t>>16L); \
346 s2=(int)(t>>24L); \
347 s1&=0xfc; \
348 s2&=0xfc; \
349 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x500+s1); \
350 LL^= *(DES_LONG *)((unsigned char *)des_SP+0x700+s2); }
351#endif
352#else
353#define D_ENCRYPT(LL,R,S) { \
354 LOAD_DATA_tmp(R,S,u,t,E0,E1); \
355 t=ROTATE(t,4); \
356 LL^= \
357 *(DES_LONG *)((unsigned char *)des_SP +((u )&0xfc))^ \
358 *(DES_LONG *)((unsigned char *)des_SP+0x200+((u>> 8L)&0xfc))^ \
359 *(DES_LONG *)((unsigned char *)des_SP+0x400+((u>>16L)&0xfc))^ \
360 *(DES_LONG *)((unsigned char *)des_SP+0x600+((u>>24L)&0xfc))^ \
361 *(DES_LONG *)((unsigned char *)des_SP+0x100+((t )&0xfc))^ \
362 *(DES_LONG *)((unsigned char *)des_SP+0x300+((t>> 8L)&0xfc))^ \
363 *(DES_LONG *)((unsigned char *)des_SP+0x500+((t>>16L)&0xfc))^ \
364 *(DES_LONG *)((unsigned char *)des_SP+0x700+((t>>24L)&0xfc)); }
365#endif
366
367#else /* original version */
368
369#if defined(DES_RISC1) || defined(DES_RISC2)
370#ifdef DES_RISC1
371#define D_ENCRYPT(LL,R,S) {\
372 unsigned int u1,u2,u3; \
373 LOAD_DATA(R,S,u,t,E0,E1,u1); \
374 u>>=2L; \
375 t=ROTATE(t,6); \
376 u2=(int)u>>8L; \
377 u1=(int)u&0x3f; \
378 u2&=0x3f; \
379 u>>=16L; \
380 LL^=des_SPtrans[0][u1]; \
381 LL^=des_SPtrans[2][u2]; \
382 u3=(int)u>>8L; \
383 u1=(int)u&0x3f; \
384 u3&=0x3f; \
385 LL^=des_SPtrans[4][u1]; \
386 LL^=des_SPtrans[6][u3]; \
387 u2=(int)t>>8L; \
388 u1=(int)t&0x3f; \
389 u2&=0x3f; \
390 t>>=16L; \
391 LL^=des_SPtrans[1][u1]; \
392 LL^=des_SPtrans[3][u2]; \
393 u3=(int)t>>8L; \
394 u1=(int)t&0x3f; \
395 u3&=0x3f; \
396 LL^=des_SPtrans[5][u1]; \
397 LL^=des_SPtrans[7][u3]; }
398#endif
399#ifdef DES_RISC2
400#define D_ENCRYPT(LL,R,S) {\
401 unsigned int u1,u2,s1,s2; \
402 LOAD_DATA(R,S,u,t,E0,E1,u1); \
403 u>>=2L; \
404 t=ROTATE(t,6); \
405 u2=(int)u>>8L; \
406 u1=(int)u&0x3f; \
407 u2&=0x3f; \
408 LL^=des_SPtrans[0][u1]; \
409 LL^=des_SPtrans[2][u2]; \
410 s1=(int)u>>16L; \
411 s2=(int)u>>24L; \
412 s1&=0x3f; \
413 s2&=0x3f; \
414 LL^=des_SPtrans[4][s1]; \
415 LL^=des_SPtrans[6][s2]; \
416 u2=(int)t>>8L; \
417 u1=(int)t&0x3f; \
418 u2&=0x3f; \
419 LL^=des_SPtrans[1][u1]; \
420 LL^=des_SPtrans[3][u2]; \
421 s1=(int)t>>16; \
422 s2=(int)t>>24L; \
423 s1&=0x3f; \
424 s2&=0x3f; \
425 LL^=des_SPtrans[5][s1]; \
426 LL^=des_SPtrans[7][s2]; }
427#endif
428
429#else
430
431#define D_ENCRYPT(LL,R,S) {\
432 LOAD_DATA_tmp(R,S,u,t,E0,E1); \
433 t=ROTATE(t,4); \
434 LL^=\
435 des_SPtrans[0][(u>> 2L)&0x3f]^ \
436 des_SPtrans[2][(u>>10L)&0x3f]^ \
437 des_SPtrans[4][(u>>18L)&0x3f]^ \
438 des_SPtrans[6][(u>>26L)&0x3f]^ \
439 des_SPtrans[1][(t>> 2L)&0x3f]^ \
440 des_SPtrans[3][(t>>10L)&0x3f]^ \
441 des_SPtrans[5][(t>>18L)&0x3f]^ \
442 des_SPtrans[7][(t>>26L)&0x3f]; }
443#endif
444#endif
445
446 /* IP and FP
447 * The problem is more of a geometric problem that random bit fiddling.
448 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6
449 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4
450 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2
451 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0
452
453 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7
454 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5
455 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3
456 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1
457
458 The output has been subject to swaps of the form
459 0 1 -> 3 1 but the odd and even bits have been put into
460 2 3 2 0
461 different words. The main trick is to remember that
462 t=((l>>size)^r)&(mask);
463 r^=t;
464 l^=(t<<size);
465 can be used to swap and move bits between words.
466
467 So l = 0 1 2 3 r = 16 17 18 19
468 4 5 6 7 20 21 22 23
469 8 9 10 11 24 25 26 27
470 12 13 14 15 28 29 30 31
471 becomes (for size == 2 and mask == 0x3333)
472 t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19
473 6^20 7^21 -- -- 4 5 20 21 6 7 22 23
474 10^24 11^25 -- -- 8 9 24 25 10 11 24 25
475 14^28 15^29 -- -- 12 13 28 29 14 15 28 29
476
477 Thanks for hints from Richard Outerbridge - he told me IP&FP
478 could be done in 15 xor, 10 shifts and 5 ands.
479 When I finally started to think of the problem in 2D
480 I first got ~42 operations without xors. When I remembered
481 how to use xors :-) I got it to its final state.
482 */
483#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
484 (b)^=(t),\
485 (a)^=((t)<<(n)))
486
487#define IP(l,r) \
488 { \
489 register DES_LONG tt; \
490 PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \
491 PERM_OP(l,r,tt,16,0x0000ffffL); \
492 PERM_OP(r,l,tt, 2,0x33333333L); \
493 PERM_OP(l,r,tt, 8,0x00ff00ffL); \
494 PERM_OP(r,l,tt, 1,0x55555555L); \
495 }
496
497#define FP(l,r) \
498 { \
499 register DES_LONG tt; \
500 PERM_OP(l,r,tt, 1,0x55555555L); \
501 PERM_OP(r,l,tt, 8,0x00ff00ffL); \
502 PERM_OP(l,r,tt, 2,0x33333333L); \
503 PERM_OP(r,l,tt,16,0x0000ffffL); \
504 PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
505 }
506
507extern const DES_LONG des_SPtrans[8][64];
508
509#ifndef NOPROTO
510void fcrypt_body(DES_LONG *out,des_key_schedule ks,
511 DES_LONG Eswap0, DES_LONG Eswap1);
512#else
513void fcrypt_body();
514#endif
515
516#endif
diff --git a/src/lib/libssl/src/crypto/des/doIP b/src/lib/libssl/src/crypto/des/doIP
new file mode 100644
index 0000000000..18cf231303
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/doIP
@@ -0,0 +1,46 @@
1#!/usr/local/bin/perl
2
3@l=(
4 0, 1, 2, 3, 4, 5, 6, 7,
5 8, 9,10,11,12,13,14,15,
6 16,17,18,19,20,21,22,23,
7 24,25,26,27,28,29,30,31
8 );
9@r=(
10 32,33,34,35,36,37,38,39,
11 40,41,42,43,44,45,46,47,
12 48,49,50,51,52,53,54,55,
13 56,57,58,59,60,61,62,63
14 );
15
16require 'shifts.pl';
17
18sub PERM_OP
19 {
20 local(*a,*b,*t,$n,$m)=@_;
21
22 @z=&shift(*a,-$n);
23 @z=&xor(*b,*z);
24 @z=&and(*z,$m);
25 @b=&xor(*b,*z);
26 @z=&shift(*z,$n);
27 @a=&xor(*a,*z);
28 }
29
30
31@L=@l;
32@R=@r;
33&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
34&PERM_OP(*L,*R,*T,16,0x0000ffff);
35&PERM_OP(*R,*L,*T,2,0x33333333);
36&PERM_OP(*L,*R,*T,8,0x00ff00ff);
37&PERM_OP(*R,*L,*T,1,0x55555555);
38 &printit(@L);
39 &printit(@R);
40&PERM_OP(*R,*L,*T,1,0x55555555);
41&PERM_OP(*L,*R,*T,8,0x00ff00ff);
42&PERM_OP(*R,*L,*T,2,0x33333333);
43&PERM_OP(*L,*R,*T,16,0x0000ffff);
44&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
45 &printit(@L);
46 &printit(@R);
diff --git a/src/lib/libssl/src/crypto/des/doPC1 b/src/lib/libssl/src/crypto/des/doPC1
new file mode 100644
index 0000000000..096afd8c46
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/doPC1
@@ -0,0 +1,110 @@
1#!/usr/local/bin/perl
2
3@l=(
4 0, 1, 2, 3, 4, 5, 6, 7,
5 8, 9,10,11,12,13,14,15,
6 16,17,18,19,20,21,22,23,
7 24,25,26,27,28,29,30,31
8 );
9@r=(
10 32,33,34,35,36,37,38,39,
11 40,41,42,43,44,45,46,47,
12 48,49,50,51,52,53,54,55,
13 56,57,58,59,60,61,62,63
14 );
15
16require 'shifts.pl';
17
18sub PERM_OP
19 {
20 local(*a,*b,*t,$n,$m)=@_;
21
22 @z=&shift(*a,-$n);
23 @z=&xor(*b,*z);
24 @z=&and(*z,$m);
25 @b=&xor(*b,*z);
26 @z=&shift(*z,$n);
27 @a=&xor(*a,*z);
28 }
29
30sub HPERM_OP2
31 {
32 local(*a,*t,$n,$m)=@_;
33 local(@x,@y,$i);
34
35 @z=&shift(*a,16-$n);
36 @z=&xor(*a,*z);
37 @z=&and(*z,$m);
38 @a=&xor(*a,*z);
39 @z=&shift(*z,$n-16);
40 @a=&xor(*a,*z);
41 }
42
43sub HPERM_OP
44 {
45 local(*a,*t,$n,$m)=@_;
46 local(@x,@y,$i);
47
48 for ($i=0; $i<16; $i++)
49 {
50 $x[$i]=$a[$i];
51 $y[$i]=$a[16+$i];
52 }
53 @z=&shift(*x,-$n);
54 @z=&xor(*y,*z);
55 @z=&and(*z,$m);
56 @y=&xor(*y,*z);
57 @z=&shift(*z,$n);
58 @x=&xor(*x,*z);
59 for ($i=0; $i<16; $i++)
60 {
61 $a[$i]=$x[$i];
62 $a[16+$i]=$y[$i];
63 }
64 }
65
66@L=@l;
67@R=@r;
68
69 print "---\n"; &printit(@R);
70&PERM_OP(*R,*L,*T,4,0x0f0f0f0f);
71 print "---\n"; &printit(@R);
72&HPERM_OP2(*L,*T,-2,0xcccc0000);
73&HPERM_OP2(*R,*T,-2,0xcccc0000);
74 print "---\n"; &printit(@R);
75&PERM_OP(*R,*L,*T,1,0x55555555);
76 print "---\n"; &printit(@R);
77&PERM_OP(*L,*R,*T,8,0x00ff00ff);
78 print "---\n"; &printit(@R);
79&PERM_OP(*R,*L,*T,1,0x55555555);
80 print "---\n"; &printit(@R);
81# &printit(@L);
82 &printit(@R);
83print <<"EOF";
84==============================
8563 55 47 39 31 23 15 7
8662 54 46 38 30 22 14 6
8761 53 45 37 29 21 13 5
8860 52 44 36 -- -- -- --
89
9057 49 41 33 25 17 9 1
9158 50 42 34 26 18 10 2
9259 51 43 35 27 19 11 3
9328 20 12 4 -- -- -- --
94EOF
95exit(1);
96@A=&and(*R,0x000000ff);
97@A=&shift(*A,16);
98@B=&and(*R,0x0000ff00);
99@C=&and(*R,0x00ff0000);
100@C=&shift(*C,-16);
101@D=&and(*L,0xf0000000);
102@D=&shift(*D,-4);
103@A=&or(*A,*B);
104@B=&or(*D,*C);
105@R=&or(*A,*B);
106@L=&and(*L,0x0fffffff);
107
108 &printit(@L);
109 &printit(@R);
110
diff --git a/src/lib/libssl/src/crypto/des/doPC2 b/src/lib/libssl/src/crypto/des/doPC2
new file mode 100644
index 0000000000..fa5cf74cf7
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/doPC2
@@ -0,0 +1,94 @@
1#!/usr/local/bin/perl
2
3@PC2_C=(14,17,11,24, 1, 5,
4 3,28,15, 6,21,10,
5 23,19,12, 4,26, 8,
6 16, 7,27,20,13, 2,
7 );
8
9@PC2_D=(41,52,31,37,47,55,
10 30,40,51,45,33,48,
11 44,49,39,56,34,53,
12 46,42,50,36,29,32,
13 );
14
15$i=0;
16foreach (@PC2_C) {
17 $_--;
18# printf "%2d,",$_;
19 $C{$_}=$i;
20 ++$i;
21# print "\n" if ((($i) % 8) == 0);
22 }
23$i=0;
24#print "\n";
25foreach (@PC2_D) {
26 $_-=28;
27 $_--;
28# printf "%2d,",$_;
29 $D{$_}=$i;
30 $i++;
31# print "\n" if ((($i) % 8) == 0);
32 }
33
34#print "\n";
35foreach $i (0 .. 27)
36 {
37 $_=$C{$i};
38# printf "%2d,",$_;
39 $i++;
40# print "\n" if ((($i) % 8) == 0);
41 }
42#print "\n";
43
44#print "\n";
45foreach $i (0 .. 27)
46 {
47 $_=$D{$i};
48# printf "%2d,",$_;
49 $i++;
50# print "\n" if ((($i) % 8) == 0);
51 }
52#print "\n";
53
54print "static ulong skb[8][64]={\n";
55&doit("C",*C, 0, 1, 2, 3, 4, 5);
56&doit("C",*C, 6, 7, 9,10,11,12);
57&doit("C",*C,13,14,15,16,18,19);
58&doit("C",*C,20,22,23,25,26,27);
59
60&doit("D",*D, 0, 1, 2, 3, 4, 5);
61&doit("D",*D, 7, 8,10,11,12,13);
62&doit("D",*D,15,16,17,18,19,20);
63&doit("D",*D,21,22,23,24,26,27);
64print "};\n";
65
66sub doit
67 {
68 local($l,*A,@b)=@_;
69 local(@out);
70
71 printf("/* for $l bits (numbered as per FIPS 46) %d %d %d %d %d %d */\n",
72 $b[0]+1, $b[1]+1, $b[2]+1, $b[3]+1, $b[4]+1, $b[5]+1);
73 for ($i=0; $i<64; $i++)
74 {
75 $out[$i]=0;
76 $j=1;
77#print "\n";
78 for ($k=0; $k<6; $k++)
79 {
80 $l=$A{$b[$k]};
81#print"$l - ";
82 if ((1<<$k) & $i)
83 {
84 $ll=int($l/6)*8+($l%6);
85 $out[$i]|=1<<($ll);
86 }
87 }
88 $pp=$out[$i];
89 $pp=($pp&0xff0000ff)| (($pp&0x00ff0000)>>8)|
90 (($pp&0x0000ff00)<<8);
91 printf("0x%08X,",$pp);
92 print "\n" if (($i+1) % 4 == 0);
93 }
94 }
diff --git a/src/lib/libssl/src/crypto/des/ede_enc.c b/src/lib/libssl/src/crypto/des/ede_enc.c
new file mode 100644
index 0000000000..9f75dd1037
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/ede_enc.c
@@ -0,0 +1,190 @@
1/* crypto/des/ede_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61void des_ede3_cbc_encrypt(input, output, length, ks1, ks2, ks3, ivec, enc)
62des_cblock (*input);
63des_cblock (*output);
64long length;
65des_key_schedule ks1;
66des_key_schedule ks2;
67des_key_schedule ks3;
68des_cblock (*ivec);
69int enc;
70 {
71 register DES_LONG tin0,tin1;
72 register DES_LONG tout0,tout1,xor0,xor1;
73 register unsigned char *in,*out;
74 register long l=length;
75 DES_LONG tin[2];
76 unsigned char *iv;
77
78 in=(unsigned char *)input;
79 out=(unsigned char *)output;
80 iv=(unsigned char *)ivec;
81
82 if (enc)
83 {
84 c2l(iv,tout0);
85 c2l(iv,tout1);
86 for (l-=8; l>=0; l-=8)
87 {
88 c2l(in,tin0);
89 c2l(in,tin1);
90 tin0^=tout0;
91 tin1^=tout1;
92
93 tin[0]=tin0;
94 tin[1]=tin1;
95 des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
96 tout0=tin[0];
97 tout1=tin[1];
98
99 l2c(tout0,out);
100 l2c(tout1,out);
101 }
102 if (l != -8)
103 {
104 c2ln(in,tin0,tin1,l+8);
105 tin0^=tout0;
106 tin1^=tout1;
107
108 tin[0]=tin0;
109 tin[1]=tin1;
110 des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
111 tout0=tin[0];
112 tout1=tin[1];
113
114 l2c(tout0,out);
115 l2c(tout1,out);
116 }
117 iv=(unsigned char *)ivec;
118 l2c(tout0,iv);
119 l2c(tout1,iv);
120 }
121 else
122 {
123 register DES_LONG t0,t1;
124
125 c2l(iv,xor0);
126 c2l(iv,xor1);
127 for (l-=8; l>=0; l-=8)
128 {
129 c2l(in,tin0);
130 c2l(in,tin1);
131
132 t0=tin0;
133 t1=tin1;
134
135 tin[0]=tin0;
136 tin[1]=tin1;
137 des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
138 tout0=tin[0];
139 tout1=tin[1];
140
141 tout0^=xor0;
142 tout1^=xor1;
143 l2c(tout0,out);
144 l2c(tout1,out);
145 xor0=t0;
146 xor1=t1;
147 }
148 if (l != -8)
149 {
150 c2l(in,tin0);
151 c2l(in,tin1);
152
153 t0=tin0;
154 t1=tin1;
155
156 tin[0]=tin0;
157 tin[1]=tin1;
158 des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
159 tout0=tin[0];
160 tout1=tin[1];
161
162 tout0^=xor0;
163 tout1^=xor1;
164 l2cn(tout0,tout1,out,l+8);
165 xor0=t0;
166 xor1=t1;
167 }
168
169 iv=(unsigned char *)ivec;
170 l2c(xor0,iv);
171 l2c(xor1,iv);
172 }
173 tin0=tin1=tout0=tout1=xor0=xor1=0;
174 tin[0]=tin[1]=0;
175 }
176
177#ifdef undef /* MACRO */
178void des_ede2_cbc_encrypt(input, output, length, ks1, ks2, ivec, enc)
179des_cblock (*input);
180des_cblock (*output);
181long length;
182des_key_schedule ks1;
183des_key_schedule ks2;
184des_cblock (*ivec);
185int enc;
186 {
187 des_ede3_cbc_encrypt(input,output,length,ks1,ks2,ks1,ivec,enc);
188 }
189#endif
190
diff --git a/src/lib/libssl/src/crypto/des/podd.h b/src/lib/libssl/src/crypto/des/podd.h
new file mode 100644
index 0000000000..1b2bfe0843
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/podd.h
@@ -0,0 +1,75 @@
1/* crypto/des/podd.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59static const unsigned char odd_parity[256]={
60 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
61 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31,
62 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47,
63 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62,
64 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79,
65 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94,
66 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110,
67112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127,
68128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143,
69145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158,
70161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174,
71176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191,
72193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206,
73208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223,
74224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239,
75241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254};
diff --git a/src/lib/libssl/src/crypto/des/ranlib.sh b/src/lib/libssl/src/crypto/des/ranlib.sh
new file mode 100644
index 0000000000..543f712c6b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/ranlib.sh
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3cwd=`pwd`
4cd /tmp
5
6if [ -s /bin/ranlib ] ; then
7 RL=/bin/ranlib
8else if [ -s /usr/bin/ranlib ] ; then
9 RL=/usr/bin/ranlib
10fi
11fi
12
13if [ "x$RL" != "x" ]
14then
15 case "$1" in
16 /*)
17 $RL "$1"
18 ;;
19 *)
20 $RL "$cwd/$1"
21 ;;
22 esac
23fi
diff --git a/src/lib/libssl/src/crypto/des/shifts.pl b/src/lib/libssl/src/crypto/des/shifts.pl
new file mode 100644
index 0000000000..d8a240c1ba
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/shifts.pl
@@ -0,0 +1,198 @@
1#!/usr/bin/perl
2
3sub lab_shift
4 {
5 local(*a,$n)=@_;
6 local(@r,$i,$j,$k,$d,@z);
7
8 @r=&shift(*a,$n);
9 foreach $i (0 .. 31)
10 {
11 @z=split(/\^/,$r[$i]);
12 for ($j=0; $j <= $#z; $j++)
13 {
14 ($d)=($z[$j] =~ /^(..)/);
15 ($k)=($z[$j] =~ /\[(.*)\]$/);
16 $k.=",$n" if ($k ne "");
17 $k="$n" if ($k eq "");
18 $d="$d[$k]";
19 $z[$j]=$d;
20 }
21 $r[$i]=join('^',@z);
22 }
23 return(@r);
24 }
25
26sub shift
27 {
28 local(*a,$n)=@_;
29 local(@f);
30
31 if ($n > 0)
32 {
33 @f=&shiftl(*a,$n);
34 }
35 else
36 {
37 @f=&shiftr(*a,-$n);
38 }
39 return(@f);
40 }
41
42sub rotate
43 {
44 local(*a,$n)=@_;
45 local(@f);
46
47 if ($n > 0)
48 { @f=&rotatel(*a,$n); }
49 else
50 { @f=&rotater(*a,-$n); }
51 return(@f);
52 }
53
54sub rotater
55 {
56 local(*a,$n)=@_;
57 local(@f,@g);
58
59 @f=&shiftr(*a,$n);
60 @g=&shiftl(*a,32-$n);
61 $#f=31;
62 $#g=31;
63 return(&or(*f,*g));
64 }
65
66sub rotatel
67 {
68 local(*a,$n)=@_;
69 local(@f,@g);
70
71 @f=&shiftl(*a,$n);
72 @g=&shiftr(*a,32-$n);
73 $#f=31;
74 $#g=31;
75 return(&or(*f,*g));
76 }
77
78sub shiftr
79 {
80 local(*a,$n)=@_;
81 local(@r,$i);
82
83 $#r=31;
84 foreach $i (0 .. 31)
85 {
86 if (($i+$n) > 31)
87 {
88 $r[$i]="--";
89 }
90 else
91 {
92 $r[$i]=$a[$i+$n];
93 }
94 }
95 return(@r);
96 }
97
98sub shiftl
99 {
100 local(*a,$n)=@_;
101 local(@r,$i);
102
103 $#r=31;
104 foreach $i (0 .. 31)
105 {
106 if ($i < $n)
107 {
108 $r[$i]="--";
109 }
110 else
111 {
112 $r[$i]=$a[$i-$n];
113 }
114 }
115 return(@r);
116 }
117
118sub printit
119 {
120 local(@a)=@_;
121 local($i);
122
123 foreach $i (0 .. 31)
124 {
125 printf "%2s ",$a[$i];
126 print "\n" if (($i%8) == 7);
127 }
128 print "\n";
129 }
130
131sub xor
132 {
133 local(*a,*b)=@_;
134 local(@r,$i);
135
136 $#r=31;
137 foreach $i (0 .. 31)
138 {
139 $r[$i]=&compress($a[$i].'^'.$b[$i]);
140# $r[$i]=$a[$i]."^".$b[$i];
141 }
142 return(@r);
143 }
144
145sub and
146 {
147 local(*a,$m)=@_;
148 local(@r,$i);
149
150 $#r=31;
151 foreach $i (0 .. 31)
152 {
153 $r[$i]=(($m & (1<<$i))?($a[$i]):('--'));
154 }
155 return(@r);
156 }
157
158sub or
159 {
160 local(*a,*b)=@_;
161 local(@r,$i);
162
163 $#r=31;
164 foreach $i (0 .. 31)
165 {
166 $r[$i]='--' if (($a[$i] eq '--') && ($b[$i] eq '--'));
167 $r[$i]=$a[$i] if (($a[$i] ne '--') && ($b[$i] eq '--'));
168 $r[$i]=$b[$i] if (($a[$i] eq '--') && ($b[$i] ne '--'));
169 $r[$i]='++' if (($a[$i] ne '--') && ($b[$i] ne '--'));
170 }
171 return(@r);
172 }
173
174sub compress
175 {
176 local($s)=@_;
177 local($_,$i,@a,%a,$r);
178
179 $s =~ s/\^\^/\^/g;
180 $s =~ s/^\^//;
181 $s =~ s/\^$//;
182 @a=split(/\^/,$s);
183
184 while ($#a >= 0)
185 {
186 $_=shift(@a);
187 next unless /\d/;
188 $a{$_}++;
189 }
190 foreach $i (sort keys %a)
191 {
192 next if ($a{$i}%2 == 0);
193 $r.="$i^";
194 }
195 chop($r);
196 return($r);
197 }
1981;
diff --git a/src/lib/libssl/src/crypto/des/sk.h b/src/lib/libssl/src/crypto/des/sk.h
new file mode 100644
index 0000000000..f2ade88c7c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/sk.h
@@ -0,0 +1,204 @@
1/* crypto/des/sk.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59static const DES_LONG des_skb[8][64]={
60{
61/* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
620x00000000L,0x00000010L,0x20000000L,0x20000010L,
630x00010000L,0x00010010L,0x20010000L,0x20010010L,
640x00000800L,0x00000810L,0x20000800L,0x20000810L,
650x00010800L,0x00010810L,0x20010800L,0x20010810L,
660x00000020L,0x00000030L,0x20000020L,0x20000030L,
670x00010020L,0x00010030L,0x20010020L,0x20010030L,
680x00000820L,0x00000830L,0x20000820L,0x20000830L,
690x00010820L,0x00010830L,0x20010820L,0x20010830L,
700x00080000L,0x00080010L,0x20080000L,0x20080010L,
710x00090000L,0x00090010L,0x20090000L,0x20090010L,
720x00080800L,0x00080810L,0x20080800L,0x20080810L,
730x00090800L,0x00090810L,0x20090800L,0x20090810L,
740x00080020L,0x00080030L,0x20080020L,0x20080030L,
750x00090020L,0x00090030L,0x20090020L,0x20090030L,
760x00080820L,0x00080830L,0x20080820L,0x20080830L,
770x00090820L,0x00090830L,0x20090820L,0x20090830L,
78},{
79/* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
800x00000000L,0x02000000L,0x00002000L,0x02002000L,
810x00200000L,0x02200000L,0x00202000L,0x02202000L,
820x00000004L,0x02000004L,0x00002004L,0x02002004L,
830x00200004L,0x02200004L,0x00202004L,0x02202004L,
840x00000400L,0x02000400L,0x00002400L,0x02002400L,
850x00200400L,0x02200400L,0x00202400L,0x02202400L,
860x00000404L,0x02000404L,0x00002404L,0x02002404L,
870x00200404L,0x02200404L,0x00202404L,0x02202404L,
880x10000000L,0x12000000L,0x10002000L,0x12002000L,
890x10200000L,0x12200000L,0x10202000L,0x12202000L,
900x10000004L,0x12000004L,0x10002004L,0x12002004L,
910x10200004L,0x12200004L,0x10202004L,0x12202004L,
920x10000400L,0x12000400L,0x10002400L,0x12002400L,
930x10200400L,0x12200400L,0x10202400L,0x12202400L,
940x10000404L,0x12000404L,0x10002404L,0x12002404L,
950x10200404L,0x12200404L,0x10202404L,0x12202404L,
96},{
97/* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
980x00000000L,0x00000001L,0x00040000L,0x00040001L,
990x01000000L,0x01000001L,0x01040000L,0x01040001L,
1000x00000002L,0x00000003L,0x00040002L,0x00040003L,
1010x01000002L,0x01000003L,0x01040002L,0x01040003L,
1020x00000200L,0x00000201L,0x00040200L,0x00040201L,
1030x01000200L,0x01000201L,0x01040200L,0x01040201L,
1040x00000202L,0x00000203L,0x00040202L,0x00040203L,
1050x01000202L,0x01000203L,0x01040202L,0x01040203L,
1060x08000000L,0x08000001L,0x08040000L,0x08040001L,
1070x09000000L,0x09000001L,0x09040000L,0x09040001L,
1080x08000002L,0x08000003L,0x08040002L,0x08040003L,
1090x09000002L,0x09000003L,0x09040002L,0x09040003L,
1100x08000200L,0x08000201L,0x08040200L,0x08040201L,
1110x09000200L,0x09000201L,0x09040200L,0x09040201L,
1120x08000202L,0x08000203L,0x08040202L,0x08040203L,
1130x09000202L,0x09000203L,0x09040202L,0x09040203L,
114},{
115/* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
1160x00000000L,0x00100000L,0x00000100L,0x00100100L,
1170x00000008L,0x00100008L,0x00000108L,0x00100108L,
1180x00001000L,0x00101000L,0x00001100L,0x00101100L,
1190x00001008L,0x00101008L,0x00001108L,0x00101108L,
1200x04000000L,0x04100000L,0x04000100L,0x04100100L,
1210x04000008L,0x04100008L,0x04000108L,0x04100108L,
1220x04001000L,0x04101000L,0x04001100L,0x04101100L,
1230x04001008L,0x04101008L,0x04001108L,0x04101108L,
1240x00020000L,0x00120000L,0x00020100L,0x00120100L,
1250x00020008L,0x00120008L,0x00020108L,0x00120108L,
1260x00021000L,0x00121000L,0x00021100L,0x00121100L,
1270x00021008L,0x00121008L,0x00021108L,0x00121108L,
1280x04020000L,0x04120000L,0x04020100L,0x04120100L,
1290x04020008L,0x04120008L,0x04020108L,0x04120108L,
1300x04021000L,0x04121000L,0x04021100L,0x04121100L,
1310x04021008L,0x04121008L,0x04021108L,0x04121108L,
132},{
133/* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
1340x00000000L,0x10000000L,0x00010000L,0x10010000L,
1350x00000004L,0x10000004L,0x00010004L,0x10010004L,
1360x20000000L,0x30000000L,0x20010000L,0x30010000L,
1370x20000004L,0x30000004L,0x20010004L,0x30010004L,
1380x00100000L,0x10100000L,0x00110000L,0x10110000L,
1390x00100004L,0x10100004L,0x00110004L,0x10110004L,
1400x20100000L,0x30100000L,0x20110000L,0x30110000L,
1410x20100004L,0x30100004L,0x20110004L,0x30110004L,
1420x00001000L,0x10001000L,0x00011000L,0x10011000L,
1430x00001004L,0x10001004L,0x00011004L,0x10011004L,
1440x20001000L,0x30001000L,0x20011000L,0x30011000L,
1450x20001004L,0x30001004L,0x20011004L,0x30011004L,
1460x00101000L,0x10101000L,0x00111000L,0x10111000L,
1470x00101004L,0x10101004L,0x00111004L,0x10111004L,
1480x20101000L,0x30101000L,0x20111000L,0x30111000L,
1490x20101004L,0x30101004L,0x20111004L,0x30111004L,
150},{
151/* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
1520x00000000L,0x08000000L,0x00000008L,0x08000008L,
1530x00000400L,0x08000400L,0x00000408L,0x08000408L,
1540x00020000L,0x08020000L,0x00020008L,0x08020008L,
1550x00020400L,0x08020400L,0x00020408L,0x08020408L,
1560x00000001L,0x08000001L,0x00000009L,0x08000009L,
1570x00000401L,0x08000401L,0x00000409L,0x08000409L,
1580x00020001L,0x08020001L,0x00020009L,0x08020009L,
1590x00020401L,0x08020401L,0x00020409L,0x08020409L,
1600x02000000L,0x0A000000L,0x02000008L,0x0A000008L,
1610x02000400L,0x0A000400L,0x02000408L,0x0A000408L,
1620x02020000L,0x0A020000L,0x02020008L,0x0A020008L,
1630x02020400L,0x0A020400L,0x02020408L,0x0A020408L,
1640x02000001L,0x0A000001L,0x02000009L,0x0A000009L,
1650x02000401L,0x0A000401L,0x02000409L,0x0A000409L,
1660x02020001L,0x0A020001L,0x02020009L,0x0A020009L,
1670x02020401L,0x0A020401L,0x02020409L,0x0A020409L,
168},{
169/* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
1700x00000000L,0x00000100L,0x00080000L,0x00080100L,
1710x01000000L,0x01000100L,0x01080000L,0x01080100L,
1720x00000010L,0x00000110L,0x00080010L,0x00080110L,
1730x01000010L,0x01000110L,0x01080010L,0x01080110L,
1740x00200000L,0x00200100L,0x00280000L,0x00280100L,
1750x01200000L,0x01200100L,0x01280000L,0x01280100L,
1760x00200010L,0x00200110L,0x00280010L,0x00280110L,
1770x01200010L,0x01200110L,0x01280010L,0x01280110L,
1780x00000200L,0x00000300L,0x00080200L,0x00080300L,
1790x01000200L,0x01000300L,0x01080200L,0x01080300L,
1800x00000210L,0x00000310L,0x00080210L,0x00080310L,
1810x01000210L,0x01000310L,0x01080210L,0x01080310L,
1820x00200200L,0x00200300L,0x00280200L,0x00280300L,
1830x01200200L,0x01200300L,0x01280200L,0x01280300L,
1840x00200210L,0x00200310L,0x00280210L,0x00280310L,
1850x01200210L,0x01200310L,0x01280210L,0x01280310L,
186},{
187/* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
1880x00000000L,0x04000000L,0x00040000L,0x04040000L,
1890x00000002L,0x04000002L,0x00040002L,0x04040002L,
1900x00002000L,0x04002000L,0x00042000L,0x04042000L,
1910x00002002L,0x04002002L,0x00042002L,0x04042002L,
1920x00000020L,0x04000020L,0x00040020L,0x04040020L,
1930x00000022L,0x04000022L,0x00040022L,0x04040022L,
1940x00002020L,0x04002020L,0x00042020L,0x04042020L,
1950x00002022L,0x04002022L,0x00042022L,0x04042022L,
1960x00000800L,0x04000800L,0x00040800L,0x04040800L,
1970x00000802L,0x04000802L,0x00040802L,0x04040802L,
1980x00002800L,0x04002800L,0x00042800L,0x04042800L,
1990x00002802L,0x04002802L,0x00042802L,0x04042802L,
2000x00000820L,0x04000820L,0x00040820L,0x04040820L,
2010x00000822L,0x04000822L,0x00040822L,0x04040822L,
2020x00002820L,0x04002820L,0x00042820L,0x04042820L,
2030x00002822L,0x04002822L,0x00042822L,0x04042822L,
204}};
diff --git a/src/lib/libssl/src/crypto/des/supp.c b/src/lib/libssl/src/crypto/des/supp.c
new file mode 100644
index 0000000000..f8e5833f69
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/supp.c
@@ -0,0 +1,109 @@
1/* crypto/des/supp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/*
60 * Copyright (c) 1995
61 * Mark Murray. All rights reserved.
62 *
63 * Redistribution and use in source and binary forms, with or without
64 * modification, are permitted provided that the following conditions
65 * are met:
66 * 1. Redistributions of source code must retain the above copyright
67 * notice, this list of conditions and the following disclaimer.
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in the
70 * documentation and/or other materials provided with the distribution.
71 * 3. All advertising materials mentioning features or use of this software
72 * must display the following acknowledgement:
73 * This product includes software developed by Mark Murray
74 * 4. Neither the name of the author nor the names of any co-contributors
75 * may be used to endorse or promote products derived from this software
76 * without specific prior written permission.
77 *
78 * THIS SOFTWARE IS PROVIDED BY MARK MURRAY AND CONTRIBUTORS ``AS IS'' AND
79 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
80 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
81 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
82 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
83 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
84 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
85 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
86 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
87 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88 * SUCH DAMAGE.
89 *
90 * $Id: supp.c,v 1.1.1.1 1998/10/05 20:12:45 ryker Exp $
91 */
92
93#include <stdio.h>
94#include "des_locl.h"
95
96void des_cblock_print_file(cb, fp)
97 des_cblock *cb;
98 FILE *fp;
99{
100 int i;
101 unsigned int *p = (unsigned int *)cb;
102
103 fprintf(fp, " 0x { ");
104 for (i = 0; i < 8; i++) {
105 fprintf(fp, "%x", p[i]);
106 if (i != 7) fprintf(fp, ", ");
107 }
108 fprintf(fp, " }");
109}
diff --git a/src/lib/libssl/src/crypto/des/testdes.pl b/src/lib/libssl/src/crypto/des/testdes.pl
new file mode 100644
index 0000000000..67fbd47f36
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/testdes.pl
@@ -0,0 +1,167 @@
1#!/usr/bin/perl
2
3# des.pl tesing code
4
5require 'des.pl';
6
7$num_tests=34;
8@key_data=(
9 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
10 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
11 0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
12 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
13 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
14 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
15 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
16 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10,
17 0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57,
18 0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E,
19 0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86,
20 0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E,
21 0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6,
22 0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE,
23 0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6,
24 0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE,
25 0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16,
26 0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F,
27 0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46,
28 0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E,
29 0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76,
30 0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07,
31 0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F,
32 0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7,
33 0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF,
34 0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6,
35 0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF,
36 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
37 0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E,
38 0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE,
39 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
40 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
41 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
42 0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10,
43 );
44
45@plain_data=(
46 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
47 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
48 0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
49 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
50 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
51 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
52 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
53 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
54 0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42,
55 0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA,
56 0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72,
57 0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A,
58 0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2,
59 0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A,
60 0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2,
61 0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A,
62 0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02,
63 0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A,
64 0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32,
65 0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA,
66 0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62,
67 0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2,
68 0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA,
69 0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92,
70 0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A,
71 0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2,
72 0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A,
73 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
74 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
75 0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF,
76 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
78 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
79 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF);
80
81@cipher_data=(
82 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7,
83 0x73,0x59,0xB2,0x16,0x3E,0x4E,0xDC,0x58,
84 0x95,0x8E,0x6E,0x62,0x7A,0x05,0x55,0x7B,
85 0xF4,0x03,0x79,0xAB,0x9E,0x0E,0xC5,0x33,
86 0x17,0x66,0x8D,0xFC,0x72,0x92,0x53,0x2D,
87 0x8A,0x5A,0xE1,0xF8,0x1A,0xB8,0xF2,0xDD,
88 0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7,
89 0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4,
90 0x69,0x0F,0x5B,0x0D,0x9A,0x26,0x93,0x9B,
91 0x7A,0x38,0x9D,0x10,0x35,0x4B,0xD2,0x71,
92 0x86,0x8E,0xBB,0x51,0xCA,0xB4,0x59,0x9A,
93 0x71,0x78,0x87,0x6E,0x01,0xF1,0x9B,0x2A,
94 0xAF,0x37,0xFB,0x42,0x1F,0x8C,0x40,0x95,
95 0x86,0xA5,0x60,0xF1,0x0E,0xC6,0xD8,0x5B,
96 0x0C,0xD3,0xDA,0x02,0x00,0x21,0xDC,0x09,
97 0xEA,0x67,0x6B,0x2C,0xB7,0xDB,0x2B,0x7A,
98 0xDF,0xD6,0x4A,0x81,0x5C,0xAF,0x1A,0x0F,
99 0x5C,0x51,0x3C,0x9C,0x48,0x86,0xC0,0x88,
100 0x0A,0x2A,0xEE,0xAE,0x3F,0xF4,0xAB,0x77,
101 0xEF,0x1B,0xF0,0x3E,0x5D,0xFA,0x57,0x5A,
102 0x88,0xBF,0x0D,0xB6,0xD7,0x0D,0xEE,0x56,
103 0xA1,0xF9,0x91,0x55,0x41,0x02,0x0B,0x56,
104 0x6F,0xBF,0x1C,0xAF,0xCF,0xFD,0x05,0x56,
105 0x2F,0x22,0xE4,0x9B,0xAB,0x7C,0xA1,0xAC,
106 0x5A,0x6B,0x61,0x2C,0xC2,0x6C,0xCE,0x4A,
107 0x5F,0x4C,0x03,0x8E,0xD1,0x2B,0x2E,0x41,
108 0x63,0xFA,0xC0,0xD0,0x34,0xD9,0xF7,0x93,
109 0x61,0x7B,0x3A,0x0C,0xE8,0xF0,0x71,0x00,
110 0xDB,0x95,0x86,0x05,0xF8,0xC8,0xC6,0x06,
111 0xED,0xBF,0xD1,0xC6,0x6C,0x29,0xCC,0xC7,
112 0x35,0x55,0x50,0xB2,0x15,0x0E,0x24,0x51,
113 0xCA,0xAA,0xAF,0x4D,0xEA,0xF1,0xDB,0xAE,
114 0xD5,0xD4,0x4F,0xF7,0x20,0x68,0x3D,0x0D,
115 0x2A,0x2B,0xB0,0x08,0xDF,0x97,0xC2,0xF2);
116
117print "Doing ecb tests\n";
118for ($i=0; $i<$num_tests; $i++)
119 {
120 printf "Doing test $i\n";
121 $key =pack("C8",splice(@key_data ,0,8));
122 $data=pack("C8",splice(@plain_data ,0,8));
123 $res =pack("C8",splice(@cipher_data,0,8));
124
125 @ks= &des_set_key($key);
126 $out1= &des_ecb_encrypt(*ks,1,$data);
127 $out2= &des_ecb_encrypt(*ks,0,$out1);
128 $out3= &des_ecb_encrypt(*ks,0,$res);
129 &eprint("encryption failure",$res,$out1)
130 if ($out1 ne $res);
131 &eprint("encryption/decryption failure",$data,$out2)
132 if ($out2 ne $data);
133 &eprint("decryption failure",$data,$out3)
134 if ($data ne $out3);
135 }
136print "Done\n";
137
138print "doing speed test over 30 seconds\n";
139$SIG{'ALRM'}='done';
140sub done {$done=1;}
141$done=0;
142
143$count=0;
144$d=pack("C8",0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef);
145@ks= &des_set_key($d);
146alarm(30);
147$start=(times)[0];
148while (!$done)
149 {
150 $count++;
151 $d=&des_ecb_encrypt(*ks,1,$d);
152 }
153$end=(times)[0];
154$t=$end-$start;
155printf "$count DESs in %.2f seconds is %.2f DESs/sec or %.2f bytes/sec\n",
156 1.0*$t,1.0*$count/$t,$count*8.0/$t;
157
158sub eprint
159 {
160 local($s,$c,$e)=@_;
161 local(@k);
162
163 @k=unpack("C8",$c);
164 printf "%02x%02x%02x%02x %02x%02x%02x%02x - ",unpack("C8",$c);
165 printf "%02x%02x%02x%02x %02x%02x%02x%02x :",unpack("C8",$e);
166 print " $s\n";
167 }
diff --git a/src/lib/libssl/src/crypto/des/vms.com b/src/lib/libssl/src/crypto/des/vms.com
new file mode 100644
index 0000000000..62ca1fbda4
--- /dev/null
+++ b/src/lib/libssl/src/crypto/des/vms.com
@@ -0,0 +1,90 @@
1$! --- VMS.com ---
2$!
3$ GoSub defines
4$ GoSub linker_options
5$ If (P1 .nes. "")
6$ Then
7$ GoSub 'P1'
8$ Else
9$ GoSub lib
10$ GoSub destest
11$ GoSub rpw
12$ GoSub speed
13$ GoSub des
14$ EndIF
15$!
16$ Exit
17$!
18$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
19$!
20$DEFINES:
21$ OPT_FILE := "VAX_LINKER_OPTIONS.OPT"
22$!
23$ CC_OPTS := "/NODebug/OPTimize/NOWarn"
24$!
25$ LINK_OPTS := "/NODebug/NOTraceback/Contiguous"
26$!
27$ OBJS = "cbc_cksm.obj,cbc_enc.obj,ecb_enc.obj,pcbc_enc.obj," + -
28 "qud_cksm.obj,rand_key.obj,read_pwd.obj,set_key.obj," + -
29 "str2key.obj,enc_read.obj,enc_writ.obj,fcrypt.obj," + -
30 "cfb_enc.obj,ecb3_enc.obj,ofb_enc.obj"
31
32
33$!
34$ LIBDES = "cbc_cksm.c,cbc_enc.c,ecb_enc.c,enc_read.c," + -
35 "enc_writ.c,pcbc_enc.c,qud_cksm.c,rand_key.c," + -
36 "read_pwd.c,set_key.c,str2key.c,fcrypt.c," + -
37 "cfb_enc.c,ecb3_enc.c,ofb_enc.c"
38$ Return
39$!
40$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41$!
42$LINKER_OPTIONS:
43$ If (f$search(OPT_FILE) .eqs. "")
44$ Then
45$ Create 'OPT_FILE'
46$DECK
47! Default system options file to link against the sharable C runtime library
48!
49Sys$Share:VAXcRTL.exe/Share
50$EOD
51$ EndIF
52$ Return
53$!
54$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
55$!
56$LIB:
57$ CC 'CC_OPTS' 'LIBDES'
58$ If (f$search("LIBDES.OLB") .nes. "")
59$ Then Library /Object /Replace libdes 'OBJS'
60$ Else Library /Create /Object libdes 'OBJS'
61$ EndIF
62$ Return
63$!
64$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
65$!
66$DESTEST:
67$ CC 'CC_OPTS' destest
68$ Link 'link_opts' /Exec=destest destest.obj,libdes/LIBRARY,'opt_file'/Option
69$ Return
70$!
71$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
72$!
73$RPW:
74$ CC 'CC_OPTS' rpw
75$ Link 'link_opts' /Exec=rpw rpw.obj,libdes/LIBRARY,'opt_file'/Option
76$ Return
77$!
78$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
79$!
80$SPEED:
81$ CC 'CC_OPTS' speed
82$ Link 'link_opts' /Exec=speed speed.obj,libdes/LIBRARY,'opt_file'/Option
83$ Return
84$!
85$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86$!
87$DES:
88$ CC 'CC_OPTS' des
89$ Link 'link_opts' /Exec=des des.obj,libdes/LIBRARY,'opt_file'/Option
90$ Return
diff --git a/src/lib/libssl/src/crypto/dh/Makefile.ssl b/src/lib/libssl/src/crypto/dh/Makefile.ssl
new file mode 100644
index 0000000000..dfa7e4525d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/dh/Makefile.ssl
@@ -0,0 +1,84 @@
1#
2# SSLeay/crypto/dh/Makefile
3#
4
5DIR= dh
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=dh
19ERRC=dh_err
20GENERAL=Makefile
21TEST= dhtest.c
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= dh_gen.c dh_key.c dh_lib.c dh_check.c $(ERRC).c
26LIBOBJ= dh_gen.o dh_key.o dh_lib.o dh_check.o $(ERRC).o
27
28SRC= $(LIBSRC)
29
30EXHEADER= dh.h
31HEADER= $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: lib
39
40lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/util/ranlib.sh $(LIB)
43 @touch lib
44
45files:
46 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
47
48links:
49 /bin/rm -f Makefile
50 $(TOP)/util/point.sh Makefile.ssl Makefile ;
51 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
52 $(TOP)/util/mklink.sh ../../test $(TEST)
53 $(TOP)/util/mklink.sh ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALLTOP)/include/$$i; \
59 chmod 644 $(INSTALLTOP)/include/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
72
73dclean:
74 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80errors:
81 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
82 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
83
84# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/dh/dh.err b/src/lib/libssl/src/crypto/dh/dh.err
new file mode 100644
index 0000000000..a4fe746985
--- /dev/null
+++ b/src/lib/libssl/src/crypto/dh/dh.err
@@ -0,0 +1,12 @@
1/* Error codes for the DH functions. */
2
3/* Function codes. */
4#define DH_F_DHPARAMS_PRINT 100
5#define DH_F_DHPARAMS_PRINT_FP 101
6#define DH_F_DH_COMPUTE_KEY 102
7#define DH_F_DH_GENERATE_KEY 103
8#define DH_F_DH_GENERATE_PARAMETERS 104
9#define DH_F_DH_NEW 105
10
11/* Reason codes. */
12#define DH_R_NO_PRIVATE_VALUE 100
diff --git a/src/lib/libssl/src/crypto/dsa/Makefile.ssl b/src/lib/libssl/src/crypto/dsa/Makefile.ssl
new file mode 100644
index 0000000000..2cc4ddb39e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/dsa/Makefile.ssl
@@ -0,0 +1,84 @@
1#
2# SSLeay/crypto/dsa/Makefile
3#
4
5DIR= dsa
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=dsa
19ERRC=dsa_err
20GENERAL=Makefile
21TEST=dsatest.c
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= dsa_gen.c dsa_key.c dsa_lib.c dsa_vrf.c dsa_sign.c $(ERRC).c
26LIBOBJ= dsa_gen.o dsa_key.o dsa_lib.o dsa_vrf.o dsa_sign.o $(ERRC).o
27
28SRC= $(LIBSRC)
29
30EXHEADER= dsa.h
31HEADER= $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: lib
39
40lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/util/ranlib.sh $(LIB)
43 @touch lib
44
45files:
46 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
47
48links:
49 /bin/rm -f Makefile
50 $(TOP)/util/point.sh Makefile.ssl Makefile ;
51 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
52 $(TOP)/util/mklink.sh ../../test $(TEST)
53 $(TOP)/util/mklink.sh ../../apps $(APPS)
54
55install:
56 @for i in $(EXHEADER) ; \
57 do \
58 (cp $$i $(INSTALLTOP)/include/$$i; \
59 chmod 644 $(INSTALLTOP)/include/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
72
73dclean:
74 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
75 mv -f Makefile.new $(MAKEFILE)
76
77clean:
78 /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
79
80errors:
81 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
82 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
83
84# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/dsa/dsa.err b/src/lib/libssl/src/crypto/dsa/dsa.err
new file mode 100644
index 0000000000..1131e9fa74
--- /dev/null
+++ b/src/lib/libssl/src/crypto/dsa/dsa.err
@@ -0,0 +1,15 @@
1/* Error codes for the DSA functions. */
2
3/* Function codes. */
4#define DSA_F_DSAPARAMS_PRINT 100
5#define DSA_F_DSAPARAMS_PRINT_FP 101
6#define DSA_F_DSA_IS_PRIME 102
7#define DSA_F_DSA_NEW 103
8#define DSA_F_DSA_PRINT 104
9#define DSA_F_DSA_PRINT_FP 105
10#define DSA_F_DSA_SIGN 106
11#define DSA_F_DSA_SIGN_SETUP 107
12#define DSA_F_DSA_VERIFY 108
13
14/* Reason codes. */
15#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
diff --git a/src/lib/libssl/src/crypto/err/Makefile.ssl b/src/lib/libssl/src/crypto/err/Makefile.ssl
new file mode 100644
index 0000000000..57c87eb041
--- /dev/null
+++ b/src/lib/libssl/src/crypto/err/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/err/Makefile
3#
4
5DIR= err
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=err.c err_all.c err_prn.c
24LIBOBJ=err.o err_all.o err_prn.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= err.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/err/err_code.pl b/src/lib/libssl/src/crypto/err/err_code.pl
new file mode 100644
index 0000000000..ebc8eef913
--- /dev/null
+++ b/src/lib/libssl/src/crypto/err/err_code.pl
@@ -0,0 +1,105 @@
1#!/usr/bin/perl
2
3while (@ARGV)
4 {
5 $in=shift(@ARGV);
6 if ($in =~ /^-conf$/)
7 {
8 $in=shift(@ARGV);
9 open(IN,"<$in") || die "unable to open '$in'\n";
10 while (<IN>)
11 {
12 s/#.*$//;
13 s/\s+$//;
14 next if (/^$/);
15 if (/^L\s+(\S+)\s+(\S+)$/)
16 { $errfile{$1}=$2; }
17 elsif (/^F\s+(\S+)$/)
18 { $function{$1}=1; }
19 elsif (/^R\s+(\S+)\s+(\S+)$/)
20 { $r_value{$1}=$2; }
21 else { die "bad input line: $in:$.\n"; }
22 }
23 close(IN);
24 next;
25 }
26
27 open(IN,"<$in") || die "unable to open '$in'\n";
28 $last="";
29 while (<IN>)
30 {
31 if (/err\(([A-Z0-9]+_F_[0-9A-Z_]+)\s*,\s*([0-9A-Z]+_R_[0-9A-Z_]+)\s*\)/)
32 {
33 if ($1 != $last)
34 {
35 if ($function{$1} == 0)
36 {
37 printf STDERR "$. $1 is bad\n";
38 }
39 }
40 $function{$1}++;
41 $last=$1;
42 $reason{$2}++;
43 }
44 }
45 close(IN);
46 }
47
48foreach (keys %function,keys %reason)
49 {
50 /^([A-Z0-9]+)_/;
51 $prefix{$1}++;
52 }
53
54@F=sort keys %function;
55@R=sort keys %reason;
56foreach $j (sort keys %prefix)
57 {
58 next if $errfile{$j} eq "NONE";
59 printf STDERR "doing %-6s - ",$j;
60 if (defined($errfile{$j}))
61 {
62 open(OUT,">$errfile{$j}") ||
63 die "unable to open '$errfile{$j}':$!\n";
64 $close_file=1;
65 }
66 else
67 {
68 *OUT=*STDOUT;
69 $close=0;
70 }
71 @f=grep(/^${j}_/,@F);
72 @r=grep(/^${j}_/,@R);
73 $num=100;
74 print OUT "/* Error codes for the $j functions. */\n\n";
75 print OUT "/* Function codes. */\n";
76 $f_count=0;
77 foreach $i (@f)
78 {
79 $z=6-int(length($i)/8);
80 printf OUT "#define $i%s $num\n","\t" x $z;
81 $num++;
82 $f_count++;
83 }
84 $num=100;
85 print OUT "\n/* Reason codes. */\n";
86 $r_count=0;
87 foreach $i (@r)
88 {
89 $z=6-int(length($i)/8);
90 if (defined($r_value{$i}))
91 {
92 printf OUT "#define $i%s $r_value{$i}\n","\t" x $z;
93 }
94 else
95 {
96 printf OUT "#define $i%s $num\n","\t" x $z;
97 $num++;
98 }
99 $r_count++;
100 }
101 close(OUT) if $close_file;
102
103 printf STDERR "%3d functions, %3d reasons\n",$f_count,$r_count;
104 }
105
diff --git a/src/lib/libssl/src/crypto/err/err_genc.pl b/src/lib/libssl/src/crypto/err/err_genc.pl
new file mode 100644
index 0000000000..a8e36c2f0c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/err/err_genc.pl
@@ -0,0 +1,198 @@
1#!/usr/bin/perl
2
3if ($ARGV[0] eq "-s") { $static=1; shift @ARGV; }
4
5($#ARGV == 1) || die "usage: $0 [-s] <header file> <output C file>\n";
6open(IN,"<$ARGV[0]") || die "unable to open $ARGV[0]:$!\n";
7open(STDOUT,">$ARGV[1]") || die "unable to open $ARGV[1]:$!\n";
8
9$Func=0;
10$Reas=0;
11$fuction{'FOPEN'}='fopen';
12while (<IN>)
13 {
14 if (/(\S+)\s*\(\);/)
15 {
16 $t=$1;
17 $t =~ s/\*//;
18 ($upper=$t) =~ tr/a-z/A-Z/;
19 $fuction{$upper}=$t;
20 }
21 next unless (/^#define\s+(\S+)\s/);
22
23 $o=$1;
24 if ($o =~ /^([^_]+)_F_(.*)/)
25 {
26 $type=$1;
27 $Func++;
28 $n=$2;
29 $n=$fuction{$n} if (defined($fuction{$n}));
30 $out{$1."_str_functs"}.=
31 sprintf("{ERR_PACK(0,%s,0),\t\"$n\"},\n",$o);
32 }
33 elsif ($o =~ /^([^_]+)_R_(.*)/)
34 {
35 $type=$1;
36 $Reas++;
37 $r=$2;
38 $r =~ tr/A-Z_/a-z /;
39 $pkg{$type."_str_reasons"}=$type;
40 $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o);
41 }
42 elsif ($ARGV[0] =~ /rsaref/ && $o =~ /^RE_(.*)/)
43 {
44 $type="RSAREF";
45 $Reas++;
46 $r=$1;
47 $r =~ tr/A-Z_/a-z /;
48 $pkg{$type."_str_reasons"}=$type;
49 $out{$type."_str_reasons"}.=sprintf("{%-40s,\"$r\"},\n",$o);
50 }
51 }
52close(IN);
53
54&header($type,$ARGV[0]);
55
56foreach (sort keys %out)
57 {
58 print "static ERR_STRING_DATA ${_}[]=\n\t{\n";
59 print $out{$_};
60 print "{0,NULL},\n";
61 print "\t};\n\n";
62 }
63print "#endif\n";
64
65if ($static)
66 { $lib="ERR_LIB_$type"; }
67else
68 { $lib="${type}_lib_error_code"; }
69
70$str="";
71$str.="#ifndef NO_ERR\n";
72$str.="\t\tERR_load_strings($lib,${type}_str_functs);\n" if $Func;
73$str.="\t\tERR_load_strings($lib,${type}_str_reasons);\n" if $Reas;
74$str.="#endif\n";
75
76if (!$static)
77 {
78print <<"EOF";
79
80static int ${type}_lib_error_code=0;
81
82void ERR_load_${type}_strings()
83 {
84 static int init=1;
85
86 if (${type}_lib_error_code == 0)
87 ${type}_lib_error_code=ERR_get_next_error_library();
88
89 if (init);
90 {;
91 init=0;
92$str
93 }
94 }
95
96void ERR_${type}_error(function,reason,file,line)
97int function;
98int reason;
99char *file;
100int line;
101 {
102 if (${type}_lib_error_code == 0)
103 ${type}_lib_error_code=ERR_get_next_error_library();
104 ERR_PUT_error(${type}_lib_error_code,function,reason,file,line);
105 }
106EOF
107 }
108else # $static
109 {
110 print <<"EOF";
111
112void ERR_load_${type}_strings()
113 {
114 static int init=1;
115
116 if (init);
117 {;
118 init=0;
119$str
120 }
121 }
122EOF
123 }
124
125sub header
126 {
127 ($type,$header)=@_;
128
129 ($lc=$type) =~ tr/A-Z/a-z/;
130 $header =~ s/^.*\///;
131
132 print "/* lib/$lc/${lc}\_err.c */\n";
133 print <<'EOF';
134/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
135 * All rights reserved.
136 *
137 * This package is an SSL implementation written
138 * by Eric Young (eay@cryptsoft.com).
139 * The implementation was written so as to conform with Netscapes SSL.
140 *
141 * This library is free for commercial and non-commercial use as long as
142 * the following conditions are aheared to. The following conditions
143 * apply to all code found in this distribution, be it the RC4, RSA,
144 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
145 * included with this distribution is covered by the same copyright terms
146 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
147 *
148 * Copyright remains Eric Young's, and as such any Copyright notices in
149 * the code are not to be removed.
150 * If this package is used in a product, Eric Young should be given attribution
151 * as the author of the parts of the library used.
152 * This can be in the form of a textual message at program startup or
153 * in documentation (online or textual) provided with the package.
154 *
155 * Redistribution and use in source and binary forms, with or without
156 * modification, are permitted provided that the following conditions
157 * are met:
158 * 1. Redistributions of source code must retain the copyright
159 * notice, this list of conditions and the following disclaimer.
160 * 2. Redistributions in binary form must reproduce the above copyright
161 * notice, this list of conditions and the following disclaimer in the
162 * documentation and/or other materials provided with the distribution.
163 * 3. All advertising materials mentioning features or use of this software
164 * must display the following acknowledgement:
165 * "This product includes cryptographic software written by
166 * Eric Young (eay@cryptsoft.com)"
167 * The word 'cryptographic' can be left out if the rouines from the library
168 * being used are not cryptographic related :-).
169 * 4. If you include any Windows specific code (or a derivative thereof) from
170 * the apps directory (application code) you must include an acknowledgement:
171 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
172 *
173 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
174 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
175 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
176 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
177 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
178 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
179 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
180 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
181 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
182 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
183 * SUCH DAMAGE.
184 *
185 * The licence and distribution terms for any publically available version or
186 * derivative of this code cannot be changed. i.e. this code cannot simply be
187 * copied and put under another distribution licence
188 * [including the GNU Public Licence.]
189 */
190EOF
191
192 print "#include <stdio.h>\n";
193 print "#include \"err.h\"\n";
194 print "#include \"$header\"\n";
195 print "\n/* BEGIN ERROR CODES */\n";
196 print "#ifndef NO_ERR\n";
197 }
198
diff --git a/src/lib/libssl/src/crypto/err/error.err b/src/lib/libssl/src/crypto/err/error.err
new file mode 100644
index 0000000000..f09557d8d9
--- /dev/null
+++ b/src/lib/libssl/src/crypto/err/error.err
@@ -0,0 +1,13 @@
1/* Error codes for the ERR functions. */
2
3/* Function codes. */
4
5/* Reason codes. */
6#define ERR_R_BN_LIB 100
7#define ERR_R_DER_LIB 101
8#define ERR_R_MALLOC_FAILURE 102
9#define ERR_R_PEM_LIB 103
10#define ERR_R_RSA_LIB 104
11#define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED 105
12#define ERR_R_SYS_LIB 106
13#define ERR_R_X509_LIB 107
diff --git a/src/lib/libssl/src/crypto/err/ssleay.ec b/src/lib/libssl/src/crypto/err/ssleay.ec
new file mode 100644
index 0000000000..10b5dbb59d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/err/ssleay.ec
@@ -0,0 +1,57 @@
1L ERR NONE
2L CRYPTO crypto.err
3L BN bn/bn.err
4L RSA rsa/rsa.err
5L DSA dsa/dsa.err
6L DH dh/dh.err
7L EVP evp/evp.err
8L BUF buffer/buffer.err
9L BIO bio/bio.err
10L OBJ objects/objects.err
11L PEM pem/pem.err
12L X509 x509/x509.err
13L METH meth/meth.err
14L ASN1 asn1/asn1.err
15L CONF conf/conf.err
16L PROXY proxy/proxy.err
17L PKCS7 pkcs7/pkcs7.err
18L RSAREF ../rsaref/rsaref.err
19L SSL ../ssl/ssl.err
20L SSL2 ../ssl/ssl2.err
21L SSL3 ../ssl/ssl3.err
22L SSL23 ../ssl/ssl23.err
23
24F RSAREF_F_RSA_BN2BIN
25F RSAREF_F_RSA_PRIVATE_DECRYPT
26F RSAREF_F_RSA_PRIVATE_ENCRYPT
27F RSAREF_F_RSA_PUBLIC_DECRYPT
28F RSAREF_F_RSA_PUBLIC_ENCRYPT
29#F SSL_F_CLIENT_CERTIFICATE
30
31R SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010
32R SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020
33R SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030
34R SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040
35R SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041
36R SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042
37R SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043
38R SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044
39R SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045
40R SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046
41R SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047
42
43R RSAREF_R_CONTENT_ENCODING 0x0400
44R RSAREF_R_DATA 0x0401
45R RSAREF_R_DIGEST_ALGORITHM 0x0402
46R RSAREF_R_ENCODING 0x0403
47R RSAREF_R_KEY 0x0404
48R RSAREF_R_KEY_ENCODING 0x0405
49R RSAREF_R_LEN 0x0406
50R RSAREF_R_MODULUS_LEN 0x0407
51R RSAREF_R_NEED_RANDOM 0x0408
52R RSAREF_R_PRIVATE_KEY 0x0409
53R RSAREF_R_PUBLIC_KEY 0x040a
54R RSAREF_R_SIGNATURE 0x040b
55R RSAREF_R_SIGNATURE_ENCODING 0x040c
56R RSAREF_R_ENCRYPTION_ALGORITHM 0x040d
57
diff --git a/src/lib/libssl/src/crypto/evp/Makefile.ssl b/src/lib/libssl/src/crypto/evp/Makefile.ssl
new file mode 100644
index 0000000000..8bf2516458
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/Makefile.ssl
@@ -0,0 +1,111 @@
1#
2# SSLeay/crypto/evp/Makefile
3#
4
5DIR= evp
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=evp
19ERRC=evp_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= encode.c digest.c evp_enc.c evp_key.c \
26 e_ecb_d.c e_cbc_d.c e_cfb_d.c e_ofb_d.c \
27 e_ecb_i.c e_cbc_i.c e_cfb_i.c e_ofb_i.c \
28 e_ecb_3d.c e_cbc_3d.c e_rc4.c names.c \
29 e_cfb_3d.c e_ofb_3d.c e_xcbc_d.c \
30 e_ecb_r2.c e_cbc_r2.c e_cfb_r2.c e_ofb_r2.c \
31 e_ecb_bf.c e_cbc_bf.c e_cfb_bf.c e_ofb_bf.c \
32 e_ecb_c.c e_cbc_c.c e_cfb_c.c e_ofb_c.c \
33 e_ecb_r5.c e_cbc_r5.c e_cfb_r5.c e_ofb_r5.c \
34 m_null.c m_md2.c m_md5.c m_sha.c m_sha1.c m_dss.c m_dss1.c m_mdc2.c \
35 m_ripemd.c \
36 p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \
37 bio_md.c bio_b64.c bio_enc.c $(ERRC).c e_null.c \
38 c_all.c evp_lib.c
39
40LIBOBJ= encode.o digest.o evp_enc.o evp_key.o \
41 e_ecb_d.o e_cbc_d.o e_cfb_d.o e_ofb_d.o \
42 e_ecb_i.o e_cbc_i.o e_cfb_i.o e_ofb_i.o \
43 e_ecb_3d.o e_cbc_3d.o e_rc4.o names.o \
44 e_cfb_3d.o e_ofb_3d.o e_xcbc_d.o \
45 e_ecb_r2.o e_cbc_r2.o e_cfb_r2.o e_ofb_r2.o \
46 e_ecb_bf.o e_cbc_bf.o e_cfb_bf.o e_ofb_bf.o \
47 e_ecb_c.o e_cbc_c.o e_cfb_c.o e_ofb_c.o \
48 e_ecb_r5.o e_cbc_r5.o e_cfb_r5.o e_ofb_r5.o \
49 m_null.o m_md2.o m_md5.o m_sha.o m_sha1.o m_dss.o m_dss1.o m_mdc2.o \
50 m_ripemd.o \
51 p_open.o p_seal.o p_sign.o p_verify.o p_lib.o p_enc.o p_dec.o \
52 bio_md.o bio_b64.o bio_enc.o $(ERRC).o e_null.o \
53 c_all.o evp_lib.o
54
55SRC= $(LIBSRC)
56
57EXHEADER= evp.h
58HEADER= $(EXHEADER)
59
60ALL= $(GENERAL) $(SRC) $(HEADER)
61
62top:
63 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
64
65all: lib
66
67lib: $(LIBOBJ)
68 $(AR) $(LIB) $(LIBOBJ)
69 sh $(TOP)/util/ranlib.sh $(LIB)
70 @touch lib
71
72files:
73 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
74
75links:
76 /bin/rm -f Makefile
77 $(TOP)/util/point.sh Makefile.ssl Makefile ;
78 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
79 $(TOP)/util/mklink.sh ../../test $(TEST)
80 $(TOP)/util/mklink.sh ../../apps $(APPS)
81
82install:
83 @for i in $(EXHEADER) ; \
84 do \
85 (cp $$i $(INSTALLTOP)/include/$$i; \
86 chmod 644 $(INSTALLTOP)/include/$$i ); \
87 done;
88
89tags:
90 ctags $(SRC)
91
92tests:
93
94lint:
95 lint -DLINT $(INCLUDES) $(SRC)>fluff
96
97depend:
98 $(MAKEDEPEND) $(INCLUDES) $(LIBSRC)
99
100dclean:
101 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
102 mv -f Makefile.new $(MAKEFILE)
103
104clean:
105 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
106
107errors:
108 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
109 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
110
111# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_3d.c b/src/lib/libssl/src/crypto/evp/e_cbc_3d.c
new file mode 100644
index 0000000000..5761bf186a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cbc_3d.c
@@ -0,0 +1,163 @@
1/* crypto/evp/e_cbc_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_cbc_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_cbc_ede_init_key();
73static void des_cbc_ede3_init_key();
74static void des_cbc_ede_cipher();
75#endif
76
77static EVP_CIPHER d_cbc_ede_cipher2=
78 {
79 NID_des_ede_cbc,
80 8,16,8,
81 des_cbc_ede_init_key,
82 des_cbc_ede_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 EVP_CIPHER_get_asn1_iv,
87 EVP_CIPHER_set_asn1_iv,
88 };
89
90static EVP_CIPHER d_cbc_ede_cipher3=
91 {
92 NID_des_ede3_cbc,
93 8,24,8,
94 des_cbc_ede3_init_key,
95 des_cbc_ede_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 EVP_CIPHER_set_asn1_iv,
100 EVP_CIPHER_get_asn1_iv,
101 };
102
103EVP_CIPHER *EVP_des_ede_cbc()
104 {
105 return(&d_cbc_ede_cipher2);
106 }
107
108EVP_CIPHER *EVP_des_ede3_cbc()
109 {
110 return(&d_cbc_ede_cipher3);
111 }
112
113static void des_cbc_ede_init_key(ctx,key,iv,enc)
114EVP_CIPHER_CTX *ctx;
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 {
119 if (iv != NULL)
120 memcpy(&(ctx->oiv[0]),iv,8);
121 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
122
123 if (key != NULL)
124 {
125 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
126 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
127 memcpy( (char *)ctx->c.des_ede.ks3,
128 (char *)ctx->c.des_ede.ks1,
129 sizeof(ctx->c.des_ede.ks1));
130 }
131 }
132
133static void des_cbc_ede3_init_key(ctx,key,iv,enc)
134EVP_CIPHER_CTX *ctx;
135unsigned char *key;
136unsigned char *iv;
137int enc;
138 {
139 if (iv != NULL)
140 memcpy(&(ctx->oiv[0]),iv,8);
141 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
142
143 if (key != NULL)
144 {
145 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
146 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
147 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
148 }
149 }
150
151static void des_cbc_ede_cipher(ctx,out,in,inl)
152EVP_CIPHER_CTX *ctx;
153unsigned char *out;
154unsigned char *in;
155unsigned int inl;
156 {
157 des_ede3_cbc_encrypt(
158 (des_cblock *)in,(des_cblock *)out,
159 (long)inl, ctx->c.des_ede.ks1,
160 ctx->c.des_ede.ks2,ctx->c.des_ede.ks3,
161 (des_cblock *)&(ctx->iv[0]),
162 ctx->encrypt);
163 }
diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_bf.c b/src/lib/libssl/src/crypto/evp/e_cbc_bf.c
new file mode 100644
index 0000000000..be605f4a13
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cbc_bf.c
@@ -0,0 +1,119 @@
1/* crypto/evp/e_cbc_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_cbc_init_key();
73static void bf_cbc_cipher();
74#endif
75
76static EVP_CIPHER bfish_cbc_cipher=
77 {
78 NID_bf_cbc,
79 8,EVP_BLOWFISH_KEY_SIZE,8,
80 bf_cbc_init_key,
81 bf_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_bf_cbc()
90 {
91 return(&bfish_cbc_cipher);
92 }
93
94static void bf_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
105 }
106
107static void bf_cbc_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 BF_cbc_encrypt(
114 in,out,(long)inl,
115 &(ctx->c.bf_ks),&(ctx->iv[0]),
116 ctx->encrypt);
117 }
118
119#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_c.c b/src/lib/libssl/src/crypto/evp/e_cbc_c.c
new file mode 100644
index 0000000000..b50c7874b3
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cbc_c.c
@@ -0,0 +1,119 @@
1/* crypto/evp/e_cbc_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_cbc_init_key();
73static void cast_cbc_cipher();
74#endif
75
76static EVP_CIPHER cast5_cbc_cipher=
77 {
78 NID_cast5_cbc,
79 8,EVP_CAST5_KEY_SIZE,8,
80 cast_cbc_init_key,
81 cast_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_cast5_cbc()
90 {
91 return(&cast5_cbc_cipher);
92 }
93
94static void cast_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
105 }
106
107static void cast_cbc_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 CAST_cbc_encrypt(
114 in,out,(long)inl,
115 &(ctx->c.cast_ks),&(ctx->iv[0]),
116 ctx->encrypt);
117 }
118
119#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_d.c b/src/lib/libssl/src/crypto/evp/e_cbc_d.c
new file mode 100644
index 0000000000..c67706e3a0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cbc_d.c
@@ -0,0 +1,116 @@
1/* crypto/evp/e_cbc_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_cbc_init_key();
71static void des_cbc_cipher();
72#endif
73
74static EVP_CIPHER d_cbc_cipher=
75 {
76 NID_des_cbc,
77 8,8,8,
78 des_cbc_init_key,
79 des_cbc_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 EVP_CIPHER_get_asn1_iv,
84 EVP_CIPHER_set_asn1_iv,
85 };
86
87EVP_CIPHER *EVP_des_cbc()
88 {
89 return(&d_cbc_cipher);
90 }
91
92static void des_cbc_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 if (iv != NULL)
99 memcpy(&(ctx->oiv[0]),iv,8);
100 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
101 if (key != NULL)
102 des_set_key((des_cblock *)key,ctx->c.des_ks);
103 }
104
105static void des_cbc_cipher(ctx,out,in,inl)
106EVP_CIPHER_CTX *ctx;
107unsigned char *out;
108unsigned char *in;
109unsigned int inl;
110 {
111 des_ncbc_encrypt(
112 (des_cblock *)in,(des_cblock *)out,
113 (long)inl, ctx->c.des_ks,
114 (des_cblock *)&(ctx->iv[0]),
115 ctx->encrypt);
116 }
diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_i.c b/src/lib/libssl/src/crypto/evp/e_cbc_i.c
new file mode 100644
index 0000000000..312ffcb721
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cbc_i.c
@@ -0,0 +1,131 @@
1/* crypto/evp/e_cbc_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_cbc_init_key();
73static void idea_cbc_cipher();
74#endif
75
76static EVP_CIPHER i_cbc_cipher=
77 {
78 NID_idea_cbc,
79 8,16,8,
80 idea_cbc_init_key,
81 idea_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_idea_cbc()
90 {
91 return(&i_cbc_cipher);
92 }
93
94static void idea_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 {
105 if (enc)
106 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
107 else
108 {
109 IDEA_KEY_SCHEDULE tmp;
110
111 idea_set_encrypt_key(key,&tmp);
112 idea_set_decrypt_key(&tmp,&(ctx->c.idea_ks));
113 memset((unsigned char *)&tmp,0,
114 sizeof(IDEA_KEY_SCHEDULE));
115 }
116 }
117 }
118
119static void idea_cbc_cipher(ctx,out,in,inl)
120EVP_CIPHER_CTX *ctx;
121unsigned char *out;
122unsigned char *in;
123unsigned int inl;
124 {
125 idea_cbc_encrypt(
126 in,out,(long)inl,
127 &(ctx->c.idea_ks),&(ctx->iv[0]),
128 ctx->encrypt);
129 }
130
131#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_r2.c b/src/lib/libssl/src/crypto/evp/e_cbc_r2.c
new file mode 100644
index 0000000000..4f8002f16d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cbc_r2.c
@@ -0,0 +1,136 @@
1/* crypto/evp/e_cbc_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_cbc_init_key();
73static void rc2_cbc_cipher();
74#endif
75
76static EVP_CIPHER r2_cbc_cipher=
77 {
78 NID_rc2_cbc,
79 8,EVP_RC2_KEY_SIZE,8,
80 rc2_cbc_init_key,
81 rc2_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 EVP_CIPHER_get_asn1_iv,
86 EVP_CIPHER_set_asn1_iv,
87 };
88
89static EVP_CIPHER r2_40_cbc_cipher=
90 {
91 NID_rc2_40_cbc,
92 8,5 /* 40 bit */,8,
93 rc2_cbc_init_key,
94 rc2_cbc_cipher,
95 NULL,
96 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
97 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
98 };
99
100EVP_CIPHER *EVP_rc2_cbc()
101 {
102 return(&r2_cbc_cipher);
103 }
104
105EVP_CIPHER *EVP_rc2_40_cbc()
106 {
107 return(&r2_40_cbc_cipher);
108 }
109
110static void rc2_cbc_init_key(ctx,key,iv,enc)
111EVP_CIPHER_CTX *ctx;
112unsigned char *key;
113unsigned char *iv;
114int enc;
115 {
116 if (iv != NULL)
117 memcpy(&(ctx->oiv[0]),iv,8);
118 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
119 if (key != NULL)
120 RC2_set_key(&(ctx->c.rc2_ks),EVP_CIPHER_CTX_key_length(ctx),
121 key,EVP_CIPHER_CTX_key_length(ctx)*8);
122 }
123
124static void rc2_cbc_cipher(ctx,out,in,inl)
125EVP_CIPHER_CTX *ctx;
126unsigned char *out;
127unsigned char *in;
128unsigned int inl;
129 {
130 RC2_cbc_encrypt(
131 in,out,(long)inl,
132 &(ctx->c.rc2_ks),&(ctx->iv[0]),
133 ctx->encrypt);
134 }
135
136#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_cbc_r5.c b/src/lib/libssl/src/crypto/evp/e_cbc_r5.c
new file mode 100644
index 0000000000..f7d46ca91f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cbc_r5.c
@@ -0,0 +1,120 @@
1/* crypto/evp/e_cbc_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void r_32_12_16_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void r_32_12_16_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void r_32_12_16_cbc_init_key();
73static void r_32_12_16_cbc_cipher();
74#endif
75
76static EVP_CIPHER rc5_32_12_16_cbc_cipher=
77 {
78 NID_rc5_cbc,
79 8,EVP_RC5_32_12_16_KEY_SIZE,8,
80 r_32_12_16_cbc_init_key,
81 r_32_12_16_cbc_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_cbc()
90 {
91 return(&rc5_32_12_16_cbc_cipher);
92 }
93
94static void r_32_12_16_cbc_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,
105 key,RC5_12_ROUNDS);
106 }
107
108static void r_32_12_16_cbc_cipher(ctx,out,in,inl)
109EVP_CIPHER_CTX *ctx;
110unsigned char *out;
111unsigned char *in;
112unsigned int inl;
113 {
114 RC5_32_cbc_encrypt(
115 in,out,(long)inl,
116 &(ctx->c.rc5_ks),&(ctx->iv[0]),
117 ctx->encrypt);
118 }
119
120#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_3d.c b/src/lib/libssl/src/crypto/evp/e_cfb_3d.c
new file mode 100644
index 0000000000..e7e3419411
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cfb_3d.c
@@ -0,0 +1,166 @@
1/* crypto/evp/e_cfb_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_cfb_init_key();
73static void des_ede3_cfb_init_key();
74static void des_ede_cfb_cipher();
75#endif
76
77static EVP_CIPHER d_ede_cfb_cipher2=
78 {
79 NID_des_ede_cfb64,
80 1,16,8,
81 des_ede_cfb_init_key,
82 des_ede_cfb_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 EVP_CIPHER_set_asn1_iv,
87 EVP_CIPHER_get_asn1_iv,
88 };
89
90static EVP_CIPHER d_ede3_cfb_cipher3=
91 {
92 NID_des_ede3_cfb64,
93 1,24,8,
94 des_ede3_cfb_init_key,
95 des_ede_cfb_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 EVP_CIPHER_set_asn1_iv,
100 EVP_CIPHER_get_asn1_iv,
101 };
102
103EVP_CIPHER *EVP_des_ede_cfb()
104 {
105 return(&d_ede_cfb_cipher2);
106 }
107
108EVP_CIPHER *EVP_des_ede3_cfb()
109 {
110 return(&d_ede3_cfb_cipher3);
111 }
112
113static void des_ede_cfb_init_key(ctx,key,iv,enc)
114EVP_CIPHER_CTX *ctx;
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 {
119 ctx->num=0;
120
121 if (iv != NULL)
122 memcpy(&(ctx->oiv[0]),iv,8);
123 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
124 if (key != NULL)
125 {
126 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
127 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
128 memcpy( (char *)ctx->c.des_ede.ks3,
129 (char *)ctx->c.des_ede.ks1,
130 sizeof(ctx->c.des_ede.ks1));
131 }
132 }
133
134static void des_ede3_cfb_init_key(ctx,key,iv,enc)
135EVP_CIPHER_CTX *ctx;
136unsigned char *key;
137unsigned char *iv;
138int enc;
139 {
140 ctx->num=0;
141
142 if (iv != NULL)
143 memcpy(&(ctx->oiv[0]),iv,8);
144 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
145 if (key != NULL)
146 {
147 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
148 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
149 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
150 }
151 }
152
153static void des_ede_cfb_cipher(ctx,out,in,inl)
154EVP_CIPHER_CTX *ctx;
155unsigned char *out;
156unsigned char *in;
157unsigned int inl;
158 {
159 des_ede3_cfb64_encrypt(
160 in,out,(long)inl,
161 ctx->c.des_ede.ks1,
162 ctx->c.des_ede.ks2,
163 ctx->c.des_ede.ks3,
164 (des_cblock *)&(ctx->iv[0]),
165 &ctx->num,ctx->encrypt);
166 }
diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_bf.c b/src/lib/libssl/src/crypto/evp/e_cfb_bf.c
new file mode 100644
index 0000000000..8aba2564b8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cfb_bf.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_cfb_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_cfb_init_key();
73static void bf_cfb_cipher();
74#endif
75
76static EVP_CIPHER bfish_cfb_cipher=
77 {
78 NID_bf_cfb64,
79 1,EVP_BLOWFISH_KEY_SIZE,8,
80 bf_cfb_init_key,
81 bf_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_bf_cfb()
90 {
91 return(&bfish_cfb_cipher);
92 }
93
94static void bf_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
107 }
108
109static void bf_cfb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 BF_cfb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.bf_ks),
118 &(ctx->iv[0]),
119 &ctx->num,ctx->encrypt);
120 }
121#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_c.c b/src/lib/libssl/src/crypto/evp/e_cfb_c.c
new file mode 100644
index 0000000000..936df55fd8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cfb_c.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_cfb_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_cfb_init_key();
73static void cast_cfb_cipher();
74#endif
75
76static EVP_CIPHER cast5_cfb_cipher=
77 {
78 NID_cast5_cfb64,
79 1,EVP_CAST5_KEY_SIZE,8,
80 cast_cfb_init_key,
81 cast_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_cast5_cfb()
90 {
91 return(&cast5_cfb_cipher);
92 }
93
94static void cast_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
107 }
108
109static void cast_cfb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 CAST_cfb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.cast_ks),
118 &(ctx->iv[0]),
119 &ctx->num,ctx->encrypt);
120 }
121#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_d.c b/src/lib/libssl/src/crypto/evp/e_cfb_d.c
new file mode 100644
index 0000000000..9ae4558f51
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cfb_d.c
@@ -0,0 +1,118 @@
1/* crypto/evp/e_cfb_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_cfb_init_key();
71static void des_cfb_cipher();
72#endif
73
74static EVP_CIPHER d_cfb_cipher=
75 {
76 NID_des_cfb64,
77 1,8,8,
78 des_cfb_init_key,
79 des_cfb_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 EVP_CIPHER_set_asn1_iv,
84 EVP_CIPHER_get_asn1_iv,
85 };
86
87EVP_CIPHER *EVP_des_cfb()
88 {
89 return(&d_cfb_cipher);
90 }
91
92static void des_cfb_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 ctx->num=0;
99
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 des_set_key((des_cblock *)key,ctx->c.des_ks);
105 }
106
107static void des_cfb_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 des_cfb64_encrypt(
114 in,out,
115 (long)inl, ctx->c.des_ks,
116 (des_cblock *)&(ctx->iv[0]),
117 &ctx->num,ctx->encrypt);
118 }
diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_i.c b/src/lib/libssl/src/crypto/evp/e_cfb_i.c
new file mode 100644
index 0000000000..9225efaa86
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cfb_i.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_cfb_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_cfb_init_key();
73static void idea_cfb_cipher();
74#endif
75
76static EVP_CIPHER i_cfb_cipher=
77 {
78 NID_idea_cfb64,
79 1,IDEA_KEY_LENGTH,IDEA_BLOCK,
80 idea_cfb_init_key,
81 idea_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_idea_cfb()
90 {
91 return(&i_cfb_cipher);
92 }
93
94static void idea_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
107 }
108
109static void idea_cfb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 idea_cfb64_encrypt(
116 in,out,(long)inl,
117 &(ctx->c.idea_ks),&(ctx->iv[0]),
118 &ctx->num,ctx->encrypt);
119 }
120
121#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_r2.c b/src/lib/libssl/src/crypto/evp/e_cfb_r2.c
new file mode 100644
index 0000000000..af5a39d1f4
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cfb_r2.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_cfb_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_cfb_init_key();
73static void rc2_cfb_cipher();
74#endif
75
76static EVP_CIPHER r2_cfb_cipher=
77 {
78 NID_rc2_cfb64,
79 1,EVP_RC2_KEY_SIZE,8,
80 rc2_cfb_init_key,
81 rc2_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc2_cfb()
90 {
91 return(&r2_cfb_cipher);
92 }
93
94static void rc2_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
107 EVP_RC2_KEY_SIZE*8);
108 }
109
110static void rc2_cfb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC2_cfb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc2_ks),
119 &(ctx->iv[0]),
120 &ctx->num,ctx->encrypt);
121 }
122#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_cfb_r5.c b/src/lib/libssl/src/crypto/evp/e_cfb_r5.c
new file mode 100644
index 0000000000..a2fddaedc0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_cfb_r5.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_cfb_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc5_32_12_16_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc5_32_12_16_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc5_32_12_16_cfb_init_key();
73static void rc5_32_12_16_cfb_cipher();
74#endif
75
76static EVP_CIPHER rc5_cfb_cipher=
77 {
78 NID_rc5_cfb64,
79 1,EVP_RC5_32_12_16_KEY_SIZE,8,
80 rc5_32_12_16_cfb_init_key,
81 rc5_32_12_16_cfb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_cfb()
90 {
91 return(&rc5_cfb_cipher);
92 }
93
94static void rc5_32_12_16_cfb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
107 RC5_12_ROUNDS);
108 }
109
110static void rc5_32_12_16_cfb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC5_32_cfb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc5_ks),
119 &(ctx->iv[0]),
120 &ctx->num,ctx->encrypt);
121 }
122#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_3d.c b/src/lib/libssl/src/crypto/evp/e_ecb_3d.c
new file mode 100644
index 0000000000..908fc0760a
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ecb_3d.c
@@ -0,0 +1,161 @@
1/* crypto/evp/e_ecb_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_init_key();
73static void des_ede3_init_key();
74static void des_ede_cipher();
75#endif
76
77static EVP_CIPHER d_ede_cipher2=
78 {
79 NID_des_ede,
80 8,16,0,
81 des_ede_init_key,
82 des_ede_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 NULL,
87 NULL,
88 };
89
90static EVP_CIPHER d_ede3_cipher3=
91 {
92 NID_des_ede3,
93 8,24,0,
94 des_ede3_init_key,
95 des_ede_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 NULL,
100 };
101
102EVP_CIPHER *EVP_des_ede()
103 {
104 return(&d_ede_cipher2);
105 }
106
107EVP_CIPHER *EVP_des_ede3()
108 {
109 return(&d_ede3_cipher3);
110 }
111
112static void des_ede_init_key(ctx,key,iv,enc)
113EVP_CIPHER_CTX *ctx;
114unsigned char *key;
115unsigned char *iv;
116int enc;
117 {
118 if (key != NULL)
119 {
120 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
121 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
122 memcpy( (char *)ctx->c.des_ede.ks3,
123 (char *)ctx->c.des_ede.ks1,
124 sizeof(ctx->c.des_ede.ks1));
125 }
126 }
127
128static void des_ede3_init_key(ctx,key,iv,enc)
129EVP_CIPHER_CTX *ctx;
130unsigned char *key;
131unsigned char *iv;
132int enc;
133 {
134 if (key != NULL)
135 {
136 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
137 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
138 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
139 }
140 }
141
142static void des_ede_cipher(ctx,out,in,inl)
143EVP_CIPHER_CTX *ctx;
144unsigned char *out;
145unsigned char *in;
146unsigned int inl;
147 {
148 unsigned int i;
149
150 if (inl < 8) return;
151 inl-=8;
152 for (i=0; i<=inl; i+=8)
153 {
154 des_ecb3_encrypt(
155 (des_cblock *)&(in[i]),(des_cblock *)&(out[i]),
156 ctx->c.des_ede.ks1,
157 ctx->c.des_ede.ks2,
158 ctx->c.des_ede.ks3,
159 ctx->encrypt);
160 }
161 }
diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_bf.c b/src/lib/libssl/src/crypto/evp/e_ecb_bf.c
new file mode 100644
index 0000000000..142a9d3123
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ecb_bf.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ecb_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_ecb_init_key();
73static void bf_ecb_cipher();
74#endif
75
76static EVP_CIPHER bfish_ecb_cipher=
77 {
78 NID_bf_ecb,
79 8,EVP_BLOWFISH_KEY_SIZE,0,
80 bf_ecb_init_key,
81 bf_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_bf_ecb()
90 {
91 return(&bfish_ecb_cipher);
92 }
93
94static void bf_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
102 }
103
104static void bf_ecb_cipher(ctx,out,in,inl)
105EVP_CIPHER_CTX *ctx;
106unsigned char *out;
107unsigned char *in;
108unsigned int inl;
109 {
110 unsigned int i;
111
112 if (inl < 8) return;
113 inl-=8;
114 for (i=0; i<=inl; i+=8)
115 {
116 BF_ecb_encrypt(
117 &(in[i]),&(out[i]),
118 &(ctx->c.bf_ks),ctx->encrypt);
119 }
120 }
121
122#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_c.c b/src/lib/libssl/src/crypto/evp/e_ecb_c.c
new file mode 100644
index 0000000000..34e0c18296
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ecb_c.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ecb_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_ecb_init_key();
73static void cast_ecb_cipher();
74#endif
75
76static EVP_CIPHER cast5_ecb_cipher=
77 {
78 NID_cast5_ecb,
79 8,EVP_CAST5_KEY_SIZE,0,
80 cast_ecb_init_key,
81 cast_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_cast5_ecb()
90 {
91 return(&cast5_ecb_cipher);
92 }
93
94static void cast_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
102 }
103
104static void cast_ecb_cipher(ctx,out,in,inl)
105EVP_CIPHER_CTX *ctx;
106unsigned char *out;
107unsigned char *in;
108unsigned int inl;
109 {
110 unsigned int i;
111
112 if (inl < 8) return;
113 inl-=8;
114 for (i=0; i<=inl; i+=8)
115 {
116 CAST_ecb_encrypt(
117 &(in[i]),&(out[i]),
118 &(ctx->c.cast_ks),ctx->encrypt);
119 }
120 }
121
122#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_d.c b/src/lib/libssl/src/crypto/evp/e_ecb_d.c
new file mode 100644
index 0000000000..7a409d6459
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ecb_d.c
@@ -0,0 +1,118 @@
1/* crypto/evp/e_ecb_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_ecb_init_key();
71static void des_ecb_cipher();
72#endif
73
74static EVP_CIPHER d_ecb_cipher=
75 {
76 NID_des_ecb,
77 8,8,0,
78 des_ecb_init_key,
79 des_ecb_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 NULL,
84 NULL,
85 };
86
87EVP_CIPHER *EVP_des_ecb()
88 {
89 return(&d_ecb_cipher);
90 }
91
92static void des_ecb_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 if (key != NULL)
99 des_set_key((des_cblock *)key,ctx->c.des_ks);
100 }
101
102static void des_ecb_cipher(ctx,out,in,inl)
103EVP_CIPHER_CTX *ctx;
104unsigned char *out;
105unsigned char *in;
106unsigned int inl;
107 {
108 unsigned int i;
109
110 if (inl < 8) return;
111 inl-=8;
112 for (i=0; i<=inl; i+=8)
113 {
114 des_ecb_encrypt(
115 (des_cblock *)&(in[i]),(des_cblock *)&(out[i]),
116 ctx->c.des_ks,ctx->encrypt);
117 }
118 }
diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_i.c b/src/lib/libssl/src/crypto/evp/e_ecb_i.c
new file mode 100644
index 0000000000..e24022a12c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ecb_i.c
@@ -0,0 +1,133 @@
1/* crypto/evp/e_ecb_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_ecb_init_key();
73static void idea_ecb_cipher();
74#endif
75
76static EVP_CIPHER i_ecb_cipher=
77 {
78 NID_idea_ecb,
79 8,16,0,
80 idea_ecb_init_key,
81 idea_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_idea_ecb()
90 {
91 return(&i_ecb_cipher);
92 }
93
94static void idea_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 {
102 if (enc)
103 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
104 else
105 {
106 IDEA_KEY_SCHEDULE tmp;
107
108 idea_set_encrypt_key(key,&tmp);
109 idea_set_decrypt_key(&tmp, &(ctx->c.idea_ks));
110 memset((unsigned char *)&tmp,0,
111 sizeof(IDEA_KEY_SCHEDULE));
112 }
113 }
114 }
115
116static void idea_ecb_cipher(ctx,out,in,inl)
117EVP_CIPHER_CTX *ctx;
118unsigned char *out;
119unsigned char *in;
120unsigned int inl;
121 {
122 unsigned int i;
123
124 if (inl < 8) return;
125 inl-=8;
126 for (i=0; i<=inl; i+=8)
127 {
128 idea_ecb_encrypt(
129 &(in[i]),&(out[i]),&(ctx->c.idea_ks));
130 }
131 }
132
133#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_r2.c b/src/lib/libssl/src/crypto/evp/e_ecb_r2.c
new file mode 100644
index 0000000000..e35b06dc6d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ecb_r2.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ecb_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_ecb_init_key();
73static void rc2_ecb_cipher();
74#endif
75
76static EVP_CIPHER r2_ecb_cipher=
77 {
78 NID_rc2_ecb,
79 8,EVP_RC2_KEY_SIZE,0,
80 rc2_ecb_init_key,
81 rc2_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_rc2_ecb()
90 {
91 return(&r2_ecb_cipher);
92 }
93
94static void rc2_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
102 EVP_RC2_KEY_SIZE*8);
103 }
104
105static void rc2_ecb_cipher(ctx,out,in,inl)
106EVP_CIPHER_CTX *ctx;
107unsigned char *out;
108unsigned char *in;
109unsigned int inl;
110 {
111 unsigned int i;
112
113 if (inl < 8) return;
114 inl-=8;
115 for (i=0; i<=inl; i+=8)
116 {
117 RC2_ecb_encrypt(
118 &(in[i]),&(out[i]),
119 &(ctx->c.rc2_ks),ctx->encrypt);
120 }
121 }
122
123#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_ecb_r5.c b/src/lib/libssl/src/crypto/evp/e_ecb_r5.c
new file mode 100644
index 0000000000..08f4a82651
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ecb_r5.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ecb_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc5_32_12_16_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc5_32_12_16_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc5_32_12_16_ecb_init_key();
73static void rc5_32_12_16_ecb_cipher();
74#endif
75
76static EVP_CIPHER rc5_ecb_cipher=
77 {
78 NID_rc5_ecb,
79 8,EVP_RC5_32_12_16_KEY_SIZE,0,
80 rc5_32_12_16_ecb_init_key,
81 rc5_32_12_16_ecb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 NULL,
86 NULL,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_ecb()
90 {
91 return(&rc5_ecb_cipher);
92 }
93
94static void rc5_32_12_16_ecb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 if (key != NULL)
101 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
102 RC5_12_ROUNDS);
103 }
104
105static void rc5_32_12_16_ecb_cipher(ctx,out,in,inl)
106EVP_CIPHER_CTX *ctx;
107unsigned char *out;
108unsigned char *in;
109unsigned int inl;
110 {
111 unsigned int i;
112
113 if (inl < 8) return;
114 inl-=8;
115 for (i=0; i<=inl; i+=8)
116 {
117 RC5_32_ecb_encrypt(
118 &(in[i]),&(out[i]),
119 &(ctx->c.rc5_ks),ctx->encrypt);
120 }
121 }
122
123#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_3d.c b/src/lib/libssl/src/crypto/evp/e_ofb_3d.c
new file mode 100644
index 0000000000..c3add18e93
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ofb_3d.c
@@ -0,0 +1,165 @@
1/* crypto/evp/e_ofb_3d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void des_ede_ofb_init_key();
73static void des_ede3_ofb_init_key();
74static void des_ede_ofb_cipher();
75#endif
76
77static EVP_CIPHER d_ede_ofb_cipher2=
78 {
79 NID_des_ede_ofb64,
80 1,16,8,
81 des_ede_ofb_init_key,
82 des_ede_ofb_cipher,
83 NULL,
84 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
85 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
86 EVP_CIPHER_set_asn1_iv,
87 EVP_CIPHER_get_asn1_iv,
88 };
89
90static EVP_CIPHER d_ede3_ofb_cipher3=
91 {
92 NID_des_ede3_ofb64,
93 1,24,8,
94 des_ede3_ofb_init_key,
95 des_ede_ofb_cipher,
96 NULL,
97 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
98 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ede)),
99 EVP_CIPHER_set_asn1_iv,
100 EVP_CIPHER_get_asn1_iv,
101 };
102
103EVP_CIPHER *EVP_des_ede_ofb()
104 {
105 return(&d_ede_ofb_cipher2);
106 }
107
108EVP_CIPHER *EVP_des_ede3_ofb()
109 {
110 return(&d_ede3_ofb_cipher3);
111 }
112
113static void des_ede_ofb_init_key(ctx,key,iv,enc)
114EVP_CIPHER_CTX *ctx;
115unsigned char *key;
116unsigned char *iv;
117int enc;
118 {
119 ctx->num=0;
120
121 if (iv != NULL)
122 memcpy(&(ctx->oiv[0]),iv,8);
123 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
124 if (key != NULL)
125 {
126 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
127 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
128 memcpy( (char *)ctx->c.des_ede.ks3,
129 (char *)ctx->c.des_ede.ks1,
130 sizeof(ctx->c.des_ede.ks1));
131 }
132 }
133
134static void des_ede3_ofb_init_key(ctx,key,iv,enc)
135EVP_CIPHER_CTX *ctx;
136unsigned char *key;
137unsigned char *iv;
138int enc;
139 {
140 ctx->num=0;
141
142 if (iv != NULL)
143 memcpy(&(ctx->oiv[0]),iv,8);
144 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
145 if (key != NULL)
146 {
147 des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
148 des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
149 des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
150 }
151 }
152
153static void des_ede_ofb_cipher(ctx,out,in,inl)
154EVP_CIPHER_CTX *ctx;
155unsigned char *out;
156unsigned char *in;
157unsigned int inl;
158 {
159 des_ede3_ofb64_encrypt(
160 in,out,
161 (long)inl,
162 ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
163 (des_cblock *)&(ctx->iv[0]),
164 &ctx->num);
165 }
diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_bf.c b/src/lib/libssl/src/crypto/evp/e_ofb_bf.c
new file mode 100644
index 0000000000..492f9b9082
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ofb_bf.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ofb_bf.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_BLOWFISH
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void bf_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void bf_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void bf_ofb_init_key();
73static void bf_ofb_cipher();
74#endif
75
76static EVP_CIPHER bfish_ofb_cipher=
77 {
78 NID_bf_ofb64,
79 1,EVP_BLOWFISH_KEY_SIZE,8,
80 bf_ofb_init_key,
81 bf_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.bf_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_bf_ofb()
90 {
91 return(&bfish_ofb_cipher);
92 }
93
94static void bf_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 BF_set_key(&(ctx->c.bf_ks),EVP_BLOWFISH_KEY_SIZE,key);
107 }
108
109static void bf_ofb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 BF_ofb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.bf_ks),
118 &(ctx->iv[0]),
119 &ctx->num);
120 }
121
122#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_c.c b/src/lib/libssl/src/crypto/evp/e_ofb_c.c
new file mode 100644
index 0000000000..f1eef4469c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ofb_c.c
@@ -0,0 +1,122 @@
1/* crypto/evp/e_ofb_c.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_CAST
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void cast_ofb_init_key();
73static void cast_ofb_cipher();
74#endif
75
76static EVP_CIPHER cast5_ofb_cipher=
77 {
78 NID_cast5_ofb64,
79 1,EVP_CAST5_KEY_SIZE,8,
80 cast_ofb_init_key,
81 cast_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_cast5_ofb()
90 {
91 return(&cast5_ofb_cipher);
92 }
93
94static void cast_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
107 }
108
109static void cast_ofb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 CAST_ofb64_encrypt(
116 in,out,
117 (long)inl, &(ctx->c.cast_ks),
118 &(ctx->iv[0]),
119 &ctx->num);
120 }
121
122#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_d.c b/src/lib/libssl/src/crypto/evp/e_ofb_d.c
new file mode 100644
index 0000000000..09d4b4139d
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ofb_d.c
@@ -0,0 +1,118 @@
1/* crypto/evp/e_ofb_d.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64#ifndef NOPROTO
65static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
66 unsigned char *iv,int enc);
67static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
68 unsigned char *in, unsigned int inl);
69#else
70static void des_ofb_init_key();
71static void des_ofb_cipher();
72#endif
73
74static EVP_CIPHER d_ofb_cipher=
75 {
76 NID_des_ofb64,
77 1,8,8,
78 des_ofb_init_key,
79 des_ofb_cipher,
80 NULL,
81 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
82 sizeof((((EVP_CIPHER_CTX *)NULL)->c.des_ks)),
83 EVP_CIPHER_set_asn1_iv,
84 EVP_CIPHER_get_asn1_iv,
85 };
86
87EVP_CIPHER *EVP_des_ofb()
88 {
89 return(&d_ofb_cipher);
90 }
91
92static void des_ofb_init_key(ctx,key,iv,enc)
93EVP_CIPHER_CTX *ctx;
94unsigned char *key;
95unsigned char *iv;
96int enc;
97 {
98 ctx->num=0;
99
100 if (iv != NULL)
101 memcpy(&(ctx->oiv[0]),iv,8);
102 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
103 if (key != NULL)
104 des_set_key((des_cblock *)key,ctx->c.des_ks);
105 }
106
107static void des_ofb_cipher(ctx,out,in,inl)
108EVP_CIPHER_CTX *ctx;
109unsigned char *out;
110unsigned char *in;
111unsigned int inl;
112 {
113 des_ofb64_encrypt(
114 in,out,
115 (long)inl, ctx->c.des_ks,
116 (des_cblock *)&(ctx->iv[0]),
117 &ctx->num);
118 }
diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_i.c b/src/lib/libssl/src/crypto/evp/e_ofb_i.c
new file mode 100644
index 0000000000..96c8afd9c8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ofb_i.c
@@ -0,0 +1,121 @@
1/* crypto/evp/e_ofb_i.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_IDEA
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void idea_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void idea_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void idea_ofb_init_key();
73static void idea_ofb_cipher();
74#endif
75
76static EVP_CIPHER i_ofb_cipher=
77 {
78 NID_idea_ofb64,
79 1,IDEA_KEY_LENGTH,IDEA_BLOCK,
80 idea_ofb_init_key,
81 idea_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.idea_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_idea_ofb()
90 {
91 return(&i_ofb_cipher);
92 }
93
94static void idea_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 idea_set_encrypt_key(key,&(ctx->c.idea_ks));
107 }
108
109static void idea_ofb_cipher(ctx,out,in,inl)
110EVP_CIPHER_CTX *ctx;
111unsigned char *out;
112unsigned char *in;
113unsigned int inl;
114 {
115 idea_ofb64_encrypt(
116 in,out,(long)inl,
117 &(ctx->c.idea_ks),&(ctx->iv[0]),
118 &ctx->num);
119 }
120
121#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_r2.c b/src/lib/libssl/src/crypto/evp/e_ofb_r2.c
new file mode 100644
index 0000000000..0f6d729988
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ofb_r2.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ofb_r2.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC2
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc2_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc2_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc2_ofb_init_key();
73static void rc2_ofb_cipher();
74#endif
75
76static EVP_CIPHER r2_ofb_cipher=
77 {
78 NID_rc2_ofb64,
79 1,EVP_RC2_KEY_SIZE,8,
80 rc2_ofb_init_key,
81 rc2_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc2_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc2_ofb()
90 {
91 return(&r2_ofb_cipher);
92 }
93
94static void rc2_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC2_set_key(&(ctx->c.rc2_ks),EVP_RC2_KEY_SIZE,key,
107 EVP_RC2_KEY_SIZE*8);
108 }
109
110static void rc2_ofb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC2_ofb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc2_ks),
119 &(ctx->iv[0]),
120 &ctx->num);
121 }
122
123#endif
diff --git a/src/lib/libssl/src/crypto/evp/e_ofb_r5.c b/src/lib/libssl/src/crypto/evp/e_ofb_r5.c
new file mode 100644
index 0000000000..db28d6c317
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/e_ofb_r5.c
@@ -0,0 +1,123 @@
1/* crypto/evp/e_ofb_r5.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef NO_RC5
60
61#include <stdio.h>
62#include "cryptlib.h"
63#include "evp.h"
64#include "objects.h"
65
66#ifndef NOPROTO
67static void rc5_32_12_16_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
68 unsigned char *iv,int enc);
69static void rc5_32_12_16_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
70 unsigned char *in, unsigned int inl);
71#else
72static void rc5_32_12_16_ofb_init_key();
73static void rc5_32_12_16_ofb_cipher();
74#endif
75
76static EVP_CIPHER rc5_ofb_cipher=
77 {
78 NID_rc5_ofb64,
79 1,EVP_RC5_32_12_16_KEY_SIZE,8,
80 rc5_32_12_16_ofb_init_key,
81 rc5_32_12_16_ofb_cipher,
82 NULL,
83 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
84 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc5_ks)),
85 EVP_CIPHER_set_asn1_iv,
86 EVP_CIPHER_get_asn1_iv,
87 };
88
89EVP_CIPHER *EVP_rc5_32_12_16_ofb()
90 {
91 return(&rc5_ofb_cipher);
92 }
93
94static void rc5_32_12_16_ofb_init_key(ctx,key,iv,enc)
95EVP_CIPHER_CTX *ctx;
96unsigned char *key;
97unsigned char *iv;
98int enc;
99 {
100 ctx->num=0;
101
102 if (iv != NULL)
103 memcpy(&(ctx->oiv[0]),iv,8);
104 memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
105 if (key != NULL)
106 RC5_32_set_key(&(ctx->c.rc5_ks),EVP_RC5_32_12_16_KEY_SIZE,key,
107 RC5_12_ROUNDS);
108 }
109
110static void rc5_32_12_16_ofb_cipher(ctx,out,in,inl)
111EVP_CIPHER_CTX *ctx;
112unsigned char *out;
113unsigned char *in;
114unsigned int inl;
115 {
116 RC5_32_ofb64_encrypt(
117 in,out,
118 (long)inl, &(ctx->c.rc5_ks),
119 &(ctx->iv[0]),
120 &ctx->num);
121 }
122
123#endif
diff --git a/src/lib/libssl/src/crypto/evp/evp.err b/src/lib/libssl/src/crypto/evp/evp.err
new file mode 100644
index 0000000000..cfc17437bc
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/evp.err
@@ -0,0 +1,24 @@
1/* Error codes for the EVP functions. */
2
3/* Function codes. */
4#define EVP_F_D2I_PKEY 100
5#define EVP_F_EVP_DECRYPTFINAL 101
6#define EVP_F_EVP_OPENINIT 102
7#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
8#define EVP_F_EVP_PKEY_DECRYPT 104
9#define EVP_F_EVP_PKEY_ENCRYPT 105
10#define EVP_F_EVP_PKEY_NEW 106
11#define EVP_F_EVP_SIGNFINAL 107
12#define EVP_F_EVP_VERIFYFINAL 108
13
14/* Reason codes. */
15#define EVP_R_BAD_DECRYPT 100
16#define EVP_R_DIFFERENT_KEY_TYPES 101
17#define EVP_R_IV_TOO_LARGE 102
18#define EVP_R_MISSING_PARMATERS 103
19#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
20#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
21#define EVP_R_PUBLIC_KEY_NOT_RSA 106
22#define EVP_R_UNSUPPORTED_CIPHER 107
23#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 108
24#define EVP_R_WRONG_PUBLIC_KEY_TYPE 109
diff --git a/src/lib/libssl/src/crypto/evp/pk_lib.c b/src/lib/libssl/src/crypto/evp/pk_lib.c
new file mode 100644
index 0000000000..08f9fabbae
--- /dev/null
+++ b/src/lib/libssl/src/crypto/evp/pk_lib.c
@@ -0,0 +1,82 @@
1/* crypto/evp/pk_lib.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62#include "objects.h"
63
64static LHASH *pk_md=NULL;
65
66static LHASH *pk_md=NULL;
67
68int EVP_add_pkey_md(oid,pkm,md)
69int oid;
70EVP_PKEY_METHOD *pkm;
71EVP_MD *md;
72 {
73 }
74
75EVP_add_pkey(pkm)
76EVP_PKEY_METHOD *pkm;
77 {
78 }
79
80EVP_PKEY_METHOD:q
81
82
diff --git a/src/lib/libssl/src/crypto/hmac/Makefile.ssl b/src/lib/libssl/src/crypto/hmac/Makefile.ssl
new file mode 100644
index 0000000000..7a042b7261
--- /dev/null
+++ b/src/lib/libssl/src/crypto/hmac/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/md/Makefile
3#
4
5DIR= hmac
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=hmactest.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=hmac.c
24LIBOBJ=hmac.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= hmac.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/idea/Makefile.ssl b/src/lib/libssl/src/crypto/idea/Makefile.ssl
new file mode 100644
index 0000000000..41b42ce03b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/idea/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/idea/Makefile
3#
4
5DIR= idea
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=ideatest.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c i_skey.c
24LIBOBJ=i_cbc.o i_cfb64.o i_ofb64.o i_ecb.o i_skey.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= idea.h
29HEADER= idea_lcl.h $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/lhash/Makefile.ssl b/src/lib/libssl/src/crypto/lhash/Makefile.ssl
new file mode 100644
index 0000000000..cb08547b4f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/lhash/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/lhash/Makefile
3#
4
5DIR= lhash
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=lhash.c lh_stats.c
24LIBOBJ=lhash.o lh_stats.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= lhash.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/libvms.com b/src/lib/libssl/src/crypto/libvms.com
new file mode 100644
index 0000000000..44f90c65b0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/libvms.com
@@ -0,0 +1,31 @@
1$!
2$! Compile crypto.c as several subset modules and insert in crypto-xxx.olb.
3$! If P1 is specifed, it specifies alternate list of subsets to compile.
4$!
5$ libname = "CRYPTO-AXP.OLB"
6$ subset_list = "LIB,ASN1,BN,BUFFER,CONF,DES,DH,DSA,ERROR,EVP,IDEA,LHASH,MD," + -
7 "METH,OBJECTS,PEM,RAND,RC,RSA,SHA,STACK,TXT_DB,X509"
8$ if p1 .nes. "" then subset_list = p1
9$!
10$ if f$getsyi("CPU") .lt. 128 then libname = "CRYPTO-VAX.OLB"
11$ if f$search(libname) .eqs. "" then library/create/object/log 'libname'
12$!
13$ cc = "cc/include=[-.include]/prefix=all" + P2
14$!
15$ i = 0
16$ next_subset:
17$ subset = f$element(i,",",subset_list)
18$ if subset .eqs. "," then goto done
19$ i = i + 1
20$ create crypto_'subset'.subset
21#include "crypto.c"
22$ ofile = "sys$disk:[]crypto_" + subset + ".obj"
23$ on warning then goto next_subset
24$ write sys$output "Compiling ", ofile
25$ cc /object='ofile' crypto_'subset'.subset -
26 /define=(CRYPTO_SUBSET,CRYPTO_'subset'_SUBSET)
27$ library/replace/log 'libname'/module=CRYPTO_'subset' 'ofile'
28$ goto next_subset
29$!
30$ done:
31$ exit
diff --git a/src/lib/libssl/src/crypto/md2/Makefile.ssl b/src/lib/libssl/src/crypto/md2/Makefile.ssl
new file mode 100644
index 0000000000..d8e7200c83
--- /dev/null
+++ b/src/lib/libssl/src/crypto/md2/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/md/Makefile
3#
4
5DIR= md
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=md2test.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=md2_dgst.c md5_one.c
24LIBOBJ=md2_dgst.o md2_one.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= md2.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/md2/md2.org b/src/lib/libssl/src/crypto/md2/md2.org
new file mode 100644
index 0000000000..9f39933790
--- /dev/null
+++ b/src/lib/libssl/src/crypto/md2/md2.org
@@ -0,0 +1,106 @@
1/* crypto/md/md2.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify md2.org since md2.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67
68#ifndef HEADER_MD2_H
69#define HEADER_MD2_H
70
71#ifdef __cplusplus
72extern "C" {
73#endif
74
75#define MD2_DIGEST_LENGTH 16
76#define MD2_BLOCK 16
77
78#define MD2_INT unsigned int
79
80typedef struct MD2state_st
81 {
82 int num;
83 unsigned char data[MD2_BLOCK];
84 MD2_INT cksm[MD2_BLOCK];
85 MD2_INT state[MD2_BLOCK];
86 } MD2_CTX;
87
88#ifndef NOPROTO
89char *MD2_options(void);
90void MD2_Init(MD2_CTX *c);
91void MD2_Update(MD2_CTX *c, register unsigned char *data, unsigned long len);
92void MD2_Final(unsigned char *md, MD2_CTX *c);
93unsigned char *MD2(unsigned char *d, unsigned long n,unsigned char *md);
94#else
95char *MD2_options();
96void MD2_Init();
97void MD2_Update();
98void MD2_Final();
99unsigned char *MD2();
100#endif
101
102#ifdef __cplusplus
103}
104#endif
105
106#endif
diff --git a/src/lib/libssl/src/crypto/md5/Makefile.ssl b/src/lib/libssl/src/crypto/md5/Makefile.ssl
new file mode 100644
index 0000000000..47e1ce05ca
--- /dev/null
+++ b/src/lib/libssl/src/crypto/md5/Makefile.ssl
@@ -0,0 +1,104 @@
1#
2# SSLeay/crypto/md5/Makefile
3#
4
5DIR= md5
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17MD5_ASM_OBJ=
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=md5test.c
23APPS=md5.c
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=md5_dgst.c md5_one.c
27LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
28
29SRC= $(LIBSRC)
30
31EXHEADER= md5.h
32HEADER= md5_locl.h $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 sh $(TOP)/util/ranlib.sh $(LIB)
44 @touch lib
45
46# elf
47asm/mx86-elf.o: asm/mx86unix.cpp
48 $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o
49
50# solaris
51asm/mx86-sol.o: asm/mx86unix.cpp
52 $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s
53 as -o asm/mx86-sol.o asm/mx86-sol.s
54 rm -f asm/mx86-sol.s
55
56# a.out
57asm/mx86-out.o: asm/mx86unix.cpp
58 $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o
59
60# bsdi
61asm/mx86bsdi.o: asm/mx86unix.cpp
62 $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o
63
64asm/mx86unix.cpp:
65 (cd asm; perl md5-586.pl cpp >mx86unix.cpp)
66
67files:
68 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
69
70links:
71 /bin/rm -f Makefile
72 $(TOP)/util/point.sh Makefile.ssl Makefile ;
73 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
74 $(TOP)/util/mklink.sh ../../test $(TEST)
75 $(TOP)/util/mklink.sh ../../apps $(APPS)
76
77install:
78 @for i in $(EXHEADER) ; \
79 do \
80 (cp $$i $(INSTALLTOP)/include/$$i; \
81 chmod 644 $(INSTALLTOP)/include/$$i ); \
82 done;
83
84tags:
85 ctags $(SRC)
86
87tests:
88
89lint:
90 lint -DLINT $(INCLUDES) $(SRC)>fluff
91
92depend:
93 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
94
95dclean:
96 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
97 mv -f Makefile.new $(MAKEFILE)
98
99clean:
100 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
101
102errors:
103
104# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/md5/Makefile.uni b/src/lib/libssl/src/crypto/md5/Makefile.uni
new file mode 100644
index 0000000000..54685712db
--- /dev/null
+++ b/src/lib/libssl/src/crypto/md5/Makefile.uni
@@ -0,0 +1,109 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= md5
11TOP= .
12CC= gcc
13CFLAG= -O3 -fomit-frame-pointer
14
15CPP= $(CC) -E
16INCLUDES=
17INSTALLTOP=/usr/local/lib
18MAKE= make
19MAKEDEPEND= makedepend
20MAKEFILE= Makefile.uni
21AR= ar r
22
23MD5_ASM_OBJ=
24
25CFLAGS= $(INCLUDES) $(CFLAG)
26
27GENERAL=Makefile
28TEST=md5test
29APPS=md5
30
31LIB=libmd5.a
32LIBSRC=md5_dgst.c md5_one.c
33LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
34
35SRC= $(LIBSRC)
36
37EXHEADER= md5.h
38HEADER= md5_locl.h $(EXHEADER)
39
40ALL= $(GENERAL) $(SRC) $(HEADER)
41
42all: $(LIB) $(TEST) $(APPS)
43
44$(LIB): $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 sh $(TOP)/ranlib.sh $(LIB)
47
48# elf
49asm/mx86-elf.o: asm/mx86unix.cpp
50 $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o
51
52# solaris
53asm/mx86-sol.o: asm/mx86unix.cpp
54 $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s
55 as -o asm/mx86-sol.o asm/mx86-sol.s
56 rm -f asm/mx86-sol.s
57
58# a.out
59asm/mx86-out.o: asm/mx86unix.cpp
60 $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o
61
62# bsdi
63asm/mx86bsdi.o: asm/mx86unix.cpp
64 $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o
65
66asm/mx86unix.cpp:
67 (cd asm; perl md5-586.pl cpp >mx86unix.cpp)
68
69test: $(TEST)
70 ./$(TEST)
71
72$(TEST): $(TEST).c $(LIB)
73 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
74
75$(APPS): $(APPS).c $(LIB)
76 $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
77
78lint:
79 lint -DLINT $(INCLUDES) $(SRC)>fluff
80
81depend:
82 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
83
84dclean:
85 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
86 mv -f Makefile.new $(MAKEFILE)
87
88clean:
89 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
90
91cc:
92 $(MAKE) MD5_ASM_OBJ="" CC="cc" CFLAG="-O" all
93
94gcc:
95 $(MAKE) MD5_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
96
97x86-elf:
98 $(MAKE) MD5_ASM_OBJ="asm/mx86-elf.o" CFLAG="-DELF -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
99
100x86-out:
101 $(MAKE) MD5_ASM_OBJ="asm/mx86-out.o" CFLAG="-DOUT -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
102
103x86-solaris:
104 $(MAKE) MD5_ASM_OBJ="asm/mx86-sol.o" CFLAG="-DSOL -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
105
106x86-bdsi:
107 $(MAKE) MD5_ASM_OBJ="asm/mx86-bdsi.o" CFLAG="-DBDSI -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
108
109# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/md5/asm/m5-win32.asm b/src/lib/libssl/src/crypto/md5/asm/m5-win32.asm
new file mode 100644
index 0000000000..c2081da746
--- /dev/null
+++ b/src/lib/libssl/src/crypto/md5/asm/m5-win32.asm
@@ -0,0 +1,686 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by md5-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE md5-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _md5_block_x86
12
13_md5_block_x86 PROC NEAR
14 push esi
15 push edi
16 mov edi, DWORD PTR 12[esp]
17 mov esi, DWORD PTR 16[esp]
18 mov ecx, DWORD PTR 20[esp]
19 push ebp
20 push ebx
21 add ecx, esi
22 sub ecx, 64
23 mov eax, DWORD PTR [edi]
24 push ecx
25 mov ebx, DWORD PTR 4[edi]
26 mov ecx, DWORD PTR 8[edi]
27 mov edx, DWORD PTR 12[edi]
28L000start:
29 ;
30 ; R0 section
31 mov edi, ecx
32 mov ebp, DWORD PTR [esi]
33 ; R0 0
34 xor edi, edx
35 and edi, ebx
36 lea eax, DWORD PTR 3614090360[ebp*1+eax]
37 mov ebp, DWORD PTR 4[esi]
38 xor edi, edx
39 add eax, edi
40 mov edi, ebx
41 rol eax, 7
42 add eax, ebx
43 ; R0 1
44 xor edi, ecx
45 and edi, eax
46 lea edx, DWORD PTR 3905402710[ebp*1+edx]
47 mov ebp, DWORD PTR 8[esi]
48 xor edi, ecx
49 add edx, edi
50 mov edi, eax
51 rol edx, 12
52 add edx, eax
53 ; R0 2
54 xor edi, ebx
55 and edi, edx
56 lea ecx, DWORD PTR 606105819[ebp*1+ecx]
57 mov ebp, DWORD PTR 12[esi]
58 xor edi, ebx
59 add ecx, edi
60 mov edi, edx
61 rol ecx, 17
62 add ecx, edx
63 ; R0 3
64 xor edi, eax
65 and edi, ecx
66 lea ebx, DWORD PTR 3250441966[ebp*1+ebx]
67 mov ebp, DWORD PTR 16[esi]
68 xor edi, eax
69 add ebx, edi
70 mov edi, ecx
71 rol ebx, 22
72 add ebx, ecx
73 ; R0 4
74 xor edi, edx
75 and edi, ebx
76 lea eax, DWORD PTR 4118548399[ebp*1+eax]
77 mov ebp, DWORD PTR 20[esi]
78 xor edi, edx
79 add eax, edi
80 mov edi, ebx
81 rol eax, 7
82 add eax, ebx
83 ; R0 5
84 xor edi, ecx
85 and edi, eax
86 lea edx, DWORD PTR 1200080426[ebp*1+edx]
87 mov ebp, DWORD PTR 24[esi]
88 xor edi, ecx
89 add edx, edi
90 mov edi, eax
91 rol edx, 12
92 add edx, eax
93 ; R0 6
94 xor edi, ebx
95 and edi, edx
96 lea ecx, DWORD PTR 2821735955[ebp*1+ecx]
97 mov ebp, DWORD PTR 28[esi]
98 xor edi, ebx
99 add ecx, edi
100 mov edi, edx
101 rol ecx, 17
102 add ecx, edx
103 ; R0 7
104 xor edi, eax
105 and edi, ecx
106 lea ebx, DWORD PTR 4249261313[ebp*1+ebx]
107 mov ebp, DWORD PTR 32[esi]
108 xor edi, eax
109 add ebx, edi
110 mov edi, ecx
111 rol ebx, 22
112 add ebx, ecx
113 ; R0 8
114 xor edi, edx
115 and edi, ebx
116 lea eax, DWORD PTR 1770035416[ebp*1+eax]
117 mov ebp, DWORD PTR 36[esi]
118 xor edi, edx
119 add eax, edi
120 mov edi, ebx
121 rol eax, 7
122 add eax, ebx
123 ; R0 9
124 xor edi, ecx
125 and edi, eax
126 lea edx, DWORD PTR 2336552879[ebp*1+edx]
127 mov ebp, DWORD PTR 40[esi]
128 xor edi, ecx
129 add edx, edi
130 mov edi, eax
131 rol edx, 12
132 add edx, eax
133 ; R0 10
134 xor edi, ebx
135 and edi, edx
136 lea ecx, DWORD PTR 4294925233[ebp*1+ecx]
137 mov ebp, DWORD PTR 44[esi]
138 xor edi, ebx
139 add ecx, edi
140 mov edi, edx
141 rol ecx, 17
142 add ecx, edx
143 ; R0 11
144 xor edi, eax
145 and edi, ecx
146 lea ebx, DWORD PTR 2304563134[ebp*1+ebx]
147 mov ebp, DWORD PTR 48[esi]
148 xor edi, eax
149 add ebx, edi
150 mov edi, ecx
151 rol ebx, 22
152 add ebx, ecx
153 ; R0 12
154 xor edi, edx
155 and edi, ebx
156 lea eax, DWORD PTR 1804603682[ebp*1+eax]
157 mov ebp, DWORD PTR 52[esi]
158 xor edi, edx
159 add eax, edi
160 mov edi, ebx
161 rol eax, 7
162 add eax, ebx
163 ; R0 13
164 xor edi, ecx
165 and edi, eax
166 lea edx, DWORD PTR 4254626195[ebp*1+edx]
167 mov ebp, DWORD PTR 56[esi]
168 xor edi, ecx
169 add edx, edi
170 mov edi, eax
171 rol edx, 12
172 add edx, eax
173 ; R0 14
174 xor edi, ebx
175 and edi, edx
176 lea ecx, DWORD PTR 2792965006[ebp*1+ecx]
177 mov ebp, DWORD PTR 60[esi]
178 xor edi, ebx
179 add ecx, edi
180 mov edi, edx
181 rol ecx, 17
182 add ecx, edx
183 ; R0 15
184 xor edi, eax
185 and edi, ecx
186 lea ebx, DWORD PTR 1236535329[ebp*1+ebx]
187 mov ebp, DWORD PTR 4[esi]
188 xor edi, eax
189 add ebx, edi
190 mov edi, ecx
191 rol ebx, 22
192 add ebx, ecx
193 ;
194 ; R1 section
195 ; R1 16
196 lea eax, DWORD PTR 4129170786[ebp*1+eax]
197 xor edi, ebx
198 and edi, edx
199 mov ebp, DWORD PTR 24[esi]
200 xor edi, ecx
201 add eax, edi
202 mov edi, ebx
203 rol eax, 5
204 add eax, ebx
205 ; R1 17
206 lea edx, DWORD PTR 3225465664[ebp*1+edx]
207 xor edi, eax
208 and edi, ecx
209 mov ebp, DWORD PTR 44[esi]
210 xor edi, ebx
211 add edx, edi
212 mov edi, eax
213 rol edx, 9
214 add edx, eax
215 ; R1 18
216 lea ecx, DWORD PTR 643717713[ebp*1+ecx]
217 xor edi, edx
218 and edi, ebx
219 mov ebp, DWORD PTR [esi]
220 xor edi, eax
221 add ecx, edi
222 mov edi, edx
223 rol ecx, 14
224 add ecx, edx
225 ; R1 19
226 lea ebx, DWORD PTR 3921069994[ebp*1+ebx]
227 xor edi, ecx
228 and edi, eax
229 mov ebp, DWORD PTR 20[esi]
230 xor edi, edx
231 add ebx, edi
232 mov edi, ecx
233 rol ebx, 20
234 add ebx, ecx
235 ; R1 20
236 lea eax, DWORD PTR 3593408605[ebp*1+eax]
237 xor edi, ebx
238 and edi, edx
239 mov ebp, DWORD PTR 40[esi]
240 xor edi, ecx
241 add eax, edi
242 mov edi, ebx
243 rol eax, 5
244 add eax, ebx
245 ; R1 21
246 lea edx, DWORD PTR 38016083[ebp*1+edx]
247 xor edi, eax
248 and edi, ecx
249 mov ebp, DWORD PTR 60[esi]
250 xor edi, ebx
251 add edx, edi
252 mov edi, eax
253 rol edx, 9
254 add edx, eax
255 ; R1 22
256 lea ecx, DWORD PTR 3634488961[ebp*1+ecx]
257 xor edi, edx
258 and edi, ebx
259 mov ebp, DWORD PTR 16[esi]
260 xor edi, eax
261 add ecx, edi
262 mov edi, edx
263 rol ecx, 14
264 add ecx, edx
265 ; R1 23
266 lea ebx, DWORD PTR 3889429448[ebp*1+ebx]
267 xor edi, ecx
268 and edi, eax
269 mov ebp, DWORD PTR 36[esi]
270 xor edi, edx
271 add ebx, edi
272 mov edi, ecx
273 rol ebx, 20
274 add ebx, ecx
275 ; R1 24
276 lea eax, DWORD PTR 568446438[ebp*1+eax]
277 xor edi, ebx
278 and edi, edx
279 mov ebp, DWORD PTR 56[esi]
280 xor edi, ecx
281 add eax, edi
282 mov edi, ebx
283 rol eax, 5
284 add eax, ebx
285 ; R1 25
286 lea edx, DWORD PTR 3275163606[ebp*1+edx]
287 xor edi, eax
288 and edi, ecx
289 mov ebp, DWORD PTR 12[esi]
290 xor edi, ebx
291 add edx, edi
292 mov edi, eax
293 rol edx, 9
294 add edx, eax
295 ; R1 26
296 lea ecx, DWORD PTR 4107603335[ebp*1+ecx]
297 xor edi, edx
298 and edi, ebx
299 mov ebp, DWORD PTR 32[esi]
300 xor edi, eax
301 add ecx, edi
302 mov edi, edx
303 rol ecx, 14
304 add ecx, edx
305 ; R1 27
306 lea ebx, DWORD PTR 1163531501[ebp*1+ebx]
307 xor edi, ecx
308 and edi, eax
309 mov ebp, DWORD PTR 52[esi]
310 xor edi, edx
311 add ebx, edi
312 mov edi, ecx
313 rol ebx, 20
314 add ebx, ecx
315 ; R1 28
316 lea eax, DWORD PTR 2850285829[ebp*1+eax]
317 xor edi, ebx
318 and edi, edx
319 mov ebp, DWORD PTR 8[esi]
320 xor edi, ecx
321 add eax, edi
322 mov edi, ebx
323 rol eax, 5
324 add eax, ebx
325 ; R1 29
326 lea edx, DWORD PTR 4243563512[ebp*1+edx]
327 xor edi, eax
328 and edi, ecx
329 mov ebp, DWORD PTR 28[esi]
330 xor edi, ebx
331 add edx, edi
332 mov edi, eax
333 rol edx, 9
334 add edx, eax
335 ; R1 30
336 lea ecx, DWORD PTR 1735328473[ebp*1+ecx]
337 xor edi, edx
338 and edi, ebx
339 mov ebp, DWORD PTR 48[esi]
340 xor edi, eax
341 add ecx, edi
342 mov edi, edx
343 rol ecx, 14
344 add ecx, edx
345 ; R1 31
346 lea ebx, DWORD PTR 2368359562[ebp*1+ebx]
347 xor edi, ecx
348 and edi, eax
349 mov ebp, DWORD PTR 20[esi]
350 xor edi, edx
351 add ebx, edi
352 mov edi, ecx
353 rol ebx, 20
354 add ebx, ecx
355 ;
356 ; R2 section
357 ; R2 32
358 xor edi, edx
359 xor edi, ebx
360 lea eax, DWORD PTR 4294588738[ebp*1+eax]
361 add eax, edi
362 mov ebp, DWORD PTR 32[esi]
363 rol eax, 4
364 mov edi, ebx
365 ; R2 33
366 lea edx, DWORD PTR 2272392833[ebp*1+edx]
367 add eax, ebx
368 xor edi, ecx
369 xor edi, eax
370 mov ebp, DWORD PTR 44[esi]
371 add edx, edi
372 mov edi, eax
373 rol edx, 11
374 add edx, eax
375 ; R2 34
376 xor edi, ebx
377 xor edi, edx
378 lea ecx, DWORD PTR 1839030562[ebp*1+ecx]
379 add ecx, edi
380 mov ebp, DWORD PTR 56[esi]
381 rol ecx, 16
382 mov edi, edx
383 ; R2 35
384 lea ebx, DWORD PTR 4259657740[ebp*1+ebx]
385 add ecx, edx
386 xor edi, eax
387 xor edi, ecx
388 mov ebp, DWORD PTR 4[esi]
389 add ebx, edi
390 mov edi, ecx
391 rol ebx, 23
392 add ebx, ecx
393 ; R2 36
394 xor edi, edx
395 xor edi, ebx
396 lea eax, DWORD PTR 2763975236[ebp*1+eax]
397 add eax, edi
398 mov ebp, DWORD PTR 16[esi]
399 rol eax, 4
400 mov edi, ebx
401 ; R2 37
402 lea edx, DWORD PTR 1272893353[ebp*1+edx]
403 add eax, ebx
404 xor edi, ecx
405 xor edi, eax
406 mov ebp, DWORD PTR 28[esi]
407 add edx, edi
408 mov edi, eax
409 rol edx, 11
410 add edx, eax
411 ; R2 38
412 xor edi, ebx
413 xor edi, edx
414 lea ecx, DWORD PTR 4139469664[ebp*1+ecx]
415 add ecx, edi
416 mov ebp, DWORD PTR 40[esi]
417 rol ecx, 16
418 mov edi, edx
419 ; R2 39
420 lea ebx, DWORD PTR 3200236656[ebp*1+ebx]
421 add ecx, edx
422 xor edi, eax
423 xor edi, ecx
424 mov ebp, DWORD PTR 52[esi]
425 add ebx, edi
426 mov edi, ecx
427 rol ebx, 23
428 add ebx, ecx
429 ; R2 40
430 xor edi, edx
431 xor edi, ebx
432 lea eax, DWORD PTR 681279174[ebp*1+eax]
433 add eax, edi
434 mov ebp, DWORD PTR [esi]
435 rol eax, 4
436 mov edi, ebx
437 ; R2 41
438 lea edx, DWORD PTR 3936430074[ebp*1+edx]
439 add eax, ebx
440 xor edi, ecx
441 xor edi, eax
442 mov ebp, DWORD PTR 12[esi]
443 add edx, edi
444 mov edi, eax
445 rol edx, 11
446 add edx, eax
447 ; R2 42
448 xor edi, ebx
449 xor edi, edx
450 lea ecx, DWORD PTR 3572445317[ebp*1+ecx]
451 add ecx, edi
452 mov ebp, DWORD PTR 24[esi]
453 rol ecx, 16
454 mov edi, edx
455 ; R2 43
456 lea ebx, DWORD PTR 76029189[ebp*1+ebx]
457 add ecx, edx
458 xor edi, eax
459 xor edi, ecx
460 mov ebp, DWORD PTR 36[esi]
461 add ebx, edi
462 mov edi, ecx
463 rol ebx, 23
464 add ebx, ecx
465 ; R2 44
466 xor edi, edx
467 xor edi, ebx
468 lea eax, DWORD PTR 3654602809[ebp*1+eax]
469 add eax, edi
470 mov ebp, DWORD PTR 48[esi]
471 rol eax, 4
472 mov edi, ebx
473 ; R2 45
474 lea edx, DWORD PTR 3873151461[ebp*1+edx]
475 add eax, ebx
476 xor edi, ecx
477 xor edi, eax
478 mov ebp, DWORD PTR 60[esi]
479 add edx, edi
480 mov edi, eax
481 rol edx, 11
482 add edx, eax
483 ; R2 46
484 xor edi, ebx
485 xor edi, edx
486 lea ecx, DWORD PTR 530742520[ebp*1+ecx]
487 add ecx, edi
488 mov ebp, DWORD PTR 8[esi]
489 rol ecx, 16
490 mov edi, edx
491 ; R2 47
492 lea ebx, DWORD PTR 3299628645[ebp*1+ebx]
493 add ecx, edx
494 xor edi, eax
495 xor edi, ecx
496 mov ebp, DWORD PTR [esi]
497 add ebx, edi
498 mov edi, -1
499 rol ebx, 23
500 add ebx, ecx
501 ;
502 ; R3 section
503 ; R3 48
504 xor edi, edx
505 or edi, ebx
506 lea eax, DWORD PTR 4096336452[ebp*1+eax]
507 xor edi, ecx
508 mov ebp, DWORD PTR 28[esi]
509 add eax, edi
510 mov edi, -1
511 rol eax, 6
512 xor edi, ecx
513 add eax, ebx
514 ; R3 49
515 or edi, eax
516 lea edx, DWORD PTR 1126891415[ebp*1+edx]
517 xor edi, ebx
518 mov ebp, DWORD PTR 56[esi]
519 add edx, edi
520 mov edi, -1
521 rol edx, 10
522 xor edi, ebx
523 add edx, eax
524 ; R3 50
525 or edi, edx
526 lea ecx, DWORD PTR 2878612391[ebp*1+ecx]
527 xor edi, eax
528 mov ebp, DWORD PTR 20[esi]
529 add ecx, edi
530 mov edi, -1
531 rol ecx, 15
532 xor edi, eax
533 add ecx, edx
534 ; R3 51
535 or edi, ecx
536 lea ebx, DWORD PTR 4237533241[ebp*1+ebx]
537 xor edi, edx
538 mov ebp, DWORD PTR 48[esi]
539 add ebx, edi
540 mov edi, -1
541 rol ebx, 21
542 xor edi, edx
543 add ebx, ecx
544 ; R3 52
545 or edi, ebx
546 lea eax, DWORD PTR 1700485571[ebp*1+eax]
547 xor edi, ecx
548 mov ebp, DWORD PTR 12[esi]
549 add eax, edi
550 mov edi, -1
551 rol eax, 6
552 xor edi, ecx
553 add eax, ebx
554 ; R3 53
555 or edi, eax
556 lea edx, DWORD PTR 2399980690[ebp*1+edx]
557 xor edi, ebx
558 mov ebp, DWORD PTR 40[esi]
559 add edx, edi
560 mov edi, -1
561 rol edx, 10
562 xor edi, ebx
563 add edx, eax
564 ; R3 54
565 or edi, edx
566 lea ecx, DWORD PTR 4293915773[ebp*1+ecx]
567 xor edi, eax
568 mov ebp, DWORD PTR 4[esi]
569 add ecx, edi
570 mov edi, -1
571 rol ecx, 15
572 xor edi, eax
573 add ecx, edx
574 ; R3 55
575 or edi, ecx
576 lea ebx, DWORD PTR 2240044497[ebp*1+ebx]
577 xor edi, edx
578 mov ebp, DWORD PTR 32[esi]
579 add ebx, edi
580 mov edi, -1
581 rol ebx, 21
582 xor edi, edx
583 add ebx, ecx
584 ; R3 56
585 or edi, ebx
586 lea eax, DWORD PTR 1873313359[ebp*1+eax]
587 xor edi, ecx
588 mov ebp, DWORD PTR 60[esi]
589 add eax, edi
590 mov edi, -1
591 rol eax, 6
592 xor edi, ecx
593 add eax, ebx
594 ; R3 57
595 or edi, eax
596 lea edx, DWORD PTR 4264355552[ebp*1+edx]
597 xor edi, ebx
598 mov ebp, DWORD PTR 24[esi]
599 add edx, edi
600 mov edi, -1
601 rol edx, 10
602 xor edi, ebx
603 add edx, eax
604 ; R3 58
605 or edi, edx
606 lea ecx, DWORD PTR 2734768916[ebp*1+ecx]
607 xor edi, eax
608 mov ebp, DWORD PTR 52[esi]
609 add ecx, edi
610 mov edi, -1
611 rol ecx, 15
612 xor edi, eax
613 add ecx, edx
614 ; R3 59
615 or edi, ecx
616 lea ebx, DWORD PTR 1309151649[ebp*1+ebx]
617 xor edi, edx
618 mov ebp, DWORD PTR 16[esi]
619 add ebx, edi
620 mov edi, -1
621 rol ebx, 21
622 xor edi, edx
623 add ebx, ecx
624 ; R3 60
625 or edi, ebx
626 lea eax, DWORD PTR 4149444226[ebp*1+eax]
627 xor edi, ecx
628 mov ebp, DWORD PTR 44[esi]
629 add eax, edi
630 mov edi, -1
631 rol eax, 6
632 xor edi, ecx
633 add eax, ebx
634 ; R3 61
635 or edi, eax
636 lea edx, DWORD PTR 3174756917[ebp*1+edx]
637 xor edi, ebx
638 mov ebp, DWORD PTR 8[esi]
639 add edx, edi
640 mov edi, -1
641 rol edx, 10
642 xor edi, ebx
643 add edx, eax
644 ; R3 62
645 or edi, edx
646 lea ecx, DWORD PTR 718787259[ebp*1+ecx]
647 xor edi, eax
648 mov ebp, DWORD PTR 36[esi]
649 add ecx, edi
650 mov edi, -1
651 rol ecx, 15
652 xor edi, eax
653 add ecx, edx
654 ; R3 63
655 or edi, ecx
656 lea ebx, DWORD PTR 3951481745[ebp*1+ebx]
657 xor edi, edx
658 mov ebp, DWORD PTR 24[esp]
659 add ebx, edi
660 add esi, 64
661 rol ebx, 21
662 mov edi, DWORD PTR [ebp]
663 add ebx, ecx
664 add eax, edi
665 mov edi, DWORD PTR 4[ebp]
666 add ebx, edi
667 mov edi, DWORD PTR 8[ebp]
668 add ecx, edi
669 mov edi, DWORD PTR 12[ebp]
670 add edx, edi
671 mov DWORD PTR [ebp],eax
672 mov DWORD PTR 4[ebp],ebx
673 mov edi, DWORD PTR [esp]
674 mov DWORD PTR 8[ebp],ecx
675 mov DWORD PTR 12[ebp],edx
676 cmp edi, esi
677 jge L000start
678 pop eax
679 pop ebx
680 pop ebp
681 pop edi
682 pop esi
683 ret
684_md5_block_x86 ENDP
685_TEXT ENDS
686END
diff --git a/src/lib/libssl/src/crypto/md5/asm/mx86unix.cpp b/src/lib/libssl/src/crypto/md5/asm/mx86unix.cpp
new file mode 100644
index 0000000000..5d399122b6
--- /dev/null
+++ b/src/lib/libssl/src/crypto/md5/asm/mx86unix.cpp
@@ -0,0 +1,730 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define md5_block_x86 _md5_block_x86
13
14#endif
15
16#ifdef OUT
17#define OK 1
18#define ALIGN 4
19#endif
20
21#ifdef BSDI
22#define OK 1
23#define ALIGN 4
24#undef SIZE
25#undef TYPE
26#define SIZE(a,b)
27#define TYPE(a,b)
28#endif
29
30#if defined(ELF) || defined(SOL)
31#define OK 1
32#define ALIGN 16
33#endif
34
35#ifndef OK
36You need to define one of
37ELF - elf systems - linux-elf, NetBSD and DG-UX
38OUT - a.out systems - linux-a.out and FreeBSD
39SOL - solaris systems, which are elf with strange comment lines
40BSDI - a.out with a very primative version of as.
41#endif
42
43/* Let the Assembler begin :-) */
44 /* Don't even think of reading this code */
45 /* It was automatically generated by md5-586.pl */
46 /* Which is a perl program used to generate the x86 assember for */
47 /* any of elf, a.out, BSDI,Win32, or Solaris */
48 /* eric <eay@cryptsoft.com> */
49
50 .file "md5-586.s"
51 .version "01.01"
52gcc2_compiled.:
53.text
54 .align ALIGN
55.globl md5_block_x86
56 TYPE(md5_block_x86,@function)
57md5_block_x86:
58 pushl %esi
59 pushl %edi
60 movl 12(%esp), %edi
61 movl 16(%esp), %esi
62 movl 20(%esp), %ecx
63 pushl %ebp
64 pushl %ebx
65 addl %esi, %ecx
66 subl $64, %ecx
67 movl (%edi), %eax
68 pushl %ecx
69 movl 4(%edi), %ebx
70 movl 8(%edi), %ecx
71 movl 12(%edi), %edx
72.L000start:
73
74 /* R0 section */
75 movl %ecx, %edi
76 movl (%esi), %ebp
77 /* R0 0 */
78 xorl %edx, %edi
79 andl %ebx, %edi
80 leal 3614090360(%eax,%ebp,1),%eax
81 movl 4(%esi), %ebp
82 xorl %edx, %edi
83 addl %edi, %eax
84 movl %ebx, %edi
85 roll $7, %eax
86 addl %ebx, %eax
87 /* R0 1 */
88 xorl %ecx, %edi
89 andl %eax, %edi
90 leal 3905402710(%edx,%ebp,1),%edx
91 movl 8(%esi), %ebp
92 xorl %ecx, %edi
93 addl %edi, %edx
94 movl %eax, %edi
95 roll $12, %edx
96 addl %eax, %edx
97 /* R0 2 */
98 xorl %ebx, %edi
99 andl %edx, %edi
100 leal 606105819(%ecx,%ebp,1),%ecx
101 movl 12(%esi), %ebp
102 xorl %ebx, %edi
103 addl %edi, %ecx
104 movl %edx, %edi
105 roll $17, %ecx
106 addl %edx, %ecx
107 /* R0 3 */
108 xorl %eax, %edi
109 andl %ecx, %edi
110 leal 3250441966(%ebx,%ebp,1),%ebx
111 movl 16(%esi), %ebp
112 xorl %eax, %edi
113 addl %edi, %ebx
114 movl %ecx, %edi
115 roll $22, %ebx
116 addl %ecx, %ebx
117 /* R0 4 */
118 xorl %edx, %edi
119 andl %ebx, %edi
120 leal 4118548399(%eax,%ebp,1),%eax
121 movl 20(%esi), %ebp
122 xorl %edx, %edi
123 addl %edi, %eax
124 movl %ebx, %edi
125 roll $7, %eax
126 addl %ebx, %eax
127 /* R0 5 */
128 xorl %ecx, %edi
129 andl %eax, %edi
130 leal 1200080426(%edx,%ebp,1),%edx
131 movl 24(%esi), %ebp
132 xorl %ecx, %edi
133 addl %edi, %edx
134 movl %eax, %edi
135 roll $12, %edx
136 addl %eax, %edx
137 /* R0 6 */
138 xorl %ebx, %edi
139 andl %edx, %edi
140 leal 2821735955(%ecx,%ebp,1),%ecx
141 movl 28(%esi), %ebp
142 xorl %ebx, %edi
143 addl %edi, %ecx
144 movl %edx, %edi
145 roll $17, %ecx
146 addl %edx, %ecx
147 /* R0 7 */
148 xorl %eax, %edi
149 andl %ecx, %edi
150 leal 4249261313(%ebx,%ebp,1),%ebx
151 movl 32(%esi), %ebp
152 xorl %eax, %edi
153 addl %edi, %ebx
154 movl %ecx, %edi
155 roll $22, %ebx
156 addl %ecx, %ebx
157 /* R0 8 */
158 xorl %edx, %edi
159 andl %ebx, %edi
160 leal 1770035416(%eax,%ebp,1),%eax
161 movl 36(%esi), %ebp
162 xorl %edx, %edi
163 addl %edi, %eax
164 movl %ebx, %edi
165 roll $7, %eax
166 addl %ebx, %eax
167 /* R0 9 */
168 xorl %ecx, %edi
169 andl %eax, %edi
170 leal 2336552879(%edx,%ebp,1),%edx
171 movl 40(%esi), %ebp
172 xorl %ecx, %edi
173 addl %edi, %edx
174 movl %eax, %edi
175 roll $12, %edx
176 addl %eax, %edx
177 /* R0 10 */
178 xorl %ebx, %edi
179 andl %edx, %edi
180 leal 4294925233(%ecx,%ebp,1),%ecx
181 movl 44(%esi), %ebp
182 xorl %ebx, %edi
183 addl %edi, %ecx
184 movl %edx, %edi
185 roll $17, %ecx
186 addl %edx, %ecx
187 /* R0 11 */
188 xorl %eax, %edi
189 andl %ecx, %edi
190 leal 2304563134(%ebx,%ebp,1),%ebx
191 movl 48(%esi), %ebp
192 xorl %eax, %edi
193 addl %edi, %ebx
194 movl %ecx, %edi
195 roll $22, %ebx
196 addl %ecx, %ebx
197 /* R0 12 */
198 xorl %edx, %edi
199 andl %ebx, %edi
200 leal 1804603682(%eax,%ebp,1),%eax
201 movl 52(%esi), %ebp
202 xorl %edx, %edi
203 addl %edi, %eax
204 movl %ebx, %edi
205 roll $7, %eax
206 addl %ebx, %eax
207 /* R0 13 */
208 xorl %ecx, %edi
209 andl %eax, %edi
210 leal 4254626195(%edx,%ebp,1),%edx
211 movl 56(%esi), %ebp
212 xorl %ecx, %edi
213 addl %edi, %edx
214 movl %eax, %edi
215 roll $12, %edx
216 addl %eax, %edx
217 /* R0 14 */
218 xorl %ebx, %edi
219 andl %edx, %edi
220 leal 2792965006(%ecx,%ebp,1),%ecx
221 movl 60(%esi), %ebp
222 xorl %ebx, %edi
223 addl %edi, %ecx
224 movl %edx, %edi
225 roll $17, %ecx
226 addl %edx, %ecx
227 /* R0 15 */
228 xorl %eax, %edi
229 andl %ecx, %edi
230 leal 1236535329(%ebx,%ebp,1),%ebx
231 movl 4(%esi), %ebp
232 xorl %eax, %edi
233 addl %edi, %ebx
234 movl %ecx, %edi
235 roll $22, %ebx
236 addl %ecx, %ebx
237
238 /* R1 section */
239 /* R1 16 */
240 leal 4129170786(%eax,%ebp,1),%eax
241 xorl %ebx, %edi
242 andl %edx, %edi
243 movl 24(%esi), %ebp
244 xorl %ecx, %edi
245 addl %edi, %eax
246 movl %ebx, %edi
247 roll $5, %eax
248 addl %ebx, %eax
249 /* R1 17 */
250 leal 3225465664(%edx,%ebp,1),%edx
251 xorl %eax, %edi
252 andl %ecx, %edi
253 movl 44(%esi), %ebp
254 xorl %ebx, %edi
255 addl %edi, %edx
256 movl %eax, %edi
257 roll $9, %edx
258 addl %eax, %edx
259 /* R1 18 */
260 leal 643717713(%ecx,%ebp,1),%ecx
261 xorl %edx, %edi
262 andl %ebx, %edi
263 movl (%esi), %ebp
264 xorl %eax, %edi
265 addl %edi, %ecx
266 movl %edx, %edi
267 roll $14, %ecx
268 addl %edx, %ecx
269 /* R1 19 */
270 leal 3921069994(%ebx,%ebp,1),%ebx
271 xorl %ecx, %edi
272 andl %eax, %edi
273 movl 20(%esi), %ebp
274 xorl %edx, %edi
275 addl %edi, %ebx
276 movl %ecx, %edi
277 roll $20, %ebx
278 addl %ecx, %ebx
279 /* R1 20 */
280 leal 3593408605(%eax,%ebp,1),%eax
281 xorl %ebx, %edi
282 andl %edx, %edi
283 movl 40(%esi), %ebp
284 xorl %ecx, %edi
285 addl %edi, %eax
286 movl %ebx, %edi
287 roll $5, %eax
288 addl %ebx, %eax
289 /* R1 21 */
290 leal 38016083(%edx,%ebp,1),%edx
291 xorl %eax, %edi
292 andl %ecx, %edi
293 movl 60(%esi), %ebp
294 xorl %ebx, %edi
295 addl %edi, %edx
296 movl %eax, %edi
297 roll $9, %edx
298 addl %eax, %edx
299 /* R1 22 */
300 leal 3634488961(%ecx,%ebp,1),%ecx
301 xorl %edx, %edi
302 andl %ebx, %edi
303 movl 16(%esi), %ebp
304 xorl %eax, %edi
305 addl %edi, %ecx
306 movl %edx, %edi
307 roll $14, %ecx
308 addl %edx, %ecx
309 /* R1 23 */
310 leal 3889429448(%ebx,%ebp,1),%ebx
311 xorl %ecx, %edi
312 andl %eax, %edi
313 movl 36(%esi), %ebp
314 xorl %edx, %edi
315 addl %edi, %ebx
316 movl %ecx, %edi
317 roll $20, %ebx
318 addl %ecx, %ebx
319 /* R1 24 */
320 leal 568446438(%eax,%ebp,1),%eax
321 xorl %ebx, %edi
322 andl %edx, %edi
323 movl 56(%esi), %ebp
324 xorl %ecx, %edi
325 addl %edi, %eax
326 movl %ebx, %edi
327 roll $5, %eax
328 addl %ebx, %eax
329 /* R1 25 */
330 leal 3275163606(%edx,%ebp,1),%edx
331 xorl %eax, %edi
332 andl %ecx, %edi
333 movl 12(%esi), %ebp
334 xorl %ebx, %edi
335 addl %edi, %edx
336 movl %eax, %edi
337 roll $9, %edx
338 addl %eax, %edx
339 /* R1 26 */
340 leal 4107603335(%ecx,%ebp,1),%ecx
341 xorl %edx, %edi
342 andl %ebx, %edi
343 movl 32(%esi), %ebp
344 xorl %eax, %edi
345 addl %edi, %ecx
346 movl %edx, %edi
347 roll $14, %ecx
348 addl %edx, %ecx
349 /* R1 27 */
350 leal 1163531501(%ebx,%ebp,1),%ebx
351 xorl %ecx, %edi
352 andl %eax, %edi
353 movl 52(%esi), %ebp
354 xorl %edx, %edi
355 addl %edi, %ebx
356 movl %ecx, %edi
357 roll $20, %ebx
358 addl %ecx, %ebx
359 /* R1 28 */
360 leal 2850285829(%eax,%ebp,1),%eax
361 xorl %ebx, %edi
362 andl %edx, %edi
363 movl 8(%esi), %ebp
364 xorl %ecx, %edi
365 addl %edi, %eax
366 movl %ebx, %edi
367 roll $5, %eax
368 addl %ebx, %eax
369 /* R1 29 */
370 leal 4243563512(%edx,%ebp,1),%edx
371 xorl %eax, %edi
372 andl %ecx, %edi
373 movl 28(%esi), %ebp
374 xorl %ebx, %edi
375 addl %edi, %edx
376 movl %eax, %edi
377 roll $9, %edx
378 addl %eax, %edx
379 /* R1 30 */
380 leal 1735328473(%ecx,%ebp,1),%ecx
381 xorl %edx, %edi
382 andl %ebx, %edi
383 movl 48(%esi), %ebp
384 xorl %eax, %edi
385 addl %edi, %ecx
386 movl %edx, %edi
387 roll $14, %ecx
388 addl %edx, %ecx
389 /* R1 31 */
390 leal 2368359562(%ebx,%ebp,1),%ebx
391 xorl %ecx, %edi
392 andl %eax, %edi
393 movl 20(%esi), %ebp
394 xorl %edx, %edi
395 addl %edi, %ebx
396 movl %ecx, %edi
397 roll $20, %ebx
398 addl %ecx, %ebx
399
400 /* R2 section */
401 /* R2 32 */
402 xorl %edx, %edi
403 xorl %ebx, %edi
404 leal 4294588738(%eax,%ebp,1),%eax
405 addl %edi, %eax
406 movl 32(%esi), %ebp
407 roll $4, %eax
408 movl %ebx, %edi
409 /* R2 33 */
410 leal 2272392833(%edx,%ebp,1),%edx
411 addl %ebx, %eax
412 xorl %ecx, %edi
413 xorl %eax, %edi
414 movl 44(%esi), %ebp
415 addl %edi, %edx
416 movl %eax, %edi
417 roll $11, %edx
418 addl %eax, %edx
419 /* R2 34 */
420 xorl %ebx, %edi
421 xorl %edx, %edi
422 leal 1839030562(%ecx,%ebp,1),%ecx
423 addl %edi, %ecx
424 movl 56(%esi), %ebp
425 roll $16, %ecx
426 movl %edx, %edi
427 /* R2 35 */
428 leal 4259657740(%ebx,%ebp,1),%ebx
429 addl %edx, %ecx
430 xorl %eax, %edi
431 xorl %ecx, %edi
432 movl 4(%esi), %ebp
433 addl %edi, %ebx
434 movl %ecx, %edi
435 roll $23, %ebx
436 addl %ecx, %ebx
437 /* R2 36 */
438 xorl %edx, %edi
439 xorl %ebx, %edi
440 leal 2763975236(%eax,%ebp,1),%eax
441 addl %edi, %eax
442 movl 16(%esi), %ebp
443 roll $4, %eax
444 movl %ebx, %edi
445 /* R2 37 */
446 leal 1272893353(%edx,%ebp,1),%edx
447 addl %ebx, %eax
448 xorl %ecx, %edi
449 xorl %eax, %edi
450 movl 28(%esi), %ebp
451 addl %edi, %edx
452 movl %eax, %edi
453 roll $11, %edx
454 addl %eax, %edx
455 /* R2 38 */
456 xorl %ebx, %edi
457 xorl %edx, %edi
458 leal 4139469664(%ecx,%ebp,1),%ecx
459 addl %edi, %ecx
460 movl 40(%esi), %ebp
461 roll $16, %ecx
462 movl %edx, %edi
463 /* R2 39 */
464 leal 3200236656(%ebx,%ebp,1),%ebx
465 addl %edx, %ecx
466 xorl %eax, %edi
467 xorl %ecx, %edi
468 movl 52(%esi), %ebp
469 addl %edi, %ebx
470 movl %ecx, %edi
471 roll $23, %ebx
472 addl %ecx, %ebx
473 /* R2 40 */
474 xorl %edx, %edi
475 xorl %ebx, %edi
476 leal 681279174(%eax,%ebp,1),%eax
477 addl %edi, %eax
478 movl (%esi), %ebp
479 roll $4, %eax
480 movl %ebx, %edi
481 /* R2 41 */
482 leal 3936430074(%edx,%ebp,1),%edx
483 addl %ebx, %eax
484 xorl %ecx, %edi
485 xorl %eax, %edi
486 movl 12(%esi), %ebp
487 addl %edi, %edx
488 movl %eax, %edi
489 roll $11, %edx
490 addl %eax, %edx
491 /* R2 42 */
492 xorl %ebx, %edi
493 xorl %edx, %edi
494 leal 3572445317(%ecx,%ebp,1),%ecx
495 addl %edi, %ecx
496 movl 24(%esi), %ebp
497 roll $16, %ecx
498 movl %edx, %edi
499 /* R2 43 */
500 leal 76029189(%ebx,%ebp,1),%ebx
501 addl %edx, %ecx
502 xorl %eax, %edi
503 xorl %ecx, %edi
504 movl 36(%esi), %ebp
505 addl %edi, %ebx
506 movl %ecx, %edi
507 roll $23, %ebx
508 addl %ecx, %ebx
509 /* R2 44 */
510 xorl %edx, %edi
511 xorl %ebx, %edi
512 leal 3654602809(%eax,%ebp,1),%eax
513 addl %edi, %eax
514 movl 48(%esi), %ebp
515 roll $4, %eax
516 movl %ebx, %edi
517 /* R2 45 */
518 leal 3873151461(%edx,%ebp,1),%edx
519 addl %ebx, %eax
520 xorl %ecx, %edi
521 xorl %eax, %edi
522 movl 60(%esi), %ebp
523 addl %edi, %edx
524 movl %eax, %edi
525 roll $11, %edx
526 addl %eax, %edx
527 /* R2 46 */
528 xorl %ebx, %edi
529 xorl %edx, %edi
530 leal 530742520(%ecx,%ebp,1),%ecx
531 addl %edi, %ecx
532 movl 8(%esi), %ebp
533 roll $16, %ecx
534 movl %edx, %edi
535 /* R2 47 */
536 leal 3299628645(%ebx,%ebp,1),%ebx
537 addl %edx, %ecx
538 xorl %eax, %edi
539 xorl %ecx, %edi
540 movl (%esi), %ebp
541 addl %edi, %ebx
542 movl $-1, %edi
543 roll $23, %ebx
544 addl %ecx, %ebx
545
546 /* R3 section */
547 /* R3 48 */
548 xorl %edx, %edi
549 orl %ebx, %edi
550 leal 4096336452(%eax,%ebp,1),%eax
551 xorl %ecx, %edi
552 movl 28(%esi), %ebp
553 addl %edi, %eax
554 movl $-1, %edi
555 roll $6, %eax
556 xorl %ecx, %edi
557 addl %ebx, %eax
558 /* R3 49 */
559 orl %eax, %edi
560 leal 1126891415(%edx,%ebp,1),%edx
561 xorl %ebx, %edi
562 movl 56(%esi), %ebp
563 addl %edi, %edx
564 movl $-1, %edi
565 roll $10, %edx
566 xorl %ebx, %edi
567 addl %eax, %edx
568 /* R3 50 */
569 orl %edx, %edi
570 leal 2878612391(%ecx,%ebp,1),%ecx
571 xorl %eax, %edi
572 movl 20(%esi), %ebp
573 addl %edi, %ecx
574 movl $-1, %edi
575 roll $15, %ecx
576 xorl %eax, %edi
577 addl %edx, %ecx
578 /* R3 51 */
579 orl %ecx, %edi
580 leal 4237533241(%ebx,%ebp,1),%ebx
581 xorl %edx, %edi
582 movl 48(%esi), %ebp
583 addl %edi, %ebx
584 movl $-1, %edi
585 roll $21, %ebx
586 xorl %edx, %edi
587 addl %ecx, %ebx
588 /* R3 52 */
589 orl %ebx, %edi
590 leal 1700485571(%eax,%ebp,1),%eax
591 xorl %ecx, %edi
592 movl 12(%esi), %ebp
593 addl %edi, %eax
594 movl $-1, %edi
595 roll $6, %eax
596 xorl %ecx, %edi
597 addl %ebx, %eax
598 /* R3 53 */
599 orl %eax, %edi
600 leal 2399980690(%edx,%ebp,1),%edx
601 xorl %ebx, %edi
602 movl 40(%esi), %ebp
603 addl %edi, %edx
604 movl $-1, %edi
605 roll $10, %edx
606 xorl %ebx, %edi
607 addl %eax, %edx
608 /* R3 54 */
609 orl %edx, %edi
610 leal 4293915773(%ecx,%ebp,1),%ecx
611 xorl %eax, %edi
612 movl 4(%esi), %ebp
613 addl %edi, %ecx
614 movl $-1, %edi
615 roll $15, %ecx
616 xorl %eax, %edi
617 addl %edx, %ecx
618 /* R3 55 */
619 orl %ecx, %edi
620 leal 2240044497(%ebx,%ebp,1),%ebx
621 xorl %edx, %edi
622 movl 32(%esi), %ebp
623 addl %edi, %ebx
624 movl $-1, %edi
625 roll $21, %ebx
626 xorl %edx, %edi
627 addl %ecx, %ebx
628 /* R3 56 */
629 orl %ebx, %edi
630 leal 1873313359(%eax,%ebp,1),%eax
631 xorl %ecx, %edi
632 movl 60(%esi), %ebp
633 addl %edi, %eax
634 movl $-1, %edi
635 roll $6, %eax
636 xorl %ecx, %edi
637 addl %ebx, %eax
638 /* R3 57 */
639 orl %eax, %edi
640 leal 4264355552(%edx,%ebp,1),%edx
641 xorl %ebx, %edi
642 movl 24(%esi), %ebp
643 addl %edi, %edx
644 movl $-1, %edi
645 roll $10, %edx
646 xorl %ebx, %edi
647 addl %eax, %edx
648 /* R3 58 */
649 orl %edx, %edi
650 leal 2734768916(%ecx,%ebp,1),%ecx
651 xorl %eax, %edi
652 movl 52(%esi), %ebp
653 addl %edi, %ecx
654 movl $-1, %edi
655 roll $15, %ecx
656 xorl %eax, %edi
657 addl %edx, %ecx
658 /* R3 59 */
659 orl %ecx, %edi
660 leal 1309151649(%ebx,%ebp,1),%ebx
661 xorl %edx, %edi
662 movl 16(%esi), %ebp
663 addl %edi, %ebx
664 movl $-1, %edi
665 roll $21, %ebx
666 xorl %edx, %edi
667 addl %ecx, %ebx
668 /* R3 60 */
669 orl %ebx, %edi
670 leal 4149444226(%eax,%ebp,1),%eax
671 xorl %ecx, %edi
672 movl 44(%esi), %ebp
673 addl %edi, %eax
674 movl $-1, %edi
675 roll $6, %eax
676 xorl %ecx, %edi
677 addl %ebx, %eax
678 /* R3 61 */
679 orl %eax, %edi
680 leal 3174756917(%edx,%ebp,1),%edx
681 xorl %ebx, %edi
682 movl 8(%esi), %ebp
683 addl %edi, %edx
684 movl $-1, %edi
685 roll $10, %edx
686 xorl %ebx, %edi
687 addl %eax, %edx
688 /* R3 62 */
689 orl %edx, %edi
690 leal 718787259(%ecx,%ebp,1),%ecx
691 xorl %eax, %edi
692 movl 36(%esi), %ebp
693 addl %edi, %ecx
694 movl $-1, %edi
695 roll $15, %ecx
696 xorl %eax, %edi
697 addl %edx, %ecx
698 /* R3 63 */
699 orl %ecx, %edi
700 leal 3951481745(%ebx,%ebp,1),%ebx
701 xorl %edx, %edi
702 movl 24(%esp), %ebp
703 addl %edi, %ebx
704 addl $64, %esi
705 roll $21, %ebx
706 movl (%ebp), %edi
707 addl %ecx, %ebx
708 addl %edi, %eax
709 movl 4(%ebp), %edi
710 addl %edi, %ebx
711 movl 8(%ebp), %edi
712 addl %edi, %ecx
713 movl 12(%ebp), %edi
714 addl %edi, %edx
715 movl %eax, (%ebp)
716 movl %ebx, 4(%ebp)
717 movl (%esp), %edi
718 movl %ecx, 8(%ebp)
719 movl %edx, 12(%ebp)
720 cmpl %esi, %edi
721 jge .L000start
722 popl %eax
723 popl %ebx
724 popl %ebp
725 popl %edi
726 popl %esi
727 ret
728.md5_block_x86_end:
729 SIZE(md5_block_x86,.md5_block_x86_end-md5_block_x86)
730.ident "desasm.pl"
diff --git a/src/lib/libssl/src/crypto/mdc2/Makefile.ssl b/src/lib/libssl/src/crypto/mdc2/Makefile.ssl
new file mode 100644
index 0000000000..495a2789a0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/mdc2/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/mdc2/Makefile
3#
4
5DIR= mdc2
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST= mdc2test.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=mdc2dgst.c mdc2_one.c
24LIBOBJ=mdc2dgst.o mdc2_one.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= mdc2.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/objects/Makefile.ssl b/src/lib/libssl/src/crypto/objects/Makefile.ssl
new file mode 100644
index 0000000000..320523cea1
--- /dev/null
+++ b/src/lib/libssl/src/crypto/objects/Makefile.ssl
@@ -0,0 +1,87 @@
1#
2# SSLeay/crypto/objects/Makefile
3#
4
5DIR= objects
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=objects
19ERRC=obj_err
20GENERAL=Makefile README
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= obj_dat.c obj_lib.c $(ERRC).c
26LIBOBJ= obj_dat.o obj_lib.o $(ERRC).o
27
28SRC= $(LIBSRC)
29
30EXHEADER= objects.h
31HEADER= $(EXHEADER) obj_dat.h
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: obj_dat.h lib
39
40obj_dat.h: objects.h obj_dat.pl
41 perl ./obj_dat.pl < objects.h > obj_dat.h
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 sh $(TOP)/util/ranlib.sh $(LIB)
46 @touch lib
47
48files:
49 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
50
51links:
52 /bin/rm -f Makefile
53 $(TOP)/util/point.sh Makefile.ssl Makefile ;
54 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
55 $(TOP)/util/mklink.sh ../../test $(TEST)
56 $(TOP)/util/mklink.sh ../../apps $(APPS)
57
58install:
59 @for i in $(EXHEADER) ; \
60 do \
61 (cp $$i $(INSTALLTOP)/include/$$i; \
62 chmod 644 $(INSTALLTOP)/include/$$i ); \
63 done;
64
65tags:
66 ctags $(SRC)
67
68tests:
69
70lint:
71 lint -DLINT $(INCLUDES) $(SRC)>fluff
72
73depend:
74 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
75
76dclean:
77 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
78 mv -f Makefile.new $(MAKEFILE)
79
80clean:
81 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
82
83errors:
84 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
85 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
86
87# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/objects/objects.err b/src/lib/libssl/src/crypto/objects/objects.err
new file mode 100644
index 0000000000..8bec3eaea2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/objects/objects.err
@@ -0,0 +1,12 @@
1/* Error codes for the OBJ functions. */
2
3/* Function codes. */
4#define OBJ_F_OBJ_CREATE 100
5#define OBJ_F_OBJ_DUP 101
6#define OBJ_F_OBJ_NID2LN 102
7#define OBJ_F_OBJ_NID2OBJ 103
8#define OBJ_F_OBJ_NID2SN 104
9
10/* Reason codes. */
11#define OBJ_R_MALLOC_FAILURE 100
12#define OBJ_R_UNKNOWN_NID 101
diff --git a/src/lib/libssl/src/crypto/pem/Makefile.ssl b/src/lib/libssl/src/crypto/pem/Makefile.ssl
new file mode 100644
index 0000000000..fc04a88fd9
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pem/Makefile.ssl
@@ -0,0 +1,96 @@
1#
2# SSLeay/crypto/pem/Makefile
3#
4
5DIR= pem
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=pem
19ERRC=pem_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24CTX_SIZE= ctx_size
25
26LIB=$(TOP)/libcrypto.a
27LIBSRC= pem_sign.c pem_seal.c pem_info.c pem_lib.c pem_all.c $(ERRC).c
28
29LIBOBJ= pem_sign.o pem_seal.o pem_info.o pem_lib.o pem_all.o $(ERRC).o
30
31SRC= $(LIBSRC)
32
33EXHEADER= pem.h
34HEADER= $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: pem.h lib
42
43pem.h: $(CTX_SIZE)
44 ./$(CTX_SIZE) <pem.org >pem.new
45 if [ -f pem.h ]; then mv -f pem.h pem.old; fi
46 mv -f pem.new pem.h
47
48$(CTX_SIZE): $(CTX_SIZE).o
49 $(CC) $(CFLAGS) -o $(CTX_SIZE) $(CTX_SIZE).o
50
51lib: $(LIBOBJ)
52 $(AR) $(LIB) $(LIBOBJ)
53 sh $(TOP)/util/ranlib.sh $(LIB)
54 @touch lib
55
56files:
57 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
58
59links:
60 /bin/rm -f Makefile
61 $(TOP)/util/point.sh Makefile.ssl Makefile ;
62 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
63 $(TOP)/util/mklink.sh ../../test $(TEST)
64 $(TOP)/util/mklink.sh ../../apps $(APPS)
65
66install:
67 @for i in $(EXHEADER) ; \
68 do \
69 (cp $$i $(INSTALLTOP)/include/$$i; \
70 chmod 644 $(INSTALLTOP)/include/$$i ); \
71 done;
72
73tags:
74 ctags $(SRC)
75
76tests:
77
78lint:
79 lint -DLINT $(INCLUDES) $(SRC)>fluff
80
81depend:
82 $(MAKEDEPEND) $(INCLUDES) $(CTX_SIZE).c $(LIBSRC)
83
84dclean:
85 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
86 mv -f Makefile.new $(MAKEFILE)
87
88clean:
89 /bin/rm -f $(CTX_SIZE) *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
90
91errors:
92 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).org # SPECIAL CASE .org
93 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
94 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
95
96# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/pem/ctx_size.c b/src/lib/libssl/src/crypto/pem/ctx_size.c
new file mode 100644
index 0000000000..87469bc4af
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pem/ctx_size.c
@@ -0,0 +1,122 @@
1/* crypto/pem/ctx_size.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "cryptlib.h"
61#include "evp.h"
62
63int main(argc,argv)
64int argc;
65char *argv[];
66 {
67 int i,j;
68 char buf[256];
69
70 for (;;)
71 {
72 char *str;
73 buf[0]='\0';
74 fgets(buf,256,stdin);
75 if (buf[0] == '\0') break;
76
77 str="#define EVP_ENCODE_CTX_SIZE ";
78 if (strncmp(buf,str,strlen(str)) == 0)
79 {
80 printf("%s %d\n",str,(int)sizeof(EVP_ENCODE_CTX));
81 continue;
82 }
83 str="#define EVP_MD_SIZE ";
84 if (strncmp(buf,str,strlen(str)) == 0)
85 {
86 printf("%s %d\n",str,(int)sizeof(EVP_MD));
87 continue;
88 }
89 str="#define EVP_MD_CTX_SIZE ";
90 if (strncmp(buf,str,strlen(str)) == 0)
91 {
92 printf("%s %d\n",str,(int)sizeof(EVP_MD_CTX));
93 continue;
94 }
95 str="#define EVP_CIPHER_SIZE ";
96 if (strncmp(buf,str,strlen(str)) == 0)
97 {
98 printf("%s %d\n",str,(int)sizeof(EVP_CIPHER));
99 continue;
100 }
101 str="#define EVP_CIPHER_CTX_SIZE ";
102 if (strncmp(buf,str,strlen(str)) == 0)
103 {
104 printf("%s %d\n",str,(int)sizeof(EVP_CIPHER_CTX));
105 continue;
106 }
107
108 str="#define EVP_MAX_MD_SIZE ";
109 if (strncmp(buf,str,strlen(str)) == 0)
110 {
111 i=MD2_DIGEST_LENGTH;
112 j=MD5_DIGEST_LENGTH;
113 if (j > i) i=j;
114 j=SHA_DIGEST_LENGTH;
115 if (j > i) i=j;
116 printf("%s %d\n",str,i);
117 continue;
118 }
119 fputs(buf,stdout);
120 }
121 exit(0);
122 }
diff --git a/src/lib/libssl/src/crypto/pem/pem.err b/src/lib/libssl/src/crypto/pem/pem.err
new file mode 100644
index 0000000000..0e523abf82
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pem/pem.err
@@ -0,0 +1,38 @@
1/* Error codes for the PEM functions. */
2
3/* Function codes. */
4#define PEM_F_DEF_CALLBACK 100
5#define PEM_F_LOAD_IV 101
6#define PEM_F_PEM_ASN1_READ 102
7#define PEM_F_PEM_ASN1_READ_BIO 103
8#define PEM_F_PEM_ASN1_WRITE 104
9#define PEM_F_PEM_ASN1_WRITE_BIO 105
10#define PEM_F_PEM_DO_HEADER 106
11#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
12#define PEM_F_PEM_READ 108
13#define PEM_F_PEM_READ_BIO 109
14#define PEM_F_PEM_SEALFINAL 110
15#define PEM_F_PEM_SEALINIT 111
16#define PEM_F_PEM_SIGNFINAL 112
17#define PEM_F_PEM_WRITE 113
18#define PEM_F_PEM_WRITE_BIO 114
19#define PEM_F_PEM_X509_INFO_READ 115
20#define PEM_F_PEM_X509_INFO_READ_BIO 116
21#define PEM_F_PEM_X509_INFO_WRITE_BIO 117
22
23/* Reason codes. */
24#define PEM_R_BAD_BASE64_DECODE 100
25#define PEM_R_BAD_DECRYPT 101
26#define PEM_R_BAD_END_LINE 102
27#define PEM_R_BAD_IV_CHARS 103
28#define PEM_R_BAD_PASSWORD_READ 104
29#define PEM_R_NOT_DEK_INFO 105
30#define PEM_R_NOT_ENCRYPTED 106
31#define PEM_R_NOT_PROC_TYPE 107
32#define PEM_R_NO_START_LINE 108
33#define PEM_R_PROBLEMS_GETTING_PASSWORD 109
34#define PEM_R_PUBLIC_KEY_NO_RSA 110
35#define PEM_R_READ_KEY 111
36#define PEM_R_SHORT_HEADER 112
37#define PEM_R_UNSUPPORTED_CIPHER 113
38#define PEM_R_UNSUPPORTED_ENCRYPTION 114
diff --git a/src/lib/libssl/src/crypto/pem/pem.org b/src/lib/libssl/src/crypto/pem/pem.org
new file mode 100644
index 0000000000..38952509dd
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pem/pem.org
@@ -0,0 +1,562 @@
1/* crypto/pem/pem.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify pem.org since pem.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_PEM_H
68#define HEADER_PEM_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74#include "evp.h"
75#include "x509.h"
76
77#define PEM_OBJ_UNDEF 0
78#define PEM_OBJ_X509 1
79#define PEM_OBJ_X509_REQ 2
80#define PEM_OBJ_CRL 3
81#define PEM_OBJ_SSL_SESSION 4
82#define PEM_OBJ_PRIV_KEY 10
83#define PEM_OBJ_PRIV_RSA 11
84#define PEM_OBJ_PRIV_DSA 12
85#define PEM_OBJ_PRIV_DH 13
86#define PEM_OBJ_PUB_RSA 14
87#define PEM_OBJ_PUB_DSA 15
88#define PEM_OBJ_PUB_DH 16
89#define PEM_OBJ_DHPARAMS 17
90#define PEM_OBJ_DSAPARAMS 18
91#define PEM_OBJ_PRIV_RSA_PUBLIC 19
92
93#define PEM_ERROR 30
94#define PEM_DEK_DES_CBC 40
95#define PEM_DEK_IDEA_CBC 45
96#define PEM_DEK_DES_EDE 50
97#define PEM_DEK_DES_ECB 60
98#define PEM_DEK_RSA 70
99#define PEM_DEK_RSA_MD2 80
100#define PEM_DEK_RSA_MD5 90
101
102#define PEM_MD_MD2 NID_md2
103#define PEM_MD_MD5 NID_md5
104#define PEM_MD_SHA NID_sha
105#define PEM_MD_MD2_RSA NID_md2WithRSAEncryption
106#define PEM_MD_MD5_RSA NID_md5WithRSAEncryption
107#define PEM_MD_SHA_RSA NID_sha1WithRSAEncryption
108
109#define PEM_STRING_X509_OLD "X509 CERTIFICATE"
110#define PEM_STRING_X509 "CERTIFICATE"
111#define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
112#define PEM_STRING_X509_REQ "CERTIFICATE REQUEST"
113#define PEM_STRING_X509_CRL "X509 CRL"
114#define PEM_STRING_EVP_PKEY "PRIVATE KEY"
115#define PEM_STRING_RSA "RSA PRIVATE KEY"
116#define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY"
117#define PEM_STRING_DSA "DSA PRIVATE KEY"
118#define PEM_STRING_PKCS7 "PKCS7"
119#define PEM_STRING_DHPARAMS "DH PARAMETERS"
120#define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS"
121#define PEM_STRING_DSAPARAMS "DSA PARAMETERS"
122
123#ifndef HEADER_ENVELOPE_H
124
125#define EVP_ENCODE_CTX_SIZE 92
126#define EVP_MD_SIZE 48
127#define EVP_MD_CTX_SIZE 152
128#define EVP_CIPHER_SIZE 28
129#define EVP_CIPHER_CTX_SIZE 4212
130#define EVP_MAX_MD_SIZE 20
131
132typedef struct evp_encode_ctx_st
133 {
134 char data[EVP_ENCODE_CTX_SIZE];
135 } EVP_ENCODE_CTX;
136
137typedef struct env_md_ctx_st
138 {
139 char data[EVP_MD_CTX_SIZE];
140 } EVP_MD_CTX;
141
142typedef struct evp_cipher_st
143 {
144 char data[EVP_CIPHER_SIZE];
145 } EVP_CIPHER;
146
147typedef struct evp_cipher_ctx_st
148 {
149 char data[EVP_CIPHER_CTX_SIZE];
150 } EVP_CIPHER_CTX;
151#endif
152
153
154typedef struct PEM_Encode_Seal_st
155 {
156 EVP_ENCODE_CTX encode;
157 EVP_MD_CTX md;
158 EVP_CIPHER_CTX cipher;
159 } PEM_ENCODE_SEAL_CTX;
160
161/* enc_type is one off */
162#define PEM_TYPE_ENCRYPTED 10
163#define PEM_TYPE_MIC_ONLY 20
164#define PEM_TYPE_MIC_CLEAR 30
165#define PEM_TYPE_CLEAR 40
166
167typedef struct pem_recip_st
168 {
169 char *name;
170 X509_NAME *dn;
171
172 int cipher;
173 int key_enc;
174 char iv[8];
175 } PEM_USER;
176
177typedef struct pem_ctx_st
178 {
179 int type; /* what type of object */
180
181 struct {
182 int version;
183 int mode;
184 } proc_type;
185
186 char *domain;
187
188 struct {
189 int cipher;
190 unsigned char iv[8];
191 } DEK_info;
192
193 PEM_USER *originator;
194
195 int num_recipient;
196 PEM_USER **recipient;
197
198#ifdef HEADER_STACK_H
199 STACK *x509_chain; /* certificate chain */
200#else
201 char *x509_chain; /* certificate chain */
202#endif
203 EVP_MD *md; /* signature type */
204
205 int md_enc; /* is the md encrypted or not? */
206 int md_len; /* length of md_data */
207 char *md_data; /* message digest, could be pkey encrypted */
208
209 EVP_CIPHER *dec; /* date encryption cipher */
210 int key_len; /* key length */
211 unsigned char *key; /* key */
212 unsigned char iv[8]; /* the iv */
213
214
215 int data_enc; /* is the data encrypted */
216 int data_len;
217 unsigned char *data;
218 } PEM_CTX;
219
220#ifdef SSLEAY_MACROS
221
222#define PEM_write_SSL_SESSION(fp,x) \
223 PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \
224 PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL)
225#define PEM_write_X509(fp,x) \
226 PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
227 (char *)x, NULL,NULL,0,NULL)
228#define PEM_write_X509_REQ(fp,x) PEM_ASN1_write( \
229 (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,fp,(char *)x, \
230 NULL,NULL,0,NULL)
231#define PEM_write_X509_CRL(fp,x) \
232 PEM_ASN1_write((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL, \
233 fp,(char *)x, NULL,NULL,0,NULL)
234#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb) \
235 PEM_ASN1_write((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,fp,\
236 (char *)x,enc,kstr,klen,cb)
237#define PEM_write_RSAPublicKey(fp,x) \
238 PEM_ASN1_write((int (*)())i2d_RSAPublicKey,\
239 PEM_STRING_RSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL)
240#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb) \
241 PEM_ASN1_write((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,fp,\
242 (char *)x,enc,kstr,klen,cb)
243#define PEM_write_PrivateKey(bp,x,enc,kstr,klen,cb) \
244 PEM_ASN1_write((int (*)())i2d_PrivateKey,\
245 (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
246 bp,(char *)x,enc,kstr,klen,cb)
247#define PEM_write_PKCS7(fp,x) \
248 PEM_ASN1_write((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,fp, \
249 (char *)x, NULL,NULL,0,NULL)
250#define PEM_write_DHparams(fp,x) \
251 PEM_ASN1_write((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,fp,\
252 (char *)x,NULL,NULL,0,NULL)
253
254#define PEM_read_SSL_SESSION(fp,x,cb) (SSL_SESSION *)PEM_ASN1_read( \
255 (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb)
256#define PEM_read_X509(fp,x,cb) (X509 *)PEM_ASN1_read( \
257 (char *(*)())d2i_X509,PEM_STRING_X509,fp,(char **)x,cb)
258#define PEM_read_X509_REQ(fp,x,cb) (X509_REQ *)PEM_ASN1_read( \
259 (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,fp,(char **)x,cb)
260#define PEM_read_X509_CRL(fp,x,cb) (X509_CRL *)PEM_ASN1_read( \
261 (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,fp,(char **)x,cb)
262#define PEM_read_RSAPrivateKey(fp,x,cb) (RSA *)PEM_ASN1_read( \
263 (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,fp,(char **)x,cb)
264#define PEM_read_RSAPublicKey(fp,x,cb) (RSA *)PEM_ASN1_read( \
265 (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,fp,(char **)x,cb)
266#define PEM_read_DSAPrivateKey(fp,x,cb) (DSA *)PEM_ASN1_read( \
267 (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,fp,(char **)x,cb)
268#define PEM_read_PrivateKey(fp,x,cb) (EVP_PKEY *)PEM_ASN1_read( \
269 (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char **)x,cb)
270#define PEM_read_PKCS7(fp,x,cb) (PKCS7 *)PEM_ASN1_read( \
271 (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,fp,(char **)x,cb)
272#define PEM_read_DHparams(fp,x,cb) (DH *)PEM_ASN1_read( \
273 (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,fp,(char **)x,cb)
274
275#define PEM_write_bio_SSL_SESSION(bp,x) \
276 PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \
277 PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL)
278#define PEM_write_bio_X509(bp,x) \
279 PEM_ASN1_write_bio((int (*)())i2d_X509,PEM_STRING_X509,bp, \
280 (char *)x, NULL,NULL,0,NULL)
281#define PEM_write_bio_X509_REQ(bp,x) PEM_ASN1_write_bio( \
282 (int (*)())i2d_X509_REQ,PEM_STRING_X509_REQ,bp,(char *)x, \
283 NULL,NULL,0,NULL)
284#define PEM_write_bio_X509_CRL(bp,x) \
285 PEM_ASN1_write_bio((int (*)())i2d_X509_CRL,PEM_STRING_X509_CRL,\
286 bp,(char *)x, NULL,NULL,0,NULL)
287#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb) \
288 PEM_ASN1_write_bio((int (*)())i2d_RSAPrivateKey,PEM_STRING_RSA,\
289 bp,(char *)x,enc,kstr,klen,cb)
290#define PEM_write_bio_RSAPublicKey(bp,x) \
291 PEM_ASN1_write_bio((int (*)())i2d_RSAPublicKey, \
292 PEM_STRING_RSA_PUBLIC,\
293 bp,(char *)x,NULL,NULL,0,NULL)
294#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb) \
295 PEM_ASN1_write_bio((int (*)())i2d_DSAPrivateKey,PEM_STRING_DSA,\
296 bp,(char *)x,enc,kstr,klen,cb)
297#define PEM_write_bio_PrivateKey(bp,x,enc,kstr,klen,cb) \
298 PEM_ASN1_write_bio((int (*)())i2d_PrivateKey,\
299 (((x)->type == EVP_PKEY_DSA)?PEM_STRING_DSA:PEM_STRING_RSA),\
300 bp,(char *)x,enc,kstr,klen,cb)
301#define PEM_write_bio_PKCS7(bp,x) \
302 PEM_ASN1_write_bio((int (*)())i2d_PKCS7,PEM_STRING_PKCS7,bp, \
303 (char *)x, NULL,NULL,0,NULL)
304#define PEM_write_bio_DHparams(bp,x) \
305 PEM_ASN1_write_bio((int (*)())i2d_DHparams,PEM_STRING_DHPARAMS,\
306 bp,(char *)x,NULL,NULL,0,NULL)
307#define PEM_write_bio_DSAparams(bp,x) \
308 PEM_ASN1_write_bio((int (*)())i2d_DSAparams, \
309 PEM_STRING_DSAPARAMS,bp,(char *)x,NULL,NULL,0,NULL)
310
311#define PEM_read_bio_SSL_SESSION(bp,x,cb) (SSL_SESSION *)PEM_ASN1_read_bio( \
312 (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb)
313#define PEM_read_bio_X509(bp,x,cb) (X509 *)PEM_ASN1_read_bio( \
314 (char *(*)())d2i_X509,PEM_STRING_X509,bp,(char **)x,cb)
315#define PEM_read_bio_X509_REQ(bp,x,cb) (X509_REQ *)PEM_ASN1_read_bio( \
316 (char *(*)())d2i_X509_REQ,PEM_STRING_X509_REQ,bp,(char **)x,cb)
317#define PEM_read_bio_X509_CRL(bp,x,cb) (X509_CRL *)PEM_ASN1_read_bio( \
318 (char *(*)())d2i_X509_CRL,PEM_STRING_X509_CRL,bp,(char **)x,cb)
319#define PEM_read_bio_RSAPrivateKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \
320 (char *(*)())d2i_RSAPrivateKey,PEM_STRING_RSA,bp,(char **)x,cb)
321#define PEM_read_bio_RSAPublicKey(bp,x,cb) (RSA *)PEM_ASN1_read_bio( \
322 (char *(*)())d2i_RSAPublicKey,PEM_STRING_RSA_PUBLIC,bp,(char **)x,cb)
323#define PEM_read_bio_DSAPrivateKey(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \
324 (char *(*)())d2i_DSAPrivateKey,PEM_STRING_DSA,bp,(char **)x,cb)
325#define PEM_read_bio_PrivateKey(bp,x,cb) (EVP_PKEY *)PEM_ASN1_read_bio( \
326 (char *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,bp,(char **)x,cb)
327
328#define PEM_read_bio_PKCS7(bp,x,cb) (PKCS7 *)PEM_ASN1_read_bio( \
329 (char *(*)())d2i_PKCS7,PEM_STRING_PKCS7,bp,(char **)x,cb)
330#define PEM_read_bio_DHparams(bp,x,cb) (DH *)PEM_ASN1_read_bio( \
331 (char *(*)())d2i_DHparams,PEM_STRING_DHPARAMS,bp,(char **)x,cb)
332#define PEM_read_bio_DSAparams(bp,x,cb) (DSA *)PEM_ASN1_read_bio( \
333 (char *(*)())d2i_DSAparams,PEM_STRING_DSAPARAMS,bp,(char **)x,cb)
334
335#endif
336
337#ifndef NOPROTO
338int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
339int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
340 int (*callback)());
341
342#ifdef HEADER_BIO_H
343int PEM_read_bio(BIO *bp, char **name, char **header,
344 unsigned char **data,long *len);
345int PEM_write_bio(BIO *bp,char *name,char *hdr,unsigned char *data,
346 long len);
347char * PEM_ASN1_read_bio(char *(*d2i)(),char *name,BIO *bp,char **x,
348 int (*cb)());
349int PEM_ASN1_write_bio(int (*i2d)(),char *name,BIO *bp,char *x,
350 EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)());
351STACK * PEM_X509_INFO_read_bio(BIO *bp, STACK *sk, int (*cb)());
352int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
353 unsigned char *kstr, int klen, int (*cb)());
354#endif
355
356#ifndef WIN16
357int PEM_read(FILE *fp, char **name, char **header,
358 unsigned char **data,long *len);
359int PEM_write(FILE *fp,char *name,char *hdr,unsigned char *data,long len);
360char * PEM_ASN1_read(char *(*d2i)(),char *name,FILE *fp,char **x,
361 int (*cb)());
362int PEM_ASN1_write(int (*i2d)(),char *name,FILE *fp,char *x,
363 EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)());
364STACK * PEM_X509_INFO_read(FILE *fp, STACK *sk, int (*cb)());
365#endif
366
367int PEM_SealInit(PEM_ENCODE_SEAL_CTX *ctx, EVP_CIPHER *type,
368 EVP_MD *md_type, unsigned char **ek, int *ekl,
369 unsigned char *iv, EVP_PKEY **pubk, int npubk);
370void PEM_SealUpdate(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *out, int *outl,
371 unsigned char *in, int inl);
372int PEM_SealFinal(PEM_ENCODE_SEAL_CTX *ctx, unsigned char *sig,int *sigl,
373 unsigned char *out, int *outl, EVP_PKEY *priv);
374
375void PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
376void PEM_SignUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
377int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
378 unsigned int *siglen, EVP_PKEY *pkey);
379
380void ERR_load_PEM_strings(void);
381
382void PEM_proc_type(char *buf, int type);
383void PEM_dek_info(char *buf, char *type, int len, char *str);
384
385#ifndef SSLEAY_MACROS
386
387#ifndef WIN16
388X509 *PEM_read_X509(FILE *fp,X509 **x,int (*cb)());
389X509_REQ *PEM_read_X509_REQ(FILE *fp,X509_REQ **x,int (*cb)());
390X509_CRL *PEM_read_X509_CRL(FILE *fp,X509_CRL **x,int (*cb)());
391RSA *PEM_read_RSAPrivateKey(FILE *fp,RSA **x,int (*cb)());
392RSA *PEM_read_RSAPublicKey(FILE *fp,RSA **x,int (*cb)());
393DSA *PEM_read_DSAPrivateKey(FILE *fp,DSA **x,int (*cb)());
394EVP_PKEY *PEM_read_PrivateKey(FILE *fp,EVP_PKEY **x,int (*cb)());
395PKCS7 *PEM_read_PKCS7(FILE *fp,PKCS7 **x,int (*cb)());
396DH *PEM_read_DHparams(FILE *fp,DH **x,int (*cb)());
397DSA *PEM_read_DSAparams(FILE *fp,DSA **x,int (*cb)());
398int PEM_write_X509(FILE *fp,X509 *x);
399int PEM_write_X509_REQ(FILE *fp,X509_REQ *x);
400int PEM_write_X509_CRL(FILE *fp,X509_CRL *x);
401int PEM_write_RSAPrivateKey(FILE *fp,RSA *x,EVP_CIPHER *enc,unsigned char *kstr,
402 int klen,int (*cb)());
403int PEM_write_RSAPublicKey(FILE *fp,RSA *x);
404int PEM_write_DSAPrivateKey(FILE *fp,DSA *x,EVP_CIPHER *enc,unsigned char *kstr,
405 int klen,int (*cb)());
406int PEM_write_PrivateKey(FILE *fp,EVP_PKEY *x,EVP_CIPHER *enc,
407 unsigned char *kstr,int klen,int (*cb)());
408int PEM_write_PKCS7(FILE *fp,PKCS7 *x);
409int PEM_write_DHparams(FILE *fp,DH *x);
410int PEM_write_DSAparams(FILE *fp,DSA *x);
411#endif
412
413#ifdef HEADER_BIO_H
414X509 *PEM_read_bio_X509(BIO *bp,X509 **x,int (*cb)());
415X509_REQ *PEM_read_bio_X509_REQ(BIO *bp,X509_REQ **x,int (*cb)());
416X509_CRL *PEM_read_bio_X509_CRL(BIO *bp,X509_CRL **x,int (*cb)());
417RSA *PEM_read_bio_RSAPrivateKey(BIO *bp,RSA **x,int (*cb)());
418RSA *PEM_read_bio_RSAPublicKey(BIO *bp,RSA **x,int (*cb)());
419DSA *PEM_read_bio_DSAPrivateKey(BIO *bp,DSA **x,int (*cb)());
420EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp,EVP_PKEY **x,int (*cb)());
421PKCS7 *PEM_read_bio_PKCS7(BIO *bp,PKCS7 **x,int (*cb)());
422DH *PEM_read_bio_DHparams(BIO *bp,DH **x,int (*cb)());
423DSA *PEM_read_bio_DSAparams(BIO *bp,DSA **x,int (*cb)());
424int PEM_write_bio_X509(BIO *bp,X509 *x);
425int PEM_write_bio_X509_REQ(BIO *bp,X509_REQ *x);
426int PEM_write_bio_X509_CRL(BIO *bp,X509_CRL *x);
427int PEM_write_bio_RSAPrivateKey(BIO *fp,RSA *x,EVP_CIPHER *enc,
428 unsigned char *kstr,int klen,int (*cb)());
429int PEM_write_bio_RSAPublicKey(BIO *fp,RSA *x);
430int PEM_write_bio_DSAPrivateKey(BIO *fp,DSA *x,EVP_CIPHER *enc,
431 unsigned char *kstr,int klen,int (*cb)());
432int PEM_write_bio_PrivateKey(BIO *fp,EVP_PKEY *x,EVP_CIPHER *enc,
433 unsigned char *kstr,int klen,int (*cb)());
434int PEM_write_bio_PKCS7(BIO *bp,PKCS7 *x);
435int PEM_write_bio_DHparams(BIO *bp,DH *x);
436int PEM_write_bio_DSAparams(BIO *bp,DSA *x);
437#endif
438
439#endif /* SSLEAY_MACROS */
440
441
442#else
443
444int PEM_get_EVP_CIPHER_INFO();
445int PEM_do_header();
446int PEM_read_bio();
447int PEM_write_bio();
448#ifndef WIN16
449int PEM_read();
450int PEM_write();
451STACK * PEM_X509_INFO_read();
452char * PEM_ASN1_read();
453int PEM_ASN1_write();
454#endif
455STACK * PEM_X509_INFO_read_bio();
456int PEM_X509_INFO_write_bio();
457char * PEM_ASN1_read_bio();
458int PEM_ASN1_write_bio();
459int PEM_SealInit();
460void PEM_SealUpdate();
461int PEM_SealFinal();
462int PEM_SignFinal();
463
464void ERR_load_PEM_strings();
465
466void PEM_proc_type();
467void PEM_dek_info();
468
469#ifndef SSLEAY_MACROS
470#ifndef WIN16
471X509 *PEM_read_X509();
472X509_REQ *PEM_read_X509_REQ();
473X509_CRL *PEM_read_X509_CRL();
474RSA *PEM_read_RSAPrivateKey();
475RSA *PEM_read_RSAPublicKey();
476DSA *PEM_read_DSAPrivateKey();
477EVP_PKEY *PEM_read_PrivateKey();
478PKCS7 *PEM_read_PKCS7();
479DH *PEM_read_DHparams();
480DSA *PEM_read_DSAparams();
481int PEM_write_X509();
482int PEM_write_X509_REQ();
483int PEM_write_X509_CRL();
484int PEM_write_RSAPrivateKey();
485int PEM_write_RSAPublicKey();
486int PEM_write_DSAPrivateKey();
487int PEM_write_PrivateKey();
488int PEM_write_PKCS7();
489int PEM_write_DHparams();
490int PEM_write_DSAparams();
491#endif
492
493X509 *PEM_read_bio_X509();
494X509_REQ *PEM_read_bio_X509_REQ();
495X509_CRL *PEM_read_bio_X509_CRL();
496RSA *PEM_read_bio_RSAPrivateKey();
497RSA *PEM_read_bio_RSAPublicKey();
498DSA *PEM_read_bio_DSAPrivateKey();
499EVP_PKEY *PEM_read_bio_PrivateKey();
500PKCS7 *PEM_read_bio_PKCS7();
501DH *PEM_read_bio_DHparams();
502DSA *PEM_read_bio_DSAparams();
503int PEM_write_bio_X509();
504int PEM_write_bio_X509_REQ();
505int PEM_write_bio_X509_CRL();
506int PEM_write_bio_RSAPrivateKey();
507int PEM_write_bio_RSAPublicKey();
508int PEM_write_bio_DSAPrivateKey();
509int PEM_write_bio_PrivateKey();
510int PEM_write_bio_PKCS7();
511int PEM_write_bio_DHparams();
512int PEM_write_bio_DSAparams();
513
514#endif /* SSLEAY_MACROS */
515
516#endif
517
518/* BEGIN ERROR CODES */
519/* Error codes for the PEM functions. */
520
521/* Function codes. */
522#define PEM_F_DEF_CALLBACK 100
523#define PEM_F_LOAD_IV 101
524#define PEM_F_PEM_ASN1_READ 102
525#define PEM_F_PEM_ASN1_READ_BIO 103
526#define PEM_F_PEM_ASN1_WRITE 104
527#define PEM_F_PEM_ASN1_WRITE_BIO 105
528#define PEM_F_PEM_DO_HEADER 106
529#define PEM_F_PEM_GET_EVP_CIPHER_INFO 107
530#define PEM_F_PEM_READ 108
531#define PEM_F_PEM_READ_BIO 109
532#define PEM_F_PEM_SEALFINAL 110
533#define PEM_F_PEM_SEALINIT 111
534#define PEM_F_PEM_SIGNFINAL 112
535#define PEM_F_PEM_WRITE 113
536#define PEM_F_PEM_WRITE_BIO 114
537#define PEM_F_PEM_X509_INFO_READ 115
538#define PEM_F_PEM_X509_INFO_READ_BIO 116
539#define PEM_F_PEM_X509_INFO_WRITE_BIO 117
540
541/* Reason codes. */
542#define PEM_R_BAD_BASE64_DECODE 100
543#define PEM_R_BAD_DECRYPT 101
544#define PEM_R_BAD_END_LINE 102
545#define PEM_R_BAD_IV_CHARS 103
546#define PEM_R_BAD_PASSWORD_READ 104
547#define PEM_R_NOT_DEK_INFO 105
548#define PEM_R_NOT_ENCRYPTED 106
549#define PEM_R_NOT_PROC_TYPE 107
550#define PEM_R_NO_START_LINE 108
551#define PEM_R_PROBLEMS_GETTING_PASSWORD 109
552#define PEM_R_PUBLIC_KEY_NO_RSA 110
553#define PEM_R_READ_KEY 111
554#define PEM_R_SHORT_HEADER 112
555#define PEM_R_UNSUPPORTED_CIPHER 113
556#define PEM_R_UNSUPPORTED_ENCRYPTION 114
557
558#ifdef __cplusplus
559}
560#endif
561#endif
562
diff --git a/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl b/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl
new file mode 100644
index 0000000000..a88359b320
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pkcs7/Makefile.ssl
@@ -0,0 +1,86 @@
1#
2# SSLeay/crypto/asn1/Makefile
3#
4
5DIR= pkcs7
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=pkcs7
19ERRC=pkcs7err
20GENERAL=Makefile README
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= pk7_lib.c pkcs7err.c pk7_doit.c
26LIBOBJ= pk7_lib.o pkcs7err.o pk7_doit.o
27
28SRC= $(LIBSRC)
29
30EXHEADER= pkcs7.h
31HEADER= $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38test:
39
40all: lib
41
42lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ)
44 sh $(TOP)/util/ranlib.sh $(LIB)
45 @touch lib
46
47files:
48 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
49
50links:
51 /bin/rm -f Makefile
52 $(TOP)/util/point.sh Makefile.ssl Makefile ;
53 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
54 $(TOP)/util/mklink.sh ../../test $(TEST)
55 $(TOP)/util/mklink.sh ../../apps $(APPS)
56
57install:
58 @for i in $(EXHEADER) ; \
59 do \
60 (cp $$i $(INSTALLTOP)/include/$$i; \
61 chmod 644 $(INSTALLTOP)/include/$$i ); \
62 done;
63
64tags:
65 ctags $(SRC)
66
67tests:
68
69lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71
72depend:
73 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
74
75dclean:
76 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
77 mv -f Makefile.new $(MAKEFILE)
78
79clean:
80 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
81
82errors:
83 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
84 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
85
86# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/pkcs7/README b/src/lib/libssl/src/crypto/pkcs7/README
new file mode 100644
index 0000000000..27001c6970
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pkcs7/README
@@ -0,0 +1,5 @@
1WARNING
2
3Everything in this directory is experimental and is subject to change.
4
5Do not rely on the stuff in here not changing in the next release
diff --git a/src/lib/libssl/src/crypto/pkcs7/mf.p7 b/src/lib/libssl/src/crypto/pkcs7/mf.p7
new file mode 100644
index 0000000000..524335b4b3
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pkcs7/mf.p7
@@ -0,0 +1,18 @@
1-----BEGIN PKCS7-----
2MIAGCSqGSIb3DQEHAqCAMIIC2QIBATEMMAoGCCqGSIb3DQIFMIAGCSqGSIb3DQEH
3AQAAoIIB7TCCAekwggFSAgEAMA0GCSqGSIb3DQEBBAUAMFsxCzAJBgNVBAYTAkFV
4MRMwEQYDVQQIEwpRdWVlbnNsYW5kMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0
5ZDEbMBkGA1UEAxMSVGVzdCBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0NloX
6DTk4MDYwOTEzNTc0NlowYzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xh
7bmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMSMwIQYDVQQDExpTZXJ2ZXIg
8dGVzdCBjZXJ0ICg1MTIgYml0KTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCfs8OE
9J5X/EjFSDxXvRhHErYDmNlsP3YDXYY3g/HJFCTT+VWZFQ0xol2r+qKCl3194/+7X
10ZLg/BMtv/yr+/rntAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAeEzEdgr2nChPcALL
11vY8gl/GIlpoAjPmKD+pLeGZI9s+SEX5u1q8nCrJ6ZzkfrRnqgI5Anmev9+qPZfdU
12bz5zdVSf4sUL9nX9ChXjK9NCJA3UzQHSFqhZErGUwGNkAHYHp2+zAdY6Ho6rmMzt
13g0CDu/sKR4qzm6REsQGS8kgpjz4xgcUwgcICAQEwYDBbMQswCQYDVQQGEwJBVTET
14MBEGA1UECBMKUXVlZW5zbGFuZDEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQx
15GzAZBgNVBAMTElRlc3QgQ0EgKDEwMjQgYml0KQIBADAKBggqhkiG9w0CBTANBgkq
16hkiG9w0BAQQFAARALnrxJiOX9XZf2D+3vL8SKMQmMq55LltomwOLGUru/q1uVXzi
17ARg7FSCegOpA1nunsTURMUGgrPXKK4XmL4IseQAAAAA=
18-----END PKCS7-----
diff --git a/src/lib/libssl/src/crypto/pkcs7/p7.tst b/src/lib/libssl/src/crypto/pkcs7/p7.tst
new file mode 100644
index 0000000000..6d14dce163
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pkcs7/p7.tst
@@ -0,0 +1,33 @@
1-----BEGIN PKCS7-----
2MIAGCSqGSIb3DQEHAqCAMIIFsQIBATELMAkGBSsOAwIaBQAwgAYJKoZIhvcNAQcB
3AACgggQdMIICJTCCAc+gAwIBAgIBIjANBgkqhkiG9w0BAQQFADCBgjELMAkGA1UE
4BhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxETAPBgNVBAcTCEJyaXNiYW5lMRow
5GAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDEUMBIGA1UECxMLZGV2ZWxvcG1lbnQx
6GTAXBgNVBAMTEENyeXB0U29mdCBEZXYgQ0EwHhcNOTcwNjEzMTgxMDE3WhcNOTgw
7NjEzMTgxMDE3WjCBiDELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx
8ETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDEU
9MBIGA1UECxMLSUlTIHRlc3RpbmcxDjAMBgNVBAMTBXRlc3QxMQ8wDQYJKoZIhvcN
10AQkBFgAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAxtWiv59VH42+rotrmFAyDxTc
11J2osFt5uy/zEllx3vvjtwewqQxGUOwf6cjqFOTrnpEdVvwywpEhIQ5364bJqIwID
12AQABoygwJjAkBglghkgBhvhCAQ0EFxYVR2VuZXJhdGVkIHdpdGggU1NMZWF5MA0G
13CSqGSIb3DQEBBAUAA0EAMnYkNV2AdpeHPy/qlcdZx6MDGIJgrLhklhcn6Or6KiAP
14t9+nv9XdOGHyMyQr9ufsweuQfAgJ9yjKPZR2/adTjTCCAfAwggGaAgEAMA0GCSqG
15SIb3DQEBBAUAMIGCMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDER
16MA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRQw
17EgYDVQQLEwtkZXZlbG9wbWVudDEZMBcGA1UEAxMQQ3J5cHRTb2Z0IERldiBDQTAe
18Fw05NzAzMjIxMzM0MDRaFw05ODAzMjIxMzM0MDRaMIGCMQswCQYDVQQGEwJBVTET
19MBEGA1UECBMKUXVlZW5zbGFuZDERMA8GA1UEBxMIQnJpc2JhbmUxGjAYBgNVBAoT
20EUNyeXB0U29mdCBQdHkgTHRkMRQwEgYDVQQLEwtkZXZlbG9wbWVudDEZMBcGA1UE
21AxMQQ3J5cHRTb2Z0IERldiBDQTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDgDgKq
22IBuUMAJi4c8juAqEZ8f8FcuDWT+HcScvNztRJy9K8DnbGpiSrzzix4El6N4A7vbl
23crwn/0CZmQJguZpfAgMBAAEwDQYJKoZIhvcNAQEEBQADQQA0UUvxlXXe6wKkVukn
24ZoCyXbjlNsqt2rwbvfZEam6fQP3S7uq+o1Pnj+KDgE33WxWbQAA9h8fY1LWN7X3a
25yTm/MYIBbTCCAWkCAQEwgYgwgYIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVl
26bnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0
27eSBMdGQxFDASBgNVBAsTC2RldmVsb3BtZW50MRkwFwYDVQQDExBDcnlwdFNvZnQg
28RGV2IENBAgEiMAkGBSsOAwIaBQCgfTAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcB
29MCMGCSqGSIb3DQEJBDEWBBSUVhbGkNE+KGqpOK13+FkfOkaoizAcBgkqhkiG9w0B
30CQUxDxcNOTcwNzAxMDE0MzM0WjAeBgkqhkiG9w0BCQ8xETAPMA0GCCqGSIb3DQMC
31AgEoMA0GCSqGSIb3DQEBAQUABECa9Jpo4w/fZOc3Vy78wZFAVF8kvpn7il99Ldsr
32AQ4JiBmcfiSwEBBY6WuKT+/SYtFwZl1oXkTwB5AVCFIC/IFNAAAAAA==
33-----END PKCS7-----
diff --git a/src/lib/libssl/src/crypto/pkcs7/pkcs7.err b/src/lib/libssl/src/crypto/pkcs7/pkcs7.err
new file mode 100644
index 0000000000..91413aae43
--- /dev/null
+++ b/src/lib/libssl/src/crypto/pkcs7/pkcs7.err
@@ -0,0 +1,26 @@
1/* Error codes for the PKCS7 functions. */
2
3/* Function codes. */
4#define PKCS7_F_PKCS7_ADD_CERTIFICATE 100
5#define PKCS7_F_PKCS7_ADD_CRL 101
6#define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102
7#define PKCS7_F_PKCS7_ADD_SIGNER 103
8#define PKCS7_F_PKCS7_CTRL 104
9#define PKCS7_F_PKCS7_DATAINIT 105
10#define PKCS7_F_PKCS7_DATASIGN 106
11#define PKCS7_F_PKCS7_DATAVERIFY 107
12#define PKCS7_F_PKCS7_SET_CIPHER 108
13#define PKCS7_F_PKCS7_SET_CONTENT 109
14#define PKCS7_F_PKCS7_SET_TYPE 110
15
16/* Reason codes. */
17#define PKCS7_R_INTERNAL_ERROR 100
18#define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 101
19#define PKCS7_R_SIGNATURE_FAILURE 102
20#define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 103
21#define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 104
22#define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 105
23#define PKCS7_R_UNKNOWN_DIGEST_TYPE 106
24#define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 107
25#define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 108
26#define PKCS7_R_WRONG_CONTENT_TYPE 109
diff --git a/src/lib/libssl/src/crypto/rand/Makefile.ssl b/src/lib/libssl/src/crypto/rand/Makefile.ssl
new file mode 100644
index 0000000000..d04f0a9b43
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rand/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/rand/Makefile
3#
4
5DIR= rand
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST= randtest.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=md_rand.c randfile.c
24LIBOBJ=md_rand.o randfile.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= rand.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/ranlib.sh b/src/lib/libssl/src/crypto/ranlib.sh
new file mode 100644
index 0000000000..543f712c6b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/ranlib.sh
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3cwd=`pwd`
4cd /tmp
5
6if [ -s /bin/ranlib ] ; then
7 RL=/bin/ranlib
8else if [ -s /usr/bin/ranlib ] ; then
9 RL=/usr/bin/ranlib
10fi
11fi
12
13if [ "x$RL" != "x" ]
14then
15 case "$1" in
16 /*)
17 $RL "$1"
18 ;;
19 *)
20 $RL "$cwd/$1"
21 ;;
22 esac
23fi
diff --git a/src/lib/libssl/src/crypto/rc2/Makefile.ssl b/src/lib/libssl/src/crypto/rc2/Makefile.ssl
new file mode 100644
index 0000000000..c5138f13e2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc2/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/rc2/Makefile
3#
4
5DIR= rc2
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=rc2test.c
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c rc2ofb64.c
24LIBOBJ=rc2_ecb.o rc2_skey.o rc2_cbc.o rc2cfb64.o rc2ofb64.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= rc2.h
29HEADER= rc2_locl.h $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/rc2/Makefile.uni b/src/lib/libssl/src/crypto/rc2/Makefile.uni
new file mode 100644
index 0000000000..e50b3f2d19
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc2/Makefile.uni
@@ -0,0 +1,72 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5
6DIR= rc2
7TOP= .
8CC= gcc
9CFLAG= -O3 -fomit-frame-pointer
10
11CPP= $(CC) -E
12INCLUDES=
13INSTALLTOP=/usr/local/lib
14MAKE= make
15MAKEDEPEND= makedepend
16MAKEFILE= Makefile.uni
17AR= ar r
18
19IDEA_ENC=rc2_cbc.o
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL=Makefile
24TEST=rc2test
25APPS=rc2speed
26
27LIB=librc2.a
28LIBSRC=rc2_skey.c rc2_ecb.c rc2_cbc.c rc2cfb64.c rc2ofb64.c
29LIBOBJ=rc2_skey.o rc2_ecb.o $(IDEA_ENC) rc2cfb64.o rc2ofb64.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= rc2.h
34HEADER= rc2_locl.h $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38all: $(LIB) $(TEST) $(APPS)
39
40$(LIB): $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/ranlib.sh $(LIB)
43
44test: $(TEST)
45 ./$(TEST)
46
47$(TEST): $(TEST).c $(LIB)
48 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
49
50$(APPS): $(APPS).c $(LIB)
51 $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
52
53lint:
54 lint -DLINT $(INCLUDES) $(SRC)>fluff
55
56depend:
57 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
58
59dclean:
60 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
61 mv -f Makefile.new $(MAKEFILE)
62
63clean:
64 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
65
66cc:
67 $(MAKE) CC="cc" CFLAG="-O" all
68
69gcc:
70 $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
71
72# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/rc2/rc2.org b/src/lib/libssl/src/crypto/rc2/rc2.org
new file mode 100644
index 0000000000..37354cfa62
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc2/rc2.org
@@ -0,0 +1,118 @@
1/* crypto/rc2/rc2.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify rc2.org since rc2.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_RC2_H
68#define HEADER_RC2_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74#define RC2_ENCRYPT 1
75#define RC2_DECRYPT 0
76
77/* I need to put in a mod for the alpha - eay */
78#define RC2_INT unsigned short
79
80#define RC2_BLOCK 8
81#define RC2_KEY_LENGTH 16
82
83typedef struct rc2_key_st
84 {
85 RC2_INT data[64];
86 } RC2_KEY;
87
88#ifndef NOPROTO
89
90void RC2_set_key(RC2_KEY *key, int len, unsigned char *data,int bits);
91void RC2_ecb_encrypt(unsigned char *in,unsigned char *out,RC2_KEY *key,
92 int enc);
93void RC2_encrypt(unsigned long *data,RC2_KEY *key);
94void RC2_decrypt(unsigned long *data,RC2_KEY *key);
95void RC2_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
96 RC2_KEY *ks, unsigned char *iv, int enc);
97void RC2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
98 RC2_KEY *schedule, unsigned char *ivec, int *num, int enc);
99void RC2_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
100 RC2_KEY *schedule, unsigned char *ivec, int *num);
101
102#else
103
104void RC2_set_key();
105void RC2_ecb_encrypt();
106void RC2_encrypt();
107void RC2_decrypt();
108void RC2_cbc_encrypt();
109void RC2_cfb64_encrypt();
110void RC2_ofb64_encrypt();
111
112#endif
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif
diff --git a/src/lib/libssl/src/crypto/rc4/Makefile.ssl b/src/lib/libssl/src/crypto/rc4/Makefile.ssl
new file mode 100644
index 0000000000..19c1e980f3
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc4/Makefile.ssl
@@ -0,0 +1,108 @@
1#
2# SSLeay/crypto/rc4/Makefile
3#
4
5DIR= rc4
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16RC4_ENC=rc4_enc.o
17# or use
18#RC4_ENC=asm/rx86-elf.o
19#RC4_ENC=asm/rx86-out.o
20#RC4_ENC=asm/rx86-sol.o
21#RC4_ENC=asm/rx86bdsi.o
22
23CFLAGS= $(INCLUDES) $(CFLAG)
24
25GENERAL=Makefile
26TEST=rc4test.c
27APPS=
28
29LIB=$(TOP)/libcrypto.a
30LIBSRC=rc4_skey.c rc4_enc.c
31LIBOBJ=rc4_skey.o $(RC4_ENC)
32
33SRC= $(LIBSRC)
34
35EXHEADER= rc4.h
36HEADER= $(EXHEADER) rc4_locl.h
37
38ALL= $(GENERAL) $(SRC) $(HEADER)
39
40top:
41 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
42
43all: lib
44
45lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ)
47 sh $(TOP)/util/ranlib.sh $(LIB)
48 @touch lib
49
50# elf
51asm/rx86-elf.o: asm/rx86unix.cpp
52 $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o
53
54# solaris
55asm/rx86-sol.o: asm/rx86unix.cpp
56 $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s
57 as -o asm/rx86-sol.o asm/rx86-sol.s
58 rm -f asm/rx86-sol.s
59
60# a.out
61asm/rx86-out.o: asm/rx86unix.cpp
62 $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o
63
64# bsdi
65asm/rx86bsdi.o: asm/rx86unix.cpp
66 $(CPP) -DBSDI asm/rx86unix.cpp | as -o asm/rx86bsdi.o
67
68asm/rx86unix.cpp:
69 (cd asm; perl rc4-586.pl cpp >rx86unix.cpp)
70
71files:
72 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
73
74links:
75 /bin/rm -f Makefile
76 $(TOP)/util/point.sh Makefile.ssl Makefile ;
77 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
78 $(TOP)/util/mklink.sh ../../test $(TEST)
79 $(TOP)/util/mklink.sh ../../apps $(APPS)
80
81install:
82 @for i in $(EXHEADER) ; \
83 do \
84 (cp $$i $(INSTALLTOP)/include/$$i; \
85 chmod 644 $(INSTALLTOP)/include/$$i ); \
86 done;
87
88tags:
89 ctags $(SRC)
90
91tests:
92
93lint:
94 lint -DLINT $(INCLUDES) $(SRC)>fluff
95
96depend:
97 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
98
99dclean:
100 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
101 mv -f Makefile.new $(MAKEFILE)
102
103clean:
104 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o
105
106errors:
107
108# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/rc4/Makefile.uni b/src/lib/libssl/src/crypto/rc4/Makefile.uni
new file mode 100644
index 0000000000..79dc17b8d1
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc4/Makefile.uni
@@ -0,0 +1,102 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= rc4
11TOP= .
12CC= gcc
13CFLAG= -O3 -fomit-frame-pointer
14
15CPP= $(CC) -E
16INCLUDES=
17INSTALLTOP=/usr/local/lib
18MAKE= make
19MAKEDEPEND= makedepend
20MAKEFILE= Makefile.uni
21AR= ar r
22
23RC4_ENC=rc4_enc.o
24# or use
25#RC4_ENC=asm/rx86-elf.o
26#RC4_ENC=asm/rx86-out.o
27#RC4_ENC=asm/rx86-sol.o
28#RC4_ENC=asm/rx86bdsi.o
29
30CFLAGS= $(INCLUDES) $(CFLAG)
31
32GENERAL=Makefile
33TEST=rc4test
34APPS=rc4speed
35
36LIB=librc4.a
37LIBSRC=rc4_skey.c rc4_enc.c
38LIBOBJ=rc4_skey.o $(RC4_ENC)
39
40SRC= $(LIBSRC)
41
42EXHEADER= rc4.h
43HEADER= $(EXHEADER) rc4_locl.h
44
45ALL= $(GENERAL) $(SRC) $(HEADER)
46
47all: $(LIB) $(TEST) $(APPS)
48
49$(LIB): $(LIBOBJ)
50 $(AR) $(LIB) $(LIBOBJ)
51 sh $(TOP)/ranlib.sh $(LIB)
52
53# elf
54asm/rx86-elf.o: asm/rx86unix.cpp
55 $(CPP) -DELF asm/rx86unix.cpp | as -o asm/rx86-elf.o
56
57# solaris
58asm/rx86-sol.o: asm/rx86unix.cpp
59 $(CC) -E -DSOL asm/rx86unix.cpp | sed 's/^#.*//' > asm/rx86-sol.s
60 as -o asm/rx86-sol.o asm/rx86-sol.s
61 rm -f asm/rx86-sol.s
62
63# a.out
64asm/rx86-out.o: asm/rx86unix.cpp
65 $(CPP) -DOUT asm/rx86unix.cpp | as -o asm/rx86-out.o
66
67# bsdi
68asm/rx86bsdi.o: asm/rx86unix.cpp
69 $(CPP) -DBSDI asm/rx86unix.cpp | as -o asm/rx86bsdi.o
70
71asm/rx86unix.cpp:
72 (cd asm; perl rc4-586.pl cpp >rx86unix.cpp)
73
74test: $(TEST)
75 ./$(TEST)
76
77$(TEST): $(TEST).c $(LIB)
78 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
79
80$(APPS): $(APPS).c $(LIB)
81 $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
82
83lint:
84 lint -DLINT $(INCLUDES) $(SRC)>fluff
85
86depend:
87 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
88
89dclean:
90 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
91 mv -f Makefile.new $(MAKEFILE)
92
93clean:
94 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
95
96cc:
97 $(MAKE) CC="cc" CFLAG="-O" all
98
99gcc:
100 $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
101
102# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/rc4/asm/r4-win32.asm b/src/lib/libssl/src/crypto/rc4/asm/r4-win32.asm
new file mode 100644
index 0000000000..70b0f7484c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc4/asm/r4-win32.asm
@@ -0,0 +1,314 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by rc4-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE rc4-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _RC4
12
13_RC4 PROC NEAR
14 ;
15 push ebp
16 push ebx
17 mov ebp, DWORD PTR 12[esp]
18 mov ebx, DWORD PTR 16[esp]
19 push esi
20 push edi
21 mov ecx, DWORD PTR [ebp]
22 mov edx, DWORD PTR 4[ebp]
23 mov esi, DWORD PTR 28[esp]
24 inc ecx
25 sub esp, 12
26 add ebp, 8
27 and ecx, 255
28 lea ebx, DWORD PTR [esi+ebx-8]
29 mov edi, DWORD PTR 44[esp]
30 mov DWORD PTR 8[esp],ebx
31 mov eax, DWORD PTR [ecx*4+ebp]
32 cmp ebx, esi
33 jl $L000end
34L001start:
35 add esi, 8
36 ; Round 0
37 add edx, eax
38 and edx, 255
39 inc ecx
40 mov ebx, DWORD PTR [edx*4+ebp]
41 mov DWORD PTR [ecx*4+ebp-4],ebx
42 add ebx, eax
43 and ecx, 255
44 and ebx, 255
45 mov DWORD PTR [edx*4+ebp],eax
46 nop
47 mov ebx, DWORD PTR [ebx*4+ebp]
48 mov eax, DWORD PTR [ecx*4+ebp]
49 mov BYTE PTR [esp], bl
50 ; Round 1
51 add edx, eax
52 and edx, 255
53 inc ecx
54 mov ebx, DWORD PTR [edx*4+ebp]
55 mov DWORD PTR [ecx*4+ebp-4],ebx
56 add ebx, eax
57 and ecx, 255
58 and ebx, 255
59 mov DWORD PTR [edx*4+ebp],eax
60 nop
61 mov ebx, DWORD PTR [ebx*4+ebp]
62 mov eax, DWORD PTR [ecx*4+ebp]
63 mov BYTE PTR 1[esp],bl
64 ; Round 2
65 add edx, eax
66 and edx, 255
67 inc ecx
68 mov ebx, DWORD PTR [edx*4+ebp]
69 mov DWORD PTR [ecx*4+ebp-4],ebx
70 add ebx, eax
71 and ecx, 255
72 and ebx, 255
73 mov DWORD PTR [edx*4+ebp],eax
74 nop
75 mov ebx, DWORD PTR [ebx*4+ebp]
76 mov eax, DWORD PTR [ecx*4+ebp]
77 mov BYTE PTR 2[esp],bl
78 ; Round 3
79 add edx, eax
80 and edx, 255
81 inc ecx
82 mov ebx, DWORD PTR [edx*4+ebp]
83 mov DWORD PTR [ecx*4+ebp-4],ebx
84 add ebx, eax
85 and ecx, 255
86 and ebx, 255
87 mov DWORD PTR [edx*4+ebp],eax
88 nop
89 mov ebx, DWORD PTR [ebx*4+ebp]
90 mov eax, DWORD PTR [ecx*4+ebp]
91 mov BYTE PTR 3[esp],bl
92 ; Round 4
93 add edx, eax
94 and edx, 255
95 inc ecx
96 mov ebx, DWORD PTR [edx*4+ebp]
97 mov DWORD PTR [ecx*4+ebp-4],ebx
98 add ebx, eax
99 and ecx, 255
100 and ebx, 255
101 mov DWORD PTR [edx*4+ebp],eax
102 nop
103 mov ebx, DWORD PTR [ebx*4+ebp]
104 mov eax, DWORD PTR [ecx*4+ebp]
105 mov BYTE PTR 4[esp],bl
106 ; Round 5
107 add edx, eax
108 and edx, 255
109 inc ecx
110 mov ebx, DWORD PTR [edx*4+ebp]
111 mov DWORD PTR [ecx*4+ebp-4],ebx
112 add ebx, eax
113 and ecx, 255
114 and ebx, 255
115 mov DWORD PTR [edx*4+ebp],eax
116 nop
117 mov ebx, DWORD PTR [ebx*4+ebp]
118 mov eax, DWORD PTR [ecx*4+ebp]
119 mov BYTE PTR 5[esp],bl
120 ; Round 6
121 add edx, eax
122 and edx, 255
123 inc ecx
124 mov ebx, DWORD PTR [edx*4+ebp]
125 mov DWORD PTR [ecx*4+ebp-4],ebx
126 add ebx, eax
127 and ecx, 255
128 and ebx, 255
129 mov DWORD PTR [edx*4+ebp],eax
130 nop
131 mov ebx, DWORD PTR [ebx*4+ebp]
132 mov eax, DWORD PTR [ecx*4+ebp]
133 mov BYTE PTR 6[esp],bl
134 ; Round 7
135 add edx, eax
136 and edx, 255
137 inc ecx
138 mov ebx, DWORD PTR [edx*4+ebp]
139 mov DWORD PTR [ecx*4+ebp-4],ebx
140 add ebx, eax
141 and ecx, 255
142 and ebx, 255
143 mov DWORD PTR [edx*4+ebp],eax
144 nop
145 mov ebx, DWORD PTR [ebx*4+ebp]
146 add edi, 8
147 mov BYTE PTR 7[esp],bl
148 ; apply the cipher text
149 mov eax, DWORD PTR [esp]
150 mov ebx, DWORD PTR [esi-8]
151 xor eax, ebx
152 mov ebx, DWORD PTR [esi-4]
153 mov DWORD PTR [edi-8],eax
154 mov eax, DWORD PTR 4[esp]
155 xor eax, ebx
156 mov ebx, DWORD PTR 8[esp]
157 mov DWORD PTR [edi-4],eax
158 mov eax, DWORD PTR [ecx*4+ebp]
159 cmp esi, ebx
160 jle L001start
161$L000end:
162 ; Round 0
163 add ebx, 8
164 inc esi
165 cmp ebx, esi
166 jl $L002finished
167 mov DWORD PTR 8[esp],ebx
168 add edx, eax
169 and edx, 255
170 inc ecx
171 mov ebx, DWORD PTR [edx*4+ebp]
172 mov DWORD PTR [ecx*4+ebp-4],ebx
173 add ebx, eax
174 and ecx, 255
175 and ebx, 255
176 mov DWORD PTR [edx*4+ebp],eax
177 nop
178 mov ebx, DWORD PTR [ebx*4+ebp]
179 mov eax, DWORD PTR [ecx*4+ebp]
180 mov bh, BYTE PTR [esi-1]
181 xor bl, bh
182 mov BYTE PTR [edi], bl
183 ; Round 1
184 mov ebx, DWORD PTR 8[esp]
185 cmp ebx, esi
186 jle $L002finished
187 inc esi
188 add edx, eax
189 and edx, 255
190 inc ecx
191 mov ebx, DWORD PTR [edx*4+ebp]
192 mov DWORD PTR [ecx*4+ebp-4],ebx
193 add ebx, eax
194 and ecx, 255
195 and ebx, 255
196 mov DWORD PTR [edx*4+ebp],eax
197 nop
198 mov ebx, DWORD PTR [ebx*4+ebp]
199 mov eax, DWORD PTR [ecx*4+ebp]
200 mov bh, BYTE PTR [esi-1]
201 xor bl, bh
202 mov BYTE PTR 1[edi],bl
203 ; Round 2
204 mov ebx, DWORD PTR 8[esp]
205 cmp ebx, esi
206 jle $L002finished
207 inc esi
208 add edx, eax
209 and edx, 255
210 inc ecx
211 mov ebx, DWORD PTR [edx*4+ebp]
212 mov DWORD PTR [ecx*4+ebp-4],ebx
213 add ebx, eax
214 and ecx, 255
215 and ebx, 255
216 mov DWORD PTR [edx*4+ebp],eax
217 nop
218 mov ebx, DWORD PTR [ebx*4+ebp]
219 mov eax, DWORD PTR [ecx*4+ebp]
220 mov bh, BYTE PTR [esi-1]
221 xor bl, bh
222 mov BYTE PTR 2[edi],bl
223 ; Round 3
224 mov ebx, DWORD PTR 8[esp]
225 cmp ebx, esi
226 jle $L002finished
227 inc esi
228 add edx, eax
229 and edx, 255
230 inc ecx
231 mov ebx, DWORD PTR [edx*4+ebp]
232 mov DWORD PTR [ecx*4+ebp-4],ebx
233 add ebx, eax
234 and ecx, 255
235 and ebx, 255
236 mov DWORD PTR [edx*4+ebp],eax
237 nop
238 mov ebx, DWORD PTR [ebx*4+ebp]
239 mov eax, DWORD PTR [ecx*4+ebp]
240 mov bh, BYTE PTR [esi-1]
241 xor bl, bh
242 mov BYTE PTR 3[edi],bl
243 ; Round 4
244 mov ebx, DWORD PTR 8[esp]
245 cmp ebx, esi
246 jle $L002finished
247 inc esi
248 add edx, eax
249 and edx, 255
250 inc ecx
251 mov ebx, DWORD PTR [edx*4+ebp]
252 mov DWORD PTR [ecx*4+ebp-4],ebx
253 add ebx, eax
254 and ecx, 255
255 and ebx, 255
256 mov DWORD PTR [edx*4+ebp],eax
257 nop
258 mov ebx, DWORD PTR [ebx*4+ebp]
259 mov eax, DWORD PTR [ecx*4+ebp]
260 mov bh, BYTE PTR [esi-1]
261 xor bl, bh
262 mov BYTE PTR 4[edi],bl
263 ; Round 5
264 mov ebx, DWORD PTR 8[esp]
265 cmp ebx, esi
266 jle $L002finished
267 inc esi
268 add edx, eax
269 and edx, 255
270 inc ecx
271 mov ebx, DWORD PTR [edx*4+ebp]
272 mov DWORD PTR [ecx*4+ebp-4],ebx
273 add ebx, eax
274 and ecx, 255
275 and ebx, 255
276 mov DWORD PTR [edx*4+ebp],eax
277 nop
278 mov ebx, DWORD PTR [ebx*4+ebp]
279 mov eax, DWORD PTR [ecx*4+ebp]
280 mov bh, BYTE PTR [esi-1]
281 xor bl, bh
282 mov BYTE PTR 5[edi],bl
283 ; Round 6
284 mov ebx, DWORD PTR 8[esp]
285 cmp ebx, esi
286 jle $L002finished
287 inc esi
288 add edx, eax
289 and edx, 255
290 inc ecx
291 mov ebx, DWORD PTR [edx*4+ebp]
292 mov DWORD PTR [ecx*4+ebp-4],ebx
293 add ebx, eax
294 and ecx, 255
295 and ebx, 255
296 mov DWORD PTR [edx*4+ebp],eax
297 nop
298 mov ebx, DWORD PTR [ebx*4+ebp]
299 mov bh, BYTE PTR [esi-1]
300 xor bl, bh
301 mov BYTE PTR 6[edi],bl
302$L002finished:
303 dec ecx
304 add esp, 12
305 mov DWORD PTR [ebp-4],edx
306 mov BYTE PTR [ebp-8],cl
307 pop edi
308 pop esi
309 pop ebx
310 pop ebp
311 ret
312_RC4 ENDP
313_TEXT ENDS
314END
diff --git a/src/lib/libssl/src/crypto/rc4/asm/rx86unix.cpp b/src/lib/libssl/src/crypto/rc4/asm/rx86unix.cpp
new file mode 100644
index 0000000000..ec1d72a110
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc4/asm/rx86unix.cpp
@@ -0,0 +1,358 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define RC4 _RC4
13
14#endif
15
16#ifdef OUT
17#define OK 1
18#define ALIGN 4
19#endif
20
21#ifdef BSDI
22#define OK 1
23#define ALIGN 4
24#undef SIZE
25#undef TYPE
26#define SIZE(a,b)
27#define TYPE(a,b)
28#endif
29
30#if defined(ELF) || defined(SOL)
31#define OK 1
32#define ALIGN 16
33#endif
34
35#ifndef OK
36You need to define one of
37ELF - elf systems - linux-elf, NetBSD and DG-UX
38OUT - a.out systems - linux-a.out and FreeBSD
39SOL - solaris systems, which are elf with strange comment lines
40BSDI - a.out with a very primative version of as.
41#endif
42
43/* Let the Assembler begin :-) */
44 /* Don't even think of reading this code */
45 /* It was automatically generated by rc4-586.pl */
46 /* Which is a perl program used to generate the x86 assember for */
47 /* any of elf, a.out, BSDI,Win32, or Solaris */
48 /* eric <eay@cryptsoft.com> */
49
50 .file "rc4-586.s"
51 .version "01.01"
52gcc2_compiled.:
53.text
54 .align ALIGN
55.globl RC4
56 TYPE(RC4,@function)
57RC4:
58
59 pushl %ebp
60 pushl %ebx
61 movl 12(%esp), %ebp
62 movl 16(%esp), %ebx
63 pushl %esi
64 pushl %edi
65 movl (%ebp), %ecx
66 movl 4(%ebp), %edx
67 movl 28(%esp), %esi
68 incl %ecx
69 subl $12, %esp
70 addl $8, %ebp
71 andl $255, %ecx
72 leal -8(%ebx,%esi,), %ebx
73 movl 44(%esp), %edi
74 movl %ebx, 8(%esp)
75 movl (%ebp,%ecx,4), %eax
76 cmpl %esi, %ebx
77 jl .L000end
78.L001start:
79 addl $8, %esi
80 /* Round 0 */
81 addl %eax, %edx
82 andl $255, %edx
83 incl %ecx
84 movl (%ebp,%edx,4), %ebx
85 movl %ebx, -4(%ebp,%ecx,4)
86 addl %eax, %ebx
87 andl $255, %ecx
88 andl $255, %ebx
89 movl %eax, (%ebp,%edx,4)
90 nop
91 movl (%ebp,%ebx,4), %ebx
92 movl (%ebp,%ecx,4), %eax
93 movb %bl, (%esp)
94 /* Round 1 */
95 addl %eax, %edx
96 andl $255, %edx
97 incl %ecx
98 movl (%ebp,%edx,4), %ebx
99 movl %ebx, -4(%ebp,%ecx,4)
100 addl %eax, %ebx
101 andl $255, %ecx
102 andl $255, %ebx
103 movl %eax, (%ebp,%edx,4)
104 nop
105 movl (%ebp,%ebx,4), %ebx
106 movl (%ebp,%ecx,4), %eax
107 movb %bl, 1(%esp)
108 /* Round 2 */
109 addl %eax, %edx
110 andl $255, %edx
111 incl %ecx
112 movl (%ebp,%edx,4), %ebx
113 movl %ebx, -4(%ebp,%ecx,4)
114 addl %eax, %ebx
115 andl $255, %ecx
116 andl $255, %ebx
117 movl %eax, (%ebp,%edx,4)
118 nop
119 movl (%ebp,%ebx,4), %ebx
120 movl (%ebp,%ecx,4), %eax
121 movb %bl, 2(%esp)
122 /* Round 3 */
123 addl %eax, %edx
124 andl $255, %edx
125 incl %ecx
126 movl (%ebp,%edx,4), %ebx
127 movl %ebx, -4(%ebp,%ecx,4)
128 addl %eax, %ebx
129 andl $255, %ecx
130 andl $255, %ebx
131 movl %eax, (%ebp,%edx,4)
132 nop
133 movl (%ebp,%ebx,4), %ebx
134 movl (%ebp,%ecx,4), %eax
135 movb %bl, 3(%esp)
136 /* Round 4 */
137 addl %eax, %edx
138 andl $255, %edx
139 incl %ecx
140 movl (%ebp,%edx,4), %ebx
141 movl %ebx, -4(%ebp,%ecx,4)
142 addl %eax, %ebx
143 andl $255, %ecx
144 andl $255, %ebx
145 movl %eax, (%ebp,%edx,4)
146 nop
147 movl (%ebp,%ebx,4), %ebx
148 movl (%ebp,%ecx,4), %eax
149 movb %bl, 4(%esp)
150 /* Round 5 */
151 addl %eax, %edx
152 andl $255, %edx
153 incl %ecx
154 movl (%ebp,%edx,4), %ebx
155 movl %ebx, -4(%ebp,%ecx,4)
156 addl %eax, %ebx
157 andl $255, %ecx
158 andl $255, %ebx
159 movl %eax, (%ebp,%edx,4)
160 nop
161 movl (%ebp,%ebx,4), %ebx
162 movl (%ebp,%ecx,4), %eax
163 movb %bl, 5(%esp)
164 /* Round 6 */
165 addl %eax, %edx
166 andl $255, %edx
167 incl %ecx
168 movl (%ebp,%edx,4), %ebx
169 movl %ebx, -4(%ebp,%ecx,4)
170 addl %eax, %ebx
171 andl $255, %ecx
172 andl $255, %ebx
173 movl %eax, (%ebp,%edx,4)
174 nop
175 movl (%ebp,%ebx,4), %ebx
176 movl (%ebp,%ecx,4), %eax
177 movb %bl, 6(%esp)
178 /* Round 7 */
179 addl %eax, %edx
180 andl $255, %edx
181 incl %ecx
182 movl (%ebp,%edx,4), %ebx
183 movl %ebx, -4(%ebp,%ecx,4)
184 addl %eax, %ebx
185 andl $255, %ecx
186 andl $255, %ebx
187 movl %eax, (%ebp,%edx,4)
188 nop
189 movl (%ebp,%ebx,4), %ebx
190 addl $8, %edi
191 movb %bl, 7(%esp)
192 /* apply the cipher text */
193 movl (%esp), %eax
194 movl -8(%esi), %ebx
195 xorl %ebx, %eax
196 movl -4(%esi), %ebx
197 movl %eax, -8(%edi)
198 movl 4(%esp), %eax
199 xorl %ebx, %eax
200 movl 8(%esp), %ebx
201 movl %eax, -4(%edi)
202 movl (%ebp,%ecx,4), %eax
203 cmpl %ebx, %esi
204 jle .L001start
205.L000end:
206 /* Round 0 */
207 addl $8, %ebx
208 incl %esi
209 cmpl %esi, %ebx
210 jl .L002finished
211 movl %ebx, 8(%esp)
212 addl %eax, %edx
213 andl $255, %edx
214 incl %ecx
215 movl (%ebp,%edx,4), %ebx
216 movl %ebx, -4(%ebp,%ecx,4)
217 addl %eax, %ebx
218 andl $255, %ecx
219 andl $255, %ebx
220 movl %eax, (%ebp,%edx,4)
221 nop
222 movl (%ebp,%ebx,4), %ebx
223 movl (%ebp,%ecx,4), %eax
224 movb -1(%esi), %bh
225 xorb %bh, %bl
226 movb %bl, (%edi)
227 /* Round 1 */
228 movl 8(%esp), %ebx
229 cmpl %esi, %ebx
230 jle .L002finished
231 incl %esi
232 addl %eax, %edx
233 andl $255, %edx
234 incl %ecx
235 movl (%ebp,%edx,4), %ebx
236 movl %ebx, -4(%ebp,%ecx,4)
237 addl %eax, %ebx
238 andl $255, %ecx
239 andl $255, %ebx
240 movl %eax, (%ebp,%edx,4)
241 nop
242 movl (%ebp,%ebx,4), %ebx
243 movl (%ebp,%ecx,4), %eax
244 movb -1(%esi), %bh
245 xorb %bh, %bl
246 movb %bl, 1(%edi)
247 /* Round 2 */
248 movl 8(%esp), %ebx
249 cmpl %esi, %ebx
250 jle .L002finished
251 incl %esi
252 addl %eax, %edx
253 andl $255, %edx
254 incl %ecx
255 movl (%ebp,%edx,4), %ebx
256 movl %ebx, -4(%ebp,%ecx,4)
257 addl %eax, %ebx
258 andl $255, %ecx
259 andl $255, %ebx
260 movl %eax, (%ebp,%edx,4)
261 nop
262 movl (%ebp,%ebx,4), %ebx
263 movl (%ebp,%ecx,4), %eax
264 movb -1(%esi), %bh
265 xorb %bh, %bl
266 movb %bl, 2(%edi)
267 /* Round 3 */
268 movl 8(%esp), %ebx
269 cmpl %esi, %ebx
270 jle .L002finished
271 incl %esi
272 addl %eax, %edx
273 andl $255, %edx
274 incl %ecx
275 movl (%ebp,%edx,4), %ebx
276 movl %ebx, -4(%ebp,%ecx,4)
277 addl %eax, %ebx
278 andl $255, %ecx
279 andl $255, %ebx
280 movl %eax, (%ebp,%edx,4)
281 nop
282 movl (%ebp,%ebx,4), %ebx
283 movl (%ebp,%ecx,4), %eax
284 movb -1(%esi), %bh
285 xorb %bh, %bl
286 movb %bl, 3(%edi)
287 /* Round 4 */
288 movl 8(%esp), %ebx
289 cmpl %esi, %ebx
290 jle .L002finished
291 incl %esi
292 addl %eax, %edx
293 andl $255, %edx
294 incl %ecx
295 movl (%ebp,%edx,4), %ebx
296 movl %ebx, -4(%ebp,%ecx,4)
297 addl %eax, %ebx
298 andl $255, %ecx
299 andl $255, %ebx
300 movl %eax, (%ebp,%edx,4)
301 nop
302 movl (%ebp,%ebx,4), %ebx
303 movl (%ebp,%ecx,4), %eax
304 movb -1(%esi), %bh
305 xorb %bh, %bl
306 movb %bl, 4(%edi)
307 /* Round 5 */
308 movl 8(%esp), %ebx
309 cmpl %esi, %ebx
310 jle .L002finished
311 incl %esi
312 addl %eax, %edx
313 andl $255, %edx
314 incl %ecx
315 movl (%ebp,%edx,4), %ebx
316 movl %ebx, -4(%ebp,%ecx,4)
317 addl %eax, %ebx
318 andl $255, %ecx
319 andl $255, %ebx
320 movl %eax, (%ebp,%edx,4)
321 nop
322 movl (%ebp,%ebx,4), %ebx
323 movl (%ebp,%ecx,4), %eax
324 movb -1(%esi), %bh
325 xorb %bh, %bl
326 movb %bl, 5(%edi)
327 /* Round 6 */
328 movl 8(%esp), %ebx
329 cmpl %esi, %ebx
330 jle .L002finished
331 incl %esi
332 addl %eax, %edx
333 andl $255, %edx
334 incl %ecx
335 movl (%ebp,%edx,4), %ebx
336 movl %ebx, -4(%ebp,%ecx,4)
337 addl %eax, %ebx
338 andl $255, %ecx
339 andl $255, %ebx
340 movl %eax, (%ebp,%edx,4)
341 nop
342 movl (%ebp,%ebx,4), %ebx
343 movb -1(%esi), %bh
344 xorb %bh, %bl
345 movb %bl, 6(%edi)
346.L002finished:
347 decl %ecx
348 addl $12, %esp
349 movl %edx, -4(%ebp)
350 movb %cl, -8(%ebp)
351 popl %edi
352 popl %esi
353 popl %ebx
354 popl %ebp
355 ret
356.RC4_end:
357 SIZE(RC4,.RC4_end-RC4)
358.ident "RC4"
diff --git a/src/lib/libssl/src/crypto/rc4/rc4.org b/src/lib/libssl/src/crypto/rc4/rc4.org
new file mode 100644
index 0000000000..c558651af8
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc4/rc4.org
@@ -0,0 +1,103 @@
1/* crypto/rc4/rc4.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify rc4.org since rc4.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67#ifndef HEADER_RC4_H
68#define HEADER_RC4_H
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74/* using int types make the structure larger but make the code faster
75 * on most boxes I have tested - up to %20 faster. */
76#define RC4_INT unsigned int
77
78typedef struct rc4_key_st
79 {
80 RC4_INT x,y;
81 RC4_INT data[256];
82 } RC4_KEY;
83
84#ifndef NOPROTO
85
86char *RC4_options(void);
87void RC4_set_key(RC4_KEY *key, int len, unsigned char *data);
88void RC4(RC4_KEY *key, unsigned long len, unsigned char *indata,
89 unsigned char *outdata);
90
91#else
92
93char *RC4_options();
94void RC4_set_key();
95void RC4();
96
97#endif
98
99#ifdef __cplusplus
100}
101#endif
102
103#endif
diff --git a/src/lib/libssl/src/crypto/rc4/rc4_locl.org b/src/lib/libssl/src/crypto/rc4/rc4_locl.org
new file mode 100644
index 0000000000..1ef4455fb7
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc4/rc4_locl.org
@@ -0,0 +1,70 @@
1/* crypto/rc4/rc4_locl.org */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
60 *
61 * Always modify bf_locl.org since bf_locl.h is automatically generated from
62 * it during SSLeay configuration.
63 *
64 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
65 */
66
67/* if this is defined data[i] is used instead of *data, this is a %20
68 * speedup on x86 */
69#undef RC4_INDEX
70
diff --git a/src/lib/libssl/src/crypto/rc5/Makefile.ssl b/src/lib/libssl/src/crypto/rc5/Makefile.ssl
new file mode 100644
index 0000000000..5e98ee2348
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/Makefile.ssl
@@ -0,0 +1,107 @@
1#
2# SSLeay/crypto/rc5/Makefile
3#
4
5DIR= rc5
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17RC5_ENC= rc5_enc.o
18# or use
19#DES_ENC= r586-elf.o
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL=Makefile
24TEST=rc5test.c
25APPS=
26
27LIB=$(TOP)/libcrypto.a
28LIBSRC=rc5_skey.c rc5_ecb.c rc5_enc.c rc5cfb64.c rc5ofb64.c
29LIBOBJ=rc5_skey.o rc5_ecb.o $(RC5_ENC) rc5cfb64.o rc5ofb64.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= rc5.h
34HEADER= rc5_locl.h $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38top:
39 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
40
41all: lib
42
43lib: $(LIBOBJ)
44 $(AR) $(LIB) $(LIBOBJ)
45 sh $(TOP)/util/ranlib.sh $(LIB)
46 @touch lib
47
48# elf
49asm/r586-elf.o: asm/r586unix.cpp
50 $(CPP) -DELF asm/r586unix.cpp | as -o asm/r586-elf.o
51
52# solaris
53asm/r586-sol.o: asm/r586unix.cpp
54 $(CC) -E -DSOL asm/r586unix.cpp | sed 's/^#.*//' > asm/r586-sol.s
55 as -o asm/r586-sol.o asm/r586-sol.s
56 rm -f asm/r586-sol.s
57
58# a.out
59asm/r586-out.o: asm/r586unix.cpp
60 $(CPP) -DOUT asm/r586unix.cpp | as -o asm/r586-out.o
61
62# bsdi
63asm/r586bsdi.o: asm/r586unix.cpp
64 $(CPP) -DBSDI asm/r586unix.cpp | as -o asm/r586bsdi.o
65
66asm/r586unix.cpp:
67 (cd asm; perl rc5-586.pl cpp >r586unix.cpp)
68
69files:
70 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
71
72links:
73 /bin/rm -f Makefile
74 $(TOP)/util/point.sh Makefile.ssl Makefile ;
75 $(TOP)/util/point.sh ../../doc/rc5.doc rc5.doc ;
76 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
77 $(TOP)/util/mklink.sh ../../test $(TEST)
78 $(TOP)/util/mklink.sh ../../apps $(APPS)
79
80install:
81 @for i in $(EXHEADER) ; \
82 do \
83 (cp $$i $(INSTALLTOP)/include/$$i; \
84 chmod 644 $(INSTALLTOP)/include/$$i ); \
85 done;
86
87tags:
88 ctags $(SRC)
89
90tests:
91
92lint:
93 lint -DLINT $(INCLUDES) $(SRC)>fluff
94
95depend:
96 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
97
98dclean:
99 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
100 mv -f Makefile.new $(MAKEFILE)
101
102clean:
103 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
104
105errors:
106
107# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/rc5/Makefile.uni b/src/lib/libssl/src/crypto/rc5/Makefile.uni
new file mode 100644
index 0000000000..e50b3f2d19
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/Makefile.uni
@@ -0,0 +1,72 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5
6DIR= rc2
7TOP= .
8CC= gcc
9CFLAG= -O3 -fomit-frame-pointer
10
11CPP= $(CC) -E
12INCLUDES=
13INSTALLTOP=/usr/local/lib
14MAKE= make
15MAKEDEPEND= makedepend
16MAKEFILE= Makefile.uni
17AR= ar r
18
19IDEA_ENC=rc2_cbc.o
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL=Makefile
24TEST=rc2test
25APPS=rc2speed
26
27LIB=librc2.a
28LIBSRC=rc2_skey.c rc2_ecb.c rc2_cbc.c rc2cfb64.c rc2ofb64.c
29LIBOBJ=rc2_skey.o rc2_ecb.o $(IDEA_ENC) rc2cfb64.o rc2ofb64.o
30
31SRC= $(LIBSRC)
32
33EXHEADER= rc2.h
34HEADER= rc2_locl.h $(EXHEADER)
35
36ALL= $(GENERAL) $(SRC) $(HEADER)
37
38all: $(LIB) $(TEST) $(APPS)
39
40$(LIB): $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/ranlib.sh $(LIB)
43
44test: $(TEST)
45 ./$(TEST)
46
47$(TEST): $(TEST).c $(LIB)
48 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
49
50$(APPS): $(APPS).c $(LIB)
51 $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
52
53lint:
54 lint -DLINT $(INCLUDES) $(SRC)>fluff
55
56depend:
57 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
58
59dclean:
60 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
61 mv -f Makefile.new $(MAKEFILE)
62
63clean:
64 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
65
66cc:
67 $(MAKE) CC="cc" CFLAG="-O" all
68
69gcc:
70 $(MAKE) CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
71
72# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/rc5/asm/r5-win32.asm b/src/lib/libssl/src/crypto/rc5/asm/r5-win32.asm
new file mode 100644
index 0000000000..f43d3711f0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/asm/r5-win32.asm
@@ -0,0 +1,574 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by rc5-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE rc5-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _RC5_32_encrypt
12
13_RC5_32_encrypt PROC NEAR
14 ;
15 push ebp
16 push esi
17 push edi
18 mov edx, DWORD PTR 16[esp]
19 mov ebp, DWORD PTR 20[esp]
20 ; Load the 2 words
21 mov edi, DWORD PTR [edx]
22 mov esi, DWORD PTR 4[edx]
23 push ebx
24 mov ebx, DWORD PTR [ebp]
25 add edi, DWORD PTR 4[ebp]
26 add esi, DWORD PTR 8[ebp]
27 xor edi, esi
28 mov eax, DWORD PTR 12[ebp]
29 mov ecx, esi
30 rol edi, cl
31 add edi, eax
32 xor esi, edi
33 mov eax, DWORD PTR 16[ebp]
34 mov ecx, edi
35 rol esi, cl
36 add esi, eax
37 xor edi, esi
38 mov eax, DWORD PTR 20[ebp]
39 mov ecx, esi
40 rol edi, cl
41 add edi, eax
42 xor esi, edi
43 mov eax, DWORD PTR 24[ebp]
44 mov ecx, edi
45 rol esi, cl
46 add esi, eax
47 xor edi, esi
48 mov eax, DWORD PTR 28[ebp]
49 mov ecx, esi
50 rol edi, cl
51 add edi, eax
52 xor esi, edi
53 mov eax, DWORD PTR 32[ebp]
54 mov ecx, edi
55 rol esi, cl
56 add esi, eax
57 xor edi, esi
58 mov eax, DWORD PTR 36[ebp]
59 mov ecx, esi
60 rol edi, cl
61 add edi, eax
62 xor esi, edi
63 mov eax, DWORD PTR 40[ebp]
64 mov ecx, edi
65 rol esi, cl
66 add esi, eax
67 xor edi, esi
68 mov eax, DWORD PTR 44[ebp]
69 mov ecx, esi
70 rol edi, cl
71 add edi, eax
72 xor esi, edi
73 mov eax, DWORD PTR 48[ebp]
74 mov ecx, edi
75 rol esi, cl
76 add esi, eax
77 xor edi, esi
78 mov eax, DWORD PTR 52[ebp]
79 mov ecx, esi
80 rol edi, cl
81 add edi, eax
82 xor esi, edi
83 mov eax, DWORD PTR 56[ebp]
84 mov ecx, edi
85 rol esi, cl
86 add esi, eax
87 xor edi, esi
88 mov eax, DWORD PTR 60[ebp]
89 mov ecx, esi
90 rol edi, cl
91 add edi, eax
92 xor esi, edi
93 mov eax, DWORD PTR 64[ebp]
94 mov ecx, edi
95 rol esi, cl
96 add esi, eax
97 xor edi, esi
98 mov eax, DWORD PTR 68[ebp]
99 mov ecx, esi
100 rol edi, cl
101 add edi, eax
102 xor esi, edi
103 mov eax, DWORD PTR 72[ebp]
104 mov ecx, edi
105 rol esi, cl
106 add esi, eax
107 cmp ebx, 8
108 je $L000rc5_exit
109 xor edi, esi
110 mov eax, DWORD PTR 76[ebp]
111 mov ecx, esi
112 rol edi, cl
113 add edi, eax
114 xor esi, edi
115 mov eax, DWORD PTR 80[ebp]
116 mov ecx, edi
117 rol esi, cl
118 add esi, eax
119 xor edi, esi
120 mov eax, DWORD PTR 84[ebp]
121 mov ecx, esi
122 rol edi, cl
123 add edi, eax
124 xor esi, edi
125 mov eax, DWORD PTR 88[ebp]
126 mov ecx, edi
127 rol esi, cl
128 add esi, eax
129 xor edi, esi
130 mov eax, DWORD PTR 92[ebp]
131 mov ecx, esi
132 rol edi, cl
133 add edi, eax
134 xor esi, edi
135 mov eax, DWORD PTR 96[ebp]
136 mov ecx, edi
137 rol esi, cl
138 add esi, eax
139 xor edi, esi
140 mov eax, DWORD PTR 100[ebp]
141 mov ecx, esi
142 rol edi, cl
143 add edi, eax
144 xor esi, edi
145 mov eax, DWORD PTR 104[ebp]
146 mov ecx, edi
147 rol esi, cl
148 add esi, eax
149 cmp ebx, 12
150 je $L000rc5_exit
151 xor edi, esi
152 mov eax, DWORD PTR 108[ebp]
153 mov ecx, esi
154 rol edi, cl
155 add edi, eax
156 xor esi, edi
157 mov eax, DWORD PTR 112[ebp]
158 mov ecx, edi
159 rol esi, cl
160 add esi, eax
161 xor edi, esi
162 mov eax, DWORD PTR 116[ebp]
163 mov ecx, esi
164 rol edi, cl
165 add edi, eax
166 xor esi, edi
167 mov eax, DWORD PTR 120[ebp]
168 mov ecx, edi
169 rol esi, cl
170 add esi, eax
171 xor edi, esi
172 mov eax, DWORD PTR 124[ebp]
173 mov ecx, esi
174 rol edi, cl
175 add edi, eax
176 xor esi, edi
177 mov eax, DWORD PTR 128[ebp]
178 mov ecx, edi
179 rol esi, cl
180 add esi, eax
181 xor edi, esi
182 mov eax, DWORD PTR 132[ebp]
183 mov ecx, esi
184 rol edi, cl
185 add edi, eax
186 xor esi, edi
187 mov eax, DWORD PTR 136[ebp]
188 mov ecx, edi
189 rol esi, cl
190 add esi, eax
191$L000rc5_exit:
192 mov DWORD PTR [edx],edi
193 mov DWORD PTR 4[edx],esi
194 pop ebx
195 pop edi
196 pop esi
197 pop ebp
198 ret
199_RC5_32_encrypt ENDP
200_TEXT ENDS
201_TEXT SEGMENT
202PUBLIC _RC5_32_decrypt
203
204_RC5_32_decrypt PROC NEAR
205 ;
206 push ebp
207 push esi
208 push edi
209 mov edx, DWORD PTR 16[esp]
210 mov ebp, DWORD PTR 20[esp]
211 ; Load the 2 words
212 mov edi, DWORD PTR [edx]
213 mov esi, DWORD PTR 4[edx]
214 push ebx
215 mov ebx, DWORD PTR [ebp]
216 cmp ebx, 12
217 je $L001rc5_dec_12
218 cmp ebx, 8
219 je $L002rc5_dec_8
220 mov eax, DWORD PTR 136[ebp]
221 sub esi, eax
222 mov ecx, edi
223 ror esi, cl
224 xor esi, edi
225 mov eax, DWORD PTR 132[ebp]
226 sub edi, eax
227 mov ecx, esi
228 ror edi, cl
229 xor edi, esi
230 mov eax, DWORD PTR 128[ebp]
231 sub esi, eax
232 mov ecx, edi
233 ror esi, cl
234 xor esi, edi
235 mov eax, DWORD PTR 124[ebp]
236 sub edi, eax
237 mov ecx, esi
238 ror edi, cl
239 xor edi, esi
240 mov eax, DWORD PTR 120[ebp]
241 sub esi, eax
242 mov ecx, edi
243 ror esi, cl
244 xor esi, edi
245 mov eax, DWORD PTR 116[ebp]
246 sub edi, eax
247 mov ecx, esi
248 ror edi, cl
249 xor edi, esi
250 mov eax, DWORD PTR 112[ebp]
251 sub esi, eax
252 mov ecx, edi
253 ror esi, cl
254 xor esi, edi
255 mov eax, DWORD PTR 108[ebp]
256 sub edi, eax
257 mov ecx, esi
258 ror edi, cl
259 xor edi, esi
260$L001rc5_dec_12:
261 mov eax, DWORD PTR 104[ebp]
262 sub esi, eax
263 mov ecx, edi
264 ror esi, cl
265 xor esi, edi
266 mov eax, DWORD PTR 100[ebp]
267 sub edi, eax
268 mov ecx, esi
269 ror edi, cl
270 xor edi, esi
271 mov eax, DWORD PTR 96[ebp]
272 sub esi, eax
273 mov ecx, edi
274 ror esi, cl
275 xor esi, edi
276 mov eax, DWORD PTR 92[ebp]
277 sub edi, eax
278 mov ecx, esi
279 ror edi, cl
280 xor edi, esi
281 mov eax, DWORD PTR 88[ebp]
282 sub esi, eax
283 mov ecx, edi
284 ror esi, cl
285 xor esi, edi
286 mov eax, DWORD PTR 84[ebp]
287 sub edi, eax
288 mov ecx, esi
289 ror edi, cl
290 xor edi, esi
291 mov eax, DWORD PTR 80[ebp]
292 sub esi, eax
293 mov ecx, edi
294 ror esi, cl
295 xor esi, edi
296 mov eax, DWORD PTR 76[ebp]
297 sub edi, eax
298 mov ecx, esi
299 ror edi, cl
300 xor edi, esi
301$L002rc5_dec_8:
302 mov eax, DWORD PTR 72[ebp]
303 sub esi, eax
304 mov ecx, edi
305 ror esi, cl
306 xor esi, edi
307 mov eax, DWORD PTR 68[ebp]
308 sub edi, eax
309 mov ecx, esi
310 ror edi, cl
311 xor edi, esi
312 mov eax, DWORD PTR 64[ebp]
313 sub esi, eax
314 mov ecx, edi
315 ror esi, cl
316 xor esi, edi
317 mov eax, DWORD PTR 60[ebp]
318 sub edi, eax
319 mov ecx, esi
320 ror edi, cl
321 xor edi, esi
322 mov eax, DWORD PTR 56[ebp]
323 sub esi, eax
324 mov ecx, edi
325 ror esi, cl
326 xor esi, edi
327 mov eax, DWORD PTR 52[ebp]
328 sub edi, eax
329 mov ecx, esi
330 ror edi, cl
331 xor edi, esi
332 mov eax, DWORD PTR 48[ebp]
333 sub esi, eax
334 mov ecx, edi
335 ror esi, cl
336 xor esi, edi
337 mov eax, DWORD PTR 44[ebp]
338 sub edi, eax
339 mov ecx, esi
340 ror edi, cl
341 xor edi, esi
342 mov eax, DWORD PTR 40[ebp]
343 sub esi, eax
344 mov ecx, edi
345 ror esi, cl
346 xor esi, edi
347 mov eax, DWORD PTR 36[ebp]
348 sub edi, eax
349 mov ecx, esi
350 ror edi, cl
351 xor edi, esi
352 mov eax, DWORD PTR 32[ebp]
353 sub esi, eax
354 mov ecx, edi
355 ror esi, cl
356 xor esi, edi
357 mov eax, DWORD PTR 28[ebp]
358 sub edi, eax
359 mov ecx, esi
360 ror edi, cl
361 xor edi, esi
362 mov eax, DWORD PTR 24[ebp]
363 sub esi, eax
364 mov ecx, edi
365 ror esi, cl
366 xor esi, edi
367 mov eax, DWORD PTR 20[ebp]
368 sub edi, eax
369 mov ecx, esi
370 ror edi, cl
371 xor edi, esi
372 mov eax, DWORD PTR 16[ebp]
373 sub esi, eax
374 mov ecx, edi
375 ror esi, cl
376 xor esi, edi
377 mov eax, DWORD PTR 12[ebp]
378 sub edi, eax
379 mov ecx, esi
380 ror edi, cl
381 xor edi, esi
382 sub esi, DWORD PTR 8[ebp]
383 sub edi, DWORD PTR 4[ebp]
384L003rc5_exit:
385 mov DWORD PTR [edx],edi
386 mov DWORD PTR 4[edx],esi
387 pop ebx
388 pop edi
389 pop esi
390 pop ebp
391 ret
392_RC5_32_decrypt ENDP
393_TEXT ENDS
394_TEXT SEGMENT
395PUBLIC _RC5_32_cbc_encrypt
396
397_RC5_32_cbc_encrypt PROC NEAR
398 ;
399 push ebp
400 push ebx
401 push esi
402 push edi
403 mov ebp, DWORD PTR 28[esp]
404 ; getting iv ptr from parameter 4
405 mov ebx, DWORD PTR 36[esp]
406 mov esi, DWORD PTR [ebx]
407 mov edi, DWORD PTR 4[ebx]
408 push edi
409 push esi
410 push edi
411 push esi
412 mov ebx, esp
413 mov esi, DWORD PTR 36[esp]
414 mov edi, DWORD PTR 40[esp]
415 ; getting encrypt flag from parameter 5
416 mov ecx, DWORD PTR 56[esp]
417 ; get and push parameter 3
418 mov eax, DWORD PTR 48[esp]
419 push eax
420 push ebx
421 cmp ecx, 0
422 jz $L004decrypt
423 and ebp, 4294967288
424 mov eax, DWORD PTR 8[esp]
425 mov ebx, DWORD PTR 12[esp]
426 jz $L005encrypt_finish
427L006encrypt_loop:
428 mov ecx, DWORD PTR [esi]
429 mov edx, DWORD PTR 4[esi]
430 xor eax, ecx
431 xor ebx, edx
432 mov DWORD PTR 8[esp],eax
433 mov DWORD PTR 12[esp],ebx
434 call _RC5_32_encrypt
435 mov eax, DWORD PTR 8[esp]
436 mov ebx, DWORD PTR 12[esp]
437 mov DWORD PTR [edi],eax
438 mov DWORD PTR 4[edi],ebx
439 add esi, 8
440 add edi, 8
441 sub ebp, 8
442 jnz L006encrypt_loop
443$L005encrypt_finish:
444 mov ebp, DWORD PTR 52[esp]
445 and ebp, 7
446 jz $L007finish
447 xor ecx, ecx
448 xor edx, edx
449 mov ebp, DWORD PTR $L008cbc_enc_jmp_table[ebp*4]
450 jmp ebp
451L009ej7:
452 mov dh, BYTE PTR 6[esi]
453 shl edx, 8
454L010ej6:
455 mov dh, BYTE PTR 5[esi]
456L011ej5:
457 mov dl, BYTE PTR 4[esi]
458L012ej4:
459 mov ecx, DWORD PTR [esi]
460 jmp $L013ejend
461L014ej3:
462 mov ch, BYTE PTR 2[esi]
463 shl ecx, 8
464L015ej2:
465 mov ch, BYTE PTR 1[esi]
466L016ej1:
467 mov cl, BYTE PTR [esi]
468$L013ejend:
469 xor eax, ecx
470 xor ebx, edx
471 mov DWORD PTR 8[esp],eax
472 mov DWORD PTR 12[esp],ebx
473 call _RC5_32_encrypt
474 mov eax, DWORD PTR 8[esp]
475 mov ebx, DWORD PTR 12[esp]
476 mov DWORD PTR [edi],eax
477 mov DWORD PTR 4[edi],ebx
478 jmp $L007finish
479$L004decrypt:
480 and ebp, 4294967288
481 mov eax, DWORD PTR 16[esp]
482 mov ebx, DWORD PTR 20[esp]
483 jz $L017decrypt_finish
484L018decrypt_loop:
485 mov eax, DWORD PTR [esi]
486 mov ebx, DWORD PTR 4[esi]
487 mov DWORD PTR 8[esp],eax
488 mov DWORD PTR 12[esp],ebx
489 call _RC5_32_decrypt
490 mov eax, DWORD PTR 8[esp]
491 mov ebx, DWORD PTR 12[esp]
492 mov ecx, DWORD PTR 16[esp]
493 mov edx, DWORD PTR 20[esp]
494 xor ecx, eax
495 xor edx, ebx
496 mov eax, DWORD PTR [esi]
497 mov ebx, DWORD PTR 4[esi]
498 mov DWORD PTR [edi],ecx
499 mov DWORD PTR 4[edi],edx
500 mov DWORD PTR 16[esp],eax
501 mov DWORD PTR 20[esp],ebx
502 add esi, 8
503 add edi, 8
504 sub ebp, 8
505 jnz L018decrypt_loop
506$L017decrypt_finish:
507 mov ebp, DWORD PTR 52[esp]
508 and ebp, 7
509 jz $L007finish
510 mov eax, DWORD PTR [esi]
511 mov ebx, DWORD PTR 4[esi]
512 mov DWORD PTR 8[esp],eax
513 mov DWORD PTR 12[esp],ebx
514 call _RC5_32_decrypt
515 mov eax, DWORD PTR 8[esp]
516 mov ebx, DWORD PTR 12[esp]
517 mov ecx, DWORD PTR 16[esp]
518 mov edx, DWORD PTR 20[esp]
519 xor ecx, eax
520 xor edx, ebx
521 mov eax, DWORD PTR [esi]
522 mov ebx, DWORD PTR 4[esi]
523L019dj7:
524 ror edx, 16
525 mov BYTE PTR 6[edi],dl
526 shr edx, 16
527L020dj6:
528 mov BYTE PTR 5[edi],dh
529L021dj5:
530 mov BYTE PTR 4[edi],dl
531L022dj4:
532 mov DWORD PTR [edi],ecx
533 jmp $L023djend
534L024dj3:
535 ror ecx, 16
536 mov BYTE PTR 2[edi],cl
537 shl ecx, 16
538L025dj2:
539 mov BYTE PTR 1[esi],ch
540L026dj1:
541 mov BYTE PTR [esi], cl
542$L023djend:
543 jmp $L007finish
544$L007finish:
545 mov ecx, DWORD PTR 60[esp]
546 add esp, 24
547 mov DWORD PTR [ecx],eax
548 mov DWORD PTR 4[ecx],ebx
549 pop edi
550 pop esi
551 pop ebx
552 pop ebp
553 ret
554$L008cbc_enc_jmp_table:
555 DD 0
556 DD L016ej1
557 DD L015ej2
558 DD L014ej3
559 DD L012ej4
560 DD L011ej5
561 DD L010ej6
562 DD L009ej7
563L027cbc_dec_jmp_table:
564 DD 0
565 DD L026dj1
566 DD L025dj2
567 DD L024dj3
568 DD L022dj4
569 DD L021dj5
570 DD L020dj6
571 DD L019dj7
572_RC5_32_cbc_encrypt ENDP
573_TEXT ENDS
574END
diff --git a/src/lib/libssl/src/crypto/rc5/asm/r586unix.cpp b/src/lib/libssl/src/crypto/rc5/asm/r586unix.cpp
new file mode 100644
index 0000000000..a25dd5a9a4
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/asm/r586unix.cpp
@@ -0,0 +1,628 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define RC5_32_encrypt _RC5_32_encrypt
13#define RC5_32_decrypt _RC5_32_decrypt
14#define RC5_32_cbc_encrypt _RC5_32_cbc_encrypt
15
16#endif
17
18#ifdef OUT
19#define OK 1
20#define ALIGN 4
21#endif
22
23#ifdef BSDI
24#define OK 1
25#define ALIGN 4
26#undef SIZE
27#undef TYPE
28#define SIZE(a,b)
29#define TYPE(a,b)
30#endif
31
32#if defined(ELF) || defined(SOL)
33#define OK 1
34#define ALIGN 16
35#endif
36
37#ifndef OK
38You need to define one of
39ELF - elf systems - linux-elf, NetBSD and DG-UX
40OUT - a.out systems - linux-a.out and FreeBSD
41SOL - solaris systems, which are elf with strange comment lines
42BSDI - a.out with a very primative version of as.
43#endif
44
45/* Let the Assembler begin :-) */
46 /* Don't even think of reading this code */
47 /* It was automatically generated by rc5-586.pl */
48 /* Which is a perl program used to generate the x86 assember for */
49 /* any of elf, a.out, BSDI,Win32, or Solaris */
50 /* eric <eay@cryptsoft.com> */
51
52 .file "rc5-586.s"
53 .version "01.01"
54gcc2_compiled.:
55.text
56 .align ALIGN
57.globl RC5_32_encrypt
58 TYPE(RC5_32_encrypt,@function)
59RC5_32_encrypt:
60
61 pushl %ebp
62 pushl %esi
63 pushl %edi
64 movl 16(%esp), %edx
65 movl 20(%esp), %ebp
66 /* Load the 2 words */
67 movl (%edx), %edi
68 movl 4(%edx), %esi
69 pushl %ebx
70 movl (%ebp), %ebx
71 addl 4(%ebp), %edi
72 addl 8(%ebp), %esi
73 xorl %esi, %edi
74 movl 12(%ebp), %eax
75 movl %esi, %ecx
76 roll %cl, %edi
77 addl %eax, %edi
78 xorl %edi, %esi
79 movl 16(%ebp), %eax
80 movl %edi, %ecx
81 roll %cl, %esi
82 addl %eax, %esi
83 xorl %esi, %edi
84 movl 20(%ebp), %eax
85 movl %esi, %ecx
86 roll %cl, %edi
87 addl %eax, %edi
88 xorl %edi, %esi
89 movl 24(%ebp), %eax
90 movl %edi, %ecx
91 roll %cl, %esi
92 addl %eax, %esi
93 xorl %esi, %edi
94 movl 28(%ebp), %eax
95 movl %esi, %ecx
96 roll %cl, %edi
97 addl %eax, %edi
98 xorl %edi, %esi
99 movl 32(%ebp), %eax
100 movl %edi, %ecx
101 roll %cl, %esi
102 addl %eax, %esi
103 xorl %esi, %edi
104 movl 36(%ebp), %eax
105 movl %esi, %ecx
106 roll %cl, %edi
107 addl %eax, %edi
108 xorl %edi, %esi
109 movl 40(%ebp), %eax
110 movl %edi, %ecx
111 roll %cl, %esi
112 addl %eax, %esi
113 xorl %esi, %edi
114 movl 44(%ebp), %eax
115 movl %esi, %ecx
116 roll %cl, %edi
117 addl %eax, %edi
118 xorl %edi, %esi
119 movl 48(%ebp), %eax
120 movl %edi, %ecx
121 roll %cl, %esi
122 addl %eax, %esi
123 xorl %esi, %edi
124 movl 52(%ebp), %eax
125 movl %esi, %ecx
126 roll %cl, %edi
127 addl %eax, %edi
128 xorl %edi, %esi
129 movl 56(%ebp), %eax
130 movl %edi, %ecx
131 roll %cl, %esi
132 addl %eax, %esi
133 xorl %esi, %edi
134 movl 60(%ebp), %eax
135 movl %esi, %ecx
136 roll %cl, %edi
137 addl %eax, %edi
138 xorl %edi, %esi
139 movl 64(%ebp), %eax
140 movl %edi, %ecx
141 roll %cl, %esi
142 addl %eax, %esi
143 xorl %esi, %edi
144 movl 68(%ebp), %eax
145 movl %esi, %ecx
146 roll %cl, %edi
147 addl %eax, %edi
148 xorl %edi, %esi
149 movl 72(%ebp), %eax
150 movl %edi, %ecx
151 roll %cl, %esi
152 addl %eax, %esi
153 cmpl $8, %ebx
154 je .L000rc5_exit
155 xorl %esi, %edi
156 movl 76(%ebp), %eax
157 movl %esi, %ecx
158 roll %cl, %edi
159 addl %eax, %edi
160 xorl %edi, %esi
161 movl 80(%ebp), %eax
162 movl %edi, %ecx
163 roll %cl, %esi
164 addl %eax, %esi
165 xorl %esi, %edi
166 movl 84(%ebp), %eax
167 movl %esi, %ecx
168 roll %cl, %edi
169 addl %eax, %edi
170 xorl %edi, %esi
171 movl 88(%ebp), %eax
172 movl %edi, %ecx
173 roll %cl, %esi
174 addl %eax, %esi
175 xorl %esi, %edi
176 movl 92(%ebp), %eax
177 movl %esi, %ecx
178 roll %cl, %edi
179 addl %eax, %edi
180 xorl %edi, %esi
181 movl 96(%ebp), %eax
182 movl %edi, %ecx
183 roll %cl, %esi
184 addl %eax, %esi
185 xorl %esi, %edi
186 movl 100(%ebp), %eax
187 movl %esi, %ecx
188 roll %cl, %edi
189 addl %eax, %edi
190 xorl %edi, %esi
191 movl 104(%ebp), %eax
192 movl %edi, %ecx
193 roll %cl, %esi
194 addl %eax, %esi
195 cmpl $12, %ebx
196 je .L000rc5_exit
197 xorl %esi, %edi
198 movl 108(%ebp), %eax
199 movl %esi, %ecx
200 roll %cl, %edi
201 addl %eax, %edi
202 xorl %edi, %esi
203 movl 112(%ebp), %eax
204 movl %edi, %ecx
205 roll %cl, %esi
206 addl %eax, %esi
207 xorl %esi, %edi
208 movl 116(%ebp), %eax
209 movl %esi, %ecx
210 roll %cl, %edi
211 addl %eax, %edi
212 xorl %edi, %esi
213 movl 120(%ebp), %eax
214 movl %edi, %ecx
215 roll %cl, %esi
216 addl %eax, %esi
217 xorl %esi, %edi
218 movl 124(%ebp), %eax
219 movl %esi, %ecx
220 roll %cl, %edi
221 addl %eax, %edi
222 xorl %edi, %esi
223 movl 128(%ebp), %eax
224 movl %edi, %ecx
225 roll %cl, %esi
226 addl %eax, %esi
227 xorl %esi, %edi
228 movl 132(%ebp), %eax
229 movl %esi, %ecx
230 roll %cl, %edi
231 addl %eax, %edi
232 xorl %edi, %esi
233 movl 136(%ebp), %eax
234 movl %edi, %ecx
235 roll %cl, %esi
236 addl %eax, %esi
237.L000rc5_exit:
238 movl %edi, (%edx)
239 movl %esi, 4(%edx)
240 popl %ebx
241 popl %edi
242 popl %esi
243 popl %ebp
244 ret
245.RC5_32_encrypt_end:
246 SIZE(RC5_32_encrypt,.RC5_32_encrypt_end-RC5_32_encrypt)
247.ident "desasm.pl"
248.text
249 .align ALIGN
250.globl RC5_32_decrypt
251 TYPE(RC5_32_decrypt,@function)
252RC5_32_decrypt:
253
254 pushl %ebp
255 pushl %esi
256 pushl %edi
257 movl 16(%esp), %edx
258 movl 20(%esp), %ebp
259 /* Load the 2 words */
260 movl (%edx), %edi
261 movl 4(%edx), %esi
262 pushl %ebx
263 movl (%ebp), %ebx
264 cmpl $12, %ebx
265 je .L001rc5_dec_12
266 cmpl $8, %ebx
267 je .L002rc5_dec_8
268 movl 136(%ebp), %eax
269 subl %eax, %esi
270 movl %edi, %ecx
271 rorl %cl, %esi
272 xorl %edi, %esi
273 movl 132(%ebp), %eax
274 subl %eax, %edi
275 movl %esi, %ecx
276 rorl %cl, %edi
277 xorl %esi, %edi
278 movl 128(%ebp), %eax
279 subl %eax, %esi
280 movl %edi, %ecx
281 rorl %cl, %esi
282 xorl %edi, %esi
283 movl 124(%ebp), %eax
284 subl %eax, %edi
285 movl %esi, %ecx
286 rorl %cl, %edi
287 xorl %esi, %edi
288 movl 120(%ebp), %eax
289 subl %eax, %esi
290 movl %edi, %ecx
291 rorl %cl, %esi
292 xorl %edi, %esi
293 movl 116(%ebp), %eax
294 subl %eax, %edi
295 movl %esi, %ecx
296 rorl %cl, %edi
297 xorl %esi, %edi
298 movl 112(%ebp), %eax
299 subl %eax, %esi
300 movl %edi, %ecx
301 rorl %cl, %esi
302 xorl %edi, %esi
303 movl 108(%ebp), %eax
304 subl %eax, %edi
305 movl %esi, %ecx
306 rorl %cl, %edi
307 xorl %esi, %edi
308.L001rc5_dec_12:
309 movl 104(%ebp), %eax
310 subl %eax, %esi
311 movl %edi, %ecx
312 rorl %cl, %esi
313 xorl %edi, %esi
314 movl 100(%ebp), %eax
315 subl %eax, %edi
316 movl %esi, %ecx
317 rorl %cl, %edi
318 xorl %esi, %edi
319 movl 96(%ebp), %eax
320 subl %eax, %esi
321 movl %edi, %ecx
322 rorl %cl, %esi
323 xorl %edi, %esi
324 movl 92(%ebp), %eax
325 subl %eax, %edi
326 movl %esi, %ecx
327 rorl %cl, %edi
328 xorl %esi, %edi
329 movl 88(%ebp), %eax
330 subl %eax, %esi
331 movl %edi, %ecx
332 rorl %cl, %esi
333 xorl %edi, %esi
334 movl 84(%ebp), %eax
335 subl %eax, %edi
336 movl %esi, %ecx
337 rorl %cl, %edi
338 xorl %esi, %edi
339 movl 80(%ebp), %eax
340 subl %eax, %esi
341 movl %edi, %ecx
342 rorl %cl, %esi
343 xorl %edi, %esi
344 movl 76(%ebp), %eax
345 subl %eax, %edi
346 movl %esi, %ecx
347 rorl %cl, %edi
348 xorl %esi, %edi
349.L002rc5_dec_8:
350 movl 72(%ebp), %eax
351 subl %eax, %esi
352 movl %edi, %ecx
353 rorl %cl, %esi
354 xorl %edi, %esi
355 movl 68(%ebp), %eax
356 subl %eax, %edi
357 movl %esi, %ecx
358 rorl %cl, %edi
359 xorl %esi, %edi
360 movl 64(%ebp), %eax
361 subl %eax, %esi
362 movl %edi, %ecx
363 rorl %cl, %esi
364 xorl %edi, %esi
365 movl 60(%ebp), %eax
366 subl %eax, %edi
367 movl %esi, %ecx
368 rorl %cl, %edi
369 xorl %esi, %edi
370 movl 56(%ebp), %eax
371 subl %eax, %esi
372 movl %edi, %ecx
373 rorl %cl, %esi
374 xorl %edi, %esi
375 movl 52(%ebp), %eax
376 subl %eax, %edi
377 movl %esi, %ecx
378 rorl %cl, %edi
379 xorl %esi, %edi
380 movl 48(%ebp), %eax
381 subl %eax, %esi
382 movl %edi, %ecx
383 rorl %cl, %esi
384 xorl %edi, %esi
385 movl 44(%ebp), %eax
386 subl %eax, %edi
387 movl %esi, %ecx
388 rorl %cl, %edi
389 xorl %esi, %edi
390 movl 40(%ebp), %eax
391 subl %eax, %esi
392 movl %edi, %ecx
393 rorl %cl, %esi
394 xorl %edi, %esi
395 movl 36(%ebp), %eax
396 subl %eax, %edi
397 movl %esi, %ecx
398 rorl %cl, %edi
399 xorl %esi, %edi
400 movl 32(%ebp), %eax
401 subl %eax, %esi
402 movl %edi, %ecx
403 rorl %cl, %esi
404 xorl %edi, %esi
405 movl 28(%ebp), %eax
406 subl %eax, %edi
407 movl %esi, %ecx
408 rorl %cl, %edi
409 xorl %esi, %edi
410 movl 24(%ebp), %eax
411 subl %eax, %esi
412 movl %edi, %ecx
413 rorl %cl, %esi
414 xorl %edi, %esi
415 movl 20(%ebp), %eax
416 subl %eax, %edi
417 movl %esi, %ecx
418 rorl %cl, %edi
419 xorl %esi, %edi
420 movl 16(%ebp), %eax
421 subl %eax, %esi
422 movl %edi, %ecx
423 rorl %cl, %esi
424 xorl %edi, %esi
425 movl 12(%ebp), %eax
426 subl %eax, %edi
427 movl %esi, %ecx
428 rorl %cl, %edi
429 xorl %esi, %edi
430 subl 8(%ebp), %esi
431 subl 4(%ebp), %edi
432.L003rc5_exit:
433 movl %edi, (%edx)
434 movl %esi, 4(%edx)
435 popl %ebx
436 popl %edi
437 popl %esi
438 popl %ebp
439 ret
440.RC5_32_decrypt_end:
441 SIZE(RC5_32_decrypt,.RC5_32_decrypt_end-RC5_32_decrypt)
442.ident "desasm.pl"
443.text
444 .align ALIGN
445.globl RC5_32_cbc_encrypt
446 TYPE(RC5_32_cbc_encrypt,@function)
447RC5_32_cbc_encrypt:
448
449 pushl %ebp
450 pushl %ebx
451 pushl %esi
452 pushl %edi
453 movl 28(%esp), %ebp
454 /* getting iv ptr from parameter 4 */
455 movl 36(%esp), %ebx
456 movl (%ebx), %esi
457 movl 4(%ebx), %edi
458 pushl %edi
459 pushl %esi
460 pushl %edi
461 pushl %esi
462 movl %esp, %ebx
463 movl 36(%esp), %esi
464 movl 40(%esp), %edi
465 /* getting encrypt flag from parameter 5 */
466 movl 56(%esp), %ecx
467 /* get and push parameter 3 */
468 movl 48(%esp), %eax
469 pushl %eax
470 pushl %ebx
471 cmpl $0, %ecx
472 jz .L004decrypt
473 andl $4294967288, %ebp
474 movl 8(%esp), %eax
475 movl 12(%esp), %ebx
476 jz .L005encrypt_finish
477.L006encrypt_loop:
478 movl (%esi), %ecx
479 movl 4(%esi), %edx
480 xorl %ecx, %eax
481 xorl %edx, %ebx
482 movl %eax, 8(%esp)
483 movl %ebx, 12(%esp)
484 call RC5_32_encrypt
485 movl 8(%esp), %eax
486 movl 12(%esp), %ebx
487 movl %eax, (%edi)
488 movl %ebx, 4(%edi)
489 addl $8, %esi
490 addl $8, %edi
491 subl $8, %ebp
492 jnz .L006encrypt_loop
493.L005encrypt_finish:
494 movl 52(%esp), %ebp
495 andl $7, %ebp
496 jz .L007finish
497 xorl %ecx, %ecx
498 xorl %edx, %edx
499 movl .L008cbc_enc_jmp_table(,%ebp,4),%ebp
500 jmp *%ebp
501.L009ej7:
502 movb 6(%esi), %dh
503 sall $8, %edx
504.L010ej6:
505 movb 5(%esi), %dh
506.L011ej5:
507 movb 4(%esi), %dl
508.L012ej4:
509 movl (%esi), %ecx
510 jmp .L013ejend
511.L014ej3:
512 movb 2(%esi), %ch
513 sall $8, %ecx
514.L015ej2:
515 movb 1(%esi), %ch
516.L016ej1:
517 movb (%esi), %cl
518.L013ejend:
519 xorl %ecx, %eax
520 xorl %edx, %ebx
521 movl %eax, 8(%esp)
522 movl %ebx, 12(%esp)
523 call RC5_32_encrypt
524 movl 8(%esp), %eax
525 movl 12(%esp), %ebx
526 movl %eax, (%edi)
527 movl %ebx, 4(%edi)
528 jmp .L007finish
529.align ALIGN
530.L004decrypt:
531 andl $4294967288, %ebp
532 movl 16(%esp), %eax
533 movl 20(%esp), %ebx
534 jz .L017decrypt_finish
535.L018decrypt_loop:
536 movl (%esi), %eax
537 movl 4(%esi), %ebx
538 movl %eax, 8(%esp)
539 movl %ebx, 12(%esp)
540 call RC5_32_decrypt
541 movl 8(%esp), %eax
542 movl 12(%esp), %ebx
543 movl 16(%esp), %ecx
544 movl 20(%esp), %edx
545 xorl %eax, %ecx
546 xorl %ebx, %edx
547 movl (%esi), %eax
548 movl 4(%esi), %ebx
549 movl %ecx, (%edi)
550 movl %edx, 4(%edi)
551 movl %eax, 16(%esp)
552 movl %ebx, 20(%esp)
553 addl $8, %esi
554 addl $8, %edi
555 subl $8, %ebp
556 jnz .L018decrypt_loop
557.L017decrypt_finish:
558 movl 52(%esp), %ebp
559 andl $7, %ebp
560 jz .L007finish
561 movl (%esi), %eax
562 movl 4(%esi), %ebx
563 movl %eax, 8(%esp)
564 movl %ebx, 12(%esp)
565 call RC5_32_decrypt
566 movl 8(%esp), %eax
567 movl 12(%esp), %ebx
568 movl 16(%esp), %ecx
569 movl 20(%esp), %edx
570 xorl %eax, %ecx
571 xorl %ebx, %edx
572 movl (%esi), %eax
573 movl 4(%esi), %ebx
574.L019dj7:
575 rorl $16, %edx
576 movb %dl, 6(%edi)
577 shrl $16, %edx
578.L020dj6:
579 movb %dh, 5(%edi)
580.L021dj5:
581 movb %dl, 4(%edi)
582.L022dj4:
583 movl %ecx, (%edi)
584 jmp .L023djend
585.L024dj3:
586 rorl $16, %ecx
587 movb %cl, 2(%edi)
588 sall $16, %ecx
589.L025dj2:
590 movb %ch, 1(%esi)
591.L026dj1:
592 movb %cl, (%esi)
593.L023djend:
594 jmp .L007finish
595.align ALIGN
596.L007finish:
597 movl 60(%esp), %ecx
598 addl $24, %esp
599 movl %eax, (%ecx)
600 movl %ebx, 4(%ecx)
601 popl %edi
602 popl %esi
603 popl %ebx
604 popl %ebp
605 ret
606.align ALIGN
607.L008cbc_enc_jmp_table:
608 .long 0
609 .long .L016ej1
610 .long .L015ej2
611 .long .L014ej3
612 .long .L012ej4
613 .long .L011ej5
614 .long .L010ej6
615 .long .L009ej7
616.align ALIGN
617.L027cbc_dec_jmp_table:
618 .long 0
619 .long .L026dj1
620 .long .L025dj2
621 .long .L024dj3
622 .long .L022dj4
623 .long .L021dj5
624 .long .L020dj6
625 .long .L019dj7
626.RC5_32_cbc_encrypt_end:
627 SIZE(RC5_32_cbc_encrypt,.RC5_32_cbc_encrypt_end-RC5_32_cbc_encrypt)
628.ident "desasm.pl"
diff --git a/src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl b/src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl
new file mode 100644
index 0000000000..172bd9ee1b
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rc5/asm/rc5-586.pl
@@ -0,0 +1,109 @@
1#!/usr/bin/perl
2
3push(@INC,"perlasm","../../perlasm");
4require "x86asm.pl";
5require "cbc.pl";
6
7&asm_init($ARGV[0],"rc5-586.pl");
8
9$RC5_MAX_ROUNDS=16;
10$RC5_32_OFF=($RC5_MAX_ROUNDS+2)*4;
11$A="edi";
12$B="esi";
13$S="ebp";
14$tmp1="eax";
15$r="ebx";
16$tmpc="ecx";
17$tmp4="edx";
18
19&RC5_32_encrypt("RC5_32_encrypt",1);
20&RC5_32_encrypt("RC5_32_decrypt",0);
21&cbc("RC5_32_cbc_encrypt","RC5_32_encrypt","RC5_32_decrypt",0,4,5,3,-1,-1);
22&asm_finish();
23
24sub RC5_32_encrypt
25 {
26 local($name,$enc)=@_;
27
28 &function_begin_B($name,"");
29
30 &comment("");
31
32 &push("ebp");
33 &push("esi");
34 &push("edi");
35 &mov($tmp4,&wparam(0));
36 &mov($S,&wparam(1));
37
38 &comment("Load the 2 words");
39 &mov($A,&DWP(0,$tmp4,"",0));
40 &mov($B,&DWP(4,$tmp4,"",0));
41
42 &push($r);
43 &mov($r, &DWP(0,$S,"",0));
44
45 # encrypting part
46
47 if ($enc)
48 {
49 &add($A, &DWP(4+0,$S,"",0));
50 &add($B, &DWP(4+4,$S,"",0));
51
52 for ($i=0; $i<$RC5_MAX_ROUNDS; $i++)
53 {
54 &xor($A, $B);
55 &mov($tmp1, &DWP(12+$i*8,$S,"",0));
56 &mov($tmpc, $B);
57 &rotl($A, &LB("ecx"));
58 &add($A, $tmp1);
59
60 &xor($B, $A);
61 &mov($tmp1, &DWP(16+$i*8,$S,"",0));
62 &mov($tmpc, $A);
63 &rotl($B, &LB("ecx"));
64 &add($B, $tmp1);
65 if (($i == 7) || ($i == 11))
66 {
67 &cmp($r, $i+1);
68 &je(&label("rc5_exit"));
69 }
70 }
71 }
72 else
73 {
74 &cmp($r, 12);
75 &je(&label("rc5_dec_12"));
76 &cmp($r, 8);
77 &je(&label("rc5_dec_8"));
78 for ($i=$RC5_MAX_ROUNDS; $i > 0; $i--)
79 {
80 &set_label("rc5_dec_$i") if ($i == 12) || ($i == 8);
81 &mov($tmp1, &DWP($i*8+8,$S,"",0));
82 &sub($B, $tmp1);
83 &mov($tmpc, $A);
84 &rotr($B, &LB("ecx"));
85 &xor($B, $A);
86
87 &mov($tmp1, &DWP($i*8+4,$S,"",0));
88 &sub($A, $tmp1);
89 &mov($tmpc, $B);
90 &rotr($A, &LB("ecx"));
91 &xor($A, $B);
92 }
93 &sub($B, &DWP(4+4,$S,"",0));
94 &sub($A, &DWP(4+0,$S,"",0));
95 }
96
97 &set_label("rc5_exit");
98 &mov(&DWP(0,$tmp4,"",0),$A);
99 &mov(&DWP(4,$tmp4,"",0),$B);
100
101 &pop("ebx");
102 &pop("edi");
103 &pop("esi");
104 &pop("ebp");
105 &ret();
106 &function_end_B($name);
107 }
108
109
diff --git a/src/lib/libssl/src/crypto/ripemd/Makefile.ssl b/src/lib/libssl/src/crypto/ripemd/Makefile.ssl
new file mode 100644
index 0000000000..67d47ceb2c
--- /dev/null
+++ b/src/lib/libssl/src/crypto/ripemd/Makefile.ssl
@@ -0,0 +1,104 @@
1#
2# SSLeay/crypto/ripemd/Makefile
3#
4
5DIR= ripemd
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl
14MAKEFILE= Makefile.ssl
15AR= ar r
16
17RIP_ASM_OBJ=
18
19CFLAGS= $(INCLUDES) $(CFLAG)
20
21GENERAL=Makefile
22TEST=rmdtest.c
23APPS=rmd160.c
24
25LIB=$(TOP)/libcrypto.a
26LIBSRC=rmd_dgst.c rmd_one.c
27LIBOBJ=rmd_dgst.o rmd_one.o $(RMD160_ASM_OBJ)
28
29SRC= $(LIBSRC)
30
31EXHEADER= ripemd.h
32HEADER= rmd_locl.h rmdconst.h $(EXHEADER)
33
34ALL= $(GENERAL) $(SRC) $(HEADER)
35
36top:
37 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 sh $(TOP)/util/ranlib.sh $(LIB)
44 @touch lib
45
46# elf
47asm/rm86-elf.o: asm/rm86unix.cpp
48 $(CPP) -DELF asm/rm86unix.cpp | as -o asm/rm86-elf.o
49
50# solaris
51asm/rm86-sol.o: asm/rm86unix.cpp
52 $(CC) -E -DSOL asm/rm86unix.cpp | sed 's/^#.*//' > asm/rm86-sol.s
53 as -o asm/rm86-sol.o asm/rm86-sol.s
54 rm -f asm/rm86-sol.s
55
56# a.out
57asm/rm86-out.o: asm/rm86unix.cpp
58 $(CPP) -DOUT asm/rm86unix.cpp | as -o asm/rm86-out.o
59
60# bsdi
61asm/rm86bsdi.o: asm/rm86unix.cpp
62 $(CPP) -DBSDI asm/rm86unix.cpp | as -o asm/rm86bsdi.o
63
64asm/rm86unix.cpp:
65 (cd asm; perl rmd-586.pl cpp >rm86unix.cpp)
66
67files:
68 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
69
70links:
71 /bin/rm -f Makefile
72 $(TOP)/util/point.sh Makefile.ssl Makefile ;
73 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
74 $(TOP)/util/mklink.sh ../../test $(TEST)
75 $(TOP)/util/mklink.sh ../../apps $(APPS)
76
77install:
78 @for i in $(EXHEADER) ; \
79 do \
80 (cp $$i $(INSTALLTOP)/include/$$i; \
81 chmod 644 $(INSTALLTOP)/include/$$i ); \
82 done;
83
84tags:
85 ctags $(SRC)
86
87tests:
88
89lint:
90 lint -DLINT $(INCLUDES) $(SRC)>fluff
91
92depend:
93 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
94
95dclean:
96 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
97 mv -f Makefile.new $(MAKEFILE)
98
99clean:
100 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
101
102errors:
103
104# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/ripemd/Makefile.uni b/src/lib/libssl/src/crypto/ripemd/Makefile.uni
new file mode 100644
index 0000000000..54685712db
--- /dev/null
+++ b/src/lib/libssl/src/crypto/ripemd/Makefile.uni
@@ -0,0 +1,109 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= md5
11TOP= .
12CC= gcc
13CFLAG= -O3 -fomit-frame-pointer
14
15CPP= $(CC) -E
16INCLUDES=
17INSTALLTOP=/usr/local/lib
18MAKE= make
19MAKEDEPEND= makedepend
20MAKEFILE= Makefile.uni
21AR= ar r
22
23MD5_ASM_OBJ=
24
25CFLAGS= $(INCLUDES) $(CFLAG)
26
27GENERAL=Makefile
28TEST=md5test
29APPS=md5
30
31LIB=libmd5.a
32LIBSRC=md5_dgst.c md5_one.c
33LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
34
35SRC= $(LIBSRC)
36
37EXHEADER= md5.h
38HEADER= md5_locl.h $(EXHEADER)
39
40ALL= $(GENERAL) $(SRC) $(HEADER)
41
42all: $(LIB) $(TEST) $(APPS)
43
44$(LIB): $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 sh $(TOP)/ranlib.sh $(LIB)
47
48# elf
49asm/mx86-elf.o: asm/mx86unix.cpp
50 $(CPP) -DELF asm/mx86unix.cpp | as -o asm/mx86-elf.o
51
52# solaris
53asm/mx86-sol.o: asm/mx86unix.cpp
54 $(CC) -E -DSOL asm/mx86unix.cpp | sed 's/^#.*//' > asm/mx86-sol.s
55 as -o asm/mx86-sol.o asm/mx86-sol.s
56 rm -f asm/mx86-sol.s
57
58# a.out
59asm/mx86-out.o: asm/mx86unix.cpp
60 $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o
61
62# bsdi
63asm/mx86bsdi.o: asm/mx86unix.cpp
64 $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o
65
66asm/mx86unix.cpp:
67 (cd asm; perl md5-586.pl cpp >mx86unix.cpp)
68
69test: $(TEST)
70 ./$(TEST)
71
72$(TEST): $(TEST).c $(LIB)
73 $(CC) -o $(TEST) $(CFLAGS) $(TEST).c $(LIB)
74
75$(APPS): $(APPS).c $(LIB)
76 $(CC) -o $(APPS) $(CFLAGS) $(APPS).c $(LIB)
77
78lint:
79 lint -DLINT $(INCLUDES) $(SRC)>fluff
80
81depend:
82 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
83
84dclean:
85 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
86 mv -f Makefile.new $(MAKEFILE)
87
88clean:
89 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
90
91cc:
92 $(MAKE) MD5_ASM_OBJ="" CC="cc" CFLAG="-O" all
93
94gcc:
95 $(MAKE) MD5_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
96
97x86-elf:
98 $(MAKE) MD5_ASM_OBJ="asm/mx86-elf.o" CFLAG="-DELF -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
99
100x86-out:
101 $(MAKE) MD5_ASM_OBJ="asm/mx86-out.o" CFLAG="-DOUT -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
102
103x86-solaris:
104 $(MAKE) MD5_ASM_OBJ="asm/mx86-sol.o" CFLAG="-DSOL -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
105
106x86-bdsi:
107 $(MAKE) MD5_ASM_OBJ="asm/mx86-bdsi.o" CFLAG="-DBDSI -DMD5_ASM -DL_ENDIAN $(CFLAGS)" all
108
109# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm b/src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm
new file mode 100644
index 0000000000..bd38791c13
--- /dev/null
+++ b/src/lib/libssl/src/crypto/ripemd/asm/rm-win32.asm
@@ -0,0 +1,1972 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by rmd-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE rmd-586.asm
8 .386
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _ripemd160_block_x86
12
13_ripemd160_block_x86 PROC NEAR
14 push esi
15 mov ecx, DWORD PTR 16[esp]
16 push edi
17 mov esi, DWORD PTR 16[esp]
18 push ebp
19 add ecx, esi
20 push ebx
21 sub ecx, 64
22 sub esp, 88
23 mov DWORD PTR [esp],ecx
24 mov edi, DWORD PTR 108[esp]
25L000start:
26 ;
27 mov eax, DWORD PTR [esi]
28 mov ebx, DWORD PTR 4[esi]
29 mov DWORD PTR 4[esp],eax
30 mov DWORD PTR 8[esp],ebx
31 mov eax, DWORD PTR 8[esi]
32 mov ebx, DWORD PTR 12[esi]
33 mov DWORD PTR 12[esp],eax
34 mov DWORD PTR 16[esp],ebx
35 mov eax, DWORD PTR 16[esi]
36 mov ebx, DWORD PTR 20[esi]
37 mov DWORD PTR 20[esp],eax
38 mov DWORD PTR 24[esp],ebx
39 mov eax, DWORD PTR 24[esi]
40 mov ebx, DWORD PTR 28[esi]
41 mov DWORD PTR 28[esp],eax
42 mov DWORD PTR 32[esp],ebx
43 mov eax, DWORD PTR 32[esi]
44 mov ebx, DWORD PTR 36[esi]
45 mov DWORD PTR 36[esp],eax
46 mov DWORD PTR 40[esp],ebx
47 mov eax, DWORD PTR 40[esi]
48 mov ebx, DWORD PTR 44[esi]
49 mov DWORD PTR 44[esp],eax
50 mov DWORD PTR 48[esp],ebx
51 mov eax, DWORD PTR 48[esi]
52 mov ebx, DWORD PTR 52[esi]
53 mov DWORD PTR 52[esp],eax
54 mov DWORD PTR 56[esp],ebx
55 mov eax, DWORD PTR 56[esi]
56 mov ebx, DWORD PTR 60[esi]
57 mov DWORD PTR 60[esp],eax
58 mov DWORD PTR 64[esp],ebx
59 add esi, 64
60 mov eax, DWORD PTR [edi]
61 mov DWORD PTR 112[esp],esi
62 mov ebx, DWORD PTR 4[edi]
63 mov ecx, DWORD PTR 8[edi]
64 mov edx, DWORD PTR 12[edi]
65 mov ebp, DWORD PTR 16[edi]
66 ; 0
67 mov esi, ecx
68 xor esi, edx
69 mov edi, DWORD PTR 4[esp]
70 xor esi, ebx
71 add eax, edi
72 rol ecx, 10
73 add eax, esi
74 mov esi, ebx
75 rol eax, 11
76 add eax, ebp
77 ; 1
78 xor esi, ecx
79 mov edi, DWORD PTR 8[esp]
80 xor esi, eax
81 add ebp, esi
82 mov esi, eax
83 rol ebx, 10
84 add ebp, edi
85 xor esi, ebx
86 rol ebp, 14
87 add ebp, edx
88 ; 2
89 mov edi, DWORD PTR 12[esp]
90 xor esi, ebp
91 add edx, edi
92 rol eax, 10
93 add edx, esi
94 mov esi, ebp
95 rol edx, 15
96 add edx, ecx
97 ; 3
98 xor esi, eax
99 mov edi, DWORD PTR 16[esp]
100 xor esi, edx
101 add ecx, esi
102 mov esi, edx
103 rol ebp, 10
104 add ecx, edi
105 xor esi, ebp
106 rol ecx, 12
107 add ecx, ebx
108 ; 4
109 mov edi, DWORD PTR 20[esp]
110 xor esi, ecx
111 add ebx, edi
112 rol edx, 10
113 add ebx, esi
114 mov esi, ecx
115 rol ebx, 5
116 add ebx, eax
117 ; 5
118 xor esi, edx
119 mov edi, DWORD PTR 24[esp]
120 xor esi, ebx
121 add eax, esi
122 mov esi, ebx
123 rol ecx, 10
124 add eax, edi
125 xor esi, ecx
126 rol eax, 8
127 add eax, ebp
128 ; 6
129 mov edi, DWORD PTR 28[esp]
130 xor esi, eax
131 add ebp, edi
132 rol ebx, 10
133 add ebp, esi
134 mov esi, eax
135 rol ebp, 7
136 add ebp, edx
137 ; 7
138 xor esi, ebx
139 mov edi, DWORD PTR 32[esp]
140 xor esi, ebp
141 add edx, esi
142 mov esi, ebp
143 rol eax, 10
144 add edx, edi
145 xor esi, eax
146 rol edx, 9
147 add edx, ecx
148 ; 8
149 mov edi, DWORD PTR 36[esp]
150 xor esi, edx
151 add ecx, edi
152 rol ebp, 10
153 add ecx, esi
154 mov esi, edx
155 rol ecx, 11
156 add ecx, ebx
157 ; 9
158 xor esi, ebp
159 mov edi, DWORD PTR 40[esp]
160 xor esi, ecx
161 add ebx, esi
162 mov esi, ecx
163 rol edx, 10
164 add ebx, edi
165 xor esi, edx
166 rol ebx, 13
167 add ebx, eax
168 ; 10
169 mov edi, DWORD PTR 44[esp]
170 xor esi, ebx
171 add eax, edi
172 rol ecx, 10
173 add eax, esi
174 mov esi, ebx
175 rol eax, 14
176 add eax, ebp
177 ; 11
178 xor esi, ecx
179 mov edi, DWORD PTR 48[esp]
180 xor esi, eax
181 add ebp, esi
182 mov esi, eax
183 rol ebx, 10
184 add ebp, edi
185 xor esi, ebx
186 rol ebp, 15
187 add ebp, edx
188 ; 12
189 mov edi, DWORD PTR 52[esp]
190 xor esi, ebp
191 add edx, edi
192 rol eax, 10
193 add edx, esi
194 mov esi, ebp
195 rol edx, 6
196 add edx, ecx
197 ; 13
198 xor esi, eax
199 mov edi, DWORD PTR 56[esp]
200 xor esi, edx
201 add ecx, esi
202 mov esi, edx
203 rol ebp, 10
204 add ecx, edi
205 xor esi, ebp
206 rol ecx, 7
207 add ecx, ebx
208 ; 14
209 mov edi, DWORD PTR 60[esp]
210 xor esi, ecx
211 add ebx, edi
212 rol edx, 10
213 add ebx, esi
214 mov esi, ecx
215 rol ebx, 9
216 add ebx, eax
217 ; 15
218 xor esi, edx
219 mov edi, DWORD PTR 64[esp]
220 xor esi, ebx
221 add eax, esi
222 mov esi, -1
223 rol ecx, 10
224 add eax, edi
225 mov edi, DWORD PTR 32[esp]
226 rol eax, 8
227 add eax, ebp
228 ; 16
229 add ebp, edi
230 mov edi, ebx
231 sub esi, eax
232 and edi, eax
233 and esi, ecx
234 or edi, esi
235 mov esi, DWORD PTR 20[esp]
236 rol ebx, 10
237 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
238 mov edi, -1
239 rol ebp, 7
240 add ebp, edx
241 ; 17
242 add edx, esi
243 mov esi, eax
244 sub edi, ebp
245 and esi, ebp
246 and edi, ebx
247 or esi, edi
248 mov edi, DWORD PTR 56[esp]
249 rol eax, 10
250 lea edx, DWORD PTR 1518500249[esi*1+edx]
251 mov esi, -1
252 rol edx, 6
253 add edx, ecx
254 ; 18
255 add ecx, edi
256 mov edi, ebp
257 sub esi, edx
258 and edi, edx
259 and esi, eax
260 or edi, esi
261 mov esi, DWORD PTR 8[esp]
262 rol ebp, 10
263 lea ecx, DWORD PTR 1518500249[edi*1+ecx]
264 mov edi, -1
265 rol ecx, 8
266 add ecx, ebx
267 ; 19
268 add ebx, esi
269 mov esi, edx
270 sub edi, ecx
271 and esi, ecx
272 and edi, ebp
273 or esi, edi
274 mov edi, DWORD PTR 44[esp]
275 rol edx, 10
276 lea ebx, DWORD PTR 1518500249[esi*1+ebx]
277 mov esi, -1
278 rol ebx, 13
279 add ebx, eax
280 ; 20
281 add eax, edi
282 mov edi, ecx
283 sub esi, ebx
284 and edi, ebx
285 and esi, edx
286 or edi, esi
287 mov esi, DWORD PTR 28[esp]
288 rol ecx, 10
289 lea eax, DWORD PTR 1518500249[edi*1+eax]
290 mov edi, -1
291 rol eax, 11
292 add eax, ebp
293 ; 21
294 add ebp, esi
295 mov esi, ebx
296 sub edi, eax
297 and esi, eax
298 and edi, ecx
299 or esi, edi
300 mov edi, DWORD PTR 64[esp]
301 rol ebx, 10
302 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
303 mov esi, -1
304 rol ebp, 9
305 add ebp, edx
306 ; 22
307 add edx, edi
308 mov edi, eax
309 sub esi, ebp
310 and edi, ebp
311 and esi, ebx
312 or edi, esi
313 mov esi, DWORD PTR 16[esp]
314 rol eax, 10
315 lea edx, DWORD PTR 1518500249[edi*1+edx]
316 mov edi, -1
317 rol edx, 7
318 add edx, ecx
319 ; 23
320 add ecx, esi
321 mov esi, ebp
322 sub edi, edx
323 and esi, edx
324 and edi, eax
325 or esi, edi
326 mov edi, DWORD PTR 52[esp]
327 rol ebp, 10
328 lea ecx, DWORD PTR 1518500249[esi*1+ecx]
329 mov esi, -1
330 rol ecx, 15
331 add ecx, ebx
332 ; 24
333 add ebx, edi
334 mov edi, edx
335 sub esi, ecx
336 and edi, ecx
337 and esi, ebp
338 or edi, esi
339 mov esi, DWORD PTR 4[esp]
340 rol edx, 10
341 lea ebx, DWORD PTR 1518500249[edi*1+ebx]
342 mov edi, -1
343 rol ebx, 7
344 add ebx, eax
345 ; 25
346 add eax, esi
347 mov esi, ecx
348 sub edi, ebx
349 and esi, ebx
350 and edi, edx
351 or esi, edi
352 mov edi, DWORD PTR 40[esp]
353 rol ecx, 10
354 lea eax, DWORD PTR 1518500249[esi*1+eax]
355 mov esi, -1
356 rol eax, 12
357 add eax, ebp
358 ; 26
359 add ebp, edi
360 mov edi, ebx
361 sub esi, eax
362 and edi, eax
363 and esi, ecx
364 or edi, esi
365 mov esi, DWORD PTR 24[esp]
366 rol ebx, 10
367 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
368 mov edi, -1
369 rol ebp, 15
370 add ebp, edx
371 ; 27
372 add edx, esi
373 mov esi, eax
374 sub edi, ebp
375 and esi, ebp
376 and edi, ebx
377 or esi, edi
378 mov edi, DWORD PTR 12[esp]
379 rol eax, 10
380 lea edx, DWORD PTR 1518500249[esi*1+edx]
381 mov esi, -1
382 rol edx, 9
383 add edx, ecx
384 ; 28
385 add ecx, edi
386 mov edi, ebp
387 sub esi, edx
388 and edi, edx
389 and esi, eax
390 or edi, esi
391 mov esi, DWORD PTR 60[esp]
392 rol ebp, 10
393 lea ecx, DWORD PTR 1518500249[edi*1+ecx]
394 mov edi, -1
395 rol ecx, 11
396 add ecx, ebx
397 ; 29
398 add ebx, esi
399 mov esi, edx
400 sub edi, ecx
401 and esi, ecx
402 and edi, ebp
403 or esi, edi
404 mov edi, DWORD PTR 48[esp]
405 rol edx, 10
406 lea ebx, DWORD PTR 1518500249[esi*1+ebx]
407 mov esi, -1
408 rol ebx, 7
409 add ebx, eax
410 ; 30
411 add eax, edi
412 mov edi, ecx
413 sub esi, ebx
414 and edi, ebx
415 and esi, edx
416 or edi, esi
417 mov esi, DWORD PTR 36[esp]
418 rol ecx, 10
419 lea eax, DWORD PTR 1518500249[edi*1+eax]
420 mov edi, -1
421 rol eax, 13
422 add eax, ebp
423 ; 31
424 add ebp, esi
425 mov esi, ebx
426 sub edi, eax
427 and esi, eax
428 and edi, ecx
429 or esi, edi
430 mov edi, -1
431 rol ebx, 10
432 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
433 sub edi, eax
434 rol ebp, 12
435 add ebp, edx
436 ; 32
437 mov esi, DWORD PTR 16[esp]
438 or edi, ebp
439 add edx, esi
440 xor edi, ebx
441 mov esi, -1
442 rol eax, 10
443 lea edx, DWORD PTR 1859775393[edi*1+edx]
444 sub esi, ebp
445 rol edx, 11
446 add edx, ecx
447 ; 33
448 mov edi, DWORD PTR 44[esp]
449 or esi, edx
450 add ecx, edi
451 xor esi, eax
452 mov edi, -1
453 rol ebp, 10
454 lea ecx, DWORD PTR 1859775393[esi*1+ecx]
455 sub edi, edx
456 rol ecx, 13
457 add ecx, ebx
458 ; 34
459 mov esi, DWORD PTR 60[esp]
460 or edi, ecx
461 add ebx, esi
462 xor edi, ebp
463 mov esi, -1
464 rol edx, 10
465 lea ebx, DWORD PTR 1859775393[edi*1+ebx]
466 sub esi, ecx
467 rol ebx, 6
468 add ebx, eax
469 ; 35
470 mov edi, DWORD PTR 20[esp]
471 or esi, ebx
472 add eax, edi
473 xor esi, edx
474 mov edi, -1
475 rol ecx, 10
476 lea eax, DWORD PTR 1859775393[esi*1+eax]
477 sub edi, ebx
478 rol eax, 7
479 add eax, ebp
480 ; 36
481 mov esi, DWORD PTR 40[esp]
482 or edi, eax
483 add ebp, esi
484 xor edi, ecx
485 mov esi, -1
486 rol ebx, 10
487 lea ebp, DWORD PTR 1859775393[edi*1+ebp]
488 sub esi, eax
489 rol ebp, 14
490 add ebp, edx
491 ; 37
492 mov edi, DWORD PTR 64[esp]
493 or esi, ebp
494 add edx, edi
495 xor esi, ebx
496 mov edi, -1
497 rol eax, 10
498 lea edx, DWORD PTR 1859775393[esi*1+edx]
499 sub edi, ebp
500 rol edx, 9
501 add edx, ecx
502 ; 38
503 mov esi, DWORD PTR 36[esp]
504 or edi, edx
505 add ecx, esi
506 xor edi, eax
507 mov esi, -1
508 rol ebp, 10
509 lea ecx, DWORD PTR 1859775393[edi*1+ecx]
510 sub esi, edx
511 rol ecx, 13
512 add ecx, ebx
513 ; 39
514 mov edi, DWORD PTR 8[esp]
515 or esi, ecx
516 add ebx, edi
517 xor esi, ebp
518 mov edi, -1
519 rol edx, 10
520 lea ebx, DWORD PTR 1859775393[esi*1+ebx]
521 sub edi, ecx
522 rol ebx, 15
523 add ebx, eax
524 ; 40
525 mov esi, DWORD PTR 12[esp]
526 or edi, ebx
527 add eax, esi
528 xor edi, edx
529 mov esi, -1
530 rol ecx, 10
531 lea eax, DWORD PTR 1859775393[edi*1+eax]
532 sub esi, ebx
533 rol eax, 14
534 add eax, ebp
535 ; 41
536 mov edi, DWORD PTR 32[esp]
537 or esi, eax
538 add ebp, edi
539 xor esi, ecx
540 mov edi, -1
541 rol ebx, 10
542 lea ebp, DWORD PTR 1859775393[esi*1+ebp]
543 sub edi, eax
544 rol ebp, 8
545 add ebp, edx
546 ; 42
547 mov esi, DWORD PTR 4[esp]
548 or edi, ebp
549 add edx, esi
550 xor edi, ebx
551 mov esi, -1
552 rol eax, 10
553 lea edx, DWORD PTR 1859775393[edi*1+edx]
554 sub esi, ebp
555 rol edx, 13
556 add edx, ecx
557 ; 43
558 mov edi, DWORD PTR 28[esp]
559 or esi, edx
560 add ecx, edi
561 xor esi, eax
562 mov edi, -1
563 rol ebp, 10
564 lea ecx, DWORD PTR 1859775393[esi*1+ecx]
565 sub edi, edx
566 rol ecx, 6
567 add ecx, ebx
568 ; 44
569 mov esi, DWORD PTR 56[esp]
570 or edi, ecx
571 add ebx, esi
572 xor edi, ebp
573 mov esi, -1
574 rol edx, 10
575 lea ebx, DWORD PTR 1859775393[edi*1+ebx]
576 sub esi, ecx
577 rol ebx, 5
578 add ebx, eax
579 ; 45
580 mov edi, DWORD PTR 48[esp]
581 or esi, ebx
582 add eax, edi
583 xor esi, edx
584 mov edi, -1
585 rol ecx, 10
586 lea eax, DWORD PTR 1859775393[esi*1+eax]
587 sub edi, ebx
588 rol eax, 12
589 add eax, ebp
590 ; 46
591 mov esi, DWORD PTR 24[esp]
592 or edi, eax
593 add ebp, esi
594 xor edi, ecx
595 mov esi, -1
596 rol ebx, 10
597 lea ebp, DWORD PTR 1859775393[edi*1+ebp]
598 sub esi, eax
599 rol ebp, 7
600 add ebp, edx
601 ; 47
602 mov edi, DWORD PTR 52[esp]
603 or esi, ebp
604 add edx, edi
605 xor esi, ebx
606 mov edi, -1
607 rol eax, 10
608 lea edx, DWORD PTR 1859775393[esi*1+edx]
609 mov esi, eax
610 rol edx, 5
611 add edx, ecx
612 ; 48
613 sub edi, eax
614 and esi, edx
615 and edi, ebp
616 or edi, esi
617 mov esi, DWORD PTR 8[esp]
618 rol ebp, 10
619 lea ecx, DWORD PTR 2400959708[edi+ecx]
620 mov edi, -1
621 add ecx, esi
622 mov esi, ebp
623 rol ecx, 11
624 add ecx, ebx
625 ; 49
626 sub edi, ebp
627 and esi, ecx
628 and edi, edx
629 or edi, esi
630 mov esi, DWORD PTR 40[esp]
631 rol edx, 10
632 lea ebx, DWORD PTR 2400959708[edi+ebx]
633 mov edi, -1
634 add ebx, esi
635 mov esi, edx
636 rol ebx, 12
637 add ebx, eax
638 ; 50
639 sub edi, edx
640 and esi, ebx
641 and edi, ecx
642 or edi, esi
643 mov esi, DWORD PTR 48[esp]
644 rol ecx, 10
645 lea eax, DWORD PTR 2400959708[edi+eax]
646 mov edi, -1
647 add eax, esi
648 mov esi, ecx
649 rol eax, 14
650 add eax, ebp
651 ; 51
652 sub edi, ecx
653 and esi, eax
654 and edi, ebx
655 or edi, esi
656 mov esi, DWORD PTR 44[esp]
657 rol ebx, 10
658 lea ebp, DWORD PTR 2400959708[edi+ebp]
659 mov edi, -1
660 add ebp, esi
661 mov esi, ebx
662 rol ebp, 15
663 add ebp, edx
664 ; 52
665 sub edi, ebx
666 and esi, ebp
667 and edi, eax
668 or edi, esi
669 mov esi, DWORD PTR 4[esp]
670 rol eax, 10
671 lea edx, DWORD PTR 2400959708[edi+edx]
672 mov edi, -1
673 add edx, esi
674 mov esi, eax
675 rol edx, 14
676 add edx, ecx
677 ; 53
678 sub edi, eax
679 and esi, edx
680 and edi, ebp
681 or edi, esi
682 mov esi, DWORD PTR 36[esp]
683 rol ebp, 10
684 lea ecx, DWORD PTR 2400959708[edi+ecx]
685 mov edi, -1
686 add ecx, esi
687 mov esi, ebp
688 rol ecx, 15
689 add ecx, ebx
690 ; 54
691 sub edi, ebp
692 and esi, ecx
693 and edi, edx
694 or edi, esi
695 mov esi, DWORD PTR 52[esp]
696 rol edx, 10
697 lea ebx, DWORD PTR 2400959708[edi+ebx]
698 mov edi, -1
699 add ebx, esi
700 mov esi, edx
701 rol ebx, 9
702 add ebx, eax
703 ; 55
704 sub edi, edx
705 and esi, ebx
706 and edi, ecx
707 or edi, esi
708 mov esi, DWORD PTR 20[esp]
709 rol ecx, 10
710 lea eax, DWORD PTR 2400959708[edi+eax]
711 mov edi, -1
712 add eax, esi
713 mov esi, ecx
714 rol eax, 8
715 add eax, ebp
716 ; 56
717 sub edi, ecx
718 and esi, eax
719 and edi, ebx
720 or edi, esi
721 mov esi, DWORD PTR 56[esp]
722 rol ebx, 10
723 lea ebp, DWORD PTR 2400959708[edi+ebp]
724 mov edi, -1
725 add ebp, esi
726 mov esi, ebx
727 rol ebp, 9
728 add ebp, edx
729 ; 57
730 sub edi, ebx
731 and esi, ebp
732 and edi, eax
733 or edi, esi
734 mov esi, DWORD PTR 16[esp]
735 rol eax, 10
736 lea edx, DWORD PTR 2400959708[edi+edx]
737 mov edi, -1
738 add edx, esi
739 mov esi, eax
740 rol edx, 14
741 add edx, ecx
742 ; 58
743 sub edi, eax
744 and esi, edx
745 and edi, ebp
746 or edi, esi
747 mov esi, DWORD PTR 32[esp]
748 rol ebp, 10
749 lea ecx, DWORD PTR 2400959708[edi+ecx]
750 mov edi, -1
751 add ecx, esi
752 mov esi, ebp
753 rol ecx, 5
754 add ecx, ebx
755 ; 59
756 sub edi, ebp
757 and esi, ecx
758 and edi, edx
759 or edi, esi
760 mov esi, DWORD PTR 64[esp]
761 rol edx, 10
762 lea ebx, DWORD PTR 2400959708[edi+ebx]
763 mov edi, -1
764 add ebx, esi
765 mov esi, edx
766 rol ebx, 6
767 add ebx, eax
768 ; 60
769 sub edi, edx
770 and esi, ebx
771 and edi, ecx
772 or edi, esi
773 mov esi, DWORD PTR 60[esp]
774 rol ecx, 10
775 lea eax, DWORD PTR 2400959708[edi+eax]
776 mov edi, -1
777 add eax, esi
778 mov esi, ecx
779 rol eax, 8
780 add eax, ebp
781 ; 61
782 sub edi, ecx
783 and esi, eax
784 and edi, ebx
785 or edi, esi
786 mov esi, DWORD PTR 24[esp]
787 rol ebx, 10
788 lea ebp, DWORD PTR 2400959708[edi+ebp]
789 mov edi, -1
790 add ebp, esi
791 mov esi, ebx
792 rol ebp, 6
793 add ebp, edx
794 ; 62
795 sub edi, ebx
796 and esi, ebp
797 and edi, eax
798 or edi, esi
799 mov esi, DWORD PTR 28[esp]
800 rol eax, 10
801 lea edx, DWORD PTR 2400959708[edi+edx]
802 mov edi, -1
803 add edx, esi
804 mov esi, eax
805 rol edx, 5
806 add edx, ecx
807 ; 63
808 sub edi, eax
809 and esi, edx
810 and edi, ebp
811 or edi, esi
812 mov esi, DWORD PTR 12[esp]
813 rol ebp, 10
814 lea ecx, DWORD PTR 2400959708[edi+ecx]
815 mov edi, -1
816 add ecx, esi
817 sub edi, ebp
818 rol ecx, 12
819 add ecx, ebx
820 ; 64
821 mov esi, DWORD PTR 20[esp]
822 or edi, edx
823 add ebx, esi
824 xor edi, ecx
825 mov esi, -1
826 rol edx, 10
827 lea ebx, DWORD PTR 2840853838[edi*1+ebx]
828 sub esi, edx
829 rol ebx, 9
830 add ebx, eax
831 ; 65
832 mov edi, DWORD PTR 4[esp]
833 or esi, ecx
834 add eax, edi
835 xor esi, ebx
836 mov edi, -1
837 rol ecx, 10
838 lea eax, DWORD PTR 2840853838[esi*1+eax]
839 sub edi, ecx
840 rol eax, 15
841 add eax, ebp
842 ; 66
843 mov esi, DWORD PTR 24[esp]
844 or edi, ebx
845 add ebp, esi
846 xor edi, eax
847 mov esi, -1
848 rol ebx, 10
849 lea ebp, DWORD PTR 2840853838[edi*1+ebp]
850 sub esi, ebx
851 rol ebp, 5
852 add ebp, edx
853 ; 67
854 mov edi, DWORD PTR 40[esp]
855 or esi, eax
856 add edx, edi
857 xor esi, ebp
858 mov edi, -1
859 rol eax, 10
860 lea edx, DWORD PTR 2840853838[esi*1+edx]
861 sub edi, eax
862 rol edx, 11
863 add edx, ecx
864 ; 68
865 mov esi, DWORD PTR 32[esp]
866 or edi, ebp
867 add ecx, esi
868 xor edi, edx
869 mov esi, -1
870 rol ebp, 10
871 lea ecx, DWORD PTR 2840853838[edi*1+ecx]
872 sub esi, ebp
873 rol ecx, 6
874 add ecx, ebx
875 ; 69
876 mov edi, DWORD PTR 52[esp]
877 or esi, edx
878 add ebx, edi
879 xor esi, ecx
880 mov edi, -1
881 rol edx, 10
882 lea ebx, DWORD PTR 2840853838[esi*1+ebx]
883 sub edi, edx
884 rol ebx, 8
885 add ebx, eax
886 ; 70
887 mov esi, DWORD PTR 12[esp]
888 or edi, ecx
889 add eax, esi
890 xor edi, ebx
891 mov esi, -1
892 rol ecx, 10
893 lea eax, DWORD PTR 2840853838[edi*1+eax]
894 sub esi, ecx
895 rol eax, 13
896 add eax, ebp
897 ; 71
898 mov edi, DWORD PTR 44[esp]
899 or esi, ebx
900 add ebp, edi
901 xor esi, eax
902 mov edi, -1
903 rol ebx, 10
904 lea ebp, DWORD PTR 2840853838[esi*1+ebp]
905 sub edi, ebx
906 rol ebp, 12
907 add ebp, edx
908 ; 72
909 mov esi, DWORD PTR 60[esp]
910 or edi, eax
911 add edx, esi
912 xor edi, ebp
913 mov esi, -1
914 rol eax, 10
915 lea edx, DWORD PTR 2840853838[edi*1+edx]
916 sub esi, eax
917 rol edx, 5
918 add edx, ecx
919 ; 73
920 mov edi, DWORD PTR 8[esp]
921 or esi, ebp
922 add ecx, edi
923 xor esi, edx
924 mov edi, -1
925 rol ebp, 10
926 lea ecx, DWORD PTR 2840853838[esi*1+ecx]
927 sub edi, ebp
928 rol ecx, 12
929 add ecx, ebx
930 ; 74
931 mov esi, DWORD PTR 16[esp]
932 or edi, edx
933 add ebx, esi
934 xor edi, ecx
935 mov esi, -1
936 rol edx, 10
937 lea ebx, DWORD PTR 2840853838[edi*1+ebx]
938 sub esi, edx
939 rol ebx, 13
940 add ebx, eax
941 ; 75
942 mov edi, DWORD PTR 36[esp]
943 or esi, ecx
944 add eax, edi
945 xor esi, ebx
946 mov edi, -1
947 rol ecx, 10
948 lea eax, DWORD PTR 2840853838[esi*1+eax]
949 sub edi, ecx
950 rol eax, 14
951 add eax, ebp
952 ; 76
953 mov esi, DWORD PTR 48[esp]
954 or edi, ebx
955 add ebp, esi
956 xor edi, eax
957 mov esi, -1
958 rol ebx, 10
959 lea ebp, DWORD PTR 2840853838[edi*1+ebp]
960 sub esi, ebx
961 rol ebp, 11
962 add ebp, edx
963 ; 77
964 mov edi, DWORD PTR 28[esp]
965 or esi, eax
966 add edx, edi
967 xor esi, ebp
968 mov edi, -1
969 rol eax, 10
970 lea edx, DWORD PTR 2840853838[esi*1+edx]
971 sub edi, eax
972 rol edx, 8
973 add edx, ecx
974 ; 78
975 mov esi, DWORD PTR 64[esp]
976 or edi, ebp
977 add ecx, esi
978 xor edi, edx
979 mov esi, -1
980 rol ebp, 10
981 lea ecx, DWORD PTR 2840853838[edi*1+ecx]
982 sub esi, ebp
983 rol ecx, 5
984 add ecx, ebx
985 ; 79
986 mov edi, DWORD PTR 56[esp]
987 or esi, edx
988 add ebx, edi
989 xor esi, ecx
990 mov edi, DWORD PTR 108[esp]
991 rol edx, 10
992 lea ebx, DWORD PTR 2840853838[esi*1+ebx]
993 mov DWORD PTR 68[esp],eax
994 rol ebx, 6
995 add ebx, eax
996 mov eax, DWORD PTR [edi]
997 mov DWORD PTR 72[esp],ebx
998 mov DWORD PTR 76[esp],ecx
999 mov ebx, DWORD PTR 4[edi]
1000 mov DWORD PTR 80[esp],edx
1001 mov ecx, DWORD PTR 8[edi]
1002 mov DWORD PTR 84[esp],ebp
1003 mov edx, DWORD PTR 12[edi]
1004 mov ebp, DWORD PTR 16[edi]
1005 ; 80
1006 mov edi, -1
1007 sub edi, edx
1008 mov esi, DWORD PTR 24[esp]
1009 or edi, ecx
1010 add eax, esi
1011 xor edi, ebx
1012 mov esi, -1
1013 rol ecx, 10
1014 lea eax, DWORD PTR 1352829926[edi*1+eax]
1015 sub esi, ecx
1016 rol eax, 8
1017 add eax, ebp
1018 ; 81
1019 mov edi, DWORD PTR 60[esp]
1020 or esi, ebx
1021 add ebp, edi
1022 xor esi, eax
1023 mov edi, -1
1024 rol ebx, 10
1025 lea ebp, DWORD PTR 1352829926[esi*1+ebp]
1026 sub edi, ebx
1027 rol ebp, 9
1028 add ebp, edx
1029 ; 82
1030 mov esi, DWORD PTR 32[esp]
1031 or edi, eax
1032 add edx, esi
1033 xor edi, ebp
1034 mov esi, -1
1035 rol eax, 10
1036 lea edx, DWORD PTR 1352829926[edi*1+edx]
1037 sub esi, eax
1038 rol edx, 9
1039 add edx, ecx
1040 ; 83
1041 mov edi, DWORD PTR 4[esp]
1042 or esi, ebp
1043 add ecx, edi
1044 xor esi, edx
1045 mov edi, -1
1046 rol ebp, 10
1047 lea ecx, DWORD PTR 1352829926[esi*1+ecx]
1048 sub edi, ebp
1049 rol ecx, 11
1050 add ecx, ebx
1051 ; 84
1052 mov esi, DWORD PTR 40[esp]
1053 or edi, edx
1054 add ebx, esi
1055 xor edi, ecx
1056 mov esi, -1
1057 rol edx, 10
1058 lea ebx, DWORD PTR 1352829926[edi*1+ebx]
1059 sub esi, edx
1060 rol ebx, 13
1061 add ebx, eax
1062 ; 85
1063 mov edi, DWORD PTR 12[esp]
1064 or esi, ecx
1065 add eax, edi
1066 xor esi, ebx
1067 mov edi, -1
1068 rol ecx, 10
1069 lea eax, DWORD PTR 1352829926[esi*1+eax]
1070 sub edi, ecx
1071 rol eax, 15
1072 add eax, ebp
1073 ; 86
1074 mov esi, DWORD PTR 48[esp]
1075 or edi, ebx
1076 add ebp, esi
1077 xor edi, eax
1078 mov esi, -1
1079 rol ebx, 10
1080 lea ebp, DWORD PTR 1352829926[edi*1+ebp]
1081 sub esi, ebx
1082 rol ebp, 15
1083 add ebp, edx
1084 ; 87
1085 mov edi, DWORD PTR 20[esp]
1086 or esi, eax
1087 add edx, edi
1088 xor esi, ebp
1089 mov edi, -1
1090 rol eax, 10
1091 lea edx, DWORD PTR 1352829926[esi*1+edx]
1092 sub edi, eax
1093 rol edx, 5
1094 add edx, ecx
1095 ; 88
1096 mov esi, DWORD PTR 56[esp]
1097 or edi, ebp
1098 add ecx, esi
1099 xor edi, edx
1100 mov esi, -1
1101 rol ebp, 10
1102 lea ecx, DWORD PTR 1352829926[edi*1+ecx]
1103 sub esi, ebp
1104 rol ecx, 7
1105 add ecx, ebx
1106 ; 89
1107 mov edi, DWORD PTR 28[esp]
1108 or esi, edx
1109 add ebx, edi
1110 xor esi, ecx
1111 mov edi, -1
1112 rol edx, 10
1113 lea ebx, DWORD PTR 1352829926[esi*1+ebx]
1114 sub edi, edx
1115 rol ebx, 7
1116 add ebx, eax
1117 ; 90
1118 mov esi, DWORD PTR 64[esp]
1119 or edi, ecx
1120 add eax, esi
1121 xor edi, ebx
1122 mov esi, -1
1123 rol ecx, 10
1124 lea eax, DWORD PTR 1352829926[edi*1+eax]
1125 sub esi, ecx
1126 rol eax, 8
1127 add eax, ebp
1128 ; 91
1129 mov edi, DWORD PTR 36[esp]
1130 or esi, ebx
1131 add ebp, edi
1132 xor esi, eax
1133 mov edi, -1
1134 rol ebx, 10
1135 lea ebp, DWORD PTR 1352829926[esi*1+ebp]
1136 sub edi, ebx
1137 rol ebp, 11
1138 add ebp, edx
1139 ; 92
1140 mov esi, DWORD PTR 8[esp]
1141 or edi, eax
1142 add edx, esi
1143 xor edi, ebp
1144 mov esi, -1
1145 rol eax, 10
1146 lea edx, DWORD PTR 1352829926[edi*1+edx]
1147 sub esi, eax
1148 rol edx, 14
1149 add edx, ecx
1150 ; 93
1151 mov edi, DWORD PTR 44[esp]
1152 or esi, ebp
1153 add ecx, edi
1154 xor esi, edx
1155 mov edi, -1
1156 rol ebp, 10
1157 lea ecx, DWORD PTR 1352829926[esi*1+ecx]
1158 sub edi, ebp
1159 rol ecx, 14
1160 add ecx, ebx
1161 ; 94
1162 mov esi, DWORD PTR 16[esp]
1163 or edi, edx
1164 add ebx, esi
1165 xor edi, ecx
1166 mov esi, -1
1167 rol edx, 10
1168 lea ebx, DWORD PTR 1352829926[edi*1+ebx]
1169 sub esi, edx
1170 rol ebx, 12
1171 add ebx, eax
1172 ; 95
1173 mov edi, DWORD PTR 52[esp]
1174 or esi, ecx
1175 add eax, edi
1176 xor esi, ebx
1177 mov edi, -1
1178 rol ecx, 10
1179 lea eax, DWORD PTR 1352829926[esi*1+eax]
1180 mov esi, ecx
1181 rol eax, 6
1182 add eax, ebp
1183 ; 96
1184 sub edi, ecx
1185 and esi, eax
1186 and edi, ebx
1187 or edi, esi
1188 mov esi, DWORD PTR 28[esp]
1189 rol ebx, 10
1190 lea ebp, DWORD PTR 1548603684[edi+ebp]
1191 mov edi, -1
1192 add ebp, esi
1193 mov esi, ebx
1194 rol ebp, 9
1195 add ebp, edx
1196 ; 97
1197 sub edi, ebx
1198 and esi, ebp
1199 and edi, eax
1200 or edi, esi
1201 mov esi, DWORD PTR 48[esp]
1202 rol eax, 10
1203 lea edx, DWORD PTR 1548603684[edi+edx]
1204 mov edi, -1
1205 add edx, esi
1206 mov esi, eax
1207 rol edx, 13
1208 add edx, ecx
1209 ; 98
1210 sub edi, eax
1211 and esi, edx
1212 and edi, ebp
1213 or edi, esi
1214 mov esi, DWORD PTR 16[esp]
1215 rol ebp, 10
1216 lea ecx, DWORD PTR 1548603684[edi+ecx]
1217 mov edi, -1
1218 add ecx, esi
1219 mov esi, ebp
1220 rol ecx, 15
1221 add ecx, ebx
1222 ; 99
1223 sub edi, ebp
1224 and esi, ecx
1225 and edi, edx
1226 or edi, esi
1227 mov esi, DWORD PTR 32[esp]
1228 rol edx, 10
1229 lea ebx, DWORD PTR 1548603684[edi+ebx]
1230 mov edi, -1
1231 add ebx, esi
1232 mov esi, edx
1233 rol ebx, 7
1234 add ebx, eax
1235 ; 100
1236 sub edi, edx
1237 and esi, ebx
1238 and edi, ecx
1239 or edi, esi
1240 mov esi, DWORD PTR 4[esp]
1241 rol ecx, 10
1242 lea eax, DWORD PTR 1548603684[edi+eax]
1243 mov edi, -1
1244 add eax, esi
1245 mov esi, ecx
1246 rol eax, 12
1247 add eax, ebp
1248 ; 101
1249 sub edi, ecx
1250 and esi, eax
1251 and edi, ebx
1252 or edi, esi
1253 mov esi, DWORD PTR 56[esp]
1254 rol ebx, 10
1255 lea ebp, DWORD PTR 1548603684[edi+ebp]
1256 mov edi, -1
1257 add ebp, esi
1258 mov esi, ebx
1259 rol ebp, 8
1260 add ebp, edx
1261 ; 102
1262 sub edi, ebx
1263 and esi, ebp
1264 and edi, eax
1265 or edi, esi
1266 mov esi, DWORD PTR 24[esp]
1267 rol eax, 10
1268 lea edx, DWORD PTR 1548603684[edi+edx]
1269 mov edi, -1
1270 add edx, esi
1271 mov esi, eax
1272 rol edx, 9
1273 add edx, ecx
1274 ; 103
1275 sub edi, eax
1276 and esi, edx
1277 and edi, ebp
1278 or edi, esi
1279 mov esi, DWORD PTR 44[esp]
1280 rol ebp, 10
1281 lea ecx, DWORD PTR 1548603684[edi+ecx]
1282 mov edi, -1
1283 add ecx, esi
1284 mov esi, ebp
1285 rol ecx, 11
1286 add ecx, ebx
1287 ; 104
1288 sub edi, ebp
1289 and esi, ecx
1290 and edi, edx
1291 or edi, esi
1292 mov esi, DWORD PTR 60[esp]
1293 rol edx, 10
1294 lea ebx, DWORD PTR 1548603684[edi+ebx]
1295 mov edi, -1
1296 add ebx, esi
1297 mov esi, edx
1298 rol ebx, 7
1299 add ebx, eax
1300 ; 105
1301 sub edi, edx
1302 and esi, ebx
1303 and edi, ecx
1304 or edi, esi
1305 mov esi, DWORD PTR 64[esp]
1306 rol ecx, 10
1307 lea eax, DWORD PTR 1548603684[edi+eax]
1308 mov edi, -1
1309 add eax, esi
1310 mov esi, ecx
1311 rol eax, 7
1312 add eax, ebp
1313 ; 106
1314 sub edi, ecx
1315 and esi, eax
1316 and edi, ebx
1317 or edi, esi
1318 mov esi, DWORD PTR 36[esp]
1319 rol ebx, 10
1320 lea ebp, DWORD PTR 1548603684[edi+ebp]
1321 mov edi, -1
1322 add ebp, esi
1323 mov esi, ebx
1324 rol ebp, 12
1325 add ebp, edx
1326 ; 107
1327 sub edi, ebx
1328 and esi, ebp
1329 and edi, eax
1330 or edi, esi
1331 mov esi, DWORD PTR 52[esp]
1332 rol eax, 10
1333 lea edx, DWORD PTR 1548603684[edi+edx]
1334 mov edi, -1
1335 add edx, esi
1336 mov esi, eax
1337 rol edx, 7
1338 add edx, ecx
1339 ; 108
1340 sub edi, eax
1341 and esi, edx
1342 and edi, ebp
1343 or edi, esi
1344 mov esi, DWORD PTR 20[esp]
1345 rol ebp, 10
1346 lea ecx, DWORD PTR 1548603684[edi+ecx]
1347 mov edi, -1
1348 add ecx, esi
1349 mov esi, ebp
1350 rol ecx, 6
1351 add ecx, ebx
1352 ; 109
1353 sub edi, ebp
1354 and esi, ecx
1355 and edi, edx
1356 or edi, esi
1357 mov esi, DWORD PTR 40[esp]
1358 rol edx, 10
1359 lea ebx, DWORD PTR 1548603684[edi+ebx]
1360 mov edi, -1
1361 add ebx, esi
1362 mov esi, edx
1363 rol ebx, 15
1364 add ebx, eax
1365 ; 110
1366 sub edi, edx
1367 and esi, ebx
1368 and edi, ecx
1369 or edi, esi
1370 mov esi, DWORD PTR 8[esp]
1371 rol ecx, 10
1372 lea eax, DWORD PTR 1548603684[edi+eax]
1373 mov edi, -1
1374 add eax, esi
1375 mov esi, ecx
1376 rol eax, 13
1377 add eax, ebp
1378 ; 111
1379 sub edi, ecx
1380 and esi, eax
1381 and edi, ebx
1382 or edi, esi
1383 mov esi, DWORD PTR 12[esp]
1384 rol ebx, 10
1385 lea ebp, DWORD PTR 1548603684[edi+ebp]
1386 mov edi, -1
1387 add ebp, esi
1388 sub edi, eax
1389 rol ebp, 11
1390 add ebp, edx
1391 ; 112
1392 mov esi, DWORD PTR 64[esp]
1393 or edi, ebp
1394 add edx, esi
1395 xor edi, ebx
1396 mov esi, -1
1397 rol eax, 10
1398 lea edx, DWORD PTR 1836072691[edi*1+edx]
1399 sub esi, ebp
1400 rol edx, 9
1401 add edx, ecx
1402 ; 113
1403 mov edi, DWORD PTR 24[esp]
1404 or esi, edx
1405 add ecx, edi
1406 xor esi, eax
1407 mov edi, -1
1408 rol ebp, 10
1409 lea ecx, DWORD PTR 1836072691[esi*1+ecx]
1410 sub edi, edx
1411 rol ecx, 7
1412 add ecx, ebx
1413 ; 114
1414 mov esi, DWORD PTR 8[esp]
1415 or edi, ecx
1416 add ebx, esi
1417 xor edi, ebp
1418 mov esi, -1
1419 rol edx, 10
1420 lea ebx, DWORD PTR 1836072691[edi*1+ebx]
1421 sub esi, ecx
1422 rol ebx, 15
1423 add ebx, eax
1424 ; 115
1425 mov edi, DWORD PTR 16[esp]
1426 or esi, ebx
1427 add eax, edi
1428 xor esi, edx
1429 mov edi, -1
1430 rol ecx, 10
1431 lea eax, DWORD PTR 1836072691[esi*1+eax]
1432 sub edi, ebx
1433 rol eax, 11
1434 add eax, ebp
1435 ; 116
1436 mov esi, DWORD PTR 32[esp]
1437 or edi, eax
1438 add ebp, esi
1439 xor edi, ecx
1440 mov esi, -1
1441 rol ebx, 10
1442 lea ebp, DWORD PTR 1836072691[edi*1+ebp]
1443 sub esi, eax
1444 rol ebp, 8
1445 add ebp, edx
1446 ; 117
1447 mov edi, DWORD PTR 60[esp]
1448 or esi, ebp
1449 add edx, edi
1450 xor esi, ebx
1451 mov edi, -1
1452 rol eax, 10
1453 lea edx, DWORD PTR 1836072691[esi*1+edx]
1454 sub edi, ebp
1455 rol edx, 6
1456 add edx, ecx
1457 ; 118
1458 mov esi, DWORD PTR 28[esp]
1459 or edi, edx
1460 add ecx, esi
1461 xor edi, eax
1462 mov esi, -1
1463 rol ebp, 10
1464 lea ecx, DWORD PTR 1836072691[edi*1+ecx]
1465 sub esi, edx
1466 rol ecx, 6
1467 add ecx, ebx
1468 ; 119
1469 mov edi, DWORD PTR 40[esp]
1470 or esi, ecx
1471 add ebx, edi
1472 xor esi, ebp
1473 mov edi, -1
1474 rol edx, 10
1475 lea ebx, DWORD PTR 1836072691[esi*1+ebx]
1476 sub edi, ecx
1477 rol ebx, 14
1478 add ebx, eax
1479 ; 120
1480 mov esi, DWORD PTR 48[esp]
1481 or edi, ebx
1482 add eax, esi
1483 xor edi, edx
1484 mov esi, -1
1485 rol ecx, 10
1486 lea eax, DWORD PTR 1836072691[edi*1+eax]
1487 sub esi, ebx
1488 rol eax, 12
1489 add eax, ebp
1490 ; 121
1491 mov edi, DWORD PTR 36[esp]
1492 or esi, eax
1493 add ebp, edi
1494 xor esi, ecx
1495 mov edi, -1
1496 rol ebx, 10
1497 lea ebp, DWORD PTR 1836072691[esi*1+ebp]
1498 sub edi, eax
1499 rol ebp, 13
1500 add ebp, edx
1501 ; 122
1502 mov esi, DWORD PTR 52[esp]
1503 or edi, ebp
1504 add edx, esi
1505 xor edi, ebx
1506 mov esi, -1
1507 rol eax, 10
1508 lea edx, DWORD PTR 1836072691[edi*1+edx]
1509 sub esi, ebp
1510 rol edx, 5
1511 add edx, ecx
1512 ; 123
1513 mov edi, DWORD PTR 12[esp]
1514 or esi, edx
1515 add ecx, edi
1516 xor esi, eax
1517 mov edi, -1
1518 rol ebp, 10
1519 lea ecx, DWORD PTR 1836072691[esi*1+ecx]
1520 sub edi, edx
1521 rol ecx, 14
1522 add ecx, ebx
1523 ; 124
1524 mov esi, DWORD PTR 44[esp]
1525 or edi, ecx
1526 add ebx, esi
1527 xor edi, ebp
1528 mov esi, -1
1529 rol edx, 10
1530 lea ebx, DWORD PTR 1836072691[edi*1+ebx]
1531 sub esi, ecx
1532 rol ebx, 13
1533 add ebx, eax
1534 ; 125
1535 mov edi, DWORD PTR 4[esp]
1536 or esi, ebx
1537 add eax, edi
1538 xor esi, edx
1539 mov edi, -1
1540 rol ecx, 10
1541 lea eax, DWORD PTR 1836072691[esi*1+eax]
1542 sub edi, ebx
1543 rol eax, 13
1544 add eax, ebp
1545 ; 126
1546 mov esi, DWORD PTR 20[esp]
1547 or edi, eax
1548 add ebp, esi
1549 xor edi, ecx
1550 mov esi, -1
1551 rol ebx, 10
1552 lea ebp, DWORD PTR 1836072691[edi*1+ebp]
1553 sub esi, eax
1554 rol ebp, 7
1555 add ebp, edx
1556 ; 127
1557 mov edi, DWORD PTR 56[esp]
1558 or esi, ebp
1559 add edx, edi
1560 xor esi, ebx
1561 mov edi, DWORD PTR 36[esp]
1562 rol eax, 10
1563 lea edx, DWORD PTR 1836072691[esi*1+edx]
1564 mov esi, -1
1565 rol edx, 5
1566 add edx, ecx
1567 ; 128
1568 add ecx, edi
1569 mov edi, ebp
1570 sub esi, edx
1571 and edi, edx
1572 and esi, eax
1573 or edi, esi
1574 mov esi, DWORD PTR 28[esp]
1575 rol ebp, 10
1576 lea ecx, DWORD PTR 2053994217[edi*1+ecx]
1577 mov edi, -1
1578 rol ecx, 15
1579 add ecx, ebx
1580 ; 129
1581 add ebx, esi
1582 mov esi, edx
1583 sub edi, ecx
1584 and esi, ecx
1585 and edi, ebp
1586 or esi, edi
1587 mov edi, DWORD PTR 20[esp]
1588 rol edx, 10
1589 lea ebx, DWORD PTR 2053994217[esi*1+ebx]
1590 mov esi, -1
1591 rol ebx, 5
1592 add ebx, eax
1593 ; 130
1594 add eax, edi
1595 mov edi, ecx
1596 sub esi, ebx
1597 and edi, ebx
1598 and esi, edx
1599 or edi, esi
1600 mov esi, DWORD PTR 8[esp]
1601 rol ecx, 10
1602 lea eax, DWORD PTR 2053994217[edi*1+eax]
1603 mov edi, -1
1604 rol eax, 8
1605 add eax, ebp
1606 ; 131
1607 add ebp, esi
1608 mov esi, ebx
1609 sub edi, eax
1610 and esi, eax
1611 and edi, ecx
1612 or esi, edi
1613 mov edi, DWORD PTR 16[esp]
1614 rol ebx, 10
1615 lea ebp, DWORD PTR 2053994217[esi*1+ebp]
1616 mov esi, -1
1617 rol ebp, 11
1618 add ebp, edx
1619 ; 132
1620 add edx, edi
1621 mov edi, eax
1622 sub esi, ebp
1623 and edi, ebp
1624 and esi, ebx
1625 or edi, esi
1626 mov esi, DWORD PTR 48[esp]
1627 rol eax, 10
1628 lea edx, DWORD PTR 2053994217[edi*1+edx]
1629 mov edi, -1
1630 rol edx, 14
1631 add edx, ecx
1632 ; 133
1633 add ecx, esi
1634 mov esi, ebp
1635 sub edi, edx
1636 and esi, edx
1637 and edi, eax
1638 or esi, edi
1639 mov edi, DWORD PTR 64[esp]
1640 rol ebp, 10
1641 lea ecx, DWORD PTR 2053994217[esi*1+ecx]
1642 mov esi, -1
1643 rol ecx, 14
1644 add ecx, ebx
1645 ; 134
1646 add ebx, edi
1647 mov edi, edx
1648 sub esi, ecx
1649 and edi, ecx
1650 and esi, ebp
1651 or edi, esi
1652 mov esi, DWORD PTR 4[esp]
1653 rol edx, 10
1654 lea ebx, DWORD PTR 2053994217[edi*1+ebx]
1655 mov edi, -1
1656 rol ebx, 6
1657 add ebx, eax
1658 ; 135
1659 add eax, esi
1660 mov esi, ecx
1661 sub edi, ebx
1662 and esi, ebx
1663 and edi, edx
1664 or esi, edi
1665 mov edi, DWORD PTR 24[esp]
1666 rol ecx, 10
1667 lea eax, DWORD PTR 2053994217[esi*1+eax]
1668 mov esi, -1
1669 rol eax, 14
1670 add eax, ebp
1671 ; 136
1672 add ebp, edi
1673 mov edi, ebx
1674 sub esi, eax
1675 and edi, eax
1676 and esi, ecx
1677 or edi, esi
1678 mov esi, DWORD PTR 52[esp]
1679 rol ebx, 10
1680 lea ebp, DWORD PTR 2053994217[edi*1+ebp]
1681 mov edi, -1
1682 rol ebp, 6
1683 add ebp, edx
1684 ; 137
1685 add edx, esi
1686 mov esi, eax
1687 sub edi, ebp
1688 and esi, ebp
1689 and edi, ebx
1690 or esi, edi
1691 mov edi, DWORD PTR 12[esp]
1692 rol eax, 10
1693 lea edx, DWORD PTR 2053994217[esi*1+edx]
1694 mov esi, -1
1695 rol edx, 9
1696 add edx, ecx
1697 ; 138
1698 add ecx, edi
1699 mov edi, ebp
1700 sub esi, edx
1701 and edi, edx
1702 and esi, eax
1703 or edi, esi
1704 mov esi, DWORD PTR 56[esp]
1705 rol ebp, 10
1706 lea ecx, DWORD PTR 2053994217[edi*1+ecx]
1707 mov edi, -1
1708 rol ecx, 12
1709 add ecx, ebx
1710 ; 139
1711 add ebx, esi
1712 mov esi, edx
1713 sub edi, ecx
1714 and esi, ecx
1715 and edi, ebp
1716 or esi, edi
1717 mov edi, DWORD PTR 40[esp]
1718 rol edx, 10
1719 lea ebx, DWORD PTR 2053994217[esi*1+ebx]
1720 mov esi, -1
1721 rol ebx, 9
1722 add ebx, eax
1723 ; 140
1724 add eax, edi
1725 mov edi, ecx
1726 sub esi, ebx
1727 and edi, ebx
1728 and esi, edx
1729 or edi, esi
1730 mov esi, DWORD PTR 32[esp]
1731 rol ecx, 10
1732 lea eax, DWORD PTR 2053994217[edi*1+eax]
1733 mov edi, -1
1734 rol eax, 12
1735 add eax, ebp
1736 ; 141
1737 add ebp, esi
1738 mov esi, ebx
1739 sub edi, eax
1740 and esi, eax
1741 and edi, ecx
1742 or esi, edi
1743 mov edi, DWORD PTR 44[esp]
1744 rol ebx, 10
1745 lea ebp, DWORD PTR 2053994217[esi*1+ebp]
1746 mov esi, -1
1747 rol ebp, 5
1748 add ebp, edx
1749 ; 142
1750 add edx, edi
1751 mov edi, eax
1752 sub esi, ebp
1753 and edi, ebp
1754 and esi, ebx
1755 or edi, esi
1756 mov esi, DWORD PTR 60[esp]
1757 rol eax, 10
1758 lea edx, DWORD PTR 2053994217[edi*1+edx]
1759 mov edi, -1
1760 rol edx, 15
1761 add edx, ecx
1762 ; 143
1763 add ecx, esi
1764 mov esi, ebp
1765 sub edi, edx
1766 and esi, edx
1767 and edi, eax
1768 or edi, esi
1769 mov esi, edx
1770 rol ebp, 10
1771 lea ecx, DWORD PTR 2053994217[edi*1+ecx]
1772 xor esi, ebp
1773 rol ecx, 8
1774 add ecx, ebx
1775 ; 144
1776 mov edi, DWORD PTR 52[esp]
1777 xor esi, ecx
1778 add ebx, edi
1779 rol edx, 10
1780 add ebx, esi
1781 mov esi, ecx
1782 rol ebx, 8
1783 add ebx, eax
1784 ; 145
1785 xor esi, edx
1786 mov edi, DWORD PTR 64[esp]
1787 xor esi, ebx
1788 add eax, esi
1789 mov esi, ebx
1790 rol ecx, 10
1791 add eax, edi
1792 xor esi, ecx
1793 rol eax, 5
1794 add eax, ebp
1795 ; 146
1796 mov edi, DWORD PTR 44[esp]
1797 xor esi, eax
1798 add ebp, edi
1799 rol ebx, 10
1800 add ebp, esi
1801 mov esi, eax
1802 rol ebp, 12
1803 add ebp, edx
1804 ; 147
1805 xor esi, ebx
1806 mov edi, DWORD PTR 20[esp]
1807 xor esi, ebp
1808 add edx, esi
1809 mov esi, ebp
1810 rol eax, 10
1811 add edx, edi
1812 xor esi, eax
1813 rol edx, 9
1814 add edx, ecx
1815 ; 148
1816 mov edi, DWORD PTR 8[esp]
1817 xor esi, edx
1818 add ecx, edi
1819 rol ebp, 10
1820 add ecx, esi
1821 mov esi, edx
1822 rol ecx, 12
1823 add ecx, ebx
1824 ; 149
1825 xor esi, ebp
1826 mov edi, DWORD PTR 24[esp]
1827 xor esi, ecx
1828 add ebx, esi
1829 mov esi, ecx
1830 rol edx, 10
1831 add ebx, edi
1832 xor esi, edx
1833 rol ebx, 5
1834 add ebx, eax
1835 ; 150
1836 mov edi, DWORD PTR 36[esp]
1837 xor esi, ebx
1838 add eax, edi
1839 rol ecx, 10
1840 add eax, esi
1841 mov esi, ebx
1842 rol eax, 14
1843 add eax, ebp
1844 ; 151
1845 xor esi, ecx
1846 mov edi, DWORD PTR 32[esp]
1847 xor esi, eax
1848 add ebp, esi
1849 mov esi, eax
1850 rol ebx, 10
1851 add ebp, edi
1852 xor esi, ebx
1853 rol ebp, 6
1854 add ebp, edx
1855 ; 152
1856 mov edi, DWORD PTR 28[esp]
1857 xor esi, ebp
1858 add edx, edi
1859 rol eax, 10
1860 add edx, esi
1861 mov esi, ebp
1862 rol edx, 8
1863 add edx, ecx
1864 ; 153
1865 xor esi, eax
1866 mov edi, DWORD PTR 12[esp]
1867 xor esi, edx
1868 add ecx, esi
1869 mov esi, edx
1870 rol ebp, 10
1871 add ecx, edi
1872 xor esi, ebp
1873 rol ecx, 13
1874 add ecx, ebx
1875 ; 154
1876 mov edi, DWORD PTR 56[esp]
1877 xor esi, ecx
1878 add ebx, edi
1879 rol edx, 10
1880 add ebx, esi
1881 mov esi, ecx
1882 rol ebx, 6
1883 add ebx, eax
1884 ; 155
1885 xor esi, edx
1886 mov edi, DWORD PTR 60[esp]
1887 xor esi, ebx
1888 add eax, esi
1889 mov esi, ebx
1890 rol ecx, 10
1891 add eax, edi
1892 xor esi, ecx
1893 rol eax, 5
1894 add eax, ebp
1895 ; 156
1896 mov edi, DWORD PTR 4[esp]
1897 xor esi, eax
1898 add ebp, edi
1899 rol ebx, 10
1900 add ebp, esi
1901 mov esi, eax
1902 rol ebp, 15
1903 add ebp, edx
1904 ; 157
1905 xor esi, ebx
1906 mov edi, DWORD PTR 16[esp]
1907 xor esi, ebp
1908 add edx, esi
1909 mov esi, ebp
1910 rol eax, 10
1911 add edx, edi
1912 xor esi, eax
1913 rol edx, 13
1914 add edx, ecx
1915 ; 158
1916 mov edi, DWORD PTR 40[esp]
1917 xor esi, edx
1918 add ecx, edi
1919 rol ebp, 10
1920 add ecx, esi
1921 mov esi, edx
1922 rol ecx, 11
1923 add ecx, ebx
1924 ; 159
1925 xor esi, ebp
1926 mov edi, DWORD PTR 48[esp]
1927 xor esi, ecx
1928 add ebx, esi
1929 rol edx, 10
1930 add ebx, edi
1931 mov edi, DWORD PTR 108[esp]
1932 rol ebx, 11
1933 add ebx, eax
1934 mov esi, DWORD PTR 4[edi]
1935 add edx, esi
1936 mov esi, DWORD PTR 76[esp]
1937 add edx, esi
1938 mov esi, DWORD PTR 8[edi]
1939 add ebp, esi
1940 mov esi, DWORD PTR 80[esp]
1941 add ebp, esi
1942 mov esi, DWORD PTR 12[edi]
1943 add eax, esi
1944 mov esi, DWORD PTR 84[esp]
1945 add eax, esi
1946 mov esi, DWORD PTR 16[edi]
1947 add ebx, esi
1948 mov esi, DWORD PTR 68[esp]
1949 add ebx, esi
1950 mov esi, DWORD PTR [edi]
1951 add ecx, esi
1952 mov esi, DWORD PTR 72[esp]
1953 add ecx, esi
1954 mov DWORD PTR [edi],edx
1955 mov DWORD PTR 4[edi],ebp
1956 mov DWORD PTR 8[edi],eax
1957 mov DWORD PTR 12[edi],ebx
1958 mov DWORD PTR 16[edi],ecx
1959 mov edi, DWORD PTR [esp]
1960 mov esi, DWORD PTR 112[esp]
1961 cmp edi, esi
1962 mov edi, DWORD PTR 108[esp]
1963 jge L000start
1964 add esp, 88
1965 pop ebx
1966 pop ebp
1967 pop edi
1968 pop esi
1969 ret
1970_ripemd160_block_x86 ENDP
1971_TEXT ENDS
1972END
diff --git a/src/lib/libssl/src/crypto/ripemd/asm/rm86unix.cpp b/src/lib/libssl/src/crypto/ripemd/asm/rm86unix.cpp
new file mode 100644
index 0000000000..f90f6f2fd6
--- /dev/null
+++ b/src/lib/libssl/src/crypto/ripemd/asm/rm86unix.cpp
@@ -0,0 +1,2016 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define ripemd160_block_x86 _ripemd160_block_x86
13
14#endif
15
16#ifdef OUT
17#define OK 1
18#define ALIGN 4
19#endif
20
21#ifdef BSDI
22#define OK 1
23#define ALIGN 4
24#undef SIZE
25#undef TYPE
26#define SIZE(a,b)
27#define TYPE(a,b)
28#endif
29
30#if defined(ELF) || defined(SOL)
31#define OK 1
32#define ALIGN 16
33#endif
34
35#ifndef OK
36You need to define one of
37ELF - elf systems - linux-elf, NetBSD and DG-UX
38OUT - a.out systems - linux-a.out and FreeBSD
39SOL - solaris systems, which are elf with strange comment lines
40BSDI - a.out with a very primative version of as.
41#endif
42
43/* Let the Assembler begin :-) */
44 /* Don't even think of reading this code */
45 /* It was automatically generated by rmd-586.pl */
46 /* Which is a perl program used to generate the x86 assember for */
47 /* any of elf, a.out, BSDI,Win32, or Solaris */
48 /* eric <eay@cryptsoft.com> */
49
50 .file "rmd-586.s"
51 .version "01.01"
52gcc2_compiled.:
53.text
54 .align ALIGN
55.globl ripemd160_block_x86
56 TYPE(ripemd160_block_x86,@function)
57ripemd160_block_x86:
58 pushl %esi
59 movl 16(%esp), %ecx
60 pushl %edi
61 movl 16(%esp), %esi
62 pushl %ebp
63 addl %esi, %ecx
64 pushl %ebx
65 subl $64, %ecx
66 subl $88, %esp
67 movl %ecx, (%esp)
68 movl 108(%esp), %edi
69.L000start:
70
71 movl (%esi), %eax
72 movl 4(%esi), %ebx
73 movl %eax, 4(%esp)
74 movl %ebx, 8(%esp)
75 movl 8(%esi), %eax
76 movl 12(%esi), %ebx
77 movl %eax, 12(%esp)
78 movl %ebx, 16(%esp)
79 movl 16(%esi), %eax
80 movl 20(%esi), %ebx
81 movl %eax, 20(%esp)
82 movl %ebx, 24(%esp)
83 movl 24(%esi), %eax
84 movl 28(%esi), %ebx
85 movl %eax, 28(%esp)
86 movl %ebx, 32(%esp)
87 movl 32(%esi), %eax
88 movl 36(%esi), %ebx
89 movl %eax, 36(%esp)
90 movl %ebx, 40(%esp)
91 movl 40(%esi), %eax
92 movl 44(%esi), %ebx
93 movl %eax, 44(%esp)
94 movl %ebx, 48(%esp)
95 movl 48(%esi), %eax
96 movl 52(%esi), %ebx
97 movl %eax, 52(%esp)
98 movl %ebx, 56(%esp)
99 movl 56(%esi), %eax
100 movl 60(%esi), %ebx
101 movl %eax, 60(%esp)
102 movl %ebx, 64(%esp)
103 addl $64, %esi
104 movl (%edi), %eax
105 movl %esi, 112(%esp)
106 movl 4(%edi), %ebx
107 movl 8(%edi), %ecx
108 movl 12(%edi), %edx
109 movl 16(%edi), %ebp
110 /* 0 */
111 movl %ecx, %esi
112 xorl %edx, %esi
113 movl 4(%esp), %edi
114 xorl %ebx, %esi
115 addl %edi, %eax
116 roll $10, %ecx
117 addl %esi, %eax
118 movl %ebx, %esi
119 roll $11, %eax
120 addl %ebp, %eax
121 /* 1 */
122 xorl %ecx, %esi
123 movl 8(%esp), %edi
124 xorl %eax, %esi
125 addl %esi, %ebp
126 movl %eax, %esi
127 roll $10, %ebx
128 addl %edi, %ebp
129 xorl %ebx, %esi
130 roll $14, %ebp
131 addl %edx, %ebp
132 /* 2 */
133 movl 12(%esp), %edi
134 xorl %ebp, %esi
135 addl %edi, %edx
136 roll $10, %eax
137 addl %esi, %edx
138 movl %ebp, %esi
139 roll $15, %edx
140 addl %ecx, %edx
141 /* 3 */
142 xorl %eax, %esi
143 movl 16(%esp), %edi
144 xorl %edx, %esi
145 addl %esi, %ecx
146 movl %edx, %esi
147 roll $10, %ebp
148 addl %edi, %ecx
149 xorl %ebp, %esi
150 roll $12, %ecx
151 addl %ebx, %ecx
152 /* 4 */
153 movl 20(%esp), %edi
154 xorl %ecx, %esi
155 addl %edi, %ebx
156 roll $10, %edx
157 addl %esi, %ebx
158 movl %ecx, %esi
159 roll $5, %ebx
160 addl %eax, %ebx
161 /* 5 */
162 xorl %edx, %esi
163 movl 24(%esp), %edi
164 xorl %ebx, %esi
165 addl %esi, %eax
166 movl %ebx, %esi
167 roll $10, %ecx
168 addl %edi, %eax
169 xorl %ecx, %esi
170 roll $8, %eax
171 addl %ebp, %eax
172 /* 6 */
173 movl 28(%esp), %edi
174 xorl %eax, %esi
175 addl %edi, %ebp
176 roll $10, %ebx
177 addl %esi, %ebp
178 movl %eax, %esi
179 roll $7, %ebp
180 addl %edx, %ebp
181 /* 7 */
182 xorl %ebx, %esi
183 movl 32(%esp), %edi
184 xorl %ebp, %esi
185 addl %esi, %edx
186 movl %ebp, %esi
187 roll $10, %eax
188 addl %edi, %edx
189 xorl %eax, %esi
190 roll $9, %edx
191 addl %ecx, %edx
192 /* 8 */
193 movl 36(%esp), %edi
194 xorl %edx, %esi
195 addl %edi, %ecx
196 roll $10, %ebp
197 addl %esi, %ecx
198 movl %edx, %esi
199 roll $11, %ecx
200 addl %ebx, %ecx
201 /* 9 */
202 xorl %ebp, %esi
203 movl 40(%esp), %edi
204 xorl %ecx, %esi
205 addl %esi, %ebx
206 movl %ecx, %esi
207 roll $10, %edx
208 addl %edi, %ebx
209 xorl %edx, %esi
210 roll $13, %ebx
211 addl %eax, %ebx
212 /* 10 */
213 movl 44(%esp), %edi
214 xorl %ebx, %esi
215 addl %edi, %eax
216 roll $10, %ecx
217 addl %esi, %eax
218 movl %ebx, %esi
219 roll $14, %eax
220 addl %ebp, %eax
221 /* 11 */
222 xorl %ecx, %esi
223 movl 48(%esp), %edi
224 xorl %eax, %esi
225 addl %esi, %ebp
226 movl %eax, %esi
227 roll $10, %ebx
228 addl %edi, %ebp
229 xorl %ebx, %esi
230 roll $15, %ebp
231 addl %edx, %ebp
232 /* 12 */
233 movl 52(%esp), %edi
234 xorl %ebp, %esi
235 addl %edi, %edx
236 roll $10, %eax
237 addl %esi, %edx
238 movl %ebp, %esi
239 roll $6, %edx
240 addl %ecx, %edx
241 /* 13 */
242 xorl %eax, %esi
243 movl 56(%esp), %edi
244 xorl %edx, %esi
245 addl %esi, %ecx
246 movl %edx, %esi
247 roll $10, %ebp
248 addl %edi, %ecx
249 xorl %ebp, %esi
250 roll $7, %ecx
251 addl %ebx, %ecx
252 /* 14 */
253 movl 60(%esp), %edi
254 xorl %ecx, %esi
255 addl %edi, %ebx
256 roll $10, %edx
257 addl %esi, %ebx
258 movl %ecx, %esi
259 roll $9, %ebx
260 addl %eax, %ebx
261 /* 15 */
262 xorl %edx, %esi
263 movl 64(%esp), %edi
264 xorl %ebx, %esi
265 addl %esi, %eax
266 movl $-1, %esi
267 roll $10, %ecx
268 addl %edi, %eax
269 movl 32(%esp), %edi
270 roll $8, %eax
271 addl %ebp, %eax
272 /* 16 */
273 addl %edi, %ebp
274 movl %ebx, %edi
275 subl %eax, %esi
276 andl %eax, %edi
277 andl %ecx, %esi
278 orl %esi, %edi
279 movl 20(%esp), %esi
280 roll $10, %ebx
281 leal 1518500249(%ebp,%edi,1),%ebp
282 movl $-1, %edi
283 roll $7, %ebp
284 addl %edx, %ebp
285 /* 17 */
286 addl %esi, %edx
287 movl %eax, %esi
288 subl %ebp, %edi
289 andl %ebp, %esi
290 andl %ebx, %edi
291 orl %edi, %esi
292 movl 56(%esp), %edi
293 roll $10, %eax
294 leal 1518500249(%edx,%esi,1),%edx
295 movl $-1, %esi
296 roll $6, %edx
297 addl %ecx, %edx
298 /* 18 */
299 addl %edi, %ecx
300 movl %ebp, %edi
301 subl %edx, %esi
302 andl %edx, %edi
303 andl %eax, %esi
304 orl %esi, %edi
305 movl 8(%esp), %esi
306 roll $10, %ebp
307 leal 1518500249(%ecx,%edi,1),%ecx
308 movl $-1, %edi
309 roll $8, %ecx
310 addl %ebx, %ecx
311 /* 19 */
312 addl %esi, %ebx
313 movl %edx, %esi
314 subl %ecx, %edi
315 andl %ecx, %esi
316 andl %ebp, %edi
317 orl %edi, %esi
318 movl 44(%esp), %edi
319 roll $10, %edx
320 leal 1518500249(%ebx,%esi,1),%ebx
321 movl $-1, %esi
322 roll $13, %ebx
323 addl %eax, %ebx
324 /* 20 */
325 addl %edi, %eax
326 movl %ecx, %edi
327 subl %ebx, %esi
328 andl %ebx, %edi
329 andl %edx, %esi
330 orl %esi, %edi
331 movl 28(%esp), %esi
332 roll $10, %ecx
333 leal 1518500249(%eax,%edi,1),%eax
334 movl $-1, %edi
335 roll $11, %eax
336 addl %ebp, %eax
337 /* 21 */
338 addl %esi, %ebp
339 movl %ebx, %esi
340 subl %eax, %edi
341 andl %eax, %esi
342 andl %ecx, %edi
343 orl %edi, %esi
344 movl 64(%esp), %edi
345 roll $10, %ebx
346 leal 1518500249(%ebp,%esi,1),%ebp
347 movl $-1, %esi
348 roll $9, %ebp
349 addl %edx, %ebp
350 /* 22 */
351 addl %edi, %edx
352 movl %eax, %edi
353 subl %ebp, %esi
354 andl %ebp, %edi
355 andl %ebx, %esi
356 orl %esi, %edi
357 movl 16(%esp), %esi
358 roll $10, %eax
359 leal 1518500249(%edx,%edi,1),%edx
360 movl $-1, %edi
361 roll $7, %edx
362 addl %ecx, %edx
363 /* 23 */
364 addl %esi, %ecx
365 movl %ebp, %esi
366 subl %edx, %edi
367 andl %edx, %esi
368 andl %eax, %edi
369 orl %edi, %esi
370 movl 52(%esp), %edi
371 roll $10, %ebp
372 leal 1518500249(%ecx,%esi,1),%ecx
373 movl $-1, %esi
374 roll $15, %ecx
375 addl %ebx, %ecx
376 /* 24 */
377 addl %edi, %ebx
378 movl %edx, %edi
379 subl %ecx, %esi
380 andl %ecx, %edi
381 andl %ebp, %esi
382 orl %esi, %edi
383 movl 4(%esp), %esi
384 roll $10, %edx
385 leal 1518500249(%ebx,%edi,1),%ebx
386 movl $-1, %edi
387 roll $7, %ebx
388 addl %eax, %ebx
389 /* 25 */
390 addl %esi, %eax
391 movl %ecx, %esi
392 subl %ebx, %edi
393 andl %ebx, %esi
394 andl %edx, %edi
395 orl %edi, %esi
396 movl 40(%esp), %edi
397 roll $10, %ecx
398 leal 1518500249(%eax,%esi,1),%eax
399 movl $-1, %esi
400 roll $12, %eax
401 addl %ebp, %eax
402 /* 26 */
403 addl %edi, %ebp
404 movl %ebx, %edi
405 subl %eax, %esi
406 andl %eax, %edi
407 andl %ecx, %esi
408 orl %esi, %edi
409 movl 24(%esp), %esi
410 roll $10, %ebx
411 leal 1518500249(%ebp,%edi,1),%ebp
412 movl $-1, %edi
413 roll $15, %ebp
414 addl %edx, %ebp
415 /* 27 */
416 addl %esi, %edx
417 movl %eax, %esi
418 subl %ebp, %edi
419 andl %ebp, %esi
420 andl %ebx, %edi
421 orl %edi, %esi
422 movl 12(%esp), %edi
423 roll $10, %eax
424 leal 1518500249(%edx,%esi,1),%edx
425 movl $-1, %esi
426 roll $9, %edx
427 addl %ecx, %edx
428 /* 28 */
429 addl %edi, %ecx
430 movl %ebp, %edi
431 subl %edx, %esi
432 andl %edx, %edi
433 andl %eax, %esi
434 orl %esi, %edi
435 movl 60(%esp), %esi
436 roll $10, %ebp
437 leal 1518500249(%ecx,%edi,1),%ecx
438 movl $-1, %edi
439 roll $11, %ecx
440 addl %ebx, %ecx
441 /* 29 */
442 addl %esi, %ebx
443 movl %edx, %esi
444 subl %ecx, %edi
445 andl %ecx, %esi
446 andl %ebp, %edi
447 orl %edi, %esi
448 movl 48(%esp), %edi
449 roll $10, %edx
450 leal 1518500249(%ebx,%esi,1),%ebx
451 movl $-1, %esi
452 roll $7, %ebx
453 addl %eax, %ebx
454 /* 30 */
455 addl %edi, %eax
456 movl %ecx, %edi
457 subl %ebx, %esi
458 andl %ebx, %edi
459 andl %edx, %esi
460 orl %esi, %edi
461 movl 36(%esp), %esi
462 roll $10, %ecx
463 leal 1518500249(%eax,%edi,1),%eax
464 movl $-1, %edi
465 roll $13, %eax
466 addl %ebp, %eax
467 /* 31 */
468 addl %esi, %ebp
469 movl %ebx, %esi
470 subl %eax, %edi
471 andl %eax, %esi
472 andl %ecx, %edi
473 orl %edi, %esi
474 movl $-1, %edi
475 roll $10, %ebx
476 leal 1518500249(%ebp,%esi,1),%ebp
477 subl %eax, %edi
478 roll $12, %ebp
479 addl %edx, %ebp
480 /* 32 */
481 movl 16(%esp), %esi
482 orl %ebp, %edi
483 addl %esi, %edx
484 xorl %ebx, %edi
485 movl $-1, %esi
486 roll $10, %eax
487 leal 1859775393(%edx,%edi,1),%edx
488 subl %ebp, %esi
489 roll $11, %edx
490 addl %ecx, %edx
491 /* 33 */
492 movl 44(%esp), %edi
493 orl %edx, %esi
494 addl %edi, %ecx
495 xorl %eax, %esi
496 movl $-1, %edi
497 roll $10, %ebp
498 leal 1859775393(%ecx,%esi,1),%ecx
499 subl %edx, %edi
500 roll $13, %ecx
501 addl %ebx, %ecx
502 /* 34 */
503 movl 60(%esp), %esi
504 orl %ecx, %edi
505 addl %esi, %ebx
506 xorl %ebp, %edi
507 movl $-1, %esi
508 roll $10, %edx
509 leal 1859775393(%ebx,%edi,1),%ebx
510 subl %ecx, %esi
511 roll $6, %ebx
512 addl %eax, %ebx
513 /* 35 */
514 movl 20(%esp), %edi
515 orl %ebx, %esi
516 addl %edi, %eax
517 xorl %edx, %esi
518 movl $-1, %edi
519 roll $10, %ecx
520 leal 1859775393(%eax,%esi,1),%eax
521 subl %ebx, %edi
522 roll $7, %eax
523 addl %ebp, %eax
524 /* 36 */
525 movl 40(%esp), %esi
526 orl %eax, %edi
527 addl %esi, %ebp
528 xorl %ecx, %edi
529 movl $-1, %esi
530 roll $10, %ebx
531 leal 1859775393(%ebp,%edi,1),%ebp
532 subl %eax, %esi
533 roll $14, %ebp
534 addl %edx, %ebp
535 /* 37 */
536 movl 64(%esp), %edi
537 orl %ebp, %esi
538 addl %edi, %edx
539 xorl %ebx, %esi
540 movl $-1, %edi
541 roll $10, %eax
542 leal 1859775393(%edx,%esi,1),%edx
543 subl %ebp, %edi
544 roll $9, %edx
545 addl %ecx, %edx
546 /* 38 */
547 movl 36(%esp), %esi
548 orl %edx, %edi
549 addl %esi, %ecx
550 xorl %eax, %edi
551 movl $-1, %esi
552 roll $10, %ebp
553 leal 1859775393(%ecx,%edi,1),%ecx
554 subl %edx, %esi
555 roll $13, %ecx
556 addl %ebx, %ecx
557 /* 39 */
558 movl 8(%esp), %edi
559 orl %ecx, %esi
560 addl %edi, %ebx
561 xorl %ebp, %esi
562 movl $-1, %edi
563 roll $10, %edx
564 leal 1859775393(%ebx,%esi,1),%ebx
565 subl %ecx, %edi
566 roll $15, %ebx
567 addl %eax, %ebx
568 /* 40 */
569 movl 12(%esp), %esi
570 orl %ebx, %edi
571 addl %esi, %eax
572 xorl %edx, %edi
573 movl $-1, %esi
574 roll $10, %ecx
575 leal 1859775393(%eax,%edi,1),%eax
576 subl %ebx, %esi
577 roll $14, %eax
578 addl %ebp, %eax
579 /* 41 */
580 movl 32(%esp), %edi
581 orl %eax, %esi
582 addl %edi, %ebp
583 xorl %ecx, %esi
584 movl $-1, %edi
585 roll $10, %ebx
586 leal 1859775393(%ebp,%esi,1),%ebp
587 subl %eax, %edi
588 roll $8, %ebp
589 addl %edx, %ebp
590 /* 42 */
591 movl 4(%esp), %esi
592 orl %ebp, %edi
593 addl %esi, %edx
594 xorl %ebx, %edi
595 movl $-1, %esi
596 roll $10, %eax
597 leal 1859775393(%edx,%edi,1),%edx
598 subl %ebp, %esi
599 roll $13, %edx
600 addl %ecx, %edx
601 /* 43 */
602 movl 28(%esp), %edi
603 orl %edx, %esi
604 addl %edi, %ecx
605 xorl %eax, %esi
606 movl $-1, %edi
607 roll $10, %ebp
608 leal 1859775393(%ecx,%esi,1),%ecx
609 subl %edx, %edi
610 roll $6, %ecx
611 addl %ebx, %ecx
612 /* 44 */
613 movl 56(%esp), %esi
614 orl %ecx, %edi
615 addl %esi, %ebx
616 xorl %ebp, %edi
617 movl $-1, %esi
618 roll $10, %edx
619 leal 1859775393(%ebx,%edi,1),%ebx
620 subl %ecx, %esi
621 roll $5, %ebx
622 addl %eax, %ebx
623 /* 45 */
624 movl 48(%esp), %edi
625 orl %ebx, %esi
626 addl %edi, %eax
627 xorl %edx, %esi
628 movl $-1, %edi
629 roll $10, %ecx
630 leal 1859775393(%eax,%esi,1),%eax
631 subl %ebx, %edi
632 roll $12, %eax
633 addl %ebp, %eax
634 /* 46 */
635 movl 24(%esp), %esi
636 orl %eax, %edi
637 addl %esi, %ebp
638 xorl %ecx, %edi
639 movl $-1, %esi
640 roll $10, %ebx
641 leal 1859775393(%ebp,%edi,1),%ebp
642 subl %eax, %esi
643 roll $7, %ebp
644 addl %edx, %ebp
645 /* 47 */
646 movl 52(%esp), %edi
647 orl %ebp, %esi
648 addl %edi, %edx
649 xorl %ebx, %esi
650 movl $-1, %edi
651 roll $10, %eax
652 leal 1859775393(%edx,%esi,1),%edx
653 movl %eax, %esi
654 roll $5, %edx
655 addl %ecx, %edx
656 /* 48 */
657 subl %eax, %edi
658 andl %edx, %esi
659 andl %ebp, %edi
660 orl %esi, %edi
661 movl 8(%esp), %esi
662 roll $10, %ebp
663 leal 2400959708(%ecx,%edi,),%ecx
664 movl $-1, %edi
665 addl %esi, %ecx
666 movl %ebp, %esi
667 roll $11, %ecx
668 addl %ebx, %ecx
669 /* 49 */
670 subl %ebp, %edi
671 andl %ecx, %esi
672 andl %edx, %edi
673 orl %esi, %edi
674 movl 40(%esp), %esi
675 roll $10, %edx
676 leal 2400959708(%ebx,%edi,),%ebx
677 movl $-1, %edi
678 addl %esi, %ebx
679 movl %edx, %esi
680 roll $12, %ebx
681 addl %eax, %ebx
682 /* 50 */
683 subl %edx, %edi
684 andl %ebx, %esi
685 andl %ecx, %edi
686 orl %esi, %edi
687 movl 48(%esp), %esi
688 roll $10, %ecx
689 leal 2400959708(%eax,%edi,),%eax
690 movl $-1, %edi
691 addl %esi, %eax
692 movl %ecx, %esi
693 roll $14, %eax
694 addl %ebp, %eax
695 /* 51 */
696 subl %ecx, %edi
697 andl %eax, %esi
698 andl %ebx, %edi
699 orl %esi, %edi
700 movl 44(%esp), %esi
701 roll $10, %ebx
702 leal 2400959708(%ebp,%edi,),%ebp
703 movl $-1, %edi
704 addl %esi, %ebp
705 movl %ebx, %esi
706 roll $15, %ebp
707 addl %edx, %ebp
708 /* 52 */
709 subl %ebx, %edi
710 andl %ebp, %esi
711 andl %eax, %edi
712 orl %esi, %edi
713 movl 4(%esp), %esi
714 roll $10, %eax
715 leal 2400959708(%edx,%edi,),%edx
716 movl $-1, %edi
717 addl %esi, %edx
718 movl %eax, %esi
719 roll $14, %edx
720 addl %ecx, %edx
721 /* 53 */
722 subl %eax, %edi
723 andl %edx, %esi
724 andl %ebp, %edi
725 orl %esi, %edi
726 movl 36(%esp), %esi
727 roll $10, %ebp
728 leal 2400959708(%ecx,%edi,),%ecx
729 movl $-1, %edi
730 addl %esi, %ecx
731 movl %ebp, %esi
732 roll $15, %ecx
733 addl %ebx, %ecx
734 /* 54 */
735 subl %ebp, %edi
736 andl %ecx, %esi
737 andl %edx, %edi
738 orl %esi, %edi
739 movl 52(%esp), %esi
740 roll $10, %edx
741 leal 2400959708(%ebx,%edi,),%ebx
742 movl $-1, %edi
743 addl %esi, %ebx
744 movl %edx, %esi
745 roll $9, %ebx
746 addl %eax, %ebx
747 /* 55 */
748 subl %edx, %edi
749 andl %ebx, %esi
750 andl %ecx, %edi
751 orl %esi, %edi
752 movl 20(%esp), %esi
753 roll $10, %ecx
754 leal 2400959708(%eax,%edi,),%eax
755 movl $-1, %edi
756 addl %esi, %eax
757 movl %ecx, %esi
758 roll $8, %eax
759 addl %ebp, %eax
760 /* 56 */
761 subl %ecx, %edi
762 andl %eax, %esi
763 andl %ebx, %edi
764 orl %esi, %edi
765 movl 56(%esp), %esi
766 roll $10, %ebx
767 leal 2400959708(%ebp,%edi,),%ebp
768 movl $-1, %edi
769 addl %esi, %ebp
770 movl %ebx, %esi
771 roll $9, %ebp
772 addl %edx, %ebp
773 /* 57 */
774 subl %ebx, %edi
775 andl %ebp, %esi
776 andl %eax, %edi
777 orl %esi, %edi
778 movl 16(%esp), %esi
779 roll $10, %eax
780 leal 2400959708(%edx,%edi,),%edx
781 movl $-1, %edi
782 addl %esi, %edx
783 movl %eax, %esi
784 roll $14, %edx
785 addl %ecx, %edx
786 /* 58 */
787 subl %eax, %edi
788 andl %edx, %esi
789 andl %ebp, %edi
790 orl %esi, %edi
791 movl 32(%esp), %esi
792 roll $10, %ebp
793 leal 2400959708(%ecx,%edi,),%ecx
794 movl $-1, %edi
795 addl %esi, %ecx
796 movl %ebp, %esi
797 roll $5, %ecx
798 addl %ebx, %ecx
799 /* 59 */
800 subl %ebp, %edi
801 andl %ecx, %esi
802 andl %edx, %edi
803 orl %esi, %edi
804 movl 64(%esp), %esi
805 roll $10, %edx
806 leal 2400959708(%ebx,%edi,),%ebx
807 movl $-1, %edi
808 addl %esi, %ebx
809 movl %edx, %esi
810 roll $6, %ebx
811 addl %eax, %ebx
812 /* 60 */
813 subl %edx, %edi
814 andl %ebx, %esi
815 andl %ecx, %edi
816 orl %esi, %edi
817 movl 60(%esp), %esi
818 roll $10, %ecx
819 leal 2400959708(%eax,%edi,),%eax
820 movl $-1, %edi
821 addl %esi, %eax
822 movl %ecx, %esi
823 roll $8, %eax
824 addl %ebp, %eax
825 /* 61 */
826 subl %ecx, %edi
827 andl %eax, %esi
828 andl %ebx, %edi
829 orl %esi, %edi
830 movl 24(%esp), %esi
831 roll $10, %ebx
832 leal 2400959708(%ebp,%edi,),%ebp
833 movl $-1, %edi
834 addl %esi, %ebp
835 movl %ebx, %esi
836 roll $6, %ebp
837 addl %edx, %ebp
838 /* 62 */
839 subl %ebx, %edi
840 andl %ebp, %esi
841 andl %eax, %edi
842 orl %esi, %edi
843 movl 28(%esp), %esi
844 roll $10, %eax
845 leal 2400959708(%edx,%edi,),%edx
846 movl $-1, %edi
847 addl %esi, %edx
848 movl %eax, %esi
849 roll $5, %edx
850 addl %ecx, %edx
851 /* 63 */
852 subl %eax, %edi
853 andl %edx, %esi
854 andl %ebp, %edi
855 orl %esi, %edi
856 movl 12(%esp), %esi
857 roll $10, %ebp
858 leal 2400959708(%ecx,%edi,),%ecx
859 movl $-1, %edi
860 addl %esi, %ecx
861 subl %ebp, %edi
862 roll $12, %ecx
863 addl %ebx, %ecx
864 /* 64 */
865 movl 20(%esp), %esi
866 orl %edx, %edi
867 addl %esi, %ebx
868 xorl %ecx, %edi
869 movl $-1, %esi
870 roll $10, %edx
871 leal 2840853838(%ebx,%edi,1),%ebx
872 subl %edx, %esi
873 roll $9, %ebx
874 addl %eax, %ebx
875 /* 65 */
876 movl 4(%esp), %edi
877 orl %ecx, %esi
878 addl %edi, %eax
879 xorl %ebx, %esi
880 movl $-1, %edi
881 roll $10, %ecx
882 leal 2840853838(%eax,%esi,1),%eax
883 subl %ecx, %edi
884 roll $15, %eax
885 addl %ebp, %eax
886 /* 66 */
887 movl 24(%esp), %esi
888 orl %ebx, %edi
889 addl %esi, %ebp
890 xorl %eax, %edi
891 movl $-1, %esi
892 roll $10, %ebx
893 leal 2840853838(%ebp,%edi,1),%ebp
894 subl %ebx, %esi
895 roll $5, %ebp
896 addl %edx, %ebp
897 /* 67 */
898 movl 40(%esp), %edi
899 orl %eax, %esi
900 addl %edi, %edx
901 xorl %ebp, %esi
902 movl $-1, %edi
903 roll $10, %eax
904 leal 2840853838(%edx,%esi,1),%edx
905 subl %eax, %edi
906 roll $11, %edx
907 addl %ecx, %edx
908 /* 68 */
909 movl 32(%esp), %esi
910 orl %ebp, %edi
911 addl %esi, %ecx
912 xorl %edx, %edi
913 movl $-1, %esi
914 roll $10, %ebp
915 leal 2840853838(%ecx,%edi,1),%ecx
916 subl %ebp, %esi
917 roll $6, %ecx
918 addl %ebx, %ecx
919 /* 69 */
920 movl 52(%esp), %edi
921 orl %edx, %esi
922 addl %edi, %ebx
923 xorl %ecx, %esi
924 movl $-1, %edi
925 roll $10, %edx
926 leal 2840853838(%ebx,%esi,1),%ebx
927 subl %edx, %edi
928 roll $8, %ebx
929 addl %eax, %ebx
930 /* 70 */
931 movl 12(%esp), %esi
932 orl %ecx, %edi
933 addl %esi, %eax
934 xorl %ebx, %edi
935 movl $-1, %esi
936 roll $10, %ecx
937 leal 2840853838(%eax,%edi,1),%eax
938 subl %ecx, %esi
939 roll $13, %eax
940 addl %ebp, %eax
941 /* 71 */
942 movl 44(%esp), %edi
943 orl %ebx, %esi
944 addl %edi, %ebp
945 xorl %eax, %esi
946 movl $-1, %edi
947 roll $10, %ebx
948 leal 2840853838(%ebp,%esi,1),%ebp
949 subl %ebx, %edi
950 roll $12, %ebp
951 addl %edx, %ebp
952 /* 72 */
953 movl 60(%esp), %esi
954 orl %eax, %edi
955 addl %esi, %edx
956 xorl %ebp, %edi
957 movl $-1, %esi
958 roll $10, %eax
959 leal 2840853838(%edx,%edi,1),%edx
960 subl %eax, %esi
961 roll $5, %edx
962 addl %ecx, %edx
963 /* 73 */
964 movl 8(%esp), %edi
965 orl %ebp, %esi
966 addl %edi, %ecx
967 xorl %edx, %esi
968 movl $-1, %edi
969 roll $10, %ebp
970 leal 2840853838(%ecx,%esi,1),%ecx
971 subl %ebp, %edi
972 roll $12, %ecx
973 addl %ebx, %ecx
974 /* 74 */
975 movl 16(%esp), %esi
976 orl %edx, %edi
977 addl %esi, %ebx
978 xorl %ecx, %edi
979 movl $-1, %esi
980 roll $10, %edx
981 leal 2840853838(%ebx,%edi,1),%ebx
982 subl %edx, %esi
983 roll $13, %ebx
984 addl %eax, %ebx
985 /* 75 */
986 movl 36(%esp), %edi
987 orl %ecx, %esi
988 addl %edi, %eax
989 xorl %ebx, %esi
990 movl $-1, %edi
991 roll $10, %ecx
992 leal 2840853838(%eax,%esi,1),%eax
993 subl %ecx, %edi
994 roll $14, %eax
995 addl %ebp, %eax
996 /* 76 */
997 movl 48(%esp), %esi
998 orl %ebx, %edi
999 addl %esi, %ebp
1000 xorl %eax, %edi
1001 movl $-1, %esi
1002 roll $10, %ebx
1003 leal 2840853838(%ebp,%edi,1),%ebp
1004 subl %ebx, %esi
1005 roll $11, %ebp
1006 addl %edx, %ebp
1007 /* 77 */
1008 movl 28(%esp), %edi
1009 orl %eax, %esi
1010 addl %edi, %edx
1011 xorl %ebp, %esi
1012 movl $-1, %edi
1013 roll $10, %eax
1014 leal 2840853838(%edx,%esi,1),%edx
1015 subl %eax, %edi
1016 roll $8, %edx
1017 addl %ecx, %edx
1018 /* 78 */
1019 movl 64(%esp), %esi
1020 orl %ebp, %edi
1021 addl %esi, %ecx
1022 xorl %edx, %edi
1023 movl $-1, %esi
1024 roll $10, %ebp
1025 leal 2840853838(%ecx,%edi,1),%ecx
1026 subl %ebp, %esi
1027 roll $5, %ecx
1028 addl %ebx, %ecx
1029 /* 79 */
1030 movl 56(%esp), %edi
1031 orl %edx, %esi
1032 addl %edi, %ebx
1033 xorl %ecx, %esi
1034 movl 108(%esp), %edi
1035 roll $10, %edx
1036 leal 2840853838(%ebx,%esi,1),%ebx
1037 movl %eax, 68(%esp)
1038 roll $6, %ebx
1039 addl %eax, %ebx
1040 movl (%edi), %eax
1041 movl %ebx, 72(%esp)
1042 movl %ecx, 76(%esp)
1043 movl 4(%edi), %ebx
1044 movl %edx, 80(%esp)
1045 movl 8(%edi), %ecx
1046 movl %ebp, 84(%esp)
1047 movl 12(%edi), %edx
1048 movl 16(%edi), %ebp
1049 /* 80 */
1050 movl $-1, %edi
1051 subl %edx, %edi
1052 movl 24(%esp), %esi
1053 orl %ecx, %edi
1054 addl %esi, %eax
1055 xorl %ebx, %edi
1056 movl $-1, %esi
1057 roll $10, %ecx
1058 leal 1352829926(%eax,%edi,1),%eax
1059 subl %ecx, %esi
1060 roll $8, %eax
1061 addl %ebp, %eax
1062 /* 81 */
1063 movl 60(%esp), %edi
1064 orl %ebx, %esi
1065 addl %edi, %ebp
1066 xorl %eax, %esi
1067 movl $-1, %edi
1068 roll $10, %ebx
1069 leal 1352829926(%ebp,%esi,1),%ebp
1070 subl %ebx, %edi
1071 roll $9, %ebp
1072 addl %edx, %ebp
1073 /* 82 */
1074 movl 32(%esp), %esi
1075 orl %eax, %edi
1076 addl %esi, %edx
1077 xorl %ebp, %edi
1078 movl $-1, %esi
1079 roll $10, %eax
1080 leal 1352829926(%edx,%edi,1),%edx
1081 subl %eax, %esi
1082 roll $9, %edx
1083 addl %ecx, %edx
1084 /* 83 */
1085 movl 4(%esp), %edi
1086 orl %ebp, %esi
1087 addl %edi, %ecx
1088 xorl %edx, %esi
1089 movl $-1, %edi
1090 roll $10, %ebp
1091 leal 1352829926(%ecx,%esi,1),%ecx
1092 subl %ebp, %edi
1093 roll $11, %ecx
1094 addl %ebx, %ecx
1095 /* 84 */
1096 movl 40(%esp), %esi
1097 orl %edx, %edi
1098 addl %esi, %ebx
1099 xorl %ecx, %edi
1100 movl $-1, %esi
1101 roll $10, %edx
1102 leal 1352829926(%ebx,%edi,1),%ebx
1103 subl %edx, %esi
1104 roll $13, %ebx
1105 addl %eax, %ebx
1106 /* 85 */
1107 movl 12(%esp), %edi
1108 orl %ecx, %esi
1109 addl %edi, %eax
1110 xorl %ebx, %esi
1111 movl $-1, %edi
1112 roll $10, %ecx
1113 leal 1352829926(%eax,%esi,1),%eax
1114 subl %ecx, %edi
1115 roll $15, %eax
1116 addl %ebp, %eax
1117 /* 86 */
1118 movl 48(%esp), %esi
1119 orl %ebx, %edi
1120 addl %esi, %ebp
1121 xorl %eax, %edi
1122 movl $-1, %esi
1123 roll $10, %ebx
1124 leal 1352829926(%ebp,%edi,1),%ebp
1125 subl %ebx, %esi
1126 roll $15, %ebp
1127 addl %edx, %ebp
1128 /* 87 */
1129 movl 20(%esp), %edi
1130 orl %eax, %esi
1131 addl %edi, %edx
1132 xorl %ebp, %esi
1133 movl $-1, %edi
1134 roll $10, %eax
1135 leal 1352829926(%edx,%esi,1),%edx
1136 subl %eax, %edi
1137 roll $5, %edx
1138 addl %ecx, %edx
1139 /* 88 */
1140 movl 56(%esp), %esi
1141 orl %ebp, %edi
1142 addl %esi, %ecx
1143 xorl %edx, %edi
1144 movl $-1, %esi
1145 roll $10, %ebp
1146 leal 1352829926(%ecx,%edi,1),%ecx
1147 subl %ebp, %esi
1148 roll $7, %ecx
1149 addl %ebx, %ecx
1150 /* 89 */
1151 movl 28(%esp), %edi
1152 orl %edx, %esi
1153 addl %edi, %ebx
1154 xorl %ecx, %esi
1155 movl $-1, %edi
1156 roll $10, %edx
1157 leal 1352829926(%ebx,%esi,1),%ebx
1158 subl %edx, %edi
1159 roll $7, %ebx
1160 addl %eax, %ebx
1161 /* 90 */
1162 movl 64(%esp), %esi
1163 orl %ecx, %edi
1164 addl %esi, %eax
1165 xorl %ebx, %edi
1166 movl $-1, %esi
1167 roll $10, %ecx
1168 leal 1352829926(%eax,%edi,1),%eax
1169 subl %ecx, %esi
1170 roll $8, %eax
1171 addl %ebp, %eax
1172 /* 91 */
1173 movl 36(%esp), %edi
1174 orl %ebx, %esi
1175 addl %edi, %ebp
1176 xorl %eax, %esi
1177 movl $-1, %edi
1178 roll $10, %ebx
1179 leal 1352829926(%ebp,%esi,1),%ebp
1180 subl %ebx, %edi
1181 roll $11, %ebp
1182 addl %edx, %ebp
1183 /* 92 */
1184 movl 8(%esp), %esi
1185 orl %eax, %edi
1186 addl %esi, %edx
1187 xorl %ebp, %edi
1188 movl $-1, %esi
1189 roll $10, %eax
1190 leal 1352829926(%edx,%edi,1),%edx
1191 subl %eax, %esi
1192 roll $14, %edx
1193 addl %ecx, %edx
1194 /* 93 */
1195 movl 44(%esp), %edi
1196 orl %ebp, %esi
1197 addl %edi, %ecx
1198 xorl %edx, %esi
1199 movl $-1, %edi
1200 roll $10, %ebp
1201 leal 1352829926(%ecx,%esi,1),%ecx
1202 subl %ebp, %edi
1203 roll $14, %ecx
1204 addl %ebx, %ecx
1205 /* 94 */
1206 movl 16(%esp), %esi
1207 orl %edx, %edi
1208 addl %esi, %ebx
1209 xorl %ecx, %edi
1210 movl $-1, %esi
1211 roll $10, %edx
1212 leal 1352829926(%ebx,%edi,1),%ebx
1213 subl %edx, %esi
1214 roll $12, %ebx
1215 addl %eax, %ebx
1216 /* 95 */
1217 movl 52(%esp), %edi
1218 orl %ecx, %esi
1219 addl %edi, %eax
1220 xorl %ebx, %esi
1221 movl $-1, %edi
1222 roll $10, %ecx
1223 leal 1352829926(%eax,%esi,1),%eax
1224 movl %ecx, %esi
1225 roll $6, %eax
1226 addl %ebp, %eax
1227 /* 96 */
1228 subl %ecx, %edi
1229 andl %eax, %esi
1230 andl %ebx, %edi
1231 orl %esi, %edi
1232 movl 28(%esp), %esi
1233 roll $10, %ebx
1234 leal 1548603684(%ebp,%edi,),%ebp
1235 movl $-1, %edi
1236 addl %esi, %ebp
1237 movl %ebx, %esi
1238 roll $9, %ebp
1239 addl %edx, %ebp
1240 /* 97 */
1241 subl %ebx, %edi
1242 andl %ebp, %esi
1243 andl %eax, %edi
1244 orl %esi, %edi
1245 movl 48(%esp), %esi
1246 roll $10, %eax
1247 leal 1548603684(%edx,%edi,),%edx
1248 movl $-1, %edi
1249 addl %esi, %edx
1250 movl %eax, %esi
1251 roll $13, %edx
1252 addl %ecx, %edx
1253 /* 98 */
1254 subl %eax, %edi
1255 andl %edx, %esi
1256 andl %ebp, %edi
1257 orl %esi, %edi
1258 movl 16(%esp), %esi
1259 roll $10, %ebp
1260 leal 1548603684(%ecx,%edi,),%ecx
1261 movl $-1, %edi
1262 addl %esi, %ecx
1263 movl %ebp, %esi
1264 roll $15, %ecx
1265 addl %ebx, %ecx
1266 /* 99 */
1267 subl %ebp, %edi
1268 andl %ecx, %esi
1269 andl %edx, %edi
1270 orl %esi, %edi
1271 movl 32(%esp), %esi
1272 roll $10, %edx
1273 leal 1548603684(%ebx,%edi,),%ebx
1274 movl $-1, %edi
1275 addl %esi, %ebx
1276 movl %edx, %esi
1277 roll $7, %ebx
1278 addl %eax, %ebx
1279 /* 100 */
1280 subl %edx, %edi
1281 andl %ebx, %esi
1282 andl %ecx, %edi
1283 orl %esi, %edi
1284 movl 4(%esp), %esi
1285 roll $10, %ecx
1286 leal 1548603684(%eax,%edi,),%eax
1287 movl $-1, %edi
1288 addl %esi, %eax
1289 movl %ecx, %esi
1290 roll $12, %eax
1291 addl %ebp, %eax
1292 /* 101 */
1293 subl %ecx, %edi
1294 andl %eax, %esi
1295 andl %ebx, %edi
1296 orl %esi, %edi
1297 movl 56(%esp), %esi
1298 roll $10, %ebx
1299 leal 1548603684(%ebp,%edi,),%ebp
1300 movl $-1, %edi
1301 addl %esi, %ebp
1302 movl %ebx, %esi
1303 roll $8, %ebp
1304 addl %edx, %ebp
1305 /* 102 */
1306 subl %ebx, %edi
1307 andl %ebp, %esi
1308 andl %eax, %edi
1309 orl %esi, %edi
1310 movl 24(%esp), %esi
1311 roll $10, %eax
1312 leal 1548603684(%edx,%edi,),%edx
1313 movl $-1, %edi
1314 addl %esi, %edx
1315 movl %eax, %esi
1316 roll $9, %edx
1317 addl %ecx, %edx
1318 /* 103 */
1319 subl %eax, %edi
1320 andl %edx, %esi
1321 andl %ebp, %edi
1322 orl %esi, %edi
1323 movl 44(%esp), %esi
1324 roll $10, %ebp
1325 leal 1548603684(%ecx,%edi,),%ecx
1326 movl $-1, %edi
1327 addl %esi, %ecx
1328 movl %ebp, %esi
1329 roll $11, %ecx
1330 addl %ebx, %ecx
1331 /* 104 */
1332 subl %ebp, %edi
1333 andl %ecx, %esi
1334 andl %edx, %edi
1335 orl %esi, %edi
1336 movl 60(%esp), %esi
1337 roll $10, %edx
1338 leal 1548603684(%ebx,%edi,),%ebx
1339 movl $-1, %edi
1340 addl %esi, %ebx
1341 movl %edx, %esi
1342 roll $7, %ebx
1343 addl %eax, %ebx
1344 /* 105 */
1345 subl %edx, %edi
1346 andl %ebx, %esi
1347 andl %ecx, %edi
1348 orl %esi, %edi
1349 movl 64(%esp), %esi
1350 roll $10, %ecx
1351 leal 1548603684(%eax,%edi,),%eax
1352 movl $-1, %edi
1353 addl %esi, %eax
1354 movl %ecx, %esi
1355 roll $7, %eax
1356 addl %ebp, %eax
1357 /* 106 */
1358 subl %ecx, %edi
1359 andl %eax, %esi
1360 andl %ebx, %edi
1361 orl %esi, %edi
1362 movl 36(%esp), %esi
1363 roll $10, %ebx
1364 leal 1548603684(%ebp,%edi,),%ebp
1365 movl $-1, %edi
1366 addl %esi, %ebp
1367 movl %ebx, %esi
1368 roll $12, %ebp
1369 addl %edx, %ebp
1370 /* 107 */
1371 subl %ebx, %edi
1372 andl %ebp, %esi
1373 andl %eax, %edi
1374 orl %esi, %edi
1375 movl 52(%esp), %esi
1376 roll $10, %eax
1377 leal 1548603684(%edx,%edi,),%edx
1378 movl $-1, %edi
1379 addl %esi, %edx
1380 movl %eax, %esi
1381 roll $7, %edx
1382 addl %ecx, %edx
1383 /* 108 */
1384 subl %eax, %edi
1385 andl %edx, %esi
1386 andl %ebp, %edi
1387 orl %esi, %edi
1388 movl 20(%esp), %esi
1389 roll $10, %ebp
1390 leal 1548603684(%ecx,%edi,),%ecx
1391 movl $-1, %edi
1392 addl %esi, %ecx
1393 movl %ebp, %esi
1394 roll $6, %ecx
1395 addl %ebx, %ecx
1396 /* 109 */
1397 subl %ebp, %edi
1398 andl %ecx, %esi
1399 andl %edx, %edi
1400 orl %esi, %edi
1401 movl 40(%esp), %esi
1402 roll $10, %edx
1403 leal 1548603684(%ebx,%edi,),%ebx
1404 movl $-1, %edi
1405 addl %esi, %ebx
1406 movl %edx, %esi
1407 roll $15, %ebx
1408 addl %eax, %ebx
1409 /* 110 */
1410 subl %edx, %edi
1411 andl %ebx, %esi
1412 andl %ecx, %edi
1413 orl %esi, %edi
1414 movl 8(%esp), %esi
1415 roll $10, %ecx
1416 leal 1548603684(%eax,%edi,),%eax
1417 movl $-1, %edi
1418 addl %esi, %eax
1419 movl %ecx, %esi
1420 roll $13, %eax
1421 addl %ebp, %eax
1422 /* 111 */
1423 subl %ecx, %edi
1424 andl %eax, %esi
1425 andl %ebx, %edi
1426 orl %esi, %edi
1427 movl 12(%esp), %esi
1428 roll $10, %ebx
1429 leal 1548603684(%ebp,%edi,),%ebp
1430 movl $-1, %edi
1431 addl %esi, %ebp
1432 subl %eax, %edi
1433 roll $11, %ebp
1434 addl %edx, %ebp
1435 /* 112 */
1436 movl 64(%esp), %esi
1437 orl %ebp, %edi
1438 addl %esi, %edx
1439 xorl %ebx, %edi
1440 movl $-1, %esi
1441 roll $10, %eax
1442 leal 1836072691(%edx,%edi,1),%edx
1443 subl %ebp, %esi
1444 roll $9, %edx
1445 addl %ecx, %edx
1446 /* 113 */
1447 movl 24(%esp), %edi
1448 orl %edx, %esi
1449 addl %edi, %ecx
1450 xorl %eax, %esi
1451 movl $-1, %edi
1452 roll $10, %ebp
1453 leal 1836072691(%ecx,%esi,1),%ecx
1454 subl %edx, %edi
1455 roll $7, %ecx
1456 addl %ebx, %ecx
1457 /* 114 */
1458 movl 8(%esp), %esi
1459 orl %ecx, %edi
1460 addl %esi, %ebx
1461 xorl %ebp, %edi
1462 movl $-1, %esi
1463 roll $10, %edx
1464 leal 1836072691(%ebx,%edi,1),%ebx
1465 subl %ecx, %esi
1466 roll $15, %ebx
1467 addl %eax, %ebx
1468 /* 115 */
1469 movl 16(%esp), %edi
1470 orl %ebx, %esi
1471 addl %edi, %eax
1472 xorl %edx, %esi
1473 movl $-1, %edi
1474 roll $10, %ecx
1475 leal 1836072691(%eax,%esi,1),%eax
1476 subl %ebx, %edi
1477 roll $11, %eax
1478 addl %ebp, %eax
1479 /* 116 */
1480 movl 32(%esp), %esi
1481 orl %eax, %edi
1482 addl %esi, %ebp
1483 xorl %ecx, %edi
1484 movl $-1, %esi
1485 roll $10, %ebx
1486 leal 1836072691(%ebp,%edi,1),%ebp
1487 subl %eax, %esi
1488 roll $8, %ebp
1489 addl %edx, %ebp
1490 /* 117 */
1491 movl 60(%esp), %edi
1492 orl %ebp, %esi
1493 addl %edi, %edx
1494 xorl %ebx, %esi
1495 movl $-1, %edi
1496 roll $10, %eax
1497 leal 1836072691(%edx,%esi,1),%edx
1498 subl %ebp, %edi
1499 roll $6, %edx
1500 addl %ecx, %edx
1501 /* 118 */
1502 movl 28(%esp), %esi
1503 orl %edx, %edi
1504 addl %esi, %ecx
1505 xorl %eax, %edi
1506 movl $-1, %esi
1507 roll $10, %ebp
1508 leal 1836072691(%ecx,%edi,1),%ecx
1509 subl %edx, %esi
1510 roll $6, %ecx
1511 addl %ebx, %ecx
1512 /* 119 */
1513 movl 40(%esp), %edi
1514 orl %ecx, %esi
1515 addl %edi, %ebx
1516 xorl %ebp, %esi
1517 movl $-1, %edi
1518 roll $10, %edx
1519 leal 1836072691(%ebx,%esi,1),%ebx
1520 subl %ecx, %edi
1521 roll $14, %ebx
1522 addl %eax, %ebx
1523 /* 120 */
1524 movl 48(%esp), %esi
1525 orl %ebx, %edi
1526 addl %esi, %eax
1527 xorl %edx, %edi
1528 movl $-1, %esi
1529 roll $10, %ecx
1530 leal 1836072691(%eax,%edi,1),%eax
1531 subl %ebx, %esi
1532 roll $12, %eax
1533 addl %ebp, %eax
1534 /* 121 */
1535 movl 36(%esp), %edi
1536 orl %eax, %esi
1537 addl %edi, %ebp
1538 xorl %ecx, %esi
1539 movl $-1, %edi
1540 roll $10, %ebx
1541 leal 1836072691(%ebp,%esi,1),%ebp
1542 subl %eax, %edi
1543 roll $13, %ebp
1544 addl %edx, %ebp
1545 /* 122 */
1546 movl 52(%esp), %esi
1547 orl %ebp, %edi
1548 addl %esi, %edx
1549 xorl %ebx, %edi
1550 movl $-1, %esi
1551 roll $10, %eax
1552 leal 1836072691(%edx,%edi,1),%edx
1553 subl %ebp, %esi
1554 roll $5, %edx
1555 addl %ecx, %edx
1556 /* 123 */
1557 movl 12(%esp), %edi
1558 orl %edx, %esi
1559 addl %edi, %ecx
1560 xorl %eax, %esi
1561 movl $-1, %edi
1562 roll $10, %ebp
1563 leal 1836072691(%ecx,%esi,1),%ecx
1564 subl %edx, %edi
1565 roll $14, %ecx
1566 addl %ebx, %ecx
1567 /* 124 */
1568 movl 44(%esp), %esi
1569 orl %ecx, %edi
1570 addl %esi, %ebx
1571 xorl %ebp, %edi
1572 movl $-1, %esi
1573 roll $10, %edx
1574 leal 1836072691(%ebx,%edi,1),%ebx
1575 subl %ecx, %esi
1576 roll $13, %ebx
1577 addl %eax, %ebx
1578 /* 125 */
1579 movl 4(%esp), %edi
1580 orl %ebx, %esi
1581 addl %edi, %eax
1582 xorl %edx, %esi
1583 movl $-1, %edi
1584 roll $10, %ecx
1585 leal 1836072691(%eax,%esi,1),%eax
1586 subl %ebx, %edi
1587 roll $13, %eax
1588 addl %ebp, %eax
1589 /* 126 */
1590 movl 20(%esp), %esi
1591 orl %eax, %edi
1592 addl %esi, %ebp
1593 xorl %ecx, %edi
1594 movl $-1, %esi
1595 roll $10, %ebx
1596 leal 1836072691(%ebp,%edi,1),%ebp
1597 subl %eax, %esi
1598 roll $7, %ebp
1599 addl %edx, %ebp
1600 /* 127 */
1601 movl 56(%esp), %edi
1602 orl %ebp, %esi
1603 addl %edi, %edx
1604 xorl %ebx, %esi
1605 movl 36(%esp), %edi
1606 roll $10, %eax
1607 leal 1836072691(%edx,%esi,1),%edx
1608 movl $-1, %esi
1609 roll $5, %edx
1610 addl %ecx, %edx
1611 /* 128 */
1612 addl %edi, %ecx
1613 movl %ebp, %edi
1614 subl %edx, %esi
1615 andl %edx, %edi
1616 andl %eax, %esi
1617 orl %esi, %edi
1618 movl 28(%esp), %esi
1619 roll $10, %ebp
1620 leal 2053994217(%ecx,%edi,1),%ecx
1621 movl $-1, %edi
1622 roll $15, %ecx
1623 addl %ebx, %ecx
1624 /* 129 */
1625 addl %esi, %ebx
1626 movl %edx, %esi
1627 subl %ecx, %edi
1628 andl %ecx, %esi
1629 andl %ebp, %edi
1630 orl %edi, %esi
1631 movl 20(%esp), %edi
1632 roll $10, %edx
1633 leal 2053994217(%ebx,%esi,1),%ebx
1634 movl $-1, %esi
1635 roll $5, %ebx
1636 addl %eax, %ebx
1637 /* 130 */
1638 addl %edi, %eax
1639 movl %ecx, %edi
1640 subl %ebx, %esi
1641 andl %ebx, %edi
1642 andl %edx, %esi
1643 orl %esi, %edi
1644 movl 8(%esp), %esi
1645 roll $10, %ecx
1646 leal 2053994217(%eax,%edi,1),%eax
1647 movl $-1, %edi
1648 roll $8, %eax
1649 addl %ebp, %eax
1650 /* 131 */
1651 addl %esi, %ebp
1652 movl %ebx, %esi
1653 subl %eax, %edi
1654 andl %eax, %esi
1655 andl %ecx, %edi
1656 orl %edi, %esi
1657 movl 16(%esp), %edi
1658 roll $10, %ebx
1659 leal 2053994217(%ebp,%esi,1),%ebp
1660 movl $-1, %esi
1661 roll $11, %ebp
1662 addl %edx, %ebp
1663 /* 132 */
1664 addl %edi, %edx
1665 movl %eax, %edi
1666 subl %ebp, %esi
1667 andl %ebp, %edi
1668 andl %ebx, %esi
1669 orl %esi, %edi
1670 movl 48(%esp), %esi
1671 roll $10, %eax
1672 leal 2053994217(%edx,%edi,1),%edx
1673 movl $-1, %edi
1674 roll $14, %edx
1675 addl %ecx, %edx
1676 /* 133 */
1677 addl %esi, %ecx
1678 movl %ebp, %esi
1679 subl %edx, %edi
1680 andl %edx, %esi
1681 andl %eax, %edi
1682 orl %edi, %esi
1683 movl 64(%esp), %edi
1684 roll $10, %ebp
1685 leal 2053994217(%ecx,%esi,1),%ecx
1686 movl $-1, %esi
1687 roll $14, %ecx
1688 addl %ebx, %ecx
1689 /* 134 */
1690 addl %edi, %ebx
1691 movl %edx, %edi
1692 subl %ecx, %esi
1693 andl %ecx, %edi
1694 andl %ebp, %esi
1695 orl %esi, %edi
1696 movl 4(%esp), %esi
1697 roll $10, %edx
1698 leal 2053994217(%ebx,%edi,1),%ebx
1699 movl $-1, %edi
1700 roll $6, %ebx
1701 addl %eax, %ebx
1702 /* 135 */
1703 addl %esi, %eax
1704 movl %ecx, %esi
1705 subl %ebx, %edi
1706 andl %ebx, %esi
1707 andl %edx, %edi
1708 orl %edi, %esi
1709 movl 24(%esp), %edi
1710 roll $10, %ecx
1711 leal 2053994217(%eax,%esi,1),%eax
1712 movl $-1, %esi
1713 roll $14, %eax
1714 addl %ebp, %eax
1715 /* 136 */
1716 addl %edi, %ebp
1717 movl %ebx, %edi
1718 subl %eax, %esi
1719 andl %eax, %edi
1720 andl %ecx, %esi
1721 orl %esi, %edi
1722 movl 52(%esp), %esi
1723 roll $10, %ebx
1724 leal 2053994217(%ebp,%edi,1),%ebp
1725 movl $-1, %edi
1726 roll $6, %ebp
1727 addl %edx, %ebp
1728 /* 137 */
1729 addl %esi, %edx
1730 movl %eax, %esi
1731 subl %ebp, %edi
1732 andl %ebp, %esi
1733 andl %ebx, %edi
1734 orl %edi, %esi
1735 movl 12(%esp), %edi
1736 roll $10, %eax
1737 leal 2053994217(%edx,%esi,1),%edx
1738 movl $-1, %esi
1739 roll $9, %edx
1740 addl %ecx, %edx
1741 /* 138 */
1742 addl %edi, %ecx
1743 movl %ebp, %edi
1744 subl %edx, %esi
1745 andl %edx, %edi
1746 andl %eax, %esi
1747 orl %esi, %edi
1748 movl 56(%esp), %esi
1749 roll $10, %ebp
1750 leal 2053994217(%ecx,%edi,1),%ecx
1751 movl $-1, %edi
1752 roll $12, %ecx
1753 addl %ebx, %ecx
1754 /* 139 */
1755 addl %esi, %ebx
1756 movl %edx, %esi
1757 subl %ecx, %edi
1758 andl %ecx, %esi
1759 andl %ebp, %edi
1760 orl %edi, %esi
1761 movl 40(%esp), %edi
1762 roll $10, %edx
1763 leal 2053994217(%ebx,%esi,1),%ebx
1764 movl $-1, %esi
1765 roll $9, %ebx
1766 addl %eax, %ebx
1767 /* 140 */
1768 addl %edi, %eax
1769 movl %ecx, %edi
1770 subl %ebx, %esi
1771 andl %ebx, %edi
1772 andl %edx, %esi
1773 orl %esi, %edi
1774 movl 32(%esp), %esi
1775 roll $10, %ecx
1776 leal 2053994217(%eax,%edi,1),%eax
1777 movl $-1, %edi
1778 roll $12, %eax
1779 addl %ebp, %eax
1780 /* 141 */
1781 addl %esi, %ebp
1782 movl %ebx, %esi
1783 subl %eax, %edi
1784 andl %eax, %esi
1785 andl %ecx, %edi
1786 orl %edi, %esi
1787 movl 44(%esp), %edi
1788 roll $10, %ebx
1789 leal 2053994217(%ebp,%esi,1),%ebp
1790 movl $-1, %esi
1791 roll $5, %ebp
1792 addl %edx, %ebp
1793 /* 142 */
1794 addl %edi, %edx
1795 movl %eax, %edi
1796 subl %ebp, %esi
1797 andl %ebp, %edi
1798 andl %ebx, %esi
1799 orl %esi, %edi
1800 movl 60(%esp), %esi
1801 roll $10, %eax
1802 leal 2053994217(%edx,%edi,1),%edx
1803 movl $-1, %edi
1804 roll $15, %edx
1805 addl %ecx, %edx
1806 /* 143 */
1807 addl %esi, %ecx
1808 movl %ebp, %esi
1809 subl %edx, %edi
1810 andl %edx, %esi
1811 andl %eax, %edi
1812 orl %esi, %edi
1813 movl %edx, %esi
1814 roll $10, %ebp
1815 leal 2053994217(%ecx,%edi,1),%ecx
1816 xorl %ebp, %esi
1817 roll $8, %ecx
1818 addl %ebx, %ecx
1819 /* 144 */
1820 movl 52(%esp), %edi
1821 xorl %ecx, %esi
1822 addl %edi, %ebx
1823 roll $10, %edx
1824 addl %esi, %ebx
1825 movl %ecx, %esi
1826 roll $8, %ebx
1827 addl %eax, %ebx
1828 /* 145 */
1829 xorl %edx, %esi
1830 movl 64(%esp), %edi
1831 xorl %ebx, %esi
1832 addl %esi, %eax
1833 movl %ebx, %esi
1834 roll $10, %ecx
1835 addl %edi, %eax
1836 xorl %ecx, %esi
1837 roll $5, %eax
1838 addl %ebp, %eax
1839 /* 146 */
1840 movl 44(%esp), %edi
1841 xorl %eax, %esi
1842 addl %edi, %ebp
1843 roll $10, %ebx
1844 addl %esi, %ebp
1845 movl %eax, %esi
1846 roll $12, %ebp
1847 addl %edx, %ebp
1848 /* 147 */
1849 xorl %ebx, %esi
1850 movl 20(%esp), %edi
1851 xorl %ebp, %esi
1852 addl %esi, %edx
1853 movl %ebp, %esi
1854 roll $10, %eax
1855 addl %edi, %edx
1856 xorl %eax, %esi
1857 roll $9, %edx
1858 addl %ecx, %edx
1859 /* 148 */
1860 movl 8(%esp), %edi
1861 xorl %edx, %esi
1862 addl %edi, %ecx
1863 roll $10, %ebp
1864 addl %esi, %ecx
1865 movl %edx, %esi
1866 roll $12, %ecx
1867 addl %ebx, %ecx
1868 /* 149 */
1869 xorl %ebp, %esi
1870 movl 24(%esp), %edi
1871 xorl %ecx, %esi
1872 addl %esi, %ebx
1873 movl %ecx, %esi
1874 roll $10, %edx
1875 addl %edi, %ebx
1876 xorl %edx, %esi
1877 roll $5, %ebx
1878 addl %eax, %ebx
1879 /* 150 */
1880 movl 36(%esp), %edi
1881 xorl %ebx, %esi
1882 addl %edi, %eax
1883 roll $10, %ecx
1884 addl %esi, %eax
1885 movl %ebx, %esi
1886 roll $14, %eax
1887 addl %ebp, %eax
1888 /* 151 */
1889 xorl %ecx, %esi
1890 movl 32(%esp), %edi
1891 xorl %eax, %esi
1892 addl %esi, %ebp
1893 movl %eax, %esi
1894 roll $10, %ebx
1895 addl %edi, %ebp
1896 xorl %ebx, %esi
1897 roll $6, %ebp
1898 addl %edx, %ebp
1899 /* 152 */
1900 movl 28(%esp), %edi
1901 xorl %ebp, %esi
1902 addl %edi, %edx
1903 roll $10, %eax
1904 addl %esi, %edx
1905 movl %ebp, %esi
1906 roll $8, %edx
1907 addl %ecx, %edx
1908 /* 153 */
1909 xorl %eax, %esi
1910 movl 12(%esp), %edi
1911 xorl %edx, %esi
1912 addl %esi, %ecx
1913 movl %edx, %esi
1914 roll $10, %ebp
1915 addl %edi, %ecx
1916 xorl %ebp, %esi
1917 roll $13, %ecx
1918 addl %ebx, %ecx
1919 /* 154 */
1920 movl 56(%esp), %edi
1921 xorl %ecx, %esi
1922 addl %edi, %ebx
1923 roll $10, %edx
1924 addl %esi, %ebx
1925 movl %ecx, %esi
1926 roll $6, %ebx
1927 addl %eax, %ebx
1928 /* 155 */
1929 xorl %edx, %esi
1930 movl 60(%esp), %edi
1931 xorl %ebx, %esi
1932 addl %esi, %eax
1933 movl %ebx, %esi
1934 roll $10, %ecx
1935 addl %edi, %eax
1936 xorl %ecx, %esi
1937 roll $5, %eax
1938 addl %ebp, %eax
1939 /* 156 */
1940 movl 4(%esp), %edi
1941 xorl %eax, %esi
1942 addl %edi, %ebp
1943 roll $10, %ebx
1944 addl %esi, %ebp
1945 movl %eax, %esi
1946 roll $15, %ebp
1947 addl %edx, %ebp
1948 /* 157 */
1949 xorl %ebx, %esi
1950 movl 16(%esp), %edi
1951 xorl %ebp, %esi
1952 addl %esi, %edx
1953 movl %ebp, %esi
1954 roll $10, %eax
1955 addl %edi, %edx
1956 xorl %eax, %esi
1957 roll $13, %edx
1958 addl %ecx, %edx
1959 /* 158 */
1960 movl 40(%esp), %edi
1961 xorl %edx, %esi
1962 addl %edi, %ecx
1963 roll $10, %ebp
1964 addl %esi, %ecx
1965 movl %edx, %esi
1966 roll $11, %ecx
1967 addl %ebx, %ecx
1968 /* 159 */
1969 xorl %ebp, %esi
1970 movl 48(%esp), %edi
1971 xorl %ecx, %esi
1972 addl %esi, %ebx
1973 roll $10, %edx
1974 addl %edi, %ebx
1975 movl 108(%esp), %edi
1976 roll $11, %ebx
1977 addl %eax, %ebx
1978 movl 4(%edi), %esi
1979 addl %esi, %edx
1980 movl 76(%esp), %esi
1981 addl %esi, %edx
1982 movl 8(%edi), %esi
1983 addl %esi, %ebp
1984 movl 80(%esp), %esi
1985 addl %esi, %ebp
1986 movl 12(%edi), %esi
1987 addl %esi, %eax
1988 movl 84(%esp), %esi
1989 addl %esi, %eax
1990 movl 16(%edi), %esi
1991 addl %esi, %ebx
1992 movl 68(%esp), %esi
1993 addl %esi, %ebx
1994 movl (%edi), %esi
1995 addl %esi, %ecx
1996 movl 72(%esp), %esi
1997 addl %esi, %ecx
1998 movl %edx, (%edi)
1999 movl %ebp, 4(%edi)
2000 movl %eax, 8(%edi)
2001 movl %ebx, 12(%edi)
2002 movl %ecx, 16(%edi)
2003 movl (%esp), %edi
2004 movl 112(%esp), %esi
2005 cmpl %esi, %edi
2006 movl 108(%esp), %edi
2007 jge .L000start
2008 addl $88, %esp
2009 popl %ebx
2010 popl %ebp
2011 popl %edi
2012 popl %esi
2013 ret
2014.ripemd160_block_x86_end:
2015 SIZE(ripemd160_block_x86,.ripemd160_block_x86_end-ripemd160_block_x86)
2016.ident "desasm.pl"
diff --git a/src/lib/libssl/src/crypto/rsa/Makefile.ssl b/src/lib/libssl/src/crypto/rsa/Makefile.ssl
new file mode 100644
index 0000000000..d52f2e609e
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rsa/Makefile.ssl
@@ -0,0 +1,86 @@
1#
2# SSLeay/crypto/rsa/Makefile
3#
4
5DIR= rsa
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=rsa
19ERRC=rsa_err
20GENERAL=Makefile
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c rsa_saos.c $(ERRC).c \
26 rsa_pk1.c rsa_ssl.c rsa_none.c
27LIBOBJ= rsa_eay.o rsa_gen.o rsa_lib.o rsa_sign.o rsa_saos.o $(ERRC).o \
28 rsa_pk1.o rsa_ssl.o rsa_none.o
29
30SRC= $(LIBSRC)
31
32EXHEADER= rsa.h
33HEADER= $(EXHEADER)
34
35ALL= $(GENERAL) $(SRC) $(HEADER)
36
37top:
38 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
39
40all: lib
41
42lib: $(LIBOBJ)
43 $(AR) $(LIB) $(LIBOBJ)
44 sh $(TOP)/util/ranlib.sh $(LIB)
45 @touch lib
46
47files:
48 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
49
50links:
51 /bin/rm -f Makefile
52 $(TOP)/util/point.sh Makefile.ssl Makefile ;
53 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
54 $(TOP)/util/mklink.sh ../../test $(TEST)
55 $(TOP)/util/mklink.sh ../../apps $(APPS)
56
57install:
58 @for i in $(EXHEADER) ; \
59 do \
60 (cp $$i $(INSTALLTOP)/include/$$i; \
61 chmod 644 $(INSTALLTOP)/include/$$i ); \
62 done;
63
64tags:
65 ctags $(SRC)
66
67tests:
68
69lint:
70 lint -DLINT $(INCLUDES) $(SRC)>fluff
71
72depend:
73 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
74
75dclean:
76 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
77 mv -f Makefile.new $(MAKEFILE)
78
79clean:
80 /bin/rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
81
82errors:
83 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
84 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
85
86# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/rsa/rsa.err b/src/lib/libssl/src/crypto/rsa/rsa.err
new file mode 100644
index 0000000000..5ded1b5fa2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/rsa/rsa.err
@@ -0,0 +1,45 @@
1/* Error codes for the RSA functions. */
2
3/* Function codes. */
4#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 100
5#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 101
6#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 102
7#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 103
8#define RSA_F_RSA_GENERATE_KEY 104
9#define RSA_F_RSA_NEW_METHOD 105
10#define RSA_F_RSA_PADDING_ADD_NONE 106
11#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 107
12#define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 108
13#define RSA_F_RSA_PADDING_ADD_SSLV23 109
14#define RSA_F_RSA_PADDING_CHECK_NONE 110
15#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 111
16#define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 112
17#define RSA_F_RSA_PADDING_CHECK_SSLV23 113
18#define RSA_F_RSA_PRINT 114
19#define RSA_F_RSA_PRINT_FP 115
20#define RSA_F_RSA_SIGN 116
21#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 117
22#define RSA_F_RSA_VERIFY 118
23#define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 119
24
25/* Reason codes. */
26#define RSA_R_ALGORITHM_MISMATCH 100
27#define RSA_R_BAD_E_VALUE 101
28#define RSA_R_BAD_FIXED_HEADER_DECRYPT 102
29#define RSA_R_BAD_PAD_BYTE_COUNT 103
30#define RSA_R_BAD_SIGNATURE 104
31#define RSA_R_BAD_ZERO_BYTE 105
32#define RSA_R_BLOCK_TYPE_IS_NOT_01 106
33#define RSA_R_BLOCK_TYPE_IS_NOT_02 107
34#define RSA_R_DATA_GREATER_THAN_MOD_LEN 108
35#define RSA_R_DATA_TOO_LARGE 109
36#define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110
37#define RSA_R_DATA_TOO_SMALL 111
38#define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112
39#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
40#define RSA_R_PADDING_CHECK_FAILED 114
41#define RSA_R_SSLV3_ROLLBACK_ATTACK 115
42#define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
43#define RSA_R_UNKNOWN_ALGORITHM_TYPE 117
44#define RSA_R_UNKNOWN_PADDING_TYPE 118
45#define RSA_R_WRONG_SIGNATURE_LENGTH 119
diff --git a/src/lib/libssl/src/crypto/sha/Makefile.ssl b/src/lib/libssl/src/crypto/sha/Makefile.ssl
new file mode 100644
index 0000000000..eeb545d140
--- /dev/null
+++ b/src/lib/libssl/src/crypto/sha/Makefile.ssl
@@ -0,0 +1,103 @@
1#
2# SSLeay/crypto/sha/Makefile
3#
4
5DIR= sha
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16SHA1_ASM_OBJ=
17
18CFLAGS= $(INCLUDES) $(CFLAG)
19
20GENERAL=Makefile
21TEST=shatest.c sha1test.c
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c
26LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o $(SHA1_ASM_OBJ)
27
28SRC= $(LIBSRC)
29
30EXHEADER= sha.h
31HEADER= sha_locl.h $(EXHEADER)
32
33ALL= $(GENERAL) $(SRC) $(HEADER)
34
35top:
36 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
37
38all: lib
39
40lib: $(LIBOBJ)
41 $(AR) $(LIB) $(LIBOBJ)
42 sh $(TOP)/util/ranlib.sh $(LIB)
43 @touch lib
44
45# elf
46asm/sx86-elf.o: asm/sx86unix.cpp
47 $(CPP) -DELF asm/sx86unix.cpp | as -o asm/sx86-elf.o
48
49# solaris
50asm/sx86-sol.o: asm/sx86unix.cpp
51 $(CC) -E -DSOL asm/sx86unix.cpp | sed 's/^#.*//' > asm/sx86-sol.s
52 as -o asm/sx86-sol.o asm/sx86-sol.s
53 rm -f asm/sx86-sol.s
54
55# a.out
56asm/sx86-out.o: asm/sx86unix.cpp
57 $(CPP) -DOUT asm/sx86unix.cpp | as -o asm/sx86-out.o
58
59# bsdi
60asm/sx86bsdi.o: asm/sx86unix.cpp
61 $(CPP) -DBSDI asm/sx86unix.cpp | as -o asm/sx86bsdi.o
62
63asm/sx86unix.cpp:
64 (cd asm; perl sha1-586.pl cpp >sx86unix.cpp)
65
66files:
67 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
68
69links:
70 /bin/rm -f Makefile
71 $(TOP)/util/point.sh Makefile.ssl Makefile ;
72 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
73 $(TOP)/util/mklink.sh ../../test $(TEST)
74 $(TOP)/util/mklink.sh ../../apps $(APPS)
75
76install:
77 @for i in $(EXHEADER) ; \
78 do \
79 (cp $$i $(INSTALLTOP)/include/$$i; \
80 chmod 644 $(INSTALLTOP)/include/$$i ); \
81 done;
82
83tags:
84 ctags $(SRC)
85
86tests:
87
88lint:
89 lint -DLINT $(INCLUDES) $(SRC)>fluff
90
91depend:
92 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
93
94dclean:
95 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
96 mv -f Makefile.new $(MAKEFILE)
97
98clean:
99 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff asm/*.o
100
101errors:
102
103# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/sha/Makefile.uni b/src/lib/libssl/src/crypto/sha/Makefile.uni
new file mode 100644
index 0000000000..f3236755b2
--- /dev/null
+++ b/src/lib/libssl/src/crypto/sha/Makefile.uni
@@ -0,0 +1,122 @@
1# Targets
2# make - twidle the options yourself :-)
3# make cc - standard cc options
4# make gcc - standard gcc options
5# make x86-elf - linux-elf etc
6# make x86-out - linux-a.out, FreeBSD etc
7# make x86-solaris
8# make x86-bdsi
9
10DIR= sha
11TOP= .
12CC= gcc
13CFLAG= -O3 -fomit-frame-pointer
14
15CPP= $(CC) -E
16INCLUDES=
17INSTALLTOP=/usr/local/lib
18MAKE= make
19MAKEDEPEND= makedepend
20MAKEFILE= Makefile.uni
21AR= ar r
22
23SHA_ASM_OBJ=
24
25CFLAGS= $(INCLUDES) $(CFLAG)
26
27GENERAL=Makefile
28
29TEST1=shatest
30TEST2=sha1test
31APP1=sha
32APP2=sha1
33
34TEST=$(TEST1) $(TEST2)
35APPS=$(APP1) $(APP2)
36
37LIB=libsha.a
38LIBSRC=sha_dgst.c sha1dgst.c sha_one.c sha1_one.c
39LIBOBJ=sha_dgst.o sha1dgst.o sha_one.o sha1_one.o $(SHA_ASM_OBJ)
40
41SRC= $(LIBSRC)
42
43EXHEADER= sha.h
44HEADER= sha_locl.h $(EXHEADER)
45
46ALL= $(GENERAL) $(SRC) $(HEADER)
47
48all: $(LIB) $(TEST) $(APPS)
49
50$(LIB): $(LIBOBJ)
51 $(AR) $(LIB) $(LIBOBJ)
52 sh $(TOP)/ranlib.sh $(LIB)
53
54# elf
55asm/sx86-elf.o: asm/sx86unix.cpp
56 $(CPP) -DELF asm/sx86unix.cpp | as -o asm/sx86-elf.o
57
58# solaris
59asm/sx86-sol.o: asm/sx86unix.cpp
60 $(CC) -E -DSOL asm/sx86unix.cpp | sed 's/^#.*//' > asm/sx86-sol.s
61 as -o asm/sx86-sol.o asm/sx86-sol.s
62 rm -f asm/sx86-sol.s
63
64# a.out
65asm/sx86-out.o: asm/sx86unix.cpp
66 $(CPP) -DOUT asm/sx86unix.cpp | as -o asm/sx86-out.o
67
68# bsdi
69asm/sx86bsdi.o: asm/sx86unix.cpp
70 $(CPP) -DBSDI asm/sx86unix.cpp | as -o asm/sx86bsdi.o
71
72asm/sx86unix.cpp:
73 (cd asm; perl sha1-586.pl cpp >sx86unix.cpp)
74
75test: $(TEST)
76 ./$(TEST1)
77 ./$(TEST2)
78
79$(TEST1): $(TEST1).c $(LIB)
80 $(CC) -o $(TEST1) $(CFLAGS) $(TEST1).c $(LIB)
81
82$(TEST2): $(TEST2).c $(LIB)
83 $(CC) -o $(TEST2) $(CFLAGS) $(TEST2).c $(LIB)
84
85$(APP1): $(APP1).c $(LIB)
86 $(CC) -o $(APP1) $(CFLAGS) $(APP1).c $(LIB)
87
88$(APP2): $(APP2).c $(LIB)
89 $(CC) -o $(APP2) $(CFLAGS) $(APP2).c $(LIB)
90
91lint:
92 lint -DLINT $(INCLUDES) $(SRC)>fluff
93
94depend:
95 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
96
97dclean:
98 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
99 mv -f Makefile.new $(MAKEFILE)
100
101clean:
102 /bin/rm -f $(LIB) $(TEST) $(APPS) *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
103
104cc:
105 $(MAKE) SHA_ASM_OBJ="" CC="cc" CFLAG="-O" all
106
107gcc:
108 $(MAKE) SHA_ASM_OBJ="" CC="gcc" CFLAGS="-O3 -fomit-frame-pointer" all
109
110x86-elf:
111 $(MAKE) SHA_ASM_OBJ="asm/sx86-elf.o" CFLAG="-DELF -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all
112
113x86-out:
114 $(MAKE) SHA_ASM_OBJ="asm/sx86-out.o" CFLAG="-DOUT -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all
115
116x86-solaris:
117 $(MAKE) SHA_ASM_OBJ="asm/sx86-sol.o" CFLAG="-DSOL -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all
118
119x86-bdsi:
120 $(MAKE) SHA_ASM_OBJ="asm/sx86-bdsi.o" CFLAG="-DBDSI -DSHA1_ASM -DL_ENDIAN $(CFLAGS)" all
121
122# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/sha/asm/s1-win32.asm b/src/lib/libssl/src/crypto/sha/asm/s1-win32.asm
new file mode 100644
index 0000000000..61335666b9
--- /dev/null
+++ b/src/lib/libssl/src/crypto/sha/asm/s1-win32.asm
@@ -0,0 +1,1664 @@
1 ; Don't even think of reading this code
2 ; It was automatically generated by sha1-586.pl
3 ; Which is a perl program used to generate the x86 assember for
4 ; any of elf, a.out, BSDI,Win32, or Solaris
5 ; eric <eay@cryptsoft.com>
6 ;
7 TITLE sha1-586.asm
8 .486
9.model FLAT
10_TEXT SEGMENT
11PUBLIC _sha1_block_x86
12
13_sha1_block_x86 PROC NEAR
14 push esi
15 push ebp
16 mov eax, DWORD PTR 20[esp]
17 mov esi, DWORD PTR 16[esp]
18 add eax, esi
19 mov ebp, DWORD PTR 12[esp]
20 push ebx
21 sub eax, 64
22 push edi
23 mov ebx, DWORD PTR 4[ebp]
24 sub esp, 72
25 mov edx, DWORD PTR 12[ebp]
26 mov edi, DWORD PTR 16[ebp]
27 mov ecx, DWORD PTR 8[ebp]
28 mov DWORD PTR 68[esp],eax
29 ; First we need to setup the X array
30 mov eax, DWORD PTR [esi]
31L000start:
32 ; First, load the words onto the stack in network byte order
33 bswap eax
34 mov DWORD PTR [esp],eax
35 mov eax, DWORD PTR 4[esi]
36 bswap eax
37 mov DWORD PTR 4[esp],eax
38 mov eax, DWORD PTR 8[esi]
39 bswap eax
40 mov DWORD PTR 8[esp],eax
41 mov eax, DWORD PTR 12[esi]
42 bswap eax
43 mov DWORD PTR 12[esp],eax
44 mov eax, DWORD PTR 16[esi]
45 bswap eax
46 mov DWORD PTR 16[esp],eax
47 mov eax, DWORD PTR 20[esi]
48 bswap eax
49 mov DWORD PTR 20[esp],eax
50 mov eax, DWORD PTR 24[esi]
51 bswap eax
52 mov DWORD PTR 24[esp],eax
53 mov eax, DWORD PTR 28[esi]
54 bswap eax
55 mov DWORD PTR 28[esp],eax
56 mov eax, DWORD PTR 32[esi]
57 bswap eax
58 mov DWORD PTR 32[esp],eax
59 mov eax, DWORD PTR 36[esi]
60 bswap eax
61 mov DWORD PTR 36[esp],eax
62 mov eax, DWORD PTR 40[esi]
63 bswap eax
64 mov DWORD PTR 40[esp],eax
65 mov eax, DWORD PTR 44[esi]
66 bswap eax
67 mov DWORD PTR 44[esp],eax
68 mov eax, DWORD PTR 48[esi]
69 bswap eax
70 mov DWORD PTR 48[esp],eax
71 mov eax, DWORD PTR 52[esi]
72 bswap eax
73 mov DWORD PTR 52[esp],eax
74 mov eax, DWORD PTR 56[esi]
75 bswap eax
76 mov DWORD PTR 56[esp],eax
77 mov eax, DWORD PTR 60[esi]
78 bswap eax
79 mov DWORD PTR 60[esp],eax
80 ; We now have the X array on the stack
81 ; starting at sp-4
82 mov DWORD PTR 64[esp],esi
83 ;
84 ; Start processing
85 mov eax, DWORD PTR [ebp]
86 ; 00_15 0
87 mov esi, ecx
88 mov ebp, eax
89 xor esi, edx
90 rol ebp, 5
91 and esi, ebx
92 add ebp, edi
93 ror ebx, 1
94 mov edi, DWORD PTR [esp]
95 ror ebx, 1
96 xor esi, edx
97 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
98 mov edi, ebx
99 add esi, ebp
100 xor edi, ecx
101 mov ebp, esi
102 and edi, eax
103 rol ebp, 5
104 add ebp, edx
105 mov edx, DWORD PTR 4[esp]
106 ror eax, 1
107 xor edi, ecx
108 ror eax, 1
109 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
110 add edi, ebp
111 ; 00_15 2
112 mov edx, eax
113 mov ebp, edi
114 xor edx, ebx
115 rol ebp, 5
116 and edx, esi
117 add ebp, ecx
118 ror esi, 1
119 mov ecx, DWORD PTR 8[esp]
120 ror esi, 1
121 xor edx, ebx
122 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
123 mov ecx, esi
124 add edx, ebp
125 xor ecx, eax
126 mov ebp, edx
127 and ecx, edi
128 rol ebp, 5
129 add ebp, ebx
130 mov ebx, DWORD PTR 12[esp]
131 ror edi, 1
132 xor ecx, eax
133 ror edi, 1
134 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
135 add ecx, ebp
136 ; 00_15 4
137 mov ebx, edi
138 mov ebp, ecx
139 xor ebx, esi
140 rol ebp, 5
141 and ebx, edx
142 add ebp, eax
143 ror edx, 1
144 mov eax, DWORD PTR 16[esp]
145 ror edx, 1
146 xor ebx, esi
147 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
148 mov eax, edx
149 add ebx, ebp
150 xor eax, edi
151 mov ebp, ebx
152 and eax, ecx
153 rol ebp, 5
154 add ebp, esi
155 mov esi, DWORD PTR 20[esp]
156 ror ecx, 1
157 xor eax, edi
158 ror ecx, 1
159 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
160 add eax, ebp
161 ; 00_15 6
162 mov esi, ecx
163 mov ebp, eax
164 xor esi, edx
165 rol ebp, 5
166 and esi, ebx
167 add ebp, edi
168 ror ebx, 1
169 mov edi, DWORD PTR 24[esp]
170 ror ebx, 1
171 xor esi, edx
172 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
173 mov edi, ebx
174 add esi, ebp
175 xor edi, ecx
176 mov ebp, esi
177 and edi, eax
178 rol ebp, 5
179 add ebp, edx
180 mov edx, DWORD PTR 28[esp]
181 ror eax, 1
182 xor edi, ecx
183 ror eax, 1
184 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
185 add edi, ebp
186 ; 00_15 8
187 mov edx, eax
188 mov ebp, edi
189 xor edx, ebx
190 rol ebp, 5
191 and edx, esi
192 add ebp, ecx
193 ror esi, 1
194 mov ecx, DWORD PTR 32[esp]
195 ror esi, 1
196 xor edx, ebx
197 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
198 mov ecx, esi
199 add edx, ebp
200 xor ecx, eax
201 mov ebp, edx
202 and ecx, edi
203 rol ebp, 5
204 add ebp, ebx
205 mov ebx, DWORD PTR 36[esp]
206 ror edi, 1
207 xor ecx, eax
208 ror edi, 1
209 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
210 add ecx, ebp
211 ; 00_15 10
212 mov ebx, edi
213 mov ebp, ecx
214 xor ebx, esi
215 rol ebp, 5
216 and ebx, edx
217 add ebp, eax
218 ror edx, 1
219 mov eax, DWORD PTR 40[esp]
220 ror edx, 1
221 xor ebx, esi
222 lea ebp, DWORD PTR 1518500249[eax*1+ebp]
223 mov eax, edx
224 add ebx, ebp
225 xor eax, edi
226 mov ebp, ebx
227 and eax, ecx
228 rol ebp, 5
229 add ebp, esi
230 mov esi, DWORD PTR 44[esp]
231 ror ecx, 1
232 xor eax, edi
233 ror ecx, 1
234 lea ebp, DWORD PTR 1518500249[esi*1+ebp]
235 add eax, ebp
236 ; 00_15 12
237 mov esi, ecx
238 mov ebp, eax
239 xor esi, edx
240 rol ebp, 5
241 and esi, ebx
242 add ebp, edi
243 ror ebx, 1
244 mov edi, DWORD PTR 48[esp]
245 ror ebx, 1
246 xor esi, edx
247 lea ebp, DWORD PTR 1518500249[edi*1+ebp]
248 mov edi, ebx
249 add esi, ebp
250 xor edi, ecx
251 mov ebp, esi
252 and edi, eax
253 rol ebp, 5
254 add ebp, edx
255 mov edx, DWORD PTR 52[esp]
256 ror eax, 1
257 xor edi, ecx
258 ror eax, 1
259 lea ebp, DWORD PTR 1518500249[edx*1+ebp]
260 add edi, ebp
261 ; 00_15 14
262 mov edx, eax
263 mov ebp, edi
264 xor edx, ebx
265 rol ebp, 5
266 and edx, esi
267 add ebp, ecx
268 ror esi, 1
269 mov ecx, DWORD PTR 56[esp]
270 ror esi, 1
271 xor edx, ebx
272 lea ebp, DWORD PTR 1518500249[ecx*1+ebp]
273 mov ecx, esi
274 add edx, ebp
275 xor ecx, eax
276 mov ebp, edx
277 and ecx, edi
278 rol ebp, 5
279 add ebp, ebx
280 mov ebx, DWORD PTR 60[esp]
281 ror edi, 1
282 xor ecx, eax
283 ror edi, 1
284 lea ebp, DWORD PTR 1518500249[ebx*1+ebp]
285 add ecx, ebp
286 ; 16_19 16
287 nop
288 mov ebp, DWORD PTR [esp]
289 mov ebx, DWORD PTR 8[esp]
290 xor ebx, ebp
291 mov ebp, DWORD PTR 32[esp]
292 xor ebx, ebp
293 mov ebp, DWORD PTR 52[esp]
294 xor ebx, ebp
295 mov ebp, edi
296 rol ebx, 1
297 xor ebp, esi
298 mov DWORD PTR [esp],ebx
299 and ebp, edx
300 lea ebx, DWORD PTR 1518500249[eax*1+ebx]
301 xor ebp, esi
302 mov eax, ecx
303 add ebx, ebp
304 rol eax, 5
305 ror edx, 1
306 add ebx, eax
307 mov eax, DWORD PTR 4[esp]
308 mov ebp, DWORD PTR 12[esp]
309 xor eax, ebp
310 mov ebp, DWORD PTR 36[esp]
311 xor eax, ebp
312 mov ebp, DWORD PTR 56[esp]
313 ror edx, 1
314 xor eax, ebp
315 rol eax, 1
316 mov ebp, edx
317 xor ebp, edi
318 mov DWORD PTR 4[esp],eax
319 and ebp, ecx
320 lea eax, DWORD PTR 1518500249[esi*1+eax]
321 xor ebp, edi
322 mov esi, ebx
323 rol esi, 5
324 ror ecx, 1
325 add eax, esi
326 ror ecx, 1
327 add eax, ebp
328 ; 16_19 18
329 mov ebp, DWORD PTR 8[esp]
330 mov esi, DWORD PTR 16[esp]
331 xor esi, ebp
332 mov ebp, DWORD PTR 40[esp]
333 xor esi, ebp
334 mov ebp, DWORD PTR 60[esp]
335 xor esi, ebp
336 mov ebp, ecx
337 rol esi, 1
338 xor ebp, edx
339 mov DWORD PTR 8[esp],esi
340 and ebp, ebx
341 lea esi, DWORD PTR 1518500249[edi*1+esi]
342 xor ebp, edx
343 mov edi, eax
344 add esi, ebp
345 rol edi, 5
346 ror ebx, 1
347 add esi, edi
348 mov edi, DWORD PTR 12[esp]
349 mov ebp, DWORD PTR 20[esp]
350 xor edi, ebp
351 mov ebp, DWORD PTR 44[esp]
352 xor edi, ebp
353 mov ebp, DWORD PTR [esp]
354 ror ebx, 1
355 xor edi, ebp
356 rol edi, 1
357 mov ebp, ebx
358 xor ebp, ecx
359 mov DWORD PTR 12[esp],edi
360 and ebp, eax
361 lea edi, DWORD PTR 1518500249[edx*1+edi]
362 xor ebp, ecx
363 mov edx, esi
364 rol edx, 5
365 ror eax, 1
366 add edi, edx
367 ror eax, 1
368 add edi, ebp
369 ; 20_39 20
370 mov edx, DWORD PTR 16[esp]
371 mov ebp, DWORD PTR 24[esp]
372 xor edx, ebp
373 mov ebp, DWORD PTR 48[esp]
374 xor edx, ebp
375 mov ebp, DWORD PTR 4[esp]
376 xor edx, ebp
377 mov ebp, esi
378 rol edx, 1
379 xor ebp, eax
380 mov DWORD PTR 16[esp],edx
381 xor ebp, ebx
382 lea edx, DWORD PTR 1859775393[ecx*1+edx]
383 mov ecx, edi
384 rol ecx, 5
385 ror esi, 1
386 add ecx, ebp
387 ror esi, 1
388 add edx, ecx
389 ; 20_39 21
390 mov ecx, DWORD PTR 20[esp]
391 mov ebp, DWORD PTR 28[esp]
392 xor ecx, ebp
393 mov ebp, DWORD PTR 52[esp]
394 xor ecx, ebp
395 mov ebp, DWORD PTR 8[esp]
396 xor ecx, ebp
397 mov ebp, edi
398 rol ecx, 1
399 xor ebp, esi
400 mov DWORD PTR 20[esp],ecx
401 xor ebp, eax
402 lea ecx, DWORD PTR 1859775393[ebx*1+ecx]
403 mov ebx, edx
404 rol ebx, 5
405 ror edi, 1
406 add ebx, ebp
407 ror edi, 1
408 add ecx, ebx
409 ; 20_39 22
410 mov ebx, DWORD PTR 24[esp]
411 mov ebp, DWORD PTR 32[esp]
412 xor ebx, ebp
413 mov ebp, DWORD PTR 56[esp]
414 xor ebx, ebp
415 mov ebp, DWORD PTR 12[esp]
416 xor ebx, ebp
417 mov ebp, edx
418 rol ebx, 1
419 xor ebp, edi
420 mov DWORD PTR 24[esp],ebx
421 xor ebp, esi
422 lea ebx, DWORD PTR 1859775393[eax*1+ebx]
423 mov eax, ecx
424 rol eax, 5
425 ror edx, 1
426 add eax, ebp
427 ror edx, 1
428 add ebx, eax
429 ; 20_39 23
430 mov eax, DWORD PTR 28[esp]
431 mov ebp, DWORD PTR 36[esp]
432 xor eax, ebp
433 mov ebp, DWORD PTR 60[esp]
434 xor eax, ebp
435 mov ebp, DWORD PTR 16[esp]
436 xor eax, ebp
437 mov ebp, ecx
438 rol eax, 1
439 xor ebp, edx
440 mov DWORD PTR 28[esp],eax
441 xor ebp, edi
442 lea eax, DWORD PTR 1859775393[esi*1+eax]
443 mov esi, ebx
444 rol esi, 5
445 ror ecx, 1
446 add esi, ebp
447 ror ecx, 1
448 add eax, esi
449 ; 20_39 24
450 mov esi, DWORD PTR 32[esp]
451 mov ebp, DWORD PTR 40[esp]
452 xor esi, ebp
453 mov ebp, DWORD PTR [esp]
454 xor esi, ebp
455 mov ebp, DWORD PTR 20[esp]
456 xor esi, ebp
457 mov ebp, ebx
458 rol esi, 1
459 xor ebp, ecx
460 mov DWORD PTR 32[esp],esi
461 xor ebp, edx
462 lea esi, DWORD PTR 1859775393[edi*1+esi]
463 mov edi, eax
464 rol edi, 5
465 ror ebx, 1
466 add edi, ebp
467 ror ebx, 1
468 add esi, edi
469 ; 20_39 25
470 mov edi, DWORD PTR 36[esp]
471 mov ebp, DWORD PTR 44[esp]
472 xor edi, ebp
473 mov ebp, DWORD PTR 4[esp]
474 xor edi, ebp
475 mov ebp, DWORD PTR 24[esp]
476 xor edi, ebp
477 mov ebp, eax
478 rol edi, 1
479 xor ebp, ebx
480 mov DWORD PTR 36[esp],edi
481 xor ebp, ecx
482 lea edi, DWORD PTR 1859775393[edx*1+edi]
483 mov edx, esi
484 rol edx, 5
485 ror eax, 1
486 add edx, ebp
487 ror eax, 1
488 add edi, edx
489 ; 20_39 26
490 mov edx, DWORD PTR 40[esp]
491 mov ebp, DWORD PTR 48[esp]
492 xor edx, ebp
493 mov ebp, DWORD PTR 8[esp]
494 xor edx, ebp
495 mov ebp, DWORD PTR 28[esp]
496 xor edx, ebp
497 mov ebp, esi
498 rol edx, 1
499 xor ebp, eax
500 mov DWORD PTR 40[esp],edx
501 xor ebp, ebx
502 lea edx, DWORD PTR 1859775393[ecx*1+edx]
503 mov ecx, edi
504 rol ecx, 5
505 ror esi, 1
506 add ecx, ebp
507 ror esi, 1
508 add edx, ecx
509 ; 20_39 27
510 mov ecx, DWORD PTR 44[esp]
511 mov ebp, DWORD PTR 52[esp]
512 xor ecx, ebp
513 mov ebp, DWORD PTR 12[esp]
514 xor ecx, ebp
515 mov ebp, DWORD PTR 32[esp]
516 xor ecx, ebp
517 mov ebp, edi
518 rol ecx, 1
519 xor ebp, esi
520 mov DWORD PTR 44[esp],ecx
521 xor ebp, eax
522 lea ecx, DWORD PTR 1859775393[ebx*1+ecx]
523 mov ebx, edx
524 rol ebx, 5
525 ror edi, 1
526 add ebx, ebp
527 ror edi, 1
528 add ecx, ebx
529 ; 20_39 28
530 mov ebx, DWORD PTR 48[esp]
531 mov ebp, DWORD PTR 56[esp]
532 xor ebx, ebp
533 mov ebp, DWORD PTR 16[esp]
534 xor ebx, ebp
535 mov ebp, DWORD PTR 36[esp]
536 xor ebx, ebp
537 mov ebp, edx
538 rol ebx, 1
539 xor ebp, edi
540 mov DWORD PTR 48[esp],ebx
541 xor ebp, esi
542 lea ebx, DWORD PTR 1859775393[eax*1+ebx]
543 mov eax, ecx
544 rol eax, 5
545 ror edx, 1
546 add eax, ebp
547 ror edx, 1
548 add ebx, eax
549 ; 20_39 29
550 mov eax, DWORD PTR 52[esp]
551 mov ebp, DWORD PTR 60[esp]
552 xor eax, ebp
553 mov ebp, DWORD PTR 20[esp]
554 xor eax, ebp
555 mov ebp, DWORD PTR 40[esp]
556 xor eax, ebp
557 mov ebp, ecx
558 rol eax, 1
559 xor ebp, edx
560 mov DWORD PTR 52[esp],eax
561 xor ebp, edi
562 lea eax, DWORD PTR 1859775393[esi*1+eax]
563 mov esi, ebx
564 rol esi, 5
565 ror ecx, 1
566 add esi, ebp
567 ror ecx, 1
568 add eax, esi
569 ; 20_39 30
570 mov esi, DWORD PTR 56[esp]
571 mov ebp, DWORD PTR [esp]
572 xor esi, ebp
573 mov ebp, DWORD PTR 24[esp]
574 xor esi, ebp
575 mov ebp, DWORD PTR 44[esp]
576 xor esi, ebp
577 mov ebp, ebx
578 rol esi, 1
579 xor ebp, ecx
580 mov DWORD PTR 56[esp],esi
581 xor ebp, edx
582 lea esi, DWORD PTR 1859775393[edi*1+esi]
583 mov edi, eax
584 rol edi, 5
585 ror ebx, 1
586 add edi, ebp
587 ror ebx, 1
588 add esi, edi
589 ; 20_39 31
590 mov edi, DWORD PTR 60[esp]
591 mov ebp, DWORD PTR 4[esp]
592 xor edi, ebp
593 mov ebp, DWORD PTR 28[esp]
594 xor edi, ebp
595 mov ebp, DWORD PTR 48[esp]
596 xor edi, ebp
597 mov ebp, eax
598 rol edi, 1
599 xor ebp, ebx
600 mov DWORD PTR 60[esp],edi
601 xor ebp, ecx
602 lea edi, DWORD PTR 1859775393[edx*1+edi]
603 mov edx, esi
604 rol edx, 5
605 ror eax, 1
606 add edx, ebp
607 ror eax, 1
608 add edi, edx
609 ; 20_39 32
610 mov edx, DWORD PTR [esp]
611 mov ebp, DWORD PTR 8[esp]
612 xor edx, ebp
613 mov ebp, DWORD PTR 32[esp]
614 xor edx, ebp
615 mov ebp, DWORD PTR 52[esp]
616 xor edx, ebp
617 mov ebp, esi
618 rol edx, 1
619 xor ebp, eax
620 mov DWORD PTR [esp],edx
621 xor ebp, ebx
622 lea edx, DWORD PTR 1859775393[ecx*1+edx]
623 mov ecx, edi
624 rol ecx, 5
625 ror esi, 1
626 add ecx, ebp
627 ror esi, 1
628 add edx, ecx
629 ; 20_39 33
630 mov ecx, DWORD PTR 4[esp]
631 mov ebp, DWORD PTR 12[esp]
632 xor ecx, ebp
633 mov ebp, DWORD PTR 36[esp]
634 xor ecx, ebp
635 mov ebp, DWORD PTR 56[esp]
636 xor ecx, ebp
637 mov ebp, edi
638 rol ecx, 1
639 xor ebp, esi
640 mov DWORD PTR 4[esp],ecx
641 xor ebp, eax
642 lea ecx, DWORD PTR 1859775393[ebx*1+ecx]
643 mov ebx, edx
644 rol ebx, 5
645 ror edi, 1
646 add ebx, ebp
647 ror edi, 1
648 add ecx, ebx
649 ; 20_39 34
650 mov ebx, DWORD PTR 8[esp]
651 mov ebp, DWORD PTR 16[esp]
652 xor ebx, ebp
653 mov ebp, DWORD PTR 40[esp]
654 xor ebx, ebp
655 mov ebp, DWORD PTR 60[esp]
656 xor ebx, ebp
657 mov ebp, edx
658 rol ebx, 1
659 xor ebp, edi
660 mov DWORD PTR 8[esp],ebx
661 xor ebp, esi
662 lea ebx, DWORD PTR 1859775393[eax*1+ebx]
663 mov eax, ecx
664 rol eax, 5
665 ror edx, 1
666 add eax, ebp
667 ror edx, 1
668 add ebx, eax
669 ; 20_39 35
670 mov eax, DWORD PTR 12[esp]
671 mov ebp, DWORD PTR 20[esp]
672 xor eax, ebp
673 mov ebp, DWORD PTR 44[esp]
674 xor eax, ebp
675 mov ebp, DWORD PTR [esp]
676 xor eax, ebp
677 mov ebp, ecx
678 rol eax, 1
679 xor ebp, edx
680 mov DWORD PTR 12[esp],eax
681 xor ebp, edi
682 lea eax, DWORD PTR 1859775393[esi*1+eax]
683 mov esi, ebx
684 rol esi, 5
685 ror ecx, 1
686 add esi, ebp
687 ror ecx, 1
688 add eax, esi
689 ; 20_39 36
690 mov esi, DWORD PTR 16[esp]
691 mov ebp, DWORD PTR 24[esp]
692 xor esi, ebp
693 mov ebp, DWORD PTR 48[esp]
694 xor esi, ebp
695 mov ebp, DWORD PTR 4[esp]
696 xor esi, ebp
697 mov ebp, ebx
698 rol esi, 1
699 xor ebp, ecx
700 mov DWORD PTR 16[esp],esi
701 xor ebp, edx
702 lea esi, DWORD PTR 1859775393[edi*1+esi]
703 mov edi, eax
704 rol edi, 5
705 ror ebx, 1
706 add edi, ebp
707 ror ebx, 1
708 add esi, edi
709 ; 20_39 37
710 mov edi, DWORD PTR 20[esp]
711 mov ebp, DWORD PTR 28[esp]
712 xor edi, ebp
713 mov ebp, DWORD PTR 52[esp]
714 xor edi, ebp
715 mov ebp, DWORD PTR 8[esp]
716 xor edi, ebp
717 mov ebp, eax
718 rol edi, 1
719 xor ebp, ebx
720 mov DWORD PTR 20[esp],edi
721 xor ebp, ecx
722 lea edi, DWORD PTR 1859775393[edx*1+edi]
723 mov edx, esi
724 rol edx, 5
725 ror eax, 1
726 add edx, ebp
727 ror eax, 1
728 add edi, edx
729 ; 20_39 38
730 mov edx, DWORD PTR 24[esp]
731 mov ebp, DWORD PTR 32[esp]
732 xor edx, ebp
733 mov ebp, DWORD PTR 56[esp]
734 xor edx, ebp
735 mov ebp, DWORD PTR 12[esp]
736 xor edx, ebp
737 mov ebp, esi
738 rol edx, 1
739 xor ebp, eax
740 mov DWORD PTR 24[esp],edx
741 xor ebp, ebx
742 lea edx, DWORD PTR 1859775393[ecx*1+edx]
743 mov ecx, edi
744 rol ecx, 5
745 ror esi, 1
746 add ecx, ebp
747 ror esi, 1
748 add edx, ecx
749 ; 20_39 39
750 mov ecx, DWORD PTR 28[esp]
751 mov ebp, DWORD PTR 36[esp]
752 xor ecx, ebp
753 mov ebp, DWORD PTR 60[esp]
754 xor ecx, ebp
755 mov ebp, DWORD PTR 16[esp]
756 xor ecx, ebp
757 mov ebp, edi
758 rol ecx, 1
759 xor ebp, esi
760 mov DWORD PTR 28[esp],ecx
761 xor ebp, eax
762 lea ecx, DWORD PTR 1859775393[ebx*1+ecx]
763 mov ebx, edx
764 rol ebx, 5
765 ror edi, 1
766 add ebx, ebp
767 ror edi, 1
768 add ecx, ebx
769 ; 40_59 40
770 mov ebx, DWORD PTR 32[esp]
771 mov ebp, DWORD PTR 40[esp]
772 xor ebx, ebp
773 mov ebp, DWORD PTR [esp]
774 xor ebx, ebp
775 mov ebp, DWORD PTR 20[esp]
776 xor ebx, ebp
777 mov ebp, edx
778 rol ebx, 1
779 or ebp, edi
780 mov DWORD PTR 32[esp],ebx
781 and ebp, esi
782 lea ebx, DWORD PTR 2400959708[eax*1+ebx]
783 mov eax, edx
784 ror edx, 1
785 and eax, edi
786 or ebp, eax
787 mov eax, ecx
788 rol eax, 5
789 add ebp, eax
790 mov eax, DWORD PTR 36[esp]
791 add ebx, ebp
792 mov ebp, DWORD PTR 44[esp]
793 xor eax, ebp
794 mov ebp, DWORD PTR 4[esp]
795 xor eax, ebp
796 mov ebp, DWORD PTR 24[esp]
797 ror edx, 1
798 xor eax, ebp
799 rol eax, 1
800 mov ebp, ecx
801 mov DWORD PTR 36[esp],eax
802 or ebp, edx
803 lea eax, DWORD PTR 2400959708[esi*1+eax]
804 mov esi, ecx
805 and ebp, edi
806 and esi, edx
807 or ebp, esi
808 mov esi, ebx
809 rol esi, 5
810 ror ecx, 1
811 add ebp, esi
812 ror ecx, 1
813 add eax, ebp
814 ; 40_59 41
815 ; 40_59 42
816 mov esi, DWORD PTR 40[esp]
817 mov ebp, DWORD PTR 48[esp]
818 xor esi, ebp
819 mov ebp, DWORD PTR 8[esp]
820 xor esi, ebp
821 mov ebp, DWORD PTR 28[esp]
822 xor esi, ebp
823 mov ebp, ebx
824 rol esi, 1
825 or ebp, ecx
826 mov DWORD PTR 40[esp],esi
827 and ebp, edx
828 lea esi, DWORD PTR 2400959708[edi*1+esi]
829 mov edi, ebx
830 ror ebx, 1
831 and edi, ecx
832 or ebp, edi
833 mov edi, eax
834 rol edi, 5
835 add ebp, edi
836 mov edi, DWORD PTR 44[esp]
837 add esi, ebp
838 mov ebp, DWORD PTR 52[esp]
839 xor edi, ebp
840 mov ebp, DWORD PTR 12[esp]
841 xor edi, ebp
842 mov ebp, DWORD PTR 32[esp]
843 ror ebx, 1
844 xor edi, ebp
845 rol edi, 1
846 mov ebp, eax
847 mov DWORD PTR 44[esp],edi
848 or ebp, ebx
849 lea edi, DWORD PTR 2400959708[edx*1+edi]
850 mov edx, eax
851 and ebp, ecx
852 and edx, ebx
853 or ebp, edx
854 mov edx, esi
855 rol edx, 5
856 ror eax, 1
857 add ebp, edx
858 ror eax, 1
859 add edi, ebp
860 ; 40_59 43
861 ; 40_59 44
862 mov edx, DWORD PTR 48[esp]
863 mov ebp, DWORD PTR 56[esp]
864 xor edx, ebp
865 mov ebp, DWORD PTR 16[esp]
866 xor edx, ebp
867 mov ebp, DWORD PTR 36[esp]
868 xor edx, ebp
869 mov ebp, esi
870 rol edx, 1
871 or ebp, eax
872 mov DWORD PTR 48[esp],edx
873 and ebp, ebx
874 lea edx, DWORD PTR 2400959708[ecx*1+edx]
875 mov ecx, esi
876 ror esi, 1
877 and ecx, eax
878 or ebp, ecx
879 mov ecx, edi
880 rol ecx, 5
881 add ebp, ecx
882 mov ecx, DWORD PTR 52[esp]
883 add edx, ebp
884 mov ebp, DWORD PTR 60[esp]
885 xor ecx, ebp
886 mov ebp, DWORD PTR 20[esp]
887 xor ecx, ebp
888 mov ebp, DWORD PTR 40[esp]
889 ror esi, 1
890 xor ecx, ebp
891 rol ecx, 1
892 mov ebp, edi
893 mov DWORD PTR 52[esp],ecx
894 or ebp, esi
895 lea ecx, DWORD PTR 2400959708[ebx*1+ecx]
896 mov ebx, edi
897 and ebp, eax
898 and ebx, esi
899 or ebp, ebx
900 mov ebx, edx
901 rol ebx, 5
902 ror edi, 1
903 add ebp, ebx
904 ror edi, 1
905 add ecx, ebp
906 ; 40_59 45
907 ; 40_59 46
908 mov ebx, DWORD PTR 56[esp]
909 mov ebp, DWORD PTR [esp]
910 xor ebx, ebp
911 mov ebp, DWORD PTR 24[esp]
912 xor ebx, ebp
913 mov ebp, DWORD PTR 44[esp]
914 xor ebx, ebp
915 mov ebp, edx
916 rol ebx, 1
917 or ebp, edi
918 mov DWORD PTR 56[esp],ebx
919 and ebp, esi
920 lea ebx, DWORD PTR 2400959708[eax*1+ebx]
921 mov eax, edx
922 ror edx, 1
923 and eax, edi
924 or ebp, eax
925 mov eax, ecx
926 rol eax, 5
927 add ebp, eax
928 mov eax, DWORD PTR 60[esp]
929 add ebx, ebp
930 mov ebp, DWORD PTR 4[esp]
931 xor eax, ebp
932 mov ebp, DWORD PTR 28[esp]
933 xor eax, ebp
934 mov ebp, DWORD PTR 48[esp]
935 ror edx, 1
936 xor eax, ebp
937 rol eax, 1
938 mov ebp, ecx
939 mov DWORD PTR 60[esp],eax
940 or ebp, edx
941 lea eax, DWORD PTR 2400959708[esi*1+eax]
942 mov esi, ecx
943 and ebp, edi
944 and esi, edx
945 or ebp, esi
946 mov esi, ebx
947 rol esi, 5
948 ror ecx, 1
949 add ebp, esi
950 ror ecx, 1
951 add eax, ebp
952 ; 40_59 47
953 ; 40_59 48
954 mov esi, DWORD PTR [esp]
955 mov ebp, DWORD PTR 8[esp]
956 xor esi, ebp
957 mov ebp, DWORD PTR 32[esp]
958 xor esi, ebp
959 mov ebp, DWORD PTR 52[esp]
960 xor esi, ebp
961 mov ebp, ebx
962 rol esi, 1
963 or ebp, ecx
964 mov DWORD PTR [esp],esi
965 and ebp, edx
966 lea esi, DWORD PTR 2400959708[edi*1+esi]
967 mov edi, ebx
968 ror ebx, 1
969 and edi, ecx
970 or ebp, edi
971 mov edi, eax
972 rol edi, 5
973 add ebp, edi
974 mov edi, DWORD PTR 4[esp]
975 add esi, ebp
976 mov ebp, DWORD PTR 12[esp]
977 xor edi, ebp
978 mov ebp, DWORD PTR 36[esp]
979 xor edi, ebp
980 mov ebp, DWORD PTR 56[esp]
981 ror ebx, 1
982 xor edi, ebp
983 rol edi, 1
984 mov ebp, eax
985 mov DWORD PTR 4[esp],edi
986 or ebp, ebx
987 lea edi, DWORD PTR 2400959708[edx*1+edi]
988 mov edx, eax
989 and ebp, ecx
990 and edx, ebx
991 or ebp, edx
992 mov edx, esi
993 rol edx, 5
994 ror eax, 1
995 add ebp, edx
996 ror eax, 1
997 add edi, ebp
998 ; 40_59 49
999 ; 40_59 50
1000 mov edx, DWORD PTR 8[esp]
1001 mov ebp, DWORD PTR 16[esp]
1002 xor edx, ebp
1003 mov ebp, DWORD PTR 40[esp]
1004 xor edx, ebp
1005 mov ebp, DWORD PTR 60[esp]
1006 xor edx, ebp
1007 mov ebp, esi
1008 rol edx, 1
1009 or ebp, eax
1010 mov DWORD PTR 8[esp],edx
1011 and ebp, ebx
1012 lea edx, DWORD PTR 2400959708[ecx*1+edx]
1013 mov ecx, esi
1014 ror esi, 1
1015 and ecx, eax
1016 or ebp, ecx
1017 mov ecx, edi
1018 rol ecx, 5
1019 add ebp, ecx
1020 mov ecx, DWORD PTR 12[esp]
1021 add edx, ebp
1022 mov ebp, DWORD PTR 20[esp]
1023 xor ecx, ebp
1024 mov ebp, DWORD PTR 44[esp]
1025 xor ecx, ebp
1026 mov ebp, DWORD PTR [esp]
1027 ror esi, 1
1028 xor ecx, ebp
1029 rol ecx, 1
1030 mov ebp, edi
1031 mov DWORD PTR 12[esp],ecx
1032 or ebp, esi
1033 lea ecx, DWORD PTR 2400959708[ebx*1+ecx]
1034 mov ebx, edi
1035 and ebp, eax
1036 and ebx, esi
1037 or ebp, ebx
1038 mov ebx, edx
1039 rol ebx, 5
1040 ror edi, 1
1041 add ebp, ebx
1042 ror edi, 1
1043 add ecx, ebp
1044 ; 40_59 51
1045 ; 40_59 52
1046 mov ebx, DWORD PTR 16[esp]
1047 mov ebp, DWORD PTR 24[esp]
1048 xor ebx, ebp
1049 mov ebp, DWORD PTR 48[esp]
1050 xor ebx, ebp
1051 mov ebp, DWORD PTR 4[esp]
1052 xor ebx, ebp
1053 mov ebp, edx
1054 rol ebx, 1
1055 or ebp, edi
1056 mov DWORD PTR 16[esp],ebx
1057 and ebp, esi
1058 lea ebx, DWORD PTR 2400959708[eax*1+ebx]
1059 mov eax, edx
1060 ror edx, 1
1061 and eax, edi
1062 or ebp, eax
1063 mov eax, ecx
1064 rol eax, 5
1065 add ebp, eax
1066 mov eax, DWORD PTR 20[esp]
1067 add ebx, ebp
1068 mov ebp, DWORD PTR 28[esp]
1069 xor eax, ebp
1070 mov ebp, DWORD PTR 52[esp]
1071 xor eax, ebp
1072 mov ebp, DWORD PTR 8[esp]
1073 ror edx, 1
1074 xor eax, ebp
1075 rol eax, 1
1076 mov ebp, ecx
1077 mov DWORD PTR 20[esp],eax
1078 or ebp, edx
1079 lea eax, DWORD PTR 2400959708[esi*1+eax]
1080 mov esi, ecx
1081 and ebp, edi
1082 and esi, edx
1083 or ebp, esi
1084 mov esi, ebx
1085 rol esi, 5
1086 ror ecx, 1
1087 add ebp, esi
1088 ror ecx, 1
1089 add eax, ebp
1090 ; 40_59 53
1091 ; 40_59 54
1092 mov esi, DWORD PTR 24[esp]
1093 mov ebp, DWORD PTR 32[esp]
1094 xor esi, ebp
1095 mov ebp, DWORD PTR 56[esp]
1096 xor esi, ebp
1097 mov ebp, DWORD PTR 12[esp]
1098 xor esi, ebp
1099 mov ebp, ebx
1100 rol esi, 1
1101 or ebp, ecx
1102 mov DWORD PTR 24[esp],esi
1103 and ebp, edx
1104 lea esi, DWORD PTR 2400959708[edi*1+esi]
1105 mov edi, ebx
1106 ror ebx, 1
1107 and edi, ecx
1108 or ebp, edi
1109 mov edi, eax
1110 rol edi, 5
1111 add ebp, edi
1112 mov edi, DWORD PTR 28[esp]
1113 add esi, ebp
1114 mov ebp, DWORD PTR 36[esp]
1115 xor edi, ebp
1116 mov ebp, DWORD PTR 60[esp]
1117 xor edi, ebp
1118 mov ebp, DWORD PTR 16[esp]
1119 ror ebx, 1
1120 xor edi, ebp
1121 rol edi, 1
1122 mov ebp, eax
1123 mov DWORD PTR 28[esp],edi
1124 or ebp, ebx
1125 lea edi, DWORD PTR 2400959708[edx*1+edi]
1126 mov edx, eax
1127 and ebp, ecx
1128 and edx, ebx
1129 or ebp, edx
1130 mov edx, esi
1131 rol edx, 5
1132 ror eax, 1
1133 add ebp, edx
1134 ror eax, 1
1135 add edi, ebp
1136 ; 40_59 55
1137 ; 40_59 56
1138 mov edx, DWORD PTR 32[esp]
1139 mov ebp, DWORD PTR 40[esp]
1140 xor edx, ebp
1141 mov ebp, DWORD PTR [esp]
1142 xor edx, ebp
1143 mov ebp, DWORD PTR 20[esp]
1144 xor edx, ebp
1145 mov ebp, esi
1146 rol edx, 1
1147 or ebp, eax
1148 mov DWORD PTR 32[esp],edx
1149 and ebp, ebx
1150 lea edx, DWORD PTR 2400959708[ecx*1+edx]
1151 mov ecx, esi
1152 ror esi, 1
1153 and ecx, eax
1154 or ebp, ecx
1155 mov ecx, edi
1156 rol ecx, 5
1157 add ebp, ecx
1158 mov ecx, DWORD PTR 36[esp]
1159 add edx, ebp
1160 mov ebp, DWORD PTR 44[esp]
1161 xor ecx, ebp
1162 mov ebp, DWORD PTR 4[esp]
1163 xor ecx, ebp
1164 mov ebp, DWORD PTR 24[esp]
1165 ror esi, 1
1166 xor ecx, ebp
1167 rol ecx, 1
1168 mov ebp, edi
1169 mov DWORD PTR 36[esp],ecx
1170 or ebp, esi
1171 lea ecx, DWORD PTR 2400959708[ebx*1+ecx]
1172 mov ebx, edi
1173 and ebp, eax
1174 and ebx, esi
1175 or ebp, ebx
1176 mov ebx, edx
1177 rol ebx, 5
1178 ror edi, 1
1179 add ebp, ebx
1180 ror edi, 1
1181 add ecx, ebp
1182 ; 40_59 57
1183 ; 40_59 58
1184 mov ebx, DWORD PTR 40[esp]
1185 mov ebp, DWORD PTR 48[esp]
1186 xor ebx, ebp
1187 mov ebp, DWORD PTR 8[esp]
1188 xor ebx, ebp
1189 mov ebp, DWORD PTR 28[esp]
1190 xor ebx, ebp
1191 mov ebp, edx
1192 rol ebx, 1
1193 or ebp, edi
1194 mov DWORD PTR 40[esp],ebx
1195 and ebp, esi
1196 lea ebx, DWORD PTR 2400959708[eax*1+ebx]
1197 mov eax, edx
1198 ror edx, 1
1199 and eax, edi
1200 or ebp, eax
1201 mov eax, ecx
1202 rol eax, 5
1203 add ebp, eax
1204 mov eax, DWORD PTR 44[esp]
1205 add ebx, ebp
1206 mov ebp, DWORD PTR 52[esp]
1207 xor eax, ebp
1208 mov ebp, DWORD PTR 12[esp]
1209 xor eax, ebp
1210 mov ebp, DWORD PTR 32[esp]
1211 ror edx, 1
1212 xor eax, ebp
1213 rol eax, 1
1214 mov ebp, ecx
1215 mov DWORD PTR 44[esp],eax
1216 or ebp, edx
1217 lea eax, DWORD PTR 2400959708[esi*1+eax]
1218 mov esi, ecx
1219 and ebp, edi
1220 and esi, edx
1221 or ebp, esi
1222 mov esi, ebx
1223 rol esi, 5
1224 ror ecx, 1
1225 add ebp, esi
1226 ror ecx, 1
1227 add eax, ebp
1228 ; 40_59 59
1229 ; 20_39 60
1230 mov esi, DWORD PTR 48[esp]
1231 mov ebp, DWORD PTR 56[esp]
1232 xor esi, ebp
1233 mov ebp, DWORD PTR 16[esp]
1234 xor esi, ebp
1235 mov ebp, DWORD PTR 36[esp]
1236 xor esi, ebp
1237 mov ebp, ebx
1238 rol esi, 1
1239 xor ebp, ecx
1240 mov DWORD PTR 48[esp],esi
1241 xor ebp, edx
1242 lea esi, DWORD PTR 3395469782[edi*1+esi]
1243 mov edi, eax
1244 rol edi, 5
1245 ror ebx, 1
1246 add edi, ebp
1247 ror ebx, 1
1248 add esi, edi
1249 ; 20_39 61
1250 mov edi, DWORD PTR 52[esp]
1251 mov ebp, DWORD PTR 60[esp]
1252 xor edi, ebp
1253 mov ebp, DWORD PTR 20[esp]
1254 xor edi, ebp
1255 mov ebp, DWORD PTR 40[esp]
1256 xor edi, ebp
1257 mov ebp, eax
1258 rol edi, 1
1259 xor ebp, ebx
1260 mov DWORD PTR 52[esp],edi
1261 xor ebp, ecx
1262 lea edi, DWORD PTR 3395469782[edx*1+edi]
1263 mov edx, esi
1264 rol edx, 5
1265 ror eax, 1
1266 add edx, ebp
1267 ror eax, 1
1268 add edi, edx
1269 ; 20_39 62
1270 mov edx, DWORD PTR 56[esp]
1271 mov ebp, DWORD PTR [esp]
1272 xor edx, ebp
1273 mov ebp, DWORD PTR 24[esp]
1274 xor edx, ebp
1275 mov ebp, DWORD PTR 44[esp]
1276 xor edx, ebp
1277 mov ebp, esi
1278 rol edx, 1
1279 xor ebp, eax
1280 mov DWORD PTR 56[esp],edx
1281 xor ebp, ebx
1282 lea edx, DWORD PTR 3395469782[ecx*1+edx]
1283 mov ecx, edi
1284 rol ecx, 5
1285 ror esi, 1
1286 add ecx, ebp
1287 ror esi, 1
1288 add edx, ecx
1289 ; 20_39 63
1290 mov ecx, DWORD PTR 60[esp]
1291 mov ebp, DWORD PTR 4[esp]
1292 xor ecx, ebp
1293 mov ebp, DWORD PTR 28[esp]
1294 xor ecx, ebp
1295 mov ebp, DWORD PTR 48[esp]
1296 xor ecx, ebp
1297 mov ebp, edi
1298 rol ecx, 1
1299 xor ebp, esi
1300 mov DWORD PTR 60[esp],ecx
1301 xor ebp, eax
1302 lea ecx, DWORD PTR 3395469782[ebx*1+ecx]
1303 mov ebx, edx
1304 rol ebx, 5
1305 ror edi, 1
1306 add ebx, ebp
1307 ror edi, 1
1308 add ecx, ebx
1309 ; 20_39 64
1310 mov ebx, DWORD PTR [esp]
1311 mov ebp, DWORD PTR 8[esp]
1312 xor ebx, ebp
1313 mov ebp, DWORD PTR 32[esp]
1314 xor ebx, ebp
1315 mov ebp, DWORD PTR 52[esp]
1316 xor ebx, ebp
1317 mov ebp, edx
1318 rol ebx, 1
1319 xor ebp, edi
1320 mov DWORD PTR [esp],ebx
1321 xor ebp, esi
1322 lea ebx, DWORD PTR 3395469782[eax*1+ebx]
1323 mov eax, ecx
1324 rol eax, 5
1325 ror edx, 1
1326 add eax, ebp
1327 ror edx, 1
1328 add ebx, eax
1329 ; 20_39 65
1330 mov eax, DWORD PTR 4[esp]
1331 mov ebp, DWORD PTR 12[esp]
1332 xor eax, ebp
1333 mov ebp, DWORD PTR 36[esp]
1334 xor eax, ebp
1335 mov ebp, DWORD PTR 56[esp]
1336 xor eax, ebp
1337 mov ebp, ecx
1338 rol eax, 1
1339 xor ebp, edx
1340 mov DWORD PTR 4[esp],eax
1341 xor ebp, edi
1342 lea eax, DWORD PTR 3395469782[esi*1+eax]
1343 mov esi, ebx
1344 rol esi, 5
1345 ror ecx, 1
1346 add esi, ebp
1347 ror ecx, 1
1348 add eax, esi
1349 ; 20_39 66
1350 mov esi, DWORD PTR 8[esp]
1351 mov ebp, DWORD PTR 16[esp]
1352 xor esi, ebp
1353 mov ebp, DWORD PTR 40[esp]
1354 xor esi, ebp
1355 mov ebp, DWORD PTR 60[esp]
1356 xor esi, ebp
1357 mov ebp, ebx
1358 rol esi, 1
1359 xor ebp, ecx
1360 mov DWORD PTR 8[esp],esi
1361 xor ebp, edx
1362 lea esi, DWORD PTR 3395469782[edi*1+esi]
1363 mov edi, eax
1364 rol edi, 5
1365 ror ebx, 1
1366 add edi, ebp
1367 ror ebx, 1
1368 add esi, edi
1369 ; 20_39 67
1370 mov edi, DWORD PTR 12[esp]
1371 mov ebp, DWORD PTR 20[esp]
1372 xor edi, ebp
1373 mov ebp, DWORD PTR 44[esp]
1374 xor edi, ebp
1375 mov ebp, DWORD PTR [esp]
1376 xor edi, ebp
1377 mov ebp, eax
1378 rol edi, 1
1379 xor ebp, ebx
1380 mov DWORD PTR 12[esp],edi
1381 xor ebp, ecx
1382 lea edi, DWORD PTR 3395469782[edx*1+edi]
1383 mov edx, esi
1384 rol edx, 5
1385 ror eax, 1
1386 add edx, ebp
1387 ror eax, 1
1388 add edi, edx
1389 ; 20_39 68
1390 mov edx, DWORD PTR 16[esp]
1391 mov ebp, DWORD PTR 24[esp]
1392 xor edx, ebp
1393 mov ebp, DWORD PTR 48[esp]
1394 xor edx, ebp
1395 mov ebp, DWORD PTR 4[esp]
1396 xor edx, ebp
1397 mov ebp, esi
1398 rol edx, 1
1399 xor ebp, eax
1400 mov DWORD PTR 16[esp],edx
1401 xor ebp, ebx
1402 lea edx, DWORD PTR 3395469782[ecx*1+edx]
1403 mov ecx, edi
1404 rol ecx, 5
1405 ror esi, 1
1406 add ecx, ebp
1407 ror esi, 1
1408 add edx, ecx
1409 ; 20_39 69
1410 mov ecx, DWORD PTR 20[esp]
1411 mov ebp, DWORD PTR 28[esp]
1412 xor ecx, ebp
1413 mov ebp, DWORD PTR 52[esp]
1414 xor ecx, ebp
1415 mov ebp, DWORD PTR 8[esp]
1416 xor ecx, ebp
1417 mov ebp, edi
1418 rol ecx, 1
1419 xor ebp, esi
1420 mov DWORD PTR 20[esp],ecx
1421 xor ebp, eax
1422 lea ecx, DWORD PTR 3395469782[ebx*1+ecx]
1423 mov ebx, edx
1424 rol ebx, 5
1425 ror edi, 1
1426 add ebx, ebp
1427 ror edi, 1
1428 add ecx, ebx
1429 ; 20_39 70
1430 mov ebx, DWORD PTR 24[esp]
1431 mov ebp, DWORD PTR 32[esp]
1432 xor ebx, ebp
1433 mov ebp, DWORD PTR 56[esp]
1434 xor ebx, ebp
1435 mov ebp, DWORD PTR 12[esp]
1436 xor ebx, ebp
1437 mov ebp, edx
1438 rol ebx, 1
1439 xor ebp, edi
1440 mov DWORD PTR 24[esp],ebx
1441 xor ebp, esi
1442 lea ebx, DWORD PTR 3395469782[eax*1+ebx]
1443 mov eax, ecx
1444 rol eax, 5
1445 ror edx, 1
1446 add eax, ebp
1447 ror edx, 1
1448 add ebx, eax
1449 ; 20_39 71
1450 mov eax, DWORD PTR 28[esp]
1451 mov ebp, DWORD PTR 36[esp]
1452 xor eax, ebp
1453 mov ebp, DWORD PTR 60[esp]
1454 xor eax, ebp
1455 mov ebp, DWORD PTR 16[esp]
1456 xor eax, ebp
1457 mov ebp, ecx
1458 rol eax, 1
1459 xor ebp, edx
1460 mov DWORD PTR 28[esp],eax
1461 xor ebp, edi
1462 lea eax, DWORD PTR 3395469782[esi*1+eax]
1463 mov esi, ebx
1464 rol esi, 5
1465 ror ecx, 1
1466 add esi, ebp
1467 ror ecx, 1
1468 add eax, esi
1469 ; 20_39 72
1470 mov esi, DWORD PTR 32[esp]
1471 mov ebp, DWORD PTR 40[esp]
1472 xor esi, ebp
1473 mov ebp, DWORD PTR [esp]
1474 xor esi, ebp
1475 mov ebp, DWORD PTR 20[esp]
1476 xor esi, ebp
1477 mov ebp, ebx
1478 rol esi, 1
1479 xor ebp, ecx
1480 mov DWORD PTR 32[esp],esi
1481 xor ebp, edx
1482 lea esi, DWORD PTR 3395469782[edi*1+esi]
1483 mov edi, eax
1484 rol edi, 5
1485 ror ebx, 1
1486 add edi, ebp
1487 ror ebx, 1
1488 add esi, edi
1489 ; 20_39 73
1490 mov edi, DWORD PTR 36[esp]
1491 mov ebp, DWORD PTR 44[esp]
1492 xor edi, ebp
1493 mov ebp, DWORD PTR 4[esp]
1494 xor edi, ebp
1495 mov ebp, DWORD PTR 24[esp]
1496 xor edi, ebp
1497 mov ebp, eax
1498 rol edi, 1
1499 xor ebp, ebx
1500 mov DWORD PTR 36[esp],edi
1501 xor ebp, ecx
1502 lea edi, DWORD PTR 3395469782[edx*1+edi]
1503 mov edx, esi
1504 rol edx, 5
1505 ror eax, 1
1506 add edx, ebp
1507 ror eax, 1
1508 add edi, edx
1509 ; 20_39 74
1510 mov edx, DWORD PTR 40[esp]
1511 mov ebp, DWORD PTR 48[esp]
1512 xor edx, ebp
1513 mov ebp, DWORD PTR 8[esp]
1514 xor edx, ebp
1515 mov ebp, DWORD PTR 28[esp]
1516 xor edx, ebp
1517 mov ebp, esi
1518 rol edx, 1
1519 xor ebp, eax
1520 mov DWORD PTR 40[esp],edx
1521 xor ebp, ebx
1522 lea edx, DWORD PTR 3395469782[ecx*1+edx]
1523 mov ecx, edi
1524 rol ecx, 5
1525 ror esi, 1
1526 add ecx, ebp
1527 ror esi, 1
1528 add edx, ecx
1529 ; 20_39 75
1530 mov ecx, DWORD PTR 44[esp]
1531 mov ebp, DWORD PTR 52[esp]
1532 xor ecx, ebp
1533 mov ebp, DWORD PTR 12[esp]
1534 xor ecx, ebp
1535 mov ebp, DWORD PTR 32[esp]
1536 xor ecx, ebp
1537 mov ebp, edi
1538 rol ecx, 1
1539 xor ebp, esi
1540 mov DWORD PTR 44[esp],ecx
1541 xor ebp, eax
1542 lea ecx, DWORD PTR 3395469782[ebx*1+ecx]
1543 mov ebx, edx
1544 rol ebx, 5
1545 ror edi, 1
1546 add ebx, ebp
1547 ror edi, 1
1548 add ecx, ebx
1549 ; 20_39 76
1550 mov ebx, DWORD PTR 48[esp]
1551 mov ebp, DWORD PTR 56[esp]
1552 xor ebx, ebp
1553 mov ebp, DWORD PTR 16[esp]
1554 xor ebx, ebp
1555 mov ebp, DWORD PTR 36[esp]
1556 xor ebx, ebp
1557 mov ebp, edx
1558 rol ebx, 1
1559 xor ebp, edi
1560 mov DWORD PTR 48[esp],ebx
1561 xor ebp, esi
1562 lea ebx, DWORD PTR 3395469782[eax*1+ebx]
1563 mov eax, ecx
1564 rol eax, 5
1565 ror edx, 1
1566 add eax, ebp
1567 ror edx, 1
1568 add ebx, eax
1569 ; 20_39 77
1570 mov eax, DWORD PTR 52[esp]
1571 mov ebp, DWORD PTR 60[esp]
1572 xor eax, ebp
1573 mov ebp, DWORD PTR 20[esp]
1574 xor eax, ebp
1575 mov ebp, DWORD PTR 40[esp]
1576 xor eax, ebp
1577 mov ebp, ecx
1578 rol eax, 1
1579 xor ebp, edx
1580 mov DWORD PTR 52[esp],eax
1581 xor ebp, edi
1582 lea eax, DWORD PTR 3395469782[esi*1+eax]
1583 mov esi, ebx
1584 rol esi, 5
1585 ror ecx, 1
1586 add esi, ebp
1587 ror ecx, 1
1588 add eax, esi
1589 ; 20_39 78
1590 mov esi, DWORD PTR 56[esp]
1591 mov ebp, DWORD PTR [esp]
1592 xor esi, ebp
1593 mov ebp, DWORD PTR 24[esp]
1594 xor esi, ebp
1595 mov ebp, DWORD PTR 44[esp]
1596 xor esi, ebp
1597 mov ebp, ebx
1598 rol esi, 1
1599 xor ebp, ecx
1600 mov DWORD PTR 56[esp],esi
1601 xor ebp, edx
1602 lea esi, DWORD PTR 3395469782[edi*1+esi]
1603 mov edi, eax
1604 rol edi, 5
1605 ror ebx, 1
1606 add edi, ebp
1607 ror ebx, 1
1608 add esi, edi
1609 ; 20_39 79
1610 mov edi, DWORD PTR 60[esp]
1611 mov ebp, DWORD PTR 4[esp]
1612 xor edi, ebp
1613 mov ebp, DWORD PTR 28[esp]
1614 xor edi, ebp
1615 mov ebp, DWORD PTR 48[esp]
1616 xor edi, ebp
1617 mov ebp, eax
1618 rol edi, 1
1619 xor ebp, ebx
1620 mov DWORD PTR 60[esp],edi
1621 xor ebp, ecx
1622 lea edi, DWORD PTR 3395469782[edx*1+edi]
1623 mov edx, esi
1624 rol edx, 5
1625 add edx, ebp
1626 mov ebp, DWORD PTR 92[esp]
1627 ror eax, 1
1628 add edi, edx
1629 ror eax, 1
1630 ; End processing
1631 ;
1632 mov edx, DWORD PTR 12[ebp]
1633 add edx, ebx
1634 mov ebx, DWORD PTR 4[ebp]
1635 add ebx, esi
1636 mov esi, eax
1637 mov eax, DWORD PTR [ebp]
1638 mov DWORD PTR 12[ebp],edx
1639 add eax, edi
1640 mov edi, DWORD PTR 16[ebp]
1641 add edi, ecx
1642 mov ecx, DWORD PTR 8[ebp]
1643 add ecx, esi
1644 mov DWORD PTR [ebp],eax
1645 mov esi, DWORD PTR 64[esp]
1646 mov DWORD PTR 8[ebp],ecx
1647 add esi, 64
1648 mov eax, DWORD PTR 68[esp]
1649 mov DWORD PTR 16[ebp],edi
1650 cmp eax, esi
1651 mov DWORD PTR 4[ebp],ebx
1652 jl $L001end
1653 mov eax, DWORD PTR [esi]
1654 jmp L000start
1655$L001end:
1656 add esp, 72
1657 pop edi
1658 pop ebx
1659 pop ebp
1660 pop esi
1661 ret
1662_sha1_block_x86 ENDP
1663_TEXT ENDS
1664END
diff --git a/src/lib/libssl/src/crypto/sha/asm/sx86unix.cpp b/src/lib/libssl/src/crypto/sha/asm/sx86unix.cpp
new file mode 100644
index 0000000000..8366664a39
--- /dev/null
+++ b/src/lib/libssl/src/crypto/sha/asm/sx86unix.cpp
@@ -0,0 +1,1948 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define sha1_block_x86 _sha1_block_x86
13
14#endif
15
16#ifdef OUT
17#define OK 1
18#define ALIGN 4
19#endif
20
21#ifdef BSDI
22#define OK 1
23#define ALIGN 4
24#undef SIZE
25#undef TYPE
26#define SIZE(a,b)
27#define TYPE(a,b)
28#endif
29
30#if defined(ELF) || defined(SOL)
31#define OK 1
32#define ALIGN 16
33#endif
34
35#ifndef OK
36You need to define one of
37ELF - elf systems - linux-elf, NetBSD and DG-UX
38OUT - a.out systems - linux-a.out and FreeBSD
39SOL - solaris systems, which are elf with strange comment lines
40BSDI - a.out with a very primative version of as.
41#endif
42
43/* Let the Assembler begin :-) */
44 /* Don't even think of reading this code */
45 /* It was automatically generated by sha1-586.pl */
46 /* Which is a perl program used to generate the x86 assember for */
47 /* any of elf, a.out, BSDI,Win32, or Solaris */
48 /* eric <eay@cryptsoft.com> */
49
50 .file "sha1-586.s"
51 .version "01.01"
52gcc2_compiled.:
53.text
54 .align ALIGN
55.globl sha1_block_x86
56 TYPE(sha1_block_x86,@function)
57sha1_block_x86:
58 pushl %esi
59 pushl %ebp
60 movl 20(%esp), %eax
61 movl 16(%esp), %esi
62 addl %esi, %eax
63 movl 12(%esp), %ebp
64 pushl %ebx
65 subl $64, %eax
66 pushl %edi
67 movl 4(%ebp), %ebx
68 subl $72, %esp
69 movl 12(%ebp), %edx
70 movl 16(%ebp), %edi
71 movl 8(%ebp), %ecx
72 movl %eax, 68(%esp)
73 /* First we need to setup the X array */
74 movl (%esi), %eax
75.L000start:
76 /* First, load the words onto the stack in network byte order */
77.byte 15
78.byte 200 /* bswapl %eax */
79 movl %eax, (%esp)
80 movl 4(%esi), %eax
81.byte 15
82.byte 200 /* bswapl %eax */
83 movl %eax, 4(%esp)
84 movl 8(%esi), %eax
85.byte 15
86.byte 200 /* bswapl %eax */
87 movl %eax, 8(%esp)
88 movl 12(%esi), %eax
89.byte 15
90.byte 200 /* bswapl %eax */
91 movl %eax, 12(%esp)
92 movl 16(%esi), %eax
93.byte 15
94.byte 200 /* bswapl %eax */
95 movl %eax, 16(%esp)
96 movl 20(%esi), %eax
97.byte 15
98.byte 200 /* bswapl %eax */
99 movl %eax, 20(%esp)
100 movl 24(%esi), %eax
101.byte 15
102.byte 200 /* bswapl %eax */
103 movl %eax, 24(%esp)
104 movl 28(%esi), %eax
105.byte 15
106.byte 200 /* bswapl %eax */
107 movl %eax, 28(%esp)
108 movl 32(%esi), %eax
109.byte 15
110.byte 200 /* bswapl %eax */
111 movl %eax, 32(%esp)
112 movl 36(%esi), %eax
113.byte 15
114.byte 200 /* bswapl %eax */
115 movl %eax, 36(%esp)
116 movl 40(%esi), %eax
117.byte 15
118.byte 200 /* bswapl %eax */
119 movl %eax, 40(%esp)
120 movl 44(%esi), %eax
121.byte 15
122.byte 200 /* bswapl %eax */
123 movl %eax, 44(%esp)
124 movl 48(%esi), %eax
125.byte 15
126.byte 200 /* bswapl %eax */
127 movl %eax, 48(%esp)
128 movl 52(%esi), %eax
129.byte 15
130.byte 200 /* bswapl %eax */
131 movl %eax, 52(%esp)
132 movl 56(%esi), %eax
133.byte 15
134.byte 200 /* bswapl %eax */
135 movl %eax, 56(%esp)
136 movl 60(%esi), %eax
137.byte 15
138.byte 200 /* bswapl %eax */
139 movl %eax, 60(%esp)
140 /* We now have the X array on the stack */
141 /* starting at sp-4 */
142 movl %esi, 64(%esp)
143
144 /* Start processing */
145 movl (%ebp), %eax
146 /* 00_15 0 */
147 movl %ecx, %esi
148 movl %eax, %ebp
149 xorl %edx, %esi
150 roll $5, %ebp
151 andl %ebx, %esi
152 addl %edi, %ebp
153.byte 209
154.byte 203 /* rorl $1 %ebx */
155 movl (%esp), %edi
156.byte 209
157.byte 203 /* rorl $1 %ebx */
158 xorl %edx, %esi
159 leal 1518500249(%ebp,%edi,1),%ebp
160 movl %ebx, %edi
161 addl %ebp, %esi
162 xorl %ecx, %edi
163 movl %esi, %ebp
164 andl %eax, %edi
165 roll $5, %ebp
166 addl %edx, %ebp
167 movl 4(%esp), %edx
168.byte 209
169.byte 200 /* rorl $1 %eax */
170 xorl %ecx, %edi
171.byte 209
172.byte 200 /* rorl $1 %eax */
173 leal 1518500249(%ebp,%edx,1),%ebp
174 addl %ebp, %edi
175 /* 00_15 2 */
176 movl %eax, %edx
177 movl %edi, %ebp
178 xorl %ebx, %edx
179 roll $5, %ebp
180 andl %esi, %edx
181 addl %ecx, %ebp
182.byte 209
183.byte 206 /* rorl $1 %esi */
184 movl 8(%esp), %ecx
185.byte 209
186.byte 206 /* rorl $1 %esi */
187 xorl %ebx, %edx
188 leal 1518500249(%ebp,%ecx,1),%ebp
189 movl %esi, %ecx
190 addl %ebp, %edx
191 xorl %eax, %ecx
192 movl %edx, %ebp
193 andl %edi, %ecx
194 roll $5, %ebp
195 addl %ebx, %ebp
196 movl 12(%esp), %ebx
197.byte 209
198.byte 207 /* rorl $1 %edi */
199 xorl %eax, %ecx
200.byte 209
201.byte 207 /* rorl $1 %edi */
202 leal 1518500249(%ebp,%ebx,1),%ebp
203 addl %ebp, %ecx
204 /* 00_15 4 */
205 movl %edi, %ebx
206 movl %ecx, %ebp
207 xorl %esi, %ebx
208 roll $5, %ebp
209 andl %edx, %ebx
210 addl %eax, %ebp
211.byte 209
212.byte 202 /* rorl $1 %edx */
213 movl 16(%esp), %eax
214.byte 209
215.byte 202 /* rorl $1 %edx */
216 xorl %esi, %ebx
217 leal 1518500249(%ebp,%eax,1),%ebp
218 movl %edx, %eax
219 addl %ebp, %ebx
220 xorl %edi, %eax
221 movl %ebx, %ebp
222 andl %ecx, %eax
223 roll $5, %ebp
224 addl %esi, %ebp
225 movl 20(%esp), %esi
226.byte 209
227.byte 201 /* rorl $1 %ecx */
228 xorl %edi, %eax
229.byte 209
230.byte 201 /* rorl $1 %ecx */
231 leal 1518500249(%ebp,%esi,1),%ebp
232 addl %ebp, %eax
233 /* 00_15 6 */
234 movl %ecx, %esi
235 movl %eax, %ebp
236 xorl %edx, %esi
237 roll $5, %ebp
238 andl %ebx, %esi
239 addl %edi, %ebp
240.byte 209
241.byte 203 /* rorl $1 %ebx */
242 movl 24(%esp), %edi
243.byte 209
244.byte 203 /* rorl $1 %ebx */
245 xorl %edx, %esi
246 leal 1518500249(%ebp,%edi,1),%ebp
247 movl %ebx, %edi
248 addl %ebp, %esi
249 xorl %ecx, %edi
250 movl %esi, %ebp
251 andl %eax, %edi
252 roll $5, %ebp
253 addl %edx, %ebp
254 movl 28(%esp), %edx
255.byte 209
256.byte 200 /* rorl $1 %eax */
257 xorl %ecx, %edi
258.byte 209
259.byte 200 /* rorl $1 %eax */
260 leal 1518500249(%ebp,%edx,1),%ebp
261 addl %ebp, %edi
262 /* 00_15 8 */
263 movl %eax, %edx
264 movl %edi, %ebp
265 xorl %ebx, %edx
266 roll $5, %ebp
267 andl %esi, %edx
268 addl %ecx, %ebp
269.byte 209
270.byte 206 /* rorl $1 %esi */
271 movl 32(%esp), %ecx
272.byte 209
273.byte 206 /* rorl $1 %esi */
274 xorl %ebx, %edx
275 leal 1518500249(%ebp,%ecx,1),%ebp
276 movl %esi, %ecx
277 addl %ebp, %edx
278 xorl %eax, %ecx
279 movl %edx, %ebp
280 andl %edi, %ecx
281 roll $5, %ebp
282 addl %ebx, %ebp
283 movl 36(%esp), %ebx
284.byte 209
285.byte 207 /* rorl $1 %edi */
286 xorl %eax, %ecx
287.byte 209
288.byte 207 /* rorl $1 %edi */
289 leal 1518500249(%ebp,%ebx,1),%ebp
290 addl %ebp, %ecx
291 /* 00_15 10 */
292 movl %edi, %ebx
293 movl %ecx, %ebp
294 xorl %esi, %ebx
295 roll $5, %ebp
296 andl %edx, %ebx
297 addl %eax, %ebp
298.byte 209
299.byte 202 /* rorl $1 %edx */
300 movl 40(%esp), %eax
301.byte 209
302.byte 202 /* rorl $1 %edx */
303 xorl %esi, %ebx
304 leal 1518500249(%ebp,%eax,1),%ebp
305 movl %edx, %eax
306 addl %ebp, %ebx
307 xorl %edi, %eax
308 movl %ebx, %ebp
309 andl %ecx, %eax
310 roll $5, %ebp
311 addl %esi, %ebp
312 movl 44(%esp), %esi
313.byte 209
314.byte 201 /* rorl $1 %ecx */
315 xorl %edi, %eax
316.byte 209
317.byte 201 /* rorl $1 %ecx */
318 leal 1518500249(%ebp,%esi,1),%ebp
319 addl %ebp, %eax
320 /* 00_15 12 */
321 movl %ecx, %esi
322 movl %eax, %ebp
323 xorl %edx, %esi
324 roll $5, %ebp
325 andl %ebx, %esi
326 addl %edi, %ebp
327.byte 209
328.byte 203 /* rorl $1 %ebx */
329 movl 48(%esp), %edi
330.byte 209
331.byte 203 /* rorl $1 %ebx */
332 xorl %edx, %esi
333 leal 1518500249(%ebp,%edi,1),%ebp
334 movl %ebx, %edi
335 addl %ebp, %esi
336 xorl %ecx, %edi
337 movl %esi, %ebp
338 andl %eax, %edi
339 roll $5, %ebp
340 addl %edx, %ebp
341 movl 52(%esp), %edx
342.byte 209
343.byte 200 /* rorl $1 %eax */
344 xorl %ecx, %edi
345.byte 209
346.byte 200 /* rorl $1 %eax */
347 leal 1518500249(%ebp,%edx,1),%ebp
348 addl %ebp, %edi
349 /* 00_15 14 */
350 movl %eax, %edx
351 movl %edi, %ebp
352 xorl %ebx, %edx
353 roll $5, %ebp
354 andl %esi, %edx
355 addl %ecx, %ebp
356.byte 209
357.byte 206 /* rorl $1 %esi */
358 movl 56(%esp), %ecx
359.byte 209
360.byte 206 /* rorl $1 %esi */
361 xorl %ebx, %edx
362 leal 1518500249(%ebp,%ecx,1),%ebp
363 movl %esi, %ecx
364 addl %ebp, %edx
365 xorl %eax, %ecx
366 movl %edx, %ebp
367 andl %edi, %ecx
368 roll $5, %ebp
369 addl %ebx, %ebp
370 movl 60(%esp), %ebx
371.byte 209
372.byte 207 /* rorl $1 %edi */
373 xorl %eax, %ecx
374.byte 209
375.byte 207 /* rorl $1 %edi */
376 leal 1518500249(%ebp,%ebx,1),%ebp
377 addl %ebp, %ecx
378 /* 16_19 16 */
379 nop
380 movl (%esp), %ebp
381 movl 8(%esp), %ebx
382 xorl %ebp, %ebx
383 movl 32(%esp), %ebp
384 xorl %ebp, %ebx
385 movl 52(%esp), %ebp
386 xorl %ebp, %ebx
387 movl %edi, %ebp
388.byte 209
389.byte 195 /* roll $1 %ebx */
390 xorl %esi, %ebp
391 movl %ebx, (%esp)
392 andl %edx, %ebp
393 leal 1518500249(%ebx,%eax,1),%ebx
394 xorl %esi, %ebp
395 movl %ecx, %eax
396 addl %ebp, %ebx
397 roll $5, %eax
398.byte 209
399.byte 202 /* rorl $1 %edx */
400 addl %eax, %ebx
401 movl 4(%esp), %eax
402 movl 12(%esp), %ebp
403 xorl %ebp, %eax
404 movl 36(%esp), %ebp
405 xorl %ebp, %eax
406 movl 56(%esp), %ebp
407.byte 209
408.byte 202 /* rorl $1 %edx */
409 xorl %ebp, %eax
410.byte 209
411.byte 192 /* roll $1 %eax */
412 movl %edx, %ebp
413 xorl %edi, %ebp
414 movl %eax, 4(%esp)
415 andl %ecx, %ebp
416 leal 1518500249(%eax,%esi,1),%eax
417 xorl %edi, %ebp
418 movl %ebx, %esi
419 roll $5, %esi
420.byte 209
421.byte 201 /* rorl $1 %ecx */
422 addl %esi, %eax
423.byte 209
424.byte 201 /* rorl $1 %ecx */
425 addl %ebp, %eax
426 /* 16_19 18 */
427 movl 8(%esp), %ebp
428 movl 16(%esp), %esi
429 xorl %ebp, %esi
430 movl 40(%esp), %ebp
431 xorl %ebp, %esi
432 movl 60(%esp), %ebp
433 xorl %ebp, %esi
434 movl %ecx, %ebp
435.byte 209
436.byte 198 /* roll $1 %esi */
437 xorl %edx, %ebp
438 movl %esi, 8(%esp)
439 andl %ebx, %ebp
440 leal 1518500249(%esi,%edi,1),%esi
441 xorl %edx, %ebp
442 movl %eax, %edi
443 addl %ebp, %esi
444 roll $5, %edi
445.byte 209
446.byte 203 /* rorl $1 %ebx */
447 addl %edi, %esi
448 movl 12(%esp), %edi
449 movl 20(%esp), %ebp
450 xorl %ebp, %edi
451 movl 44(%esp), %ebp
452 xorl %ebp, %edi
453 movl (%esp), %ebp
454.byte 209
455.byte 203 /* rorl $1 %ebx */
456 xorl %ebp, %edi
457.byte 209
458.byte 199 /* roll $1 %edi */
459 movl %ebx, %ebp
460 xorl %ecx, %ebp
461 movl %edi, 12(%esp)
462 andl %eax, %ebp
463 leal 1518500249(%edi,%edx,1),%edi
464 xorl %ecx, %ebp
465 movl %esi, %edx
466 roll $5, %edx
467.byte 209
468.byte 200 /* rorl $1 %eax */
469 addl %edx, %edi
470.byte 209
471.byte 200 /* rorl $1 %eax */
472 addl %ebp, %edi
473 /* 20_39 20 */
474 movl 16(%esp), %edx
475 movl 24(%esp), %ebp
476 xorl %ebp, %edx
477 movl 48(%esp), %ebp
478 xorl %ebp, %edx
479 movl 4(%esp), %ebp
480 xorl %ebp, %edx
481 movl %esi, %ebp
482.byte 209
483.byte 194 /* roll $1 %edx */
484 xorl %eax, %ebp
485 movl %edx, 16(%esp)
486 xorl %ebx, %ebp
487 leal 1859775393(%edx,%ecx,1),%edx
488 movl %edi, %ecx
489 roll $5, %ecx
490.byte 209
491.byte 206 /* rorl $1 %esi */
492 addl %ebp, %ecx
493.byte 209
494.byte 206 /* rorl $1 %esi */
495 addl %ecx, %edx
496 /* 20_39 21 */
497 movl 20(%esp), %ecx
498 movl 28(%esp), %ebp
499 xorl %ebp, %ecx
500 movl 52(%esp), %ebp
501 xorl %ebp, %ecx
502 movl 8(%esp), %ebp
503 xorl %ebp, %ecx
504 movl %edi, %ebp
505.byte 209
506.byte 193 /* roll $1 %ecx */
507 xorl %esi, %ebp
508 movl %ecx, 20(%esp)
509 xorl %eax, %ebp
510 leal 1859775393(%ecx,%ebx,1),%ecx
511 movl %edx, %ebx
512 roll $5, %ebx
513.byte 209
514.byte 207 /* rorl $1 %edi */
515 addl %ebp, %ebx
516.byte 209
517.byte 207 /* rorl $1 %edi */
518 addl %ebx, %ecx
519 /* 20_39 22 */
520 movl 24(%esp), %ebx
521 movl 32(%esp), %ebp
522 xorl %ebp, %ebx
523 movl 56(%esp), %ebp
524 xorl %ebp, %ebx
525 movl 12(%esp), %ebp
526 xorl %ebp, %ebx
527 movl %edx, %ebp
528.byte 209
529.byte 195 /* roll $1 %ebx */
530 xorl %edi, %ebp
531 movl %ebx, 24(%esp)
532 xorl %esi, %ebp
533 leal 1859775393(%ebx,%eax,1),%ebx
534 movl %ecx, %eax
535 roll $5, %eax
536.byte 209
537.byte 202 /* rorl $1 %edx */
538 addl %ebp, %eax
539.byte 209
540.byte 202 /* rorl $1 %edx */
541 addl %eax, %ebx
542 /* 20_39 23 */
543 movl 28(%esp), %eax
544 movl 36(%esp), %ebp
545 xorl %ebp, %eax
546 movl 60(%esp), %ebp
547 xorl %ebp, %eax
548 movl 16(%esp), %ebp
549 xorl %ebp, %eax
550 movl %ecx, %ebp
551.byte 209
552.byte 192 /* roll $1 %eax */
553 xorl %edx, %ebp
554 movl %eax, 28(%esp)
555 xorl %edi, %ebp
556 leal 1859775393(%eax,%esi,1),%eax
557 movl %ebx, %esi
558 roll $5, %esi
559.byte 209
560.byte 201 /* rorl $1 %ecx */
561 addl %ebp, %esi
562.byte 209
563.byte 201 /* rorl $1 %ecx */
564 addl %esi, %eax
565 /* 20_39 24 */
566 movl 32(%esp), %esi
567 movl 40(%esp), %ebp
568 xorl %ebp, %esi
569 movl (%esp), %ebp
570 xorl %ebp, %esi
571 movl 20(%esp), %ebp
572 xorl %ebp, %esi
573 movl %ebx, %ebp
574.byte 209
575.byte 198 /* roll $1 %esi */
576 xorl %ecx, %ebp
577 movl %esi, 32(%esp)
578 xorl %edx, %ebp
579 leal 1859775393(%esi,%edi,1),%esi
580 movl %eax, %edi
581 roll $5, %edi
582.byte 209
583.byte 203 /* rorl $1 %ebx */
584 addl %ebp, %edi
585.byte 209
586.byte 203 /* rorl $1 %ebx */
587 addl %edi, %esi
588 /* 20_39 25 */
589 movl 36(%esp), %edi
590 movl 44(%esp), %ebp
591 xorl %ebp, %edi
592 movl 4(%esp), %ebp
593 xorl %ebp, %edi
594 movl 24(%esp), %ebp
595 xorl %ebp, %edi
596 movl %eax, %ebp
597.byte 209
598.byte 199 /* roll $1 %edi */
599 xorl %ebx, %ebp
600 movl %edi, 36(%esp)
601 xorl %ecx, %ebp
602 leal 1859775393(%edi,%edx,1),%edi
603 movl %esi, %edx
604 roll $5, %edx
605.byte 209
606.byte 200 /* rorl $1 %eax */
607 addl %ebp, %edx
608.byte 209
609.byte 200 /* rorl $1 %eax */
610 addl %edx, %edi
611 /* 20_39 26 */
612 movl 40(%esp), %edx
613 movl 48(%esp), %ebp
614 xorl %ebp, %edx
615 movl 8(%esp), %ebp
616 xorl %ebp, %edx
617 movl 28(%esp), %ebp
618 xorl %ebp, %edx
619 movl %esi, %ebp
620.byte 209
621.byte 194 /* roll $1 %edx */
622 xorl %eax, %ebp
623 movl %edx, 40(%esp)
624 xorl %ebx, %ebp
625 leal 1859775393(%edx,%ecx,1),%edx
626 movl %edi, %ecx
627 roll $5, %ecx
628.byte 209
629.byte 206 /* rorl $1 %esi */
630 addl %ebp, %ecx
631.byte 209
632.byte 206 /* rorl $1 %esi */
633 addl %ecx, %edx
634 /* 20_39 27 */
635 movl 44(%esp), %ecx
636 movl 52(%esp), %ebp
637 xorl %ebp, %ecx
638 movl 12(%esp), %ebp
639 xorl %ebp, %ecx
640 movl 32(%esp), %ebp
641 xorl %ebp, %ecx
642 movl %edi, %ebp
643.byte 209
644.byte 193 /* roll $1 %ecx */
645 xorl %esi, %ebp
646 movl %ecx, 44(%esp)
647 xorl %eax, %ebp
648 leal 1859775393(%ecx,%ebx,1),%ecx
649 movl %edx, %ebx
650 roll $5, %ebx
651.byte 209
652.byte 207 /* rorl $1 %edi */
653 addl %ebp, %ebx
654.byte 209
655.byte 207 /* rorl $1 %edi */
656 addl %ebx, %ecx
657 /* 20_39 28 */
658 movl 48(%esp), %ebx
659 movl 56(%esp), %ebp
660 xorl %ebp, %ebx
661 movl 16(%esp), %ebp
662 xorl %ebp, %ebx
663 movl 36(%esp), %ebp
664 xorl %ebp, %ebx
665 movl %edx, %ebp
666.byte 209
667.byte 195 /* roll $1 %ebx */
668 xorl %edi, %ebp
669 movl %ebx, 48(%esp)
670 xorl %esi, %ebp
671 leal 1859775393(%ebx,%eax,1),%ebx
672 movl %ecx, %eax
673 roll $5, %eax
674.byte 209
675.byte 202 /* rorl $1 %edx */
676 addl %ebp, %eax
677.byte 209
678.byte 202 /* rorl $1 %edx */
679 addl %eax, %ebx
680 /* 20_39 29 */
681 movl 52(%esp), %eax
682 movl 60(%esp), %ebp
683 xorl %ebp, %eax
684 movl 20(%esp), %ebp
685 xorl %ebp, %eax
686 movl 40(%esp), %ebp
687 xorl %ebp, %eax
688 movl %ecx, %ebp
689.byte 209
690.byte 192 /* roll $1 %eax */
691 xorl %edx, %ebp
692 movl %eax, 52(%esp)
693 xorl %edi, %ebp
694 leal 1859775393(%eax,%esi,1),%eax
695 movl %ebx, %esi
696 roll $5, %esi
697.byte 209
698.byte 201 /* rorl $1 %ecx */
699 addl %ebp, %esi
700.byte 209
701.byte 201 /* rorl $1 %ecx */
702 addl %esi, %eax
703 /* 20_39 30 */
704 movl 56(%esp), %esi
705 movl (%esp), %ebp
706 xorl %ebp, %esi
707 movl 24(%esp), %ebp
708 xorl %ebp, %esi
709 movl 44(%esp), %ebp
710 xorl %ebp, %esi
711 movl %ebx, %ebp
712.byte 209
713.byte 198 /* roll $1 %esi */
714 xorl %ecx, %ebp
715 movl %esi, 56(%esp)
716 xorl %edx, %ebp
717 leal 1859775393(%esi,%edi,1),%esi
718 movl %eax, %edi
719 roll $5, %edi
720.byte 209
721.byte 203 /* rorl $1 %ebx */
722 addl %ebp, %edi
723.byte 209
724.byte 203 /* rorl $1 %ebx */
725 addl %edi, %esi
726 /* 20_39 31 */
727 movl 60(%esp), %edi
728 movl 4(%esp), %ebp
729 xorl %ebp, %edi
730 movl 28(%esp), %ebp
731 xorl %ebp, %edi
732 movl 48(%esp), %ebp
733 xorl %ebp, %edi
734 movl %eax, %ebp
735.byte 209
736.byte 199 /* roll $1 %edi */
737 xorl %ebx, %ebp
738 movl %edi, 60(%esp)
739 xorl %ecx, %ebp
740 leal 1859775393(%edi,%edx,1),%edi
741 movl %esi, %edx
742 roll $5, %edx
743.byte 209
744.byte 200 /* rorl $1 %eax */
745 addl %ebp, %edx
746.byte 209
747.byte 200 /* rorl $1 %eax */
748 addl %edx, %edi
749 /* 20_39 32 */
750 movl (%esp), %edx
751 movl 8(%esp), %ebp
752 xorl %ebp, %edx
753 movl 32(%esp), %ebp
754 xorl %ebp, %edx
755 movl 52(%esp), %ebp
756 xorl %ebp, %edx
757 movl %esi, %ebp
758.byte 209
759.byte 194 /* roll $1 %edx */
760 xorl %eax, %ebp
761 movl %edx, (%esp)
762 xorl %ebx, %ebp
763 leal 1859775393(%edx,%ecx,1),%edx
764 movl %edi, %ecx
765 roll $5, %ecx
766.byte 209
767.byte 206 /* rorl $1 %esi */
768 addl %ebp, %ecx
769.byte 209
770.byte 206 /* rorl $1 %esi */
771 addl %ecx, %edx
772 /* 20_39 33 */
773 movl 4(%esp), %ecx
774 movl 12(%esp), %ebp
775 xorl %ebp, %ecx
776 movl 36(%esp), %ebp
777 xorl %ebp, %ecx
778 movl 56(%esp), %ebp
779 xorl %ebp, %ecx
780 movl %edi, %ebp
781.byte 209
782.byte 193 /* roll $1 %ecx */
783 xorl %esi, %ebp
784 movl %ecx, 4(%esp)
785 xorl %eax, %ebp
786 leal 1859775393(%ecx,%ebx,1),%ecx
787 movl %edx, %ebx
788 roll $5, %ebx
789.byte 209
790.byte 207 /* rorl $1 %edi */
791 addl %ebp, %ebx
792.byte 209
793.byte 207 /* rorl $1 %edi */
794 addl %ebx, %ecx
795 /* 20_39 34 */
796 movl 8(%esp), %ebx
797 movl 16(%esp), %ebp
798 xorl %ebp, %ebx
799 movl 40(%esp), %ebp
800 xorl %ebp, %ebx
801 movl 60(%esp), %ebp
802 xorl %ebp, %ebx
803 movl %edx, %ebp
804.byte 209
805.byte 195 /* roll $1 %ebx */
806 xorl %edi, %ebp
807 movl %ebx, 8(%esp)
808 xorl %esi, %ebp
809 leal 1859775393(%ebx,%eax,1),%ebx
810 movl %ecx, %eax
811 roll $5, %eax
812.byte 209
813.byte 202 /* rorl $1 %edx */
814 addl %ebp, %eax
815.byte 209
816.byte 202 /* rorl $1 %edx */
817 addl %eax, %ebx
818 /* 20_39 35 */
819 movl 12(%esp), %eax
820 movl 20(%esp), %ebp
821 xorl %ebp, %eax
822 movl 44(%esp), %ebp
823 xorl %ebp, %eax
824 movl (%esp), %ebp
825 xorl %ebp, %eax
826 movl %ecx, %ebp
827.byte 209
828.byte 192 /* roll $1 %eax */
829 xorl %edx, %ebp
830 movl %eax, 12(%esp)
831 xorl %edi, %ebp
832 leal 1859775393(%eax,%esi,1),%eax
833 movl %ebx, %esi
834 roll $5, %esi
835.byte 209
836.byte 201 /* rorl $1 %ecx */
837 addl %ebp, %esi
838.byte 209
839.byte 201 /* rorl $1 %ecx */
840 addl %esi, %eax
841 /* 20_39 36 */
842 movl 16(%esp), %esi
843 movl 24(%esp), %ebp
844 xorl %ebp, %esi
845 movl 48(%esp), %ebp
846 xorl %ebp, %esi
847 movl 4(%esp), %ebp
848 xorl %ebp, %esi
849 movl %ebx, %ebp
850.byte 209
851.byte 198 /* roll $1 %esi */
852 xorl %ecx, %ebp
853 movl %esi, 16(%esp)
854 xorl %edx, %ebp
855 leal 1859775393(%esi,%edi,1),%esi
856 movl %eax, %edi
857 roll $5, %edi
858.byte 209
859.byte 203 /* rorl $1 %ebx */
860 addl %ebp, %edi
861.byte 209
862.byte 203 /* rorl $1 %ebx */
863 addl %edi, %esi
864 /* 20_39 37 */
865 movl 20(%esp), %edi
866 movl 28(%esp), %ebp
867 xorl %ebp, %edi
868 movl 52(%esp), %ebp
869 xorl %ebp, %edi
870 movl 8(%esp), %ebp
871 xorl %ebp, %edi
872 movl %eax, %ebp
873.byte 209
874.byte 199 /* roll $1 %edi */
875 xorl %ebx, %ebp
876 movl %edi, 20(%esp)
877 xorl %ecx, %ebp
878 leal 1859775393(%edi,%edx,1),%edi
879 movl %esi, %edx
880 roll $5, %edx
881.byte 209
882.byte 200 /* rorl $1 %eax */
883 addl %ebp, %edx
884.byte 209
885.byte 200 /* rorl $1 %eax */
886 addl %edx, %edi
887 /* 20_39 38 */
888 movl 24(%esp), %edx
889 movl 32(%esp), %ebp
890 xorl %ebp, %edx
891 movl 56(%esp), %ebp
892 xorl %ebp, %edx
893 movl 12(%esp), %ebp
894 xorl %ebp, %edx
895 movl %esi, %ebp
896.byte 209
897.byte 194 /* roll $1 %edx */
898 xorl %eax, %ebp
899 movl %edx, 24(%esp)
900 xorl %ebx, %ebp
901 leal 1859775393(%edx,%ecx,1),%edx
902 movl %edi, %ecx
903 roll $5, %ecx
904.byte 209
905.byte 206 /* rorl $1 %esi */
906 addl %ebp, %ecx
907.byte 209
908.byte 206 /* rorl $1 %esi */
909 addl %ecx, %edx
910 /* 20_39 39 */
911 movl 28(%esp), %ecx
912 movl 36(%esp), %ebp
913 xorl %ebp, %ecx
914 movl 60(%esp), %ebp
915 xorl %ebp, %ecx
916 movl 16(%esp), %ebp
917 xorl %ebp, %ecx
918 movl %edi, %ebp
919.byte 209
920.byte 193 /* roll $1 %ecx */
921 xorl %esi, %ebp
922 movl %ecx, 28(%esp)
923 xorl %eax, %ebp
924 leal 1859775393(%ecx,%ebx,1),%ecx
925 movl %edx, %ebx
926 roll $5, %ebx
927.byte 209
928.byte 207 /* rorl $1 %edi */
929 addl %ebp, %ebx
930.byte 209
931.byte 207 /* rorl $1 %edi */
932 addl %ebx, %ecx
933 /* 40_59 40 */
934 movl 32(%esp), %ebx
935 movl 40(%esp), %ebp
936 xorl %ebp, %ebx
937 movl (%esp), %ebp
938 xorl %ebp, %ebx
939 movl 20(%esp), %ebp
940 xorl %ebp, %ebx
941 movl %edx, %ebp
942.byte 209
943.byte 195 /* roll $1 %ebx */
944 orl %edi, %ebp
945 movl %ebx, 32(%esp)
946 andl %esi, %ebp
947 leal 2400959708(%ebx,%eax,1),%ebx
948 movl %edx, %eax
949.byte 209
950.byte 202 /* rorl $1 %edx */
951 andl %edi, %eax
952 orl %eax, %ebp
953 movl %ecx, %eax
954 roll $5, %eax
955 addl %eax, %ebp
956 movl 36(%esp), %eax
957 addl %ebp, %ebx
958 movl 44(%esp), %ebp
959 xorl %ebp, %eax
960 movl 4(%esp), %ebp
961 xorl %ebp, %eax
962 movl 24(%esp), %ebp
963.byte 209
964.byte 202 /* rorl $1 %edx */
965 xorl %ebp, %eax
966.byte 209
967.byte 192 /* roll $1 %eax */
968 movl %ecx, %ebp
969 movl %eax, 36(%esp)
970 orl %edx, %ebp
971 leal 2400959708(%eax,%esi,1),%eax
972 movl %ecx, %esi
973 andl %edi, %ebp
974 andl %edx, %esi
975 orl %esi, %ebp
976 movl %ebx, %esi
977 roll $5, %esi
978.byte 209
979.byte 201 /* rorl $1 %ecx */
980 addl %esi, %ebp
981.byte 209
982.byte 201 /* rorl $1 %ecx */
983 addl %ebp, %eax
984 /* 40_59 41 */
985 /* 40_59 42 */
986 movl 40(%esp), %esi
987 movl 48(%esp), %ebp
988 xorl %ebp, %esi
989 movl 8(%esp), %ebp
990 xorl %ebp, %esi
991 movl 28(%esp), %ebp
992 xorl %ebp, %esi
993 movl %ebx, %ebp
994.byte 209
995.byte 198 /* roll $1 %esi */
996 orl %ecx, %ebp
997 movl %esi, 40(%esp)
998 andl %edx, %ebp
999 leal 2400959708(%esi,%edi,1),%esi
1000 movl %ebx, %edi
1001.byte 209
1002.byte 203 /* rorl $1 %ebx */
1003 andl %ecx, %edi
1004 orl %edi, %ebp
1005 movl %eax, %edi
1006 roll $5, %edi
1007 addl %edi, %ebp
1008 movl 44(%esp), %edi
1009 addl %ebp, %esi
1010 movl 52(%esp), %ebp
1011 xorl %ebp, %edi
1012 movl 12(%esp), %ebp
1013 xorl %ebp, %edi
1014 movl 32(%esp), %ebp
1015.byte 209
1016.byte 203 /* rorl $1 %ebx */
1017 xorl %ebp, %edi
1018.byte 209
1019.byte 199 /* roll $1 %edi */
1020 movl %eax, %ebp
1021 movl %edi, 44(%esp)
1022 orl %ebx, %ebp
1023 leal 2400959708(%edi,%edx,1),%edi
1024 movl %eax, %edx
1025 andl %ecx, %ebp
1026 andl %ebx, %edx
1027 orl %edx, %ebp
1028 movl %esi, %edx
1029 roll $5, %edx
1030.byte 209
1031.byte 200 /* rorl $1 %eax */
1032 addl %edx, %ebp
1033.byte 209
1034.byte 200 /* rorl $1 %eax */
1035 addl %ebp, %edi
1036 /* 40_59 43 */
1037 /* 40_59 44 */
1038 movl 48(%esp), %edx
1039 movl 56(%esp), %ebp
1040 xorl %ebp, %edx
1041 movl 16(%esp), %ebp
1042 xorl %ebp, %edx
1043 movl 36(%esp), %ebp
1044 xorl %ebp, %edx
1045 movl %esi, %ebp
1046.byte 209
1047.byte 194 /* roll $1 %edx */
1048 orl %eax, %ebp
1049 movl %edx, 48(%esp)
1050 andl %ebx, %ebp
1051 leal 2400959708(%edx,%ecx,1),%edx
1052 movl %esi, %ecx
1053.byte 209
1054.byte 206 /* rorl $1 %esi */
1055 andl %eax, %ecx
1056 orl %ecx, %ebp
1057 movl %edi, %ecx
1058 roll $5, %ecx
1059 addl %ecx, %ebp
1060 movl 52(%esp), %ecx
1061 addl %ebp, %edx
1062 movl 60(%esp), %ebp
1063 xorl %ebp, %ecx
1064 movl 20(%esp), %ebp
1065 xorl %ebp, %ecx
1066 movl 40(%esp), %ebp
1067.byte 209
1068.byte 206 /* rorl $1 %esi */
1069 xorl %ebp, %ecx
1070.byte 209
1071.byte 193 /* roll $1 %ecx */
1072 movl %edi, %ebp
1073 movl %ecx, 52(%esp)
1074 orl %esi, %ebp
1075 leal 2400959708(%ecx,%ebx,1),%ecx
1076 movl %edi, %ebx
1077 andl %eax, %ebp
1078 andl %esi, %ebx
1079 orl %ebx, %ebp
1080 movl %edx, %ebx
1081 roll $5, %ebx
1082.byte 209
1083.byte 207 /* rorl $1 %edi */
1084 addl %ebx, %ebp
1085.byte 209
1086.byte 207 /* rorl $1 %edi */
1087 addl %ebp, %ecx
1088 /* 40_59 45 */
1089 /* 40_59 46 */
1090 movl 56(%esp), %ebx
1091 movl (%esp), %ebp
1092 xorl %ebp, %ebx
1093 movl 24(%esp), %ebp
1094 xorl %ebp, %ebx
1095 movl 44(%esp), %ebp
1096 xorl %ebp, %ebx
1097 movl %edx, %ebp
1098.byte 209
1099.byte 195 /* roll $1 %ebx */
1100 orl %edi, %ebp
1101 movl %ebx, 56(%esp)
1102 andl %esi, %ebp
1103 leal 2400959708(%ebx,%eax,1),%ebx
1104 movl %edx, %eax
1105.byte 209
1106.byte 202 /* rorl $1 %edx */
1107 andl %edi, %eax
1108 orl %eax, %ebp
1109 movl %ecx, %eax
1110 roll $5, %eax
1111 addl %eax, %ebp
1112 movl 60(%esp), %eax
1113 addl %ebp, %ebx
1114 movl 4(%esp), %ebp
1115 xorl %ebp, %eax
1116 movl 28(%esp), %ebp
1117 xorl %ebp, %eax
1118 movl 48(%esp), %ebp
1119.byte 209
1120.byte 202 /* rorl $1 %edx */
1121 xorl %ebp, %eax
1122.byte 209
1123.byte 192 /* roll $1 %eax */
1124 movl %ecx, %ebp
1125 movl %eax, 60(%esp)
1126 orl %edx, %ebp
1127 leal 2400959708(%eax,%esi,1),%eax
1128 movl %ecx, %esi
1129 andl %edi, %ebp
1130 andl %edx, %esi
1131 orl %esi, %ebp
1132 movl %ebx, %esi
1133 roll $5, %esi
1134.byte 209
1135.byte 201 /* rorl $1 %ecx */
1136 addl %esi, %ebp
1137.byte 209
1138.byte 201 /* rorl $1 %ecx */
1139 addl %ebp, %eax
1140 /* 40_59 47 */
1141 /* 40_59 48 */
1142 movl (%esp), %esi
1143 movl 8(%esp), %ebp
1144 xorl %ebp, %esi
1145 movl 32(%esp), %ebp
1146 xorl %ebp, %esi
1147 movl 52(%esp), %ebp
1148 xorl %ebp, %esi
1149 movl %ebx, %ebp
1150.byte 209
1151.byte 198 /* roll $1 %esi */
1152 orl %ecx, %ebp
1153 movl %esi, (%esp)
1154 andl %edx, %ebp
1155 leal 2400959708(%esi,%edi,1),%esi
1156 movl %ebx, %edi
1157.byte 209
1158.byte 203 /* rorl $1 %ebx */
1159 andl %ecx, %edi
1160 orl %edi, %ebp
1161 movl %eax, %edi
1162 roll $5, %edi
1163 addl %edi, %ebp
1164 movl 4(%esp), %edi
1165 addl %ebp, %esi
1166 movl 12(%esp), %ebp
1167 xorl %ebp, %edi
1168 movl 36(%esp), %ebp
1169 xorl %ebp, %edi
1170 movl 56(%esp), %ebp
1171.byte 209
1172.byte 203 /* rorl $1 %ebx */
1173 xorl %ebp, %edi
1174.byte 209
1175.byte 199 /* roll $1 %edi */
1176 movl %eax, %ebp
1177 movl %edi, 4(%esp)
1178 orl %ebx, %ebp
1179 leal 2400959708(%edi,%edx,1),%edi
1180 movl %eax, %edx
1181 andl %ecx, %ebp
1182 andl %ebx, %edx
1183 orl %edx, %ebp
1184 movl %esi, %edx
1185 roll $5, %edx
1186.byte 209
1187.byte 200 /* rorl $1 %eax */
1188 addl %edx, %ebp
1189.byte 209
1190.byte 200 /* rorl $1 %eax */
1191 addl %ebp, %edi
1192 /* 40_59 49 */
1193 /* 40_59 50 */
1194 movl 8(%esp), %edx
1195 movl 16(%esp), %ebp
1196 xorl %ebp, %edx
1197 movl 40(%esp), %ebp
1198 xorl %ebp, %edx
1199 movl 60(%esp), %ebp
1200 xorl %ebp, %edx
1201 movl %esi, %ebp
1202.byte 209
1203.byte 194 /* roll $1 %edx */
1204 orl %eax, %ebp
1205 movl %edx, 8(%esp)
1206 andl %ebx, %ebp
1207 leal 2400959708(%edx,%ecx,1),%edx
1208 movl %esi, %ecx
1209.byte 209
1210.byte 206 /* rorl $1 %esi */
1211 andl %eax, %ecx
1212 orl %ecx, %ebp
1213 movl %edi, %ecx
1214 roll $5, %ecx
1215 addl %ecx, %ebp
1216 movl 12(%esp), %ecx
1217 addl %ebp, %edx
1218 movl 20(%esp), %ebp
1219 xorl %ebp, %ecx
1220 movl 44(%esp), %ebp
1221 xorl %ebp, %ecx
1222 movl (%esp), %ebp
1223.byte 209
1224.byte 206 /* rorl $1 %esi */
1225 xorl %ebp, %ecx
1226.byte 209
1227.byte 193 /* roll $1 %ecx */
1228 movl %edi, %ebp
1229 movl %ecx, 12(%esp)
1230 orl %esi, %ebp
1231 leal 2400959708(%ecx,%ebx,1),%ecx
1232 movl %edi, %ebx
1233 andl %eax, %ebp
1234 andl %esi, %ebx
1235 orl %ebx, %ebp
1236 movl %edx, %ebx
1237 roll $5, %ebx
1238.byte 209
1239.byte 207 /* rorl $1 %edi */
1240 addl %ebx, %ebp
1241.byte 209
1242.byte 207 /* rorl $1 %edi */
1243 addl %ebp, %ecx
1244 /* 40_59 51 */
1245 /* 40_59 52 */
1246 movl 16(%esp), %ebx
1247 movl 24(%esp), %ebp
1248 xorl %ebp, %ebx
1249 movl 48(%esp), %ebp
1250 xorl %ebp, %ebx
1251 movl 4(%esp), %ebp
1252 xorl %ebp, %ebx
1253 movl %edx, %ebp
1254.byte 209
1255.byte 195 /* roll $1 %ebx */
1256 orl %edi, %ebp
1257 movl %ebx, 16(%esp)
1258 andl %esi, %ebp
1259 leal 2400959708(%ebx,%eax,1),%ebx
1260 movl %edx, %eax
1261.byte 209
1262.byte 202 /* rorl $1 %edx */
1263 andl %edi, %eax
1264 orl %eax, %ebp
1265 movl %ecx, %eax
1266 roll $5, %eax
1267 addl %eax, %ebp
1268 movl 20(%esp), %eax
1269 addl %ebp, %ebx
1270 movl 28(%esp), %ebp
1271 xorl %ebp, %eax
1272 movl 52(%esp), %ebp
1273 xorl %ebp, %eax
1274 movl 8(%esp), %ebp
1275.byte 209
1276.byte 202 /* rorl $1 %edx */
1277 xorl %ebp, %eax
1278.byte 209
1279.byte 192 /* roll $1 %eax */
1280 movl %ecx, %ebp
1281 movl %eax, 20(%esp)
1282 orl %edx, %ebp
1283 leal 2400959708(%eax,%esi,1),%eax
1284 movl %ecx, %esi
1285 andl %edi, %ebp
1286 andl %edx, %esi
1287 orl %esi, %ebp
1288 movl %ebx, %esi
1289 roll $5, %esi
1290.byte 209
1291.byte 201 /* rorl $1 %ecx */
1292 addl %esi, %ebp
1293.byte 209
1294.byte 201 /* rorl $1 %ecx */
1295 addl %ebp, %eax
1296 /* 40_59 53 */
1297 /* 40_59 54 */
1298 movl 24(%esp), %esi
1299 movl 32(%esp), %ebp
1300 xorl %ebp, %esi
1301 movl 56(%esp), %ebp
1302 xorl %ebp, %esi
1303 movl 12(%esp), %ebp
1304 xorl %ebp, %esi
1305 movl %ebx, %ebp
1306.byte 209
1307.byte 198 /* roll $1 %esi */
1308 orl %ecx, %ebp
1309 movl %esi, 24(%esp)
1310 andl %edx, %ebp
1311 leal 2400959708(%esi,%edi,1),%esi
1312 movl %ebx, %edi
1313.byte 209
1314.byte 203 /* rorl $1 %ebx */
1315 andl %ecx, %edi
1316 orl %edi, %ebp
1317 movl %eax, %edi
1318 roll $5, %edi
1319 addl %edi, %ebp
1320 movl 28(%esp), %edi
1321 addl %ebp, %esi
1322 movl 36(%esp), %ebp
1323 xorl %ebp, %edi
1324 movl 60(%esp), %ebp
1325 xorl %ebp, %edi
1326 movl 16(%esp), %ebp
1327.byte 209
1328.byte 203 /* rorl $1 %ebx */
1329 xorl %ebp, %edi
1330.byte 209
1331.byte 199 /* roll $1 %edi */
1332 movl %eax, %ebp
1333 movl %edi, 28(%esp)
1334 orl %ebx, %ebp
1335 leal 2400959708(%edi,%edx,1),%edi
1336 movl %eax, %edx
1337 andl %ecx, %ebp
1338 andl %ebx, %edx
1339 orl %edx, %ebp
1340 movl %esi, %edx
1341 roll $5, %edx
1342.byte 209
1343.byte 200 /* rorl $1 %eax */
1344 addl %edx, %ebp
1345.byte 209
1346.byte 200 /* rorl $1 %eax */
1347 addl %ebp, %edi
1348 /* 40_59 55 */
1349 /* 40_59 56 */
1350 movl 32(%esp), %edx
1351 movl 40(%esp), %ebp
1352 xorl %ebp, %edx
1353 movl (%esp), %ebp
1354 xorl %ebp, %edx
1355 movl 20(%esp), %ebp
1356 xorl %ebp, %edx
1357 movl %esi, %ebp
1358.byte 209
1359.byte 194 /* roll $1 %edx */
1360 orl %eax, %ebp
1361 movl %edx, 32(%esp)
1362 andl %ebx, %ebp
1363 leal 2400959708(%edx,%ecx,1),%edx
1364 movl %esi, %ecx
1365.byte 209
1366.byte 206 /* rorl $1 %esi */
1367 andl %eax, %ecx
1368 orl %ecx, %ebp
1369 movl %edi, %ecx
1370 roll $5, %ecx
1371 addl %ecx, %ebp
1372 movl 36(%esp), %ecx
1373 addl %ebp, %edx
1374 movl 44(%esp), %ebp
1375 xorl %ebp, %ecx
1376 movl 4(%esp), %ebp
1377 xorl %ebp, %ecx
1378 movl 24(%esp), %ebp
1379.byte 209
1380.byte 206 /* rorl $1 %esi */
1381 xorl %ebp, %ecx
1382.byte 209
1383.byte 193 /* roll $1 %ecx */
1384 movl %edi, %ebp
1385 movl %ecx, 36(%esp)
1386 orl %esi, %ebp
1387 leal 2400959708(%ecx,%ebx,1),%ecx
1388 movl %edi, %ebx
1389 andl %eax, %ebp
1390 andl %esi, %ebx
1391 orl %ebx, %ebp
1392 movl %edx, %ebx
1393 roll $5, %ebx
1394.byte 209
1395.byte 207 /* rorl $1 %edi */
1396 addl %ebx, %ebp
1397.byte 209
1398.byte 207 /* rorl $1 %edi */
1399 addl %ebp, %ecx
1400 /* 40_59 57 */
1401 /* 40_59 58 */
1402 movl 40(%esp), %ebx
1403 movl 48(%esp), %ebp
1404 xorl %ebp, %ebx
1405 movl 8(%esp), %ebp
1406 xorl %ebp, %ebx
1407 movl 28(%esp), %ebp
1408 xorl %ebp, %ebx
1409 movl %edx, %ebp
1410.byte 209
1411.byte 195 /* roll $1 %ebx */
1412 orl %edi, %ebp
1413 movl %ebx, 40(%esp)
1414 andl %esi, %ebp
1415 leal 2400959708(%ebx,%eax,1),%ebx
1416 movl %edx, %eax
1417.byte 209
1418.byte 202 /* rorl $1 %edx */
1419 andl %edi, %eax
1420 orl %eax, %ebp
1421 movl %ecx, %eax
1422 roll $5, %eax
1423 addl %eax, %ebp
1424 movl 44(%esp), %eax
1425 addl %ebp, %ebx
1426 movl 52(%esp), %ebp
1427 xorl %ebp, %eax
1428 movl 12(%esp), %ebp
1429 xorl %ebp, %eax
1430 movl 32(%esp), %ebp
1431.byte 209
1432.byte 202 /* rorl $1 %edx */
1433 xorl %ebp, %eax
1434.byte 209
1435.byte 192 /* roll $1 %eax */
1436 movl %ecx, %ebp
1437 movl %eax, 44(%esp)
1438 orl %edx, %ebp
1439 leal 2400959708(%eax,%esi,1),%eax
1440 movl %ecx, %esi
1441 andl %edi, %ebp
1442 andl %edx, %esi
1443 orl %esi, %ebp
1444 movl %ebx, %esi
1445 roll $5, %esi
1446.byte 209
1447.byte 201 /* rorl $1 %ecx */
1448 addl %esi, %ebp
1449.byte 209
1450.byte 201 /* rorl $1 %ecx */
1451 addl %ebp, %eax
1452 /* 40_59 59 */
1453 /* 20_39 60 */
1454 movl 48(%esp), %esi
1455 movl 56(%esp), %ebp
1456 xorl %ebp, %esi
1457 movl 16(%esp), %ebp
1458 xorl %ebp, %esi
1459 movl 36(%esp), %ebp
1460 xorl %ebp, %esi
1461 movl %ebx, %ebp
1462.byte 209
1463.byte 198 /* roll $1 %esi */
1464 xorl %ecx, %ebp
1465 movl %esi, 48(%esp)
1466 xorl %edx, %ebp
1467 leal 3395469782(%esi,%edi,1),%esi
1468 movl %eax, %edi
1469 roll $5, %edi
1470.byte 209
1471.byte 203 /* rorl $1 %ebx */
1472 addl %ebp, %edi
1473.byte 209
1474.byte 203 /* rorl $1 %ebx */
1475 addl %edi, %esi
1476 /* 20_39 61 */
1477 movl 52(%esp), %edi
1478 movl 60(%esp), %ebp
1479 xorl %ebp, %edi
1480 movl 20(%esp), %ebp
1481 xorl %ebp, %edi
1482 movl 40(%esp), %ebp
1483 xorl %ebp, %edi
1484 movl %eax, %ebp
1485.byte 209
1486.byte 199 /* roll $1 %edi */
1487 xorl %ebx, %ebp
1488 movl %edi, 52(%esp)
1489 xorl %ecx, %ebp
1490 leal 3395469782(%edi,%edx,1),%edi
1491 movl %esi, %edx
1492 roll $5, %edx
1493.byte 209
1494.byte 200 /* rorl $1 %eax */
1495 addl %ebp, %edx
1496.byte 209
1497.byte 200 /* rorl $1 %eax */
1498 addl %edx, %edi
1499 /* 20_39 62 */
1500 movl 56(%esp), %edx
1501 movl (%esp), %ebp
1502 xorl %ebp, %edx
1503 movl 24(%esp), %ebp
1504 xorl %ebp, %edx
1505 movl 44(%esp), %ebp
1506 xorl %ebp, %edx
1507 movl %esi, %ebp
1508.byte 209
1509.byte 194 /* roll $1 %edx */
1510 xorl %eax, %ebp
1511 movl %edx, 56(%esp)
1512 xorl %ebx, %ebp
1513 leal 3395469782(%edx,%ecx,1),%edx
1514 movl %edi, %ecx
1515 roll $5, %ecx
1516.byte 209
1517.byte 206 /* rorl $1 %esi */
1518 addl %ebp, %ecx
1519.byte 209
1520.byte 206 /* rorl $1 %esi */
1521 addl %ecx, %edx
1522 /* 20_39 63 */
1523 movl 60(%esp), %ecx
1524 movl 4(%esp), %ebp
1525 xorl %ebp, %ecx
1526 movl 28(%esp), %ebp
1527 xorl %ebp, %ecx
1528 movl 48(%esp), %ebp
1529 xorl %ebp, %ecx
1530 movl %edi, %ebp
1531.byte 209
1532.byte 193 /* roll $1 %ecx */
1533 xorl %esi, %ebp
1534 movl %ecx, 60(%esp)
1535 xorl %eax, %ebp
1536 leal 3395469782(%ecx,%ebx,1),%ecx
1537 movl %edx, %ebx
1538 roll $5, %ebx
1539.byte 209
1540.byte 207 /* rorl $1 %edi */
1541 addl %ebp, %ebx
1542.byte 209
1543.byte 207 /* rorl $1 %edi */
1544 addl %ebx, %ecx
1545 /* 20_39 64 */
1546 movl (%esp), %ebx
1547 movl 8(%esp), %ebp
1548 xorl %ebp, %ebx
1549 movl 32(%esp), %ebp
1550 xorl %ebp, %ebx
1551 movl 52(%esp), %ebp
1552 xorl %ebp, %ebx
1553 movl %edx, %ebp
1554.byte 209
1555.byte 195 /* roll $1 %ebx */
1556 xorl %edi, %ebp
1557 movl %ebx, (%esp)
1558 xorl %esi, %ebp
1559 leal 3395469782(%ebx,%eax,1),%ebx
1560 movl %ecx, %eax
1561 roll $5, %eax
1562.byte 209
1563.byte 202 /* rorl $1 %edx */
1564 addl %ebp, %eax
1565.byte 209
1566.byte 202 /* rorl $1 %edx */
1567 addl %eax, %ebx
1568 /* 20_39 65 */
1569 movl 4(%esp), %eax
1570 movl 12(%esp), %ebp
1571 xorl %ebp, %eax
1572 movl 36(%esp), %ebp
1573 xorl %ebp, %eax
1574 movl 56(%esp), %ebp
1575 xorl %ebp, %eax
1576 movl %ecx, %ebp
1577.byte 209
1578.byte 192 /* roll $1 %eax */
1579 xorl %edx, %ebp
1580 movl %eax, 4(%esp)
1581 xorl %edi, %ebp
1582 leal 3395469782(%eax,%esi,1),%eax
1583 movl %ebx, %esi
1584 roll $5, %esi
1585.byte 209
1586.byte 201 /* rorl $1 %ecx */
1587 addl %ebp, %esi
1588.byte 209
1589.byte 201 /* rorl $1 %ecx */
1590 addl %esi, %eax
1591 /* 20_39 66 */
1592 movl 8(%esp), %esi
1593 movl 16(%esp), %ebp
1594 xorl %ebp, %esi
1595 movl 40(%esp), %ebp
1596 xorl %ebp, %esi
1597 movl 60(%esp), %ebp
1598 xorl %ebp, %esi
1599 movl %ebx, %ebp
1600.byte 209
1601.byte 198 /* roll $1 %esi */
1602 xorl %ecx, %ebp
1603 movl %esi, 8(%esp)
1604 xorl %edx, %ebp
1605 leal 3395469782(%esi,%edi,1),%esi
1606 movl %eax, %edi
1607 roll $5, %edi
1608.byte 209
1609.byte 203 /* rorl $1 %ebx */
1610 addl %ebp, %edi
1611.byte 209
1612.byte 203 /* rorl $1 %ebx */
1613 addl %edi, %esi
1614 /* 20_39 67 */
1615 movl 12(%esp), %edi
1616 movl 20(%esp), %ebp
1617 xorl %ebp, %edi
1618 movl 44(%esp), %ebp
1619 xorl %ebp, %edi
1620 movl (%esp), %ebp
1621 xorl %ebp, %edi
1622 movl %eax, %ebp
1623.byte 209
1624.byte 199 /* roll $1 %edi */
1625 xorl %ebx, %ebp
1626 movl %edi, 12(%esp)
1627 xorl %ecx, %ebp
1628 leal 3395469782(%edi,%edx,1),%edi
1629 movl %esi, %edx
1630 roll $5, %edx
1631.byte 209
1632.byte 200 /* rorl $1 %eax */
1633 addl %ebp, %edx
1634.byte 209
1635.byte 200 /* rorl $1 %eax */
1636 addl %edx, %edi
1637 /* 20_39 68 */
1638 movl 16(%esp), %edx
1639 movl 24(%esp), %ebp
1640 xorl %ebp, %edx
1641 movl 48(%esp), %ebp
1642 xorl %ebp, %edx
1643 movl 4(%esp), %ebp
1644 xorl %ebp, %edx
1645 movl %esi, %ebp
1646.byte 209
1647.byte 194 /* roll $1 %edx */
1648 xorl %eax, %ebp
1649 movl %edx, 16(%esp)
1650 xorl %ebx, %ebp
1651 leal 3395469782(%edx,%ecx,1),%edx
1652 movl %edi, %ecx
1653 roll $5, %ecx
1654.byte 209
1655.byte 206 /* rorl $1 %esi */
1656 addl %ebp, %ecx
1657.byte 209
1658.byte 206 /* rorl $1 %esi */
1659 addl %ecx, %edx
1660 /* 20_39 69 */
1661 movl 20(%esp), %ecx
1662 movl 28(%esp), %ebp
1663 xorl %ebp, %ecx
1664 movl 52(%esp), %ebp
1665 xorl %ebp, %ecx
1666 movl 8(%esp), %ebp
1667 xorl %ebp, %ecx
1668 movl %edi, %ebp
1669.byte 209
1670.byte 193 /* roll $1 %ecx */
1671 xorl %esi, %ebp
1672 movl %ecx, 20(%esp)
1673 xorl %eax, %ebp
1674 leal 3395469782(%ecx,%ebx,1),%ecx
1675 movl %edx, %ebx
1676 roll $5, %ebx
1677.byte 209
1678.byte 207 /* rorl $1 %edi */
1679 addl %ebp, %ebx
1680.byte 209
1681.byte 207 /* rorl $1 %edi */
1682 addl %ebx, %ecx
1683 /* 20_39 70 */
1684 movl 24(%esp), %ebx
1685 movl 32(%esp), %ebp
1686 xorl %ebp, %ebx
1687 movl 56(%esp), %ebp
1688 xorl %ebp, %ebx
1689 movl 12(%esp), %ebp
1690 xorl %ebp, %ebx
1691 movl %edx, %ebp
1692.byte 209
1693.byte 195 /* roll $1 %ebx */
1694 xorl %edi, %ebp
1695 movl %ebx, 24(%esp)
1696 xorl %esi, %ebp
1697 leal 3395469782(%ebx,%eax,1),%ebx
1698 movl %ecx, %eax
1699 roll $5, %eax
1700.byte 209
1701.byte 202 /* rorl $1 %edx */
1702 addl %ebp, %eax
1703.byte 209
1704.byte 202 /* rorl $1 %edx */
1705 addl %eax, %ebx
1706 /* 20_39 71 */
1707 movl 28(%esp), %eax
1708 movl 36(%esp), %ebp
1709 xorl %ebp, %eax
1710 movl 60(%esp), %ebp
1711 xorl %ebp, %eax
1712 movl 16(%esp), %ebp
1713 xorl %ebp, %eax
1714 movl %ecx, %ebp
1715.byte 209
1716.byte 192 /* roll $1 %eax */
1717 xorl %edx, %ebp
1718 movl %eax, 28(%esp)
1719 xorl %edi, %ebp
1720 leal 3395469782(%eax,%esi,1),%eax
1721 movl %ebx, %esi
1722 roll $5, %esi
1723.byte 209
1724.byte 201 /* rorl $1 %ecx */
1725 addl %ebp, %esi
1726.byte 209
1727.byte 201 /* rorl $1 %ecx */
1728 addl %esi, %eax
1729 /* 20_39 72 */
1730 movl 32(%esp), %esi
1731 movl 40(%esp), %ebp
1732 xorl %ebp, %esi
1733 movl (%esp), %ebp
1734 xorl %ebp, %esi
1735 movl 20(%esp), %ebp
1736 xorl %ebp, %esi
1737 movl %ebx, %ebp
1738.byte 209
1739.byte 198 /* roll $1 %esi */
1740 xorl %ecx, %ebp
1741 movl %esi, 32(%esp)
1742 xorl %edx, %ebp
1743 leal 3395469782(%esi,%edi,1),%esi
1744 movl %eax, %edi
1745 roll $5, %edi
1746.byte 209
1747.byte 203 /* rorl $1 %ebx */
1748 addl %ebp, %edi
1749.byte 209
1750.byte 203 /* rorl $1 %ebx */
1751 addl %edi, %esi
1752 /* 20_39 73 */
1753 movl 36(%esp), %edi
1754 movl 44(%esp), %ebp
1755 xorl %ebp, %edi
1756 movl 4(%esp), %ebp
1757 xorl %ebp, %edi
1758 movl 24(%esp), %ebp
1759 xorl %ebp, %edi
1760 movl %eax, %ebp
1761.byte 209
1762.byte 199 /* roll $1 %edi */
1763 xorl %ebx, %ebp
1764 movl %edi, 36(%esp)
1765 xorl %ecx, %ebp
1766 leal 3395469782(%edi,%edx,1),%edi
1767 movl %esi, %edx
1768 roll $5, %edx
1769.byte 209
1770.byte 200 /* rorl $1 %eax */
1771 addl %ebp, %edx
1772.byte 209
1773.byte 200 /* rorl $1 %eax */
1774 addl %edx, %edi
1775 /* 20_39 74 */
1776 movl 40(%esp), %edx
1777 movl 48(%esp), %ebp
1778 xorl %ebp, %edx
1779 movl 8(%esp), %ebp
1780 xorl %ebp, %edx
1781 movl 28(%esp), %ebp
1782 xorl %ebp, %edx
1783 movl %esi, %ebp
1784.byte 209
1785.byte 194 /* roll $1 %edx */
1786 xorl %eax, %ebp
1787 movl %edx, 40(%esp)
1788 xorl %ebx, %ebp
1789 leal 3395469782(%edx,%ecx,1),%edx
1790 movl %edi, %ecx
1791 roll $5, %ecx
1792.byte 209
1793.byte 206 /* rorl $1 %esi */
1794 addl %ebp, %ecx
1795.byte 209
1796.byte 206 /* rorl $1 %esi */
1797 addl %ecx, %edx
1798 /* 20_39 75 */
1799 movl 44(%esp), %ecx
1800 movl 52(%esp), %ebp
1801 xorl %ebp, %ecx
1802 movl 12(%esp), %ebp
1803 xorl %ebp, %ecx
1804 movl 32(%esp), %ebp
1805 xorl %ebp, %ecx
1806 movl %edi, %ebp
1807.byte 209
1808.byte 193 /* roll $1 %ecx */
1809 xorl %esi, %ebp
1810 movl %ecx, 44(%esp)
1811 xorl %eax, %ebp
1812 leal 3395469782(%ecx,%ebx,1),%ecx
1813 movl %edx, %ebx
1814 roll $5, %ebx
1815.byte 209
1816.byte 207 /* rorl $1 %edi */
1817 addl %ebp, %ebx
1818.byte 209
1819.byte 207 /* rorl $1 %edi */
1820 addl %ebx, %ecx
1821 /* 20_39 76 */
1822 movl 48(%esp), %ebx
1823 movl 56(%esp), %ebp
1824 xorl %ebp, %ebx
1825 movl 16(%esp), %ebp
1826 xorl %ebp, %ebx
1827 movl 36(%esp), %ebp
1828 xorl %ebp, %ebx
1829 movl %edx, %ebp
1830.byte 209
1831.byte 195 /* roll $1 %ebx */
1832 xorl %edi, %ebp
1833 movl %ebx, 48(%esp)
1834 xorl %esi, %ebp
1835 leal 3395469782(%ebx,%eax,1),%ebx
1836 movl %ecx, %eax
1837 roll $5, %eax
1838.byte 209
1839.byte 202 /* rorl $1 %edx */
1840 addl %ebp, %eax
1841.byte 209
1842.byte 202 /* rorl $1 %edx */
1843 addl %eax, %ebx
1844 /* 20_39 77 */
1845 movl 52(%esp), %eax
1846 movl 60(%esp), %ebp
1847 xorl %ebp, %eax
1848 movl 20(%esp), %ebp
1849 xorl %ebp, %eax
1850 movl 40(%esp), %ebp
1851 xorl %ebp, %eax
1852 movl %ecx, %ebp
1853.byte 209
1854.byte 192 /* roll $1 %eax */
1855 xorl %edx, %ebp
1856 movl %eax, 52(%esp)
1857 xorl %edi, %ebp
1858 leal 3395469782(%eax,%esi,1),%eax
1859 movl %ebx, %esi
1860 roll $5, %esi
1861.byte 209
1862.byte 201 /* rorl $1 %ecx */
1863 addl %ebp, %esi
1864.byte 209
1865.byte 201 /* rorl $1 %ecx */
1866 addl %esi, %eax
1867 /* 20_39 78 */
1868 movl 56(%esp), %esi
1869 movl (%esp), %ebp
1870 xorl %ebp, %esi
1871 movl 24(%esp), %ebp
1872 xorl %ebp, %esi
1873 movl 44(%esp), %ebp
1874 xorl %ebp, %esi
1875 movl %ebx, %ebp
1876.byte 209
1877.byte 198 /* roll $1 %esi */
1878 xorl %ecx, %ebp
1879 movl %esi, 56(%esp)
1880 xorl %edx, %ebp
1881 leal 3395469782(%esi,%edi,1),%esi
1882 movl %eax, %edi
1883 roll $5, %edi
1884.byte 209
1885.byte 203 /* rorl $1 %ebx */
1886 addl %ebp, %edi
1887.byte 209
1888.byte 203 /* rorl $1 %ebx */
1889 addl %edi, %esi
1890 /* 20_39 79 */
1891 movl 60(%esp), %edi
1892 movl 4(%esp), %ebp
1893 xorl %ebp, %edi
1894 movl 28(%esp), %ebp
1895 xorl %ebp, %edi
1896 movl 48(%esp), %ebp
1897 xorl %ebp, %edi
1898 movl %eax, %ebp
1899.byte 209
1900.byte 199 /* roll $1 %edi */
1901 xorl %ebx, %ebp
1902 movl %edi, 60(%esp)
1903 xorl %ecx, %ebp
1904 leal 3395469782(%edi,%edx,1),%edi
1905 movl %esi, %edx
1906 roll $5, %edx
1907 addl %ebp, %edx
1908 movl 92(%esp), %ebp
1909.byte 209
1910.byte 200 /* rorl $1 %eax */
1911 addl %edx, %edi
1912.byte 209
1913.byte 200 /* rorl $1 %eax */
1914 /* End processing */
1915
1916 movl 12(%ebp), %edx
1917 addl %ebx, %edx
1918 movl 4(%ebp), %ebx
1919 addl %esi, %ebx
1920 movl %eax, %esi
1921 movl (%ebp), %eax
1922 movl %edx, 12(%ebp)
1923 addl %edi, %eax
1924 movl 16(%ebp), %edi
1925 addl %ecx, %edi
1926 movl 8(%ebp), %ecx
1927 addl %esi, %ecx
1928 movl %eax, (%ebp)
1929 movl 64(%esp), %esi
1930 movl %ecx, 8(%ebp)
1931 addl $64, %esi
1932 movl 68(%esp), %eax
1933 movl %edi, 16(%ebp)
1934 cmpl %esi, %eax
1935 movl %ebx, 4(%ebp)
1936 jl .L001end
1937 movl (%esi), %eax
1938 jmp .L000start
1939.L001end:
1940 addl $72, %esp
1941 popl %edi
1942 popl %ebx
1943 popl %ebp
1944 popl %esi
1945 ret
1946.sha1_block_x86_end:
1947 SIZE(sha1_block_x86,.sha1_block_x86_end-sha1_block_x86)
1948.ident "desasm.pl"
diff --git a/src/lib/libssl/src/crypto/sha/sha_sgst.c b/src/lib/libssl/src/crypto/sha/sha_sgst.c
new file mode 100644
index 0000000000..8a16801328
--- /dev/null
+++ b/src/lib/libssl/src/crypto/sha/sha_sgst.c
@@ -0,0 +1,246 @@
1/* crypto/sha/sha_sgst.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdlib.h>
60#include <string.h>
61
62#ifdef undef
63/* one or the other needs to be defined */
64#ifndef SHA_1 /* FIPE 180-1 */
65#define SHA_0 /* FIPS 180 */
66#endif
67#endif
68
69#define ULONG unsigned long
70#define UCHAR unsigned char
71#define UINT unsigned int
72
73#ifdef NOCONST
74#define const
75#endif
76
77#undef c2nl
78#define c2nl(c,l) (l =(((unsigned long)(*((c)++)))<<24), \
79 l|=(((unsigned long)(*((c)++)))<<16), \
80 l|=(((unsigned long)(*((c)++)))<< 8), \
81 l|=(((unsigned long)(*((c)++))) ))
82
83#undef p_c2nl
84#define p_c2nl(c,l,n) { \
85 switch (n) { \
86 case 0: l =((unsigned long)(*((c)++)))<<24; \
87 case 1: l|=((unsigned long)(*((c)++)))<<16; \
88 case 2: l|=((unsigned long)(*((c)++)))<< 8; \
89 case 3: l|=((unsigned long)(*((c)++))); \
90 } \
91 }
92
93#undef c2nl_p
94/* NOTE the pointer is not incremented at the end of this */
95#define c2nl_p(c,l,n) { \
96 l=0; \
97 (c)+=n; \
98 switch (n) { \
99 case 3: l =((unsigned long)(*(--(c))))<< 8; \
100 case 2: l|=((unsigned long)(*(--(c))))<<16; \
101 case 1: l|=((unsigned long)(*(--(c))))<<24; \
102 } \
103 }
104
105#undef p_c2nl_p
106#define p_c2nl_p(c,l,sc,len) { \
107 switch (sc) \
108 { \
109 case 0: l =((unsigned long)(*((c)++)))<<24; \
110 if (--len == 0) break; \
111 case 1: l|=((unsigned long)(*((c)++)))<<16; \
112 if (--len == 0) break; \
113 case 2: l|=((unsigned long)(*((c)++)))<< 8; \
114 } \
115 }
116
117#undef nl2c
118#define nl2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
119 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
120 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
121 *((c)++)=(unsigned char)(((l) )&0xff))
122
123#undef c2l
124#define c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
125 l|=(((unsigned long)(*((c)++)))<< 8), \
126 l|=(((unsigned long)(*((c)++)))<<16), \
127 l|=(((unsigned long)(*((c)++)))<<24))
128
129#undef p_c2l
130#define p_c2l(c,l,n) { \
131 switch (n) { \
132 case 0: l =((unsigned long)(*((c)++))); \
133 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
134 case 2: l|=((unsigned long)(*((c)++)))<<16; \
135 case 3: l|=((unsigned long)(*((c)++)))<<24; \
136 } \
137 }
138
139#undef c2l_p
140/* NOTE the pointer is not incremented at the end of this */
141#define c2l_p(c,l,n) { \
142 l=0; \
143 (c)+=n; \
144 switch (n) { \
145 case 3: l =((unsigned long)(*(--(c))))<<16; \
146 case 2: l|=((unsigned long)(*(--(c))))<< 8; \
147 case 1: l|=((unsigned long)(*(--(c)))); \
148 } \
149 }
150
151#undef p_c2l_p
152#define p_c2l_p(c,l,sc,len) { \
153 switch (sc) \
154 { \
155 case 0: l =((unsigned long)(*((c)++))); \
156 if (--len == 0) break; \
157 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
158 if (--len == 0) break; \
159 case 2: l|=((unsigned long)(*((c)++)))<<16; \
160 } \
161 }
162
163#undef l2c
164#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
165 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
166 *((c)++)=(unsigned char)(((l)>>16)&0xff), \
167 *((c)++)=(unsigned char)(((l)>>24)&0xff))
168
169#undef ROTATE
170#if defined(WIN32)
171#define ROTATE(a,n) _lrotl(a,n)
172#else
173#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
174#endif
175
176/* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */
177#if defined(WIN32)
178/* 5 instructions with rotate instruction, else 9 */
179#define Endian_Reverse32(a) \
180 { \
181 unsigned long l=(a); \
182 (a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \
183 }
184#else
185/* 6 instructions with rotate instruction, else 8 */
186#define Endian_Reverse32(a) \
187 { \
188 unsigned long l=(a); \
189 l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \
190 (a)=ROTATE(l,16L); \
191 }
192#endif
193
194/* As pointed out by Wei Dai <weidai@eskimo.com>, F() below can be
195 * simplified to the code in F_00_19. Wei attributes these optimisations
196 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
197 * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
198 * I've just become aware of another tweak to be made, again from Wei Dai,
199 * in F_40_59, (x&a)|(y&a) -> (x|y)&a
200 */
201#define F_00_19(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
202#define F_20_39(b,c,d) ((b) ^ (c) ^ (d))
203#define F_40_59(b,c,d) (((b) & (c)) | (((b)|(c)) & (d)))
204#define F_60_79(b,c,d) F_20_39(b,c,d)
205
206#ifdef SHA_0
207#undef Xupdate
208#define Xupdate(a,i,ia,ib,ic,id) X[(i)&0x0f]=(a)=\
209 (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);
210#endif
211#ifdef SHA_1
212#undef Xupdate
213#define Xupdate(a,i,ia,ib,ic,id) (a)=\
214 (ia[(i)&0x0f]^ib[((i)+2)&0x0f]^ic[((i)+8)&0x0f]^id[((i)+13)&0x0f]);\
215 X[(i)&0x0f]=(a)=ROTATE((a),1);
216#endif
217
218#define BODY_00_15(i,a,b,c,d,e,f,xa) \
219 (f)=xa[i]+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
220 (b)=ROTATE((b),30);
221
222#define BODY_16_19(i,a,b,c,d,e,f,xa,xb,xc,xd) \
223 Xupdate(f,i,xa,xb,xc,xd); \
224 (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \
225 (b)=ROTATE((b),30);
226
227#define BODY_20_31(i,a,b,c,d,e,f,xa,xb,xc,xd) \
228 Xupdate(f,i,xa,xb,xc,xd); \
229 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
230 (b)=ROTATE((b),30);
231
232#define BODY_32_39(i,a,b,c,d,e,f,xa) \
233 Xupdate(f,i,xa,xa,xa,xa); \
234 (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \
235 (b)=ROTATE((b),30);
236
237#define BODY_40_59(i,a,b,c,d,e,f,xa) \
238 Xupdate(f,i,xa,xa,xa,xa); \
239 (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \
240 (b)=ROTATE((b),30);
241
242#define BODY_60_79(i,a,b,c,d,e,f,xa) \
243 Xupdate(f,i,xa,xa,xa,xa); \
244 (f)=X[(i)&0x0f]+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \
245 (b)=ROTATE((b),30);
246
diff --git a/src/lib/libssl/src/crypto/stack/Makefile.ssl b/src/lib/libssl/src/crypto/stack/Makefile.ssl
new file mode 100644
index 0000000000..0d232c08cf
--- /dev/null
+++ b/src/lib/libssl/src/crypto/stack/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/stack/Makefile
3#
4
5DIR= stack
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=stack.c
24LIBOBJ=stack.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= stack.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/txt_db/Makefile.ssl b/src/lib/libssl/src/crypto/txt_db/Makefile.ssl
new file mode 100644
index 0000000000..76e511534f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/txt_db/Makefile.ssl
@@ -0,0 +1,80 @@
1#
2# SSLeay/crypto/txt_db/Makefile
3#
4
5DIR= txt_db
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18GENERAL=Makefile
19TEST=
20APPS=
21
22LIB=$(TOP)/libcrypto.a
23LIBSRC=txt_db.c
24LIBOBJ=txt_db.o
25
26SRC= $(LIBSRC)
27
28EXHEADER= txt_db.h
29HEADER= $(EXHEADER)
30
31ALL= $(GENERAL) $(SRC) $(HEADER)
32
33top:
34 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
35
36all: lib
37
38lib: $(LIBOBJ)
39 $(AR) $(LIB) $(LIBOBJ)
40 sh $(TOP)/util/ranlib.sh $(LIB)
41 @touch lib
42
43files:
44 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
45
46links:
47 /bin/rm -f Makefile
48 $(TOP)/util/point.sh Makefile.ssl Makefile ;
49 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
50 $(TOP)/util/mklink.sh ../../test $(TEST)
51 $(TOP)/util/mklink.sh ../../apps $(APPS)
52
53install:
54 @for i in $(EXHEADER) ; \
55 do \
56 (cp $$i $(INSTALLTOP)/include/$$i; \
57 chmod 644 $(INSTALLTOP)/include/$$i ); \
58 done;
59
60tags:
61 ctags $(SRC)
62
63tests:
64
65lint:
66 lint -DLINT $(INCLUDES) $(SRC)>fluff
67
68depend:
69 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
70
71dclean:
72 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
73 mv -f Makefile.new $(MAKEFILE)
74
75clean:
76 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
77
78errors:
79
80# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/x509/Makefile.ssl b/src/lib/libssl/src/crypto/x509/Makefile.ssl
new file mode 100644
index 0000000000..1c1ca2ffa0
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/Makefile.ssl
@@ -0,0 +1,96 @@
1#
2# SSLeay/crypto/x509/Makefile
3#
4
5DIR= x509
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=x509
19ERRC=x509_err
20GENERAL=Makefile README
21TEST=
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= x509_def.c x509_d2.c x509_r2x.c x509_cmp.c \
26 x509_obj.c x509_req.c x509_vfy.c \
27 x509_set.c x509rset.c $(ERRC).c \
28 x509name.c x509_v3.c x509_ext.c x509pack.c \
29 x509type.c x509_lu.c x_all.c x509_txt.c \
30 by_file.c by_dir.c \
31 v3_net.c v3_x509.c
32LIBOBJ= x509_def.o x509_d2.o x509_r2x.o x509_cmp.o \
33 x509_obj.o x509_req.o x509_vfy.o \
34 x509_set.o x509rset.o $(ERRC).o \
35 x509name.o x509_v3.o x509_ext.o x509pack.o \
36 x509type.o x509_lu.o x_all.o x509_txt.o \
37 by_file.o by_dir.o \
38 v3_net.o v3_x509.o
39
40SRC= $(LIBSRC)
41
42EXHEADER= x509.h x509_vfy.h
43HEADER= $(EXHEADER)
44
45ALL= $(GENERAL) $(SRC) $(HEADER)
46
47top:
48 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
49
50all: lib
51
52lib: $(LIBOBJ)
53 $(AR) $(LIB) $(LIBOBJ)
54 sh $(TOP)/util/ranlib.sh $(LIB)
55 @touch lib
56
57files:
58 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
59
60links:
61 /bin/rm -f Makefile
62 $(TOP)/util/point.sh Makefile.ssl Makefile ;
63 $(TOP)/util/mklink.sh ../../include $(EXHEADER)
64 $(TOP)/util/mklink.sh ../../test $(TEST)
65 $(TOP)/util/mklink.sh ../../apps $(APPS)
66
67install:
68 @for i in $(EXHEADER) ; \
69 do \
70 (cp $$i $(INSTALLTOP)/include/$$i; \
71 chmod 644 $(INSTALLTOP)/include/$$i ); \
72 done;
73
74tags:
75 ctags $(SRC)
76
77tests:
78
79lint:
80 lint -DLINT $(INCLUDES) $(SRC)>fluff
81
82depend:
83 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
84
85dclean:
86 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
87 mv -f Makefile.new $(MAKEFILE)
88
89clean:
90 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
91
92errors:
93 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
94 perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c
95
96# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/crypto/x509/attrib b/src/lib/libssl/src/crypto/x509/attrib
new file mode 100644
index 0000000000..37f6cd755f
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/attrib
@@ -0,0 +1,38 @@
1
2PKCS7
3 STACK of X509_ATTRIBUTES
4 ASN1_OBJECT
5 STACK of ASN1_TYPE
6
7So it is
8
9p7.xa[].obj
10p7.xa[].data[]
11
12get_obj_by_nid(STACK , nid)
13get_num_by_nid(STACK , nid)
14get_data_by_nid(STACK , nid, index)
15
16X509_ATTRIBUTE *X509_ATTRIBUTE_new(void );
17void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a);
18
19X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **ex,
20 int nid, STACK *value);
21
22X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **ex,
23 int nid, STACK *value);
24
25int X509_ATTRIBUTE_set_object(X509_ATTRIBUTE *ex,ASN1_OBJECT *obj);
26int X509_ATTRIBUTE_add_data(X509_ATTRIBUTE *ex, int index,
27 ASN1_TYPE *value);
28
29ASN1_OBJECT * X509_ATTRIBUTE_get_object(X509_ATTRIBUTE *ex);
30int X509_ATTRIBUTE_get_num(X509_ATTRIBUTE *ne);
31ASN1_TYPE * X509_ATTRIBUTE_get_data(X509_ATTRIBUTE *ne,int index);
32
33ASN1_TYPE * X509_ATTRIBUTE_get_data_by_NID(X509_ATTRIBUTE *ne,
34 ASN1_OBJECT *obj);
35
36X509_ATTRUBUTE *PKCS7_get_s_att_by_NID(PKCS7 *p7,int nid);
37X509_ATTRUBUTE *PKCS7_get_u_att_by_NID(PKCS7 *p7,int nid);
38
diff --git a/src/lib/libssl/src/crypto/x509/v3_net.c b/src/lib/libssl/src/crypto/x509/v3_net.c
new file mode 100644
index 0000000000..0c2d276d13
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/v3_net.c
@@ -0,0 +1,87 @@
1/* crypto/x509/v3_net.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "stack.h"
61#include "cryptlib.h"
62#include "asn1.h"
63#include "objects.h"
64#include "x509.h"
65
66#define NETSCAPE_X509_EXT_NUM 8
67
68static X509_EXTENSION_METHOD netscape_x509_ext[NETSCAPE_X509_EXT_NUM]={
69{NID_netscape_ca_policy_url, V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
70{NID_netscape_ssl_server_name, V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
71{NID_netscape_revocation_url, V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
72{NID_netscape_base_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
73{NID_netscape_cert_type,V_ASN1_BIT_STRING,X509_EXT_PACK_STRING},
74{NID_netscape_ca_revocation_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
75{NID_netscape_renewal_url,V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
76{NID_netscape_comment,V_ASN1_IA5STRING,X509_EXT_PACK_STRING},
77 };
78
79int X509v3_add_netscape_extensions()
80 {
81 int i;
82
83 for (i=0; i<NETSCAPE_X509_EXT_NUM; i++)
84 if (!X509v3_add_extension(&(netscape_x509_ext[i])))
85 return(0);
86 return(1);
87 }
diff --git a/src/lib/libssl/src/crypto/x509/v3_x509.c b/src/lib/libssl/src/crypto/x509/v3_x509.c
new file mode 100644
index 0000000000..f685aa4c71
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/v3_x509.c
@@ -0,0 +1,253 @@
1/* crypto/x509/v3_x509.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <ctype.h>
61#include "stack.h"
62#include "cryptlib.h"
63#include "bio.h"
64#include "asn1.h"
65#include "objects.h"
66#include "x509.h"
67
68#if 0
69static int i2a_key_usage(BIO *bp, X509 *x);
70static int a2i_key_usage(X509 *x, char *str, int len);
71#endif
72
73int X509v3_get_key_usage(X509 *x);
74int X509v3_set_key_usage(X509 *x,unsigned int use);
75int i2a_X509v3_key_usage(BIO *bp, unsigned int use);
76unsigned int a2i_X509v3_key_usage(char *p);
77
78#define STD_X509_EXT_NUM 9
79
80#if 0
81static X509_OBJECTS std_x509_ext[STD_X509_EXT_NUM]={
82{NID_subject_key_identifier, NULL,NULL},
83{NID_key_usage, a2i_key_usage,i2a_key_usage}, /**/
84{NID_private_key_usage_period, NULL,NULL},
85{NID_subject_alt_name, NULL,NULL},
86{NID_issuer_alt_name, NULL,NULL},
87{NID_basic_constraints, NULL,NULL},
88{NID_crl_number, NULL,NULL},
89{NID_certificate_policies, NULL,NULL},
90{NID_authority_key_identifier, NULL,NULL},
91 };
92#endif
93
94int X509v3_add_standard_extensions()
95 {
96
97#if 0
98 for (i=0; i<STD_X509_EXT_NUM; i++)
99 if (!X509v3_add_extension(&(std_x509_ext[i])))
100 return(0);
101#endif
102 return(1);
103 }
104
105int X509v3_get_key_usage(x)
106X509 *x;
107 {
108 X509_EXTENSION *ext;
109 ASN1_STRING *st;
110 char *p;
111 int i;
112
113 i=X509_get_ext_by_NID(x,NID_key_usage,-1);
114 if (i < 0) return(X509v3_KU_UNDEF);
115 ext=X509_get_ext(x,i);
116 st=X509v3_unpack_string(NULL,V_ASN1_BIT_STRING,
117 X509_EXTENSION_get_data(X509_get_ext(x,i)));
118
119 p=(char *)ASN1_STRING_data(st);
120 if (ASN1_STRING_length(st) == 1)
121 i=p[0];
122 else if (ASN1_STRING_length(st) == 2)
123 i=p[0]|(p[1]<<8);
124 else
125 i=0;
126 return(i);
127 }
128
129static struct
130 {
131 char *name;
132 unsigned int value;
133 } key_usage_data[] ={
134 {"digitalSignature", X509v3_KU_DIGITAL_SIGNATURE},
135 {"nonRepudiation", X509v3_KU_NON_REPUDIATION},
136 {"keyEncipherment", X509v3_KU_KEY_ENCIPHERMENT},
137 {"dataEncipherment", X509v3_KU_DATA_ENCIPHERMENT},
138 {"keyAgreement", X509v3_KU_KEY_AGREEMENT},
139 {"keyCertSign", X509v3_KU_KEY_CERT_SIGN},
140 {"cRLSign", X509v3_KU_CRL_SIGN},
141 {"encipherOnly", X509v3_KU_ENCIPHER_ONLY},
142 {"decipherOnly", X509v3_KU_DECIPHER_ONLY},
143 {NULL,0},
144 };
145
146#if 0
147static int a2i_key_usage(x,str,len)
148X509 *x;
149char *str;
150int len;
151 {
152 return(X509v3_set_key_usage(x,a2i_X509v3_key_usage(str)));
153 }
154
155static int i2a_key_usage(bp,x)
156BIO *bp;
157X509 *x;
158 {
159 return(i2a_X509v3_key_usage(bp,X509v3_get_key_usage(x)));
160 }
161#endif
162
163int i2a_X509v3_key_usage(bp,use)
164BIO *bp;
165unsigned int use;
166 {
167 int i=0,first=1;
168
169 for (;;)
170 {
171 if (use | key_usage_data[i].value)
172 {
173 BIO_printf(bp,"%s%s",((first)?"":" "),
174 key_usage_data[i].name);
175 first=0;
176 }
177 }
178 return(1);
179 }
180
181unsigned int a2i_X509v3_key_usage(p)
182char *p;
183 {
184 unsigned int ret=0;
185 char *q,*s;
186 int i,n;
187
188 q=p;
189 for (;;)
190 {
191 while ((*q != '\0') && isalnum(*q))
192 q++;
193 if (*q == '\0') break;
194 s=q++;
195 while (isalnum(*q))
196 q++;
197 n=q-s;
198 i=0;
199 for (;;)
200 {
201 if (strncmp(key_usage_data[i].name,s,n) == 0)
202 {
203 ret|=key_usage_data[i].value;
204 break;
205 }
206 i++;
207 if (key_usage_data[i].name == NULL)
208 return(X509v3_KU_UNDEF);
209 }
210 }
211 return(ret);
212 }
213
214int X509v3_set_key_usage(x,use)
215X509 *x;
216unsigned int use;
217 {
218 ASN1_OCTET_STRING *os;
219 X509_EXTENSION *ext;
220 int i;
221 unsigned char data[4];
222
223 i=X509_get_ext_by_NID(x,NID_key_usage,-1);
224 if (i < 0)
225 {
226 i=X509_get_ext_count(x)+1;
227 if ((ext=X509_EXTENSION_new()) == NULL) return(0);
228 if (!X509_add_ext(x,ext,i))
229 {
230 X509_EXTENSION_free(ext);
231 return(0);
232 }
233 }
234 else
235 ext=X509_get_ext(x,i);
236
237 /* fill in 'ext' */
238 os=X509_EXTENSION_get_data(ext);
239
240 i=0;
241 if (use > 0)
242 {
243 i=1;
244 data[0]=use&0xff;
245 }
246 if (use > 0xff)
247 {
248 i=2;
249 data[1]=(use>>8)&0xff;
250 }
251 return((X509v3_pack_string(&os,V_ASN1_BIT_STRING,data,i) == NULL)?0:1);
252 }
253
diff --git a/src/lib/libssl/src/crypto/x509/x509.doc b/src/lib/libssl/src/crypto/x509/x509.doc
new file mode 100644
index 0000000000..73cfc9f034
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/x509.doc
@@ -0,0 +1,27 @@
1X509_verify()
2X509_sign()
3
4X509_get_version()
5X509_get_serialNumber()
6X509_get_issuer()
7X509_get_subject()
8X509_get_notBefore()
9X509_get_notAfter()
10X509_get_pubkey()
11
12X509_set_version()
13X509_set_serialNumber()
14X509_set_issuer()
15X509_set_subject()
16X509_set_notBefore()
17X509_set_notAfter()
18X509_set_pubkey()
19
20X509_get_extensions()
21X509_set_extensions()
22
23X509_EXTENSIONS_clear()
24X509_EXTENSIONS_retrieve()
25X509_EXTENSIONS_add()
26X509_EXTENSIONS_delete()
27
diff --git a/src/lib/libssl/src/crypto/x509/x509.err b/src/lib/libssl/src/crypto/x509/x509.err
new file mode 100644
index 0000000000..8d0862d7d1
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/x509.err
@@ -0,0 +1,46 @@
1/* Error codes for the X509 functions. */
2
3/* Function codes. */
4#define X509_F_ADD_CERT_DIR 100
5#define X509_F_BY_FILE_CTRL 101
6#define X509_F_DIR_CTRL 102
7#define X509_F_GET_CERT_BY_SUBJECT 103
8#define X509_F_X509V3_ADD_EXT 104
9#define X509_F_X509V3_ADD_EXTENSION 105
10#define X509_F_X509V3_PACK_STRING 106
11#define X509_F_X509V3_UNPACK_STRING 107
12#define X509_F_X509_EXTENSION_CREATE_BY_NID 108
13#define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109
14#define X509_F_X509_GET_PUBKEY_PARAMETERS 110
15#define X509_F_X509_LOAD_CERT_FILE 111
16#define X509_F_X509_LOAD_CRL_FILE 112
17#define X509_F_X509_NAME_ADD_ENTRY 113
18#define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114
19#define X509_F_X509_NAME_ENTRY_SET_OBJECT 115
20#define X509_F_X509_NAME_ONELINE 116
21#define X509_F_X509_NAME_PRINT 117
22#define X509_F_X509_PRINT_FP 118
23#define X509_F_X509_PUBKEY_GET 119
24#define X509_F_X509_PUBKEY_SET 120
25#define X509_F_X509_REQ_PRINT 121
26#define X509_F_X509_REQ_PRINT_FP 122
27#define X509_F_X509_REQ_TO_X509 123
28#define X509_F_X509_STORE_ADD_CERT 124
29#define X509_F_X509_STORE_ADD_CRL 125
30#define X509_F_X509_TO_X509_REQ 126
31#define X509_F_X509_VERIFY_CERT 127
32
33/* Reason codes. */
34#define X509_R_BAD_X509_FILETYPE 100
35#define X509_R_CERT_ALREADY_IN_HASH_TABLE 101
36#define X509_R_ERR_ASN1_LIB 102
37#define X509_R_LOADING_CERT_DIR 103
38#define X509_R_LOADING_DEFAULTS 104
39#define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105
40#define X509_R_SHOULD_RETRY 106
41#define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107
42#define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108
43#define X509_R_UNKNOWN_NID 109
44#define X509_R_UNKNOWN_STRING_TYPE 110
45#define X509_R_UNSUPPORTED_ALGORITHM 111
46#define X509_R_WRONG_LOOKUP_TYPE 112
diff --git a/src/lib/libssl/src/crypto/x509/x509pack.c b/src/lib/libssl/src/crypto/x509/x509pack.c
new file mode 100644
index 0000000000..846f125859
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/x509pack.c
@@ -0,0 +1,157 @@
1/* crypto/x509/x509pack.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include "stack.h"
61#include "cryptlib.h"
62#include "asn1.h"
63#include "objects.h"
64#include "evp.h"
65#include "x509.h"
66
67ASN1_OCTET_STRING *X509v3_pack_string(ex,type,bytes,len)
68ASN1_OCTET_STRING **ex;
69int type;
70unsigned char *bytes;
71int len;
72 {
73 ASN1_OCTET_STRING *os;
74 ASN1_STRING str;
75 unsigned char *p;
76 int i;
77
78 if ((ex == NULL) || (*ex == NULL))
79 os=ASN1_OCTET_STRING_new();
80 else
81 os= *ex;
82
83 if (len < 0) len=strlen((char *)bytes);
84 str.length=len;
85 str.type=type;
86 str.data=bytes;
87
88 /* str now holds the data, we just have to copy it into ->value */
89
90 switch (type)
91 {
92 case V_ASN1_BIT_STRING:
93 i=i2d_ASN1_BIT_STRING((ASN1_BIT_STRING *)&str,NULL);
94 if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i))
95 goto err;
96 p=(unsigned char *)os->data;
97 i2d_ASN1_BIT_STRING((ASN1_BIT_STRING *)&str,&p);
98 break;
99 case V_ASN1_OCTET_STRING:
100 i=i2d_ASN1_OCTET_STRING((ASN1_OCTET_STRING *)&str,NULL);
101 if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i))
102 goto err;
103 p=(unsigned char *)os->data;
104 i2d_ASN1_OCTET_STRING((ASN1_OCTET_STRING *)&str,&p);
105 break;
106 case V_ASN1_IA5STRING:
107 case V_ASN1_PRINTABLESTRING:
108 case V_ASN1_T61STRING:
109 i=i2d_ASN1_bytes(&str,NULL,type,V_ASN1_UNIVERSAL);
110 if (!ASN1_STRING_set((ASN1_STRING *)os,NULL,i))
111 goto err;
112 p=(unsigned char *)os->data;
113 i=i2d_ASN1_bytes(&str,&p,type,V_ASN1_UNIVERSAL);
114 break;
115 default:
116 X509err(X509_F_X509V3_PACK_STRING,X509_R_UNKNOWN_STRING_TYPE);
117 goto err;
118 }
119 os->length=i;
120
121 if ((ex != NULL) && (os != *ex))
122 *ex=os;
123 return(os);
124err:
125 return(NULL);
126 }
127
128ASN1_STRING *X509v3_unpack_string(ex,type,os)
129ASN1_STRING **ex;
130int type;
131ASN1_OCTET_STRING *os;
132 {
133 unsigned char *p;
134 ASN1_STRING *ret=NULL;
135
136 p=os->data;
137 switch (type)
138 {
139 case V_ASN1_BIT_STRING:
140 ret=(ASN1_STRING *)d2i_ASN1_BIT_STRING(
141 (ASN1_BIT_STRING **)ex,&p,os->length);
142 break;
143 case V_ASN1_OCTET_STRING:
144 ret=(ASN1_STRING *)d2i_ASN1_OCTET_STRING(
145 (ASN1_BIT_STRING **)ex,&p,os->length);
146 break;
147 case V_ASN1_IA5STRING:
148 case V_ASN1_PRINTABLESTRING:
149 case V_ASN1_T61STRING:
150 ret=(ASN1_STRING *)d2i_ASN1_PRINTABLE(ex,&p,os->length);
151 break;
152 default:
153 X509err(X509_F_X509V3_UNPACK_STRING,X509_R_UNKNOWN_STRING_TYPE);
154 }
155 return(ret);
156 }
157
diff --git a/src/lib/libssl/src/crypto/x509/x509v3.doc b/src/lib/libssl/src/crypto/x509/x509v3.doc
new file mode 100644
index 0000000000..1e760a9469
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509/x509v3.doc
@@ -0,0 +1,24 @@
1The 'new' system.
2
3The X509_EXTENSION_METHOD includes extensions and attributes and/or names.
4Basically everthing that can be added to an X509 with an OID identifying it.
5
6It operates via 2 methods per object id.
7int a2i_XXX(X509 *x,char *str,int len);
8int i2a_XXX(BIO *bp,X509 *x);
9
10The a2i_XXX function will add the object with a value converted from the
11string into the X509. Len can be -1 in which case the length is calculated
12via strlen(str). Applications can always use direct knowledge to load and
13unload the relevent objects themselves.
14
15i2a_XXX will print to the passed BIO, a text representation of the
16relevet object. Use a memory BIO if you want it printed to a buffer :-).
17
18X509_add_by_NID(X509 *x,int nid,char *str,int len);
19X509_add_by_OBJ(X509 *x,ASN1_OBJECT *obj,char *str,int len);
20
21X509_print_by_name(BIO *bp,X509 *x);
22X509_print_by_NID(BIO *bp,X509 *x);
23X509_print_by_OBJ(BIO *bp,X509 *x);
24
diff --git a/src/lib/libssl/src/crypto/x509v3/format b/src/lib/libssl/src/crypto/x509v3/format
new file mode 100644
index 0000000000..3307978121
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509v3/format
@@ -0,0 +1,92 @@
1AuthorityKeyIdentifier
2 {
3 keyIdentifier [0] OCTET_STRING OPTIONAL
4 authorityCertIssuer [1] GeneralNames OPTIONAL
5 authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL
6 }
7
8SubjectKeyIdentifier OCTET_STRING
9
10KeyUsage
11 {
12 BIT_STRING
13 digitalSignature 0
14 nonRepudiation 1
15 keyEncipherment 2
16 dataEncipherment 3
17 keyAgreement 4
18 keyCertSign 5
19 cRLSign 6
20 encipherOnly 7
21 decipherOnly 8
22 }
23
24extKeyUsage
25 {
26 SEQUENCE of OBJECT_IDENTIFIER
27 }
28
29privateKeyUsagePeriod
30 {
31 notBefore [0] GeneralizedTime OPTIONAL
32 notAfter [1] GeneralizedTime OPTIONAL
33 }
34
35certificatePoliciesSyntax
36 SEQUENCE of PoliciesInformation
37
38PoliciesInformation XXX
39policyMappings XXX
40supportedAlgorithms XXX
41
42subjectAltName
43 GeneralNames sequence of GeneralName
44
45GeneralName
46 {
47 otherName [0] INSTANCE OF OTHER-NAME
48 rfc882Name [1] IA5String
49 dNSName [2] IA5String
50 x400Address [3] ORAddress
51 directoryName [4] Name
52 ediPartyName [5]
53 {
54 nameAssigner [0] DirectoryString OPTIONAL
55 partyName [1] DirectoryString
56 }
57 uniformResourceIdentifier [6] IA5String
58 iPAddress [7] OCTET_STRING
59 registeredID [8] OBJECT_IDENTIFIER
60 }
61
62issuerAltName
63 GeneralNames sequence of GeneralName
64
65subjectDirectoryAttribute SEQUENCE of Attribute
66
67basicConstraints
68 {
69 cA BOOLEAN default FALSE
70 pathLenConstraint INTEGER OPTIONAL
71 }
72
73nameConstraints
74 {
75 permittedSubtrees [0] sequence of GeneralSubtree OPTIONAL
76 excludedSubtrees [1] sequence of GeneralSubtree OPTIONAL
77 }
78
79GeneralSubtree
80 {
81 base GeneralName
82 minimum [0] BaseDistance DEFAULT 0
83 maximum [1] BaseDistance OPTIONAL
84 }
85
86PolicyConstraints
87 {
88 requiredExplicitPolicy [0] SkipCerts OPTIONAL
89 inhibitPolicyMapping [1] SkipCerts OPTIONAL
90 }
91SkipCerts == INTEGER
92
diff --git a/src/lib/libssl/src/crypto/x509v3/header b/src/lib/libssl/src/crypto/x509v3/header
new file mode 100644
index 0000000000..3d791ca3dd
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509v3/header
@@ -0,0 +1,6 @@
1int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size)
2int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a)
3int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp)
4ASN1_INTEGER * d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,long length)
5
6
diff --git a/src/lib/libssl/src/crypto/x509v3/v3_ku.c b/src/lib/libssl/src/crypto/x509v3/v3_ku.c
new file mode 100644
index 0000000000..87c7402f43
--- /dev/null
+++ b/src/lib/libssl/src/crypto/x509v3/v3_ku.c
@@ -0,0 +1,318 @@
1/* crypto/x509v3/v3_ku.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <ctype.h>
61#include "stack.h"
62#include "cryptlib.h"
63#include "bio.h"
64#include "asn1.h"
65#include "objects.h"
66#include "x509.h"
67
68X509_EXTENSION_METHOD X509v3_key_usage_method=
69 {
70 NID_key_usage,
71 ku_clear,
72 ex_get_bool,
73 ex_set_bool,
74 NULL,
75 NULL,
76 NULL,
77 NULL,
78 ku_a2i,
79 ku_i2a,
80 };
81
82static void ku_clear(a)
83X509_EXTENSION *a;
84 {
85 }
86
87static int ku_expand(a)
88X509_EXTENSION *a;
89 {
90 ASN1_BIT_STRING *bs;
91
92 if (a->argp == NULL)
93 {
94 bs=X509v3_unpack_string(NULL,V_ASN1_BIT_STRING,value);
95 if (bs == NULL) return(0);
96 a->argp=(char *)bs;
97 a->ex_free=ASN1_STRING_free;
98 }
99 return(1);
100 }
101
102static int ku_get_bool(a,num)
103X509_EXTENSION *a;
104int num;
105 {
106 int ret;
107 ASN1_BIT_STRING *bs;
108
109 if ((a->argp == NULL) && !ku_expand(a))
110 return(-1);
111 bs=(ASN1_BIT_STRING *)a->argp;
112 ret=ASN1_BIT_STRING_get_bit(bs,num);
113 return(ret);
114 }
115
116static int ku_set_bool(a,num,value)
117X509_EXTENSION *a;
118int num;
119int value;
120 {
121 ASN1_BIT_STRING *a;
122
123 if ((a->argp == NULL) && !ku_expand(a))
124 return(0);
125 bs=(ASN1_BIT_STRING *)a->argp;
126 ret=ASN1_BIT_STRING_set_bit(bs,num,value);
127 }
128
129static int ku_a2i(bio,a,buf,len)
130BIO *bio;
131X509_EXTENSION *a;
132char *buf;
133int len;
134 {
135 get token
136 }
137
138static char ku_names[X509v3_N_KU_NUM]={
139 X509v3_S_KU_digitalSignature,
140 X509v3_S_KU_nonRepudiation,
141 X509v3_S_KU_keyEncipherment,
142 X509v3_S_KU_dataEncipherment,
143 X509v3_S_KU_keyAgreement,
144 X509v3_S_KU_keyCertSign,
145 X509v3_S_KU_cRLSign,
146 X509v3_S_KU_encipherOnly,
147 X509v3_S_KU_decipherOnly,
148 };
149
150static int ku_i2a(bio,a);
151BIO *bio;
152X509_EXTENSION *a;
153 {
154 int i,first=1;
155 char *c;
156
157 for (i=0; i<X509v3_N_KU_NUM; i++)
158 {
159 if (ku_get_bool(a,i) > 0)
160 {
161 BIO_printf(bio,"%s%s",((first)?"":" "),ku_names[i]);
162 first=0;
163 }
164 }
165 }
166
167/***********************/
168
169int X509v3_get_key_usage(x,ret)
170STACK *x;
171unsigned long *ret;
172 {
173 X509_EXTENSION *ext;
174 ASN1_STRING *st;
175 char *p;
176 int i;
177
178 i=X509_get_ext_by_NID(x,NID_key_usage,-1);
179 if (i < 0) return(X509v3_KU_UNDEF);
180 ext=X509_get_ext(x,i);
181 st=X509v3_unpack_string(NULL,V_ASN1_BIT_STRING,
182 X509_EXTENSION_get_data(X509_get_ext(x,i)));
183
184 p=ASN1_STRING_data(st);
185 if (ASN1_STRING_length(st) == 1)
186 i=p[0];
187 else if (ASN1_STRING_length(st) == 2)
188 i=p[0]|(p[1]<<8);
189 else
190 i=0;
191 return(i);
192 }
193
194static struct
195 {
196 char *name;
197 unsigned int value;
198 } key_usage_data[] ={
199 {"digitalSignature", X509v3_KU_DIGITAL_SIGNATURE},
200 {"nonRepudiation", X509v3_KU_NON_REPUDIATION},
201 {"keyEncipherment", X509v3_KU_KEY_ENCIPHERMENT},
202 {"dataEncipherment", X509v3_KU_DATA_ENCIPHERMENT},
203 {"keyAgreement", X509v3_KU_KEY_AGREEMENT},
204 {"keyCertSign", X509v3_KU_KEY_CERT_SIGN},
205 {"cRLSign", X509v3_KU_CRL_SIGN},
206 {"encipherOnly", X509v3_KU_ENCIPHER_ONLY},
207 {"decipherOnly", X509v3_KU_DECIPHER_ONLY},
208 {NULL,0},
209 };
210
211#if 0
212static int a2i_key_usage(x,str,len)
213X509 *x;
214char *str;
215int len;
216 {
217 return(X509v3_set_key_usage(x,a2i_X509v3_key_usage(str)));
218 }
219
220static int i2a_key_usage(bp,x)
221BIO *bp;
222X509 *x;
223 {
224 return(i2a_X509v3_key_usage(bp,X509v3_get_key_usage(x)));
225 }
226#endif
227
228int i2a_X509v3_key_usage(bp,use)
229BIO *bp;
230unsigned int use;
231 {
232 int i=0,first=1;
233
234 for (;;)
235 {
236 if (use | key_usage_data[i].value)
237 {
238 BIO_printf(bp,"%s%s",((first)?"":" "),
239 key_usage_data[i].name);
240 first=0;
241 }
242 }
243 return(1);
244 }
245
246unsigned int a2i_X509v3_key_usage(p)
247char *p;
248 {
249 unsigned int ret=0;
250 char *q,*s;
251 int i,n;
252
253 q=p;
254 for (;;)
255 {
256 while ((*q != '\0') && isalnum(*q))
257 q++;
258 if (*q == '\0') break;
259 s=q++;
260 while (isalnum(*q))
261 q++;
262 n=q-s;
263 i=0;
264 for (;;)
265 {
266 if (strncmp(key_usage_data[i].name,s,n) == 0)
267 {
268 ret|=key_usage_data[i].value;
269 break;
270 }
271 i++;
272 if (key_usage_data[i].name == NULL)
273 return(X509v3_KU_UNDEF);
274 }
275 }
276 return(ret);
277 }
278
279int X509v3_set_key_usage(x,use)
280X509 *x;
281unsigned int use;
282 {
283 ASN1_OCTET_STRING *os;
284 X509_EXTENSION *ext;
285 int i;
286 unsigned char data[4];
287
288 i=X509_get_ext_by_NID(x,NID_key_usage,-1);
289 if (i < 0)
290 {
291 i=X509_get_ext_count(x)+1;
292 if ((ext=X509_EXTENSION_new()) == NULL) return(0);
293 if (!X509_add_ext(x,ext,i))
294 {
295 X509_EXTENSION_free(ext);
296 return(0);
297 }
298 }
299 else
300 ext=X509_get_ext(x,i);
301
302 /* fill in 'ext' */
303 os=X509_EXTENSION_get_data(ext);
304
305 i=0;
306 if (use > 0)
307 {
308 i=1;
309 data[0]=use&0xff;
310 }
311 if (use > 0xff)
312 {
313 i=2;
314 data[1]=(use>>8)&0xff;
315 }
316 return((X509v3_pack_string(&os,V_ASN1_BIT_STRING,data,i) == NULL)?0:1);
317 }
318
diff --git a/src/lib/libssl/src/dep/crypto.txt b/src/lib/libssl/src/dep/crypto.txt
new file mode 100644
index 0000000000..9e5144fec6
--- /dev/null
+++ b/src/lib/libssl/src/dep/crypto.txt
@@ -0,0 +1,1043 @@
1ASN1_BIT_STRING_asn1_meth
2ASN1_BIT_STRING_get_bit
3ASN1_BIT_STRING_set_bit
4ASN1_HEADER_free
5ASN1_HEADER_new
6ASN1_IA5STRING_asn1_meth
7ASN1_INTEGER_get
8ASN1_INTEGER_set
9ASN1_INTEGER_to_BN
10ASN1_OBJECT_create
11ASN1_OBJECT_free
12ASN1_OBJECT_new
13ASN1_PRINTABLE_type
14ASN1_STRING_cmp
15ASN1_STRING_dup
16ASN1_STRING_free
17ASN1_STRING_new
18ASN1_STRING_print
19ASN1_STRING_set
20ASN1_STRING_type_new
21ASN1_TYPE_free
22ASN1_TYPE_get
23ASN1_TYPE_new
24ASN1_TYPE_set
25ASN1_UNIVERSALSTRING_to_string
26ASN1_UTCTIME_check
27ASN1_UTCTIME_print
28ASN1_UTCTIME_set
29ASN1_check_infinite_end
30ASN1_d2i_bio
31ASN1_d2i_fp
32ASN1_digest
33ASN1_dup
34ASN1_get_object
35ASN1_i2d_bio
36ASN1_i2d_fp
37ASN1_object_size
38ASN1_parse
39ASN1_put_object
40ASN1_sign
41ASN1_verify
42BF_cbc_encrypt
43BF_cfb64_encrypt
44BF_decrypt
45BF_ecb_encrypt
46BF_encrypt
47BF_ofb64_encrypt
48BF_options
49BF_set_key
50BIO_ACCEPT_free
51BIO_ACCEPT_new
52BIO_CONNECT_free
53BIO_CONNECT_new
54BIO_accept
55BIO_copy_next_retry
56BIO_ctrl
57BIO_ctrl_int
58BIO_debug_callback
59BIO_dump
60BIO_dup_chain
61BIO_f_base64
62BIO_f_buffer
63BIO_f_cipher
64BIO_f_md
65BIO_f_nbio_test
66BIO_f_null
67BIO_f_proxy_server
68BIO_fd_non_fatal_error
69BIO_fd_should_retry
70BIO_find_type
71BIO_free
72BIO_free_all
73BIO_get_accept_socket
74BIO_get_ex_data
75BIO_get_ex_new_index
76BIO_get_filter_bio
77BIO_get_host_ip
78BIO_get_port
79BIO_get_retry_BIO
80BIO_get_retry_reason
81BIO_gethostbyname
82BIO_gets
83BIO_ghbn_ctrl
84BIO_new
85BIO_new_accept
86BIO_new_connect
87BIO_new_fd
88BIO_new_file
89BIO_new_fp
90BIO_new_socket
91BIO_pop
92BIO_printf
93BIO_ptr_ctrl
94BIO_push
95BIO_puts
96BIO_read
97BIO_s_accept
98BIO_s_connect
99BIO_s_fd
100BIO_s_file
101BIO_s_mem
102BIO_s_null
103BIO_s_proxy_client
104BIO_s_socket
105BIO_set
106BIO_set_cipher
107BIO_set_ex_data
108BIO_set_tcp_ndelay
109BIO_sock_cleanup
110BIO_sock_error
111BIO_sock_init
112BIO_sock_non_fatal_error
113BIO_sock_should_retry
114BIO_socket_ioctl
115BIO_write
116BN_BLINDING_convert
117BN_BLINDING_free
118BN_BLINDING_invert
119BN_BLINDING_new
120BN_BLINDING_update
121BN_CTX_free
122BN_CTX_new
123BN_MONT_CTX_free
124BN_MONT_CTX_new
125BN_MONT_CTX_set
126BN_add
127BN_add_word
128BN_bin2bn
129BN_bn2bin
130BN_bn2dec
131BN_bn2hex
132BN_bn2mpi
133BN_clear
134BN_clear_bit
135BN_clear_free
136BN_cmp
137BN_copy
138BN_dec2bn
139BN_div
140BN_div_word
141BN_dup
142BN_exp
143BN_free
144BN_from_montgomery
145BN_gcd
146BN_generate_prime
147BN_get_word
148BN_hex2bn
149BN_is_bit_set
150BN_is_prime
151BN_lshift
152BN_lshift1
153BN_mask_bits
154BN_mod
155BN_mod_exp
156BN_mod_exp_mont
157BN_mod_exp_recp
158BN_mod_exp_simple
159BN_mod_inverse
160BN_mod_mul
161BN_mod_mul_montgomery
162BN_mod_mul_reciprocal
163BN_mod_word
164BN_mpi2bn
165BN_mul
166BN_mul_word
167BN_new
168BN_num_bits
169BN_num_bits_word
170BN_options
171BN_print
172BN_print_fp
173BN_rand
174BN_reciprocal
175BN_rshift
176BN_rshift1
177BN_set_bit
178BN_set_word
179BN_sqr
180BN_sub
181BN_sub_word
182BN_to_ASN1_INTEGER
183BN_ucmp
184BN_value_one
185BUF_MEM_free
186BUF_MEM_grow
187BUF_MEM_new
188BUF_strdup
189CAST_cbc_encrypt
190CAST_cfb64_encrypt
191CAST_decrypt
192CAST_ecb_encrypt
193CAST_encrypt
194CAST_ofb64_encrypt
195CAST_set_key
196CONF_free
197CONF_get_number
198CONF_get_section
199CONF_get_string
200CONF_load
201CRYPTO_add_lock
202CRYPTO_dbg_free
203CRYPTO_dbg_malloc
204CRYPTO_dbg_realloc
205CRYPTO_dbg_remalloc
206CRYPTO_dup_ex_data
207CRYPTO_free
208CRYPTO_free_ex_data
209CRYPTO_get_add_lock_callback
210CRYPTO_get_ex_data
211CRYPTO_get_ex_new_index
212CRYPTO_get_id_callback
213CRYPTO_get_lock_name
214CRYPTO_get_locking_callback
215CRYPTO_get_mem_functions
216CRYPTO_get_new_lockid
217CRYPTO_lock
218CRYPTO_malloc
219CRYPTO_mem_ctrl
220CRYPTO_mem_leaks
221CRYPTO_mem_leaks_cb
222CRYPTO_mem_leaks_fp
223CRYPTO_new_ex_data
224CRYPTO_realloc
225CRYPTO_remalloc
226CRYPTO_set_add_lock_callback
227CRYPTO_set_ex_data
228CRYPTO_set_id_callback
229CRYPTO_set_locking_callback
230CRYPTO_set_mem_functions
231CRYPTO_thread_id
232DH_check
233DH_compute_key
234DH_free
235DH_generate_key
236DH_generate_parameters
237DH_new
238DH_size
239DHparams_print
240DHparams_print_fp
241DSA_free
242DSA_generate_key
243DSA_generate_parameters
244DSA_is_prime
245DSA_new
246DSA_print
247DSA_print_fp
248DSA_sign
249DSA_sign_setup
250DSA_size
251DSA_verify
252DSAparams_print
253DSAparams_print_fp
254ERR_clear_error
255ERR_error_string
256ERR_free_strings
257ERR_func_error_string
258ERR_get_err_state_table
259ERR_get_error
260ERR_get_error_line
261ERR_get_next_error_library
262ERR_get_state
263ERR_get_string_table
264ERR_lib_error_string
265ERR_load_ASN1_strings
266ERR_load_BIO_strings
267ERR_load_BN_strings
268ERR_load_BUF_strings
269ERR_load_CONF_strings
270ERR_load_CRYPTO_strings
271ERR_load_DH_strings
272ERR_load_DSA_strings
273ERR_load_ERR_strings
274ERR_load_EVP_strings
275ERR_load_OBJ_strings
276ERR_load_PEM_strings
277ERR_load_PKCS7_strings
278ERR_load_PROXY_strings
279ERR_load_RSA_strings
280ERR_load_X509_strings
281ERR_load_crypto_strings
282ERR_load_strings
283ERR_peek_error
284ERR_peek_error_line
285ERR_print_errors
286ERR_print_errors_fp
287ERR_put_error
288ERR_reason_error_string
289ERR_remove_state
290EVP_BytesToKey
291EVP_CIPHER_CTX_cleanup
292EVP_CIPHER_CTX_init
293EVP_CipherFinal
294EVP_CipherInit
295EVP_CipherUpdate
296EVP_DecodeBlock
297EVP_DecodeFinal
298EVP_DecodeInit
299EVP_DecodeUpdate
300EVP_DecryptFinal
301EVP_DecryptInit
302EVP_DecryptUpdate
303EVP_DigestFinal
304EVP_DigestInit
305EVP_DigestUpdate
306EVP_EncodeBlock
307EVP_EncodeFinal
308EVP_EncodeInit
309EVP_EncodeUpdate
310EVP_EncryptFinal
311EVP_EncryptInit
312EVP_EncryptUpdate
313EVP_OpenFinal
314EVP_OpenInit
315EVP_PKEY_assign
316EVP_PKEY_bits
317EVP_PKEY_cmp_parameters
318EVP_PKEY_copy_parameters
319EVP_PKEY_free
320EVP_PKEY_missing_parameters
321EVP_PKEY_new
322EVP_PKEY_save_parameters
323EVP_PKEY_size
324EVP_PKEY_type
325EVP_SealFinal
326EVP_SealInit
327EVP_SignFinal
328EVP_VerifyFinal
329EVP_add_alias
330EVP_add_cipher
331EVP_add_digest
332EVP_bf_cbc
333EVP_bf_cfb
334EVP_bf_ecb
335EVP_bf_ofb
336EVP_cast5_cbc
337EVP_cast5_cfb
338EVP_cast5_ecb
339EVP_cast5_ofb
340EVP_cleanup
341EVP_delete_alias
342EVP_des_cbc
343EVP_des_cfb
344EVP_des_ecb
345EVP_des_ede
346EVP_des_ede3
347EVP_des_ede3_cbc
348EVP_des_ede3_cfb
349EVP_des_ede3_ofb
350EVP_des_ede_cbc
351EVP_des_ede_cfb
352EVP_des_ede_ofb
353EVP_des_ofb
354EVP_desx_cbc
355EVP_dss
356EVP_dss1
357EVP_enc_null
358EVP_get_cipherbyname
359EVP_get_digestbyname
360EVP_get_pw_prompt
361EVP_idea_cbc
362EVP_idea_cfb
363EVP_idea_ecb
364EVP_idea_ofb
365EVP_md2
366EVP_md5
367EVP_md_null
368EVP_mdc2
369EVP_rc2_40_cbc
370EVP_rc2_cbc
371EVP_rc2_cfb
372EVP_rc2_ecb
373EVP_rc2_ofb
374EVP_rc4
375EVP_rc4_40
376EVP_read_pw_string
377EVP_set_pw_prompt
378EVP_sha
379EVP_sha1
380HMAC
381HMAC_Final
382HMAC_Init
383HMAC_Update
384HMAC_cleanup
385MD2
386MD2_Final
387MD2_Init
388MD2_Update
389MD2_options
390MD5
391MD5_Final
392MD5_Init
393MD5_Transform
394MD5_Update
395MDC2
396MDC2_Final
397MDC2_Init
398MDC2_Update
399NETSCAPE_SPKAC_free
400NETSCAPE_SPKAC_new
401NETSCAPE_SPKI_free
402NETSCAPE_SPKI_new
403NETSCAPE_SPKI_sign
404NETSCAPE_SPKI_verify
405OBJ_add_object
406OBJ_bsearch
407OBJ_cleanup
408OBJ_cmp
409OBJ_create
410OBJ_create_objects
411OBJ_dup
412OBJ_ln2nid
413OBJ_new_nid
414OBJ_nid2ln
415OBJ_nid2obj
416OBJ_nid2sn
417OBJ_obj2nid
418OBJ_sn2nid
419OBJ_txt2nid
420PEM_ASN1_read
421PEM_ASN1_read_bio
422PEM_ASN1_write
423PEM_ASN1_write_bio
424PEM_SealFinal
425PEM_SealInit
426PEM_SealUpdate
427PEM_SignFinal
428PEM_SignInit
429PEM_SignUpdate
430PEM_X509_INFO_read
431PEM_X509_INFO_read_bio
432PEM_X509_INFO_write_bio
433PEM_dek_info
434PEM_do_header
435PEM_get_EVP_CIPHER_INFO
436PEM_proc_type
437PEM_read
438PEM_read_DHparams
439PEM_read_DSAPrivateKey
440PEM_read_DSAparams
441PEM_read_PKCS7
442PEM_read_PrivateKey
443PEM_read_RSAPrivateKey
444PEM_read_RSAPublicKey
445PEM_read_X509
446PEM_read_X509_CRL
447PEM_read_X509_REQ
448PEM_read_bio
449PEM_read_bio_DHparams
450PEM_read_bio_DSAPrivateKey
451PEM_read_bio_DSAparams
452PEM_read_bio_PKCS7
453PEM_read_bio_PrivateKey
454PEM_read_bio_RSAPrivateKey
455PEM_read_bio_RSAPublicKey
456PEM_read_bio_X509
457PEM_read_bio_X509_CRL
458PEM_read_bio_X509_REQ
459PEM_write
460PEM_write_DHparams
461PEM_write_DSAPrivateKey
462PEM_write_DSAparams
463PEM_write_PKCS7
464PEM_write_PrivateKey
465PEM_write_RSAPrivateKey
466PEM_write_RSAPublicKey
467PEM_write_X509
468PEM_write_X509_CRL
469PEM_write_X509_REQ
470PEM_write_bio
471PEM_write_bio_DHparams
472PEM_write_bio_DSAPrivateKey
473PEM_write_bio_DSAparams
474PEM_write_bio_PKCS7
475PEM_write_bio_PrivateKey
476PEM_write_bio_RSAPrivateKey
477PEM_write_bio_RSAPublicKey
478PEM_write_bio_X509
479PEM_write_bio_X509_CRL
480PEM_write_bio_X509_REQ
481PKCS7_DIGEST_free
482PKCS7_DIGEST_new
483PKCS7_ENCRYPT_free
484PKCS7_ENCRYPT_new
485PKCS7_ENC_CONTENT_free
486PKCS7_ENC_CONTENT_new
487PKCS7_ENVELOPE_free
488PKCS7_ENVELOPE_new
489PKCS7_ISSUER_AND_SERIAL_digest
490PKCS7_ISSUER_AND_SERIAL_free
491PKCS7_ISSUER_AND_SERIAL_new
492PKCS7_RECIP_INFO_free
493PKCS7_RECIP_INFO_new
494PKCS7_SIGNED_free
495PKCS7_SIGNED_new
496PKCS7_SIGNER_INFO_free
497PKCS7_SIGNER_INFO_new
498PKCS7_SIGNER_INFO_set
499PKCS7_SIGN_ENVELOPE_free
500PKCS7_SIGN_ENVELOPE_new
501PKCS7_add_certificate
502PKCS7_add_crl
503PKCS7_add_signature
504PKCS7_add_signer
505PKCS7_cert_from_signer_info
506PKCS7_content_free
507PKCS7_content_new
508PKCS7_ctrl
509PKCS7_dataInit
510PKCS7_dataSign
511PKCS7_dataVerify
512PKCS7_dup
513PKCS7_free
514PKCS7_get_signer_info
515PKCS7_new
516PKCS7_set_content
517PKCS7_set_type
518PROXY_ENTRY_add_noproxy
519PROXY_ENTRY_clear_noproxy
520PROXY_ENTRY_free
521PROXY_ENTRY_get_noproxy
522PROXY_ENTRY_new
523PROXY_ENTRY_set_server
524PROXY_add_noproxy
525PROXY_add_server
526PROXY_check_by_host
527PROXY_check_url
528PROXY_clear_noproxy
529PROXY_free
530PROXY_get_noproxy
531PROXY_get_proxies
532PROXY_get_proxy_entry
533PROXY_load_conf
534PROXY_new
535PROXY_print
536RAND_bytes
537RAND_cleanup
538RAND_file_name
539RAND_load_file
540RAND_seed
541RAND_write_file
542RC2_cbc_encrypt
543RC2_cfb64_encrypt
544RC2_decrypt
545RC2_ecb_encrypt
546RC2_encrypt
547RC2_ofb64_encrypt
548RC2_set_key
549RC4
550RC4_options
551RC4_set_key
552RC5_32_cbc_encrypt
553RC5_32_cfb64_encrypt
554RC5_32_decrypt
555RC5_32_ecb_encrypt
556RC5_32_encrypt
557RC5_32_ofb64_encrypt
558RC5_32_set_key
559RIPEMD160
560RIPEMD160_Final
561RIPEMD160_Init
562RIPEMD160_Transform
563RIPEMD160_Update
564RSAPrivateKey_asn1_meth
565RSAPrivateKey_dup
566RSAPublicKey_dup
567RSA_PKCS1_SSLeay
568RSA_blinding_off
569RSA_blinding_on
570RSA_flags
571RSA_free
572RSA_generate_key
573RSA_get_ex_data
574RSA_get_ex_new_index
575RSA_new
576RSA_new_method
577RSA_padding_add_PKCS1_type_1
578RSA_padding_add_PKCS1_type_2
579RSA_padding_add_SSLv23
580RSA_padding_add_none
581RSA_padding_check_PKCS1_type_1
582RSA_padding_check_PKCS1_type_2
583RSA_padding_check_SSLv23
584RSA_padding_check_none
585RSA_print
586RSA_print_fp
587RSA_private_decrypt
588RSA_private_encrypt
589RSA_public_decrypt
590RSA_public_encrypt
591RSA_set_default_method
592RSA_set_ex_data
593RSA_sign
594RSA_sign_ASN1_OCTET_STRING
595RSA_size
596RSA_verify
597RSA_verify_ASN1_OCTET_STRING
598SHA
599SHA1
600SHA1_Final
601SHA1_Init
602SHA1_Transform
603SHA1_Update
604SHA_Final
605SHA_Init
606SHA_Transform
607SHA_Update
608SSLeay
609SSLeay_add_all_algorithms
610SSLeay_add_all_ciphers
611SSLeay_add_all_digests
612SSLeay_version
613TXT_DB_create_index
614TXT_DB_free
615TXT_DB_get_by_index
616TXT_DB_insert
617TXT_DB_read
618TXT_DB_write
619X509_ALGOR_free
620X509_ALGOR_new
621X509_ATTRIBUTE_free
622X509_ATTRIBUTE_new
623X509_CINF_free
624X509_CINF_new
625X509_CRL_INFO_free
626X509_CRL_INFO_new
627X509_CRL_add_ext
628X509_CRL_cmp
629X509_CRL_delete_ext
630X509_CRL_dup
631X509_CRL_free
632X509_CRL_get_ext
633X509_CRL_get_ext_by_NID
634X509_CRL_get_ext_by_OBJ
635X509_CRL_get_ext_by_critical
636X509_CRL_get_ext_count
637X509_CRL_new
638X509_CRL_sign
639X509_CRL_verify
640X509_EXTENSION_create_by_NID
641X509_EXTENSION_create_by_OBJ
642X509_EXTENSION_dup
643X509_EXTENSION_free
644X509_EXTENSION_get_critical
645X509_EXTENSION_get_data
646X509_EXTENSION_get_object
647X509_EXTENSION_new
648X509_EXTENSION_set_critical
649X509_EXTENSION_set_data
650X509_EXTENSION_set_object
651X509_INFO_free
652X509_INFO_new
653X509_LOOKUP_by_alias
654X509_LOOKUP_by_fingerprint
655X509_LOOKUP_by_issuer_serial
656X509_LOOKUP_by_subject
657X509_LOOKUP_ctrl
658X509_LOOKUP_file
659X509_LOOKUP_free
660X509_LOOKUP_hash_dir
661X509_LOOKUP_init
662X509_LOOKUP_new
663X509_LOOKUP_shutdown
664X509_NAME_ENTRY_create_by_NID
665X509_NAME_ENTRY_create_by_OBJ
666X509_NAME_ENTRY_dup
667X509_NAME_ENTRY_free
668X509_NAME_ENTRY_get_data
669X509_NAME_ENTRY_get_object
670X509_NAME_ENTRY_new
671X509_NAME_ENTRY_set_data
672X509_NAME_ENTRY_set_object
673X509_NAME_add_entry
674X509_NAME_cmp
675X509_NAME_delete_entry
676X509_NAME_digest
677X509_NAME_dup
678X509_NAME_entry_count
679X509_NAME_free
680X509_NAME_get_entry
681X509_NAME_get_index_by_NID
682X509_NAME_get_index_by_OBJ
683X509_NAME_get_text_by_NID
684X509_NAME_get_text_by_OBJ
685X509_NAME_hash
686X509_NAME_new
687X509_NAME_oneline
688X509_NAME_print
689X509_NAME_set
690X509_OBJECT_free_contents
691X509_OBJECT_retrive_by_subject
692X509_OBJECT_up_ref_count
693X509_PKEY_free
694X509_PKEY_new
695X509_PUBKEY_free
696X509_PUBKEY_get
697X509_PUBKEY_new
698X509_PUBKEY_set
699X509_REQ_INFO_free
700X509_REQ_INFO_new
701X509_REQ_dup
702X509_REQ_free
703X509_REQ_get_pubkey
704X509_REQ_new
705X509_REQ_print
706X509_REQ_print_fp
707X509_REQ_set_pubkey
708X509_REQ_set_subject_name
709X509_REQ_set_version
710X509_REQ_sign
711X509_REQ_to_X509
712X509_REQ_verify
713X509_REVOKED_add_ext
714X509_REVOKED_delete_ext
715X509_REVOKED_free
716X509_REVOKED_get_ext
717X509_REVOKED_get_ext_by_NID
718X509_REVOKED_get_ext_by_OBJ
719X509_REVOKED_get_ext_by_critical
720X509_REVOKED_get_ext_count
721X509_REVOKED_new
722X509_SIG_free
723X509_SIG_new
724X509_STORE_CTX_cleanup
725X509_STORE_CTX_get_chain
726X509_STORE_CTX_get_current_cert
727X509_STORE_CTX_get_error
728X509_STORE_CTX_get_error_depth
729X509_STORE_CTX_get_ex_data
730X509_STORE_CTX_get_ex_new_index
731X509_STORE_CTX_init
732X509_STORE_CTX_set_cert
733X509_STORE_CTX_set_chain
734X509_STORE_CTX_set_error
735X509_STORE_CTX_set_ex_data
736X509_STORE_add_cert
737X509_STORE_add_crl
738X509_STORE_add_lookup
739X509_STORE_free
740X509_STORE_get_by_subject
741X509_STORE_load_locations
742X509_STORE_new
743X509_STORE_set_default_paths
744X509_VAL_free
745X509_VAL_new
746X509_add_ext
747X509_asn1_meth
748X509_certificate_type
749X509_check_private_key
750X509_cmp_current_time
751X509_delete_ext
752X509_digest
753X509_dup
754X509_find_by_issuer_and_serial
755X509_find_by_subject
756X509_free
757X509_get_default_cert_area
758X509_get_default_cert_dir
759X509_get_default_cert_dir_env
760X509_get_default_cert_file
761X509_get_default_cert_file_env
762X509_get_default_private_dir
763X509_get_ext
764X509_get_ext_by_NID
765X509_get_ext_by_OBJ
766X509_get_ext_by_critical
767X509_get_ext_count
768X509_get_issuer_name
769X509_get_pubkey
770X509_get_pubkey_parameters
771X509_get_serialNumber
772X509_get_subject_name
773X509_gmtime_adj
774X509_issuer_and_serial_cmp
775X509_issuer_and_serial_hash
776X509_issuer_name_cmp
777X509_issuer_name_hash
778X509_load_cert_file
779X509_load_crl_file
780X509_new
781X509_print
782X509_print_fp
783X509_set_issuer_name
784X509_set_notAfter
785X509_set_notBefore
786X509_set_pubkey
787X509_set_serialNumber
788X509_set_subject_name
789X509_set_version
790X509_sign
791X509_subject_name_cmp
792X509_subject_name_hash
793X509_to_X509_REQ
794X509_verify
795X509_verify_cert
796X509_verify_cert_error_string
797X509v3_add_ext
798X509v3_add_extension
799X509v3_add_netscape_extensions
800X509v3_add_standard_extensions
801X509v3_cleanup_extensions
802X509v3_data_type_by_NID
803X509v3_data_type_by_OBJ
804X509v3_delete_ext
805X509v3_get_ext
806X509v3_get_ext_by_NID
807X509v3_get_ext_by_OBJ
808X509v3_get_ext_by_critical
809X509v3_get_ext_count
810X509v3_get_key_usage
811X509v3_pack_string
812X509v3_pack_type_by_NID
813X509v3_pack_type_by_OBJ
814X509v3_set_key_usage
815X509v3_unpack_string
816_des_crypt
817a2d_ASN1_OBJECT
818a2i_ASN1_INTEGER
819a2i_ASN1_STRING
820a2i_X509v3_key_usage
821asn1_Finish
822asn1_GetSequence
823bn_add_words
824bn_div64
825bn_expand2
826bn_mul_add_words
827bn_mul_words
828bn_qadd
829bn_qsub
830bn_sqr_words
831crypt
832d2i_ASN1_BIT_STRING
833d2i_ASN1_BOOLEAN
834d2i_ASN1_HEADER
835d2i_ASN1_IA5STRING
836d2i_ASN1_INTEGER
837d2i_ASN1_OBJECT
838d2i_ASN1_OCTET_STRING
839d2i_ASN1_PRINTABLE
840d2i_ASN1_PRINTABLESTRING
841d2i_ASN1_SET
842d2i_ASN1_T61STRING
843d2i_ASN1_TYPE
844d2i_ASN1_UTCTIME
845d2i_ASN1_bytes
846d2i_ASN1_type_bytes
847d2i_DHparams
848d2i_DSAPrivateKey
849d2i_DSAPrivateKey_bio
850d2i_DSAPrivateKey_fp
851d2i_DSAPublicKey
852d2i_DSAparams
853d2i_NETSCAPE_SPKAC
854d2i_NETSCAPE_SPKI
855d2i_Netscape_RSA
856d2i_Netscape_RSA_2
857d2i_PKCS7
858d2i_PKCS7_DIGEST
859d2i_PKCS7_ENCRYPT
860d2i_PKCS7_ENC_CONTENT
861d2i_PKCS7_ENVELOPE
862d2i_PKCS7_ISSUER_AND_SERIAL
863d2i_PKCS7_RECIP_INFO
864d2i_PKCS7_SIGNED
865d2i_PKCS7_SIGNER_INFO
866d2i_PKCS7_SIGN_ENVELOPE
867d2i_PKCS7_bio
868d2i_PKCS7_fp
869d2i_PrivateKey
870d2i_PublicKey
871d2i_RSAPrivateKey
872d2i_RSAPrivateKey_bio
873d2i_RSAPrivateKey_fp
874d2i_RSAPublicKey
875d2i_RSAPublicKey_bio
876d2i_RSAPublicKey_fp
877d2i_X509
878d2i_X509_ALGOR
879d2i_X509_ATTRIBUTE
880d2i_X509_CINF
881d2i_X509_CRL
882d2i_X509_CRL_INFO
883d2i_X509_CRL_bio
884d2i_X509_CRL_fp
885d2i_X509_EXTENSION
886d2i_X509_NAME
887d2i_X509_NAME_ENTRY
888d2i_X509_PKEY
889d2i_X509_PUBKEY
890d2i_X509_REQ
891d2i_X509_REQ_INFO
892d2i_X509_REQ_bio
893d2i_X509_REQ_fp
894d2i_X509_REVOKED
895d2i_X509_SIG
896d2i_X509_VAL
897d2i_X509_bio
898d2i_X509_fp
899des_cbc_cksum
900des_cbc_encrypt
901des_cblock_print_file
902des_cfb64_encrypt
903des_cfb_encrypt
904des_decrypt3
905des_ecb3_encrypt
906des_ecb_encrypt
907des_ede3_cbc_encrypt
908des_ede3_cfb64_encrypt
909des_ede3_ofb64_encrypt
910des_enc_read
911des_enc_write
912des_encrypt
913des_encrypt2
914des_encrypt3
915des_fcrypt
916des_is_weak_key
917des_key_sched
918des_ncbc_encrypt
919des_ofb64_encrypt
920des_ofb_encrypt
921des_options
922des_pcbc_encrypt
923des_quad_cksum
924des_random_key
925des_random_seed
926des_read_2passwords
927des_read_password
928des_read_pw
929des_read_pw_string
930des_set_key
931des_set_odd_parity
932des_string_to_2keys
933des_string_to_key
934des_xcbc_encrypt
935des_xwhite_in2out
936fcrypt_body
937i2a_ASN1_INTEGER
938i2a_ASN1_OBJECT
939i2a_ASN1_STRING
940i2a_X509v3_key_usage
941i2d_ASN1_BIT_STRING
942i2d_ASN1_BOOLEAN
943i2d_ASN1_HEADER
944i2d_ASN1_IA5STRING
945i2d_ASN1_INTEGER
946i2d_ASN1_OBJECT
947i2d_ASN1_OCTET_STRING
948i2d_ASN1_PRINTABLE
949i2d_ASN1_SET
950i2d_ASN1_TYPE
951i2d_ASN1_UTCTIME
952i2d_ASN1_bytes
953i2d_DHparams
954i2d_DSAPrivateKey
955i2d_DSAPrivateKey_bio
956i2d_DSAPrivateKey_fp
957i2d_DSAPublicKey
958i2d_DSAparams
959i2d_NETSCAPE_SPKAC
960i2d_NETSCAPE_SPKI
961i2d_Netscape_RSA
962i2d_PKCS7
963i2d_PKCS7_DIGEST
964i2d_PKCS7_ENCRYPT
965i2d_PKCS7_ENC_CONTENT
966i2d_PKCS7_ENVELOPE
967i2d_PKCS7_ISSUER_AND_SERIAL
968i2d_PKCS7_RECIP_INFO
969i2d_PKCS7_SIGNED
970i2d_PKCS7_SIGNER_INFO
971i2d_PKCS7_SIGN_ENVELOPE
972i2d_PKCS7_bio
973i2d_PKCS7_fp
974i2d_PrivateKey
975i2d_PublicKey
976i2d_RSAPrivateKey
977i2d_RSAPrivateKey_bio
978i2d_RSAPrivateKey_fp
979i2d_RSAPublicKey
980i2d_RSAPublicKey_bio
981i2d_RSAPublicKey_fp
982i2d_X509
983i2d_X509_ALGOR
984i2d_X509_ATTRIBUTE
985i2d_X509_CINF
986i2d_X509_CRL
987i2d_X509_CRL_INFO
988i2d_X509_CRL_bio
989i2d_X509_CRL_fp
990i2d_X509_EXTENSION
991i2d_X509_NAME
992i2d_X509_NAME_ENTRY
993i2d_X509_PKEY
994i2d_X509_PUBKEY
995i2d_X509_REQ
996i2d_X509_REQ_INFO
997i2d_X509_REQ_bio
998i2d_X509_REQ_fp
999i2d_X509_REVOKED
1000i2d_X509_SIG
1001i2d_X509_VAL
1002i2d_X509_bio
1003i2d_X509_fp
1004i2t_ASN1_OBJECT
1005idea_cbc_encrypt
1006idea_cfb64_encrypt
1007idea_ecb_encrypt
1008idea_encrypt
1009idea_ofb64_encrypt
1010idea_options
1011idea_set_decrypt_key
1012idea_set_encrypt_key
1013lh_delete
1014lh_doall
1015lh_doall_arg
1016lh_free
1017lh_insert
1018lh_new
1019lh_node_stats
1020lh_node_stats_bio
1021lh_node_usage_stats
1022lh_node_usage_stats_bio
1023lh_retrieve
1024lh_stats
1025lh_stats_bio
1026lh_strhash
1027ripemd160_block
1028sha1_block
1029sha_block
1030sk_delete
1031sk_delete_ptr
1032sk_dup
1033sk_find
1034sk_free
1035sk_insert
1036sk_new
1037sk_pop
1038sk_pop_free
1039sk_push
1040sk_set_cmp_func
1041sk_shift
1042sk_unshift
1043sk_zero
diff --git a/src/lib/libssl/src/dep/files b/src/lib/libssl/src/dep/files
new file mode 100644
index 0000000000..8c5550c37c
--- /dev/null
+++ b/src/lib/libssl/src/dep/files
@@ -0,0 +1,574 @@
1./e_os.h
2
3./crypto/cryptall.h CRYPTO
4./crypto/cryptlib.h CRYPTO
5./crypto/crypto.c CRYPTO
6./crypto/cversion.c CRYPTO
7./crypto/date.h CRYPTO
8./crypto/mem.c CRYPTO
9./crypto/cpt_err.c CRYPTO
10./crypto/ex_data.c CRYPTO
11./crypto/crypto.h CRYPTO
12./crypto/cryptlib.c CRYPTO
13./crypto/tmdiff.c CRYPTO
14
15./crypto/asn1/asn1.h ASN1
16./crypto/asn1/asn1_mac.h ASN1
17./crypto/asn1/asn1_err.c ASN1
18./crypto/asn1/asn1_lib.c ASN1
19./crypto/asn1/asn1_par.c ASN1
20./crypto/asn1/a_bitstr.c ASN1
21./crypto/asn1/a_bmp.c ASN1
22./crypto/asn1/a_bool.c ASN1
23./crypto/asn1/a_bytes.c ASN1
24./crypto/asn1/a_d2i_fp.c ASN1
25./crypto/asn1/a_digest.c ASN1
26./crypto/asn1/a_dup.c ASN1
27./crypto/asn1/a_hdr.c ASN1
28./crypto/asn1/a_i2d_fp.c ASN1
29./crypto/asn1/a_int.c ASN1
30./crypto/asn1/a_meth.c ASN1
31./crypto/asn1/a_object.c ASN1
32./crypto/asn1/a_octet.c ASN1
33./crypto/asn1/a_print.c ASN1
34./crypto/asn1/a_set.c ASN1
35./crypto/asn1/a_sign.c ASN1
36./crypto/asn1/a_type.c ASN1
37./crypto/asn1/a_utctm.c ASN1
38./crypto/asn1/a_verify.c ASN1
39./crypto/asn1/d2i_dhp.c ASN1
40./crypto/asn1/d2i_dsap.c ASN1
41./crypto/asn1/d2i_pr.c ASN1
42./crypto/asn1/d2i_pu.c ASN1
43./crypto/asn1/d2i_r_pr.c ASN1
44./crypto/asn1/d2i_r_pu.c ASN1
45./crypto/asn1/d2i_s_pr.c ASN1
46./crypto/asn1/d2i_s_pu.c ASN1
47./crypto/asn1/f_int.c ASN1
48./crypto/asn1/f_string.c ASN1
49./crypto/asn1/i2d_dhp.c ASN1
50./crypto/asn1/i2d_dsap.c ASN1
51./crypto/asn1/i2d_pr.c ASN1
52./crypto/asn1/i2d_pu.c ASN1
53./crypto/asn1/i2d_r_pr.c ASN1
54./crypto/asn1/i2d_r_pu.c ASN1
55./crypto/asn1/i2d_s_pr.c ASN1
56./crypto/asn1/i2d_s_pu.c ASN1
57./crypto/asn1/n_pkey.c ASN1
58./crypto/asn1/p7_dgst.c ASN1
59./crypto/asn1/p7_enc.c ASN1
60./crypto/asn1/p7_enc_c.c ASN1
61./crypto/asn1/p7_evp.c ASN1
62./crypto/asn1/p7_i_s.c ASN1
63./crypto/asn1/p7_lib.c ASN1
64./crypto/asn1/p7_recip.c ASN1
65./crypto/asn1/p7_signd.c ASN1
66./crypto/asn1/p7_signi.c ASN1
67./crypto/asn1/p7_s_e.c ASN1
68./crypto/asn1/pk.c ASN1
69./crypto/asn1/pkcs8.c ASN1
70./crypto/asn1/t_pkey.c ASN1
71./crypto/asn1/t_req.c ASN1
72./crypto/asn1/t_x509.c ASN1
73./crypto/asn1/x_algor.c ASN1
74./crypto/asn1/x_attrib.c ASN1
75./crypto/asn1/x_cinf.c ASN1
76./crypto/asn1/x_crl.c ASN1
77./crypto/asn1/x_exten.c ASN1
78./crypto/asn1/x_info.c ASN1
79./crypto/asn1/x_name.c ASN1
80./crypto/asn1/x_pkey.c ASN1
81./crypto/asn1/x_pubkey.c ASN1
82./crypto/asn1/x_req.c ASN1
83./crypto/asn1/x_sig.c ASN1
84./crypto/asn1/x_spki.c ASN1
85./crypto/asn1/x_val.c ASN1
86./crypto/asn1/x_x509.c ASN1
87
88./crypto/bf/blowfish.h BF
89./crypto/bf/bf_pi.h BF
90./crypto/bf/bf_locl.h BF
91./crypto/bf/bfspeed.c BF
92./crypto/bf/bftest.c BF
93./crypto/bf/bf_cbc.c BF
94./crypto/bf/bf_cfb64.c BF
95./crypto/bf/bf_ecb.c BF
96./crypto/bf/bf_enc.c BF
97./crypto/bf/bf_ofb64.c BF
98./crypto/bf/bf_opts.c BF
99./crypto/bf/bf_skey.c BF
100
101./crypto/bio/bio.h BIO
102./crypto/bio/bf_buff.c BIO
103./crypto/bio/bf_nbio.c BIO
104./crypto/bio/bf_null.c BIO
105./crypto/bio/bio_cb.c BIO
106./crypto/bio/bio_err.c BIO
107./crypto/bio/bio_lib.c BIO
108./crypto/bio/bss_acpt.c BIO
109./crypto/bio/bss_conn.c BIO
110./crypto/bio/bss_fd.c BIO
111./crypto/bio/bss_file.c BIO
112./crypto/bio/bss_mem.c BIO
113./crypto/bio/bss_null.c BIO
114./crypto/bio/bss_rtcp.c BIO
115./crypto/bio/bss_sock.c BIO
116./crypto/bio/b_dump.c BIO
117./crypto/bio/b_print.c BIO
118./crypto/bio/b_sock.c BIO
119
120./crypto/bn/bn.h BN
121./crypto/bn/bn_lcl.h BN
122./crypto/bn/bn_prime.h BN
123./crypto/bn/bnspeed.c BN
124./crypto/bn/bntest.c BN
125./crypto/bn/bn_add.c BN
126./crypto/bn/bn_bld.c BN
127./crypto/bn/bn_blind.c BN
128./crypto/bn/bn_div.c BN
129./crypto/bn/bn_err.c BN
130./crypto/bn/bn_exp.c BN
131./crypto/bn/bn_gcd.c BN
132./crypto/bn/bn_lib.c BN
133./crypto/bn/bn_mod.c BN
134./crypto/bn/bn_mont.c BN
135./crypto/bn/bn_mul.c BN
136./crypto/bn/bn_mulw.c BN
137./crypto/bn/bn_prime.c BN
138./crypto/bn/bn_print.c BN
139./crypto/bn/bn_rand.c BN
140./crypto/bn/bn_recp.c BN
141./crypto/bn/bn_shift.c BN
142./crypto/bn/bn_sqr.c BN
143./crypto/bn/bn_sub.c BN
144./crypto/bn/bn_word.c BN
145./crypto/bn/bn_m.c BN
146./crypto/bn/m.c BN
147./crypto/bn/expspeed.c BN
148./crypto/bn/bn_mpi.c BN
149./crypto/bn/exptest.c BN
150
151./crypto/buffer/buffer.c BUFF
152./crypto/buffer/buffer.h BUFF
153./crypto/buffer/buf_err.c BUFF
154
155./crypto/cast/cast.h CAST
156./crypto/cast/castopts.c CAST
157./crypto/cast/casttest.c CAST
158./crypto/cast/cast_lcl.h CAST
159./crypto/cast/cast_s.h CAST
160./crypto/cast/cast_spd.c CAST
161./crypto/cast/c_cfb64.c CAST
162./crypto/cast/c_ecb.c CAST
163./crypto/cast/c_enc.c CAST
164./crypto/cast/c_ofb64.c CAST
165./crypto/cast/c_skey.c CAST
166
167./crypto/conf/conf_lcl.h CONF
168./crypto/conf/cnf_save.c CONF
169./crypto/conf/conf.c CONF
170./crypto/conf/conf.h CONF
171./crypto/conf/conf_err.c CONF
172
173./crypto/des/des.h DES
174./crypto/des/des_locl.h DES
175./crypto/des/spr.h DES
176./crypto/des/podd.h DES
177./crypto/des/sk.h DES
178./crypto/des/cbc3_enc.c DES
179./crypto/des/cbc_cksm.c DES
180./crypto/des/cbc_enc.c DES
181./crypto/des/cfb64ede.c DES
182./crypto/des/cfb64enc.c DES
183./crypto/des/cfb_enc.c DES
184./crypto/des/des.c DES
185./crypto/des/destest.c DES
186./crypto/des/des_enc.c DES
187./crypto/des/des_opts.c DES
188./crypto/des/des_ver.h DES
189./crypto/des/ecb3_enc.c DES
190./crypto/des/ecb_enc.c DES
191./crypto/des/ede_enc.c DES
192./crypto/des/enc_read.c DES
193./crypto/des/enc_writ.c DES
194./crypto/des/fcrypt.c DES
195./crypto/des/fcrypt_b.c DES
196./crypto/des/ncbc_enc.c DES
197./crypto/des/ofb64ede.c DES
198./crypto/des/ofb64enc.c DES
199./crypto/des/ofb_enc.c DES
200./crypto/des/pcbc_enc.c DES
201./crypto/des/qud_cksm.c DES
202./crypto/des/rand_key.c DES
203./crypto/des/read2pwd.c DES
204./crypto/des/read_pwd.c DES
205./crypto/des/rpc_des.h DES
206./crypto/des/rpc_enc.c DES
207./crypto/des/rpw.c DES
208./crypto/des/set_key.c DES
209./crypto/des/str2key.c DES
210./crypto/des/supp.c DES
211./crypto/des/xcbc_enc.c DES
212
213./crypto/dh/dh.h DH
214./crypto/dh/dh_check.c DH
215./crypto/dh/dh_err.c DH
216./crypto/dh/dh_gen.c DH
217./crypto/dh/dh_key.c DH
218./crypto/dh/dh_lib.c DH
219./crypto/dh/p1024.c DH
220./crypto/dh/p192.c DH
221./crypto/dh/p512.c DH
222./crypto/dh/dhtest.c DH
223
224./crypto/dsa/dsa.h DSA
225./crypto/dsa/dsagen.c DSA
226./crypto/dsa/dsa_err.c DSA
227./crypto/dsa/dsa_gen.c DSA
228./crypto/dsa/dsa_key.c DSA
229./crypto/dsa/dsa_lib.c DSA
230./crypto/dsa/dsa_sign.c DSA
231./crypto/dsa/dsa_vrf.c DSA
232./crypto/dsa/dsatest.c DSA
233
234./crypto/err/err.c ERR
235./crypto/err/err.h ERR
236./crypto/err/err_all.c ERR
237./crypto/err/err_prn.c ERR
238
239./crypto/evp/evp.h EVP
240./crypto/evp/bio_b64.c EVP
241./crypto/evp/bio_enc.c EVP
242./crypto/evp/bio_md.c EVP
243./crypto/evp/c_all.c EVP
244./crypto/evp/digest.c EVP
245./crypto/evp/encode.c EVP
246./crypto/evp/evp_enc.c EVP
247./crypto/evp/evp_err.c EVP
248./crypto/evp/evp_key.c EVP
249./crypto/evp/e_cbc_3d.c EVP
250./crypto/evp/e_cbc_bf.c EVP
251./crypto/evp/e_cbc_c.c EVP
252./crypto/evp/e_cbc_d.c EVP
253./crypto/evp/e_cbc_i.c EVP
254./crypto/evp/e_cbc_r2.c EVP
255./crypto/evp/e_cfb_3d.c EVP
256./crypto/evp/e_cfb_bf.c EVP
257./crypto/evp/e_cfb_c.c EVP
258./crypto/evp/e_cfb_d.c EVP
259./crypto/evp/e_cfb_i.c EVP
260./crypto/evp/e_cfb_r2.c EVP
261./crypto/evp/e_dsa.c EVP
262./crypto/evp/e_ecb_3d.c EVP
263./crypto/evp/e_ecb_bf.c EVP
264./crypto/evp/e_ecb_c.c EVP
265./crypto/evp/e_ecb_d.c EVP
266./crypto/evp/e_ecb_i.c EVP
267./crypto/evp/e_ecb_r2.c EVP
268./crypto/evp/e_null.c EVP
269./crypto/evp/e_ofb_3d.c EVP
270./crypto/evp/e_ofb_bf.c EVP
271./crypto/evp/e_ofb_c.c EVP
272./crypto/evp/e_ofb_d.c EVP
273./crypto/evp/e_ofb_i.c EVP
274./crypto/evp/e_ofb_r2.c EVP
275./crypto/evp/e_rc4.c EVP
276./crypto/evp/e_xcbc_d.c EVP
277./crypto/evp/m_dss.c EVP
278./crypto/evp/m_dss1.c EVP
279./crypto/evp/m_md2.c EVP
280./crypto/evp/m_md5.c EVP
281./crypto/evp/m_mdc2.c EVP
282./crypto/evp/m_null.c EVP
283./crypto/evp/m_sha.c EVP
284./crypto/evp/m_sha1.c EVP
285./crypto/evp/names.c EVP
286./crypto/evp/p_lib.c EVP
287./crypto/evp/p_open.c EVP
288./crypto/evp/p_seal.c EVP
289./crypto/evp/p_sign.c EVP
290./crypto/evp/p_verify.c EVP
291
292./crypto/hmac/hmac.c HMAC
293./crypto/hmac/hmac.h HMAC
294./crypto/hmac/hmactest.c HMAC
295
296./crypto/idea/ideatest.c IDEA
297./crypto/idea/idea_lcl.h IDEA
298./crypto/idea/idea_spd.c IDEA
299./crypto/idea/i_cbc.c IDEA
300./crypto/idea/i_cfb64.c IDEA
301./crypto/idea/i_ecb.c IDEA
302./crypto/idea/i_ofb64.c IDEA
303./crypto/idea/i_skey.c IDEA
304./crypto/idea/idea.h IDEA
305
306./crypto/lhash/lhash.c LHASH
307./crypto/lhash/lhash.h LHASH
308./crypto/lhash/lh_stats.c LHASH
309./crypto/lhash/lh_test.c LHASH
310
311./crypto/md2/md2.c MD2
312./crypto/md2/md2test.c MD2
313./crypto/md2/md2_dgst.c MD2
314./crypto/md2/md2_one.c MD2
315./crypto/md2/md2.h MD2
316
317./crypto/md5/md5.c MD5
318./crypto/md5/md5.h MD5
319./crypto/md5/md5test.c MD5
320./crypto/md5/md5_dgst.c MD5
321./crypto/md5/md5_locl.h MD5
322./crypto/md5/md5_one.c MD5
323
324./crypto/mdc2/mdc2.h MDC2
325./crypto/mdc2/mdc2dgst.c MDC2
326./crypto/mdc2/mdc2test.c MDC2
327./crypto/mdc2/mdc2_one.c MDC2
328
329./crypto/objects/objects.h OBJ
330./crypto/objects/obj_dat.c OBJ
331./crypto/objects/obj_dat.h OBJ
332./crypto/objects/obj_err.c OBJ
333./crypto/objects/obj_lib.c OBJ
334
335./crypto/pem/ctx_size.c PEM
336./crypto/pem/pem.h PEM
337./crypto/pem/pem_all.c PEM
338./crypto/pem/pem_err.c PEM
339./crypto/pem/pem_info.c PEM
340./crypto/pem/pem_lib.c PEM
341./crypto/pem/pem_seal.c PEM
342./crypto/pem/pem_sign.c PEM
343
344./crypto/pkcs7/pk7_dgst.c PKCS7
345./crypto/pkcs7/pk7_doit.c PKCS7
346./crypto/pkcs7/pk7_enc.c PKCS7
347./crypto/pkcs7/pk7_lib.c PKCS7
348./crypto/pkcs7/pkcs7.h PKCS7
349./crypto/pkcs7/pkcs7err.c PKCS7
350./crypto/pkcs7/sign.c PKCS7
351
352./crypto/proxy/bf_proxy.c PROXY
353./crypto/proxy/p2test.c PROXY
354./crypto/proxy/p3test.c PROXY
355./crypto/proxy/paccept.c PROXY
356./crypto/proxy/proxy.c PROXY
357./crypto/proxy/proxy.h PROXY
358./crypto/proxy/ptest.c PROXY
359./crypto/proxy/pxy_conf.c PROXY
360./crypto/proxy/pxy_err.c PROXY
361./crypto/proxy/pxy_txt.c PROXY
362
363./crypto/rand/md_rand.c RAND
364./crypto/rand/rand.h RAND
365./crypto/rand/randfile.c RAND
366./crypto/rand/randtest.c RAND
367
368./crypto/rc2/rc2cfb64.c RC2
369./crypto/rc2/rc2ofb64.c RC2
370./crypto/rc2/rc2speed.c RC2
371./crypto/rc2/rc2test.c RC2
372./crypto/rc2/rc2_cbc.c RC2
373./crypto/rc2/rc2_ecb.c RC2
374./crypto/rc2/rc2_locl.h RC2
375./crypto/rc2/rc2_skey.c RC2
376./crypto/rc2/rc2.h RC2
377
378./crypto/rc4/rc4.c RC4
379./crypto/rc4/rc4speed.c RC4
380./crypto/rc4/rc4test.c RC4
381./crypto/rc4/rc4_enc.c RC4
382./crypto/rc4/rc4_skey.c RC4
383./crypto/rc4/rc4.h RC4
384./crypto/rc4/rc4_locl.h RC4
385
386./crypto/rsa/rsa.h RSA
387./crypto/rsa/rsa_eay.c RSA
388./crypto/rsa/rsa_err.c RSA
389./crypto/rsa/rsa_gen.c RSA
390./crypto/rsa/rsa_lib.c RSA
391./crypto/rsa/rsa_saos.c RSA
392./crypto/rsa/rsa_sign.c RSA
393./crypto/rsa/rsa_ssl.c RSA
394./crypto/rsa/rsa_pk1.c RSA
395./crypto/rsa/rsa_none.c RSA
396
397./crypto/sha/sha.h SHA
398./crypto/sha/sha_locl.h SHA
399./crypto/sha/sha.c SHA0
400./crypto/sha/sha_dgst.c SHA0
401./crypto/sha/sha_one.c SHA0
402./crypto/sha/sha_sgst.c SHA0
403./crypto/sha/shatest.c SHA0
404./crypto/sha/sha1.c SHA1
405./crypto/sha/sha1dgst.c SHA1
406./crypto/sha/sha1_one.c SHA1
407./crypto/sha/sha1test.c SHA1
408
409./crypto/stack/stack.c STACK
410./crypto/stack/stack.h STACK
411
412./crypto/txt_db/txt_db.c TXTDB
413./crypto/txt_db/txt_db.h TXTDB
414
415./crypto/x509/by_dir.c X509
416./crypto/x509/by_file.c X509
417./crypto/x509/v3_net.c X509
418./crypto/x509/v3_x509.c X509
419./crypto/x509/x509.h X509
420./crypto/x509/x509name.c X509
421./crypto/x509/x509pack.c X509
422./crypto/x509/x509rset.c X509
423./crypto/x509/x509type.c X509
424./crypto/x509/x509_cmp.c X509
425./crypto/x509/x509_d2.c X509
426./crypto/x509/x509_def.c X509
427./crypto/x509/x509_err.c X509
428./crypto/x509/x509_ext.c X509
429./crypto/x509/x509_lu.c X509
430./crypto/x509/x509_obj.c X509
431./crypto/x509/x509_r2x.c X509
432./crypto/x509/x509_req.c X509
433./crypto/x509/x509_set.c X509
434./crypto/x509/x509_txt.c X509
435./crypto/x509/x509_v3.c X509
436./crypto/x509/x509_vfy.c X509
437./crypto/x509/x_all.c X509
438./crypto/x509/x509_vfy.h X509
439./crypto/x509v3/v3_ku.c X509
440./crypto/x509v3/x509v3.h X509
441
442./crypto/threads/mttest.c THREADS
443./crypto/threads/th-lock.c THREADS
444
445./crypto/ripemd/rmdtest.c RMD160
446./crypto/ripemd/ripemd.h RMD160
447./crypto/ripemd/rmdconst.h RMD160
448./crypto/ripemd/rmd_locl.h RMD160
449./crypto/ripemd/rmd_one.c RMD160
450./crypto/ripemd/rmd160.c RMD160
451./crypto/ripemd/rmd_dgst.c RMD160
452
453./crypto/rc5/rc5_ecb.c RC5
454./crypto/rc5/rc5cfb64.c RC5
455./crypto/rc5/rc5ofb64.c RC5
456./crypto/rc5/rc5speed.c RC5
457./crypto/rc5/rc5test.c RC5
458./crypto/rc5/rc5_enc.c RC5
459./crypto/rc5/rc5.h RC5
460./crypto/rc5/rc5_locl.h RC5
461./crypto/rc5/rc5_skey.c RC5
462
463./ssl/bio_ssl.c SSL
464./ssl/pxy_ssl.c SSL
465./ssl/s23_clnt.c SSL
466./ssl/s23_lib.c SSL
467./ssl/s23_meth.c SSL
468./ssl/s23_pkt.c SSL
469./ssl/s23_srvr.c SSL
470./ssl/s2_clnt.c SSL
471./ssl/s2_enc.c SSL
472./ssl/s2_lib.c SSL
473./ssl/s2_meth.c SSL
474./ssl/s2_pkt.c SSL
475./ssl/s2_srvr.c SSL
476./ssl/s3_both.c SSL
477./ssl/s3_clnt.c SSL
478./ssl/s3_enc.c SSL
479./ssl/s3_lib.c SSL
480./ssl/s3_meth.c SSL
481./ssl/s3_pkt.c SSL
482./ssl/s3_srvr.c SSL
483./ssl/ssl.c SSL
484./ssl/ssl2.h SSL
485./ssl/ssl23.h SSL
486./ssl/ssl3.h SSL
487./ssl/ssl_algs.c SSL
488./ssl/ssl_asn1.c SSL
489./ssl/ssl_cert.c SSL
490./ssl/ssl_ciph.c SSL
491./ssl/ssl_err.c SSL
492./ssl/ssl_err2.c SSL
493./ssl/ssl_lib.c SSL
494./ssl/ssl_locl.h SSL
495./ssl/ssl_rsa.c SSL
496./ssl/ssl_sess.c SSL
497./ssl/ssl_stat.c SSL
498./ssl/ssl_task.c SSL
499./ssl/ssl_txt.c SSL
500./ssl/tls1.h SSL
501./ssl/t1_lib.c SSL
502./ssl/t1_enc.c SSL
503./ssl/t1_meth.c SSL
504./ssl/t1_srvr.c SSL
505./ssl/t1_clnt.c SSL
506./ssl/ssl.h SSL
507./ssl/ssltest.c SSL
508
509./rsaref/rsaref.c RSAREF
510./rsaref/rsaref.h RSAREF
511./rsaref/rsar_err.c RSAREF
512
513./apps/apps.c APPS
514./apps/apps.h APPS
515./apps/asn1pars.c APPS
516./apps/bf_perm.c APPS
517./apps/bf_perm.h APPS
518./apps/ca.c APPS
519./apps/ciphers.c APPS
520./apps/crl.c APPS
521./apps/crl2p7.c APPS
522./apps/dgst.c APPS
523./apps/dh.c APPS
524./apps/dsa.c APPS
525./apps/dsaparam.c APPS
526./apps/eay.c APPS
527./apps/enc.c APPS
528./apps/errstr.c APPS
529./apps/speed.c APPS
530./apps/gendh.c APPS
531./apps/gendsa.c APPS
532./apps/genrsa.c APPS
533./apps/mybio_cb.c APPS
534./apps/pem_mail.c APPS
535./apps/pkcs7.c APPS
536./apps/progs.h APPS
537./apps/req.c APPS
538./apps/rsa.c APPS
539./apps/sess_id.c APPS
540./apps/s_apps.h APPS
541./apps/s_args.c APPS
542./apps/s_cache.c APPS
543./apps/s_cb.c APPS
544./apps/s_client.c APPS
545./apps/s_eio.c APPS
546./apps/s_eio.h APPS
547./apps/s_filter.c APPS
548./apps/s_filter.h APPS
549./apps/s_server.c APPS
550./apps/s_socket.c APPS
551./apps/s_state.c APPS
552./apps/s_state.h APPS
553./apps/s_time.c APPS
554./apps/testdsa.h APPS
555./apps/testrsa.h APPS
556./apps/verify.c APPS
557./apps/version.c APPS
558./apps/x509.c APPS
559./apps/ssleay.c APPS
560./apps/sp.c APPS
561
562./demos/b64.c DEMO
563./demos/bio/saccept.c DEMO
564./demos/bio/sconnect.c DEMO
565./demos/maurice/example1.c DEMO
566./demos/maurice/example2.c DEMO
567./demos/maurice/example3.c DEMO
568./demos/maurice/example4.c DEMO
569./demos/maurice/loadkeys.c DEMO
570./demos/maurice/loadkeys.h DEMO
571./demos/prime/prime.c DEMO
572./demos/selfsign.c DEMO
573./demos/spkigen.c DEMO
574
diff --git a/src/lib/libssl/src/dep/gen.pl b/src/lib/libssl/src/dep/gen.pl
new file mode 100644
index 0000000000..35490f2794
--- /dev/null
+++ b/src/lib/libssl/src/dep/gen.pl
@@ -0,0 +1,113 @@
1#!/usr/bin/perl
2
3require 'getopts.pl';
4
5$files="files";
6%have=();
7%missing=();
8%name=();
9%func=();
10
11&Getopts('Ff:');
12
13&load_file("files");
14foreach $file (@ARGV)
15 { &do_nm($file); }
16
17if (defined($opt_f))
18 {
19 %a=();
20 $r=&list_files($opt_f,"",*a);
21 if ($opt_F)
22 {
23 foreach (sort split(/\n/,$r))
24 { print "$_\n"; }
25 }
26 else
27 { print $r; }
28 }
29else
30 {
31 for (sort keys %have)
32 {
33 print "$_:$have{$_}\n";
34 }
35 }
36
37sub list_files
38 {
39 local($f,$o,*done)=@_;
40 local($a,$_,$ff,$ret);
41
42 return if $f =~ /^\s*$/;
43
44 $done{$f}=1;
45 $ret.=$f."\n" if $opt_F;
46 foreach (split(/ /,$have{$f}))
47 {
48 $ret.="$o$f:$_\n" unless $opt_F;
49 }
50
51 foreach (split(/ /,$missing{$f}))
52 {
53 $ff=$func{$_};
54 next if defined($done{$ff});
55 $ret.=&list_files($ff,$o." ");
56 }
57 $ret;
58 }
59
60sub do_nm
61 {
62 local($file)=@_;
63 local($fname)="";
64
65 open(IN,"nm $file|") || die "unable to run 'nm $file|':$!\n";
66 while (<IN>)
67 {
68 chop;
69 next if /^\s*$/;
70 if (/^(.*)\.o:\s*$/)
71 {
72 $fname="$1.c";
73 next;
74 }
75 ($type,$name)=/^.{8} (.) (.+)/;
76# print "$fname $type $name\n";
77
78 if ($type eq "T")
79 {
80 $have{$fname}.="$name ";
81 $func{$name}=$fname;
82 }
83 elsif ($type eq "U")
84 {
85 $missing{$fname}.="$name ";
86 }
87 }
88 close(IN);
89 }
90
91sub load_file
92 {
93 local($file)=@_;
94
95 open(IN,"<$files") || die "unable to open $files:$!\n";
96
97 while (<IN>)
98 {
99 chop;
100 next if /^\s*$/;
101 ($n)=/\/([^\/\s]+)\s+/;
102 ($fn)=/^(\S+)\s/;
103# print "$n - $fn\n";
104 if (defined($name{$n}))
105 { print "$n already exists\n"; }
106 else
107 { $name{$n}=$fn; }
108 }
109 close(IN);
110 @name=%name;
111 }
112
113
diff --git a/src/lib/libssl/src/dep/ssl.txt b/src/lib/libssl/src/dep/ssl.txt
new file mode 100644
index 0000000000..7cd125a0d1
--- /dev/null
+++ b/src/lib/libssl/src/dep/ssl.txt
@@ -0,0 +1,156 @@
1BIO_f_ssl
2BIO_new_buffer_ssl_connect
3BIO_new_ssl
4BIO_new_ssl_connect
5BIO_proxy_ssl_copy_session_id
6BIO_ssl_copy_session_id
7BIO_ssl_shutdown
8ERR_load_SSL_strings
9SSL_CIPHER_description
10SSL_CIPHER_get_bits
11SSL_CIPHER_get_name
12SSL_CIPHER_get_version
13SSL_CTX_add_client_CA
14SSL_CTX_add_session
15SSL_CTX_check_private_key
16SSL_CTX_ctrl
17SSL_CTX_flush_sessions
18SSL_CTX_free
19SSL_CTX_get_client_CA_list
20SSL_CTX_get_ex_data
21SSL_CTX_get_ex_new_index
22SSL_CTX_get_quiet_shutdown
23SSL_CTX_get_verify_callback
24SSL_CTX_get_verify_mode
25SSL_CTX_load_verify_locations
26SSL_CTX_new
27SSL_CTX_remove_session
28SSL_CTX_set_cert_verify_cb
29SSL_CTX_set_cipher_list
30SSL_CTX_set_client_CA_list
31SSL_CTX_set_default_passwd_cb
32SSL_CTX_set_default_verify_paths
33SSL_CTX_set_ex_data
34SSL_CTX_set_quiet_shutdown
35SSL_CTX_set_ssl_version
36SSL_CTX_set_verify
37SSL_CTX_use_PrivateKey
38SSL_CTX_use_PrivateKey_ASN1
39SSL_CTX_use_PrivateKey_file
40SSL_CTX_use_RSAPrivateKey
41SSL_CTX_use_RSAPrivateKey_ASN1
42SSL_CTX_use_RSAPrivateKey_file
43SSL_CTX_use_certificate
44SSL_CTX_use_certificate_ASN1
45SSL_CTX_use_certificate_file
46SSL_SESSION_cmp
47SSL_SESSION_free
48SSL_SESSION_get_ex_data
49SSL_SESSION_get_ex_new_index
50SSL_SESSION_get_time
51SSL_SESSION_get_timeout
52SSL_SESSION_hash
53SSL_SESSION_new
54SSL_SESSION_print
55SSL_SESSION_print_fp
56SSL_SESSION_set_ex_data
57SSL_SESSION_set_time
58SSL_SESSION_set_timeout
59SSL_accept
60SSL_add_client_CA
61SSL_alert_desc_string
62SSL_alert_desc_string_long
63SSL_alert_type_string
64SSL_alert_type_string_long
65SSL_check_private_key
66SSL_clear
67SSL_connect
68SSL_copy_session_id
69SSL_ctrl
70SSL_do_handshake
71SSL_dup
72SSL_dup_CA_list
73SSL_free
74SSL_get_SSL_CTX
75SSL_get_certificate
76SSL_get_cipher_list
77SSL_get_ciphers
78SSL_get_client_CA_list
79SSL_get_current_cipher
80SSL_get_default_timeout
81SSL_get_error
82SSL_get_ex_data
83SSL_get_ex_new_index
84SSL_get_fd
85SSL_get_info_callback
86SSL_get_peer_cert_chain
87SSL_get_peer_certificate
88SSL_get_privatekey
89SSL_get_quiet_shutdown
90SSL_get_rbio
91SSL_get_read_ahead
92SSL_get_session
93SSL_get_shared_ciphers
94SSL_get_shutdown
95SSL_get_ssl_method
96SSL_get_verify_callback
97SSL_get_verify_mode
98SSL_get_verify_result
99SSL_get_version
100SSL_get_wbio
101SSL_load_client_CA_file
102SSL_load_error_strings
103SSL_new
104SSL_peek
105SSL_pending
106SSL_read
107SSL_renegotiate
108SSL_rstate_string
109SSL_rstate_string_long
110SSL_set_accept_state
111SSL_set_bio
112SSL_set_cipher_list
113SSL_set_client_CA_list
114SSL_set_connect_state
115SSL_set_ex_data
116SSL_set_fd
117SSL_set_info_callback
118SSL_set_quiet_shutdown
119SSL_set_read_ahead
120SSL_set_rfd
121SSL_set_session
122SSL_set_shutdown
123SSL_set_ssl_method
124SSL_set_verify
125SSL_set_verify_result
126SSL_set_wfd
127SSL_shutdown
128SSL_state
129SSL_state_string
130SSL_state_string_long
131SSL_use_PrivateKey
132SSL_use_PrivateKey_ASN1
133SSL_use_PrivateKey_file
134SSL_use_RSAPrivateKey
135SSL_use_RSAPrivateKey_ASN1
136SSL_use_RSAPrivateKey_file
137SSL_use_certificate
138SSL_use_certificate_ASN1
139SSL_use_certificate_file
140SSL_version
141SSL_write
142SSLeay_add_ssl_algorithms
143SSLv23_client_method
144SSLv23_method
145SSLv23_server_method
146SSLv2_client_method
147SSLv2_method
148SSLv2_server_method
149SSLv3_client_method
150SSLv3_method
151SSLv3_server_method
152TLSv1_client_method
153TLSv1_method
154TLSv1_server_method
155d2i_SSL_SESSION
156i2d_SSL_SESSION
diff --git a/src/lib/libssl/src/doc/API.doc b/src/lib/libssl/src/doc/API.doc
new file mode 100644
index 0000000000..fe2820259a
--- /dev/null
+++ b/src/lib/libssl/src/doc/API.doc
@@ -0,0 +1,24 @@
1SSL - SSLv2/v3/v23 etc.
2
3BIO - methods and how they plug together
4
5MEM - memory allocation callback
6
7CRYPTO - locking for threads
8
9EVP - Ciphers/Digests/signatures
10
11RSA - methods
12
13X509 - certificate retrieval
14
15X509 - validation
16
17X509 - X509v3 extensions
18
19Objects - adding object identifiers
20
21ASN.1 - parsing
22
23PEM - parsing
24
diff --git a/src/lib/libssl/src/doc/a_verify.doc b/src/lib/libssl/src/doc/a_verify.doc
new file mode 100644
index 0000000000..06eec17c2b
--- /dev/null
+++ b/src/lib/libssl/src/doc/a_verify.doc
@@ -0,0 +1,85 @@
1From eay@mincom.com Fri Oct 4 18:29:06 1996
2Received: by orb.mincom.oz.au id AA29080
3 (5.65c/IDA-1.4.4 for eay); Fri, 4 Oct 1996 08:29:07 +1000
4Date: Fri, 4 Oct 1996 08:29:06 +1000 (EST)
5From: Eric Young <eay@mincom.oz.au>
6X-Sender: eay@orb
7To: wplatzer <wplatzer@iaik.tu-graz.ac.at>
8Cc: Eric Young <eay@mincom.oz.au>, SSL Mailing List <ssl-users@mincom.com>
9Subject: Re: Netscape's Public Key
10In-Reply-To: <19961003134837.NTM0049@iaik.tu-graz.ac.at>
11Message-Id: <Pine.SOL.3.91.961004081346.8018K-100000@orb>
12Mime-Version: 1.0
13Content-Type: TEXT/PLAIN; charset=US-ASCII
14Status: RO
15X-Status:
16
17On Thu, 3 Oct 1996, wplatzer wrote:
18> I get Public Key from Netscape (Gold 3.0b4), but cannot do anything
19> with it... It looks like (asn1parse):
20>
21> 0:d=0 hl=3 l=180 cons: SEQUENCE
22> 3:d=1 hl=2 l= 96 cons: SEQUENCE
23> 5:d=2 hl=2 l= 92 cons: SEQUENCE
24> 7:d=3 hl=2 l= 13 cons: SEQUENCE
25> 9:d=4 hl=2 l= 9 prim: OBJECT :rsaEncryption
26> 20:d=4 hl=2 l= 0 prim: NULL
27> 22:d=3 hl=2 l= 75 prim: BIT STRING
28> 99:d=2 hl=2 l= 0 prim: IA5STRING :
29> 101:d=1 hl=2 l= 13 cons: SEQUENCE
30> 103:d=2 hl=2 l= 9 prim: OBJECT :md5withRSAEncryption
31> 114:d=2 hl=2 l= 0 prim: NULL
32> 116:d=1 hl=2 l= 65 prim: BIT STRING
33>
34> The first BIT STRING is the public key and the second BIT STRING is
35> the signature.
36> But a public key consists of the public exponent and the modulus. Are
37> both numbers in the first BIT STRING?
38> Is there a document simply describing this coding stuff (checking
39> signature, get the public key, etc.)?
40
41Minimal in SSLeay. If you want to see what the modulus and exponent are,
42try asn1parse -offset 25 -length 75 <key.pem
43asn1parse will currently stuff up on the 'length 75' part (fixed in next
44release) but it will print the stuff. If you are after more
45documentation on ASN.1, have a look at www.rsa.com and get their PKCS
46documents, most of my initial work on SSLeay was done using them.
47
48As for SSLeay,
49util/crypto.num and util/ssl.num are lists of all exported functions in
50the library (but not macros :-(.
51
52The ones for extracting public keys from certificates and certificate
53requests are EVP_PKEY * X509_REQ_extract_key(X509_REQ *req);
54EVP_PKEY * X509_extract_key(X509 *x509);
55
56To verify a signature on a signed ASN.1 object
57int X509_verify(X509 *a,EVP_PKEY *key);
58int X509_REQ_verify(X509_REQ *a,EVP_PKEY *key);
59int X509_CRL_verify(X509_CRL *a,EVP_PKEY *key);
60int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a,EVP_PKEY *key);
61
62I should mention that EVP_PKEY can be used to hold a public or a private key,
63since for things like RSA and DSS, a public key is just a subset of what
64is stored for the private key.
65
66To sign any of the above structures
67
68int X509_sign(X509 *a,EVP_PKEY *key,EVP_MD *md);
69int X509_REQ_sign(X509_REQ *a,EVP_PKEY *key,EVP_MD *md);
70int X509_CRL_sign(X509_CRL *a,EVP_PKEY *key,EVP_MD *md);
71int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *a,EVP_PKEY *key,EVP_MD *md);
72
73where md is the message digest to sign with.
74
75There are all defined in x509.h and all the _sign and _verify functions are
76actually macros to the ASN1_sign() and ASN1_verify() functions.
77These functions will put the correct algorithm identifiers in the correct
78places in the structures.
79
80eric
81--
82Eric Young | BOOL is tri-state according to Bill Gates.
83AARNet: eay@mincom.oz.au | RTFM Win32 GetMessage().
84
85
diff --git a/src/lib/libssl/src/doc/apps.doc b/src/lib/libssl/src/doc/apps.doc
new file mode 100644
index 0000000000..a2a4e0de72
--- /dev/null
+++ b/src/lib/libssl/src/doc/apps.doc
@@ -0,0 +1,53 @@
1The applications
2
3Ok, where to begin....
4In the begining, when SSLeay was small (April 1995), there
5were but few applications, they did happily cohabit in
6the one bin directory. Then over time, they did multiply and grow,
7and they started to look like microsoft software; 500k to print 'hello world'.
8A new approach was needed. They were coalessed into one 'Monolithic'
9application, ssleay. This one program is composed of many programs that
10can all be compiled independantly.
11
12ssleay has 3 modes of operation.
131) If the ssleay binaray has the name of one of its component programs, it
14executes that program and then exits. This can be achieve by using hard or
15symbolic links, or failing that, just renaming the binary.
162) If the first argument to ssleay is the name of one of the component
17programs, that program runs that program and then exits.
183) If there are no arguments, ssleay enters a 'command' mode. Each line is
19interpreted as a program name plus arguments. After each 'program' is run,
20ssleay returns to the comand line.
21
22dgst - message digests
23enc - encryption and base64 encoding
24
25ans1parse - 'pulls' appart ASN.1 encoded objects like certificates.
26
27dh - Diffle-Hellman parameter manipulation.
28rsa - RSA manipulations.
29crl - Certificate revokion list manipulations
30x509 - X509 cert fiddles, including signing.
31pkcs7 - pkcs7 manipulation, only DER versions right now.
32
33genrsa - generate an RSA private key.
34gendh - Generate a set of Diffle-Hellman parameters.
35req - Generate a PKCS#10 object, a certificate request.
36
37s_client - SSL client program
38s_server - SSL server program
39s_time - A SSL protocol timing program
40s_mult - Another SSL server, but it multiplexes
41 connections.
42s_filter - under development
43
44errstr - Convert SSLeay error numbers to strings.
45ca - Sign certificate requests, and generate
46 certificate revokion lists
47crl2pkcs7 - put a crl and certifcates into a pkcs7 object.
48speed - Benchmark the ciphers.
49verify - Check certificates
50hashdir - under development
51
52[ there a now a few more options, play with the program to see what they
53 are ]
diff --git a/src/lib/libssl/src/doc/asn1.doc b/src/lib/libssl/src/doc/asn1.doc
new file mode 100644
index 0000000000..fdad17c05c
--- /dev/null
+++ b/src/lib/libssl/src/doc/asn1.doc
@@ -0,0 +1,401 @@
1The ASN.1 Routines.
2
3ASN.1 is a specification for how to encode structured 'data' in binary form.
4The approach I have take to the manipulation of structures and their encoding
5into ASN.1 is as follows.
6
7For each distinct structure there are 4 function of the following form
8TYPE *TYPE_new(void);
9void TYPE_free(TYPE *);
10TYPE *d2i_TYPE(TYPE **a,unsigned char **pp,long length);
11long i2d_TYPE(TYPE *a,unsigned char **pp); /* CHECK RETURN VALUE */
12
13where TYPE is the type of the 'object'. The TYPE that have these functions
14can be in one of 2 forms, either the internal C malloc()ed data structure
15or in the DER (a variant of ASN.1 encoding) binary encoding which is just
16an array of unsigned bytes. The 'i2d' functions converts from the internal
17form to the DER form and the 'd2i' functions convert from the DER form to
18the internal form.
19
20The 'new' function returns a malloc()ed version of the structure with all
21substructures either created or left as NULL pointers. For 'optional'
22fields, they are normally left as NULL to indicate no value. For variable
23size sub structures (often 'SET OF' or 'SEQUENCE OF' in ASN.1 syntax) the
24STACK data type is used to hold the values. Have a read of stack.doc
25and have a look at the relevant header files to see what I mean. If there
26is an error while malloc()ing the structure, NULL is returned.
27
28The 'free' function will free() all the sub components of a particular
29structure. If any of those sub components have been 'removed', replace
30them with NULL pointers, the 'free' functions are tolerant of NULL fields.
31
32The 'd2i' function copies a binary representation into a C structure. It
33operates as follows. 'a' is a pointer to a pointer to
34the structure to populate, 'pp' is a pointer to a pointer to where the DER
35byte string is located and 'length' is the length of the '*pp' data.
36If there are no errors, a pointer to the populated structure is returned.
37If there is an error, NULL is returned. Errors can occur because of
38malloc() failures but normally they will be due to syntax errors in the DER
39encoded data being parsed. It is also an error if there was an
40attempt to read more that 'length' bytes from '*p'. If
41everything works correctly, the value in '*p' is updated
42to point at the location just beyond where the DER
43structure was read from. In this way, chained calls to 'd2i' type
44functions can be made, with the pointer into the 'data' array being
45'walked' along the input byte array.
46Depending on the value passed for 'a', different things will be done. If
47'a' is NULL, a new structure will be malloc()ed and returned. If '*a' is
48NULL, a new structure will be malloc()ed and put into '*a' and returned.
49If '*a' is not NULL, the structure in '*a' will be populated, or in the
50case of an error, free()ed and then returned.
51Having these semantics means that a structure
52can call a 'd2i' function to populate a field and if the field is currently
53NULL, the structure will be created.
54
55The 'i2d' function type is used to copy a C structure to a byte array.
56The parameter 'a' is the structure to convert and '*p' is where to put it.
57As for the 'd2i' type structure, 'p' is updated to point after the last
58byte written. If p is NULL, no data is written. The function also returns
59the number of bytes written. Where this becomes useful is that if the
60function is called with a NULL 'p' value, the length is returned. This can
61then be used to malloc() an array of bytes and then the same function can
62be recalled passing the malloced array to be written to. e.g.
63
64int len;
65unsigned char *bytes,*p;
66len=i2d_X509(x,NULL); /* get the size of the ASN1 encoding of 'x' */
67if ((bytes=(unsigned char *)malloc(len)) == NULL)
68 goto err;
69p=bytes;
70i2d_X509(x,&p);
71
72Please note that a new variable, 'p' was passed to i2d_X509. After the
73call to i2d_X509 p has been incremented by len bytes.
74
75Now the reason for this functional organisation is that it allows nested
76structures to be built up by calling these functions as required. There
77are various macros used to help write the general 'i2d', 'd2i', 'new' and
78'free' functions. They are discussed in another file and would only be
79used by some-one wanting to add new structures to the library. As you
80might be able to guess, the process of writing ASN.1 files can be a bit CPU
81expensive for complex structures. I'm willing to live with this since the
82simpler library code make my life easier and hopefully most programs using
83these routines will have their execution profiles dominated by cipher or
84message digest routines.
85What follows is a list of 'TYPE' values and the corresponding ASN.1
86structure and where it is used.
87
88TYPE ASN.1
89ASN1_INTEGER INTEGER
90ASN1_BIT_STRING BIT STRING
91ASN1_OCTET_STRING OCTET STRING
92ASN1_OBJECT OBJECT IDENTIFIER
93ASN1_PRINTABLESTRING PrintableString
94ASN1_T61STRING T61String
95ASN1_IA5STRING IA5String
96ASN1_UTCTIME UTCTime
97ASN1_TYPE Any of the above mentioned types plus SEQUENCE and SET
98
99Most of the above mentioned types are actualled stored in the
100ASN1_BIT_STRING type and macros are used to differentiate between them.
101The 3 types used are
102
103typedef struct asn1_object_st
104 {
105 /* both null if a dynamic ASN1_OBJECT, one is
106 * defined if a 'static' ASN1_OBJECT */
107 char *sn,*ln;
108 int nid;
109 int length;
110 unsigned char *data;
111 } ASN1_OBJECT;
112This is used to store ASN1 OBJECTS. Read 'objects.doc' for details ono
113routines to manipulate this structure. 'sn' and 'ln' are used to hold text
114strings that represent the object (short name and long or lower case name).
115These are used by the 'OBJ' library. 'nid' is a number used by the OBJ
116library to uniquely identify objects. The ASN1 routines will populate the
117'length' and 'data' fields which will contain the bit string representing
118the object.
119
120typedef struct asn1_bit_string_st
121 {
122 int length;
123 int type;
124 unsigned char *data;
125 } ASN1_BIT_STRING;
126This structure is used to hold all the other base ASN1 types except for
127ASN1_UTCTIME (which is really just a 'char *'). Length is the number of
128bytes held in data and type is the ASN1 type of the object (there is a list
129in asn1.h).
130
131typedef struct asn1_type_st
132 {
133 int type;
134 union {
135 char *ptr;
136 ASN1_INTEGER * integer;
137 ASN1_BIT_STRING * bit_string;
138 ASN1_OCTET_STRING * octet_string;
139 ASN1_OBJECT * object;
140 ASN1_PRINTABLESTRING * printablestring;
141 ASN1_T61STRING * t61string;
142 ASN1_IA5STRING * ia5string;
143 ASN1_UTCTIME * utctime;
144 ASN1_BIT_STRING * set;
145 ASN1_BIT_STRING * sequence;
146 } value;
147 } ASN1_TYPE;
148This structure is used in a few places when 'any' type of object can be
149expected.
150
151X509 Certificate
152X509_CINF CertificateInfo
153X509_ALGOR AlgorithmIdentifier
154X509_NAME Name
155X509_NAME_ENTRY A single sub component of the name.
156X509_VAL Validity
157X509_PUBKEY SubjectPublicKeyInfo
158The above mentioned types are declared in x509.h. They are all quite
159straight forward except for the X509_NAME/X509_NAME_ENTRY pair.
160A X509_NAME is a STACK (see stack.doc) of X509_NAME_ENTRY's.
161typedef struct X509_name_entry_st
162 {
163 ASN1_OBJECT *object;
164 ASN1_BIT_STRING *value;
165 int set;
166 int size; /* temp variable */
167 } X509_NAME_ENTRY;
168The size is a temporary variable used by i2d_NAME and set is the set number
169for the particular NAME_ENTRY. A X509_NAME is encoded as a sequence of
170sequence of sets. Normally each set contains only a single item.
171Sometimes it contains more. Normally throughout this library there will be
172only one item per set. The set field contains the 'set' that this entry is
173a member of. So if you have just created a X509_NAME structure and
174populated it with X509_NAME_ENTRYs, you should then traverse the X509_NAME
175(which is just a STACK) and set the 'set/' field to incrementing numbers.
176For more details on why this is done, read the ASN.1 spec for Distinguished
177Names.
178
179X509_REQ CertificateRequest
180X509_REQ_INFO CertificateRequestInfo
181These are used to hold certificate requests.
182
183X509_CRL CertificateRevocationList
184These are used to hold a certificate revocation list
185
186RSAPrivateKey PrivateKeyInfo
187RSAPublicKey PublicKeyInfo
188Both these 'function groups' operate on 'RSA' structures (see rsa.doc).
189The difference is that the RSAPublicKey operations only manipulate the m
190and e fields in the RSA structure.
191
192DSAPrivateKey DSS private key
193DSAPublicKey DSS public key
194Both these 'function groups' operate on 'DSS' structures (see dsa.doc).
195The difference is that the RSAPublicKey operations only manipulate the
196XXX fields in the DSA structure.
197
198DHparams DHParameter
199This is used to hold the p and g value for The Diffie-Hellman operation.
200The function deal with the 'DH' strucure (see dh.doc).
201
202Now all of these function types can be used with several other functions to give
203quite useful set of general manipulation routines. Normally one would
204not uses these functions directly but use them via macros.
205
206char *ASN1_dup(int (*i2d)(),char *(*d2i)(),char *x);
207'x' is the input structure case to a 'char *', 'i2d' is the 'i2d_TYPE'
208function for the type that 'x' is and d2i is the 'd2i_TYPE' function for the
209type that 'x' is. As is obvious from the parameters, this function
210duplicates the strucutre by transforming it into the DER form and then
211re-loading it into a new strucutre and returning the new strucutre. This
212is obviously a bit cpu intensive but when faced with a complex dynamic
213structure this is the simplest programming approach. There are macros for
214duplicating the major data types but is simple to add extras.
215
216char *ASN1_d2i_fp(char *(*new)(),char *(*d2i)(),FILE *fp,unsigned char **x);
217'x' is a pointer to a pointer of the 'desired type'. new and d2i are the
218corresponding 'TYPE_new' and 'd2i_TYPE' functions for the type and 'fp' is
219an open file pointer to read from. This function reads from 'fp' as much
220data as it can and then uses 'd2i' to parse the bytes to load and return
221the parsed strucutre in 'x' (if it was non-NULL) and to actually return the
222strucutre. The behavior of 'x' is as per all the other d2i functions.
223
224char *ASN1_d2i_bio(char *(*new)(),char *(*d2i)(),BIO *fp,unsigned char **x);
225The 'BIO' is the new IO type being used in SSLeay (see bio.doc). This
226function is the same as ASN1_d2i_fp() except for the BIO argument.
227ASN1_d2i_fp() actually calls this function.
228
229int ASN1_i2d_fp(int (*i2d)(),FILE *out,unsigned char *x);
230'x' is converted to bytes by 'i2d' and then written to 'out'. ASN1_i2d_fp
231and ASN1_d2i_fp are not really symetric since ASN1_i2d_fp will read all
232available data from the file pointer before parsing a single item while
233ASN1_i2d_fp can be used to write a sequence of data objects. To read a
234series of objects from a file I would sugest loading the file into a buffer
235and calling the relevent 'd2i' functions.
236
237char *ASN1_d2i_bio(char *(*new)(),char *(*d2i)(),BIO *fp,unsigned char **x);
238This function is the same as ASN1_i2d_fp() except for the BIO argument.
239ASN1_i2d_fp() actually calls this function.
240
241char * PEM_ASN1_read(char *(*d2i)(),char *name,FILE *fp,char **x,int (*cb)());
242This function will read the next PEM encoded (base64) object of the same
243type as 'x' (loaded by the d2i function). 'name' is the name that is in
244the '-----BEGIN name-----' that designates the start of that object type.
245If the data is encrypted, 'cb' will be called to prompt for a password. If
246it is NULL a default function will be used to prompt from the password.
247'x' is delt with as per the standard 'd2i' function interface. This
248function can be used to read a series of objects from a file. While any
249data type can be encrypted (see PEM_ASN1_write) only RSA private keys tend
250to be encrypted.
251
252char * PEM_ASN1_read_bio(char *(*d2i)(),char *name,BIO *fp,
253 char **x,int (*cb)());
254Same as PEM_ASN1_read() except using a BIO. This is called by
255PEM_ASN1_read().
256
257int PEM_ASN1_write(int (*i2d)(),char *name,FILE *fp,char *x,EVP_CIPHER *enc,
258 unsigned char *kstr,int klen,int (*callback)());
259
260int PEM_ASN1_write_bio(int (*i2d)(),char *name,BIO *fp,
261 char *x,EVP_CIPHER *enc,unsigned char *kstr,int klen,
262 int (*callback)());
263
264int ASN1_sign(int (*i2d)(), X509_ALGOR *algor1, X509_ALGOR *algor2,
265 ASN1_BIT_STRING *signature, char *data, RSA *rsa, EVP_MD *type);
266int ASN1_verify(int (*i2d)(), X509_ALGOR *algor1,
267 ASN1_BIT_STRING *signature,char *data, RSA *rsa);
268
269int ASN1_BIT_STRING_cmp(ASN1_BIT_STRING *a, ASN1_BIT_STRING *b);
270ASN1_BIT_STRING *ASN1_BIT_STRING_type_new(int type );
271
272int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
273void ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a);
274ASN1_UTCTIME *ASN1_UTCTIME_dup(ASN1_UTCTIME *a);
275
276ASN1_BIT_STRING *d2i_asn1_print_type(ASN1_BIT_STRING **a,unsigned char **pp,
277 long length,int type);
278
279int i2d_ASN1_SET(STACK *a, unsigned char **pp,
280 int (*func)(), int ex_tag, int ex_class);
281STACK * d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
282 char *(*func)(), int ex_tag, int ex_class);
283
284int i2a_ASN1_OBJECT(BIO *bp,ASN1_OBJECT *object);
285int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
286int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
287
288int ASN1_INTEGER_set(ASN1_INTEGER *a, long v);
289long ASN1_INTEGER_get(ASN1_INTEGER *a);
290ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai);
291BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn);
292
293/* given a string, return the correct type. Max is the maximum number
294 * of bytes to parse. It stops parsing when 'max' bytes have been
295 * processed or a '\0' is hit */
296int ASN1_PRINTABLE_type(unsigned char *s,int max);
297
298void ASN1_parse(BIO *fp,unsigned char *pp,long len);
299
300int i2d_ASN1_bytes(ASN1_BIT_STRING *a, unsigned char **pp, int tag, int class);
301ASN1_BIT_STRING *d2i_ASN1_bytes(ASN1_OCTET_STRING **a, unsigned char **pp,
302 long length, int Ptag, int Pclass);
303
304/* PARSING */
305int asn1_Finish(ASN1_CTX *c);
306
307/* SPECIALS */
308int ASN1_get_object(unsigned char **pp, long *plength, int *ptag,
309 int *pclass, long omax);
310int ASN1_check_infinite_end(unsigned char **p,long len);
311void ASN1_put_object(unsigned char **pp, int constructed, int length,
312 int tag, int class);
313int ASN1_object_size(int constructed, int length, int tag);
314
315X509 * X509_get_cert(CERTIFICATE_CTX *ctx,X509_NAME * name,X509 *tmp_x509);
316int X509_add_cert(CERTIFICATE_CTX *ctx,X509 *);
317
318char * X509_cert_verify_error_string(int n);
319int X509_add_cert_file(CERTIFICATE_CTX *c,char *file, int type);
320char * X509_gmtime (char *s, long adj);
321int X509_add_cert_dir (CERTIFICATE_CTX *c,char *dir, int type);
322int X509_load_verify_locations (CERTIFICATE_CTX *ctx,
323 char *file_env, char *dir_env);
324int X509_set_default_verify_paths(CERTIFICATE_CTX *cts);
325X509 * X509_new_D2i_X509(int len, unsigned char *p);
326char * X509_get_default_cert_area(void );
327char * X509_get_default_cert_dir(void );
328char * X509_get_default_cert_file(void );
329char * X509_get_default_cert_dir_env(void );
330char * X509_get_default_cert_file_env(void );
331char * X509_get_default_private_dir(void );
332X509_REQ *X509_X509_TO_req(X509 *x, RSA *rsa);
333int X509_cert_verify(CERTIFICATE_CTX *ctx,X509 *xs, int (*cb)());
334
335CERTIFICATE_CTX *CERTIFICATE_CTX_new();
336void CERTIFICATE_CTX_free(CERTIFICATE_CTX *c);
337
338void X509_NAME_print(BIO *fp, X509_NAME *name, int obase);
339int X509_print_fp(FILE *fp,X509 *x);
340int X509_print(BIO *fp,X509 *x);
341
342X509_INFO * X509_INFO_new(void);
343void X509_INFO_free(X509_INFO *a);
344
345char * X509_NAME_oneline(X509_NAME *a);
346
347#define X509_verify(x,rsa)
348#define X509_REQ_verify(x,rsa)
349#define X509_CRL_verify(x,rsa)
350
351#define X509_sign(x,rsa,md)
352#define X509_REQ_sign(x,rsa,md)
353#define X509_CRL_sign(x,rsa,md)
354
355#define X509_dup(x509)
356#define d2i_X509_fp(fp,x509)
357#define i2d_X509_fp(fp,x509)
358#define d2i_X509_bio(bp,x509)
359#define i2d_X509_bio(bp,x509)
360
361#define X509_CRL_dup(crl)
362#define d2i_X509_CRL_fp(fp,crl)
363#define i2d_X509_CRL_fp(fp,crl)
364#define d2i_X509_CRL_bio(bp,crl)
365#define i2d_X509_CRL_bio(bp,crl)
366
367#define X509_REQ_dup(req)
368#define d2i_X509_REQ_fp(fp,req)
369#define i2d_X509_REQ_fp(fp,req)
370#define d2i_X509_REQ_bio(bp,req)
371#define i2d_X509_REQ_bio(bp,req)
372
373#define RSAPrivateKey_dup(rsa)
374#define d2i_RSAPrivateKey_fp(fp,rsa)
375#define i2d_RSAPrivateKey_fp(fp,rsa)
376#define d2i_RSAPrivateKey_bio(bp,rsa)
377#define i2d_RSAPrivateKey_bio(bp,rsa)
378
379#define X509_NAME_dup(xn)
380#define X509_NAME_ENTRY_dup(ne)
381
382void X509_REQ_print_fp(FILE *fp,X509_REQ *req);
383void X509_REQ_print(BIO *fp,X509_REQ *req);
384
385RSA *X509_REQ_extract_key(X509_REQ *req);
386RSA *X509_extract_key(X509 *x509);
387
388int X509_issuer_and_serial_cmp(X509 *a, X509 *b);
389unsigned long X509_issuer_and_serial_hash(X509 *a);
390
391X509_NAME * X509_get_issuer_name(X509 *a);
392int X509_issuer_name_cmp(X509 *a, X509 *b);
393unsigned long X509_issuer_name_hash(X509 *a);
394
395X509_NAME * X509_get_subject_name(X509 *a);
396int X509_subject_name_cmp(X509 *a,X509 *b);
397unsigned long X509_subject_name_hash(X509 *x);
398
399int X509_NAME_cmp (X509_NAME *a, X509_NAME *b);
400unsigned long X509_NAME_hash(X509_NAME *x);
401
diff --git a/src/lib/libssl/src/doc/bio.doc b/src/lib/libssl/src/doc/bio.doc
new file mode 100644
index 0000000000..545a57cdff
--- /dev/null
+++ b/src/lib/libssl/src/doc/bio.doc
@@ -0,0 +1,423 @@
1BIO Routines
2
3This documentation is rather sparse, you are probably best
4off looking at the code for specific details.
5
6The BIO library is a IO abstraction that was originally
7inspired by the need to have callbacks to perform IO to FILE
8pointers when using Windows 3.1 DLLs. There are two types
9of BIO; a source/sink type and a filter type.
10The source/sink methods are as follows:
11- BIO_s_mem() memory buffer - a read/write byte array that
12 grows until memory runs out :-).
13- BIO_s_file() FILE pointer - A wrapper around the normal
14 'FILE *' commands, good for use with stdin/stdout.
15- BIO_s_fd() File descriptor - A wrapper around file
16 descriptors, often used with pipes.
17- BIO_s_socket() Socket - Used around sockets. It is
18 mostly in the Microsoft world that sockets are different
19 from file descriptors and there are all those ugly winsock
20 commands.
21- BIO_s_null() Null - read nothing and write nothing.; a
22 useful endpoint for filter type BIO's specifically things
23 like the message digest BIO.
24
25The filter types are
26- BIO_f_buffer() IO buffering - does output buffering into
27 larger chunks and performs input buffering to allow gets()
28 type functions.
29- BIO_f_md() Message digest - a transparent filter that can
30 be asked to return a message digest for the data that has
31 passed through it.
32- BIO_f_cipher() Encrypt or decrypt all data passing
33 through the filter.
34- BIO_f_base64() Base64 decode on read and encode on write.
35- BIO_f_ssl() A filter that performs SSL encryption on the
36 data sent through it.
37
38Base BIO functions.
39The BIO library has a set of base functions that are
40implemented for each particular type. Filter BIOs will
41normally call the equivalent function on the source/sink BIO
42that they are layered on top of after they have performed
43some modification to the data stream. Multiple filter BIOs
44can be 'push' into a stack of modifers, so to read from a
45file, unbase64 it, then decrypt it, a BIO_f_cipher,
46BIO_f_base64 and a BIO_s_file would probably be used. If a
47sha-1 and md5 message digest needed to be generated, a stack
48two BIO_f_md() BIOs and a BIO_s_null() BIO could be used.
49The base functions are
50- BIO *BIO_new(BIO_METHOD *type); Create a new BIO of type 'type'.
51- int BIO_free(BIO *a); Free a BIO structure. Depending on
52 the configuration, this will free the underlying data
53 object for a source/sink BIO.
54- int BIO_read(BIO *b, char *data, int len); Read upto 'len'
55 bytes into 'data'.
56- int BIO_gets(BIO *bp,char *buf, int size); Depending on
57 the BIO, this can either be a 'get special' or a get one
58 line of data, as per fgets();
59- int BIO_write(BIO *b, char *data, int len); Write 'len'
60 bytes from 'data' to the 'b' BIO.
61- int BIO_puts(BIO *bp,char *buf); Either a 'put special' or
62 a write null terminated string as per fputs().
63- long BIO_ctrl(BIO *bp,int cmd,long larg,char *parg); A
64 control function which is used to manipulate the BIO
65 structure and modify it's state and or report on it. This
66 function is just about never used directly, rather it
67 should be used in conjunction with BIO_METHOD specific
68 macros.
69- BIO *BIO_push(BIO *new_top, BIO *old); new_top is apped to the
70 top of the 'old' BIO list. new_top should be a filter BIO.
71 All writes will go through 'new_top' first and last on read.
72 'old' is returned.
73- BIO *BIO_pop(BIO *bio); the new topmost BIO is returned, NULL if
74 there are no more.
75
76If a particular low level BIO method is not supported
77(normally BIO_gets()), -2 will be returned if that method is
78called. Otherwise the IO methods (read, write, gets, puts)
79will return the number of bytes read or written, and 0 or -1
80for error (or end of input). For the -1 case,
81BIO_should_retry(bio) can be called to determine if it was a
82genuine error or a temporary problem. -2 will also be
83returned if the BIO has not been initalised yet, in all
84cases, the correct error codes are set (accessible via the
85ERR library).
86
87
88The following functions are convenience functions:
89- int BIO_printf(BIO *bio, char * format, ..); printf but
90 to a BIO handle.
91- long BIO_ctrl_int(BIO *bp,int cmd,long larg,int iarg); a
92 convenience function to allow a different argument types
93 to be passed to BIO_ctrl().
94- int BIO_dump(BIO *b,char *bytes,int len); output 'len'
95 bytes from 'bytes' in a hex dump debug format.
96- long BIO_debug_callback(BIO *bio, int cmd, char *argp, int
97 argi, long argl, long ret) - a default debug BIO callback,
98 this is mentioned below. To use this one normally has to
99 use the BIO_set_callback_arg() function to assign an
100 output BIO for the callback to use.
101- BIO *BIO_find_type(BIO *bio,int type); when there is a 'stack'
102 of BIOs, this function scan the list and returns the first
103 that is of type 'type', as listed in buffer.h under BIO_TYPE_XXX.
104- void BIO_free_all(BIO *bio); Free the bio and all other BIOs
105 in the list. It walks the bio->next_bio list.
106
107
108
109Extra commands are normally implemented as macros calling BIO_ctrl().
110- BIO_number_read(BIO *bio) - the number of bytes processed
111 by BIO_read(bio,.).
112- BIO_number_written(BIO *bio) - the number of bytes written
113 by BIO_write(bio,.).
114- BIO_reset(BIO *bio) - 'reset' the BIO.
115- BIO_eof(BIO *bio) - non zero if we are at the current end
116 of input.
117- BIO_set_close(BIO *bio, int close_flag) - set the close flag.
118- BIO_get_close(BIO *bio) - return the close flag.
119 BIO_pending(BIO *bio) - return the number of bytes waiting
120 to be read (normally buffered internally).
121- BIO_flush(BIO *bio) - output any data waiting to be output.
122- BIO_should_retry(BIO *io) - after a BIO_read/BIO_write
123 operation returns 0 or -1, a call to this function will
124 return non zero if you should retry the call later (this
125 is for non-blocking IO).
126- BIO_should_read(BIO *io) - we should retry when data can
127 be read.
128- BIO_should_write(BIO *io) - we should retry when data can
129 be written.
130- BIO_method_name(BIO *io) - return a string for the method name.
131- BIO_method_type(BIO *io) - return the unique ID of the BIO method.
132- BIO_set_callback(BIO *io, long (*callback)(BIO *io, int
133 cmd, char *argp, int argi, long argl, long ret); - sets
134 the debug callback.
135- BIO_get_callback(BIO *io) - return the assigned function
136 as mentioned above.
137- BIO_set_callback_arg(BIO *io, char *arg) - assign some
138 data against the BIO. This is normally used by the debug
139 callback but could in reality be used for anything. To
140 get an idea of how all this works, have a look at the code
141 in the default debug callback mentioned above. The
142 callback can modify the return values.
143
144Details of the BIO_METHOD structure.
145typedef struct bio_method_st
146 {
147 int type;
148 char *name;
149 int (*bwrite)();
150 int (*bread)();
151 int (*bputs)();
152 int (*bgets)();
153 long (*ctrl)();
154 int (*create)();
155 int (*destroy)();
156 } BIO_METHOD;
157
158The 'type' is the numeric type of the BIO, these are listed in buffer.h;
159'Name' is a textual representation of the BIO 'type'.
160The 7 function pointers point to the respective function
161methods, some of which can be NULL if not implemented.
162The BIO structure
163typedef struct bio_st
164 {
165 BIO_METHOD *method;
166 long (*callback)(BIO * bio, int mode, char *argp, int
167 argi, long argl, long ret);
168 char *cb_arg; /* first argument for the callback */
169 int init;
170 int shutdown;
171 int flags; /* extra storage */
172 int num;
173 char *ptr;
174 struct bio_st *next_bio; /* used by filter BIOs */
175 int references;
176 unsigned long num_read;
177 unsigned long num_write;
178 } BIO;
179
180- 'Method' is the BIO method.
181- 'callback', when configured, is called before and after
182 each BIO method is called for that particular BIO. This
183 is intended primarily for debugging and of informational feedback.
184- 'init' is 0 when the BIO can be used for operation.
185 Often, after a BIO is created, a number of operations may
186 need to be performed before it is available for use. An
187 example is for BIO_s_sock(). A socket needs to be
188 assigned to the BIO before it can be used.
189- 'shutdown', this flag indicates if the underlying
190 comunication primative being used should be closed/freed
191 when the BIO is closed.
192- 'flags' is used to hold extra state. It is primarily used
193 to hold information about why a non-blocking operation
194 failed and to record startup protocol information for the
195 SSL BIO.
196- 'num' and 'ptr' are used to hold instance specific state
197 like file descriptors or local data structures.
198- 'next_bio' is used by filter BIOs to hold the pointer of the
199 next BIO in the chain. written data is sent to this BIO and
200 data read is taken from it.
201- 'references' is used to indicate the number of pointers to
202 this structure. This needs to be '1' before a call to
203 BIO_free() is made if the BIO_free() function is to
204 actually free() the structure, otherwise the reference
205 count is just decreased. The actual BIO subsystem does
206 not really use this functionality but it is useful when
207 used in more advanced applicaion.
208- num_read and num_write are the total number of bytes
209 read/written via the 'read()' and 'write()' methods.
210
211BIO_ctrl operations.
212The following is the list of standard commands passed as the
213second parameter to BIO_ctrl() and should be supported by
214all BIO as best as possible. Some are optional, some are
215manditory, in any case, where is makes sense, a filter BIO
216should pass such requests to underlying BIO's.
217- BIO_CTRL_RESET - Reset the BIO back to an initial state.
218- BIO_CTRL_EOF - return 0 if we are not at the end of input,
219 non 0 if we are.
220- BIO_CTRL_INFO - BIO specific special command, normal
221 information return.
222- BIO_CTRL_SET - set IO specific parameter.
223- BIO_CTRL_GET - get IO specific parameter.
224- BIO_CTRL_GET_CLOSE - Get the close on BIO_free() flag, one
225 of BIO_CLOSE or BIO_NOCLOSE.
226- BIO_CTRL_SET_CLOSE - Set the close on BIO_free() flag.
227- BIO_CTRL_PENDING - Return the number of bytes available
228 for instant reading
229- BIO_CTRL_FLUSH - Output pending data, return number of bytes output.
230- BIO_CTRL_SHOULD_RETRY - After an IO error (-1 returned)
231 should we 'retry' when IO is possible on the underlying IO object.
232- BIO_CTRL_RETRY_TYPE - What kind of IO are we waiting on.
233
234The following command is a special BIO_s_file() specific option.
235- BIO_CTRL_SET_FILENAME - specify a file to open for IO.
236
237The BIO_CTRL_RETRY_TYPE needs a little more explanation.
238When performing non-blocking IO, or say reading on a memory
239BIO, when no data is present (or cannot be written),
240BIO_read() and/or BIO_write() will return -1.
241BIO_should_retry(bio) will return true if this is due to an
242IO condition rather than an actual error. In the case of
243BIO_s_mem(), a read when there is no data will return -1 and
244a should retry when there is more 'read' data.
245The retry type is deduced from 2 macros
246BIO_should_read(bio) and BIO_should_write(bio).
247Now while it may appear obvious that a BIO_read() failure
248should indicate that a retry should be performed when more
249read data is available, this is often not true when using
250things like an SSL BIO. During the SSL protocol startup
251multiple reads and writes are performed, triggered by any
252SSL_read or SSL_write.
253So to write code that will transparently handle either a
254socket or SSL BIO,
255 i=BIO_read(bio,..)
256 if (I == -1)
257 {
258 if (BIO_should_retry(bio))
259 {
260 if (BIO_should_read(bio))
261 {
262 /* call us again when BIO can be read */
263 }
264 if (BIO_should_write(bio))
265 {
266 /* call us again when BIO can be written */
267 }
268 }
269 }
270
271At this point in time only read and write conditions can be
272used but in the future I can see the situation for other
273conditions, specifically with SSL there could be a condition
274of a X509 certificate lookup taking place and so the non-
275blocking BIO_read would require a retry when the certificate
276lookup subsystem has finished it's lookup. This is all
277makes more sense and is easy to use in a event loop type
278setup.
279When using the SSL BIO, either SSL_read() or SSL_write()s
280can be called during the protocol startup and things will
281still work correctly.
282The nice aspect of the use of the BIO_should_retry() macro
283is that all the errno codes that indicate a non-fatal error
284are encapsulated in one place. The Windows specific error
285codes and WSAGetLastError() calls are also hidden from the
286application.
287
288Notes on each BIO method.
289Normally buffer.h is just required but depending on the
290BIO_METHOD, ssl.h or evp.h will also be required.
291
292BIO_METHOD *BIO_s_mem(void);
293- BIO_set_mem_buf(BIO *bio, BUF_MEM *bm, int close_flag) -
294 set the underlying BUF_MEM structure for the BIO to use.
295- BIO_get_mem_ptr(BIO *bio, char **pp) - if pp is not NULL,
296 set it to point to the memory array and return the number
297 of bytes available.
298A read/write BIO. Any data written is appended to the
299memory array and any read is read from the front. This BIO
300can be used for read/write at the same time. BIO_gets() is
301supported in the fgets() sense.
302BIO_CTRL_INFO can be used to retrieve pointers to the memory
303buffer and it's length.
304
305BIO_METHOD *BIO_s_file(void);
306- BIO_set_fp(BIO *bio, FILE *fp, int close_flag) - set 'FILE *' to use.
307- BIO_get_fp(BIO *bio, FILE **fp) - get the 'FILE *' in use.
308- BIO_read_filename(BIO *bio, char *name) - read from file.
309- BIO_write_filename(BIO *bio, char *name) - write to file.
310- BIO_append_filename(BIO *bio, char *name) - append to file.
311This BIO sits over the normal system fread()/fgets() type
312functions. Gets() is supported. This BIO in theory could be
313used for read and write but it is best to think of each BIO
314of this type as either a read or a write BIO, not both.
315
316BIO_METHOD *BIO_s_socket(void);
317BIO_METHOD *BIO_s_fd(void);
318- BIO_sock_should_retry(int i) - the underlying function
319 used to determine if a call should be retried; the
320 argument is the '0' or '-1' returned by the previous BIO
321 operation.
322- BIO_fd_should_retry(int i) - same as the
323- BIO_sock_should_retry() except that it is different internally.
324- BIO_set_fd(BIO *bio, int fd, int close_flag) - set the
325 file descriptor to use
326- BIO_get_fd(BIO *bio, int *fd) - get the file descriptor.
327These two methods are very similar. Gets() is not
328supported, if you want this functionality, put a
329BIO_f_buffer() onto it. This BIO is bi-directional if the
330underlying file descriptor is. This is normally the case
331for sockets but not the case for stdio descriptors.
332
333BIO_METHOD *BIO_s_null(void);
334Read and write as much data as you like, it all disappears
335into this BIO.
336
337BIO_METHOD *BIO_f_buffer(void);
338- BIO_get_buffer_num_lines(BIO *bio) - return the number of
339 complete lines in the buffer.
340- BIO_set_buffer_size(BIO *bio, long size) - set the size of
341 the buffers.
342This type performs input and output buffering. It performs
343both at the same time. The size of the buffer can be set
344via the set buffer size option. Data buffered for output is
345only written when the buffer fills.
346
347BIO_METHOD *BIO_f_ssl(void);
348- BIO_set_ssl(BIO *bio, SSL *ssl, int close_flag) - the SSL
349 structure to use.
350- BIO_get_ssl(BIO *bio, SSL **ssl) - get the SSL structure
351 in use.
352The SSL bio is a little different from normal BIOs because
353the underlying SSL structure is a little different. A SSL
354structure performs IO via a read and write BIO. These can
355be different and are normally set via the
356SSL_set_rbio()/SSL_set_wbio() calls. The SSL_set_fd() calls
357are just wrappers that create socket BIOs and then call
358SSL_set_bio() where the read and write BIOs are the same.
359The BIO_push() operation makes the SSLs IO BIOs the same, so
360make sure the BIO pushed is capable of two directional
361traffic. If it is not, you will have to install the BIOs
362via the more conventional SSL_set_bio() call. BIO_pop() will retrieve
363the 'SSL read' BIO.
364
365BIO_METHOD *BIO_f_md(void);
366- BIO_set_md(BIO *bio, EVP_MD *md) - set the message digest
367 to use.
368- BIO_get_md(BIO *bio, EVP_MD **mdp) - return the digest
369 method in use in mdp, return 0 if not set yet.
370- BIO_reset() reinitializes the digest (EVP_DigestInit())
371 and passes the reset to the underlying BIOs.
372All data read or written via BIO_read() or BIO_write() to
373this BIO will be added to the calculated digest. This
374implies that this BIO is only one directional. If read and
375write operations are performed, two separate BIO_f_md() BIOs
376are reuqired to generate digests on both the input and the
377output. BIO_gets(BIO *bio, char *md, int size) will place the
378generated digest into 'md' and return the number of bytes.
379The EVP_MAX_MD_SIZE should probably be used to size the 'md'
380array. Reading the digest will also reset it.
381
382BIO_METHOD *BIO_f_cipher(void);
383- BIO_reset() reinitializes the cipher.
384- BIO_flush() should be called when the last bytes have been
385 output to flush the final block of block ciphers.
386- BIO_get_cipher_status(BIO *b), when called after the last
387 read from a cipher BIO, returns non-zero if the data
388 decrypted correctly, otherwise, 0.
389- BIO_set_cipher(BIO *b, EVP_CIPHER *c, unsigned char *key,
390 unsigned char *iv, int encrypt) This function is used to
391 setup a cipher BIO. The length of key and iv are
392 specified by the choice of EVP_CIPHER. Encrypt is 1 to
393 encrypt and 0 to decrypt.
394
395BIO_METHOD *BIO_f_base64(void);
396- BIO_flush() should be called when the last bytes have been output.
397This BIO base64 encodes when writing and base64 decodes when
398reading. It will scan the input until a suitable begin line
399is found. After reading data, BIO_reset() will reset the
400BIO to start scanning again. Do not mix reading and writing
401on the same base64 BIO. It is meant as a single stream BIO.
402
403Directions type
404both BIO_s_mem()
405one/both BIO_s_file()
406both BIO_s_fd()
407both BIO_s_socket()
408both BIO_s_null()
409both BIO_f_buffer()
410one BIO_f_md()
411one BIO_f_cipher()
412one BIO_f_base64()
413both BIO_f_ssl()
414
415It is easy to mix one and two directional BIOs, all one has
416to do is to keep two separate BIO pointers for reading and
417writing and be careful about usage of underlying BIOs. The
418SSL bio by it's very nature has to be two directional but
419the BIO_push() command will push the one BIO into the SSL
420BIO for both reading and writing.
421
422The best example program to look at is apps/enc.c and/or perhaps apps/dgst.c.
423
diff --git a/src/lib/libssl/src/doc/blowfish.doc b/src/lib/libssl/src/doc/blowfish.doc
new file mode 100644
index 0000000000..8a7f425b32
--- /dev/null
+++ b/src/lib/libssl/src/doc/blowfish.doc
@@ -0,0 +1,146 @@
1The Blowfish library.
2
3Blowfish is a block cipher that operates on 64bit (8 byte) quantities. It
4uses variable size key, but 128bit (16 byte) key would normally be considered
5good. It can be used in all the modes that DES can be used. This
6library implements the ecb, cbc, cfb64, ofb64 modes.
7
8Blowfish is quite a bit faster that DES, and much faster than IDEA or
9RC2. It is one of the faster block ciphers.
10
11For all calls that have an 'input' and 'output' variables, they can be the
12same.
13
14This library requires the inclusion of 'blowfish.h'.
15
16All of the encryption functions take what is called an BF_KEY as an
17argument. An BF_KEY is an expanded form of the Blowfish key.
18For all modes of the Blowfish algorithm, the BF_KEY used for
19decryption is the same one that was used for encryption.
20
21The define BF_ENCRYPT is passed to specify encryption for the functions
22that require an encryption/decryption flag. BF_DECRYPT is passed to
23specify decryption.
24
25Please note that any of the encryption modes specified in my DES library
26could be used with Blowfish. I have only implemented ecb, cbc, cfb64 and
27ofb64 for the following reasons.
28- ecb is the basic Blowfish encryption.
29- cbc is the normal 'chaining' form for block ciphers.
30- cfb64 can be used to encrypt single characters, therefore input and output
31 do not need to be a multiple of 8.
32- ofb64 is similar to cfb64 but is more like a stream cipher, not as
33 secure (not cipher feedback) but it does not have an encrypt/decrypt mode.
34- If you want triple Blowfish, thats 384 bits of key and you must be totally
35 obsessed with security. Still, if you want it, it is simple enough to
36 copy the function from the DES library and change the des_encrypt to
37 BF_encrypt; an exercise left for the paranoid reader :-).
38
39The functions are as follows:
40
41void BF_set_key(
42BF_KEY *ks;
43int len;
44unsigned char *key;
45 BF_set_key converts an 'len' byte key into a BF_KEY.
46 A 'ks' is an expanded form of the 'key' which is used to
47 perform actual encryption. It can be regenerated from the Blowfish key
48 so it only needs to be kept when encryption or decryption is about
49 to occur. Don't save or pass around BF_KEY's since they
50 are CPU architecture dependent, 'key's are not. Blowfish is an
51 interesting cipher in that it can be used with a variable length
52 key. 'len' is the length of 'key' to be used as the key.
53 A 'len' of 16 is recomended by me, but blowfish can use upto
54 72 bytes. As a warning, blowfish has a very very slow set_key
55 function, it actually runs BF_encrypt 521 times.
56
57void BF_encrypt(unsigned long *data, BF_KEY *key);
58void BF_decrypt(unsigned long *data, BF_KEY *key);
59 These are the Blowfish encryption function that gets called by just
60 about every other Blowfish routine in the library. You should not
61 use this function except to implement 'modes' of Blowfish.
62 I say this because the
63 functions that call this routine do the conversion from 'char *' to
64 long, and this needs to be done to make sure 'non-aligned' memory
65 access do not occur.
66 Data is a pointer to 2 unsigned long's and key is the
67 BF_KEY to use.
68
69void BF_ecb_encrypt(
70unsigned char *in,
71unsigned char *out,
72BF_KEY *key,
73int encrypt);
74 This is the basic Electronic Code Book form of Blowfish (in DES this
75 mode is called Electronic Code Book so I'm going to use the term
76 for blowfish as well.
77 Input is encrypted into output using the key represented by
78 key. Depending on the encrypt, encryption or
79 decryption occurs. Input is 8 bytes long and output is 8 bytes.
80
81void BF_cbc_encrypt(
82unsigned char *in,
83unsigned char *out,
84long length,
85BF_KEY *ks,
86unsigned char *ivec,
87int encrypt);
88 This routine implements Blowfish in Cipher Block Chaining mode.
89 Input, which should be a multiple of 8 bytes is encrypted
90 (or decrypted) to output which will also be a multiple of 8 bytes.
91 The number of bytes is in length (and from what I've said above,
92 should be a multiple of 8). If length is not a multiple of 8, bad
93 things will probably happen. ivec is the initialisation vector.
94 This function updates iv after each call so that it can be passed to
95 the next call to BF_cbc_encrypt().
96
97void BF_cfb64_encrypt(
98unsigned char *in,
99unsigned char *out,
100long length,
101BF_KEY *schedule,
102unsigned char *ivec,
103int *num,
104int encrypt);
105 This is one of the more useful functions in this Blowfish library, it
106 implements CFB mode of Blowfish with 64bit feedback.
107 This allows you to encrypt an arbitrary number of bytes,
108 you do not require 8 byte padding. Each call to this
109 routine will encrypt the input bytes to output and then update ivec
110 and num. Num contains 'how far' we are though ivec.
111 'Encrypt' is used to indicate encryption or decryption.
112 CFB64 mode operates by using the cipher to generate a stream
113 of bytes which is used to encrypt the plain text.
114 The cipher text is then encrypted to generate the next 64 bits to
115 be xored (incrementally) with the next 64 bits of plain
116 text. As can be seen from this, to encrypt or decrypt,
117 the same 'cipher stream' needs to be generated but the way the next
118 block of data is gathered for encryption is different for
119 encryption and decryption.
120
121void BF_ofb64_encrypt(
122unsigned char *in,
123unsigned char *out,
124long length,
125BF_KEY *schedule,
126unsigned char *ivec,
127int *num);
128 This functions implements OFB mode of Blowfish with 64bit feedback.
129 This allows you to encrypt an arbitrary number of bytes,
130 you do not require 8 byte padding. Each call to this
131 routine will encrypt the input bytes to output and then update ivec
132 and num. Num contains 'how far' we are though ivec.
133 This is in effect a stream cipher, there is no encryption or
134 decryption mode.
135
136For reading passwords, I suggest using des_read_pw_string() from my DES library.
137To generate a password from a text string, I suggest using MD5 (or MD2) to
138produce a 16 byte message digest that can then be passed directly to
139BF_set_key().
140
141=====
142For more information about the specific Blowfish modes in this library
143(ecb, cbc, cfb and ofb), read the section entitled 'Modes of DES' from the
144documentation on my DES library. What is said about DES is directly
145applicable for Blowfish.
146
diff --git a/src/lib/libssl/src/doc/bn.doc b/src/lib/libssl/src/doc/bn.doc
new file mode 100644
index 0000000000..47be23b6ea
--- /dev/null
+++ b/src/lib/libssl/src/doc/bn.doc
@@ -0,0 +1,381 @@
1The Big Number library.
2
3#include "bn.h" when using this library.
4
5This big number library was written for use in implementing the RSA and DH
6public key encryption algorithms. As such, features such as negative
7numbers have not been extensively tested but they should work as expected.
8This library uses dynamic memory allocation for storing its data structures
9and so there are no limit on the size of the numbers manipulated by these
10routines but there is always the requirement to check return codes from
11functions just in case a memory allocation error has occurred.
12
13The basic object in this library is a BIGNUM. It is used to hold a single
14large integer. This type should be considered opaque and fields should not
15be modified or accessed directly.
16typedef struct bignum_st
17 {
18 int top; /* Index of last used d. */
19 BN_ULONG *d; /* Pointer to an array of 'BITS2' bit chunks. */
20 int max; /* Size of the d array. */
21 int neg;
22 } BIGNUM;
23The big number is stored in a malloced array of BN_ULONG's. A BN_ULONG can
24be either 16, 32 or 64 bits in size, depending on the 'number of bits'
25specified in bn.h.
26The 'd' field is this array. 'max' is the size of the 'd' array that has
27been allocated. 'top' is the 'last' entry being used, so for a value of 4,
28bn.d[0]=4 and bn.top=1. 'neg' is 1 if the number is negative.
29When a BIGNUM is '0', the 'd' field can be NULL and top == 0.
30
31Various routines in this library require the use of 'temporary' BIGNUM
32variables during their execution. Due to the use of dynamic memory
33allocation to create BIGNUMs being rather expensive when used in
34conjunction with repeated subroutine calls, the BN_CTX structure is
35used. This structure contains BN_CTX BIGNUMs. BN_CTX
36is the maximum number of temporary BIGNUMs any publicly exported
37function will use.
38
39#define BN_CTX 12
40typedef struct bignum_ctx
41 {
42 int tos; /* top of stack */
43 BIGNUM *bn[BN_CTX]; /* The variables */
44 } BN_CTX;
45
46The functions that follow have been grouped according to function. Most
47arithmetic functions return a result in the first argument, sometimes this
48first argument can also be an input parameter, sometimes it cannot. These
49restrictions are documented.
50
51extern BIGNUM *BN_value_one;
52There is one variable defined by this library, a BIGNUM which contains the
53number 1. This variable is useful for use in comparisons and assignment.
54
55Get Size functions.
56
57int BN_num_bits(BIGNUM *a);
58 This function returns the size of 'a' in bits.
59
60int BN_num_bytes(BIGNUM *a);
61 This function (macro) returns the size of 'a' in bytes.
62 For conversion of BIGNUMs to byte streams, this is the number of
63 bytes the output string will occupy. If the output byte
64 format specifies that the 'top' bit indicates if the number is
65 signed, so an extra '0' byte is required if the top bit on a
66 positive number is being written, it is upto the application to
67 make this adjustment. Like I said at the start, I don't
68 really support negative numbers :-).
69
70Creation/Destruction routines.
71
72BIGNUM *BN_new();
73 Return a new BIGNUM object. The number initially has a value of 0. If
74 there is an error, NULL is returned.
75
76void BN_free(BIGNUM *a);
77 Free()s a BIGNUM.
78
79void BN_clear(BIGNUM *a);
80 Sets 'a' to a value of 0 and also zeros all unused allocated
81 memory. This function is used to clear a variable of 'sensitive'
82 data that was held in it.
83
84void BN_clear_free(BIGNUM *a);
85 This function zeros the memory used by 'a' and then free()'s it.
86 This function should be used to BN_free() BIGNUMS that have held
87 sensitive numeric values like RSA private key values. Both this
88 function and BN_clear tend to only be used by RSA and DH routines.
89
90BN_CTX *BN_CTX_new(void);
91 Returns a new BN_CTX. NULL on error.
92
93void BN_CTX_free(BN_CTX *c);
94 Free a BN_CTX structure. The BIGNUMs in 'c' are BN_clear_free()ed.
95
96BIGNUM *bn_expand(BIGNUM *b, int bits);
97 This is an internal function that should not normally be used. It
98 ensures that 'b' has enough room for a 'bits' bit number. It is
99 mostly used by the various BIGNUM routines. If there is an error,
100 NULL is returned. if not, 'b' is returned.
101
102BIGNUM *BN_copy(BIGNUM *to, BIGNUM *from);
103 The 'from' is copied into 'to'. NULL is returned if there is an
104 error, otherwise 'to' is returned.
105
106BIGNUM *BN_dup(BIGNUM *a);
107 A new BIGNUM is created and returned containing the value of 'a'.
108 NULL is returned on error.
109
110Comparison and Test Functions.
111
112int BN_is_zero(BIGNUM *a)
113 Return 1 if 'a' is zero, else 0.
114
115int BN_is_one(a)
116 Return 1 is 'a' is one, else 0.
117
118int BN_is_word(a,w)
119 Return 1 if 'a' == w, else 0. 'w' is a BN_ULONG.
120
121int BN_cmp(BIGNUM *a, BIGNUM *b);
122 Return -1 if 'a' is less than 'b', 0 if 'a' and 'b' are the same
123 and 1 is 'a' is greater than 'b'. This is a signed comparison.
124
125int BN_ucmp(BIGNUM *a, BIGNUM *b);
126 This function is the same as BN_cmp except that the comparison
127 ignores the sign of the numbers.
128
129Arithmetic Functions
130For all of these functions, 0 is returned if there is an error and 1 is
131returned for success. The return value should always be checked. eg.
132if (!BN_add(r,a,b)) goto err;
133Unless explicitly mentioned, the 'return' value can be one of the
134'parameters' to the function.
135
136int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b);
137 Add 'a' and 'b' and return the result in 'r'. This is r=a+b.
138
139int BN_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b);
140 Subtract 'a' from 'b' and put the result in 'r'. This is r=a-b.
141
142int BN_lshift(BIGNUM *r, BIGNUM *a, int n);
143 Shift 'a' left by 'n' bits. This is r=a*(2^n).
144
145int BN_lshift1(BIGNUM *r, BIGNUM *a);
146 Shift 'a' left by 1 bit. This form is more efficient than
147 BN_lshift(r,a,1). This is r=a*2.
148
149int BN_rshift(BIGNUM *r, BIGNUM *a, int n);
150 Shift 'a' right by 'n' bits. This is r=int(a/(2^n)).
151
152int BN_rshift1(BIGNUM *r, BIGNUM *a);
153 Shift 'a' right by 1 bit. This form is more efficient than
154 BN_rshift(r,a,1). This is r=int(a/2).
155
156int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b);
157 Multiply a by b and return the result in 'r'. 'r' must not be
158 either 'a' or 'b'. It has to be a different BIGNUM.
159 This is r=a*b.
160
161int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx);
162 Multiply a by a and return the result in 'r'. 'r' must not be
163 'a'. This function is alot faster than BN_mul(r,a,a). This is r=a*a.
164
165int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx);
166 Divide 'm' by 'd' and return the result in 'dv' and the remainder
167 in 'rem'. Either of 'dv' or 'rem' can be NULL in which case that
168 value is not returned. 'ctx' needs to be passed as a source of
169 temporary BIGNUM variables.
170 This is dv=int(m/d), rem=m%d.
171
172int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx);
173 Find the remainder of 'm' divided by 'd' and return it in 'rem'.
174 'ctx' holds the temporary BIGNUMs required by this function.
175 This function is more efficient than BN_div(NULL,rem,m,d,ctx);
176 This is rem=m%d.
177
178int BN_mod_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *m,BN_CTX *ctx);
179 Multiply 'a' by 'b' and return the remainder when divided by 'm'.
180 'ctx' holds the temporary BIGNUMs required by this function.
181 This is r=(a*b)%m.
182
183int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m,BN_CTX *ctx);
184 Raise 'a' to the 'p' power and return the remainder when divided by
185 'm'. 'ctx' holds the temporary BIGNUMs required by this function.
186 This is r=(a^p)%m.
187
188int BN_reciprocal(BIGNUM *r, BIGNUM *m, BN_CTX *ctx);
189 Return the reciprocal of 'm'. 'ctx' holds the temporary variables
190 required. This function returns -1 on error, otherwise it returns
191 the number of bits 'r' is shifted left to make 'r' into an integer.
192 This number of bits shifted is required in BN_mod_mul_reciprocal().
193 This is r=(1/m)<<(BN_num_bits(m)+1).
194
195int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BIGNUM *m,
196 BIGNUM *i, int nb, BN_CTX *ctx);
197 This function is used to perform an efficient BN_mod_mul()
198 operation. If one is going to repeatedly perform BN_mod_mul() with
199 the same modulus is worth calculating the reciprocal of the modulus
200 and then using this function. This operation uses the fact that
201 a/b == a*r where r is the reciprocal of b. On modern computers
202 multiplication is very fast and big number division is very slow.
203 'x' is multiplied by 'y' and then divided by 'm' and the remainder
204 is returned. 'i' is the reciprocal of 'm' and 'nb' is the number
205 of bits as returned from BN_reciprocal(). Normal usage is as follows.
206 bn=BN_reciprocal(i,m);
207 for (...)
208 { BN_mod_mul_reciprocal(r,x,y,m,i,bn,ctx); }
209 This is r=(x*y)%m. Internally it is approximately
210 r=(x*y)-m*(x*y/m) or r=(x*y)-m*((x*y*i) >> bn)
211 This function is used in BN_mod_exp() and BN_is_prime().
212
213Assignment Operations
214
215int BN_one(BIGNUM *a)
216 Set 'a' to hold the value one.
217 This is a=1.
218
219int BN_zero(BIGNUM *a)
220 Set 'a' to hold the value zero.
221 This is a=0.
222
223int BN_set_word(BIGNUM *a, unsigned long w);
224 Set 'a' to hold the value of 'w'. 'w' is an unsigned long.
225 This is a=w.
226
227unsigned long BN_get_word(BIGNUM *a);
228 Returns 'a' in an unsigned long. Not remarkably, often 'a' will
229 be biger than a word, in which case 0xffffffffL is returned.
230
231Word Operations
232These functions are much more efficient that the normal bignum arithmetic
233operations.
234
235BN_ULONG BN_mod_word(BIGNUM *a, unsigned long w);
236 Return the remainder of 'a' divided by 'w'.
237 This is return(a%w).
238
239int BN_add_word(BIGNUM *a, unsigned long w);
240 Add 'w' to 'a'. This function does not take the sign of 'a' into
241 account. This is a+=w;
242
243Bit operations.
244
245int BN_is_bit_set(BIGNUM *a, int n);
246 This function return 1 if bit 'n' is set in 'a' else 0.
247
248int BN_set_bit(BIGNUM *a, int n);
249 This function sets bit 'n' to 1 in 'a'.
250 This is a&= ~(1<<n);
251
252int BN_clear_bit(BIGNUM *a, int n);
253 This function sets bit 'n' to zero in 'a'. Return 0 if less
254 than 'n' bits in 'a' else 1. This is a&= ~(1<<n);
255
256int BN_mask_bits(BIGNUM *a, int n);
257 Truncate 'a' to n bits long. This is a&= ~((~0)<<n)
258
259Format conversion routines.
260
261BIGNUM *BN_bin2bn(unsigned char *s, int len,BIGNUM *ret);
262 This function converts 'len' bytes in 's' into a BIGNUM which
263 is put in 'ret'. If ret is NULL, a new BIGNUM is created.
264 Either this new BIGNUM or ret is returned. The number is
265 assumed to be in bigendian form in 's'. By this I mean that
266 to 'ret' is created as follows for 'len' == 5.
267 ret = s[0]*2^32 + s[1]*2^24 + s[2]*2^16 + s[3]*2^8 + s[4];
268 This function cannot be used to convert negative numbers. It
269 is always assumed the number is positive. The application
270 needs to diddle the 'neg' field of th BIGNUM its self.
271 The better solution would be to save the numbers in ASN.1 format
272 since this is a defined standard for storing big numbers.
273 Look at the functions
274
275 ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai);
276 BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *ai,BIGNUM *bn);
277 int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
278 ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
279 long length;
280
281int BN_bn2bin(BIGNUM *a, unsigned char *to);
282 This function converts 'a' to a byte string which is put into
283 'to'. The representation is big-endian in that the most
284 significant byte of 'a' is put into to[0]. This function
285 returns the number of bytes used to hold 'a'. BN_num_bytes(a)
286 would return the same value and can be used to determine how
287 large 'to' needs to be. If the number is negative, this
288 information is lost. Since this library was written to
289 manipulate large positive integers, the inability to save and
290 restore them is not considered to be a problem by me :-).
291 As for BN_bin2bn(), look at the ASN.1 integer encoding funtions
292 for SSLeay. They use BN_bin2bn() and BN_bn2bin() internally.
293
294char *BN_bn2ascii(BIGNUM *a);
295 This function returns a malloc()ed string that contains the
296 ascii hexadecimal encoding of 'a'. The number is in bigendian
297 format with a '-' in front if the number is negative.
298
299int BN_ascii2bn(BIGNUM **bn, char *a);
300 The inverse of BN_bn2ascii. The function returns the number of
301 characters from 'a' were processed in generating a the bignum.
302 error is inticated by 0 being returned. The number is a
303 hex digit string, optionally with a leading '-'. If *bn
304 is null, a BIGNUM is created and returned via that variable.
305
306int BN_print_fp(FILE *fp, BIGNUM *a);
307 'a' is printed to file pointer 'fp'. It is in the same format
308 that is output from BN_bn2ascii(). 0 is returned on error,
309 1 if things are ok.
310
311int BN_print(BIO *bp, BIGNUM *a);
312 Same as BN_print except that the output is done to the SSLeay libraries
313 BIO routines. BN_print_fp() actually calls this function.
314
315Miscellaneous Routines.
316
317int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
318 This function returns in 'rnd' a random BIGNUM that is bits
319 long. If bottom is 1, the number returned is odd. If top is set,
320 the top 2 bits of the number are set. This is useful because if
321 this is set, 2 'n; bit numbers multiplied together will return a 2n
322 bit number. If top was not set, they could produce a 2n-1 bit
323 number.
324
325BIGNUM *BN_mod_inverse(BIGNUM *a, BIGNUM *n,BN_CTX *ctx);
326 This function create a new BIGNUM and returns it. This number
327 is the inverse mod 'n' of 'a'. By this it is meant that the
328 returned value 'r' satisfies (a*r)%n == 1. This function is
329 used in the generation of RSA keys. 'ctx', as per usual,
330 is used to hold temporary variables that are required by the
331 function. NULL is returned on error.
332
333int BN_gcd(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_CTX *ctx);
334 'r' has the greatest common divisor of 'a' and 'b'. 'ctx' is
335 used for temporary variables and 0 is returned on error.
336
337int BN_is_prime(BIGNUM *p,int nchecks,void (*callback)(),BN_CTX *ctx,
338 char *cb_arg);
339 This function is used to check if a BIGNUM ('p') is prime.
340 It performs this test by using the Miller-Rabin randomised
341 primality test. This is a probalistic test that requires a
342 number of rounds to ensure the number is prime to a high
343 degree of probability. Since this can take quite some time, a
344 callback function can be passed and it will be called each
345 time 'p' passes a round of the prime testing. 'callback' will
346 be called as follows, callback(1,n,cb_arg) where n is the number of
347 the round, just passed. As per usual 'ctx' contains temporary
348 variables used. If ctx is NULL, it does not matter, a local version
349 will be malloced. This parameter is present to save some mallocing
350 inside the function but probably could be removed.
351 0 is returned on error.
352 'ncheck' is the number of Miller-Rabin tests to run. It is
353 suggested to use the value 'BN_prime_checks' by default.
354
355BIGNUM *BN_generate_prime(
356int bits,
357int strong,
358BIGNUM *a,
359BIGNUM *rems,
360void (*callback)());
361char *cb_arg
362 This function is used to generate prime numbers. It returns a
363 new BIGNUM that has a high probability of being a prime.
364 'bits' is the number of bits that
365 are to be in the prime. If 'strong' is true, the returned prime
366 will also be a strong prime ((p-1)/2 is also prime).
367 While searching for the prime ('p'), we
368 can add the requirement that the prime fill the following
369 condition p%a == rem. This can be used to help search for
370 primes with specific features, which is required when looking
371 for primes suitable for use with certain 'g' values in the
372 Diffie-Hellman key exchange algorithm. If 'a' is NULL,
373 this condition is not checked. If rem is NULL, rem is assumed
374 to be 1. Since this search for a prime
375 can take quite some time, if callback is not NULL, it is called
376 in the following situations.
377 We have a suspected prime (from a quick sieve),
378 callback(0,sus_prime++,cb_arg). Each item to be passed to BN_is_prime().
379 callback(1,round++,cb_arg). Each successful 'round' in BN_is_prime().
380 callback(2,round,cb_arg). For each successful BN_is_prime() test.
381
diff --git a/src/lib/libssl/src/doc/ca.1 b/src/lib/libssl/src/doc/ca.1
new file mode 100644
index 0000000000..5b0c5a198d
--- /dev/null
+++ b/src/lib/libssl/src/doc/ca.1
@@ -0,0 +1,121 @@
1From eay@orb.mincom.oz.au Thu Dec 28 23:56:45 1995
2Received: by orb.mincom.oz.au id AA07374
3 (5.65c/IDA-1.4.4 for eay); Thu, 28 Dec 1995 13:56:45 +1000
4Date: Thu, 28 Dec 1995 13:56:45 +1000 (EST)
5From: Eric Young <eay@mincom.oz.au>
6X-Sender: eay@orb
7To: sameer <sameer@c2.org>
8Cc: ssleay@mincom.oz.au
9Subject: Re: 'ca'
10In-Reply-To: <199512230440.UAA23410@infinity.c2.org>
11Message-Id: <Pine.SOL.3.91.951228133525.7269A-100000@orb>
12Mime-Version: 1.0
13Content-Type: TEXT/PLAIN; charset=US-ASCII
14Status: RO
15X-Status:
16
17On Fri, 22 Dec 1995, sameer wrote:
18> I could use documentation on 'ca'. Thanks.
19
20Very quickly.
21The ca program uses the ssleay.conf file for most of its configuration
22
23./ca -help
24
25 -verbose - Talk alot while doing things
26 -config file - A config file. If you don't want to use the
27 default config file
28 -name arg - The particular CA definition to use
29 In the config file, the section to use for parameters. This lets
30 multiple setups to be contained in the one file. By default, the
31 default_ca variable is looked up in the [ ca ] section. So in the
32 shipped ssleay.conf, the CA definition used is CA_default. It could be
33 any other name.
34 -gencrl days - Generate a new CRL, days is when the next CRL is due
35 This will generate a new certificate revocion list.
36 -days arg - number of days to certify the certificate for
37 When certifiying certificates, this is the number of days to use.
38 -md arg - md to use, one of md2, md5, sha or sha1
39 -policy arg - The CA 'policy' to support
40 I'll describe this later, but there are 2 policies definied in the
41 shipped ssleay.conf
42 -keyfile arg - PEM RSA private key file
43 -key arg - key to decode the RSA private key if it is encrypted
44 since we need to keep the CA's RSA key encrypted
45 -cert - The CA certificate
46 -in file - The input PEM encoded certificate request(s)
47 -out file - Where to put the output file(s)
48 -outdir dir - Where to put output certificates
49 The -out options concatinates all the output certificied
50 certificates to one file, -outdir puts them in a directory,
51 named by serial number.
52 -infiles .... - The last argument, requests to process
53 The certificate requests to process, -in is the same.
54
55Just about all the above have default values defined in ssleay.conf.
56
57The key variables in ssleay.conf are (for the pariticular '-name' being
58used, in the default, it is CA_default).
59
60dir is where all the CA database stuff is kept.
61certs is where all the previously issued certificates are kept.
62The database is a simple text database containing the following tab separated
63fields.
64status: a value of 'R' - revoked, 'E' -expired or 'V' valid.
65issued date: When the certificate was certified.
66revoked date: When it was revoked, blank if not revoked.
67serial number: The certificate serial number.
68certificate: Where the certificate is located.
69CN: The name of the certificate.
70
71The demo file has quite a few made up values it it. The last 2 were
72added by the ca program and are acurate.
73The CA program does not update the 'certificate' file correctly right now.
74The serial field should be unique as should the CN/status combination.
75The ca program checks these at startup. What still needs to be
76wrtten is a program to 'regenerate' the data base file from the issued
77certificate list (and a CRL list).
78
79Back to the CA_default variables.
80
81Most of the variables are commented.
82
83policy is the default policy.
84
85Ok for policies, they define the order and which fields must be present
86in the certificate request and what gets filled in.
87
88So a value of
89countryName = match
90means that the country name must match the CA certificate.
91organizationalUnitName = optional
92The org.Unit,Name does not have to be present and
93commonName = supplied
94commonName must be supplied in the certificate request.
95
96For the 'policy_match' polocy, the order of the attributes in the
97generated certiticate would be
98countryName
99stateOrProvinceName
100organizationName
101organizationalUnitName
102commonName
103emailAddress
104
105Have a play, it sort of makes sense. If you think about how the persona
106requests operate, it is similar to the 'policy_match' policy and the
107'policy_anything' is similar to what versign is doing.
108
109I hope this helps a bit. Some backend scripts are definitly needed to
110update the database and to make certificate revocion easy. All
111certificates issued should also be kept forever (or until they expire?)
112
113hope this helps
114eric (who has to run off an buy some cheap knee pads for the caving in 4
115days time :-)
116
117--
118Eric Young | Signature removed since it was generating
119AARNet: eay@mincom.oz.au | more followups than the message contents :-)
120
121
diff --git a/src/lib/libssl/src/doc/callback.doc b/src/lib/libssl/src/doc/callback.doc
new file mode 100644
index 0000000000..7ad0f7f7d2
--- /dev/null
+++ b/src/lib/libssl/src/doc/callback.doc
@@ -0,0 +1,240 @@
1Callback functions used in SSLeay.
2
3--------------------------
4The BIO library.
5
6Each BIO structure can have a callback defined against it. This callback is
7called 2 times for each BIO 'function'. It is passed 6 parameters.
8BIO_debug_callback() is an example callback which is defined in
9crypto/buffer/bio_cb.c and is used in apps/dgst.c This is intended mostly
10for debuging or to notify the application of IO.
11
12long BIO_debug_callback(BIO *bio,int cmd,char *argp,int argi,long argl,
13 long ret);
14bio is the BIO being called, cmd is the type of BIO function being called.
15Look at the BIO_CB_* defines in buffer.h. Argp and argi are the arguments
16passed to BIO_read(), BIO_write, BIO_gets(), BIO_puts(). In the case of
17BIO_ctrl(), argl is also defined. The first time the callback is called,
18before the underlying function has been executed, 0 is passed as 'ret', and
19if the return code from the callback is not > 0, the call is aborted
20and the returned <= 0 value is returned.
21The second time the callback is called, the 'cmd' value also has
22BIO_CB_RETURN logically 'or'ed with it. The 'ret' value is the value returned
23from the actuall function call and whatever the callback returns is returned
24from the BIO function.
25
26BIO_set_callback(b,cb) can be used to set the callback function
27(b is a BIO), and BIO_set_callback_arg(b,arg) can be used to
28set the cb_arg argument in the BIO strucutre. This field is only intended
29to be used by application, primarily in the callback function since it is
30accessable since the BIO is passed.
31
32--------------------------
33The PEM library.
34
35The pem library only really uses one type of callback,
36static int def_callback(char *buf, int num, int verify);
37which is used to return a password string if required.
38'buf' is the buffer to put the string in. 'num' is the size of 'buf'
39and 'verify' is used to indicate that the password should be checked.
40This last flag is mostly used when reading a password for encryption.
41
42For all of these functions, a NULL callback will call the above mentioned
43default callback. This default function does not work under Windows 3.1.
44For other machines, it will use an application defined prompt string
45(EVP_set_pw_prompt(), which defines a library wide prompt string)
46if defined, otherwise it will use it's own PEM password prompt.
47It will then call EVP_read_pw_string() to get a password from the console.
48If your application wishes to use nice fancy windows to retrieve passwords,
49replace this function. The callback should return the number of bytes read
50into 'buf'. If the number of bytes <= 0, it is considered an error.
51
52Functions that take this callback are listed below. For the 'read' type
53functions, the callback will only be required if the PEM data is encrypted.
54
55For the Write functions, normally a password can be passed in 'kstr', of
56'klen' bytes which will be used if the 'enc' cipher is not NULL. If
57'kstr' is NULL, the callback will be used to retrieve a password.
58
59int PEM_do_header (EVP_CIPHER_INFO *cipher, unsigned char *data,long *len,
60 int (*callback)());
61char *PEM_ASN1_read_bio(char *(*d2i)(),char *name,BIO *bp,char **x,int (*cb)());
62char *PEM_ASN1_read(char *(*d2i)(),char *name,FILE *fp,char **x,int (*cb)());
63int PEM_ASN1_write_bio(int (*i2d)(),char *name,BIO *bp,char *x,
64 EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)());
65int PEM_ASN1_write(int (*i2d)(),char *name,FILE *fp,char *x,
66 EVP_CIPHER *enc,unsigned char *kstr,int klen,int (*callback)());
67STACK *PEM_X509_INFO_read(FILE *fp, STACK *sk, int (*cb)());
68STACK *PEM_X509_INFO_read_bio(BIO *fp, STACK *sk, int (*cb)());
69
70#define PEM_write_RSAPrivateKey(fp,x,enc,kstr,klen,cb)
71#define PEM_write_DSAPrivateKey(fp,x,enc,kstr,klen,cb)
72#define PEM_write_bio_RSAPrivateKey(bp,x,enc,kstr,klen,cb)
73#define PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb)
74#define PEM_read_SSL_SESSION(fp,x,cb)
75#define PEM_read_X509(fp,x,cb)
76#define PEM_read_X509_REQ(fp,x,cb)
77#define PEM_read_X509_CRL(fp,x,cb)
78#define PEM_read_RSAPrivateKey(fp,x,cb)
79#define PEM_read_DSAPrivateKey(fp,x,cb)
80#define PEM_read_PrivateKey(fp,x,cb)
81#define PEM_read_PKCS7(fp,x,cb)
82#define PEM_read_DHparams(fp,x,cb)
83#define PEM_read_bio_SSL_SESSION(bp,x,cb)
84#define PEM_read_bio_X509(bp,x,cb)
85#define PEM_read_bio_X509_REQ(bp,x,cb)
86#define PEM_read_bio_X509_CRL(bp,x,cb)
87#define PEM_read_bio_RSAPrivateKey(bp,x,cb)
88#define PEM_read_bio_DSAPrivateKey(bp,x,cb)
89#define PEM_read_bio_PrivateKey(bp,x,cb)
90#define PEM_read_bio_PKCS7(bp,x,cb)
91#define PEM_read_bio_DHparams(bp,x,cb)
92int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)());
93RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)());
94
95Now you will notice that macros like
96#define PEM_write_X509(fp,x) \
97 PEM_ASN1_write((int (*)())i2d_X509,PEM_STRING_X509,fp, \
98 (char *)x, NULL,NULL,0,NULL)
99Don't do encryption normally. If you want to PEM encrypt your X509 structure,
100either just call PEM_ASN1_write directly or just define you own
101macro variant. As you can see, this macro just sets all encryption related
102parameters to NULL.
103
104
105--------------------------
106The SSL library.
107
108#define SSL_set_info_callback(ssl,cb)
109#define SSL_CTX_set_info_callback(ctx,cb)
110void callback(SSL *ssl,int location,int ret)
111This callback is called each time around the SSL_connect()/SSL_accept()
112state machine. So it will be called each time the SSL protocol progresses.
113It is mostly present for use when debugging. When SSL_connect() or
114SSL_accept() return, the location flag is SSL_CB_ACCEPT_EXIT or
115SSL_CB_CONNECT_EXIT and 'ret' is the value about to be returned.
116Have a look at the SSL_CB_* defines in ssl.h. If an info callback is defined
117against the SSL_CTX, it is called unless there is one set against the SSL.
118Have a look at
119void client_info_callback() in apps/s_client() for an example.
120
121Certificate verification.
122void SSL_set_verify(SSL *s, int mode, int (*callback) ());
123void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*callback)());
124This callback is used to help verify client and server X509 certificates.
125It is actually passed to X509_cert_verify(), along with the SSL structure
126so you have to read about X509_cert_verify() :-). The SSL_CTX version is used
127if the SSL version is not defined. X509_cert_verify() is the function used
128by the SSL part of the library to verify certificates. This function is
129nearly always defined by the application.
130
131void SSL_CTX_set_cert_verify_cb(SSL_CTX *ctx, int (*cb)(),char *arg);
132int callback(char *arg,SSL *s,X509 *xs,STACK *cert_chain);
133This call is used to replace the SSLeay certificate verification code.
134The 'arg' is kept in the SSL_CTX and is passed to the callback.
135If the callback returns 0, the certificate is rejected, otherwise it
136is accepted. The callback is replacing the X509_cert_verify() call.
137This feature is not often used, but if you wished to implement
138some totally different certificate authentication system, this 'hook' is
139vital.
140
141SSLeay keeps a cache of session-ids against each SSL_CTX. These callbacks can
142be used to notify the application when a SSL_SESSION is added to the cache
143or to retrieve a SSL_SESSION that is not in the cache from the application.
144#define SSL_CTX_sess_set_get_cb(ctx,cb)
145SSL_SESSION *callback(SSL *s,char *session_id,int session_id_len,int *copy);
146If defined, this callback is called to return the SESSION_ID for the
147session-id in 'session_id', of 'session_id_len' bytes. 'copy' is set to 1
148if the server is to 'take a copy' of the SSL_SESSION structure. It is 0
149if the SSL_SESSION is being 'passed in' so the SSLeay library is now
150responsible for 'free()ing' the structure. Basically it is used to indicate
151if the reference count on the SSL_SESSION structure needs to be incremented.
152
153#define SSL_CTX_sess_set_new_cb(ctx,cb)
154int callback(SSL *s, SSL_SESSION *sess);
155When a new connection is established, if the SSL_SESSION is going to be added
156to the cache, this callback is called. Return 1 if a 'copy' is required,
157otherwise, return 0. This return value just causes the reference count
158to be incremented (on return of a 1), this means the application does
159not need to worry about incrementing the refernece count (and the
160locking that implies in a multi-threaded application).
161
162void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx,int (*cb)());
163This sets the SSL password reading function.
164It is mostly used for windowing applications
165and used by PEM_read_bio_X509() and PEM_read_bio_RSAPrivateKey()
166calls inside the SSL library. The only reason this is present is because the
167calls to PEM_* functions is hidden in the SSLeay library so you have to
168pass in the callback some how.
169
170#define SSL_CTX_set_client_cert_cb(ctx,cb)
171int callback(SSL *s,X509 **x509, EVP_PKEY **pkey);
172Called when a client certificate is requested but there is not one set
173against the SSL_CTX or the SSL. If the callback returns 1, x509 and
174pkey need to point to valid data. The library will free these when
175required so if the application wants to keep these around, increment
176their reference counts. If 0 is returned, no client cert is
177available. If -1 is returned, it is assumed that the callback needs
178to be called again at a later point in time. SSL_connect will return
179-1 and SSL_want_x509_lookup(ssl) returns true. Remember that
180application data can be attached to an SSL structure via the
181SSL_set_app_data(SSL *ssl,char *data) call.
182
183--------------------------
184The X509 library.
185
186int X509_cert_verify(CERTIFICATE_CTX *ctx,X509 *xs, int (*cb)(),
187 int *error,char *arg,STACK *cert_chain);
188int verify_callback(int ok,X509 *xs,X509 *xi,int depth,int error,char *arg,
189 STACK *cert_chain);
190
191X509_cert_verify() is used to authenticate X509 certificates. The 'ctx' holds
192the details of the various caches and files used to locate certificates.
193'xs' is the certificate to verify and 'cb' is the application callback (more
194detail later). 'error' will be set to the error code and 'arg' is passed
195to the 'cb' callback. Look at the VERIFY_* defines in crypto/x509/x509.h
196
197When ever X509_cert_verify() makes a 'negative' decision about a
198certitificate, the callback is called. If everything checks out, the
199callback is called with 'VERIFY_OK' or 'VERIFY_ROOT_OK' (for a self
200signed cert that is not the passed certificate).
201
202The callback is passed the X509_cert_verify opinion of the certificate
203in 'ok', the certificate in 'xs', the issuer certificate in 'xi',
204the 'depth' of the certificate in the verification 'chain', the
205VERIFY_* code in 'error' and the argument passed to X509_cert_verify()
206in 'arg'. cert_chain is a list of extra certs to use if they are not
207in the cache.
208
209The callback can be used to look at the error reason, and then return 0
210for an 'error' or '1' for ok. This will override the X509_cert_verify()
211opinion of the certificates validity. Processing will continue depending on
212the return value. If one just wishes to use the callback for informational
213reason, just return the 'ok' parameter.
214
215--------------------------
216The BN and DH library.
217
218BIGNUM *BN_generate_prime(int bits,int strong,BIGNUM *add,
219 BIGNUM *rem,void (*callback)(int,int));
220int BN_is_prime(BIGNUM *p,int nchecks,void (*callback)(int,int),
221
222Read doc/bn.doc for the description of these 2.
223
224DH *DH_generate_parameters(int prime_len,int generator,
225 void (*callback)(int,int));
226Read doc/bn.doc for the description of the callback, since it is just passed
227to BN_generate_prime(), except that it is also called as
228callback(3,0) by this function.
229
230--------------------------
231The CRYPTO library.
232
233void CRYPTO_set_locking_callback(void (*func)(int mode,int type,char *file,
234 int line));
235void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,
236 int type,char *file, int line));
237void CRYPTO_set_id_callback(unsigned long (*func)(void));
238
239Read threads.doc for info on these ones.
240
diff --git a/src/lib/libssl/src/doc/cipher.doc b/src/lib/libssl/src/doc/cipher.doc
new file mode 100644
index 0000000000..d49ba78c5c
--- /dev/null
+++ b/src/lib/libssl/src/doc/cipher.doc
@@ -0,0 +1,345 @@
1The Cipher subroutines.
2
3These routines require "evp.h" to be included.
4
5These functions are a higher level interface to the various cipher
6routines found in this library. As such, they allow the same code to be
7used to encrypt and decrypt via different ciphers with only a change
8in an initial parameter. These routines also provide buffering for block
9ciphers.
10
11These routines all take a pointer to the following structure to specify
12which cipher to use. If you wish to use a new cipher with these routines,
13you would probably be best off looking an how an existing cipher is
14implemented and copying it. At this point in time, I'm not going to go
15into many details. This structure should be considered opaque
16
17typedef struct pem_cipher_st
18 {
19 int type;
20 int block_size;
21 int key_len;
22 int iv_len;
23 void (*enc_init)(); /* init for encryption */
24 void (*dec_init)(); /* init for decryption */
25 void (*do_cipher)(); /* encrypt data */
26 } EVP_CIPHER;
27
28The type field is the object NID of the cipher type
29(read the section on Objects for an explanation of what a NID is).
30The cipher block_size is how many bytes need to be passed
31to the cipher at a time. Key_len is the
32length of the key the cipher requires and iv_len is the length of the
33initialisation vector required. enc_init is the function
34called to initialise the ciphers context for encryption and dec_init is the
35function to initialise for decryption (they need to be different, especially
36for the IDEA cipher).
37
38One reason for specifying the Cipher via a pointer to a structure
39is that if you only use des-cbc, only the des-cbc routines will
40be included when you link the program. If you passed an integer
41that specified which cipher to use, the routine that mapped that
42integer to a set of cipher functions would cause all the ciphers
43to be link into the code. This setup also allows new ciphers
44to be added by the application (with some restrictions).
45
46The thirteen ciphers currently defined in this library are
47
48EVP_CIPHER *EVP_des_ecb(); /* DES in ecb mode, iv=0, block=8, key= 8 */
49EVP_CIPHER *EVP_des_ede(); /* DES in ecb ede mode, iv=0, block=8, key=16 */
50EVP_CIPHER *EVP_des_ede3(); /* DES in ecb ede mode, iv=0, block=8, key=24 */
51EVP_CIPHER *EVP_des_cfb(); /* DES in cfb mode, iv=8, block=1, key= 8 */
52EVP_CIPHER *EVP_des_ede_cfb(); /* DES in ede cfb mode, iv=8, block=1, key=16 */
53EVP_CIPHER *EVP_des_ede3_cfb();/* DES in ede cfb mode, iv=8, block=1, key=24 */
54EVP_CIPHER *EVP_des_ofb(); /* DES in ofb mode, iv=8, block=1, key= 8 */
55EVP_CIPHER *EVP_des_ede_ofb(); /* DES in ede ofb mode, iv=8, block=1, key=16 */
56EVP_CIPHER *EVP_des_ede3_ofb();/* DES in ede ofb mode, iv=8, block=1, key=24 */
57EVP_CIPHER *EVP_des_cbc(); /* DES in cbc mode, iv=8, block=8, key= 8 */
58EVP_CIPHER *EVP_des_ede_cbc(); /* DES in cbc ede mode, iv=8, block=8, key=16 */
59EVP_CIPHER *EVP_des_ede3_cbc();/* DES in cbc ede mode, iv=8, block=8, key=24 */
60EVP_CIPHER *EVP_desx_cbc(); /* DES in desx cbc mode,iv=8, block=8, key=24 */
61EVP_CIPHER *EVP_rc4(); /* RC4, iv=0, block=1, key=16 */
62EVP_CIPHER *EVP_idea_ecb(); /* IDEA in ecb mode, iv=0, block=8, key=16 */
63EVP_CIPHER *EVP_idea_cfb(); /* IDEA in cfb mode, iv=8, block=1, key=16 */
64EVP_CIPHER *EVP_idea_ofb(); /* IDEA in ofb mode, iv=8, block=1, key=16 */
65EVP_CIPHER *EVP_idea_cbc(); /* IDEA in cbc mode, iv=8, block=8, key=16 */
66EVP_CIPHER *EVP_rc2_ecb(); /* RC2 in ecb mode, iv=0, block=8, key=16 */
67EVP_CIPHER *EVP_rc2_cfb(); /* RC2 in cfb mode, iv=8, block=1, key=16 */
68EVP_CIPHER *EVP_rc2_ofb(); /* RC2 in ofb mode, iv=8, block=1, key=16 */
69EVP_CIPHER *EVP_rc2_cbc(); /* RC2 in cbc mode, iv=8, block=8, key=16 */
70EVP_CIPHER *EVP_bf_ecb(); /* Blowfish in ecb mode,iv=0, block=8, key=16 */
71EVP_CIPHER *EVP_bf_cfb(); /* Blowfish in cfb mode,iv=8, block=1, key=16 */
72EVP_CIPHER *EVP_bf_ofb(); /* Blowfish in ofb mode,iv=8, block=1, key=16 */
73EVP_CIPHER *EVP_bf_cbc(); /* Blowfish in cbc mode,iv=8, block=8, key=16 */
74
75The meaning of the compound names is as follows.
76des The base cipher is DES.
77idea The base cipher is IDEA
78rc4 The base cipher is RC4-128
79rc2 The base cipher is RC2-128
80ecb Electronic Code Book form of the cipher.
81cbc Cipher Block Chaining form of the cipher.
82cfb 64 bit Cipher Feedback form of the cipher.
83ofb 64 bit Output Feedback form of the cipher.
84ede The cipher is used in Encrypt, Decrypt, Encrypt mode. The first
85 and last keys are the same.
86ede3 The cipher is used in Encrypt, Decrypt, Encrypt mode.
87
88All the Cipher routines take a EVP_CIPHER_CTX pointer as an argument.
89The state of the cipher is kept in this structure.
90
91typedef struct EVP_CIPHER_Ctx_st
92 {
93 EVP_CIPHER *cipher;
94 int encrypt; /* encrypt or decrypt */
95 int buf_len; /* number we have left */
96 unsigned char buf[8];
97 union {
98 .... /* cipher specific stuff */
99 } c;
100 } EVP_CIPHER_CTX;
101
102Cipher is a pointer the the EVP_CIPHER for the current context. The encrypt
103flag indicates encryption or decryption. buf_len is the number of bytes
104currently being held in buf.
105The 'c' union holds the cipher specify context.
106
107The following functions are to be used.
108
109int EVP_read_pw_string(
110char *buf,
111int len,
112char *prompt,
113int verify,
114 This function is the same as des_read_pw_string() (des.doc).
115
116void EVP_set_pw_prompt(char *prompt);
117 This function sets the 'default' prompt to use to use in
118 EVP_read_pw_string when the prompt parameter is NULL. If the
119 prompt parameter is NULL, this 'default prompt' feature is turned
120 off. Be warned, this is a global variable so weird things
121 will happen if it is used under Win16 and care must be taken
122 with a multi-threaded version of the library.
123
124char *EVP_get_pw_prompt();
125 This returns a pointer to the default prompt string. NULL
126 if it is not set.
127
128int EVP_BytesToKey(
129EVP_CIPHER *type,
130EVP_MD *md,
131unsigned char *salt,
132unsigned char *data,
133int datal,
134int count,
135unsigned char *key,
136unsigned char *iv);
137 This function is used to generate a key and an initialisation vector
138 for a specified cipher from a key string and a salt. Type
139 specifies the cipher the 'key' is being generated for. Md is the
140 message digest algorithm to use to generate the key and iv. The salt
141 is an optional 8 byte object that is used to help seed the key
142 generator.
143 If the salt value is NULL, it is just not used. Datal is the
144 number of bytes to use from 'data' in the key generation.
145 This function returns the key size for the specified cipher, if
146 data is NULL, this value is returns and no other
147 computation is performed. Count is
148 the number of times to loop around the key generator. I would
149 suggest leaving it's value as 1. Key and iv are the structures to
150 place the returning iv and key in. If they are NULL, no value is
151 generated for that particular value.
152 The algorithm used is as follows
153
154 /* M[] is an array of message digests
155 * MD() is the message digest function */
156 M[0]=MD(data . salt);
157 for (i=1; i<count; i++) M[0]=MD(M[0]);
158
159 i=1
160 while (data still needed for key and iv)
161 {
162 M[i]=MD(M[i-1] . data . salt);
163 for (i=1; i<count; i++) M[i]=MD(M[i]);
164 i++;
165 }
166
167 If the salt is NULL, it is not used.
168 The digests are concatenated together.
169 M = M[0] . M[1] . M[2] .......
170
171 For key= 8, iv=8 => key=M[0.. 8], iv=M[ 9 .. 16].
172 For key=16, iv=0 => key=M[0..16].
173 For key=16, iv=8 => key=M[0..16], iv=M[17 .. 24].
174 For key=24, iv=8 => key=M[0..24], iv=M[25 .. 32].
175
176 This routine will produce DES-CBC keys and iv that are compatible
177 with the PKCS-5 standard when md2 or md5 are used. If md5 is
178 used, the salt is NULL and count is 1, this routine will produce
179 the password to key mapping normally used with RC4.
180 I have attempted to logically extend the PKCS-5 standard to
181 generate keys and iv for ciphers that require more than 16 bytes,
182 if anyone knows what the correct standard is, please inform me.
183 When using sha or sha1, things are a bit different under this scheme,
184 since sha produces a 20 byte digest. So for ciphers requiring
185 24 bits of data, 20 will come from the first MD and 4 will
186 come from the second.
187
188 I have considered having a separate function so this 'routine'
189 can be used without the requirement of passing a EVP_CIPHER *,
190 but I have decided to not bother. If you wish to use the
191 function without official EVP_CIPHER structures, just declare
192 a local one and set the key_len and iv_len fields to the
193 length you desire.
194
195The following routines perform encryption and decryption 'by parts'. By
196this I mean that there are groups of 3 routines. An Init function that is
197used to specify a cipher and initialise data structures. An Update routine
198that does encryption/decryption, one 'chunk' at a time. And finally a
199'Final' function that finishes the encryption/decryption process.
200All these functions take a EVP_CIPHER pointer to specify which cipher to
201encrypt/decrypt with. They also take a EVP_CIPHER_CTX object as an
202argument. This structure is used to hold the state information associated
203with the operation in progress.
204
205void EVP_EncryptInit(
206EVP_CIPHER_CTX *ctx,
207EVP_CIPHER *type,
208unsigned char *key,
209unsigned char *iv);
210 This function initialise a EVP_CIPHER_CTX for encryption using the
211 cipher passed in the 'type' field. The cipher is initialised to use
212 'key' as the key and 'iv' for the initialisation vector (if one is
213 required). If the type, key or iv is NULL, the value currently in the
214 EVP_CIPHER_CTX is reused. So to perform several decrypt
215 using the same cipher, key and iv, initialise with the cipher,
216 key and iv the first time and then for subsequent calls,
217 reuse 'ctx' but pass NULL for type, key and iv. You must make sure
218 to pass a key that is large enough for a particular cipher. I
219 would suggest using the EVP_BytesToKey() function.
220
221void EVP_EncryptUpdate(
222EVP_CIPHER_CTX *ctx,
223unsigned char *out,
224int *outl,
225unsigned char *in,
226int inl);
227 This function takes 'inl' bytes from 'in' and outputs bytes
228 encrypted by the cipher 'ctx' was initialised with into 'out'. The
229 number of bytes written to 'out' is put into outl. If a particular
230 cipher encrypts in blocks, less or more bytes than input may be
231 output. Currently the largest block size used by supported ciphers
232 is 8 bytes, so 'out' should have room for 'inl+7' bytes. Normally
233 EVP_EncryptInit() is called once, followed by lots and lots of
234 calls to EVP_EncryptUpdate, followed by a single EVP_EncryptFinal
235 call.
236
237void EVP_EncryptFinal(
238EVP_CIPHER_CTX *ctx,
239unsigned char *out,
240int *outl);
241 Because quite a large number of ciphers are block ciphers, there is
242 often an incomplete block to write out at the end of the
243 encryption. EVP_EncryptFinal() performs processing on this last
244 block. The last block in encoded in such a way that it is possible
245 to determine how many bytes in the last block are valid. For 8 byte
246 block size ciphers, if only 5 bytes in the last block are valid, the
247 last three bytes will be filled with the value 3. If only 2 were
248 valid, the other 6 would be filled with sixes. If all 8 bytes are
249 valid, a extra 8 bytes are appended to the cipher stream containing
250 nothing but 8 eights. These last bytes are output into 'out' and
251 the number of bytes written is put into 'outl' These last bytes
252 are output into 'out' and the number of bytes written is put into
253 'outl'. This form of block cipher finalisation is compatible with
254 PKCS-5. Please remember that even if you are using ciphers like
255 RC4 that has no blocking and so the function will not write
256 anything into 'out', it would still be a good idea to pass a
257 variable for 'out' that can hold 8 bytes just in case the cipher is
258 changed some time in the future. It should also be remembered
259 that the EVP_CIPHER_CTX contains the password and so when one has
260 finished encryption with a particular EVP_CIPHER_CTX, it is good
261 practice to zero the structure
262 (ie. memset(ctx,0,sizeof(EVP_CIPHER_CTX)).
263
264void EVP_DecryptInit(
265EVP_CIPHER_CTX *ctx,
266EVP_CIPHER *type,
267unsigned char *key,
268unsigned char *iv);
269 This function is basically the same as EVP_EncryptInit() accept that
270 is prepares the EVP_CIPHER_CTX for decryption.
271
272void EVP_DecryptUpdate(
273EVP_CIPHER_CTX *ctx,
274unsigned char *out,
275int *outl,
276unsigned char *in,
277int inl);
278 This function is basically the same as EVP_EncryptUpdate()
279 except that it performs decryption. There is one
280 fundamental difference though. 'out' can not be the same as
281 'in' for any ciphers with a block size greater than 1 if more
282 than one call to EVP_DecryptUpdate() will be made. This
283 is because this routine can hold a 'partial' block between
284 calls. When a partial block is decrypted (due to more bytes
285 being passed via this function, they will be written to 'out'
286 overwriting the input bytes in 'in' that have not been read
287 yet. From this it should also be noted that 'out' should
288 be at least one 'block size' larger than 'inl'. This problem
289 only occurs on the second and subsequent call to
290 EVP_DecryptUpdate() when using a block cipher.
291
292int EVP_DecryptFinal(
293EVP_CIPHER_CTX *ctx,
294unsigned char *out,
295int *outl);
296 This function is different to EVP_EncryptFinal in that it 'removes'
297 any padding bytes appended when the data was encrypted. Due to the
298 way in which 1 to 8 bytes may have been appended when encryption
299 using a block cipher, 'out' can end up with 0 to 7 bytes being put
300 into it. When decoding the padding bytes, it is possible to detect
301 an incorrect decryption. If the decryption appears to be wrong, 0
302 is returned. If everything seems ok, 1 is returned. For ciphers
303 with a block size of 1 (RC4), this function would normally not
304 return any bytes and would always return 1. Just because this
305 function returns 1 does not mean the decryption was correct. It
306 would normally be wrong due to either the wrong key/iv or
307 corruption of the cipher data fed to EVP_DecryptUpdate().
308 As for EVP_EncryptFinal, it is a good idea to zero the
309 EVP_CIPHER_CTX after use since the structure contains the key used
310 to decrypt the data.
311
312The following Cipher routines are convenience routines that call either
313EVP_EncryptXxx or EVP_DecryptXxx depending on weather the EVP_CIPHER_CTX
314was setup to encrypt or decrypt.
315
316void EVP_CipherInit(
317EVP_CIPHER_CTX *ctx,
318EVP_CIPHER *type,
319unsigned char *key,
320unsigned char *iv,
321int enc);
322 This function take arguments that are the same as EVP_EncryptInit()
323 and EVP_DecryptInit() except for the extra 'enc' flag. If 1, the
324 EVP_CIPHER_CTX is setup for encryption, if 0, decryption.
325
326void EVP_CipherUpdate(
327EVP_CIPHER_CTX *ctx,
328unsigned char *out,
329int *outl,
330unsigned char *in,
331int inl);
332 Again this function calls either EVP_EncryptUpdate() or
333 EVP_DecryptUpdate() depending on state in the 'ctx' structure.
334 As noted for EVP_DecryptUpdate(), when this routine is used
335 for decryption with block ciphers, 'out' should not be the
336 same as 'in'.
337
338int EVP_CipherFinal(
339EVP_CIPHER_CTX *ctx,
340unsigned char *outm,
341int *outl);
342 This routine call EVP_EncryptFinal() or EVP_DecryptFinal()
343 depending on the state information in 'ctx'. 1 is always returned
344 if the mode is encryption, otherwise the return value is the return
345 value of EVP_DecryptFinal().
diff --git a/src/lib/libssl/src/doc/cipher.m b/src/lib/libssl/src/doc/cipher.m
new file mode 100644
index 0000000000..9f74917135
--- /dev/null
+++ b/src/lib/libssl/src/doc/cipher.m
@@ -0,0 +1,128 @@
1From ssl-lists-owner@mincom.com Tue Oct 15 18:16:14 1996
2Received: from cygnus.mincom.oz.au by orb.mincom.oz.au with SMTP id AA11550
3 (5.65c/IDA-1.4.4 for eay); Tue, 15 Oct 1996 08:17:41 +1000
4Received: (from daemon@localhost) by cygnus.mincom.oz.au (8.7.5/8.7.3) id IAA12472 for ssl-users-outgoing; Tue, 15 Oct 1996 08:16:35 +1000 (EST)
5Received: from orb.mincom.oz.au (eay@orb.mincom.oz.au [192.55.197.1]) by cygnus.mincom.oz.au (8.7.5/8.7.3) with SMTP id IAA12463 for <ssl-users@listserv.mincom.oz.au>; Tue, 15 Oct 1996 08:16:32 +1000 (EST)
6Received: by orb.mincom.oz.au id AA11544
7 (5.65c/IDA-1.4.4 for ssl-users@listserv.mincom.oz.au); Tue, 15 Oct 1996 08:16:15 +1000
8Date: Tue, 15 Oct 1996 08:16:14 +1000 (EST)
9From: Eric Young <eay@mincom.com>
10X-Sender: eay@orb
11To: Roland Haring <rharing@tandem.cl>
12Cc: ssl-users@mincom.com
13Subject: Re: Symmetric encryption with ssleay
14In-Reply-To: <m0vBpyq-00001aC@tandemnet.tandem.cl>
15Message-Id: <Pine.SOL.3.91.961015075623.11394A-100000@orb>
16Mime-Version: 1.0
17Content-Type: TEXT/PLAIN; charset=US-ASCII
18Sender: ssl-lists-owner@mincom.com
19Precedence: bulk
20Status: RO
21X-Status:
22
23
24On Fri, 11 Oct 1996, Roland Haring wrote:
25> THE_POINT:
26> Would somebody be so kind to give me the minimum basic
27> calls I need to do to libcrypto.a to get some text encrypted
28> and decrypted again? ...hopefully with code included to do
29> base64 encryption and decryption ... e.g. that sign-it.c code
30> posted some while ago was a big help :-) (please, do not point
31> me to apps/enc.c where I suspect my Heissenbug to be hidden :-)
32
33Ok, the base64 encoding stuff in 'enc.c' does the wrong thing sometimes
34when the data is less than a line long (this is for decoding). I'll dig
35up the exact fix today and post it. I am taking longer on 0.6.5 than I
36intended so I'll just post this patch.
37
38The documentation to read is in
39doc/cipher.doc,
40doc/encode.doc (very sparse :-).
41and perhaps
42doc/digest.doc,
43
44The basic calls to encrypt with say triple DES are
45
46Given
47char key[EVP_MAX_KEY_LENGTH];
48char iv[EVP_MAX_IV_LENGTH];
49EVP_CIPHER_CTX ctx;
50unsigned char out[512+8];
51int outl;
52
53/* optional generation of key/iv data from text password using md5
54 * via an upward compatable verson of PKCS#5. */
55EVP_BytesToKey(EVP_des_ede3_cbc,EVP_md5,NULL,passwd,strlen(passwd),
56 key,iv);
57
58/* Initalise the EVP_CIPHER_CTX */
59EVP_EncryptInit(ctx,EVP_des_ede3_cbc,key,iv);
60
61while (....)
62 {
63 /* This is processing 512 bytes at a time, the bytes are being
64 * copied into 'out', outl bytes are output. 'out' should not be the
65 * same as 'in' for reasons mentioned in the documentation. */
66 EVP_EncryptUpdate(ctx,out,&outl,in,512);
67 }
68
69/* Output the last 'block'. If the cipher is a block cipher, the last
70 * block is encoded in such a way so that a wrong decryption will normally be
71 * detected - again, one of the PKCS standards. */
72
73EVP_EncryptFinal(ctx,out,&outl);
74
75To decrypt, use the EVP_DecryptXXXXX functions except that EVP_DecryptFinal()
76will return 0 if the decryption fails (only detectable on block ciphers).
77
78You can also use
79EVP_CipherInit()
80EVP_CipherUpdate()
81EVP_CipherFinal()
82which does either encryption or decryption depending on an extra
83parameter to EVP_CipherInit().
84
85
86To do the base64 encoding,
87EVP_EncodeInit()
88EVP_EncodeUpdate()
89EVP_EncodeFinal()
90
91EVP_DecodeInit()
92EVP_DecodeUpdate()
93EVP_DecodeFinal()
94
95where the encoding is quite simple, but the decoding can be a bit more
96fun (due to dud input).
97
98EVP_DecodeUpdate() returns -1 for an error on an input line, 0 if the
99'last line' was just processed, and 1 if more lines should be submitted.
100
101EVP_DecodeFinal() returns -1 for an error or 1 if things are ok.
102
103So the loop becomes
104EVP_DecodeInit(....)
105for (;;)
106 {
107 i=EVP_DecodeUpdate(....);
108 if (i < 0) goto err;
109
110 /* process the data */
111
112 if (i == 0) break;
113 }
114EVP_DecodeFinal(....);
115/* process the data */
116
117The problem in 'enc.c' is that I was stuff the processing up after the
118EVP_DecodeFinal(...) when the for(..) loop was not being run (one line of
119base64 data) and this was because 'enc.c' tries to scan over a file until
120it hits the first valid base64 encoded line.
121
122hope this helps a bit.
123eric
124--
125Eric Young | BOOL is tri-state according to Bill Gates.
126AARNet: eay@mincom.oz.au | RTFM Win32 GetMessage().
127
128
diff --git a/src/lib/libssl/src/doc/conf.doc b/src/lib/libssl/src/doc/conf.doc
new file mode 100644
index 0000000000..f12fe884f5
--- /dev/null
+++ b/src/lib/libssl/src/doc/conf.doc
@@ -0,0 +1,89 @@
1The CONF library.
2
3The CONF library is a simple set of routines that can be used to configure
4programs. It is a superset of the genenv() function with some extra
5structure.
6
7The library consists of 5 functions.
8
9LHASH *CONF_load(LHASH *config,char *file);
10This function is called to load in a configuration file. Multiple
11configuration files can be loaded, with each subsequent 'load' overwriting
12any already defined 'variables'. If there is an error, NULL is returned.
13If config is NULL, a new LHASH structure is created and returned, otherwise
14the new data in the 'file' is loaded into the 'config' structure.
15
16void CONF_free(LHASH *config);
17This function free()s the data in config.
18
19char *CONF_get_string(LHASH *config,char *section,char *name);
20This function returns the string found in 'config' that corresponds to the
21'section' and 'name' specified. Classes and the naming system used will be
22discussed later in this document. If the variable is not defined, an NULL
23is returned.
24
25long CONF_get_long(LHASH *config,char *section, char *name);
26This function is the same as CONF_get_string() except that it converts the
27string to an long and returns it. If variable is not a number or the
28variable does not exist, 0 is returned. This is a little problematic but I
29don't know of a simple way around it.
30
31STACK *CONF_get_section(LHASH *config, char *section);
32This function returns a 'stack' of CONF_VALUE items that are all the
33items defined in a particular section. DO NOT free() any of the
34variable returned. They will disappear when CONF_free() is called.
35
36The 'lookup' model.
37The configuration file is divided into 'sections'. Each section is started by
38a line of the form '[ section ]'. All subsequent variable definitions are
39of this section. A variable definition is a simple alpha-numeric name
40followed by an '=' and then the data. A section or variable name can be
41described by a regular expression of the following form '[A-Za-z0-9_]+'.
42The value of the variable is the text after the '=' until the end of the
43line, stripped of leading and trailing white space.
44At this point I should mention that a '#' is a comment character, \ is the
45escape character, and all three types of quote can be used to stop any
46special interpretation of the data.
47Now when the data is being loaded, variable expansion can occur. This is
48done by expanding any $NAME sequences into the value represented by the
49variable NAME. If the variable is not in the current section, the different
50section can be specified by using the $SECTION::NAME form. The ${NAME} form
51also works and is very useful for expanding variables inside strings.
52
53When a variable is looked up, there are 2 special section. 'default', which
54is the initial section, and 'ENV' which is the processes environment
55variables (accessed via getenv()). When a variable is looked up, it is
56first 'matched' with it's section (if one was specified), if this fails, the
57'default' section is matched.
58If the 'lhash' variable passed was NULL, the environment is searched.
59
60Now why do we bother with sections? So we can have multiple programs using
61the same configuration file, or multiple instances of the same program
62using different variables. It also provides a nice mechanism to override
63the processes environment variables (eg ENV::HOME=/tmp). If there is a
64program specific variable missing, we can have default values.
65Multiple configuration files can be loaded, with each new value clearing
66any predefined values. A system config file can provide 'default' values,
67and application/usr specific files can provide overriding values.
68
69Examples
70
71# This is a simple example
72SSLEAY_HOME = /usr/local/ssl
73ENV::PATH = $SSLEAY_HOME/bin:$PATH # override my path
74
75[X509]
76cert_dir = $SSLEAY_HOME/certs # /usr/local/ssl/certs
77
78[SSL]
79CIPHER = DES-EDE-MD5:RC4-MD5
80USER_CERT = $HOME/${USER}di'r 5' # /home/eay/eaydir 5
81USER_CERT = $HOME/\${USER}di\'r # /home/eay/${USER}di'r
82USER_CERT = "$HOME/${US"ER}di\'r # $HOME/${USER}di'r
83
84TEST = 1234\
855678\
869ab # TEST=123456789ab
87TTT = 1234\n\n # TTT=1234<nl><nl>
88
89
diff --git a/src/lib/libssl/src/doc/des.doc b/src/lib/libssl/src/doc/des.doc
new file mode 100644
index 0000000000..5879d968f3
--- /dev/null
+++ b/src/lib/libssl/src/doc/des.doc
@@ -0,0 +1,505 @@
1The DES library.
2
3Please note that this library was originally written to operate with
4eBones, a version of Kerberos that had had encryption removed when it left
5the USA and then put back in. As such there are some routines that I will
6advise not using but they are still in the library for historical reasons.
7For all calls that have an 'input' and 'output' variables, they can be the
8same.
9
10This library requires the inclusion of 'des.h'.
11
12All of the encryption functions take what is called a des_key_schedule as an
13argument. A des_key_schedule is an expanded form of the des key.
14A des_key is 8 bytes of odd parity, the type used to hold the key is a
15des_cblock. A des_cblock is an array of 8 bytes, often in this library
16description I will refer to input bytes when the function specifies
17des_cblock's as input or output, this just means that the variable should
18be a multiple of 8 bytes.
19
20The define DES_ENCRYPT is passed to specify encryption, DES_DECRYPT to
21specify decryption. The functions and global variable are as follows:
22
23int des_check_key;
24 DES keys are supposed to be odd parity. If this variable is set to
25 a non-zero value, des_set_key() will check that the key has odd
26 parity and is not one of the known weak DES keys. By default this
27 variable is turned off;
28
29void des_set_odd_parity(
30des_cblock *key );
31 This function takes a DES key (8 bytes) and sets the parity to odd.
32
33int des_is_weak_key(
34des_cblock *key );
35 This function returns a non-zero value if the DES key passed is a
36 weak, DES key. If it is a weak key, don't use it, try a different
37 one. If you are using 'random' keys, the chances of hitting a weak
38 key are 1/2^52 so it is probably not worth checking for them.
39
40int des_set_key(
41des_cblock *key,
42des_key_schedule schedule);
43 Des_set_key converts an 8 byte DES key into a des_key_schedule.
44 A des_key_schedule is an expanded form of the key which is used to
45 perform actual encryption. It can be regenerated from the DES key
46 so it only needs to be kept when encryption or decryption is about
47 to occur. Don't save or pass around des_key_schedule's since they
48 are CPU architecture dependent, DES keys are not. If des_check_key
49 is non zero, zero is returned if the key has the wrong parity or
50 the key is a weak key, else 1 is returned.
51
52int des_key_sched(
53des_cblock *key,
54des_key_schedule schedule);
55 An alternative name for des_set_key().
56
57int des_rw_mode; /* defaults to DES_PCBC_MODE */
58 This flag holds either DES_CBC_MODE or DES_PCBC_MODE (default).
59 This specifies the function to use in the enc_read() and enc_write()
60 functions.
61
62void des_encrypt(
63unsigned long *data,
64des_key_schedule ks,
65int enc);
66 This is the DES encryption function that gets called by just about
67 every other DES routine in the library. You should not use this
68 function except to implement 'modes' of DES. I say this because the
69 functions that call this routine do the conversion from 'char *' to
70 long, and this needs to be done to make sure 'non-aligned' memory
71 access do not occur. The characters are loaded 'little endian',
72 have a look at my source code for more details on how I use this
73 function.
74 Data is a pointer to 2 unsigned long's and ks is the
75 des_key_schedule to use. enc, is non zero specifies encryption,
76 zero if decryption.
77
78void des_encrypt2(
79unsigned long *data,
80des_key_schedule ks,
81int enc);
82 This functions is the same as des_encrypt() except that the DES
83 initial permutation (IP) and final permutation (FP) have been left
84 out. As for des_encrypt(), you should not use this function.
85 It is used by the routines in my library that implement triple DES.
86 IP() des_encrypt2() des_encrypt2() des_encrypt2() FP() is the same
87 as des_encrypt() des_encrypt() des_encrypt() except faster :-).
88
89void des_ecb_encrypt(
90des_cblock *input,
91des_cblock *output,
92des_key_schedule ks,
93int enc);
94 This is the basic Electronic Code Book form of DES, the most basic
95 form. Input is encrypted into output using the key represented by
96 ks. If enc is non zero (DES_ENCRYPT), encryption occurs, otherwise
97 decryption occurs. Input is 8 bytes long and output is 8 bytes.
98 (the des_cblock structure is 8 chars).
99
100void des_ecb3_encrypt(
101des_cblock *input,
102des_cblock *output,
103des_key_schedule ks1,
104des_key_schedule ks2,
105des_key_schedule ks3,
106int enc);
107 This is the 3 key EDE mode of ECB DES. What this means is that
108 the 8 bytes of input is encrypted with ks1, decrypted with ks2 and
109 then encrypted again with ks3, before being put into output;
110 C=E(ks3,D(ks2,E(ks1,M))). There is a macro, des_ecb2_encrypt()
111 that only takes 2 des_key_schedules that implements,
112 C=E(ks1,D(ks2,E(ks1,M))) in that the final encrypt is done with ks1.
113
114void des_cbc_encrypt(
115des_cblock *input,
116des_cblock *output,
117long length,
118des_key_schedule ks,
119des_cblock *ivec,
120int enc);
121 This routine implements DES in Cipher Block Chaining mode.
122 Input, which should be a multiple of 8 bytes is encrypted
123 (or decrypted) to output which will also be a multiple of 8 bytes.
124 The number of bytes is in length (and from what I've said above,
125 should be a multiple of 8). If length is not a multiple of 8, I'm
126 not being held responsible :-). ivec is the initialisation vector.
127 This function does not modify this variable. To correctly implement
128 cbc mode, you need to do one of 2 things; copy the last 8 bytes of
129 cipher text for use as the next ivec in your application,
130 or use des_ncbc_encrypt().
131 Only this routine has this problem with updating the ivec, all
132 other routines that are implementing cbc mode update ivec.
133
134void des_ncbc_encrypt(
135des_cblock *input,
136des_cblock *output,
137long length,
138des_key_schedule sk,
139des_cblock *ivec,
140int enc);
141 For historical reasons, des_cbc_encrypt() did not update the
142 ivec with the value requires so that subsequent calls to
143 des_cbc_encrypt() would 'chain'. This was needed so that the same
144 'length' values would not need to be used when decrypting.
145 des_ncbc_encrypt() does the right thing. It is the same as
146 des_cbc_encrypt accept that ivec is updates with the correct value
147 to pass in subsequent calls to des_ncbc_encrypt(). I advise using
148 des_ncbc_encrypt() instead of des_cbc_encrypt();
149
150void des_xcbc_encrypt(
151des_cblock *input,
152des_cblock *output,
153long length,
154des_key_schedule sk,
155des_cblock *ivec,
156des_cblock *inw,
157des_cblock *outw,
158int enc);
159 This is RSA's DESX mode of DES. It uses inw and outw to
160 'whiten' the encryption. inw and outw are secret (unlike the iv)
161 and are as such, part of the key. So the key is sort of 24 bytes.
162 This is much better than cbc des.
163
164void des_3cbc_encrypt(
165des_cblock *input,
166des_cblock *output,
167long length,
168des_key_schedule sk1,
169des_key_schedule sk2,
170des_cblock *ivec1,
171des_cblock *ivec2,
172int enc);
173 This function is flawed, do not use it. I have left it in the
174 library because it is used in my des(1) program and will function
175 correctly when used by des(1). If I removed the function, people
176 could end up unable to decrypt files.
177 This routine implements outer triple cbc encryption using 2 ks and
178 2 ivec's. Use des_ede2_cbc_encrypt() instead.
179
180void des_ede3_cbc_encrypt(
181des_cblock *input,
182des_cblock *output,
183long length,
184des_key_schedule ks1,
185des_key_schedule ks2,
186des_key_schedule ks3,
187des_cblock *ivec,
188int enc);
189 This function implements outer triple CBC DES encryption with 3
190 keys. What this means is that each 'DES' operation
191 inside the cbc mode is really an C=E(ks3,D(ks2,E(ks1,M))).
192 Again, this is cbc mode so an ivec is requires.
193 This mode is used by SSL.
194 There is also a des_ede2_cbc_encrypt() that only uses 2
195 des_key_schedule's, the first being reused for the final
196 encryption. C=E(ks1,D(ks2,E(ks1,M))). This form of triple DES
197 is used by the RSAref library.
198
199void des_pcbc_encrypt(
200des_cblock *input,
201des_cblock *output,
202long length,
203des_key_schedule ks,
204des_cblock *ivec,
205int enc);
206 This is Propagating Cipher Block Chaining mode of DES. It is used
207 by Kerberos v4. It's parameters are the same as des_ncbc_encrypt().
208
209void des_cfb_encrypt(
210unsigned char *in,
211unsigned char *out,
212int numbits,
213long length,
214des_key_schedule ks,
215des_cblock *ivec,
216int enc);
217 Cipher Feedback Back mode of DES. This implementation 'feeds back'
218 in numbit blocks. The input (and output) is in multiples of numbits
219 bits. numbits should to be a multiple of 8 bits. Length is the
220 number of bytes input. If numbits is not a multiple of 8 bits,
221 the extra bits in the bytes will be considered padding. So if
222 numbits is 12, for each 2 input bytes, the 4 high bits of the
223 second byte will be ignored. So to encode 72 bits when using
224 a numbits of 12 take 12 bytes. To encode 72 bits when using
225 numbits of 9 will take 16 bytes. To encode 80 bits when using
226 numbits of 16 will take 10 bytes. etc, etc. This padding will
227 apply to both input and output.
228
229
230void des_cfb64_encrypt(
231unsigned char *in,
232unsigned char *out,
233long length,
234des_key_schedule ks,
235des_cblock *ivec,
236int *num,
237int enc);
238 This is one of the more useful functions in this DES library, it
239 implements CFB mode of DES with 64bit feedback. Why is this
240 useful you ask? Because this routine will allow you to encrypt an
241 arbitrary number of bytes, no 8 byte padding. Each call to this
242 routine will encrypt the input bytes to output and then update ivec
243 and num. num contains 'how far' we are though ivec. If this does
244 not make much sense, read more about cfb mode of DES :-).
245
246void des_ede3_cfb64_encrypt(
247unsigned char *in,
248unsigned char *out,
249long length,
250des_key_schedule ks1,
251des_key_schedule ks2,
252des_key_schedule ks3,
253des_cblock *ivec,
254int *num,
255int enc);
256 Same as des_cfb64_encrypt() accept that the DES operation is
257 triple DES. As usual, there is a macro for
258 des_ede2_cfb64_encrypt() which reuses ks1.
259
260void des_ofb_encrypt(
261unsigned char *in,
262unsigned char *out,
263int numbits,
264long length,
265des_key_schedule ks,
266des_cblock *ivec);
267 This is a implementation of Output Feed Back mode of DES. It is
268 the same as des_cfb_encrypt() in that numbits is the size of the
269 units dealt with during input and output (in bits).
270
271void des_ofb64_encrypt(
272unsigned char *in,
273unsigned char *out,
274long length,
275des_key_schedule ks,
276des_cblock *ivec,
277int *num);
278 The same as des_cfb64_encrypt() except that it is Output Feed Back
279 mode.
280
281void des_ede3_ofb64_encrypt(
282unsigned char *in,
283unsigned char *out,
284long length,
285des_key_schedule ks1,
286des_key_schedule ks2,
287des_key_schedule ks3,
288des_cblock *ivec,
289int *num);
290 Same as des_ofb64_encrypt() accept that the DES operation is
291 triple DES. As usual, there is a macro for
292 des_ede2_ofb64_encrypt() which reuses ks1.
293
294int des_read_pw_string(
295char *buf,
296int length,
297char *prompt,
298int verify);
299 This routine is used to get a password from the terminal with echo
300 turned off. Buf is where the string will end up and length is the
301 size of buf. Prompt is a string presented to the 'user' and if
302 verify is set, the key is asked for twice and unless the 2 copies
303 match, an error is returned. A return code of -1 indicates a
304 system error, 1 failure due to use interaction, and 0 is success.
305
306unsigned long des_cbc_cksum(
307des_cblock *input,
308des_cblock *output,
309long length,
310des_key_schedule ks,
311des_cblock *ivec);
312 This function produces an 8 byte checksum from input that it puts in
313 output and returns the last 4 bytes as a long. The checksum is
314 generated via cbc mode of DES in which only the last 8 byes are
315 kept. I would recommend not using this function but instead using
316 the EVP_Digest routines, or at least using MD5 or SHA. This
317 function is used by Kerberos v4 so that is why it stays in the
318 library.
319
320char *des_fcrypt(
321const char *buf,
322const char *salt
323char *ret);
324 This is my fast version of the unix crypt(3) function. This version
325 takes only a small amount of space relative to other fast
326 crypt() implementations. This is different to the normal crypt
327 in that the third parameter is the buffer that the return value
328 is written into. It needs to be at least 14 bytes long. This
329 function is thread safe, unlike the normal crypt.
330
331char *crypt(
332const char *buf,
333const char *salt);
334 This function calls des_fcrypt() with a static array passed as the
335 third parameter. This emulates the normal non-thread safe semantics
336 of crypt(3).
337
338void des_string_to_key(
339char *str,
340des_cblock *key);
341 This function takes str and converts it into a DES key. I would
342 recommend using MD5 instead and use the first 8 bytes of output.
343 When I wrote the first version of these routines back in 1990, MD5
344 did not exist but I feel these routines are still sound. This
345 routines is compatible with the one in MIT's libdes.
346
347void des_string_to_2keys(
348char *str,
349des_cblock *key1,
350des_cblock *key2);
351 This function takes str and converts it into 2 DES keys.
352 I would recommend using MD5 and using the 16 bytes as the 2 keys.
353 I have nothing against these 2 'string_to_key' routines, it's just
354 that if you say that your encryption key is generated by using the
355 16 bytes of an MD5 hash, every-one knows how you generated your
356 keys.
357
358int des_read_password(
359des_cblock *key,
360char *prompt,
361int verify);
362 This routine combines des_read_pw_string() with des_string_to_key().
363
364int des_read_2passwords(
365des_cblock *key1,
366des_cblock *key2,
367char *prompt,
368int verify);
369 This routine combines des_read_pw_string() with des_string_to_2key().
370
371void des_random_seed(
372des_cblock key);
373 This routine sets a starting point for des_random_key().
374
375void des_random_key(
376des_cblock ret);
377 This function return a random key. Make sure to 'seed' the random
378 number generator (with des_random_seed()) before using this function.
379 I personally now use a MD5 based random number system.
380
381int des_enc_read(
382int fd,
383char *buf,
384int len,
385des_key_schedule ks,
386des_cblock *iv);
387 This function will write to a file descriptor the encrypted data
388 from buf. This data will be preceded by a 4 byte 'byte count' and
389 will be padded out to 8 bytes. The encryption is either CBC of
390 PCBC depending on the value of des_rw_mode. If it is DES_PCBC_MODE,
391 pcbc is used, if DES_CBC_MODE, cbc is used. The default is to use
392 DES_PCBC_MODE.
393
394int des_enc_write(
395int fd,
396char *buf,
397int len,
398des_key_schedule ks,
399des_cblock *iv);
400 This routines read stuff written by des_enc_read() and decrypts it.
401 I have used these routines quite a lot but I don't believe they are
402 suitable for non-blocking io. If you are after a full
403 authentication/encryption over networks, have a look at SSL instead.
404
405unsigned long des_quad_cksum(
406des_cblock *input,
407des_cblock *output,
408long length,
409int out_count,
410des_cblock *seed);
411 This is a function from Kerberos v4 that is not anything to do with
412 DES but was needed. It is a cksum that is quicker to generate than
413 des_cbc_cksum(); I personally would use MD5 routines now.
414=====
415Modes of DES
416Quite a bit of the following information has been taken from
417 AS 2805.5.2
418 Australian Standard
419 Electronic funds transfer - Requirements for interfaces,
420 Part 5.2: Modes of operation for an n-bit block cipher algorithm
421 Appendix A
422
423There are several different modes in which DES can be used, they are
424as follows.
425
426Electronic Codebook Mode (ECB) (des_ecb_encrypt())
427- 64 bits are enciphered at a time.
428- The order of the blocks can be rearranged without detection.
429- The same plaintext block always produces the same ciphertext block
430 (for the same key) making it vulnerable to a 'dictionary attack'.
431- An error will only affect one ciphertext block.
432
433Cipher Block Chaining Mode (CBC) (des_cbc_encrypt())
434- a multiple of 64 bits are enciphered at a time.
435- The CBC mode produces the same ciphertext whenever the same
436 plaintext is encrypted using the same key and starting variable.
437- The chaining operation makes the ciphertext blocks dependent on the
438 current and all preceding plaintext blocks and therefore blocks can not
439 be rearranged.
440- The use of different starting variables prevents the same plaintext
441 enciphering to the same ciphertext.
442- An error will affect the current and the following ciphertext blocks.
443
444Cipher Feedback Mode (CFB) (des_cfb_encrypt())
445- a number of bits (j) <= 64 are enciphered at a time.
446- The CFB mode produces the same ciphertext whenever the same
447 plaintext is encrypted using the same key and starting variable.
448- The chaining operation makes the ciphertext variables dependent on the
449 current and all preceding variables and therefore j-bit variables are
450 chained together and can not be rearranged.
451- The use of different starting variables prevents the same plaintext
452 enciphering to the same ciphertext.
453- The strength of the CFB mode depends on the size of k (maximal if
454 j == k). In my implementation this is always the case.
455- Selection of a small value for j will require more cycles through
456 the encipherment algorithm per unit of plaintext and thus cause
457 greater processing overheads.
458- Only multiples of j bits can be enciphered.
459- An error will affect the current and the following ciphertext variables.
460
461Output Feedback Mode (OFB) (des_ofb_encrypt())
462- a number of bits (j) <= 64 are enciphered at a time.
463- The OFB mode produces the same ciphertext whenever the same
464 plaintext enciphered using the same key and starting variable. More
465 over, in the OFB mode the same key stream is produced when the same
466 key and start variable are used. Consequently, for security reasons
467 a specific start variable should be used only once for a given key.
468- The absence of chaining makes the OFB more vulnerable to specific attacks.
469- The use of different start variables values prevents the same
470 plaintext enciphering to the same ciphertext, by producing different
471 key streams.
472- Selection of a small value for j will require more cycles through
473 the encipherment algorithm per unit of plaintext and thus cause
474 greater processing overheads.
475- Only multiples of j bits can be enciphered.
476- OFB mode of operation does not extend ciphertext errors in the
477 resultant plaintext output. Every bit error in the ciphertext causes
478 only one bit to be in error in the deciphered plaintext.
479- OFB mode is not self-synchronising. If the two operation of
480 encipherment and decipherment get out of synchronism, the system needs
481 to be re-initialised.
482- Each re-initialisation should use a value of the start variable
483 different from the start variable values used before with the same
484 key. The reason for this is that an identical bit stream would be
485 produced each time from the same parameters. This would be
486 susceptible to a ' known plaintext' attack.
487
488Triple ECB Mode (des_ecb3_encrypt())
489- Encrypt with key1, decrypt with key2 and encrypt with key3 again.
490- As for ECB encryption but increases the key length to 168 bits.
491 There are theoretic attacks that can be used that make the effective
492 key length 112 bits, but this attack also requires 2^56 blocks of
493 memory, not very likely, even for the NSA.
494- If both keys are the same it is equivalent to encrypting once with
495 just one key.
496- If the first and last key are the same, the key length is 112 bits.
497 There are attacks that could reduce the key space to 55 bit's but it
498 requires 2^56 blocks of memory.
499- If all 3 keys are the same, this is effectively the same as normal
500 ecb mode.
501
502Triple CBC Mode (des_ede3_cbc_encrypt())
503- Encrypt with key1, decrypt with key2 and then encrypt with key3.
504- As for CBC encryption but increases the key length to 168 bits with
505 the same restrictions as for triple ecb mode.
diff --git a/src/lib/libssl/src/doc/digest.doc b/src/lib/libssl/src/doc/digest.doc
new file mode 100644
index 0000000000..d2fb987591
--- /dev/null
+++ b/src/lib/libssl/src/doc/digest.doc
@@ -0,0 +1,94 @@
1
2The Message Digest subroutines.
3
4These routines require "evp.h" to be included.
5
6These functions are a higher level interface to the various message digest
7routines found in this library. As such, they allow the same code to be
8used to digest via different algorithms with only a change in an initial
9parameter. They are basically just a front-end to the MD2, MD5, SHA
10and SHA1
11routines.
12
13These routines all take a pointer to the following structure to specify
14which message digest algorithm to use.
15typedef struct evp_md_st
16 {
17 int type;
18 int pkey_type;
19 int md_size;
20 void (*init)();
21 void (*update)();
22 void (*final)();
23
24 int required_pkey_type; /*EVP_PKEY_xxx */
25 int (*sign)();
26 int (*verify)();
27 } EVP_MD;
28
29If additional message digest algorithms are to be supported, a structure of
30this type needs to be declared and populated and then the Digest routines
31can be used with that algorithm. The type field is the object NID of the
32digest type (read the section on Objects for an explanation). The pkey_type
33is the Object type to use when the a message digest is generated by there
34routines and then is to be signed with the pkey algorithm. Md_size is
35the size of the message digest returned. Init, update
36and final are the relevant functions to perform the message digest function
37by parts. One reason for specifying the message digest to use via this
38mechanism is that if you only use md5, only the md5 routines will
39be included in you linked program. If you passed an integer
40that specified which message digest to use, the routine that mapped that
41integer to a set of message digest functions would cause all the message
42digests functions to be link into the code. This setup also allows new
43message digest functions to be added by the application.
44
45The six message digests defined in this library are
46
47EVP_MD *EVP_md2(void); /* RSA sign/verify */
48EVP_MD *EVP_md5(void); /* RSA sign/verify */
49EVP_MD *EVP_sha(void); /* RSA sign/verify */
50EVP_MD *EVP_sha1(void); /* RSA sign/verify */
51EVP_MD *EVP_dss(void); /* DSA sign/verify */
52EVP_MD *EVP_dss1(void); /* DSA sign/verify */
53
54All the message digest routines take a EVP_MD_CTX pointer as an argument.
55The state of the message digest is kept in this structure.
56
57typedef struct pem_md_ctx_st
58 {
59 EVP_MD *digest;
60 union {
61 unsigned char base[4]; /* this is used in my library as a
62 * 'pointer' to all union elements
63 * structures. */
64 MD2_CTX md2;
65 MD5_CTX md5;
66 SHA_CTX sha;
67 } md;
68 } EVP_MD_CTX;
69
70The Digest functions are as follows.
71
72void EVP_DigestInit(
73EVP_MD_CTX *ctx,
74EVP_MD *type);
75 This function is used to initialise the EVP_MD_CTX. The message
76 digest that will associated with 'ctx' is specified by 'type'.
77
78void EVP_DigestUpdate(
79EVP_MD_CTX *ctx,
80unsigned char *data,
81unsigned int cnt);
82 This function is used to pass more data to the message digest
83 function. 'cnt' bytes are digested from 'data'.
84
85void EVP_DigestFinal(
86EVP_MD_CTX *ctx,
87unsigned char *md,
88unsigned int *len);
89 This function finishes the digestion and puts the message digest
90 into 'md'. The length of the message digest is put into len;
91 EVP_MAX_MD_SIZE is the size of the largest message digest that
92 can be returned from this function. Len can be NULL if the
93 size of the digest is not required.
94
diff --git a/src/lib/libssl/src/doc/encode.doc b/src/lib/libssl/src/doc/encode.doc
new file mode 100644
index 0000000000..af17549289
--- /dev/null
+++ b/src/lib/libssl/src/doc/encode.doc
@@ -0,0 +1,15 @@
1
2void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
3void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,
4 int *outl,unsigned char *in,int inl);
5void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
6int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int n);
7
8void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
9int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
10 unsigned char *in, int inl);
11int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
12 char *out, int *outl);
13int EVP_DecodeBlock(unsigned char *t, unsigned
14 char *f, int n);
15
diff --git a/src/lib/libssl/src/doc/envelope.doc b/src/lib/libssl/src/doc/envelope.doc
new file mode 100644
index 0000000000..483e4fca6b
--- /dev/null
+++ b/src/lib/libssl/src/doc/envelope.doc
@@ -0,0 +1,67 @@
1The following routines are use to create 'digital' envelopes.
2By this I mean that they perform various 'higher' level cryptographic
3functions. Have a read of 'cipher.doc' and 'digest.doc' since those
4routines are used by these functions.
5cipher.doc contains documentation about the cipher part of the
6envelope library and digest.doc contatins the description of the
7message digests supported.
8
9To 'sign' a document involves generating a message digest and then encrypting
10the digest with an private key.
11
12#define EVP_SignInit(a,b) EVP_DigestInit(a,b)
13#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
14Due to the fact this operation is basically just an extended message
15digest, the first 2 functions are macro calls to Digest generating
16functions.
17
18int EVP_SignFinal(
19EVP_MD_CTX *ctx,
20unsigned char *md,
21unsigned int *s,
22EVP_PKEY *pkey);
23 This finalisation function finishes the generation of the message
24digest and then encrypts the digest (with the correct message digest
25object identifier) with the EVP_PKEY private key. 'ctx' is the message digest
26context. 'md' will end up containing the encrypted message digest. This
27array needs to be EVP_PKEY_size(pkey) bytes long. 's' will actually
28contain the exact length. 'pkey' of course is the private key. It is
29one of EVP_PKEY_RSA or EVP_PKEY_DSA type.
30If there is an error, 0 is returned, otherwise 1.
31
32Verify is used to check an signed message digest.
33
34#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
35#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
36Since the first step is to generate a message digest, the first 2 functions
37are macros.
38
39int EVP_VerifyFinal(
40EVP_MD_CTX *ctx,
41unsigned char *md,
42unsigned int s,
43EVP_PKEY *pkey);
44 This function finishes the generation of the message digest and then
45compares it with the supplied encrypted message digest. 'md' contains the
46's' bytes of encrypted message digest. 'pkey' is used to public key decrypt
47the digest. It is then compared with the message digest just generated.
48If they match, 1 is returned else 0.
49
50int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek,
51 int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk);
52Must have at least one public key, error is 0. I should also mention that
53the buffers pointed to by 'ek' need to be EVP_PKEY_size(pubk[n]) is size.
54
55#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
56void EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
57
58
59int EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek,
60 int ekl,unsigned char *iv,EVP_PKEY *priv);
610 on failure
62
63#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
64
65int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
66Decrypt final return code
67
diff --git a/src/lib/libssl/src/doc/error.doc b/src/lib/libssl/src/doc/error.doc
new file mode 100644
index 0000000000..a91654999a
--- /dev/null
+++ b/src/lib/libssl/src/doc/error.doc
@@ -0,0 +1,115 @@
1The error routines.
2
3The 'error' system I've implemented is intended to server 2 purpose, to
4record the reason why a command failed and to record where in the libraries
5the failure occurred. It is more or less setup to record a 'trace' of which
6library components were being traversed when the error occurred.
7
8When an error is recorded, it is done so a as single unsigned long which is
9composed of three parts. The top byte is the 'library' number, the middle
1012 bytes is the function code, and the bottom 12 bits is the 'reason' code.
11
12Each 'library', or should a say, 'section' of the SSLeay library has a
13different unique 'library' error number. Each function in the library has
14a number that is unique for that library. Each 'library' also has a number
15for each 'error reason' that is only unique for that 'library'.
16
17Due to the way these error routines record a 'error trace', there is an
18array per thread that is used to store the error codes.
19The various functions in this library are used to access
20and manipulate this array.
21
22void ERR_put_error(int lib, int func,int reason);
23 This routine records an error in library 'lib', function 'func'
24and reason 'reason'. As errors get 'put' into the buffer, they wrap
25around and overwrite old errors if too many are written. It is assumed
26that the last errors are the most important.
27
28unsigned long ERR_get_error(void );
29 This function returns the last error added to the error buffer.
30In effect it is popping the value off the buffer so repeated calls will
31continue to return values until there are no more errors to return in which
32case 0 is returned.
33
34unsigned long ERR_peek_error(void );
35 This function returns the value of the last error added to the
36error buffer but does not 'pop' it from the buffer.
37
38void ERR_clear_error(void );
39 This function clears the error buffer, discarding all unread
40errors.
41
42While the above described error system obviously produces lots of different
43error number, a method for 'reporting' these errors in a human readable
44form is required. To achieve this, each library has the option of
45'registering' error strings.
46
47typedef struct ERR_string_data_st
48 {
49 unsigned long error;
50 char *string;
51 } ERR_STRING_DATA;
52
53The 'ERR_STRING_DATA' contains an error code and the corresponding text
54string. To add new function error strings for a library, the
55ERR_STRING_DATA needs to be 'registered' with the library.
56
57void ERR_load_strings(unsigned long lib,ERR_STRING_DATA *err);
58 This function 'registers' the array of ERR_STRING_DATA pointed to by
59'err' as error text strings for the error library 'lib'.
60
61void ERR_free_strings(void);
62 This function free()s all the loaded error strings.
63
64char *ERR_error_string(unsigned long error,char *buf);
65 This function returns a text string that is a human readable
66version of the error represented by 'error'. Buff should be at least 120
67bytes long and if it is NULL, the return value is a pointer to a static
68variable that will contain the error string, otherwise 'buf' is returned.
69If there is not a text string registered for a particular error, a text
70string containing the error number is returned instead.
71
72void ERR_print_errors(BIO *bp);
73void ERR_print_errors_fp(FILE *fp);
74 This function is a convenience routine that prints the error string
75for each error until all errors have been accounted for.
76
77char *ERR_lib_error_string(unsigned long e);
78char *ERR_func_error_string(unsigned long e);
79char *ERR_reason_error_string(unsigned long e);
80The above three functions return the 3 different components strings for the
81error 'e'. ERR_error_string() uses these functions.
82
83void ERR_load_ERR_strings(void );
84 This function 'registers' the error strings for the 'ERR' module.
85
86void ERR_load_crypto_strings(void );
87 This function 'register' the error strings for just about every
88library in the SSLeay package except for the SSL routines. There is no
89need to ever register any error text strings and you will probably save in
90program size. If on the other hand you do 'register' all errors, it is
91quite easy to determine why a particular routine failed.
92
93As a final footnote as to why the error system is designed as it is.
941) I did not want a single 'global' error code.
952) I wanted to know which subroutine a failure occurred in.
963) For Windows NT etc, it should be simple to replace the 'key' routines
97 with code to pass error codes back to the application.
984) I wanted the option of meaningful error text strings.
99
100Late breaking news - the changes to support threads.
101
102Each 'thread' has an 'ERR_STATE' state associated with it.
103ERR_STATE *ERR_get_state(void ) will return the 'state' for the calling
104thread/process.
105
106ERR_remove_state(unsigned long pid); will 'free()' this state. If pid == 0
107the current 'thread/process' will have it's error state removed.
108If you do not remove the error state of a thread, this could be considered a
109form of memory leak, so just after 'reaping' a thread that has died,
110call ERR_remove_state(pid).
111
112Have a read of thread.doc for more details for what is required for
113multi-threading support. All the other error routines will
114work correctly when using threads.
115
diff --git a/src/lib/libssl/src/doc/legal.doc b/src/lib/libssl/src/doc/legal.doc
new file mode 100644
index 0000000000..b55ed5ce6a
--- /dev/null
+++ b/src/lib/libssl/src/doc/legal.doc
@@ -0,0 +1,117 @@
1From eay@mincom.com Thu Jun 27 00:25:45 1996
2Received: by orb.mincom.oz.au id AA15821
3 (5.65c/IDA-1.4.4 for eay); Wed, 26 Jun 1996 14:25:45 +1000
4Date: Wed, 26 Jun 1996 14:25:45 +1000 (EST)
5From: Eric Young <eay@mincom.oz.au>
6X-Sender: eay@orb
7To: Ken Toll <ktoll@ren.digitalage.com>
8Cc: Eric Young <eay@mincom.oz.au>, ssl-talk@netscape.com
9Subject: Re: Unidentified subject!
10In-Reply-To: <9606261950.ZM28943@ren.digitalage.com>
11Message-Id: <Pine.SOL.3.91.960626131156.28573K-100000@orb>
12Mime-Version: 1.0
13Content-Type: TEXT/PLAIN; charset=US-ASCII
14Status: O
15X-Status:
16
17
18This is a little off topic but since SSLeay is a free implementation of
19the SSLv2 protocol, I feel it is worth responding on the topic of if it
20is actually legal for Americans to use free cryptographic software.
21
22On Wed, 26 Jun 1996, Ken Toll wrote:
23> Is the U.S the only country that SSLeay cannot be used commercially
24> (because of RSAref) or is that going to be an issue with every country
25> that a client/server application (non-web browser/server) is deployed
26> and sold?
27
28>From what I understand, the software patents that apply to algorithms
29like RSA and DH only apply in the USA. The IDEA algorithm I believe is
30patened in europe (USA?), but considing how little it is used by other SSL
31implementations, it quite easily be left out of the SSLeay build
32(this can be done with a compile flag).
33
34Actually if the RSA patent did apply outside the USA, it could be rather
35interesting since RSA is not alowed to let RSA toolkits outside of the USA
36[1], and since these are the only forms that they will alow the algorithm
37to be used in, it would mean that non-one outside of the USA could produce
38public key software which would be a very strong statment for
39international patent law to make :-). This logic is a little flawed but
40it still points out some of the more interesting permutations of USA
41patent law and ITAR restrictions.
42
43Inside the USA there is also the unresolved issue of RC4/RC2 which were
44made public on sci.crypt in Sep 1994 (RC4) and Feb 1996 (RC2). I have
45copies of the origional postings if people are interested. RSA I believe
46claim that they were 'trade-secrets' and that some-one broke an NDA in
47revealing them. Other claim they reverse engineered the algorithms from
48compiled binaries. If the algorithms were reverse engineered, I belive
49RSA had no legal leg to stand on. If an NDA was broken, I don't know.
50Regardless, RSA, I belive, is willing to go to court over the issue so
51licencing is probably the best idea, or at least talk to them.
52If there are people who actually know more about this, pease let me know, I
53don't want to vilify or spread miss-information if I can help it.
54
55If you are not producing a web browser, it is easy to build SSLeay with
56RC2/RC4 removed. Since RC4 is the defacto standard cipher in
57all web software (and it is damn fast) it is more or less required for
58www use. For non www use of SSL, especially for an application where
59interoperability with other vendors is not critical just leave it out.
60
61Removing IDEA, RC2 and RC4 would only leave DES and Triple DES but
62they should be ok. Considing that Triple DES can encrypt at rates of
63410k/sec on a pentium 100, and 940k/sec on a P6/200, this is quite
64reasonable performance. Single DES clocks in at 1160k/s and 2467k/s
65respectivly is actually quite fast for those not so paranoid (56 bit key).[1]
66
67> Is it possible to get a certificate for commercial use outside of the U.S.?
68yes.
69
70Thawte Consulting issues certificates (they are the people who sell the
71 Sioux httpd server and are based in South Africa)
72Verisign will issue certificates for Sioux (sold from South Africa), so this
73 proves that they will issue certificate for OS use if they are
74 happy with the quality of the software.
75
76(The above mentioned companies just the ones that I know for sure are issuing
77 certificates outside the USA).
78
79There is always the point that if you are using SSL for an intra net,
80SSLeay provides programs that can be used so you can issue your own
81certificates. They need polishing but at least it is a good starting point.
82
83I am not doing anything outside Australian law by implementing these
84algorithms (to the best of my knowedge). It is another example of how
85the world legal system does not cope with the internet very well.
86
87I may start making shared libraries available (I have now got DLL's for
88Windows). This will mean that distributions into the usa could be
89shipped with a version with a reduced cipher set and the versions outside
90could use the DLL/shared library with all the ciphers (and without RSAref).
91
92This could be completly hidden from the application, so this would not
93even require a re-linking.
94
95This is the reverse of what people were talking about doing to get around
96USA export regulations :-)
97
98eric
99
100[1]: The RSAref2.0 tookit is available on at least 3 ftp sites in Europe
101 and one in South Africa.
102
103[2]: Since I always get questions when I post benchmark numbers :-),
104 DES performace figures are in 1000's of bytes per second in cbc
105 mode using an 8192 byte buffer. The pentium 100 was running Windows NT
106 3.51 DLLs and the 686/200 was running NextStep.
107 I quote pentium 100 benchmarks because it is basically the
108 'entry level' computer that most people buy for personal use.
109 Windows 95 is the OS shipping on those boxes, so I'll give
110 NT numbers (the same Win32 runtime environment). The 686
111 numbers are present as an indication of where we will be in a
112 few years.
113--
114Eric Young | BOOL is tri-state according to Bill Gates.
115AARNet: eay@mincom.oz.au | RTFM Win32 GetMessage().
116
117
diff --git a/src/lib/libssl/src/doc/lhash.doc b/src/lib/libssl/src/doc/lhash.doc
new file mode 100644
index 0000000000..5a2aeb4b38
--- /dev/null
+++ b/src/lib/libssl/src/doc/lhash.doc
@@ -0,0 +1,151 @@
1The LHASH library.
2
3I wrote this library in 1991 and have since forgotten why I called it lhash.
4It implements a hash table from an article I read at the
5time from 'Communications of the ACM'. What makes this hash
6table different is that as the table fills, the hash table is
7increased (or decreased) in size via realloc().
8When a 'resize' is done, instead of all hashes being redistributed over
9twice as many 'buckets', one bucket is split. So when an 'expand' is done,
10there is only a minimal cost to redistribute some values. Subsequent
11inserts will cause more single 'bucket' redistributions but there will
12never be a sudden large cost due to redistributing all the 'buckets'.
13
14The state for a particular hash table is kept in the LHASH structure.
15The LHASH structure also records statistics about most aspects of accessing
16the hash table. This is mostly a legacy of my writing this library for
17the reasons of implementing what looked like a nice algorithm rather than
18for a particular software product.
19
20Internal stuff you probably don't want to know about.
21The decision to increase or decrease the hash table size is made depending
22on the 'load' of the hash table. The load is the number of items in the
23hash table divided by the size of the hash table. The default values are
24as follows. If (hash->up_load < load) => expand.
25if (hash->down_load > load) => contract. The 'up_load' has a default value of
261 and 'down_load' has a default value of 2. These numbers can be modified
27by the application by just playing with the 'up_load' and 'down_load'
28variables. The 'load' is kept in a form which is multiplied by 256. So
29hash->up_load=8*256; will cause a load of 8 to be set.
30
31If you are interested in performance the field to watch is
32num_comp_calls. The hash library keeps track of the 'hash' value for
33each item so when a lookup is done, the 'hashes' are compared, if
34there is a match, then a full compare is done, and
35hash->num_comp_calls is incremented. If num_comp_calls is not equal
36to num_delete plus num_retrieve it means that your hash function is
37generating hashes that are the same for different values. It is
38probably worth changing your hash function if this is the case because
39even if your hash table has 10 items in a 'bucked', it can be searched
40with 10 'unsigned long' compares and 10 linked list traverses. This
41will be much less expensive that 10 calls to you compare function.
42
43LHASH *lh_new(
44unsigned long (*hash)(),
45int (*cmp)());
46 This function is used to create a new LHASH structure. It is passed
47 function pointers that are used to store and retrieve values passed
48 into the hash table. The 'hash'
49 function is a hashing function that will return a hashed value of
50 it's passed structure. 'cmp' is passed 2 parameters, it returns 0
51 is they are equal, otherwise, non zero.
52 If there are any problems (usually malloc failures), NULL is
53 returned, otherwise a new LHASH structure is returned. The
54 hash value is normally truncated to a power of 2, so make sure
55 that your hash function returns well mixed low order bits.
56
57void lh_free(
58LHASH *lh);
59 This function free()s a LHASH structure. If there is malloced
60 data in the hash table, it will not be freed. Consider using the
61 lh_doall function to deallocate any remaining entries in the hash
62 table.
63
64char *lh_insert(
65LHASH *lh,
66char *data);
67 This function inserts the data pointed to by data into the lh hash
68 table. If there is already and entry in the hash table entry, the
69 value being replaced is returned. A NULL is returned if the new
70 entry does not clash with an entry already in the table (the normal
71 case) or on a malloc() failure (perhaps I should change this....).
72 The 'char *data' is exactly what is passed to the hash and
73 comparison functions specified in lh_new().
74
75char *lh_delete(
76LHASH *lh,
77char *data);
78 This routine deletes an entry from the hash table. The value being
79 deleted is returned. NULL is returned if there is no such value in
80 the hash table.
81
82char *lh_retrieve(
83LHASH *lh,
84char *data);
85 If 'data' is in the hash table it is returned, else NULL is
86 returned. The way these routines would normally be uses is that a
87 dummy structure would have key fields populated and then
88 ret=lh_retrieve(hash,&dummy);. Ret would now be a pointer to a fully
89 populated structure.
90
91void lh_doall(
92LHASH *lh,
93void (*func)(char *a));
94 This function will, for every entry in the hash table, call function
95 'func' with the data item as parameters.
96 This function can be quite useful when used as follows.
97 void cleanup(STUFF *a)
98 { STUFF_free(a); }
99 lh_doall(hash,cleanup);
100 lh_free(hash);
101 This can be used to free all the entries, lh_free() then
102 cleans up the 'buckets' that point to nothing. Be careful
103 when doing this. If you delete entries from the hash table,
104 in the call back function, the table may decrease in size,
105 moving item that you are
106 currently on down lower in the hash table. This could cause
107 some entries to be skipped. The best solution to this problem
108 is to set lh->down_load=0 before you start. This will stop
109 the hash table ever being decreased in size.
110
111void lh_doall_arg(
112LHASH *lh;
113void(*func)(char *a,char *arg));
114char *arg;
115 This function is the same as lh_doall except that the function
116 called will be passed 'arg' as the second argument.
117
118unsigned long lh_strhash(
119char *c);
120 This function is a demo string hashing function. Since the LHASH
121 routines would normally be passed structures, this routine would
122 not normally be passed to lh_new(), rather it would be used in the
123 function passed to lh_new().
124
125The next three routines print out various statistics about the state of the
126passed hash table. These numbers are all kept in the lhash structure.
127
128void lh_stats(
129LHASH *lh,
130FILE *out);
131 This function prints out statistics on the size of the hash table,
132 how many entries are in it, and the number and result of calls to
133 the routines in this library.
134
135void lh_node_stats(
136LHASH *lh,
137FILE *out);
138 For each 'bucket' in the hash table, the number of entries is
139 printed.
140
141void lh_node_usage_stats(
142LHASH *lh,
143FILE *out);
144 This function prints out a short summary of the state of the hash
145 table. It prints what I call the 'load' and the 'actual load'.
146 The load is the average number of data items per 'bucket' in the
147 hash table. The 'actual load' is the average number of items per
148 'bucket', but only for buckets which contain entries. So the
149 'actual load' is the average number of searches that will need to
150 find an item in the hash table, while the 'load' is the average number
151 that will be done to record a miss.
diff --git a/src/lib/libssl/src/doc/md2.doc b/src/lib/libssl/src/doc/md2.doc
new file mode 100644
index 0000000000..b106bc675d
--- /dev/null
+++ b/src/lib/libssl/src/doc/md2.doc
@@ -0,0 +1,49 @@
1The MD2 library.
2MD2 is a message digest algorithm that can be used to condense an arbitrary
3length message down to a 16 byte hash. The functions all need to be passed
4a MD2_CTX which is used to hold the MD2 context during multiple MD2_Update()
5function calls. The normal method of use for this library is as follows
6
7MD2_Init(...);
8MD2_Update(...);
9...
10MD2_Update(...);
11MD2_Final(...);
12
13This library requires the inclusion of 'md2.h'.
14
15The main negative about MD2 is that it is slow, especially when compared
16to MD5.
17
18The functions are as follows:
19
20void MD2_Init(
21MD2_CTX *c);
22 This function needs to be called to initiate a MD2_CTX structure for
23 use.
24
25void MD2_Update(
26MD2_CTX *c;
27unsigned char *data;
28unsigned long len);
29 This updates the message digest context being generated with 'len'
30 bytes from the 'data' pointer. The number of bytes can be any
31 length.
32
33void MD2_Final(
34unsigned char *md;
35MD2_CTX *c;
36 This function is called when a message digest of the data digested
37 with MD2_Update() is wanted. The message digest is put in the 'md'
38 array and is MD2_DIGEST_LENGTH (16) bytes long.
39
40unsigned char *MD2(
41unsigned long n;
42unsigned char *d;
43unsigned char *md;
44 This function performs a MD2_Init(), followed by a MD2_Update()
45 followed by a MD2_Final() (using a local MD2_CTX).
46 The resulting digest is put into 'md' if it is not NULL.
47 Regardless of the value of 'md', the message
48 digest is returned from the function. If 'md' was NULL, the message
49 digest returned is being stored in a static structure.
diff --git a/src/lib/libssl/src/doc/md5.doc b/src/lib/libssl/src/doc/md5.doc
new file mode 100644
index 0000000000..519dbdc61a
--- /dev/null
+++ b/src/lib/libssl/src/doc/md5.doc
@@ -0,0 +1,50 @@
1The MD5 library.
2MD5 is a message digest algorithm that can be used to condense an arbitrary
3length message down to a 16 byte hash. The functions all need to be passed
4a MD5_CTX which is used to hold the MD5 context during multiple MD5_Update()
5function calls. This library also contains random number routines that are
6based on MD5
7
8The normal method of use for this library is as follows
9
10MD5_Init(...);
11MD5_Update(...);
12...
13MD5_Update(...);
14MD5_Final(...);
15
16This library requires the inclusion of 'md5.h'.
17
18The functions are as follows:
19
20void MD5_Init(
21MD5_CTX *c);
22 This function needs to be called to initiate a MD5_CTX structure for
23 use.
24
25void MD5_Update(
26MD5_CTX *c;
27unsigned char *data;
28unsigned long len);
29 This updates the message digest context being generated with 'len'
30 bytes from the 'data' pointer. The number of bytes can be any
31 length.
32
33void MD5_Final(
34unsigned char *md;
35MD5_CTX *c;
36 This function is called when a message digest of the data digested
37 with MD5_Update() is wanted. The message digest is put in the 'md'
38 array and is MD5_DIGEST_LENGTH (16) bytes long.
39
40unsigned char *MD5(
41unsigned char *d;
42unsigned long n;
43unsigned char *md;
44 This function performs a MD5_Init(), followed by a MD5_Update()
45 followed by a MD5_Final() (using a local MD5_CTX).
46 The resulting digest is put into 'md' if it is not NULL.
47 Regardless of the value of 'md', the message
48 digest is returned from the function. If 'md' was NULL, the message
49 digest returned is being stored in a static structure.
50
diff --git a/src/lib/libssl/src/doc/memory.doc b/src/lib/libssl/src/doc/memory.doc
new file mode 100644
index 0000000000..b9aa33ace0
--- /dev/null
+++ b/src/lib/libssl/src/doc/memory.doc
@@ -0,0 +1,27 @@
1In the interests of debugging SSLeay, there is an option to compile
2using some simple memory leak checking.
3
4All malloc(), free() and realloc() calls in SSLeay now go via
5Malloc(), Free() and Realloc() (except those in crypto/lhash).
6
7If CRYPTO_MDEBUG is defined, these calls are #defined to
8CRYPTO_malloc(), CRYPTO_free() and CRYPTO_realloc().
9If it is not defined, they are #defined to malloc(), free() and realloc().
10
11the CRYPTO_malloc() routines by default just call the underlying library
12functons.
13
14If CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) is called, memory leak detection is
15turned on. CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) turns it off.
16
17When turned on, each Malloc() or Realloc() call is recored along with the file
18and line number from where the call was made. (This is done using the
19lhash library which always uses normal system malloc(3) routines).
20
21void CRYPTO_mem_leaks(BIO *b);
22void CRYPTO_mem_leaks_fp(FILE *fp);
23These both print out the list of memory that has not been free()ed.
24This will probably be rather hard to read, but if you look for the 'top level'
25structure allocation, this will often give an idea as to what is not being
26free()ed. I don't expect people to use this stuff normally.
27
diff --git a/src/lib/libssl/src/doc/ms3-ca.doc b/src/lib/libssl/src/doc/ms3-ca.doc
new file mode 100644
index 0000000000..f8350aadc2
--- /dev/null
+++ b/src/lib/libssl/src/doc/ms3-ca.doc
@@ -0,0 +1,398 @@
1Date: Mon, 9 Jun 97 08:00:33 +0200
2From: Holger.Reif@PrakInf.TU-Ilmenau.DE (Holger Reif)
3Subject: ms3-ca.doc
4Organization: TU Ilmenau, Fak. IA, FG Telematik
5Content-Length: 14575
6Status: RO
7X-Status:
8
9Loading client certs into MSIE 3.01
10===================================
11
12This document conatains all the information necessary to succesfully set up
13some scripts to issue client certs to Microsoft Internet Explorer. It
14includes the required knowledge about the model MSIE uses for client
15certification and includes complete sample scripts ready to play with. The
16scripts were tested against a modified ca program of SSLeay 0.6.6 and should
17work with the regular ca program that comes with version 0.8.0. I haven't
18tested against MSIE 4.0
19
20You can use the information contained in this document in either way you
21want. However if you feel it saved you a lot of time I ask you to be as fair
22as to mention my name: Holger Reif <reif@prakinf.tu-ilmenau.de>.
23
241.) The model used by MSIE
25--------------------------
26
27The Internet Explorer doesn't come with a embedded engine for installing
28client certs like Netscape's Navigator. It rather uses the CryptoAPI (CAPI)
29defined by Microsoft. CAPI comes with WindowsNT 4.0 or is installed together
30with Internet Explorer since 3.01. The advantage of this approach is a higher
31flexibility because the certificates in the (per user) system open
32certificate store may be used by other applications as well. The drawback
33however is that you need to do a bit more work to get a client cert issued.
34
35CAPI defines functions which will handle basic cryptographic work, eg.
36generating keys, encrypting some data, signing text or building a certificate
37request. The procedure is as follows: A CAPI function generates you a key
38pair and saves it into the certificate store. After that one builds a
39Distinguished Name. Together with that key pair another CAPI function forms a
40PKCS#10 request which you somehow need to submit to a CA. Finally the issued
41cert is given to a yet another CAPI function which saves it into the
42certificate store.
43
44The certificate store with the user's keys and certs is in the registry. You
45will find it under HKEY_CURRENT_USER/Software/Microsoft/Cryptography/ (I
46leave it to you as a little exercise to figure out what all the entries mean
47;-). Note that the keys are protected only with the user's usual Windows
48login password.
49
502.) The practical usage
51-----------------------
52
53Unfortunatly since CAPI is a system API you can't access its functions from
54HTML code directly. For this purpose Microsoft provides a wrapper called
55certenr3.dll. This DLL accesses the CAPI functions and provides an interface
56usable from Visual Basic Script. One needs to install that library on the
57computer which wants to have client cert. The easiest way is to load it as an
58ActiveX control (certenr3.dll is properly authenticode signed by MS ;-). If
59you have ever enrolled e cert request at a CA you will have installed it.
60
61At time of writing certenr3.dll is contained in
62http://www.microsoft.com/workshop/prog/security/csa/certenr3.exe. It comes
63with an README file which explains the available functions. It is labeled
64beta but every CA seems to use it anyway. The license.txt allows you the
65usage for your own purposes (as far as I understood) and a somehow limited
66distribution.
67
68The two functions of main interest are GenerateKeyPair and AcceptCredentials.
69For complete explanation of all possible parameters see the README file. Here
70are only minimal required parameters and their values.
71
72GenerateKeyPair(sessionID, FASLE, szName, 0, "ClientAuth", TRUE, FALSE, 1)
73- sessionID is a (locally to that computer) unique string to correlate the
74generated key pair with a cert installed later.
75- szName is the DN of the form "C=DE; S=Thueringen; L=Ilmenau; CN=Holger
76Reif; 1.2.840.113549.1.9.1=reif@prakinf.tu-ilmenau.de". Note that S is the
77abreviation for StateOrProvince. The recognized abreviation include CN, O, C,
78OU, G, I, L, S, T. If the abreviation is unknown (eg. for PKCS#9 email addr)
79you need to use the full object identifier. The starting point for searching
80them could be crypto/objects.h since all OIDs know to SSLeay are listed
81there.
82- note: the possible ninth parameter which should give a default name to the
83certificate storage location doesn't seem to work. Changes to the constant
84values in the call above doesn't seem to make sense. You can't generate
85PKCS#10 extensions with that function.
86
87The result of GenerateKeyPair is the base64 encoded PKCS#10 request. However
88it has a little strange format that SSLeay doesn't accept. (BTW I feel the
89decision of rejecting that format as standard conforming.) It looks like
90follows:
91 1st line with 76 chars
92 2nd line with 76 chars
93 ...
94 (n-2)th line with 76 chars
95 (n-1)th line contains a multiple of 4 chars less then 76 (possible
96empty)
97 (n)th line has zero or 4 chars (then with 1 or 2 equal signs - the
98 original text's lenght wasn'T a multiple of 3)
99 The line separator has two chars: 0x0d 0x0a
100
101AcceptCredentials(sessionID, credentials, 0, FALSE)
102- sessionID needs to be the same as while generating the key pair
103- credentials is the base64 encoded PKCS#7 object containing the cert.
104
105CRL's and CA certs are not required simply just the client cert. (It seems to
106me that both are not even checked somehow.) The only format of the base64
107encoded object I succesfully used was all characters in a very long string
108without line feeds or carriage returns. (Hey, it doesn't matter, only a
109computer reads it!)
110
111The result should be S_OK. For error handling see the example that comes with
112certenr3.dll.
113
114A note about ASN.1 character encodings. certenr3.dll seems to know only about
1152 of them: UniversalString and PrintableString. First it is definitely wrong
116for an email address which is IA5STRING (checked by ssleay's ca). Second
117unfortunately MSIE (at least until version 3.02) can't handle UniversalString
118correctly - they just blow up you cert store! Therefore ssleay's ca (starting
119from version 0.8.0) tries to convert the encodings automatically to IA5STRING
120or TeletexString. The beef is it will work only for the latin-1 (western)
121charset. Microsoft still has to do abit of homework...
122
1233.) An example
124--------------
125
126At least you need two steps: generating the key & request and then installing
127the certificate. A real world CA would have some more steps involved, eg.
128accepting some license. Note that both scripts shown below are just
129experimental state without any warrenty!
130
131First how to generate a request. Note that we can't use a static page because
132of the sessionID. I generate it from system time plus pid and hope it is
133unique enough. Your are free to feed it through md5 to get more impressive
134ID's ;-) Then the intended text is read in with sed which inserts the
135sessionID.
136
137-----BEGIN ms-enroll.cgi-----
138#!/bin/sh
139SESSION_ID=`date '+%y%m%d%H%M%S'`$$
140echo Content-type: text/html
141echo
142sed s/template_for_sessId/$SESSION_ID/ <<EOF
143<HTML><HEAD>
144<TITLE>Certificate Enrollment Test Page</TITLE>
145</HEAD><BODY>
146
147<OBJECT
148 classid="clsid:33BEC9E0-F78F-11cf-B782-00C04FD7BF43"
149 codebase=certenr3.dll
150 id=certHelper
151 >
152</OBJECT>
153
154<CENTER>
155<H2>enrollment for a personal cert</H2>
156<BR><HR WIDTH=50%><BR><P>
157<FORM NAME="MSIE_Enrollment" ACTION="ms-gencert.cgi" ENCTYPE=x-www-form-
158encoded METHOD=POST>
159<TABLE>
160 <TR><TD>Country</TD><TD><INPUT NAME="Country" VALUE=""></TD></TR>
161 <TR><TD>State</TD><TD><INPUT NAME="StateOrProvince" VALUE=""></TD></TR>
162 <TR><TD>Location</TD><TD><INPUT NAME="Location" VALUE=""></TD></TR>
163 <TR><TD>Organization</TD><TD><INPUT NAME="Organization"
164VALUE=""></TD></TR>
165 <TR><TD>Organizational Unit</TD>
166 <TD><INPUT NAME="OrganizationalUnit" VALUE=""></TD></TR>
167 <TR><TD>Name</TD><TD><INPUT NAME="CommonName" VALUE=""></TD></TR>
168 <TR><TD>eMail Address</TD>
169 <TD><INPUT NAME="EmailAddress" VALUE=""></TD></TR>
170 <TR><TD></TD>
171 <TD><INPUT TYPE="BUTTON" NAME="submit" VALUE="Beantragen"></TD></TR>
172</TABLE>
173 <INPUT TYPE="hidden" NAME="SessionId" VALUE="template_for_sessId">
174 <INPUT TYPE="hidden" NAME="Request" VALUE="">
175</FORM>
176<BR><HR WIDTH=50%><BR><P>
177</CENTER>
178
179<SCRIPT LANGUAGE=VBS>
180 Dim DN
181
182 Sub Submit_OnClick
183 Dim TheForm
184 Set TheForm = Document.MSIE_Enrollment
185 sessionId = TheForm.SessionId.value
186 reqHardware = FALSE
187 C = TheForm.Country.value
188 SP = TheForm.StateOrProvince.value
189 L = TheForm.Location.value
190 O = TheForm.Organization.value
191 OU = TheForm.OrganizationalUnit.value
192 CN = TheForm.CommonName.value
193 Email = TheForm.EmailAddress.value
194 szPurpose = "ClientAuth"
195 doAcceptanceUINow = FALSE
196 doOnline = TRUE
197
198 DN = ""
199
200 Call Add_RDN("C", C)
201 Call Add_RDN("S", SP)
202 Call Add_RDN("L", L)
203 Call Add_RDN("O", O)
204 Call Add_RDN("OU", OU)
205 Call Add_RDN("CN", CN)
206 Call Add_RDN("1.2.840.113549.1.9.1", Email)
207 ' rsadsi
208 ' pkcs
209 ' pkcs9
210 ' eMailAddress
211 On Error Resume Next
212 sz10 = certHelper.GenerateKeyPair(sessionId, _
213 FALSE, DN, 0, ClientAuth, FASLE, TRUE, 1)_
214 theError = Err.Number
215 On Error Goto 0
216 if (sz10 = Empty OR theError <> 0) Then
217 sz = "The error '" & Hex(theError) & "' occurred." & chr(13) & _
218 chr(10) & "Your credentials could not be generated."
219 result = MsgBox(sz, 0, "Credentials Enrollment")
220 Exit Sub
221 else
222 TheForm.Request.value = sz10
223 TheForm.Submit
224 end if
225 End Sub
226
227 Sub Add_RDN(sn, value)
228 if (value <> "") then
229 if (DN <> "") then
230 DN = DN & "; "
231 end if
232 DN = DN & sn & "=" & value
233 end if
234 End Sub
235</SCRIPT>
236</BODY>
237</HTML>
238EOF
239-----END ms-enroll.cgi-----
240
241Second, how to extract the request and feed the certificate back? We need to
242"normalize" the base64 encoding of the PKCS#10 format which means
243regenerating the lines and wrapping with BEGIN and END line. This is done by
244gawk. The request is taken by ca the normal way. Then the cert needs to be
245packed into a PKCS#7 structure (note: the use of a CRL is necessary for
246crl2pkcs7 as of version 0.6.6. Starting with 0.8.0 it it might probably be
247ommited). Finally we need to format the PKCS#7 object and generate the HTML
248text. I use two templates to have a clearer script.
249
2501st note: postit2 is slightly modified from a program I found at ncsa's ftp
251site. Grab it from http://www.easterngraphics.com/certs/IX9704/postit2.c. You
252need utils.c from there too.
253
2542nd note: I'm note quite sure wether the gawk script really handles all
255possible inputs for the request right! Today I don't use this construction
256anymore myself.
257
2583d note: the cert must be of version 3! This could be done with the nsComment
259line in ssleay.cnf...
260
261------BEGIN ms-gencert.cgi-----
262#!/bin/sh
263FILE="/tmp/"`date '+%y%m%d%H%M%S'-`$$
264rm -f "$FILE".*
265
266HOME=`pwd`; export HOME # as ssleay.cnf insists on having such an env var
267cd /usr/local/ssl #where demoCA (as named in ssleay.conf) is located
268
269postit2 -s " " -i 0x0d > "$FILE".inp # process the FORM vars
270
271SESSION_ID=`gawk '$1 == "SessionId" { print $2; exit }' "$FILE".inp`
272
273gawk \
274 'BEGIN { \
275 OFS = ""; \
276 print "-----BEGIN CERTIFICATE REQUEST-----"; \
277 req_seen=0 \
278 } \
279 $1 == "Request" { \
280 req_seen=1; \
281 if (length($2) == 72) print($2); \
282 lastline=$2; \
283 next; \
284 } \
285 { \
286 if (req_seen == 1) { \
287 if (length($1) >= 72) print($1); \
288 else if (length(lastline) < 72) { \
289 req_seen=0; \
290 print (lastline,$1); \
291 } \
292 lastline=$1; \
293 } \
294 } \
295 END { \
296 print "-----END CERTIFICATE REQUEST-----"; \
297 }' > "$FILE".pem < "$FILE".inp
298
299ssleay ca -batch -in "$FILE".pem -key passwd -out "$FILE".out
300ssleay crl2pkcs7 -certfile "$FILE".out -out "$FILE".pkcs7 -in demoCA/crl.pem
301
302sed s/template_for_sessId/$SESSION_ID/ <ms-enroll2a.html >"$FILE".cert
303/usr/local/bin/gawk \
304 'BEGIN { \
305 OFS = ""; \
306 dq = sprintf("%c",34); \
307 } \
308 $0 ~ "PKCS7" { next; } \
309 { \
310 print dq$0dq" & _"; \
311 }' <"$FILE".pkcs7 >> "$FILE".cert
312cat ms-enroll2b.html >>"$FILE".cert
313
314echo Content-type: text/html
315echo Content-length: `wc -c "$FILE".cert`
316echo
317cat "$FILE".cert
318rm -f "$FILE".*
319-----END ms-gencert.cgi-----
320
321----BEGIN ms-enroll2a.html----
322<HTML><HEAD><TITLE>Certificate Acceptance Test Page</TITLE></HEAD><BODY>
323
324<OBJECT
325 classid="clsid:33BEC9E0-F78F-11cf-B782-00C04FD7BF43"
326 codebase=certenr3.dll
327 id=certHelper
328 >
329</OBJECT>
330
331<CENTER>
332<H2>Your personal certificate</H2>
333<BR><HR WIDTH=50%><BR><P>
334Press the button!
335<P><INPUT TYPE=BUTTON VALUE="Nimm mich!" NAME="InstallCert">
336</CENTER>
337<BR><HR WIDTH=50%><BR>
338
339<SCRIPT LANGUAGE=VBS>
340 Sub InstallCert_OnClick
341
342 sessionId = "template_for_sessId"
343credentials = "" & _
344----END ms-enroll2a.html----
345
346----BEGIN ms-enroll2b.html----
347""
348 On Error Resume Next
349 result = certHelper.AcceptCredentials(sessionId, credentials, 0,
350FALSE)
351 if (IsEmpty(result)) Then
352 sz = "The error '" & Err.Number & "' occurred." & chr(13) &
353chr(10) & "This Digital ID could not be registered."
354 msgOut = MsgBox(sz, 0, "Credentials Registration Error")
355 navigate "error.html"
356 else
357 sz = "Digital ID successfully registered."
358 msgOut = MsgBox(sz, 0, "Credentials Registration")
359 navigate "success.html"
360 end if
361 Exit Sub
362 End Sub
363</SCRIPT>
364</BODY>
365</HTML>
366----END ms-enroll2b.html----
367
3684.) What do do with the cert?
369-----------------------------
370
371The cert is visible (without restarting MSIE) under the following menu:
372View->Options->Security->Personal certs. You can examine it's contents at
373least partially.
374
375To use it for client authentication you need to use SSL3.0 (fortunately
376SSLeay supports it with 0.8.0). Furthermore MSIE is told to only supports a
377kind of automatic selection of certs (I personally wasn't able to test it
378myself). But there is a requirement that the issuer of the server cert and
379the issuer of the client cert needs to be the same (according to a developer
380from MS). Which means: you need may more then one cert to talk to all
381servers...
382
383I'm sure we will get a bit more experience after ApacheSSL is available for
384SSLeay 0.8.8.
385
386
387I hope you enjoyed reading and that in future questions on this topic will
388rarely appear on ssl-users@moncom.com ;-)
389
390Ilmenau, 9th of June 1997
391Holger Reif <reif@prakinf.tu-ilmenau.de>
392--
393read you later - Holger Reif
394---------------------------------------- Signaturprojekt Deutsche Einheit
395TU Ilmenau - Informatik - Telematik (Verdamp lang her)
396Holger.Reif@PrakInf.TU-Ilmenau.DE Alt wie ein Baum werden, um ueber
397http://Remus.PrakInf.TU-Ilmenau.DE/Reif/ alle 7 Bruecken gehen zu koennen
398
diff --git a/src/lib/libssl/src/doc/ns-ca.doc b/src/lib/libssl/src/doc/ns-ca.doc
new file mode 100644
index 0000000000..836883e1a0
--- /dev/null
+++ b/src/lib/libssl/src/doc/ns-ca.doc
@@ -0,0 +1,154 @@
1The following documentation was supplied by Jeff Barber, who provided the
2patch to the CA program to add this functionality.
3
4eric
5--
6Jeff Barber Email: jeffb@issl.atl.hp.com
7
8Hewlett Packard Phone: (404) 648-9503
9Internet and System Security Lab Fax: (404) 648-9516
10
11 oo
12---------------------cut /\ here for ns-ca.doc ------------------------------
13
14This document briefly describes how to use SSLeay to implement a
15certificate authority capable of dynamically serving up client
16certificates for version 3.0 beta 5 (and presumably later) versions of
17the Netscape Navigator. Before describing how this is done, it's
18important to understand a little about how the browser implements its
19client certificate support. This is documented in some detail in the
20URLs based at <URL:http://home.netscape.com/eng/security/certs.html>.
21Here's a brief overview:
22
23- The Navigator supports a new HTML tag "KEYGEN" which will cause
24 the browser to generate an RSA key pair when you submit a form
25 containing the tag. The public key, along with an optional
26 challenge (supposedly provided for use in certificate revocation
27 but I don't use it) is signed, DER-encoded, base-64 encoded
28 and sent to the web server as the value of the variable
29 whose NAME is provided in the KEYGEN tag. The private key is
30 stored by the browser in a local key database.
31
32 This "Signed Public Key And Challenge" (SPKAC) arrives formatted
33 into 64 character lines (which are of course URL-encoded when
34 sent via HTTP -- i.e. spaces, newlines and most punctuatation are
35 encoded as "%HH" where HH is the hex equivalent of the ASCII code).
36 Note that the SPKAC does not contain the other usual attributes
37 of a certificate request, especially the subject name fields.
38 These must be otherwise encoded in the form for submission along
39 with the SPKAC.
40
41- Either immediately (in response to this form submission), or at
42 some later date (a real CA will probably verify your identity in
43 some way before issuing the certificate), a web server can send a
44 certificate based on the public key and other attributes back to
45 the browser by encoding it in DER (the binary form) and sending it
46 to the browser as MIME type:
47 "Content-type: application/x-x509-user-cert"
48
49 The browser uses the public key encoded in the certificate to
50 associate the certificate with the appropriate private key in
51 its local key database. Now, the certificate is "installed".
52
53- When a server wants to require authentication based on client
54 certificates, it uses the right signals via the SSL protocol to
55 trigger the Navigator to ask you which certificate you want to
56 send. Whether the certificate is accepted is dependent on CA
57 certificates and so forth installed in the server and is beyond
58 the scope of this document.
59
60
61Now, here's how the SSLeay package can be used to provide client
62certficates:
63
64- You prepare a file for input to the SSLeay ca application.
65 The file contains a number of "name = value" pairs that identify
66 the subject. The names here are the same subject name component
67 identifiers used in the CA section of the lib/ssleay.conf file,
68 such as "emailAddress", "commonName" "organizationName" and so
69 forth. Both the long version and the short version (e.g. "Email",
70 "CN", "O") can be used.
71
72 One more name is supported: this one is "SPKAC". Its value
73 is simply the value of the base-64 encoded SPKAC sent by the
74 browser (with all the newlines and other space charaters
75 removed -- and newline escapes are NOT supported).
76
77 [ As of SSLeay 0.6.4, multiple lines are supported.
78 Put a \ at the end of each line and it will be joined with the
79 previous line with the '\n' removed - eay ]
80
81 Here's a sample input file:
82
83C = US
84SP = Georgia
85O = Some Organization, Inc.
86OU = Netscape Compatibility Group
87CN = John X. Doe
88Email = jxdoe@someorg.com
89SPKAC = MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAwmk6FMJ4uAVIYbcvIOx5+bDGTfvL8X5gE+R67ccMk6rCSGbVQz2cetyQtnI+VIs0NwdD6wjuSuVtVFbLoHonowIDAQABFgAwDQYJKoZIhvcNAQEEBQADQQBFZDUWFl6BJdomtN1Bi53mwijy1rRgJ4YirF15yBEDM3DjAQkKXHYOIX+qpz4KXKnl6EYxTnGSFL5wWt8X2iyx
90
91- You execute the ca command (either from a CGI program run out of
92 the web server, or as a later manual task) giving it the above
93 file as input. For example, if the file were named /tmp/cert.req,
94 you'd run:
95 $SSLDIR/bin/ca -spkac /tmp/cert.req -out /tmp/cert
96
97 The output is in DER format (binary) if a -out argument is
98 provided, as above; otherwise, it's in the PEM format (base-64
99 encoded DER). Also, the "-batch" switch is implied by the
100 "-spkac" so you don't get asked whether to complete the signing
101 (probably it shouldn't work this way but I was only interested
102 in hacking together an online CA that could be used for issuing
103 test certificates).
104
105 The "-spkac" capability doesn't support multiple files (I think).
106
107 Any CHALLENGE provided in the SPKAC is simply ignored.
108
109 The interactions between the identification fields you provide
110 and those identified in your lib/ssleay.conf are the same as if
111 you did an ordinary "ca -in infile -out outfile" -- that is, if
112 something is marked as required in the ssleay.conf file and it
113 isn't found in the -spkac file, the certificate won't be issued.
114
115- Now, you pick up the output from /tmp/cert and pass it back to
116 the Navigator prepending the Content-type string described earlier.
117
118- In order to run the ca command out of a CGI program, you must
119 provide a password to decrypt the CA's private key. You can
120 do this by using "echo MyKeyPassword | $SSLDIR/bin/ca ..."
121 I think there's a way to not encrypt the key file in the first
122 place, but I didn't see how to do that, so I made a small change
123 to the library that allows the password to be accepted from a pipe.
124 Either way is UTTERLY INSECURE and a real CA would never do that.
125
126 [ You can use the 'ssleay rsa' command to remove the password
127 from the private key, or you can use the '-key' option to the
128 ca command to specify the decryption key on the command line
129 or use the -nodes option when generating the key.
130 ca will try to clear the command line version of the password
131 but for quite a few operating systems, this is not possible.
132 - eric ]
133
134So, what do you have to do to make use of this stuff to create an online
135demo CA capability with SSLeay?
136
1371 Create an HTML form for your users. The form should contain
138 fields for all of the required or optional fields in ssleay.conf.
139 The form must contain a KEYGEN tag somewhere with at least a NAME
140 attribute.
141
1422 Create a CGI program to process the form input submitted by the
143 browser. The CGI program must URL-decode the variables and create
144 the file described above, containing subject identification info
145 as well as the SPKAC block. It should then run the the ca program
146 with the -spkac option. If it works (check the exit status),
147 return the new certificate with the appropriate MIME type. If not,
148 return the output of the ca command with MIME type "text/plain".
149
1503 Set up your web server to accept connections signed by your demo
151 CA. This probably involves obtaining the PEM-encoded CA certificate
152 (ordinarily in $SSLDIR/CA/cacert.pem) and installing it into a
153 server database. See your server manual for instructions.
154
diff --git a/src/lib/libssl/src/doc/obj.doc b/src/lib/libssl/src/doc/obj.doc
new file mode 100644
index 0000000000..bad347c936
--- /dev/null
+++ b/src/lib/libssl/src/doc/obj.doc
@@ -0,0 +1,69 @@
1The Object library.
2
3As part of my Crypto library, I found I required a method of identifying various
4objects. These objects normally had 3 different values associated with
5them, a short text name, a long (or lower case) text name, and an
6ASN.1 Object Identifier (which is a sequence of numbers).
7This library contains a static list of objects and functions to lookup
8according to one type and to return the other types.
9
10To use these routines, 'Object.h' needs to be included.
11
12For each supported object, #define entries are defined as follows
13#define SN_Algorithm "Algorithm"
14#define LN_algorithm "algorithm"
15#define NID_algorithm 38
16#define OBJ_algorithm 1L,3L,14L,3L,2L
17
18SN_ stands for short name.
19LN_ stands for either long name or lowercase name.
20NID_ stands for Numeric ID. I each object has a unique NID and this
21 should be used internally to identify objects.
22OBJ_ stands for ASN.1 Object Identifier or ASN1_OBJECT as defined in the
23 ASN1 routines. These values are used in ASN1 encoding.
24
25The following functions are to be used to return pointers into a static
26definition of these types. What this means is "don't try to free() any
27pointers returned from these functions.
28
29ASN1_OBJECT *OBJ_nid2obj(
30int n);
31 Return the ASN1_OBJECT that corresponds to a NID of n.
32
33char *OBJ_nid2ln(
34int n);
35 Return the long/lower case name of the object represented by the
36 NID of n.
37
38char *OBJ_nid2sn(
39int n);
40 Return the short name for the object represented by the NID of n.
41
42ASN1_OBJECT *OBJ_dup(
43ASN1_OBJECT *o);
44 Duplicate and return a new ASN1_OBJECT that is the same as the
45 passed parameter.
46
47int OBJ_obj2nid(
48ASN1_OBJECT *o);
49 Given ASN1_OBJECT o, return the NID that corresponds.
50
51int OBJ_ln2nid(
52char *s);
53 Given the long/lower case name 's', return the NID of the object.
54
55int OBJ_sn2nid(
56char *s);
57 Given the short name 's', return the NID of the object.
58
59char *OBJ_bsearch(
60char *key,
61char *base,
62int num,
63int size,
64int (*cmp)());
65 Since I have come across a few platforms that do not have the
66 bsearch() function, OBJ_bsearch is my version of that function.
67 Feel free to use this function, but you may as well just use the
68 normal system bsearch(3) if it is present. This version also
69 has tolerance of being passed NULL pointers.
diff --git a/src/lib/libssl/src/doc/rand.doc b/src/lib/libssl/src/doc/rand.doc
new file mode 100644
index 0000000000..da02a07f64
--- /dev/null
+++ b/src/lib/libssl/src/doc/rand.doc
@@ -0,0 +1,141 @@
1My Random number library.
2
3These routines can be used to generate pseudo random numbers and can be
4used to 'seed' the pseudo random number generator (RNG). The RNG make no
5effort to reproduce the same random number stream with each execution.
6Various other routines in the SSLeay library 'seed' the RNG when suitable
7'random' input data is available. Read the section at the end for details
8on the design of the RNG.
9
10void RAND_bytes(
11unsigned char *buf,
12int num);
13 This routine puts 'num' random bytes into 'buf'. One should make
14 sure RAND_seed() has been called before using this routine.
15
16void RAND_seed(
17unsigned char *buf,
18int num);
19 This routine adds more 'seed' data the RNG state. 'num' bytes
20 are added to the RNG state, they are taken from 'buf'. This
21 routine can be called with sensitive data such as user entered
22 passwords. This sensitive data is in no way recoverable from
23 the RAND library routines or state. Try to pass as much data
24 from 'random' sources as possible into the RNG via this function.
25 Also strongly consider using the RAND_load_file() and
26 RAND_write_file() routines.
27
28void RAND_cleanup();
29 When a program has finished with the RAND library, if it so
30 desires, it can 'zero' all RNG state.
31
32The following 3 routines are convenience routines that can be used to
33'save' and 'restore' data from/to the RNG and it's state.
34Since the more 'random' data that is feed as seed data the better, why not
35keep it around between executions of the program? Of course the
36application should pass more 'random' data in via RAND_seed() and
37make sure no-one can read the 'random' data file.
38
39char *RAND_file_name(
40char *buf,
41int size);
42 This routine returns a 'default' name for the location of a 'rand'
43 file. The 'rand' file should keep a sequence of random bytes used
44 to initialise the RNG. The filename is put in 'buf'. Buf is 'size'
45 bytes long. Buf is returned if things go well, if they do not,
46 NULL is returned. The 'rand' file name is generated in the
47 following way. First, if there is a 'RANDFILE' environment
48 variable, it is returned. Second, if there is a 'HOME' environment
49 variable, $HOME/.rand is returned. Third, NULL is returned. NULL
50 is also returned if a buf would overflow.
51
52int RAND_load_file(
53char *file,
54long number);
55 This function 'adds' the 'file' into the RNG state. It does this by
56 doing a RAND_seed() on the value returned from a stat() system call
57 on the file and if 'number' is non-zero, upto 'number' bytes read
58 from the file. The number of bytes passed to RAND_seed() is returned.
59
60int RAND_write_file(
61char *file),
62 RAND_write_file() writes N random bytes to the file 'file', where
63 N is the size of the internal RND state (currently 1k).
64 This is a suitable method of saving RNG state for reloading via
65 RAND_load_file().
66
67What follows is a description of this RNG and a description of the rational
68behind it's design.
69
70It should be noted that this RNG is intended to be used to generate
71'random' keys for various ciphers including generation of DH and RSA keys.
72
73It should also be noted that I have just created a system that I am happy with.
74It may be overkill but that does not worry me. I have not spent that much
75time on this algorithm so if there are glaring errors, please let me know.
76Speed has not been a consideration in the design of these routines.
77
78First up I will state the things I believe I need for a good RNG.
791) A good hashing algorithm to mix things up and to convert the RNG 'state'
80 to random numbers.
812) An initial source of random 'state'.
823) The state should be very large. If the RNG is being used to generate
83 4096 bit RSA keys, 2 2048 bit random strings are required (at a minimum).
84 If your RNG state only has 128 bits, you are obviously limiting the
85 search space to 128 bits, not 2048. I'm probably getting a little
86 carried away on this last point but it does indicate that it may not be
87 a bad idea to keep quite a lot of RNG state. It should be easier to
88 break a cipher than guess the RNG seed data.
894) Any RNG seed data should influence all subsequent random numbers
90 generated. This implies that any random seed data entered will have
91 an influence on all subsequent random numbers generated.
925) When using data to seed the RNG state, the data used should not be
93 extractable from the RNG state. I believe this should be a
94 requirement because one possible source of 'secret' semi random
95 data would be a private key or a password. This data must
96 not be disclosed by either subsequent random numbers or a
97 'core' dump left by a program crash.
986) Given the same initial 'state', 2 systems should deviate in their RNG state
99 (and hence the random numbers generated) over time if at all possible.
1007) Given the random number output stream, it should not be possible to determine
101 the RNG state or the next random number.
102
103
104The algorithm is as follows.
105
106There is global state made up of a 1023 byte buffer (the 'state'), a
107working message digest ('md') and a counter ('count').
108
109Whenever seed data is added, it is inserted into the 'state' as
110follows.
111 The input is chopped up into units of 16 bytes (or less for
112 the last block). Each of these blocks is run through the MD5
113 message digest. The data passed to the MD5 digest is the
114 current 'md', the same number of bytes from the 'state'
115 (the location determined by in incremented looping index) as
116 the current 'block' and the new key data 'block'. The result
117 of this is kept in 'md' and also xored into the 'state' at the
118 same locations that were used as input into the MD5.
119 I believe this system addresses points 1 (MD5), 3 (the 'state'),
120 4 (via the 'md'), 5 (by the use of MD5 and xor).
121
122When bytes are extracted from the RNG, the following process is used.
123For each group of 8 bytes (or less), we do the following,
124 Input into MD5, the top 8 bytes from 'md', the byte that are
125 to be overwritten by the random bytes and bytes from the
126 'state' (incrementing looping index). From this digest output
127 (which is kept in 'md'), the top (upto) 8 bytes are
128 returned to the caller and the bottom (upto) 8 bytes are xored
129 into the 'state'.
130 Finally, after we have finished 'generation' random bytes for the
131 called, 'count' (which is incremented) and 'md' are fed into MD5 and
132 the results are kept in 'md'.
133 I believe the above addressed points 1 (use of MD5), 6 (by
134 hashing into the 'state' the 'old' data from the caller that
135 is about to be overwritten) and 7 (by not using the 8 bytes
136 given to the caller to update the 'state', but they are used
137 to update 'md').
138
139So of the points raised, only 2 is not addressed, but sources of
140random data will always be a problem.
141
diff --git a/src/lib/libssl/src/doc/rc2.doc b/src/lib/libssl/src/doc/rc2.doc
new file mode 100644
index 0000000000..efab015bd1
--- /dev/null
+++ b/src/lib/libssl/src/doc/rc2.doc
@@ -0,0 +1,165 @@
1The RC2 library.
2
3RC2 is a block cipher that operates on 64bit (8 byte) quantities. It
4uses variable size key, but 128bit (16 byte) key would normally be considered
5good. It can be used in all the modes that DES can be used. This
6library implements the ecb, cbc, cfb64, ofb64 modes.
7
8I have implemented this library from an article posted to sci.crypt on
911-Feb-1996. I personally don't know how far to trust the RC2 cipher.
10While it is capable of having a key of any size, not much reseach has
11publically been done on it at this point in time (Apr-1996)
12since the cipher has only been public for a few months :-)
13It is of a similar speed to DES and IDEA, so unless it is required for
14meeting some standard (SSLv2, perhaps S/MIME), it would probably be advisable
15to stick to IDEA, or for the paranoid, Tripple DES.
16
17Mind you, having said all that, I should mention that I just read alot and
18implement ciphers, I'm a 'babe in the woods' when it comes to evaluating
19ciphers :-).
20
21For all calls that have an 'input' and 'output' variables, they can be the
22same.
23
24This library requires the inclusion of 'rc2.h'.
25
26All of the encryption functions take what is called an RC2_KEY as an
27argument. An RC2_KEY is an expanded form of the RC2 key.
28For all modes of the RC2 algorithm, the RC2_KEY used for
29decryption is the same one that was used for encryption.
30
31The define RC2_ENCRYPT is passed to specify encryption for the functions
32that require an encryption/decryption flag. RC2_DECRYPT is passed to
33specify decryption.
34
35Please note that any of the encryption modes specified in my DES library
36could be used with RC2. I have only implemented ecb, cbc, cfb64 and
37ofb64 for the following reasons.
38- ecb is the basic RC2 encryption.
39- cbc is the normal 'chaining' form for block ciphers.
40- cfb64 can be used to encrypt single characters, therefore input and output
41 do not need to be a multiple of 8.
42- ofb64 is similar to cfb64 but is more like a stream cipher, not as
43 secure (not cipher feedback) but it does not have an encrypt/decrypt mode.
44- If you want triple RC2, thats 384 bits of key and you must be totally
45 obsessed with security. Still, if you want it, it is simple enough to
46 copy the function from the DES library and change the des_encrypt to
47 RC2_encrypt; an exercise left for the paranoid reader :-).
48
49The functions are as follows:
50
51void RC2_set_key(
52RC2_KEY *ks;
53int len;
54unsigned char *key;
55int bits;
56 RC2_set_key converts an 'len' byte key into a RC2_KEY.
57 A 'ks' is an expanded form of the 'key' which is used to
58 perform actual encryption. It can be regenerated from the RC2 key
59 so it only needs to be kept when encryption or decryption is about
60 to occur. Don't save or pass around RC2_KEY's since they
61 are CPU architecture dependent, 'key's are not. RC2 is an
62 interesting cipher in that it can be used with a variable length
63 key. 'len' is the length of 'key' to be used as the key.
64 A 'len' of 16 is recomended. The 'bits' argument is an
65 interesting addition which I only found out about in Aug 96.
66 BSAFE uses this parameter to 'limit' the number of bits used
67 for the key. To use the 'key' unmodified, set bits to 1024.
68 This is what old versions of my RC2 library did (SSLeay 0.6.3).
69 RSAs BSAFE library sets this parameter to be 128 if 128 bit
70 keys are being used. So to be compatable with BSAFE, set it
71 to 128, if you don't want to reduce RC2's key length, leave it
72 at 1024.
73
74void RC2_encrypt(
75unsigned long *data,
76RC2_KEY *key,
77int encrypt);
78 This is the RC2 encryption function that gets called by just about
79 every other RC2 routine in the library. You should not use this
80 function except to implement 'modes' of RC2. I say this because the
81 functions that call this routine do the conversion from 'char *' to
82 long, and this needs to be done to make sure 'non-aligned' memory
83 access do not occur.
84 Data is a pointer to 2 unsigned long's and key is the
85 RC2_KEY to use. Encryption or decryption is indicated by 'encrypt'.
86 which can have the values RC2_ENCRYPT or RC2_DECRYPT.
87
88void RC2_ecb_encrypt(
89unsigned char *in,
90unsigned char *out,
91RC2_KEY *key,
92int encrypt);
93 This is the basic Electronic Code Book form of RC2 (in DES this
94 mode is called Electronic Code Book so I'm going to use the term
95 for rc2 as well.
96 Input is encrypted into output using the key represented by
97 key. Depending on the encrypt, encryption or
98 decryption occurs. Input is 8 bytes long and output is 8 bytes.
99
100void RC2_cbc_encrypt(
101unsigned char *in,
102unsigned char *out,
103long length,
104RC2_KEY *ks,
105unsigned char *ivec,
106int encrypt);
107 This routine implements RC2 in Cipher Block Chaining mode.
108 Input, which should be a multiple of 8 bytes is encrypted
109 (or decrypted) to output which will also be a multiple of 8 bytes.
110 The number of bytes is in length (and from what I've said above,
111 should be a multiple of 8). If length is not a multiple of 8, bad
112 things will probably happen. ivec is the initialisation vector.
113 This function updates iv after each call so that it can be passed to
114 the next call to RC2_cbc_encrypt().
115
116void RC2_cfb64_encrypt(
117unsigned char *in,
118unsigned char *out,
119long length,
120RC2_KEY *schedule,
121unsigned char *ivec,
122int *num,
123int encrypt);
124 This is one of the more useful functions in this RC2 library, it
125 implements CFB mode of RC2 with 64bit feedback.
126 This allows you to encrypt an arbitrary number of bytes,
127 you do not require 8 byte padding. Each call to this
128 routine will encrypt the input bytes to output and then update ivec
129 and num. Num contains 'how far' we are though ivec.
130 'Encrypt' is used to indicate encryption or decryption.
131 CFB64 mode operates by using the cipher to generate a stream
132 of bytes which is used to encrypt the plain text.
133 The cipher text is then encrypted to generate the next 64 bits to
134 be xored (incrementally) with the next 64 bits of plain
135 text. As can be seen from this, to encrypt or decrypt,
136 the same 'cipher stream' needs to be generated but the way the next
137 block of data is gathered for encryption is different for
138 encryption and decryption.
139
140void RC2_ofb64_encrypt(
141unsigned char *in,
142unsigned char *out,
143long length,
144RC2_KEY *schedule,
145unsigned char *ivec,
146int *num);
147 This functions implements OFB mode of RC2 with 64bit feedback.
148 This allows you to encrypt an arbitrary number of bytes,
149 you do not require 8 byte padding. Each call to this
150 routine will encrypt the input bytes to output and then update ivec
151 and num. Num contains 'how far' we are though ivec.
152 This is in effect a stream cipher, there is no encryption or
153 decryption mode.
154
155For reading passwords, I suggest using des_read_pw_string() from my DES library.
156To generate a password from a text string, I suggest using MD5 (or MD2) to
157produce a 16 byte message digest that can then be passed directly to
158RC2_set_key().
159
160=====
161For more information about the specific RC2 modes in this library
162(ecb, cbc, cfb and ofb), read the section entitled 'Modes of DES' from the
163documentation on my DES library. What is said about DES is directly
164applicable for RC2.
165
diff --git a/src/lib/libssl/src/doc/rc4.doc b/src/lib/libssl/src/doc/rc4.doc
new file mode 100644
index 0000000000..4b2897eb74
--- /dev/null
+++ b/src/lib/libssl/src/doc/rc4.doc
@@ -0,0 +1,44 @@
1The RC4 library.
2RC4 is a stream cipher that operates on a byte stream. It can be used with
3any length key but I would recommend normally using 16 bytes.
4
5This library requires the inclusion of 'rc4.h'.
6
7The RC4 encryption function takes what is called an RC4_KEY as an argument.
8The RC4_KEY is generated by the RC4_set_key function from the key bytes.
9
10RC4, being a stream cipher, does not have an encryption or decryption mode.
11It produces a stream of bytes that the input stream is xor'ed against and
12so decryption is just a case of 'encrypting' again with the same key.
13
14I have only put in one 'mode' for RC4 which is the normal one. This means
15there is no initialisation vector and there is no feedback of the cipher
16text into the cipher. This implies that you should not ever use the
17same key twice if you can help it. If you do, you leave yourself open to
18known plain text attacks; if you know the plain text and
19corresponding cipher text in one message, all messages that used the same
20key can have the cipher text decoded for the corresponding positions in the
21cipher stream.
22
23The main positive feature of RC4 is that it is a very fast cipher; about 4
24times faster that DES. This makes it ideally suited to protocols where the
25key is randomly chosen, like SSL.
26
27The functions are as follows:
28
29void RC4_set_key(
30RC4_KEY *key;
31int len;
32unsigned char *data);
33 This function initialises the RC4_KEY structure with the key passed
34 in 'data', which is 'len' bytes long. The key data can be any
35 length but 16 bytes seems to be a good number.
36
37void RC4(
38RC4_KEY *key;
39unsigned long len;
40unsigned char *in;
41unsigned char *out);
42 Do the actual RC4 encryption/decryption. Using the 'key', 'len'
43 bytes are transformed from 'in' to 'out'. As mentioned above,
44 decryption is the operation as encryption.
diff --git a/src/lib/libssl/src/doc/readme b/src/lib/libssl/src/doc/readme
new file mode 100644
index 0000000000..824d4fd0e2
--- /dev/null
+++ b/src/lib/libssl/src/doc/readme
@@ -0,0 +1,6 @@
1This is the old 0.6.6 docuementation. Most of the cipher stuff is still
2relevent but I'm working (very slowly) on new docuemtation.
3The current version can be found online at
4
5http://www.cryptsoft.com/ssleay/doc
6
diff --git a/src/lib/libssl/src/doc/ref.doc b/src/lib/libssl/src/doc/ref.doc
new file mode 100644
index 0000000000..211559900d
--- /dev/null
+++ b/src/lib/libssl/src/doc/ref.doc
@@ -0,0 +1,48 @@
1I have lots more references etc, and will update this list in the future,
230 Aug 1996 - eay
3
4
5SSL The SSL Protocol - from Netscapes.
6
7RC4 Newsgroups: sci.crypt
8 From: sterndark@netcom.com (David Sterndark)
9 Subject: RC4 Algorithm revealed.
10 Message-ID: <sternCvKL4B.Hyy@netcom.com>
11
12RC2 Newsgroups: sci.crypt
13 From: pgut01@cs.auckland.ac.nz (Peter Gutmann)
14 Subject: Specification for Ron Rivests Cipher No.2
15 Message-ID: <4fk39f$f70@net.auckland.ac.nz>
16
17MD2 RFC1319 The MD2 Message-Digest Algorithm
18MD5 RFC1321 The MD5 Message-Digest Algorithm
19
20X509 Certificates
21 RFC1421 Privacy Enhancement for Internet Electronic Mail: Part I
22 RFC1422 Privacy Enhancement for Internet Electronic Mail: Part II
23 RFC1423 Privacy Enhancement for Internet Electronic Mail: Part III
24 RFC1424 Privacy Enhancement for Internet Electronic Mail: Part IV
25
26RSA and various standard encoding
27 PKCS#1 RSA Encryption Standard
28 PKCS#5 Password-Based Encryption Standard
29 PKCS#7 Cryptographic Message Syntax Standard
30 A Layman's Guide to a Subset of ASN.1, BER, and DER
31 An Overview of the PKCS Standards
32 Some Examples of the PKCS Standards
33
34IDEA Chapter 3 The Block Cipher IDEA
35
36RSA, prime number generation and bignum algorithms
37 Introduction To Algorithms,
38 Thomas Cormen, Charles Leiserson, Ronald Rivest,
39 Section 29 Arithmetic Circuits
40 Section 33 Number-Theoretic Algorithms
41
42Fast Private Key algorithm
43 Fast Decipherment Algorithm for RSA Public-Key Cryptosystem
44 J.-J. Quisquater and C. Couvreur, Electronics Letters,
45 14th October 1982, Vol. 18 No. 21
46
47Prime number generation and bignum algorithms.
48 PGP-2.3a
diff --git a/src/lib/libssl/src/doc/req.1 b/src/lib/libssl/src/doc/req.1
new file mode 100644
index 0000000000..684fda580e
--- /dev/null
+++ b/src/lib/libssl/src/doc/req.1
@@ -0,0 +1,137 @@
1The 'req' command is used to manipulate and deal with pkcs#10
2certificate requests.
3
4It's default mode of operation is to load a certificate and then
5write it out again.
6
7By default the 'req' is read from stdin in 'PEM' format.
8The -inform option can be used to specify 'pem' format or 'der'
9format. PEM format is the base64 encoding of the DER format.
10
11By default 'req' then writes the request back out. -outform can be used
12to indicate the desired output format, be it 'pem' or 'der'.
13
14To specify an input file, use the '-in' option and the '-out' option
15can be used to specify the output file.
16
17If you wish to perform a command and not output the certificate
18request afterwards, use the '-noout' option.
19
20When a certificate is loaded, it can be printed in a human readable
21ascii format via the '-text' option.
22
23To check that the signature on a certificate request is correct, use
24the '-verify' option to make sure that the private key contained in the
25certificate request corresponds to the signature.
26
27Besides the default mode, there is also the 'generate a certificate
28request' mode. There are several flags that trigger this mode.
29
30-new will generate a new RSA key (if required) and then prompts
31the user for details for the certificate request.
32-newkey has an argument that is the number of bits to make the new
33key. This function also triggers '-new'.
34
35The '-new' option can have a key to use specified instead of having to
36load one, '-key' is used to specify the file containg the key.
37-keyform can be used to specify the format of the key. Only
38'pem' and 'der' formats are supported, later, 'netscape' format may be added.
39
40Finally there is the '-x509' options which makes req output a self
41signed x509 certificate instead of a certificate request.
42
43Now as you may have noticed, there are lots of default options that
44cannot be specified via the command line. They are held in a 'template'
45or 'configuration file'. The -config option specifies which configuration
46file to use. See conf.doc for details on the syntax of this file.
47
48The req command uses the 'req' section of the config file.
49
50---
51# The following variables are defined. For this example I will populate
52# the various values
53[ req ]
54default_bits = 512 # default number of bits to use.
55default_keyfile = testkey.pem # Where to write the generated keyfile
56 # if not specified.
57distinguished_name= req_dn # The section that contains the
58 # information about which 'object' we
59 # want to put in the DN.
60attributes = req_attr # The objects we want for the
61 # attributes field.
62encrypt_rsa_key = no # Should we encrypt newly generated
63 # keys. I strongly recommend 'yes'.
64
65# The distinguished name section. For the following entries, the
66# object names must exist in the SSLeay header file objects.h. If they
67# do not, they will be silently ignored. The entries have the following
68# format.
69# <object_name> => string to prompt with
70# <object_name>_default => default value for people
71# <object_name>_value => Automatically use this value for this field.
72# <object_name>_min => minimum number of characters for data (def. 0)
73# <object_name>_max => maximum number of characters for data (def. inf.)
74# All of these entries are optional except for the first one.
75[ req_dn ]
76countryName = Country Name (2 letter code)
77countryName_default = AU
78
79stateOrProvinceName = State or Province Name (full name)
80stateOrProvinceName_default = Queensland
81
82localityName = Locality Name (eg, city)
83
84organizationName = Organization Name (eg, company)
85organizationName_default = Mincom Pty Ltd
86
87organizationalUnitName = Organizational Unit Name (eg, section)
88organizationalUnitName_default = MTR
89
90commonName = Common Name (eg, YOUR name)
91commonName_max = 64
92
93emailAddress = Email Address
94emailAddress_max = 40
95
96# The next section is the attributes section. This is exactly the
97# same as for the previous section except that the resulting objects are
98# put in the attributes field.
99[ req_attr ]
100challengePassword = A challenge password
101challengePassword_min = 4
102challengePassword_max = 20
103
104unstructuredName = An optional company name
105
106----
107Also note that the order that attributes appear in this file is the
108order they will be put into the distinguished name.
109
110Once this request has been generated, it can be sent to a CA for
111certifying.
112
113----
114A few quick examples....
115
116To generate a new request and a new key
117req -new
118
119To generate a new request and a 1058 bit key
120req -newkey 1058
121
122To generate a new request using a pre-existing key
123req -new -key key.pem
124
125To generate a self signed x509 certificate from a certificate
126request using a supplied key, and we want to see the text form of the
127output certificate (which we will put in the file selfSign.pem
128req -x509 -in req.pem -key key.pem -text -out selfSign.pem
129
130Verify that the signature is correct on a certificate request.
131req -verify -in req.pem
132
133Verify that the signature was made using a specified public key.
134req -verify -in req.pem -key key.pem
135
136Print the contents of a certificate request
137req -text -in req.pem
diff --git a/src/lib/libssl/src/doc/rsa.doc b/src/lib/libssl/src/doc/rsa.doc
new file mode 100644
index 0000000000..f260452bc6
--- /dev/null
+++ b/src/lib/libssl/src/doc/rsa.doc
@@ -0,0 +1,135 @@
1The RSA encryption and utility routines.
2
3The RSA routines are built on top of a big number library (the BN library).
4There are support routines in the X509 library for loading and manipulating
5the various objects in the RSA library. When errors are returned, read
6about the ERR library for how to access the error codes.
7
8All RSA encryption is done according to the PKCS-1 standard which is
9compatible with PEM and RSAref. This means that any values being encrypted
10must be less than the size of the modulus in bytes, minus 10, bytes long.
11
12This library uses RAND_bytes()() for it's random data, make sure to feed
13RAND_seed() with lots of interesting and varied data before using these
14routines.
15
16The RSA library has one specific data type, the RSA structure.
17It is composed of 8 BIGNUM variables (see the BN library for details) and
18can hold either a private RSA key or a public RSA key.
19Some RSA libraries have different structures for public and private keys, I
20don't. For my libraries, a public key is determined by the fact that the
21RSA->d value is NULL. These routines will operate on any size RSA keys.
22While I'm sure 4096 bit keys are very very secure, they take a lot longer
23to process that 1024 bit keys :-).
24
25The function in the RSA library are as follows.
26
27RSA *RSA_new();
28 This function creates a new RSA object. The sub-fields of the RSA
29 type are also malloced so you should always use this routine to
30 create RSA variables.
31
32void RSA_free(
33RSA *rsa);
34 This function 'frees' an RSA structure. This routine should always
35 be used to free the RSA structure since it will also 'free' any
36 sub-fields of the RSA type that need freeing.
37
38int RSA_size(
39RSA *rsa);
40 This function returns the size of the RSA modulus in bytes. Why do
41 I need this you may ask, well the reason is that when you encrypt
42 with RSA, the output string will be the size of the RSA modulus.
43 So the output for the RSA_encrypt and the input for the RSA_decrypt
44 routines need to be RSA_size() bytes long, because this is how many
45 bytes are expected.
46
47For the following 4 RSA encryption routines, it should be noted that
48RSA_private_decrypt() should be used on the output from
49RSA_public_encrypt() and RSA_public_decrypt() should be used on
50the output from RSA_private_encrypt().
51
52int RSA_public_encrypt(
53int from_len;
54unsigned char *from
55unsigned char *to
56RSA *rsa);
57 This function implements RSA public encryption, the rsa variable
58 should be a public key (but can be a private key). 'from_len'
59 bytes taken from 'from' and encrypted and put into 'to'. 'to' needs
60 to be at least RSA_size(rsa) bytes long. The number of bytes
61 written into 'to' is returned. -1 is returned on an error. The
62 operation performed is
63 to = from^rsa->e mod rsa->n.
64
65int RSA_private_encrypt(
66int from_len;
67unsigned char *from
68unsigned char *to
69RSA *rsa);
70 This function implements RSA private encryption, the rsa variable
71 should be a private key. 'from_len' bytes taken from
72 'from' and encrypted and put into 'to'. 'to' needs
73 to be at least RSA_size(rsa) bytes long. The number of bytes
74 written into 'to' is returned. -1 is returned on an error. The
75 operation performed is
76 to = from^rsa->d mod rsa->n.
77
78int RSA_public_decrypt(
79int from_len;
80unsigned char *from
81unsigned char *to
82RSA *rsa);
83 This function implements RSA public decryption, the rsa variable
84 should be a public key (but can be a private key). 'from_len'
85 bytes are taken from 'from' and decrypted. The decrypted data is
86 put into 'to'. The number of bytes encrypted is returned. -1 is
87 returned to indicate an error. The operation performed is
88 to = from^rsa->e mod rsa->n.
89
90int RSA_private_decrypt(
91int from_len;
92unsigned char *from
93unsigned char *to
94RSA *rsa);
95 This function implements RSA private decryption, the rsa variable
96 should be a private key. 'from_len' bytes are taken
97 from 'from' and decrypted. The decrypted data is
98 put into 'to'. The number of bytes encrypted is returned. -1 is
99 returned to indicate an error. The operation performed is
100 to = from^rsa->d mod rsa->n.
101
102int RSA_mod_exp(
103BIGNUM *n;
104BIGNUM *p;
105RSA *rsa);
106 Normally you will never use this routine.
107 This is really an internal function which is called by
108 RSA_private_encrypt() and RSA_private_decrypt(). It performs
109 n=n^p mod rsa->n except that it uses the 5 extra variables in the
110 RSA structure to make this more efficient.
111
112RSA *RSA_generate_key(
113int bits;
114unsigned long e;
115void (*callback)();
116char *cb_arg;
117 This routine is used to generate RSA private keys. It takes
118 quite a period of time to run and should only be used to
119 generate initial private keys that should then be stored
120 for later use. The passed callback function
121 will be called periodically so that feedback can be given
122 as to how this function is progressing.
123 'bits' is the length desired for the modulus, so it would be 1024
124 to generate a 1024 bit private key.
125 'e' is the value to use for the public exponent 'e'. Traditionally
126 it is set to either 3 or 0x10001.
127 The callback function (if not NULL) is called in the following
128 situations.
129 when we have generated a suspected prime number to test,
130 callback(0,num1++,cb_arg). When it passes a prime number test,
131 callback(1,num2++,cb_arg). When it is rejected as one of
132 the 2 primes required due to gcd(prime,e value) != 0,
133 callback(2,num3++,cb_arg). When finally accepted as one
134 of the 2 primes, callback(3,num4++,cb_arg).
135
diff --git a/src/lib/libssl/src/doc/rsaref.doc b/src/lib/libssl/src/doc/rsaref.doc
new file mode 100644
index 0000000000..0505b76f76
--- /dev/null
+++ b/src/lib/libssl/src/doc/rsaref.doc
@@ -0,0 +1,35 @@
1This package can be compiled to use the RSAref library.
2This library is not allowed outside of the USA but inside the USA it is
3claimed by RSA to be the only RSA public key library that can be used
4besides BSAFE..
5
6There are 2 files, rsaref/rsaref.c and rsaref/rsaref.h that contain the glue
7code to use RSAref. These files were written by looking at the PGP
8source code and seeing which routines it used to access RSAref.
9I have also been sent by some-one a copy of the RSAref header file that
10contains the library error codes.
11
12[ Jun 1996 update - I have recently gotten hold of RSAref 2.0 from
13 South Africa and have been doing some performace tests. ]
14
15They have now been tested against the recently announced RSAEURO
16library.
17
18There are 2 ways to use SSLeay and RSAref. First, to build so that
19the programs must be linked with RSAref, add '-DRSAref' to CFLAG in the top
20level makefile and -lrsaref (or where ever you are keeping RSAref) to
21EX_LIBS.
22
23To build a makefile via util/mk1mf.pl to do this, use the 'rsaref' option.
24
25The second method is to build as per normal and link applications with
26the RSAglue library. The correct library order would be
27cc -o cmd cmd.o -lssl -lRSAglue -lcrypto -lrsaref -ldes
28The RSAglue library is built in the rsa directory and is NOT
29automatically installed.
30
31Be warned that the RSAEURO library, that is claimed to be compatible
32with RSAref contains a different value for the maximum number of bits
33supported. This changes structure sizes and so if you are using
34RSAEURO, change the value of RSAref_MAX_BITS in rsa/rsaref.h
35
diff --git a/src/lib/libssl/src/doc/s_mult.doc b/src/lib/libssl/src/doc/s_mult.doc
new file mode 100644
index 0000000000..726085bc57
--- /dev/null
+++ b/src/lib/libssl/src/doc/s_mult.doc
@@ -0,0 +1,17 @@
1s_mult is a test program I hacked up on a Sunday for testing non-blocking
2IO. It has a select loop at it's centre that handles multiple readers
3and writers.
4
5Try the following command
6ssleay s_mult -echo -nbio -ssl -v
7echo - sends any sent text back to the sender
8nbio - turns on non-blocking IO
9ssl - accept SSL connections, default is normal text
10v - print lots
11 type Q<cr> to quit
12
13In another window, run the following
14ssleay s_client -pause </etc/termcap
15
16The pause option puts in a 1 second pause in each read(2)/write(2) call
17so the other end will have read()s fail.
diff --git a/src/lib/libssl/src/doc/session.doc b/src/lib/libssl/src/doc/session.doc
new file mode 100644
index 0000000000..ffccb0306e
--- /dev/null
+++ b/src/lib/libssl/src/doc/session.doc
@@ -0,0 +1,297 @@
1I have just checked over and re-worked the session stuff.
2The following brief example will ignore all setup information to do with
3authentication.
4
5Things operate as follows.
6
7The SSL environment has a 'context', a SSL_CTX structure. This holds the
8cached SSL_SESSIONS (which can be reused) and the certificate lookup
9information. Each SSL structure needs to be associated with a SSL_CTX.
10Normally only one SSL_CTX structure is needed per program.
11
12SSL_CTX *SSL_CTX_new(void );
13void SSL_CTX_free(SSL_CTX *);
14These 2 functions create and destroy SSL_CTX structures
15
16The SSL_CTX has a session_cache_mode which is by default,
17in SSL_SESS_CACHE_SERVER mode. What this means is that the library
18will automatically add new session-id's to the cache apon sucsessful
19SSL_accept() calls.
20If SSL_SESS_CACHE_CLIENT is set, then client certificates are also added
21to the cache.
22SSL_set_session_cache_mode(ctx,mode) will set the 'mode' and
23SSL_get_session_cache_mode(ctx) will get the cache 'mode'.
24The modes can be
25SSL_SESS_CACHE_OFF - no caching
26SSL_SESS_CACHE_CLIENT - only SSL_connect()
27SSL_SESS_CACHE_SERVER - only SSL_accept()
28SSL_SESS_NO_CACHE_BOTH - Either SSL_accept() or SSL_connect().
29If SSL_SESS_CACHE_NO_AUTO_CLEAR is set, old timed out sessions are
30not automatically removed each 255, SSL_connect()s or SSL_accept()s.
31
32By default, apon every 255 successful SSL_connect() or SSL_accept()s,
33the cache is flush. Please note that this could be expensive on
34a heavily loaded SSL server, in which case, turn this off and
35clear the cache of old entries 'manually' (with one of the functions
36listed below) every few hours. Perhaps I should up this number, it is hard
37to say. Remember, the '255' new calls is just a mechanims to get called
38every now and then, in theory at most 255 new session-id's will have been
39added but if 100 are added every minute, you would still have
40500 in the cache before any would start being flushed (assuming a 3 minute
41timeout)..
42
43int SSL_CTX_sess_hits(SSL_CTX *ctx);
44int SSL_CTX_sess_misses(SSL_CTX *ctx);
45int SSL_CTX_sess_timeouts(SSL_CTX *ctx);
46These 3 functions return statistics about the SSL_CTX. These 3 are the
47number of session id reuses. hits is the number of reuses, misses are the
48number of lookups that failed, and timeouts is the number of cached
49entries ignored because they had timeouted.
50
51ctx->new_session_cb is a function pointer to a function of type
52int new_session_callback(SSL *ssl,SSL_SESSION *new);
53This function, if set in the SSL_CTX structure is called whenever a new
54SSL_SESSION is added to the cache. If the callback returns non-zero, it
55means that the application will have to do a SSL_SESSION_free()
56on the structure (this is
57to do with the cache keeping the reference counts correct, without the
58application needing to know about it.
59The 'active' parameter is the current SSL session for which this connection
60was created.
61
62void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx,int (*cb)());
63to set the callback,
64int (*cb)() SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)
65to get the callback.
66
67If the 'get session' callback is set, when a session id is looked up and
68it is not in the session-id cache, this callback is called. The callback is
69of the form
70SSL_SESSION *get_session_callback(unsigned char *sess_id,int sess_id_len,
71 int *copy);
72
73The get_session_callback is intended to return null if no session id is found.
74The reference count on the SSL_SESSION in incremented by the SSL library,
75if copy is 1. Otherwise, the reference count is not modified.
76
77void SSL_CTX_sess_set_get_cb(ctx,cb) sets the callback and
78int (*cb)()SSL_CTX_sess_get_get_cb(ctx) returns the callback.
79
80These callbacks are basically indended to be used by processes to
81send their session-id's to other processes. I currently have not implemented
82non-blocking semantics for these callbacks, it is upto the appication
83to make the callbacks effiecent if they require blocking (perhaps
84by 'saving' them and then 'posting them' when control returns from
85the SSL_accept().
86
87LHASH *SSL_CTX_sessions(SSL_CTX *ctx)
88This returns the session cache. The lhash strucutre can be accessed for
89statistics about the cache.
90
91void lh_stats(LHASH *lh, FILE *out);
92void lh_node_stats(LHASH *lh, FILE *out);
93void lh_node_usage_stats(LHASH *lh, FILE *out);
94
95can be used to print details about it's activity and current state.
96You can also delve directly into the lhash structure for 14 different
97counters that are kept against the structure. When I wrote the lhash library,
98I was interested in gathering statistics :-).
99Have a read of doc/lhash.doc in the SSLeay distribution area for more details
100on the lhash library.
101
102Now as mentioned ealier, when a SSL is created, it needs a SSL_CTX.
103SSL * SSL_new(SSL_CTX *);
104
105This stores a session. A session is secret information shared between 2
106SSL contexts. It will only be created if both ends of the connection have
107authenticated their peer to their satisfaction. It basically contains
108the information required to use a particular secret key cipher.
109
110To retrieve the SSL_CTX being used by a SSL,
111SSL_CTX *SSL_get_SSL_CTX(SSL *s);
112
113Now when a SSL session is established between to programs, the 'session'
114information that is cached in the SSL_CTX can me manipulated by the
115following functions.
116int SSL_set_session(SSL *s, SSL_SESSION *session);
117This will set the SSL_SESSION to use for the next SSL_connect(). If you use
118this function on an already 'open' established SSL connection, 'bad things
119will happen'. This function is meaning-less when used on a ssl strucutre
120that is just about to be used in a SSL_accept() call since the
121SSL_accept() will either create a new session or retrieve one from the
122cache.
123
124SSL_SESSION *SSL_get_session(SSL *s);
125This will return the SSL_SESSION for the current SSL, NULL if there is
126no session associated with the SSL structure.
127
128The SSL sessions are kept in the SSL_CTX in a hash table, to remove a
129session
130void SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c);
131and to add one
132int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c);
133SSL_CTX_add_session() returns 1 if the session was already in the cache (so it
134was not added).
135Whenever a new session is created via SSL_connect()/SSL_accept(),
136they are automatically added to the cache, depending on the session_cache_mode
137settings. SSL_set_session()
138does not add it to the cache. Just call SSL_CTX_add_session() if you do want the
139session added. For a 'client' this would not normally be the case.
140SSL_CTX_add_session() is not normally ever used, except for doing 'evil' things
141which the next 2 funtions help you do.
142
143int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp);
144SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,unsigned char **pp,long length);
145These 2 functions are in the standard ASN1 library form and can be used to
146load and save to a byte format, the SSL_SESSION structure.
147With these functions, you can save and read these structures to a files or
148arbitary byte string.
149The PEM_write_SSL_SESSION(fp,x) and PEM_read_SSL_SESSION(fp,x,cb) will
150write to a file pointer in base64 encoding.
151
152What you can do with this, is pass session information between separate
153processes. Please note, that you will probably also need to modify the
154timeout information on the SSL_SESSIONs.
155
156long SSL_get_time(SSL_SESSION *s)
157will return the 'time' that the session
158was loaded. The timeout is relative to this time. This information is
159saved when the SSL_SESSION is converted to binarary but it is stored
160in as a unix long, which is rather OS dependant, but easy to convert back.
161
162long SSL_set_time(SSL_SESSION *s,long t) will set the above mentioned time.
163The time value is just the value returned from time(3), and should really
164be defined by be to be time_t.
165
166long SSL_get_timeout(SSL_SESSION *s);
167long SSL_set_timeout(SSL_SESSION *s,long t);
168These 2 retrieve and set the timeout which is just a number of secconds
169from the 'SSL_get_time()' value. When this time period has elapesed,
170the session will no longer be in the cache (well it will actually be removed
171the next time it is attempted to be retrieved, so you could 'bump'
172the timeout so it remains valid).
173The 'time' and 'timeout' are set on a session when it is created, not reset
174each time it is reused. If you did wish to 'bump it', just after establishing
175a connection, do a
176SSL_set_time(ssl,time(NULL));
177
178You can also use
179SSL_CTX_set_timeout(SSL_CTX *ctx,unsigned long t) and
180SSL_CTX_get_timeout(SSL_CTX *ctx) to manipulate the default timeouts for
181all SSL connections created against a SSL_CTX. If you set a timeout in
182an SSL_CTX, all new SSL's created will inherit the timeout. It can be over
183written by the SSL_set_timeout(SSL *s,unsigned long t) function call.
184If you 'set' the timeout back to 0, the system default will be used.
185
186SSL_SESSION *SSL_SESSION_new();
187void SSL_SESSION_free(SSL_SESSION *ses);
188These 2 functions are used to create and dispose of SSL_SESSION functions.
189You should not ever normally need to use them unless you are using
190i2d_SSL_SESSION() and/or d2i_SSL_SESSION(). If you 'load' a SSL_SESSION
191via d2i_SSL_SESSION(), you will need to SSL_SESSION_free() it.
192Both SSL_set_session() and SSL_CTX_add_session() will 'take copies' of the
193structure (via reference counts) when it is passed to them.
194
195SSL_CTX_flush_sessions(ctx,time);
196The first function will clear all sessions from the cache, which have expired
197relative to 'time' (which could just be time(NULL)).
198
199SSL_CTX_flush_sessions(ctx,0);
200This is a special case that clears everything.
201
202As a final comment, a 'session' is not enough to establish a new
203connection. If a session has timed out, a certificate and private key
204need to have been associated with the SSL structure.
205SSL_copy_session_id(SSL *to,SSL *from); will copy not only the session
206strucutre but also the private key and certificate associated with
207'from'.
208
209EXAMPLES.
210
211So lets play at being a wierd SSL server.
212
213/* setup a context */
214ctx=SSL_CTX_new();
215
216/* Lets load some session from binary into the cache, why one would do
217 * this is not toally clear, but passing between programs does make sense
218 * Perhaps you are using 4096 bit keys and are happy to keep them
219 * valid for a week, to avoid the RSA overhead of 15 seconds, I'm not toally
220 * sure, perhaps this is a process called from an SSL inetd and this is being
221 * passed to the application. */
222session=d2i_SSL_SESSION(....)
223SSL_CTX_add_session(ctx,session);
224
225/* Lets even add a session from a file */
226session=PEM_read_SSL_SESSION(....)
227SSL_CTX_add_session(ctx,session);
228
229/* create a new SSL structure */
230ssl=SSL_new(ctx);
231
232/* At this point we want to be able to 'create' new session if
233 * required, so we need a certificate and RSAkey. */
234SSL_use_RSAPrivateKey_file(ssl,...)
235SSL_use_certificate_file(ssl,...)
236
237/* Now since we are a server, it make little sence to load a session against
238 * the ssl strucutre since a SSL_accept() will either create a new session or
239 * grab an existing one from the cache. */
240
241/* grab a socket descriptor */
242fd=accept(...);
243
244/* associated it with the ssl strucutre */
245SSL_set_fd(ssl,fd);
246
247SSL_accept(ssl); /* 'do' SSL using out cert and RSA key */
248
249/* Lets print out the session details or lets save it to a file,
250 * perhaps with a secret key cipher, so that we can pass it to the FBI
251 * when they want to decode the session :-). While we have RSA
252 * this does not matter much but when I do SSLv3, this will allow a mechanism
253 * for the server/client to record the information needed to decode
254 * the traffic that went over the wire, even when using Diffie-Hellman */
255PEM_write_SSL_SESSION(SSL_get_session(ssl),stdout,....)
256
257Lets 'connect' back to the caller using the same session id.
258
259ssl2=SSL_new(ctx);
260fd2=connect(them);
261SSL_set_fd(ssl2,fd2);
262SSL_set_session(ssl2,SSL_get_session(ssl));
263SSL_connect(ssl2);
264
265/* what the hell, lets accept no more connections using this session */
266SSL_CTX_remove_session(SSL_get_SSL_CTX(ssl),SSL_get_session(ssl));
267
268/* we could have just as easily used ssl2 since they both are using the
269 * same session.
270 * You will note that both ssl and ssl2 are still using the session, and
271 * the SSL_SESSION structure will be free()ed when both ssl and ssl2
272 * finish using the session. Also note that you could continue to initiate
273 * connections using this session by doing SSL_get_session(ssl) to get the
274 * existing session, but SSL_accept() will not be able to find it to
275 * use for incoming connections.
276 * Of corse, the session will timeout at the far end and it will no
277 * longer be accepted after a while. The time and timeout are ignored except
278 * by SSL_accept(). */
279
280/* Since we have had our server running for 10 weeks, and memory is getting
281 * short, perhaps we should clear the session cache to remove those
282 * 100000 session entries that have expired. Some may consider this
283 * a memory leak :-) */
284
285SSL_CTX_flush_sessions(ctx,time(NULL));
286
287/* Ok, after a bit more time we wish to flush all sessions from the cache
288 * so that all new connections will be authenticated and incure the
289 * public key operation overhead */
290
291SSL_CTX_flush_sessions(ctx,0);
292
293/* As a final note, to copy everything to do with a SSL, use */
294SSL_copy_session_id(SSL *to,SSL *from);
295/* as this also copies the certificate and RSA key so new session can
296 * be established using the same details */
297
diff --git a/src/lib/libssl/src/doc/sha.doc b/src/lib/libssl/src/doc/sha.doc
new file mode 100644
index 0000000000..895fa182ed
--- /dev/null
+++ b/src/lib/libssl/src/doc/sha.doc
@@ -0,0 +1,52 @@
1The SHA (Secure Hash Algorithm) library.
2SHA is a message digest algorithm that can be used to condense an arbitrary
3length message down to a 20 byte hash. The functions all need to be passed
4a SHA_CTX which is used to hold the SHA context during multiple SHA_Update()
5function calls. The normal method of use for this library is as follows
6This library contains both SHA and SHA-1 digest algorithms. SHA-1 is
7an update to SHA (which should really be called SHA-0 now) which
8tweaks the algorithm slightly. The SHA-1 algorithm is used by simply
9using SHA1_Init(), SHA1_Update(), SHA1_Final() and SHA1() instead of the
10SHA*() calls
11
12SHA_Init(...);
13SHA_Update(...);
14...
15SHA_Update(...);
16SHA_Final(...);
17
18This library requires the inclusion of 'sha.h'.
19
20The functions are as follows:
21
22void SHA_Init(
23SHA_CTX *c);
24 This function needs to be called to initiate a SHA_CTX structure for
25 use.
26
27void SHA_Update(
28SHA_CTX *c;
29unsigned char *data;
30unsigned long len);
31 This updates the message digest context being generated with 'len'
32 bytes from the 'data' pointer. The number of bytes can be any
33 length.
34
35void SHA_Final(
36unsigned char *md;
37SHA_CTX *c;
38 This function is called when a message digest of the data digested
39 with SHA_Update() is wanted. The message digest is put in the 'md'
40 array and is SHA_DIGEST_LENGTH (20) bytes long.
41
42unsigned char *SHA(
43unsigned char *d;
44unsigned long n;
45unsigned char *md;
46 This function performs a SHA_Init(), followed by a SHA_Update()
47 followed by a SHA_Final() (using a local SHA_CTX).
48 The resulting digest is put into 'md' if it is not NULL.
49 Regardless of the value of 'md', the message
50 digest is returned from the function. If 'md' was NULL, the message
51 digest returned is being stored in a static structure.
52
diff --git a/src/lib/libssl/src/doc/speed.doc b/src/lib/libssl/src/doc/speed.doc
new file mode 100644
index 0000000000..11dfa85f08
--- /dev/null
+++ b/src/lib/libssl/src/doc/speed.doc
@@ -0,0 +1,96 @@
1To get an idea of the performance of this library, use
2ssleay speed
3
4perl util/sp-diff.pl file1 file2
5
6will print out the relative differences between the 2 files which are
7expected to be the output from the speed program.
8
9The performace of the library is very dependant on the Compiler
10quality and various flags used to build.
11
12---
13
14These are some numbers I did comparing RSAref and SSLeay on a Pentium 100.
15[ These numbers are all out of date, as of SSL - 0.6.1 the RSA
16operations are about 2 times faster, so check the version number ]
17
18RSA performance.
19
20SSLeay 0.6.0
21Pentium 100, 32meg, Windows NT Workstation 3.51
22linux - gcc v 2.7.0 -O3 -fomit-frame-pointer -m486
23and
24Windows NT - Windows NT 3.51 - Visual C++ 4.1 - 586 code + 32bit assember
25Windows 3.1 - Windows NT 3.51 - Visual C++ 1.52c - 286 code + 32bit assember
26NT Dos Shell- Windows NT 3.51 - Visual C++ 1.52c - 286 code + 16bit assember
27
28Times are how long it takes to do an RSA private key operation.
29
30 512bits 1024bits
31-------------------------------
32SSLeay NT dll 0.042s 0.202s see above
33SSLeay linux 0.046s 0.218s Assember inner loops (normal build)
34SSLeay linux 0.067s 0.380s Pure C code with BN_LLONG defined
35SSLeay W3.1 dll 0.108s 0.478s see above
36SSLeay linux 0.109s 0.713s C without BN_LLONG.
37RSAref2.0 linux 0.149s 0.936s
38SSLeay MS-DOS 0.197s 1.049s see above
39
40486DX66, 32meg, Windows NT Server 3.51
41 512bits 1024bits
42-------------------------------
43SSLeay NT dll 0.084s 0.495s <- SSLeay 0.6.3
44SSLeay NT dll 0.154s 0.882s
45SSLeay W3.1 dll 0.335s 1.538s
46SSLeay MS-DOS 0.490s 2.790s
47
48What I find cute is that I'm still faster than RSAref when using standard C,
49without using the 'long long' data type :-), %35 faster for 512bit and we
50scale up to 3.2 times faster for the 'default linux' build. I should mention
51that people should 'try' to use either x86-lnx.s (elf), x86-lnxa.s or
52x86-sol.s for any x86 based unix they are building on. The only problems
53with be with syntax but the performance gain is quite large, especially for
54servers. The code is very simple, you just need to modify the 'header'.
55
56The message is, if you are stuck using RSAref, the RSA performance will be
57bad. Considering the code was compiled for a pentium, the 486DX66 number
58would indicate 'Use RSAref and turn you Pentium 100 into a 486DX66' :-).
59[ As of verson 0.6.1, it would be correct to say 'turn you pentium 100
60 into a 486DX33' :-) ]
61
62I won't tell people if the DLL's are using RSAref or my stuff if no-one
63asks :-).
64
65eric
66
67PS while I know I could speed things up further, I will probably not do
68 so due to the effort involved. I did do some timings on the
69 SSLeay bignum format -> RSAref number format conversion that occurs
70 each time RSAref is used by SSLeay, and the numbers are trivial.
71 0.00012s a call for 512bit vs 0.149s for the time spent in the function.
72 0.00018s for 1024bit vs 0.938s. Insignificant.
73 So the 'way to go', to support faster RSA libraries, if people are keen,
74 is to write 'glue' code in a similar way that I do for RSAref and send it
75 to me :-).
76 My base library still has the advantage of being able to operate on
77 any size numbers, and is not that far from the performance from the
78 leaders in the field. (-%30?)
79 [ Well as of 0.6.1 I am now the leader in the filed on x86 (we at
80 least very close :-) ]
81
82 I suppose I should also mention some other numbers RSAref numbers, again
83 on my Pentium.
84 DES CBC EDE-DES MD5
85 RSAref linux 830k/s 302k/s 4390k/s
86 SSLeay linux 855k/s 319k/s 10025k/s
87 SSLeay NT 1158k/s 410k/s 10470k/s
88 SSLeay w31 378k/s 143k/s 2383k/s (fully 16bit)
89
90 Got to admit that Visual C++ 4.[01] is a damn fine compiler :-)
91--
92Eric Young | BOOL is tri-state according to Bill Gates.
93AARNet: eay@cryptsoft.com | RTFM Win32 GetMessage().
94
95
96
diff --git a/src/lib/libssl/src/doc/ssl-ciph.doc b/src/lib/libssl/src/doc/ssl-ciph.doc
new file mode 100644
index 0000000000..33a7e41f0e
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl-ciph.doc
@@ -0,0 +1,84 @@
1This is a quick high level summery of how things work now.
2
3Each SSLv2 and SSLv3 cipher is composed of 4 major attributes plus a few extra
4minor ones.
5
6They are 'The key exchange algorithm', which is RSA for SSLv2 but can also
7be Diffle-Hellman for SSLv3.
8
9An 'Authenticion algorithm', which can be RSA, Diffle-Helman, DSS or
10none.
11
12The cipher
13
14The MAC digest.
15
16A cipher can also be an export cipher and is either an SSLv2 or a
17SSLv3 ciphers.
18
19To specify which ciphers to use, one can either specify all the ciphers,
20one at a time, or use 'aliases' to specify the preference and order for
21the ciphers.
22
23There are a large number of aliases, but the most importaint are
24kRSA, kDHr, kDHd and kEDH for key exchange types.
25
26aRSA, aDSS, aNULL and aDH for authentication
27DES, 3DES, RC4, RC2, IDEA and eNULL for ciphers
28MD5, SHA0 and SHA1 digests
29
30Now where this becomes interesting is that these can be put together to
31specify the order and ciphers you wish to use.
32
33To speed this up there are also aliases for certian groups of ciphers.
34The main ones are
35SSLv2 - all SSLv2 ciphers
36SSLv3 - all SSLv3 ciphers
37EXP - all export ciphers
38LOW - all low strngth ciphers (no export ciphers, normally single DES)
39MEDIUM - 128 bit encryption
40HIGH - Triple DES
41
42These aliases can be joined in a : separated list which specifies to
43add ciphers, move them to the current location and delete them.
44
45A simpler way to look at all of this is to use the 'ssleay ciphers -v' command.
46The default library cipher spec is
47!ADH:RC4+RSA:HIGH:MEDIUM:LOW:EXP:+SSLv2:+EXP
48which means, first, remove from consideration any ciphers that do not
49authenticate. Next up, use ciphers using RC4 and RSA. Next include the HIGH,
50MEDIUM and the LOW security ciphers. Finish up by adding all the export
51ciphers on the end, then 'pull' all the SSLv2 and export ciphers to
52the end of the list.
53
54The results are
55$ ssleay ciphers -v '!ADH:RC4+RSA:HIGH:MEDIUM:LOW:EXP:+SSLv2:+EXP'
56
57RC4-SHA SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=SHA1
58RC4-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5
59EDH-RSA-DES-CBC3-SHA SSLv3 Kx=DH Au=RSA Enc=3DES(168) Mac=SHA1
60EDH-DSS-DES-CBC3-SHA SSLv3 Kx=DH Au=DSS Enc=3DES(168) Mac=SHA1
61DES-CBC3-SHA SSLv3 Kx=RSA Au=RSA Enc=3DES(168) Mac=SHA1
62IDEA-CBC-MD5 SSLv3 Kx=RSA Au=RSA Enc=IDEA(128) Mac=SHA1
63EDH-RSA-DES-CBC-SHA SSLv3 Kx=DH Au=RSA Enc=DES(56) Mac=SHA1
64EDH-DSS-DES-CBC-SHA SSLv3 Kx=DH Au=DSS Enc=DES(56) Mac=SHA1
65DES-CBC-SHA SSLv3 Kx=RSA Au=RSA Enc=DES(56) Mac=SHA1
66DES-CBC3-MD5 SSLv2 Kx=RSA Au=RSA Enc=3DES(168) Mac=MD5
67DES-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=DES(56) Mac=MD5
68IDEA-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=IDEA(128) Mac=MD5
69RC2-CBC-MD5 SSLv2 Kx=RSA Au=RSA Enc=RC2(128) Mac=MD5
70RC4-MD5 SSLv2 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5
71EXP-EDH-RSA-DES-CBC SSLv3 Kx=DH(512) Au=RSA Enc=DES(40) Mac=SHA1 export
72EXP-EDH-DSS-DES-CBC-SHA SSLv3 Kx=DH(512) Au=DSS Enc=DES(40) Mac=SHA1 export
73EXP-DES-CBC-SHA SSLv3 Kx=RSA(512) Au=RSA Enc=DES(40) Mac=SHA1 export
74EXP-RC2-CBC-MD5 SSLv3 Kx=RSA(512) Au=RSA Enc=RC2(40) Mac=MD5 export
75EXP-RC4-MD5 SSLv3 Kx=RSA(512) Au=RSA Enc=RC4(40) Mac=MD5 export
76EXP-RC2-CBC-MD5 SSLv2 Kx=RSA(512) Au=RSA Enc=RC2(40) Mac=MD5 export
77EXP-RC4-MD5 SSLv2 Kx=RSA(512) Au=RSA Enc=RC4(40) Mac=MD5 export
78
79I would recoment people use the 'ssleay ciphers -v "text"'
80command to check what they are going to use.
81
82Anyway, I'm falling asleep here so I'll do some more tomorrow.
83
84eric
diff --git a/src/lib/libssl/src/doc/ssl.doc b/src/lib/libssl/src/doc/ssl.doc
new file mode 100644
index 0000000000..1f89cd5db2
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl.doc
@@ -0,0 +1,172 @@
1SSL_CTX_sessions(SSL_CTX *ctx) - the session-id hash table.
2
3/* Session-id cache stats */
4SSL_CTX_sess_number
5SSL_CTX_sess_connect
6SSL_CTX_sess_connect_good
7SSL_CTX_sess_accept
8SSL_CTX_sess_accept_good
9SSL_CTX_sess_hits
10SSL_CTX_sess_cb_hits
11SSL_CTX_sess_misses
12SSL_CTX_sess_timeouts
13
14/* Session-id application notification callbacks */
15SSL_CTX_sess_set_new_cb
16SSL_CTX_sess_get_new_cb
17SSL_CTX_sess_set_get_cb
18SSL_CTX_sess_get_get_cb
19
20/* Session-id cache operation mode */
21SSL_CTX_set_session_cache_mode
22SSL_CTX_get_session_cache_mode
23
24/* Set default timeout values to use. */
25SSL_CTX_set_timeout
26SSL_CTX_get_timeout
27
28/* Global SSL initalisation informational callback */
29SSL_CTX_set_info_callback
30SSL_CTX_get_info_callback
31SSL_set_info_callback
32SSL_get_info_callback
33
34/* If the SSL_accept/SSL_connect returned with -1, these indicate when
35 * we should re-call *.
36SSL_want
37SSL_want_nothing
38SSL_want_read
39SSL_want_write
40SSL_want_x509_lookup
41
42/* Where we are in SSL initalisation, used in non-blocking, perhaps
43 * have a look at ssl/bio_ssl.c */
44SSL_state
45SSL_is_init_finished
46SSL_in_init
47SSL_in_connect_init
48SSL_in_accept_init
49
50/* Used to set the 'inital' state so SSL_in_connect_init and SSL_in_accept_init
51 * can be used to work out which function to call. */
52SSL_set_connect_state
53SSL_set_accept_state
54
55/* Where to look for certificates for authentication */
56SSL_set_default_verify_paths /* calles SSL_load_verify_locations */
57SSL_load_verify_locations
58
59/* get info from an established connection */
60SSL_get_session
61SSL_get_certificate
62SSL_get_SSL_CTX
63
64SSL_CTX_new
65SSL_CTX_free
66SSL_new
67SSL_clear
68SSL_free
69
70SSL_CTX_set_cipher_list
71SSL_get_cipher
72SSL_set_cipher_list
73SSL_get_cipher_list
74SSL_get_shared_ciphers
75
76SSL_accept
77SSL_connect
78SSL_read
79SSL_write
80
81SSL_debug
82
83SSL_get_read_ahead
84SSL_set_read_ahead
85SSL_set_verify
86
87SSL_pending
88
89SSL_set_fd
90SSL_set_rfd
91SSL_set_wfd
92SSL_set_bio
93SSL_get_fd
94SSL_get_rbio
95SSL_get_wbio
96
97SSL_use_RSAPrivateKey
98SSL_use_RSAPrivateKey_ASN1
99SSL_use_RSAPrivateKey_file
100SSL_use_PrivateKey
101SSL_use_PrivateKey_ASN1
102SSL_use_PrivateKey_file
103SSL_use_certificate
104SSL_use_certificate_ASN1
105SSL_use_certificate_file
106
107ERR_load_SSL_strings
108SSL_load_error_strings
109
110/* human readable version of the 'state' of the SSL connection. */
111SSL_state_string
112SSL_state_string_long
113/* These 2 report what kind of IO operation the library was trying to
114 * perform last. Probably not very usefull. */
115SSL_rstate_string
116SSL_rstate_string_long
117
118SSL_get_peer_certificate
119
120SSL_SESSION_new
121SSL_SESSION_print_fp
122SSL_SESSION_print
123SSL_SESSION_free
124i2d_SSL_SESSION
125d2i_SSL_SESSION
126
127SSL_get_time
128SSL_set_time
129SSL_get_timeout
130SSL_set_timeout
131SSL_copy_session_id
132SSL_set_session
133SSL_CTX_add_session
134SSL_CTX_remove_session
135SSL_CTX_flush_sessions
136
137BIO_f_ssl
138
139/* used to hold information as to why a certificate verification failed */
140SSL_set_verify_result
141SSL_get_verify_result
142
143/* can be used by the application to associate data with an SSL structure.
144 * It needs to be 'free()ed' by the application */
145SSL_set_app_data
146SSL_get_app_data
147
148/* The following all set values that are kept in the SSL_CTX but
149 * are used as the default values when an SSL session is created.
150 * They are over writen by the relevent SSL_xxxx functions */
151
152/* SSL_set_verify */
153void SSL_CTX_set_default_verify
154
155/* This callback, if set, totaly overrides the normal SSLeay verification
156 * functions and should return 1 on sucesss and 0 on failure */
157void SSL_CTX_set_cert_verify_callback
158
159/* The following are the same as the equivilent SSL_xxx functions.
160 * Only one copy of this information is kept and if a particular
161 * SSL structure has a local override, it is totally separate structure.
162 */
163int SSL_CTX_use_RSAPrivateKey
164int SSL_CTX_use_RSAPrivateKey_ASN1
165int SSL_CTX_use_RSAPrivateKey_file
166int SSL_CTX_use_PrivateKey
167int SSL_CTX_use_PrivateKey_ASN1
168int SSL_CTX_use_PrivateKey_file
169int SSL_CTX_use_certificate
170int SSL_CTX_use_certificate_ASN1
171int SSL_CTX_use_certificate_file
172
diff --git a/src/lib/libssl/src/doc/ssl_ctx.doc b/src/lib/libssl/src/doc/ssl_ctx.doc
new file mode 100644
index 0000000000..508394e75f
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssl_ctx.doc
@@ -0,0 +1,68 @@
1This is now a bit dated, quite a few of the SSL_ functions could be
2SSL_CTX_ functions. I will update this in the future. 30 Aug 1996
3
4From eay@orb.mincom.oz.au Mon Dec 11 21:37:08 1995
5Received: by orb.mincom.oz.au id AA00696
6 (5.65c/IDA-1.4.4 for eay); Mon, 11 Dec 1995 11:37:08 +1000
7Date: Mon, 11 Dec 1995 11:37:08 +1000 (EST)
8From: Eric Young <eay@mincom.oz.au>
9X-Sender: eay@orb
10To: sameer <sameer@c2.org>
11Cc: Eric Young <eay@mincom.oz.au>
12Subject: Re: PEM_readX509 oesn't seem to be working
13In-Reply-To: <199512110102.RAA12521@infinity.c2.org>
14Message-Id: <Pine.SOL.3.91.951211112115.28608D-100000@orb>
15Mime-Version: 1.0
16Content-Type: TEXT/PLAIN; charset=US-ASCII
17Status: RO
18X-Status:
19
20On Sun, 10 Dec 1995, sameer wrote:
21> OK, that's solved. I've found out that it is saying "no
22> certificate set" in SSL_accept because s->conn == NULL
23> so there is some place I need to initialize s->conn that I am
24> not initializing it.
25
26The full order of things for a server should be.
27
28ctx=SSL_CTX_new();
29
30/* The next line should not really be using ctx->cert but I'll leave it
31 * this way right now... I don't want a X509_ routine to know about an SSL
32 * structure, there should be an SSL_load_verify_locations... hmm, I may
33 * add it tonight.
34 */
35X509_load_verify_locations(ctx->cert,CAfile,CApath);
36
37/* Ok now for each new connection we do the following */
38con=SSL_new(ctx);
39SSL_set_fd(con,s);
40SSL_set_verify(con,verify,verify_callback);
41
42/* set the certificate and private key to use. */
43SSL_use_certificate_ASN1(con,X509_certificate);
44SSL_use_RSAPrivateKey_ASN1(con,RSA_private_key);
45
46SSL_accept(con);
47
48SSL_read(con)/SSL_write(con);
49
50There is a bit more than that but that is basically the structure.
51
52Create a context and specify where to lookup certificates.
53
54foreach connection
55 {
56 create a SSL structure
57 set the certificate and private key
58 do a SSL_accept
59
60 we should now be ok
61 }
62
63eric
64--
65Eric Young | Signature removed since it was generating
66AARNet: eay@mincom.oz.au | more followups than the message contents :-)
67
68
diff --git a/src/lib/libssl/src/doc/ssleay.doc b/src/lib/libssl/src/doc/ssleay.doc
new file mode 100644
index 0000000000..a0e86aef7c
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssleay.doc
@@ -0,0 +1,213 @@
1SSLeay: a cryptographic kitchen sink.
2
31st December 1995
4Way back at the start of April 1995, I was looking for a mindless
5programming project. A friend of mine (Tim Hudson) said "why don't you do SSL,
6it has DES encryption in it and I would not mind using it in a SSL telnet".
7While it was true I had written a DES library in previous years, litle
8did I know what an expansive task SSL would turn into.
9
10First of all, the SSL protocol contains DES encryption. Well and good. My
11DES library was fast and portable. It also contained the RSA's RC4 stream
12cipher. Again, not a problem, some-one had just posted to sci.crypt
13something that was claimed to be RC4. It also contained IDEA, I had the
14specifications, not a problem to implement. MD5, an RFC, trivial, at most
15I could spend a week or so trying to see if I could speed up the
16implementation. All in all a nice set of ciphers.
17Then the first 'expantion of the scope', RSA public key
18encryption. Since I did not knowing a thing about public key encryption
19or number theory, this appeared quite a daunting task. Just writing a
20big number library would be problomatic in itself, let alone making it fast.
21At this point the scope of 'implementing SSL' expands eponentialy.
22First of all, the RSA private keys were being kept in ASN.1 format.
23Thankfully the RSA PKCS series of documents explains this format. So I now
24needed to be able to encode and decode arbitary ASN.1 objects. The Public
25keys were embeded in X509 certificates. Hmm... these are not only
26ASN.1 objects but they make up a heirachy of authentication. To
27authenticate a X509 certificate one needs to retrieve it's issuers
28certificate etc etc. Hmm..., so I also need to implement some kind
29of certificate management software. I would also have to implement
30software to authenticate certificates. At this point the support code made
31the SSL part of my library look quite small.
32Around this time, the first version of SSLeay was released.
33
34Ah, but here was the problem, I was not happy with the code so far. As may
35have become obvious, I had been treating all of this as a learning
36exersize, so I have completely written the library myself. As such, due
37to the way it had grown like a fungus, much of the library was not
38'elagent' or neat. There were global and static variables all over the
39place, the SSL part did not even handle non-blocking IO.
40The Great rewrite began.
41
42As of this point in time, the 'Great rewrite' has almost finished. So what
43follows is an approximate list of what is actually SSLeay 0.5.0
44
45/********* This needs to be updated for 0.6.0+ *************/
46
47---
48The library contains the following routines. Please note that most of these
49functions are not specfic for SSL or any other particular cipher
50implementation. I have tried to make all the routines as general purpose
51as possible. So you should not think of this library as an SSL
52implemtation, but rather as a library of cryptographic functions
53that also contains SSL. I refer to each of these function groupings as
54libraries since they are often capable of functioning as independant
55libraries
56
57First up, the general ciphers and message digests supported by the library.
58
59MD2 rfc???, a standard 'by parts' interface to this algorithm.
60MD5 rfc???, the same type of interface as for the MD2 library except a
61 different algorithm.
62SHA THe Secure Hash Algorithm. Again the same type of interface as
63 MD2/MD5 except the digest is 20 bytes.
64SHA1 The 'revised' version of SHA. Just about identical to SHA except
65 for one tweak of an inner loop.
66DES This is my libdes library that has been floating around for the last
67 few years. It has been enhanced for no other reason than completeness.
68 It now supports ecb, cbc, cfb, ofb, cfb64, ofb64 in normal mode and
69 triple DES modes of ecb, cbc, cfb64 and ofb64. cfb64 and ofb64 are
70 functional interfaces to the 64 bit modes of cfb and ofb used in
71 such a way thay they function as single character interfaces.
72RC4 The RSA Inc. stream cipher.
73RC2 The RSA Inc. block cipher.
74IDEA An implmentation of the IDEA cipher, the library supports ecb, cbc,
75 cfb64 and ofb64 modes of operation.
76
77Now all the above mentioned ciphers and digests libraries support high
78speed, minimal 'crap in the way' type interfaces. For fastest and
79lowest level access, these routines should be used directly.
80
81Now there was also the matter of public key crypto systems. These are
82based on large integer arithmatic.
83
84BN This is my large integer library. It supports all the normal
85 arithmentic operations. It uses malloc extensivly and as such has
86 no limits of the size of the numbers being manipulated. If you
87 wish to use 4000 bit RSA moduli, these routines will handle it.
88 This library also contains routines to 'generate' prime numbers and
89 to test for primality. The RSA and DH libraries sit on top of this
90 library. As of this point in time, I don't support SHA, but
91 when I do add it, it will just sit on top of the routines contained
92 in this library.
93RSA This implements the RSA public key algorithm. It also contains
94 routines that will generate a new private/public key pair.
95 All the RSA functions conform to the PKCS#1 standard.
96DH This is an implementation of the
97 Diffie-Hellman protocol. There are all the require routines for
98 the protocol, plus extra routines that can be used to generate a
99 strong prime for use with a specified generator. While this last
100 routine is not generally required by applications implementing DH,
101 It is present for completeness and because I thing it is much
102 better to be able to 'generate' your own 'magic' numbers as oposed
103 to using numbers suplied by others. I conform to the PKCS#3
104 standard where required.
105
106You may have noticed the preceeding section mentions the 'generation' of
107prime numbers. Now this requries the use of 'random numbers'.
108
109RAND This psuedo-random number library is based on MD5 at it's core
110 and a large internal state (2k bytes). Once you have entered enough
111 seed data into this random number algorithm I don't feel
112 you will ever need to worry about it generating predictable output.
113 Due to the way I am writing a portable library, I have left the
114 issue of how to get good initial random seed data upto the
115 application but I do have support routines for saving and loading a
116 persistant random number state for use between program runs.
117
118Now to make all these ciphers easier to use, a higher level
119interface was required. In this form, the same function would be used to
120encrypt 'by parts', via any one of the above mentioned ciphers.
121
122EVP The Digital EnVeloPe library is quite large. At it's core are
123 function to perform encryption and decryption by parts while using
124 an initial parameter to specify which of the 17 different ciphers
125 or 4 different message digests to use. On top of these are implmented
126 the digital signature functions, sign, verify, seal and open.
127 Base64 encoding of binary data is also done in this library.
128
129PEM rfc???? describe the format for Privacy Enhanced eMail.
130 As part of this standard, methods of encoding digital enveloped
131 data is an ascii format are defined. As such, I use a form of these
132 to encode enveloped data. While at this point in time full support
133 for PEM has not been built into the library, a minimal subset of
134 the secret key and Base64 encoding is present. These reoutines are
135 mostly used to Ascii encode binary data with a 'type' associated
136 with it and perhaps details of private key encryption used to
137 encrypt the data.
138
139PKCS7 This is another Digital Envelope encoding standard which uses ASN.1
140 to encode the data. At this point in time, while there are some
141 routines to encode and decode this binary format, full support is
142 not present.
143
144As Mentioned, above, there are several different ways to encode
145data structures.
146
147ASN1 This library is more a set of primatives used to encode the packing
148 and unpacking of data structures. It is used by the X509
149 certificate standard and by the PKCS standards which are used by
150 this library. It also contains routines for duplicating and signing
151 the structures asocisated with X509.
152
153X509 The X509 library contains routines for packing and unpacking,
154 verifying and just about every thing else you would want to do with
155 X509 certificates.
156
157PKCS7 PKCS-7 is a standard for encoding digital envelope data
158 structures. At this point in time the routines will load and save
159 DER forms of these structees. They need to be re-worked to support
160 the BER form which is the normal way PKCS-7 is encoded. If the
161 previous 2 sentances don't make much sense, don't worry, this
162 library is not used by this version of SSLeay anyway.
163
164OBJ ASN.1 uses 'object identifiers' to identify objects. A set of
165 functions were requred to translate from ASN.1 to an intenger, to a
166 character string. This library provieds these translations
167
168Now I mentioned an X509 library. X509 specified a hieachy of certificates
169which needs to be traversed to authenticate particular certificates.
170
171METH This library is used to push 'methods' of retrieving certificates
172 into the library. There are some supplied 'methods' with SSLeay
173 but applications can add new methods if they so desire.
174 This library has not been finished and is not being used in this
175 version.
176
177Now all the above are required for use in the initial point of this project.
178
179SSL The SSL protocol. This is a full implmentation of SSL v 2. It
180 support both server and client authentication. SSL v 3 support
181 will be added when the SSL v 3 specification is released in it's
182 final form.
183
184Now quite a few of the above mentioned libraries rely on a few 'complex'
185data structures. For each of these I have a library.
186
187Lhash This is a hash table library which is used extensivly.
188
189STACK An implemetation of a Stack data structure.
190
191BUF A simple character array structure that also support a function to
192 check that the array is greater that a certain size, if it is not,
193 it is realloced so that is it.
194
195TXT_DB A simple memory based text file data base. The application can specify
196 unique indexes that will be enforced at update time.
197
198CONF Most of the programs written for this library require a configuration
199 file. Instead of letting programs constantly re-implment this
200 subsystem, the CONF library provides a consistant and flexable
201 interface to not only configuration files but also environment
202 variables.
203
204But what about when something goes wrong?
205The one advantage (and perhaps disadvantage) of all of these
206functions being in one library was the ability to implement a
207single error reporting system.
208
209ERR This library is used to report errors. The error system records
210 library number, function number (in the library) and reason
211 number. Multiple errors can be reported so that an 'error' trace
212 is created. The errors can be printed in numeric or textual form.
213
diff --git a/src/lib/libssl/src/doc/ssluse.doc b/src/lib/libssl/src/doc/ssluse.doc
new file mode 100644
index 0000000000..2e3a26cbf3
--- /dev/null
+++ b/src/lib/libssl/src/doc/ssluse.doc
@@ -0,0 +1,45 @@
1We have an SSL_CTX which contains global information for lots of
2SSL connections. The session-id cache and the certificate verificate cache.
3It also contains default values for use when certificates are used.
4
5SSL_CTX
6 default cipher list
7 session-id cache
8 certificate cache
9 default session-id timeout period
10 New session-id callback
11 Required session-id callback
12 session-id stats
13 Informational callback
14 Callback that is set, overrides the SSLeay X509 certificate
15 verification
16 The default Certificate/Private Key pair
17 Default read ahead mode.
18 Default verify mode and verify callback. These are not used
19 if the over ride callback mentioned above is used.
20
21Each SSL can have the following defined for it before a connection is made.
22
23Certificate
24Private key
25Ciphers to use
26Certificate verify mode and callback
27IO object to use in the comunication.
28Some 'read-ahead' mode information.
29A previous session-id to re-use.
30
31A connection is made by using SSL_connect or SSL_accept.
32When non-blocking IO is being used, there are functions that can be used
33to determin where and why the SSL_connect or SSL_accept did not complete.
34This information can be used to recall the functions when the 'error'
35condition has dissapeared.
36
37After the connection has been made, information can be retrived about the
38SSL session and the session-id values that have been decided apon.
39The 'peer' certificate can be retrieved.
40
41The session-id values include
42'start time'
43'timeout length'
44
45
diff --git a/src/lib/libssl/src/doc/stack.doc b/src/lib/libssl/src/doc/stack.doc
new file mode 100644
index 0000000000..7c20b1b664
--- /dev/null
+++ b/src/lib/libssl/src/doc/stack.doc
@@ -0,0 +1,96 @@
1The stack data structure is used to store an ordered list of objects.
2It is basically misnamed to call it a stack but it can function that way
3and that is what I originally used it for. Due to the way element
4pointers are kept in a malloc()ed array, the most efficient way to use this
5structure is to add and delete elements from the end via sk_pop() and
6sk_push(). If you wish to do 'lookups' sk_find() is quite efficient since
7it will sort the stack (if required) and then do a binary search to lookup
8the requested item. This sorting occurs automatically so just sk_push()
9elements on the stack and don't worry about the order. Do remember that if
10you do a sk_find(), the order of the elements will change.
11
12You should never need to 'touch' this structure directly.
13typedef struct stack_st
14 {
15 unsigned int num;
16 char **data;
17 int sorted;
18
19 unsigned int num_alloc;
20 int (*comp)();
21 } STACK;
22
23'num' holds the number of elements in the stack, 'data' is the array of
24elements. 'sorted' is 1 is the list has been sorted, 0 if not.
25
26num_alloc is the number of 'nodes' allocated in 'data'. When num becomes
27larger than num_alloc, data is realloced to a larger size.
28If 'comp' is set, it is a function that is used to compare 2 of the items
29in the stack. The function should return -1, 0 or 1, depending on the
30ordering.
31
32#define sk_num(sk) ((sk)->num)
33#define sk_value(sk,n) ((sk)->data[n])
34
35These 2 macros should be used to access the number of elements in the
36'stack' and to access a pointer to one of the values.
37
38STACK *sk_new(int (*c)());
39 This creates a new stack. If 'c', the comparison function, is not
40specified, the various functions that operate on a sorted 'stack' will not
41work (sk_find()). NULL is returned on failure.
42
43void sk_free(STACK *);
44 This function free()'s a stack structure. The elements in the
45stack will not be freed so one should 'pop' and free all elements from the
46stack before calling this function or call sk_pop_free() instead.
47
48void sk_pop_free(STACK *st; void (*func)());
49 This function calls 'func' for each element on the stack, passing
50the element as the argument. sk_free() is then called to free the 'stack'
51structure.
52
53int sk_insert(STACK *sk,char *data,int where);
54 This function inserts 'data' into stack 'sk' at location 'where'.
55If 'where' is larger that the number of elements in the stack, the element
56is put at the end. This function tends to be used by other 'stack'
57functions. Returns 0 on failure, otherwise the number of elements in the
58new stack.
59
60char *sk_delete(STACK *st,int loc);
61 Remove the item a location 'loc' from the stack and returns it.
62Returns NULL if the 'loc' is out of range.
63
64char *sk_delete_ptr(STACK *st, char *p);
65 If the data item pointed to by 'p' is in the stack, it is deleted
66from the stack and returned. NULL is returned if the element is not in the
67stack.
68
69int sk_find(STACK *st,char *data);
70 Returns the location that contains a value that is equal to
71the 'data' item. If the comparison function was not set, this function
72does a linear search. This function actually qsort()s the stack if it is not
73in order and then uses bsearch() to do the initial search. If the
74search fails,, -1 is returned. For mutliple items with the same
75value, the index of the first in the array is returned.
76
77int sk_push(STACK *st,char *data);
78 Append 'data' to the stack. 0 is returned if there is a failure
79(due to a malloc failure), else 1. This is
80sk_insert(st,data,sk_num(st));
81
82int sk_unshift(STACK *st,char *data);
83 Prepend 'data' to the front (location 0) of the stack. This is
84sk_insert(st,data,0);
85
86char *sk_shift(STACK *st);
87 Return and delete from the stack the first element in the stack.
88This is sk_delete(st,0);
89
90char *sk_pop(STACK *st);
91 Return and delete the last element on the stack. This is
92sk_delete(st,sk_num(sk)-1);
93
94void sk_zero(STACK *st);
95 Removes all items from the stack. It does not 'free'
96pointers but is a quick way to clear a 'stack of references'.
diff --git a/src/lib/libssl/src/doc/threads.doc b/src/lib/libssl/src/doc/threads.doc
new file mode 100644
index 0000000000..251061e896
--- /dev/null
+++ b/src/lib/libssl/src/doc/threads.doc
@@ -0,0 +1,90 @@
1How to compile SSLeay for multi-threading.
2
3Well basically it is quite simple, set the compiler flags and build.
4I have only really done much testing under Solaris and Windows NT.
5If you library supports localtime_r() and gmtime_r() add,
6-DTHREADS to the makefile parameters. You can probably survive with out
7this define unless you are going to have multiple threads generating
8certificates at once. It will not affect the SSL side of things.
9
10The approach I have taken to doing locking is to make the application provide
11callbacks to perform locking and so that the SSLeay library can distinguish
12between threads (for the error state).
13
14To have a look at an example program, 'cd mt; vi mttest.c'.
15To build under solaris, sh solaris.sh, for Windows NT or Windows 95,
16win32.bat
17
18This will build mttest which will fire up 10 threads that talk SSL
19to each other 10 times.
20To enable everything to work, the application needs to call
21
22CRYPTO_set_id_callback(id_function);
23CRYPTO_set_locking_callback(locking_function);
24
25before any multithreading is started.
26id_function does not need to be defined under Windows NT or 95, the
27correct function will be called if it is not. Under unix, getpid()
28is call if the id_callback is not defined, for solaris this is wrong
29(since threads id's are not pid's) but under IRIX it is correct
30(threads are just processes sharing the data segement).
31
32The locking_callback is used to perform locking by the SSLeay library.
33eg.
34
35void solaris_locking_callback(mode,type,file,line)
36int mode;
37int type;
38char *file;
39int line;
40 {
41 if (mode & CRYPTO_LOCK)
42 mutex_lock(&(lock_cs[type]));
43 else
44 mutex_unlock(&(lock_cs[type]));
45 }
46
47Now in this case I have used mutexes instead of read/write locks, since they
48are faster and there are not many read locks in SSLeay, you may as well
49always use write locks. file and line are __FILE__ and __LINE__ from
50the compile and can be usefull when debugging.
51
52Now as you can see, 'type' can be one of a range of values, these values are
53defined in crypto/crypto.h
54CRYPTO_get_lock_name(type) will return a text version of what the lock is.
55There are CRYPTO_NUM_LOCKS locks required, so under solaris, the setup
56for multi-threading can be
57
58static mutex_t lock_cs[CRYPTO_NUM_LOCKS];
59
60void thread_setup()
61 {
62 int i;
63
64 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
65 mutex_init(&(lock_cs[i]),USYNC_THREAD,NULL);
66 CRYPTO_set_id_callback((unsigned long (*)())solaris_thread_id);
67 CRYPTO_set_locking_callback((void (*)())solaris_locking_callback);
68 }
69
70As a final note, under Windows NT or Windows 95, you have to be careful
71not to mix the various threaded, unthreaded and debug libraries.
72Normally if they are mixed incorrectly, mttest will crash just after printing
73out some usage statistics at the end. This is because the
74different system libraries use different malloc routines and if
75data is malloc()ed inside crypt32.dll or ssl32.dll and then free()ed by a
76different library malloc, things get very confused.
77
78The default SSLeay DLL builds use /MD, so if you use this on your
79application, things will work as expected. If you use /MDd,
80you will probably have to rebuild SSLeay using this flag.
81I should modify util/mk1mf.pl so it does all this correctly, but
82this has not been done yet.
83
84One last warning. Because locking overheads are actually quite large, the
85statistics collected against the SSL_CTX for successfull connections etc
86are not locked when updated. This does make it possible for these
87values to be slightly lower than they should be, if you are
88running multithreaded on a multi-processor box, but this does not really
89matter much.
90
diff --git a/src/lib/libssl/src/doc/txt_db.doc b/src/lib/libssl/src/doc/txt_db.doc
new file mode 100644
index 0000000000..3a5b0d50a1
--- /dev/null
+++ b/src/lib/libssl/src/doc/txt_db.doc
@@ -0,0 +1,4 @@
1TXT_DB, a simple text based in memory database.
2
3It holds rows of ascii data, for which the only special character is '\0'.
4The rows can be of an unlimited length.
diff --git a/src/lib/libssl/src/doc/verify b/src/lib/libssl/src/doc/verify
new file mode 100644
index 0000000000..b78d96159d
--- /dev/null
+++ b/src/lib/libssl/src/doc/verify
@@ -0,0 +1,22 @@
1X509_verify_cert_chain(
2 CERT_STORE *cert_store,
3 STACK /* X509 */ *certs,
4 int *verify_result,
5 int (*verify_error_callback)()
6 char *argument_to_callback, /* SSL */
7
8app_verify_callback(
9 char *app_verify_arg, /* from SSL_CTX */
10 STACK /* X509 */ *certs,
11 int *verify_result,
12 int (*verify_error_callback)()
13 SSL *s,
14
15int X509_verify_cert(
16 CERT_STORE *cert_store,
17 X509 *x509,
18 int *verify_result,
19 int (*verify_error_callback)(),
20 char *arg,
21
22
diff --git a/src/lib/libssl/src/doc/why.doc b/src/lib/libssl/src/doc/why.doc
new file mode 100644
index 0000000000..a1ac84bd27
--- /dev/null
+++ b/src/lib/libssl/src/doc/why.doc
@@ -0,0 +1,79 @@
1This file is more of a note for other people who wish to understand why
2the build environment is the way it is :-).
3
4The include files 'depend' as follows.
5Each of
6crypto/*/*.c includes crypto/cryptlib.h
7ssl/*.c include ssl/ssl_locl.h
8apps/*.c include apps/apps.h
9crypto/cryptlib.h, ssl/ssl_locl.h and apps/apps.h
10all include e_os.h which contains OS/environment specific information.
11If you need to add something todo with a particular environment,
12add it to this file. It is worth remembering that quite a few libraries,
13like lhash, des, md, sha etc etc do not include crypto/cryptlib.h. This
14is because these libraries should be 'independantly compilable' and so I
15try to keep them this way.
16e_os.h is not so much a part of SSLeay, as the placing in one spot all the
17evil OS dependant muck.
18
19I wanted to automate as many things as possible. This includes
20error number generation. A
21make errors
22will scan the source files for error codes, append them to the correct
23header files, and generate the functions to print the text version
24of the error numbers. So don't even think about adding error numbers by
25hand, put them in the form
26XXXerr(XXXX_F_XXXX,YYYY_R_YYYY);
27on line and it will be automatically picked up my a make errors.
28
29In a similar vein, programs to be added into ssleay in the apps directory
30just need to have an entry added to E_EXE in makefile.ssl and
31everthing will work as expected. Don't edit progs.h by hand.
32
33make links re-generates the symbolic links that are used. The reason why
34I keep everything in its own directory, and don't put all the
35test programs and header files in 'test' and 'include' is because I want
36to keep the 'sub-libraries' independant. I still 'pull' out
37indervidual libraries for use in specific projects where the code is
38required. I have used the 'lhash' library in just about every software
39project I have worked on :-).
40
41make depend generates dependancies and
42make dclean removes them.
43
44You will notice that I use perl quite a bit when I could be using 'sed'.
45The reason I decided to do this was to just stick to one 'extra' program.
46For Windows NT, I have perl and no sed.
47
48The util/mk1mf.pl program can be used to generate a single makefile.
49I use this because makefiles under Microsoft are horrific.
50Each C compiler seems to have different linker formats, which have
51to be used because the retarted C compilers explode when you do
52cl -o file *.o.
53
54Now some would argue that I should just use the single makefile. I don't
55like it during develoment for 2 reasons. First, the actuall make
56command takes a long time. For my current setup, if I'm in
57crypto/bn and I type make, only the crypto/bn directory gets rebuilt,
58which is nice when you are modifying prototypes in bn.h which
59half the SSLeay depends on. The second is that to add a new souce file
60I just plonk it in at the required spot in the local makefile. This
61then alows me to keep things local, I don't need to modify a 'global'
62tables (the make for unix, the make for NT, the make for w31...).
63When I am ripping apart a library structure, it is nice to only
64have to worry about one directory :-).
65
66Having said all this, for the hell of it I put together 2 files that
67#include all the souce code (generated by doing a ls */*.o after a build).
68crypto.c takes only 30 seconds to build under NT and 2 minutes under linux
69for my pentium100. Much faster that the normal build :-).
70Again, the problem is that when using libraries, every program linked
71to libcrypto.a would suddenly get 330k of library when it may only need
721k. This technique does look like a nice way to do shared libraries though.
73
74Oh yes, as a final note, to 'build' a distribution, I just type
75make dist.
76This cleans and packages everything. The directory needs to be called
77SSLeay since the make does a 'cd ..' and renames and tars things up.
78
79
diff --git a/src/lib/libssl/src/makefile.one b/src/lib/libssl/src/makefile.one
new file mode 100644
index 0000000000..b0931e0d6f
--- /dev/null
+++ b/src/lib/libssl/src/makefile.one
@@ -0,0 +1,1781 @@
1# This makefile has been automatically generated from the SSLeay distribution.
2# This single makefile will build the complete SSLeay distribution and
3# by default leave the 'intertesting' output files in ./out and the stuff
4# that needs deleting in ./tmp.
5# The file was generated by running 'make makefile.one', which
6# does a 'make files', which writes all the environment variables from all
7# the makefiles to the file call MINFO. This file is used by
8# util/mk1mf.pl to generate makefile.one.
9# The 'makefile per directory' system suites me when developing this
10# library and also so I can 'distribute' indervidual library sections.
11# The one monster makefile better suits building in non-unix
12# environments.
13
14INSTALLTOP=/usr/local/ssl
15
16# Set your compiler options
17CC=cc
18CFLAG=-O -DTERMIO
19APP_CFLAG=
20LIB_CFLAG=
21SHLIB_CFLAG=
22APP_EX_OBJ=
23SHLIB_EX_OBJ=
24# add extra libraries to this define, for solaris -lsocket -lnsl would
25# be added
26EX_LIBS=
27
28# The SSLeay directory
29SRC_D=.
30
31LINK=${CC}
32LFLAGS=${CFLAGS}
33
34BN_MULW_OBJ=
35BN_MULW_SRC=
36DES_ENC_OBJ=
37DES_ENC_SRC=
38DES_CRYPT_OBJ=
39DES_CRYPT_SRC=
40BF_ENC_OBJ=
41BF_ENC_SRC=
42CAST_ENC_OBJ=
43CAST_ENC_SRC=
44RC4_ENC_OBJ=
45RC4_ENC_SRC=
46RC5_ENC_OBJ=
47RC5_ENC_SRC=
48MD5_ASM_OBJ=
49MD5_ASM_SRC=
50SHA1_ASM_OBJ=
51SHA1_ASM_SRC=
52RMD160_ASM_OBJ=
53RMD160_ASM_SRC=
54
55# The output directory for everything intersting
56OUT_D=out
57# The output directory for all the temporary muck
58TMP_D=tmp
59# The output directory for the header files
60INC_D=outinc
61
62CP=/bin/cp
63RM=/bin/rm -f
64RANLIB=$(SRC_D)/util/ranlib.sh
65MKDIR=mkdir
66MKLIB=ar r
67MLFLAGS=
68ASM=as
69
70######################################################
71# You should not need to touch anything below this point
72######################################################
73
74E_EXE=ssleay
75SSL=ssl
76CRYPTO=crypto
77RSAGLUE=RSAglue
78
79# BIN_D - Binary output directory
80# TEST_D - Binary test file output directory
81# LIB_D - library output directory
82BIN_D=$(OUT_D)
83TEST_D=$(OUT_D)
84LIB_D=$(OUT_D)
85
86# INCL_D - local library directory
87# OBJ_D - temp object file directory
88OBJ_D=$(TMP_D)
89INCL_D=$(TMP_D)
90
91O_SSL= $(LIB_D)/lib$(SSL).a
92O_CRYPTO= $(LIB_D)/lib$(CRYPTO).a
93O_RSAGLUE= $(LIB_D)/lib$(RSAGLUE).a
94SO_SSL= lib$(SSL)
95SO_CRYPTO= lib$(CRYPTO)
96L_SSL= $(LIB_D)/$(SSL).a
97L_CRYPTO= $(LIB_D)/$(CRYPTO).a
98
99L_LIBS= $(L_SSL) $(L_CRYPTO)
100#L_LIBS= $(O_SSL) $(O_RSAGLUE) -lrsaref $(O_CRYPTO)
101
102######################################################
103# Don't touch anything below this point
104######################################################
105
106INC=-I$(INC_D) -I$(INCL_D)
107APP_CFLAGS=$(INC) $(CFLAG) $(APP_CFLAG)
108LIB_CFLAGS=$(INC) $(CFLAG) $(LIB_CFLAG)
109SHLIB_CFLAGS=$(INC) $(CFLAG) $(LIB_CFLAG) $(SHLIB_CFLAG)
110LIBS_DEP=$(O_CRYPTO) $(O_RSAGLUE) $(O_SSL)
111
112#############################################
113HEADER=$(INCL_D)/cryptlib.h \
114 $(INCL_D)/date.h $(INCL_D)/md5_locl.h $(INCL_D)/sha_locl.h \
115 $(INCL_D)/rmd_locl.h $(INCL_D)/rmdconst.h $(INCL_D)/des_locl.h \
116 $(INCL_D)/rpc_des.h $(INCL_D)/podd.h $(INCL_D)/sk.h \
117 $(INCL_D)/spr.h $(INCL_D)/des_ver.h $(INCL_D)/rc2_locl.h \
118 $(INCL_D)/rc4_locl.h $(INCL_D)/rc5_locl.h $(INCL_D)/idea_lcl.h \
119 $(INCL_D)/bf_pi.h $(INCL_D)/bf_locl.h $(INCL_D)/cast_s.h \
120 $(INCL_D)/cast_lcl.h $(INCL_D)/bn_lcl.h $(INCL_D)/bn_prime.h \
121 $(INCL_D)/obj_dat.h $(INCL_D)/conf_lcl.h $(INCL_D)/ssl_locl.h \
122 $(INCL_D)/rsaref.h $(INCL_D)/apps.h $(INCL_D)/progs.h \
123 $(INCL_D)/s_apps.h $(INCL_D)/testdsa.h $(INCL_D)/testrsa.h
124
125EXHEADER=$(INC_D)/e_os.h \
126 $(INC_D)/crypto.h $(INC_D)/cryptall.h $(INC_D)/md2.h \
127 $(INC_D)/md5.h $(INC_D)/sha.h $(INC_D)/mdc2.h \
128 $(INC_D)/hmac.h $(INC_D)/ripemd.h $(INC_D)/des.h \
129 $(INC_D)/rc2.h $(INC_D)/rc4.h $(INC_D)/rc5.h \
130 $(INC_D)/idea.h $(INC_D)/blowfish.h $(INC_D)/cast.h \
131 $(INC_D)/bn.h $(INC_D)/rsa.h $(INC_D)/dsa.h \
132 $(INC_D)/dh.h $(INC_D)/buffer.h $(INC_D)/bio.h \
133 $(INC_D)/bss_file.c $(INC_D)/stack.h $(INC_D)/lhash.h \
134 $(INC_D)/rand.h $(INC_D)/err.h $(INC_D)/objects.h \
135 $(INC_D)/evp.h $(INC_D)/pem.h $(INC_D)/asn1.h \
136 $(INC_D)/asn1_mac.h $(INC_D)/x509.h $(INC_D)/x509_vfy.h \
137 $(INC_D)/conf.h $(INC_D)/txt_db.h $(INC_D)/pkcs7.h \
138 $(INC_D)/ssl.h $(INC_D)/ssl2.h $(INC_D)/ssl3.h \
139 $(INC_D)/ssl23.h $(INC_D)/tls1.h
140
141T_OBJ=$(OBJ_D)/md2test.o \
142 $(OBJ_D)/md5test.o $(OBJ_D)/shatest.o $(OBJ_D)/sha1test.o \
143 $(OBJ_D)/mdc2test.o $(OBJ_D)/hmactest.o $(OBJ_D)/rmdtest.o \
144 $(OBJ_D)/destest.o $(OBJ_D)/rc2test.o $(OBJ_D)/rc4test.o \
145 $(OBJ_D)/rc5test.o $(OBJ_D)/ideatest.o $(OBJ_D)/bftest.o \
146 $(OBJ_D)/casttest.o $(OBJ_D)/bntest.o $(OBJ_D)/exptest.o \
147 $(OBJ_D)/dsatest.o $(OBJ_D)/dhtest.o $(OBJ_D)/randtest.o \
148 $(OBJ_D)/ssltest.o
149
150E_OBJ=$(OBJ_D)/verify.o \
151 $(OBJ_D)/asn1pars.o $(OBJ_D)/req.o $(OBJ_D)/dgst.o \
152 $(OBJ_D)/dh.o $(OBJ_D)/enc.o $(OBJ_D)/gendh.o \
153 $(OBJ_D)/errstr.o $(OBJ_D)/ca.o $(OBJ_D)/pkcs7.o \
154 $(OBJ_D)/crl2p7.o $(OBJ_D)/crl.o $(OBJ_D)/rsa.o \
155 $(OBJ_D)/dsa.o $(OBJ_D)/dsaparam.o $(OBJ_D)/x509.o \
156 $(OBJ_D)/genrsa.o $(OBJ_D)/s_server.o $(OBJ_D)/s_client.o \
157 $(OBJ_D)/speed.o $(OBJ_D)/s_time.o $(OBJ_D)/apps.o \
158 $(OBJ_D)/s_cb.o $(OBJ_D)/s_socket.o $(OBJ_D)/version.o \
159 $(OBJ_D)/sess_id.o $(OBJ_D)/ciphers.o $(OBJ_D)/ssleay.o
160
161CRYPTOOBJ=$(OBJ_D)/cryptlib.o \
162 $(OBJ_D)/mem.o $(OBJ_D)/cversion.o $(OBJ_D)/ex_data.o \
163 $(OBJ_D)/cpt_err.o $(OBJ_D)/md2_dgst.o $(OBJ_D)/md2_one.o \
164 $(OBJ_D)/md5_dgst.o $(OBJ_D)/md5_one.o $(OBJ_D)/sha_dgst.o \
165 $(OBJ_D)/sha1dgst.o $(OBJ_D)/sha_one.o $(OBJ_D)/sha1_one.o \
166 $(OBJ_D)/mdc2dgst.o $(OBJ_D)/mdc2_one.o $(OBJ_D)/hmac.o \
167 $(OBJ_D)/rmd_dgst.o $(OBJ_D)/rmd_one.o $(OBJ_D)/set_key.o \
168 $(OBJ_D)/ecb_enc.o $(OBJ_D)/cbc_enc.o $(OBJ_D)/ecb3_enc.o \
169 $(OBJ_D)/cfb64enc.o $(OBJ_D)/cfb64ede.o $(OBJ_D)/cfb_enc.o \
170 $(OBJ_D)/ofb64ede.o $(OBJ_D)/enc_read.o $(OBJ_D)/enc_writ.o \
171 $(OBJ_D)/ofb64enc.o $(OBJ_D)/ofb_enc.o $(OBJ_D)/str2key.o \
172 $(OBJ_D)/pcbc_enc.o $(OBJ_D)/qud_cksm.o $(OBJ_D)/rand_key.o \
173 $(OBJ_D)/des_enc.o $(OBJ_D)/fcrypt_b.o $(OBJ_D)/read2pwd.o \
174 $(OBJ_D)/fcrypt.o $(OBJ_D)/xcbc_enc.o $(OBJ_D)/read_pwd.o \
175 $(OBJ_D)/rpc_enc.o $(OBJ_D)/cbc_cksm.o $(OBJ_D)/supp.o \
176 $(OBJ_D)/rc2_ecb.o $(OBJ_D)/rc2_skey.o $(OBJ_D)/rc2_cbc.o \
177 $(OBJ_D)/rc2cfb64.o $(OBJ_D)/rc2ofb64.o $(OBJ_D)/rc4_skey.o \
178 $(OBJ_D)/rc4_enc.o $(OBJ_D)/rc5_skey.o $(OBJ_D)/rc5_ecb.o \
179 $(OBJ_D)/rc5_enc.o $(OBJ_D)/rc5cfb64.o $(OBJ_D)/rc5ofb64.o \
180 $(OBJ_D)/i_cbc.o $(OBJ_D)/i_cfb64.o $(OBJ_D)/i_ofb64.o \
181 $(OBJ_D)/i_ecb.o $(OBJ_D)/i_skey.o $(OBJ_D)/bf_skey.o \
182 $(OBJ_D)/bf_ecb.o $(OBJ_D)/bf_enc.o $(OBJ_D)/bf_cfb64.o \
183 $(OBJ_D)/bf_ofb64.o $(OBJ_D)/c_skey.o $(OBJ_D)/c_ecb.o \
184 $(OBJ_D)/c_enc.o $(OBJ_D)/c_cfb64.o $(OBJ_D)/c_ofb64.o \
185 $(OBJ_D)/bn_add.o $(OBJ_D)/bn_div.o $(OBJ_D)/bn_exp.o \
186 $(OBJ_D)/bn_lib.o $(OBJ_D)/bn_mod.o $(OBJ_D)/bn_mul.o \
187 $(OBJ_D)/bn_print.o $(OBJ_D)/bn_rand.o $(OBJ_D)/bn_shift.o \
188 $(OBJ_D)/bn_sub.o $(OBJ_D)/bn_word.o $(OBJ_D)/bn_blind.o \
189 $(OBJ_D)/bn_gcd.o $(OBJ_D)/bn_prime.o $(OBJ_D)/bn_err.o \
190 $(OBJ_D)/bn_sqr.o $(OBJ_D)/bn_mulw.o $(OBJ_D)/bn_recp.o \
191 $(OBJ_D)/bn_mont.o $(OBJ_D)/bn_mpi.o $(OBJ_D)/rsa_eay.o \
192 $(OBJ_D)/rsa_gen.o $(OBJ_D)/rsa_lib.o $(OBJ_D)/rsa_sign.o \
193 $(OBJ_D)/rsa_saos.o $(OBJ_D)/rsa_err.o $(OBJ_D)/rsa_pk1.o \
194 $(OBJ_D)/rsa_ssl.o $(OBJ_D)/rsa_none.o $(OBJ_D)/dsa_gen.o \
195 $(OBJ_D)/dsa_key.o $(OBJ_D)/dsa_lib.o $(OBJ_D)/dsa_vrf.o \
196 $(OBJ_D)/dsa_sign.o $(OBJ_D)/dsa_err.o $(OBJ_D)/dh_gen.o \
197 $(OBJ_D)/dh_key.o $(OBJ_D)/dh_lib.o $(OBJ_D)/dh_check.o \
198 $(OBJ_D)/dh_err.o $(OBJ_D)/buffer.o $(OBJ_D)/buf_err.o \
199 $(OBJ_D)/bio_lib.o $(OBJ_D)/bio_cb.o $(OBJ_D)/bio_err.o \
200 $(OBJ_D)/bss_mem.o $(OBJ_D)/bss_null.o $(OBJ_D)/bss_fd.o \
201 $(OBJ_D)/bss_file.o $(OBJ_D)/bss_sock.o $(OBJ_D)/bss_conn.o \
202 $(OBJ_D)/bf_null.o $(OBJ_D)/bf_buff.o $(OBJ_D)/b_print.o \
203 $(OBJ_D)/b_dump.o $(OBJ_D)/b_sock.o $(OBJ_D)/bss_acpt.o \
204 $(OBJ_D)/bf_nbio.o $(OBJ_D)/stack.o $(OBJ_D)/lhash.o \
205 $(OBJ_D)/lh_stats.o $(OBJ_D)/md_rand.o $(OBJ_D)/randfile.o \
206 $(OBJ_D)/err.o $(OBJ_D)/err_all.o $(OBJ_D)/err_prn.o \
207 $(OBJ_D)/obj_dat.o $(OBJ_D)/obj_lib.o $(OBJ_D)/obj_err.o \
208 $(OBJ_D)/encode.o $(OBJ_D)/digest.o $(OBJ_D)/evp_enc.o \
209 $(OBJ_D)/evp_key.o $(OBJ_D)/e_ecb_d.o $(OBJ_D)/e_cbc_d.o \
210 $(OBJ_D)/e_cfb_d.o $(OBJ_D)/e_ofb_d.o $(OBJ_D)/e_ecb_i.o \
211 $(OBJ_D)/e_cbc_i.o $(OBJ_D)/e_cfb_i.o $(OBJ_D)/e_ofb_i.o \
212 $(OBJ_D)/e_ecb_3d.o $(OBJ_D)/e_cbc_3d.o $(OBJ_D)/e_rc4.o \
213 $(OBJ_D)/names.o $(OBJ_D)/e_cfb_3d.o $(OBJ_D)/e_ofb_3d.o \
214 $(OBJ_D)/e_xcbc_d.o $(OBJ_D)/e_ecb_r2.o $(OBJ_D)/e_cbc_r2.o \
215 $(OBJ_D)/e_cfb_r2.o $(OBJ_D)/e_ofb_r2.o $(OBJ_D)/e_ecb_bf.o \
216 $(OBJ_D)/e_cbc_bf.o $(OBJ_D)/e_cfb_bf.o $(OBJ_D)/e_ofb_bf.o \
217 $(OBJ_D)/e_ecb_c.o $(OBJ_D)/e_cbc_c.o $(OBJ_D)/e_cfb_c.o \
218 $(OBJ_D)/e_ofb_c.o $(OBJ_D)/e_ecb_r5.o $(OBJ_D)/e_cbc_r5.o \
219 $(OBJ_D)/e_cfb_r5.o $(OBJ_D)/e_ofb_r5.o $(OBJ_D)/m_null.o \
220 $(OBJ_D)/m_md2.o $(OBJ_D)/m_md5.o $(OBJ_D)/m_sha.o \
221 $(OBJ_D)/m_sha1.o $(OBJ_D)/m_dss.o $(OBJ_D)/m_dss1.o \
222 $(OBJ_D)/m_mdc2.o $(OBJ_D)/m_ripemd.o $(OBJ_D)/p_open.o \
223 $(OBJ_D)/p_seal.o $(OBJ_D)/p_sign.o $(OBJ_D)/p_verify.o \
224 $(OBJ_D)/p_lib.o $(OBJ_D)/p_enc.o $(OBJ_D)/p_dec.o \
225 $(OBJ_D)/bio_md.o $(OBJ_D)/bio_b64.o $(OBJ_D)/bio_enc.o \
226 $(OBJ_D)/evp_err.o $(OBJ_D)/e_null.o $(OBJ_D)/c_all.o \
227 $(OBJ_D)/evp_lib.o $(OBJ_D)/pem_sign.o $(OBJ_D)/pem_seal.o \
228 $(OBJ_D)/pem_info.o $(OBJ_D)/pem_lib.o $(OBJ_D)/pem_all.o \
229 $(OBJ_D)/pem_err.o $(OBJ_D)/a_object.o $(OBJ_D)/a_bitstr.o \
230 $(OBJ_D)/a_utctm.o $(OBJ_D)/a_int.o $(OBJ_D)/a_octet.o \
231 $(OBJ_D)/a_print.o $(OBJ_D)/a_type.o $(OBJ_D)/a_set.o \
232 $(OBJ_D)/a_dup.o $(OBJ_D)/a_d2i_fp.o $(OBJ_D)/a_i2d_fp.o \
233 $(OBJ_D)/a_sign.o $(OBJ_D)/a_digest.o $(OBJ_D)/a_verify.o \
234 $(OBJ_D)/x_algor.o $(OBJ_D)/x_val.o $(OBJ_D)/x_pubkey.o \
235 $(OBJ_D)/x_sig.o $(OBJ_D)/x_req.o $(OBJ_D)/x_attrib.o \
236 $(OBJ_D)/x_name.o $(OBJ_D)/x_cinf.o $(OBJ_D)/x_x509.o \
237 $(OBJ_D)/x_crl.o $(OBJ_D)/x_info.o $(OBJ_D)/x_spki.o \
238 $(OBJ_D)/d2i_r_pr.o $(OBJ_D)/i2d_r_pr.o $(OBJ_D)/d2i_r_pu.o \
239 $(OBJ_D)/i2d_r_pu.o $(OBJ_D)/d2i_s_pr.o $(OBJ_D)/i2d_s_pr.o \
240 $(OBJ_D)/d2i_s_pu.o $(OBJ_D)/i2d_s_pu.o $(OBJ_D)/d2i_pu.o \
241 $(OBJ_D)/d2i_pr.o $(OBJ_D)/i2d_pu.o $(OBJ_D)/i2d_pr.o \
242 $(OBJ_D)/t_req.o $(OBJ_D)/t_x509.o $(OBJ_D)/t_pkey.o \
243 $(OBJ_D)/p7_i_s.o $(OBJ_D)/p7_signi.o $(OBJ_D)/p7_signd.o \
244 $(OBJ_D)/p7_recip.o $(OBJ_D)/p7_enc_c.o $(OBJ_D)/p7_evp.o \
245 $(OBJ_D)/p7_dgst.o $(OBJ_D)/p7_s_e.o $(OBJ_D)/p7_enc.o \
246 $(OBJ_D)/p7_lib.o $(OBJ_D)/f_int.o $(OBJ_D)/f_string.o \
247 $(OBJ_D)/i2d_dhp.o $(OBJ_D)/i2d_dsap.o $(OBJ_D)/d2i_dhp.o \
248 $(OBJ_D)/d2i_dsap.o $(OBJ_D)/n_pkey.o $(OBJ_D)/a_hdr.o \
249 $(OBJ_D)/x_pkey.o $(OBJ_D)/a_bool.o $(OBJ_D)/x_exten.o \
250 $(OBJ_D)/asn1_par.o $(OBJ_D)/asn1_lib.o $(OBJ_D)/asn1_err.o \
251 $(OBJ_D)/a_meth.o $(OBJ_D)/a_bytes.o $(OBJ_D)/evp_asn1.o \
252 $(OBJ_D)/x509_def.o $(OBJ_D)/x509_d2.o $(OBJ_D)/x509_r2x.o \
253 $(OBJ_D)/x509_cmp.o $(OBJ_D)/x509_obj.o $(OBJ_D)/x509_req.o \
254 $(OBJ_D)/x509_vfy.o $(OBJ_D)/x509_set.o $(OBJ_D)/x509rset.o \
255 $(OBJ_D)/x509_err.o $(OBJ_D)/x509name.o $(OBJ_D)/x509_v3.o \
256 $(OBJ_D)/x509_ext.o $(OBJ_D)/x509pack.o $(OBJ_D)/x509type.o \
257 $(OBJ_D)/x509_lu.o $(OBJ_D)/x_all.o $(OBJ_D)/x509_txt.o \
258 $(OBJ_D)/by_file.o $(OBJ_D)/by_dir.o $(OBJ_D)/v3_net.o \
259 $(OBJ_D)/v3_x509.o $(OBJ_D)/conf.o $(OBJ_D)/conf_err.o \
260 $(OBJ_D)/txt_db.o $(OBJ_D)/pk7_lib.o $(OBJ_D)/pkcs7err.o \
261 $(OBJ_D)/pk7_doit.o
262
263SSLOBJ=$(OBJ_D)/s2_meth.o \
264 $(OBJ_D)/s2_srvr.o $(OBJ_D)/s2_clnt.o $(OBJ_D)/s2_lib.o \
265 $(OBJ_D)/s2_enc.o $(OBJ_D)/s2_pkt.o $(OBJ_D)/s3_meth.o \
266 $(OBJ_D)/s3_srvr.o $(OBJ_D)/s3_clnt.o $(OBJ_D)/s3_lib.o \
267 $(OBJ_D)/s3_enc.o $(OBJ_D)/s3_pkt.o $(OBJ_D)/s3_both.o \
268 $(OBJ_D)/s23_meth.o $(OBJ_D)/s23_srvr.o $(OBJ_D)/s23_clnt.o \
269 $(OBJ_D)/s23_lib.o $(OBJ_D)/s23_pkt.o $(OBJ_D)/t1_meth.o \
270 $(OBJ_D)/t1_srvr.o $(OBJ_D)/t1_clnt.o $(OBJ_D)/t1_lib.o \
271 $(OBJ_D)/t1_enc.o $(OBJ_D)/ssl_lib.o $(OBJ_D)/ssl_err2.o \
272 $(OBJ_D)/ssl_cert.o $(OBJ_D)/ssl_sess.o $(OBJ_D)/ssl_ciph.o \
273 $(OBJ_D)/ssl_stat.o $(OBJ_D)/ssl_rsa.o $(OBJ_D)/ssl_asn1.o \
274 $(OBJ_D)/ssl_txt.o $(OBJ_D)/ssl_algs.o $(OBJ_D)/bio_ssl.o \
275 $(OBJ_D)/ssl_err.o
276
277RSAGLUEOBJ=$(OBJ_D)/rsaref.o \
278 $(OBJ_D)/rsar_err.o
279
280T_EXE=$(TEST_D)/md2test \
281 $(TEST_D)/md5test $(TEST_D)/shatest $(TEST_D)/sha1test \
282 $(TEST_D)/mdc2test $(TEST_D)/hmactest $(TEST_D)/rmdtest \
283 $(TEST_D)/destest $(TEST_D)/rc2test $(TEST_D)/rc4test \
284 $(TEST_D)/rc5test $(TEST_D)/ideatest $(TEST_D)/bftest \
285 $(TEST_D)/casttest $(TEST_D)/bntest $(TEST_D)/exptest \
286 $(TEST_D)/dsatest $(TEST_D)/dhtest $(TEST_D)/randtest \
287 $(TEST_D)/ssltest
288
289###################################################################
290all: banner $(TMP_D) $(BIN_D) $(TEST_D) $(LIB_D) $(INC_D) headers lib exe
291
292banner:
293
294
295$(TMP_D):
296 $(MKDIR) $(TMP_D)
297
298$(BIN_D):
299 $(MKDIR) $(BIN_D)
300
301$(TEST_D):
302 $(MKDIR) $(TEST_D)
303
304$(LIB_D):
305 $(MKDIR) $(LIB_D)
306
307$(INC_D):
308 $(MKDIR) $(INC_D)
309
310headers: $(HEADER) $(EXHEADER)
311
312lib: $(LIBS_DEP)
313
314exe: $(T_EXE) $(BIN_D)/$(E_EXE)
315
316install:
317 $(MKDIR) $(INSTALLTOP)
318 $(MKDIR) $(INSTALLTOP)/bin
319 $(MKDIR) $(INSTALLTOP)/include
320 $(MKDIR) $(INSTALLTOP)/lib
321 $(CP) $(INC_D)/*.[ch] $(INSTALLTOP)/include
322 $(CP) $(BIN_D)/$(E_EXE) $(INSTALLTOP)/bin
323 $(CP) $(O_SSL) $(INSTALLTOP)/lib
324 $(CP) $(O_CRYPTO) $(INSTALLTOP)/lib
325
326clean:
327 $(RM) $(TMP_D)/*.*
328
329vclean:
330 $(RM) $(TMP_D)/*.*
331 $(RM) $(OUT_D)/*.*
332
333$(INCL_D)/cryptlib.h: $(SRC_D)/crypto/cryptlib.h
334 $(CP) $(SRC_D)/crypto/cryptlib.h $(INCL_D)/cryptlib.h
335
336$(INCL_D)/date.h: $(SRC_D)/crypto/date.h
337 $(CP) $(SRC_D)/crypto/date.h $(INCL_D)/date.h
338
339$(INCL_D)/md5_locl.h: $(SRC_D)/crypto/md5/md5_locl.h
340 $(CP) $(SRC_D)/crypto/md5/md5_locl.h $(INCL_D)/md5_locl.h
341
342$(INCL_D)/sha_locl.h: $(SRC_D)/crypto/sha/sha_locl.h
343 $(CP) $(SRC_D)/crypto/sha/sha_locl.h $(INCL_D)/sha_locl.h
344
345$(INCL_D)/rmd_locl.h: $(SRC_D)/crypto/ripemd/rmd_locl.h
346 $(CP) $(SRC_D)/crypto/ripemd/rmd_locl.h $(INCL_D)/rmd_locl.h
347
348$(INCL_D)/rmdconst.h: $(SRC_D)/crypto/ripemd/rmdconst.h
349 $(CP) $(SRC_D)/crypto/ripemd/rmdconst.h $(INCL_D)/rmdconst.h
350
351$(INCL_D)/des_locl.h: $(SRC_D)/crypto/des/des_locl.h
352 $(CP) $(SRC_D)/crypto/des/des_locl.h $(INCL_D)/des_locl.h
353
354$(INCL_D)/rpc_des.h: $(SRC_D)/crypto/des/rpc_des.h
355 $(CP) $(SRC_D)/crypto/des/rpc_des.h $(INCL_D)/rpc_des.h
356
357$(INCL_D)/podd.h: $(SRC_D)/crypto/des/podd.h
358 $(CP) $(SRC_D)/crypto/des/podd.h $(INCL_D)/podd.h
359
360$(INCL_D)/sk.h: $(SRC_D)/crypto/des/sk.h
361 $(CP) $(SRC_D)/crypto/des/sk.h $(INCL_D)/sk.h
362
363$(INCL_D)/spr.h: $(SRC_D)/crypto/des/spr.h
364 $(CP) $(SRC_D)/crypto/des/spr.h $(INCL_D)/spr.h
365
366$(INCL_D)/des_ver.h: $(SRC_D)/crypto/des/des_ver.h
367 $(CP) $(SRC_D)/crypto/des/des_ver.h $(INCL_D)/des_ver.h
368
369$(INCL_D)/rc2_locl.h: $(SRC_D)/crypto/rc2/rc2_locl.h
370 $(CP) $(SRC_D)/crypto/rc2/rc2_locl.h $(INCL_D)/rc2_locl.h
371
372$(INCL_D)/rc4_locl.h: $(SRC_D)/crypto/rc4/rc4_locl.h
373 $(CP) $(SRC_D)/crypto/rc4/rc4_locl.h $(INCL_D)/rc4_locl.h
374
375$(INCL_D)/rc5_locl.h: $(SRC_D)/crypto/rc5/rc5_locl.h
376 $(CP) $(SRC_D)/crypto/rc5/rc5_locl.h $(INCL_D)/rc5_locl.h
377
378$(INCL_D)/idea_lcl.h: $(SRC_D)/crypto/idea/idea_lcl.h
379 $(CP) $(SRC_D)/crypto/idea/idea_lcl.h $(INCL_D)/idea_lcl.h
380
381$(INCL_D)/bf_pi.h: $(SRC_D)/crypto/bf/bf_pi.h
382 $(CP) $(SRC_D)/crypto/bf/bf_pi.h $(INCL_D)/bf_pi.h
383
384$(INCL_D)/bf_locl.h: $(SRC_D)/crypto/bf/bf_locl.h
385 $(CP) $(SRC_D)/crypto/bf/bf_locl.h $(INCL_D)/bf_locl.h
386
387$(INCL_D)/cast_s.h: $(SRC_D)/crypto/cast/cast_s.h
388 $(CP) $(SRC_D)/crypto/cast/cast_s.h $(INCL_D)/cast_s.h
389
390$(INCL_D)/cast_lcl.h: $(SRC_D)/crypto/cast/cast_lcl.h
391 $(CP) $(SRC_D)/crypto/cast/cast_lcl.h $(INCL_D)/cast_lcl.h
392
393$(INCL_D)/bn_lcl.h: $(SRC_D)/crypto/bn/bn_lcl.h
394 $(CP) $(SRC_D)/crypto/bn/bn_lcl.h $(INCL_D)/bn_lcl.h
395
396$(INCL_D)/bn_prime.h: $(SRC_D)/crypto/bn/bn_prime.h
397 $(CP) $(SRC_D)/crypto/bn/bn_prime.h $(INCL_D)/bn_prime.h
398
399$(INCL_D)/obj_dat.h: $(SRC_D)/crypto/objects/obj_dat.h
400 $(CP) $(SRC_D)/crypto/objects/obj_dat.h $(INCL_D)/obj_dat.h
401
402$(INCL_D)/conf_lcl.h: $(SRC_D)/crypto/conf/conf_lcl.h
403 $(CP) $(SRC_D)/crypto/conf/conf_lcl.h $(INCL_D)/conf_lcl.h
404
405$(INCL_D)/ssl_locl.h: $(SRC_D)/ssl/ssl_locl.h
406 $(CP) $(SRC_D)/ssl/ssl_locl.h $(INCL_D)/ssl_locl.h
407
408$(INCL_D)/rsaref.h: $(SRC_D)/rsaref/rsaref.h
409 $(CP) $(SRC_D)/rsaref/rsaref.h $(INCL_D)/rsaref.h
410
411$(INCL_D)/apps.h: $(SRC_D)/apps/apps.h
412 $(CP) $(SRC_D)/apps/apps.h $(INCL_D)/apps.h
413
414$(INCL_D)/progs.h: $(SRC_D)/apps/progs.h
415 $(CP) $(SRC_D)/apps/progs.h $(INCL_D)/progs.h
416
417$(INCL_D)/s_apps.h: $(SRC_D)/apps/s_apps.h
418 $(CP) $(SRC_D)/apps/s_apps.h $(INCL_D)/s_apps.h
419
420$(INCL_D)/testdsa.h: $(SRC_D)/apps/testdsa.h
421 $(CP) $(SRC_D)/apps/testdsa.h $(INCL_D)/testdsa.h
422
423$(INCL_D)/testrsa.h: $(SRC_D)/apps/testrsa.h
424 $(CP) $(SRC_D)/apps/testrsa.h $(INCL_D)/testrsa.h
425
426$(INC_D)/e_os.h: $(SRC_D)/./e_os.h
427 $(CP) $(SRC_D)/./e_os.h $(INC_D)/e_os.h
428
429$(INC_D)/crypto.h: $(SRC_D)/crypto/crypto.h
430 $(CP) $(SRC_D)/crypto/crypto.h $(INC_D)/crypto.h
431
432$(INC_D)/cryptall.h: $(SRC_D)/crypto/cryptall.h
433 $(CP) $(SRC_D)/crypto/cryptall.h $(INC_D)/cryptall.h
434
435$(INC_D)/md2.h: $(SRC_D)/crypto/md2/md2.h
436 $(CP) $(SRC_D)/crypto/md2/md2.h $(INC_D)/md2.h
437
438$(INC_D)/md5.h: $(SRC_D)/crypto/md5/md5.h
439 $(CP) $(SRC_D)/crypto/md5/md5.h $(INC_D)/md5.h
440
441$(INC_D)/sha.h: $(SRC_D)/crypto/sha/sha.h
442 $(CP) $(SRC_D)/crypto/sha/sha.h $(INC_D)/sha.h
443
444$(INC_D)/mdc2.h: $(SRC_D)/crypto/mdc2/mdc2.h
445 $(CP) $(SRC_D)/crypto/mdc2/mdc2.h $(INC_D)/mdc2.h
446
447$(INC_D)/hmac.h: $(SRC_D)/crypto/hmac/hmac.h
448 $(CP) $(SRC_D)/crypto/hmac/hmac.h $(INC_D)/hmac.h
449
450$(INC_D)/ripemd.h: $(SRC_D)/crypto/ripemd/ripemd.h
451 $(CP) $(SRC_D)/crypto/ripemd/ripemd.h $(INC_D)/ripemd.h
452
453$(INC_D)/des.h: $(SRC_D)/crypto/des/des.h
454 $(CP) $(SRC_D)/crypto/des/des.h $(INC_D)/des.h
455
456$(INC_D)/rc2.h: $(SRC_D)/crypto/rc2/rc2.h
457 $(CP) $(SRC_D)/crypto/rc2/rc2.h $(INC_D)/rc2.h
458
459$(INC_D)/rc4.h: $(SRC_D)/crypto/rc4/rc4.h
460 $(CP) $(SRC_D)/crypto/rc4/rc4.h $(INC_D)/rc4.h
461
462$(INC_D)/rc5.h: $(SRC_D)/crypto/rc5/rc5.h
463 $(CP) $(SRC_D)/crypto/rc5/rc5.h $(INC_D)/rc5.h
464
465$(INC_D)/idea.h: $(SRC_D)/crypto/idea/idea.h
466 $(CP) $(SRC_D)/crypto/idea/idea.h $(INC_D)/idea.h
467
468$(INC_D)/blowfish.h: $(SRC_D)/crypto/bf/blowfish.h
469 $(CP) $(SRC_D)/crypto/bf/blowfish.h $(INC_D)/blowfish.h
470
471$(INC_D)/cast.h: $(SRC_D)/crypto/cast/cast.h
472 $(CP) $(SRC_D)/crypto/cast/cast.h $(INC_D)/cast.h
473
474$(INC_D)/bn.h: $(SRC_D)/crypto/bn/bn.h
475 $(CP) $(SRC_D)/crypto/bn/bn.h $(INC_D)/bn.h
476
477$(INC_D)/rsa.h: $(SRC_D)/crypto/rsa/rsa.h
478 $(CP) $(SRC_D)/crypto/rsa/rsa.h $(INC_D)/rsa.h
479
480$(INC_D)/dsa.h: $(SRC_D)/crypto/dsa/dsa.h
481 $(CP) $(SRC_D)/crypto/dsa/dsa.h $(INC_D)/dsa.h
482
483$(INC_D)/dh.h: $(SRC_D)/crypto/dh/dh.h
484 $(CP) $(SRC_D)/crypto/dh/dh.h $(INC_D)/dh.h
485
486$(INC_D)/buffer.h: $(SRC_D)/crypto/buffer/buffer.h
487 $(CP) $(SRC_D)/crypto/buffer/buffer.h $(INC_D)/buffer.h
488
489$(INC_D)/bio.h: $(SRC_D)/crypto/bio/bio.h
490 $(CP) $(SRC_D)/crypto/bio/bio.h $(INC_D)/bio.h
491
492$(INC_D)/bss_file.c: $(SRC_D)/crypto/bio/bss_file.c
493 $(CP) $(SRC_D)/crypto/bio/bss_file.c $(INC_D)/bss_file.c
494
495$(INC_D)/stack.h: $(SRC_D)/crypto/stack/stack.h
496 $(CP) $(SRC_D)/crypto/stack/stack.h $(INC_D)/stack.h
497
498$(INC_D)/lhash.h: $(SRC_D)/crypto/lhash/lhash.h
499 $(CP) $(SRC_D)/crypto/lhash/lhash.h $(INC_D)/lhash.h
500
501$(INC_D)/rand.h: $(SRC_D)/crypto/rand/rand.h
502 $(CP) $(SRC_D)/crypto/rand/rand.h $(INC_D)/rand.h
503
504$(INC_D)/err.h: $(SRC_D)/crypto/err/err.h
505 $(CP) $(SRC_D)/crypto/err/err.h $(INC_D)/err.h
506
507$(INC_D)/objects.h: $(SRC_D)/crypto/objects/objects.h
508 $(CP) $(SRC_D)/crypto/objects/objects.h $(INC_D)/objects.h
509
510$(INC_D)/evp.h: $(SRC_D)/crypto/evp/evp.h
511 $(CP) $(SRC_D)/crypto/evp/evp.h $(INC_D)/evp.h
512
513$(INC_D)/pem.h: $(SRC_D)/crypto/pem/pem.h
514 $(CP) $(SRC_D)/crypto/pem/pem.h $(INC_D)/pem.h
515
516$(INC_D)/asn1.h: $(SRC_D)/crypto/asn1/asn1.h
517 $(CP) $(SRC_D)/crypto/asn1/asn1.h $(INC_D)/asn1.h
518
519$(INC_D)/asn1_mac.h: $(SRC_D)/crypto/asn1/asn1_mac.h
520 $(CP) $(SRC_D)/crypto/asn1/asn1_mac.h $(INC_D)/asn1_mac.h
521
522$(INC_D)/x509.h: $(SRC_D)/crypto/x509/x509.h
523 $(CP) $(SRC_D)/crypto/x509/x509.h $(INC_D)/x509.h
524
525$(INC_D)/x509_vfy.h: $(SRC_D)/crypto/x509/x509_vfy.h
526 $(CP) $(SRC_D)/crypto/x509/x509_vfy.h $(INC_D)/x509_vfy.h
527
528$(INC_D)/conf.h: $(SRC_D)/crypto/conf/conf.h
529 $(CP) $(SRC_D)/crypto/conf/conf.h $(INC_D)/conf.h
530
531$(INC_D)/txt_db.h: $(SRC_D)/crypto/txt_db/txt_db.h
532 $(CP) $(SRC_D)/crypto/txt_db/txt_db.h $(INC_D)/txt_db.h
533
534$(INC_D)/pkcs7.h: $(SRC_D)/crypto/pkcs7/pkcs7.h
535 $(CP) $(SRC_D)/crypto/pkcs7/pkcs7.h $(INC_D)/pkcs7.h
536
537$(INC_D)/ssl.h: $(SRC_D)/ssl/ssl.h
538 $(CP) $(SRC_D)/ssl/ssl.h $(INC_D)/ssl.h
539
540$(INC_D)/ssl2.h: $(SRC_D)/ssl/ssl2.h
541 $(CP) $(SRC_D)/ssl/ssl2.h $(INC_D)/ssl2.h
542
543$(INC_D)/ssl3.h: $(SRC_D)/ssl/ssl3.h
544 $(CP) $(SRC_D)/ssl/ssl3.h $(INC_D)/ssl3.h
545
546$(INC_D)/ssl23.h: $(SRC_D)/ssl/ssl23.h
547 $(CP) $(SRC_D)/ssl/ssl23.h $(INC_D)/ssl23.h
548
549$(INC_D)/tls1.h: $(SRC_D)/ssl/tls1.h
550 $(CP) $(SRC_D)/ssl/tls1.h $(INC_D)/tls1.h
551
552$(OBJ_D)/md2test.o: $(SRC_D)/crypto/md2/md2test.c
553 $(CC) -o $(OBJ_D)/md2test.o $(APP_CFLAGS) -c $(SRC_D)/crypto/md2/md2test.c
554
555$(OBJ_D)/md5test.o: $(SRC_D)/crypto/md5/md5test.c
556 $(CC) -o $(OBJ_D)/md5test.o $(APP_CFLAGS) -c $(SRC_D)/crypto/md5/md5test.c
557
558$(OBJ_D)/shatest.o: $(SRC_D)/crypto/sha/shatest.c
559 $(CC) -o $(OBJ_D)/shatest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/sha/shatest.c
560
561$(OBJ_D)/sha1test.o: $(SRC_D)/crypto/sha/sha1test.c
562 $(CC) -o $(OBJ_D)/sha1test.o $(APP_CFLAGS) -c $(SRC_D)/crypto/sha/sha1test.c
563
564$(OBJ_D)/mdc2test.o: $(SRC_D)/crypto/mdc2/mdc2test.c
565 $(CC) -o $(OBJ_D)/mdc2test.o $(APP_CFLAGS) -c $(SRC_D)/crypto/mdc2/mdc2test.c
566
567$(OBJ_D)/hmactest.o: $(SRC_D)/crypto/hmac/hmactest.c
568 $(CC) -o $(OBJ_D)/hmactest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/hmac/hmactest.c
569
570$(OBJ_D)/rmdtest.o: $(SRC_D)/crypto/ripemd/rmdtest.c
571 $(CC) -o $(OBJ_D)/rmdtest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/ripemd/rmdtest.c
572
573$(OBJ_D)/destest.o: $(SRC_D)/crypto/des/destest.c
574 $(CC) -o $(OBJ_D)/destest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/des/destest.c
575
576$(OBJ_D)/rc2test.o: $(SRC_D)/crypto/rc2/rc2test.c
577 $(CC) -o $(OBJ_D)/rc2test.o $(APP_CFLAGS) -c $(SRC_D)/crypto/rc2/rc2test.c
578
579$(OBJ_D)/rc4test.o: $(SRC_D)/crypto/rc4/rc4test.c
580 $(CC) -o $(OBJ_D)/rc4test.o $(APP_CFLAGS) -c $(SRC_D)/crypto/rc4/rc4test.c
581
582$(OBJ_D)/rc5test.o: $(SRC_D)/crypto/rc5/rc5test.c
583 $(CC) -o $(OBJ_D)/rc5test.o $(APP_CFLAGS) -c $(SRC_D)/crypto/rc5/rc5test.c
584
585$(OBJ_D)/ideatest.o: $(SRC_D)/crypto/idea/ideatest.c
586 $(CC) -o $(OBJ_D)/ideatest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/idea/ideatest.c
587
588$(OBJ_D)/bftest.o: $(SRC_D)/crypto/bf/bftest.c
589 $(CC) -o $(OBJ_D)/bftest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/bf/bftest.c
590
591$(OBJ_D)/casttest.o: $(SRC_D)/crypto/cast/casttest.c
592 $(CC) -o $(OBJ_D)/casttest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/cast/casttest.c
593
594$(OBJ_D)/bntest.o: $(SRC_D)/crypto/bn/bntest.c
595 $(CC) -o $(OBJ_D)/bntest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/bn/bntest.c
596
597$(OBJ_D)/exptest.o: $(SRC_D)/crypto/bn/exptest.c
598 $(CC) -o $(OBJ_D)/exptest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/bn/exptest.c
599
600$(OBJ_D)/dsatest.o: $(SRC_D)/crypto/dsa/dsatest.c
601 $(CC) -o $(OBJ_D)/dsatest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/dsa/dsatest.c
602
603$(OBJ_D)/dhtest.o: $(SRC_D)/crypto/dh/dhtest.c
604 $(CC) -o $(OBJ_D)/dhtest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/dh/dhtest.c
605
606$(OBJ_D)/randtest.o: $(SRC_D)/crypto/rand/randtest.c
607 $(CC) -o $(OBJ_D)/randtest.o $(APP_CFLAGS) -c $(SRC_D)/crypto/rand/randtest.c
608
609$(OBJ_D)/ssltest.o: $(SRC_D)/ssl/ssltest.c
610 $(CC) -o $(OBJ_D)/ssltest.o $(APP_CFLAGS) -c $(SRC_D)/ssl/ssltest.c
611
612$(OBJ_D)/verify.o: $(SRC_D)/apps/verify.c
613 $(CC) -o $(OBJ_D)/verify.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/verify.c
614
615$(OBJ_D)/asn1pars.o: $(SRC_D)/apps/asn1pars.c
616 $(CC) -o $(OBJ_D)/asn1pars.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/asn1pars.c
617
618$(OBJ_D)/req.o: $(SRC_D)/apps/req.c
619 $(CC) -o $(OBJ_D)/req.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/req.c
620
621$(OBJ_D)/dgst.o: $(SRC_D)/apps/dgst.c
622 $(CC) -o $(OBJ_D)/dgst.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/dgst.c
623
624$(OBJ_D)/dh.o: $(SRC_D)/apps/dh.c
625 $(CC) -o $(OBJ_D)/dh.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/dh.c
626
627$(OBJ_D)/enc.o: $(SRC_D)/apps/enc.c
628 $(CC) -o $(OBJ_D)/enc.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/enc.c
629
630$(OBJ_D)/gendh.o: $(SRC_D)/apps/gendh.c
631 $(CC) -o $(OBJ_D)/gendh.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/gendh.c
632
633$(OBJ_D)/errstr.o: $(SRC_D)/apps/errstr.c
634 $(CC) -o $(OBJ_D)/errstr.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/errstr.c
635
636$(OBJ_D)/ca.o: $(SRC_D)/apps/ca.c
637 $(CC) -o $(OBJ_D)/ca.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/ca.c
638
639$(OBJ_D)/pkcs7.o: $(SRC_D)/apps/pkcs7.c
640 $(CC) -o $(OBJ_D)/pkcs7.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/pkcs7.c
641
642$(OBJ_D)/crl2p7.o: $(SRC_D)/apps/crl2p7.c
643 $(CC) -o $(OBJ_D)/crl2p7.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/crl2p7.c
644
645$(OBJ_D)/crl.o: $(SRC_D)/apps/crl.c
646 $(CC) -o $(OBJ_D)/crl.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/crl.c
647
648$(OBJ_D)/rsa.o: $(SRC_D)/apps/rsa.c
649 $(CC) -o $(OBJ_D)/rsa.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/rsa.c
650
651$(OBJ_D)/dsa.o: $(SRC_D)/apps/dsa.c
652 $(CC) -o $(OBJ_D)/dsa.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/dsa.c
653
654$(OBJ_D)/dsaparam.o: $(SRC_D)/apps/dsaparam.c
655 $(CC) -o $(OBJ_D)/dsaparam.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/dsaparam.c
656
657$(OBJ_D)/x509.o: $(SRC_D)/apps/x509.c
658 $(CC) -o $(OBJ_D)/x509.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/x509.c
659
660$(OBJ_D)/genrsa.o: $(SRC_D)/apps/genrsa.c
661 $(CC) -o $(OBJ_D)/genrsa.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/genrsa.c
662
663$(OBJ_D)/s_server.o: $(SRC_D)/apps/s_server.c
664 $(CC) -o $(OBJ_D)/s_server.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/s_server.c
665
666$(OBJ_D)/s_client.o: $(SRC_D)/apps/s_client.c
667 $(CC) -o $(OBJ_D)/s_client.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/s_client.c
668
669$(OBJ_D)/speed.o: $(SRC_D)/apps/speed.c
670 $(CC) -o $(OBJ_D)/speed.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/speed.c
671
672$(OBJ_D)/s_time.o: $(SRC_D)/apps/s_time.c
673 $(CC) -o $(OBJ_D)/s_time.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/s_time.c
674
675$(OBJ_D)/apps.o: $(SRC_D)/apps/apps.c
676 $(CC) -o $(OBJ_D)/apps.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/apps.c
677
678$(OBJ_D)/s_cb.o: $(SRC_D)/apps/s_cb.c
679 $(CC) -o $(OBJ_D)/s_cb.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/s_cb.c
680
681$(OBJ_D)/s_socket.o: $(SRC_D)/apps/s_socket.c
682 $(CC) -o $(OBJ_D)/s_socket.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/s_socket.c
683
684$(OBJ_D)/version.o: $(SRC_D)/apps/version.c
685 $(CC) -o $(OBJ_D)/version.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/version.c
686
687$(OBJ_D)/sess_id.o: $(SRC_D)/apps/sess_id.c
688 $(CC) -o $(OBJ_D)/sess_id.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/sess_id.c
689
690$(OBJ_D)/ciphers.o: $(SRC_D)/apps/ciphers.c
691 $(CC) -o $(OBJ_D)/ciphers.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/ciphers.c
692
693$(OBJ_D)/ssleay.o: $(SRC_D)/apps/ssleay.c
694 $(CC) -o $(OBJ_D)/ssleay.o -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)/apps/ssleay.c
695
696$(OBJ_D)/cryptlib.o: $(SRC_D)/crypto/cryptlib.c
697 $(CC) -o $(OBJ_D)/cryptlib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/cryptlib.c
698
699$(OBJ_D)/mem.o: $(SRC_D)/crypto/mem.c
700 $(CC) -o $(OBJ_D)/mem.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/mem.c
701
702$(OBJ_D)/cversion.o: $(SRC_D)/crypto/cversion.c
703 $(CC) -o $(OBJ_D)/cversion.o $(LIB_CFLAGS) -DCFLAGS="\"$(CC) $(CFLAG)\"" -c $(SRC_D)/crypto/cversion.c
704
705$(OBJ_D)/ex_data.o: $(SRC_D)/crypto/ex_data.c
706 $(CC) -o $(OBJ_D)/ex_data.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/ex_data.c
707
708$(OBJ_D)/cpt_err.o: $(SRC_D)/crypto/cpt_err.c
709 $(CC) -o $(OBJ_D)/cpt_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/cpt_err.c
710
711$(OBJ_D)/md2_dgst.o: $(SRC_D)/crypto/md2/md2_dgst.c
712 $(CC) -o $(OBJ_D)/md2_dgst.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/md2/md2_dgst.c
713
714$(OBJ_D)/md2_one.o: $(SRC_D)/crypto/md2/md2_one.c
715 $(CC) -o $(OBJ_D)/md2_one.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/md2/md2_one.c
716
717$(OBJ_D)/md5_dgst.o: $(SRC_D)/crypto/md5/md5_dgst.c
718 $(CC) -o $(OBJ_D)/md5_dgst.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/md5/md5_dgst.c
719
720$(OBJ_D)/md5_one.o: $(SRC_D)/crypto/md5/md5_one.c
721 $(CC) -o $(OBJ_D)/md5_one.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/md5/md5_one.c
722
723$(OBJ_D)/sha_dgst.o: $(SRC_D)/crypto/sha/sha_dgst.c
724 $(CC) -o $(OBJ_D)/sha_dgst.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/sha/sha_dgst.c
725
726$(OBJ_D)/sha1dgst.o: $(SRC_D)/crypto/sha/sha1dgst.c
727 $(CC) -o $(OBJ_D)/sha1dgst.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/sha/sha1dgst.c
728
729$(OBJ_D)/sha_one.o: $(SRC_D)/crypto/sha/sha_one.c
730 $(CC) -o $(OBJ_D)/sha_one.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/sha/sha_one.c
731
732$(OBJ_D)/sha1_one.o: $(SRC_D)/crypto/sha/sha1_one.c
733 $(CC) -o $(OBJ_D)/sha1_one.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/sha/sha1_one.c
734
735$(OBJ_D)/mdc2dgst.o: $(SRC_D)/crypto/mdc2/mdc2dgst.c
736 $(CC) -o $(OBJ_D)/mdc2dgst.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/mdc2/mdc2dgst.c
737
738$(OBJ_D)/mdc2_one.o: $(SRC_D)/crypto/mdc2/mdc2_one.c
739 $(CC) -o $(OBJ_D)/mdc2_one.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/mdc2/mdc2_one.c
740
741$(OBJ_D)/hmac.o: $(SRC_D)/crypto/hmac/hmac.c
742 $(CC) -o $(OBJ_D)/hmac.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/hmac/hmac.c
743
744$(OBJ_D)/rmd_dgst.o: $(SRC_D)/crypto/ripemd/rmd_dgst.c
745 $(CC) -o $(OBJ_D)/rmd_dgst.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/ripemd/rmd_dgst.c
746
747$(OBJ_D)/rmd_one.o: $(SRC_D)/crypto/ripemd/rmd_one.c
748 $(CC) -o $(OBJ_D)/rmd_one.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/ripemd/rmd_one.c
749
750$(OBJ_D)/set_key.o: $(SRC_D)/crypto/des/set_key.c
751 $(CC) -o $(OBJ_D)/set_key.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/set_key.c
752
753$(OBJ_D)/ecb_enc.o: $(SRC_D)/crypto/des/ecb_enc.c
754 $(CC) -o $(OBJ_D)/ecb_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/ecb_enc.c
755
756$(OBJ_D)/cbc_enc.o: $(SRC_D)/crypto/des/cbc_enc.c
757 $(CC) -o $(OBJ_D)/cbc_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/cbc_enc.c
758
759$(OBJ_D)/ecb3_enc.o: $(SRC_D)/crypto/des/ecb3_enc.c
760 $(CC) -o $(OBJ_D)/ecb3_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/ecb3_enc.c
761
762$(OBJ_D)/cfb64enc.o: $(SRC_D)/crypto/des/cfb64enc.c
763 $(CC) -o $(OBJ_D)/cfb64enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/cfb64enc.c
764
765$(OBJ_D)/cfb64ede.o: $(SRC_D)/crypto/des/cfb64ede.c
766 $(CC) -o $(OBJ_D)/cfb64ede.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/cfb64ede.c
767
768$(OBJ_D)/cfb_enc.o: $(SRC_D)/crypto/des/cfb_enc.c
769 $(CC) -o $(OBJ_D)/cfb_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/cfb_enc.c
770
771$(OBJ_D)/ofb64ede.o: $(SRC_D)/crypto/des/ofb64ede.c
772 $(CC) -o $(OBJ_D)/ofb64ede.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/ofb64ede.c
773
774$(OBJ_D)/enc_read.o: $(SRC_D)/crypto/des/enc_read.c
775 $(CC) -o $(OBJ_D)/enc_read.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/enc_read.c
776
777$(OBJ_D)/enc_writ.o: $(SRC_D)/crypto/des/enc_writ.c
778 $(CC) -o $(OBJ_D)/enc_writ.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/enc_writ.c
779
780$(OBJ_D)/ofb64enc.o: $(SRC_D)/crypto/des/ofb64enc.c
781 $(CC) -o $(OBJ_D)/ofb64enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/ofb64enc.c
782
783$(OBJ_D)/ofb_enc.o: $(SRC_D)/crypto/des/ofb_enc.c
784 $(CC) -o $(OBJ_D)/ofb_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/ofb_enc.c
785
786$(OBJ_D)/str2key.o: $(SRC_D)/crypto/des/str2key.c
787 $(CC) -o $(OBJ_D)/str2key.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/str2key.c
788
789$(OBJ_D)/pcbc_enc.o: $(SRC_D)/crypto/des/pcbc_enc.c
790 $(CC) -o $(OBJ_D)/pcbc_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/pcbc_enc.c
791
792$(OBJ_D)/qud_cksm.o: $(SRC_D)/crypto/des/qud_cksm.c
793 $(CC) -o $(OBJ_D)/qud_cksm.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/qud_cksm.c
794
795$(OBJ_D)/rand_key.o: $(SRC_D)/crypto/des/rand_key.c
796 $(CC) -o $(OBJ_D)/rand_key.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/rand_key.c
797
798$(OBJ_D)/des_enc.o: $(SRC_D)/crypto/des/des_enc.c
799 $(CC) -o $(OBJ_D)/des_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/des_enc.c
800
801$(OBJ_D)/fcrypt_b.o: $(SRC_D)/crypto/des/fcrypt_b.c
802 $(CC) -o $(OBJ_D)/fcrypt_b.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/fcrypt_b.c
803
804$(OBJ_D)/read2pwd.o: $(SRC_D)/crypto/des/read2pwd.c
805 $(CC) -o $(OBJ_D)/read2pwd.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/read2pwd.c
806
807$(OBJ_D)/fcrypt.o: $(SRC_D)/crypto/des/fcrypt.c
808 $(CC) -o $(OBJ_D)/fcrypt.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/fcrypt.c
809
810$(OBJ_D)/xcbc_enc.o: $(SRC_D)/crypto/des/xcbc_enc.c
811 $(CC) -o $(OBJ_D)/xcbc_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/xcbc_enc.c
812
813$(OBJ_D)/read_pwd.o: $(SRC_D)/crypto/des/read_pwd.c
814 $(CC) -o $(OBJ_D)/read_pwd.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/read_pwd.c
815
816$(OBJ_D)/rpc_enc.o: $(SRC_D)/crypto/des/rpc_enc.c
817 $(CC) -o $(OBJ_D)/rpc_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/rpc_enc.c
818
819$(OBJ_D)/cbc_cksm.o: $(SRC_D)/crypto/des/cbc_cksm.c
820 $(CC) -o $(OBJ_D)/cbc_cksm.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/cbc_cksm.c
821
822$(OBJ_D)/supp.o: $(SRC_D)/crypto/des/supp.c
823 $(CC) -o $(OBJ_D)/supp.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/des/supp.c
824
825$(OBJ_D)/rc2_ecb.o: $(SRC_D)/crypto/rc2/rc2_ecb.c
826 $(CC) -o $(OBJ_D)/rc2_ecb.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc2/rc2_ecb.c
827
828$(OBJ_D)/rc2_skey.o: $(SRC_D)/crypto/rc2/rc2_skey.c
829 $(CC) -o $(OBJ_D)/rc2_skey.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc2/rc2_skey.c
830
831$(OBJ_D)/rc2_cbc.o: $(SRC_D)/crypto/rc2/rc2_cbc.c
832 $(CC) -o $(OBJ_D)/rc2_cbc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc2/rc2_cbc.c
833
834$(OBJ_D)/rc2cfb64.o: $(SRC_D)/crypto/rc2/rc2cfb64.c
835 $(CC) -o $(OBJ_D)/rc2cfb64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc2/rc2cfb64.c
836
837$(OBJ_D)/rc2ofb64.o: $(SRC_D)/crypto/rc2/rc2ofb64.c
838 $(CC) -o $(OBJ_D)/rc2ofb64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc2/rc2ofb64.c
839
840$(OBJ_D)/rc4_skey.o: $(SRC_D)/crypto/rc4/rc4_skey.c
841 $(CC) -o $(OBJ_D)/rc4_skey.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc4/rc4_skey.c
842
843$(OBJ_D)/rc4_enc.o: $(SRC_D)/crypto/rc4/rc4_enc.c
844 $(CC) -o $(OBJ_D)/rc4_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc4/rc4_enc.c
845
846$(OBJ_D)/rc5_skey.o: $(SRC_D)/crypto/rc5/rc5_skey.c
847 $(CC) -o $(OBJ_D)/rc5_skey.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc5/rc5_skey.c
848
849$(OBJ_D)/rc5_ecb.o: $(SRC_D)/crypto/rc5/rc5_ecb.c
850 $(CC) -o $(OBJ_D)/rc5_ecb.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc5/rc5_ecb.c
851
852$(OBJ_D)/rc5_enc.o: $(SRC_D)/crypto/rc5/rc5_enc.c
853 $(CC) -o $(OBJ_D)/rc5_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc5/rc5_enc.c
854
855$(OBJ_D)/rc5cfb64.o: $(SRC_D)/crypto/rc5/rc5cfb64.c
856 $(CC) -o $(OBJ_D)/rc5cfb64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc5/rc5cfb64.c
857
858$(OBJ_D)/rc5ofb64.o: $(SRC_D)/crypto/rc5/rc5ofb64.c
859 $(CC) -o $(OBJ_D)/rc5ofb64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rc5/rc5ofb64.c
860
861$(OBJ_D)/i_cbc.o: $(SRC_D)/crypto/idea/i_cbc.c
862 $(CC) -o $(OBJ_D)/i_cbc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/idea/i_cbc.c
863
864$(OBJ_D)/i_cfb64.o: $(SRC_D)/crypto/idea/i_cfb64.c
865 $(CC) -o $(OBJ_D)/i_cfb64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/idea/i_cfb64.c
866
867$(OBJ_D)/i_ofb64.o: $(SRC_D)/crypto/idea/i_ofb64.c
868 $(CC) -o $(OBJ_D)/i_ofb64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/idea/i_ofb64.c
869
870$(OBJ_D)/i_ecb.o: $(SRC_D)/crypto/idea/i_ecb.c
871 $(CC) -o $(OBJ_D)/i_ecb.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/idea/i_ecb.c
872
873$(OBJ_D)/i_skey.o: $(SRC_D)/crypto/idea/i_skey.c
874 $(CC) -o $(OBJ_D)/i_skey.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/idea/i_skey.c
875
876$(OBJ_D)/bf_skey.o: $(SRC_D)/crypto/bf/bf_skey.c
877 $(CC) -o $(OBJ_D)/bf_skey.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bf/bf_skey.c
878
879$(OBJ_D)/bf_ecb.o: $(SRC_D)/crypto/bf/bf_ecb.c
880 $(CC) -o $(OBJ_D)/bf_ecb.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bf/bf_ecb.c
881
882$(OBJ_D)/bf_enc.o: $(SRC_D)/crypto/bf/bf_enc.c
883 $(CC) -o $(OBJ_D)/bf_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bf/bf_enc.c
884
885$(OBJ_D)/bf_cfb64.o: $(SRC_D)/crypto/bf/bf_cfb64.c
886 $(CC) -o $(OBJ_D)/bf_cfb64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bf/bf_cfb64.c
887
888$(OBJ_D)/bf_ofb64.o: $(SRC_D)/crypto/bf/bf_ofb64.c
889 $(CC) -o $(OBJ_D)/bf_ofb64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bf/bf_ofb64.c
890
891$(OBJ_D)/c_skey.o: $(SRC_D)/crypto/cast/c_skey.c
892 $(CC) -o $(OBJ_D)/c_skey.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/cast/c_skey.c
893
894$(OBJ_D)/c_ecb.o: $(SRC_D)/crypto/cast/c_ecb.c
895 $(CC) -o $(OBJ_D)/c_ecb.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/cast/c_ecb.c
896
897$(OBJ_D)/c_enc.o: $(SRC_D)/crypto/cast/c_enc.c
898 $(CC) -o $(OBJ_D)/c_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/cast/c_enc.c
899
900$(OBJ_D)/c_cfb64.o: $(SRC_D)/crypto/cast/c_cfb64.c
901 $(CC) -o $(OBJ_D)/c_cfb64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/cast/c_cfb64.c
902
903$(OBJ_D)/c_ofb64.o: $(SRC_D)/crypto/cast/c_ofb64.c
904 $(CC) -o $(OBJ_D)/c_ofb64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/cast/c_ofb64.c
905
906$(OBJ_D)/bn_add.o: $(SRC_D)/crypto/bn/bn_add.c
907 $(CC) -o $(OBJ_D)/bn_add.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_add.c
908
909$(OBJ_D)/bn_div.o: $(SRC_D)/crypto/bn/bn_div.c
910 $(CC) -o $(OBJ_D)/bn_div.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_div.c
911
912$(OBJ_D)/bn_exp.o: $(SRC_D)/crypto/bn/bn_exp.c
913 $(CC) -o $(OBJ_D)/bn_exp.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_exp.c
914
915$(OBJ_D)/bn_lib.o: $(SRC_D)/crypto/bn/bn_lib.c
916 $(CC) -o $(OBJ_D)/bn_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_lib.c
917
918$(OBJ_D)/bn_mod.o: $(SRC_D)/crypto/bn/bn_mod.c
919 $(CC) -o $(OBJ_D)/bn_mod.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_mod.c
920
921$(OBJ_D)/bn_mul.o: $(SRC_D)/crypto/bn/bn_mul.c
922 $(CC) -o $(OBJ_D)/bn_mul.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_mul.c
923
924$(OBJ_D)/bn_print.o: $(SRC_D)/crypto/bn/bn_print.c
925 $(CC) -o $(OBJ_D)/bn_print.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_print.c
926
927$(OBJ_D)/bn_rand.o: $(SRC_D)/crypto/bn/bn_rand.c
928 $(CC) -o $(OBJ_D)/bn_rand.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_rand.c
929
930$(OBJ_D)/bn_shift.o: $(SRC_D)/crypto/bn/bn_shift.c
931 $(CC) -o $(OBJ_D)/bn_shift.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_shift.c
932
933$(OBJ_D)/bn_sub.o: $(SRC_D)/crypto/bn/bn_sub.c
934 $(CC) -o $(OBJ_D)/bn_sub.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_sub.c
935
936$(OBJ_D)/bn_word.o: $(SRC_D)/crypto/bn/bn_word.c
937 $(CC) -o $(OBJ_D)/bn_word.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_word.c
938
939$(OBJ_D)/bn_blind.o: $(SRC_D)/crypto/bn/bn_blind.c
940 $(CC) -o $(OBJ_D)/bn_blind.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_blind.c
941
942$(OBJ_D)/bn_gcd.o: $(SRC_D)/crypto/bn/bn_gcd.c
943 $(CC) -o $(OBJ_D)/bn_gcd.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_gcd.c
944
945$(OBJ_D)/bn_prime.o: $(SRC_D)/crypto/bn/bn_prime.c
946 $(CC) -o $(OBJ_D)/bn_prime.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_prime.c
947
948$(OBJ_D)/bn_err.o: $(SRC_D)/crypto/bn/bn_err.c
949 $(CC) -o $(OBJ_D)/bn_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_err.c
950
951$(OBJ_D)/bn_sqr.o: $(SRC_D)/crypto/bn/bn_sqr.c
952 $(CC) -o $(OBJ_D)/bn_sqr.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_sqr.c
953
954$(OBJ_D)/bn_mulw.o: $(SRC_D)/crypto/bn/bn_mulw.c
955 $(CC) -o $(OBJ_D)/bn_mulw.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_mulw.c
956
957$(OBJ_D)/bn_recp.o: $(SRC_D)/crypto/bn/bn_recp.c
958 $(CC) -o $(OBJ_D)/bn_recp.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_recp.c
959
960$(OBJ_D)/bn_mont.o: $(SRC_D)/crypto/bn/bn_mont.c
961 $(CC) -o $(OBJ_D)/bn_mont.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_mont.c
962
963$(OBJ_D)/bn_mpi.o: $(SRC_D)/crypto/bn/bn_mpi.c
964 $(CC) -o $(OBJ_D)/bn_mpi.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bn/bn_mpi.c
965
966$(OBJ_D)/rsa_eay.o: $(SRC_D)/crypto/rsa/rsa_eay.c
967 $(CC) -o $(OBJ_D)/rsa_eay.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rsa/rsa_eay.c
968
969$(OBJ_D)/rsa_gen.o: $(SRC_D)/crypto/rsa/rsa_gen.c
970 $(CC) -o $(OBJ_D)/rsa_gen.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rsa/rsa_gen.c
971
972$(OBJ_D)/rsa_lib.o: $(SRC_D)/crypto/rsa/rsa_lib.c
973 $(CC) -o $(OBJ_D)/rsa_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rsa/rsa_lib.c
974
975$(OBJ_D)/rsa_sign.o: $(SRC_D)/crypto/rsa/rsa_sign.c
976 $(CC) -o $(OBJ_D)/rsa_sign.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rsa/rsa_sign.c
977
978$(OBJ_D)/rsa_saos.o: $(SRC_D)/crypto/rsa/rsa_saos.c
979 $(CC) -o $(OBJ_D)/rsa_saos.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rsa/rsa_saos.c
980
981$(OBJ_D)/rsa_err.o: $(SRC_D)/crypto/rsa/rsa_err.c
982 $(CC) -o $(OBJ_D)/rsa_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rsa/rsa_err.c
983
984$(OBJ_D)/rsa_pk1.o: $(SRC_D)/crypto/rsa/rsa_pk1.c
985 $(CC) -o $(OBJ_D)/rsa_pk1.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rsa/rsa_pk1.c
986
987$(OBJ_D)/rsa_ssl.o: $(SRC_D)/crypto/rsa/rsa_ssl.c
988 $(CC) -o $(OBJ_D)/rsa_ssl.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rsa/rsa_ssl.c
989
990$(OBJ_D)/rsa_none.o: $(SRC_D)/crypto/rsa/rsa_none.c
991 $(CC) -o $(OBJ_D)/rsa_none.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rsa/rsa_none.c
992
993$(OBJ_D)/dsa_gen.o: $(SRC_D)/crypto/dsa/dsa_gen.c
994 $(CC) -o $(OBJ_D)/dsa_gen.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dsa/dsa_gen.c
995
996$(OBJ_D)/dsa_key.o: $(SRC_D)/crypto/dsa/dsa_key.c
997 $(CC) -o $(OBJ_D)/dsa_key.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dsa/dsa_key.c
998
999$(OBJ_D)/dsa_lib.o: $(SRC_D)/crypto/dsa/dsa_lib.c
1000 $(CC) -o $(OBJ_D)/dsa_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dsa/dsa_lib.c
1001
1002$(OBJ_D)/dsa_vrf.o: $(SRC_D)/crypto/dsa/dsa_vrf.c
1003 $(CC) -o $(OBJ_D)/dsa_vrf.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dsa/dsa_vrf.c
1004
1005$(OBJ_D)/dsa_sign.o: $(SRC_D)/crypto/dsa/dsa_sign.c
1006 $(CC) -o $(OBJ_D)/dsa_sign.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dsa/dsa_sign.c
1007
1008$(OBJ_D)/dsa_err.o: $(SRC_D)/crypto/dsa/dsa_err.c
1009 $(CC) -o $(OBJ_D)/dsa_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dsa/dsa_err.c
1010
1011$(OBJ_D)/dh_gen.o: $(SRC_D)/crypto/dh/dh_gen.c
1012 $(CC) -o $(OBJ_D)/dh_gen.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dh/dh_gen.c
1013
1014$(OBJ_D)/dh_key.o: $(SRC_D)/crypto/dh/dh_key.c
1015 $(CC) -o $(OBJ_D)/dh_key.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dh/dh_key.c
1016
1017$(OBJ_D)/dh_lib.o: $(SRC_D)/crypto/dh/dh_lib.c
1018 $(CC) -o $(OBJ_D)/dh_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dh/dh_lib.c
1019
1020$(OBJ_D)/dh_check.o: $(SRC_D)/crypto/dh/dh_check.c
1021 $(CC) -o $(OBJ_D)/dh_check.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dh/dh_check.c
1022
1023$(OBJ_D)/dh_err.o: $(SRC_D)/crypto/dh/dh_err.c
1024 $(CC) -o $(OBJ_D)/dh_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/dh/dh_err.c
1025
1026$(OBJ_D)/buffer.o: $(SRC_D)/crypto/buffer/buffer.c
1027 $(CC) -o $(OBJ_D)/buffer.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/buffer/buffer.c
1028
1029$(OBJ_D)/buf_err.o: $(SRC_D)/crypto/buffer/buf_err.c
1030 $(CC) -o $(OBJ_D)/buf_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/buffer/buf_err.c
1031
1032$(OBJ_D)/bio_lib.o: $(SRC_D)/crypto/bio/bio_lib.c
1033 $(CC) -o $(OBJ_D)/bio_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bio_lib.c
1034
1035$(OBJ_D)/bio_cb.o: $(SRC_D)/crypto/bio/bio_cb.c
1036 $(CC) -o $(OBJ_D)/bio_cb.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bio_cb.c
1037
1038$(OBJ_D)/bio_err.o: $(SRC_D)/crypto/bio/bio_err.c
1039 $(CC) -o $(OBJ_D)/bio_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bio_err.c
1040
1041$(OBJ_D)/bss_mem.o: $(SRC_D)/crypto/bio/bss_mem.c
1042 $(CC) -o $(OBJ_D)/bss_mem.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bss_mem.c
1043
1044$(OBJ_D)/bss_null.o: $(SRC_D)/crypto/bio/bss_null.c
1045 $(CC) -o $(OBJ_D)/bss_null.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bss_null.c
1046
1047$(OBJ_D)/bss_fd.o: $(SRC_D)/crypto/bio/bss_fd.c
1048 $(CC) -o $(OBJ_D)/bss_fd.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bss_fd.c
1049
1050$(OBJ_D)/bss_file.o: $(SRC_D)/crypto/bio/bss_file.c
1051 $(CC) -o $(OBJ_D)/bss_file.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bss_file.c
1052
1053$(OBJ_D)/bss_sock.o: $(SRC_D)/crypto/bio/bss_sock.c
1054 $(CC) -o $(OBJ_D)/bss_sock.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bss_sock.c
1055
1056$(OBJ_D)/bss_conn.o: $(SRC_D)/crypto/bio/bss_conn.c
1057 $(CC) -o $(OBJ_D)/bss_conn.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bss_conn.c
1058
1059$(OBJ_D)/bf_null.o: $(SRC_D)/crypto/bio/bf_null.c
1060 $(CC) -o $(OBJ_D)/bf_null.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bf_null.c
1061
1062$(OBJ_D)/bf_buff.o: $(SRC_D)/crypto/bio/bf_buff.c
1063 $(CC) -o $(OBJ_D)/bf_buff.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bf_buff.c
1064
1065$(OBJ_D)/b_print.o: $(SRC_D)/crypto/bio/b_print.c
1066 $(CC) -o $(OBJ_D)/b_print.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/b_print.c
1067
1068$(OBJ_D)/b_dump.o: $(SRC_D)/crypto/bio/b_dump.c
1069 $(CC) -o $(OBJ_D)/b_dump.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/b_dump.c
1070
1071$(OBJ_D)/b_sock.o: $(SRC_D)/crypto/bio/b_sock.c
1072 $(CC) -o $(OBJ_D)/b_sock.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/b_sock.c
1073
1074$(OBJ_D)/bss_acpt.o: $(SRC_D)/crypto/bio/bss_acpt.c
1075 $(CC) -o $(OBJ_D)/bss_acpt.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bss_acpt.c
1076
1077$(OBJ_D)/bf_nbio.o: $(SRC_D)/crypto/bio/bf_nbio.c
1078 $(CC) -o $(OBJ_D)/bf_nbio.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/bio/bf_nbio.c
1079
1080$(OBJ_D)/stack.o: $(SRC_D)/crypto/stack/stack.c
1081 $(CC) -o $(OBJ_D)/stack.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/stack/stack.c
1082
1083$(OBJ_D)/lhash.o: $(SRC_D)/crypto/lhash/lhash.c
1084 $(CC) -o $(OBJ_D)/lhash.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/lhash/lhash.c
1085
1086$(OBJ_D)/lh_stats.o: $(SRC_D)/crypto/lhash/lh_stats.c
1087 $(CC) -o $(OBJ_D)/lh_stats.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/lhash/lh_stats.c
1088
1089$(OBJ_D)/md_rand.o: $(SRC_D)/crypto/rand/md_rand.c
1090 $(CC) -o $(OBJ_D)/md_rand.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rand/md_rand.c
1091
1092$(OBJ_D)/randfile.o: $(SRC_D)/crypto/rand/randfile.c
1093 $(CC) -o $(OBJ_D)/randfile.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/rand/randfile.c
1094
1095$(OBJ_D)/err.o: $(SRC_D)/crypto/err/err.c
1096 $(CC) -o $(OBJ_D)/err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/err/err.c
1097
1098$(OBJ_D)/err_all.o: $(SRC_D)/crypto/err/err_all.c
1099 $(CC) -o $(OBJ_D)/err_all.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/err/err_all.c
1100
1101$(OBJ_D)/err_prn.o: $(SRC_D)/crypto/err/err_prn.c
1102 $(CC) -o $(OBJ_D)/err_prn.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/err/err_prn.c
1103
1104$(OBJ_D)/obj_dat.o: $(SRC_D)/crypto/objects/obj_dat.c
1105 $(CC) -o $(OBJ_D)/obj_dat.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/objects/obj_dat.c
1106
1107$(OBJ_D)/obj_lib.o: $(SRC_D)/crypto/objects/obj_lib.c
1108 $(CC) -o $(OBJ_D)/obj_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/objects/obj_lib.c
1109
1110$(OBJ_D)/obj_err.o: $(SRC_D)/crypto/objects/obj_err.c
1111 $(CC) -o $(OBJ_D)/obj_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/objects/obj_err.c
1112
1113$(OBJ_D)/encode.o: $(SRC_D)/crypto/evp/encode.c
1114 $(CC) -o $(OBJ_D)/encode.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/encode.c
1115
1116$(OBJ_D)/digest.o: $(SRC_D)/crypto/evp/digest.c
1117 $(CC) -o $(OBJ_D)/digest.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/digest.c
1118
1119$(OBJ_D)/evp_enc.o: $(SRC_D)/crypto/evp/evp_enc.c
1120 $(CC) -o $(OBJ_D)/evp_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/evp_enc.c
1121
1122$(OBJ_D)/evp_key.o: $(SRC_D)/crypto/evp/evp_key.c
1123 $(CC) -o $(OBJ_D)/evp_key.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/evp_key.c
1124
1125$(OBJ_D)/e_ecb_d.o: $(SRC_D)/crypto/evp/e_ecb_d.c
1126 $(CC) -o $(OBJ_D)/e_ecb_d.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ecb_d.c
1127
1128$(OBJ_D)/e_cbc_d.o: $(SRC_D)/crypto/evp/e_cbc_d.c
1129 $(CC) -o $(OBJ_D)/e_cbc_d.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cbc_d.c
1130
1131$(OBJ_D)/e_cfb_d.o: $(SRC_D)/crypto/evp/e_cfb_d.c
1132 $(CC) -o $(OBJ_D)/e_cfb_d.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cfb_d.c
1133
1134$(OBJ_D)/e_ofb_d.o: $(SRC_D)/crypto/evp/e_ofb_d.c
1135 $(CC) -o $(OBJ_D)/e_ofb_d.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ofb_d.c
1136
1137$(OBJ_D)/e_ecb_i.o: $(SRC_D)/crypto/evp/e_ecb_i.c
1138 $(CC) -o $(OBJ_D)/e_ecb_i.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ecb_i.c
1139
1140$(OBJ_D)/e_cbc_i.o: $(SRC_D)/crypto/evp/e_cbc_i.c
1141 $(CC) -o $(OBJ_D)/e_cbc_i.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cbc_i.c
1142
1143$(OBJ_D)/e_cfb_i.o: $(SRC_D)/crypto/evp/e_cfb_i.c
1144 $(CC) -o $(OBJ_D)/e_cfb_i.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cfb_i.c
1145
1146$(OBJ_D)/e_ofb_i.o: $(SRC_D)/crypto/evp/e_ofb_i.c
1147 $(CC) -o $(OBJ_D)/e_ofb_i.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ofb_i.c
1148
1149$(OBJ_D)/e_ecb_3d.o: $(SRC_D)/crypto/evp/e_ecb_3d.c
1150 $(CC) -o $(OBJ_D)/e_ecb_3d.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ecb_3d.c
1151
1152$(OBJ_D)/e_cbc_3d.o: $(SRC_D)/crypto/evp/e_cbc_3d.c
1153 $(CC) -o $(OBJ_D)/e_cbc_3d.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cbc_3d.c
1154
1155$(OBJ_D)/e_rc4.o: $(SRC_D)/crypto/evp/e_rc4.c
1156 $(CC) -o $(OBJ_D)/e_rc4.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_rc4.c
1157
1158$(OBJ_D)/names.o: $(SRC_D)/crypto/evp/names.c
1159 $(CC) -o $(OBJ_D)/names.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/names.c
1160
1161$(OBJ_D)/e_cfb_3d.o: $(SRC_D)/crypto/evp/e_cfb_3d.c
1162 $(CC) -o $(OBJ_D)/e_cfb_3d.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cfb_3d.c
1163
1164$(OBJ_D)/e_ofb_3d.o: $(SRC_D)/crypto/evp/e_ofb_3d.c
1165 $(CC) -o $(OBJ_D)/e_ofb_3d.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ofb_3d.c
1166
1167$(OBJ_D)/e_xcbc_d.o: $(SRC_D)/crypto/evp/e_xcbc_d.c
1168 $(CC) -o $(OBJ_D)/e_xcbc_d.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_xcbc_d.c
1169
1170$(OBJ_D)/e_ecb_r2.o: $(SRC_D)/crypto/evp/e_ecb_r2.c
1171 $(CC) -o $(OBJ_D)/e_ecb_r2.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ecb_r2.c
1172
1173$(OBJ_D)/e_cbc_r2.o: $(SRC_D)/crypto/evp/e_cbc_r2.c
1174 $(CC) -o $(OBJ_D)/e_cbc_r2.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cbc_r2.c
1175
1176$(OBJ_D)/e_cfb_r2.o: $(SRC_D)/crypto/evp/e_cfb_r2.c
1177 $(CC) -o $(OBJ_D)/e_cfb_r2.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cfb_r2.c
1178
1179$(OBJ_D)/e_ofb_r2.o: $(SRC_D)/crypto/evp/e_ofb_r2.c
1180 $(CC) -o $(OBJ_D)/e_ofb_r2.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ofb_r2.c
1181
1182$(OBJ_D)/e_ecb_bf.o: $(SRC_D)/crypto/evp/e_ecb_bf.c
1183 $(CC) -o $(OBJ_D)/e_ecb_bf.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ecb_bf.c
1184
1185$(OBJ_D)/e_cbc_bf.o: $(SRC_D)/crypto/evp/e_cbc_bf.c
1186 $(CC) -o $(OBJ_D)/e_cbc_bf.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cbc_bf.c
1187
1188$(OBJ_D)/e_cfb_bf.o: $(SRC_D)/crypto/evp/e_cfb_bf.c
1189 $(CC) -o $(OBJ_D)/e_cfb_bf.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cfb_bf.c
1190
1191$(OBJ_D)/e_ofb_bf.o: $(SRC_D)/crypto/evp/e_ofb_bf.c
1192 $(CC) -o $(OBJ_D)/e_ofb_bf.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ofb_bf.c
1193
1194$(OBJ_D)/e_ecb_c.o: $(SRC_D)/crypto/evp/e_ecb_c.c
1195 $(CC) -o $(OBJ_D)/e_ecb_c.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ecb_c.c
1196
1197$(OBJ_D)/e_cbc_c.o: $(SRC_D)/crypto/evp/e_cbc_c.c
1198 $(CC) -o $(OBJ_D)/e_cbc_c.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cbc_c.c
1199
1200$(OBJ_D)/e_cfb_c.o: $(SRC_D)/crypto/evp/e_cfb_c.c
1201 $(CC) -o $(OBJ_D)/e_cfb_c.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cfb_c.c
1202
1203$(OBJ_D)/e_ofb_c.o: $(SRC_D)/crypto/evp/e_ofb_c.c
1204 $(CC) -o $(OBJ_D)/e_ofb_c.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ofb_c.c
1205
1206$(OBJ_D)/e_ecb_r5.o: $(SRC_D)/crypto/evp/e_ecb_r5.c
1207 $(CC) -o $(OBJ_D)/e_ecb_r5.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ecb_r5.c
1208
1209$(OBJ_D)/e_cbc_r5.o: $(SRC_D)/crypto/evp/e_cbc_r5.c
1210 $(CC) -o $(OBJ_D)/e_cbc_r5.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cbc_r5.c
1211
1212$(OBJ_D)/e_cfb_r5.o: $(SRC_D)/crypto/evp/e_cfb_r5.c
1213 $(CC) -o $(OBJ_D)/e_cfb_r5.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_cfb_r5.c
1214
1215$(OBJ_D)/e_ofb_r5.o: $(SRC_D)/crypto/evp/e_ofb_r5.c
1216 $(CC) -o $(OBJ_D)/e_ofb_r5.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_ofb_r5.c
1217
1218$(OBJ_D)/m_null.o: $(SRC_D)/crypto/evp/m_null.c
1219 $(CC) -o $(OBJ_D)/m_null.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/m_null.c
1220
1221$(OBJ_D)/m_md2.o: $(SRC_D)/crypto/evp/m_md2.c
1222 $(CC) -o $(OBJ_D)/m_md2.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/m_md2.c
1223
1224$(OBJ_D)/m_md5.o: $(SRC_D)/crypto/evp/m_md5.c
1225 $(CC) -o $(OBJ_D)/m_md5.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/m_md5.c
1226
1227$(OBJ_D)/m_sha.o: $(SRC_D)/crypto/evp/m_sha.c
1228 $(CC) -o $(OBJ_D)/m_sha.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/m_sha.c
1229
1230$(OBJ_D)/m_sha1.o: $(SRC_D)/crypto/evp/m_sha1.c
1231 $(CC) -o $(OBJ_D)/m_sha1.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/m_sha1.c
1232
1233$(OBJ_D)/m_dss.o: $(SRC_D)/crypto/evp/m_dss.c
1234 $(CC) -o $(OBJ_D)/m_dss.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/m_dss.c
1235
1236$(OBJ_D)/m_dss1.o: $(SRC_D)/crypto/evp/m_dss1.c
1237 $(CC) -o $(OBJ_D)/m_dss1.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/m_dss1.c
1238
1239$(OBJ_D)/m_mdc2.o: $(SRC_D)/crypto/evp/m_mdc2.c
1240 $(CC) -o $(OBJ_D)/m_mdc2.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/m_mdc2.c
1241
1242$(OBJ_D)/m_ripemd.o: $(SRC_D)/crypto/evp/m_ripemd.c
1243 $(CC) -o $(OBJ_D)/m_ripemd.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/m_ripemd.c
1244
1245$(OBJ_D)/p_open.o: $(SRC_D)/crypto/evp/p_open.c
1246 $(CC) -o $(OBJ_D)/p_open.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/p_open.c
1247
1248$(OBJ_D)/p_seal.o: $(SRC_D)/crypto/evp/p_seal.c
1249 $(CC) -o $(OBJ_D)/p_seal.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/p_seal.c
1250
1251$(OBJ_D)/p_sign.o: $(SRC_D)/crypto/evp/p_sign.c
1252 $(CC) -o $(OBJ_D)/p_sign.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/p_sign.c
1253
1254$(OBJ_D)/p_verify.o: $(SRC_D)/crypto/evp/p_verify.c
1255 $(CC) -o $(OBJ_D)/p_verify.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/p_verify.c
1256
1257$(OBJ_D)/p_lib.o: $(SRC_D)/crypto/evp/p_lib.c
1258 $(CC) -o $(OBJ_D)/p_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/p_lib.c
1259
1260$(OBJ_D)/p_enc.o: $(SRC_D)/crypto/evp/p_enc.c
1261 $(CC) -o $(OBJ_D)/p_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/p_enc.c
1262
1263$(OBJ_D)/p_dec.o: $(SRC_D)/crypto/evp/p_dec.c
1264 $(CC) -o $(OBJ_D)/p_dec.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/p_dec.c
1265
1266$(OBJ_D)/bio_md.o: $(SRC_D)/crypto/evp/bio_md.c
1267 $(CC) -o $(OBJ_D)/bio_md.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/bio_md.c
1268
1269$(OBJ_D)/bio_b64.o: $(SRC_D)/crypto/evp/bio_b64.c
1270 $(CC) -o $(OBJ_D)/bio_b64.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/bio_b64.c
1271
1272$(OBJ_D)/bio_enc.o: $(SRC_D)/crypto/evp/bio_enc.c
1273 $(CC) -o $(OBJ_D)/bio_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/bio_enc.c
1274
1275$(OBJ_D)/evp_err.o: $(SRC_D)/crypto/evp/evp_err.c
1276 $(CC) -o $(OBJ_D)/evp_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/evp_err.c
1277
1278$(OBJ_D)/e_null.o: $(SRC_D)/crypto/evp/e_null.c
1279 $(CC) -o $(OBJ_D)/e_null.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/e_null.c
1280
1281$(OBJ_D)/c_all.o: $(SRC_D)/crypto/evp/c_all.c
1282 $(CC) -o $(OBJ_D)/c_all.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/c_all.c
1283
1284$(OBJ_D)/evp_lib.o: $(SRC_D)/crypto/evp/evp_lib.c
1285 $(CC) -o $(OBJ_D)/evp_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/evp/evp_lib.c
1286
1287$(OBJ_D)/pem_sign.o: $(SRC_D)/crypto/pem/pem_sign.c
1288 $(CC) -o $(OBJ_D)/pem_sign.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/pem/pem_sign.c
1289
1290$(OBJ_D)/pem_seal.o: $(SRC_D)/crypto/pem/pem_seal.c
1291 $(CC) -o $(OBJ_D)/pem_seal.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/pem/pem_seal.c
1292
1293$(OBJ_D)/pem_info.o: $(SRC_D)/crypto/pem/pem_info.c
1294 $(CC) -o $(OBJ_D)/pem_info.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/pem/pem_info.c
1295
1296$(OBJ_D)/pem_lib.o: $(SRC_D)/crypto/pem/pem_lib.c
1297 $(CC) -o $(OBJ_D)/pem_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/pem/pem_lib.c
1298
1299$(OBJ_D)/pem_all.o: $(SRC_D)/crypto/pem/pem_all.c
1300 $(CC) -o $(OBJ_D)/pem_all.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/pem/pem_all.c
1301
1302$(OBJ_D)/pem_err.o: $(SRC_D)/crypto/pem/pem_err.c
1303 $(CC) -o $(OBJ_D)/pem_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/pem/pem_err.c
1304
1305$(OBJ_D)/a_object.o: $(SRC_D)/crypto/asn1/a_object.c
1306 $(CC) -o $(OBJ_D)/a_object.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_object.c
1307
1308$(OBJ_D)/a_bitstr.o: $(SRC_D)/crypto/asn1/a_bitstr.c
1309 $(CC) -o $(OBJ_D)/a_bitstr.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_bitstr.c
1310
1311$(OBJ_D)/a_utctm.o: $(SRC_D)/crypto/asn1/a_utctm.c
1312 $(CC) -o $(OBJ_D)/a_utctm.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_utctm.c
1313
1314$(OBJ_D)/a_int.o: $(SRC_D)/crypto/asn1/a_int.c
1315 $(CC) -o $(OBJ_D)/a_int.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_int.c
1316
1317$(OBJ_D)/a_octet.o: $(SRC_D)/crypto/asn1/a_octet.c
1318 $(CC) -o $(OBJ_D)/a_octet.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_octet.c
1319
1320$(OBJ_D)/a_print.o: $(SRC_D)/crypto/asn1/a_print.c
1321 $(CC) -o $(OBJ_D)/a_print.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_print.c
1322
1323$(OBJ_D)/a_type.o: $(SRC_D)/crypto/asn1/a_type.c
1324 $(CC) -o $(OBJ_D)/a_type.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_type.c
1325
1326$(OBJ_D)/a_set.o: $(SRC_D)/crypto/asn1/a_set.c
1327 $(CC) -o $(OBJ_D)/a_set.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_set.c
1328
1329$(OBJ_D)/a_dup.o: $(SRC_D)/crypto/asn1/a_dup.c
1330 $(CC) -o $(OBJ_D)/a_dup.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_dup.c
1331
1332$(OBJ_D)/a_d2i_fp.o: $(SRC_D)/crypto/asn1/a_d2i_fp.c
1333 $(CC) -o $(OBJ_D)/a_d2i_fp.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_d2i_fp.c
1334
1335$(OBJ_D)/a_i2d_fp.o: $(SRC_D)/crypto/asn1/a_i2d_fp.c
1336 $(CC) -o $(OBJ_D)/a_i2d_fp.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_i2d_fp.c
1337
1338$(OBJ_D)/a_sign.o: $(SRC_D)/crypto/asn1/a_sign.c
1339 $(CC) -o $(OBJ_D)/a_sign.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_sign.c
1340
1341$(OBJ_D)/a_digest.o: $(SRC_D)/crypto/asn1/a_digest.c
1342 $(CC) -o $(OBJ_D)/a_digest.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_digest.c
1343
1344$(OBJ_D)/a_verify.o: $(SRC_D)/crypto/asn1/a_verify.c
1345 $(CC) -o $(OBJ_D)/a_verify.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_verify.c
1346
1347$(OBJ_D)/x_algor.o: $(SRC_D)/crypto/asn1/x_algor.c
1348 $(CC) -o $(OBJ_D)/x_algor.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_algor.c
1349
1350$(OBJ_D)/x_val.o: $(SRC_D)/crypto/asn1/x_val.c
1351 $(CC) -o $(OBJ_D)/x_val.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_val.c
1352
1353$(OBJ_D)/x_pubkey.o: $(SRC_D)/crypto/asn1/x_pubkey.c
1354 $(CC) -o $(OBJ_D)/x_pubkey.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_pubkey.c
1355
1356$(OBJ_D)/x_sig.o: $(SRC_D)/crypto/asn1/x_sig.c
1357 $(CC) -o $(OBJ_D)/x_sig.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_sig.c
1358
1359$(OBJ_D)/x_req.o: $(SRC_D)/crypto/asn1/x_req.c
1360 $(CC) -o $(OBJ_D)/x_req.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_req.c
1361
1362$(OBJ_D)/x_attrib.o: $(SRC_D)/crypto/asn1/x_attrib.c
1363 $(CC) -o $(OBJ_D)/x_attrib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_attrib.c
1364
1365$(OBJ_D)/x_name.o: $(SRC_D)/crypto/asn1/x_name.c
1366 $(CC) -o $(OBJ_D)/x_name.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_name.c
1367
1368$(OBJ_D)/x_cinf.o: $(SRC_D)/crypto/asn1/x_cinf.c
1369 $(CC) -o $(OBJ_D)/x_cinf.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_cinf.c
1370
1371$(OBJ_D)/x_x509.o: $(SRC_D)/crypto/asn1/x_x509.c
1372 $(CC) -o $(OBJ_D)/x_x509.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_x509.c
1373
1374$(OBJ_D)/x_crl.o: $(SRC_D)/crypto/asn1/x_crl.c
1375 $(CC) -o $(OBJ_D)/x_crl.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_crl.c
1376
1377$(OBJ_D)/x_info.o: $(SRC_D)/crypto/asn1/x_info.c
1378 $(CC) -o $(OBJ_D)/x_info.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_info.c
1379
1380$(OBJ_D)/x_spki.o: $(SRC_D)/crypto/asn1/x_spki.c
1381 $(CC) -o $(OBJ_D)/x_spki.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_spki.c
1382
1383$(OBJ_D)/d2i_r_pr.o: $(SRC_D)/crypto/asn1/d2i_r_pr.c
1384 $(CC) -o $(OBJ_D)/d2i_r_pr.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/d2i_r_pr.c
1385
1386$(OBJ_D)/i2d_r_pr.o: $(SRC_D)/crypto/asn1/i2d_r_pr.c
1387 $(CC) -o $(OBJ_D)/i2d_r_pr.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/i2d_r_pr.c
1388
1389$(OBJ_D)/d2i_r_pu.o: $(SRC_D)/crypto/asn1/d2i_r_pu.c
1390 $(CC) -o $(OBJ_D)/d2i_r_pu.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/d2i_r_pu.c
1391
1392$(OBJ_D)/i2d_r_pu.o: $(SRC_D)/crypto/asn1/i2d_r_pu.c
1393 $(CC) -o $(OBJ_D)/i2d_r_pu.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/i2d_r_pu.c
1394
1395$(OBJ_D)/d2i_s_pr.o: $(SRC_D)/crypto/asn1/d2i_s_pr.c
1396 $(CC) -o $(OBJ_D)/d2i_s_pr.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/d2i_s_pr.c
1397
1398$(OBJ_D)/i2d_s_pr.o: $(SRC_D)/crypto/asn1/i2d_s_pr.c
1399 $(CC) -o $(OBJ_D)/i2d_s_pr.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/i2d_s_pr.c
1400
1401$(OBJ_D)/d2i_s_pu.o: $(SRC_D)/crypto/asn1/d2i_s_pu.c
1402 $(CC) -o $(OBJ_D)/d2i_s_pu.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/d2i_s_pu.c
1403
1404$(OBJ_D)/i2d_s_pu.o: $(SRC_D)/crypto/asn1/i2d_s_pu.c
1405 $(CC) -o $(OBJ_D)/i2d_s_pu.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/i2d_s_pu.c
1406
1407$(OBJ_D)/d2i_pu.o: $(SRC_D)/crypto/asn1/d2i_pu.c
1408 $(CC) -o $(OBJ_D)/d2i_pu.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/d2i_pu.c
1409
1410$(OBJ_D)/d2i_pr.o: $(SRC_D)/crypto/asn1/d2i_pr.c
1411 $(CC) -o $(OBJ_D)/d2i_pr.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/d2i_pr.c
1412
1413$(OBJ_D)/i2d_pu.o: $(SRC_D)/crypto/asn1/i2d_pu.c
1414 $(CC) -o $(OBJ_D)/i2d_pu.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/i2d_pu.c
1415
1416$(OBJ_D)/i2d_pr.o: $(SRC_D)/crypto/asn1/i2d_pr.c
1417 $(CC) -o $(OBJ_D)/i2d_pr.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/i2d_pr.c
1418
1419$(OBJ_D)/t_req.o: $(SRC_D)/crypto/asn1/t_req.c
1420 $(CC) -o $(OBJ_D)/t_req.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/t_req.c
1421
1422$(OBJ_D)/t_x509.o: $(SRC_D)/crypto/asn1/t_x509.c
1423 $(CC) -o $(OBJ_D)/t_x509.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/t_x509.c
1424
1425$(OBJ_D)/t_pkey.o: $(SRC_D)/crypto/asn1/t_pkey.c
1426 $(CC) -o $(OBJ_D)/t_pkey.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/t_pkey.c
1427
1428$(OBJ_D)/p7_i_s.o: $(SRC_D)/crypto/asn1/p7_i_s.c
1429 $(CC) -o $(OBJ_D)/p7_i_s.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/p7_i_s.c
1430
1431$(OBJ_D)/p7_signi.o: $(SRC_D)/crypto/asn1/p7_signi.c
1432 $(CC) -o $(OBJ_D)/p7_signi.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/p7_signi.c
1433
1434$(OBJ_D)/p7_signd.o: $(SRC_D)/crypto/asn1/p7_signd.c
1435 $(CC) -o $(OBJ_D)/p7_signd.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/p7_signd.c
1436
1437$(OBJ_D)/p7_recip.o: $(SRC_D)/crypto/asn1/p7_recip.c
1438 $(CC) -o $(OBJ_D)/p7_recip.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/p7_recip.c
1439
1440$(OBJ_D)/p7_enc_c.o: $(SRC_D)/crypto/asn1/p7_enc_c.c
1441 $(CC) -o $(OBJ_D)/p7_enc_c.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/p7_enc_c.c
1442
1443$(OBJ_D)/p7_evp.o: $(SRC_D)/crypto/asn1/p7_evp.c
1444 $(CC) -o $(OBJ_D)/p7_evp.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/p7_evp.c
1445
1446$(OBJ_D)/p7_dgst.o: $(SRC_D)/crypto/asn1/p7_dgst.c
1447 $(CC) -o $(OBJ_D)/p7_dgst.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/p7_dgst.c
1448
1449$(OBJ_D)/p7_s_e.o: $(SRC_D)/crypto/asn1/p7_s_e.c
1450 $(CC) -o $(OBJ_D)/p7_s_e.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/p7_s_e.c
1451
1452$(OBJ_D)/p7_enc.o: $(SRC_D)/crypto/asn1/p7_enc.c
1453 $(CC) -o $(OBJ_D)/p7_enc.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/p7_enc.c
1454
1455$(OBJ_D)/p7_lib.o: $(SRC_D)/crypto/asn1/p7_lib.c
1456 $(CC) -o $(OBJ_D)/p7_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/p7_lib.c
1457
1458$(OBJ_D)/f_int.o: $(SRC_D)/crypto/asn1/f_int.c
1459 $(CC) -o $(OBJ_D)/f_int.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/f_int.c
1460
1461$(OBJ_D)/f_string.o: $(SRC_D)/crypto/asn1/f_string.c
1462 $(CC) -o $(OBJ_D)/f_string.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/f_string.c
1463
1464$(OBJ_D)/i2d_dhp.o: $(SRC_D)/crypto/asn1/i2d_dhp.c
1465 $(CC) -o $(OBJ_D)/i2d_dhp.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/i2d_dhp.c
1466
1467$(OBJ_D)/i2d_dsap.o: $(SRC_D)/crypto/asn1/i2d_dsap.c
1468 $(CC) -o $(OBJ_D)/i2d_dsap.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/i2d_dsap.c
1469
1470$(OBJ_D)/d2i_dhp.o: $(SRC_D)/crypto/asn1/d2i_dhp.c
1471 $(CC) -o $(OBJ_D)/d2i_dhp.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/d2i_dhp.c
1472
1473$(OBJ_D)/d2i_dsap.o: $(SRC_D)/crypto/asn1/d2i_dsap.c
1474 $(CC) -o $(OBJ_D)/d2i_dsap.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/d2i_dsap.c
1475
1476$(OBJ_D)/n_pkey.o: $(SRC_D)/crypto/asn1/n_pkey.c
1477 $(CC) -o $(OBJ_D)/n_pkey.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/n_pkey.c
1478
1479$(OBJ_D)/a_hdr.o: $(SRC_D)/crypto/asn1/a_hdr.c
1480 $(CC) -o $(OBJ_D)/a_hdr.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_hdr.c
1481
1482$(OBJ_D)/x_pkey.o: $(SRC_D)/crypto/asn1/x_pkey.c
1483 $(CC) -o $(OBJ_D)/x_pkey.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_pkey.c
1484
1485$(OBJ_D)/a_bool.o: $(SRC_D)/crypto/asn1/a_bool.c
1486 $(CC) -o $(OBJ_D)/a_bool.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_bool.c
1487
1488$(OBJ_D)/x_exten.o: $(SRC_D)/crypto/asn1/x_exten.c
1489 $(CC) -o $(OBJ_D)/x_exten.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/x_exten.c
1490
1491$(OBJ_D)/asn1_par.o: $(SRC_D)/crypto/asn1/asn1_par.c
1492 $(CC) -o $(OBJ_D)/asn1_par.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/asn1_par.c
1493
1494$(OBJ_D)/asn1_lib.o: $(SRC_D)/crypto/asn1/asn1_lib.c
1495 $(CC) -o $(OBJ_D)/asn1_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/asn1_lib.c
1496
1497$(OBJ_D)/asn1_err.o: $(SRC_D)/crypto/asn1/asn1_err.c
1498 $(CC) -o $(OBJ_D)/asn1_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/asn1_err.c
1499
1500$(OBJ_D)/a_meth.o: $(SRC_D)/crypto/asn1/a_meth.c
1501 $(CC) -o $(OBJ_D)/a_meth.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_meth.c
1502
1503$(OBJ_D)/a_bytes.o: $(SRC_D)/crypto/asn1/a_bytes.c
1504 $(CC) -o $(OBJ_D)/a_bytes.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/a_bytes.c
1505
1506$(OBJ_D)/evp_asn1.o: $(SRC_D)/crypto/asn1/evp_asn1.c
1507 $(CC) -o $(OBJ_D)/evp_asn1.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/asn1/evp_asn1.c
1508
1509$(OBJ_D)/x509_def.o: $(SRC_D)/crypto/x509/x509_def.c
1510 $(CC) -o $(OBJ_D)/x509_def.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_def.c
1511
1512$(OBJ_D)/x509_d2.o: $(SRC_D)/crypto/x509/x509_d2.c
1513 $(CC) -o $(OBJ_D)/x509_d2.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_d2.c
1514
1515$(OBJ_D)/x509_r2x.o: $(SRC_D)/crypto/x509/x509_r2x.c
1516 $(CC) -o $(OBJ_D)/x509_r2x.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_r2x.c
1517
1518$(OBJ_D)/x509_cmp.o: $(SRC_D)/crypto/x509/x509_cmp.c
1519 $(CC) -o $(OBJ_D)/x509_cmp.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_cmp.c
1520
1521$(OBJ_D)/x509_obj.o: $(SRC_D)/crypto/x509/x509_obj.c
1522 $(CC) -o $(OBJ_D)/x509_obj.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_obj.c
1523
1524$(OBJ_D)/x509_req.o: $(SRC_D)/crypto/x509/x509_req.c
1525 $(CC) -o $(OBJ_D)/x509_req.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_req.c
1526
1527$(OBJ_D)/x509_vfy.o: $(SRC_D)/crypto/x509/x509_vfy.c
1528 $(CC) -o $(OBJ_D)/x509_vfy.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_vfy.c
1529
1530$(OBJ_D)/x509_set.o: $(SRC_D)/crypto/x509/x509_set.c
1531 $(CC) -o $(OBJ_D)/x509_set.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_set.c
1532
1533$(OBJ_D)/x509rset.o: $(SRC_D)/crypto/x509/x509rset.c
1534 $(CC) -o $(OBJ_D)/x509rset.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509rset.c
1535
1536$(OBJ_D)/x509_err.o: $(SRC_D)/crypto/x509/x509_err.c
1537 $(CC) -o $(OBJ_D)/x509_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_err.c
1538
1539$(OBJ_D)/x509name.o: $(SRC_D)/crypto/x509/x509name.c
1540 $(CC) -o $(OBJ_D)/x509name.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509name.c
1541
1542$(OBJ_D)/x509_v3.o: $(SRC_D)/crypto/x509/x509_v3.c
1543 $(CC) -o $(OBJ_D)/x509_v3.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_v3.c
1544
1545$(OBJ_D)/x509_ext.o: $(SRC_D)/crypto/x509/x509_ext.c
1546 $(CC) -o $(OBJ_D)/x509_ext.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_ext.c
1547
1548$(OBJ_D)/x509pack.o: $(SRC_D)/crypto/x509/x509pack.c
1549 $(CC) -o $(OBJ_D)/x509pack.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509pack.c
1550
1551$(OBJ_D)/x509type.o: $(SRC_D)/crypto/x509/x509type.c
1552 $(CC) -o $(OBJ_D)/x509type.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509type.c
1553
1554$(OBJ_D)/x509_lu.o: $(SRC_D)/crypto/x509/x509_lu.c
1555 $(CC) -o $(OBJ_D)/x509_lu.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_lu.c
1556
1557$(OBJ_D)/x_all.o: $(SRC_D)/crypto/x509/x_all.c
1558 $(CC) -o $(OBJ_D)/x_all.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x_all.c
1559
1560$(OBJ_D)/x509_txt.o: $(SRC_D)/crypto/x509/x509_txt.c
1561 $(CC) -o $(OBJ_D)/x509_txt.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/x509_txt.c
1562
1563$(OBJ_D)/by_file.o: $(SRC_D)/crypto/x509/by_file.c
1564 $(CC) -o $(OBJ_D)/by_file.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/by_file.c
1565
1566$(OBJ_D)/by_dir.o: $(SRC_D)/crypto/x509/by_dir.c
1567 $(CC) -o $(OBJ_D)/by_dir.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/by_dir.c
1568
1569$(OBJ_D)/v3_net.o: $(SRC_D)/crypto/x509/v3_net.c
1570 $(CC) -o $(OBJ_D)/v3_net.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/v3_net.c
1571
1572$(OBJ_D)/v3_x509.o: $(SRC_D)/crypto/x509/v3_x509.c
1573 $(CC) -o $(OBJ_D)/v3_x509.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/x509/v3_x509.c
1574
1575$(OBJ_D)/conf.o: $(SRC_D)/crypto/conf/conf.c
1576 $(CC) -o $(OBJ_D)/conf.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/conf/conf.c
1577
1578$(OBJ_D)/conf_err.o: $(SRC_D)/crypto/conf/conf_err.c
1579 $(CC) -o $(OBJ_D)/conf_err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/conf/conf_err.c
1580
1581$(OBJ_D)/txt_db.o: $(SRC_D)/crypto/txt_db/txt_db.c
1582 $(CC) -o $(OBJ_D)/txt_db.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/txt_db/txt_db.c
1583
1584$(OBJ_D)/pk7_lib.o: $(SRC_D)/crypto/pkcs7/pk7_lib.c
1585 $(CC) -o $(OBJ_D)/pk7_lib.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/pkcs7/pk7_lib.c
1586
1587$(OBJ_D)/pkcs7err.o: $(SRC_D)/crypto/pkcs7/pkcs7err.c
1588 $(CC) -o $(OBJ_D)/pkcs7err.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/pkcs7/pkcs7err.c
1589
1590$(OBJ_D)/pk7_doit.o: $(SRC_D)/crypto/pkcs7/pk7_doit.c
1591 $(CC) -o $(OBJ_D)/pk7_doit.o $(LIB_CFLAGS) -c $(SRC_D)/crypto/pkcs7/pk7_doit.c
1592
1593$(OBJ_D)/s2_meth.o: $(SRC_D)/ssl/s2_meth.c
1594 $(CC) -o $(OBJ_D)/s2_meth.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s2_meth.c
1595
1596$(OBJ_D)/s2_srvr.o: $(SRC_D)/ssl/s2_srvr.c
1597 $(CC) -o $(OBJ_D)/s2_srvr.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s2_srvr.c
1598
1599$(OBJ_D)/s2_clnt.o: $(SRC_D)/ssl/s2_clnt.c
1600 $(CC) -o $(OBJ_D)/s2_clnt.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s2_clnt.c
1601
1602$(OBJ_D)/s2_lib.o: $(SRC_D)/ssl/s2_lib.c
1603 $(CC) -o $(OBJ_D)/s2_lib.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s2_lib.c
1604
1605$(OBJ_D)/s2_enc.o: $(SRC_D)/ssl/s2_enc.c
1606 $(CC) -o $(OBJ_D)/s2_enc.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s2_enc.c
1607
1608$(OBJ_D)/s2_pkt.o: $(SRC_D)/ssl/s2_pkt.c
1609 $(CC) -o $(OBJ_D)/s2_pkt.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s2_pkt.c
1610
1611$(OBJ_D)/s3_meth.o: $(SRC_D)/ssl/s3_meth.c
1612 $(CC) -o $(OBJ_D)/s3_meth.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s3_meth.c
1613
1614$(OBJ_D)/s3_srvr.o: $(SRC_D)/ssl/s3_srvr.c
1615 $(CC) -o $(OBJ_D)/s3_srvr.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s3_srvr.c
1616
1617$(OBJ_D)/s3_clnt.o: $(SRC_D)/ssl/s3_clnt.c
1618 $(CC) -o $(OBJ_D)/s3_clnt.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s3_clnt.c
1619
1620$(OBJ_D)/s3_lib.o: $(SRC_D)/ssl/s3_lib.c
1621 $(CC) -o $(OBJ_D)/s3_lib.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s3_lib.c
1622
1623$(OBJ_D)/s3_enc.o: $(SRC_D)/ssl/s3_enc.c
1624 $(CC) -o $(OBJ_D)/s3_enc.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s3_enc.c
1625
1626$(OBJ_D)/s3_pkt.o: $(SRC_D)/ssl/s3_pkt.c
1627 $(CC) -o $(OBJ_D)/s3_pkt.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s3_pkt.c
1628
1629$(OBJ_D)/s3_both.o: $(SRC_D)/ssl/s3_both.c
1630 $(CC) -o $(OBJ_D)/s3_both.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s3_both.c
1631
1632$(OBJ_D)/s23_meth.o: $(SRC_D)/ssl/s23_meth.c
1633 $(CC) -o $(OBJ_D)/s23_meth.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s23_meth.c
1634
1635$(OBJ_D)/s23_srvr.o: $(SRC_D)/ssl/s23_srvr.c
1636 $(CC) -o $(OBJ_D)/s23_srvr.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s23_srvr.c
1637
1638$(OBJ_D)/s23_clnt.o: $(SRC_D)/ssl/s23_clnt.c
1639 $(CC) -o $(OBJ_D)/s23_clnt.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s23_clnt.c
1640
1641$(OBJ_D)/s23_lib.o: $(SRC_D)/ssl/s23_lib.c
1642 $(CC) -o $(OBJ_D)/s23_lib.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s23_lib.c
1643
1644$(OBJ_D)/s23_pkt.o: $(SRC_D)/ssl/s23_pkt.c
1645 $(CC) -o $(OBJ_D)/s23_pkt.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/s23_pkt.c
1646
1647$(OBJ_D)/t1_meth.o: $(SRC_D)/ssl/t1_meth.c
1648 $(CC) -o $(OBJ_D)/t1_meth.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/t1_meth.c
1649
1650$(OBJ_D)/t1_srvr.o: $(SRC_D)/ssl/t1_srvr.c
1651 $(CC) -o $(OBJ_D)/t1_srvr.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/t1_srvr.c
1652
1653$(OBJ_D)/t1_clnt.o: $(SRC_D)/ssl/t1_clnt.c
1654 $(CC) -o $(OBJ_D)/t1_clnt.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/t1_clnt.c
1655
1656$(OBJ_D)/t1_lib.o: $(SRC_D)/ssl/t1_lib.c
1657 $(CC) -o $(OBJ_D)/t1_lib.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/t1_lib.c
1658
1659$(OBJ_D)/t1_enc.o: $(SRC_D)/ssl/t1_enc.c
1660 $(CC) -o $(OBJ_D)/t1_enc.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/t1_enc.c
1661
1662$(OBJ_D)/ssl_lib.o: $(SRC_D)/ssl/ssl_lib.c
1663 $(CC) -o $(OBJ_D)/ssl_lib.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_lib.c
1664
1665$(OBJ_D)/ssl_err2.o: $(SRC_D)/ssl/ssl_err2.c
1666 $(CC) -o $(OBJ_D)/ssl_err2.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_err2.c
1667
1668$(OBJ_D)/ssl_cert.o: $(SRC_D)/ssl/ssl_cert.c
1669 $(CC) -o $(OBJ_D)/ssl_cert.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_cert.c
1670
1671$(OBJ_D)/ssl_sess.o: $(SRC_D)/ssl/ssl_sess.c
1672 $(CC) -o $(OBJ_D)/ssl_sess.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_sess.c
1673
1674$(OBJ_D)/ssl_ciph.o: $(SRC_D)/ssl/ssl_ciph.c
1675 $(CC) -o $(OBJ_D)/ssl_ciph.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_ciph.c
1676
1677$(OBJ_D)/ssl_stat.o: $(SRC_D)/ssl/ssl_stat.c
1678 $(CC) -o $(OBJ_D)/ssl_stat.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_stat.c
1679
1680$(OBJ_D)/ssl_rsa.o: $(SRC_D)/ssl/ssl_rsa.c
1681 $(CC) -o $(OBJ_D)/ssl_rsa.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_rsa.c
1682
1683$(OBJ_D)/ssl_asn1.o: $(SRC_D)/ssl/ssl_asn1.c
1684 $(CC) -o $(OBJ_D)/ssl_asn1.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_asn1.c
1685
1686$(OBJ_D)/ssl_txt.o: $(SRC_D)/ssl/ssl_txt.c
1687 $(CC) -o $(OBJ_D)/ssl_txt.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_txt.c
1688
1689$(OBJ_D)/ssl_algs.o: $(SRC_D)/ssl/ssl_algs.c
1690 $(CC) -o $(OBJ_D)/ssl_algs.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_algs.c
1691
1692$(OBJ_D)/bio_ssl.o: $(SRC_D)/ssl/bio_ssl.c
1693 $(CC) -o $(OBJ_D)/bio_ssl.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/bio_ssl.c
1694
1695$(OBJ_D)/ssl_err.o: $(SRC_D)/ssl/ssl_err.c
1696 $(CC) -o $(OBJ_D)/ssl_err.o $(LIB_CFLAGS) -c $(SRC_D)/ssl/ssl_err.c
1697
1698$(OBJ_D)/rsaref.o: $(SRC_D)/rsaref/rsaref.c
1699 $(CC) -o $(OBJ_D)/rsaref.o $(LIB_CFLAGS) -c $(SRC_D)/rsaref/rsaref.c
1700
1701$(OBJ_D)/rsar_err.o: $(SRC_D)/rsaref/rsar_err.c
1702 $(CC) -o $(OBJ_D)/rsar_err.o $(LIB_CFLAGS) -c $(SRC_D)/rsaref/rsar_err.c
1703
1704$(TEST_D)/md2test: $(OBJ_D)/md2test.o $(LIBS_DEP)
1705 $(LINK) -o $(TEST_D)/md2test $(LFLAGS) $(OBJ_D)/md2test.o $(L_LIBS) $(EX_LIBS)
1706
1707$(TEST_D)/md5test: $(OBJ_D)/md5test.o $(LIBS_DEP)
1708 $(LINK) -o $(TEST_D)/md5test $(LFLAGS) $(OBJ_D)/md5test.o $(L_LIBS) $(EX_LIBS)
1709
1710$(TEST_D)/shatest: $(OBJ_D)/shatest.o $(LIBS_DEP)
1711 $(LINK) -o $(TEST_D)/shatest $(LFLAGS) $(OBJ_D)/shatest.o $(L_LIBS) $(EX_LIBS)
1712
1713$(TEST_D)/sha1test: $(OBJ_D)/sha1test.o $(LIBS_DEP)
1714 $(LINK) -o $(TEST_D)/sha1test $(LFLAGS) $(OBJ_D)/sha1test.o $(L_LIBS) $(EX_LIBS)
1715
1716$(TEST_D)/mdc2test: $(OBJ_D)/mdc2test.o $(LIBS_DEP)
1717 $(LINK) -o $(TEST_D)/mdc2test $(LFLAGS) $(OBJ_D)/mdc2test.o $(L_LIBS) $(EX_LIBS)
1718
1719$(TEST_D)/hmactest: $(OBJ_D)/hmactest.o $(LIBS_DEP)
1720 $(LINK) -o $(TEST_D)/hmactest $(LFLAGS) $(OBJ_D)/hmactest.o $(L_LIBS) $(EX_LIBS)
1721
1722$(TEST_D)/rmdtest: $(OBJ_D)/rmdtest.o $(LIBS_DEP)
1723 $(LINK) -o $(TEST_D)/rmdtest $(LFLAGS) $(OBJ_D)/rmdtest.o $(L_LIBS) $(EX_LIBS)
1724
1725$(TEST_D)/destest: $(OBJ_D)/destest.o $(LIBS_DEP)
1726 $(LINK) -o $(TEST_D)/destest $(LFLAGS) $(OBJ_D)/destest.o $(L_LIBS) $(EX_LIBS)
1727
1728$(TEST_D)/rc2test: $(OBJ_D)/rc2test.o $(LIBS_DEP)
1729 $(LINK) -o $(TEST_D)/rc2test $(LFLAGS) $(OBJ_D)/rc2test.o $(L_LIBS) $(EX_LIBS)
1730
1731$(TEST_D)/rc4test: $(OBJ_D)/rc4test.o $(LIBS_DEP)
1732 $(LINK) -o $(TEST_D)/rc4test $(LFLAGS) $(OBJ_D)/rc4test.o $(L_LIBS) $(EX_LIBS)
1733
1734$(TEST_D)/rc5test: $(OBJ_D)/rc5test.o $(LIBS_DEP)
1735 $(LINK) -o $(TEST_D)/rc5test $(LFLAGS) $(OBJ_D)/rc5test.o $(L_LIBS) $(EX_LIBS)
1736
1737$(TEST_D)/ideatest: $(OBJ_D)/ideatest.o $(LIBS_DEP)
1738 $(LINK) -o $(TEST_D)/ideatest $(LFLAGS) $(OBJ_D)/ideatest.o $(L_LIBS) $(EX_LIBS)
1739
1740$(TEST_D)/bftest: $(OBJ_D)/bftest.o $(LIBS_DEP)
1741 $(LINK) -o $(TEST_D)/bftest $(LFLAGS) $(OBJ_D)/bftest.o $(L_LIBS) $(EX_LIBS)
1742
1743$(TEST_D)/casttest: $(OBJ_D)/casttest.o $(LIBS_DEP)
1744 $(LINK) -o $(TEST_D)/casttest $(LFLAGS) $(OBJ_D)/casttest.o $(L_LIBS) $(EX_LIBS)
1745
1746$(TEST_D)/bntest: $(OBJ_D)/bntest.o $(LIBS_DEP)
1747 $(LINK) -o $(TEST_D)/bntest $(LFLAGS) $(OBJ_D)/bntest.o $(L_LIBS) $(EX_LIBS)
1748
1749$(TEST_D)/exptest: $(OBJ_D)/exptest.o $(LIBS_DEP)
1750 $(LINK) -o $(TEST_D)/exptest $(LFLAGS) $(OBJ_D)/exptest.o $(L_LIBS) $(EX_LIBS)
1751
1752$(TEST_D)/dsatest: $(OBJ_D)/dsatest.o $(LIBS_DEP)
1753 $(LINK) -o $(TEST_D)/dsatest $(LFLAGS) $(OBJ_D)/dsatest.o $(L_LIBS) $(EX_LIBS)
1754
1755$(TEST_D)/dhtest: $(OBJ_D)/dhtest.o $(LIBS_DEP)
1756 $(LINK) -o $(TEST_D)/dhtest $(LFLAGS) $(OBJ_D)/dhtest.o $(L_LIBS) $(EX_LIBS)
1757
1758$(TEST_D)/randtest: $(OBJ_D)/randtest.o $(LIBS_DEP)
1759 $(LINK) -o $(TEST_D)/randtest $(LFLAGS) $(OBJ_D)/randtest.o $(L_LIBS) $(EX_LIBS)
1760
1761$(TEST_D)/ssltest: $(OBJ_D)/ssltest.o $(LIBS_DEP)
1762 $(LINK) -o $(TEST_D)/ssltest $(LFLAGS) $(OBJ_D)/ssltest.o $(L_LIBS) $(EX_LIBS)
1763
1764$(LIB_D)/$(O_SSL): $(SSLOBJ)
1765 $(RM) $(LIB_D)/$(O_SSL)
1766 $(MKLIB) $(LIB_D)/$(O_SSL) $(SSLOBJ)
1767 $(RANLIB) $(LIB_D)/$(O_SSL)
1768
1769$(LIB_D)/$(O_RSAGLUE): $(RSAGLUEOBJ)
1770 $(RM) $(LIB_D)/$(O_RSAGLUE)
1771 $(MKLIB) $(LIB_D)/$(O_RSAGLUE) $(RSAGLUEOBJ)
1772 $(RANLIB) $(LIB_D)/$(O_RSAGLUE)
1773
1774$(LIB_D)/$(O_CRYPTO): $(CRYPTOOBJ)
1775 $(RM) $(LIB_D)/$(O_CRYPTO)
1776 $(MKLIB) $(LIB_D)/$(O_CRYPTO) $(CRYPTOOBJ)
1777 $(RANLIB) $(LIB_D)/$(O_CRYPTO)
1778
1779$(BIN_D)/$(E_EXE): $(E_OBJ) $(LIBS_DEP)
1780 $(LINK) -o $(BIN_D)/$(E_EXE) $(LFLAGS) $(E_OBJ) $(L_LIBS) $(EX_LIBS)
1781
diff --git a/src/lib/libssl/src/ms/cipher.out b/src/lib/libssl/src/ms/cipher.out
new file mode 100644
index 0000000000..2c73bb7d1c
--- /dev/null
+++ b/src/lib/libssl/src/ms/cipher.out
@@ -0,0 +1,93 @@
1echo=off
2
3echo start testenc
4path=..\ms;%path%
5set ssleay=%1%
6set input=..\ms\testenc.bat
7set tmp1=..\ms\cipher.out
8set out1=..\ms\clear.out
9set cmp=perl ..\ms\cmp.pl
10
11call tenc.bat enc
12if errorlevel 1 goto err
13
14call tenc.bat rc4
15if errorlevel 1 goto err
16
17call tenc.bat des-cfb
18if errorlevel 1 goto err
19
20call tenc.bat des-ede-cfb
21if errorlevel 1 goto err
22
23call tenc.bat des-ede3-cfb
24if errorlevel 1 goto err
25
26call tenc.bat des-ofb
27if errorlevel 1 goto err
28
29call tenc.bat des-ede-ofb
30if errorlevel 1 goto err
31
32call tenc.bat des-ede3-ofb
33if errorlevel 1 goto err
34
35call tenc.bat des-ecb
36if errorlevel 1 goto err
37
38call tenc.bat des-ede
39if errorlevel 1 goto err
40
41call tenc.bat des-ede3
42if errorlevel 1 goto err
43
44call tenc.bat des-cbc
45if errorlevel 1 goto err
46
47call tenc.bat des-ede-cbc
48if errorlevel 1 goto err
49
50call tenc.bat des-ede3-cbc
51if errorlevel 1 goto err
52
53call tenc.bat idea-ecb
54if errorlevel 1 goto err
55
56call tenc.bat idea-cfb
57if errorlevel 1 goto err
58
59call tenc.bat idea-ofb
60if errorlevel 1 goto err
61
62call tenc.bat idea-cbc
63if errorlevel 1 goto err
64
65call tenc.bat rc2-ecb
66if errorlevel 1 goto err
67
68call tenc.bat rc2-cfb
69if errorlevel 1 goto err
70
71call tenc.bat rc2-ofb
72if errorlevel 1 goto err
73
74call tenc.bat rc2-cbc
75if errorlevel 1 goto err
76
77call tenc.bat bf-ecb
78if errorlevel 1 goto err
79
80call tenc.bat bf-cfb
81if errorlevel 1 goto err
82
83call tenc.bat bf-ofb
84if errorlevel 1 goto err
85
86call tenc.bat bf-cbc
87if errorlevel 1 goto err
88
89echo OK
90del %out1%
91del %tmp1%
92:err
93
diff --git a/src/lib/libssl/src/ms/clear.out b/src/lib/libssl/src/ms/clear.out
new file mode 100644
index 0000000000..2c73bb7d1c
--- /dev/null
+++ b/src/lib/libssl/src/ms/clear.out
@@ -0,0 +1,93 @@
1echo=off
2
3echo start testenc
4path=..\ms;%path%
5set ssleay=%1%
6set input=..\ms\testenc.bat
7set tmp1=..\ms\cipher.out
8set out1=..\ms\clear.out
9set cmp=perl ..\ms\cmp.pl
10
11call tenc.bat enc
12if errorlevel 1 goto err
13
14call tenc.bat rc4
15if errorlevel 1 goto err
16
17call tenc.bat des-cfb
18if errorlevel 1 goto err
19
20call tenc.bat des-ede-cfb
21if errorlevel 1 goto err
22
23call tenc.bat des-ede3-cfb
24if errorlevel 1 goto err
25
26call tenc.bat des-ofb
27if errorlevel 1 goto err
28
29call tenc.bat des-ede-ofb
30if errorlevel 1 goto err
31
32call tenc.bat des-ede3-ofb
33if errorlevel 1 goto err
34
35call tenc.bat des-ecb
36if errorlevel 1 goto err
37
38call tenc.bat des-ede
39if errorlevel 1 goto err
40
41call tenc.bat des-ede3
42if errorlevel 1 goto err
43
44call tenc.bat des-cbc
45if errorlevel 1 goto err
46
47call tenc.bat des-ede-cbc
48if errorlevel 1 goto err
49
50call tenc.bat des-ede3-cbc
51if errorlevel 1 goto err
52
53call tenc.bat idea-ecb
54if errorlevel 1 goto err
55
56call tenc.bat idea-cfb
57if errorlevel 1 goto err
58
59call tenc.bat idea-ofb
60if errorlevel 1 goto err
61
62call tenc.bat idea-cbc
63if errorlevel 1 goto err
64
65call tenc.bat rc2-ecb
66if errorlevel 1 goto err
67
68call tenc.bat rc2-cfb
69if errorlevel 1 goto err
70
71call tenc.bat rc2-ofb
72if errorlevel 1 goto err
73
74call tenc.bat rc2-cbc
75if errorlevel 1 goto err
76
77call tenc.bat bf-ecb
78if errorlevel 1 goto err
79
80call tenc.bat bf-cfb
81if errorlevel 1 goto err
82
83call tenc.bat bf-ofb
84if errorlevel 1 goto err
85
86call tenc.bat bf-cbc
87if errorlevel 1 goto err
88
89echo OK
90del %out1%
91del %tmp1%
92:err
93
diff --git a/src/lib/libssl/src/ms/libeay16.def b/src/lib/libssl/src/ms/libeay16.def
new file mode 100644
index 0000000000..65bbad629e
--- /dev/null
+++ b/src/lib/libssl/src/ms/libeay16.def
@@ -0,0 +1,987 @@
1;
2; Definition file for the DDL version of the LIBEAY16 library from SSLeay
3;
4
5LIBRARY LIBEAY16
6
7DESCRIPTION 'SSLeay LIBEAY16 - eay@cryptsoft.com'
8
9CODE PRELOAD MOVEABLE
10DATA PRELOAD MOVEABLE SINGLE
11
12EXETYPE WINDOWS
13
14HEAPSIZE 4096
15STACKSIZE 8192
16
17EXPORTS
18 _SSLeay @1
19 _SSLeay_add_all_algorithms @508
20 _SSLeay_add_all_ciphers @509
21 _SSLeay_add_all_digests @510
22 _SSLeay_version @2
23 _ASN1_BIT_STRING_asn1_meth @3
24 _ASN1_BIT_STRING_get_bit @1060
25 _ASN1_BIT_STRING_set_bit @1061
26 _ASN1_HEADER_free @4
27 _ASN1_HEADER_new @5
28 _ASN1_IA5STRING_asn1_meth @6
29 _ASN1_INTEGER_get @7
30 _ASN1_INTEGER_set @8
31 _ASN1_INTEGER_to_BN @9
32 _ASN1_OBJECT_create @10
33 _ASN1_OBJECT_free @11
34 _ASN1_OBJECT_new @12
35 _ASN1_PRINTABLE_type @13
36 _ASN1_STRING_cmp @14
37 _ASN1_STRING_dup @15
38 _ASN1_STRING_free @16
39 _ASN1_STRING_new @17
40 _ASN1_STRING_print @18
41 _ASN1_STRING_set @19
42 _ASN1_STRING_type_new @20
43 _ASN1_TYPE_free @21
44 _ASN1_TYPE_get @916
45 _ASN1_TYPE_get_int_octetstring @1076
46 _ASN1_TYPE_get_octetstring @1077
47 _ASN1_TYPE_new @22
48 _ASN1_TYPE_set @917
49 _ASN1_TYPE_set_int_octetstring @1078
50 _ASN1_TYPE_set_octetstring @1079
51 _ASN1_UNIVERSALSTRING_to_string @23
52 _ASN1_UTCTIME_check @24
53 _ASN1_UTCTIME_print @25
54 _ASN1_UTCTIME_set @26
55 _ASN1_UTCTIME_set_string @1080
56 _ASN1_check_infinite_end @27
57 _ASN1_d2i_bio @28
58 _ASN1_digest @30
59 _ASN1_dup @31
60 _ASN1_get_object @32
61 _ASN1_i2d_bio @33
62 _ASN1_object_size @35
63 _ASN1_parse @36
64 _ASN1_put_object @37
65 _ASN1_sign @38
66 _ASN1_verify @39
67 _BF_cbc_encrypt @40
68 _BF_cfb64_encrypt @41
69 _BF_decrypt @987
70 _BF_ecb_encrypt @42
71 _BF_encrypt @43
72 _BF_ofb64_encrypt @44
73 _BF_options @45
74 _BF_set_key @46
75 _BIO_accept @51
76 _BIO_copy_next_retry @955
77 _BIO_ctrl @52
78 _BIO_debug_callback @54
79 _BIO_dump @55
80 _BIO_dup_chain @56
81 _BIO_f_base64 @57
82 _BIO_f_buffer @58
83 _BIO_f_cipher @59
84 _BIO_f_md @60
85 _BIO_f_nbio_test @915
86 _BIO_f_null @61
87 _BIO_fd_non_fatal_error @63
88 _BIO_fd_should_retry @64
89 _BIO_find_type @65
90 _BIO_free @66
91 _BIO_free_all @67
92 _BIO_get_accept_socket @69
93 _BIO_get_host_ip @71
94 _BIO_get_port @72
95 _BIO_get_retry_BIO @73
96 _BIO_get_retry_reason @74
97 _BIO_gethostbyname @75
98 _BIO_gets @76
99 _BIO_ghbn_ctrl @1003
100 _BIO_int_ctrl @53
101 _BIO_new @78
102 _BIO_new_accept @79
103 _BIO_new_connect @80
104 _BIO_new_fd @81
105 _BIO_new_socket @84
106 _BIO_pop @85
107 _BIO_printf @86
108 _BIO_ptr_ctrl @969
109 _BIO_push @87
110 _BIO_puts @88
111 _BIO_read @89
112 _BIO_s_accept @90
113 _BIO_s_connect @91
114 _BIO_s_fd @92
115 _BIO_s_mem @95
116 _BIO_s_null @96
117 _BIO_s_socket @98
118 _BIO_set @100
119 _BIO_set_cipher @101
120 _BIO_set_tcp_ndelay @102
121 _BIO_sock_cleanup @103
122 _BIO_sock_error @104
123 _BIO_sock_init @105
124 _BIO_sock_non_fatal_error @106
125 _BIO_sock_should_retry @107
126 _BIO_socket_ioctl @108
127 _BIO_write @109
128 _BN_BLINDING_convert @973
129 _BN_BLINDING_free @981
130 _BN_BLINDING_invert @974
131 _BN_BLINDING_new @980
132 _BN_BLINDING_update @975
133 _BN_CTX_free @110
134 _BN_CTX_new @111
135 _BN_MONT_CTX_free @112
136 _BN_MONT_CTX_new @113
137 _BN_MONT_CTX_set @114
138 _BN_add @115
139 _BN_add_word @116
140 _BN_bin2bn @118
141 _BN_bn2bin @120
142 _BN_bn2dec @1002
143 _BN_bn2hex @119
144 _BN_bn2mpi @1058
145 _BN_clear @121
146 _BN_clear_bit @122
147 _BN_clear_free @123
148 _BN_cmp @124
149 _BN_copy @125
150 _BN_dec2bn @1001
151 _BN_div @126
152 _BN_div_word @127
153 _BN_dup @128
154 _BN_exp @998
155 _BN_free @129
156 _BN_from_montgomery @130
157 _BN_gcd @131
158 _BN_generate_prime @132
159 _BN_get_word @133
160 _BN_hex2bn @117
161 _BN_is_bit_set @134
162 _BN_is_prime @135
163 _BN_lshift @136
164 _BN_lshift1 @137
165 _BN_mask_bits @138
166 _BN_mod @139
167 _BN_mod_exp @140
168 _BN_mod_exp_mont @141
169 _BN_mod_exp_recp @142
170 _BN_mod_exp_simple @143
171 _BN_mod_inverse @144
172 _BN_mod_mul @145
173 _BN_mod_mul_montgomery @146
174 _BN_mod_mul_reciprocal @147
175 _BN_mod_word @148
176 _BN_mpi2bn @1059
177 _BN_mul @149
178 _BN_mul_word @999
179 _BN_new @150
180 _BN_num_bits @151
181 _BN_num_bits_word @152
182 _BN_options @153
183 _BN_print @154
184 _BN_rand @156
185 _BN_reciprocal @157
186 _BN_rshift @158
187 _BN_rshift1 @159
188 _BN_set_bit @160
189 _BN_set_word @161
190 _BN_sqr @162
191 _BN_sub @163
192 _BN_sub_word @1000
193 _BN_to_ASN1_INTEGER @164
194 _BN_ucmp @165
195 _BN_value_one @166
196 _BUF_MEM_free @167
197 _BUF_MEM_grow @168
198 _BUF_MEM_new @169
199 _BUF_strdup @170
200 _CAST_cbc_encrypt @992
201 _CAST_cfb64_encrypt @993
202 _CAST_decrypt @990
203 _CAST_ecb_encrypt @991
204 _CAST_encrypt @989
205 _CAST_ofb64_encrypt @994
206 _CAST_set_key @988
207 _CONF_free @171
208 _CONF_get_number @172
209 _CONF_get_section @173
210 _CONF_get_string @174
211 _CONF_load @175
212 _CRYPTO_add_lock @176
213 _CRYPTO_dbg_free @177
214 _CRYPTO_dbg_malloc @178
215 _CRYPTO_dbg_realloc @179
216 _CRYPTO_dbg_remalloc @180
217 _CRYPTO_dup_ex_data @1025
218 _CRYPTO_free @181
219 _CRYPTO_free_ex_data @1004
220 _CRYPTO_get_add_lock_callback @182
221 _CRYPTO_get_ex_data @1005
222 _CRYPTO_get_ex_new_index @1041
223 _CRYPTO_get_id_callback @183
224 _CRYPTO_get_lock_name @184
225 _CRYPTO_get_locking_callback @185
226 _CRYPTO_get_mem_functions @186
227 _CRYPTO_get_new_lockid @1026
228 _CRYPTO_lock @187
229 _CRYPTO_malloc @188
230 _CRYPTO_mem_ctrl @189
231 _CRYPTO_mem_leaks @190
232 _CRYPTO_mem_leaks_cb @191
233 _CRYPTO_new_ex_data @1027
234 _CRYPTO_realloc @193
235 _CRYPTO_remalloc @194
236 _CRYPTO_set_add_lock_callback @195
237 _CRYPTO_set_ex_data @1007
238 _CRYPTO_set_id_callback @196
239 _CRYPTO_set_locking_callback @197
240 _CRYPTO_set_mem_functions @198
241 _CRYPTO_thread_id @199
242 _DH_check @200
243 _DH_compute_key @201
244 _DH_free @202
245 _DH_generate_key @203
246 _DH_generate_parameters @204
247 _DH_new @205
248 _DH_size @206
249 _DHparams_print @207
250 _DSA_free @209
251 _DSA_generate_key @210
252 _DSA_generate_parameters @211
253 _DSA_is_prime @212
254 _DSA_new @213
255 _DSA_print @214
256 _DSA_sign @216
257 _DSA_sign_setup @217
258 _DSA_size @218
259 _DSA_verify @219
260 _DSAparams_print @220
261 _ERR_add_error_data @1081
262 _ERR_clear_error @222
263 _ERR_error_string @223
264 _ERR_free_strings @224
265 _ERR_func_error_string @225
266 _ERR_get_err_state_table @226
267 _ERR_get_error @227
268 _ERR_get_error_line @228
269 _ERR_get_next_error_library @966
270 _ERR_get_state @229
271 _ERR_get_string_table @230
272 _ERR_lib_error_string @231
273 _ERR_load_ASN1_strings @232
274 _ERR_load_BIO_strings @233
275 _ERR_load_BN_strings @234
276 _ERR_load_BUF_strings @235
277 _ERR_load_CONF_strings @236
278 _ERR_load_CRYPTOlib_strings @1009
279 _ERR_load_DH_strings @237
280 _ERR_load_DSA_strings @238
281 _ERR_load_ERR_strings @239
282 _ERR_load_EVP_strings @240
283 _ERR_load_OBJ_strings @241
284 _ERR_load_PEM_strings @242
285 _ERR_load_PKCS7_strings @919
286 _ERR_load_RSA_strings @244
287 _ERR_load_X509_strings @245
288 _ERR_load_crypto_strings @246
289 _ERR_load_strings @247
290 _ERR_peek_error @248
291 _ERR_peek_error_line @249
292 _ERR_print_errors @250
293 _ERR_put_error @252
294 _ERR_reason_error_string @253
295 _ERR_remove_state @254
296 _ERR_set_error_data @1082
297 _EVP_BytesToKey @255
298 _EVP_CIPHER_CTX_cleanup @256
299 _EVP_CIPHER_CTX_init @961
300 _EVP_CIPHER_asn1_to_param @1083
301 _EVP_CIPHER_get_asn1_iv @1085
302 _EVP_CIPHER_param_to_asn1 @1084
303 _EVP_CIPHER_set_asn1_iv @1086
304 _EVP_CipherFinal @257
305 _EVP_CipherInit @258
306 _EVP_CipherUpdate @259
307 _EVP_DecodeBlock @260
308 _EVP_DecodeFinal @261
309 _EVP_DecodeInit @262
310 _EVP_DecodeUpdate @263
311 _EVP_DecryptFinal @264
312 _EVP_DecryptInit @265
313 _EVP_DecryptUpdate @266
314 _EVP_DigestFinal @267
315 _EVP_DigestInit @268
316 _EVP_DigestUpdate @269
317 _EVP_EncodeBlock @270
318 _EVP_EncodeFinal @271
319 _EVP_EncodeInit @272
320 _EVP_EncodeUpdate @273
321 _EVP_EncryptFinal @274
322 _EVP_EncryptInit @275
323 _EVP_EncryptUpdate @276
324 _EVP_OpenFinal @277
325 _EVP_OpenInit @278
326 _EVP_PKEY_assign @279
327 _EVP_PKEY_bits @1010
328 _EVP_PKEY_cmp_parameters @967
329 _EVP_PKEY_copy_parameters @280
330 _EVP_PKEY_decrypt @1070
331 _EVP_PKEY_encrypt @1071
332 _EVP_PKEY_free @281
333 _EVP_PKEY_missing_parameters @282
334 _EVP_PKEY_new @283
335 _EVP_PKEY_save_parameters @284
336 _EVP_PKEY_size @285
337 _EVP_PKEY_type @286
338 _EVP_SealFinal @287
339 _EVP_SealInit @288
340 _EVP_SignFinal @289
341 _EVP_VerifyFinal @290
342 _EVP_add_alias @291
343 _EVP_add_cipher @292
344 _EVP_add_digest @293
345 _EVP_bf_cbc @294
346 _EVP_bf_cfb @295
347 _EVP_bf_ecb @296
348 _EVP_bf_ofb @297
349 _EVP_cast5_cbc @983
350 _EVP_cast5_cfb @984
351 _EVP_cast5_ecb @985
352 _EVP_cast5_ofb @986
353 _EVP_cleanup @298
354 _EVP_delete_alias @941
355 _EVP_des_cbc @299
356 _EVP_des_cfb @300
357 _EVP_des_ecb @301
358 _EVP_des_ede @302
359 _EVP_des_ede3 @303
360 _EVP_des_ede3_cbc @304
361 _EVP_des_ede3_cfb @305
362 _EVP_des_ede3_ofb @306
363 _EVP_des_ede_cbc @307
364 _EVP_des_ede_cfb @308
365 _EVP_des_ede_ofb @309
366 _EVP_des_ofb @310
367 _EVP_desx_cbc @311
368 _EVP_dss @312
369 _EVP_dss1 @313
370 _EVP_enc_null @314
371 _EVP_get_cipherbyname @315
372 _EVP_get_digestbyname @316
373 _EVP_get_pw_prompt @317
374 _EVP_idea_cbc @318
375 _EVP_idea_cfb @319
376 _EVP_idea_ecb @320
377 _EVP_idea_ofb @321
378 _EVP_md2 @322
379 _EVP_md5 @323
380 _EVP_md_null @324
381 _EVP_mdc2 @942
382 _EVP_rc2_40_cbc @959
383 _EVP_rc2_cbc @325
384 _EVP_rc2_cfb @326
385 _EVP_rc2_ecb @327
386 _EVP_rc2_ofb @328
387 _EVP_rc4 @329
388 _EVP_rc4_40 @960
389 _EVP_rc5_32_12_16_cbc @1087
390 _EVP_rc5_32_12_16_cfb @1088
391 _EVP_rc5_32_12_16_ecb @1089
392 _EVP_rc5_32_12_16_ofb @1090
393 _EVP_read_pw_string @330
394 _EVP_set_pw_prompt @331
395 _EVP_sha @332
396 _EVP_sha1 @333
397 _HMAC @962
398 _HMAC_Final @965
399 _HMAC_Init @963
400 _HMAC_Update @964
401 _HMAC_cleanup @968
402 _MD2 @334
403 _MD2_Final @335
404 _MD2_Init @336
405 _MD2_Update @337
406 _MD2_options @338
407 _MD5 @339
408 _MD5_Final @340
409 _MD5_Init @341
410 _MD5_Transform @1011
411 _MD5_Update @342
412 _MDC2 @343
413 _MDC2_Final @344
414 _MDC2_Init @345
415 _MDC2_Update @346
416 _NETSCAPE_SPKAC_free @347
417 _NETSCAPE_SPKAC_new @348
418 _NETSCAPE_SPKI_free @349
419 _NETSCAPE_SPKI_new @350
420 _NETSCAPE_SPKI_sign @351
421 _NETSCAPE_SPKI_verify @352
422 _OBJ_add_object @353
423 _OBJ_bsearch @354
424 _OBJ_cleanup @355
425 _OBJ_cmp @356
426 _OBJ_create @357
427 _OBJ_create_objects @997
428 _OBJ_dup @358
429 _OBJ_ln2nid @359
430 _OBJ_new_nid @360
431 _OBJ_nid2ln @361
432 _OBJ_nid2obj @362
433 _OBJ_nid2sn @363
434 _OBJ_obj2nid @364
435 _OBJ_sn2nid @365
436 _OBJ_txt2nid @366
437 _PEM_ASN1_read_bio @368
438 _PEM_ASN1_write_bio @370
439 _PEM_SealFinal @371
440 _PEM_SealInit @372
441 _PEM_SealUpdate @373
442 _PEM_SignFinal @374
443 _PEM_X509_INFO_read_bio @378
444 _PEM_X509_INFO_write_bio @379
445 _PEM_dek_info @380
446 _PEM_do_header @381
447 _PEM_get_EVP_CIPHER_INFO @382
448 _PEM_proc_type @383
449 _PEM_read_bio @394
450 _PEM_read_bio_DHparams @395
451 _PEM_read_bio_DSAPrivateKey @396
452 _PEM_read_bio_DSAparams @397
453 _PEM_read_bio_PKCS7 @398
454 _PEM_read_bio_PrivateKey @399
455 _PEM_read_bio_RSAPrivateKey @400
456 _PEM_read_bio_RSAPublicKey @943
457 _PEM_read_bio_X509 @401
458 _PEM_read_bio_X509_CRL @402
459 _PEM_read_bio_X509_REQ @403
460 _PEM_write_bio @414
461 _PEM_write_bio_DHparams @415
462 _PEM_write_bio_DSAPrivateKey @416
463 _PEM_write_bio_DSAparams @417
464 _PEM_write_bio_PKCS7 @418
465 _PEM_write_bio_PrivateKey @419
466 _PEM_write_bio_RSAPrivateKey @420
467 _PEM_write_bio_RSAPublicKey @944
468 _PEM_write_bio_X509 @421
469 _PEM_write_bio_X509_CRL @422
470 _PEM_write_bio_X509_REQ @423
471 _PKCS7_DIGEST_free @424
472 _PKCS7_DIGEST_new @425
473 _PKCS7_ENCRYPT_free @426
474 _PKCS7_ENCRYPT_new @427
475 _PKCS7_ENC_CONTENT_free @428
476 _PKCS7_ENC_CONTENT_new @429
477 _PKCS7_ENVELOPE_free @430
478 _PKCS7_ENVELOPE_new @431
479 _PKCS7_ISSUER_AND_SERIAL_digest @432
480 _PKCS7_ISSUER_AND_SERIAL_free @433
481 _PKCS7_ISSUER_AND_SERIAL_new @434
482 _PKCS7_RECIP_INFO_free @435
483 _PKCS7_RECIP_INFO_new @436
484 _PKCS7_RECIP_INFO_set @1072
485 _PKCS7_SIGNED_free @437
486 _PKCS7_SIGNED_new @438
487 _PKCS7_SIGNER_INFO_free @439
488 _PKCS7_SIGNER_INFO_new @440
489 _PKCS7_SIGNER_INFO_set @930
490 _PKCS7_SIGN_ENVELOPE_free @441
491 _PKCS7_SIGN_ENVELOPE_new @442
492 _PKCS7_add_certificate @932
493 _PKCS7_add_crl @933
494 _PKCS7_add_recipient @1073
495 _PKCS7_add_recipient_info @1074
496 _PKCS7_add_signature @938
497 _PKCS7_add_signer @931
498 _PKCS7_cert_from_signer_info @939
499 _PKCS7_content_free @918
500 _PKCS7_content_new @934
501 _PKCS7_ctrl @927
502 _PKCS7_dataInit @937
503 _PKCS7_dataSign @935
504 _PKCS7_dataVerify @936
505 _PKCS7_dup @443
506 _PKCS7_free @444
507 _PKCS7_get_signer_info @940
508 _PKCS7_new @445
509 _PKCS7_set_cipher @1075
510 _PKCS7_set_content @929
511 _PKCS7_set_type @928
512 _RAND_bytes @464
513 _RAND_cleanup @465
514 _RAND_file_name @466
515 _RAND_load_file @467
516 _RAND_screen @468
517 _RAND_seed @469
518 _RAND_write_file @470
519 _RC2_cbc_encrypt @471
520 _RC2_cfb64_encrypt @472
521 _RC2_decrypt @995
522 _RC2_ecb_encrypt @473
523 _RC2_encrypt @474
524 _RC2_ofb64_encrypt @475
525 _RC2_set_key @476
526 _RC4 @477
527 _RC4_options @478
528 _RC4_set_key @479
529 _RC5_32_cbc_encrypt @1051
530 _RC5_32_cfb64_encrypt @1052
531 _RC5_32_decrypt @1050
532 _RC5_32_ecb_encrypt @1048
533 _RC5_32_encrypt @1049
534 _RC5_32_ofb64_encrypt @1053
535 _RC5_32_set_key @1047
536 _RIPEMD160 @1045
537 _RIPEMD160_Final @1044
538 _RIPEMD160_Init @1042
539 _RIPEMD160_Transform @1046
540 _RIPEMD160_Update @1043
541 _RSAPrivateKey_asn1_meth @480
542 _RSAPrivateKey_dup @481
543 _RSAPublicKey_dup @482
544 _RSA_PKCS1_SSLeay @483
545 _RSA_blinding_off @978
546 _RSA_blinding_on @977
547 _RSA_flags @956
548 _RSA_free @484
549 _RSA_generate_key @485
550 _RSA_get_ex_data @1029
551 _RSA_get_ex_new_index @1030
552 _RSA_new @486
553 _RSA_new_method @487
554 _RSA_padding_add_PKCS1_type_1 @1031
555 _RSA_padding_add_PKCS1_type_2 @1032
556 _RSA_padding_add_SSLv23 @1033
557 _RSA_padding_add_none @1034
558 _RSA_padding_check_PKCS1_type_1 @1035
559 _RSA_padding_check_PKCS1_type_2 @1036
560 _RSA_padding_check_SSLv23 @1037
561 _RSA_padding_check_none @1038
562 _RSA_print @488
563 _RSA_private_decrypt @490
564 _RSA_private_encrypt @491
565 _RSA_public_decrypt @492
566 _RSA_public_encrypt @493
567 _RSA_set_default_method @494
568 _RSA_set_ex_data @1028
569 _RSA_sign @495
570 _RSA_sign_ASN1_OCTET_STRING @496
571 _RSA_size @497
572 _RSA_verify @498
573 _RSA_verify_ASN1_OCTET_STRING @499
574 _SHA @500
575 _SHA1 @501
576 _SHA1_Final @502
577 _SHA1_Init @503
578 _SHA1_Transform @1012
579 _SHA1_Update @504
580 _SHA_Final @505
581 _SHA_Init @506
582 _SHA_Transform @1013
583 _SHA_Update @507
584 _TXT_DB_create_index @511
585 _TXT_DB_free @512
586 _TXT_DB_get_by_index @513
587 _TXT_DB_insert @514
588 _TXT_DB_read @515
589 _TXT_DB_write @516
590 _X509_ALGOR_free @517
591 _X509_ALGOR_new @518
592 _X509_ATTRIBUTE_free @519
593 _X509_ATTRIBUTE_new @520
594 _X509_CINF_free @521
595 _X509_CINF_new @522
596 _X509_CRL_INFO_free @523
597 _X509_CRL_INFO_new @524
598 _X509_CRL_add_ext @525
599 _X509_CRL_cmp @526
600 _X509_CRL_delete_ext @527
601 _X509_CRL_dup @528
602 _X509_CRL_free @529
603 _X509_CRL_get_ext @530
604 _X509_CRL_get_ext_by_NID @531
605 _X509_CRL_get_ext_by_OBJ @532
606 _X509_CRL_get_ext_by_critical @533
607 _X509_CRL_get_ext_count @534
608 _X509_CRL_new @535
609 _X509_CRL_sign @536
610 _X509_CRL_verify @537
611 _X509_EXTENSION_create_by_NID @538
612 _X509_EXTENSION_create_by_OBJ @539
613 _X509_EXTENSION_dup @540
614 _X509_EXTENSION_free @541
615 _X509_EXTENSION_get_critical @542
616 _X509_EXTENSION_get_data @543
617 _X509_EXTENSION_get_object @544
618 _X509_EXTENSION_new @545
619 _X509_EXTENSION_set_critical @546
620 _X509_EXTENSION_set_data @547
621 _X509_EXTENSION_set_object @548
622 _X509_INFO_free @549
623 _X509_INFO_new @550
624 _X509_LOOKUP_by_alias @551
625 _X509_LOOKUP_by_fingerprint @552
626 _X509_LOOKUP_by_issuer_serial @553
627 _X509_LOOKUP_by_subject @554
628 _X509_LOOKUP_ctrl @555
629 _X509_LOOKUP_file @556
630 _X509_LOOKUP_free @557
631 _X509_LOOKUP_hash_dir @558
632 _X509_LOOKUP_init @559
633 _X509_LOOKUP_new @560
634 _X509_LOOKUP_shutdown @561
635 _X509_NAME_ENTRY_create_by_NID @562
636 _X509_NAME_ENTRY_create_by_OBJ @563
637 _X509_NAME_ENTRY_dup @564
638 _X509_NAME_ENTRY_free @565
639 _X509_NAME_ENTRY_get_data @566
640 _X509_NAME_ENTRY_get_object @567
641 _X509_NAME_ENTRY_new @568
642 _X509_NAME_ENTRY_set_data @569
643 _X509_NAME_ENTRY_set_object @570
644 _X509_NAME_add_entry @571
645 _X509_NAME_cmp @572
646 _X509_NAME_delete_entry @573
647 _X509_NAME_digest @574
648 _X509_NAME_dup @575
649 _X509_NAME_entry_count @576
650 _X509_NAME_free @577
651 _X509_NAME_get_entry @578
652 _X509_NAME_get_index_by_NID @579
653 _X509_NAME_get_index_by_OBJ @580
654 _X509_NAME_get_text_by_NID @581
655 _X509_NAME_get_text_by_OBJ @582
656 _X509_NAME_hash @583
657 _X509_NAME_new @584
658 _X509_NAME_oneline @585
659 _X509_NAME_print @586
660 _X509_NAME_set @587
661 _X509_OBJECT_free_contents @588
662 _X509_OBJECT_retrive_by_subject @589
663 _X509_OBJECT_up_ref_count @590
664 _X509_PKEY_free @591
665 _X509_PKEY_new @592
666 _X509_PUBKEY_free @593
667 _X509_PUBKEY_get @594
668 _X509_PUBKEY_new @595
669 _X509_PUBKEY_set @596
670 _X509_REQ_INFO_free @597
671 _X509_REQ_INFO_new @598
672 _X509_REQ_dup @599
673 _X509_REQ_free @600
674 _X509_REQ_get_pubkey @601
675 _X509_REQ_new @602
676 _X509_REQ_print @603
677 _X509_REQ_set_pubkey @605
678 _X509_REQ_set_subject_name @606
679 _X509_REQ_set_version @607
680 _X509_REQ_sign @608
681 _X509_REQ_to_X509 @609
682 _X509_REQ_verify @610
683 _X509_REVOKED_add_ext @611
684 _X509_REVOKED_delete_ext @612
685 _X509_REVOKED_free @613
686 _X509_REVOKED_get_ext @614
687 _X509_REVOKED_get_ext_by_NID @615
688 _X509_REVOKED_get_ext_by_OBJ @616
689 _X509_REVOKED_get_ext_by_critical @617
690 _X509_REVOKED_get_ext_count @618
691 _X509_REVOKED_new @619
692 _X509_SIG_free @620
693 _X509_SIG_new @621
694 _X509_STORE_CTX_cleanup @622
695 _X509_STORE_CTX_get_chain @1014
696 _X509_STORE_CTX_get_current_cert @1015
697 _X509_STORE_CTX_get_error @1016
698 _X509_STORE_CTX_get_error_depth @1017
699 _X509_STORE_CTX_get_ex_data @1018
700 _X509_STORE_CTX_init @623
701 _X509_STORE_CTX_set_cert @1020
702 _X509_STORE_CTX_set_chain @1021
703 _X509_STORE_CTX_set_error @1022
704 _X509_STORE_CTX_set_ex_data @1023
705 _X509_STORE_add_cert @624
706 _X509_STORE_add_crl @957
707 _X509_STORE_add_lookup @625
708 _X509_STORE_free @626
709 _X509_STORE_get_by_subject @627
710 _X509_STORE_load_locations @628
711 _X509_STORE_new @629
712 _X509_STORE_set_default_paths @630
713 _X509_VAL_free @631
714 _X509_VAL_new @632
715 _X509_add_ext @633
716 _X509_asn1_meth @634
717 _X509_certificate_type @635
718 _X509_check_private_key @636
719 _X509_cmp_current_time @637
720 _X509_delete_ext @638
721 _X509_digest @639
722 _X509_dup @640
723 _X509_find_by_issuer_and_serial @920
724 _X509_find_by_subject @921
725 _X509_free @641
726 _X509_get_default_cert_area @642
727 _X509_get_default_cert_dir @643
728 _X509_get_default_cert_dir_env @644
729 _X509_get_default_cert_file @645
730 _X509_get_default_cert_file_env @646
731 _X509_get_default_private_dir @647
732 _X509_get_ext @648
733 _X509_get_ext_by_NID @649
734 _X509_get_ext_by_OBJ @650
735 _X509_get_ext_by_critical @651
736 _X509_get_ext_count @652
737 _X509_get_issuer_name @653
738 _X509_get_pubkey @654
739 _X509_get_pubkey_parameters @655
740 _X509_get_serialNumber @656
741 _X509_get_subject_name @657
742 _X509_gmtime_adj @658
743 _X509_issuer_and_serial_cmp @659
744 _X509_issuer_and_serial_hash @660
745 _X509_issuer_name_cmp @661
746 _X509_issuer_name_hash @662
747 _X509_load_cert_file @663
748 _X509_load_crl_file @958
749 _X509_new @664
750 _X509_print @665
751 _X509_set_issuer_name @667
752 _X509_set_notAfter @668
753 _X509_set_notBefore @669
754 _X509_set_pubkey @670
755 _X509_set_serialNumber @671
756 _X509_set_subject_name @672
757 _X509_set_version @673
758 _X509_sign @674
759 _X509_subject_name_cmp @675
760 _X509_subject_name_hash @676
761 _X509_to_X509_REQ @677
762 _X509_verify @678
763 _X509_verify_cert @679
764 _X509_verify_cert_error_string @680
765 _X509v3_add_ext @681
766 _X509v3_add_extension @682
767 _X509v3_add_netscape_extensions @683
768 _X509v3_add_standard_extensions @684
769 _X509v3_cleanup_extensions @685
770 _X509v3_data_type_by_NID @686
771 _X509v3_data_type_by_OBJ @687
772 _X509v3_delete_ext @688
773 _X509v3_get_ext @689
774 _X509v3_get_ext_by_NID @690
775 _X509v3_get_ext_by_OBJ @691
776 _X509v3_get_ext_by_critical @692
777 _X509v3_get_ext_count @693
778 _X509v3_pack_string @694
779 _X509v3_pack_type_by_NID @695
780 _X509v3_pack_type_by_OBJ @696
781 _X509v3_unpack_string @697
782 _a2d_ASN1_OBJECT @699
783 _a2i_ASN1_INTEGER @700
784 _a2i_ASN1_STRING @701
785 _asn1_Finish @702
786 _asn1_GetSequence @703
787 _asn1_add_error @1091
788 _bn_add_words @1039
789 _bn_div64 @704
790 _bn_expand2 @705
791 _bn_mul_add_words @706
792 _bn_mul_words @707
793 _bn_qadd @708
794 _bn_qsub @709
795 _bn_sqr_words @710
796 _crypt @711
797 _d2i_ASN1_BIT_STRING @712
798 _d2i_ASN1_BOOLEAN @713
799 _d2i_ASN1_HEADER @714
800 _d2i_ASN1_IA5STRING @715
801 _d2i_ASN1_INTEGER @716
802 _d2i_ASN1_OBJECT @717
803 _d2i_ASN1_OCTET_STRING @718
804 _d2i_ASN1_PRINTABLE @719
805 _d2i_ASN1_PRINTABLESTRING @720
806 _d2i_ASN1_SET @721
807 _d2i_ASN1_T61STRING @722
808 _d2i_ASN1_TYPE @723
809 _d2i_ASN1_UTCTIME @724
810 _d2i_ASN1_bytes @725
811 _d2i_ASN1_type_bytes @726
812 _d2i_DHparams @727
813 _d2i_DSAPrivateKey @728
814 _d2i_DSAPrivateKey_bio @729
815 _d2i_DSAPublicKey @731
816 _d2i_DSAparams @732
817 _d2i_NETSCAPE_SPKAC @733
818 _d2i_NETSCAPE_SPKI @734
819 _d2i_Netscape_RSA @735
820 _d2i_Netscape_RSA_2 @1040
821 _d2i_PKCS7 @736
822 _d2i_PKCS7_DIGEST @737
823 _d2i_PKCS7_ENCRYPT @738
824 _d2i_PKCS7_ENC_CONTENT @739
825 _d2i_PKCS7_ENVELOPE @740
826 _d2i_PKCS7_ISSUER_AND_SERIAL @741
827 _d2i_PKCS7_RECIP_INFO @742
828 _d2i_PKCS7_SIGNED @743
829 _d2i_PKCS7_SIGNER_INFO @744
830 _d2i_PKCS7_SIGN_ENVELOPE @745
831 _d2i_PKCS7_bio @746
832 _d2i_PrivateKey @748
833 _d2i_PublicKey @749
834 _d2i_RSAPrivateKey @750
835 _d2i_RSAPrivateKey_bio @751
836 _d2i_RSAPublicKey @753
837 _d2i_RSAPublicKey_bio @945
838 _d2i_X509 @754
839 _d2i_X509_ALGOR @755
840 _d2i_X509_ATTRIBUTE @756
841 _d2i_X509_CINF @757
842 _d2i_X509_CRL @758
843 _d2i_X509_CRL_INFO @759
844 _d2i_X509_CRL_bio @760
845 _d2i_X509_EXTENSION @762
846 _d2i_X509_NAME @763
847 _d2i_X509_NAME_ENTRY @764
848 _d2i_X509_PKEY @765
849 _d2i_X509_PUBKEY @766
850 _d2i_X509_REQ @767
851 _d2i_X509_REQ_INFO @768
852 _d2i_X509_REQ_bio @769
853 _d2i_X509_REVOKED @771
854 _d2i_X509_SIG @772
855 _d2i_X509_VAL @773
856 _d2i_X509_bio @774
857 _des_cbc_cksum @777
858 _des_cbc_encrypt @778
859 _des_cblock_print_file @779
860 _des_cfb64_encrypt @780
861 _des_cfb_encrypt @781
862 _des_decrypt3 @782
863 _des_ecb3_encrypt @783
864 _des_ecb_encrypt @784
865 _des_ede3_cbc_encrypt @785
866 _des_ede3_cfb64_encrypt @786
867 _des_ede3_ofb64_encrypt @787
868 _des_enc_read @788
869 _des_enc_write @789
870 _des_encrypt @790
871 _des_encrypt2 @791
872 _des_encrypt3 @792
873 _des_fcrypt @793
874 _des_is_weak_key @794
875 _des_key_sched @795
876 _des_ncbc_encrypt @796
877 _des_ofb64_encrypt @797
878 _des_ofb_encrypt @798
879 _des_options @799
880 _des_pcbc_encrypt @800
881 _des_quad_cksum @801
882 _des_random_key @802
883 _des_random_seed @803
884 _des_read_2passwords @804
885 _des_read_password @805
886 _des_read_pw @806
887 _des_read_pw_string @807
888 _des_set_key @808
889 _des_set_odd_parity @809
890 _des_string_to_2keys @810
891 _des_string_to_key @811
892 _des_xcbc_encrypt @812
893 _des_xwhite_in2out @813
894 _i2a_ASN1_INTEGER @815
895 _i2a_ASN1_OBJECT @816
896 _i2a_ASN1_STRING @817
897 _i2d_ASN1_BIT_STRING @818
898 _i2d_ASN1_BOOLEAN @819
899 _i2d_ASN1_HEADER @820
900 _i2d_ASN1_IA5STRING @821
901 _i2d_ASN1_INTEGER @822
902 _i2d_ASN1_OBJECT @823
903 _i2d_ASN1_OCTET_STRING @824
904 _i2d_ASN1_PRINTABLE @825
905 _i2d_ASN1_SET @826
906 _i2d_ASN1_TYPE @827
907 _i2d_ASN1_UTCTIME @828
908 _i2d_ASN1_bytes @829
909 _i2d_DHparams @830
910 _i2d_DSAPrivateKey @831
911 _i2d_DSAPrivateKey_bio @832
912 _i2d_DSAPublicKey @834
913 _i2d_DSAparams @835
914 _i2d_NETSCAPE_SPKAC @836
915 _i2d_NETSCAPE_SPKI @837
916 _i2d_Netscape_RSA @838
917 _i2d_PKCS7 @839
918 _i2d_PKCS7_DIGEST @840
919 _i2d_PKCS7_ENCRYPT @841
920 _i2d_PKCS7_ENC_CONTENT @842
921 _i2d_PKCS7_ENVELOPE @843
922 _i2d_PKCS7_ISSUER_AND_SERIAL @844
923 _i2d_PKCS7_RECIP_INFO @845
924 _i2d_PKCS7_SIGNED @846
925 _i2d_PKCS7_SIGNER_INFO @847
926 _i2d_PKCS7_SIGN_ENVELOPE @848
927 _i2d_PKCS7_bio @849
928 _i2d_PrivateKey @851
929 _i2d_PublicKey @852
930 _i2d_RSAPrivateKey @853
931 _i2d_RSAPrivateKey_bio @854
932 _i2d_RSAPublicKey @856
933 _i2d_RSAPublicKey_bio @946
934 _i2d_X509 @857
935 _i2d_X509_ALGOR @858
936 _i2d_X509_ATTRIBUTE @859
937 _i2d_X509_CINF @860
938 _i2d_X509_CRL @861
939 _i2d_X509_CRL_INFO @862
940 _i2d_X509_CRL_bio @863
941 _i2d_X509_EXTENSION @865
942 _i2d_X509_NAME @866
943 _i2d_X509_NAME_ENTRY @867
944 _i2d_X509_PKEY @868
945 _i2d_X509_PUBKEY @869
946 _i2d_X509_REQ @870
947 _i2d_X509_REQ_INFO @871
948 _i2d_X509_REQ_bio @872
949 _i2d_X509_REVOKED @874
950 _i2d_X509_SIG @875
951 _i2d_X509_VAL @876
952 _i2d_X509_bio @877
953 _i2t_ASN1_OBJECT @979
954 _idea_cbc_encrypt @879
955 _idea_cfb64_encrypt @880
956 _idea_ecb_encrypt @881
957 _idea_encrypt @882
958 _idea_ofb64_encrypt @883
959 _idea_options @884
960 _idea_set_decrypt_key @885
961 _idea_set_encrypt_key @886
962 _lh_delete @887
963 _lh_doall @888
964 _lh_doall_arg @889
965 _lh_free @890
966 _lh_insert @891
967 _lh_new @892
968 _lh_node_stats_bio @894
969 _lh_node_usage_stats_bio @896
970 _lh_retrieve @897
971 _lh_stats_bio @899
972 _lh_strhash @900
973 _sk_delete @901
974 _sk_delete_ptr @902
975 _sk_dup @903
976 _sk_find @904
977 _sk_free @905
978 _sk_insert @906
979 _sk_new @907
980 _sk_pop @908
981 _sk_pop_free @909
982 _sk_push @910
983 _sk_set_cmp_func @911
984 _sk_shift @912
985 _sk_unshift @913
986 _sk_zero @914
987
diff --git a/src/lib/libssl/src/ms/libeay32.def b/src/lib/libssl/src/ms/libeay32.def
new file mode 100644
index 0000000000..196c52216e
--- /dev/null
+++ b/src/lib/libssl/src/ms/libeay32.def
@@ -0,0 +1,1035 @@
1;
2; Definition file for the DDL version of the LIBEAY32 library from SSLeay
3;
4
5LIBRARY LIBEAY32
6
7DESCRIPTION 'SSLeay LIBEAY32 - eay@cryptsoft.com'
8
9EXPORTS
10 SSLeay @1
11 SSLeay_add_all_algorithms @508
12 SSLeay_add_all_ciphers @509
13 SSLeay_add_all_digests @510
14 SSLeay_version @2
15 ASN1_BIT_STRING_asn1_meth @3
16 ASN1_BIT_STRING_get_bit @1060
17 ASN1_BIT_STRING_set_bit @1061
18 ASN1_HEADER_free @4
19 ASN1_HEADER_new @5
20 ASN1_IA5STRING_asn1_meth @6
21 ASN1_INTEGER_get @7
22 ASN1_INTEGER_set @8
23 ASN1_INTEGER_to_BN @9
24 ASN1_OBJECT_create @10
25 ASN1_OBJECT_free @11
26 ASN1_OBJECT_new @12
27 ASN1_PRINTABLE_type @13
28 ASN1_STRING_cmp @14
29 ASN1_STRING_dup @15
30 ASN1_STRING_free @16
31 ASN1_STRING_new @17
32 ASN1_STRING_print @18
33 ASN1_STRING_set @19
34 ASN1_STRING_type_new @20
35 ASN1_TYPE_free @21
36 ASN1_TYPE_get @916
37 ASN1_TYPE_get_int_octetstring @1076
38 ASN1_TYPE_get_octetstring @1077
39 ASN1_TYPE_new @22
40 ASN1_TYPE_set @917
41 ASN1_TYPE_set_int_octetstring @1078
42 ASN1_TYPE_set_octetstring @1079
43 ASN1_UNIVERSALSTRING_to_string @23
44 ASN1_UTCTIME_check @24
45 ASN1_UTCTIME_print @25
46 ASN1_UTCTIME_set @26
47 ASN1_UTCTIME_set_string @1080
48 ASN1_check_infinite_end @27
49 ASN1_d2i_bio @28
50 ASN1_d2i_fp @29
51 ASN1_digest @30
52 ASN1_dup @31
53 ASN1_get_object @32
54 ASN1_i2d_bio @33
55 ASN1_i2d_fp @34
56 ASN1_object_size @35
57 ASN1_parse @36
58 ASN1_put_object @37
59 ASN1_sign @38
60 ASN1_verify @39
61 BF_cbc_encrypt @40
62 BF_cfb64_encrypt @41
63 BF_decrypt @987
64 BF_ecb_encrypt @42
65 BF_encrypt @43
66 BF_ofb64_encrypt @44
67 BF_options @45
68 BF_set_key @46
69 BIO_accept @51
70 BIO_copy_next_retry @955
71 BIO_ctrl @52
72 BIO_debug_callback @54
73 BIO_dump @55
74 BIO_dup_chain @56
75 BIO_f_base64 @57
76 BIO_f_buffer @58
77 BIO_f_cipher @59
78 BIO_f_md @60
79 BIO_f_nbio_test @915
80 BIO_f_null @61
81 BIO_fd_non_fatal_error @63
82 BIO_fd_should_retry @64
83 BIO_find_type @65
84 BIO_free @66
85 BIO_free_all @67
86 BIO_get_accept_socket @69
87 BIO_get_host_ip @71
88 BIO_get_port @72
89 BIO_get_retry_BIO @73
90 BIO_get_retry_reason @74
91 BIO_gethostbyname @75
92 BIO_gets @76
93 BIO_ghbn_ctrl @1003
94 BIO_int_ctrl @53
95 BIO_new @78
96 BIO_new_accept @79
97 BIO_new_connect @80
98 BIO_new_fd @81
99 BIO_new_file @82
100 BIO_new_fp @83
101 BIO_new_socket @84
102 BIO_pop @85
103 BIO_printf @86
104 BIO_ptr_ctrl @969
105 BIO_push @87
106 BIO_puts @88
107 BIO_read @89
108 BIO_s_accept @90
109 BIO_s_connect @91
110 BIO_s_fd @92
111 BIO_s_file @93
112 BIO_s_mem @95
113 BIO_s_null @96
114 BIO_s_socket @98
115 BIO_set @100
116 BIO_set_cipher @101
117 BIO_set_tcp_ndelay @102
118 BIO_sock_cleanup @103
119 BIO_sock_error @104
120 BIO_sock_init @105
121 BIO_sock_non_fatal_error @106
122 BIO_sock_should_retry @107
123 BIO_socket_ioctl @108
124 BIO_write @109
125 BN_BLINDING_convert @973
126 BN_BLINDING_free @981
127 BN_BLINDING_invert @974
128 BN_BLINDING_new @980
129 BN_BLINDING_update @975
130 BN_CTX_free @110
131 BN_CTX_new @111
132 BN_MONT_CTX_free @112
133 BN_MONT_CTX_new @113
134 BN_MONT_CTX_set @114
135 BN_add @115
136 BN_add_word @116
137 BN_bin2bn @118
138 BN_bn2bin @120
139 BN_bn2dec @1002
140 BN_bn2hex @119
141 BN_bn2mpi @1058
142 BN_clear @121
143 BN_clear_bit @122
144 BN_clear_free @123
145 BN_cmp @124
146 BN_copy @125
147 BN_dec2bn @1001
148 BN_div @126
149 BN_div_word @127
150 BN_dup @128
151 BN_exp @998
152 BN_free @129
153 BN_from_montgomery @130
154 BN_gcd @131
155 BN_generate_prime @132
156 BN_get_word @133
157 BN_hex2bn @117
158 BN_is_bit_set @134
159 BN_is_prime @135
160 BN_lshift @136
161 BN_lshift1 @137
162 BN_mask_bits @138
163 BN_mod @139
164 BN_mod_exp @140
165 BN_mod_exp_mont @141
166 BN_mod_exp_recp @142
167 BN_mod_exp_simple @143
168 BN_mod_inverse @144
169 BN_mod_mul @145
170 BN_mod_mul_montgomery @146
171 BN_mod_mul_reciprocal @147
172 BN_mod_word @148
173 BN_mpi2bn @1059
174 BN_mul @149
175 BN_mul_word @999
176 BN_new @150
177 BN_num_bits @151
178 BN_num_bits_word @152
179 BN_options @153
180 BN_print @154
181 BN_print_fp @155
182 BN_rand @156
183 BN_reciprocal @157
184 BN_rshift @158
185 BN_rshift1 @159
186 BN_set_bit @160
187 BN_set_word @161
188 BN_sqr @162
189 BN_sub @163
190 BN_sub_word @1000
191 BN_to_ASN1_INTEGER @164
192 BN_ucmp @165
193 BN_value_one @166
194 BUF_MEM_free @167
195 BUF_MEM_grow @168
196 BUF_MEM_new @169
197 BUF_strdup @170
198 CAST_cbc_encrypt @992
199 CAST_cfb64_encrypt @993
200 CAST_decrypt @990
201 CAST_ecb_encrypt @991
202 CAST_encrypt @989
203 CAST_ofb64_encrypt @994
204 CAST_set_key @988
205 CONF_free @171
206 CONF_get_number @172
207 CONF_get_section @173
208 CONF_get_string @174
209 CONF_load @175
210 CRYPTO_add_lock @176
211 CRYPTO_dbg_free @177
212 CRYPTO_dbg_malloc @178
213 CRYPTO_dbg_realloc @179
214 CRYPTO_dbg_remalloc @180
215 CRYPTO_dup_ex_data @1025
216 CRYPTO_free @181
217 CRYPTO_free_ex_data @1004
218 CRYPTO_get_add_lock_callback @182
219 CRYPTO_get_ex_data @1005
220 CRYPTO_get_ex_new_index @1041
221 CRYPTO_get_id_callback @183
222 CRYPTO_get_lock_name @184
223 CRYPTO_get_locking_callback @185
224 CRYPTO_get_mem_functions @186
225 CRYPTO_get_new_lockid @1026
226 CRYPTO_lock @187
227 CRYPTO_malloc @188
228 CRYPTO_mem_ctrl @189
229 CRYPTO_mem_leaks @190
230 CRYPTO_mem_leaks_cb @191
231 CRYPTO_mem_leaks_fp @192
232 CRYPTO_new_ex_data @1027
233 CRYPTO_realloc @193
234 CRYPTO_remalloc @194
235 CRYPTO_set_add_lock_callback @195
236 CRYPTO_set_ex_data @1007
237 CRYPTO_set_id_callback @196
238 CRYPTO_set_locking_callback @197
239 CRYPTO_set_mem_functions @198
240 CRYPTO_thread_id @199
241 DH_check @200
242 DH_compute_key @201
243 DH_free @202
244 DH_generate_key @203
245 DH_generate_parameters @204
246 DH_new @205
247 DH_size @206
248 DHparams_print @207
249 DHparams_print_fp @208
250 DSA_free @209
251 DSA_generate_key @210
252 DSA_generate_parameters @211
253 DSA_is_prime @212
254 DSA_new @213
255 DSA_print @214
256 DSA_print_fp @215
257 DSA_sign @216
258 DSA_sign_setup @217
259 DSA_size @218
260 DSA_verify @219
261 DSAparams_print @220
262 DSAparams_print_fp @221
263 ERR_add_error_data @1081
264 ERR_clear_error @222
265 ERR_error_string @223
266 ERR_free_strings @224
267 ERR_func_error_string @225
268 ERR_get_err_state_table @226
269 ERR_get_error @227
270 ERR_get_error_line @228
271 ERR_get_next_error_library @966
272 ERR_get_state @229
273 ERR_get_string_table @230
274 ERR_lib_error_string @231
275 ERR_load_ASN1_strings @232
276 ERR_load_BIO_strings @233
277 ERR_load_BN_strings @234
278 ERR_load_BUF_strings @235
279 ERR_load_CONF_strings @236
280 ERR_load_CRYPTO_strings @1009
281 ERR_load_DH_strings @237
282 ERR_load_DSA_strings @238
283 ERR_load_ERR_strings @239
284 ERR_load_EVP_strings @240
285 ERR_load_OBJ_strings @241
286 ERR_load_PEM_strings @242
287 ERR_load_PKCS7_strings @919
288 ERR_load_RSA_strings @244
289 ERR_load_X509_strings @245
290 ERR_load_crypto_strings @246
291 ERR_load_strings @247
292 ERR_peek_error @248
293 ERR_peek_error_line @249
294 ERR_print_errors @250
295 ERR_print_errors_fp @251
296 ERR_put_error @252
297 ERR_reason_error_string @253
298 ERR_remove_state @254
299 ERR_set_error_data @1082
300 EVP_BytesToKey @255
301 EVP_CIPHER_CTX_cleanup @256
302 EVP_CIPHER_CTX_init @961
303 EVP_CIPHER_asn1_to_param @1083
304 EVP_CIPHER_get_asn1_iv @1085
305 EVP_CIPHER_param_to_asn1 @1084
306 EVP_CIPHER_set_asn1_iv @1086
307 EVP_CipherFinal @257
308 EVP_CipherInit @258
309 EVP_CipherUpdate @259
310 EVP_DecodeBlock @260
311 EVP_DecodeFinal @261
312 EVP_DecodeInit @262
313 EVP_DecodeUpdate @263
314 EVP_DecryptFinal @264
315 EVP_DecryptInit @265
316 EVP_DecryptUpdate @266
317 EVP_DigestFinal @267
318 EVP_DigestInit @268
319 EVP_DigestUpdate @269
320 EVP_EncodeBlock @270
321 EVP_EncodeFinal @271
322 EVP_EncodeInit @272
323 EVP_EncodeUpdate @273
324 EVP_EncryptFinal @274
325 EVP_EncryptInit @275
326 EVP_EncryptUpdate @276
327 EVP_OpenFinal @277
328 EVP_OpenInit @278
329 EVP_PKEY_assign @279
330 EVP_PKEY_bits @1010
331 EVP_PKEY_cmp_parameters @967
332 EVP_PKEY_copy_parameters @280
333 EVP_PKEY_decrypt @1070
334 EVP_PKEY_encrypt @1071
335 EVP_PKEY_free @281
336 EVP_PKEY_missing_parameters @282
337 EVP_PKEY_new @283
338 EVP_PKEY_save_parameters @284
339 EVP_PKEY_size @285
340 EVP_PKEY_type @286
341 EVP_SealFinal @287
342 EVP_SealInit @288
343 EVP_SignFinal @289
344 EVP_VerifyFinal @290
345 EVP_add_alias @291
346 EVP_add_cipher @292
347 EVP_add_digest @293
348 EVP_bf_cbc @294
349 EVP_bf_cfb @295
350 EVP_bf_ecb @296
351 EVP_bf_ofb @297
352 EVP_cast5_cbc @983
353 EVP_cast5_cfb @984
354 EVP_cast5_ecb @985
355 EVP_cast5_ofb @986
356 EVP_cleanup @298
357 EVP_delete_alias @941
358 EVP_des_cbc @299
359 EVP_des_cfb @300
360 EVP_des_ecb @301
361 EVP_des_ede @302
362 EVP_des_ede3 @303
363 EVP_des_ede3_cbc @304
364 EVP_des_ede3_cfb @305
365 EVP_des_ede3_ofb @306
366 EVP_des_ede_cbc @307
367 EVP_des_ede_cfb @308
368 EVP_des_ede_ofb @309
369 EVP_des_ofb @310
370 EVP_desx_cbc @311
371 EVP_dss @312
372 EVP_dss1 @313
373 EVP_enc_null @314
374 EVP_get_cipherbyname @315
375 EVP_get_digestbyname @316
376 EVP_get_pw_prompt @317
377 EVP_idea_cbc @318
378 EVP_idea_cfb @319
379 EVP_idea_ecb @320
380 EVP_idea_ofb @321
381 EVP_md2 @322
382 EVP_md5 @323
383 EVP_md_null @324
384 EVP_mdc2 @942
385 EVP_rc2_40_cbc @959
386 EVP_rc2_cbc @325
387 EVP_rc2_cfb @326
388 EVP_rc2_ecb @327
389 EVP_rc2_ofb @328
390 EVP_rc4 @329
391 EVP_rc4_40 @960
392 EVP_rc5_32_12_16_cbc @1087
393 EVP_rc5_32_12_16_cfb @1088
394 EVP_rc5_32_12_16_ecb @1089
395 EVP_rc5_32_12_16_ofb @1090
396 EVP_read_pw_string @330
397 EVP_set_pw_prompt @331
398 EVP_sha @332
399 EVP_sha1 @333
400 HMAC @962
401 HMAC_Final @965
402 HMAC_Init @963
403 HMAC_Update @964
404 HMAC_cleanup @968
405 MD2 @334
406 MD2_Final @335
407 MD2_Init @336
408 MD2_Update @337
409 MD2_options @338
410 MD5 @339
411 MD5_Final @340
412 MD5_Init @341
413 MD5_Transform @1011
414 MD5_Update @342
415 MDC2 @343
416 MDC2_Final @344
417 MDC2_Init @345
418 MDC2_Update @346
419 NETSCAPE_SPKAC_free @347
420 NETSCAPE_SPKAC_new @348
421 NETSCAPE_SPKI_free @349
422 NETSCAPE_SPKI_new @350
423 NETSCAPE_SPKI_sign @351
424 NETSCAPE_SPKI_verify @352
425 OBJ_add_object @353
426 OBJ_bsearch @354
427 OBJ_cleanup @355
428 OBJ_cmp @356
429 OBJ_create @357
430 OBJ_create_objects @997
431 OBJ_dup @358
432 OBJ_ln2nid @359
433 OBJ_new_nid @360
434 OBJ_nid2ln @361
435 OBJ_nid2obj @362
436 OBJ_nid2sn @363
437 OBJ_obj2nid @364
438 OBJ_sn2nid @365
439 OBJ_txt2nid @366
440 PEM_ASN1_read @367
441 PEM_ASN1_read_bio @368
442 PEM_ASN1_write @369
443 PEM_ASN1_write_bio @370
444 PEM_SealFinal @371
445 PEM_SealInit @372
446 PEM_SealUpdate @373
447 PEM_SignFinal @374
448 PEM_X509_INFO_read @377
449 PEM_X509_INFO_read_bio @378
450 PEM_X509_INFO_write_bio @379
451 PEM_dek_info @380
452 PEM_do_header @381
453 PEM_get_EVP_CIPHER_INFO @382
454 PEM_proc_type @383
455 PEM_read @384
456 PEM_read_DHparams @385
457 PEM_read_DSAPrivateKey @386
458 PEM_read_DSAparams @387
459 PEM_read_PKCS7 @388
460 PEM_read_PrivateKey @389
461 PEM_read_RSAPrivateKey @390
462 PEM_read_RSAPublicKey @947
463 PEM_read_X509 @391
464 PEM_read_X509_CRL @392
465 PEM_read_X509_REQ @393
466 PEM_read_bio @394
467 PEM_read_bio_DHparams @395
468 PEM_read_bio_DSAPrivateKey @396
469 PEM_read_bio_DSAparams @397
470 PEM_read_bio_PKCS7 @398
471 PEM_read_bio_PrivateKey @399
472 PEM_read_bio_RSAPrivateKey @400
473 PEM_read_bio_RSAPublicKey @943
474 PEM_read_bio_X509 @401
475 PEM_read_bio_X509_CRL @402
476 PEM_read_bio_X509_REQ @403
477 PEM_write @404
478 PEM_write_DHparams @405
479 PEM_write_DSAPrivateKey @406
480 PEM_write_DSAparams @407
481 PEM_write_PKCS7 @408
482 PEM_write_PrivateKey @409
483 PEM_write_RSAPrivateKey @410
484 PEM_write_RSAPublicKey @949
485 PEM_write_X509 @411
486 PEM_write_X509_CRL @412
487 PEM_write_X509_REQ @413
488 PEM_write_bio @414
489 PEM_write_bio_DHparams @415
490 PEM_write_bio_DSAPrivateKey @416
491 PEM_write_bio_DSAparams @417
492 PEM_write_bio_PKCS7 @418
493 PEM_write_bio_PrivateKey @419
494 PEM_write_bio_RSAPrivateKey @420
495 PEM_write_bio_RSAPublicKey @944
496 PEM_write_bio_X509 @421
497 PEM_write_bio_X509_CRL @422
498 PEM_write_bio_X509_REQ @423
499 PKCS7_DIGEST_free @424
500 PKCS7_DIGEST_new @425
501 PKCS7_ENCRYPT_free @426
502 PKCS7_ENCRYPT_new @427
503 PKCS7_ENC_CONTENT_free @428
504 PKCS7_ENC_CONTENT_new @429
505 PKCS7_ENVELOPE_free @430
506 PKCS7_ENVELOPE_new @431
507 PKCS7_ISSUER_AND_SERIAL_digest @432
508 PKCS7_ISSUER_AND_SERIAL_free @433
509 PKCS7_ISSUER_AND_SERIAL_new @434
510 PKCS7_RECIP_INFO_free @435
511 PKCS7_RECIP_INFO_new @436
512 PKCS7_RECIP_INFO_set @1072
513 PKCS7_SIGNED_free @437
514 PKCS7_SIGNED_new @438
515 PKCS7_SIGNER_INFO_free @439
516 PKCS7_SIGNER_INFO_new @440
517 PKCS7_SIGNER_INFO_set @930
518 PKCS7_SIGN_ENVELOPE_free @441
519 PKCS7_SIGN_ENVELOPE_new @442
520 PKCS7_add_certificate @932
521 PKCS7_add_crl @933
522 PKCS7_add_recipient @1073
523 PKCS7_add_recipient_info @1074
524 PKCS7_add_signature @938
525 PKCS7_add_signer @931
526 PKCS7_cert_from_signer_info @939
527 PKCS7_content_free @918
528 PKCS7_content_new @934
529 PKCS7_ctrl @927
530 PKCS7_dataInit @937
531 PKCS7_dataSign @935
532 PKCS7_dataVerify @936
533 PKCS7_dup @443
534 PKCS7_free @444
535 PKCS7_get_signer_info @940
536 PKCS7_new @445
537 PKCS7_set_cipher @1075
538 PKCS7_set_content @929
539 PKCS7_set_type @928
540 RAND_bytes @464
541 RAND_cleanup @465
542 RAND_file_name @466
543 RAND_load_file @467
544 RAND_screen @468
545 RAND_seed @469
546 RAND_write_file @470
547 RC2_cbc_encrypt @471
548 RC2_cfb64_encrypt @472
549 RC2_decrypt @995
550 RC2_ecb_encrypt @473
551 RC2_encrypt @474
552 RC2_ofb64_encrypt @475
553 RC2_set_key @476
554 RC4 @477
555 RC4_options @478
556 RC4_set_key @479
557 RC5_32_cbc_encrypt @1051
558 RC5_32_cfb64_encrypt @1052
559 RC5_32_decrypt @1050
560 RC5_32_ecb_encrypt @1048
561 RC5_32_encrypt @1049
562 RC5_32_ofb64_encrypt @1053
563 RC5_32_set_key @1047
564 RIPEMD160 @1045
565 RIPEMD160_Final @1044
566 RIPEMD160_Init @1042
567 RIPEMD160_Transform @1046
568 RIPEMD160_Update @1043
569 RSAPrivateKey_asn1_meth @480
570 RSAPrivateKey_dup @481
571 RSAPublicKey_dup @482
572 RSA_PKCS1_SSLeay @483
573 RSA_blinding_off @978
574 RSA_blinding_on @977
575 RSA_flags @956
576 RSA_free @484
577 RSA_generate_key @485
578 RSA_get_ex_data @1029
579 RSA_get_ex_new_index @1030
580 RSA_new @486
581 RSA_new_method @487
582 RSA_padding_add_PKCS1_type_1 @1031
583 RSA_padding_add_PKCS1_type_2 @1032
584 RSA_padding_add_SSLv23 @1033
585 RSA_padding_add_none @1034
586 RSA_padding_check_PKCS1_type_1 @1035
587 RSA_padding_check_PKCS1_type_2 @1036
588 RSA_padding_check_SSLv23 @1037
589 RSA_padding_check_none @1038
590 RSA_print @488
591 RSA_print_fp @489
592 RSA_private_decrypt @490
593 RSA_private_encrypt @491
594 RSA_public_decrypt @492
595 RSA_public_encrypt @493
596 RSA_set_default_method @494
597 RSA_set_ex_data @1028
598 RSA_sign @495
599 RSA_sign_ASN1_OCTET_STRING @496
600 RSA_size @497
601 RSA_verify @498
602 RSA_verify_ASN1_OCTET_STRING @499
603 SHA @500
604 SHA1 @501
605 SHA1_Final @502
606 SHA1_Init @503
607 SHA1_Transform @1012
608 SHA1_Update @504
609 SHA_Final @505
610 SHA_Init @506
611 SHA_Transform @1013
612 SHA_Update @507
613 TXT_DB_create_index @511
614 TXT_DB_free @512
615 TXT_DB_get_by_index @513
616 TXT_DB_insert @514
617 TXT_DB_read @515
618 TXT_DB_write @516
619 X509_ALGOR_free @517
620 X509_ALGOR_new @518
621 X509_ATTRIBUTE_free @519
622 X509_ATTRIBUTE_new @520
623 X509_CINF_free @521
624 X509_CINF_new @522
625 X509_CRL_INFO_free @523
626 X509_CRL_INFO_new @524
627 X509_CRL_add_ext @525
628 X509_CRL_cmp @526
629 X509_CRL_delete_ext @527
630 X509_CRL_dup @528
631 X509_CRL_free @529
632 X509_CRL_get_ext @530
633 X509_CRL_get_ext_by_NID @531
634 X509_CRL_get_ext_by_OBJ @532
635 X509_CRL_get_ext_by_critical @533
636 X509_CRL_get_ext_count @534
637 X509_CRL_new @535
638 X509_CRL_sign @536
639 X509_CRL_verify @537
640 X509_EXTENSION_create_by_NID @538
641 X509_EXTENSION_create_by_OBJ @539
642 X509_EXTENSION_dup @540
643 X509_EXTENSION_free @541
644 X509_EXTENSION_get_critical @542
645 X509_EXTENSION_get_data @543
646 X509_EXTENSION_get_object @544
647 X509_EXTENSION_new @545
648 X509_EXTENSION_set_critical @546
649 X509_EXTENSION_set_data @547
650 X509_EXTENSION_set_object @548
651 X509_INFO_free @549
652 X509_INFO_new @550
653 X509_LOOKUP_by_alias @551
654 X509_LOOKUP_by_fingerprint @552
655 X509_LOOKUP_by_issuer_serial @553
656 X509_LOOKUP_by_subject @554
657 X509_LOOKUP_ctrl @555
658 X509_LOOKUP_file @556
659 X509_LOOKUP_free @557
660 X509_LOOKUP_hash_dir @558
661 X509_LOOKUP_init @559
662 X509_LOOKUP_new @560
663 X509_LOOKUP_shutdown @561
664 X509_NAME_ENTRY_create_by_NID @562
665 X509_NAME_ENTRY_create_by_OBJ @563
666 X509_NAME_ENTRY_dup @564
667 X509_NAME_ENTRY_free @565
668 X509_NAME_ENTRY_get_data @566
669 X509_NAME_ENTRY_get_object @567
670 X509_NAME_ENTRY_new @568
671 X509_NAME_ENTRY_set_data @569
672 X509_NAME_ENTRY_set_object @570
673 X509_NAME_add_entry @571
674 X509_NAME_cmp @572
675 X509_NAME_delete_entry @573
676 X509_NAME_digest @574
677 X509_NAME_dup @575
678 X509_NAME_entry_count @576
679 X509_NAME_free @577
680 X509_NAME_get_entry @578
681 X509_NAME_get_index_by_NID @579
682 X509_NAME_get_index_by_OBJ @580
683 X509_NAME_get_text_by_NID @581
684 X509_NAME_get_text_by_OBJ @582
685 X509_NAME_hash @583
686 X509_NAME_new @584
687 X509_NAME_oneline @585
688 X509_NAME_print @586
689 X509_NAME_set @587
690 X509_OBJECT_free_contents @588
691 X509_OBJECT_retrive_by_subject @589
692 X509_OBJECT_up_ref_count @590
693 X509_PKEY_free @591
694 X509_PKEY_new @592
695 X509_PUBKEY_free @593
696 X509_PUBKEY_get @594
697 X509_PUBKEY_new @595
698 X509_PUBKEY_set @596
699 X509_REQ_INFO_free @597
700 X509_REQ_INFO_new @598
701 X509_REQ_dup @599
702 X509_REQ_free @600
703 X509_REQ_get_pubkey @601
704 X509_REQ_new @602
705 X509_REQ_print @603
706 X509_REQ_print_fp @604
707 X509_REQ_set_pubkey @605
708 X509_REQ_set_subject_name @606
709 X509_REQ_set_version @607
710 X509_REQ_sign @608
711 X509_REQ_to_X509 @609
712 X509_REQ_verify @610
713 X509_REVOKED_add_ext @611
714 X509_REVOKED_delete_ext @612
715 X509_REVOKED_free @613
716 X509_REVOKED_get_ext @614
717 X509_REVOKED_get_ext_by_NID @615
718 X509_REVOKED_get_ext_by_OBJ @616
719 X509_REVOKED_get_ext_by_critical @617
720 X509_REVOKED_get_ext_count @618
721 X509_REVOKED_new @619
722 X509_SIG_free @620
723 X509_SIG_new @621
724 X509_STORE_CTX_cleanup @622
725 X509_STORE_CTX_get_chain @1014
726 X509_STORE_CTX_get_current_cert @1015
727 X509_STORE_CTX_get_error @1016
728 X509_STORE_CTX_get_error_depth @1017
729 X509_STORE_CTX_get_ex_data @1018
730 X509_STORE_CTX_init @623
731 X509_STORE_CTX_set_cert @1020
732 X509_STORE_CTX_set_chain @1021
733 X509_STORE_CTX_set_error @1022
734 X509_STORE_CTX_set_ex_data @1023
735 X509_STORE_add_cert @624
736 X509_STORE_add_crl @957
737 X509_STORE_add_lookup @625
738 X509_STORE_free @626
739 X509_STORE_get_by_subject @627
740 X509_STORE_load_locations @628
741 X509_STORE_new @629
742 X509_STORE_set_default_paths @630
743 X509_VAL_free @631
744 X509_VAL_new @632
745 X509_add_ext @633
746 X509_asn1_meth @634
747 X509_certificate_type @635
748 X509_check_private_key @636
749 X509_cmp_current_time @637
750 X509_delete_ext @638
751 X509_digest @639
752 X509_dup @640
753 X509_find_by_issuer_and_serial @920
754 X509_find_by_subject @921
755 X509_free @641
756 X509_get_default_cert_area @642
757 X509_get_default_cert_dir @643
758 X509_get_default_cert_dir_env @644
759 X509_get_default_cert_file @645
760 X509_get_default_cert_file_env @646
761 X509_get_default_private_dir @647
762 X509_get_ext @648
763 X509_get_ext_by_NID @649
764 X509_get_ext_by_OBJ @650
765 X509_get_ext_by_critical @651
766 X509_get_ext_count @652
767 X509_get_issuer_name @653
768 X509_get_pubkey @654
769 X509_get_pubkey_parameters @655
770 X509_get_serialNumber @656
771 X509_get_subject_name @657
772 X509_gmtime_adj @658
773 X509_issuer_and_serial_cmp @659
774 X509_issuer_and_serial_hash @660
775 X509_issuer_name_cmp @661
776 X509_issuer_name_hash @662
777 X509_load_cert_file @663
778 X509_load_crl_file @958
779 X509_new @664
780 X509_print @665
781 X509_print_fp @666
782 X509_set_issuer_name @667
783 X509_set_notAfter @668
784 X509_set_notBefore @669
785 X509_set_pubkey @670
786 X509_set_serialNumber @671
787 X509_set_subject_name @672
788 X509_set_version @673
789 X509_sign @674
790 X509_subject_name_cmp @675
791 X509_subject_name_hash @676
792 X509_to_X509_REQ @677
793 X509_verify @678
794 X509_verify_cert @679
795 X509_verify_cert_error_string @680
796 X509v3_add_ext @681
797 X509v3_add_extension @682
798 X509v3_add_netscape_extensions @683
799 X509v3_add_standard_extensions @684
800 X509v3_cleanup_extensions @685
801 X509v3_data_type_by_NID @686
802 X509v3_data_type_by_OBJ @687
803 X509v3_delete_ext @688
804 X509v3_get_ext @689
805 X509v3_get_ext_by_NID @690
806 X509v3_get_ext_by_OBJ @691
807 X509v3_get_ext_by_critical @692
808 X509v3_get_ext_count @693
809 X509v3_pack_string @694
810 X509v3_pack_type_by_NID @695
811 X509v3_pack_type_by_OBJ @696
812 X509v3_unpack_string @697
813 a2d_ASN1_OBJECT @699
814 a2i_ASN1_INTEGER @700
815 a2i_ASN1_STRING @701
816 asn1_Finish @702
817 asn1_GetSequence @703
818 asn1_add_error @1091
819 bn_add_words @1039
820 bn_div64 @704
821 bn_expand2 @705
822 bn_mul_add_words @706
823 bn_mul_words @707
824 bn_qadd @708
825 bn_qsub @709
826 bn_sqr_words @710
827 crypt @711
828 d2i_ASN1_BIT_STRING @712
829 d2i_ASN1_BOOLEAN @713
830 d2i_ASN1_HEADER @714
831 d2i_ASN1_IA5STRING @715
832 d2i_ASN1_INTEGER @716
833 d2i_ASN1_OBJECT @717
834 d2i_ASN1_OCTET_STRING @718
835 d2i_ASN1_PRINTABLE @719
836 d2i_ASN1_PRINTABLESTRING @720
837 d2i_ASN1_SET @721
838 d2i_ASN1_T61STRING @722
839 d2i_ASN1_TYPE @723
840 d2i_ASN1_UTCTIME @724
841 d2i_ASN1_bytes @725
842 d2i_ASN1_type_bytes @726
843 d2i_DHparams @727
844 d2i_DSAPrivateKey @728
845 d2i_DSAPrivateKey_bio @729
846 d2i_DSAPrivateKey_fp @730
847 d2i_DSAPublicKey @731
848 d2i_DSAparams @732
849 d2i_NETSCAPE_SPKAC @733
850 d2i_NETSCAPE_SPKI @734
851 d2i_Netscape_RSA @735
852 d2i_Netscape_RSA_2 @1040
853 d2i_PKCS7 @736
854 d2i_PKCS7_DIGEST @737
855 d2i_PKCS7_ENCRYPT @738
856 d2i_PKCS7_ENC_CONTENT @739
857 d2i_PKCS7_ENVELOPE @740
858 d2i_PKCS7_ISSUER_AND_SERIAL @741
859 d2i_PKCS7_RECIP_INFO @742
860 d2i_PKCS7_SIGNED @743
861 d2i_PKCS7_SIGNER_INFO @744
862 d2i_PKCS7_SIGN_ENVELOPE @745
863 d2i_PKCS7_bio @746
864 d2i_PKCS7_fp @747
865 d2i_PrivateKey @748
866 d2i_PublicKey @749
867 d2i_RSAPrivateKey @750
868 d2i_RSAPrivateKey_bio @751
869 d2i_RSAPrivateKey_fp @752
870 d2i_RSAPublicKey @753
871 d2i_RSAPublicKey_bio @945
872 d2i_RSAPublicKey_fp @952
873 d2i_X509 @754
874 d2i_X509_ALGOR @755
875 d2i_X509_ATTRIBUTE @756
876 d2i_X509_CINF @757
877 d2i_X509_CRL @758
878 d2i_X509_CRL_INFO @759
879 d2i_X509_CRL_bio @760
880 d2i_X509_CRL_fp @761
881 d2i_X509_EXTENSION @762
882 d2i_X509_NAME @763
883 d2i_X509_NAME_ENTRY @764
884 d2i_X509_PKEY @765
885 d2i_X509_PUBKEY @766
886 d2i_X509_REQ @767
887 d2i_X509_REQ_INFO @768
888 d2i_X509_REQ_bio @769
889 d2i_X509_REQ_fp @770
890 d2i_X509_REVOKED @771
891 d2i_X509_SIG @772
892 d2i_X509_VAL @773
893 d2i_X509_bio @774
894 d2i_X509_fp @775
895 des_cbc_cksum @777
896 des_cbc_encrypt @778
897 des_cblock_print_file @779
898 des_cfb64_encrypt @780
899 des_cfb_encrypt @781
900 des_decrypt3 @782
901 des_ecb3_encrypt @783
902 des_ecb_encrypt @784
903 des_ede3_cbc_encrypt @785
904 des_ede3_cfb64_encrypt @786
905 des_ede3_ofb64_encrypt @787
906 des_enc_read @788
907 des_enc_write @789
908 des_encrypt @790
909 des_encrypt2 @791
910 des_encrypt3 @792
911 des_fcrypt @793
912 des_is_weak_key @794
913 des_key_sched @795
914 des_ncbc_encrypt @796
915 des_ofb64_encrypt @797
916 des_ofb_encrypt @798
917 des_options @799
918 des_pcbc_encrypt @800
919 des_quad_cksum @801
920 des_random_key @802
921 des_random_seed @803
922 des_read_2passwords @804
923 des_read_password @805
924 des_read_pw @806
925 des_read_pw_string @807
926 des_set_key @808
927 des_set_odd_parity @809
928 des_string_to_2keys @810
929 des_string_to_key @811
930 des_xcbc_encrypt @812
931 des_xwhite_in2out @813
932 i2a_ASN1_INTEGER @815
933 i2a_ASN1_OBJECT @816
934 i2a_ASN1_STRING @817
935 i2d_ASN1_BIT_STRING @818
936 i2d_ASN1_BOOLEAN @819
937 i2d_ASN1_HEADER @820
938 i2d_ASN1_IA5STRING @821
939 i2d_ASN1_INTEGER @822
940 i2d_ASN1_OBJECT @823
941 i2d_ASN1_OCTET_STRING @824
942 i2d_ASN1_PRINTABLE @825
943 i2d_ASN1_SET @826
944 i2d_ASN1_TYPE @827
945 i2d_ASN1_UTCTIME @828
946 i2d_ASN1_bytes @829
947 i2d_DHparams @830
948 i2d_DSAPrivateKey @831
949 i2d_DSAPrivateKey_bio @832
950 i2d_DSAPrivateKey_fp @833
951 i2d_DSAPublicKey @834
952 i2d_DSAparams @835
953 i2d_NETSCAPE_SPKAC @836
954 i2d_NETSCAPE_SPKI @837
955 i2d_Netscape_RSA @838
956 i2d_PKCS7 @839
957 i2d_PKCS7_DIGEST @840
958 i2d_PKCS7_ENCRYPT @841
959 i2d_PKCS7_ENC_CONTENT @842
960 i2d_PKCS7_ENVELOPE @843
961 i2d_PKCS7_ISSUER_AND_SERIAL @844
962 i2d_PKCS7_RECIP_INFO @845
963 i2d_PKCS7_SIGNED @846
964 i2d_PKCS7_SIGNER_INFO @847
965 i2d_PKCS7_SIGN_ENVELOPE @848
966 i2d_PKCS7_bio @849
967 i2d_PKCS7_fp @850
968 i2d_PrivateKey @851
969 i2d_PublicKey @852
970 i2d_RSAPrivateKey @853
971 i2d_RSAPrivateKey_bio @854
972 i2d_RSAPrivateKey_fp @855
973 i2d_RSAPublicKey @856
974 i2d_RSAPublicKey_bio @946
975 i2d_RSAPublicKey_fp @954
976 i2d_X509 @857
977 i2d_X509_ALGOR @858
978 i2d_X509_ATTRIBUTE @859
979 i2d_X509_CINF @860
980 i2d_X509_CRL @861
981 i2d_X509_CRL_INFO @862
982 i2d_X509_CRL_bio @863
983 i2d_X509_CRL_fp @864
984 i2d_X509_EXTENSION @865
985 i2d_X509_NAME @866
986 i2d_X509_NAME_ENTRY @867
987 i2d_X509_PKEY @868
988 i2d_X509_PUBKEY @869
989 i2d_X509_REQ @870
990 i2d_X509_REQ_INFO @871
991 i2d_X509_REQ_bio @872
992 i2d_X509_REQ_fp @873
993 i2d_X509_REVOKED @874
994 i2d_X509_SIG @875
995 i2d_X509_VAL @876
996 i2d_X509_bio @877
997 i2d_X509_fp @878
998 i2t_ASN1_OBJECT @979
999 idea_cbc_encrypt @879
1000 idea_cfb64_encrypt @880
1001 idea_ecb_encrypt @881
1002 idea_encrypt @882
1003 idea_ofb64_encrypt @883
1004 idea_options @884
1005 idea_set_decrypt_key @885
1006 idea_set_encrypt_key @886
1007 lh_delete @887
1008 lh_doall @888
1009 lh_doall_arg @889
1010 lh_free @890
1011 lh_insert @891
1012 lh_new @892
1013 lh_node_stats @893
1014 lh_node_stats_bio @894
1015 lh_node_usage_stats @895
1016 lh_node_usage_stats_bio @896
1017 lh_retrieve @897
1018 lh_stats @898
1019 lh_stats_bio @899
1020 lh_strhash @900
1021 sk_delete @901
1022 sk_delete_ptr @902
1023 sk_dup @903
1024 sk_find @904
1025 sk_free @905
1026 sk_insert @906
1027 sk_new @907
1028 sk_pop @908
1029 sk_pop_free @909
1030 sk_push @910
1031 sk_set_cmp_func @911
1032 sk_shift @912
1033 sk_unshift @913
1034 sk_zero @914
1035
diff --git a/src/lib/libssl/src/ms/ntdll.mak b/src/lib/libssl/src/ms/ntdll.mak
new file mode 100644
index 0000000000..044cd909bc
--- /dev/null
+++ b/src/lib/libssl/src/ms/ntdll.mak
@@ -0,0 +1,1853 @@
1# This makefile has been automatically generated from the SSLeay distribution.
2# This single makefile will build the complete SSLeay distribution and
3# by default leave the 'intertesting' output files in .\out and the stuff
4# that needs deleting in .\tmp.
5# The file was generated by running 'make makefile.one', which
6# does a 'make files', which writes all the environment variables from all
7# the makefiles to the file call MINFO. This file is used by
8# util\mk1mf.pl to generate makefile.one.
9# The 'makefile per directory' system suites me when developing this
10# library and also so I can 'distribute' indervidual library sections.
11# The one monster makefile better suits building in non-unix
12# environments.
13
14INSTALLTOP=\usr\local\ssl
15
16# Set your compiler options
17CC=cl
18CFLAG= /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DWIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM
19APP_CFLAG=
20LIB_CFLAG= /GD -D_WINDLL -D_DLL
21SHLIB_CFLAG=
22APP_EX_OBJ=setargv.obj
23SHLIB_EX_OBJ=
24# add extra libraries to this define, for solaris -lsocket -lnsl would
25# be added
26EX_LIBS=wsock32.lib user32.lib gdi32.lib
27
28# The SSLeay directory
29SRC_D=.
30
31LINK=link
32LFLAGS=/nologo /subsystem:console /machine:I386 /opt:ref
33
34BN_MULW_OBJ=crypto\bn\asm\bn-win32.obj
35BN_MULW_SRC=crypto\bn\asm\bn-win32.asm
36DES_ENC_OBJ=crypto\des\asm\d-win32.obj crypto\des\asm\y-win32.obj
37DES_ENC_SRC=crypto\des\asm\d-win32.asm crypto\des\asm\y-win32.asm
38DES_CRYPT_OBJ=
39DES_CRYPT_SRC=
40BF_ENC_OBJ=crypto\bf\asm\b-win32.obj
41BF_ENC_SRC=crypto\bf\asm\b-win32.asm
42CAST_ENC_OBJ=crypto\cast\asm\c-win32.obj
43CAST_ENC_SRC=crypto\cast\asm\c-win32.asm
44RC4_ENC_OBJ=crypto\rc4\asm\r4-win32.obj
45RC4_ENC_SRC=crypto\rc4\asm\r4-win32.asm
46RC5_ENC_OBJ=crypto\rc5\asm\r5-win32.obj
47RC5_ENC_SRC=crypto\rc5\asm\r5-win32.asm
48MD5_ASM_OBJ=crypto\md5\asm\m5-win32.obj
49MD5_ASM_SRC=crypto\md5\asm\m5-win32.asm
50SHA1_ASM_OBJ=crypto\sha\asm\s1-win32.obj
51SHA1_ASM_SRC=crypto\sha\asm\s1-win32.asm
52RMD160_ASM_OBJ=crypto\ripemd\asm\rm-win32.obj
53RMD160_ASM_SRC=crypto\ripemd\asm\rm-win32.asm
54
55# The output directory for everything intersting
56OUT_D=out32dll
57# The output directory for all the temporary muck
58TMP_D=tmp32dll
59# The output directory for the header files
60INC_D=inc32
61
62CP=copy
63RM=del
64RANLIB=
65MKDIR=mkdir
66MKLIB=lib
67MLFLAGS= /nologo /subsystem:console /machine:I386 /opt:ref /dll
68ASM=ml /Cp /coff /c /Cx
69
70######################################################
71# You should not need to touch anything below this point
72######################################################
73
74E_EXE=ssleay
75SSL=ssleay32
76CRYPTO=libeay32
77RSAGLUE=RSAglue
78
79# BIN_D - Binary output directory
80# TEST_D - Binary test file output directory
81# LIB_D - library output directory
82BIN_D=$(OUT_D)
83TEST_D=$(OUT_D)
84LIB_D=$(OUT_D)
85
86# INCL_D - local library directory
87# OBJ_D - temp object file directory
88OBJ_D=$(TMP_D)
89INCL_D=$(TMP_D)
90
91O_SSL= $(LIB_D)\$(SSL).dll
92O_CRYPTO= $(LIB_D)\$(CRYPTO).dll
93O_RSAGLUE= $(LIB_D)\$(RSAGLUE).lib
94SO_SSL= $(SSL)
95SO_CRYPTO= $(CRYPTO)
96L_SSL= $(LIB_D)\$(SSL).lib
97L_CRYPTO= $(LIB_D)\$(CRYPTO).lib
98
99L_LIBS= $(L_SSL) $(L_CRYPTO)
100#L_LIBS= $(O_SSL) $(O_RSAGLUE) -lrsaref $(O_CRYPTO)
101
102######################################################
103# Don't touch anything below this point
104######################################################
105
106INC=-I$(INC_D) -I$(INCL_D)
107APP_CFLAGS=$(INC) $(CFLAG) $(APP_CFLAG)
108LIB_CFLAGS=$(INC) $(CFLAG) $(LIB_CFLAG)
109SHLIB_CFLAGS=$(INC) $(CFLAG) $(LIB_CFLAG) $(SHLIB_CFLAG)
110LIBS_DEP=$(O_CRYPTO) $(O_RSAGLUE) $(O_SSL)
111
112#############################################
113HEADER=$(INCL_D)\cryptlib.h \
114 $(INCL_D)\date.h $(INCL_D)\md5_locl.h $(INCL_D)\sha_locl.h \
115 $(INCL_D)\rmd_locl.h $(INCL_D)\rmdconst.h $(INCL_D)\des_locl.h \
116 $(INCL_D)\rpc_des.h $(INCL_D)\podd.h $(INCL_D)\sk.h \
117 $(INCL_D)\spr.h $(INCL_D)\des_ver.h $(INCL_D)\rc2_locl.h \
118 $(INCL_D)\rc4_locl.h $(INCL_D)\rc5_locl.h $(INCL_D)\idea_lcl.h \
119 $(INCL_D)\bf_pi.h $(INCL_D)\bf_locl.h $(INCL_D)\cast_s.h \
120 $(INCL_D)\cast_lcl.h $(INCL_D)\bn_lcl.h $(INCL_D)\bn_prime.h \
121 $(INCL_D)\obj_dat.h $(INCL_D)\conf_lcl.h $(INCL_D)\ssl_locl.h \
122 $(INCL_D)\rsaref.h $(INCL_D)\apps.h $(INCL_D)\progs.h \
123 $(INCL_D)\s_apps.h $(INCL_D)\testdsa.h $(INCL_D)\testrsa.h
124
125EXHEADER=$(INC_D)\e_os.h \
126 $(INC_D)\crypto.h $(INC_D)\cryptall.h $(INC_D)\md2.h \
127 $(INC_D)\md5.h $(INC_D)\sha.h $(INC_D)\mdc2.h \
128 $(INC_D)\hmac.h $(INC_D)\ripemd.h $(INC_D)\des.h \
129 $(INC_D)\rc2.h $(INC_D)\rc4.h $(INC_D)\rc5.h \
130 $(INC_D)\idea.h $(INC_D)\blowfish.h $(INC_D)\cast.h \
131 $(INC_D)\bn.h $(INC_D)\rsa.h $(INC_D)\dsa.h \
132 $(INC_D)\dh.h $(INC_D)\buffer.h $(INC_D)\bio.h \
133 $(INC_D)\bss_file.c $(INC_D)\stack.h $(INC_D)\lhash.h \
134 $(INC_D)\rand.h $(INC_D)\err.h $(INC_D)\objects.h \
135 $(INC_D)\evp.h $(INC_D)\pem.h $(INC_D)\asn1.h \
136 $(INC_D)\asn1_mac.h $(INC_D)\x509.h $(INC_D)\x509_vfy.h \
137 $(INC_D)\conf.h $(INC_D)\txt_db.h $(INC_D)\pkcs7.h \
138 $(INC_D)\ssl.h $(INC_D)\ssl2.h $(INC_D)\ssl3.h \
139 $(INC_D)\ssl23.h $(INC_D)\tls1.h
140
141T_OBJ=$(OBJ_D)\md2test.obj \
142 $(OBJ_D)\md5test.obj $(OBJ_D)\shatest.obj $(OBJ_D)\sha1test.obj \
143 $(OBJ_D)\mdc2test.obj $(OBJ_D)\hmactest.obj $(OBJ_D)\rmdtest.obj \
144 $(OBJ_D)\destest.obj $(OBJ_D)\rc2test.obj $(OBJ_D)\rc4test.obj \
145 $(OBJ_D)\rc5test.obj $(OBJ_D)\ideatest.obj $(OBJ_D)\bftest.obj \
146 $(OBJ_D)\casttest.obj $(OBJ_D)\bntest.obj $(OBJ_D)\exptest.obj \
147 $(OBJ_D)\dsatest.obj $(OBJ_D)\dhtest.obj $(OBJ_D)\randtest.obj \
148 $(OBJ_D)\ssltest.obj
149
150E_OBJ=$(OBJ_D)\verify.obj \
151 $(OBJ_D)\asn1pars.obj $(OBJ_D)\req.obj $(OBJ_D)\dgst.obj \
152 $(OBJ_D)\dh.obj $(OBJ_D)\enc.obj $(OBJ_D)\gendh.obj \
153 $(OBJ_D)\errstr.obj $(OBJ_D)\ca.obj $(OBJ_D)\pkcs7.obj \
154 $(OBJ_D)\crl2p7.obj $(OBJ_D)\crl.obj $(OBJ_D)\rsa.obj \
155 $(OBJ_D)\dsa.obj $(OBJ_D)\dsaparam.obj $(OBJ_D)\x509.obj \
156 $(OBJ_D)\genrsa.obj $(OBJ_D)\s_server.obj $(OBJ_D)\s_client.obj \
157 $(OBJ_D)\speed.obj $(OBJ_D)\s_time.obj $(OBJ_D)\apps.obj \
158 $(OBJ_D)\s_cb.obj $(OBJ_D)\s_socket.obj $(OBJ_D)\version.obj \
159 $(OBJ_D)\sess_id.obj $(OBJ_D)\ciphers.obj $(OBJ_D)\ssleay.obj
160
161CRYPTOOBJ=$(OBJ_D)\cryptlib.obj \
162 $(OBJ_D)\mem.obj $(OBJ_D)\cversion.obj $(OBJ_D)\ex_data.obj \
163 $(OBJ_D)\cpt_err.obj $(OBJ_D)\md2_dgst.obj $(OBJ_D)\md2_one.obj \
164 $(OBJ_D)\md5_dgst.obj $(MD5_ASM_OBJ) $(OBJ_D)\md5_one.obj \
165 $(OBJ_D)\sha_dgst.obj $(OBJ_D)\sha1dgst.obj $(SHA1_ASM_OBJ) \
166 $(OBJ_D)\sha_one.obj $(OBJ_D)\sha1_one.obj $(OBJ_D)\mdc2dgst.obj \
167 $(OBJ_D)\mdc2_one.obj $(OBJ_D)\hmac.obj $(OBJ_D)\rmd_dgst.obj \
168 $(RMD160_ASM_OBJ) $(OBJ_D)\rmd_one.obj $(OBJ_D)\set_key.obj \
169 $(OBJ_D)\ecb_enc.obj $(OBJ_D)\cbc_enc.obj $(OBJ_D)\ecb3_enc.obj \
170 $(OBJ_D)\cfb64enc.obj $(OBJ_D)\cfb64ede.obj $(OBJ_D)\cfb_enc.obj \
171 $(OBJ_D)\ofb64ede.obj $(OBJ_D)\enc_read.obj $(OBJ_D)\enc_writ.obj \
172 $(OBJ_D)\ofb64enc.obj $(OBJ_D)\ofb_enc.obj $(OBJ_D)\str2key.obj \
173 $(OBJ_D)\pcbc_enc.obj $(OBJ_D)\qud_cksm.obj $(OBJ_D)\rand_key.obj \
174 $(DES_ENC_OBJ) $(OBJ_D)\read2pwd.obj $(OBJ_D)\fcrypt.obj \
175 $(OBJ_D)\xcbc_enc.obj $(OBJ_D)\read_pwd.obj $(OBJ_D)\rpc_enc.obj \
176 $(OBJ_D)\cbc_cksm.obj $(OBJ_D)\supp.obj $(OBJ_D)\rc2_ecb.obj \
177 $(OBJ_D)\rc2_skey.obj $(OBJ_D)\rc2_cbc.obj $(OBJ_D)\rc2cfb64.obj \
178 $(OBJ_D)\rc2ofb64.obj $(OBJ_D)\rc4_skey.obj $(RC4_ENC_OBJ) \
179 $(OBJ_D)\rc5_skey.obj $(OBJ_D)\rc5_ecb.obj $(RC5_ENC_OBJ) \
180 $(OBJ_D)\rc5cfb64.obj $(OBJ_D)\rc5ofb64.obj $(OBJ_D)\i_cbc.obj \
181 $(OBJ_D)\i_cfb64.obj $(OBJ_D)\i_ofb64.obj $(OBJ_D)\i_ecb.obj \
182 $(OBJ_D)\i_skey.obj $(OBJ_D)\bf_skey.obj $(OBJ_D)\bf_ecb.obj \
183 $(BF_ENC_OBJ) $(OBJ_D)\bf_cfb64.obj $(OBJ_D)\bf_ofb64.obj \
184 $(OBJ_D)\c_skey.obj $(OBJ_D)\c_ecb.obj $(CAST_ENC_OBJ) \
185 $(OBJ_D)\c_cfb64.obj $(OBJ_D)\c_ofb64.obj $(OBJ_D)\bn_add.obj \
186 $(OBJ_D)\bn_div.obj $(OBJ_D)\bn_exp.obj $(OBJ_D)\bn_lib.obj \
187 $(OBJ_D)\bn_mod.obj $(OBJ_D)\bn_mul.obj $(OBJ_D)\bn_print.obj \
188 $(OBJ_D)\bn_rand.obj $(OBJ_D)\bn_shift.obj $(OBJ_D)\bn_sub.obj \
189 $(OBJ_D)\bn_word.obj $(OBJ_D)\bn_blind.obj $(OBJ_D)\bn_gcd.obj \
190 $(OBJ_D)\bn_prime.obj $(OBJ_D)\bn_err.obj $(OBJ_D)\bn_sqr.obj \
191 $(BN_MULW_OBJ) $(OBJ_D)\bn_recp.obj $(OBJ_D)\bn_mont.obj \
192 $(OBJ_D)\bn_mpi.obj $(OBJ_D)\rsa_eay.obj $(OBJ_D)\rsa_gen.obj \
193 $(OBJ_D)\rsa_lib.obj $(OBJ_D)\rsa_sign.obj $(OBJ_D)\rsa_saos.obj \
194 $(OBJ_D)\rsa_err.obj $(OBJ_D)\rsa_pk1.obj $(OBJ_D)\rsa_ssl.obj \
195 $(OBJ_D)\rsa_none.obj $(OBJ_D)\dsa_gen.obj $(OBJ_D)\dsa_key.obj \
196 $(OBJ_D)\dsa_lib.obj $(OBJ_D)\dsa_vrf.obj $(OBJ_D)\dsa_sign.obj \
197 $(OBJ_D)\dsa_err.obj $(OBJ_D)\dh_gen.obj $(OBJ_D)\dh_key.obj \
198 $(OBJ_D)\dh_lib.obj $(OBJ_D)\dh_check.obj $(OBJ_D)\dh_err.obj \
199 $(OBJ_D)\buffer.obj $(OBJ_D)\buf_err.obj $(OBJ_D)\bio_lib.obj \
200 $(OBJ_D)\bio_cb.obj $(OBJ_D)\bio_err.obj $(OBJ_D)\bss_mem.obj \
201 $(OBJ_D)\bss_null.obj $(OBJ_D)\bss_fd.obj $(OBJ_D)\bss_file.obj \
202 $(OBJ_D)\bss_sock.obj $(OBJ_D)\bss_conn.obj $(OBJ_D)\bf_null.obj \
203 $(OBJ_D)\bf_buff.obj $(OBJ_D)\b_print.obj $(OBJ_D)\b_dump.obj \
204 $(OBJ_D)\b_sock.obj $(OBJ_D)\bss_acpt.obj $(OBJ_D)\bf_nbio.obj \
205 $(OBJ_D)\stack.obj $(OBJ_D)\lhash.obj $(OBJ_D)\lh_stats.obj \
206 $(OBJ_D)\md_rand.obj $(OBJ_D)\randfile.obj $(OBJ_D)\err.obj \
207 $(OBJ_D)\err_all.obj $(OBJ_D)\err_prn.obj $(OBJ_D)\obj_dat.obj \
208 $(OBJ_D)\obj_lib.obj $(OBJ_D)\obj_err.obj $(OBJ_D)\encode.obj \
209 $(OBJ_D)\digest.obj $(OBJ_D)\evp_enc.obj $(OBJ_D)\evp_key.obj \
210 $(OBJ_D)\e_ecb_d.obj $(OBJ_D)\e_cbc_d.obj $(OBJ_D)\e_cfb_d.obj \
211 $(OBJ_D)\e_ofb_d.obj $(OBJ_D)\e_ecb_i.obj $(OBJ_D)\e_cbc_i.obj \
212 $(OBJ_D)\e_cfb_i.obj $(OBJ_D)\e_ofb_i.obj $(OBJ_D)\e_ecb_3d.obj \
213 $(OBJ_D)\e_cbc_3d.obj $(OBJ_D)\e_rc4.obj $(OBJ_D)\names.obj \
214 $(OBJ_D)\e_cfb_3d.obj $(OBJ_D)\e_ofb_3d.obj $(OBJ_D)\e_xcbc_d.obj \
215 $(OBJ_D)\e_ecb_r2.obj $(OBJ_D)\e_cbc_r2.obj $(OBJ_D)\e_cfb_r2.obj \
216 $(OBJ_D)\e_ofb_r2.obj $(OBJ_D)\e_ecb_bf.obj $(OBJ_D)\e_cbc_bf.obj \
217 $(OBJ_D)\e_cfb_bf.obj $(OBJ_D)\e_ofb_bf.obj $(OBJ_D)\e_ecb_c.obj \
218 $(OBJ_D)\e_cbc_c.obj $(OBJ_D)\e_cfb_c.obj $(OBJ_D)\e_ofb_c.obj \
219 $(OBJ_D)\e_ecb_r5.obj $(OBJ_D)\e_cbc_r5.obj $(OBJ_D)\e_cfb_r5.obj \
220 $(OBJ_D)\e_ofb_r5.obj $(OBJ_D)\m_null.obj $(OBJ_D)\m_md2.obj \
221 $(OBJ_D)\m_md5.obj $(OBJ_D)\m_sha.obj $(OBJ_D)\m_sha1.obj \
222 $(OBJ_D)\m_dss.obj $(OBJ_D)\m_dss1.obj $(OBJ_D)\m_mdc2.obj \
223 $(OBJ_D)\m_ripemd.obj $(OBJ_D)\p_open.obj $(OBJ_D)\p_seal.obj \
224 $(OBJ_D)\p_sign.obj $(OBJ_D)\p_verify.obj $(OBJ_D)\p_lib.obj \
225 $(OBJ_D)\p_enc.obj $(OBJ_D)\p_dec.obj $(OBJ_D)\bio_md.obj \
226 $(OBJ_D)\bio_b64.obj $(OBJ_D)\bio_enc.obj $(OBJ_D)\evp_err.obj \
227 $(OBJ_D)\e_null.obj $(OBJ_D)\c_all.obj $(OBJ_D)\evp_lib.obj \
228 $(OBJ_D)\pem_sign.obj $(OBJ_D)\pem_seal.obj $(OBJ_D)\pem_info.obj \
229 $(OBJ_D)\pem_lib.obj $(OBJ_D)\pem_all.obj $(OBJ_D)\pem_err.obj \
230 $(OBJ_D)\a_object.obj $(OBJ_D)\a_bitstr.obj $(OBJ_D)\a_utctm.obj \
231 $(OBJ_D)\a_int.obj $(OBJ_D)\a_octet.obj $(OBJ_D)\a_print.obj \
232 $(OBJ_D)\a_type.obj $(OBJ_D)\a_set.obj $(OBJ_D)\a_dup.obj \
233 $(OBJ_D)\a_d2i_fp.obj $(OBJ_D)\a_i2d_fp.obj $(OBJ_D)\a_sign.obj \
234 $(OBJ_D)\a_digest.obj $(OBJ_D)\a_verify.obj $(OBJ_D)\x_algor.obj \
235 $(OBJ_D)\x_val.obj $(OBJ_D)\x_pubkey.obj $(OBJ_D)\x_sig.obj \
236 $(OBJ_D)\x_req.obj $(OBJ_D)\x_attrib.obj $(OBJ_D)\x_name.obj \
237 $(OBJ_D)\x_cinf.obj $(OBJ_D)\x_x509.obj $(OBJ_D)\x_crl.obj \
238 $(OBJ_D)\x_info.obj $(OBJ_D)\x_spki.obj $(OBJ_D)\d2i_r_pr.obj \
239 $(OBJ_D)\i2d_r_pr.obj $(OBJ_D)\d2i_r_pu.obj $(OBJ_D)\i2d_r_pu.obj \
240 $(OBJ_D)\d2i_s_pr.obj $(OBJ_D)\i2d_s_pr.obj $(OBJ_D)\d2i_s_pu.obj \
241 $(OBJ_D)\i2d_s_pu.obj $(OBJ_D)\d2i_pu.obj $(OBJ_D)\d2i_pr.obj \
242 $(OBJ_D)\i2d_pu.obj $(OBJ_D)\i2d_pr.obj $(OBJ_D)\t_req.obj \
243 $(OBJ_D)\t_x509.obj $(OBJ_D)\t_pkey.obj $(OBJ_D)\p7_i_s.obj \
244 $(OBJ_D)\p7_signi.obj $(OBJ_D)\p7_signd.obj $(OBJ_D)\p7_recip.obj \
245 $(OBJ_D)\p7_enc_c.obj $(OBJ_D)\p7_evp.obj $(OBJ_D)\p7_dgst.obj \
246 $(OBJ_D)\p7_s_e.obj $(OBJ_D)\p7_enc.obj $(OBJ_D)\p7_lib.obj \
247 $(OBJ_D)\f_int.obj $(OBJ_D)\f_string.obj $(OBJ_D)\i2d_dhp.obj \
248 $(OBJ_D)\i2d_dsap.obj $(OBJ_D)\d2i_dhp.obj $(OBJ_D)\d2i_dsap.obj \
249 $(OBJ_D)\n_pkey.obj $(OBJ_D)\a_hdr.obj $(OBJ_D)\x_pkey.obj \
250 $(OBJ_D)\a_bool.obj $(OBJ_D)\x_exten.obj $(OBJ_D)\asn1_par.obj \
251 $(OBJ_D)\asn1_lib.obj $(OBJ_D)\asn1_err.obj $(OBJ_D)\a_meth.obj \
252 $(OBJ_D)\a_bytes.obj $(OBJ_D)\evp_asn1.obj $(OBJ_D)\x509_def.obj \
253 $(OBJ_D)\x509_d2.obj $(OBJ_D)\x509_r2x.obj $(OBJ_D)\x509_cmp.obj \
254 $(OBJ_D)\x509_obj.obj $(OBJ_D)\x509_req.obj $(OBJ_D)\x509_vfy.obj \
255 $(OBJ_D)\x509_set.obj $(OBJ_D)\x509rset.obj $(OBJ_D)\x509_err.obj \
256 $(OBJ_D)\x509name.obj $(OBJ_D)\x509_v3.obj $(OBJ_D)\x509_ext.obj \
257 $(OBJ_D)\x509pack.obj $(OBJ_D)\x509type.obj $(OBJ_D)\x509_lu.obj \
258 $(OBJ_D)\x_all.obj $(OBJ_D)\x509_txt.obj $(OBJ_D)\by_file.obj \
259 $(OBJ_D)\by_dir.obj $(OBJ_D)\v3_net.obj $(OBJ_D)\v3_x509.obj \
260 $(OBJ_D)\conf.obj $(OBJ_D)\conf_err.obj $(OBJ_D)\txt_db.obj \
261 $(OBJ_D)\pk7_lib.obj $(OBJ_D)\pkcs7err.obj $(OBJ_D)\pk7_doit.obj
262
263SSLOBJ=$(OBJ_D)\s2_meth.obj \
264 $(OBJ_D)\s2_srvr.obj $(OBJ_D)\s2_clnt.obj $(OBJ_D)\s2_lib.obj \
265 $(OBJ_D)\s2_enc.obj $(OBJ_D)\s2_pkt.obj $(OBJ_D)\s3_meth.obj \
266 $(OBJ_D)\s3_srvr.obj $(OBJ_D)\s3_clnt.obj $(OBJ_D)\s3_lib.obj \
267 $(OBJ_D)\s3_enc.obj $(OBJ_D)\s3_pkt.obj $(OBJ_D)\s3_both.obj \
268 $(OBJ_D)\s23_meth.obj $(OBJ_D)\s23_srvr.obj $(OBJ_D)\s23_clnt.obj \
269 $(OBJ_D)\s23_lib.obj $(OBJ_D)\s23_pkt.obj $(OBJ_D)\t1_meth.obj \
270 $(OBJ_D)\t1_srvr.obj $(OBJ_D)\t1_clnt.obj $(OBJ_D)\t1_lib.obj \
271 $(OBJ_D)\t1_enc.obj $(OBJ_D)\ssl_lib.obj $(OBJ_D)\ssl_err2.obj \
272 $(OBJ_D)\ssl_cert.obj $(OBJ_D)\ssl_sess.obj $(OBJ_D)\ssl_ciph.obj \
273 $(OBJ_D)\ssl_stat.obj $(OBJ_D)\ssl_rsa.obj $(OBJ_D)\ssl_asn1.obj \
274 $(OBJ_D)\ssl_txt.obj $(OBJ_D)\ssl_algs.obj $(OBJ_D)\bio_ssl.obj \
275 $(OBJ_D)\ssl_err.obj
276
277RSAGLUEOBJ=$(OBJ_D)\rsaref.obj \
278 $(OBJ_D)\rsar_err.obj
279
280T_EXE=$(TEST_D)\md2test.exe \
281 $(TEST_D)\md5test.exe $(TEST_D)\shatest.exe $(TEST_D)\sha1test.exe \
282 $(TEST_D)\mdc2test.exe $(TEST_D)\hmactest.exe $(TEST_D)\rmdtest.exe \
283 $(TEST_D)\destest.exe $(TEST_D)\rc2test.exe $(TEST_D)\rc4test.exe \
284 $(TEST_D)\rc5test.exe $(TEST_D)\ideatest.exe $(TEST_D)\bftest.exe \
285 $(TEST_D)\casttest.exe $(TEST_D)\bntest.exe $(TEST_D)\exptest.exe \
286 $(TEST_D)\dsatest.exe $(TEST_D)\dhtest.exe $(TEST_D)\randtest.exe \
287 $(TEST_D)\ssltest.exe
288
289###################################################################
290all: banner $(TMP_D) $(BIN_D) $(TEST_D) $(LIB_D) $(INC_D) headers lib exe
291
292banner:
293
294
295$(TMP_D):
296 $(MKDIR) $(TMP_D)
297
298$(BIN_D):
299 $(MKDIR) $(BIN_D)
300
301$(TEST_D):
302 $(MKDIR) $(TEST_D)
303
304$(LIB_D):
305 $(MKDIR) $(LIB_D)
306
307$(INC_D):
308 $(MKDIR) $(INC_D)
309
310headers: $(HEADER) $(EXHEADER)
311
312lib: $(LIBS_DEP)
313
314exe: $(T_EXE) $(BIN_D)\$(E_EXE).exe
315
316install:
317 $(MKDIR) $(INSTALLTOP)
318 $(MKDIR) $(INSTALLTOP)\bin
319 $(MKDIR) $(INSTALLTOP)\include
320 $(MKDIR) $(INSTALLTOP)\lib
321 $(CP) $(INC_D)\*.[ch] $(INSTALLTOP)\include
322 $(CP) $(BIN_D)\$(E_EXE).exe $(INSTALLTOP)\bin
323 $(CP) $(O_SSL) $(INSTALLTOP)\lib
324 $(CP) $(O_CRYPTO) $(INSTALLTOP)\lib
325
326clean:
327 $(RM) $(TMP_D)\*.*
328
329vclean:
330 $(RM) $(TMP_D)\*.*
331 $(RM) $(OUT_D)\*.*
332
333$(INCL_D)\cryptlib.h: $(SRC_D)\crypto\cryptlib.h
334 $(CP) $(SRC_D)\crypto\cryptlib.h $(INCL_D)\cryptlib.h
335
336$(INCL_D)\date.h: $(SRC_D)\crypto\date.h
337 $(CP) $(SRC_D)\crypto\date.h $(INCL_D)\date.h
338
339$(INCL_D)\md5_locl.h: $(SRC_D)\crypto\md5\md5_locl.h
340 $(CP) $(SRC_D)\crypto\md5\md5_locl.h $(INCL_D)\md5_locl.h
341
342$(INCL_D)\sha_locl.h: $(SRC_D)\crypto\sha\sha_locl.h
343 $(CP) $(SRC_D)\crypto\sha\sha_locl.h $(INCL_D)\sha_locl.h
344
345$(INCL_D)\rmd_locl.h: $(SRC_D)\crypto\ripemd\rmd_locl.h
346 $(CP) $(SRC_D)\crypto\ripemd\rmd_locl.h $(INCL_D)\rmd_locl.h
347
348$(INCL_D)\rmdconst.h: $(SRC_D)\crypto\ripemd\rmdconst.h
349 $(CP) $(SRC_D)\crypto\ripemd\rmdconst.h $(INCL_D)\rmdconst.h
350
351$(INCL_D)\des_locl.h: $(SRC_D)\crypto\des\des_locl.h
352 $(CP) $(SRC_D)\crypto\des\des_locl.h $(INCL_D)\des_locl.h
353
354$(INCL_D)\rpc_des.h: $(SRC_D)\crypto\des\rpc_des.h
355 $(CP) $(SRC_D)\crypto\des\rpc_des.h $(INCL_D)\rpc_des.h
356
357$(INCL_D)\podd.h: $(SRC_D)\crypto\des\podd.h
358 $(CP) $(SRC_D)\crypto\des\podd.h $(INCL_D)\podd.h
359
360$(INCL_D)\sk.h: $(SRC_D)\crypto\des\sk.h
361 $(CP) $(SRC_D)\crypto\des\sk.h $(INCL_D)\sk.h
362
363$(INCL_D)\spr.h: $(SRC_D)\crypto\des\spr.h
364 $(CP) $(SRC_D)\crypto\des\spr.h $(INCL_D)\spr.h
365
366$(INCL_D)\des_ver.h: $(SRC_D)\crypto\des\des_ver.h
367 $(CP) $(SRC_D)\crypto\des\des_ver.h $(INCL_D)\des_ver.h
368
369$(INCL_D)\rc2_locl.h: $(SRC_D)\crypto\rc2\rc2_locl.h
370 $(CP) $(SRC_D)\crypto\rc2\rc2_locl.h $(INCL_D)\rc2_locl.h
371
372$(INCL_D)\rc4_locl.h: $(SRC_D)\crypto\rc4\rc4_locl.h
373 $(CP) $(SRC_D)\crypto\rc4\rc4_locl.h $(INCL_D)\rc4_locl.h
374
375$(INCL_D)\rc5_locl.h: $(SRC_D)\crypto\rc5\rc5_locl.h
376 $(CP) $(SRC_D)\crypto\rc5\rc5_locl.h $(INCL_D)\rc5_locl.h
377
378$(INCL_D)\idea_lcl.h: $(SRC_D)\crypto\idea\idea_lcl.h
379 $(CP) $(SRC_D)\crypto\idea\idea_lcl.h $(INCL_D)\idea_lcl.h
380
381$(INCL_D)\bf_pi.h: $(SRC_D)\crypto\bf\bf_pi.h
382 $(CP) $(SRC_D)\crypto\bf\bf_pi.h $(INCL_D)\bf_pi.h
383
384$(INCL_D)\bf_locl.h: $(SRC_D)\crypto\bf\bf_locl.h
385 $(CP) $(SRC_D)\crypto\bf\bf_locl.h $(INCL_D)\bf_locl.h
386
387$(INCL_D)\cast_s.h: $(SRC_D)\crypto\cast\cast_s.h
388 $(CP) $(SRC_D)\crypto\cast\cast_s.h $(INCL_D)\cast_s.h
389
390$(INCL_D)\cast_lcl.h: $(SRC_D)\crypto\cast\cast_lcl.h
391 $(CP) $(SRC_D)\crypto\cast\cast_lcl.h $(INCL_D)\cast_lcl.h
392
393$(INCL_D)\bn_lcl.h: $(SRC_D)\crypto\bn\bn_lcl.h
394 $(CP) $(SRC_D)\crypto\bn\bn_lcl.h $(INCL_D)\bn_lcl.h
395
396$(INCL_D)\bn_prime.h: $(SRC_D)\crypto\bn\bn_prime.h
397 $(CP) $(SRC_D)\crypto\bn\bn_prime.h $(INCL_D)\bn_prime.h
398
399$(INCL_D)\obj_dat.h: $(SRC_D)\crypto\objects\obj_dat.h
400 $(CP) $(SRC_D)\crypto\objects\obj_dat.h $(INCL_D)\obj_dat.h
401
402$(INCL_D)\conf_lcl.h: $(SRC_D)\crypto\conf\conf_lcl.h
403 $(CP) $(SRC_D)\crypto\conf\conf_lcl.h $(INCL_D)\conf_lcl.h
404
405$(INCL_D)\ssl_locl.h: $(SRC_D)\ssl\ssl_locl.h
406 $(CP) $(SRC_D)\ssl\ssl_locl.h $(INCL_D)\ssl_locl.h
407
408$(INCL_D)\rsaref.h: $(SRC_D)\rsaref\rsaref.h
409 $(CP) $(SRC_D)\rsaref\rsaref.h $(INCL_D)\rsaref.h
410
411$(INCL_D)\apps.h: $(SRC_D)\apps\apps.h
412 $(CP) $(SRC_D)\apps\apps.h $(INCL_D)\apps.h
413
414$(INCL_D)\progs.h: $(SRC_D)\apps\progs.h
415 $(CP) $(SRC_D)\apps\progs.h $(INCL_D)\progs.h
416
417$(INCL_D)\s_apps.h: $(SRC_D)\apps\s_apps.h
418 $(CP) $(SRC_D)\apps\s_apps.h $(INCL_D)\s_apps.h
419
420$(INCL_D)\testdsa.h: $(SRC_D)\apps\testdsa.h
421 $(CP) $(SRC_D)\apps\testdsa.h $(INCL_D)\testdsa.h
422
423$(INCL_D)\testrsa.h: $(SRC_D)\apps\testrsa.h
424 $(CP) $(SRC_D)\apps\testrsa.h $(INCL_D)\testrsa.h
425
426$(INC_D)\e_os.h: $(SRC_D)\.\e_os.h
427 $(CP) $(SRC_D)\.\e_os.h $(INC_D)\e_os.h
428
429$(INC_D)\crypto.h: $(SRC_D)\crypto\crypto.h
430 $(CP) $(SRC_D)\crypto\crypto.h $(INC_D)\crypto.h
431
432$(INC_D)\cryptall.h: $(SRC_D)\crypto\cryptall.h
433 $(CP) $(SRC_D)\crypto\cryptall.h $(INC_D)\cryptall.h
434
435$(INC_D)\md2.h: $(SRC_D)\crypto\md2\md2.h
436 $(CP) $(SRC_D)\crypto\md2\md2.h $(INC_D)\md2.h
437
438$(INC_D)\md5.h: $(SRC_D)\crypto\md5\md5.h
439 $(CP) $(SRC_D)\crypto\md5\md5.h $(INC_D)\md5.h
440
441$(INC_D)\sha.h: $(SRC_D)\crypto\sha\sha.h
442 $(CP) $(SRC_D)\crypto\sha\sha.h $(INC_D)\sha.h
443
444$(INC_D)\mdc2.h: $(SRC_D)\crypto\mdc2\mdc2.h
445 $(CP) $(SRC_D)\crypto\mdc2\mdc2.h $(INC_D)\mdc2.h
446
447$(INC_D)\hmac.h: $(SRC_D)\crypto\hmac\hmac.h
448 $(CP) $(SRC_D)\crypto\hmac\hmac.h $(INC_D)\hmac.h
449
450$(INC_D)\ripemd.h: $(SRC_D)\crypto\ripemd\ripemd.h
451 $(CP) $(SRC_D)\crypto\ripemd\ripemd.h $(INC_D)\ripemd.h
452
453$(INC_D)\des.h: $(SRC_D)\crypto\des\des.h
454 $(CP) $(SRC_D)\crypto\des\des.h $(INC_D)\des.h
455
456$(INC_D)\rc2.h: $(SRC_D)\crypto\rc2\rc2.h
457 $(CP) $(SRC_D)\crypto\rc2\rc2.h $(INC_D)\rc2.h
458
459$(INC_D)\rc4.h: $(SRC_D)\crypto\rc4\rc4.h
460 $(CP) $(SRC_D)\crypto\rc4\rc4.h $(INC_D)\rc4.h
461
462$(INC_D)\rc5.h: $(SRC_D)\crypto\rc5\rc5.h
463 $(CP) $(SRC_D)\crypto\rc5\rc5.h $(INC_D)\rc5.h
464
465$(INC_D)\idea.h: $(SRC_D)\crypto\idea\idea.h
466 $(CP) $(SRC_D)\crypto\idea\idea.h $(INC_D)\idea.h
467
468$(INC_D)\blowfish.h: $(SRC_D)\crypto\bf\blowfish.h
469 $(CP) $(SRC_D)\crypto\bf\blowfish.h $(INC_D)\blowfish.h
470
471$(INC_D)\cast.h: $(SRC_D)\crypto\cast\cast.h
472 $(CP) $(SRC_D)\crypto\cast\cast.h $(INC_D)\cast.h
473
474$(INC_D)\bn.h: $(SRC_D)\crypto\bn\bn.h
475 $(CP) $(SRC_D)\crypto\bn\bn.h $(INC_D)\bn.h
476
477$(INC_D)\rsa.h: $(SRC_D)\crypto\rsa\rsa.h
478 $(CP) $(SRC_D)\crypto\rsa\rsa.h $(INC_D)\rsa.h
479
480$(INC_D)\dsa.h: $(SRC_D)\crypto\dsa\dsa.h
481 $(CP) $(SRC_D)\crypto\dsa\dsa.h $(INC_D)\dsa.h
482
483$(INC_D)\dh.h: $(SRC_D)\crypto\dh\dh.h
484 $(CP) $(SRC_D)\crypto\dh\dh.h $(INC_D)\dh.h
485
486$(INC_D)\buffer.h: $(SRC_D)\crypto\buffer\buffer.h
487 $(CP) $(SRC_D)\crypto\buffer\buffer.h $(INC_D)\buffer.h
488
489$(INC_D)\bio.h: $(SRC_D)\crypto\bio\bio.h
490 $(CP) $(SRC_D)\crypto\bio\bio.h $(INC_D)\bio.h
491
492$(INC_D)\bss_file.c: $(SRC_D)\crypto\bio\bss_file.c
493 $(CP) $(SRC_D)\crypto\bio\bss_file.c $(INC_D)\bss_file.c
494
495$(INC_D)\stack.h: $(SRC_D)\crypto\stack\stack.h
496 $(CP) $(SRC_D)\crypto\stack\stack.h $(INC_D)\stack.h
497
498$(INC_D)\lhash.h: $(SRC_D)\crypto\lhash\lhash.h
499 $(CP) $(SRC_D)\crypto\lhash\lhash.h $(INC_D)\lhash.h
500
501$(INC_D)\rand.h: $(SRC_D)\crypto\rand\rand.h
502 $(CP) $(SRC_D)\crypto\rand\rand.h $(INC_D)\rand.h
503
504$(INC_D)\err.h: $(SRC_D)\crypto\err\err.h
505 $(CP) $(SRC_D)\crypto\err\err.h $(INC_D)\err.h
506
507$(INC_D)\objects.h: $(SRC_D)\crypto\objects\objects.h
508 $(CP) $(SRC_D)\crypto\objects\objects.h $(INC_D)\objects.h
509
510$(INC_D)\evp.h: $(SRC_D)\crypto\evp\evp.h
511 $(CP) $(SRC_D)\crypto\evp\evp.h $(INC_D)\evp.h
512
513$(INC_D)\pem.h: $(SRC_D)\crypto\pem\pem.h
514 $(CP) $(SRC_D)\crypto\pem\pem.h $(INC_D)\pem.h
515
516$(INC_D)\asn1.h: $(SRC_D)\crypto\asn1\asn1.h
517 $(CP) $(SRC_D)\crypto\asn1\asn1.h $(INC_D)\asn1.h
518
519$(INC_D)\asn1_mac.h: $(SRC_D)\crypto\asn1\asn1_mac.h
520 $(CP) $(SRC_D)\crypto\asn1\asn1_mac.h $(INC_D)\asn1_mac.h
521
522$(INC_D)\x509.h: $(SRC_D)\crypto\x509\x509.h
523 $(CP) $(SRC_D)\crypto\x509\x509.h $(INC_D)\x509.h
524
525$(INC_D)\x509_vfy.h: $(SRC_D)\crypto\x509\x509_vfy.h
526 $(CP) $(SRC_D)\crypto\x509\x509_vfy.h $(INC_D)\x509_vfy.h
527
528$(INC_D)\conf.h: $(SRC_D)\crypto\conf\conf.h
529 $(CP) $(SRC_D)\crypto\conf\conf.h $(INC_D)\conf.h
530
531$(INC_D)\txt_db.h: $(SRC_D)\crypto\txt_db\txt_db.h
532 $(CP) $(SRC_D)\crypto\txt_db\txt_db.h $(INC_D)\txt_db.h
533
534$(INC_D)\pkcs7.h: $(SRC_D)\crypto\pkcs7\pkcs7.h
535 $(CP) $(SRC_D)\crypto\pkcs7\pkcs7.h $(INC_D)\pkcs7.h
536
537$(INC_D)\ssl.h: $(SRC_D)\ssl\ssl.h
538 $(CP) $(SRC_D)\ssl\ssl.h $(INC_D)\ssl.h
539
540$(INC_D)\ssl2.h: $(SRC_D)\ssl\ssl2.h
541 $(CP) $(SRC_D)\ssl\ssl2.h $(INC_D)\ssl2.h
542
543$(INC_D)\ssl3.h: $(SRC_D)\ssl\ssl3.h
544 $(CP) $(SRC_D)\ssl\ssl3.h $(INC_D)\ssl3.h
545
546$(INC_D)\ssl23.h: $(SRC_D)\ssl\ssl23.h
547 $(CP) $(SRC_D)\ssl\ssl23.h $(INC_D)\ssl23.h
548
549$(INC_D)\tls1.h: $(SRC_D)\ssl\tls1.h
550 $(CP) $(SRC_D)\ssl\tls1.h $(INC_D)\tls1.h
551
552$(OBJ_D)\md2test.obj: $(SRC_D)\crypto\md2\md2test.c
553 $(CC) /Fo$(OBJ_D)\md2test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\md2\md2test.c
554
555$(OBJ_D)\md5test.obj: $(SRC_D)\crypto\md5\md5test.c
556 $(CC) /Fo$(OBJ_D)\md5test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\md5\md5test.c
557
558$(OBJ_D)\shatest.obj: $(SRC_D)\crypto\sha\shatest.c
559 $(CC) /Fo$(OBJ_D)\shatest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\sha\shatest.c
560
561$(OBJ_D)\sha1test.obj: $(SRC_D)\crypto\sha\sha1test.c
562 $(CC) /Fo$(OBJ_D)\sha1test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\sha\sha1test.c
563
564$(OBJ_D)\mdc2test.obj: $(SRC_D)\crypto\mdc2\mdc2test.c
565 $(CC) /Fo$(OBJ_D)\mdc2test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\mdc2\mdc2test.c
566
567$(OBJ_D)\hmactest.obj: $(SRC_D)\crypto\hmac\hmactest.c
568 $(CC) /Fo$(OBJ_D)\hmactest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\hmac\hmactest.c
569
570$(OBJ_D)\rmdtest.obj: $(SRC_D)\crypto\ripemd\rmdtest.c
571 $(CC) /Fo$(OBJ_D)\rmdtest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\ripemd\rmdtest.c
572
573$(OBJ_D)\destest.obj: $(SRC_D)\crypto\des\destest.c
574 $(CC) /Fo$(OBJ_D)\destest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\des\destest.c
575
576$(OBJ_D)\rc2test.obj: $(SRC_D)\crypto\rc2\rc2test.c
577 $(CC) /Fo$(OBJ_D)\rc2test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2test.c
578
579$(OBJ_D)\rc4test.obj: $(SRC_D)\crypto\rc4\rc4test.c
580 $(CC) /Fo$(OBJ_D)\rc4test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\rc4\rc4test.c
581
582$(OBJ_D)\rc5test.obj: $(SRC_D)\crypto\rc5\rc5test.c
583 $(CC) /Fo$(OBJ_D)\rc5test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5test.c
584
585$(OBJ_D)\ideatest.obj: $(SRC_D)\crypto\idea\ideatest.c
586 $(CC) /Fo$(OBJ_D)\ideatest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\idea\ideatest.c
587
588$(OBJ_D)\bftest.obj: $(SRC_D)\crypto\bf\bftest.c
589 $(CC) /Fo$(OBJ_D)\bftest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\bf\bftest.c
590
591$(OBJ_D)\casttest.obj: $(SRC_D)\crypto\cast\casttest.c
592 $(CC) /Fo$(OBJ_D)\casttest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\cast\casttest.c
593
594$(OBJ_D)\bntest.obj: $(SRC_D)\crypto\bn\bntest.c
595 $(CC) /Fo$(OBJ_D)\bntest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\bn\bntest.c
596
597$(OBJ_D)\exptest.obj: $(SRC_D)\crypto\bn\exptest.c
598 $(CC) /Fo$(OBJ_D)\exptest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\bn\exptest.c
599
600$(OBJ_D)\dsatest.obj: $(SRC_D)\crypto\dsa\dsatest.c
601 $(CC) /Fo$(OBJ_D)\dsatest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\dsa\dsatest.c
602
603$(OBJ_D)\dhtest.obj: $(SRC_D)\crypto\dh\dhtest.c
604 $(CC) /Fo$(OBJ_D)\dhtest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\dh\dhtest.c
605
606$(OBJ_D)\randtest.obj: $(SRC_D)\crypto\rand\randtest.c
607 $(CC) /Fo$(OBJ_D)\randtest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\rand\randtest.c
608
609$(OBJ_D)\ssltest.obj: $(SRC_D)\ssl\ssltest.c
610 $(CC) /Fo$(OBJ_D)\ssltest.obj $(APP_CFLAGS) -c $(SRC_D)\ssl\ssltest.c
611
612$(OBJ_D)\verify.obj: $(SRC_D)\apps\verify.c
613 $(CC) /Fo$(OBJ_D)\verify.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\verify.c
614
615$(OBJ_D)\asn1pars.obj: $(SRC_D)\apps\asn1pars.c
616 $(CC) /Fo$(OBJ_D)\asn1pars.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\asn1pars.c
617
618$(OBJ_D)\req.obj: $(SRC_D)\apps\req.c
619 $(CC) /Fo$(OBJ_D)\req.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\req.c
620
621$(OBJ_D)\dgst.obj: $(SRC_D)\apps\dgst.c
622 $(CC) /Fo$(OBJ_D)\dgst.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\dgst.c
623
624$(OBJ_D)\dh.obj: $(SRC_D)\apps\dh.c
625 $(CC) /Fo$(OBJ_D)\dh.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\dh.c
626
627$(OBJ_D)\enc.obj: $(SRC_D)\apps\enc.c
628 $(CC) /Fo$(OBJ_D)\enc.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\enc.c
629
630$(OBJ_D)\gendh.obj: $(SRC_D)\apps\gendh.c
631 $(CC) /Fo$(OBJ_D)\gendh.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\gendh.c
632
633$(OBJ_D)\errstr.obj: $(SRC_D)\apps\errstr.c
634 $(CC) /Fo$(OBJ_D)\errstr.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\errstr.c
635
636$(OBJ_D)\ca.obj: $(SRC_D)\apps\ca.c
637 $(CC) /Fo$(OBJ_D)\ca.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\ca.c
638
639$(OBJ_D)\pkcs7.obj: $(SRC_D)\apps\pkcs7.c
640 $(CC) /Fo$(OBJ_D)\pkcs7.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\pkcs7.c
641
642$(OBJ_D)\crl2p7.obj: $(SRC_D)\apps\crl2p7.c
643 $(CC) /Fo$(OBJ_D)\crl2p7.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\crl2p7.c
644
645$(OBJ_D)\crl.obj: $(SRC_D)\apps\crl.c
646 $(CC) /Fo$(OBJ_D)\crl.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\crl.c
647
648$(OBJ_D)\rsa.obj: $(SRC_D)\apps\rsa.c
649 $(CC) /Fo$(OBJ_D)\rsa.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\rsa.c
650
651$(OBJ_D)\dsa.obj: $(SRC_D)\apps\dsa.c
652 $(CC) /Fo$(OBJ_D)\dsa.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\dsa.c
653
654$(OBJ_D)\dsaparam.obj: $(SRC_D)\apps\dsaparam.c
655 $(CC) /Fo$(OBJ_D)\dsaparam.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\dsaparam.c
656
657$(OBJ_D)\x509.obj: $(SRC_D)\apps\x509.c
658 $(CC) /Fo$(OBJ_D)\x509.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\x509.c
659
660$(OBJ_D)\genrsa.obj: $(SRC_D)\apps\genrsa.c
661 $(CC) /Fo$(OBJ_D)\genrsa.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\genrsa.c
662
663$(OBJ_D)\s_server.obj: $(SRC_D)\apps\s_server.c
664 $(CC) /Fo$(OBJ_D)\s_server.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\s_server.c
665
666$(OBJ_D)\s_client.obj: $(SRC_D)\apps\s_client.c
667 $(CC) /Fo$(OBJ_D)\s_client.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\s_client.c
668
669$(OBJ_D)\speed.obj: $(SRC_D)\apps\speed.c
670 $(CC) /Fo$(OBJ_D)\speed.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\speed.c
671
672$(OBJ_D)\s_time.obj: $(SRC_D)\apps\s_time.c
673 $(CC) /Fo$(OBJ_D)\s_time.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\s_time.c
674
675$(OBJ_D)\apps.obj: $(SRC_D)\apps\apps.c
676 $(CC) /Fo$(OBJ_D)\apps.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\apps.c
677
678$(OBJ_D)\s_cb.obj: $(SRC_D)\apps\s_cb.c
679 $(CC) /Fo$(OBJ_D)\s_cb.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\s_cb.c
680
681$(OBJ_D)\s_socket.obj: $(SRC_D)\apps\s_socket.c
682 $(CC) /Fo$(OBJ_D)\s_socket.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\s_socket.c
683
684$(OBJ_D)\version.obj: $(SRC_D)\apps\version.c
685 $(CC) /Fo$(OBJ_D)\version.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\version.c
686
687$(OBJ_D)\sess_id.obj: $(SRC_D)\apps\sess_id.c
688 $(CC) /Fo$(OBJ_D)\sess_id.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\sess_id.c
689
690$(OBJ_D)\ciphers.obj: $(SRC_D)\apps\ciphers.c
691 $(CC) /Fo$(OBJ_D)\ciphers.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\ciphers.c
692
693$(OBJ_D)\ssleay.obj: $(SRC_D)\apps\ssleay.c
694 $(CC) /Fo$(OBJ_D)\ssleay.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\ssleay.c
695
696crypto\bn\asm\bn-win32.obj: crypto\bn\asm\bn-win32.asm
697 $(ASM) /Focrypto\bn\asm\bn-win32.obj $(SRC_D)\crypto\bn\asm\bn-win32.asm
698
699crypto\des\asm\d-win32.obj: crypto\des\asm\d-win32.asm
700 $(ASM) /Focrypto\des\asm\d-win32.obj $(SRC_D)\crypto\des\asm\d-win32.asm
701
702crypto\des\asm\y-win32.obj: crypto\des\asm\y-win32.asm
703 $(ASM) /Focrypto\des\asm\y-win32.obj $(SRC_D)\crypto\des\asm\y-win32.asm
704
705crypto\bf\asm\b-win32.obj: crypto\bf\asm\b-win32.asm
706 $(ASM) /Focrypto\bf\asm\b-win32.obj $(SRC_D)\crypto\bf\asm\b-win32.asm
707
708crypto\cast\asm\c-win32.obj: crypto\cast\asm\c-win32.asm
709 $(ASM) /Focrypto\cast\asm\c-win32.obj $(SRC_D)\crypto\cast\asm\c-win32.asm
710
711crypto\rc4\asm\r4-win32.obj: crypto\rc4\asm\r4-win32.asm
712 $(ASM) /Focrypto\rc4\asm\r4-win32.obj $(SRC_D)\crypto\rc4\asm\r4-win32.asm
713
714crypto\rc5\asm\r5-win32.obj: crypto\rc5\asm\r5-win32.asm
715 $(ASM) /Focrypto\rc5\asm\r5-win32.obj $(SRC_D)\crypto\rc5\asm\r5-win32.asm
716
717crypto\md5\asm\m5-win32.obj: crypto\md5\asm\m5-win32.asm
718 $(ASM) /Focrypto\md5\asm\m5-win32.obj $(SRC_D)\crypto\md5\asm\m5-win32.asm
719
720crypto\sha\asm\s1-win32.obj: crypto\sha\asm\s1-win32.asm
721 $(ASM) /Focrypto\sha\asm\s1-win32.obj $(SRC_D)\crypto\sha\asm\s1-win32.asm
722
723crypto\ripemd\asm\rm-win32.obj: crypto\ripemd\asm\rm-win32.asm
724 $(ASM) /Focrypto\ripemd\asm\rm-win32.obj $(SRC_D)\crypto\ripemd\asm\rm-win32.asm
725
726$(OBJ_D)\cryptlib.obj: $(SRC_D)\crypto\cryptlib.c
727 $(CC) /Fo$(OBJ_D)\cryptlib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cryptlib.c
728
729$(OBJ_D)\mem.obj: $(SRC_D)\crypto\mem.c
730 $(CC) /Fo$(OBJ_D)\mem.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\mem.c
731
732$(OBJ_D)\cversion.obj: $(SRC_D)\crypto\cversion.c
733 $(CC) /Fo$(OBJ_D)\cversion.obj $(SHLIB_CFLAGS) -DCFLAGS="\"$(CC) $(CFLAG)\"" -c $(SRC_D)\crypto\cversion.c
734
735$(OBJ_D)\ex_data.obj: $(SRC_D)\crypto\ex_data.c
736 $(CC) /Fo$(OBJ_D)\ex_data.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\ex_data.c
737
738$(OBJ_D)\cpt_err.obj: $(SRC_D)\crypto\cpt_err.c
739 $(CC) /Fo$(OBJ_D)\cpt_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cpt_err.c
740
741$(OBJ_D)\md2_dgst.obj: $(SRC_D)\crypto\md2\md2_dgst.c
742 $(CC) /Fo$(OBJ_D)\md2_dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\md2\md2_dgst.c
743
744$(OBJ_D)\md2_one.obj: $(SRC_D)\crypto\md2\md2_one.c
745 $(CC) /Fo$(OBJ_D)\md2_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\md2\md2_one.c
746
747$(OBJ_D)\md5_dgst.obj: $(SRC_D)\crypto\md5\md5_dgst.c
748 $(CC) /Fo$(OBJ_D)\md5_dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\md5\md5_dgst.c
749
750$(OBJ_D)\md5_one.obj: $(SRC_D)\crypto\md5\md5_one.c
751 $(CC) /Fo$(OBJ_D)\md5_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\md5\md5_one.c
752
753$(OBJ_D)\sha_dgst.obj: $(SRC_D)\crypto\sha\sha_dgst.c
754 $(CC) /Fo$(OBJ_D)\sha_dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\sha\sha_dgst.c
755
756$(OBJ_D)\sha1dgst.obj: $(SRC_D)\crypto\sha\sha1dgst.c
757 $(CC) /Fo$(OBJ_D)\sha1dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\sha\sha1dgst.c
758
759$(OBJ_D)\sha_one.obj: $(SRC_D)\crypto\sha\sha_one.c
760 $(CC) /Fo$(OBJ_D)\sha_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\sha\sha_one.c
761
762$(OBJ_D)\sha1_one.obj: $(SRC_D)\crypto\sha\sha1_one.c
763 $(CC) /Fo$(OBJ_D)\sha1_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\sha\sha1_one.c
764
765$(OBJ_D)\mdc2dgst.obj: $(SRC_D)\crypto\mdc2\mdc2dgst.c
766 $(CC) /Fo$(OBJ_D)\mdc2dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\mdc2\mdc2dgst.c
767
768$(OBJ_D)\mdc2_one.obj: $(SRC_D)\crypto\mdc2\mdc2_one.c
769 $(CC) /Fo$(OBJ_D)\mdc2_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\mdc2\mdc2_one.c
770
771$(OBJ_D)\hmac.obj: $(SRC_D)\crypto\hmac\hmac.c
772 $(CC) /Fo$(OBJ_D)\hmac.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\hmac\hmac.c
773
774$(OBJ_D)\rmd_dgst.obj: $(SRC_D)\crypto\ripemd\rmd_dgst.c
775 $(CC) /Fo$(OBJ_D)\rmd_dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\ripemd\rmd_dgst.c
776
777$(OBJ_D)\rmd_one.obj: $(SRC_D)\crypto\ripemd\rmd_one.c
778 $(CC) /Fo$(OBJ_D)\rmd_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\ripemd\rmd_one.c
779
780$(OBJ_D)\set_key.obj: $(SRC_D)\crypto\des\set_key.c
781 $(CC) /Fo$(OBJ_D)\set_key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\set_key.c
782
783$(OBJ_D)\ecb_enc.obj: $(SRC_D)\crypto\des\ecb_enc.c
784 $(CC) /Fo$(OBJ_D)\ecb_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\ecb_enc.c
785
786$(OBJ_D)\cbc_enc.obj: $(SRC_D)\crypto\des\cbc_enc.c
787 $(CC) /Fo$(OBJ_D)\cbc_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\cbc_enc.c
788
789$(OBJ_D)\ecb3_enc.obj: $(SRC_D)\crypto\des\ecb3_enc.c
790 $(CC) /Fo$(OBJ_D)\ecb3_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\ecb3_enc.c
791
792$(OBJ_D)\cfb64enc.obj: $(SRC_D)\crypto\des\cfb64enc.c
793 $(CC) /Fo$(OBJ_D)\cfb64enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\cfb64enc.c
794
795$(OBJ_D)\cfb64ede.obj: $(SRC_D)\crypto\des\cfb64ede.c
796 $(CC) /Fo$(OBJ_D)\cfb64ede.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\cfb64ede.c
797
798$(OBJ_D)\cfb_enc.obj: $(SRC_D)\crypto\des\cfb_enc.c
799 $(CC) /Fo$(OBJ_D)\cfb_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\cfb_enc.c
800
801$(OBJ_D)\ofb64ede.obj: $(SRC_D)\crypto\des\ofb64ede.c
802 $(CC) /Fo$(OBJ_D)\ofb64ede.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\ofb64ede.c
803
804$(OBJ_D)\enc_read.obj: $(SRC_D)\crypto\des\enc_read.c
805 $(CC) /Fo$(OBJ_D)\enc_read.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\enc_read.c
806
807$(OBJ_D)\enc_writ.obj: $(SRC_D)\crypto\des\enc_writ.c
808 $(CC) /Fo$(OBJ_D)\enc_writ.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\enc_writ.c
809
810$(OBJ_D)\ofb64enc.obj: $(SRC_D)\crypto\des\ofb64enc.c
811 $(CC) /Fo$(OBJ_D)\ofb64enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\ofb64enc.c
812
813$(OBJ_D)\ofb_enc.obj: $(SRC_D)\crypto\des\ofb_enc.c
814 $(CC) /Fo$(OBJ_D)\ofb_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\ofb_enc.c
815
816$(OBJ_D)\str2key.obj: $(SRC_D)\crypto\des\str2key.c
817 $(CC) /Fo$(OBJ_D)\str2key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\str2key.c
818
819$(OBJ_D)\pcbc_enc.obj: $(SRC_D)\crypto\des\pcbc_enc.c
820 $(CC) /Fo$(OBJ_D)\pcbc_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\pcbc_enc.c
821
822$(OBJ_D)\qud_cksm.obj: $(SRC_D)\crypto\des\qud_cksm.c
823 $(CC) /Fo$(OBJ_D)\qud_cksm.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\qud_cksm.c
824
825$(OBJ_D)\rand_key.obj: $(SRC_D)\crypto\des\rand_key.c
826 $(CC) /Fo$(OBJ_D)\rand_key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\rand_key.c
827
828$(OBJ_D)\des_enc.obj: $(SRC_D)\crypto\des\des_enc.c
829 $(CC) /Fo$(OBJ_D)\des_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\des_enc.c
830
831$(OBJ_D)\fcrypt_b.obj: $(SRC_D)\crypto\des\fcrypt_b.c
832 $(CC) /Fo$(OBJ_D)\fcrypt_b.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\fcrypt_b.c
833
834$(OBJ_D)\read2pwd.obj: $(SRC_D)\crypto\des\read2pwd.c
835 $(CC) /Fo$(OBJ_D)\read2pwd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\read2pwd.c
836
837$(OBJ_D)\fcrypt.obj: $(SRC_D)\crypto\des\fcrypt.c
838 $(CC) /Fo$(OBJ_D)\fcrypt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\fcrypt.c
839
840$(OBJ_D)\xcbc_enc.obj: $(SRC_D)\crypto\des\xcbc_enc.c
841 $(CC) /Fo$(OBJ_D)\xcbc_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\xcbc_enc.c
842
843$(OBJ_D)\read_pwd.obj: $(SRC_D)\crypto\des\read_pwd.c
844 $(CC) /Fo$(OBJ_D)\read_pwd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\read_pwd.c
845
846$(OBJ_D)\rpc_enc.obj: $(SRC_D)\crypto\des\rpc_enc.c
847 $(CC) /Fo$(OBJ_D)\rpc_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\rpc_enc.c
848
849$(OBJ_D)\cbc_cksm.obj: $(SRC_D)\crypto\des\cbc_cksm.c
850 $(CC) /Fo$(OBJ_D)\cbc_cksm.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\cbc_cksm.c
851
852$(OBJ_D)\supp.obj: $(SRC_D)\crypto\des\supp.c
853 $(CC) /Fo$(OBJ_D)\supp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\supp.c
854
855$(OBJ_D)\rc2_ecb.obj: $(SRC_D)\crypto\rc2\rc2_ecb.c
856 $(CC) /Fo$(OBJ_D)\rc2_ecb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2_ecb.c
857
858$(OBJ_D)\rc2_skey.obj: $(SRC_D)\crypto\rc2\rc2_skey.c
859 $(CC) /Fo$(OBJ_D)\rc2_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2_skey.c
860
861$(OBJ_D)\rc2_cbc.obj: $(SRC_D)\crypto\rc2\rc2_cbc.c
862 $(CC) /Fo$(OBJ_D)\rc2_cbc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2_cbc.c
863
864$(OBJ_D)\rc2cfb64.obj: $(SRC_D)\crypto\rc2\rc2cfb64.c
865 $(CC) /Fo$(OBJ_D)\rc2cfb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2cfb64.c
866
867$(OBJ_D)\rc2ofb64.obj: $(SRC_D)\crypto\rc2\rc2ofb64.c
868 $(CC) /Fo$(OBJ_D)\rc2ofb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2ofb64.c
869
870$(OBJ_D)\rc4_skey.obj: $(SRC_D)\crypto\rc4\rc4_skey.c
871 $(CC) /Fo$(OBJ_D)\rc4_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc4\rc4_skey.c
872
873$(OBJ_D)\rc4_enc.obj: $(SRC_D)\crypto\rc4\rc4_enc.c
874 $(CC) /Fo$(OBJ_D)\rc4_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc4\rc4_enc.c
875
876$(OBJ_D)\rc5_skey.obj: $(SRC_D)\crypto\rc5\rc5_skey.c
877 $(CC) /Fo$(OBJ_D)\rc5_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5_skey.c
878
879$(OBJ_D)\rc5_ecb.obj: $(SRC_D)\crypto\rc5\rc5_ecb.c
880 $(CC) /Fo$(OBJ_D)\rc5_ecb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5_ecb.c
881
882$(OBJ_D)\rc5_enc.obj: $(SRC_D)\crypto\rc5\rc5_enc.c
883 $(CC) /Fo$(OBJ_D)\rc5_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5_enc.c
884
885$(OBJ_D)\rc5cfb64.obj: $(SRC_D)\crypto\rc5\rc5cfb64.c
886 $(CC) /Fo$(OBJ_D)\rc5cfb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5cfb64.c
887
888$(OBJ_D)\rc5ofb64.obj: $(SRC_D)\crypto\rc5\rc5ofb64.c
889 $(CC) /Fo$(OBJ_D)\rc5ofb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5ofb64.c
890
891$(OBJ_D)\i_cbc.obj: $(SRC_D)\crypto\idea\i_cbc.c
892 $(CC) /Fo$(OBJ_D)\i_cbc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\idea\i_cbc.c
893
894$(OBJ_D)\i_cfb64.obj: $(SRC_D)\crypto\idea\i_cfb64.c
895 $(CC) /Fo$(OBJ_D)\i_cfb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\idea\i_cfb64.c
896
897$(OBJ_D)\i_ofb64.obj: $(SRC_D)\crypto\idea\i_ofb64.c
898 $(CC) /Fo$(OBJ_D)\i_ofb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\idea\i_ofb64.c
899
900$(OBJ_D)\i_ecb.obj: $(SRC_D)\crypto\idea\i_ecb.c
901 $(CC) /Fo$(OBJ_D)\i_ecb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\idea\i_ecb.c
902
903$(OBJ_D)\i_skey.obj: $(SRC_D)\crypto\idea\i_skey.c
904 $(CC) /Fo$(OBJ_D)\i_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\idea\i_skey.c
905
906$(OBJ_D)\bf_skey.obj: $(SRC_D)\crypto\bf\bf_skey.c
907 $(CC) /Fo$(OBJ_D)\bf_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bf\bf_skey.c
908
909$(OBJ_D)\bf_ecb.obj: $(SRC_D)\crypto\bf\bf_ecb.c
910 $(CC) /Fo$(OBJ_D)\bf_ecb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bf\bf_ecb.c
911
912$(OBJ_D)\bf_enc.obj: $(SRC_D)\crypto\bf\bf_enc.c
913 $(CC) /Fo$(OBJ_D)\bf_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bf\bf_enc.c
914
915$(OBJ_D)\bf_cfb64.obj: $(SRC_D)\crypto\bf\bf_cfb64.c
916 $(CC) /Fo$(OBJ_D)\bf_cfb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bf\bf_cfb64.c
917
918$(OBJ_D)\bf_ofb64.obj: $(SRC_D)\crypto\bf\bf_ofb64.c
919 $(CC) /Fo$(OBJ_D)\bf_ofb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bf\bf_ofb64.c
920
921$(OBJ_D)\c_skey.obj: $(SRC_D)\crypto\cast\c_skey.c
922 $(CC) /Fo$(OBJ_D)\c_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cast\c_skey.c
923
924$(OBJ_D)\c_ecb.obj: $(SRC_D)\crypto\cast\c_ecb.c
925 $(CC) /Fo$(OBJ_D)\c_ecb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cast\c_ecb.c
926
927$(OBJ_D)\c_enc.obj: $(SRC_D)\crypto\cast\c_enc.c
928 $(CC) /Fo$(OBJ_D)\c_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cast\c_enc.c
929
930$(OBJ_D)\c_cfb64.obj: $(SRC_D)\crypto\cast\c_cfb64.c
931 $(CC) /Fo$(OBJ_D)\c_cfb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cast\c_cfb64.c
932
933$(OBJ_D)\c_ofb64.obj: $(SRC_D)\crypto\cast\c_ofb64.c
934 $(CC) /Fo$(OBJ_D)\c_ofb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cast\c_ofb64.c
935
936$(OBJ_D)\bn_add.obj: $(SRC_D)\crypto\bn\bn_add.c
937 $(CC) /Fo$(OBJ_D)\bn_add.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_add.c
938
939$(OBJ_D)\bn_div.obj: $(SRC_D)\crypto\bn\bn_div.c
940 $(CC) /Fo$(OBJ_D)\bn_div.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_div.c
941
942$(OBJ_D)\bn_exp.obj: $(SRC_D)\crypto\bn\bn_exp.c
943 $(CC) /Fo$(OBJ_D)\bn_exp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_exp.c
944
945$(OBJ_D)\bn_lib.obj: $(SRC_D)\crypto\bn\bn_lib.c
946 $(CC) /Fo$(OBJ_D)\bn_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_lib.c
947
948$(OBJ_D)\bn_mod.obj: $(SRC_D)\crypto\bn\bn_mod.c
949 $(CC) /Fo$(OBJ_D)\bn_mod.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_mod.c
950
951$(OBJ_D)\bn_mul.obj: $(SRC_D)\crypto\bn\bn_mul.c
952 $(CC) /Fo$(OBJ_D)\bn_mul.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_mul.c
953
954$(OBJ_D)\bn_print.obj: $(SRC_D)\crypto\bn\bn_print.c
955 $(CC) /Fo$(OBJ_D)\bn_print.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_print.c
956
957$(OBJ_D)\bn_rand.obj: $(SRC_D)\crypto\bn\bn_rand.c
958 $(CC) /Fo$(OBJ_D)\bn_rand.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_rand.c
959
960$(OBJ_D)\bn_shift.obj: $(SRC_D)\crypto\bn\bn_shift.c
961 $(CC) /Fo$(OBJ_D)\bn_shift.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_shift.c
962
963$(OBJ_D)\bn_sub.obj: $(SRC_D)\crypto\bn\bn_sub.c
964 $(CC) /Fo$(OBJ_D)\bn_sub.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_sub.c
965
966$(OBJ_D)\bn_word.obj: $(SRC_D)\crypto\bn\bn_word.c
967 $(CC) /Fo$(OBJ_D)\bn_word.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_word.c
968
969$(OBJ_D)\bn_blind.obj: $(SRC_D)\crypto\bn\bn_blind.c
970 $(CC) /Fo$(OBJ_D)\bn_blind.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_blind.c
971
972$(OBJ_D)\bn_gcd.obj: $(SRC_D)\crypto\bn\bn_gcd.c
973 $(CC) /Fo$(OBJ_D)\bn_gcd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_gcd.c
974
975$(OBJ_D)\bn_prime.obj: $(SRC_D)\crypto\bn\bn_prime.c
976 $(CC) /Fo$(OBJ_D)\bn_prime.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_prime.c
977
978$(OBJ_D)\bn_err.obj: $(SRC_D)\crypto\bn\bn_err.c
979 $(CC) /Fo$(OBJ_D)\bn_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_err.c
980
981$(OBJ_D)\bn_sqr.obj: $(SRC_D)\crypto\bn\bn_sqr.c
982 $(CC) /Fo$(OBJ_D)\bn_sqr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_sqr.c
983
984$(OBJ_D)\bn_mulw.obj: $(SRC_D)\crypto\bn\bn_mulw.c
985 $(CC) /Fo$(OBJ_D)\bn_mulw.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_mulw.c
986
987$(OBJ_D)\bn_recp.obj: $(SRC_D)\crypto\bn\bn_recp.c
988 $(CC) /Fo$(OBJ_D)\bn_recp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_recp.c
989
990$(OBJ_D)\bn_mont.obj: $(SRC_D)\crypto\bn\bn_mont.c
991 $(CC) /Fo$(OBJ_D)\bn_mont.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_mont.c
992
993$(OBJ_D)\bn_mpi.obj: $(SRC_D)\crypto\bn\bn_mpi.c
994 $(CC) /Fo$(OBJ_D)\bn_mpi.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_mpi.c
995
996$(OBJ_D)\rsa_eay.obj: $(SRC_D)\crypto\rsa\rsa_eay.c
997 $(CC) /Fo$(OBJ_D)\rsa_eay.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_eay.c
998
999$(OBJ_D)\rsa_gen.obj: $(SRC_D)\crypto\rsa\rsa_gen.c
1000 $(CC) /Fo$(OBJ_D)\rsa_gen.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_gen.c
1001
1002$(OBJ_D)\rsa_lib.obj: $(SRC_D)\crypto\rsa\rsa_lib.c
1003 $(CC) /Fo$(OBJ_D)\rsa_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_lib.c
1004
1005$(OBJ_D)\rsa_sign.obj: $(SRC_D)\crypto\rsa\rsa_sign.c
1006 $(CC) /Fo$(OBJ_D)\rsa_sign.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_sign.c
1007
1008$(OBJ_D)\rsa_saos.obj: $(SRC_D)\crypto\rsa\rsa_saos.c
1009 $(CC) /Fo$(OBJ_D)\rsa_saos.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_saos.c
1010
1011$(OBJ_D)\rsa_err.obj: $(SRC_D)\crypto\rsa\rsa_err.c
1012 $(CC) /Fo$(OBJ_D)\rsa_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_err.c
1013
1014$(OBJ_D)\rsa_pk1.obj: $(SRC_D)\crypto\rsa\rsa_pk1.c
1015 $(CC) /Fo$(OBJ_D)\rsa_pk1.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_pk1.c
1016
1017$(OBJ_D)\rsa_ssl.obj: $(SRC_D)\crypto\rsa\rsa_ssl.c
1018 $(CC) /Fo$(OBJ_D)\rsa_ssl.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_ssl.c
1019
1020$(OBJ_D)\rsa_none.obj: $(SRC_D)\crypto\rsa\rsa_none.c
1021 $(CC) /Fo$(OBJ_D)\rsa_none.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_none.c
1022
1023$(OBJ_D)\dsa_gen.obj: $(SRC_D)\crypto\dsa\dsa_gen.c
1024 $(CC) /Fo$(OBJ_D)\dsa_gen.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_gen.c
1025
1026$(OBJ_D)\dsa_key.obj: $(SRC_D)\crypto\dsa\dsa_key.c
1027 $(CC) /Fo$(OBJ_D)\dsa_key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_key.c
1028
1029$(OBJ_D)\dsa_lib.obj: $(SRC_D)\crypto\dsa\dsa_lib.c
1030 $(CC) /Fo$(OBJ_D)\dsa_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_lib.c
1031
1032$(OBJ_D)\dsa_vrf.obj: $(SRC_D)\crypto\dsa\dsa_vrf.c
1033 $(CC) /Fo$(OBJ_D)\dsa_vrf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_vrf.c
1034
1035$(OBJ_D)\dsa_sign.obj: $(SRC_D)\crypto\dsa\dsa_sign.c
1036 $(CC) /Fo$(OBJ_D)\dsa_sign.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_sign.c
1037
1038$(OBJ_D)\dsa_err.obj: $(SRC_D)\crypto\dsa\dsa_err.c
1039 $(CC) /Fo$(OBJ_D)\dsa_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_err.c
1040
1041$(OBJ_D)\dh_gen.obj: $(SRC_D)\crypto\dh\dh_gen.c
1042 $(CC) /Fo$(OBJ_D)\dh_gen.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dh\dh_gen.c
1043
1044$(OBJ_D)\dh_key.obj: $(SRC_D)\crypto\dh\dh_key.c
1045 $(CC) /Fo$(OBJ_D)\dh_key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dh\dh_key.c
1046
1047$(OBJ_D)\dh_lib.obj: $(SRC_D)\crypto\dh\dh_lib.c
1048 $(CC) /Fo$(OBJ_D)\dh_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dh\dh_lib.c
1049
1050$(OBJ_D)\dh_check.obj: $(SRC_D)\crypto\dh\dh_check.c
1051 $(CC) /Fo$(OBJ_D)\dh_check.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dh\dh_check.c
1052
1053$(OBJ_D)\dh_err.obj: $(SRC_D)\crypto\dh\dh_err.c
1054 $(CC) /Fo$(OBJ_D)\dh_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dh\dh_err.c
1055
1056$(OBJ_D)\buffer.obj: $(SRC_D)\crypto\buffer\buffer.c
1057 $(CC) /Fo$(OBJ_D)\buffer.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\buffer\buffer.c
1058
1059$(OBJ_D)\buf_err.obj: $(SRC_D)\crypto\buffer\buf_err.c
1060 $(CC) /Fo$(OBJ_D)\buf_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\buffer\buf_err.c
1061
1062$(OBJ_D)\bio_lib.obj: $(SRC_D)\crypto\bio\bio_lib.c
1063 $(CC) /Fo$(OBJ_D)\bio_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bio_lib.c
1064
1065$(OBJ_D)\bio_cb.obj: $(SRC_D)\crypto\bio\bio_cb.c
1066 $(CC) /Fo$(OBJ_D)\bio_cb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bio_cb.c
1067
1068$(OBJ_D)\bio_err.obj: $(SRC_D)\crypto\bio\bio_err.c
1069 $(CC) /Fo$(OBJ_D)\bio_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bio_err.c
1070
1071$(OBJ_D)\bss_mem.obj: $(SRC_D)\crypto\bio\bss_mem.c
1072 $(CC) /Fo$(OBJ_D)\bss_mem.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_mem.c
1073
1074$(OBJ_D)\bss_null.obj: $(SRC_D)\crypto\bio\bss_null.c
1075 $(CC) /Fo$(OBJ_D)\bss_null.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_null.c
1076
1077$(OBJ_D)\bss_fd.obj: $(SRC_D)\crypto\bio\bss_fd.c
1078 $(CC) /Fo$(OBJ_D)\bss_fd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_fd.c
1079
1080$(OBJ_D)\bss_file.obj: $(SRC_D)\crypto\bio\bss_file.c
1081 $(CC) /Fo$(OBJ_D)\bss_file.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_file.c
1082
1083$(OBJ_D)\bss_sock.obj: $(SRC_D)\crypto\bio\bss_sock.c
1084 $(CC) /Fo$(OBJ_D)\bss_sock.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_sock.c
1085
1086$(OBJ_D)\bss_conn.obj: $(SRC_D)\crypto\bio\bss_conn.c
1087 $(CC) /Fo$(OBJ_D)\bss_conn.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_conn.c
1088
1089$(OBJ_D)\bf_null.obj: $(SRC_D)\crypto\bio\bf_null.c
1090 $(CC) /Fo$(OBJ_D)\bf_null.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bf_null.c
1091
1092$(OBJ_D)\bf_buff.obj: $(SRC_D)\crypto\bio\bf_buff.c
1093 $(CC) /Fo$(OBJ_D)\bf_buff.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bf_buff.c
1094
1095$(OBJ_D)\b_print.obj: $(SRC_D)\crypto\bio\b_print.c
1096 $(CC) /Fo$(OBJ_D)\b_print.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\b_print.c
1097
1098$(OBJ_D)\b_dump.obj: $(SRC_D)\crypto\bio\b_dump.c
1099 $(CC) /Fo$(OBJ_D)\b_dump.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\b_dump.c
1100
1101$(OBJ_D)\b_sock.obj: $(SRC_D)\crypto\bio\b_sock.c
1102 $(CC) /Fo$(OBJ_D)\b_sock.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\b_sock.c
1103
1104$(OBJ_D)\bss_acpt.obj: $(SRC_D)\crypto\bio\bss_acpt.c
1105 $(CC) /Fo$(OBJ_D)\bss_acpt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_acpt.c
1106
1107$(OBJ_D)\bf_nbio.obj: $(SRC_D)\crypto\bio\bf_nbio.c
1108 $(CC) /Fo$(OBJ_D)\bf_nbio.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bf_nbio.c
1109
1110$(OBJ_D)\stack.obj: $(SRC_D)\crypto\stack\stack.c
1111 $(CC) /Fo$(OBJ_D)\stack.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\stack\stack.c
1112
1113$(OBJ_D)\lhash.obj: $(SRC_D)\crypto\lhash\lhash.c
1114 $(CC) /Fo$(OBJ_D)\lhash.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\lhash\lhash.c
1115
1116$(OBJ_D)\lh_stats.obj: $(SRC_D)\crypto\lhash\lh_stats.c
1117 $(CC) /Fo$(OBJ_D)\lh_stats.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\lhash\lh_stats.c
1118
1119$(OBJ_D)\md_rand.obj: $(SRC_D)\crypto\rand\md_rand.c
1120 $(CC) /Fo$(OBJ_D)\md_rand.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rand\md_rand.c
1121
1122$(OBJ_D)\randfile.obj: $(SRC_D)\crypto\rand\randfile.c
1123 $(CC) /Fo$(OBJ_D)\randfile.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rand\randfile.c
1124
1125$(OBJ_D)\err.obj: $(SRC_D)\crypto\err\err.c
1126 $(CC) /Fo$(OBJ_D)\err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\err\err.c
1127
1128$(OBJ_D)\err_all.obj: $(SRC_D)\crypto\err\err_all.c
1129 $(CC) /Fo$(OBJ_D)\err_all.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\err\err_all.c
1130
1131$(OBJ_D)\err_prn.obj: $(SRC_D)\crypto\err\err_prn.c
1132 $(CC) /Fo$(OBJ_D)\err_prn.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\err\err_prn.c
1133
1134$(OBJ_D)\obj_dat.obj: $(SRC_D)\crypto\objects\obj_dat.c
1135 $(CC) /Fo$(OBJ_D)\obj_dat.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\objects\obj_dat.c
1136
1137$(OBJ_D)\obj_lib.obj: $(SRC_D)\crypto\objects\obj_lib.c
1138 $(CC) /Fo$(OBJ_D)\obj_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\objects\obj_lib.c
1139
1140$(OBJ_D)\obj_err.obj: $(SRC_D)\crypto\objects\obj_err.c
1141 $(CC) /Fo$(OBJ_D)\obj_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\objects\obj_err.c
1142
1143$(OBJ_D)\encode.obj: $(SRC_D)\crypto\evp\encode.c
1144 $(CC) /Fo$(OBJ_D)\encode.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\encode.c
1145
1146$(OBJ_D)\digest.obj: $(SRC_D)\crypto\evp\digest.c
1147 $(CC) /Fo$(OBJ_D)\digest.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\digest.c
1148
1149$(OBJ_D)\evp_enc.obj: $(SRC_D)\crypto\evp\evp_enc.c
1150 $(CC) /Fo$(OBJ_D)\evp_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\evp_enc.c
1151
1152$(OBJ_D)\evp_key.obj: $(SRC_D)\crypto\evp\evp_key.c
1153 $(CC) /Fo$(OBJ_D)\evp_key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\evp_key.c
1154
1155$(OBJ_D)\e_ecb_d.obj: $(SRC_D)\crypto\evp\e_ecb_d.c
1156 $(CC) /Fo$(OBJ_D)\e_ecb_d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_d.c
1157
1158$(OBJ_D)\e_cbc_d.obj: $(SRC_D)\crypto\evp\e_cbc_d.c
1159 $(CC) /Fo$(OBJ_D)\e_cbc_d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_d.c
1160
1161$(OBJ_D)\e_cfb_d.obj: $(SRC_D)\crypto\evp\e_cfb_d.c
1162 $(CC) /Fo$(OBJ_D)\e_cfb_d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_d.c
1163
1164$(OBJ_D)\e_ofb_d.obj: $(SRC_D)\crypto\evp\e_ofb_d.c
1165 $(CC) /Fo$(OBJ_D)\e_ofb_d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_d.c
1166
1167$(OBJ_D)\e_ecb_i.obj: $(SRC_D)\crypto\evp\e_ecb_i.c
1168 $(CC) /Fo$(OBJ_D)\e_ecb_i.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_i.c
1169
1170$(OBJ_D)\e_cbc_i.obj: $(SRC_D)\crypto\evp\e_cbc_i.c
1171 $(CC) /Fo$(OBJ_D)\e_cbc_i.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_i.c
1172
1173$(OBJ_D)\e_cfb_i.obj: $(SRC_D)\crypto\evp\e_cfb_i.c
1174 $(CC) /Fo$(OBJ_D)\e_cfb_i.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_i.c
1175
1176$(OBJ_D)\e_ofb_i.obj: $(SRC_D)\crypto\evp\e_ofb_i.c
1177 $(CC) /Fo$(OBJ_D)\e_ofb_i.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_i.c
1178
1179$(OBJ_D)\e_ecb_3d.obj: $(SRC_D)\crypto\evp\e_ecb_3d.c
1180 $(CC) /Fo$(OBJ_D)\e_ecb_3d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_3d.c
1181
1182$(OBJ_D)\e_cbc_3d.obj: $(SRC_D)\crypto\evp\e_cbc_3d.c
1183 $(CC) /Fo$(OBJ_D)\e_cbc_3d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_3d.c
1184
1185$(OBJ_D)\e_rc4.obj: $(SRC_D)\crypto\evp\e_rc4.c
1186 $(CC) /Fo$(OBJ_D)\e_rc4.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_rc4.c
1187
1188$(OBJ_D)\names.obj: $(SRC_D)\crypto\evp\names.c
1189 $(CC) /Fo$(OBJ_D)\names.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\names.c
1190
1191$(OBJ_D)\e_cfb_3d.obj: $(SRC_D)\crypto\evp\e_cfb_3d.c
1192 $(CC) /Fo$(OBJ_D)\e_cfb_3d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_3d.c
1193
1194$(OBJ_D)\e_ofb_3d.obj: $(SRC_D)\crypto\evp\e_ofb_3d.c
1195 $(CC) /Fo$(OBJ_D)\e_ofb_3d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_3d.c
1196
1197$(OBJ_D)\e_xcbc_d.obj: $(SRC_D)\crypto\evp\e_xcbc_d.c
1198 $(CC) /Fo$(OBJ_D)\e_xcbc_d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_xcbc_d.c
1199
1200$(OBJ_D)\e_ecb_r2.obj: $(SRC_D)\crypto\evp\e_ecb_r2.c
1201 $(CC) /Fo$(OBJ_D)\e_ecb_r2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_r2.c
1202
1203$(OBJ_D)\e_cbc_r2.obj: $(SRC_D)\crypto\evp\e_cbc_r2.c
1204 $(CC) /Fo$(OBJ_D)\e_cbc_r2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_r2.c
1205
1206$(OBJ_D)\e_cfb_r2.obj: $(SRC_D)\crypto\evp\e_cfb_r2.c
1207 $(CC) /Fo$(OBJ_D)\e_cfb_r2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_r2.c
1208
1209$(OBJ_D)\e_ofb_r2.obj: $(SRC_D)\crypto\evp\e_ofb_r2.c
1210 $(CC) /Fo$(OBJ_D)\e_ofb_r2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_r2.c
1211
1212$(OBJ_D)\e_ecb_bf.obj: $(SRC_D)\crypto\evp\e_ecb_bf.c
1213 $(CC) /Fo$(OBJ_D)\e_ecb_bf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_bf.c
1214
1215$(OBJ_D)\e_cbc_bf.obj: $(SRC_D)\crypto\evp\e_cbc_bf.c
1216 $(CC) /Fo$(OBJ_D)\e_cbc_bf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_bf.c
1217
1218$(OBJ_D)\e_cfb_bf.obj: $(SRC_D)\crypto\evp\e_cfb_bf.c
1219 $(CC) /Fo$(OBJ_D)\e_cfb_bf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_bf.c
1220
1221$(OBJ_D)\e_ofb_bf.obj: $(SRC_D)\crypto\evp\e_ofb_bf.c
1222 $(CC) /Fo$(OBJ_D)\e_ofb_bf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_bf.c
1223
1224$(OBJ_D)\e_ecb_c.obj: $(SRC_D)\crypto\evp\e_ecb_c.c
1225 $(CC) /Fo$(OBJ_D)\e_ecb_c.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_c.c
1226
1227$(OBJ_D)\e_cbc_c.obj: $(SRC_D)\crypto\evp\e_cbc_c.c
1228 $(CC) /Fo$(OBJ_D)\e_cbc_c.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_c.c
1229
1230$(OBJ_D)\e_cfb_c.obj: $(SRC_D)\crypto\evp\e_cfb_c.c
1231 $(CC) /Fo$(OBJ_D)\e_cfb_c.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_c.c
1232
1233$(OBJ_D)\e_ofb_c.obj: $(SRC_D)\crypto\evp\e_ofb_c.c
1234 $(CC) /Fo$(OBJ_D)\e_ofb_c.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_c.c
1235
1236$(OBJ_D)\e_ecb_r5.obj: $(SRC_D)\crypto\evp\e_ecb_r5.c
1237 $(CC) /Fo$(OBJ_D)\e_ecb_r5.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_r5.c
1238
1239$(OBJ_D)\e_cbc_r5.obj: $(SRC_D)\crypto\evp\e_cbc_r5.c
1240 $(CC) /Fo$(OBJ_D)\e_cbc_r5.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_r5.c
1241
1242$(OBJ_D)\e_cfb_r5.obj: $(SRC_D)\crypto\evp\e_cfb_r5.c
1243 $(CC) /Fo$(OBJ_D)\e_cfb_r5.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_r5.c
1244
1245$(OBJ_D)\e_ofb_r5.obj: $(SRC_D)\crypto\evp\e_ofb_r5.c
1246 $(CC) /Fo$(OBJ_D)\e_ofb_r5.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_r5.c
1247
1248$(OBJ_D)\m_null.obj: $(SRC_D)\crypto\evp\m_null.c
1249 $(CC) /Fo$(OBJ_D)\m_null.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_null.c
1250
1251$(OBJ_D)\m_md2.obj: $(SRC_D)\crypto\evp\m_md2.c
1252 $(CC) /Fo$(OBJ_D)\m_md2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_md2.c
1253
1254$(OBJ_D)\m_md5.obj: $(SRC_D)\crypto\evp\m_md5.c
1255 $(CC) /Fo$(OBJ_D)\m_md5.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_md5.c
1256
1257$(OBJ_D)\m_sha.obj: $(SRC_D)\crypto\evp\m_sha.c
1258 $(CC) /Fo$(OBJ_D)\m_sha.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_sha.c
1259
1260$(OBJ_D)\m_sha1.obj: $(SRC_D)\crypto\evp\m_sha1.c
1261 $(CC) /Fo$(OBJ_D)\m_sha1.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_sha1.c
1262
1263$(OBJ_D)\m_dss.obj: $(SRC_D)\crypto\evp\m_dss.c
1264 $(CC) /Fo$(OBJ_D)\m_dss.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_dss.c
1265
1266$(OBJ_D)\m_dss1.obj: $(SRC_D)\crypto\evp\m_dss1.c
1267 $(CC) /Fo$(OBJ_D)\m_dss1.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_dss1.c
1268
1269$(OBJ_D)\m_mdc2.obj: $(SRC_D)\crypto\evp\m_mdc2.c
1270 $(CC) /Fo$(OBJ_D)\m_mdc2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_mdc2.c
1271
1272$(OBJ_D)\m_ripemd.obj: $(SRC_D)\crypto\evp\m_ripemd.c
1273 $(CC) /Fo$(OBJ_D)\m_ripemd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_ripemd.c
1274
1275$(OBJ_D)\p_open.obj: $(SRC_D)\crypto\evp\p_open.c
1276 $(CC) /Fo$(OBJ_D)\p_open.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_open.c
1277
1278$(OBJ_D)\p_seal.obj: $(SRC_D)\crypto\evp\p_seal.c
1279 $(CC) /Fo$(OBJ_D)\p_seal.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_seal.c
1280
1281$(OBJ_D)\p_sign.obj: $(SRC_D)\crypto\evp\p_sign.c
1282 $(CC) /Fo$(OBJ_D)\p_sign.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_sign.c
1283
1284$(OBJ_D)\p_verify.obj: $(SRC_D)\crypto\evp\p_verify.c
1285 $(CC) /Fo$(OBJ_D)\p_verify.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_verify.c
1286
1287$(OBJ_D)\p_lib.obj: $(SRC_D)\crypto\evp\p_lib.c
1288 $(CC) /Fo$(OBJ_D)\p_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_lib.c
1289
1290$(OBJ_D)\p_enc.obj: $(SRC_D)\crypto\evp\p_enc.c
1291 $(CC) /Fo$(OBJ_D)\p_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_enc.c
1292
1293$(OBJ_D)\p_dec.obj: $(SRC_D)\crypto\evp\p_dec.c
1294 $(CC) /Fo$(OBJ_D)\p_dec.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_dec.c
1295
1296$(OBJ_D)\bio_md.obj: $(SRC_D)\crypto\evp\bio_md.c
1297 $(CC) /Fo$(OBJ_D)\bio_md.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\bio_md.c
1298
1299$(OBJ_D)\bio_b64.obj: $(SRC_D)\crypto\evp\bio_b64.c
1300 $(CC) /Fo$(OBJ_D)\bio_b64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\bio_b64.c
1301
1302$(OBJ_D)\bio_enc.obj: $(SRC_D)\crypto\evp\bio_enc.c
1303 $(CC) /Fo$(OBJ_D)\bio_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\bio_enc.c
1304
1305$(OBJ_D)\evp_err.obj: $(SRC_D)\crypto\evp\evp_err.c
1306 $(CC) /Fo$(OBJ_D)\evp_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\evp_err.c
1307
1308$(OBJ_D)\e_null.obj: $(SRC_D)\crypto\evp\e_null.c
1309 $(CC) /Fo$(OBJ_D)\e_null.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_null.c
1310
1311$(OBJ_D)\c_all.obj: $(SRC_D)\crypto\evp\c_all.c
1312 $(CC) /Fo$(OBJ_D)\c_all.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\c_all.c
1313
1314$(OBJ_D)\evp_lib.obj: $(SRC_D)\crypto\evp\evp_lib.c
1315 $(CC) /Fo$(OBJ_D)\evp_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\evp_lib.c
1316
1317$(OBJ_D)\pem_sign.obj: $(SRC_D)\crypto\pem\pem_sign.c
1318 $(CC) /Fo$(OBJ_D)\pem_sign.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_sign.c
1319
1320$(OBJ_D)\pem_seal.obj: $(SRC_D)\crypto\pem\pem_seal.c
1321 $(CC) /Fo$(OBJ_D)\pem_seal.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_seal.c
1322
1323$(OBJ_D)\pem_info.obj: $(SRC_D)\crypto\pem\pem_info.c
1324 $(CC) /Fo$(OBJ_D)\pem_info.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_info.c
1325
1326$(OBJ_D)\pem_lib.obj: $(SRC_D)\crypto\pem\pem_lib.c
1327 $(CC) /Fo$(OBJ_D)\pem_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_lib.c
1328
1329$(OBJ_D)\pem_all.obj: $(SRC_D)\crypto\pem\pem_all.c
1330 $(CC) /Fo$(OBJ_D)\pem_all.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_all.c
1331
1332$(OBJ_D)\pem_err.obj: $(SRC_D)\crypto\pem\pem_err.c
1333 $(CC) /Fo$(OBJ_D)\pem_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_err.c
1334
1335$(OBJ_D)\a_object.obj: $(SRC_D)\crypto\asn1\a_object.c
1336 $(CC) /Fo$(OBJ_D)\a_object.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_object.c
1337
1338$(OBJ_D)\a_bitstr.obj: $(SRC_D)\crypto\asn1\a_bitstr.c
1339 $(CC) /Fo$(OBJ_D)\a_bitstr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_bitstr.c
1340
1341$(OBJ_D)\a_utctm.obj: $(SRC_D)\crypto\asn1\a_utctm.c
1342 $(CC) /Fo$(OBJ_D)\a_utctm.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_utctm.c
1343
1344$(OBJ_D)\a_int.obj: $(SRC_D)\crypto\asn1\a_int.c
1345 $(CC) /Fo$(OBJ_D)\a_int.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_int.c
1346
1347$(OBJ_D)\a_octet.obj: $(SRC_D)\crypto\asn1\a_octet.c
1348 $(CC) /Fo$(OBJ_D)\a_octet.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_octet.c
1349
1350$(OBJ_D)\a_print.obj: $(SRC_D)\crypto\asn1\a_print.c
1351 $(CC) /Fo$(OBJ_D)\a_print.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_print.c
1352
1353$(OBJ_D)\a_type.obj: $(SRC_D)\crypto\asn1\a_type.c
1354 $(CC) /Fo$(OBJ_D)\a_type.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_type.c
1355
1356$(OBJ_D)\a_set.obj: $(SRC_D)\crypto\asn1\a_set.c
1357 $(CC) /Fo$(OBJ_D)\a_set.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_set.c
1358
1359$(OBJ_D)\a_dup.obj: $(SRC_D)\crypto\asn1\a_dup.c
1360 $(CC) /Fo$(OBJ_D)\a_dup.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_dup.c
1361
1362$(OBJ_D)\a_d2i_fp.obj: $(SRC_D)\crypto\asn1\a_d2i_fp.c
1363 $(CC) /Fo$(OBJ_D)\a_d2i_fp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_d2i_fp.c
1364
1365$(OBJ_D)\a_i2d_fp.obj: $(SRC_D)\crypto\asn1\a_i2d_fp.c
1366 $(CC) /Fo$(OBJ_D)\a_i2d_fp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_i2d_fp.c
1367
1368$(OBJ_D)\a_sign.obj: $(SRC_D)\crypto\asn1\a_sign.c
1369 $(CC) /Fo$(OBJ_D)\a_sign.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_sign.c
1370
1371$(OBJ_D)\a_digest.obj: $(SRC_D)\crypto\asn1\a_digest.c
1372 $(CC) /Fo$(OBJ_D)\a_digest.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_digest.c
1373
1374$(OBJ_D)\a_verify.obj: $(SRC_D)\crypto\asn1\a_verify.c
1375 $(CC) /Fo$(OBJ_D)\a_verify.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_verify.c
1376
1377$(OBJ_D)\x_algor.obj: $(SRC_D)\crypto\asn1\x_algor.c
1378 $(CC) /Fo$(OBJ_D)\x_algor.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_algor.c
1379
1380$(OBJ_D)\x_val.obj: $(SRC_D)\crypto\asn1\x_val.c
1381 $(CC) /Fo$(OBJ_D)\x_val.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_val.c
1382
1383$(OBJ_D)\x_pubkey.obj: $(SRC_D)\crypto\asn1\x_pubkey.c
1384 $(CC) /Fo$(OBJ_D)\x_pubkey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_pubkey.c
1385
1386$(OBJ_D)\x_sig.obj: $(SRC_D)\crypto\asn1\x_sig.c
1387 $(CC) /Fo$(OBJ_D)\x_sig.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_sig.c
1388
1389$(OBJ_D)\x_req.obj: $(SRC_D)\crypto\asn1\x_req.c
1390 $(CC) /Fo$(OBJ_D)\x_req.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_req.c
1391
1392$(OBJ_D)\x_attrib.obj: $(SRC_D)\crypto\asn1\x_attrib.c
1393 $(CC) /Fo$(OBJ_D)\x_attrib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_attrib.c
1394
1395$(OBJ_D)\x_name.obj: $(SRC_D)\crypto\asn1\x_name.c
1396 $(CC) /Fo$(OBJ_D)\x_name.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_name.c
1397
1398$(OBJ_D)\x_cinf.obj: $(SRC_D)\crypto\asn1\x_cinf.c
1399 $(CC) /Fo$(OBJ_D)\x_cinf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_cinf.c
1400
1401$(OBJ_D)\x_x509.obj: $(SRC_D)\crypto\asn1\x_x509.c
1402 $(CC) /Fo$(OBJ_D)\x_x509.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_x509.c
1403
1404$(OBJ_D)\x_crl.obj: $(SRC_D)\crypto\asn1\x_crl.c
1405 $(CC) /Fo$(OBJ_D)\x_crl.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_crl.c
1406
1407$(OBJ_D)\x_info.obj: $(SRC_D)\crypto\asn1\x_info.c
1408 $(CC) /Fo$(OBJ_D)\x_info.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_info.c
1409
1410$(OBJ_D)\x_spki.obj: $(SRC_D)\crypto\asn1\x_spki.c
1411 $(CC) /Fo$(OBJ_D)\x_spki.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_spki.c
1412
1413$(OBJ_D)\d2i_r_pr.obj: $(SRC_D)\crypto\asn1\d2i_r_pr.c
1414 $(CC) /Fo$(OBJ_D)\d2i_r_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_r_pr.c
1415
1416$(OBJ_D)\i2d_r_pr.obj: $(SRC_D)\crypto\asn1\i2d_r_pr.c
1417 $(CC) /Fo$(OBJ_D)\i2d_r_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_r_pr.c
1418
1419$(OBJ_D)\d2i_r_pu.obj: $(SRC_D)\crypto\asn1\d2i_r_pu.c
1420 $(CC) /Fo$(OBJ_D)\d2i_r_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_r_pu.c
1421
1422$(OBJ_D)\i2d_r_pu.obj: $(SRC_D)\crypto\asn1\i2d_r_pu.c
1423 $(CC) /Fo$(OBJ_D)\i2d_r_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_r_pu.c
1424
1425$(OBJ_D)\d2i_s_pr.obj: $(SRC_D)\crypto\asn1\d2i_s_pr.c
1426 $(CC) /Fo$(OBJ_D)\d2i_s_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_s_pr.c
1427
1428$(OBJ_D)\i2d_s_pr.obj: $(SRC_D)\crypto\asn1\i2d_s_pr.c
1429 $(CC) /Fo$(OBJ_D)\i2d_s_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_s_pr.c
1430
1431$(OBJ_D)\d2i_s_pu.obj: $(SRC_D)\crypto\asn1\d2i_s_pu.c
1432 $(CC) /Fo$(OBJ_D)\d2i_s_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_s_pu.c
1433
1434$(OBJ_D)\i2d_s_pu.obj: $(SRC_D)\crypto\asn1\i2d_s_pu.c
1435 $(CC) /Fo$(OBJ_D)\i2d_s_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_s_pu.c
1436
1437$(OBJ_D)\d2i_pu.obj: $(SRC_D)\crypto\asn1\d2i_pu.c
1438 $(CC) /Fo$(OBJ_D)\d2i_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_pu.c
1439
1440$(OBJ_D)\d2i_pr.obj: $(SRC_D)\crypto\asn1\d2i_pr.c
1441 $(CC) /Fo$(OBJ_D)\d2i_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_pr.c
1442
1443$(OBJ_D)\i2d_pu.obj: $(SRC_D)\crypto\asn1\i2d_pu.c
1444 $(CC) /Fo$(OBJ_D)\i2d_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_pu.c
1445
1446$(OBJ_D)\i2d_pr.obj: $(SRC_D)\crypto\asn1\i2d_pr.c
1447 $(CC) /Fo$(OBJ_D)\i2d_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_pr.c
1448
1449$(OBJ_D)\t_req.obj: $(SRC_D)\crypto\asn1\t_req.c
1450 $(CC) /Fo$(OBJ_D)\t_req.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\t_req.c
1451
1452$(OBJ_D)\t_x509.obj: $(SRC_D)\crypto\asn1\t_x509.c
1453 $(CC) /Fo$(OBJ_D)\t_x509.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\t_x509.c
1454
1455$(OBJ_D)\t_pkey.obj: $(SRC_D)\crypto\asn1\t_pkey.c
1456 $(CC) /Fo$(OBJ_D)\t_pkey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\t_pkey.c
1457
1458$(OBJ_D)\p7_i_s.obj: $(SRC_D)\crypto\asn1\p7_i_s.c
1459 $(CC) /Fo$(OBJ_D)\p7_i_s.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_i_s.c
1460
1461$(OBJ_D)\p7_signi.obj: $(SRC_D)\crypto\asn1\p7_signi.c
1462 $(CC) /Fo$(OBJ_D)\p7_signi.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_signi.c
1463
1464$(OBJ_D)\p7_signd.obj: $(SRC_D)\crypto\asn1\p7_signd.c
1465 $(CC) /Fo$(OBJ_D)\p7_signd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_signd.c
1466
1467$(OBJ_D)\p7_recip.obj: $(SRC_D)\crypto\asn1\p7_recip.c
1468 $(CC) /Fo$(OBJ_D)\p7_recip.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_recip.c
1469
1470$(OBJ_D)\p7_enc_c.obj: $(SRC_D)\crypto\asn1\p7_enc_c.c
1471 $(CC) /Fo$(OBJ_D)\p7_enc_c.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_enc_c.c
1472
1473$(OBJ_D)\p7_evp.obj: $(SRC_D)\crypto\asn1\p7_evp.c
1474 $(CC) /Fo$(OBJ_D)\p7_evp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_evp.c
1475
1476$(OBJ_D)\p7_dgst.obj: $(SRC_D)\crypto\asn1\p7_dgst.c
1477 $(CC) /Fo$(OBJ_D)\p7_dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_dgst.c
1478
1479$(OBJ_D)\p7_s_e.obj: $(SRC_D)\crypto\asn1\p7_s_e.c
1480 $(CC) /Fo$(OBJ_D)\p7_s_e.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_s_e.c
1481
1482$(OBJ_D)\p7_enc.obj: $(SRC_D)\crypto\asn1\p7_enc.c
1483 $(CC) /Fo$(OBJ_D)\p7_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_enc.c
1484
1485$(OBJ_D)\p7_lib.obj: $(SRC_D)\crypto\asn1\p7_lib.c
1486 $(CC) /Fo$(OBJ_D)\p7_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_lib.c
1487
1488$(OBJ_D)\f_int.obj: $(SRC_D)\crypto\asn1\f_int.c
1489 $(CC) /Fo$(OBJ_D)\f_int.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\f_int.c
1490
1491$(OBJ_D)\f_string.obj: $(SRC_D)\crypto\asn1\f_string.c
1492 $(CC) /Fo$(OBJ_D)\f_string.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\f_string.c
1493
1494$(OBJ_D)\i2d_dhp.obj: $(SRC_D)\crypto\asn1\i2d_dhp.c
1495 $(CC) /Fo$(OBJ_D)\i2d_dhp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_dhp.c
1496
1497$(OBJ_D)\i2d_dsap.obj: $(SRC_D)\crypto\asn1\i2d_dsap.c
1498 $(CC) /Fo$(OBJ_D)\i2d_dsap.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_dsap.c
1499
1500$(OBJ_D)\d2i_dhp.obj: $(SRC_D)\crypto\asn1\d2i_dhp.c
1501 $(CC) /Fo$(OBJ_D)\d2i_dhp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_dhp.c
1502
1503$(OBJ_D)\d2i_dsap.obj: $(SRC_D)\crypto\asn1\d2i_dsap.c
1504 $(CC) /Fo$(OBJ_D)\d2i_dsap.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_dsap.c
1505
1506$(OBJ_D)\n_pkey.obj: $(SRC_D)\crypto\asn1\n_pkey.c
1507 $(CC) /Fo$(OBJ_D)\n_pkey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\n_pkey.c
1508
1509$(OBJ_D)\a_hdr.obj: $(SRC_D)\crypto\asn1\a_hdr.c
1510 $(CC) /Fo$(OBJ_D)\a_hdr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_hdr.c
1511
1512$(OBJ_D)\x_pkey.obj: $(SRC_D)\crypto\asn1\x_pkey.c
1513 $(CC) /Fo$(OBJ_D)\x_pkey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_pkey.c
1514
1515$(OBJ_D)\a_bool.obj: $(SRC_D)\crypto\asn1\a_bool.c
1516 $(CC) /Fo$(OBJ_D)\a_bool.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_bool.c
1517
1518$(OBJ_D)\x_exten.obj: $(SRC_D)\crypto\asn1\x_exten.c
1519 $(CC) /Fo$(OBJ_D)\x_exten.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_exten.c
1520
1521$(OBJ_D)\asn1_par.obj: $(SRC_D)\crypto\asn1\asn1_par.c
1522 $(CC) /Fo$(OBJ_D)\asn1_par.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\asn1_par.c
1523
1524$(OBJ_D)\asn1_lib.obj: $(SRC_D)\crypto\asn1\asn1_lib.c
1525 $(CC) /Fo$(OBJ_D)\asn1_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\asn1_lib.c
1526
1527$(OBJ_D)\asn1_err.obj: $(SRC_D)\crypto\asn1\asn1_err.c
1528 $(CC) /Fo$(OBJ_D)\asn1_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\asn1_err.c
1529
1530$(OBJ_D)\a_meth.obj: $(SRC_D)\crypto\asn1\a_meth.c
1531 $(CC) /Fo$(OBJ_D)\a_meth.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_meth.c
1532
1533$(OBJ_D)\a_bytes.obj: $(SRC_D)\crypto\asn1\a_bytes.c
1534 $(CC) /Fo$(OBJ_D)\a_bytes.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_bytes.c
1535
1536$(OBJ_D)\evp_asn1.obj: $(SRC_D)\crypto\asn1\evp_asn1.c
1537 $(CC) /Fo$(OBJ_D)\evp_asn1.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\evp_asn1.c
1538
1539$(OBJ_D)\x509_def.obj: $(SRC_D)\crypto\x509\x509_def.c
1540 $(CC) /Fo$(OBJ_D)\x509_def.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_def.c
1541
1542$(OBJ_D)\x509_d2.obj: $(SRC_D)\crypto\x509\x509_d2.c
1543 $(CC) /Fo$(OBJ_D)\x509_d2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_d2.c
1544
1545$(OBJ_D)\x509_r2x.obj: $(SRC_D)\crypto\x509\x509_r2x.c
1546 $(CC) /Fo$(OBJ_D)\x509_r2x.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_r2x.c
1547
1548$(OBJ_D)\x509_cmp.obj: $(SRC_D)\crypto\x509\x509_cmp.c
1549 $(CC) /Fo$(OBJ_D)\x509_cmp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_cmp.c
1550
1551$(OBJ_D)\x509_obj.obj: $(SRC_D)\crypto\x509\x509_obj.c
1552 $(CC) /Fo$(OBJ_D)\x509_obj.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_obj.c
1553
1554$(OBJ_D)\x509_req.obj: $(SRC_D)\crypto\x509\x509_req.c
1555 $(CC) /Fo$(OBJ_D)\x509_req.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_req.c
1556
1557$(OBJ_D)\x509_vfy.obj: $(SRC_D)\crypto\x509\x509_vfy.c
1558 $(CC) /Fo$(OBJ_D)\x509_vfy.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_vfy.c
1559
1560$(OBJ_D)\x509_set.obj: $(SRC_D)\crypto\x509\x509_set.c
1561 $(CC) /Fo$(OBJ_D)\x509_set.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_set.c
1562
1563$(OBJ_D)\x509rset.obj: $(SRC_D)\crypto\x509\x509rset.c
1564 $(CC) /Fo$(OBJ_D)\x509rset.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509rset.c
1565
1566$(OBJ_D)\x509_err.obj: $(SRC_D)\crypto\x509\x509_err.c
1567 $(CC) /Fo$(OBJ_D)\x509_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_err.c
1568
1569$(OBJ_D)\x509name.obj: $(SRC_D)\crypto\x509\x509name.c
1570 $(CC) /Fo$(OBJ_D)\x509name.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509name.c
1571
1572$(OBJ_D)\x509_v3.obj: $(SRC_D)\crypto\x509\x509_v3.c
1573 $(CC) /Fo$(OBJ_D)\x509_v3.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_v3.c
1574
1575$(OBJ_D)\x509_ext.obj: $(SRC_D)\crypto\x509\x509_ext.c
1576 $(CC) /Fo$(OBJ_D)\x509_ext.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_ext.c
1577
1578$(OBJ_D)\x509pack.obj: $(SRC_D)\crypto\x509\x509pack.c
1579 $(CC) /Fo$(OBJ_D)\x509pack.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509pack.c
1580
1581$(OBJ_D)\x509type.obj: $(SRC_D)\crypto\x509\x509type.c
1582 $(CC) /Fo$(OBJ_D)\x509type.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509type.c
1583
1584$(OBJ_D)\x509_lu.obj: $(SRC_D)\crypto\x509\x509_lu.c
1585 $(CC) /Fo$(OBJ_D)\x509_lu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_lu.c
1586
1587$(OBJ_D)\x_all.obj: $(SRC_D)\crypto\x509\x_all.c
1588 $(CC) /Fo$(OBJ_D)\x_all.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x_all.c
1589
1590$(OBJ_D)\x509_txt.obj: $(SRC_D)\crypto\x509\x509_txt.c
1591 $(CC) /Fo$(OBJ_D)\x509_txt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_txt.c
1592
1593$(OBJ_D)\by_file.obj: $(SRC_D)\crypto\x509\by_file.c
1594 $(CC) /Fo$(OBJ_D)\by_file.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\by_file.c
1595
1596$(OBJ_D)\by_dir.obj: $(SRC_D)\crypto\x509\by_dir.c
1597 $(CC) /Fo$(OBJ_D)\by_dir.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\by_dir.c
1598
1599$(OBJ_D)\v3_net.obj: $(SRC_D)\crypto\x509\v3_net.c
1600 $(CC) /Fo$(OBJ_D)\v3_net.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\v3_net.c
1601
1602$(OBJ_D)\v3_x509.obj: $(SRC_D)\crypto\x509\v3_x509.c
1603 $(CC) /Fo$(OBJ_D)\v3_x509.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\v3_x509.c
1604
1605$(OBJ_D)\conf.obj: $(SRC_D)\crypto\conf\conf.c
1606 $(CC) /Fo$(OBJ_D)\conf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\conf\conf.c
1607
1608$(OBJ_D)\conf_err.obj: $(SRC_D)\crypto\conf\conf_err.c
1609 $(CC) /Fo$(OBJ_D)\conf_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\conf\conf_err.c
1610
1611$(OBJ_D)\txt_db.obj: $(SRC_D)\crypto\txt_db\txt_db.c
1612 $(CC) /Fo$(OBJ_D)\txt_db.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\txt_db\txt_db.c
1613
1614$(OBJ_D)\pk7_lib.obj: $(SRC_D)\crypto\pkcs7\pk7_lib.c
1615 $(CC) /Fo$(OBJ_D)\pk7_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pkcs7\pk7_lib.c
1616
1617$(OBJ_D)\pkcs7err.obj: $(SRC_D)\crypto\pkcs7\pkcs7err.c
1618 $(CC) /Fo$(OBJ_D)\pkcs7err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pkcs7\pkcs7err.c
1619
1620$(OBJ_D)\pk7_doit.obj: $(SRC_D)\crypto\pkcs7\pk7_doit.c
1621 $(CC) /Fo$(OBJ_D)\pk7_doit.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pkcs7\pk7_doit.c
1622
1623$(OBJ_D)\s2_meth.obj: $(SRC_D)\ssl\s2_meth.c
1624 $(CC) /Fo$(OBJ_D)\s2_meth.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_meth.c
1625
1626$(OBJ_D)\s2_srvr.obj: $(SRC_D)\ssl\s2_srvr.c
1627 $(CC) /Fo$(OBJ_D)\s2_srvr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_srvr.c
1628
1629$(OBJ_D)\s2_clnt.obj: $(SRC_D)\ssl\s2_clnt.c
1630 $(CC) /Fo$(OBJ_D)\s2_clnt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_clnt.c
1631
1632$(OBJ_D)\s2_lib.obj: $(SRC_D)\ssl\s2_lib.c
1633 $(CC) /Fo$(OBJ_D)\s2_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_lib.c
1634
1635$(OBJ_D)\s2_enc.obj: $(SRC_D)\ssl\s2_enc.c
1636 $(CC) /Fo$(OBJ_D)\s2_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_enc.c
1637
1638$(OBJ_D)\s2_pkt.obj: $(SRC_D)\ssl\s2_pkt.c
1639 $(CC) /Fo$(OBJ_D)\s2_pkt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_pkt.c
1640
1641$(OBJ_D)\s3_meth.obj: $(SRC_D)\ssl\s3_meth.c
1642 $(CC) /Fo$(OBJ_D)\s3_meth.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_meth.c
1643
1644$(OBJ_D)\s3_srvr.obj: $(SRC_D)\ssl\s3_srvr.c
1645 $(CC) /Fo$(OBJ_D)\s3_srvr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_srvr.c
1646
1647$(OBJ_D)\s3_clnt.obj: $(SRC_D)\ssl\s3_clnt.c
1648 $(CC) /Fo$(OBJ_D)\s3_clnt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_clnt.c
1649
1650$(OBJ_D)\s3_lib.obj: $(SRC_D)\ssl\s3_lib.c
1651 $(CC) /Fo$(OBJ_D)\s3_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_lib.c
1652
1653$(OBJ_D)\s3_enc.obj: $(SRC_D)\ssl\s3_enc.c
1654 $(CC) /Fo$(OBJ_D)\s3_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_enc.c
1655
1656$(OBJ_D)\s3_pkt.obj: $(SRC_D)\ssl\s3_pkt.c
1657 $(CC) /Fo$(OBJ_D)\s3_pkt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_pkt.c
1658
1659$(OBJ_D)\s3_both.obj: $(SRC_D)\ssl\s3_both.c
1660 $(CC) /Fo$(OBJ_D)\s3_both.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_both.c
1661
1662$(OBJ_D)\s23_meth.obj: $(SRC_D)\ssl\s23_meth.c
1663 $(CC) /Fo$(OBJ_D)\s23_meth.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s23_meth.c
1664
1665$(OBJ_D)\s23_srvr.obj: $(SRC_D)\ssl\s23_srvr.c
1666 $(CC) /Fo$(OBJ_D)\s23_srvr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s23_srvr.c
1667
1668$(OBJ_D)\s23_clnt.obj: $(SRC_D)\ssl\s23_clnt.c
1669 $(CC) /Fo$(OBJ_D)\s23_clnt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s23_clnt.c
1670
1671$(OBJ_D)\s23_lib.obj: $(SRC_D)\ssl\s23_lib.c
1672 $(CC) /Fo$(OBJ_D)\s23_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s23_lib.c
1673
1674$(OBJ_D)\s23_pkt.obj: $(SRC_D)\ssl\s23_pkt.c
1675 $(CC) /Fo$(OBJ_D)\s23_pkt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s23_pkt.c
1676
1677$(OBJ_D)\t1_meth.obj: $(SRC_D)\ssl\t1_meth.c
1678 $(CC) /Fo$(OBJ_D)\t1_meth.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\t1_meth.c
1679
1680$(OBJ_D)\t1_srvr.obj: $(SRC_D)\ssl\t1_srvr.c
1681 $(CC) /Fo$(OBJ_D)\t1_srvr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\t1_srvr.c
1682
1683$(OBJ_D)\t1_clnt.obj: $(SRC_D)\ssl\t1_clnt.c
1684 $(CC) /Fo$(OBJ_D)\t1_clnt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\t1_clnt.c
1685
1686$(OBJ_D)\t1_lib.obj: $(SRC_D)\ssl\t1_lib.c
1687 $(CC) /Fo$(OBJ_D)\t1_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\t1_lib.c
1688
1689$(OBJ_D)\t1_enc.obj: $(SRC_D)\ssl\t1_enc.c
1690 $(CC) /Fo$(OBJ_D)\t1_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\t1_enc.c
1691
1692$(OBJ_D)\ssl_lib.obj: $(SRC_D)\ssl\ssl_lib.c
1693 $(CC) /Fo$(OBJ_D)\ssl_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_lib.c
1694
1695$(OBJ_D)\ssl_err2.obj: $(SRC_D)\ssl\ssl_err2.c
1696 $(CC) /Fo$(OBJ_D)\ssl_err2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_err2.c
1697
1698$(OBJ_D)\ssl_cert.obj: $(SRC_D)\ssl\ssl_cert.c
1699 $(CC) /Fo$(OBJ_D)\ssl_cert.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_cert.c
1700
1701$(OBJ_D)\ssl_sess.obj: $(SRC_D)\ssl\ssl_sess.c
1702 $(CC) /Fo$(OBJ_D)\ssl_sess.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_sess.c
1703
1704$(OBJ_D)\ssl_ciph.obj: $(SRC_D)\ssl\ssl_ciph.c
1705 $(CC) /Fo$(OBJ_D)\ssl_ciph.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_ciph.c
1706
1707$(OBJ_D)\ssl_stat.obj: $(SRC_D)\ssl\ssl_stat.c
1708 $(CC) /Fo$(OBJ_D)\ssl_stat.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_stat.c
1709
1710$(OBJ_D)\ssl_rsa.obj: $(SRC_D)\ssl\ssl_rsa.c
1711 $(CC) /Fo$(OBJ_D)\ssl_rsa.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_rsa.c
1712
1713$(OBJ_D)\ssl_asn1.obj: $(SRC_D)\ssl\ssl_asn1.c
1714 $(CC) /Fo$(OBJ_D)\ssl_asn1.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_asn1.c
1715
1716$(OBJ_D)\ssl_txt.obj: $(SRC_D)\ssl\ssl_txt.c
1717 $(CC) /Fo$(OBJ_D)\ssl_txt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_txt.c
1718
1719$(OBJ_D)\ssl_algs.obj: $(SRC_D)\ssl\ssl_algs.c
1720 $(CC) /Fo$(OBJ_D)\ssl_algs.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_algs.c
1721
1722$(OBJ_D)\bio_ssl.obj: $(SRC_D)\ssl\bio_ssl.c
1723 $(CC) /Fo$(OBJ_D)\bio_ssl.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\bio_ssl.c
1724
1725$(OBJ_D)\ssl_err.obj: $(SRC_D)\ssl\ssl_err.c
1726 $(CC) /Fo$(OBJ_D)\ssl_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_err.c
1727
1728$(OBJ_D)\rsaref.obj: $(SRC_D)\rsaref\rsaref.c
1729 $(CC) /Fo$(OBJ_D)\rsaref.obj $(LIB_CFLAGS) -c $(SRC_D)\rsaref\rsaref.c
1730
1731$(OBJ_D)\rsar_err.obj: $(SRC_D)\rsaref\rsar_err.c
1732 $(CC) /Fo$(OBJ_D)\rsar_err.obj $(LIB_CFLAGS) -c $(SRC_D)\rsaref\rsar_err.c
1733
1734$(TEST_D)\md2test.exe: $(OBJ_D)\md2test.obj $(LIBS_DEP)
1735 $(LINK) $(LFLAGS) /out:$(TEST_D)\md2test.exe @<<
1736 $(APP_EX_OBJ) $(OBJ_D)\md2test.obj $(L_LIBS) $(EX_LIBS)
1737<<
1738
1739$(TEST_D)\md5test.exe: $(OBJ_D)\md5test.obj $(LIBS_DEP)
1740 $(LINK) $(LFLAGS) /out:$(TEST_D)\md5test.exe @<<
1741 $(APP_EX_OBJ) $(OBJ_D)\md5test.obj $(L_LIBS) $(EX_LIBS)
1742<<
1743
1744$(TEST_D)\shatest.exe: $(OBJ_D)\shatest.obj $(LIBS_DEP)
1745 $(LINK) $(LFLAGS) /out:$(TEST_D)\shatest.exe @<<
1746 $(APP_EX_OBJ) $(OBJ_D)\shatest.obj $(L_LIBS) $(EX_LIBS)
1747<<
1748
1749$(TEST_D)\sha1test.exe: $(OBJ_D)\sha1test.obj $(LIBS_DEP)
1750 $(LINK) $(LFLAGS) /out:$(TEST_D)\sha1test.exe @<<
1751 $(APP_EX_OBJ) $(OBJ_D)\sha1test.obj $(L_LIBS) $(EX_LIBS)
1752<<
1753
1754$(TEST_D)\mdc2test.exe: $(OBJ_D)\mdc2test.obj $(LIBS_DEP)
1755 $(LINK) $(LFLAGS) /out:$(TEST_D)\mdc2test.exe @<<
1756 $(APP_EX_OBJ) $(OBJ_D)\mdc2test.obj $(L_LIBS) $(EX_LIBS)
1757<<
1758
1759$(TEST_D)\hmactest.exe: $(OBJ_D)\hmactest.obj $(LIBS_DEP)
1760 $(LINK) $(LFLAGS) /out:$(TEST_D)\hmactest.exe @<<
1761 $(APP_EX_OBJ) $(OBJ_D)\hmactest.obj $(L_LIBS) $(EX_LIBS)
1762<<
1763
1764$(TEST_D)\rmdtest.exe: $(OBJ_D)\rmdtest.obj $(LIBS_DEP)
1765 $(LINK) $(LFLAGS) /out:$(TEST_D)\rmdtest.exe @<<
1766 $(APP_EX_OBJ) $(OBJ_D)\rmdtest.obj $(L_LIBS) $(EX_LIBS)
1767<<
1768
1769$(TEST_D)\destest.exe: $(OBJ_D)\destest.obj $(LIBS_DEP)
1770 $(LINK) $(LFLAGS) /out:$(TEST_D)\destest.exe @<<
1771 $(APP_EX_OBJ) $(OBJ_D)\destest.obj $(L_LIBS) $(EX_LIBS)
1772<<
1773
1774$(TEST_D)\rc2test.exe: $(OBJ_D)\rc2test.obj $(LIBS_DEP)
1775 $(LINK) $(LFLAGS) /out:$(TEST_D)\rc2test.exe @<<
1776 $(APP_EX_OBJ) $(OBJ_D)\rc2test.obj $(L_LIBS) $(EX_LIBS)
1777<<
1778
1779$(TEST_D)\rc4test.exe: $(OBJ_D)\rc4test.obj $(LIBS_DEP)
1780 $(LINK) $(LFLAGS) /out:$(TEST_D)\rc4test.exe @<<
1781 $(APP_EX_OBJ) $(OBJ_D)\rc4test.obj $(L_LIBS) $(EX_LIBS)
1782<<
1783
1784$(TEST_D)\rc5test.exe: $(OBJ_D)\rc5test.obj $(LIBS_DEP)
1785 $(LINK) $(LFLAGS) /out:$(TEST_D)\rc5test.exe @<<
1786 $(APP_EX_OBJ) $(OBJ_D)\rc5test.obj $(L_LIBS) $(EX_LIBS)
1787<<
1788
1789$(TEST_D)\ideatest.exe: $(OBJ_D)\ideatest.obj $(LIBS_DEP)
1790 $(LINK) $(LFLAGS) /out:$(TEST_D)\ideatest.exe @<<
1791 $(APP_EX_OBJ) $(OBJ_D)\ideatest.obj $(L_LIBS) $(EX_LIBS)
1792<<
1793
1794$(TEST_D)\bftest.exe: $(OBJ_D)\bftest.obj $(LIBS_DEP)
1795 $(LINK) $(LFLAGS) /out:$(TEST_D)\bftest.exe @<<
1796 $(APP_EX_OBJ) $(OBJ_D)\bftest.obj $(L_LIBS) $(EX_LIBS)
1797<<
1798
1799$(TEST_D)\casttest.exe: $(OBJ_D)\casttest.obj $(LIBS_DEP)
1800 $(LINK) $(LFLAGS) /out:$(TEST_D)\casttest.exe @<<
1801 $(APP_EX_OBJ) $(OBJ_D)\casttest.obj $(L_LIBS) $(EX_LIBS)
1802<<
1803
1804$(TEST_D)\bntest.exe: $(OBJ_D)\bntest.obj $(LIBS_DEP)
1805 $(LINK) $(LFLAGS) /out:$(TEST_D)\bntest.exe @<<
1806 $(APP_EX_OBJ) $(OBJ_D)\bntest.obj $(L_LIBS) $(EX_LIBS)
1807<<
1808
1809$(TEST_D)\exptest.exe: $(OBJ_D)\exptest.obj $(LIBS_DEP)
1810 $(LINK) $(LFLAGS) /out:$(TEST_D)\exptest.exe @<<
1811 $(APP_EX_OBJ) $(OBJ_D)\exptest.obj $(L_LIBS) $(EX_LIBS)
1812<<
1813
1814$(TEST_D)\dsatest.exe: $(OBJ_D)\dsatest.obj $(LIBS_DEP)
1815 $(LINK) $(LFLAGS) /out:$(TEST_D)\dsatest.exe @<<
1816 $(APP_EX_OBJ) $(OBJ_D)\dsatest.obj $(L_LIBS) $(EX_LIBS)
1817<<
1818
1819$(TEST_D)\dhtest.exe: $(OBJ_D)\dhtest.obj $(LIBS_DEP)
1820 $(LINK) $(LFLAGS) /out:$(TEST_D)\dhtest.exe @<<
1821 $(APP_EX_OBJ) $(OBJ_D)\dhtest.obj $(L_LIBS) $(EX_LIBS)
1822<<
1823
1824$(TEST_D)\randtest.exe: $(OBJ_D)\randtest.obj $(LIBS_DEP)
1825 $(LINK) $(LFLAGS) /out:$(TEST_D)\randtest.exe @<<
1826 $(APP_EX_OBJ) $(OBJ_D)\randtest.obj $(L_LIBS) $(EX_LIBS)
1827<<
1828
1829$(TEST_D)\ssltest.exe: $(OBJ_D)\ssltest.obj $(LIBS_DEP)
1830 $(LINK) $(LFLAGS) /out:$(TEST_D)\ssltest.exe @<<
1831 $(APP_EX_OBJ) $(OBJ_D)\ssltest.obj $(L_LIBS) $(EX_LIBS)
1832<<
1833
1834$(O_SSL): $(SSLOBJ)
1835 $(LINK) $(MLFLAGS) /out:$(O_SSL) /def:ms/SSLEAY32.def @<<
1836 $(SHLIB_EX_OBJ) $(SSLOBJ) $(L_CRYPTO) wsock32.lib gdi32.lib
1837<<
1838
1839$(O_RSAGLUE): $(RSAGLUEOBJ)
1840 $(MKLIB) /out:$(O_RSAGLUE) @<<
1841 $(RSAGLUEOBJ)
1842<<
1843
1844$(O_CRYPTO): $(CRYPTOOBJ)
1845 $(LINK) $(MLFLAGS) /out:$(O_CRYPTO) /def:ms/LIBEAY32.def @<<
1846 $(SHLIB_EX_OBJ) $(CRYPTOOBJ) wsock32.lib gdi32.lib
1847<<
1848
1849$(BIN_D)\$(E_EXE).exe: $(E_OBJ) $(LIBS_DEP)
1850 $(LINK) $(LFLAGS) /out:$(BIN_D)\$(E_EXE).exe @<<
1851 $(APP_EX_OBJ) $(E_OBJ) $(L_LIBS) $(EX_LIBS)
1852<<
1853
diff --git a/src/lib/libssl/src/ms/ssleay16.def b/src/lib/libssl/src/ms/ssleay16.def
new file mode 100644
index 0000000000..2c61644308
--- /dev/null
+++ b/src/lib/libssl/src/ms/ssleay16.def
@@ -0,0 +1,171 @@
1;
2; Definition file for the DDL version of the SSLEAY16 library from SSLeay
3;
4
5LIBRARY SSLEAY16
6
7DESCRIPTION 'SSLeay SSLEAY16 - eay@cryptsoft.com'
8
9CODE PRELOAD MOVEABLE
10DATA PRELOAD MOVEABLE SINGLE
11
12EXETYPE WINDOWS
13
14HEAPSIZE 4096
15STACKSIZE 8192
16
17EXPORTS
18 _SSLeay_add_ssl_algorithms @109
19 _BIO_f_ssl @121
20 _BIO_new_buffer_ssl_connect @173
21 _BIO_new_ssl @122
22 _BIO_new_ssl_connect @174
23 _BIO_ssl_copy_session_id @124
24 _BIO_ssl_shutdown @131
25 _ERR_load_SSL_strings @1
26 _SSL_CIPHER_description @2
27 _SSL_CIPHER_get_bits @128
28 _SSL_CIPHER_get_name @130
29 _SSL_CIPHER_get_version @129
30 _SSL_CTX_add_client_CA @3
31 _SSL_CTX_add_session @4
32 _SSL_CTX_check_private_key @5
33 _SSL_CTX_ctrl @6
34 _SSL_CTX_flush_sessions @7
35 _SSL_CTX_free @8
36 _SSL_CTX_get_client_CA_list @9
37 _SSL_CTX_get_ex_data @138
38 _SSL_CTX_get_ex_new_index @167
39 _SSL_CTX_get_quiet_shutdown @140
40 _SSL_CTX_get_verify_callback @10
41 _SSL_CTX_get_verify_mode @11
42 _SSL_CTX_load_verify_locations @141
43 _SSL_CTX_new @12
44 _SSL_CTX_remove_session @13
45 _SSL_CTX_set_cert_verify_cb @14
46 _SSL_CTX_set_cipher_list @15
47 _SSL_CTX_set_client_CA_list @16
48 _SSL_CTX_set_default_passwd_cb @17
49 _SSL_CTX_set_default_verify_paths @142
50 _SSL_CTX_set_ex_data @143
51 _SSL_CTX_set_quiet_shutdown @145
52 _SSL_CTX_set_ssl_version @19
53 _SSL_CTX_set_verify @21
54 _SSL_CTX_use_PrivateKey @22
55 _SSL_CTX_use_PrivateKey_ASN1 @23
56 _SSL_CTX_use_PrivateKey_file @24
57 _SSL_CTX_use_RSAPrivateKey @25
58 _SSL_CTX_use_RSAPrivateKey_ASN1 @26
59 _SSL_CTX_use_RSAPrivateKey_file @27
60 _SSL_CTX_use_certificate @28
61 _SSL_CTX_use_certificate_ASN1 @29
62 _SSL_CTX_use_certificate_file @30
63 _SSL_SESSION_cmp @132
64 _SSL_SESSION_free @31
65 _SSL_SESSION_get_ex_data @146
66 _SSL_SESSION_get_ex_new_index @168
67 _SSL_SESSION_get_time @134
68 _SSL_SESSION_get_timeout @136
69 _SSL_SESSION_hash @133
70 _SSL_SESSION_new @32
71 _SSL_SESSION_print @33
72 _SSL_SESSION_set_ex_data @148
73 _SSL_SESSION_set_time @135
74 _SSL_SESSION_set_timeout @137
75 _SSL_accept @35
76 _SSL_add_client_CA @36
77 _SSL_alert_desc_string @37
78 _SSL_alert_desc_string_long @38
79 _SSL_alert_type_string @39
80 _SSL_alert_type_string_long @40
81 _SSL_check_private_key @41
82 _SSL_clear @42
83 _SSL_connect @43
84 _SSL_copy_session_id @44
85 _SSL_ctrl @45
86 _SSL_do_handshake @125
87 _SSL_dup @46
88 _SSL_dup_CA_list @47
89 _SSL_free @48
90 _SSL_get_SSL_CTX @150
91 _SSL_get_certificate @49
92 _SSL_get_cipher_list @52
93 _SSL_get_ciphers @55
94 _SSL_get_client_CA_list @56
95 _SSL_get_current_cipher @127
96 _SSL_get_default_timeout @57
97 _SSL_get_error @58
98 _SSL_get_ex_data @151
99 _SSL_get_ex_new_index @169
100 _SSL_get_fd @59
101 _SSL_get_info_callback @165
102 _SSL_get_peer_cert_chain @60
103 _SSL_get_peer_certificate @61
104 _SSL_get_privatekey @126
105 _SSL_get_quiet_shutdown @153
106 _SSL_get_rbio @63
107 _SSL_get_read_ahead @64
108 _SSL_get_session @154
109 _SSL_get_shared_ciphers @65
110 _SSL_get_shutdown @155
111 _SSL_get_ssl_method @66
112 _SSL_get_verify_mode @70
113 _SSL_get_verify_result @157
114 _SSL_get_version @71
115 _SSL_get_wbio @72
116 _SSL_load_client_CA_file @73
117 _SSL_load_error_strings @74
118 _SSL_new @75
119 _SSL_peek @76
120 _SSL_pending @77
121 _SSL_read @78
122 _SSL_renegotiate @79
123 _SSL_rstate_string @80
124 _SSL_rstate_string_long @81
125 _SSL_set_accept_state @82
126 _SSL_set_bio @83
127 _SSL_set_cipher_list @84
128 _SSL_set_client_CA_list @85
129 _SSL_set_connect_state @86
130 _SSL_set_ex_data @158
131 _SSL_set_fd @87
132 _SSL_set_info_callback @160
133 _SSL_set_quiet_shutdown @161
134 _SSL_set_read_ahead @88
135 _SSL_set_rfd @89
136 _SSL_set_session @90
137 _SSL_set_shutdown @162
138 _SSL_set_ssl_method @91
139 _SSL_set_verify @94
140 _SSL_set_verify_result @163
141 _SSL_set_wfd @95
142 _SSL_shutdown @96
143 _SSL_state @166
144 _SSL_state_string @97
145 _SSL_state_string_long @98
146 _SSL_use_PrivateKey @99
147 _SSL_use_PrivateKey_ASN1 @100
148 _SSL_use_PrivateKey_file @101
149 _SSL_use_RSAPrivateKey @102
150 _SSL_use_RSAPrivateKey_ASN1 @103
151 _SSL_use_RSAPrivateKey_file @104
152 _SSL_use_certificate @105
153 _SSL_use_certificate_ASN1 @106
154 _SSL_use_certificate_file @107
155 _SSL_version @164
156 _SSL_write @108
157 _SSLv23_client_method @110
158 _SSLv23_method @111
159 _SSLv23_server_method @112
160 _SSLv2_client_method @113
161 _SSLv2_method @114
162 _SSLv2_server_method @115
163 _SSLv3_client_method @116
164 _SSLv3_method @117
165 _SSLv3_server_method @118
166 _TLSv1_client_method @172
167 _TLSv1_method @170
168 _TLSv1_server_method @171
169 _d2i_SSL_SESSION @119
170 _i2d_SSL_SESSION @120
171
diff --git a/src/lib/libssl/src/ms/ssleay32.def b/src/lib/libssl/src/ms/ssleay32.def
new file mode 100644
index 0000000000..aa823b8069
--- /dev/null
+++ b/src/lib/libssl/src/ms/ssleay32.def
@@ -0,0 +1,164 @@
1;
2; Definition file for the DDL version of the SSLEAY32 library from SSLeay
3;
4
5LIBRARY SSLEAY32
6
7DESCRIPTION 'SSLeay SSLEAY32 - eay@cryptsoft.com'
8
9EXPORTS
10 SSLeay_add_ssl_algorithms @109
11 BIO_f_ssl @121
12 BIO_new_buffer_ssl_connect @173
13 BIO_new_ssl @122
14 BIO_new_ssl_connect @174
15 BIO_ssl_copy_session_id @124
16 BIO_ssl_shutdown @131
17 ERR_load_SSL_strings @1
18 SSL_CIPHER_description @2
19 SSL_CIPHER_get_bits @128
20 SSL_CIPHER_get_name @130
21 SSL_CIPHER_get_version @129
22 SSL_CTX_add_client_CA @3
23 SSL_CTX_add_session @4
24 SSL_CTX_check_private_key @5
25 SSL_CTX_ctrl @6
26 SSL_CTX_flush_sessions @7
27 SSL_CTX_free @8
28 SSL_CTX_get_client_CA_list @9
29 SSL_CTX_get_ex_data @138
30 SSL_CTX_get_ex_new_index @167
31 SSL_CTX_get_quiet_shutdown @140
32 SSL_CTX_get_verify_callback @10
33 SSL_CTX_get_verify_mode @11
34 SSL_CTX_load_verify_locations @141
35 SSL_CTX_new @12
36 SSL_CTX_remove_session @13
37 SSL_CTX_set_cert_verify_cb @14
38 SSL_CTX_set_cipher_list @15
39 SSL_CTX_set_client_CA_list @16
40 SSL_CTX_set_default_passwd_cb @17
41 SSL_CTX_set_default_verify_paths @142
42 SSL_CTX_set_ex_data @143
43 SSL_CTX_set_quiet_shutdown @145
44 SSL_CTX_set_ssl_version @19
45 SSL_CTX_set_verify @21
46 SSL_CTX_use_PrivateKey @22
47 SSL_CTX_use_PrivateKey_ASN1 @23
48 SSL_CTX_use_PrivateKey_file @24
49 SSL_CTX_use_RSAPrivateKey @25
50 SSL_CTX_use_RSAPrivateKey_ASN1 @26
51 SSL_CTX_use_RSAPrivateKey_file @27
52 SSL_CTX_use_certificate @28
53 SSL_CTX_use_certificate_ASN1 @29
54 SSL_CTX_use_certificate_file @30
55 SSL_SESSION_cmp @132
56 SSL_SESSION_free @31
57 SSL_SESSION_get_ex_data @146
58 SSL_SESSION_get_ex_new_index @168
59 SSL_SESSION_get_time @134
60 SSL_SESSION_get_timeout @136
61 SSL_SESSION_hash @133
62 SSL_SESSION_new @32
63 SSL_SESSION_print @33
64 SSL_SESSION_print_fp @34
65 SSL_SESSION_set_ex_data @148
66 SSL_SESSION_set_time @135
67 SSL_SESSION_set_timeout @137
68 SSL_accept @35
69 SSL_add_client_CA @36
70 SSL_alert_desc_string @37
71 SSL_alert_desc_string_long @38
72 SSL_alert_type_string @39
73 SSL_alert_type_string_long @40
74 SSL_check_private_key @41
75 SSL_clear @42
76 SSL_connect @43
77 SSL_copy_session_id @44
78 SSL_ctrl @45
79 SSL_do_handshake @125
80 SSL_dup @46
81 SSL_dup_CA_list @47
82 SSL_free @48
83 SSL_get_SSL_CTX @150
84 SSL_get_certificate @49
85 SSL_get_cipher_list @52
86 SSL_get_ciphers @55
87 SSL_get_client_CA_list @56
88 SSL_get_current_cipher @127
89 SSL_get_default_timeout @57
90 SSL_get_error @58
91 SSL_get_ex_data @151
92 SSL_get_ex_new_index @169
93 SSL_get_fd @59
94 SSL_get_info_callback @165
95 SSL_get_peer_cert_chain @60
96 SSL_get_peer_certificate @61
97 SSL_get_privatekey @126
98 SSL_get_quiet_shutdown @153
99 SSL_get_rbio @63
100 SSL_get_read_ahead @64
101 SSL_get_session @154
102 SSL_get_shared_ciphers @65
103 SSL_get_shutdown @155
104 SSL_get_ssl_method @66
105 SSL_get_verify_mode @70
106 SSL_get_verify_result @157
107 SSL_get_version @71
108 SSL_get_wbio @72
109 SSL_load_client_CA_file @73
110 SSL_load_error_strings @74
111 SSL_new @75
112 SSL_peek @76
113 SSL_pending @77
114 SSL_read @78
115 SSL_renegotiate @79
116 SSL_rstate_string @80
117 SSL_rstate_string_long @81
118 SSL_set_accept_state @82
119 SSL_set_bio @83
120 SSL_set_cipher_list @84
121 SSL_set_client_CA_list @85
122 SSL_set_connect_state @86
123 SSL_set_ex_data @158
124 SSL_set_fd @87
125 SSL_set_info_callback @160
126 SSL_set_quiet_shutdown @161
127 SSL_set_read_ahead @88
128 SSL_set_rfd @89
129 SSL_set_session @90
130 SSL_set_shutdown @162
131 SSL_set_ssl_method @91
132 SSL_set_verify @94
133 SSL_set_verify_result @163
134 SSL_set_wfd @95
135 SSL_shutdown @96
136 SSL_state @166
137 SSL_state_string @97
138 SSL_state_string_long @98
139 SSL_use_PrivateKey @99
140 SSL_use_PrivateKey_ASN1 @100
141 SSL_use_PrivateKey_file @101
142 SSL_use_RSAPrivateKey @102
143 SSL_use_RSAPrivateKey_ASN1 @103
144 SSL_use_RSAPrivateKey_file @104
145 SSL_use_certificate @105
146 SSL_use_certificate_ASN1 @106
147 SSL_use_certificate_file @107
148 SSL_version @164
149 SSL_write @108
150 SSLv23_client_method @110
151 SSLv23_method @111
152 SSLv23_server_method @112
153 SSLv2_client_method @113
154 SSLv2_method @114
155 SSLv2_server_method @115
156 SSLv3_client_method @116
157 SSLv3_method @117
158 SSLv3_server_method @118
159 TLSv1_client_method @172
160 TLSv1_method @170
161 TLSv1_server_method @171
162 d2i_SSL_SESSION @119
163 i2d_SSL_SESSION @120
164
diff --git a/src/lib/libssl/src/ms/w31dll.mak b/src/lib/libssl/src/ms/w31dll.mak
new file mode 100644
index 0000000000..6821d82604
--- /dev/null
+++ b/src/lib/libssl/src/ms/w31dll.mak
@@ -0,0 +1,2295 @@
1# This makefile has been automatically generated from the SSLeay distribution.
2# This single makefile will build the complete SSLeay distribution and
3# by default leave the 'intertesting' output files in .\out and the stuff
4# that needs deleting in .\tmp.
5# The file was generated by running 'make makefile.one', which
6# does a 'make files', which writes all the environment variables from all
7# the makefiles to the file call MINFO. This file is used by
8# util\mk1mf.pl to generate makefile.one.
9# The 'makefile per directory' system suites me when developing this
10# library and also so I can 'distribute' indervidual library sections.
11# The one monster makefile better suits building in non-unix
12# environments.
13
14INSTALLTOP=\usr\local\ssl
15
16# Set your compiler options
17CC=cl
18CFLAG=/ALw /Gx- /Gt256 /Gf /G2 /f- /Ocgnotb2 /W3 /WX -DL_ENDIAN /nologo -DWINDOWS -DWIN16
19APP_CFLAG=/Gw /FPi87
20LIB_CFLAG=/Gw -D_WINDLL -D_DLL
21SHLIB_CFLAG=
22APP_EX_OBJ=setargv.obj
23SHLIB_EX_OBJ=
24# add extra libraries to this define, for solaris -lsocket -lnsl would
25# be added
26EX_LIBS=oldnames llibcewq libw winsock
27
28# The SSLeay directory
29SRC_D=.
30
31LINK=link
32LFLAGS= /FARCALL /NOLOGO /NOD /SEG:1024 /ONERROR:NOEXE /NOE /PACKC:60000 /PACKD:60000 /STACK:20000 /ALIGN:256
33
34BN_MULW_OBJ=crypto\bn\asm\x86w32.obj
35BN_MULW_SRC=crypto\bn\asm\x86w32.asm
36DES_ENC_OBJ=
37DES_ENC_SRC=
38DES_CRYPT_OBJ=
39DES_CRYPT_SRC=
40BF_ENC_OBJ=
41BF_ENC_SRC=
42CAST_ENC_OBJ=
43CAST_ENC_SRC=
44RC4_ENC_OBJ=
45RC4_ENC_SRC=
46RC5_ENC_OBJ=
47RC5_ENC_SRC=
48MD5_ASM_OBJ=
49MD5_ASM_SRC=
50SHA1_ASM_OBJ=
51SHA1_ASM_SRC=
52RMD160_ASM_OBJ=
53RMD160_ASM_SRC=
54
55# The output directory for everything intersting
56OUT_D=out16dll
57# The output directory for all the temporary muck
58TMP_D=tmp16dll
59# The output directory for the header files
60INC_D=inc16
61
62CP=copy
63RM=del
64RANLIB=
65MKDIR=mkdir
66MKLIB=lib /PAGESIZE:1024
67MLFLAGS= /FARCALL /NOLOGO /NOD /SEG:1024 /ONERROR:NOEXE /NOE /PACKC:60000 /PACKD:60000
68ASM=ml /Cp /c /Cx
69
70######################################################
71# You should not need to touch anything below this point
72######################################################
73
74E_EXE=ssleay
75SSL=ssleay16
76CRYPTO=libeay16
77RSAGLUE=RSAglue
78
79# BIN_D - Binary output directory
80# TEST_D - Binary test file output directory
81# LIB_D - library output directory
82BIN_D=$(OUT_D)
83TEST_D=$(OUT_D)
84LIB_D=$(OUT_D)
85
86# INCL_D - local library directory
87# OBJ_D - temp object file directory
88OBJ_D=$(TMP_D)
89INCL_D=$(TMP_D)
90
91O_SSL= $(LIB_D)\$(SSL).dll
92O_CRYPTO= $(LIB_D)\$(CRYPTO).dll
93O_RSAGLUE= $(LIB_D)\$(RSAGLUE).lib
94SO_SSL= $(SSL)
95SO_CRYPTO= $(CRYPTO)
96L_SSL= $(LIB_D)\$(SSL).lib
97L_CRYPTO= $(LIB_D)\$(CRYPTO).lib
98
99L_LIBS= $(L_SSL) $(L_CRYPTO)
100#L_LIBS= $(O_SSL) $(O_RSAGLUE) -lrsaref $(O_CRYPTO)
101
102######################################################
103# Don't touch anything below this point
104######################################################
105
106INC=-I$(INC_D) -I$(INCL_D)
107APP_CFLAGS=$(INC) $(CFLAG) $(APP_CFLAG)
108LIB_CFLAGS=$(INC) $(CFLAG) $(LIB_CFLAG)
109SHLIB_CFLAGS=$(INC) $(CFLAG) $(LIB_CFLAG) $(SHLIB_CFLAG)
110LIBS_DEP=$(O_CRYPTO) $(O_RSAGLUE) $(O_SSL)
111
112#############################################
113HEADER=$(INCL_D)\cryptlib.h \
114 $(INCL_D)\date.h $(INCL_D)\md5_locl.h $(INCL_D)\sha_locl.h \
115 $(INCL_D)\rmd_locl.h $(INCL_D)\rmdconst.h $(INCL_D)\des_locl.h \
116 $(INCL_D)\rpc_des.h $(INCL_D)\podd.h $(INCL_D)\sk.h \
117 $(INCL_D)\spr.h $(INCL_D)\des_ver.h $(INCL_D)\rc2_locl.h \
118 $(INCL_D)\rc4_locl.h $(INCL_D)\rc5_locl.h $(INCL_D)\idea_lcl.h \
119 $(INCL_D)\bf_pi.h $(INCL_D)\bf_locl.h $(INCL_D)\cast_s.h \
120 $(INCL_D)\cast_lcl.h $(INCL_D)\bn_lcl.h $(INCL_D)\bn_prime.h \
121 $(INCL_D)\obj_dat.h $(INCL_D)\conf_lcl.h $(INCL_D)\ssl_locl.h \
122 $(INCL_D)\rsaref.h $(INCL_D)\apps.h $(INCL_D)\progs.h \
123 $(INCL_D)\s_apps.h $(INCL_D)\testdsa.h $(INCL_D)\testrsa.h
124
125EXHEADER=$(INC_D)\e_os.h \
126 $(INC_D)\crypto.h $(INC_D)\cryptall.h $(INC_D)\md2.h \
127 $(INC_D)\md5.h $(INC_D)\sha.h $(INC_D)\mdc2.h \
128 $(INC_D)\hmac.h $(INC_D)\ripemd.h $(INC_D)\des.h \
129 $(INC_D)\rc2.h $(INC_D)\rc4.h $(INC_D)\rc5.h \
130 $(INC_D)\idea.h $(INC_D)\blowfish.h $(INC_D)\cast.h \
131 $(INC_D)\bn.h $(INC_D)\rsa.h $(INC_D)\dsa.h \
132 $(INC_D)\dh.h $(INC_D)\buffer.h $(INC_D)\bio.h \
133 $(INC_D)\bss_file.c $(INC_D)\stack.h $(INC_D)\lhash.h \
134 $(INC_D)\rand.h $(INC_D)\err.h $(INC_D)\objects.h \
135 $(INC_D)\evp.h $(INC_D)\pem.h $(INC_D)\asn1.h \
136 $(INC_D)\asn1_mac.h $(INC_D)\x509.h $(INC_D)\x509_vfy.h \
137 $(INC_D)\conf.h $(INC_D)\txt_db.h $(INC_D)\pkcs7.h \
138 $(INC_D)\ssl.h $(INC_D)\ssl2.h $(INC_D)\ssl3.h \
139 $(INC_D)\ssl23.h $(INC_D)\tls1.h
140
141T_OBJ=$(OBJ_D)\md2test.obj \
142 $(OBJ_D)\md5test.obj $(OBJ_D)\shatest.obj $(OBJ_D)\sha1test.obj \
143 $(OBJ_D)\mdc2test.obj $(OBJ_D)\hmactest.obj $(OBJ_D)\rmdtest.obj \
144 $(OBJ_D)\destest.obj $(OBJ_D)\rc2test.obj $(OBJ_D)\rc4test.obj \
145 $(OBJ_D)\rc5test.obj $(OBJ_D)\ideatest.obj $(OBJ_D)\bftest.obj \
146 $(OBJ_D)\casttest.obj $(OBJ_D)\bntest.obj $(OBJ_D)\exptest.obj \
147 $(OBJ_D)\dsatest.obj $(OBJ_D)\dhtest.obj $(OBJ_D)\randtest.obj \
148 $(OBJ_D)\ssltest.obj
149
150E_OBJ=$(OBJ_D)\verify.obj \
151 $(OBJ_D)\asn1pars.obj $(OBJ_D)\req.obj $(OBJ_D)\dgst.obj \
152 $(OBJ_D)\dh.obj $(OBJ_D)\enc.obj $(OBJ_D)\gendh.obj \
153 $(OBJ_D)\errstr.obj $(OBJ_D)\ca.obj $(OBJ_D)\pkcs7.obj \
154 $(OBJ_D)\crl2p7.obj $(OBJ_D)\crl.obj $(OBJ_D)\rsa.obj \
155 $(OBJ_D)\dsa.obj $(OBJ_D)\dsaparam.obj $(OBJ_D)\x509.obj \
156 $(OBJ_D)\genrsa.obj $(OBJ_D)\s_server.obj $(OBJ_D)\s_client.obj \
157 $(OBJ_D)\speed.obj $(OBJ_D)\s_time.obj $(OBJ_D)\apps.obj \
158 $(OBJ_D)\s_cb.obj $(OBJ_D)\s_socket.obj $(OBJ_D)\version.obj \
159 $(OBJ_D)\sess_id.obj $(OBJ_D)\ciphers.obj $(OBJ_D)\ssleay.obj
160
161CRYPTOOBJ=$(OBJ_D)\cryptlib.obj \
162 $(OBJ_D)\mem.obj $(OBJ_D)\cversion.obj $(OBJ_D)\ex_data.obj \
163 $(OBJ_D)\cpt_err.obj $(OBJ_D)\md2_dgst.obj $(OBJ_D)\md2_one.obj \
164 $(OBJ_D)\md5_dgst.obj $(OBJ_D)\md5_one.obj $(OBJ_D)\sha_dgst.obj \
165 $(OBJ_D)\sha1dgst.obj $(OBJ_D)\sha_one.obj $(OBJ_D)\sha1_one.obj \
166 $(OBJ_D)\mdc2dgst.obj $(OBJ_D)\mdc2_one.obj $(OBJ_D)\hmac.obj \
167 $(OBJ_D)\rmd_dgst.obj $(OBJ_D)\rmd_one.obj $(OBJ_D)\set_key.obj \
168 $(OBJ_D)\ecb_enc.obj $(OBJ_D)\cbc_enc.obj $(OBJ_D)\ecb3_enc.obj \
169 $(OBJ_D)\cfb64enc.obj $(OBJ_D)\cfb64ede.obj $(OBJ_D)\cfb_enc.obj \
170 $(OBJ_D)\ofb64ede.obj $(OBJ_D)\enc_read.obj $(OBJ_D)\enc_writ.obj \
171 $(OBJ_D)\ofb64enc.obj $(OBJ_D)\ofb_enc.obj $(OBJ_D)\str2key.obj \
172 $(OBJ_D)\pcbc_enc.obj $(OBJ_D)\qud_cksm.obj $(OBJ_D)\rand_key.obj \
173 $(OBJ_D)\des_enc.obj $(OBJ_D)\fcrypt_b.obj $(OBJ_D)\read2pwd.obj \
174 $(OBJ_D)\fcrypt.obj $(OBJ_D)\xcbc_enc.obj $(OBJ_D)\read_pwd.obj \
175 $(OBJ_D)\rpc_enc.obj $(OBJ_D)\cbc_cksm.obj $(OBJ_D)\supp.obj \
176 $(OBJ_D)\rc2_ecb.obj $(OBJ_D)\rc2_skey.obj $(OBJ_D)\rc2_cbc.obj \
177 $(OBJ_D)\rc2cfb64.obj $(OBJ_D)\rc2ofb64.obj $(OBJ_D)\rc4_skey.obj \
178 $(OBJ_D)\rc4_enc.obj $(OBJ_D)\rc5_skey.obj $(OBJ_D)\rc5_ecb.obj \
179 $(OBJ_D)\rc5_enc.obj $(OBJ_D)\rc5cfb64.obj $(OBJ_D)\rc5ofb64.obj \
180 $(OBJ_D)\i_cbc.obj $(OBJ_D)\i_cfb64.obj $(OBJ_D)\i_ofb64.obj \
181 $(OBJ_D)\i_ecb.obj $(OBJ_D)\i_skey.obj $(OBJ_D)\bf_skey.obj \
182 $(OBJ_D)\bf_ecb.obj $(OBJ_D)\bf_enc.obj $(OBJ_D)\bf_cfb64.obj \
183 $(OBJ_D)\bf_ofb64.obj $(OBJ_D)\c_skey.obj $(OBJ_D)\c_ecb.obj \
184 $(OBJ_D)\c_enc.obj $(OBJ_D)\c_cfb64.obj $(OBJ_D)\c_ofb64.obj \
185 $(OBJ_D)\bn_add.obj $(OBJ_D)\bn_div.obj $(OBJ_D)\bn_exp.obj \
186 $(OBJ_D)\bn_lib.obj $(OBJ_D)\bn_mod.obj $(OBJ_D)\bn_mul.obj \
187 $(OBJ_D)\bn_print.obj $(OBJ_D)\bn_rand.obj $(OBJ_D)\bn_shift.obj \
188 $(OBJ_D)\bn_sub.obj $(OBJ_D)\bn_word.obj $(OBJ_D)\bn_blind.obj \
189 $(OBJ_D)\bn_gcd.obj $(OBJ_D)\bn_prime.obj $(OBJ_D)\bn_err.obj \
190 $(OBJ_D)\bn_sqr.obj $(BN_MULW_OBJ) $(OBJ_D)\bn_recp.obj \
191 $(OBJ_D)\bn_mont.obj $(OBJ_D)\bn_mpi.obj $(OBJ_D)\rsa_eay.obj \
192 $(OBJ_D)\rsa_gen.obj $(OBJ_D)\rsa_lib.obj $(OBJ_D)\rsa_sign.obj \
193 $(OBJ_D)\rsa_saos.obj $(OBJ_D)\rsa_err.obj $(OBJ_D)\rsa_pk1.obj \
194 $(OBJ_D)\rsa_ssl.obj $(OBJ_D)\rsa_none.obj $(OBJ_D)\dsa_gen.obj \
195 $(OBJ_D)\dsa_key.obj $(OBJ_D)\dsa_lib.obj $(OBJ_D)\dsa_vrf.obj \
196 $(OBJ_D)\dsa_sign.obj $(OBJ_D)\dsa_err.obj $(OBJ_D)\dh_gen.obj \
197 $(OBJ_D)\dh_key.obj $(OBJ_D)\dh_lib.obj $(OBJ_D)\dh_check.obj \
198 $(OBJ_D)\dh_err.obj $(OBJ_D)\buffer.obj $(OBJ_D)\buf_err.obj \
199 $(OBJ_D)\bio_lib.obj $(OBJ_D)\bio_cb.obj $(OBJ_D)\bio_err.obj \
200 $(OBJ_D)\bss_mem.obj $(OBJ_D)\bss_null.obj $(OBJ_D)\bss_fd.obj \
201 $(OBJ_D)\bss_file.obj $(OBJ_D)\bss_sock.obj $(OBJ_D)\bss_conn.obj \
202 $(OBJ_D)\bf_null.obj $(OBJ_D)\bf_buff.obj $(OBJ_D)\b_print.obj \
203 $(OBJ_D)\b_dump.obj $(OBJ_D)\b_sock.obj $(OBJ_D)\bss_acpt.obj \
204 $(OBJ_D)\bf_nbio.obj $(OBJ_D)\stack.obj $(OBJ_D)\lhash.obj \
205 $(OBJ_D)\lh_stats.obj $(OBJ_D)\md_rand.obj $(OBJ_D)\randfile.obj \
206 $(OBJ_D)\err.obj $(OBJ_D)\err_all.obj $(OBJ_D)\err_prn.obj \
207 $(OBJ_D)\obj_dat.obj $(OBJ_D)\obj_lib.obj $(OBJ_D)\obj_err.obj \
208 $(OBJ_D)\encode.obj $(OBJ_D)\digest.obj $(OBJ_D)\evp_enc.obj \
209 $(OBJ_D)\evp_key.obj $(OBJ_D)\e_ecb_d.obj $(OBJ_D)\e_cbc_d.obj \
210 $(OBJ_D)\e_cfb_d.obj $(OBJ_D)\e_ofb_d.obj $(OBJ_D)\e_ecb_i.obj \
211 $(OBJ_D)\e_cbc_i.obj $(OBJ_D)\e_cfb_i.obj $(OBJ_D)\e_ofb_i.obj \
212 $(OBJ_D)\e_ecb_3d.obj $(OBJ_D)\e_cbc_3d.obj $(OBJ_D)\e_rc4.obj \
213 $(OBJ_D)\names.obj $(OBJ_D)\e_cfb_3d.obj $(OBJ_D)\e_ofb_3d.obj \
214 $(OBJ_D)\e_xcbc_d.obj $(OBJ_D)\e_ecb_r2.obj $(OBJ_D)\e_cbc_r2.obj \
215 $(OBJ_D)\e_cfb_r2.obj $(OBJ_D)\e_ofb_r2.obj $(OBJ_D)\e_ecb_bf.obj \
216 $(OBJ_D)\e_cbc_bf.obj $(OBJ_D)\e_cfb_bf.obj $(OBJ_D)\e_ofb_bf.obj \
217 $(OBJ_D)\e_ecb_c.obj $(OBJ_D)\e_cbc_c.obj $(OBJ_D)\e_cfb_c.obj \
218 $(OBJ_D)\e_ofb_c.obj $(OBJ_D)\e_ecb_r5.obj $(OBJ_D)\e_cbc_r5.obj \
219 $(OBJ_D)\e_cfb_r5.obj $(OBJ_D)\e_ofb_r5.obj $(OBJ_D)\m_null.obj \
220 $(OBJ_D)\m_md2.obj $(OBJ_D)\m_md5.obj $(OBJ_D)\m_sha.obj \
221 $(OBJ_D)\m_sha1.obj $(OBJ_D)\m_dss.obj $(OBJ_D)\m_dss1.obj \
222 $(OBJ_D)\m_mdc2.obj $(OBJ_D)\m_ripemd.obj $(OBJ_D)\p_open.obj \
223 $(OBJ_D)\p_seal.obj $(OBJ_D)\p_sign.obj $(OBJ_D)\p_verify.obj \
224 $(OBJ_D)\p_lib.obj $(OBJ_D)\p_enc.obj $(OBJ_D)\p_dec.obj \
225 $(OBJ_D)\bio_md.obj $(OBJ_D)\bio_b64.obj $(OBJ_D)\bio_enc.obj \
226 $(OBJ_D)\evp_err.obj $(OBJ_D)\e_null.obj $(OBJ_D)\c_all.obj \
227 $(OBJ_D)\evp_lib.obj $(OBJ_D)\pem_sign.obj $(OBJ_D)\pem_seal.obj \
228 $(OBJ_D)\pem_info.obj $(OBJ_D)\pem_lib.obj $(OBJ_D)\pem_all.obj \
229 $(OBJ_D)\pem_err.obj $(OBJ_D)\a_object.obj $(OBJ_D)\a_bitstr.obj \
230 $(OBJ_D)\a_utctm.obj $(OBJ_D)\a_int.obj $(OBJ_D)\a_octet.obj \
231 $(OBJ_D)\a_print.obj $(OBJ_D)\a_type.obj $(OBJ_D)\a_set.obj \
232 $(OBJ_D)\a_dup.obj $(OBJ_D)\a_d2i_fp.obj $(OBJ_D)\a_i2d_fp.obj \
233 $(OBJ_D)\a_sign.obj $(OBJ_D)\a_digest.obj $(OBJ_D)\a_verify.obj \
234 $(OBJ_D)\x_algor.obj $(OBJ_D)\x_val.obj $(OBJ_D)\x_pubkey.obj \
235 $(OBJ_D)\x_sig.obj $(OBJ_D)\x_req.obj $(OBJ_D)\x_attrib.obj \
236 $(OBJ_D)\x_name.obj $(OBJ_D)\x_cinf.obj $(OBJ_D)\x_x509.obj \
237 $(OBJ_D)\x_crl.obj $(OBJ_D)\x_info.obj $(OBJ_D)\x_spki.obj \
238 $(OBJ_D)\d2i_r_pr.obj $(OBJ_D)\i2d_r_pr.obj $(OBJ_D)\d2i_r_pu.obj \
239 $(OBJ_D)\i2d_r_pu.obj $(OBJ_D)\d2i_s_pr.obj $(OBJ_D)\i2d_s_pr.obj \
240 $(OBJ_D)\d2i_s_pu.obj $(OBJ_D)\i2d_s_pu.obj $(OBJ_D)\d2i_pu.obj \
241 $(OBJ_D)\d2i_pr.obj $(OBJ_D)\i2d_pu.obj $(OBJ_D)\i2d_pr.obj \
242 $(OBJ_D)\t_req.obj $(OBJ_D)\t_x509.obj $(OBJ_D)\t_pkey.obj \
243 $(OBJ_D)\p7_i_s.obj $(OBJ_D)\p7_signi.obj $(OBJ_D)\p7_signd.obj \
244 $(OBJ_D)\p7_recip.obj $(OBJ_D)\p7_enc_c.obj $(OBJ_D)\p7_evp.obj \
245 $(OBJ_D)\p7_dgst.obj $(OBJ_D)\p7_s_e.obj $(OBJ_D)\p7_enc.obj \
246 $(OBJ_D)\p7_lib.obj $(OBJ_D)\f_int.obj $(OBJ_D)\f_string.obj \
247 $(OBJ_D)\i2d_dhp.obj $(OBJ_D)\i2d_dsap.obj $(OBJ_D)\d2i_dhp.obj \
248 $(OBJ_D)\d2i_dsap.obj $(OBJ_D)\n_pkey.obj $(OBJ_D)\a_hdr.obj \
249 $(OBJ_D)\x_pkey.obj $(OBJ_D)\a_bool.obj $(OBJ_D)\x_exten.obj \
250 $(OBJ_D)\asn1_par.obj $(OBJ_D)\asn1_lib.obj $(OBJ_D)\asn1_err.obj \
251 $(OBJ_D)\a_meth.obj $(OBJ_D)\a_bytes.obj $(OBJ_D)\evp_asn1.obj \
252 $(OBJ_D)\x509_def.obj $(OBJ_D)\x509_d2.obj $(OBJ_D)\x509_r2x.obj \
253 $(OBJ_D)\x509_cmp.obj $(OBJ_D)\x509_obj.obj $(OBJ_D)\x509_req.obj \
254 $(OBJ_D)\x509_vfy.obj $(OBJ_D)\x509_set.obj $(OBJ_D)\x509rset.obj \
255 $(OBJ_D)\x509_err.obj $(OBJ_D)\x509name.obj $(OBJ_D)\x509_v3.obj \
256 $(OBJ_D)\x509_ext.obj $(OBJ_D)\x509pack.obj $(OBJ_D)\x509type.obj \
257 $(OBJ_D)\x509_lu.obj $(OBJ_D)\x_all.obj $(OBJ_D)\x509_txt.obj \
258 $(OBJ_D)\by_file.obj $(OBJ_D)\by_dir.obj $(OBJ_D)\v3_net.obj \
259 $(OBJ_D)\v3_x509.obj $(OBJ_D)\conf.obj $(OBJ_D)\conf_err.obj \
260 $(OBJ_D)\txt_db.obj $(OBJ_D)\pk7_lib.obj $(OBJ_D)\pkcs7err.obj \
261 $(OBJ_D)\pk7_doit.obj
262
263SSLOBJ=$(OBJ_D)\s2_meth.obj \
264 $(OBJ_D)\s2_srvr.obj $(OBJ_D)\s2_clnt.obj $(OBJ_D)\s2_lib.obj \
265 $(OBJ_D)\s2_enc.obj $(OBJ_D)\s2_pkt.obj $(OBJ_D)\s3_meth.obj \
266 $(OBJ_D)\s3_srvr.obj $(OBJ_D)\s3_clnt.obj $(OBJ_D)\s3_lib.obj \
267 $(OBJ_D)\s3_enc.obj $(OBJ_D)\s3_pkt.obj $(OBJ_D)\s3_both.obj \
268 $(OBJ_D)\s23_meth.obj $(OBJ_D)\s23_srvr.obj $(OBJ_D)\s23_clnt.obj \
269 $(OBJ_D)\s23_lib.obj $(OBJ_D)\s23_pkt.obj $(OBJ_D)\t1_meth.obj \
270 $(OBJ_D)\t1_srvr.obj $(OBJ_D)\t1_clnt.obj $(OBJ_D)\t1_lib.obj \
271 $(OBJ_D)\t1_enc.obj $(OBJ_D)\ssl_lib.obj $(OBJ_D)\ssl_err2.obj \
272 $(OBJ_D)\ssl_cert.obj $(OBJ_D)\ssl_sess.obj $(OBJ_D)\ssl_ciph.obj \
273 $(OBJ_D)\ssl_stat.obj $(OBJ_D)\ssl_rsa.obj $(OBJ_D)\ssl_asn1.obj \
274 $(OBJ_D)\ssl_txt.obj $(OBJ_D)\ssl_algs.obj $(OBJ_D)\bio_ssl.obj \
275 $(OBJ_D)\ssl_err.obj
276
277RSAGLUEOBJ=$(OBJ_D)\rsaref.obj \
278 $(OBJ_D)\rsar_err.obj
279
280T_EXE=$(TEST_D)\md2test.exe \
281 $(TEST_D)\md5test.exe $(TEST_D)\shatest.exe $(TEST_D)\sha1test.exe \
282 $(TEST_D)\mdc2test.exe $(TEST_D)\hmactest.exe $(TEST_D)\rmdtest.exe \
283 $(TEST_D)\destest.exe $(TEST_D)\rc2test.exe $(TEST_D)\rc4test.exe \
284 $(TEST_D)\rc5test.exe $(TEST_D)\ideatest.exe $(TEST_D)\bftest.exe \
285 $(TEST_D)\casttest.exe $(TEST_D)\bntest.exe $(TEST_D)\exptest.exe \
286 $(TEST_D)\dsatest.exe $(TEST_D)\dhtest.exe $(TEST_D)\randtest.exe \
287 $(TEST_D)\ssltest.exe
288
289###################################################################
290all: banner $(TMP_D) $(BIN_D) $(TEST_D) $(LIB_D) $(INC_D) headers lib exe
291
292banner:
293 @echo Make sure you have run 'perl Configure VC-WIN16' in the
294 @echo top level directory, if you don't have perl, you will
295 @echo need to probably edit crypto/bn/bn.h, check the
296 @echo documentation for details.
297
298
299$(TMP_D):
300 $(MKDIR) $(TMP_D)
301
302$(BIN_D):
303 $(MKDIR) $(BIN_D)
304
305$(TEST_D):
306 $(MKDIR) $(TEST_D)
307
308$(LIB_D):
309 $(MKDIR) $(LIB_D)
310
311$(INC_D):
312 $(MKDIR) $(INC_D)
313
314headers: $(HEADER) $(EXHEADER)
315
316lib: $(LIBS_DEP)
317
318exe: $(T_EXE) $(BIN_D)\$(E_EXE).exe
319
320install:
321 $(MKDIR) $(INSTALLTOP)
322 $(MKDIR) $(INSTALLTOP)\bin
323 $(MKDIR) $(INSTALLTOP)\include
324 $(MKDIR) $(INSTALLTOP)\lib
325 $(CP) $(INC_D)\*.[ch] $(INSTALLTOP)\include
326 $(CP) $(BIN_D)\$(E_EXE).exe $(INSTALLTOP)\bin
327 $(CP) $(O_SSL) $(INSTALLTOP)\lib
328 $(CP) $(O_CRYPTO) $(INSTALLTOP)\lib
329
330clean:
331 $(RM) $(TMP_D)\*.*
332
333vclean:
334 $(RM) $(TMP_D)\*.*
335 $(RM) $(OUT_D)\*.*
336
337$(INCL_D)\cryptlib.h: $(SRC_D)\crypto\cryptlib.h
338 $(CP) $(SRC_D)\crypto\cryptlib.h $(INCL_D)\cryptlib.h
339
340$(INCL_D)\date.h: $(SRC_D)\crypto\date.h
341 $(CP) $(SRC_D)\crypto\date.h $(INCL_D)\date.h
342
343$(INCL_D)\md5_locl.h: $(SRC_D)\crypto\md5\md5_locl.h
344 $(CP) $(SRC_D)\crypto\md5\md5_locl.h $(INCL_D)\md5_locl.h
345
346$(INCL_D)\sha_locl.h: $(SRC_D)\crypto\sha\sha_locl.h
347 $(CP) $(SRC_D)\crypto\sha\sha_locl.h $(INCL_D)\sha_locl.h
348
349$(INCL_D)\rmd_locl.h: $(SRC_D)\crypto\ripemd\rmd_locl.h
350 $(CP) $(SRC_D)\crypto\ripemd\rmd_locl.h $(INCL_D)\rmd_locl.h
351
352$(INCL_D)\rmdconst.h: $(SRC_D)\crypto\ripemd\rmdconst.h
353 $(CP) $(SRC_D)\crypto\ripemd\rmdconst.h $(INCL_D)\rmdconst.h
354
355$(INCL_D)\des_locl.h: $(SRC_D)\crypto\des\des_locl.h
356 $(CP) $(SRC_D)\crypto\des\des_locl.h $(INCL_D)\des_locl.h
357
358$(INCL_D)\rpc_des.h: $(SRC_D)\crypto\des\rpc_des.h
359 $(CP) $(SRC_D)\crypto\des\rpc_des.h $(INCL_D)\rpc_des.h
360
361$(INCL_D)\podd.h: $(SRC_D)\crypto\des\podd.h
362 $(CP) $(SRC_D)\crypto\des\podd.h $(INCL_D)\podd.h
363
364$(INCL_D)\sk.h: $(SRC_D)\crypto\des\sk.h
365 $(CP) $(SRC_D)\crypto\des\sk.h $(INCL_D)\sk.h
366
367$(INCL_D)\spr.h: $(SRC_D)\crypto\des\spr.h
368 $(CP) $(SRC_D)\crypto\des\spr.h $(INCL_D)\spr.h
369
370$(INCL_D)\des_ver.h: $(SRC_D)\crypto\des\des_ver.h
371 $(CP) $(SRC_D)\crypto\des\des_ver.h $(INCL_D)\des_ver.h
372
373$(INCL_D)\rc2_locl.h: $(SRC_D)\crypto\rc2\rc2_locl.h
374 $(CP) $(SRC_D)\crypto\rc2\rc2_locl.h $(INCL_D)\rc2_locl.h
375
376$(INCL_D)\rc4_locl.h: $(SRC_D)\crypto\rc4\rc4_locl.h
377 $(CP) $(SRC_D)\crypto\rc4\rc4_locl.h $(INCL_D)\rc4_locl.h
378
379$(INCL_D)\rc5_locl.h: $(SRC_D)\crypto\rc5\rc5_locl.h
380 $(CP) $(SRC_D)\crypto\rc5\rc5_locl.h $(INCL_D)\rc5_locl.h
381
382$(INCL_D)\idea_lcl.h: $(SRC_D)\crypto\idea\idea_lcl.h
383 $(CP) $(SRC_D)\crypto\idea\idea_lcl.h $(INCL_D)\idea_lcl.h
384
385$(INCL_D)\bf_pi.h: $(SRC_D)\crypto\bf\bf_pi.h
386 $(CP) $(SRC_D)\crypto\bf\bf_pi.h $(INCL_D)\bf_pi.h
387
388$(INCL_D)\bf_locl.h: $(SRC_D)\crypto\bf\bf_locl.h
389 $(CP) $(SRC_D)\crypto\bf\bf_locl.h $(INCL_D)\bf_locl.h
390
391$(INCL_D)\cast_s.h: $(SRC_D)\crypto\cast\cast_s.h
392 $(CP) $(SRC_D)\crypto\cast\cast_s.h $(INCL_D)\cast_s.h
393
394$(INCL_D)\cast_lcl.h: $(SRC_D)\crypto\cast\cast_lcl.h
395 $(CP) $(SRC_D)\crypto\cast\cast_lcl.h $(INCL_D)\cast_lcl.h
396
397$(INCL_D)\bn_lcl.h: $(SRC_D)\crypto\bn\bn_lcl.h
398 $(CP) $(SRC_D)\crypto\bn\bn_lcl.h $(INCL_D)\bn_lcl.h
399
400$(INCL_D)\bn_prime.h: $(SRC_D)\crypto\bn\bn_prime.h
401 $(CP) $(SRC_D)\crypto\bn\bn_prime.h $(INCL_D)\bn_prime.h
402
403$(INCL_D)\obj_dat.h: $(SRC_D)\crypto\objects\obj_dat.h
404 $(CP) $(SRC_D)\crypto\objects\obj_dat.h $(INCL_D)\obj_dat.h
405
406$(INCL_D)\conf_lcl.h: $(SRC_D)\crypto\conf\conf_lcl.h
407 $(CP) $(SRC_D)\crypto\conf\conf_lcl.h $(INCL_D)\conf_lcl.h
408
409$(INCL_D)\ssl_locl.h: $(SRC_D)\ssl\ssl_locl.h
410 $(CP) $(SRC_D)\ssl\ssl_locl.h $(INCL_D)\ssl_locl.h
411
412$(INCL_D)\rsaref.h: $(SRC_D)\rsaref\rsaref.h
413 $(CP) $(SRC_D)\rsaref\rsaref.h $(INCL_D)\rsaref.h
414
415$(INCL_D)\apps.h: $(SRC_D)\apps\apps.h
416 $(CP) $(SRC_D)\apps\apps.h $(INCL_D)\apps.h
417
418$(INCL_D)\progs.h: $(SRC_D)\apps\progs.h
419 $(CP) $(SRC_D)\apps\progs.h $(INCL_D)\progs.h
420
421$(INCL_D)\s_apps.h: $(SRC_D)\apps\s_apps.h
422 $(CP) $(SRC_D)\apps\s_apps.h $(INCL_D)\s_apps.h
423
424$(INCL_D)\testdsa.h: $(SRC_D)\apps\testdsa.h
425 $(CP) $(SRC_D)\apps\testdsa.h $(INCL_D)\testdsa.h
426
427$(INCL_D)\testrsa.h: $(SRC_D)\apps\testrsa.h
428 $(CP) $(SRC_D)\apps\testrsa.h $(INCL_D)\testrsa.h
429
430$(INC_D)\e_os.h: $(SRC_D)\.\e_os.h
431 $(CP) $(SRC_D)\.\e_os.h $(INC_D)\e_os.h
432
433$(INC_D)\crypto.h: $(SRC_D)\crypto\crypto.h
434 $(CP) $(SRC_D)\crypto\crypto.h $(INC_D)\crypto.h
435
436$(INC_D)\cryptall.h: $(SRC_D)\crypto\cryptall.h
437 $(CP) $(SRC_D)\crypto\cryptall.h $(INC_D)\cryptall.h
438
439$(INC_D)\md2.h: $(SRC_D)\crypto\md2\md2.h
440 $(CP) $(SRC_D)\crypto\md2\md2.h $(INC_D)\md2.h
441
442$(INC_D)\md5.h: $(SRC_D)\crypto\md5\md5.h
443 $(CP) $(SRC_D)\crypto\md5\md5.h $(INC_D)\md5.h
444
445$(INC_D)\sha.h: $(SRC_D)\crypto\sha\sha.h
446 $(CP) $(SRC_D)\crypto\sha\sha.h $(INC_D)\sha.h
447
448$(INC_D)\mdc2.h: $(SRC_D)\crypto\mdc2\mdc2.h
449 $(CP) $(SRC_D)\crypto\mdc2\mdc2.h $(INC_D)\mdc2.h
450
451$(INC_D)\hmac.h: $(SRC_D)\crypto\hmac\hmac.h
452 $(CP) $(SRC_D)\crypto\hmac\hmac.h $(INC_D)\hmac.h
453
454$(INC_D)\ripemd.h: $(SRC_D)\crypto\ripemd\ripemd.h
455 $(CP) $(SRC_D)\crypto\ripemd\ripemd.h $(INC_D)\ripemd.h
456
457$(INC_D)\des.h: $(SRC_D)\crypto\des\des.h
458 $(CP) $(SRC_D)\crypto\des\des.h $(INC_D)\des.h
459
460$(INC_D)\rc2.h: $(SRC_D)\crypto\rc2\rc2.h
461 $(CP) $(SRC_D)\crypto\rc2\rc2.h $(INC_D)\rc2.h
462
463$(INC_D)\rc4.h: $(SRC_D)\crypto\rc4\rc4.h
464 $(CP) $(SRC_D)\crypto\rc4\rc4.h $(INC_D)\rc4.h
465
466$(INC_D)\rc5.h: $(SRC_D)\crypto\rc5\rc5.h
467 $(CP) $(SRC_D)\crypto\rc5\rc5.h $(INC_D)\rc5.h
468
469$(INC_D)\idea.h: $(SRC_D)\crypto\idea\idea.h
470 $(CP) $(SRC_D)\crypto\idea\idea.h $(INC_D)\idea.h
471
472$(INC_D)\blowfish.h: $(SRC_D)\crypto\bf\blowfish.h
473 $(CP) $(SRC_D)\crypto\bf\blowfish.h $(INC_D)\blowfish.h
474
475$(INC_D)\cast.h: $(SRC_D)\crypto\cast\cast.h
476 $(CP) $(SRC_D)\crypto\cast\cast.h $(INC_D)\cast.h
477
478$(INC_D)\bn.h: $(SRC_D)\crypto\bn\bn.h
479 $(CP) $(SRC_D)\crypto\bn\bn.h $(INC_D)\bn.h
480
481$(INC_D)\rsa.h: $(SRC_D)\crypto\rsa\rsa.h
482 $(CP) $(SRC_D)\crypto\rsa\rsa.h $(INC_D)\rsa.h
483
484$(INC_D)\dsa.h: $(SRC_D)\crypto\dsa\dsa.h
485 $(CP) $(SRC_D)\crypto\dsa\dsa.h $(INC_D)\dsa.h
486
487$(INC_D)\dh.h: $(SRC_D)\crypto\dh\dh.h
488 $(CP) $(SRC_D)\crypto\dh\dh.h $(INC_D)\dh.h
489
490$(INC_D)\buffer.h: $(SRC_D)\crypto\buffer\buffer.h
491 $(CP) $(SRC_D)\crypto\buffer\buffer.h $(INC_D)\buffer.h
492
493$(INC_D)\bio.h: $(SRC_D)\crypto\bio\bio.h
494 $(CP) $(SRC_D)\crypto\bio\bio.h $(INC_D)\bio.h
495
496$(INC_D)\bss_file.c: $(SRC_D)\crypto\bio\bss_file.c
497 $(CP) $(SRC_D)\crypto\bio\bss_file.c $(INC_D)\bss_file.c
498
499$(INC_D)\stack.h: $(SRC_D)\crypto\stack\stack.h
500 $(CP) $(SRC_D)\crypto\stack\stack.h $(INC_D)\stack.h
501
502$(INC_D)\lhash.h: $(SRC_D)\crypto\lhash\lhash.h
503 $(CP) $(SRC_D)\crypto\lhash\lhash.h $(INC_D)\lhash.h
504
505$(INC_D)\rand.h: $(SRC_D)\crypto\rand\rand.h
506 $(CP) $(SRC_D)\crypto\rand\rand.h $(INC_D)\rand.h
507
508$(INC_D)\err.h: $(SRC_D)\crypto\err\err.h
509 $(CP) $(SRC_D)\crypto\err\err.h $(INC_D)\err.h
510
511$(INC_D)\objects.h: $(SRC_D)\crypto\objects\objects.h
512 $(CP) $(SRC_D)\crypto\objects\objects.h $(INC_D)\objects.h
513
514$(INC_D)\evp.h: $(SRC_D)\crypto\evp\evp.h
515 $(CP) $(SRC_D)\crypto\evp\evp.h $(INC_D)\evp.h
516
517$(INC_D)\pem.h: $(SRC_D)\crypto\pem\pem.h
518 $(CP) $(SRC_D)\crypto\pem\pem.h $(INC_D)\pem.h
519
520$(INC_D)\asn1.h: $(SRC_D)\crypto\asn1\asn1.h
521 $(CP) $(SRC_D)\crypto\asn1\asn1.h $(INC_D)\asn1.h
522
523$(INC_D)\asn1_mac.h: $(SRC_D)\crypto\asn1\asn1_mac.h
524 $(CP) $(SRC_D)\crypto\asn1\asn1_mac.h $(INC_D)\asn1_mac.h
525
526$(INC_D)\x509.h: $(SRC_D)\crypto\x509\x509.h
527 $(CP) $(SRC_D)\crypto\x509\x509.h $(INC_D)\x509.h
528
529$(INC_D)\x509_vfy.h: $(SRC_D)\crypto\x509\x509_vfy.h
530 $(CP) $(SRC_D)\crypto\x509\x509_vfy.h $(INC_D)\x509_vfy.h
531
532$(INC_D)\conf.h: $(SRC_D)\crypto\conf\conf.h
533 $(CP) $(SRC_D)\crypto\conf\conf.h $(INC_D)\conf.h
534
535$(INC_D)\txt_db.h: $(SRC_D)\crypto\txt_db\txt_db.h
536 $(CP) $(SRC_D)\crypto\txt_db\txt_db.h $(INC_D)\txt_db.h
537
538$(INC_D)\pkcs7.h: $(SRC_D)\crypto\pkcs7\pkcs7.h
539 $(CP) $(SRC_D)\crypto\pkcs7\pkcs7.h $(INC_D)\pkcs7.h
540
541$(INC_D)\ssl.h: $(SRC_D)\ssl\ssl.h
542 $(CP) $(SRC_D)\ssl\ssl.h $(INC_D)\ssl.h
543
544$(INC_D)\ssl2.h: $(SRC_D)\ssl\ssl2.h
545 $(CP) $(SRC_D)\ssl\ssl2.h $(INC_D)\ssl2.h
546
547$(INC_D)\ssl3.h: $(SRC_D)\ssl\ssl3.h
548 $(CP) $(SRC_D)\ssl\ssl3.h $(INC_D)\ssl3.h
549
550$(INC_D)\ssl23.h: $(SRC_D)\ssl\ssl23.h
551 $(CP) $(SRC_D)\ssl\ssl23.h $(INC_D)\ssl23.h
552
553$(INC_D)\tls1.h: $(SRC_D)\ssl\tls1.h
554 $(CP) $(SRC_D)\ssl\tls1.h $(INC_D)\tls1.h
555
556$(OBJ_D)\md2test.obj: $(SRC_D)\crypto\md2\md2test.c
557 $(CC) /Fo$(OBJ_D)\md2test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\md2\md2test.c
558
559$(OBJ_D)\md5test.obj: $(SRC_D)\crypto\md5\md5test.c
560 $(CC) /Fo$(OBJ_D)\md5test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\md5\md5test.c
561
562$(OBJ_D)\shatest.obj: $(SRC_D)\crypto\sha\shatest.c
563 $(CC) /Fo$(OBJ_D)\shatest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\sha\shatest.c
564
565$(OBJ_D)\sha1test.obj: $(SRC_D)\crypto\sha\sha1test.c
566 $(CC) /Fo$(OBJ_D)\sha1test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\sha\sha1test.c
567
568$(OBJ_D)\mdc2test.obj: $(SRC_D)\crypto\mdc2\mdc2test.c
569 $(CC) /Fo$(OBJ_D)\mdc2test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\mdc2\mdc2test.c
570
571$(OBJ_D)\hmactest.obj: $(SRC_D)\crypto\hmac\hmactest.c
572 $(CC) /Fo$(OBJ_D)\hmactest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\hmac\hmactest.c
573
574$(OBJ_D)\rmdtest.obj: $(SRC_D)\crypto\ripemd\rmdtest.c
575 $(CC) /Fo$(OBJ_D)\rmdtest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\ripemd\rmdtest.c
576
577$(OBJ_D)\destest.obj: $(SRC_D)\crypto\des\destest.c
578 $(CC) /Fo$(OBJ_D)\destest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\des\destest.c
579
580$(OBJ_D)\rc2test.obj: $(SRC_D)\crypto\rc2\rc2test.c
581 $(CC) /Fo$(OBJ_D)\rc2test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2test.c
582
583$(OBJ_D)\rc4test.obj: $(SRC_D)\crypto\rc4\rc4test.c
584 $(CC) /Fo$(OBJ_D)\rc4test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\rc4\rc4test.c
585
586$(OBJ_D)\rc5test.obj: $(SRC_D)\crypto\rc5\rc5test.c
587 $(CC) /Fo$(OBJ_D)\rc5test.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5test.c
588
589$(OBJ_D)\ideatest.obj: $(SRC_D)\crypto\idea\ideatest.c
590 $(CC) /Fo$(OBJ_D)\ideatest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\idea\ideatest.c
591
592$(OBJ_D)\bftest.obj: $(SRC_D)\crypto\bf\bftest.c
593 $(CC) /Fo$(OBJ_D)\bftest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\bf\bftest.c
594
595$(OBJ_D)\casttest.obj: $(SRC_D)\crypto\cast\casttest.c
596 $(CC) /Fo$(OBJ_D)\casttest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\cast\casttest.c
597
598$(OBJ_D)\bntest.obj: $(SRC_D)\crypto\bn\bntest.c
599 $(CC) /Fo$(OBJ_D)\bntest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\bn\bntest.c
600
601$(OBJ_D)\exptest.obj: $(SRC_D)\crypto\bn\exptest.c
602 $(CC) /Fo$(OBJ_D)\exptest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\bn\exptest.c
603
604$(OBJ_D)\dsatest.obj: $(SRC_D)\crypto\dsa\dsatest.c
605 $(CC) /Fo$(OBJ_D)\dsatest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\dsa\dsatest.c
606
607$(OBJ_D)\dhtest.obj: $(SRC_D)\crypto\dh\dhtest.c
608 $(CC) /Fo$(OBJ_D)\dhtest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\dh\dhtest.c
609
610$(OBJ_D)\randtest.obj: $(SRC_D)\crypto\rand\randtest.c
611 $(CC) /Fo$(OBJ_D)\randtest.obj $(APP_CFLAGS) -c $(SRC_D)\crypto\rand\randtest.c
612
613$(OBJ_D)\ssltest.obj: $(SRC_D)\ssl\ssltest.c
614 $(CC) /Fo$(OBJ_D)\ssltest.obj $(APP_CFLAGS) -c $(SRC_D)\ssl\ssltest.c
615
616$(OBJ_D)\verify.obj: $(SRC_D)\apps\verify.c
617 $(CC) /Fo$(OBJ_D)\verify.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\verify.c
618
619$(OBJ_D)\asn1pars.obj: $(SRC_D)\apps\asn1pars.c
620 $(CC) /Fo$(OBJ_D)\asn1pars.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\asn1pars.c
621
622$(OBJ_D)\req.obj: $(SRC_D)\apps\req.c
623 $(CC) /Fo$(OBJ_D)\req.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\req.c
624
625$(OBJ_D)\dgst.obj: $(SRC_D)\apps\dgst.c
626 $(CC) /Fo$(OBJ_D)\dgst.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\dgst.c
627
628$(OBJ_D)\dh.obj: $(SRC_D)\apps\dh.c
629 $(CC) /Fo$(OBJ_D)\dh.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\dh.c
630
631$(OBJ_D)\enc.obj: $(SRC_D)\apps\enc.c
632 $(CC) /Fo$(OBJ_D)\enc.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\enc.c
633
634$(OBJ_D)\gendh.obj: $(SRC_D)\apps\gendh.c
635 $(CC) /Fo$(OBJ_D)\gendh.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\gendh.c
636
637$(OBJ_D)\errstr.obj: $(SRC_D)\apps\errstr.c
638 $(CC) /Fo$(OBJ_D)\errstr.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\errstr.c
639
640$(OBJ_D)\ca.obj: $(SRC_D)\apps\ca.c
641 $(CC) /Fo$(OBJ_D)\ca.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\ca.c
642
643$(OBJ_D)\pkcs7.obj: $(SRC_D)\apps\pkcs7.c
644 $(CC) /Fo$(OBJ_D)\pkcs7.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\pkcs7.c
645
646$(OBJ_D)\crl2p7.obj: $(SRC_D)\apps\crl2p7.c
647 $(CC) /Fo$(OBJ_D)\crl2p7.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\crl2p7.c
648
649$(OBJ_D)\crl.obj: $(SRC_D)\apps\crl.c
650 $(CC) /Fo$(OBJ_D)\crl.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\crl.c
651
652$(OBJ_D)\rsa.obj: $(SRC_D)\apps\rsa.c
653 $(CC) /Fo$(OBJ_D)\rsa.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\rsa.c
654
655$(OBJ_D)\dsa.obj: $(SRC_D)\apps\dsa.c
656 $(CC) /Fo$(OBJ_D)\dsa.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\dsa.c
657
658$(OBJ_D)\dsaparam.obj: $(SRC_D)\apps\dsaparam.c
659 $(CC) /Fo$(OBJ_D)\dsaparam.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\dsaparam.c
660
661$(OBJ_D)\x509.obj: $(SRC_D)\apps\x509.c
662 $(CC) /Fo$(OBJ_D)\x509.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\x509.c
663
664$(OBJ_D)\genrsa.obj: $(SRC_D)\apps\genrsa.c
665 $(CC) /Fo$(OBJ_D)\genrsa.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\genrsa.c
666
667$(OBJ_D)\s_server.obj: $(SRC_D)\apps\s_server.c
668 $(CC) /Fo$(OBJ_D)\s_server.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\s_server.c
669
670$(OBJ_D)\s_client.obj: $(SRC_D)\apps\s_client.c
671 $(CC) /Fo$(OBJ_D)\s_client.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\s_client.c
672
673$(OBJ_D)\speed.obj: $(SRC_D)\apps\speed.c
674 $(CC) /Fo$(OBJ_D)\speed.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\speed.c
675
676$(OBJ_D)\s_time.obj: $(SRC_D)\apps\s_time.c
677 $(CC) /Fo$(OBJ_D)\s_time.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\s_time.c
678
679$(OBJ_D)\apps.obj: $(SRC_D)\apps\apps.c
680 $(CC) /Fo$(OBJ_D)\apps.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\apps.c
681
682$(OBJ_D)\s_cb.obj: $(SRC_D)\apps\s_cb.c
683 $(CC) /Fo$(OBJ_D)\s_cb.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\s_cb.c
684
685$(OBJ_D)\s_socket.obj: $(SRC_D)\apps\s_socket.c
686 $(CC) /Fo$(OBJ_D)\s_socket.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\s_socket.c
687
688$(OBJ_D)\version.obj: $(SRC_D)\apps\version.c
689 $(CC) /Fo$(OBJ_D)\version.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\version.c
690
691$(OBJ_D)\sess_id.obj: $(SRC_D)\apps\sess_id.c
692 $(CC) /Fo$(OBJ_D)\sess_id.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\sess_id.c
693
694$(OBJ_D)\ciphers.obj: $(SRC_D)\apps\ciphers.c
695 $(CC) /Fo$(OBJ_D)\ciphers.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\ciphers.c
696
697$(OBJ_D)\ssleay.obj: $(SRC_D)\apps\ssleay.c
698 $(CC) /Fo$(OBJ_D)\ssleay.obj -DMONOLITH $(APP_CFLAGS) -c $(SRC_D)\apps\ssleay.c
699
700crypto\bn\asm\x86w32.obj: crypto\bn\asm\x86w32.asm
701 $(ASM) /Focrypto\bn\asm\x86w32.obj $(SRC_D)\crypto\bn\asm\x86w32.asm
702
703$(OBJ_D)\cryptlib.obj: $(SRC_D)\crypto\cryptlib.c
704 $(CC) /Fo$(OBJ_D)\cryptlib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cryptlib.c
705
706$(OBJ_D)\mem.obj: $(SRC_D)\crypto\mem.c
707 $(CC) /Fo$(OBJ_D)\mem.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\mem.c
708
709$(OBJ_D)\cversion.obj: $(SRC_D)\crypto\cversion.c
710 $(CC) /Fo$(OBJ_D)\cversion.obj $(SHLIB_CFLAGS) -DCFLAGS="\"$(CC) $(CFLAG)\"" -c $(SRC_D)\crypto\cversion.c
711
712$(OBJ_D)\ex_data.obj: $(SRC_D)\crypto\ex_data.c
713 $(CC) /Fo$(OBJ_D)\ex_data.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\ex_data.c
714
715$(OBJ_D)\cpt_err.obj: $(SRC_D)\crypto\cpt_err.c
716 $(CC) /Fo$(OBJ_D)\cpt_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cpt_err.c
717
718$(OBJ_D)\md2_dgst.obj: $(SRC_D)\crypto\md2\md2_dgst.c
719 $(CC) /Fo$(OBJ_D)\md2_dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\md2\md2_dgst.c
720
721$(OBJ_D)\md2_one.obj: $(SRC_D)\crypto\md2\md2_one.c
722 $(CC) /Fo$(OBJ_D)\md2_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\md2\md2_one.c
723
724$(OBJ_D)\md5_dgst.obj: $(SRC_D)\crypto\md5\md5_dgst.c
725 $(CC) /Fo$(OBJ_D)\md5_dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\md5\md5_dgst.c
726
727$(OBJ_D)\md5_one.obj: $(SRC_D)\crypto\md5\md5_one.c
728 $(CC) /Fo$(OBJ_D)\md5_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\md5\md5_one.c
729
730$(OBJ_D)\sha_dgst.obj: $(SRC_D)\crypto\sha\sha_dgst.c
731 $(CC) /Fo$(OBJ_D)\sha_dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\sha\sha_dgst.c
732
733$(OBJ_D)\sha1dgst.obj: $(SRC_D)\crypto\sha\sha1dgst.c
734 $(CC) /Fo$(OBJ_D)\sha1dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\sha\sha1dgst.c
735
736$(OBJ_D)\sha_one.obj: $(SRC_D)\crypto\sha\sha_one.c
737 $(CC) /Fo$(OBJ_D)\sha_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\sha\sha_one.c
738
739$(OBJ_D)\sha1_one.obj: $(SRC_D)\crypto\sha\sha1_one.c
740 $(CC) /Fo$(OBJ_D)\sha1_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\sha\sha1_one.c
741
742$(OBJ_D)\mdc2dgst.obj: $(SRC_D)\crypto\mdc2\mdc2dgst.c
743 $(CC) /Fo$(OBJ_D)\mdc2dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\mdc2\mdc2dgst.c
744
745$(OBJ_D)\mdc2_one.obj: $(SRC_D)\crypto\mdc2\mdc2_one.c
746 $(CC) /Fo$(OBJ_D)\mdc2_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\mdc2\mdc2_one.c
747
748$(OBJ_D)\hmac.obj: $(SRC_D)\crypto\hmac\hmac.c
749 $(CC) /Fo$(OBJ_D)\hmac.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\hmac\hmac.c
750
751$(OBJ_D)\rmd_dgst.obj: $(SRC_D)\crypto\ripemd\rmd_dgst.c
752 $(CC) /Fo$(OBJ_D)\rmd_dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\ripemd\rmd_dgst.c
753
754$(OBJ_D)\rmd_one.obj: $(SRC_D)\crypto\ripemd\rmd_one.c
755 $(CC) /Fo$(OBJ_D)\rmd_one.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\ripemd\rmd_one.c
756
757$(OBJ_D)\set_key.obj: $(SRC_D)\crypto\des\set_key.c
758 $(CC) /Fo$(OBJ_D)\set_key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\set_key.c
759
760$(OBJ_D)\ecb_enc.obj: $(SRC_D)\crypto\des\ecb_enc.c
761 $(CC) /Fo$(OBJ_D)\ecb_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\ecb_enc.c
762
763$(OBJ_D)\cbc_enc.obj: $(SRC_D)\crypto\des\cbc_enc.c
764 $(CC) /Fo$(OBJ_D)\cbc_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\cbc_enc.c
765
766$(OBJ_D)\ecb3_enc.obj: $(SRC_D)\crypto\des\ecb3_enc.c
767 $(CC) /Fo$(OBJ_D)\ecb3_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\ecb3_enc.c
768
769$(OBJ_D)\cfb64enc.obj: $(SRC_D)\crypto\des\cfb64enc.c
770 $(CC) /Fo$(OBJ_D)\cfb64enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\cfb64enc.c
771
772$(OBJ_D)\cfb64ede.obj: $(SRC_D)\crypto\des\cfb64ede.c
773 $(CC) /Fo$(OBJ_D)\cfb64ede.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\cfb64ede.c
774
775$(OBJ_D)\cfb_enc.obj: $(SRC_D)\crypto\des\cfb_enc.c
776 $(CC) /Fo$(OBJ_D)\cfb_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\cfb_enc.c
777
778$(OBJ_D)\ofb64ede.obj: $(SRC_D)\crypto\des\ofb64ede.c
779 $(CC) /Fo$(OBJ_D)\ofb64ede.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\ofb64ede.c
780
781$(OBJ_D)\enc_read.obj: $(SRC_D)\crypto\des\enc_read.c
782 $(CC) /Fo$(OBJ_D)\enc_read.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\enc_read.c
783
784$(OBJ_D)\enc_writ.obj: $(SRC_D)\crypto\des\enc_writ.c
785 $(CC) /Fo$(OBJ_D)\enc_writ.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\enc_writ.c
786
787$(OBJ_D)\ofb64enc.obj: $(SRC_D)\crypto\des\ofb64enc.c
788 $(CC) /Fo$(OBJ_D)\ofb64enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\ofb64enc.c
789
790$(OBJ_D)\ofb_enc.obj: $(SRC_D)\crypto\des\ofb_enc.c
791 $(CC) /Fo$(OBJ_D)\ofb_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\ofb_enc.c
792
793$(OBJ_D)\str2key.obj: $(SRC_D)\crypto\des\str2key.c
794 $(CC) /Fo$(OBJ_D)\str2key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\str2key.c
795
796$(OBJ_D)\pcbc_enc.obj: $(SRC_D)\crypto\des\pcbc_enc.c
797 $(CC) /Fo$(OBJ_D)\pcbc_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\pcbc_enc.c
798
799$(OBJ_D)\qud_cksm.obj: $(SRC_D)\crypto\des\qud_cksm.c
800 $(CC) /Fo$(OBJ_D)\qud_cksm.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\qud_cksm.c
801
802$(OBJ_D)\rand_key.obj: $(SRC_D)\crypto\des\rand_key.c
803 $(CC) /Fo$(OBJ_D)\rand_key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\rand_key.c
804
805$(OBJ_D)\des_enc.obj: $(SRC_D)\crypto\des\des_enc.c
806 $(CC) /Fo$(OBJ_D)\des_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\des_enc.c
807
808$(OBJ_D)\fcrypt_b.obj: $(SRC_D)\crypto\des\fcrypt_b.c
809 $(CC) /Fo$(OBJ_D)\fcrypt_b.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\fcrypt_b.c
810
811$(OBJ_D)\read2pwd.obj: $(SRC_D)\crypto\des\read2pwd.c
812 $(CC) /Fo$(OBJ_D)\read2pwd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\read2pwd.c
813
814$(OBJ_D)\fcrypt.obj: $(SRC_D)\crypto\des\fcrypt.c
815 $(CC) /Fo$(OBJ_D)\fcrypt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\fcrypt.c
816
817$(OBJ_D)\xcbc_enc.obj: $(SRC_D)\crypto\des\xcbc_enc.c
818 $(CC) /Fo$(OBJ_D)\xcbc_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\xcbc_enc.c
819
820$(OBJ_D)\read_pwd.obj: $(SRC_D)\crypto\des\read_pwd.c
821 $(CC) /Fo$(OBJ_D)\read_pwd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\read_pwd.c
822
823$(OBJ_D)\rpc_enc.obj: $(SRC_D)\crypto\des\rpc_enc.c
824 $(CC) /Fo$(OBJ_D)\rpc_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\rpc_enc.c
825
826$(OBJ_D)\cbc_cksm.obj: $(SRC_D)\crypto\des\cbc_cksm.c
827 $(CC) /Fo$(OBJ_D)\cbc_cksm.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\cbc_cksm.c
828
829$(OBJ_D)\supp.obj: $(SRC_D)\crypto\des\supp.c
830 $(CC) /Fo$(OBJ_D)\supp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\des\supp.c
831
832$(OBJ_D)\rc2_ecb.obj: $(SRC_D)\crypto\rc2\rc2_ecb.c
833 $(CC) /Fo$(OBJ_D)\rc2_ecb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2_ecb.c
834
835$(OBJ_D)\rc2_skey.obj: $(SRC_D)\crypto\rc2\rc2_skey.c
836 $(CC) /Fo$(OBJ_D)\rc2_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2_skey.c
837
838$(OBJ_D)\rc2_cbc.obj: $(SRC_D)\crypto\rc2\rc2_cbc.c
839 $(CC) /Fo$(OBJ_D)\rc2_cbc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2_cbc.c
840
841$(OBJ_D)\rc2cfb64.obj: $(SRC_D)\crypto\rc2\rc2cfb64.c
842 $(CC) /Fo$(OBJ_D)\rc2cfb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2cfb64.c
843
844$(OBJ_D)\rc2ofb64.obj: $(SRC_D)\crypto\rc2\rc2ofb64.c
845 $(CC) /Fo$(OBJ_D)\rc2ofb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc2\rc2ofb64.c
846
847$(OBJ_D)\rc4_skey.obj: $(SRC_D)\crypto\rc4\rc4_skey.c
848 $(CC) /Fo$(OBJ_D)\rc4_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc4\rc4_skey.c
849
850$(OBJ_D)\rc4_enc.obj: $(SRC_D)\crypto\rc4\rc4_enc.c
851 $(CC) /Fo$(OBJ_D)\rc4_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc4\rc4_enc.c
852
853$(OBJ_D)\rc5_skey.obj: $(SRC_D)\crypto\rc5\rc5_skey.c
854 $(CC) /Fo$(OBJ_D)\rc5_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5_skey.c
855
856$(OBJ_D)\rc5_ecb.obj: $(SRC_D)\crypto\rc5\rc5_ecb.c
857 $(CC) /Fo$(OBJ_D)\rc5_ecb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5_ecb.c
858
859$(OBJ_D)\rc5_enc.obj: $(SRC_D)\crypto\rc5\rc5_enc.c
860 $(CC) /Fo$(OBJ_D)\rc5_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5_enc.c
861
862$(OBJ_D)\rc5cfb64.obj: $(SRC_D)\crypto\rc5\rc5cfb64.c
863 $(CC) /Fo$(OBJ_D)\rc5cfb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5cfb64.c
864
865$(OBJ_D)\rc5ofb64.obj: $(SRC_D)\crypto\rc5\rc5ofb64.c
866 $(CC) /Fo$(OBJ_D)\rc5ofb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rc5\rc5ofb64.c
867
868$(OBJ_D)\i_cbc.obj: $(SRC_D)\crypto\idea\i_cbc.c
869 $(CC) /Fo$(OBJ_D)\i_cbc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\idea\i_cbc.c
870
871$(OBJ_D)\i_cfb64.obj: $(SRC_D)\crypto\idea\i_cfb64.c
872 $(CC) /Fo$(OBJ_D)\i_cfb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\idea\i_cfb64.c
873
874$(OBJ_D)\i_ofb64.obj: $(SRC_D)\crypto\idea\i_ofb64.c
875 $(CC) /Fo$(OBJ_D)\i_ofb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\idea\i_ofb64.c
876
877$(OBJ_D)\i_ecb.obj: $(SRC_D)\crypto\idea\i_ecb.c
878 $(CC) /Fo$(OBJ_D)\i_ecb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\idea\i_ecb.c
879
880$(OBJ_D)\i_skey.obj: $(SRC_D)\crypto\idea\i_skey.c
881 $(CC) /Fo$(OBJ_D)\i_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\idea\i_skey.c
882
883$(OBJ_D)\bf_skey.obj: $(SRC_D)\crypto\bf\bf_skey.c
884 $(CC) /Fo$(OBJ_D)\bf_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bf\bf_skey.c
885
886$(OBJ_D)\bf_ecb.obj: $(SRC_D)\crypto\bf\bf_ecb.c
887 $(CC) /Fo$(OBJ_D)\bf_ecb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bf\bf_ecb.c
888
889$(OBJ_D)\bf_enc.obj: $(SRC_D)\crypto\bf\bf_enc.c
890 $(CC) /Fo$(OBJ_D)\bf_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bf\bf_enc.c
891
892$(OBJ_D)\bf_cfb64.obj: $(SRC_D)\crypto\bf\bf_cfb64.c
893 $(CC) /Fo$(OBJ_D)\bf_cfb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bf\bf_cfb64.c
894
895$(OBJ_D)\bf_ofb64.obj: $(SRC_D)\crypto\bf\bf_ofb64.c
896 $(CC) /Fo$(OBJ_D)\bf_ofb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bf\bf_ofb64.c
897
898$(OBJ_D)\c_skey.obj: $(SRC_D)\crypto\cast\c_skey.c
899 $(CC) /Fo$(OBJ_D)\c_skey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cast\c_skey.c
900
901$(OBJ_D)\c_ecb.obj: $(SRC_D)\crypto\cast\c_ecb.c
902 $(CC) /Fo$(OBJ_D)\c_ecb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cast\c_ecb.c
903
904$(OBJ_D)\c_enc.obj: $(SRC_D)\crypto\cast\c_enc.c
905 $(CC) /Fo$(OBJ_D)\c_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cast\c_enc.c
906
907$(OBJ_D)\c_cfb64.obj: $(SRC_D)\crypto\cast\c_cfb64.c
908 $(CC) /Fo$(OBJ_D)\c_cfb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cast\c_cfb64.c
909
910$(OBJ_D)\c_ofb64.obj: $(SRC_D)\crypto\cast\c_ofb64.c
911 $(CC) /Fo$(OBJ_D)\c_ofb64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\cast\c_ofb64.c
912
913$(OBJ_D)\bn_add.obj: $(SRC_D)\crypto\bn\bn_add.c
914 $(CC) /Fo$(OBJ_D)\bn_add.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_add.c
915
916$(OBJ_D)\bn_div.obj: $(SRC_D)\crypto\bn\bn_div.c
917 $(CC) /Fo$(OBJ_D)\bn_div.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_div.c
918
919$(OBJ_D)\bn_exp.obj: $(SRC_D)\crypto\bn\bn_exp.c
920 $(CC) /Fo$(OBJ_D)\bn_exp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_exp.c
921
922$(OBJ_D)\bn_lib.obj: $(SRC_D)\crypto\bn\bn_lib.c
923 $(CC) /Fo$(OBJ_D)\bn_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_lib.c
924
925$(OBJ_D)\bn_mod.obj: $(SRC_D)\crypto\bn\bn_mod.c
926 $(CC) /Fo$(OBJ_D)\bn_mod.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_mod.c
927
928$(OBJ_D)\bn_mul.obj: $(SRC_D)\crypto\bn\bn_mul.c
929 $(CC) /Fo$(OBJ_D)\bn_mul.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_mul.c
930
931$(OBJ_D)\bn_print.obj: $(SRC_D)\crypto\bn\bn_print.c
932 $(CC) /Fo$(OBJ_D)\bn_print.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_print.c
933
934$(OBJ_D)\bn_rand.obj: $(SRC_D)\crypto\bn\bn_rand.c
935 $(CC) /Fo$(OBJ_D)\bn_rand.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_rand.c
936
937$(OBJ_D)\bn_shift.obj: $(SRC_D)\crypto\bn\bn_shift.c
938 $(CC) /Fo$(OBJ_D)\bn_shift.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_shift.c
939
940$(OBJ_D)\bn_sub.obj: $(SRC_D)\crypto\bn\bn_sub.c
941 $(CC) /Fo$(OBJ_D)\bn_sub.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_sub.c
942
943$(OBJ_D)\bn_word.obj: $(SRC_D)\crypto\bn\bn_word.c
944 $(CC) /Fo$(OBJ_D)\bn_word.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_word.c
945
946$(OBJ_D)\bn_blind.obj: $(SRC_D)\crypto\bn\bn_blind.c
947 $(CC) /Fo$(OBJ_D)\bn_blind.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_blind.c
948
949$(OBJ_D)\bn_gcd.obj: $(SRC_D)\crypto\bn\bn_gcd.c
950 $(CC) /Fo$(OBJ_D)\bn_gcd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_gcd.c
951
952$(OBJ_D)\bn_prime.obj: $(SRC_D)\crypto\bn\bn_prime.c
953 $(CC) /Fo$(OBJ_D)\bn_prime.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_prime.c
954
955$(OBJ_D)\bn_err.obj: $(SRC_D)\crypto\bn\bn_err.c
956 $(CC) /Fo$(OBJ_D)\bn_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_err.c
957
958$(OBJ_D)\bn_sqr.obj: $(SRC_D)\crypto\bn\bn_sqr.c
959 $(CC) /Fo$(OBJ_D)\bn_sqr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_sqr.c
960
961$(OBJ_D)\bn_mulw.obj: $(SRC_D)\crypto\bn\bn_mulw.c
962 $(CC) /Fo$(OBJ_D)\bn_mulw.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_mulw.c
963
964$(OBJ_D)\bn_recp.obj: $(SRC_D)\crypto\bn\bn_recp.c
965 $(CC) /Fo$(OBJ_D)\bn_recp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_recp.c
966
967$(OBJ_D)\bn_mont.obj: $(SRC_D)\crypto\bn\bn_mont.c
968 $(CC) /Fo$(OBJ_D)\bn_mont.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_mont.c
969
970$(OBJ_D)\bn_mpi.obj: $(SRC_D)\crypto\bn\bn_mpi.c
971 $(CC) /Fo$(OBJ_D)\bn_mpi.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bn\bn_mpi.c
972
973$(OBJ_D)\rsa_eay.obj: $(SRC_D)\crypto\rsa\rsa_eay.c
974 $(CC) /Fo$(OBJ_D)\rsa_eay.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_eay.c
975
976$(OBJ_D)\rsa_gen.obj: $(SRC_D)\crypto\rsa\rsa_gen.c
977 $(CC) /Fo$(OBJ_D)\rsa_gen.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_gen.c
978
979$(OBJ_D)\rsa_lib.obj: $(SRC_D)\crypto\rsa\rsa_lib.c
980 $(CC) /Fo$(OBJ_D)\rsa_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_lib.c
981
982$(OBJ_D)\rsa_sign.obj: $(SRC_D)\crypto\rsa\rsa_sign.c
983 $(CC) /Fo$(OBJ_D)\rsa_sign.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_sign.c
984
985$(OBJ_D)\rsa_saos.obj: $(SRC_D)\crypto\rsa\rsa_saos.c
986 $(CC) /Fo$(OBJ_D)\rsa_saos.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_saos.c
987
988$(OBJ_D)\rsa_err.obj: $(SRC_D)\crypto\rsa\rsa_err.c
989 $(CC) /Fo$(OBJ_D)\rsa_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_err.c
990
991$(OBJ_D)\rsa_pk1.obj: $(SRC_D)\crypto\rsa\rsa_pk1.c
992 $(CC) /Fo$(OBJ_D)\rsa_pk1.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_pk1.c
993
994$(OBJ_D)\rsa_ssl.obj: $(SRC_D)\crypto\rsa\rsa_ssl.c
995 $(CC) /Fo$(OBJ_D)\rsa_ssl.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_ssl.c
996
997$(OBJ_D)\rsa_none.obj: $(SRC_D)\crypto\rsa\rsa_none.c
998 $(CC) /Fo$(OBJ_D)\rsa_none.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rsa\rsa_none.c
999
1000$(OBJ_D)\dsa_gen.obj: $(SRC_D)\crypto\dsa\dsa_gen.c
1001 $(CC) /Fo$(OBJ_D)\dsa_gen.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_gen.c
1002
1003$(OBJ_D)\dsa_key.obj: $(SRC_D)\crypto\dsa\dsa_key.c
1004 $(CC) /Fo$(OBJ_D)\dsa_key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_key.c
1005
1006$(OBJ_D)\dsa_lib.obj: $(SRC_D)\crypto\dsa\dsa_lib.c
1007 $(CC) /Fo$(OBJ_D)\dsa_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_lib.c
1008
1009$(OBJ_D)\dsa_vrf.obj: $(SRC_D)\crypto\dsa\dsa_vrf.c
1010 $(CC) /Fo$(OBJ_D)\dsa_vrf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_vrf.c
1011
1012$(OBJ_D)\dsa_sign.obj: $(SRC_D)\crypto\dsa\dsa_sign.c
1013 $(CC) /Fo$(OBJ_D)\dsa_sign.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_sign.c
1014
1015$(OBJ_D)\dsa_err.obj: $(SRC_D)\crypto\dsa\dsa_err.c
1016 $(CC) /Fo$(OBJ_D)\dsa_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dsa\dsa_err.c
1017
1018$(OBJ_D)\dh_gen.obj: $(SRC_D)\crypto\dh\dh_gen.c
1019 $(CC) /Fo$(OBJ_D)\dh_gen.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dh\dh_gen.c
1020
1021$(OBJ_D)\dh_key.obj: $(SRC_D)\crypto\dh\dh_key.c
1022 $(CC) /Fo$(OBJ_D)\dh_key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dh\dh_key.c
1023
1024$(OBJ_D)\dh_lib.obj: $(SRC_D)\crypto\dh\dh_lib.c
1025 $(CC) /Fo$(OBJ_D)\dh_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dh\dh_lib.c
1026
1027$(OBJ_D)\dh_check.obj: $(SRC_D)\crypto\dh\dh_check.c
1028 $(CC) /Fo$(OBJ_D)\dh_check.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dh\dh_check.c
1029
1030$(OBJ_D)\dh_err.obj: $(SRC_D)\crypto\dh\dh_err.c
1031 $(CC) /Fo$(OBJ_D)\dh_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\dh\dh_err.c
1032
1033$(OBJ_D)\buffer.obj: $(SRC_D)\crypto\buffer\buffer.c
1034 $(CC) /Fo$(OBJ_D)\buffer.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\buffer\buffer.c
1035
1036$(OBJ_D)\buf_err.obj: $(SRC_D)\crypto\buffer\buf_err.c
1037 $(CC) /Fo$(OBJ_D)\buf_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\buffer\buf_err.c
1038
1039$(OBJ_D)\bio_lib.obj: $(SRC_D)\crypto\bio\bio_lib.c
1040 $(CC) /Fo$(OBJ_D)\bio_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bio_lib.c
1041
1042$(OBJ_D)\bio_cb.obj: $(SRC_D)\crypto\bio\bio_cb.c
1043 $(CC) /Fo$(OBJ_D)\bio_cb.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bio_cb.c
1044
1045$(OBJ_D)\bio_err.obj: $(SRC_D)\crypto\bio\bio_err.c
1046 $(CC) /Fo$(OBJ_D)\bio_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bio_err.c
1047
1048$(OBJ_D)\bss_mem.obj: $(SRC_D)\crypto\bio\bss_mem.c
1049 $(CC) /Fo$(OBJ_D)\bss_mem.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_mem.c
1050
1051$(OBJ_D)\bss_null.obj: $(SRC_D)\crypto\bio\bss_null.c
1052 $(CC) /Fo$(OBJ_D)\bss_null.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_null.c
1053
1054$(OBJ_D)\bss_fd.obj: $(SRC_D)\crypto\bio\bss_fd.c
1055 $(CC) /Fo$(OBJ_D)\bss_fd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_fd.c
1056
1057$(OBJ_D)\bss_file.obj: $(SRC_D)\crypto\bio\bss_file.c
1058 $(CC) /Fo$(OBJ_D)\bss_file.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_file.c
1059
1060$(OBJ_D)\bss_sock.obj: $(SRC_D)\crypto\bio\bss_sock.c
1061 $(CC) /Fo$(OBJ_D)\bss_sock.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_sock.c
1062
1063$(OBJ_D)\bss_conn.obj: $(SRC_D)\crypto\bio\bss_conn.c
1064 $(CC) /Fo$(OBJ_D)\bss_conn.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_conn.c
1065
1066$(OBJ_D)\bf_null.obj: $(SRC_D)\crypto\bio\bf_null.c
1067 $(CC) /Fo$(OBJ_D)\bf_null.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bf_null.c
1068
1069$(OBJ_D)\bf_buff.obj: $(SRC_D)\crypto\bio\bf_buff.c
1070 $(CC) /Fo$(OBJ_D)\bf_buff.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bf_buff.c
1071
1072$(OBJ_D)\b_print.obj: $(SRC_D)\crypto\bio\b_print.c
1073 $(CC) /Fo$(OBJ_D)\b_print.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\b_print.c
1074
1075$(OBJ_D)\b_dump.obj: $(SRC_D)\crypto\bio\b_dump.c
1076 $(CC) /Fo$(OBJ_D)\b_dump.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\b_dump.c
1077
1078$(OBJ_D)\b_sock.obj: $(SRC_D)\crypto\bio\b_sock.c
1079 $(CC) /Fo$(OBJ_D)\b_sock.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\b_sock.c
1080
1081$(OBJ_D)\bss_acpt.obj: $(SRC_D)\crypto\bio\bss_acpt.c
1082 $(CC) /Fo$(OBJ_D)\bss_acpt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bss_acpt.c
1083
1084$(OBJ_D)\bf_nbio.obj: $(SRC_D)\crypto\bio\bf_nbio.c
1085 $(CC) /Fo$(OBJ_D)\bf_nbio.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\bio\bf_nbio.c
1086
1087$(OBJ_D)\stack.obj: $(SRC_D)\crypto\stack\stack.c
1088 $(CC) /Fo$(OBJ_D)\stack.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\stack\stack.c
1089
1090$(OBJ_D)\lhash.obj: $(SRC_D)\crypto\lhash\lhash.c
1091 $(CC) /Fo$(OBJ_D)\lhash.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\lhash\lhash.c
1092
1093$(OBJ_D)\lh_stats.obj: $(SRC_D)\crypto\lhash\lh_stats.c
1094 $(CC) /Fo$(OBJ_D)\lh_stats.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\lhash\lh_stats.c
1095
1096$(OBJ_D)\md_rand.obj: $(SRC_D)\crypto\rand\md_rand.c
1097 $(CC) /Fo$(OBJ_D)\md_rand.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rand\md_rand.c
1098
1099$(OBJ_D)\randfile.obj: $(SRC_D)\crypto\rand\randfile.c
1100 $(CC) /Fo$(OBJ_D)\randfile.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\rand\randfile.c
1101
1102$(OBJ_D)\err.obj: $(SRC_D)\crypto\err\err.c
1103 $(CC) /Fo$(OBJ_D)\err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\err\err.c
1104
1105$(OBJ_D)\err_all.obj: $(SRC_D)\crypto\err\err_all.c
1106 $(CC) /Fo$(OBJ_D)\err_all.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\err\err_all.c
1107
1108$(OBJ_D)\err_prn.obj: $(SRC_D)\crypto\err\err_prn.c
1109 $(CC) /Fo$(OBJ_D)\err_prn.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\err\err_prn.c
1110
1111$(OBJ_D)\obj_dat.obj: $(SRC_D)\crypto\objects\obj_dat.c
1112 $(CC) /Fo$(OBJ_D)\obj_dat.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\objects\obj_dat.c
1113
1114$(OBJ_D)\obj_lib.obj: $(SRC_D)\crypto\objects\obj_lib.c
1115 $(CC) /Fo$(OBJ_D)\obj_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\objects\obj_lib.c
1116
1117$(OBJ_D)\obj_err.obj: $(SRC_D)\crypto\objects\obj_err.c
1118 $(CC) /Fo$(OBJ_D)\obj_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\objects\obj_err.c
1119
1120$(OBJ_D)\encode.obj: $(SRC_D)\crypto\evp\encode.c
1121 $(CC) /Fo$(OBJ_D)\encode.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\encode.c
1122
1123$(OBJ_D)\digest.obj: $(SRC_D)\crypto\evp\digest.c
1124 $(CC) /Fo$(OBJ_D)\digest.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\digest.c
1125
1126$(OBJ_D)\evp_enc.obj: $(SRC_D)\crypto\evp\evp_enc.c
1127 $(CC) /Fo$(OBJ_D)\evp_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\evp_enc.c
1128
1129$(OBJ_D)\evp_key.obj: $(SRC_D)\crypto\evp\evp_key.c
1130 $(CC) /Fo$(OBJ_D)\evp_key.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\evp_key.c
1131
1132$(OBJ_D)\e_ecb_d.obj: $(SRC_D)\crypto\evp\e_ecb_d.c
1133 $(CC) /Fo$(OBJ_D)\e_ecb_d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_d.c
1134
1135$(OBJ_D)\e_cbc_d.obj: $(SRC_D)\crypto\evp\e_cbc_d.c
1136 $(CC) /Fo$(OBJ_D)\e_cbc_d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_d.c
1137
1138$(OBJ_D)\e_cfb_d.obj: $(SRC_D)\crypto\evp\e_cfb_d.c
1139 $(CC) /Fo$(OBJ_D)\e_cfb_d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_d.c
1140
1141$(OBJ_D)\e_ofb_d.obj: $(SRC_D)\crypto\evp\e_ofb_d.c
1142 $(CC) /Fo$(OBJ_D)\e_ofb_d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_d.c
1143
1144$(OBJ_D)\e_ecb_i.obj: $(SRC_D)\crypto\evp\e_ecb_i.c
1145 $(CC) /Fo$(OBJ_D)\e_ecb_i.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_i.c
1146
1147$(OBJ_D)\e_cbc_i.obj: $(SRC_D)\crypto\evp\e_cbc_i.c
1148 $(CC) /Fo$(OBJ_D)\e_cbc_i.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_i.c
1149
1150$(OBJ_D)\e_cfb_i.obj: $(SRC_D)\crypto\evp\e_cfb_i.c
1151 $(CC) /Fo$(OBJ_D)\e_cfb_i.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_i.c
1152
1153$(OBJ_D)\e_ofb_i.obj: $(SRC_D)\crypto\evp\e_ofb_i.c
1154 $(CC) /Fo$(OBJ_D)\e_ofb_i.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_i.c
1155
1156$(OBJ_D)\e_ecb_3d.obj: $(SRC_D)\crypto\evp\e_ecb_3d.c
1157 $(CC) /Fo$(OBJ_D)\e_ecb_3d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_3d.c
1158
1159$(OBJ_D)\e_cbc_3d.obj: $(SRC_D)\crypto\evp\e_cbc_3d.c
1160 $(CC) /Fo$(OBJ_D)\e_cbc_3d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_3d.c
1161
1162$(OBJ_D)\e_rc4.obj: $(SRC_D)\crypto\evp\e_rc4.c
1163 $(CC) /Fo$(OBJ_D)\e_rc4.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_rc4.c
1164
1165$(OBJ_D)\names.obj: $(SRC_D)\crypto\evp\names.c
1166 $(CC) /Fo$(OBJ_D)\names.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\names.c
1167
1168$(OBJ_D)\e_cfb_3d.obj: $(SRC_D)\crypto\evp\e_cfb_3d.c
1169 $(CC) /Fo$(OBJ_D)\e_cfb_3d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_3d.c
1170
1171$(OBJ_D)\e_ofb_3d.obj: $(SRC_D)\crypto\evp\e_ofb_3d.c
1172 $(CC) /Fo$(OBJ_D)\e_ofb_3d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_3d.c
1173
1174$(OBJ_D)\e_xcbc_d.obj: $(SRC_D)\crypto\evp\e_xcbc_d.c
1175 $(CC) /Fo$(OBJ_D)\e_xcbc_d.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_xcbc_d.c
1176
1177$(OBJ_D)\e_ecb_r2.obj: $(SRC_D)\crypto\evp\e_ecb_r2.c
1178 $(CC) /Fo$(OBJ_D)\e_ecb_r2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_r2.c
1179
1180$(OBJ_D)\e_cbc_r2.obj: $(SRC_D)\crypto\evp\e_cbc_r2.c
1181 $(CC) /Fo$(OBJ_D)\e_cbc_r2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_r2.c
1182
1183$(OBJ_D)\e_cfb_r2.obj: $(SRC_D)\crypto\evp\e_cfb_r2.c
1184 $(CC) /Fo$(OBJ_D)\e_cfb_r2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_r2.c
1185
1186$(OBJ_D)\e_ofb_r2.obj: $(SRC_D)\crypto\evp\e_ofb_r2.c
1187 $(CC) /Fo$(OBJ_D)\e_ofb_r2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_r2.c
1188
1189$(OBJ_D)\e_ecb_bf.obj: $(SRC_D)\crypto\evp\e_ecb_bf.c
1190 $(CC) /Fo$(OBJ_D)\e_ecb_bf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_bf.c
1191
1192$(OBJ_D)\e_cbc_bf.obj: $(SRC_D)\crypto\evp\e_cbc_bf.c
1193 $(CC) /Fo$(OBJ_D)\e_cbc_bf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_bf.c
1194
1195$(OBJ_D)\e_cfb_bf.obj: $(SRC_D)\crypto\evp\e_cfb_bf.c
1196 $(CC) /Fo$(OBJ_D)\e_cfb_bf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_bf.c
1197
1198$(OBJ_D)\e_ofb_bf.obj: $(SRC_D)\crypto\evp\e_ofb_bf.c
1199 $(CC) /Fo$(OBJ_D)\e_ofb_bf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_bf.c
1200
1201$(OBJ_D)\e_ecb_c.obj: $(SRC_D)\crypto\evp\e_ecb_c.c
1202 $(CC) /Fo$(OBJ_D)\e_ecb_c.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_c.c
1203
1204$(OBJ_D)\e_cbc_c.obj: $(SRC_D)\crypto\evp\e_cbc_c.c
1205 $(CC) /Fo$(OBJ_D)\e_cbc_c.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_c.c
1206
1207$(OBJ_D)\e_cfb_c.obj: $(SRC_D)\crypto\evp\e_cfb_c.c
1208 $(CC) /Fo$(OBJ_D)\e_cfb_c.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_c.c
1209
1210$(OBJ_D)\e_ofb_c.obj: $(SRC_D)\crypto\evp\e_ofb_c.c
1211 $(CC) /Fo$(OBJ_D)\e_ofb_c.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_c.c
1212
1213$(OBJ_D)\e_ecb_r5.obj: $(SRC_D)\crypto\evp\e_ecb_r5.c
1214 $(CC) /Fo$(OBJ_D)\e_ecb_r5.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ecb_r5.c
1215
1216$(OBJ_D)\e_cbc_r5.obj: $(SRC_D)\crypto\evp\e_cbc_r5.c
1217 $(CC) /Fo$(OBJ_D)\e_cbc_r5.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cbc_r5.c
1218
1219$(OBJ_D)\e_cfb_r5.obj: $(SRC_D)\crypto\evp\e_cfb_r5.c
1220 $(CC) /Fo$(OBJ_D)\e_cfb_r5.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_cfb_r5.c
1221
1222$(OBJ_D)\e_ofb_r5.obj: $(SRC_D)\crypto\evp\e_ofb_r5.c
1223 $(CC) /Fo$(OBJ_D)\e_ofb_r5.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_ofb_r5.c
1224
1225$(OBJ_D)\m_null.obj: $(SRC_D)\crypto\evp\m_null.c
1226 $(CC) /Fo$(OBJ_D)\m_null.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_null.c
1227
1228$(OBJ_D)\m_md2.obj: $(SRC_D)\crypto\evp\m_md2.c
1229 $(CC) /Fo$(OBJ_D)\m_md2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_md2.c
1230
1231$(OBJ_D)\m_md5.obj: $(SRC_D)\crypto\evp\m_md5.c
1232 $(CC) /Fo$(OBJ_D)\m_md5.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_md5.c
1233
1234$(OBJ_D)\m_sha.obj: $(SRC_D)\crypto\evp\m_sha.c
1235 $(CC) /Fo$(OBJ_D)\m_sha.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_sha.c
1236
1237$(OBJ_D)\m_sha1.obj: $(SRC_D)\crypto\evp\m_sha1.c
1238 $(CC) /Fo$(OBJ_D)\m_sha1.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_sha1.c
1239
1240$(OBJ_D)\m_dss.obj: $(SRC_D)\crypto\evp\m_dss.c
1241 $(CC) /Fo$(OBJ_D)\m_dss.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_dss.c
1242
1243$(OBJ_D)\m_dss1.obj: $(SRC_D)\crypto\evp\m_dss1.c
1244 $(CC) /Fo$(OBJ_D)\m_dss1.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_dss1.c
1245
1246$(OBJ_D)\m_mdc2.obj: $(SRC_D)\crypto\evp\m_mdc2.c
1247 $(CC) /Fo$(OBJ_D)\m_mdc2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_mdc2.c
1248
1249$(OBJ_D)\m_ripemd.obj: $(SRC_D)\crypto\evp\m_ripemd.c
1250 $(CC) /Fo$(OBJ_D)\m_ripemd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\m_ripemd.c
1251
1252$(OBJ_D)\p_open.obj: $(SRC_D)\crypto\evp\p_open.c
1253 $(CC) /Fo$(OBJ_D)\p_open.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_open.c
1254
1255$(OBJ_D)\p_seal.obj: $(SRC_D)\crypto\evp\p_seal.c
1256 $(CC) /Fo$(OBJ_D)\p_seal.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_seal.c
1257
1258$(OBJ_D)\p_sign.obj: $(SRC_D)\crypto\evp\p_sign.c
1259 $(CC) /Fo$(OBJ_D)\p_sign.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_sign.c
1260
1261$(OBJ_D)\p_verify.obj: $(SRC_D)\crypto\evp\p_verify.c
1262 $(CC) /Fo$(OBJ_D)\p_verify.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_verify.c
1263
1264$(OBJ_D)\p_lib.obj: $(SRC_D)\crypto\evp\p_lib.c
1265 $(CC) /Fo$(OBJ_D)\p_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_lib.c
1266
1267$(OBJ_D)\p_enc.obj: $(SRC_D)\crypto\evp\p_enc.c
1268 $(CC) /Fo$(OBJ_D)\p_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_enc.c
1269
1270$(OBJ_D)\p_dec.obj: $(SRC_D)\crypto\evp\p_dec.c
1271 $(CC) /Fo$(OBJ_D)\p_dec.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\p_dec.c
1272
1273$(OBJ_D)\bio_md.obj: $(SRC_D)\crypto\evp\bio_md.c
1274 $(CC) /Fo$(OBJ_D)\bio_md.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\bio_md.c
1275
1276$(OBJ_D)\bio_b64.obj: $(SRC_D)\crypto\evp\bio_b64.c
1277 $(CC) /Fo$(OBJ_D)\bio_b64.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\bio_b64.c
1278
1279$(OBJ_D)\bio_enc.obj: $(SRC_D)\crypto\evp\bio_enc.c
1280 $(CC) /Fo$(OBJ_D)\bio_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\bio_enc.c
1281
1282$(OBJ_D)\evp_err.obj: $(SRC_D)\crypto\evp\evp_err.c
1283 $(CC) /Fo$(OBJ_D)\evp_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\evp_err.c
1284
1285$(OBJ_D)\e_null.obj: $(SRC_D)\crypto\evp\e_null.c
1286 $(CC) /Fo$(OBJ_D)\e_null.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\e_null.c
1287
1288$(OBJ_D)\c_all.obj: $(SRC_D)\crypto\evp\c_all.c
1289 $(CC) /Fo$(OBJ_D)\c_all.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\c_all.c
1290
1291$(OBJ_D)\evp_lib.obj: $(SRC_D)\crypto\evp\evp_lib.c
1292 $(CC) /Fo$(OBJ_D)\evp_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\evp\evp_lib.c
1293
1294$(OBJ_D)\pem_sign.obj: $(SRC_D)\crypto\pem\pem_sign.c
1295 $(CC) /Fo$(OBJ_D)\pem_sign.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_sign.c
1296
1297$(OBJ_D)\pem_seal.obj: $(SRC_D)\crypto\pem\pem_seal.c
1298 $(CC) /Fo$(OBJ_D)\pem_seal.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_seal.c
1299
1300$(OBJ_D)\pem_info.obj: $(SRC_D)\crypto\pem\pem_info.c
1301 $(CC) /Fo$(OBJ_D)\pem_info.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_info.c
1302
1303$(OBJ_D)\pem_lib.obj: $(SRC_D)\crypto\pem\pem_lib.c
1304 $(CC) /Fo$(OBJ_D)\pem_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_lib.c
1305
1306$(OBJ_D)\pem_all.obj: $(SRC_D)\crypto\pem\pem_all.c
1307 $(CC) /Fo$(OBJ_D)\pem_all.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_all.c
1308
1309$(OBJ_D)\pem_err.obj: $(SRC_D)\crypto\pem\pem_err.c
1310 $(CC) /Fo$(OBJ_D)\pem_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pem\pem_err.c
1311
1312$(OBJ_D)\a_object.obj: $(SRC_D)\crypto\asn1\a_object.c
1313 $(CC) /Fo$(OBJ_D)\a_object.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_object.c
1314
1315$(OBJ_D)\a_bitstr.obj: $(SRC_D)\crypto\asn1\a_bitstr.c
1316 $(CC) /Fo$(OBJ_D)\a_bitstr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_bitstr.c
1317
1318$(OBJ_D)\a_utctm.obj: $(SRC_D)\crypto\asn1\a_utctm.c
1319 $(CC) /Fo$(OBJ_D)\a_utctm.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_utctm.c
1320
1321$(OBJ_D)\a_int.obj: $(SRC_D)\crypto\asn1\a_int.c
1322 $(CC) /Fo$(OBJ_D)\a_int.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_int.c
1323
1324$(OBJ_D)\a_octet.obj: $(SRC_D)\crypto\asn1\a_octet.c
1325 $(CC) /Fo$(OBJ_D)\a_octet.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_octet.c
1326
1327$(OBJ_D)\a_print.obj: $(SRC_D)\crypto\asn1\a_print.c
1328 $(CC) /Fo$(OBJ_D)\a_print.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_print.c
1329
1330$(OBJ_D)\a_type.obj: $(SRC_D)\crypto\asn1\a_type.c
1331 $(CC) /Fo$(OBJ_D)\a_type.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_type.c
1332
1333$(OBJ_D)\a_set.obj: $(SRC_D)\crypto\asn1\a_set.c
1334 $(CC) /Fo$(OBJ_D)\a_set.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_set.c
1335
1336$(OBJ_D)\a_dup.obj: $(SRC_D)\crypto\asn1\a_dup.c
1337 $(CC) /Fo$(OBJ_D)\a_dup.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_dup.c
1338
1339$(OBJ_D)\a_d2i_fp.obj: $(SRC_D)\crypto\asn1\a_d2i_fp.c
1340 $(CC) /Fo$(OBJ_D)\a_d2i_fp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_d2i_fp.c
1341
1342$(OBJ_D)\a_i2d_fp.obj: $(SRC_D)\crypto\asn1\a_i2d_fp.c
1343 $(CC) /Fo$(OBJ_D)\a_i2d_fp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_i2d_fp.c
1344
1345$(OBJ_D)\a_sign.obj: $(SRC_D)\crypto\asn1\a_sign.c
1346 $(CC) /Fo$(OBJ_D)\a_sign.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_sign.c
1347
1348$(OBJ_D)\a_digest.obj: $(SRC_D)\crypto\asn1\a_digest.c
1349 $(CC) /Fo$(OBJ_D)\a_digest.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_digest.c
1350
1351$(OBJ_D)\a_verify.obj: $(SRC_D)\crypto\asn1\a_verify.c
1352 $(CC) /Fo$(OBJ_D)\a_verify.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_verify.c
1353
1354$(OBJ_D)\x_algor.obj: $(SRC_D)\crypto\asn1\x_algor.c
1355 $(CC) /Fo$(OBJ_D)\x_algor.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_algor.c
1356
1357$(OBJ_D)\x_val.obj: $(SRC_D)\crypto\asn1\x_val.c
1358 $(CC) /Fo$(OBJ_D)\x_val.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_val.c
1359
1360$(OBJ_D)\x_pubkey.obj: $(SRC_D)\crypto\asn1\x_pubkey.c
1361 $(CC) /Fo$(OBJ_D)\x_pubkey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_pubkey.c
1362
1363$(OBJ_D)\x_sig.obj: $(SRC_D)\crypto\asn1\x_sig.c
1364 $(CC) /Fo$(OBJ_D)\x_sig.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_sig.c
1365
1366$(OBJ_D)\x_req.obj: $(SRC_D)\crypto\asn1\x_req.c
1367 $(CC) /Fo$(OBJ_D)\x_req.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_req.c
1368
1369$(OBJ_D)\x_attrib.obj: $(SRC_D)\crypto\asn1\x_attrib.c
1370 $(CC) /Fo$(OBJ_D)\x_attrib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_attrib.c
1371
1372$(OBJ_D)\x_name.obj: $(SRC_D)\crypto\asn1\x_name.c
1373 $(CC) /Fo$(OBJ_D)\x_name.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_name.c
1374
1375$(OBJ_D)\x_cinf.obj: $(SRC_D)\crypto\asn1\x_cinf.c
1376 $(CC) /Fo$(OBJ_D)\x_cinf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_cinf.c
1377
1378$(OBJ_D)\x_x509.obj: $(SRC_D)\crypto\asn1\x_x509.c
1379 $(CC) /Fo$(OBJ_D)\x_x509.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_x509.c
1380
1381$(OBJ_D)\x_crl.obj: $(SRC_D)\crypto\asn1\x_crl.c
1382 $(CC) /Fo$(OBJ_D)\x_crl.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_crl.c
1383
1384$(OBJ_D)\x_info.obj: $(SRC_D)\crypto\asn1\x_info.c
1385 $(CC) /Fo$(OBJ_D)\x_info.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_info.c
1386
1387$(OBJ_D)\x_spki.obj: $(SRC_D)\crypto\asn1\x_spki.c
1388 $(CC) /Fo$(OBJ_D)\x_spki.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_spki.c
1389
1390$(OBJ_D)\d2i_r_pr.obj: $(SRC_D)\crypto\asn1\d2i_r_pr.c
1391 $(CC) /Fo$(OBJ_D)\d2i_r_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_r_pr.c
1392
1393$(OBJ_D)\i2d_r_pr.obj: $(SRC_D)\crypto\asn1\i2d_r_pr.c
1394 $(CC) /Fo$(OBJ_D)\i2d_r_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_r_pr.c
1395
1396$(OBJ_D)\d2i_r_pu.obj: $(SRC_D)\crypto\asn1\d2i_r_pu.c
1397 $(CC) /Fo$(OBJ_D)\d2i_r_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_r_pu.c
1398
1399$(OBJ_D)\i2d_r_pu.obj: $(SRC_D)\crypto\asn1\i2d_r_pu.c
1400 $(CC) /Fo$(OBJ_D)\i2d_r_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_r_pu.c
1401
1402$(OBJ_D)\d2i_s_pr.obj: $(SRC_D)\crypto\asn1\d2i_s_pr.c
1403 $(CC) /Fo$(OBJ_D)\d2i_s_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_s_pr.c
1404
1405$(OBJ_D)\i2d_s_pr.obj: $(SRC_D)\crypto\asn1\i2d_s_pr.c
1406 $(CC) /Fo$(OBJ_D)\i2d_s_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_s_pr.c
1407
1408$(OBJ_D)\d2i_s_pu.obj: $(SRC_D)\crypto\asn1\d2i_s_pu.c
1409 $(CC) /Fo$(OBJ_D)\d2i_s_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_s_pu.c
1410
1411$(OBJ_D)\i2d_s_pu.obj: $(SRC_D)\crypto\asn1\i2d_s_pu.c
1412 $(CC) /Fo$(OBJ_D)\i2d_s_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_s_pu.c
1413
1414$(OBJ_D)\d2i_pu.obj: $(SRC_D)\crypto\asn1\d2i_pu.c
1415 $(CC) /Fo$(OBJ_D)\d2i_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_pu.c
1416
1417$(OBJ_D)\d2i_pr.obj: $(SRC_D)\crypto\asn1\d2i_pr.c
1418 $(CC) /Fo$(OBJ_D)\d2i_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_pr.c
1419
1420$(OBJ_D)\i2d_pu.obj: $(SRC_D)\crypto\asn1\i2d_pu.c
1421 $(CC) /Fo$(OBJ_D)\i2d_pu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_pu.c
1422
1423$(OBJ_D)\i2d_pr.obj: $(SRC_D)\crypto\asn1\i2d_pr.c
1424 $(CC) /Fo$(OBJ_D)\i2d_pr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_pr.c
1425
1426$(OBJ_D)\t_req.obj: $(SRC_D)\crypto\asn1\t_req.c
1427 $(CC) /Fo$(OBJ_D)\t_req.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\t_req.c
1428
1429$(OBJ_D)\t_x509.obj: $(SRC_D)\crypto\asn1\t_x509.c
1430 $(CC) /Fo$(OBJ_D)\t_x509.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\t_x509.c
1431
1432$(OBJ_D)\t_pkey.obj: $(SRC_D)\crypto\asn1\t_pkey.c
1433 $(CC) /Fo$(OBJ_D)\t_pkey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\t_pkey.c
1434
1435$(OBJ_D)\p7_i_s.obj: $(SRC_D)\crypto\asn1\p7_i_s.c
1436 $(CC) /Fo$(OBJ_D)\p7_i_s.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_i_s.c
1437
1438$(OBJ_D)\p7_signi.obj: $(SRC_D)\crypto\asn1\p7_signi.c
1439 $(CC) /Fo$(OBJ_D)\p7_signi.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_signi.c
1440
1441$(OBJ_D)\p7_signd.obj: $(SRC_D)\crypto\asn1\p7_signd.c
1442 $(CC) /Fo$(OBJ_D)\p7_signd.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_signd.c
1443
1444$(OBJ_D)\p7_recip.obj: $(SRC_D)\crypto\asn1\p7_recip.c
1445 $(CC) /Fo$(OBJ_D)\p7_recip.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_recip.c
1446
1447$(OBJ_D)\p7_enc_c.obj: $(SRC_D)\crypto\asn1\p7_enc_c.c
1448 $(CC) /Fo$(OBJ_D)\p7_enc_c.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_enc_c.c
1449
1450$(OBJ_D)\p7_evp.obj: $(SRC_D)\crypto\asn1\p7_evp.c
1451 $(CC) /Fo$(OBJ_D)\p7_evp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_evp.c
1452
1453$(OBJ_D)\p7_dgst.obj: $(SRC_D)\crypto\asn1\p7_dgst.c
1454 $(CC) /Fo$(OBJ_D)\p7_dgst.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_dgst.c
1455
1456$(OBJ_D)\p7_s_e.obj: $(SRC_D)\crypto\asn1\p7_s_e.c
1457 $(CC) /Fo$(OBJ_D)\p7_s_e.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_s_e.c
1458
1459$(OBJ_D)\p7_enc.obj: $(SRC_D)\crypto\asn1\p7_enc.c
1460 $(CC) /Fo$(OBJ_D)\p7_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_enc.c
1461
1462$(OBJ_D)\p7_lib.obj: $(SRC_D)\crypto\asn1\p7_lib.c
1463 $(CC) /Fo$(OBJ_D)\p7_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\p7_lib.c
1464
1465$(OBJ_D)\f_int.obj: $(SRC_D)\crypto\asn1\f_int.c
1466 $(CC) /Fo$(OBJ_D)\f_int.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\f_int.c
1467
1468$(OBJ_D)\f_string.obj: $(SRC_D)\crypto\asn1\f_string.c
1469 $(CC) /Fo$(OBJ_D)\f_string.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\f_string.c
1470
1471$(OBJ_D)\i2d_dhp.obj: $(SRC_D)\crypto\asn1\i2d_dhp.c
1472 $(CC) /Fo$(OBJ_D)\i2d_dhp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_dhp.c
1473
1474$(OBJ_D)\i2d_dsap.obj: $(SRC_D)\crypto\asn1\i2d_dsap.c
1475 $(CC) /Fo$(OBJ_D)\i2d_dsap.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\i2d_dsap.c
1476
1477$(OBJ_D)\d2i_dhp.obj: $(SRC_D)\crypto\asn1\d2i_dhp.c
1478 $(CC) /Fo$(OBJ_D)\d2i_dhp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_dhp.c
1479
1480$(OBJ_D)\d2i_dsap.obj: $(SRC_D)\crypto\asn1\d2i_dsap.c
1481 $(CC) /Fo$(OBJ_D)\d2i_dsap.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\d2i_dsap.c
1482
1483$(OBJ_D)\n_pkey.obj: $(SRC_D)\crypto\asn1\n_pkey.c
1484 $(CC) /Fo$(OBJ_D)\n_pkey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\n_pkey.c
1485
1486$(OBJ_D)\a_hdr.obj: $(SRC_D)\crypto\asn1\a_hdr.c
1487 $(CC) /Fo$(OBJ_D)\a_hdr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_hdr.c
1488
1489$(OBJ_D)\x_pkey.obj: $(SRC_D)\crypto\asn1\x_pkey.c
1490 $(CC) /Fo$(OBJ_D)\x_pkey.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_pkey.c
1491
1492$(OBJ_D)\a_bool.obj: $(SRC_D)\crypto\asn1\a_bool.c
1493 $(CC) /Fo$(OBJ_D)\a_bool.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_bool.c
1494
1495$(OBJ_D)\x_exten.obj: $(SRC_D)\crypto\asn1\x_exten.c
1496 $(CC) /Fo$(OBJ_D)\x_exten.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\x_exten.c
1497
1498$(OBJ_D)\asn1_par.obj: $(SRC_D)\crypto\asn1\asn1_par.c
1499 $(CC) /Fo$(OBJ_D)\asn1_par.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\asn1_par.c
1500
1501$(OBJ_D)\asn1_lib.obj: $(SRC_D)\crypto\asn1\asn1_lib.c
1502 $(CC) /Fo$(OBJ_D)\asn1_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\asn1_lib.c
1503
1504$(OBJ_D)\asn1_err.obj: $(SRC_D)\crypto\asn1\asn1_err.c
1505 $(CC) /Fo$(OBJ_D)\asn1_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\asn1_err.c
1506
1507$(OBJ_D)\a_meth.obj: $(SRC_D)\crypto\asn1\a_meth.c
1508 $(CC) /Fo$(OBJ_D)\a_meth.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_meth.c
1509
1510$(OBJ_D)\a_bytes.obj: $(SRC_D)\crypto\asn1\a_bytes.c
1511 $(CC) /Fo$(OBJ_D)\a_bytes.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\a_bytes.c
1512
1513$(OBJ_D)\evp_asn1.obj: $(SRC_D)\crypto\asn1\evp_asn1.c
1514 $(CC) /Fo$(OBJ_D)\evp_asn1.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\asn1\evp_asn1.c
1515
1516$(OBJ_D)\x509_def.obj: $(SRC_D)\crypto\x509\x509_def.c
1517 $(CC) /Fo$(OBJ_D)\x509_def.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_def.c
1518
1519$(OBJ_D)\x509_d2.obj: $(SRC_D)\crypto\x509\x509_d2.c
1520 $(CC) /Fo$(OBJ_D)\x509_d2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_d2.c
1521
1522$(OBJ_D)\x509_r2x.obj: $(SRC_D)\crypto\x509\x509_r2x.c
1523 $(CC) /Fo$(OBJ_D)\x509_r2x.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_r2x.c
1524
1525$(OBJ_D)\x509_cmp.obj: $(SRC_D)\crypto\x509\x509_cmp.c
1526 $(CC) /Fo$(OBJ_D)\x509_cmp.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_cmp.c
1527
1528$(OBJ_D)\x509_obj.obj: $(SRC_D)\crypto\x509\x509_obj.c
1529 $(CC) /Fo$(OBJ_D)\x509_obj.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_obj.c
1530
1531$(OBJ_D)\x509_req.obj: $(SRC_D)\crypto\x509\x509_req.c
1532 $(CC) /Fo$(OBJ_D)\x509_req.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_req.c
1533
1534$(OBJ_D)\x509_vfy.obj: $(SRC_D)\crypto\x509\x509_vfy.c
1535 $(CC) /Fo$(OBJ_D)\x509_vfy.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_vfy.c
1536
1537$(OBJ_D)\x509_set.obj: $(SRC_D)\crypto\x509\x509_set.c
1538 $(CC) /Fo$(OBJ_D)\x509_set.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_set.c
1539
1540$(OBJ_D)\x509rset.obj: $(SRC_D)\crypto\x509\x509rset.c
1541 $(CC) /Fo$(OBJ_D)\x509rset.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509rset.c
1542
1543$(OBJ_D)\x509_err.obj: $(SRC_D)\crypto\x509\x509_err.c
1544 $(CC) /Fo$(OBJ_D)\x509_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_err.c
1545
1546$(OBJ_D)\x509name.obj: $(SRC_D)\crypto\x509\x509name.c
1547 $(CC) /Fo$(OBJ_D)\x509name.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509name.c
1548
1549$(OBJ_D)\x509_v3.obj: $(SRC_D)\crypto\x509\x509_v3.c
1550 $(CC) /Fo$(OBJ_D)\x509_v3.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_v3.c
1551
1552$(OBJ_D)\x509_ext.obj: $(SRC_D)\crypto\x509\x509_ext.c
1553 $(CC) /Fo$(OBJ_D)\x509_ext.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_ext.c
1554
1555$(OBJ_D)\x509pack.obj: $(SRC_D)\crypto\x509\x509pack.c
1556 $(CC) /Fo$(OBJ_D)\x509pack.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509pack.c
1557
1558$(OBJ_D)\x509type.obj: $(SRC_D)\crypto\x509\x509type.c
1559 $(CC) /Fo$(OBJ_D)\x509type.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509type.c
1560
1561$(OBJ_D)\x509_lu.obj: $(SRC_D)\crypto\x509\x509_lu.c
1562 $(CC) /Fo$(OBJ_D)\x509_lu.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_lu.c
1563
1564$(OBJ_D)\x_all.obj: $(SRC_D)\crypto\x509\x_all.c
1565 $(CC) /Fo$(OBJ_D)\x_all.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x_all.c
1566
1567$(OBJ_D)\x509_txt.obj: $(SRC_D)\crypto\x509\x509_txt.c
1568 $(CC) /Fo$(OBJ_D)\x509_txt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\x509_txt.c
1569
1570$(OBJ_D)\by_file.obj: $(SRC_D)\crypto\x509\by_file.c
1571 $(CC) /Fo$(OBJ_D)\by_file.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\by_file.c
1572
1573$(OBJ_D)\by_dir.obj: $(SRC_D)\crypto\x509\by_dir.c
1574 $(CC) /Fo$(OBJ_D)\by_dir.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\by_dir.c
1575
1576$(OBJ_D)\v3_net.obj: $(SRC_D)\crypto\x509\v3_net.c
1577 $(CC) /Fo$(OBJ_D)\v3_net.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\v3_net.c
1578
1579$(OBJ_D)\v3_x509.obj: $(SRC_D)\crypto\x509\v3_x509.c
1580 $(CC) /Fo$(OBJ_D)\v3_x509.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\x509\v3_x509.c
1581
1582$(OBJ_D)\conf.obj: $(SRC_D)\crypto\conf\conf.c
1583 $(CC) /Fo$(OBJ_D)\conf.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\conf\conf.c
1584
1585$(OBJ_D)\conf_err.obj: $(SRC_D)\crypto\conf\conf_err.c
1586 $(CC) /Fo$(OBJ_D)\conf_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\conf\conf_err.c
1587
1588$(OBJ_D)\txt_db.obj: $(SRC_D)\crypto\txt_db\txt_db.c
1589 $(CC) /Fo$(OBJ_D)\txt_db.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\txt_db\txt_db.c
1590
1591$(OBJ_D)\pk7_lib.obj: $(SRC_D)\crypto\pkcs7\pk7_lib.c
1592 $(CC) /Fo$(OBJ_D)\pk7_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pkcs7\pk7_lib.c
1593
1594$(OBJ_D)\pkcs7err.obj: $(SRC_D)\crypto\pkcs7\pkcs7err.c
1595 $(CC) /Fo$(OBJ_D)\pkcs7err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pkcs7\pkcs7err.c
1596
1597$(OBJ_D)\pk7_doit.obj: $(SRC_D)\crypto\pkcs7\pk7_doit.c
1598 $(CC) /Fo$(OBJ_D)\pk7_doit.obj $(SHLIB_CFLAGS) -c $(SRC_D)\crypto\pkcs7\pk7_doit.c
1599
1600$(OBJ_D)\s2_meth.obj: $(SRC_D)\ssl\s2_meth.c
1601 $(CC) /Fo$(OBJ_D)\s2_meth.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_meth.c
1602
1603$(OBJ_D)\s2_srvr.obj: $(SRC_D)\ssl\s2_srvr.c
1604 $(CC) /Fo$(OBJ_D)\s2_srvr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_srvr.c
1605
1606$(OBJ_D)\s2_clnt.obj: $(SRC_D)\ssl\s2_clnt.c
1607 $(CC) /Fo$(OBJ_D)\s2_clnt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_clnt.c
1608
1609$(OBJ_D)\s2_lib.obj: $(SRC_D)\ssl\s2_lib.c
1610 $(CC) /Fo$(OBJ_D)\s2_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_lib.c
1611
1612$(OBJ_D)\s2_enc.obj: $(SRC_D)\ssl\s2_enc.c
1613 $(CC) /Fo$(OBJ_D)\s2_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_enc.c
1614
1615$(OBJ_D)\s2_pkt.obj: $(SRC_D)\ssl\s2_pkt.c
1616 $(CC) /Fo$(OBJ_D)\s2_pkt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s2_pkt.c
1617
1618$(OBJ_D)\s3_meth.obj: $(SRC_D)\ssl\s3_meth.c
1619 $(CC) /Fo$(OBJ_D)\s3_meth.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_meth.c
1620
1621$(OBJ_D)\s3_srvr.obj: $(SRC_D)\ssl\s3_srvr.c
1622 $(CC) /Fo$(OBJ_D)\s3_srvr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_srvr.c
1623
1624$(OBJ_D)\s3_clnt.obj: $(SRC_D)\ssl\s3_clnt.c
1625 $(CC) /Fo$(OBJ_D)\s3_clnt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_clnt.c
1626
1627$(OBJ_D)\s3_lib.obj: $(SRC_D)\ssl\s3_lib.c
1628 $(CC) /Fo$(OBJ_D)\s3_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_lib.c
1629
1630$(OBJ_D)\s3_enc.obj: $(SRC_D)\ssl\s3_enc.c
1631 $(CC) /Fo$(OBJ_D)\s3_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_enc.c
1632
1633$(OBJ_D)\s3_pkt.obj: $(SRC_D)\ssl\s3_pkt.c
1634 $(CC) /Fo$(OBJ_D)\s3_pkt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_pkt.c
1635
1636$(OBJ_D)\s3_both.obj: $(SRC_D)\ssl\s3_both.c
1637 $(CC) /Fo$(OBJ_D)\s3_both.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s3_both.c
1638
1639$(OBJ_D)\s23_meth.obj: $(SRC_D)\ssl\s23_meth.c
1640 $(CC) /Fo$(OBJ_D)\s23_meth.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s23_meth.c
1641
1642$(OBJ_D)\s23_srvr.obj: $(SRC_D)\ssl\s23_srvr.c
1643 $(CC) /Fo$(OBJ_D)\s23_srvr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s23_srvr.c
1644
1645$(OBJ_D)\s23_clnt.obj: $(SRC_D)\ssl\s23_clnt.c
1646 $(CC) /Fo$(OBJ_D)\s23_clnt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s23_clnt.c
1647
1648$(OBJ_D)\s23_lib.obj: $(SRC_D)\ssl\s23_lib.c
1649 $(CC) /Fo$(OBJ_D)\s23_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s23_lib.c
1650
1651$(OBJ_D)\s23_pkt.obj: $(SRC_D)\ssl\s23_pkt.c
1652 $(CC) /Fo$(OBJ_D)\s23_pkt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\s23_pkt.c
1653
1654$(OBJ_D)\t1_meth.obj: $(SRC_D)\ssl\t1_meth.c
1655 $(CC) /Fo$(OBJ_D)\t1_meth.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\t1_meth.c
1656
1657$(OBJ_D)\t1_srvr.obj: $(SRC_D)\ssl\t1_srvr.c
1658 $(CC) /Fo$(OBJ_D)\t1_srvr.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\t1_srvr.c
1659
1660$(OBJ_D)\t1_clnt.obj: $(SRC_D)\ssl\t1_clnt.c
1661 $(CC) /Fo$(OBJ_D)\t1_clnt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\t1_clnt.c
1662
1663$(OBJ_D)\t1_lib.obj: $(SRC_D)\ssl\t1_lib.c
1664 $(CC) /Fo$(OBJ_D)\t1_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\t1_lib.c
1665
1666$(OBJ_D)\t1_enc.obj: $(SRC_D)\ssl\t1_enc.c
1667 $(CC) /Fo$(OBJ_D)\t1_enc.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\t1_enc.c
1668
1669$(OBJ_D)\ssl_lib.obj: $(SRC_D)\ssl\ssl_lib.c
1670 $(CC) /Fo$(OBJ_D)\ssl_lib.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_lib.c
1671
1672$(OBJ_D)\ssl_err2.obj: $(SRC_D)\ssl\ssl_err2.c
1673 $(CC) /Fo$(OBJ_D)\ssl_err2.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_err2.c
1674
1675$(OBJ_D)\ssl_cert.obj: $(SRC_D)\ssl\ssl_cert.c
1676 $(CC) /Fo$(OBJ_D)\ssl_cert.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_cert.c
1677
1678$(OBJ_D)\ssl_sess.obj: $(SRC_D)\ssl\ssl_sess.c
1679 $(CC) /Fo$(OBJ_D)\ssl_sess.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_sess.c
1680
1681$(OBJ_D)\ssl_ciph.obj: $(SRC_D)\ssl\ssl_ciph.c
1682 $(CC) /Fo$(OBJ_D)\ssl_ciph.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_ciph.c
1683
1684$(OBJ_D)\ssl_stat.obj: $(SRC_D)\ssl\ssl_stat.c
1685 $(CC) /Fo$(OBJ_D)\ssl_stat.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_stat.c
1686
1687$(OBJ_D)\ssl_rsa.obj: $(SRC_D)\ssl\ssl_rsa.c
1688 $(CC) /Fo$(OBJ_D)\ssl_rsa.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_rsa.c
1689
1690$(OBJ_D)\ssl_asn1.obj: $(SRC_D)\ssl\ssl_asn1.c
1691 $(CC) /Fo$(OBJ_D)\ssl_asn1.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_asn1.c
1692
1693$(OBJ_D)\ssl_txt.obj: $(SRC_D)\ssl\ssl_txt.c
1694 $(CC) /Fo$(OBJ_D)\ssl_txt.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_txt.c
1695
1696$(OBJ_D)\ssl_algs.obj: $(SRC_D)\ssl\ssl_algs.c
1697 $(CC) /Fo$(OBJ_D)\ssl_algs.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_algs.c
1698
1699$(OBJ_D)\bio_ssl.obj: $(SRC_D)\ssl\bio_ssl.c
1700 $(CC) /Fo$(OBJ_D)\bio_ssl.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\bio_ssl.c
1701
1702$(OBJ_D)\ssl_err.obj: $(SRC_D)\ssl\ssl_err.c
1703 $(CC) /Fo$(OBJ_D)\ssl_err.obj $(SHLIB_CFLAGS) -c $(SRC_D)\ssl\ssl_err.c
1704
1705$(OBJ_D)\rsaref.obj: $(SRC_D)\rsaref\rsaref.c
1706 $(CC) /Fo$(OBJ_D)\rsaref.obj $(LIB_CFLAGS) -c $(SRC_D)\rsaref\rsaref.c
1707
1708$(OBJ_D)\rsar_err.obj: $(SRC_D)\rsaref\rsar_err.c
1709 $(CC) /Fo$(OBJ_D)\rsar_err.obj $(LIB_CFLAGS) -c $(SRC_D)\rsaref\rsar_err.c
1710
1711$(TEST_D)\md2test.exe: $(OBJ_D)\md2test.obj $(LIBS_DEP)
1712 $(LINK) $(LFLAGS) @<<
1713 $(APP_EX_OBJ) $(OBJ_D)\md2test.obj
1714 $(TEST_D)\md2test.exe
1715
1716 $(L_LIBS) $(EX_LIBS)
1717
1718<<
1719
1720$(TEST_D)\md5test.exe: $(OBJ_D)\md5test.obj $(LIBS_DEP)
1721 $(LINK) $(LFLAGS) @<<
1722 $(APP_EX_OBJ) $(OBJ_D)\md5test.obj
1723 $(TEST_D)\md5test.exe
1724
1725 $(L_LIBS) $(EX_LIBS)
1726
1727<<
1728
1729$(TEST_D)\shatest.exe: $(OBJ_D)\shatest.obj $(LIBS_DEP)
1730 $(LINK) $(LFLAGS) @<<
1731 $(APP_EX_OBJ) $(OBJ_D)\shatest.obj
1732 $(TEST_D)\shatest.exe
1733
1734 $(L_LIBS) $(EX_LIBS)
1735
1736<<
1737
1738$(TEST_D)\sha1test.exe: $(OBJ_D)\sha1test.obj $(LIBS_DEP)
1739 $(LINK) $(LFLAGS) @<<
1740 $(APP_EX_OBJ) $(OBJ_D)\sha1test.obj
1741 $(TEST_D)\sha1test.exe
1742
1743 $(L_LIBS) $(EX_LIBS)
1744
1745<<
1746
1747$(TEST_D)\mdc2test.exe: $(OBJ_D)\mdc2test.obj $(LIBS_DEP)
1748 $(LINK) $(LFLAGS) @<<
1749 $(APP_EX_OBJ) $(OBJ_D)\mdc2test.obj
1750 $(TEST_D)\mdc2test.exe
1751
1752 $(L_LIBS) $(EX_LIBS)
1753
1754<<
1755
1756$(TEST_D)\hmactest.exe: $(OBJ_D)\hmactest.obj $(LIBS_DEP)
1757 $(LINK) $(LFLAGS) @<<
1758 $(APP_EX_OBJ) $(OBJ_D)\hmactest.obj
1759 $(TEST_D)\hmactest.exe
1760
1761 $(L_LIBS) $(EX_LIBS)
1762
1763<<
1764
1765$(TEST_D)\rmdtest.exe: $(OBJ_D)\rmdtest.obj $(LIBS_DEP)
1766 $(LINK) $(LFLAGS) @<<
1767 $(APP_EX_OBJ) $(OBJ_D)\rmdtest.obj
1768 $(TEST_D)\rmdtest.exe
1769
1770 $(L_LIBS) $(EX_LIBS)
1771
1772<<
1773
1774$(TEST_D)\destest.exe: $(OBJ_D)\destest.obj $(LIBS_DEP)
1775 $(LINK) $(LFLAGS) @<<
1776 $(APP_EX_OBJ) $(OBJ_D)\destest.obj
1777 $(TEST_D)\destest.exe
1778
1779 $(L_LIBS) $(EX_LIBS)
1780
1781<<
1782
1783$(TEST_D)\rc2test.exe: $(OBJ_D)\rc2test.obj $(LIBS_DEP)
1784 $(LINK) $(LFLAGS) @<<
1785 $(APP_EX_OBJ) $(OBJ_D)\rc2test.obj
1786 $(TEST_D)\rc2test.exe
1787
1788 $(L_LIBS) $(EX_LIBS)
1789
1790<<
1791
1792$(TEST_D)\rc4test.exe: $(OBJ_D)\rc4test.obj $(LIBS_DEP)
1793 $(LINK) $(LFLAGS) @<<
1794 $(APP_EX_OBJ) $(OBJ_D)\rc4test.obj
1795 $(TEST_D)\rc4test.exe
1796
1797 $(L_LIBS) $(EX_LIBS)
1798
1799<<
1800
1801$(TEST_D)\rc5test.exe: $(OBJ_D)\rc5test.obj $(LIBS_DEP)
1802 $(LINK) $(LFLAGS) @<<
1803 $(APP_EX_OBJ) $(OBJ_D)\rc5test.obj
1804 $(TEST_D)\rc5test.exe
1805
1806 $(L_LIBS) $(EX_LIBS)
1807
1808<<
1809
1810$(TEST_D)\ideatest.exe: $(OBJ_D)\ideatest.obj $(LIBS_DEP)
1811 $(LINK) $(LFLAGS) @<<
1812 $(APP_EX_OBJ) $(OBJ_D)\ideatest.obj
1813 $(TEST_D)\ideatest.exe
1814
1815 $(L_LIBS) $(EX_LIBS)
1816
1817<<
1818
1819$(TEST_D)\bftest.exe: $(OBJ_D)\bftest.obj $(LIBS_DEP)
1820 $(LINK) $(LFLAGS) @<<
1821 $(APP_EX_OBJ) $(OBJ_D)\bftest.obj
1822 $(TEST_D)\bftest.exe
1823
1824 $(L_LIBS) $(EX_LIBS)
1825
1826<<
1827
1828$(TEST_D)\casttest.exe: $(OBJ_D)\casttest.obj $(LIBS_DEP)
1829 $(LINK) $(LFLAGS) @<<
1830 $(APP_EX_OBJ) $(OBJ_D)\casttest.obj
1831 $(TEST_D)\casttest.exe
1832
1833 $(L_LIBS) $(EX_LIBS)
1834
1835<<
1836
1837$(TEST_D)\bntest.exe: $(OBJ_D)\bntest.obj $(LIBS_DEP)
1838 $(LINK) $(LFLAGS) @<<
1839 $(APP_EX_OBJ) $(OBJ_D)\bntest.obj
1840 $(TEST_D)\bntest.exe
1841
1842 $(L_LIBS) $(EX_LIBS)
1843
1844<<
1845
1846$(TEST_D)\exptest.exe: $(OBJ_D)\exptest.obj $(LIBS_DEP)
1847 $(LINK) $(LFLAGS) @<<
1848 $(APP_EX_OBJ) $(OBJ_D)\exptest.obj
1849 $(TEST_D)\exptest.exe
1850
1851 $(L_LIBS) $(EX_LIBS)
1852
1853<<
1854
1855$(TEST_D)\dsatest.exe: $(OBJ_D)\dsatest.obj $(LIBS_DEP)
1856 $(LINK) $(LFLAGS) @<<
1857 $(APP_EX_OBJ) $(OBJ_D)\dsatest.obj
1858 $(TEST_D)\dsatest.exe
1859
1860 $(L_LIBS) $(EX_LIBS)
1861
1862<<
1863
1864$(TEST_D)\dhtest.exe: $(OBJ_D)\dhtest.obj $(LIBS_DEP)
1865 $(LINK) $(LFLAGS) @<<
1866 $(APP_EX_OBJ) $(OBJ_D)\dhtest.obj
1867 $(TEST_D)\dhtest.exe
1868
1869 $(L_LIBS) $(EX_LIBS)
1870
1871<<
1872
1873$(TEST_D)\randtest.exe: $(OBJ_D)\randtest.obj $(LIBS_DEP)
1874 $(LINK) $(LFLAGS) @<<
1875 $(APP_EX_OBJ) $(OBJ_D)\randtest.obj
1876 $(TEST_D)\randtest.exe
1877
1878 $(L_LIBS) $(EX_LIBS)
1879
1880<<
1881
1882$(TEST_D)\ssltest.exe: $(OBJ_D)\ssltest.obj $(LIBS_DEP)
1883 $(LINK) $(LFLAGS) @<<
1884 $(APP_EX_OBJ) $(OBJ_D)\ssltest.obj
1885 $(TEST_D)\ssltest.exe
1886
1887 $(L_LIBS) $(EX_LIBS)
1888
1889<<
1890
1891$(O_SSL): $(SSLOBJ)
1892 $(LINK) $(MLFLAGS) @<<
1893 $(SHLIB_EX_OBJ) +
1894 $(OBJ_D)\bio_ssl.obj +
1895 $(OBJ_D)\s23_clnt.obj +
1896 $(OBJ_D)\s23_lib.obj +
1897 $(OBJ_D)\s23_meth.obj +
1898 $(OBJ_D)\s23_pkt.obj +
1899 $(OBJ_D)\s23_srvr.obj +
1900 $(OBJ_D)\s2_clnt.obj +
1901 $(OBJ_D)\s2_enc.obj +
1902 $(OBJ_D)\s2_lib.obj +
1903 $(OBJ_D)\s2_meth.obj +
1904 $(OBJ_D)\s2_pkt.obj +
1905 $(OBJ_D)\s2_srvr.obj +
1906 $(OBJ_D)\s3_both.obj +
1907 $(OBJ_D)\s3_clnt.obj +
1908 $(OBJ_D)\s3_enc.obj +
1909 $(OBJ_D)\s3_lib.obj +
1910 $(OBJ_D)\s3_meth.obj +
1911 $(OBJ_D)\s3_pkt.obj +
1912 $(OBJ_D)\s3_srvr.obj +
1913 $(OBJ_D)\ssl_algs.obj +
1914 $(OBJ_D)\ssl_asn1.obj +
1915 $(OBJ_D)\ssl_cert.obj +
1916 $(OBJ_D)\ssl_ciph.obj +
1917 $(OBJ_D)\ssl_err.obj +
1918 $(OBJ_D)\ssl_err2.obj +
1919 $(OBJ_D)\ssl_lib.obj +
1920 $(OBJ_D)\ssl_rsa.obj +
1921 $(OBJ_D)\ssl_sess.obj +
1922 $(OBJ_D)\ssl_stat.obj +
1923 $(OBJ_D)\ssl_txt.obj +
1924 $(OBJ_D)\t1_clnt.obj +
1925 $(OBJ_D)\t1_enc.obj +
1926 $(OBJ_D)\t1_lib.obj +
1927 $(OBJ_D)\t1_meth.obj +
1928 $(OBJ_D)\t1_srvr.obj +
1929
1930 $(O_SSL)
1931
1932 $(L_CRYPTO) winsock oldnames ldllcew libw
1933ms\ssleay16.def;
1934<<
1935 implib /noignorecase /nowep $(L_SSL) $(O_SSL)
1936
1937$(O_RSAGLUE): $(RSAGLUEOBJ)
1938 del $(O_RSAGLUE)
1939 $(MKLIB) @<<
1940$(O_RSAGLUE)
1941y
1942+$(OBJ_D)\rsar_err.obj &
1943+$(OBJ_D)\rsaref.obj &
1944
1945
1946<<
1947
1948$(O_CRYPTO): $(CRYPTOOBJ)
1949 $(LINK) $(MLFLAGS) @<<
1950 $(SHLIB_EX_OBJ) +
1951 $(BN_MULW_OBJ) +
1952 $(OBJ_D)\a_bitstr.obj +
1953 $(OBJ_D)\a_bool.obj +
1954 $(OBJ_D)\a_bytes.obj +
1955 $(OBJ_D)\a_d2i_fp.obj +
1956 $(OBJ_D)\a_digest.obj +
1957 $(OBJ_D)\a_dup.obj +
1958 $(OBJ_D)\a_hdr.obj +
1959 $(OBJ_D)\a_i2d_fp.obj +
1960 $(OBJ_D)\a_int.obj +
1961 $(OBJ_D)\a_meth.obj +
1962 $(OBJ_D)\a_object.obj +
1963 $(OBJ_D)\a_octet.obj +
1964 $(OBJ_D)\a_print.obj +
1965 $(OBJ_D)\a_set.obj +
1966 $(OBJ_D)\a_sign.obj +
1967 $(OBJ_D)\a_type.obj +
1968 $(OBJ_D)\a_utctm.obj +
1969 $(OBJ_D)\a_verify.obj +
1970 $(OBJ_D)\asn1_err.obj +
1971 $(OBJ_D)\asn1_lib.obj +
1972 $(OBJ_D)\asn1_par.obj +
1973 $(OBJ_D)\b_dump.obj +
1974 $(OBJ_D)\b_print.obj +
1975 $(OBJ_D)\b_sock.obj +
1976 $(OBJ_D)\bf_buff.obj +
1977 $(OBJ_D)\bf_cfb64.obj +
1978 $(OBJ_D)\bf_ecb.obj +
1979 $(OBJ_D)\bf_enc.obj +
1980 $(OBJ_D)\bf_nbio.obj +
1981 $(OBJ_D)\bf_null.obj +
1982 $(OBJ_D)\bf_ofb64.obj +
1983 $(OBJ_D)\bf_skey.obj +
1984 $(OBJ_D)\bio_b64.obj +
1985 $(OBJ_D)\bio_cb.obj +
1986 $(OBJ_D)\bio_enc.obj +
1987 $(OBJ_D)\bio_err.obj +
1988 $(OBJ_D)\bio_lib.obj +
1989 $(OBJ_D)\bio_md.obj +
1990 $(OBJ_D)\bn_add.obj +
1991 $(OBJ_D)\bn_blind.obj +
1992 $(OBJ_D)\bn_div.obj +
1993 $(OBJ_D)\bn_err.obj +
1994 $(OBJ_D)\bn_exp.obj +
1995 $(OBJ_D)\bn_gcd.obj +
1996 $(OBJ_D)\bn_lib.obj +
1997 $(OBJ_D)\bn_mod.obj +
1998 $(OBJ_D)\bn_mont.obj +
1999 $(OBJ_D)\bn_mpi.obj +
2000 $(OBJ_D)\bn_mul.obj +
2001 $(OBJ_D)\bn_prime.obj +
2002 $(OBJ_D)\bn_print.obj +
2003 $(OBJ_D)\bn_rand.obj +
2004 $(OBJ_D)\bn_recp.obj +
2005 $(OBJ_D)\bn_shift.obj +
2006 $(OBJ_D)\bn_sqr.obj +
2007 $(OBJ_D)\bn_sub.obj +
2008 $(OBJ_D)\bn_word.obj +
2009 $(OBJ_D)\bss_acpt.obj +
2010 $(OBJ_D)\bss_conn.obj +
2011 $(OBJ_D)\bss_fd.obj +
2012 $(OBJ_D)\bss_file.obj +
2013 $(OBJ_D)\bss_mem.obj +
2014 $(OBJ_D)\bss_null.obj +
2015 $(OBJ_D)\bss_sock.obj +
2016 $(OBJ_D)\buf_err.obj +
2017 $(OBJ_D)\buffer.obj +
2018 $(OBJ_D)\by_dir.obj +
2019 $(OBJ_D)\by_file.obj +
2020 $(OBJ_D)\c_all.obj +
2021 $(OBJ_D)\c_cfb64.obj +
2022 $(OBJ_D)\c_ecb.obj +
2023 $(OBJ_D)\c_enc.obj +
2024 $(OBJ_D)\c_ofb64.obj +
2025 $(OBJ_D)\c_skey.obj +
2026 $(OBJ_D)\cbc_cksm.obj +
2027 $(OBJ_D)\cbc_enc.obj +
2028 $(OBJ_D)\cfb64ede.obj +
2029 $(OBJ_D)\cfb64enc.obj +
2030 $(OBJ_D)\cfb_enc.obj +
2031 $(OBJ_D)\conf.obj +
2032 $(OBJ_D)\conf_err.obj +
2033 $(OBJ_D)\cpt_err.obj +
2034 $(OBJ_D)\cryptlib.obj +
2035 $(OBJ_D)\cversion.obj +
2036 $(OBJ_D)\d2i_dhp.obj +
2037 $(OBJ_D)\d2i_dsap.obj +
2038 $(OBJ_D)\d2i_pr.obj +
2039 $(OBJ_D)\d2i_pu.obj +
2040 $(OBJ_D)\d2i_r_pr.obj +
2041 $(OBJ_D)\d2i_r_pu.obj +
2042 $(OBJ_D)\d2i_s_pr.obj +
2043 $(OBJ_D)\d2i_s_pu.obj +
2044 $(OBJ_D)\des_enc.obj +
2045 $(OBJ_D)\dh_check.obj +
2046 $(OBJ_D)\dh_err.obj +
2047 $(OBJ_D)\dh_gen.obj +
2048 $(OBJ_D)\dh_key.obj +
2049 $(OBJ_D)\dh_lib.obj +
2050 $(OBJ_D)\digest.obj +
2051 $(OBJ_D)\dsa_err.obj +
2052 $(OBJ_D)\dsa_gen.obj +
2053 $(OBJ_D)\dsa_key.obj +
2054 $(OBJ_D)\dsa_lib.obj +
2055 $(OBJ_D)\dsa_sign.obj +
2056 $(OBJ_D)\dsa_vrf.obj +
2057 $(OBJ_D)\e_cbc_3d.obj +
2058 $(OBJ_D)\e_cbc_bf.obj +
2059 $(OBJ_D)\e_cbc_c.obj +
2060 $(OBJ_D)\e_cbc_d.obj +
2061 $(OBJ_D)\e_cbc_i.obj +
2062 $(OBJ_D)\e_cbc_r2.obj +
2063 $(OBJ_D)\e_cbc_r5.obj +
2064 $(OBJ_D)\e_cfb_3d.obj +
2065 $(OBJ_D)\e_cfb_bf.obj +
2066 $(OBJ_D)\e_cfb_c.obj +
2067 $(OBJ_D)\e_cfb_d.obj +
2068 $(OBJ_D)\e_cfb_i.obj +
2069 $(OBJ_D)\e_cfb_r2.obj +
2070 $(OBJ_D)\e_cfb_r5.obj +
2071 $(OBJ_D)\e_ecb_3d.obj +
2072 $(OBJ_D)\e_ecb_bf.obj +
2073 $(OBJ_D)\e_ecb_c.obj +
2074 $(OBJ_D)\e_ecb_d.obj +
2075 $(OBJ_D)\e_ecb_i.obj +
2076 $(OBJ_D)\e_ecb_r2.obj +
2077 $(OBJ_D)\e_ecb_r5.obj +
2078 $(OBJ_D)\e_null.obj +
2079 $(OBJ_D)\e_ofb_3d.obj +
2080 $(OBJ_D)\e_ofb_bf.obj +
2081 $(OBJ_D)\e_ofb_c.obj +
2082 $(OBJ_D)\e_ofb_d.obj +
2083 $(OBJ_D)\e_ofb_i.obj +
2084 $(OBJ_D)\e_ofb_r2.obj +
2085 $(OBJ_D)\e_ofb_r5.obj +
2086 $(OBJ_D)\e_rc4.obj +
2087 $(OBJ_D)\e_xcbc_d.obj +
2088 $(OBJ_D)\ecb3_enc.obj +
2089 $(OBJ_D)\ecb_enc.obj +
2090 $(OBJ_D)\enc_read.obj +
2091 $(OBJ_D)\enc_writ.obj +
2092 $(OBJ_D)\encode.obj +
2093 $(OBJ_D)\err.obj +
2094 $(OBJ_D)\err_all.obj +
2095 $(OBJ_D)\err_prn.obj +
2096 $(OBJ_D)\evp_asn1.obj +
2097 $(OBJ_D)\evp_enc.obj +
2098 $(OBJ_D)\evp_err.obj +
2099 $(OBJ_D)\evp_key.obj +
2100 $(OBJ_D)\evp_lib.obj +
2101 $(OBJ_D)\ex_data.obj +
2102 $(OBJ_D)\f_int.obj +
2103 $(OBJ_D)\f_string.obj +
2104 $(OBJ_D)\fcrypt.obj +
2105 $(OBJ_D)\fcrypt_b.obj +
2106 $(OBJ_D)\hmac.obj +
2107 $(OBJ_D)\i2d_dhp.obj +
2108 $(OBJ_D)\i2d_dsap.obj +
2109 $(OBJ_D)\i2d_pr.obj +
2110 $(OBJ_D)\i2d_pu.obj +
2111 $(OBJ_D)\i2d_r_pr.obj +
2112 $(OBJ_D)\i2d_r_pu.obj +
2113 $(OBJ_D)\i2d_s_pr.obj +
2114 $(OBJ_D)\i2d_s_pu.obj +
2115 $(OBJ_D)\i_cbc.obj +
2116 $(OBJ_D)\i_cfb64.obj +
2117 $(OBJ_D)\i_ecb.obj +
2118 $(OBJ_D)\i_ofb64.obj +
2119 $(OBJ_D)\i_skey.obj +
2120 $(OBJ_D)\lh_stats.obj +
2121 $(OBJ_D)\lhash.obj +
2122 $(OBJ_D)\m_dss.obj +
2123 $(OBJ_D)\m_dss1.obj +
2124 $(OBJ_D)\m_md2.obj +
2125 $(OBJ_D)\m_md5.obj +
2126 $(OBJ_D)\m_mdc2.obj +
2127 $(OBJ_D)\m_null.obj +
2128 $(OBJ_D)\m_ripemd.obj +
2129 $(OBJ_D)\m_sha.obj +
2130 $(OBJ_D)\m_sha1.obj +
2131 $(OBJ_D)\md2_dgst.obj +
2132 $(OBJ_D)\md2_one.obj +
2133 $(OBJ_D)\md5_dgst.obj +
2134 $(OBJ_D)\md5_one.obj +
2135 $(OBJ_D)\md_rand.obj +
2136 $(OBJ_D)\mdc2_one.obj +
2137 $(OBJ_D)\mdc2dgst.obj +
2138 $(OBJ_D)\mem.obj +
2139 $(OBJ_D)\n_pkey.obj +
2140 $(OBJ_D)\names.obj +
2141 $(OBJ_D)\obj_dat.obj +
2142 $(OBJ_D)\obj_err.obj +
2143 $(OBJ_D)\obj_lib.obj +
2144 $(OBJ_D)\ofb64ede.obj +
2145 $(OBJ_D)\ofb64enc.obj +
2146 $(OBJ_D)\ofb_enc.obj +
2147 $(OBJ_D)\p7_dgst.obj +
2148 $(OBJ_D)\p7_enc.obj +
2149 $(OBJ_D)\p7_enc_c.obj +
2150 $(OBJ_D)\p7_evp.obj +
2151 $(OBJ_D)\p7_i_s.obj +
2152 $(OBJ_D)\p7_lib.obj +
2153 $(OBJ_D)\p7_recip.obj +
2154 $(OBJ_D)\p7_s_e.obj +
2155 $(OBJ_D)\p7_signd.obj +
2156 $(OBJ_D)\p7_signi.obj +
2157 $(OBJ_D)\p_dec.obj +
2158 $(OBJ_D)\p_enc.obj +
2159 $(OBJ_D)\p_lib.obj +
2160 $(OBJ_D)\p_open.obj +
2161 $(OBJ_D)\p_seal.obj +
2162 $(OBJ_D)\p_sign.obj +
2163 $(OBJ_D)\p_verify.obj +
2164 $(OBJ_D)\pcbc_enc.obj +
2165 $(OBJ_D)\pem_all.obj +
2166 $(OBJ_D)\pem_err.obj +
2167 $(OBJ_D)\pem_info.obj +
2168 $(OBJ_D)\pem_lib.obj +
2169 $(OBJ_D)\pem_seal.obj +
2170 $(OBJ_D)\pem_sign.obj +
2171 $(OBJ_D)\pk7_doit.obj +
2172 $(OBJ_D)\pk7_lib.obj +
2173 $(OBJ_D)\pkcs7err.obj +
2174 $(OBJ_D)\qud_cksm.obj +
2175 $(OBJ_D)\rand_key.obj +
2176 $(OBJ_D)\randfile.obj +
2177 $(OBJ_D)\rc2_cbc.obj +
2178 $(OBJ_D)\rc2_ecb.obj +
2179 $(OBJ_D)\rc2_skey.obj +
2180 $(OBJ_D)\rc2cfb64.obj +
2181 $(OBJ_D)\rc2ofb64.obj +
2182 $(OBJ_D)\rc4_enc.obj +
2183 $(OBJ_D)\rc4_skey.obj +
2184 $(OBJ_D)\rc5_ecb.obj +
2185 $(OBJ_D)\rc5_enc.obj +
2186 $(OBJ_D)\rc5_skey.obj +
2187 $(OBJ_D)\rc5cfb64.obj +
2188 $(OBJ_D)\rc5ofb64.obj +
2189 $(OBJ_D)\read2pwd.obj +
2190 $(OBJ_D)\read_pwd.obj +
2191 $(OBJ_D)\rmd_dgst.obj +
2192 $(OBJ_D)\rmd_one.obj +
2193 $(OBJ_D)\rpc_enc.obj +
2194 $(OBJ_D)\rsa_eay.obj +
2195 $(OBJ_D)\rsa_err.obj +
2196 $(OBJ_D)\rsa_gen.obj +
2197 $(OBJ_D)\rsa_lib.obj +
2198 $(OBJ_D)\rsa_none.obj +
2199 $(OBJ_D)\rsa_pk1.obj +
2200 $(OBJ_D)\rsa_saos.obj +
2201 $(OBJ_D)\rsa_sign.obj +
2202 $(OBJ_D)\rsa_ssl.obj +
2203 $(OBJ_D)\set_key.obj +
2204 $(OBJ_D)\sha1_one.obj +
2205 $(OBJ_D)\sha1dgst.obj +
2206 $(OBJ_D)\sha_dgst.obj +
2207 $(OBJ_D)\sha_one.obj +
2208 $(OBJ_D)\stack.obj +
2209 $(OBJ_D)\str2key.obj +
2210 $(OBJ_D)\supp.obj +
2211 $(OBJ_D)\t_pkey.obj +
2212 $(OBJ_D)\t_req.obj +
2213 $(OBJ_D)\t_x509.obj +
2214 $(OBJ_D)\txt_db.obj +
2215 $(OBJ_D)\v3_net.obj +
2216 $(OBJ_D)\v3_x509.obj +
2217 $(OBJ_D)\x509_cmp.obj +
2218 $(OBJ_D)\x509_d2.obj +
2219 $(OBJ_D)\x509_def.obj +
2220 $(OBJ_D)\x509_err.obj +
2221 $(OBJ_D)\x509_ext.obj +
2222 $(OBJ_D)\x509_lu.obj +
2223 $(OBJ_D)\x509_obj.obj +
2224 $(OBJ_D)\x509_r2x.obj +
2225 $(OBJ_D)\x509_req.obj +
2226 $(OBJ_D)\x509_set.obj +
2227 $(OBJ_D)\x509_txt.obj +
2228 $(OBJ_D)\x509_v3.obj +
2229 $(OBJ_D)\x509_vfy.obj +
2230 $(OBJ_D)\x509name.obj +
2231 $(OBJ_D)\x509pack.obj +
2232 $(OBJ_D)\x509rset.obj +
2233 $(OBJ_D)\x509type.obj +
2234 $(OBJ_D)\x_algor.obj +
2235 $(OBJ_D)\x_all.obj +
2236 $(OBJ_D)\x_attrib.obj +
2237 $(OBJ_D)\x_cinf.obj +
2238 $(OBJ_D)\x_crl.obj +
2239 $(OBJ_D)\x_exten.obj +
2240 $(OBJ_D)\x_info.obj +
2241 $(OBJ_D)\x_name.obj +
2242 $(OBJ_D)\x_pkey.obj +
2243 $(OBJ_D)\x_pubkey.obj +
2244 $(OBJ_D)\x_req.obj +
2245 $(OBJ_D)\x_sig.obj +
2246 $(OBJ_D)\x_spki.obj +
2247 $(OBJ_D)\x_val.obj +
2248 $(OBJ_D)\x_x509.obj +
2249 $(OBJ_D)\xcbc_enc.obj +
2250
2251 $(O_CRYPTO)
2252
2253 winsock oldnames ldllcew libw
2254ms\libeay16.def;
2255<<
2256 implib /noignorecase /nowep $(L_CRYPTO) $(O_CRYPTO)
2257
2258$(BIN_D)\$(E_EXE).exe: $(E_OBJ) $(LIBS_DEP)
2259 $(LINK) $(LFLAGS) @<<
2260 $(APP_EX_OBJ) +
2261 $(OBJ_D)\apps.obj +
2262 $(OBJ_D)\asn1pars.obj +
2263 $(OBJ_D)\ca.obj +
2264 $(OBJ_D)\ciphers.obj +
2265 $(OBJ_D)\crl.obj +
2266 $(OBJ_D)\crl2p7.obj +
2267 $(OBJ_D)\dgst.obj +
2268 $(OBJ_D)\dh.obj +
2269 $(OBJ_D)\dsa.obj +
2270 $(OBJ_D)\dsaparam.obj +
2271 $(OBJ_D)\enc.obj +
2272 $(OBJ_D)\errstr.obj +
2273 $(OBJ_D)\gendh.obj +
2274 $(OBJ_D)\genrsa.obj +
2275 $(OBJ_D)\pkcs7.obj +
2276 $(OBJ_D)\req.obj +
2277 $(OBJ_D)\rsa.obj +
2278 $(OBJ_D)\s_cb.obj +
2279 $(OBJ_D)\s_client.obj +
2280 $(OBJ_D)\s_server.obj +
2281 $(OBJ_D)\s_socket.obj +
2282 $(OBJ_D)\s_time.obj +
2283 $(OBJ_D)\sess_id.obj +
2284 $(OBJ_D)\speed.obj +
2285 $(OBJ_D)\ssleay.obj +
2286 $(OBJ_D)\verify.obj +
2287 $(OBJ_D)\version.obj +
2288 $(OBJ_D)\x509.obj +
2289
2290 $(BIN_D)\$(E_EXE).exe
2291
2292 $(L_LIBS) $(EX_LIBS)
2293
2294<<
2295
diff --git a/src/lib/libssl/src/mt/README b/src/lib/libssl/src/mt/README
new file mode 100644
index 0000000000..df6b26e146
--- /dev/null
+++ b/src/lib/libssl/src/mt/README
@@ -0,0 +1,14 @@
1Mutithreading testing area.
2
3Since this stuff is very very platorm specific, this is not part of the
4normal build. Have a read of doc/threads.doc.
5
6mttest will do some testing and will currently build under Windows NT/95,
7Solaris and Linux. The IRIX stuff is not finished.
8
9I have tested this program on a 12 CPU ultra sparc box (solaris 2.5.1)
10and things seem to work ok.
11
12The Linux pthreads package can be retrieved from
13http://www.mit.edu:8001/people/proven/pthreads.html
14
diff --git a/src/lib/libssl/src/mt/mttest.c b/src/lib/libssl/src/mt/mttest.c
new file mode 100644
index 0000000000..8651a1131a
--- /dev/null
+++ b/src/lib/libssl/src/mt/mttest.c
@@ -0,0 +1,1115 @@
1/* mt/mttest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <errno.h>
63#ifdef LINUX
64#include <typedefs.h>
65#endif
66#ifdef WIN32
67#include <windows.h>
68#endif
69#ifdef SOLARIS
70#include <synch.h>
71#include <thread.h>
72#endif
73#ifdef IRIX
74#include <ulocks.h>
75#include <sys/prctl.h>
76#endif
77#include "lhash.h"
78#include "crypto.h"
79#include "buffer.h"
80#include "../e_os.h"
81#include "x509.h"
82#include "ssl.h"
83#include "err.h"
84
85#ifdef NO_FP_API
86#define APPS_WIN16
87#include "../crypto/buffer/bss_file.c"
88#endif
89
90#define TEST_SERVER_CERT "../apps/server.pem"
91#define TEST_CLIENT_CERT "../apps/client.pem"
92
93#define MAX_THREAD_NUMBER 100
94
95#ifndef NOPROTO
96int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth,
97 int error,char *arg);
98void thread_setup(void);
99void thread_cleanup(void);
100void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx);
101
102void irix_locking_callback(int mode,int type,char *file,int line);
103void solaris_locking_callback(int mode,int type,char *file,int line);
104void win32_locking_callback(int mode,int type,char *file,int line);
105void pthreads_locking_callback(int mode,int type,char *file,int line);
106
107unsigned long irix_thread_id(void );
108unsigned long solaris_thread_id(void );
109unsigned long pthreads_thread_id(void );
110
111#else
112int MS_CALLBACK verify_callback();
113void thread_setup();
114void thread_cleanup();
115void do_threads();
116
117void irix_locking_callback();
118void solaris_locking_callback();
119void win32_locking_callback();
120void pthreads_locking_callback();
121
122unsigned long irix_thread_id();
123unsigned long solaris_thread_id();
124unsigned long pthreads_thread_id();
125
126#endif
127
128BIO *bio_err=NULL;
129BIO *bio_stdout=NULL;
130
131static char *cipher=NULL;
132int verbose=0;
133#ifdef FIONBIO
134static int s_nbio=0;
135#endif
136
137int thread_number=10;
138int number_of_loops=10;
139int reconnect=0;
140int cache_stats=0;
141
142#ifndef NOPROTO
143int doit(char *ctx[4]);
144#else
145int doit();
146#endif
147
148static void print_stats(fp,ctx)
149FILE *fp;
150SSL_CTX *ctx;
151{
152 fprintf(fp,"%4ld items in the session cache\n",
153 SSL_CTX_sess_number(ctx));
154 fprintf(fp,"%4d client connects (SSL_connect())\n",
155 SSL_CTX_sess_connect(ctx));
156 fprintf(fp,"%4d client connects that finished\n",
157 SSL_CTX_sess_connect_good(ctx));
158 fprintf(fp,"%4d server connects (SSL_accept())\n",
159 SSL_CTX_sess_accept(ctx));
160 fprintf(fp,"%4d server connects that finished\n",
161 SSL_CTX_sess_accept_good(ctx));
162 fprintf(fp,"%4d session cache hits\n",SSL_CTX_sess_hits(ctx));
163 fprintf(fp,"%4d session cache misses\n",SSL_CTX_sess_misses(ctx));
164 fprintf(fp,"%4d session cache timeouts\n",SSL_CTX_sess_timeouts(ctx));
165 }
166
167static void sv_usage()
168 {
169 fprintf(stderr,"usage: ssltest [args ...]\n");
170 fprintf(stderr,"\n");
171 fprintf(stderr," -server_auth - check server certificate\n");
172 fprintf(stderr," -client_auth - do client authentication\n");
173 fprintf(stderr," -v - more output\n");
174 fprintf(stderr," -CApath arg - PEM format directory of CA's\n");
175 fprintf(stderr," -CAfile arg - PEM format file of CA's\n");
176 fprintf(stderr," -threads arg - number of threads\n");
177 fprintf(stderr," -loops arg - number of 'connections', per thread\n");
178 fprintf(stderr," -reconnect - reuse session-id's\n");
179 fprintf(stderr," -stats - server session-id cache stats\n");
180 fprintf(stderr," -cert arg - server certificate/key\n");
181 fprintf(stderr," -ccert arg - client certificate/key\n");
182 fprintf(stderr," -ssl3 - just SSLv3n\n");
183 }
184
185int main(argc, argv)
186int argc;
187char *argv[];
188 {
189 char *CApath=NULL,*CAfile=NULL;
190 int badop=0;
191 int ret=1;
192 int client_auth=0;
193 int server_auth=0;
194 SSL_CTX *s_ctx=NULL;
195 SSL_CTX *c_ctx=NULL;
196 char *scert=TEST_SERVER_CERT;
197 char *ccert=TEST_CLIENT_CERT;
198 SSL_METHOD *ssl_method=SSLv23_method();
199
200 if (bio_err == NULL)
201 bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
202 if (bio_stdout == NULL)
203 bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE);
204 argc--;
205 argv++;
206
207 while (argc >= 1)
208 {
209 if (strcmp(*argv,"-server_auth") == 0)
210 server_auth=1;
211 else if (strcmp(*argv,"-client_auth") == 0)
212 client_auth=1;
213 else if (strcmp(*argv,"-reconnect") == 0)
214 reconnect=1;
215 else if (strcmp(*argv,"-stats") == 0)
216 cache_stats=1;
217 else if (strcmp(*argv,"-ssl3") == 0)
218 ssl_method=SSLv3_method();
219 else if (strcmp(*argv,"-ssl2") == 0)
220 ssl_method=SSLv2_method();
221 else if (strcmp(*argv,"-CApath") == 0)
222 {
223 if (--argc < 1) goto bad;
224 CApath= *(++argv);
225 }
226 else if (strcmp(*argv,"-CAfile") == 0)
227 {
228 if (--argc < 1) goto bad;
229 CAfile= *(++argv);
230 }
231 else if (strcmp(*argv,"-cert") == 0)
232 {
233 if (--argc < 1) goto bad;
234 scert= *(++argv);
235 }
236 else if (strcmp(*argv,"-ccert") == 0)
237 {
238 if (--argc < 1) goto bad;
239 ccert= *(++argv);
240 }
241 else if (strcmp(*argv,"-threads") == 0)
242 {
243 if (--argc < 1) goto bad;
244 thread_number= atoi(*(++argv));
245 if (thread_number == 0) thread_number=1;
246 if (thread_number > MAX_THREAD_NUMBER)
247 thread_number=MAX_THREAD_NUMBER;
248 }
249 else if (strcmp(*argv,"-loops") == 0)
250 {
251 if (--argc < 1) goto bad;
252 number_of_loops= atoi(*(++argv));
253 if (number_of_loops == 0) number_of_loops=1;
254 }
255 else
256 {
257 fprintf(stderr,"unknown option %s\n",*argv);
258 badop=1;
259 break;
260 }
261 argc--;
262 argv++;
263 }
264 if (badop)
265 {
266bad:
267 sv_usage();
268 goto end;
269 }
270
271 if (cipher == NULL) cipher=getenv("SSL_CIPHER");
272
273 SSL_load_error_strings();
274 SSLeay_add_ssl_algorithms();
275
276 c_ctx=SSL_CTX_new(ssl_method);
277 s_ctx=SSL_CTX_new(ssl_method);
278 if ((c_ctx == NULL) || (s_ctx == NULL))
279 {
280 ERR_print_errors(bio_err);
281 goto end;
282 }
283
284 SSL_CTX_set_session_cache_mode(s_ctx,
285 SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER);
286 SSL_CTX_set_session_cache_mode(c_ctx,
287 SSL_SESS_CACHE_NO_AUTO_CLEAR|SSL_SESS_CACHE_SERVER);
288
289 SSL_CTX_use_certificate_file(s_ctx,scert,SSL_FILETYPE_PEM);
290 SSL_CTX_use_RSAPrivateKey_file(s_ctx,scert,SSL_FILETYPE_PEM);
291
292 if (client_auth)
293 {
294 SSL_CTX_use_certificate_file(c_ctx,ccert,
295 SSL_FILETYPE_PEM);
296 SSL_CTX_use_RSAPrivateKey_file(c_ctx,ccert,
297 SSL_FILETYPE_PEM);
298 }
299
300 if ( (!SSL_CTX_load_verify_locations(s_ctx,CAfile,CApath)) ||
301 (!SSL_CTX_set_default_verify_paths(s_ctx)) ||
302 (!SSL_CTX_load_verify_locations(c_ctx,CAfile,CApath)) ||
303 (!SSL_CTX_set_default_verify_paths(c_ctx)))
304 {
305 fprintf(stderr,"SSL_load_verify_locations\n");
306 ERR_print_errors(bio_err);
307 goto end;
308 }
309
310 if (client_auth)
311 {
312 fprintf(stderr,"client authentication\n");
313 SSL_CTX_set_verify(s_ctx,
314 SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
315 verify_callback);
316 }
317 if (server_auth)
318 {
319 fprintf(stderr,"server authentication\n");
320 SSL_CTX_set_verify(c_ctx,SSL_VERIFY_PEER,
321 verify_callback);
322 }
323
324 thread_setup();
325 do_threads(s_ctx,c_ctx);
326 thread_cleanup();
327end:
328
329 if (c_ctx != NULL)
330 {
331 fprintf(stderr,"Client SSL_CTX stats then free it\n");
332 print_stats(stderr,c_ctx);
333 SSL_CTX_free(c_ctx);
334 }
335 if (s_ctx != NULL)
336 {
337 fprintf(stderr,"Server SSL_CTX stats then free it\n");
338 print_stats(stderr,s_ctx);
339 if (cache_stats)
340 {
341 fprintf(stderr,"-----\n");
342 lh_stats(SSL_CTX_sessions(s_ctx),stderr);
343 fprintf(stderr,"-----\n");
344 /* lh_node_stats(SSL_CTX_sessions(s_ctx),stderr);
345 fprintf(stderr,"-----\n"); */
346 lh_node_usage_stats(SSL_CTX_sessions(s_ctx),stderr);
347 fprintf(stderr,"-----\n");
348 }
349 SSL_CTX_free(s_ctx);
350 fprintf(stderr,"done free\n");
351 }
352 exit(ret);
353 return(0);
354 }
355
356#define W_READ 1
357#define W_WRITE 2
358#define C_DONE 1
359#define S_DONE 2
360
361int ndoit(ssl_ctx)
362SSL_CTX *ssl_ctx[2];
363 {
364 int i;
365 int ret;
366 char *ctx[4];
367
368 ctx[0]=(char *)ssl_ctx[0];
369 ctx[1]=(char *)ssl_ctx[1];
370
371 if (reconnect)
372 {
373 ctx[2]=(char *)SSL_new(ssl_ctx[0]);
374 ctx[3]=(char *)SSL_new(ssl_ctx[1]);
375 }
376 else
377 {
378 ctx[2]=NULL;
379 ctx[3]=NULL;
380 }
381
382 fprintf(stdout,"started thread %lu\n",CRYPTO_thread_id());
383 for (i=0; i<number_of_loops; i++)
384 {
385/* fprintf(stderr,"%4d %2d ctx->ref (%3d,%3d)\n",
386 CRYPTO_thread_id(),i,
387 ssl_ctx[0]->references,
388 ssl_ctx[1]->references); */
389 /* pthread_delay_np(&tm);*/
390
391 ret=doit(ctx);
392 if (ret != 0)
393 {
394 fprintf(stdout,"error[%d] %lu - %d\n",
395 i,CRYPTO_thread_id(),ret);
396 return(ret);
397 }
398 }
399 fprintf(stdout,"DONE %lu\n",CRYPTO_thread_id());
400 if (reconnect)
401 {
402 SSL_free((SSL *)ctx[2]);
403 SSL_free((SSL *)ctx[3]);
404 }
405 return(0);
406 }
407
408int doit(ctx)
409char *ctx[4];
410 {
411 SSL_CTX *s_ctx,*c_ctx;
412 static char cbuf[200],sbuf[200];
413 SSL *c_ssl=NULL;
414 SSL *s_ssl=NULL;
415 BIO *c_to_s=NULL;
416 BIO *s_to_c=NULL;
417 BIO *c_bio=NULL;
418 BIO *s_bio=NULL;
419 int c_r,c_w,s_r,s_w;
420 int c_want,s_want;
421 int i;
422 int done=0;
423 int c_write,s_write;
424 int do_server=0,do_client=0;
425
426 s_ctx=(SSL_CTX *)ctx[0];
427 c_ctx=(SSL_CTX *)ctx[1];
428
429 if (ctx[2] != NULL)
430 s_ssl=(SSL *)ctx[2];
431 else
432 s_ssl=SSL_new(s_ctx);
433
434 if (ctx[3] != NULL)
435 c_ssl=(SSL *)ctx[3];
436 else
437 c_ssl=SSL_new(c_ctx);
438
439 if ((s_ssl == NULL) || (c_ssl == NULL)) goto err;
440
441 c_to_s=BIO_new(BIO_s_mem());
442 s_to_c=BIO_new(BIO_s_mem());
443 if ((s_to_c == NULL) || (c_to_s == NULL)) goto err;
444
445 c_bio=BIO_new(BIO_f_ssl());
446 s_bio=BIO_new(BIO_f_ssl());
447 if ((c_bio == NULL) || (s_bio == NULL)) goto err;
448
449 SSL_set_connect_state(c_ssl);
450 SSL_set_bio(c_ssl,s_to_c,c_to_s);
451 BIO_set_ssl(c_bio,c_ssl,(ctx[2] == NULL)?BIO_CLOSE:BIO_NOCLOSE);
452
453 SSL_set_accept_state(s_ssl);
454 SSL_set_bio(s_ssl,c_to_s,s_to_c);
455 BIO_set_ssl(s_bio,s_ssl,(ctx[3] == NULL)?BIO_CLOSE:BIO_NOCLOSE);
456
457 c_r=0; s_r=1;
458 c_w=1; s_w=0;
459 c_want=W_WRITE;
460 s_want=0;
461 c_write=1,s_write=0;
462
463 /* We can always do writes */
464 for (;;)
465 {
466 do_server=0;
467 do_client=0;
468
469 i=(int)BIO_pending(s_bio);
470 if ((i && s_r) || s_w) do_server=1;
471
472 i=(int)BIO_pending(c_bio);
473 if ((i && c_r) || c_w) do_client=1;
474
475 if (do_server && verbose)
476 {
477 if (SSL_in_init(s_ssl))
478 printf("server waiting in SSL_accept - %s\n",
479 SSL_state_string_long(s_ssl));
480 else if (s_write)
481 printf("server:SSL_write()\n");
482 else
483 printf("server:SSL_read()\n");
484 }
485
486 if (do_client && verbose)
487 {
488 if (SSL_in_init(c_ssl))
489 printf("client waiting in SSL_connect - %s\n",
490 SSL_state_string_long(c_ssl));
491 else if (c_write)
492 printf("client:SSL_write()\n");
493 else
494 printf("client:SSL_read()\n");
495 }
496
497 if (!do_client && !do_server)
498 {
499 fprintf(stdout,"ERROR IN STARTUP\n");
500 break;
501 }
502 if (do_client && !(done & C_DONE))
503 {
504 if (c_write)
505 {
506 i=BIO_write(c_bio,"hello from client\n",18);
507 if (i < 0)
508 {
509 c_r=0;
510 c_w=0;
511 if (BIO_should_retry(c_bio))
512 {
513 if (BIO_should_read(c_bio))
514 c_r=1;
515 if (BIO_should_write(c_bio))
516 c_w=1;
517 }
518 else
519 {
520 fprintf(stderr,"ERROR in CLIENT\n");
521 return(1);
522 }
523 }
524 else if (i == 0)
525 {
526 fprintf(stderr,"SSL CLIENT STARTUP FAILED\n");
527 return(1);
528 }
529 else
530 {
531 /* ok */
532 c_write=0;
533 }
534 }
535 else
536 {
537 i=BIO_read(c_bio,cbuf,100);
538 if (i < 0)
539 {
540 c_r=0;
541 c_w=0;
542 if (BIO_should_retry(c_bio))
543 {
544 if (BIO_should_read(c_bio))
545 c_r=1;
546 if (BIO_should_write(c_bio))
547 c_w=1;
548 }
549 else
550 {
551 fprintf(stderr,"ERROR in CLIENT\n");
552 return(1);
553 }
554 }
555 else if (i == 0)
556 {
557 fprintf(stderr,"SSL CLIENT STARTUP FAILED\n");
558 return(1);
559 }
560 else
561 {
562 done|=C_DONE;
563#ifdef undef
564 fprintf(stdout,"CLIENT:from server:");
565 fwrite(cbuf,1,i,stdout);
566 fflush(stdout);
567#endif
568 }
569 }
570 }
571
572 if (do_server && !(done & S_DONE))
573 {
574 if (!s_write)
575 {
576 i=BIO_read(s_bio,sbuf,100);
577 if (i < 0)
578 {
579 s_r=0;
580 s_w=0;
581 if (BIO_should_retry(s_bio))
582 {
583 if (BIO_should_read(s_bio))
584 s_r=1;
585 if (BIO_should_write(s_bio))
586 s_w=1;
587 }
588 else
589 {
590 fprintf(stderr,"ERROR in SERVER\n");
591 ERR_print_errors_fp(stderr);
592 return(1);
593 }
594 }
595 else if (i == 0)
596 {
597 fprintf(stderr,"SSL SERVER STARTUP FAILED\n");
598 return(1);
599 }
600 else
601 {
602 s_write=1;
603 s_w=1;
604#ifdef undef
605 fprintf(stdout,"SERVER:from client:");
606 fwrite(sbuf,1,i,stdout);
607 fflush(stdout);
608#endif
609 }
610 }
611 else
612 {
613 i=BIO_write(s_bio,"hello from server\n",18);
614 if (i < 0)
615 {
616 s_r=0;
617 s_w=0;
618 if (BIO_should_retry(s_bio))
619 {
620 if (BIO_should_read(s_bio))
621 s_r=1;
622 if (BIO_should_write(s_bio))
623 s_w=1;
624 }
625 else
626 {
627 fprintf(stderr,"ERROR in SERVER\n");
628 ERR_print_errors_fp(stderr);
629 return(1);
630 }
631 }
632 else if (i == 0)
633 {
634 fprintf(stderr,"SSL SERVER STARTUP FAILED\n");
635 return(1);
636 }
637 else
638 {
639 s_write=0;
640 s_r=1;
641 done|=S_DONE;
642 }
643 }
644 }
645
646 if ((done & S_DONE) && (done & C_DONE)) break;
647 }
648
649 SSL_set_shutdown(c_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
650 SSL_set_shutdown(s_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
651
652#ifdef undef
653 fprintf(stdout,"DONE\n");
654#endif
655err:
656 /* We have to set the BIO's to NULL otherwise they will be
657 * free()ed twice. Once when th s_ssl is SSL_free()ed and
658 * again when c_ssl is SSL_free()ed.
659 * This is a hack required because s_ssl and c_ssl are sharing the same
660 * BIO structure and SSL_set_bio() and SSL_free() automatically
661 * BIO_free non NULL entries.
662 * You should not normally do this or be required to do this */
663
664 if (s_ssl != NULL)
665 {
666 s_ssl->rbio=NULL;
667 s_ssl->wbio=NULL;
668 }
669 if (c_ssl != NULL)
670 {
671 c_ssl->rbio=NULL;
672 c_ssl->wbio=NULL;
673 }
674
675 /* The SSL's are optionally freed in the following calls */
676 if (c_to_s != NULL) BIO_free(c_to_s);
677 if (s_to_c != NULL) BIO_free(s_to_c);
678
679 if (c_bio != NULL) BIO_free(c_bio);
680 if (s_bio != NULL) BIO_free(s_bio);
681 return(0);
682 }
683
684int MS_CALLBACK verify_callback(ok, xs, xi, depth, error, arg)
685int ok;
686X509 *xs;
687X509 *xi;
688int depth;
689int error;
690char *arg;
691 {
692 char buf[256];
693
694 if (verbose)
695 {
696 X509_NAME_oneline(X509_get_subject_name(xs),buf,256);
697 if (ok)
698 fprintf(stderr,"depth=%d %s\n",depth,buf);
699 else
700 fprintf(stderr,"depth=%d error=%d %s\n",depth,error,buf);
701 }
702 return(ok);
703 }
704
705#define THREAD_STACK_SIZE (16*1024)
706
707#ifdef WIN32
708
709static PRLOCK lock_cs[CRYPTO_NUM_LOCKS];
710
711void thread_setup()
712 {
713 int i;
714
715 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
716 {
717 lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
718 }
719
720 CRYPTO_set_locking_callback((void (*)(int,int,char *,int))win32_locking_callback);
721 /* id callback defined */
722 }
723
724void thread_cleanup()
725 {
726 int i;
727
728 CRYPTO_set_locking_callback(NULL);
729 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
730 CloseHandle(lock_cs[i]);
731 }
732
733void win32_locking_callback(mode,type,file,line)
734int mode;
735int type;
736char *file;
737int line;
738 {
739 if (mode & CRYPTO_LOCK)
740 {
741 WaitForSingleObject(lock_cs[type],INFINITE);
742 }
743 else
744 {
745 ReleaseMutex(lock_cs[type]);
746 }
747 }
748
749void do_threads(s_ctx,c_ctx)
750SSL_CTX *s_ctx,*c_ctx;
751 {
752 double ret;
753 SSL_CTX *ssl_ctx[2];
754 DWORD thread_id[MAX_THREAD_NUMBER];
755 HANDLE thread_handle[MAX_THREAD_NUMBER];
756 int i;
757 SYSTEMTIME start,end;
758
759 ssl_ctx[0]=s_ctx;
760 ssl_ctx[1]=c_ctx;
761
762 GetSystemTime(&start);
763 for (i=0; i<thread_number; i++)
764 {
765 thread_handle[i]=CreateThread(NULL,
766 THREAD_STACK_SIZE,
767 (LPTHREAD_START_ROUTINE)ndoit,
768 (void *)ssl_ctx,
769 0L,
770 &(thread_id[i]));
771 }
772
773 printf("reaping\n");
774 for (i=0; i<thread_number; i+=50)
775 {
776 int j;
777
778 j=(thread_number < (i+50))?(thread_number-i):50;
779
780 if (WaitForMultipleObjects(j,
781 (CONST HANDLE *)&(thread_handle[i]),TRUE,INFINITE)
782 == WAIT_FAILED)
783 {
784 fprintf(stderr,"WaitForMultipleObjects failed:%d\n",GetLastError());
785 exit(1);
786 }
787 }
788 GetSystemTime(&end);
789
790 if (start.wDayOfWeek > end.wDayOfWeek) end.wDayOfWeek+=7;
791 ret=(end.wDayOfWeek-start.wDayOfWeek)*24;
792
793 ret=(ret+end.wHour-start.wHour)*60;
794 ret=(ret+end.wMinute-start.wMinute)*60;
795 ret=(ret+end.wSecond-start.wSecond);
796 ret+=(end.wMilliseconds-start.wMilliseconds)/1000.0;
797
798 printf("win32 threads done - %.3f seconds\n",ret);
799 }
800
801#endif /* WIN32 */
802
803#ifdef SOLARIS
804
805static mutex_t lock_cs[CRYPTO_NUM_LOCKS];
806/*static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; */
807static long lock_count[CRYPTO_NUM_LOCKS];
808
809void thread_setup()
810 {
811 int i;
812
813 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
814 {
815 lock_count[i]=0;
816 /* rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL); */
817 mutex_init(&(lock_cs[i]),USYNC_THREAD,NULL);
818 }
819
820 CRYPTO_set_id_callback((unsigned long (*)())solaris_thread_id);
821 CRYPTO_set_locking_callback((void (*)())solaris_locking_callback);
822 }
823
824void thread_cleanup()
825 {
826 int i;
827
828 CRYPTO_set_locking_callback(NULL);
829fprintf(stderr,"cleanup\n");
830 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
831 {
832 /* rwlock_destroy(&(lock_cs[i])); */
833 mutex_destroy(&(lock_cs[i]));
834 fprintf(stderr,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i));
835 }
836fprintf(stderr,"done cleanup\n");
837 }
838
839void solaris_locking_callback(mode,type,file,line)
840int mode;
841int type;
842char *file;
843int line;
844 {
845#ifdef undef
846fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
847 CRYPTO_thread_id(),
848 (mode&CRYPTO_LOCK)?"l":"u",
849 (type&CRYPTO_READ)?"r":"w",file,line);
850#endif
851
852/*
853if (CRYPTO_LOCK_SSL_CERT == type)
854 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
855 CRYPTO_thread_id(),
856 mode,file,line);
857*/
858 if (mode & CRYPTO_LOCK)
859 {
860 /* if (mode & CRYPTO_READ)
861 rw_rdlock(&(lock_cs[type]));
862 else
863 rw_wrlock(&(lock_cs[type])); */
864
865 mutex_lock(&(lock_cs[type]));
866 lock_count[type]++;
867 }
868 else
869 {
870/* rw_unlock(&(lock_cs[type])); */
871 mutex_unlock(&(lock_cs[type]));
872 }
873 }
874
875void do_threads(s_ctx,c_ctx)
876SSL_CTX *s_ctx,*c_ctx;
877 {
878 SSL_CTX *ssl_ctx[2];
879 thread_t thread_ctx[MAX_THREAD_NUMBER];
880 int i;
881
882 ssl_ctx[0]=s_ctx;
883 ssl_ctx[1]=c_ctx;
884
885 thr_setconcurrency(thread_number);
886 for (i=0; i<thread_number; i++)
887 {
888 thr_create(NULL, THREAD_STACK_SIZE,
889 (void *(*)())ndoit,
890 (void *)ssl_ctx,
891 0L,
892 &(thread_ctx[i]));
893 }
894
895 printf("reaping\n");
896 for (i=0; i<thread_number; i++)
897 {
898 thr_join(thread_ctx[i],NULL,NULL);
899 }
900
901 printf("solaris threads done (%d,%d)\n",
902 s_ctx->references,c_ctx->references);
903 }
904
905unsigned long solaris_thread_id()
906 {
907 unsigned long ret;
908
909 ret=(unsigned long)thr_self();
910 return(ret);
911 }
912#endif /* SOLARIS */
913
914#ifdef IRIX
915
916
917static usptr_t *arena;
918static usema_t *lock_cs[CRYPTO_NUM_LOCKS];
919
920void thread_setup()
921 {
922 int i;
923 char filename[20];
924
925 strcpy(filename,"/tmp/mttest.XXXXXX");
926 mktemp(filename);
927
928 usconfig(CONF_STHREADIOOFF);
929 usconfig(CONF_STHREADMALLOCOFF);
930 usconfig(CONF_INITUSERS,100);
931 usconfig(CONF_LOCKTYPE,US_DEBUGPLUS);
932 arena=usinit(filename);
933 unlink(filename);
934
935 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
936 {
937 lock_cs[i]=usnewsema(arena,1);
938 }
939
940 CRYPTO_set_id_callback((unsigned long (*)())irix_thread_id);
941 CRYPTO_set_locking_callback((void (*)())irix_locking_callback);
942 }
943
944void thread_cleanup()
945 {
946 int i;
947
948 CRYPTO_set_locking_callback(NULL);
949 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
950 {
951 char buf[10];
952
953 sprintf(buf,"%2d:",i);
954 usdumpsema(lock_cs[i],stdout,buf);
955 usfreesema(lock_cs[i],arena);
956 }
957 }
958
959void irix_locking_callback(mode,type,file,line)
960int mode;
961int type;
962char *file;
963int line;
964 {
965 if (mode & CRYPTO_LOCK)
966 {
967 printf("lock %d\n",type);
968 uspsema(lock_cs[type]);
969 }
970 else
971 {
972 printf("unlock %d\n",type);
973 usvsema(lock_cs[type]);
974 }
975 }
976
977void do_threads(s_ctx,c_ctx)
978SSL_CTX *s_ctx,*c_ctx;
979 {
980 SSL_CTX *ssl_ctx[2];
981 int thread_ctx[MAX_THREAD_NUMBER];
982 int i;
983
984 ssl_ctx[0]=s_ctx;
985 ssl_ctx[1]=c_ctx;
986
987 for (i=0; i<thread_number; i++)
988 {
989 thread_ctx[i]=sproc((void (*)())ndoit,
990 PR_SADDR|PR_SFDS,(void *)ssl_ctx);
991 }
992
993 printf("reaping\n");
994 for (i=0; i<thread_number; i++)
995 {
996 wait(NULL);
997 }
998
999 printf("irix threads done (%d,%d)\n",
1000 s_ctx->references,c_ctx->references);
1001 }
1002
1003unsigned long irix_thread_id()
1004 {
1005 unsigned long ret;
1006
1007 ret=(unsigned long)getpid();
1008 return(ret);
1009 }
1010#endif /* IRIX */
1011
1012#ifdef PTHREADS
1013
1014static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS];
1015static long lock_count[CRYPTO_NUM_LOCKS];
1016
1017void thread_setup()
1018 {
1019 int i;
1020
1021 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
1022 {
1023 lock_count[i]=0;
1024 pthread_mutex_init(&(lock_cs[i]),NULL);
1025 }
1026
1027 CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);
1028 CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback);
1029 }
1030
1031void thread_cleanup()
1032 {
1033 int i;
1034
1035 CRYPTO_set_locking_callback(NULL);
1036 fprintf(stderr,"cleanup\n");
1037 for (i=0; i<CRYPTO_NUM_LOCKS; i++)
1038 {
1039 pthread_mutex_destroy(&(lock_cs[i]));
1040 fprintf(stderr,"%8ld:%s\n",lock_count[i],
1041 CRYPTO_get_lock_name(i));
1042 }
1043 fprintf(stderr,"done cleanup\n");
1044 }
1045
1046void pthreads_locking_callback(mode,type,file,line)
1047int mode;
1048int type;
1049char *file;
1050int line;
1051 {
1052#ifdef undef
1053 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
1054 CRYPTO_thread_id(),
1055 (mode&CRYPTO_LOCK)?"l":"u",
1056 (type&CRYPTO_READ)?"r":"w",file,line);
1057#endif
1058/*
1059 if (CRYPTO_LOCK_SSL_CERT == type)
1060 fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
1061 CRYPTO_thread_id(),
1062 mode,file,line);
1063*/
1064 if (mode & CRYPTO_LOCK)
1065 {
1066 pthread_mutex_lock(&(lock_cs[type]));
1067 lock_count[type]++;
1068 }
1069 else
1070 {
1071 pthread_mutex_unlock(&(lock_cs[type]));
1072 }
1073 }
1074
1075void do_threads(s_ctx,c_ctx)
1076SSL_CTX *s_ctx,*c_ctx;
1077 {
1078 SSL_CTX *ssl_ctx[2];
1079 pthread_t thread_ctx[MAX_THREAD_NUMBER];
1080 int i;
1081
1082 ssl_ctx[0]=s_ctx;
1083 ssl_ctx[1]=c_ctx;
1084
1085 /*
1086 thr_setconcurrency(thread_number);
1087 */
1088 for (i=0; i<thread_number; i++)
1089 {
1090 pthread_create(&(thread_ctx[i]), NULL,
1091 (void *(*)())ndoit, (void *)ssl_ctx);
1092 }
1093
1094 printf("reaping\n");
1095 for (i=0; i<thread_number; i++)
1096 {
1097 pthread_join(thread_ctx[i],NULL);
1098 }
1099
1100 printf("pthreads threads done (%d,%d)\n",
1101 s_ctx->references,c_ctx->references);
1102 }
1103
1104unsigned long pthreads_thread_id()
1105 {
1106 unsigned long ret;
1107
1108 ret=(unsigned long)pthread_self();
1109 return(ret);
1110 }
1111
1112#endif /* PTHREADS */
1113
1114
1115
diff --git a/src/lib/libssl/src/mt/profile.sh b/src/lib/libssl/src/mt/profile.sh
new file mode 100644
index 0000000000..de5eb06708
--- /dev/null
+++ b/src/lib/libssl/src/mt/profile.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3cc -p -DSOLARIS -I../include -g mttest.c -o mttest -L/usr/lib/libc -ldl -L.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libssl/src/mt/ptest.bat b/src/lib/libssl/src/mt/ptest.bat
new file mode 100644
index 0000000000..ccaccae09d
--- /dev/null
+++ b/src/lib/libssl/src/mt/ptest.bat
@@ -0,0 +1,4 @@
1del mttest.exe
2
3purify cl /O2 -DWIN32 /MD -I..\out mttest.c /Femttest ..\out\ssl32.lib ..\out\crypt32.lib
4
diff --git a/src/lib/libssl/src/mt/pthread.sh b/src/lib/libssl/src/mt/pthread.sh
new file mode 100644
index 0000000000..7d0b6e55f5
--- /dev/null
+++ b/src/lib/libssl/src/mt/pthread.sh
@@ -0,0 +1,9 @@
1#!/bin/sh
2#
3# build using pthreads
4#
5# http://www.mit.edu:8001/people/proven/pthreads.html
6#
7/bin/rm -f mttest
8pgcc -DPTHREADS -I../include -g mttest.c -o mttest -L.. -lssl -lcrypto
9
diff --git a/src/lib/libssl/src/mt/purify.sh b/src/lib/libssl/src/mt/purify.sh
new file mode 100644
index 0000000000..57c4017073
--- /dev/null
+++ b/src/lib/libssl/src/mt/purify.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3purify cc -DSOLARIS -I../include -g mttest.c -o mttest -L.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libssl/src/mt/solaris.sh b/src/lib/libssl/src/mt/solaris.sh
new file mode 100644
index 0000000000..f6a90b17ee
--- /dev/null
+++ b/src/lib/libssl/src/mt/solaris.sh
@@ -0,0 +1,4 @@
1#!/bin/sh
2/bin/rm -f mttest
3cc -DSOLARIS -I../include -g mttest.c -o mttest -L.. -lthread -lssl -lcrypto -lnsl -lsocket
4
diff --git a/src/lib/libssl/src/mt/win32.bat b/src/lib/libssl/src/mt/win32.bat
new file mode 100644
index 0000000000..56089f69be
--- /dev/null
+++ b/src/lib/libssl/src/mt/win32.bat
@@ -0,0 +1,4 @@
1del mttest.exe
2
3cl /O2 -DWIN32 /MD -I..\out mttest.c /Femttest ..\out\ssleay32.lib ..\out\libeay32.lib
4
diff --git a/src/lib/libssl/src/perl/MANIFEST b/src/lib/libssl/src/perl/MANIFEST
new file mode 100644
index 0000000000..992db5ed4c
--- /dev/null
+++ b/src/lib/libssl/src/perl/MANIFEST
@@ -0,0 +1,17 @@
1MANIFEST
2Makefile.PL
3SSLeay.pm
4bio.xs
5bn.xs
6cipher.xs
7digest.xs
8err.xs
9ssl.xs
10x509.xs
11test.pl
12test2.pl
13test3.pl
14test9.pl
15testbn.pl
16testmd.pl
17typemap
diff --git a/src/lib/libssl/src/perl/Makefile.PL b/src/lib/libssl/src/perl/Makefile.PL
new file mode 100644
index 0000000000..f9998e0a61
--- /dev/null
+++ b/src/lib/libssl/src/perl/Makefile.PL
@@ -0,0 +1,25 @@
1use ExtUtils::MakeMaker;
2# See lib/ExtUtils/MakeMaker.pm for details of how to influence
3# the contents of the Makefile that is written.
4WriteMakefile(
5 'OPTIMIZE' => '-g',
6 'DISTNAME' => 'SSLeay-perl5-0.8.5',
7 'NAME' => 'SSLeay',
8 'VERSION_FROM' => 'SSLeay.pm',
9 'LIBS' => ['-L.. -lssl -lcrypto'],
10 'DEFINE' => '',
11 'INC' => '-I../include',
12 'C' => ['callback.c'],
13 'H' => ['p5SSLeay.h'],
14 'OBJECT' => " SSLeay.o bio.o bn.o cipher.o digest.o err.o
15 ssl.o x509.o",
16 'XS' => { 'SSLeay.xs' => 'SSLeay.c',
17 'bio.xs' => 'bio.c',
18 'bn.xs' => 'bn.c',
19 'cipher.xs' => 'cipher.c',
20 'digest.xs' => 'digest.c',
21 'err.xs' => 'err.c',
22 'ssl.xs' => 'ssl.c',
23 'x509.xs' => 'x509.c',
24 }
25 );
diff --git a/src/lib/libssl/src/perl/SSLeay.pm b/src/lib/libssl/src/perl/SSLeay.pm
new file mode 100644
index 0000000000..f7710039d2
--- /dev/null
+++ b/src/lib/libssl/src/perl/SSLeay.pm
@@ -0,0 +1,78 @@
1package SSLeay;
2
3use Exporter;
4use DynaLoader;
5
6@ISA = qw(Exporter DynaLoader);
7@EXPORT = qw();
8
9$VERSION='0.82';
10$VERSION='0.82';
11bootstrap SSLeay;
12
13@SSLeay::BN::ISA= qw(SSLeay::ERR);
14@SSLeay::MD::ISA= qw(SSLeay::ERR);
15@SSLeay::Cipher::ISA= qw(SSLeay::ERR);
16@SSLeay::SSL::CTX::ISA= qw(SSLeay::ERR);
17@SSLeay::BIO::ISA= qw(SSLeay::ERR);
18@SSLeay::SSL::ISA= qw(SSLeay::ERR);
19
20@BN::ISA= qw(SSLeay::BN);
21@MD::ISA= qw(SSLeay::MD);
22@Cipher::ISA= qw(SSLeay::Cipher);
23@SSL::ISA= qw(SSLeay::SSL);
24@SSL::CTX::ISA= qw(SSLeay::SSL::CTX);
25@BIO::ISA= qw(SSLeay::BIO);
26
27
28@SSLeay::MD::names=qw(md2 md5 sha sha1 ripemd160 mdc2);
29
30@SSLeay::Cipher::names=qw(
31 des-ecb des-cfb des-ofb des-cbc
32 des-ede des-ede-cfb des-ede-ofb des-ede-cbc
33 des-ede3 des-ede3-cfb des-ede3-ofb des-ede3-cbc
34 desx-cbc rc4 rc4-40
35 idea-ecb idea-cfb idea-ofb idea-cbc
36 rc2-ecb rc2-cbc rc2-40-cbc rc2-cfb rc2-ofb
37 bf-ecb bf-cfb bf-ofb bf-cbc
38 cast5-ecb cast5-cfb cast5-ofb cast5-cbc
39 rc5-ecb rc5-cfb rc5-ofb rc5-cbc
40 );
41
42sub SSLeay::SSL::CTX::new_ssl { SSLeay::SSL::new($_[0]); }
43
44sub SSLeay::ERR::error
45 {
46 my($o)=@_;
47 my($s,$ret);
48
49 while (($s=$o->get_error()) != 0)
50 {
51 $ret.=$s."\n";
52 }
53 return($ret);
54 }
55
56@SSLeay::Cipher::aliases=qw(des desx des3 idea rc2 bf cast);
57
58package SSLeay::BN;
59
60sub bnfix { (ref($_[0]) ne "SSLeay::BN")?SSLeay::BN::dec2bn($_[0]):$_[0]; }
61use overload
62"=" => sub { dup($_[0]); },
63"+" => sub { add($_[0],$_[1]); },
64"-" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2];
65 SSLeay::BN::sub($_[0],$_[1]); },
66"*" => sub { mul($_[0],$_[1]); },
67"/" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; (div($_[0],$_[1]))[0]; },
68"%" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; mod($_[0],$_[1]); },
69"**" => sub { ($_[1],$_[0])=($_[0],$_[1]) if $_[2]; exp($_[0],$_[1]); },
70"<<" => sub { lshift($_[0],$_[1]); },
71">>" => sub { rshift($_[0],$_[1]); },
72"<=>" => sub { SSLeay::BN::cmp($_[0],$_[1]); },
73'""' => sub { bn2dec($_[0]); },
74'0+' => sub { dec2bn($_[0]); },
75"bool" => sub { ref($_[0]) eq "SSLeay::BN"; };
76
77sub SSLeay::BIO::do_accept { SSLeay::BIO::do_handshake(@_); }
781;
diff --git a/src/lib/libssl/src/perl/SSLeay.xs b/src/lib/libssl/src/perl/SSLeay.xs
new file mode 100644
index 0000000000..582b5705aa
--- /dev/null
+++ b/src/lib/libssl/src/perl/SSLeay.xs
@@ -0,0 +1,63 @@
1#include "p5SSLeay.h"
2
3SV *new_ref(type,obj,mort)
4char *type;
5char *obj;
6 {
7 SV *ret;
8
9 if (mort)
10 ret=sv_newmortal();
11 else
12 ret=newSViv(0);
13 sv_setref_pv(ret,type,(void *)obj);
14 return(ret);
15 }
16
17int ex_new(obj,data,ad,idx,argl,argp)
18char *obj;
19SV *data;
20CRYPTO_EX_DATA *ad;
21int idx;
22long argl;
23char *argp;
24 {
25 SV *sv;
26
27fprintf(stderr,"ex_new %08X %s\n",obj,argp);
28 sv=sv_newmortal();
29 sv_setref_pv(sv,argp,(void *)obj);
30 CRYPTO_set_ex_data(ad,idx,(char *)sv);
31 return(1);
32 }
33
34void ex_cleanup(obj,data,ad,idx,argl,argp)
35char *obj;
36SV *data;
37CRYPTO_EX_DATA *ad;
38int idx;
39long argl;
40char *argp;
41 {
42 pr_name("ex_cleanup");
43fprintf(stderr,"ex_cleanup %08X %s\n",obj,argp);
44 if (data != NULL)
45 SvREFCNT_dec((SV *)data);
46 }
47
48MODULE = SSLeay PACKAGE = SSLeay
49
50BOOT:
51 boot_bio();
52 boot_cipher();
53 boot_digest();
54 boot_err();
55 boot_ssl();
56 boot_SSLeay__BN();
57 boot_SSLeay__BIO();
58 boot_SSLeay__Cipher();
59 boot_SSLeay__MD();
60 boot_SSLeay__ERR();
61 boot_SSLeay__SSL();
62 boot_SSLeay__X509();
63
diff --git a/src/lib/libssl/src/perl/b.pl b/src/lib/libssl/src/perl/b.pl
new file mode 100644
index 0000000000..e8b3fd0dd9
--- /dev/null
+++ b/src/lib/libssl/src/perl/b.pl
@@ -0,0 +1,21 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$cmd=<<"EOF";
8
9EOF
10
11$conn="localhost:4433";
12$conn=$ARGV[0] if $#ARGV >= 0;
13print "X\n";
14$bio=BIO->new("connect");
15print "XX\n";
16$bio->set_callback(sub {print STDERR $_[0]->number_read."\n"; $_[$#_] });
17print "XXX\n";
18$bio->hostname($conn) || die $ssl->error();
19print "XXXX\n";
20
21#$ssl=BIO->new("ssl");
diff --git a/src/lib/libssl/src/perl/bio.pl b/src/lib/libssl/src/perl/bio.pl
new file mode 100644
index 0000000000..653322c2cc
--- /dev/null
+++ b/src/lib/libssl/src/perl/bio.pl
@@ -0,0 +1,28 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$cmd=<<"EOF";
8
9EOF
10
11$conn="localhost:4433";
12$conn=$ARGV[0] if $#ARGV >= 0;
13$bio=SSLeay::BIO::new("connect");
14$bio->set_callback(sub {print STDERR $_[0]->number_read."\n"; $_[$#_] });
15$bio->hostname($conn) || die $ssl->error();
16
17
18(($ret=$bio->do_handshake()) > 0) || die $bio->error();
19
20(($ret=$bio->syswrite($cmd)) > 0) || die $bio->error();
21
22while (1)
23 {
24 $ret=$bio->sysread($buf,10240);
25 last if ($ret <= 0);
26 print $buf;
27 }
28
diff --git a/src/lib/libssl/src/perl/bio.txt b/src/lib/libssl/src/perl/bio.txt
new file mode 100644
index 0000000000..5b46c9f5ee
--- /dev/null
+++ b/src/lib/libssl/src/perl/bio.txt
@@ -0,0 +1,36 @@
1BIO::new(type)
2 "connect"
3 "accept"
4 "ssl"
5 "buffer"
6
7"connect"
8 BIO::hostname(name) host:port to connect to
9
10"accept"
11 BIO::set_accept_port(port) port to connect too.
12
13"connect", "accept", "ssl"
14 BIO::do_andshake do protocol
15
16"ssl"
17 BIO::set_ssl(ssl)
18 BIO::get_ssl()
19
20BIO::push(bio)
21BIO::pop; return BIO
22BIO::number_read()
23BIO::number_written()
24BIO::references()
25
26BIO::sysread(buf,len[,offset])
27BIO::syswrite(in[,len][,offset])
28BIO::getline()
29BIO::puts(in)
30BIO::flush()
31BIO::type()
32BIO::next_bio();
33BIO::set_callback(callback[, args])
34
35BIO::new_buffer_ssl_connect(SSL_CTX)
36BIO::new_ssl_connect(SSL_CTX)
diff --git a/src/lib/libssl/src/perl/bio.xs b/src/lib/libssl/src/perl/bio.xs
new file mode 100644
index 0000000000..3782d42062
--- /dev/null
+++ b/src/lib/libssl/src/perl/bio.xs
@@ -0,0 +1,448 @@
1#include "p5SSLeay.h"
2
3static int p5_bio_ex_bio_ptr=0;
4static int p5_bio_ex_bio_callback=0;
5static int p5_bio_ex_bio_callback_data=0;
6
7static long p5_bio_callback(bio,state,parg,cmd,larg,ret)
8BIO *bio;
9int state;
10char *parg;
11int cmd;
12long larg;
13int ret;
14 {
15 int i;
16 SV *me,*cb;
17
18 me=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr);
19 cb=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_callback);
20 if (cb != NULL)
21 {
22 dSP;
23
24 ENTER ;
25 SAVETMPS;
26
27 PUSHMARK(sp);
28 XPUSHs(me);
29 XPUSHs(sv_2mortal(newSViv(state)));
30 XPUSHs(sv_2mortal(newSViv(cmd)));
31 if ((state == BIO_CB_READ) || (state == BIO_CB_WRITE))
32 {
33 XPUSHs(sv_2mortal(newSVpv(parg,larg)));
34 }
35 else
36 XPUSHs(&sv_undef);
37 /* ptr one */
38 XPUSHs(sv_2mortal(newSViv(larg)));
39 XPUSHs(sv_2mortal(newSViv(ret)));
40 PUTBACK;
41
42 i=perl_call_sv(cb,G_SCALAR);
43
44 SPAGAIN;
45 if (i == 1)
46 ret=POPi;
47 else
48 ret=1;
49 PUTBACK;
50 FREETMPS;
51 LEAVE;
52 }
53 else
54 {
55 croak("Internal error in SSL p5_ssl_info_callback");
56 }
57 return(ret);
58 }
59
60int boot_bio()
61 {
62 p5_bio_ex_bio_ptr=
63 BIO_get_ex_new_index(0,"SSLeay::BIO",ex_new,NULL,ex_cleanup);
64 p5_bio_ex_bio_callback=
65 BIO_get_ex_new_index(0,"bio_callback",NULL,NULL,
66 ex_cleanup);
67 p5_bio_ex_bio_callback_data=
68 BIO_get_ex_new_index(0,"bio_callback_data",NULL,NULL,
69 ex_cleanup);
70 return(1);
71 }
72
73MODULE = SSLeay::BIO PACKAGE = SSLeay::BIO PREFIX = p5_BIO_
74
75VERSIONCHECK: DISABLE
76
77void
78p5_BIO_new_buffer_ssl_connect(...)
79 PREINIT:
80 SSL_CTX *ctx;
81 BIO *bio;
82 SV *arg;
83 PPCODE:
84 if (items == 1)
85 arg=ST(0);
86 else if (items == 2)
87 arg=ST(1);
88 else
89 arg=NULL;
90
91 if ((arg == NULL) || !(sv_derived_from(arg,"SSLeay::SSL::CTX")))
92 croak("Usage: SSLeay::BIO::new_buffer_ssl_connect(SSL_CTX)");
93 else
94 {
95 IV tmp=SvIV((SV *)SvRV(arg));
96 ctx=(SSL_CTX *)tmp;
97 }
98 EXTEND(sp,1);
99 bio=BIO_new_buffer_ssl_connect(ctx);
100 arg=new_ref("SSLeay::BIO",(char *)bio,0);
101 PUSHs(arg);
102 BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg);
103
104void
105p5_BIO_new_ssl_connect(...)
106 PREINIT:
107 SSL_CTX *ctx;
108 BIO *bio;
109 SV *arg;
110 PPCODE:
111 if (items == 1)
112 arg=ST(0);
113 else if (items == 2)
114 arg=ST(1);
115 else
116 arg=NULL;
117
118 if ((arg == NULL) || !(sv_derived_from(arg,"SSLeay::SSL::CTX")))
119 croak("Usage: SSLeay::BIO::new_ssl_connect(SSL_CTX)");
120 else
121 {
122 IV tmp=SvIV((SV *)SvRV(arg));
123 ctx=(SSL_CTX *)tmp;
124 }
125 EXTEND(sp,1);
126 bio=BIO_new_ssl_connect(ctx);
127 arg=new_ref("SSLeay::BIO",(char *)bio,0);
128 PUSHs(arg);
129 BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg);
130
131void
132p5_BIO_new(...)
133 PREINIT:
134 BIO *bio;
135 char *type;
136 SV *arg;
137 PPCODE:
138 pr_name("p5_BIO_new");
139 if ((items == 1) && SvPOK(ST(0)))
140 type=SvPV(ST(0),na);
141 else if ((items == 2) && SvPOK(ST(1)))
142 type=SvPV(ST(1),na);
143 else
144 croak("Usage: SSLeay::BIO::new(type)");
145
146 EXTEND(sp,1);
147 if (strcmp(type,"connect") == 0)
148 bio=BIO_new(BIO_s_connect());
149 else if (strcmp(type,"accept") == 0)
150 bio=BIO_new(BIO_s_accept());
151 else if (strcmp(type,"ssl") == 0)
152 bio=BIO_new(BIO_f_ssl());
153 else if (strcmp(type,"buffer") == 0)
154 bio=BIO_new(BIO_f_buffer());
155 else
156 croak("unknown BIO type");
157 arg=new_ref("SSLeay::BIO",(char *)bio,0);
158 PUSHs(arg);
159 BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg);
160
161int
162p5_BIO_hostname(bio,name)
163 BIO *bio;
164 char *name;
165 CODE:
166 RETVAL=BIO_set_hostname(bio,name);
167 OUTPUT:
168 RETVAL
169
170int
171p5_BIO_set_accept_port(bio,str)
172 BIO *bio;
173 char *str;
174 CODE:
175 RETVAL=BIO_set_accept_port(bio,str);
176 OUTPUT:
177 RETVAL
178
179int
180p5_BIO_do_handshake(bio)
181 BIO *bio;
182 CODE:
183 RETVAL=BIO_do_handshake(bio);
184 OUTPUT:
185 RETVAL
186
187BIO *
188p5_BIO_push(b,bio)
189 BIO *b;
190 BIO *bio;
191 CODE:
192 /* This reference will be reduced when the reference is
193 * let go, and then when the BIO_free_all() is called
194 * inside the SSLeay library by the BIO with this
195 * pushed into */
196 bio->references++;
197 RETVAL=BIO_push(b,bio);
198 OUTPUT:
199 RETVAL
200
201void
202p5_BIO_pop(b)
203 BIO *b
204 PREINIT:
205 BIO *bio;
206 char *type;
207 SV *arg;
208 PPCODE:
209 bio=BIO_pop(b);
210 if (bio != NULL)
211 {
212 /* This BIO will either be one created in the
213 * perl library, in which case it will have a perl
214 * SV, otherwise it will have been created internally,
215 * inside SSLeay. For the 'pushed in', it needs
216 * the reference count decememted. */
217 arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr);
218 if (arg == NULL)
219 {
220 arg=new_ref("SSLeay::BIO",(char *)bio,0);
221 PUSHs(arg);
222 BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg);
223 }
224 else
225 {
226 /* it was pushed in */
227 SvREFCNT_inc(arg);
228 PUSHs(arg);
229 if (bio->references < 1)
230 abort();
231 /* decrement the reference count */
232 BIO_free(bio);
233 }
234 }
235
236int
237p5_BIO_sysread(bio,in,num, ...)
238 BIO *bio;
239 SV *in;
240 int num;
241 PREINIT:
242 int i,n,olen;
243 int offset;
244 char *p;
245 CODE:
246 offset=0;
247 if (!SvPOK(in))
248 sv_setpvn(in,"",0);
249 SvPV(in,olen);
250 if (items > 3)
251 {
252 offset=SvIV(ST(3));
253 if (offset < 0)
254 {
255 if (-offset > olen)
256 croad("Offset outside string");
257 offset+=olen;
258 }
259 }
260 if ((num+offset) > olen)
261 {
262 SvGROW(in,num+offset+1);
263 p=SvPV(in,i);
264 memset(&(p[olen]),0,(num+offset)-olen+1);
265 }
266 p=SvPV(in,n);
267
268 i=BIO_read(bio,p+offset,num);
269 RETVAL=i;
270 if (i <= 0) i=0;
271 SvCUR_set(in,offset+i);
272 OUTPUT:
273 RETVAL
274
275int
276p5_BIO_syswrite(bio,in, ...)
277 BIO *bio;
278 SV *in;
279 PREINIT:
280 char *ptr;
281 int len,in_len;
282 int offset=0;
283 int n;
284 CODE:
285 ptr=SvPV(in,in_len);
286 if (items > 2)
287 {
288 len=SvOK(ST(2))?SvIV(ST(2)):in_len;
289 if (items > 3)
290 {
291 offset=SvIV(ST(3));
292 if (offset < 0)
293 {
294 if (-offset > in_len)
295 croak("Offset outside string");
296 offset+=in_len;
297 }
298 else if ((offset >= in_len) && (in_len > 0))
299 croak("Offset outside string");
300 }
301 if (len >= (in_len-offset))
302 len=in_len-offset;
303 }
304 else
305 len=in_len;
306
307 RETVAL=BIO_write(bio,ptr+offset,len);
308 OUTPUT:
309 RETVAL
310
311void
312p5_BIO_getline(bio)
313 BIO *bio;
314 PREINIT:
315 int i;
316 char *p;
317 PPCODE:
318 pr_name("p5_BIO_gets");
319 EXTEND(sp,1);
320 PUSHs(sv_newmortal());
321 sv_setpvn(ST(0),"",0);
322 SvGROW(ST(0),1024);
323 p=SvPV(ST(0),na);
324 i=BIO_gets(bio,p,1024);
325 if (i < 0) i=0;
326 SvCUR_set(ST(0),i);
327
328int
329p5_BIO_flush(bio)
330 BIO *bio;
331 CODE:
332 RETVAL=BIO_flush(bio);
333 OUTPUT:
334 RETVAL
335
336char *
337p5_BIO_type(bio)
338 BIO *bio;
339 CODE:
340 RETVAL=bio->method->name;
341 OUTPUT:
342 RETVAL
343
344void
345p5_BIO_next_bio(b)
346 BIO *b
347 PREINIT:
348 BIO *bio;
349 char *type;
350 SV *arg;
351 PPCODE:
352 bio=b->next_bio;
353 if (bio != NULL)
354 {
355 arg=(SV *)BIO_get_ex_data(bio,p5_bio_ex_bio_ptr);
356 if (arg == NULL)
357 {
358 arg=new_ref("SSLeay::BIO",(char *)bio,0);
359 PUSHs(arg);
360 BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,(char *)arg);
361 }
362 else
363 {
364 SvREFCNT_inc(arg);
365 PUSHs(arg);
366 }
367 }
368
369int
370p5_BIO_puts(bio,in)
371 BIO *bio;
372 SV *in;
373 PREINIT:
374 char *ptr;
375 CODE:
376 ptr=SvPV(in,na);
377 RETVAL=BIO_puts(bio,ptr);
378 OUTPUT:
379 RETVAL
380
381void
382p5_BIO_set_callback(bio,cb,...)
383 BIO *bio;
384 SV *cb;
385 PREINIT:
386 SV *arg=NULL;
387 SV *arg2=NULL;
388 CODE:
389 if (items > 3)
390 croak("Usage: SSLeay::BIO::set_callback(bio,callback[,arg]");
391 if (items == 3)
392 {
393 arg2=sv_mortalcopy(ST(2));
394 SvREFCNT_inc(arg2);
395 BIO_set_ex_data(bio,p5_bio_ex_bio_callback_data,
396 (char *)arg2);
397 }
398 arg=sv_mortalcopy(ST(1));
399 SvREFCNT_inc(arg);
400 BIO_set_ex_data(bio,p5_bio_ex_bio_callback,(char *)arg);
401 BIO_set_callback(bio,p5_bio_callback);
402
403void
404p5_BIO_DESTROY(bio)
405 BIO *bio
406 PREINIT:
407 SV *sv;
408 PPCODE:
409 pr_name_d("p5_BIO_DESTROY",bio->references);
410 printf("p5_BIO_DESTROY <%s> %d\n",bio->method->name,bio->references);
411 BIO_set_ex_data(bio,p5_bio_ex_bio_ptr,NULL);
412 BIO_free_all(bio);
413
414int
415p5_BIO_set_ssl(bio,ssl)
416 BIO *bio;
417 SSL *ssl;
418 CODE:
419 pr_name("p5_BIO_set_ssl");
420 ssl->references++;
421 RETVAL=BIO_set_ssl(bio,ssl,BIO_CLOSE);
422 OUTPUT:
423 RETVAL
424
425int
426p5_BIO_number_read(bio)
427 BIO *bio;
428 CODE:
429 RETVAL=BIO_number_read(bio);
430 OUTPUT:
431 RETVAL
432
433int
434p5_BIO_number_written(bio)
435 BIO *bio;
436 CODE:
437 RETVAL=BIO_number_written(bio);
438 OUTPUT:
439 RETVAL
440
441int
442p5_BIO_references(bio)
443 BIO *bio;
444 CODE:
445 RETVAL=bio->references;
446 OUTPUT:
447 RETVAL
448
diff --git a/src/lib/libssl/src/perl/bn.pl b/src/lib/libssl/src/perl/bn.pl
new file mode 100644
index 0000000000..5314ca46e1
--- /dev/null
+++ b/src/lib/libssl/src/perl/bn.pl
@@ -0,0 +1,23 @@
1#!/usr/bin/perl
2use ExtUtils::testlib;
3use SSLeay;
4
5$message=SSLeay::BN::new();
6$e=SSLeay::BN::new();
7$mod=SSLeay::BN::new();
8
9$mod=SSLeay::BN::dec2bn("114381625757888867669235779976146612010218296721242362562561842935706935245733897830597123563958705058989075147599290026879543541");
10$e=5;
11$d=SSLeay::BN::dec2bn("45752650303155547067694311990458644804087318688496945025024737159778909096647814932594914301288138204957467016445183857236173773");
12
13$message=SSLeay::BN::bin2bn("The magic words are squeamish ossifrage");
14
15
16 $cipher_text= $message->mod_exp($e,$mod);
17print $mod."\n";
18print $mod->num_bits()."\n";
19for (1 .. 1000)
20 {
21 $clear= $cipher_text->mod_exp($d,$mod);
22 }
23print $clear->bn2bin()."\n";
diff --git a/src/lib/libssl/src/perl/bn.txt b/src/lib/libssl/src/perl/bn.txt
new file mode 100644
index 0000000000..784e761558
--- /dev/null
+++ b/src/lib/libssl/src/perl/bn.txt
@@ -0,0 +1,38 @@
1BN->new()
2BN->dup(a)
3BN->rand(bits[,top][,bottom])
4
5BN->hex2bn(a)
6BN->bn2hex(a)
7BN->dec2bn(a)
8BN->bn2dec(a)
9BN->bin2bn(a)
10BN->bn2bin(a)
11BN->mpi2bn(a)
12BN->bn2mpi(a)
13
14BN->add(a,b)
15BN->sub(a,b)
16BN->mul(a,b)
17(div,mod)=BN->div(a,b)
18BN->mod(a,b)
19BN->exp(a,p)
20BN->mod_mul(a,b,c)
21BN->mod_exp(a,b,c)
22
23BN->is_prime(p,num)
24BN->generate_prime(bits,strong,callback)
25
26BN->num_bits(a)
27BN->cmp(a,b)
28BN->ucmp(a,b)
29BN->is_bit_set(a,pos)
30BN->set_bit(a,pos)
31BN->clear_bit(a,pos)
32BN->lshift(a,num)
33BN->rshift(a,num)
34BN->mask_bits(a,pos)
35BN->clear(a)
36BN->gcd(a,b)
37BN->mod_inverse(a,mod)
38
diff --git a/src/lib/libssl/src/perl/bn.xs b/src/lib/libssl/src/perl/bn.xs
new file mode 100644
index 0000000000..c15be3729a
--- /dev/null
+++ b/src/lib/libssl/src/perl/bn.xs
@@ -0,0 +1,589 @@
1#include "p5SSLeay.h"
2
3int sv_to_BIGNUM(var,arg,name)
4BIGNUM **var;
5SV *arg;
6char *name;
7 {
8 int ret=1;
9
10 if (sv_derived_from(arg,"SSLeay::BN"))
11 {
12 IV tmp = SvIV((SV*)SvRV(arg));
13 *var = (BIGNUM *) tmp;
14 }
15 else if (SvIOK(arg)) {
16 SV *tmp=sv_newmortal();
17 *var=BN_new();
18 BN_set_word(*var,SvIV(arg));
19 sv_setref_pv(tmp,"SSLeay::BN",(void*)*var);
20 }
21 else if (SvPOK(arg)) {
22 char *ptr;
23 STRLEN len;
24 SV *tmp=sv_newmortal();
25 *var=BN_new();
26 sv_setref_pv(tmp,"SSLeay::BN", (void*)*var);
27 ptr=SvPV(arg,len);
28 SvGROW(arg,len+1);
29 ptr[len]='\0';
30 BN_dec2bn(var,ptr);
31 }
32 else
33 {
34 croak(name);
35 ret=0;
36 }
37 return(ret);
38 }
39
40typedef struct gpc_args_st {
41 SV *cb;
42 SV *arg;
43 } GPC_ARGS;
44
45static void generate_prime_callback(pos,num,arg)
46int pos;
47int num;
48char *arg;
49 {
50 dSP ;
51 int i;
52 GPC_ARGS *a=(GPC_ARGS *)arg;
53
54 ENTER ;
55 SAVETMPS ;
56
57 PUSHMARK(sp);
58 XPUSHs(sv_2mortal(newSViv(pos)));
59 XPUSHs(sv_2mortal(newSViv(num)));
60 XPUSHs(sv_2mortal(newSVsv(a->arg)));
61 PUTBACK;
62
63 i=perl_call_sv(a->cb,G_DISCARD);
64
65 SPAGAIN;
66
67 PUTBACK;
68 FREETMPS;
69 LEAVE;
70 }
71
72MODULE = SSLeay::BN PACKAGE = SSLeay::BN PREFIX = p5_BN_
73
74VERSIONCHECK: DISABLE
75
76void
77p5_BN_new(...)
78 PREINIT:
79 BIGNUM *bn;
80 SV *arg;
81 PPCODE:
82 pr_name("p5_BN_new");
83 EXTEND(sp,1);
84 PUSHs(sv_newmortal());
85 bn=BN_new();
86 sv_setref_pv(ST(0), "SSLeay::BN", (void*)bn);
87
88void
89p5_BN_dup(a)
90 BIGNUM *a;
91 PREINIT:
92 BIGNUM *bn;
93 PPCODE:
94 pr_name("p5_BN_dup");
95 EXTEND(sp,1);
96 PUSHs(sv_newmortal());
97 bn=BN_dup(a);
98 sv_setref_pv(ST(0), "SSLeay::BN", (void*)bn);
99
100void
101p5_BN_rand(bits,...)
102 int bits;
103 PREINIT:
104 int top=1;
105 int bottom=0;
106 BIGNUM *ret;
107 PPCODE:
108 pr_name("p5_BN_rand");
109 if ((items < 1) || (items > 3))
110 croak("Usage: SSLeay::BN::rand(bits[,top_bit][,bottombit]");
111 if (items >= 2) top=(int)SvIV(ST(0));
112 if (items >= 3) bottom=(int)SvIV(ST(1));
113 EXTEND(sp,1);
114 PUSHs(sv_newmortal());
115 ret=BN_new();
116 BN_rand(ret,bits,top,bottom);
117 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
118
119void
120p5_BN_bin2bn(a)
121 datum a;
122 PREINIT:
123 BIGNUM *ret;
124 PPCODE:
125 pr_name("p5_BN_bin2bn");
126 EXTEND(sp,1);
127 PUSHs(sv_newmortal());
128 ret=BN_bin2bn(a.dptr,a.dsize,NULL);
129 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
130
131void
132p5_BN_bn2bin(a)
133 BIGNUM *a;
134 PREINIT:
135 int i;
136 PPCODE:
137 pr_name("p5_BN_bn2bin");
138 EXTEND(sp,1);
139 PUSHs(sv_newmortal());
140 i=BN_num_bytes(a)+2;
141 sv_setpvn(ST(0),"",1);
142 SvGROW(ST(0),i+1);
143 SvCUR_set(ST(0),BN_bn2bin(a,SvPV(ST(0),na)));
144
145void
146p5_BN_mpi2bn(a)
147 datum a;
148 PREINIT:
149 BIGNUM *ret;
150 PPCODE:
151 pr_name("p5_BN_mpi2bn");
152 EXTEND(sp,1);
153 PUSHs(sv_newmortal());
154 ret=BN_mpi2bn(a.dptr,a.dsize,NULL);
155 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
156
157void
158p5_BN_bn2mpi(a)
159 BIGNUM *a;
160 PREINIT:
161 int i;
162 PPCODE:
163 pr_name("p5_BN_bn2mpi");
164 EXTEND(sp,1);
165 PUSHs(sv_newmortal());
166 i=BN_bn2mpi(a,NULL);
167 sv_setpvn(ST(0),"",1);
168 SvGROW(ST(0),i+1);
169 SvCUR_set(ST(0),BN_bn2mpi(a,SvPV(ST(0),na)));
170
171void
172p5_BN_hex2bn(a)
173 datum a;
174 PREINIT:
175 BIGNUM *ret;
176 PPCODE:
177 pr_name("p5_BN_hex2bn");
178 EXTEND(sp,1);
179 PUSHs(sv_newmortal());
180 ret=BN_new();
181 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
182 BN_hex2bn(&ret,a.dptr);
183
184void
185p5_BN_dec2bn(a)
186 datum a;
187 PREINIT:
188 BIGNUM *ret;
189 PPCODE:
190 pr_name("p5_BN_dec2bn");
191 EXTEND(sp,1);
192 PUSHs(sv_newmortal());
193 ret=BN_new();
194 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
195 BN_dec2bn(&ret,a.dptr);
196
197SV *
198p5_BN_bn2hex(a)
199 BIGNUM *a;
200 PREINIT:
201 char *ptr;
202 int i;
203 CODE:
204 pr_name("p5_BN_bn2hex");
205 ptr=BN_bn2hex(a);
206 RETVAL=newSVpv("",0);
207 i=strlen(ptr);
208 SvGROW(RETVAL,i+1);
209 memcpy(SvPV(RETVAL,na),ptr,i+1);
210 SvCUR_set(RETVAL,i);
211 Free(ptr);
212 OUTPUT:
213 RETVAL
214
215SV *
216p5_BN_bn2dec(a)
217 BIGNUM *a;
218 PREINIT:
219 char *ptr;
220 int i;
221 CODE:
222 pr_name("p5_BN_bn2dec");
223 ptr=BN_bn2dec(a);
224 RETVAL=newSVpv("",0);
225 i=strlen(ptr);
226 SvGROW(RETVAL,i+1);
227 memcpy(SvPV(RETVAL,na),ptr,i+1);
228 SvCUR_set(RETVAL,i);
229 Free(ptr);
230 OUTPUT:
231 RETVAL
232
233void
234p5_BN_add(a,b)
235 BIGNUM *a;
236 BIGNUM *b;
237 PREINIT:
238 BIGNUM *ret;
239 PPCODE:
240 pr_name("p5_BN_add");
241 EXTEND(sp,1);
242 PUSHs(sv_newmortal());
243 ret=BN_new();
244 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
245 BN_add(ret,a,b);
246
247void
248p5_BN_sub(a,b)
249 BIGNUM *a;
250 BIGNUM *b;
251 PREINIT:
252 BIGNUM *ret;
253 PPCODE:
254 pr_name("p5_BN_sub");
255 EXTEND(sp,1);
256 PUSHs(sv_newmortal());
257 ret=BN_new();
258 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
259 BN_sub(ret,a,b);
260
261void
262p5_BN_mul(a,b)
263 BIGNUM *a;
264 BIGNUM *b;
265 PREINIT:
266 BIGNUM *ret;
267 PPCODE:
268 pr_name("p5_BN_mul");
269 EXTEND(sp,1);
270 PUSHs(sv_newmortal());
271 ret=BN_new();
272 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
273 BN_mul(ret,a,b);
274
275void
276p5_BN_div(a,b)
277 BIGNUM *a;
278 BIGNUM *b;
279 PREINIT:
280 static BN_CTX *ctx=NULL;
281 BIGNUM *div,*mod;
282 PPCODE:
283 pr_name("p5_BN_div");
284 if (ctx == NULL) ctx=BN_CTX_new();
285 EXTEND(sp,2);
286 PUSHs(sv_newmortal());
287 PUSHs(sv_newmortal());
288 div=BN_new();
289 mod=BN_new();
290 sv_setref_pv(ST(0), "SSLeay::BN", (void*)div);
291 sv_setref_pv(ST(1), "SSLeay::BN", (void*)mod);
292 BN_div(div,mod,a,b,ctx);
293
294void
295p5_BN_mod(a,b)
296 BIGNUM *a;
297 BIGNUM *b;
298 PREINIT:
299 static BN_CTX *ctx=NULL;
300 BIGNUM *rem;
301 PPCODE:
302 pr_name("p5_BN_mod");
303 if (ctx == NULL) ctx=BN_CTX_new();
304 EXTEND(sp,1);
305 PUSHs(sv_newmortal());
306 rem=BN_new();
307 sv_setref_pv(ST(0), "SSLeay::BN", (void*)rem);
308 BN_mod(rem,a,b,ctx);
309
310void
311p5_BN_exp(a,p)
312 BIGNUM *a;
313 BIGNUM *p;
314 PREINIT:
315 BIGNUM *ret;
316 static BN_CTX *ctx=NULL;
317 PPCODE:
318 pr_name("p5_BN_exp");
319 if (ctx == NULL) ctx=BN_CTX_new();
320 EXTEND(sp,1);
321 PUSHs(sv_newmortal());
322 ret=BN_new();
323 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
324 BN_exp(ret,a,p,ctx);
325
326void
327p5_BN_mod_mul(a,b,c)
328 BIGNUM *a;
329 BIGNUM *b;
330 BIGNUM *c;
331 PREINIT:
332 static BN_CTX *ctx=NULL;
333 BIGNUM *ret;
334 PPCODE:
335 pr_name("p5_BN_mod_mul");
336 if (ctx == NULL) ctx=BN_CTX_new();
337 EXTEND(sp,1);
338 PUSHs(sv_newmortal());
339 ret=BN_new();
340 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
341 BN_mod_mul(ret,a,b,c,ctx);
342
343void
344p5_BN_mod_exp(a,b,c)
345 BIGNUM *a;
346 BIGNUM *b;
347 BIGNUM *c;
348 PREINIT:
349 static BN_CTX *ctx=NULL;
350 BIGNUM *ret;
351 PPCODE:
352 pr_name("p5_BN_mod_exp");
353 if (ctx == NULL) ctx=BN_CTX_new();
354 EXTEND(sp,1);
355 PUSHs(sv_newmortal());
356 ret=BN_new();
357 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
358 BN_mod_exp(ret,a,b,c,ctx);
359
360void
361p5_BN_generate_prime(...)
362 PREINIT:
363 int bits=512;
364 int strong=0;
365 BIGNUM *ret=NULL;
366 SV *callback=NULL;
367 SV *cb_arg=NULL;
368 GPC_ARGS arg;
369 dSP;
370
371 PPCODE:
372 pr_name("p5_BN_generate_prime");
373 if ((items < 0) || (items > 4))
374 croak("Usage: SSLeay::BN::generate_prime(a[,strong][,callback][,cb_arg]");
375 if (items >= 1) bits=(int)SvIV(ST(0));
376 if (items >= 2) strong=(int)SvIV(ST(1));
377 if (items >= 3) callback=ST(2);
378 if (items == 4) cb_arg=ST(3);
379
380 if (callback == NULL)
381 ret=BN_generate_prime(bits,strong,NULL,NULL,NULL,NULL);
382 else
383 {
384 arg.cb=callback;
385 arg.arg=cb_arg;
386
387 ret=BN_generate_prime(bits,strong,NULL,NULL,
388 generate_prime_callback,(char *)&arg);
389 }
390
391 SPAGAIN;
392 sp-=items; /* a bit evil that I do this */
393
394 EXTEND(sp,1);
395 PUSHs(sv_newmortal());
396 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
397
398void
399p5_BN_is_prime(p,...)
400 BIGNUM *p;
401 PREINIT:
402 int nchecks=5,ret;
403 SV *callback=NULL;
404 SV *cb_arg=NULL;
405 GPC_ARGS arg;
406 dSP;
407 static BN_CTX *ctx=NULL;
408 PPCODE:
409 pr_name("p5_BN_is_prime");
410 if ((items < 1) || (items > 4))
411 croak("Usage: SSLeay::BN::is_prime(a[,ncheck][,callback][,callback_arg]");
412 if (ctx == NULL) ctx=BN_CTX_new();
413 if (items >= 2) nchecks=(int)SvIV(ST(1));
414 if (items >= 3) callback=ST(2);
415 if (items >= 4) cb_arg=ST(3);
416 arg.arg=cb_arg;
417 if (callback == NULL)
418 ret=BN_is_prime(p,nchecks,NULL,ctx,NULL);
419 else
420 {
421 arg.cb=callback;
422 arg.arg=cb_arg;
423 ret=BN_is_prime(p,nchecks,generate_prime_callback,
424 ctx,(char *)&arg);
425 }
426 SPAGAIN;
427 sp-=items; /* a bit evil */
428 PUSHs(sv_2mortal(newSViv(ret)));
429
430int
431p5_BN_num_bits(a)
432 BIGNUM *a;
433 CODE:
434 pr_name("p5_BN_num_bits");
435 RETVAL=BN_num_bits(a);
436 OUTPUT:
437 RETVAL
438
439int
440p5_BN_cmp(a,b)
441 BIGNUM *a;
442 BIGNUM *b;
443 CODE:
444 pr_name("p5_BN_cmp");
445 RETVAL=BN_cmp(a,b);
446 OUTPUT:
447 RETVAL
448
449int
450p5_BN_ucmp(a,b)
451 BIGNUM *a;
452 BIGNUM *b;
453 CODE:
454 pr_name("p5_BN_ucmp");
455 RETVAL=BN_ucmp(a,b);
456 OUTPUT:
457 RETVAL
458
459int
460p5_BN_is_bit_set(a,b)
461 BIGNUM *a;
462 int b;
463 CODE:
464 pr_name("p5_BN_is_bit_set");
465 RETVAL=BN_is_bit_set(a,b);
466 OUTPUT:
467 RETVAL
468
469void
470p5_BN_set_bit(a,b)
471 BIGNUM *a;
472 int b;
473 PREINIT:
474 BIGNUM *ret;
475 PPCODE:
476 pr_name("p5_BN_set_bit");
477 EXTEND(sp,1);
478 PUSHs(sv_newmortal());
479 ret=BN_dup(a);
480 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
481 BN_set_bit(ret,b);
482
483void
484p5_BN_clear_bit(a,b)
485 BIGNUM *a;
486 int b;
487 PREINIT:
488 BIGNUM *ret;
489 PPCODE:
490 pr_name("p5_BN_clear_bit");
491 EXTEND(sp,1);
492 PUSHs(sv_newmortal());
493 ret=BN_dup(a);
494 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
495 BN_clear_bit(ret,b);
496
497void
498p5_BN_lshift(a,b)
499 BIGNUM *a;
500 int b;
501 PREINIT:
502 BIGNUM *ret;
503 PPCODE:
504 pr_name("p5_BN_lshift");
505 EXTEND(sp,1);
506 PUSHs(sv_newmortal());
507 ret=BN_new();
508 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
509 if (b == 1)
510 BN_lshift1(ret,a);
511 else
512 BN_lshift(ret,a,b);
513
514void
515p5_BN_rshift(a,b)
516 BIGNUM *a;
517 int b;
518 PREINIT:
519 BIGNUM *ret;
520 PPCODE:
521 pr_name("p5_BN_rshift");
522 EXTEND(sp,1);
523 PUSHs(sv_newmortal());
524 ret=BN_new();
525 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
526 if (b == 1)
527 BN_rshift1(ret,a);
528 else
529 BN_rshift(ret,a,b);
530
531void
532p5_BN_mask_bits(a,b)
533 BIGNUM *a;
534 int b;
535 PREINIT:
536 BIGNUM *ret;
537 PPCODE:
538 pr_name("p5_BN_mask_bits");
539 EXTEND(sp,1);
540 PUSHs(sv_newmortal());
541 ret=BN_dup(a);
542 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
543 BN_mask_bits(ret,b);
544
545void
546p5_BN_clear(a)
547 BIGNUM *a;
548 PPCODE:
549 pr_name("p5_BN_clear");
550 BN_clear(a);
551
552void
553p5_BN_gcd(a,b)
554 BIGNUM *a;
555 BIGNUM *b;
556 PREINIT:
557 static BN_CTX *ctx=NULL;
558 BIGNUM *ret;
559 PPCODE:
560 pr_name("p5_BN_gcd");
561 if (ctx == NULL) ctx=BN_CTX_new();
562 EXTEND(sp,1);
563 PUSHs(sv_newmortal());
564 ret=BN_new();
565 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
566 BN_gcd(ret,a,b,ctx);
567
568void
569p5_BN_mod_inverse(a,mod)
570 BIGNUM *a;
571 BIGNUM *mod;
572 PREINIT:
573 static BN_CTX *ctx=NULL;
574 BIGNUM *ret;
575 PPCODE:
576 pr_name("p5_BN_mod_inverse");
577 if (ctx == NULL) ctx=BN_CTX_new();
578 ret=BN_mod_inverse(a,mod,ctx);
579 EXTEND(sp,1);
580 PUSHs(sv_newmortal());
581 sv_setref_pv(ST(0), "SSLeay::BN", (void*)ret);
582
583void
584p5_BN_DESTROY(bn)
585 BIGNUM *bn
586 CODE:
587 pr_name("p5_BN_DESTROY");
588 BN_free(bn);
589
diff --git a/src/lib/libssl/src/perl/callback.c b/src/lib/libssl/src/perl/callback.c
new file mode 100644
index 0000000000..01840abc85
--- /dev/null
+++ b/src/lib/libssl/src/perl/callback.c
@@ -0,0 +1,103 @@
1/* perl/callback.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59SV *new_ref(type,obj,mort)
60char *type;
61char *obj;
62 {
63 SV *ret;
64
65 if (mort)
66 ret=sv_newmortal();
67 else
68 ret=newSViv(0);
69 sv_setref_pv(ret,type,(void *)obj);
70 return(ret);
71 }
72
73int ex_new(obj,data,ad,idx,argl,argp)
74char *obj;
75SV *data;
76CRYPTO_EX_DATA *ad;
77int idx;
78long argl;
79char *argp;
80 {
81 SV *sv;
82
83fprintf(stderr,"ex_new %08X %s\n",obj,argp);
84 sv=sv_newmortal();
85 sv_setref_pv(sv,argp,(void *)obj);
86 CRYPTO_set_ex_data(ad,idx,(char *)sv);
87 return(1);
88 }
89
90void ex_cleanup(obj,data,ad,idx,argl,argp)
91char *obj;
92SV *data;
93CRYPTO_EX_DATA *ad;
94int idx;
95long argl;
96char *argp;
97 {
98 pr_name("ex_cleanup");
99fprintf(stderr,"ex_cleanup %08X %s\n",obj,argp);
100 if (data != NULL)
101 SvREFCNT_dec((SV *)data);
102 }
103
diff --git a/src/lib/libssl/src/perl/cipher.pl b/src/lib/libssl/src/perl/cipher.pl
new file mode 100644
index 0000000000..e774bceed2
--- /dev/null
+++ b/src/lib/libssl/src/perl/cipher.pl
@@ -0,0 +1,39 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$md=SSLeay::MD::new("md5");
8
9foreach (@SSLeay::Cipher::names)
10 {
11 ($c=SSLeay::Cipher::new($_)) ||
12 die "'$_' is an unknown cipher algorithm\n";
13
14
15 $data="012345678abcdefghijklmnopqrstuvwxyz";
16 $c->init("01234567abcdefghABCDEFGH","zyxwvut",1);
17
18 $in =$c->update(substr($data, 0, 5));
19 $in.=$c->update(substr($data, 5,10));
20 $in.=$c->update(substr($data,15,1));
21 $in.=$c->update(substr($data,16));
22
23 $in.=$c->final();
24
25 $c->init("01234567abcdefghABCDEFGH","zyxwvut",0);
26 $out=$c->update($in);
27 $out.=$c->final();
28
29 ($out eq $data) || die "decrypt for $_ failed:$!\n";
30
31 $md->init();
32 $md->update($in);
33 $digest=$md->final();
34
35 print unpack("H*",$digest);
36 printf " %2d %2d %2d %s\n", $c->key_length(), $c->iv_length(),
37 $c->block_size(), $c->name();
38 }
39
diff --git a/src/lib/libssl/src/perl/cipher.txt b/src/lib/libssl/src/perl/cipher.txt
new file mode 100644
index 0000000000..c47952b5c9
--- /dev/null
+++ b/src/lib/libssl/src/perl/cipher.txt
@@ -0,0 +1,10 @@
1Cipher::new(name) "des-cbc" etc
2Cipher::name()
3Cipher::key_length()
4Cipher::iv_length()
5Cipher::block_size()
6
7Cipher::init(key,iv,enc)
8Cipher::update(in)
9Cipher::final()
10Cipher::cipher(in)
diff --git a/src/lib/libssl/src/perl/cipher.xs b/src/lib/libssl/src/perl/cipher.xs
new file mode 100644
index 0000000000..1044d7a4ef
--- /dev/null
+++ b/src/lib/libssl/src/perl/cipher.xs
@@ -0,0 +1,152 @@
1#include "p5SSLeay.h"
2
3int boot_cipher()
4 {
5 SSLeay_add_all_ciphers();
6 return(1);
7 }
8
9MODULE = SSLeay::Cipher PACKAGE = SSLeay::Cipher PREFIX = p5_EVP_C_
10
11VERSIONCHECK: DISABLE
12
13void
14p5_EVP_C_new(...)
15 PREINIT:
16 EVP_CIPHER_CTX *ctx;
17 EVP_CIPHER *c;
18 char *name;
19 PPCODE:
20 if ((items == 1) && SvPOK(ST(0)))
21 name=SvPV(ST(0),na);
22 else if ((items == 2) && SvPOK(ST(1)))
23 name=SvPV(ST(1),na);
24 else
25 croak("Usage: SSLeay::Cipher::new(type)");
26 PUSHs(sv_newmortal());
27 c=EVP_get_cipherbyname(name);
28 if (c != NULL)
29 {
30 ctx=malloc(sizeof(EVP_CIPHER_CTX));
31 EVP_EncryptInit(ctx,c,NULL,NULL);
32 sv_setref_pv(ST(0), "SSLeay::Cipher", (void*)ctx);
33 }
34
35datum
36p5_EVP_C_name(ctx)
37 EVP_CIPHER_CTX *ctx
38 CODE:
39 RETVAL.dptr=OBJ_nid2ln(EVP_CIPHER_CTX_nid(ctx));
40 RETVAL.dsize=strlen(RETVAL.dptr);
41 OUTPUT:
42 RETVAL
43
44int
45p5_EVP_C_key_length(ctx)
46 EVP_CIPHER_CTX *ctx
47 CODE:
48 RETVAL=EVP_CIPHER_CTX_key_length(ctx);
49 OUTPUT:
50 RETVAL
51
52int
53p5_EVP_C_iv_length(ctx)
54 EVP_CIPHER_CTX *ctx
55 CODE:
56 RETVAL=EVP_CIPHER_CTX_iv_length(ctx);
57 OUTPUT:
58 RETVAL
59
60int
61p5_EVP_C_block_size(ctx)
62 EVP_CIPHER_CTX *ctx
63 CODE:
64 RETVAL=EVP_CIPHER_CTX_block_size(ctx);
65 OUTPUT:
66 RETVAL
67
68void
69p5_EVP_C_init(ctx,key,iv,enc)
70 EVP_CIPHER_CTX *ctx
71 datum key
72 datum iv
73 int enc
74 PREINIT:
75 char loc_iv[EVP_MAX_IV_LENGTH];
76 char loc_key[EVP_MAX_KEY_LENGTH];
77 char *ip=loc_iv,*kp=loc_key;
78 int i;
79 memset(loc_iv,0,EVP_MAX_IV_LENGTH);
80 memset(loc_key,0,EVP_MAX_KEY_LENGTH);
81 CODE:
82 i=key.dsize;
83 if (key.dsize > EVP_CIPHER_CTX_key_length(ctx))
84 i=EVP_CIPHER_CTX_key_length(ctx);
85 if (i > 0)
86 {
87 memset(kp,0,EVP_MAX_KEY_LENGTH);
88 memcpy(kp,key.dptr,i);
89 }
90 else
91 kp=NULL;
92 i=iv.dsize;
93 if (iv.dsize > EVP_CIPHER_CTX_iv_length(ctx))
94 i=EVP_CIPHER_CTX_iv_length(ctx);
95 if (i > 0)
96 {
97 memcpy(ip,iv.dptr,i);
98 memset(ip,0,EVP_MAX_IV_LENGTH);
99 }
100 else
101 ip=NULL;
102 EVP_CipherInit(ctx,EVP_CIPHER_CTX_cipher(ctx),kp,ip,enc);
103 memset(loc_key,0,sizeof(loc_key));
104 memset(loc_iv,0,sizeof(loc_iv));
105
106SV *
107p5_EVP_C_cipher(ctx,in)
108 EVP_CIPHER_CTX *ctx;
109 datum in;
110 CODE:
111 RETVAL=newSVpv("",0);
112 SvGROW(RETVAL,in.dsize+EVP_CIPHER_CTX_block_size(ctx)+1);
113 EVP_Cipher(ctx,SvPV(RETVAL,na),in.dptr,in.dsize);
114 SvCUR_set(RETVAL,in.dsize);
115 OUTPUT:
116 RETVAL
117
118SV *
119p5_EVP_C_update(ctx, in)
120 EVP_CIPHER_CTX *ctx
121 datum in
122 PREINIT:
123 int i;
124 CODE:
125 RETVAL=newSVpv("",0);
126 SvGROW(RETVAL,in.dsize+EVP_CIPHER_CTX_block_size(ctx)+1);
127 EVP_CipherUpdate(ctx,SvPV(RETVAL,na),&i,in.dptr,in.dsize);
128 SvCUR_set(RETVAL,i);
129 OUTPUT:
130 RETVAL
131
132SV *
133p5_EVP_C_final(ctx)
134 EVP_CIPHER_CTX *ctx
135 PREINIT:
136 int i;
137 CODE:
138 RETVAL=newSVpv("",0);
139 SvGROW(RETVAL,EVP_CIPHER_CTX_block_size(ctx)+1);
140 if (!EVP_CipherFinal(ctx,SvPV(RETVAL,na),&i))
141 sv_setpv(RETVAL,"BAD DECODE");
142 else
143 SvCUR_set(RETVAL,i);
144 OUTPUT:
145 RETVAL
146
147void
148p5_EVP_C_DESTROY(ctx)
149 EVP_CIPHER_CTX *ctx
150 CODE:
151 free((char *)ctx);
152
diff --git a/src/lib/libssl/src/perl/dh.pl b/src/lib/libssl/src/perl/dh.pl
new file mode 100644
index 0000000000..73decc241a
--- /dev/null
+++ b/src/lib/libssl/src/perl/dh.pl
@@ -0,0 +1,40 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$g=SSLeay::BN::hex2bn("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002");
8$p=SSLeay::BN::hex2bn("ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff");
9$pub=SSLeay::BN::hex2bn("521b5b72d0a23f5f908eff62741b9c43ac65c47ad264a4f8d62d73dfab4938a6e019f81c28d64efd9b47c1b8188566c6184b6064cc42fac2778bd732678148c6cc7601bfe0ed18da76dd7bb976cd2ff0afc7b20f3f81171e2ea6534de061f929");
10$priv=SSLeay::BN::hex2bn("6e15c752af3f4cf6d7425164c451eeba760ec0651d12dc3b0ee5002a95af6191268ca47c0fbb3d836136eee795ae4af3a1adad5e04d0dbb04378cae0406ece23ca3b86839c0fd60064c1019c7d18be4dc0ec4be6c1e9ff6b0f5bd76373585503");
11$his=SSLeay::BN::hex2bn("d0fb51cd44a8578f55eb0822ede90f07504f4720d7367ff4bf76c27fedbce79d9204421ff7e86bd1dd02031bce4ceccd1d3e7c62679b6eb5fda8238fd4fe07bff573d552795f0d46f25753c688300fb9ed396792b59a49fdf89c8429124b668e");
12$sh=SSLeay::BN::hex2bn("66ec34b09bddf86147f6c6efd5ee4e6691e690eb0e90aceda16a742cad0abe531cb61d057aff362001ca19013215140ca2a1dd8966c78105bacbf2161f9cfbd58d351ff87923de77f9c56851037223d48272565416ee769e65a621cefb90b403");
13
14$g2=SSLeay::BN::hex2bn("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002");
15$p2=SSLeay::BN::hex2bn("ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff");
16$pub2=SSLeay::BN::hex2bn("d0fb51cd44a8578f55eb0822ede90f07504f4720d7367ff4bf76c27fedbce79d9204421ff7e86bd1dd02031bce4ceccd1d3e7c62679b6eb5fda8238fd4fe07bff573d552795f0d46f25753c688300fb9ed396792b59a49fdf89c8429124b668e");
17$priv2=SSLeay::BN::hex2bn("b81d54f52b687669fc8bd8087ac319accc2f94a2feafe09779f4a81e8e01f77290f5bbe84a08003afc4448145be427fad0b9d047889cf361c9dd378b15c1ebd5bda33e051fbd9eba8bf063e2bd836467cddb61f1db5c4b06bea5c9a77fb87b24");
18$his2=SSLeay::BN::hex2bn("521b5b72d0a23f5f908eff62741b9c43ac65c47ad264a4f8d62d73dfab4938a6e019f81c28d64efd9b47c1b8188566c6184b6064cc42fac2778bd732678148c6cc7601bfe0ed18da76dd7bb976cd2ff0afc7b20f3f81171e2ea6534de061f929");
19$sh2=SSLeay::BN::hex2bn("791faba7a6b592cb68a963945229483dc30f80f5cb295b2b5a59ef618a262d22de0845948a34db83d8bde260b940967ff85593a609e53ee6510aea09b776b4704d5e916917f384458d4790b6e0befcb1cb2f112b850e9ed410a091db80e1db2e");
20
21print "g=".$g->bn2hex."\n";
22print "p=".$p->bn2hex."\n";
23print "pub=".$pub->bn2hex."\n";
24print "priv=".$priv->bn2hex."\n";
25print "sh=".$sh->bn2hex."\n";
26
27print "new p - p2 = ".($p-$p2)."\n";
28
29$tmp=$g->mod_exp($priv,$p);
30print "XXXXXXXXXXXXXXXX\n";
31print "new pub - pub = ".($tmp-$pub)."\n";
32$tmp2=$g2->mod_exp($priv2,$p2);
33print "XXXXXXXXXXXXXXXX\n";
34
35print $p." pub\n";
36print $tmp2." calc pub\n";
37print $pub2." txt pub\n";
38
39
40
diff --git a/src/lib/libssl/src/perl/digest.txt b/src/lib/libssl/src/perl/digest.txt
new file mode 100644
index 0000000000..6cb3ffedb0
--- /dev/null
+++ b/src/lib/libssl/src/perl/digest.txt
@@ -0,0 +1,7 @@
1MD::new(name) "md2", "md5" etc
2MD::name()
3MD::init()
4MD::update(in)
5MD::final()
6
7
diff --git a/src/lib/libssl/src/perl/digest.xs b/src/lib/libssl/src/perl/digest.xs
new file mode 100644
index 0000000000..5738b09e48
--- /dev/null
+++ b/src/lib/libssl/src/perl/digest.xs
@@ -0,0 +1,83 @@
1#include "p5SSLeay.h"
2
3int boot_digest()
4 {
5 SSLeay_add_all_digests();
6 return(1);
7 }
8
9MODULE = SSLeay::MD PACKAGE = SSLeay::MD PREFIX = p5_EVP_MD_
10
11PROTOTYPES: ENABLE
12VERSIONCHECK: DISABLE
13
14# SSLeay::MD::new(name) name= md2, md5, sha, sha1, or mdc2
15# md->name() - returns the name
16# md->init() - reinitalises the digest
17# md->update(data) - adds more data to digest
18# digest=md->final() - returns digest
19#
20
21void
22p5_EVP_MD_new(...)
23 PREINIT:
24 EVP_MD_CTX *ctx;
25 EVP_MD *md;
26 char *name;
27 PPCODE:
28 if ((items == 1) && SvPOK(ST(0)))
29 name=SvPV(ST(0),na);
30 else if ((items == 2) && SvPOK(ST(1)))
31 name=SvPV(ST(1),na);
32 else
33 croak("Usage: SSLeay::MD::new(type)");
34 PUSHs(sv_newmortal());
35 md=EVP_get_digestbyname(name);
36 if (md != NULL)
37 {
38 ctx=malloc(sizeof(EVP_MD_CTX));
39 EVP_DigestInit(ctx,md);
40 sv_setref_pv(ST(0), "SSLeay::MD", (void*)ctx);
41 }
42
43datum
44p5_EVP_MD_name(ctx)
45 EVP_MD_CTX *ctx
46 CODE:
47 RETVAL.dptr=OBJ_nid2ln(EVP_MD_type(EVP_MD_CTX_type(ctx)));
48 RETVAL.dsize=strlen(RETVAL.dptr);
49 OUTPUT:
50 RETVAL
51
52void
53p5_EVP_MD_init(ctx)
54 EVP_MD_CTX *ctx
55 CODE:
56 EVP_DigestInit(ctx,EVP_MD_CTX_type(ctx));
57
58void
59p5_EVP_MD_update(ctx, in)
60 EVP_MD_CTX *ctx
61 datum in
62 CODE:
63 EVP_DigestUpdate(ctx,in.dptr,in.dsize);
64
65datum
66p5_EVP_MD_final(ctx)
67 EVP_MD_CTX *ctx
68 PREINIT:
69 char md[EVP_MAX_MD_SIZE];
70 int len;
71 CODE:
72 EVP_DigestFinal(ctx,md,&len);
73 RETVAL.dptr=md;
74 RETVAL.dsize=len;
75 OUTPUT:
76 RETVAL
77
78void
79p5_EVP_MD_DESTROY(ctx)
80 EVP_MD_CTX *ctx
81 CODE:
82 free((char *)ctx);
83
diff --git a/src/lib/libssl/src/perl/err.txt b/src/lib/libssl/src/perl/err.txt
new file mode 100644
index 0000000000..5e6cdaecdc
--- /dev/null
+++ b/src/lib/libssl/src/perl/err.txt
@@ -0,0 +1,2 @@
1ERR::get_error()
2ERR::peek_error()
diff --git a/src/lib/libssl/src/perl/err.xs b/src/lib/libssl/src/perl/err.xs
new file mode 100644
index 0000000000..6d1aec3ea1
--- /dev/null
+++ b/src/lib/libssl/src/perl/err.xs
@@ -0,0 +1,46 @@
1#include "p5SSLeay.h"
2
3int boot_err()
4 {
5 SSL_load_error_strings();
6 return(1);
7 }
8
9MODULE = SSLeay::ERR PACKAGE = SSLeay::ERR PREFIX = p5_ERR_
10
11PROTOTYPES: ENABLE
12VERSIONCHECK: DISABLE
13
14# md->error() - returns the last error in text or numeric context
15
16void
17p5_ERR_get_error(...)
18 PPCODE:
19 char buf[512];
20 unsigned long l;
21
22 pr_name("p5_ERR_get_code");
23 EXTEND(sp,1);
24 PUSHs(sv_newmortal());
25 l=ERR_get_error();
26 ERR_error_string(l,buf);
27 sv_setiv(ST(0),l);
28 sv_setpv(ST(0),buf);
29 SvIOK_on(ST(0));
30
31void
32p5_ERR_peek_error(...)
33 PPCODE:
34 char buf[512];
35 unsigned long l;
36
37 pr_name("p5_ERR_get_code");
38 EXTEND(sp,1);
39 PUSHs(sv_newmortal());
40 l=ERR_peek_error();
41 ERR_error_string(l,buf);
42 sv_setiv(ST(0),l);
43 sv_setpv(ST(0),buf);
44 SvIOK_on(ST(0));
45
46
diff --git a/src/lib/libssl/src/perl/f.pl b/src/lib/libssl/src/perl/f.pl
new file mode 100644
index 0000000000..a255931864
--- /dev/null
+++ b/src/lib/libssl/src/perl/f.pl
@@ -0,0 +1,25 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$data=<>;
8
9#$b=SSLeay::BN::hex2bn($a);
10#$data=$b->bn2bin;
11
12#substr($data,0,8)="";
13#print $data;
14
15$md=SSLeay::MD::new("md5");
16$md->init();
17$md->update("test");
18$key=$md->final();
19
20$rc4=SSLeay::Cipher::new("rc4");
21$rc4->init($key,"",1);
22$out=$rc4->cipher($data);
23
24print $out;
25
diff --git a/src/lib/libssl/src/perl/g.pl b/src/lib/libssl/src/perl/g.pl
new file mode 100644
index 0000000000..ffbe694b05
--- /dev/null
+++ b/src/lib/libssl/src/perl/g.pl
@@ -0,0 +1,18 @@
1#!/usr/bin/perl
2use ExtUtils::testlib;
3use SSLeay;
4
5$num=SSLeay::BN::new();
6$shift=SSLeay::BN::new();
7
8print "0\n";
9$num=SSLeay::BN::hex2bn("1234329378209857309429670349760347603497603496398");
10print "1\n";
11$s=SSLeay::BN::hex2bn("59");
12print "a\n";
13$r=$num->lshift(59);
14print "b";
15
16print $num->bn2hex."\n";
17print $s->bn2hex."\n";
18print $r->bn2hex."\n";
diff --git a/src/lib/libssl/src/perl/gen_rsa.pl b/src/lib/libssl/src/perl/gen_rsa.pl
new file mode 100644
index 0000000000..ed8c71aa9e
--- /dev/null
+++ b/src/lib/libssl/src/perl/gen_rsa.pl
@@ -0,0 +1,49 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$bits=512;
8$bits=$ARGV[0] if $#ARGV >= 0;
9
10$p=SSLeay::BN::generate_prime($bits/2,0,sub {print STDERR $_[0]?"+":"."});
11print "\n";
12$q=SSLeay::BN::generate_prime($bits/2,0,sub {print STDERR $_[0]?"+":"."});
13print "\n";
14
15$e=SSLeay::BN::hex2bn("10001");
16
17$t1=$p-1;
18$t2=$q-1;
19
20($t1->gcd($e) == 1) || die "p failed the gcd test\n";
21($t2->gcd($e) == 1) || die "q failed the gcd test\n";
22
23($q,$p)=($p,$q) if ($p < $q);
24$n=$p*$q;
25$t=($p-1)*($q-1);
26($t->gcd($e) == 1) || die "t failed the gcd test\n";
27
28$d=$e->mod_inverse($t);
29
30$dmp1=$d%($p-1);
31$dmq1=$d%($q-1);
32$iqmp=$q->mod_inverse($p);
33
34print "n =$n\n";
35print "e =$e\n";
36print "d =$d\n";
37print "dmp1=$dmp1\n";
38print "dmq1=$dmq1\n";
39print "iqmp=$iqmp\n";
40
41$a=SSLeay::BN::bin2bn("This is an RSA test");
42print "Test with\n'".$a->bn2bin."' or\n$a\n";
43
44$t1=$a->mod_exp($e,$n);
45print "$t1\n";
46$t2=$t1->mod_exp($d,$n);
47print "'".$t2->bn2bin."'\n";
48
49
diff --git a/src/lib/libssl/src/perl/mul.pl b/src/lib/libssl/src/perl/mul.pl
new file mode 100644
index 0000000000..611a760625
--- /dev/null
+++ b/src/lib/libssl/src/perl/mul.pl
@@ -0,0 +1,56 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7
8sub mul
9 {
10 my($ab,$cd,$num)=@_;
11
12 if ($num <= 4096)
13 {
14 return($ab*$cd);
15 }
16 else
17 {
18 my($a,$b,$c,$d,$n,$ac,$bd,$m,$t1,$t2);
19
20 $n=$num/2;
21
22 $a=$ab->mask_bits($n);
23 $b=$ab->rshift($n);
24 $c=$cd->mask_bits($n);
25 $d=$cd->rshift($n);
26
27 $t1=($b-$a);
28 $t2=($c-$d);
29 $m= &mul($t1,$t2,$n);
30 $ac=&mul($a,$c,$n);
31 $bd=&mul($b,$d,$n);
32 $m=$m+$ac+$bd;
33 $m=$m->lshift($n);
34 $bd=$bd->lshift($num);
35
36 $r=$ac+$m+$bd;
37 return($r);
38 }
39 }
40
41$num=4096*32;
42$a=SSLeay::BN::rand($num);
43$b=SSLeay::BN::rand($num);
44
45#for (1 .. 10)
46 {
47 $r=&mul($a,$b,$num);
48 }
49
50#for (1 .. 10)
51 {
52 $rr=$a*$b;
53 }
54
55$res=$rr-$r;
56print $res->bn2hex()."\n";
diff --git a/src/lib/libssl/src/perl/p5SSLeay.h b/src/lib/libssl/src/perl/p5SSLeay.h
new file mode 100644
index 0000000000..bcccda7d5f
--- /dev/null
+++ b/src/lib/libssl/src/perl/p5SSLeay.h
@@ -0,0 +1,96 @@
1/* perl/p5SSLeay.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58#ifdef __cplusplus
59extern "C" {
60#endif
61#include "EXTERN.h"
62#include "perl.h"
63#include "XSUB.h"
64#ifdef __cplusplus
65}
66#endif
67
68typedef struct datum_st
69 {
70 char *dptr;
71 int dsize;
72 } datum;
73
74#include "crypto.h"
75#include "buffer.h"
76#include "bio.h"
77#include "evp.h"
78#include "err.h"
79#include "x509.h"
80#include "ssl.h"
81
82#if 0
83#define pr_name(name) printf("%s\n",name)
84#define pr_name_d(name,p2) printf("%s %d\n",name,p2)
85#define pr_name_dd(name,p2,p3) printf("%s %d %d\n",name,p2,p3)
86#else
87#define pr_name(name)
88#define pr_name_d(name,p2)
89#define pr_name_dd(name,p2,p3)
90#endif
91
92SV *new_ref(char *type, char *obj, int mort);
93int ex_new(char *obj,SV *data,CRYPTO_EX_DATA *ad,int idx,long argl,char *argp);
94void ex_cleanup(char *obj,SV *data,CRYPTO_EX_DATA *ad,int idx,
95 long argl,char *argp);
96
diff --git a/src/lib/libssl/src/perl/r.pl b/src/lib/libssl/src/perl/r.pl
new file mode 100644
index 0000000000..abcc331c78
--- /dev/null
+++ b/src/lib/libssl/src/perl/r.pl
@@ -0,0 +1,56 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$bits=512;
8$bits=$ARGV[0] if $#ARGV >= 0;
9
10$q=SSLeay::BN::dec2bn("334533373942443239443435463034324139443635374634423531423146313742443038394230324138363038393539303745363034393946353346323345374537463935433635374238353245344341444241344138413244373443323338334431414134363244443532423243423133433537");
11
12$p=SSLeay::BN::dec2bn("3338413942343132463534373734353742343636444439363131313131353843334536434330363934313646414132453044434138413630434631334134443046313735313632344131433437443642434436423642453234383046393732383538444139393131314339303743393939363744443235443332393332394543384630304634323646333735");
13$pp=SSLeay::BN::generate_prime($bits/2,0,sub {print STDERR $_[0]?"+":"."});
14
15printf $pp->is_prime."\n";
16printf $p->is_prime."\n";
17printf $q->is_prime."\n";
18printf "p->length=%d\n",$p->num_bits;
19printf "q->length=%d\n",$q->num_bits;
20$bits=$p->num_bits+$q->num_bits;
21$e=SSLeay::BN::hex2bn("10001");
22
23$t1=$p-1;
24$t2=$q-1;
25
26($t1->gcd($e) == 1) || die "p failed the gcd test\n";
27($t2->gcd($e) == 1) || die "q failed the gcd test\n";
28
29($q,$p)=($p,$q) if ($p < $q);
30$n=$p*$q;
31$t=($p-1)*($q-1);
32($t->gcd($e) == 1) || die "t failed the gcd test\n";
33
34$d=$e->mod_inverse($t);
35
36$dmp1=$d%($p-1);
37$dmq1=$d%($q-1);
38$iqmp=$q->mod_inverse($p);
39
40print "n =$n\n";
41print "e =$e\n";
42print "d =$d\n";
43print "dmp1=$dmp1\n";
44print "dmq1=$dmq1\n";
45print "iqmp=$iqmp\n";
46
47$a=SSLeay::BN::bin2bn("This is an RSA test");
48print "Test with\n'".$a->bn2bin."' or\n$a\n";
49
50print "<$a>\n";
51$t1=$a->mod_exp($e,$n);
52print ">$t1>\n";
53$t2=$t1->mod_exp($d,$n);
54print "<$t2>\n";
55
56
diff --git a/src/lib/libssl/src/perl/s.pl b/src/lib/libssl/src/perl/s.pl
new file mode 100644
index 0000000000..1d438a6765
--- /dev/null
+++ b/src/lib/libssl/src/perl/s.pl
@@ -0,0 +1,72 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$ssl_ctx=SSL::CTX->new("SSLv3_client");
8
9$ssl_ctx->set_options("-info_callback" =>
10 sub {
11 print STDERR $_[0]->state()."\n";
12 }
13 );
14
15$conn="localhost:4433";
16$conn=$ARGV[0] if $#ARGV >= 0;
17$cbio=BIO->new("connect");
18$cbio->hostname($conn) || die $ssl->error();
19
20$bbio=BIO->new("buffer");
21
22$sbio=BIO->new("ssl");
23$ssl=$ssl_ctx->new_ssl;
24$ssl->set_options(-connect_state);
25$sbio->set_ssl($ssl);
26
27$sbio->push($cbio);
28$bbio->push($sbio);
29$bio=$bbio;
30
31#$bio->set_callback(
32# sub {
33# my($bio,$state,$cmd,$buf,$lart,$ret)=@_;
34# print STDERR "$state:$cmd\n";
35# return($ret);
36# }
37# );
38
39$b=$bio;
40do {
41 print STDERR $b->type."\n";
42 } while ($b=$b->next_bio);
43
44(($ret=$bio->syswrite("GET / HTTP/1.0\r\n\r\n")) > 0) || die $bio->error();
45$bio->flush;
46
47$data="";
48while (1)
49 {
50 $ret=$bio->getline;
51 $ret =~ s/[\r\n]//g;
52 print STDERR "$ret\n";
53 last if $ret eq "";
54 $server=$1 if $ret=~ /^Server: (.*)/;
55 }
56
57
58print "server is $server\n";
59$x509=$ssl->get_peer_certificate();
60print "version :".$x509->get_version()."\n";
61print "serialNumber:".$x509->get_serialNumber()->bn2hex."\n";
62print "subject :".$x509->get_subject_name()."\n";
63print "issuer :". $x509->get_issuer_name()."\n";
64
65$c=$ssl->get_current_cipher;
66($i,$a)=$c->get_bits;
67$v=$c->get_version;
68$n=$c->get_name;
69
70print "protocol=".$ssl->get_version."\n";
71print "bits=$i($a) cipher type=$v cipher=$n\n";
72
diff --git a/src/lib/libssl/src/perl/s2.pl b/src/lib/libssl/src/perl/s2.pl
new file mode 100644
index 0000000000..d39b4b8e25
--- /dev/null
+++ b/src/lib/libssl/src/perl/s2.pl
@@ -0,0 +1,49 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$ssl_ctx=SSL::CTX->new("SSLv3");
8
9$ssl_ctx->set_options("-info_callback" =>
10 sub {
11 print STDERR $_[0]->state()."\n";
12 }
13 );
14
15$conn="localhost:4433";
16$conn=$ARGV[0] if $#ARGV >= 0;
17$cbio=BIO->new("connect");
18$cbio->hostname($conn) || die $ssl->error();
19
20$ssl=$ssl_ctx->new_ssl;
21$sbio=BIO->new("ssl");
22$sbio->set_ssl($ssl);
23$ssl->set_options("-connect_state");
24
25$bio=BIO->new("buffer");
26
27$sbio->push($cbio);
28$bio->push($sbio);
29
30($bio->do_handshake() > 0) || die $bio->error();
31
32(($ret=$bio->syswrite("GET / HTTP/1.0\r\n\r\n")) > 0) || die $ssl->error();
33$bio->flush() || die $bio->error();
34
35$data="";
36while ($_=$bio->getline())
37 {
38 if (/^Server:/)
39 {
40 print;
41 last;
42 }
43 }
44
45if ($bio->peek_error())
46 {
47 print "There was an error:".$ssl->error();
48 }
49print "exit\n";
diff --git a/src/lib/libssl/src/perl/server.pem b/src/lib/libssl/src/perl/server.pem
new file mode 100644
index 0000000000..eabb927036
--- /dev/null
+++ b/src/lib/libssl/src/perl/server.pem
@@ -0,0 +1,369 @@
1issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
2subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Server test cert (512 bit)
3-----BEGIN CERTIFICATE-----
4MIIB6TCCAVICAQAwDQYJKoZIhvcNAQEEBQAwWzELMAkGA1UEBhMCQVUxEzARBgNV
5BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYD
6VQQDExJUZXN0IENBICgxMDI0IGJpdCkwHhcNOTcwNjA5MTM1NzQ2WhcNOTgwNjA5
7MTM1NzQ2WjBjMQswCQYDVQQGEwJBVTETMBEGA1UECBMKUXVlZW5zbGFuZDEaMBgG
8A1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxIzAhBgNVBAMTGlNlcnZlciB0ZXN0IGNl
9cnQgKDUxMiBiaXQpMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJ+zw4Qnlf8SMVIP
10Fe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVDTGiXav6ooKXfX3j/7tdkuD8Ey2//
11Kv7+ue0CAwEAATANBgkqhkiG9w0BAQQFAAOBgQB4TMR2CvacKE9wAsu9jyCX8YiW
12mgCM+YoP6kt4Zkj2z5IRfm7WrycKsnpnOR+tGeqAjkCeZ6/36o9l91RvPnN1VJ/i
13xQv2df0KFeMr00IkDdTNAdIWqFkSsZTAY2QAdgenb7MB1joejquYzO2DQIO7+wpH
14irObpESxAZLySCmPPg==
15-----END CERTIFICATE-----
16-----BEGIN RSA PRIVATE KEY-----
17MIIBPAIBAAJBAJ+zw4Qnlf8SMVIPFe9GEcStgOY2Ww/dgNdhjeD8ckUJNP5VZkVD
18TGiXav6ooKXfX3j/7tdkuD8Ey2//Kv7+ue0CAwEAAQJAN6W31vDEP2DjdqhzCDDu
19OA4NACqoiFqyblo7yc2tM4h4xMbC3Yx5UKMN9ZkCtX0gzrz6DyF47bdKcWBzNWCj
20gQIhANEoojVt7hq+SQ6MCN6FTAysGgQf56Q3TYoJMoWvdiXVAiEAw3e3rc+VJpOz
21rHuDo6bgpjUAAXM+v3fcpsfZSNO6V7kCIQCtbVjanpUwvZkMI9by02oUk9taki3b
22PzPfAfNPYAbCJQIhAJXNQDWyqwn/lGmR11cqY2y9nZ1+5w3yHGatLrcDnQHxAiEA
23vnlEGo8K85u+KwIOimM48ZG8oTk7iFdkqLJR1utT3aU=
24-----END RSA PRIVATE KEY-----
25subject=/C=US/O=AT&T Bell Laboratories/OU=Prototype Research CA
26issuer= /C=US/O=AT&T Bell Laboratories/OU=Prototype Research CA
27notBefore=950413210656Z
28notAfter =970412210656Z
29-----BEGIN X509 CERTIFICATE-----
30
31MIICCDCCAXECAQAwDQYJKoZIhvcNAQEEBQAwTjELMAkGA1UEBhMCVVMxHzAdBgNV
32BAoUFkFUJlQgQmVsbCBMYWJvcmF0b3JpZXMxHjAcBgNVBAsUFVByb3RvdHlwZSBS
33ZXNlYXJjaCBDQTAeFw05NTA0MTMyMTA2NTZaFw05NzA0MTIyMTA2NTZaME4xCzAJ
34BgNVBAYTAlVTMR8wHQYDVQQKFBZBVCZUIEJlbGwgTGFib3JhdG9yaWVzMR4wHAYD
35VQQLFBVQcm90b3R5cGUgUmVzZWFyY2ggQ0EwgZwwDQYJKoZIhvcNAQEBBQADgYoA
36MIGGAoGAebOmgtSCl+wCYZc86UGYeTLY8cjmW2P0FN8ToT/u2pECCoFdrlycX0OR
373wt0ZhpFXLVNeDnHwEE9veNUih7pCL2ZBFqoIoQkB1lZmXRiVtjGonz8BLm/qrFM
38YHb0lme/Ol+s118mwKVxnn6bSAeI/OXKhLaVdYZWk+aEaxEDkVkCAQ8wDQYJKoZI
39hvcNAQEEBQADgYEAAZMG14lZmZ8bahkaHaTV9dQf4p2FZiQTFwHP9ZyGsXPC+LT5
40dG5iTaRmyjNIJdPWohZDl97kAci79aBndvuEvRKOjLHs3WRGBIwERnAcnY9Mz8u/
41zIHK23PjYVxGGaZd669OJwD0CYyqH22HH9nFUGaoJdsv39ChW0NRdLE9+y8=
42-----END X509 CERTIFICATE-----
43issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit)
44subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
45-----BEGIN CERTIFICATE-----
46MIICJjCCAY8CAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV
47BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD
48VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTc0M1oXDTAxMDYw
49OTEzNTc0M1owWzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxGjAY
50BgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYDVQQDExJUZXN0IENBICgxMDI0
51IGJpdCkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKO7o8t116VP6cgybTsZ
52DCZhr95nYlZuya3aCi1IKoztqwWnjbmDFIriOqGFPrZQ+moMETC9D59iRW/dFXSv
531F65ka/XY2hLh9exCCo7XuUcDs53Qp3bI3AmMqHjgzE8oO3ajyJAzJkTTOUecQU2
54mw/gI4tMM0LqWMQS7luTy4+xAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAM7achv3v
55hLQJcv/65eGEpBXM40ZDVoFQFFJWaY5p883HTqLB1x4FdzsXHH0QKBTcKpWwqyu4
56YDm3fb8oDugw72bCzfyZK/zVZPR/hVlqI/fvU109Qoc+7oPvIXWky71HfcK6ZBCA
57q30KIqGM/uoM60INq97qjDmCJapagcNBGQs=
58-----END CERTIFICATE-----
59-----BEGIN RSA PRIVATE KEY-----
60MIICXQIBAAKBgQCju6PLddelT+nIMm07GQwmYa/eZ2JWbsmt2gotSCqM7asFp425
61gxSK4jqhhT62UPpqDBEwvQ+fYkVv3RV0r9ReuZGv12NoS4fXsQgqO17lHA7Od0Kd
622yNwJjKh44MxPKDt2o8iQMyZE0zlHnEFNpsP4COLTDNC6ljEEu5bk8uPsQIDAQAB
63AoGAVZmpFZsDZfr0l2S9tLLwpjRWNOlKATQkno6q2WesT0eGLQufTciY+c8ypfU6
64hyio8r5iUl/VhhdjhAtKx1mRpiotftHo/eYf8rtsrnprOnWG0bWjLjtIoMbcxGn2
65J3bN6LJmbJMjDs0eJ3KnTu646F3nDUw2oGAwmpzKXA1KAP0CQQDRvQhxk2D3Pehs
66HvG665u2pB5ipYQngEFlZO7RHJZzJOZEWSLuuMqaF/7pTfA5jiBvWqCgJeCRRInL
6721ru4dlPAkEAx9jj7BgKn5TYnMoBSSe0afjsV9oApVpN1Nacb1YDtCwy+scp3++s
68nFxlv98wxIlSdpwMUn+AUWfjiWR7Tu/G/wJBAJ/KjwZIrFVxewP0x2ILYsTRYLzz
69MS4PDsO7FB+I0i7DbBOifXS2oNSpd3I0CNMwrxFnUHzynpbOStVfN3ZL5w0CQQCa
70pwFahxBRhkJKsxhjoFJBX9yl75JoY4Wvm5Tbo9ih6UJaRx3kqfkN14L2BKYcsZgb
71KY9vmDOYy6iNfjDeWTfJAkBkfPUb8oTJ/nSP5zN6sqGxSY4krc4xLxpRmxoJ8HL2
72XfhqXkTzbU13RX9JJ/NZ8vQN9Vm2NhxRGJocQkmcdVtJ
73-----END RSA PRIVATE KEY-----
74-----BEGIN X509 CERTIFICATE-----
75MIICYDCCAiACAgEoMAkGBSsOAwINBQAwfDELMAkGA1UEBhMCVVMxNjA0BgNVBAoT
76LU5hdGlvbmFsIEFlcm9uYXV0aWNzIGFuZCBTcGFjZSBBZG1pbmlzdHJhdGlvbjEZ
77MBcGA1UECxMQVGVzdCBFbnZpcm9ubWVudDEaMBgGA1UECxMRRFNTLU5BU0EtUGls
78b3QtQ0EwHhcNOTYwMjI2MTYzMjQ1WhcNOTcwMjI1MTYzMjQ1WjB8MQswCQYDVQQG
79EwJVUzE2MDQGA1UEChMtTmF0aW9uYWwgQWVyb25hdXRpY3MgYW5kIFNwYWNlIEFk
80bWluaXN0cmF0aW9uMRkwFwYDVQQLExBUZXN0IEVudmlyb25tZW50MRowGAYDVQQL
81ExFEU1MtTkFTQS1QaWxvdC1DQTCB8jAJBgUrDgMCDAUAA4HkADCB4AJBAMA/ssKb
82hPNUG7ZlASfVwEJU21O5OyF/iyBzgHI1O8eOhJGUYO8cc8wDMjR508Mr9cp6Uhl/
83ZB7FV5GkLNEnRHYCQQDUEaSg45P2qrDwixTRhFhmWz5Nvc4lRFQ/42XPcchiJBLb
84bn3QK74T2IxY1yY+kCNq8XrIqf5fJJzIH0J/xUP3AhUAsg2wsQHfDGYk/BOSulX3
85fVd0geUCQQCzCFUQAh+ZkEmp5804cs6ZWBhrUAfnra8lJItYo9xPcXgdIfLfibcX
86R71UsyO77MRD7B0+Ag2tq794IleCVcEEMAkGBSsOAwINBQADLwAwLAIUUayDfreR
87Yh2WeU86/pHNdkUC1IgCFEfxe1f0oMpxJyrJ5XIxTi7vGdoK
88-----END X509 CERTIFICATE-----
89-----BEGIN X509 CERTIFICATE-----
90
91MIICGTCCAdgCAwCqTDAJBgUrDgMCDQUAMHwxCzAJBgNVBAYTAlVTMTYwNAYDVQQK
92Ey1OYXRpb25hbCBBZXJvbmF1dGljcyBhbmQgU3BhY2UgQWRtaW5pc3RyYXRpb24x
93GTAXBgNVBAsTEFRlc3QgRW52aXJvbm1lbnQxGjAYBgNVBAsTEURTUy1OQVNBLVBp
94bG90LUNBMB4XDTk2MDUxNDE3MDE0MVoXDTk3MDUxNDE3MDE0MVowMzELMAkGA1UE
95BhMCQVUxDzANBgNVBAoTBk1pbmNvbTETMBEGA1UEAxMKRXJpYyBZb3VuZzCB8jAJ
96BgUrDgMCDAUAA4HkADCB4AJBAKbfHz6vE6pXXMTpswtGUec2tvnfLJUsoxE9qs4+
97ObZX7LmLvragNPUeiTJx7UOWZ5DfBj6bXLc8eYne0lP1g3ACQQDUEaSg45P2qrDw
98ixTRhFhmWz5Nvc4lRFQ/42XPcchiJBLbbn3QK74T2IxY1yY+kCNq8XrIqf5fJJzI
99H0J/xUP3AhUAsg2wsQHfDGYk/BOSulX3fVd0geUCQQCzCFUQAh+ZkEmp5804cs6Z
100WBhrUAfnra8lJItYo9xPcXgdIfLfibcXR71UsyO77MRD7B0+Ag2tq794IleCVcEE
101MAkGBSsOAwINBQADMAAwLQIUWsuuJRE3VT4ueWkWMAJMJaZjj1ECFQCYY0zX4bzM
102LC7obsrHD8XAHG+ZRG==
103-----END X509 CERTIFICATE-----
104-----BEGIN CERTIFICATE-----
105MIICTTCCAbagAwIBAgIBADANBgkqhkiG9w0BAQQFADBMMQswCQYDVQQGEwJHQjEM
106MAoGA1UEChMDVUNMMRgwFgYDVQQLEw9JQ0UtVEVMIFByb2plY3QxFTATBgNVBAMT
107DFRydXN0RmFjdG9yeTAeFw05NzA0MjIxNDM5MTRaFw05ODA0MjIxNDM5MTRaMEwx
108CzAJBgNVBAYTAkdCMQwwCgYDVQQKEwNVQ0wxGDAWBgNVBAsTD0lDRS1URUwgUHJv
109amVjdDEVMBMGA1UEAxMMVHJ1c3RGYWN0b3J5MIGcMAoGBFUIAQECAgQAA4GNADCB
110iQKBgQCEieR8NcXkUW1f0G6aC6u0i8q/98JqS6RxK5YmHIGKCkuTWAUjzLfUa4dt
111U9igGCjTuxaDqlzEim+t/02pmiBZT9HaX++35MjQPUWmsChcYU5WyzGErXi+rQaw
112zlwS73zM8qiPj/97lXYycWhgL0VaiDSPxRXEUdWoaGruom4mNQIDAQABo0IwQDAd
113BgNVHQ4EFgQUHal1LZr7oVg5z6lYzrhTgZRCmcUwDgYDVR0PAQH/BAQDAgH2MA8G
114A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEEBQADgYEAfaggfl6FZoioecjv0dq8
115/DXo/u11iMZvXn08gjX/zl2b4wtPbShOSY5FhkSm8GeySasz+/Nwb/uzfnIhokWi
116lfPZHtlCWtXbIy/TN51eJyq04ceDCQDWvLC2enVg9KB+GJ34b5c5VaPRzq8MBxsA
117S7ELuYGtmYgYm9NZOIr7yU0=
118-----END CERTIFICATE-----
119-----BEGIN CERTIFICATE-----
120MIIB6jCCAZQCAgEtMA0GCSqGSIb3DQEBBAUAMIGAMQswCQYDVQQGEwJVUzE2MDQG
121A1UEChMtTmF0aW9uYWwgQWVyb25hdXRpY3MgYW5kIFNwYWNlIEFkbWluaXN0cmF0
122aW9uMRkwFwYDVQQLExBUZXN0IEVudmlyb25tZW50MR4wHAYDVQQLExVNRDUtUlNB
123LU5BU0EtUGlsb3QtQ0EwHhcNOTYwNDMwMjIwNTAwWhcNOTcwNDMwMjIwNTAwWjCB
124gDELMAkGA1UEBhMCVVMxNjA0BgNVBAoTLU5hdGlvbmFsIEFlcm9uYXV0aWNzIGFu
125ZCBTcGFjZSBBZG1pbmlzdHJhdGlvbjEZMBcGA1UECxMQVGVzdCBFbnZpcm9ubWVu
126dDEeMBwGA1UECxMVTUQ1LVJTQS1OQVNBLVBpbG90LUNBMFkwCgYEVQgBAQICAgAD
127SwAwSAJBALmmX5+GqAvcrWK13rfDrNX9UfeA7f+ijyBgeFQjYUoDpFqapw4nzQBL
128bAXug8pKkRwa2Zh8YODhXsRWu2F/UckCAwEAATANBgkqhkiG9w0BAQQFAANBAH9a
129OBA+QCsjxXgnSqHx04gcU8S49DVUb1f2XVoLnHlIb8RnX0k5O6mpHT5eti9bLkiW
130GJNMJ4L0AJ/ac+SmHZc=
131-----END CERTIFICATE-----
132-----BEGIN CERTIFICATE-----
133MIICajCCAdMCBDGA0QUwDQYJKoZIhvcNAQEEBQAwfTELMAkGA1UEBhMCQ2ExDzAN
134BgNVBAcTBk5lcGVhbjEeMBwGA1UECxMVTm8gTGlhYmlsaXR5IEFjY2VwdGVkMR8w
135HQYDVQQKExZGb3IgRGVtbyBQdXJwb3NlcyBPbmx5MRwwGgYDVQQDExNFbnRydXN0
136IERlbW8gV2ViIENBMB4XDTk2MDQyNjEzMzUwMVoXDTA2MDQyNjEzMzUwMVowfTEL
137MAkGA1UEBhMCQ2ExDzANBgNVBAcTBk5lcGVhbjEeMBwGA1UECxMVTm8gTGlhYmls
138aXR5IEFjY2VwdGVkMR8wHQYDVQQKExZGb3IgRGVtbyBQdXJwb3NlcyBPbmx5MRww
139GgYDVQQDExNFbnRydXN0IERlbW8gV2ViIENBMIGdMA0GCSqGSIb3DQEBAQUAA4GL
140ADCBhwKBgQCaroS7O1DA0hm4IefNYU1cx/nqOmzEnk291d1XqznDeF4wEgakbkCc
141zTKxK791yNpXG5RmngqH7cygDRTHZJ6mfCRn0wGC+AI00F2vYTGqPGRQL1N3lZT0
142YDKFC0SQeMMjFIZ1aeQigroFQnHo0VB3zWIMpNkka8PY9lxHZAmWwQIBAzANBgkq
143hkiG9w0BAQQFAAOBgQBAx0UMVA1s54lMQyXjMX5kj99FJN5itb8bK1Rk+cegPQPF
144cWO9SEWyEjjBjIkjjzAwBkaEszFsNGxemxtXvwjIm1xEUMTVlPEWTs2qnDvAUA9W
145YqhWbhH0toGT36236QAsqCZ76rbTRVSSX2BHyJwJMG2tCRv7kRJ//NIgxj3H4w==
146-----END CERTIFICATE-----
147
148issuer= /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit)
149subject=/C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test PCA (1024 bit)
150-----BEGIN CERTIFICATE-----
151MIICJzCCAZACAQAwDQYJKoZIhvcNAQEEBQAwXDELMAkGA1UEBhMCQVUxEzARBgNV
152BAgTClF1ZWVuc2xhbmQxGjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYD
153VQQDExNUZXN0IFBDQSAoMTAyNCBiaXQpMB4XDTk3MDYwOTEzNTczN1oXDTAxMDYw
154OTEzNTczN1owXDELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQxGjAY
155BgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRwwGgYDVQQDExNUZXN0IFBDQSAoMTAy
156NCBiaXQpMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCdoWk/3+WcMlfjIrkg
15740ketmnQaEogQe1LLcuOJV6rKfUSAsPgwgsabJ/wn8TxA1yy3eKJbFl3OiUXMRsp
15822Jp85PmemiDzyUIStwk72qhp1imbANZvlmlCFKiQrjUyuDfu4TABmn+kkt3vR1Y
159BEOGt+IFye1UBVSATVdRJ2UVhwIDAQABMA0GCSqGSIb3DQEBBAUAA4GBABNA1u/S
160Cg/LJZWb7GliiKJsvuhxlE4E5JxQF2zMub/CSNbF97//tYSyj96sxeFQxZXbcjm9
161xt6mr/xNLA4szNQMJ4P+L7b5e/jC5DSqlwS+CUYJgaFs/SP+qJoCSu1bR3IM9XWO
162cRBpDmcBbYLkSyB92WURvsZ1LtjEcn+cdQVI
163-----END CERTIFICATE-----
164-----BEGIN RSA PRIVATE KEY-----
165MIICXAIBAAKBgQCdoWk/3+WcMlfjIrkg40ketmnQaEogQe1LLcuOJV6rKfUSAsPg
166wgsabJ/wn8TxA1yy3eKJbFl3OiUXMRsp22Jp85PmemiDzyUIStwk72qhp1imbANZ
167vlmlCFKiQrjUyuDfu4TABmn+kkt3vR1YBEOGt+IFye1UBVSATVdRJ2UVhwIDAQAB
168AoGAba4fTtuap5l7/8ZsbE7Z1O32KJY4ZcOZukLOLUUhXxXduT+FTgGWujc0/rgc
169z9qYCLlNZHOouMYTgtSfYvuMuLZ11VIt0GYH+nRioLShE59Yy+zCRyC+gPigS1kz
170xvo14AsOIPYV14Tk/SsHyq6E0eTk7VzaIE197giiINUERPECQQDSKmtPTh/lRKw7
171HSZSM0I1mFWn/1zqrAbontRQY5w98QWIOe5qmzYyFbPXYT3d9BzlsMyhgiRNoBbD
172yvohSHXJAkEAwAHx6ezAZeWWzD5yXD36nyjpkVCw7Tk7TSmOceLJMWt1QcrCfqlS
173xA5jjpQ6Z8suU5DdtWAryM2sAir1WisYzwJAd6Zcx56jvAQ3xcPXsE6scBTVFzrj
1747FqZ6E+cclPzfLQ+QQsyOBE7bpI6e/FJppY26XGZXo3YGzV8IGXrt40oOQJALETG
175h86EFXo3qGOFbmsDy4pdP5nBERCu8X1xUCSfintiD4c2DInxgS5oGclnJeMcjTvL
176QjQoJCX3UJCi/OUO1QJBAKgcDHWjMvt+l1pjJBsSEZ0HX9AAIIVx0RQmbFGS+F2Q
177hhu5l77WnnZOQ9vvhV5u7NPCUF9nhU3jh60qWWO8mkc=
178-----END RSA PRIVATE KEY-----
179subject=/C=US/O=RSA Data Security, Inc./OU=Commercial Certification Authority
180issuer= /C=US/O=RSA Data Security, Inc./OU=Commercial Certification Authority
181notBefore=941104185834Z
182notAfter =991103185834Z
183-----BEGIN X509 CERTIFICATE-----
184
185MIICIzCCAZACBQJBAAAWMA0GCSqGSIb3DQEBAgUAMFwxCzAJBgNVBAYTAlVTMSAw
186HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjErMCkGA1UECxMiQ29tbWVy
187Y2lhbCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NDExMDQxODU4MzRaFw05
188OTExMDMxODU4MzRaMFwxCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0YSBT
189ZWN1cml0eSwgSW5jLjErMCkGA1UECxMiQ29tbWVyY2lhbCBDZXJ0aWZpY2F0aW9u
190IEF1dGhvcml0eTCBmzANBgkqhkiG9w0BAQEFAAOBiQAwgYUCfgCk+4Fie84QJ93o
191975sbsZwmdu41QUDaSiCnHJ/lj+O7Kwpkj+KFPhCdr69XQO5kNTQvAayUTNfxMK/
192touPmbZiImDd298ggrTKoi8tUO2UMt7gVY3UaOLgTNLNBRYulWZcYVI4HlGogqHE
1937yXpCuaLK44xZtn42f29O2nZ6wIDAQABMA0GCSqGSIb3DQEBAgUAA34AdrW2EP4j
1949/dZYkuwX5zBaLxJu7NJbyFHXSudVMQAKD+YufKKg5tgf+tQx6sFEC097TgCwaVI
1950v5loMC86qYjFmZsGySp8+x5NRhPJsjjr1BKx6cxa9B8GJ1Qv6km+iYrRpwUqbtb
196MJhCKLVLU7tDCZJAuqiqWqTGtotXTcU=
197-----END X509 CERTIFICATE-----
198subject=/C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority
199issuer= /C=US/O=RSA Data Security, Inc./OU=Secure Server Certification Authority
200notBefore=941109235417Z
201notAfter =991231235417Z
202-----BEGIN X509 CERTIFICATE-----
203
204MIICKTCCAZYCBQJBAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMSAw
205HgYDVQQKExdSU0EgRGF0YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJl
206IFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NDExMDkyMzU0MTda
207Fw05OTEyMzEyMzU0MTdaMF8xCzAJBgNVBAYTAlVTMSAwHgYDVQQKExdSU0EgRGF0
208YSBTZWN1cml0eSwgSW5jLjEuMCwGA1UECxMlU2VjdXJlIFNlcnZlciBDZXJ0aWZp
209Y2F0aW9uIEF1dGhvcml0eTCBmzANBgkqhkiG9w0BAQEFAAOBiQAwgYUCfgCSznrB
210roM+WqqJg1esJQF2DK2ujiw3zus1eGRUA+WEQFHJv48I4oqCCNIWhjdV6bEhAq12
211aIGaBaJLyUslZiJWbIgHj/eBWW2EB2VwE3F2Ppt3TONQiVaYSLkdpykaEy5KEVmc
212HhXVSVQsczppgrGXOZxtcGdI5d0t1sgeewIDAQABMA0GCSqGSIb3DQEBAgUAA34A
213iNHReSHO4ovo+MF9NFM/YYPZtgs4F7boviGNjwC4i1N+RGceIr2XJ+CchcxK9oU7
214suK+ktPlDemvXA4MRpX/oRxePug2WHpzpgr4IhFrwwk4fia7c+8AvQKk8xQNMD9h
215cHsg/jKjn7P0Z1LctO6EjJY2IN6BCINxIYoPnqk=
216-----END X509 CERTIFICATE-----
217subject=/C=ZA/SP=Western Cape/L=Cape Town/O=Thawte Consulting cc
218 /OU=Certification Services Division/CN=Thawte Server CA
219 /Email=server-certs@thawte.com
220issuer= /C=ZA/SP=Western Cape/L=Cape Town/O=Thawte Consulting cc
221 /OU=Certification Services Division/CN=Thawte Server CA
222 /Email=server-certs@thawte.com
223-----BEGIN CERTIFICATE-----
224MIIC+TCCAmICAQAwDQYJKoZIhvcNAQEEBQAwgcQxCzAJBgNVBAYTAlpBMRUwEwYD
225VQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsGA1UEChMU
226VGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2Vy
227dmljZXMgRGl2aXNpb24xGTAXBgNVBAMTEFRoYXd0ZSBTZXJ2ZXIgQ0ExJjAkBgkq
228hkiG9w0BCQEWF3NlcnZlci1jZXJ0c0B0aGF3dGUuY29tMB4XDTk2MDcyNzE4MDc1
229N1oXDTk4MDcyNzE4MDc1N1owgcQxCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0
230ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsGA1UEChMUVGhhd3RlIENv
231bnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2
232aXNpb24xGTAXBgNVBAMTEFRoYXd0ZSBTZXJ2ZXIgQ0ExJjAkBgkqhkiG9w0BCQEW
233F3NlcnZlci1jZXJ0c0B0aGF3dGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB
234iQKBgQDTpFBuyP9Wa+bPXbbqDGh1R6KqwtqEJfyo9EdR2oW1IHSUhh4PdcnpCGH1
235Bm0wbhUZAulSwGLbTZme4moMRDjN/r7jZAlwxf6xaym2L0nIO9QnBCUQly/nkG3A
236KEKZ10xD3sP1IW1Un13DWOHA5NlbsLjctHvfNjrCtWYiEtaHDQIDAQABMA0GCSqG
237SIb3DQEBBAUAA4GBAIsvn7ifX3RUIrvYXtpI4DOfARkTogwm6o7OwVdl93yFhDcX
2387h5t0XZ11MUAMziKdde3rmTvzUYIUCYoY5b032IwGMTvdiclK+STN6NP2m5nvFAM
239qJT5gC5O+j/jBuZRQ4i0AMYQr5F4lT8oBJnhgafw6PL8aDY2vMHGSPl9+7uf
240-----END CERTIFICATE-----
241
242-----BEGIN CERTIFICATE-----
243MIIDDTCCAnYCAQAwDQYJKoZIhvcNAQEEBQAwgc4xCzAJBgNVBAYTAlpBMRUwEwYD
244VQQIEwxXZXN0ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEdMBsGA1UEChMU
245VGhhd3RlIENvbnN1bHRpbmcgY2MxKDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2Vy
246dmljZXMgRGl2aXNpb24xITAfBgNVBAMTGFRoYXd0ZSBQcmVtaXVtIFNlcnZlciBD
247QTEoMCYGCSqGSIb3DQEJARYZcHJlbWl1bS1zZXJ2ZXJAdGhhd3RlLmNvbTAeFw05
248NjA3MjcxODA3MTRaFw05ODA3MjcxODA3MTRaMIHOMQswCQYDVQQGEwJaQTEVMBMG
249A1UECBMMV2VzdGVybiBDYXBlMRIwEAYDVQQHEwlDYXBlIFRvd24xHTAbBgNVBAoT
250FFRoYXd0ZSBDb25zdWx0aW5nIGNjMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNl
251cnZpY2VzIERpdmlzaW9uMSEwHwYDVQQDExhUaGF3dGUgUHJlbWl1bSBTZXJ2ZXIg
252Q0ExKDAmBgkqhkiG9w0BCQEWGXByZW1pdW0tc2VydmVyQHRoYXd0ZS5jb20wgZ8w
253DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANI2NmqL18JbntqBQWKPOO5JBFXW0O8c
254G5UWR+8YSDU6UvQragaPOy/qVuOvho2eF/eetGV1Ak3vywmiIVHYm9Bn0LoNkgYU
255c9STy5cqAJxcTgy8+hVS/PJEbtoRSm4Iny8t4/mqOoZztkZTWMiJBb2DEbhzP6oH
256jfRCTedAnRw3AgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAutFIgTRZVYerIZfL9lvR
257w9Eifvvo5KTZ3h+Bj+VzNnyw4Qc/IyXkPOu6SIiH9LQ3sCmWBdxpe+qr4l77rLj2
258GYuMtESFfn1XVALzkYgC7JcPuTOjMfIiMByt+uFf8AV8x0IW/Qkuv+hEQcyM9vxK
2593VZdLbCVIhNoEsysrxCpxcI=
260-----END CERTIFICATE-----
261Tims test GCI CA
262
263-----BEGIN CERTIFICATE-----
264MIIB8DCCAZoCAQAwDQYJKoZIhvcNAQEEBQAwgYIxCzAJBgNVBAYTAkFVMRMwEQYD
265VQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5
266cHRTb2Z0IFB0eSBMdGQxFDASBgNVBAsTC2RldmVsb3BtZW50MRkwFwYDVQQDExBD
267cnlwdFNvZnQgRGV2IENBMB4XDTk3MDMyMjEzMzQwNFoXDTk4MDMyMjEzMzQwNFow
268gYIxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhC
269cmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxFDASBgNVBAsTC2Rl
270dmVsb3BtZW50MRkwFwYDVQQDExBDcnlwdFNvZnQgRGV2IENBMFwwDQYJKoZIhvcN
271AQEBBQADSwAwSAJBAOAOAqogG5QwAmLhzyO4CoRnx/wVy4NZP4dxJy83O1EnL0rw
272OdsamJKvPOLHgSXo3gDu9uVyvCf/QJmZAmC5ml8CAwEAATANBgkqhkiG9w0BAQQF
273AANBADRRS/GVdd7rAqRW6SdmgLJduOU2yq3avBu99kRqbp9A/dLu6r6jU+eP4oOA
274TfdbFZtAAD2Hx9jUtY3tfdrJOb8=
275-----END CERTIFICATE-----
276
277-----BEGIN CERTIFICATE-----
278MIICVjCCAgACAQAwDQYJKoZIhvcNAQEEBQAwgbUxCzAJBgNVBAYTAkFVMRMwEQYD
279VQQIEwpRdWVlbnNsYW5kMREwDwYDVQQHEwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5
280cHRTb2Z0IFB0eSBMdGQxLDAqBgNVBAsTI1dPUlRITEVTUyBDRVJUSUZJQ0FUSU9O
281IEFVVEhPUklUSUVTMTQwMgYDVQQDEytaRVJPIFZBTFVFIENBIC0gREVNT05TVFJB
282VElPTiBQVVJQT1NFUyBPTkxZMB4XDTk3MDQwMzEzMjI1NFoXDTk4MDQwMzEzMjI1
283NFowgbUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpRdWVlbnNsYW5kMREwDwYDVQQH
284EwhCcmlzYmFuZTEaMBgGA1UEChMRQ3J5cHRTb2Z0IFB0eSBMdGQxLDAqBgNVBAsT
285I1dPUlRITEVTUyBDRVJUSUZJQ0FUSU9OIEFVVEhPUklUSUVTMTQwMgYDVQQDEyta
286RVJPIFZBTFVFIENBIC0gREVNT05TVFJBVElPTiBQVVJQT1NFUyBPTkxZMFwwDQYJ
287KoZIhvcNAQEBBQADSwAwSAJBAOZ7T7yqP/tyspcko3yPY1y0Cm2EmwNvzW4QgVXR
288Fjs3HmJ4xtSpXdo6mwcGezL3Abt/aQXaxv9PU8xt+Jr0OFUCAwEAATANBgkqhkiG
2899w0BAQQFAANBAOQpYmGgyCqCy1OljgJhCqQOu627oVlHzK1L+t9vBaMfn40AVUR4
290WzQVWO31KTgi5vTK1U+3h46fgUWqQ0h+6rU=
291-----END CERTIFICATE-----
292-----BEGIN CERTIFICATE-----
293MIAwgKADAgECAgEAMA0GCSqGSIb3DQEBBAUAMGIxETAPBgNVBAcTCEludGVybmV0
294MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE0MDIGA1UECxMrVmVyaVNpZ24gQ2xh
295c3MgMSBDQSAtIEluZGl2aWR1YWwgU3Vic2NyaWJlcjAeFw05NjA0MDgxMDIwMjda
296Fw05NzA0MDgxMDIwMjdaMGIxETAPBgNVBAcTCEludGVybmV0MRcwFQYDVQQKEw5W
297ZXJpU2lnbiwgSW5jLjE0MDIGA1UECxMrVmVyaVNpZ24gQ2xhc3MgMSBDQSAtIElu
298ZGl2aWR1YWwgU3Vic2NyaWJlcjCAMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2
299FKbPTdAFDdjKI9BvqrQpkmOOLPhvltcunXZLEbE2jVfJw/0cxrr+Hgi6M8qV6r7j
300W80GqLd5HUQq7XPysVKDaBBwZJHXPmv5912dFEObbpdFmIFH0S3L3bty10w/cari
301QPJUObwW7s987LrbP2wqsxaxhhKdrpM01bjV0Pc+qQIDAQABAAAAADANBgkqhkiG
3029w0BAQQFAAOBgQA+1nJryNt8VBRjRr07ArDAV/3jAH7GjDc9jsrxZS68ost9v06C
303TvTNKGL+LISNmFLXl+JXhgGB0JZ9fvyYzNgHQ46HBUng1H6voalfJgS2KdEo50wW
3048EFZYMDkT1k4uynwJqkVN2QJK/2q4/A/VCov5h6SlM8Affg2W+1TLqvqkwAA
305-----END CERTIFICATE-----
306
307 subject=/L=Internet/O=VeriSign, Inc./OU=VeriSign Class 2 CA - Individual Subscriber
308 issuer= /L=Internet/O=VeriSign, Inc./OU=VeriSign Class 2 CA - Individual Subscriber
309
310-----BEGIN CERTIFICATE-----
311MIIEkzCCA/ygAwIBAgIRANDTUpSRL3nTFeMrMayFSPAwDQYJKoZIhvcNAQECBQAw
312YjERMA8GA1UEBxMISW50ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQw
313MgYDVQQLEytWZXJpU2lnbiBDbGFzcyAyIENBIC0gSW5kaXZpZHVhbCBTdWJzY3Jp
314YmVyMB4XDTk2MDYwNDAwMDAwMFoXDTk4MDYwNDIzNTk1OVowYjERMA8GA1UEBxMI
315SW50ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQLEytWZXJp
316U2lnbiBDbGFzcyAyIENBIC0gSW5kaXZpZHVhbCBTdWJzY3JpYmVyMIGfMA0GCSqG
317SIb3DQEBAQUAA4GNADCBiQKBgQC6A+2czKGRcYMfm8gdnk+0de99TDDzsqo0v5nb
318RsbUmMcdRQ7nsMbRWe0SAb/9QoLTZ/cJ0iOBqdrkz7UpqqKarVoTSdlSMVM92tWp
3193bJncZHQD1t4xd6lQVdI1/T6R+5J0T1ukOdsI9Jmf+F28S6g3R3L1SFwiHKeZKZv
320z+793wIDAQABo4ICRzCCAkMwggIpBgNVHQMBAf8EggIdMIICGTCCAhUwggIRBgtg
321hkgBhvhFAQcBATCCAgAWggGrVGhpcyBjZXJ0aWZpY2F0ZSBpbmNvcnBvcmF0ZXMg
322YnkgcmVmZXJlbmNlLCBhbmQgaXRzIHVzZSBpcyBzdHJpY3RseSBzdWJqZWN0IHRv
323LCB0aGUgVmVyaVNpZ24gQ2VydGlmaWNhdGlvbiBQcmFjdGljZSBTdGF0ZW1lbnQg
324KENQUyksIGF2YWlsYWJsZSBhdDogaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL0NQ
325Uy0xLjA7IGJ5IEUtbWFpbCBhdCBDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29tOyBv
326ciBieSBtYWlsIGF0IFZlcmlTaWduLCBJbmMuLCAyNTkzIENvYXN0IEF2ZS4sIE1v
327dW50YWluIFZpZXcsIENBIDk0MDQzIFVTQSBUZWwuICsxICg0MTUpIDk2MS04ODMw
328IENvcHlyaWdodCAoYykgMTk5NiBWZXJpU2lnbiwgSW5jLiAgQWxsIFJpZ2h0cyBS
329ZXNlcnZlZC4gQ0VSVEFJTiBXQVJSQU5USUVTIERJU0NMQUlNRUQgYW5kIExJQUJJ
330TElUWSBMSU1JVEVELqAOBgxghkgBhvhFAQcBAQGhDgYMYIZIAYb4RQEHAQECMC8w
331LRYraHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvQ1BTLTEuMDAU
332BglghkgBhvhCAQEBAf8EBAMCAgQwDQYJKoZIhvcNAQECBQADgYEApRJRkNBqLLgs
33353IR/d18ODdLOWMTZ+QOOxBrq460iBEdUwgF8vmPRX1ku7UiDeNzaLlurE6eFqHq
3342zPyK5j60zfTLVJMWKcQWwTJLjHtXrW8pxhNtFc6Fdvy5ZkHnC/9NIl7/t4U6WqB
335p4y+p7SdMIkEwIZfds0VbnQyX5MRUJY=
336-----END CERTIFICATE-----
337
338 subject=/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority
339 issuer= /C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority
340-----BEGIN CERTIFICATE-----
341MIICMTCCAZoCBQKhAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMRcw
342FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgMyBQdWJsaWMg
343UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NjAxMjkwMDAwMDBa
344Fw05OTEyMzEyMzU5NTlaMF8xCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2ln
345biwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZp
346Y2F0aW9uIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAyVxZ
347nvIbigEUtBDfBEDb41evakVAj4QMC9Ez2dkRz+4CWB8l9yqoRAWq7AMfeH+ek7ma
348AKojfdashaJjRcdyJ8z0TMZ1cdI5709C8HXfCpDGjiBvmA/4rCNfcCk2pMmG57Ga
349IMtTpYXnPb59mv4kRTPcdhXtD6JxZExlLoFoRacCAwEAATANBgkqhkiG9w0BAQIF
350AAOBgQB1Zmw+0c2B27X4LzZRtvdCvM1Cr9wO+hVs+GeTVzrrtpLotgHKjLeOQ7RJ
351Zfk+7r11Ri7J/CVdqMcvi5uPaM+0nJcYwE3vH9mvgrPmZLiEXIqaB1JDYft0nls6
352NvxMsvwaPxUupVs8G5DsiCnkWRb5zget7Ond2tIxik/W2O8XjQ==
353-----END CERTIFICATE-----
354 subject=/C=US/O=VeriSign, Inc./OU=Class 4 Public Primary Certification Authority
355 issuer= /C=US/O=VeriSign, Inc./OU=Class 4 Public Primary Certification Authority
356-----BEGIN CERTIFICATE-----
357MIICMTCCAZoCBQKmAAABMA0GCSqGSIb3DQEBAgUAMF8xCzAJBgNVBAYTAlVTMRcw
358FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgNCBQdWJsaWMg
359UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05NjAxMjkwMDAwMDBa
360Fw05OTEyMzEyMzU5NTlaMF8xCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2ln
361biwgSW5jLjE3MDUGA1UECxMuQ2xhc3MgNCBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZp
362Y2F0aW9uIEF1dGhvcml0eTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0LJ1
3639njQrlpQ9OlQqZ+M1++RlHDo0iSQdomF1t+s5gEXMoDwnZNHvJplnR+Xrr/phnVj
364IIm9gFidBAydqMEk6QvlMXi9/C0MN2qeeIDpRnX57aP7E3vIwUzSo+/1PLBij0pd
365O92VZ48TucE81qcmm+zDO3rZTbxtm+gVAePwR6kCAwEAATANBgkqhkiG9w0BAQIF
366AAOBgQBT3dPwnCR+QKri/AAa19oM/DJhuBUNlvP6Vxt/M3yv6ZiaYch6s7f/sdyZ
367g9ysEvxwyR84Qu1E9oAuW2szaayc01znX1oYx7EteQSWQZGZQbE8DbqEOcY7l/Am
368yY7uvcxClf8exwI/VAx49byqYHwCaejcrOICdmHEPgPq0ook0Q==
369-----END CERTIFICATE-----
diff --git a/src/lib/libssl/src/perl/ss.pl b/src/lib/libssl/src/perl/ss.pl
new file mode 100644
index 0000000000..f243a3af50
--- /dev/null
+++ b/src/lib/libssl/src/perl/ss.pl
@@ -0,0 +1,64 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$ssl_ctx=SSL::CTX->new("SSLv3_client");
8
9#$ssl_ctx->set_options("-info_callback" =>
10# sub {
11# print STDERR $_[0]->state()."\n";
12# }
13# );
14
15$conn="localhost:4433";
16$conn=$ARGV[0] if $#ARGV >= 0;
17
18print $ssl_ctx."\n";
19$bio=BIO->new_buffer_ssl_connect($ssl_ctx);
20$bio->hostname($conn) || die $bio->error();
21
22#$bio->set_callback(
23# sub {
24# my($bio,$state,$cmd,$buf,$lart,$ret)=@_;
25# print STDERR "$state:$cmd\n";
26# return($ret);
27# }
28# );
29
30#$b=$bio;
31#do {
32# print STDERR $b->type."\n";
33# } while ($b=$b->next_bio);
34
35(($ret=$bio->syswrite("GET / HTTP/1.0\r\n\r\n")) > 0) || die $bio->error();
36$bio->flush;
37
38$data="";
39while (1)
40 {
41 $ret=$bio->getline;
42 $ret =~ s/[\r\n]//g;
43 print STDERR "$ret\n";
44 last if $ret eq "";
45 $server=$1 if $ret=~ /^Server: (.*)/;
46 }
47
48
49print "server is $server\n";
50$x509=$ssl->get_peer_certificate();
51print "version :".$x509->get_version()."\n";
52print "serialNumber:".$x509->get_serialNumber()->bn2hex."\n";
53print "subject :".$x509->get_subject_name()."\n";
54print "issuer :". $x509->get_issuer_name()."\n";
55
56$c=$ssl->get_current_cipher;
57($i,$a)=$c->get_bits;
58$v=$c->get_version;
59$n=$c->get_name;
60
61$ssl=$bio->get_ssl();
62print "protocol=".$ssl->get_version."\n";
63print "bits=$i($a) cipher type=$v cipher=$n\n";
64
diff --git a/src/lib/libssl/src/perl/ssl.pl b/src/lib/libssl/src/perl/ssl.pl
new file mode 100644
index 0000000000..f9e983ed87
--- /dev/null
+++ b/src/lib/libssl/src/perl/ssl.pl
@@ -0,0 +1,71 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$ssl_ctx=SSL::CTX->new("SSLv3");
8
9$ssl_ctx->set_options("-info_callback" =>
10 sub {
11 print STDERR $_[0]->state()."\n";
12 }
13 );
14
15$conn="localhost:4433";
16$conn=$ARGV[0] if $#ARGV >= 0;
17$bio=BIO->new("connect");
18$bio->hostname($conn) || die $ssl->error();
19
20#$bbio=BIO->new("buffer");
21#$bbio->push($cbio);
22#$bio=$bbio;
23
24#$bio->set_callback(
25# sub {
26# my($bio,$state,$cmd,$buf,$lart,$ret)=@_;
27# print STDERR "$state:$cmd\n";
28# return($ret);
29# }
30# );
31
32print STDERR "-1 ABCD\n";
33$ssl=$ssl_ctx->new_ssl;
34print STDERR "000 ABCD\n";
35$ssl->set_bio($bio);
36
37print STDERR "00 ABCD\n";
38(($ret=$ssl->connect()) > 0) || die $ssl->error();
39
40print STDERR "0 ABCD\n";
41
42(($ret=$ssl->syswrite("GET / HTTP/1.0\r\n\r\n")) > 0) || die $ssl->error();
43
44print STDERR "1 ABCD\n";
45$data="";
46while (1)
47 {
48print STDERR "2 ABCD\n";
49 $ret=$ssl->sysread($buf,1024);
50print STDERR "3 ABCD\n";
51 last if $ret <= 0;
52 $data.=$buf;
53 }
54
55print STDERR "4 ABCD\n";
56@a=split(/[\r]\n/,$data);
57($server)=grep(/^Server:/,@a);
58
59print "$server\n";
60$x509=$ssl->get_peer_certificate();
61print "subject:".$x509->get_subject_name()."\n";
62print "issuer:". $x509->get_issuer_name()."\n";
63
64$c=$ssl->get_current_cipher;
65($i,$a)=$c->get_bits;
66$v=$c->get_version;
67$n=$c->get_name;
68
69print "protocol=".$ssl->get_version."\n";
70print "bits=$i($a) cipher type=$v cipher=$n\n";
71
diff --git a/src/lib/libssl/src/perl/ssl.txt b/src/lib/libssl/src/perl/ssl.txt
new file mode 100644
index 0000000000..63c52a0e1d
--- /dev/null
+++ b/src/lib/libssl/src/perl/ssl.txt
@@ -0,0 +1,43 @@
1SSL_CTX::new(method)
2 SSLv3
3 SSLv3_client
4 SSLv3_server
5 SSLv23
6 SSLv23_client
7 SSLv23_server
8 SSLv2
9 SSLv2_client
10 SSLv2_server
11
12SSL_CTX::use_PrivateKey_file(file[,type])
13 type eq "der" or "pem". Default == 'pem'.
14
15SSL_CTX::set_options(...)
16 -info_callback function
17
18SSL::new(SSL_CTX)
19
20SSL::connect(); returns 0, -1 or 1
21SSL::accept(); return 0, -1 or 1
22SSL::sysread(); as per sysread
23SSL::syswrite(); as per syswrite
24SSL::set_bio(bio);
25
26SSL::set_options(...)
27 -info_callback function
28 -connect_state
29 -accept_state
30
31SSL::state(); the state in numeric and text form.
32SSL::references(); debug stuff
33SSL::get_peer_certificate()
34SSL::do_handshake()
35SSL::renegotiate()
36SSL::shutdown()
37SSL::get_version()
38
39SSL::get_current_cipher();
40
41(key,alg)=SSL_CIPHER::get_bits();
42SSL_CIPHER::get_version();
43SSL_CIPHER::get_name();
diff --git a/src/lib/libssl/src/perl/ssl.xs b/src/lib/libssl/src/perl/ssl.xs
new file mode 100644
index 0000000000..6777cf7ada
--- /dev/null
+++ b/src/lib/libssl/src/perl/ssl.xs
@@ -0,0 +1,474 @@
1#include "p5SSLeay.h"
2
3static int p5_ssl_ex_ssl_ptr=0;
4static int p5_ssl_ex_ssl_info_callback=0;
5static int p5_ssl_ex_ssl_ctx_ptr=0;
6static int p5_ssl_ctx_ex_ssl_info_callback=0;
7
8typedef struct ssl_ic_args_st {
9 SV *cb;
10 SV *arg;
11 } SSL_IC_ARGS;
12
13static void p5_ssl_info_callback(ssl,mode,ret)
14SSL *ssl;
15int mode;
16int ret;
17 {
18 int i;
19 SV *me,*cb;
20
21 me=(SV *)SSL_get_ex_data(ssl,p5_ssl_ex_ssl_ptr);
22 cb=(SV *)SSL_get_ex_data(ssl,p5_ssl_ex_ssl_info_callback);
23 if (cb == NULL)
24 cb=(SV *)SSL_CTX_get_ex_data(
25 SSL_get_SSL_CTX(ssl),p5_ssl_ctx_ex_ssl_info_callback);
26 if (cb != NULL)
27 {
28 dSP;
29
30 PUSHMARK(sp);
31 XPUSHs(me);
32 XPUSHs(sv_2mortal(newSViv(mode)));
33 XPUSHs(sv_2mortal(newSViv(ret)));
34 PUTBACK;
35
36 i=perl_call_sv(cb,G_DISCARD);
37 }
38 else
39 {
40 croak("Internal error in SSL p5_ssl_info_callback");
41 }
42 }
43
44int boot_ssl()
45 {
46 p5_ssl_ex_ssl_ptr=
47 SSL_get_ex_new_index(0,"SSLeay::SSL",ex_new,NULL,ex_cleanup);
48 p5_ssl_ex_ssl_info_callback=
49 SSL_get_ex_new_index(0,"ssl_info_callback",NULL,NULL,
50 ex_cleanup);
51 p5_ssl_ex_ssl_ctx_ptr=
52 SSL_get_ex_new_index(0,"ssl_ctx_ptr",NULL,NULL,
53 ex_cleanup);
54 p5_ssl_ctx_ex_ssl_info_callback=
55 SSL_CTX_get_ex_new_index(0,"ssl_ctx_info_callback",NULL,NULL,
56 ex_cleanup);
57 return(1);
58 }
59
60MODULE = SSLeay::SSL PACKAGE = SSLeay::SSL::CTX PREFIX = p5_SSL_CTX_
61
62VERSIONCHECK: DISABLE
63
64void
65p5_SSL_CTX_new(...)
66 PREINIT:
67 SSL_METHOD *meth;
68 SSL_CTX *ctx;
69 char *method;
70 PPCODE:
71 pr_name("p5_SSL_CTX_new");
72 if ((items == 1) && SvPOK(ST(0)))
73 method=SvPV(ST(0),na);
74 else if ((items == 2) && SvPOK(ST(1)))
75 method=SvPV(ST(1),na);
76 else
77 croak("Usage: SSLeay::SSL_CTX::new(type)");
78
79 if (strcmp(method,"SSLv3") == 0)
80 meth=SSLv3_method();
81 else if (strcmp(method,"SSLv3_client") == 0)
82 meth=SSLv3_client_method();
83 else if (strcmp(method,"SSLv3_server") == 0)
84 meth=SSLv3_server_method();
85 else if (strcmp(method,"SSLv23") == 0)
86 meth=SSLv23_method();
87 else if (strcmp(method,"SSLv23_client") == 0)
88 meth=SSLv23_client_method();
89 else if (strcmp(method,"SSLv23_server") == 0)
90 meth=SSLv23_server_method();
91 else if (strcmp(method,"SSLv2") == 0)
92 meth=SSLv2_method();
93 else if (strcmp(method,"SSLv2_client") == 0)
94 meth=SSLv2_client_method();
95 else if (strcmp(method,"SSLv2_server") == 0)
96 meth=SSLv2_server_method();
97 else
98 {
99 croak("Not passed a valid SSL method name, should be 'SSLv[23] [client|server]'");
100 }
101 EXTEND(sp,1);
102 PUSHs(sv_newmortal());
103 ctx=SSL_CTX_new(meth);
104 sv_setref_pv(ST(0), "SSLeay::SSL::CTX", (void*)ctx);
105
106int
107p5_SSL_CTX_use_PrivateKey_file(ctx,file,...)
108 SSL_CTX *ctx;
109 char *file;
110 PREINIT:
111 int i=SSL_FILETYPE_PEM;
112 char *ptr;
113 CODE:
114 pr_name("p5_SSL_CTX_use_PrivateKey_file");
115 if (items > 3)
116 croak("SSLeay::SSL::CTX::use_PrivateKey_file(ssl_ctx,file[,type])");
117 if (items == 3)
118 {
119 ptr=SvPV(ST(2),na);
120 if (strcmp(ptr,"der") == 0)
121 i=SSL_FILETYPE_ASN1;
122 else
123 i=SSL_FILETYPE_PEM;
124 }
125 RETVAL=SSL_CTX_use_RSAPrivateKey_file(ctx,file,i);
126 OUTPUT:
127 RETVAL
128
129int
130p5_SSL_CTX_set_options(ctx,...)
131 SSL_CTX *ctx;
132 PREINIT:
133 int i;
134 char *ptr;
135 SV *sv;
136 CODE:
137 pr_name("p5_SSL_CTX_set_options");
138
139 for (i=1; i<items; i++)
140 {
141 if (!SvPOK(ST(i)))
142 croak("Usage: SSLeay::SSL_CTX::set_options(ssl_ctx[,option,value]+)");
143 ptr=SvPV(ST(i),na);
144 if (strcmp(ptr,"-info_callback") == 0)
145 {
146 SSL_CTX_set_info_callback(ctx,
147 p5_ssl_info_callback);
148 sv=sv_mortalcopy(ST(i+1));
149 SvREFCNT_inc(sv);
150 SSL_CTX_set_ex_data(ctx,
151 p5_ssl_ctx_ex_ssl_info_callback,
152 (char *)sv);
153 i++;
154 }
155 else
156 {
157 croak("SSLeay::SSL_CTX::set_options(): unknown option");
158 }
159 }
160
161void
162p5_SSL_CTX_DESTROY(ctx)
163 SSL_CTX *ctx
164 PREINIT:
165 SV *sv;
166 PPCODE:
167 pr_name_d("p5_SSL_CTX_DESTROY",ctx->references);
168 SSL_CTX_free(ctx);
169
170MODULE = SSLeay::SSL PACKAGE = SSLeay::SSL PREFIX = p5_SSL_
171
172void
173p5_SSL_new(...)
174 PREINIT:
175 SV *sv_ctx;
176 SSL_CTX *ctx;
177 SSL *ssl;
178 int i;
179 SV *arg;
180 PPCODE:
181 pr_name("p5_SSL_new");
182 if ((items != 1) && (items != 2))
183 croak("Usage: SSLeay::SSL::new(ssl_ctx)");
184 if (sv_derived_from(ST(items-1),"SSLeay::SSL::CTX"))
185 {
186 IV tmp = SvIV((SV*)SvRV(ST(items-1)));
187 ctx=(SSL_CTX *)tmp;
188 sv_ctx=ST(items-1);
189 }
190 else
191 croak("ssl_ctx is not of type SSLeay::SSL::CTX");
192
193 EXTEND(sp,1);
194 PUSHs(sv_newmortal());
195 ssl=SSL_new(ctx);
196 sv_setref_pv(ST(0), "SSLeay::SSL", (void*)ssl);
197
198 /* Now this is being a little hairy, we keep a pointer to
199 * our perl reference. We need to do a different one
200 * to the one we return because it will have it's reference
201 * count droped to 0 apon return and if we up its reference
202 * count, it will never be DESTROYED */
203 arg=newSVsv(ST(0));
204 SSL_set_ex_data(ssl,p5_ssl_ex_ssl_ptr,(char *)arg);
205 SvREFCNT_inc(sv_ctx);
206 SSL_set_ex_data(ssl,p5_ssl_ex_ssl_ctx_ptr,(char *)sv_ctx);
207
208int
209p5_SSL_connect(ssl)
210 SSL *ssl;
211 CODE:
212 RETVAL=SSL_connect(ssl);
213 OUTPUT:
214 RETVAL
215
216int
217p5_SSL_accept(ssl)
218 SSL *ssl;
219 CODE:
220 RETVAL=SSL_connect(ssl);
221 OUTPUT:
222 RETVAL
223
224int
225p5_SSL_sysread(ssl,in,num, ...)
226 SSL *ssl;
227 SV *in;
228 int num;
229 PREINIT:
230 int i,n,olen;
231 int offset;
232 char *p;
233 CODE:
234 offset=0;
235 if (!SvPOK(in))
236 sv_setpvn(in,"",0);
237 SvPV(in,olen);
238 if (items > 3)
239 {
240 offset=SvIV(ST(3));
241 if (offset < 0)
242 {
243 if (-offset > olen)
244 croad("Offset outside string");
245 offset+=olen;
246 }
247 }
248 if ((num+offset) > olen)
249 {
250 SvGROW(in,num+offset+1);
251 p=SvPV(in,i);
252 memset(&(p[olen]),0,(num+offset)-olen+1);
253 }
254 p=SvPV(in,n);
255
256 i=SSL_read(ssl,p+offset,num);
257 RETVAL=i;
258 if (i <= 0) i=0;
259 SvCUR_set(in,offset+i);
260 OUTPUT:
261 RETVAL
262
263int
264p5_SSL_syswrite(ssl,in, ...)
265 SSL *ssl;
266 SV *in;
267 PREINIT:
268 char *ptr;
269 int len,in_len;
270 int offset=0;
271 int n;
272 CODE:
273 ptr=SvPV(in,in_len);
274 if (items > 2)
275 {
276 len=SvOK(ST(2))?SvIV(ST(2)):in_len;
277 if (items > 3)
278 {
279 offset=SvIV(ST(3));
280 if (offset < 0)
281 {
282 if (-offset > in_len)
283 croak("Offset outside string");
284 offset+=in_len;
285 }
286 else if ((offset >= in_len) && (in_len > 0))
287 croak("Offset outside string");
288 }
289 if (len >= (in_len-offset))
290 len=in_len-offset;
291 }
292 else
293 len=in_len;
294
295 RETVAL=SSL_write(ssl,ptr+offset,len);
296 OUTPUT:
297 RETVAL
298
299void
300p5_SSL_set_bio(ssl,bio)
301 SSL *ssl;
302 BIO *bio;
303 CODE:
304 bio->references++;
305 SSL_set_bio(ssl,bio,bio);
306
307int
308p5_SSL_set_options(ssl,...)
309 SSL *ssl;
310 PREINIT:
311 int i;
312 char *ptr;
313 SV *sv;
314 CODE:
315 pr_name("p5_SSL_set_options");
316
317 for (i=1; i<items; i++)
318 {
319 if (!SvPOK(ST(i)))
320 croak("Usage: SSLeay::SSL::set_options(ssl[,option,value]+)");
321 ptr=SvPV(ST(i),na);
322 if (strcmp(ptr,"-info_callback") == 0)
323 {
324 SSL_set_info_callback(ssl,
325 p5_ssl_info_callback);
326 sv=sv_mortalcopy(ST(i+1));
327 SvREFCNT_inc(sv);
328 SSL_set_ex_data(ssl,
329 p5_ssl_ex_ssl_info_callback,(char *)sv);
330 i++;
331 }
332 else if (strcmp(ptr,"-connect_state") == 0)
333 {
334 SSL_set_connect_state(ssl);
335 }
336 else if (strcmp(ptr,"-accept_state") == 0)
337 {
338 SSL_set_accept_state(ssl);
339 }
340 else
341 {
342 croak("SSLeay::SSL::set_options(): unknown option");
343 }
344 }
345
346void
347p5_SSL_state(ssl)
348 SSL *ssl;
349 PREINIT:
350 int state;
351 PPCODE:
352 pr_name("p5_SSL_state");
353 EXTEND(sp,1);
354 PUSHs(sv_newmortal());
355 state=SSL_state(ssl);
356 sv_setpv(ST(0),SSL_state_string_long(ssl));
357 sv_setiv(ST(0),state);
358 SvPOK_on(ST(0));
359
360void
361p5_SSL_DESTROY(ssl)
362 SSL *ssl;
363 CODE:
364 pr_name_dd("p5_SSL_DESTROY",ssl->references,ssl->ctx->references);
365 fprintf(stderr,"SSL_DESTROY %d\n",ssl->references);
366 SSL_free(ssl);
367
368int
369p5_SSL_references(ssl)
370 SSL *ssl;
371 CODE:
372 RETVAL=ssl->references;
373 OUTPUT:
374 RETVAL
375
376int
377p5_SSL_do_handshake(ssl)
378 SSL *ssl;
379 CODE:
380 RETVAL=SSL_do_handshake(ssl);
381 OUTPUT:
382 RETVAL
383
384int
385p5_SSL_renegotiate(ssl)
386 SSL *ssl;
387 CODE:
388 RETVAL=SSL_renegotiate(ssl);
389 OUTPUT:
390 RETVAL
391
392int
393p5_SSL_shutdown(ssl)
394 SSL *ssl;
395 CODE:
396 RETVAL=SSL_shutdown(ssl);
397 OUTPUT:
398 RETVAL
399
400char *
401p5_SSL_get_version(ssl)
402 SSL *ssl;
403 CODE:
404 RETVAL=SSL_get_version(ssl);
405 OUTPUT:
406 RETVAL
407
408SSL_CIPHER *
409p5_SSL_get_current_cipher(ssl)
410 SSL *ssl;
411 CODE:
412 RETVAL=SSL_get_current_cipher(ssl);
413 OUTPUT:
414 RETVAL
415
416X509 *
417p5_SSL_get_peer_certificate(ssl)
418 SSL *ssl
419 CODE:
420 RETVAL=SSL_get_peer_certificate(ssl);
421 OUTPUT:
422 RETVAL
423
424MODULE = SSLeay::SSL PACKAGE = SSLeay::SSL::CIPHER PREFIX = p5_SSL_CIPHER_
425
426int
427p5_SSL_CIPHER_get_bits(sc)
428 SSL_CIPHER *sc
429 PREINIT:
430 int i,ret;
431 PPCODE:
432 EXTEND(sp,2);
433 PUSHs(sv_newmortal());
434 PUSHs(sv_newmortal());
435 ret=SSL_CIPHER_get_bits(sc,&i);
436 sv_setiv(ST(0),(IV)ret);
437 sv_setiv(ST(1),(IV)i);
438
439char *
440p5_SSL_CIPHER_get_version(sc)
441 SSL_CIPHER *sc
442 CODE:
443 RETVAL=SSL_CIPHER_get_version(sc);
444 OUTPUT:
445 RETVAL
446
447char *
448p5_SSL_CIPHER_get_name(sc)
449 SSL_CIPHER *sc
450 CODE:
451 RETVAL=SSL_CIPHER_get_name(sc);
452 OUTPUT:
453 RETVAL
454
455MODULE = SSLeay::SSL PACKAGE = SSLeay::BIO PREFIX = p5_BIO_
456
457void
458p5_BIO_get_ssl(bio)
459 BIO *bio;
460 PREINIT:
461 SSL *ssl;
462 SV *ret;
463 int i;
464 PPCODE:
465 if ((i=BIO_get_ssl(bio,&ssl)) > 0)
466 {
467 ret=(SV *)SSL_get_ex_data(ssl,p5_ssl_ex_ssl_ptr);
468 ret=sv_mortalcopy(ret);
469 }
470 else
471 ret= &sv_undef;
472 EXTEND(sp,1);
473 PUSHs(ret);
474
diff --git a/src/lib/libssl/src/perl/ssl_srvr.pl b/src/lib/libssl/src/perl/ssl_srvr.pl
new file mode 100644
index 0000000000..653a2e7f03
--- /dev/null
+++ b/src/lib/libssl/src/perl/ssl_srvr.pl
@@ -0,0 +1,35 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$ssl_ctx=SSL::CTX->new("SSLv3");
8
9$ssl_ctx->set_options("-info_callback" =>
10 sub {
11 print STDERR $_[0]->state()."\n";
12 }
13 );
14
15$ssl_ctx->use_PrivateKey_file("server.pem");
16
17$conn="localhost:4433";
18$conn=$ARGV[0] if $#ARGV >= 0;
19$bio=BIO->new("connect");
20$bio->hostname($conn) || die $ssl->error();
21
22$ssl=$ssl_ctx->new_ssl;
23$ssl->set_bio($bio);
24
25(($ret=$ssl->connect()) > 0) || die $ssl->error();
26
27(($ret=$ssl->write("GET / HTTP/1.0\r\n\r\n")) > 0) || die $ssl->error();
28
29while (1)
30 {
31 $ret=$ssl->read($buf,10240);
32 last if ($ret <= 0);
33 print $buf;
34 }
35
diff --git a/src/lib/libssl/src/perl/sslbio.pl b/src/lib/libssl/src/perl/sslbio.pl
new file mode 100644
index 0000000000..ca9daa36a1
--- /dev/null
+++ b/src/lib/libssl/src/perl/sslbio.pl
@@ -0,0 +1,40 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$ssl_ctx=SSL::CTX->new("SSLv3");
8
9#$ssl_ctx->set_options("-info_callback" =>
10# sub {
11# print STDOUT $_[0]->state()."\n";
12# }
13# );
14
15# create a ssl bio
16$bssl=BIO->new("ssl");
17$bssl->set_ssl($ssl_ctx->new_ssl()) || die $bssl->error();
18$bssl->get_ssl->set_options("-connect_state") || die $ssl->error();
19
20$bssl->set_callback(sub { printf "XXXXXXXXXXXXXXXXXXXXXX %d %s\n",$_[1],$_[0]->type; });
21
22# create connect bio
23$host="localhost:4433";
24$host=$ARGV[0] if $#ARGV >= 0;
25$bio=BIO->new("connect");
26$bio->hostname($host) || die $bio->error();
27
28# push it in
29$bssl->push($bio);
30
31(($ret=$bssl->write("GET / HTTP/1.0\r\n\r\n")) > 0) || die $bssl->error();
32
33while (1)
34 {
35 $ret=$bssl->read($buf,10240);
36 last if ($ret <= 0);
37 print $buf;
38 }
39
40
diff --git a/src/lib/libssl/src/perl/t.pl b/src/lib/libssl/src/perl/t.pl
new file mode 100644
index 0000000000..fbd9fb8490
--- /dev/null
+++ b/src/lib/libssl/src/perl/t.pl
@@ -0,0 +1,12 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$a=SSLeay::BN::dec2bn("1231353465324563455");
8print "a=$a\n".$a->bn2dec."\n";
9$b=SSLeay::BN::dec2bn("98790816238765235");
10print "a=$a\nb=$b\n";
11print $a->gcd($b)."\n";
12
diff --git a/src/lib/libssl/src/perl/test b/src/lib/libssl/src/perl/test
new file mode 100644
index 0000000000..3977c48865
--- /dev/null
+++ b/src/lib/libssl/src/perl/test
@@ -0,0 +1,32 @@
130373b8dbfc38d360bda81fad2fb462e 8 0 8 des-ecb
2a5f61a73a0894979d46c2481e9f27151 8 8 1 des-cfb
3a64a08dc69e79becccde95bed6239fca 8 8 1 des-ofb
4553d168193e54100524541f2c473b705 8 8 8 des-cbc
5bb75383e4aad6d83418dde16c6cea6f5 16 0 8 des-ede
63ea71cd9a2e50d82d66b433e9471eeb2 16 8 1 des-ede-cfb
73d56b76d43dc8d51647773bc9719a355 16 8 1 des-ede-ofb
8eafa89aae63167b9798639c0e31223b4 16 8 8 des-ede-cbc
9a952f8c409fb0df75a7df1aa54ba30b8 24 0 8 des-ede3
100badccc43a14d8503d33f32a2345bbd2 24 8 1 des-ede3-cfb
11bae638c0e33850d02c792ed0e3d6b600 24 8 1 des-ede3-ofb
12ec4522bbefabf0198126683e661325e2 24 8 8 des-ede3-cbc
134431f05d198d8afc003aeec85bea01b9 24 8 8 desx-cbc
14606af8d6f30c1fd9c647df5eb716ae0f 16 0 1 rc4
154aaaf7e4bc3fd2caa6318a4852f636f4 5 0 1 rc4-40
1677e0851e8c96c4a1e26140d1ec822036 16 0 8 idea-ecb
17a28e51e283519fde0e128bcb697bc23e 16 8 1 idea-cfb
1817d0e70f07de6c08e9673d52987599ab 16 8 1 idea-ofb
190687cf6ca11ee45f8bf9c29525405a4d 16 8 8 idea-cbc
20e2268681a63198fe38282b0a1bb6ed36 16 0 8 rc2-ecb
21f48748e6386790e639bbee4fccaa5067 16 8 8 rc2-cbc
22f250cfe829ef797d6866e32526ec4fe4 5 8 8 rc2-40-cbc
23a372f970b6c346341a2899bb872a7349 16 8 1 rc2-cfb
24d2da66102dea6b833f0fbf71e2cb4988 16 8 1 rc2-ofb
25237b0ef0e4f7fb28a5708d59773caecf 16 0 8 bf-ecb
26c58cf5da90472caf0f0b7fafb0590977 16 8 1 bf-cfb
271f3e49e2e27f9ad177a6a64b09d361ed 16 8 1 bf-ofb
2866acaf2cb5f301580c59fa17d005b716 16 8 8 bf-cbc
293548c9fe9fcd13f647ae177a15915af9 16 0 8 cast5-ecb
30e8d074ad8cc0d3d828da80ab18452f91 16 8 1 cast5-cfb
315331eb4351c2048c27c8a8901fd29e20 16 8 1 cast5-ofb
328033607fdb68598cc62c379af218eeeb 16 8 8 cast5-cbc
diff --git a/src/lib/libssl/src/perl/test.pl b/src/lib/libssl/src/perl/test.pl
new file mode 100644
index 0000000000..52423ef620
--- /dev/null
+++ b/src/lib/libssl/src/perl/test.pl
@@ -0,0 +1,30 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7($a=SSLeay::BN::new()) || die "unable to make bignum\n";
8($b=SSLeay::BN::new()) || die "unable to make bignum\n";
9
10$a=SSLeay::BN::hex2bn("123456789ABCDEF");
11$b=SSLeay::BN::hex2bn("123456789ABCDEF");
12$mod=SSLeay::BN::hex2bn("fedcba9876543201");
13$c=SSLeay::BN::hex2bn("1234");
14
15print "a=".$a->bn2hex()."\n";
16print "b=".$b->bn2hex()."\n";
17print "c=".$c->bn2hex()."\n";
18
19print $a->mul($b)->bn2hex."\n";
20($d,$r)=$b->div($c);
21print "($d)($r)\n";
22printf "%s x %s + %s\n",$c->bn2hex,$d->bn2hex,$r->bn2hex;
23
24$g=$d;
25
26for (;;)
27 {
28 $a=$a->mod_mul($a,$mod);
29 print $a->bn2hex."\n";
30 }
diff --git a/src/lib/libssl/src/perl/test.txt b/src/lib/libssl/src/perl/test.txt
new file mode 100644
index 0000000000..ff37ffd09b
--- /dev/null
+++ b/src/lib/libssl/src/perl/test.txt
@@ -0,0 +1,36 @@
130373b8dbfc38d360bda81fad2fb462e 8 0 8 des-ecb
2a5f61a73a0894979d46c2481e9f27151 8 8 1 des-cfb
3a64a08dc69e79becccde95bed6239fca 8 8 1 des-ofb
4553d168193e54100524541f2c473b705 8 8 8 des-cbc
5bb75383e4aad6d83418dde16c6cea6f5 16 0 8 des-ede
63ea71cd9a2e50d82d66b433e9471eeb2 16 8 1 des-ede-cfb
73d56b76d43dc8d51647773bc9719a355 16 8 1 des-ede-ofb
8eafa89aae63167b9798639c0e31223b4 16 8 8 des-ede-cbc
9a952f8c409fb0df75a7df1aa54ba30b8 24 0 8 des-ede3
100badccc43a14d8503d33f32a2345bbd2 24 8 1 des-ede3-cfb
11bae638c0e33850d02c792ed0e3d6b600 24 8 1 des-ede3-ofb
12ec4522bbefabf0198126683e661325e2 24 8 8 des-ede3-cbc
134431f05d198d8afc003aeec85bea01b9 24 8 8 desx-cbc
14606af8d6f30c1fd9c647df5eb716ae0f 16 0 1 rc4
154aaaf7e4bc3fd2caa6318a4852f636f4 5 0 1 rc4-40
1677e0851e8c96c4a1e26140d1ec822036 16 0 8 idea-ecb
17a28e51e283519fde0e128bcb697bc23e 16 8 1 idea-cfb
1817d0e70f07de6c08e9673d52987599ab 16 8 1 idea-ofb
190687cf6ca11ee45f8bf9c29525405a4d 16 8 8 idea-cbc
20e2268681a63198fe38282b0a1bb6ed36 16 0 8 rc2-ecb
21f48748e6386790e639bbee4fccaa5067 16 8 8 rc2-cbc
22f250cfe829ef797d6866e32526ec4fe4 5 8 8 rc2-40-cbc
23a372f970b6c346341a2899bb872a7349 16 8 1 rc2-cfb
24d2da66102dea6b833f0fbf71e2cb4988 16 8 1 rc2-ofb
25237b0ef0e4f7fb28a5708d59773caecf 16 0 8 bf-ecb
26c58cf5da90472caf0f0b7fafb0590977 16 8 1 bf-cfb
271f3e49e2e27f9ad177a6a64b09d361ed 16 8 1 bf-ofb
2866acaf2cb5f301580c59fa17d005b716 16 8 8 bf-cbc
293548c9fe9fcd13f647ae177a15915af9 16 0 8 cast5-ecb
30e8d074ad8cc0d3d828da80ab18452f91 16 8 1 cast5-cfb
315331eb4351c2048c27c8a8901fd29e20 16 8 1 cast5-ofb
328033607fdb68598cc62c379af218eeeb 16 8 8 cast5-cbc
33e3a6760eb5e79bf4063cf0791e99842d 16 0 8 rc5-ecb
342f5eab0d0992dcce8615a5a60966391a 16 8 1 rc5-cfb
35c5893e49e73342db2957b83b70f23e27 16 8 1 rc5-ofb
36683ce60c8b7bf028ec0d3dc0f018a1a4 16 8 8 rc5-cbc
diff --git a/src/lib/libssl/src/perl/test2.pl b/src/lib/libssl/src/perl/test2.pl
new file mode 100644
index 0000000000..2e1196c072
--- /dev/null
+++ b/src/lib/libssl/src/perl/test2.pl
@@ -0,0 +1,28 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7@md=();
8($c=SSLeay::Cipher::new("idea")) ||
9 die "'des' is an unknown cipher algorithm\n";
10
11printf "name =%s\n" ,$c->name();
12printf "key length=%2d\n",$c->key_length();
13printf "iv length =%2d\n",$c->iv_length();
14printf "block size=%2d\n",$c->block_size();
15
16$data="1234";
17$c->init("01234567","abcdefgh",1);
18$in=$c->update($data);
19$in.=$c->final();
20
21$c->init("01234567","abcdefgh",0);
22$out=$c->update($in);
23$out.=$c->final();
24print $data;
25print " -> ";
26print $out;
27print "\n";
28
diff --git a/src/lib/libssl/src/perl/test3.pl b/src/lib/libssl/src/perl/test3.pl
new file mode 100644
index 0000000000..4102ab9297
--- /dev/null
+++ b/src/lib/libssl/src/perl/test3.pl
@@ -0,0 +1,19 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7@md=();
8($c=SSLeay::Cipher::new("idea")) ||
9 die "'des' is an unknown cipher algorithm\n";
10
11$key=" ";
12$iv=" ";
13$c->init($key,$iv,0);
14while (<>)
15 {
16 print $c->update($_);
17 }
18print $c->final();
19
diff --git a/src/lib/libssl/src/perl/test8.pl b/src/lib/libssl/src/perl/test8.pl
new file mode 100644
index 0000000000..c144f7f136
--- /dev/null
+++ b/src/lib/libssl/src/perl/test8.pl
@@ -0,0 +1,19 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7# 2687145 * 3003 * 10^5072 - 1.
8
9$a=SSLeay::BN::set_word(99);
10$b=SSLeay::BN::set_word(100);
11
12$aa=$a->dup;
13$bb=$b->dup;
14
15$c=$a*$b;
16$bb+=$a;
17
18print "$a*$b=$c\n";
19print "$bb\n";
diff --git a/src/lib/libssl/src/perl/test9.pl b/src/lib/libssl/src/perl/test9.pl
new file mode 100644
index 0000000000..cc710c310e
--- /dev/null
+++ b/src/lib/libssl/src/perl/test9.pl
@@ -0,0 +1,38 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7# 2687145 * 3003 * 10^5072 - 1.
8
9$a=SSLeay::BN::set_word(2687145);
10$b=SSLeay::BN::set_word(3003);
11$c=SSLeay::BN::set_word(10);
12$d=SSLeay::BN::set_word(5072);
13$e=SSLeay::BN::set_word(1);
14
15print $a->bn2hex()."\n";
16print $b->bn2hex()."\n";
17print $c->bn2hex()."\n";
18print $d->bn2hex()."\n";
19print $e->bn2hex()."\n";
20
21$f=(($a->mul($b)->mul($c->exp($d)))->sub($e));
22#print "$a $b\n";
23
24$c=$a->mul($b);
25print "1->".$c->bn2hex()." \n";
26
27$c=$a*$b;
28print "2->".$c->bn2hex()." \n";
29$a*=$b;
30print "3->$a\n";
31
32print $f->bn2hex()." $a\n";
33print $a."\n";
34
35print "$a=(($b*$c)/$d);\n";
36$a=(($b*$c)/$d);
37print "$a\n";
38
diff --git a/src/lib/libssl/src/perl/testbn.pl b/src/lib/libssl/src/perl/testbn.pl
new file mode 100644
index 0000000000..3062439563
--- /dev/null
+++ b/src/lib/libssl/src/perl/testbn.pl
@@ -0,0 +1,23 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$num ="a43f6a8885a308d313198a2e03707344a4093822";
8$num.="299f31d0082efa98ec4e6c89452821e638d01377";
9$num.="be5466cf34e90c6cc0ac29b7c97c50dd3f84d5b5";
10$num.="b54709179216d5d98979fb1bd1310ba698dfb5ac";
11$num.="2ffd72dbd01adfb7b8e1afed6a267e96ba7c9045";
12$num.="f12c7f9924a19947b3916cf70801f2e2858efc16";
13$num.="636920d871574e69a458fea3f4933d7e0d95748f";
14$num.="728eb658718bcd5882154aee7b54a41dc25a59b5";
15$num.="9c30d5392af26013c5d1b023286085f0ca417918";
16$num.="b8db38ef8e79dcb0603a180e6c9e0e8bb01e8a3e";
17$num.="d71577c1bd314b2778af2fda55605c60e65525f3";
18$num.="aa55ab945748986263e8144055ca396a2aab10b6";
19$num.="b4cc5c341141e8cea15486af7c8f14a7";
20
21$a=SSLeay::BN::hex2bn($num);
22print "num bits =".$a->num_bits."\n";
23print $a->is_prime(50,sub {print STDERR $_[0]?"+":"."})."\n";
diff --git a/src/lib/libssl/src/perl/testdec.pl b/src/lib/libssl/src/perl/testdec.pl
new file mode 100644
index 0000000000..0dce3f8e79
--- /dev/null
+++ b/src/lib/libssl/src/perl/testdec.pl
@@ -0,0 +1,14 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$a=SSLeay::BN::dec2bn("1234");
8
9foreach (1..4)
10 {
11 $a*=$a;
12 print $a."\n",$a->bn2dec()."\n";
13 }
14
diff --git a/src/lib/libssl/src/perl/testmd.pl b/src/lib/libssl/src/perl/testmd.pl
new file mode 100644
index 0000000000..6549166c8a
--- /dev/null
+++ b/src/lib/libssl/src/perl/testmd.pl
@@ -0,0 +1,26 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7@md=();
8foreach ("md2", "md5", "sha", "sha1", "mdc2", "ripemd160")
9 {
10 ($f=MD->new($_)) ||
11 die "$_ is an unknown message digest algorithm\n";
12 push(@md,$f);
13 }
14
15while (<>)
16 {
17 foreach $md (@md)
18 { $md->update($_); }
19 }
20
21foreach (@md)
22 {
23 $digest=$_->final();
24 printf "%-4s=%s\n",$_->name(),unpack("H*",$digest);
25 }
26
diff --git a/src/lib/libssl/src/perl/tt.pl b/src/lib/libssl/src/perl/tt.pl
new file mode 100644
index 0000000000..80ec88b2a8
--- /dev/null
+++ b/src/lib/libssl/src/perl/tt.pl
@@ -0,0 +1,15 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7for ($i=1; $i<1000; $i++)
8 {
9 $a.=$i%10;
10 $y=SSLeay::BN::dec2bn($a);
11 $z=SSLeay::BN::bn2dec($y);
12
13 print "$a\n$y\n$z\n";
14 }
15
diff --git a/src/lib/libssl/src/perl/typemap b/src/lib/libssl/src/perl/typemap
new file mode 100644
index 0000000000..5226fbc369
--- /dev/null
+++ b/src/lib/libssl/src/perl/typemap
@@ -0,0 +1,96 @@
1
2datum T_DATUM
3EVP_MD_CTX * T_MD_CTX
4EVP_CIPHER_CTX * T_CIPHER_CTX
5BIGNUM * T_BIGNUM
6SSL_METHOD * T_SSL_METHOD
7SSL_CTX * T_SSL_CTX
8SSL_CIPHER * T_SSL_CIPHER
9SSL * T_SSL
10BIO * T_BIO
11X509 * T_X509
12
13INPUT
14T_DATUM
15 $var.dptr=SvPV($arg,$var.dsize);
16T_MD_CTX
17 if (sv_derived_from($arg, \"SSLeay::MD\")) {
18 IV tmp = SvIV((SV*)SvRV($arg));
19 $var = (EVP_MD_CTX *) tmp;
20 }
21 else
22 croak(\"$var is not of type SSLeay::MD\")
23T_CIPHER_CTX
24 if (sv_derived_from($arg, \"SSLeay::Cipher\")) {
25 IV tmp = SvIV((SV*)SvRV($arg));
26 $var = (EVP_CIPHER_CTX *) tmp;
27 }
28 else
29 croak(\"$var is not of type SSLeay::Cipher\")
30T_BIGNUM
31 sv_to_BIGNUM(&($var),$arg,\"$var is not of type SSLeay::MD, int or string\")
32T_SSL_METHOD
33 if (sv_derived_from($arg, \"SSLeay::SSL::METHOD\")) {
34 IV tmp = SvIV((SV*)SvRV($arg));
35 $var = (SSL_METHOD *) tmp;
36 }
37 else
38 croak(\"$var is not of type SSLeay::SSL::METHOD\")
39T_SSL_CTX
40 if (sv_derived_from($arg, \"SSLeay::SSL::CTX\")) {
41 IV tmp = SvIV((SV*)SvRV($arg));
42 $var = (SSL_CTX *) tmp;
43 }
44 else
45 croak(\"$var is not of type SSLeay::SSL::CTX\")
46T_SSL_CIPHER
47 if (sv_derived_from($arg, \"SSLeay::SSL::CIPHER\")) {
48 IV tmp = SvIV((SV*)SvRV($arg));
49 $var = (SSL_CIPHER *) tmp;
50 }
51 else
52 croak(\"$var is not of type SSLeay::SSL::CIPHER\")
53T_SSL
54 if (sv_derived_from($arg, \"SSLeay::SSL\")) {
55 IV tmp = SvIV((SV*)SvRV($arg));
56 $var = (SSL *) tmp;
57 }
58 else
59 croak(\"$var is not of type SSLeay::SSL\")
60T_BIO
61 if (sv_derived_from($arg, \"SSLeay::BIO\")) {
62 IV tmp = SvIV((SV*)SvRV($arg));
63 $var = (BIO *) tmp;
64 }
65 else
66 croak(\"$var is not of type SSLeay::BIO\")
67T_X509
68 if (sv_derived_from($arg, \"SSLeay::X509\")) {
69 IV tmp = SvIV((SV*)SvRV($arg));
70 $var = (X509 *) tmp;
71 }
72 else
73 croak(\"$var is not of type SSLeay::X509\")
74OUTPUT
75T_DATUM
76 sv_setpvn($arg,$var.dptr,$var.dsize);
77T_MD_CTX
78 sv_setref_pv($arg, \"SSLeay::MD\", (void*)$var);
79T_CIPHER_CTX
80 sv_setref_pv($arg, \"SSLeay::Cipher\", (void*)$var);
81T_BIGNUM
82 sv_setref_pv($arg, \"SSLeay::BN\", (void*)$var);
83T_SSL_METHOD
84 sv_setref_pv($arg, \"SSLeay::SSL::METHOD\", (void*)$var);
85T_SSL_CTX
86 sv_setref_pv($arg, \"SSLeay::SSL::CTX\", (void*)$var);
87T_SSL_CIPHER
88 sv_setref_pv($arg, \"SSLeay::SSL::CIPHER\", (void*)$var);
89T_SSL
90 sv_setref_pv($arg, \"SSLeay::SSL\", (void*)$var);
91T_BIO
92 sv_setref_pv($arg, \"SSLeay::BIO\", (void*)$var);
93T_X509
94 sv_setref_pv($arg, \"SSLeay::X509\", (void*)$var);
95
96
diff --git a/src/lib/libssl/src/perl/x509.txt b/src/lib/libssl/src/perl/x509.txt
new file mode 100644
index 0000000000..8468eff512
--- /dev/null
+++ b/src/lib/libssl/src/perl/x509.txt
@@ -0,0 +1,6 @@
1X509::new()
2
3X509::get_verson()
4X509::get_serial_number()
5X509::get_subject_name()
6X509::get_issuer_name()
diff --git a/src/lib/libssl/src/perl/x509.xs b/src/lib/libssl/src/perl/x509.xs
new file mode 100644
index 0000000000..67633ad225
--- /dev/null
+++ b/src/lib/libssl/src/perl/x509.xs
@@ -0,0 +1,74 @@
1#include "p5SSLeay.h"
2
3MODULE = SSLeay::X509 PACKAGE = SSLeay::X509 PREFIX = p5_X509_
4
5PROTOTYPES: ENABLE
6VERSIONCHECK: DISABLE
7
8void
9p5_X509_new(void )
10 PREINIT:
11 X509 *x509;
12 SV *arg;
13 PPCODE:
14 pr_name("p5_X509_new");
15 EXTEND(sp,1);
16 PUSHs(sv_newmortal());
17 x509=X509_new();
18 sv_setref_pv(ST(0),"SSLeay::X509",(void *)x509);
19
20char *
21p5_X509_get_subject_name(x509)
22 X509 *x509;
23 PREINIT:
24 char *p;
25 X509_NAME *name;
26 char buf[1024];
27 int i;
28 CODE:
29 name=X509_get_subject_name(x509);
30 X509_NAME_oneline(name,buf,sizeof(buf));
31 p= &(buf[0]);
32 RETVAL=p;
33 OUTPUT:
34 RETVAL
35
36char *
37p5_X509_get_issuer_name(x509)
38 X509 *x509;
39 PREINIT:
40 char *p;
41 X509_NAME *name;
42 char buf[1024];
43 int i;
44 CODE:
45 name=X509_get_issuer_name(x509);
46 X509_NAME_oneline(name,buf,sizeof(buf));
47 p= &(buf[0]);
48 RETVAL=p;
49 OUTPUT:
50 RETVAL
51
52int
53p5_X509_get_version(x509)
54 X509 *x509;
55 CODE:
56 RETVAL=X509_get_version(x509);
57 OUTPUT:
58 RETVAL
59
60BIGNUM *
61p5_X509_get_serialNumber(x509)
62 X509 *x509;
63 CODE:
64 RETVAL=ASN1_INTEGER_to_BN(X509_get_serialNumber(x509),NULL);
65 OUTPUT:
66 RETVAL
67
68void
69p5_X509_DESTROY(x509)
70 X509 *x509;
71 CODE:
72 pr_name("p5_X509_DESTROY");
73 X509_free(x509);
74
diff --git a/src/lib/libssl/src/perl/xstmp.c b/src/lib/libssl/src/perl/xstmp.c
new file mode 100644
index 0000000000..aa18959017
--- /dev/null
+++ b/src/lib/libssl/src/perl/xstmp.c
@@ -0,0 +1,102 @@
1/* perl/xstmp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58/*
59 * This file was generated automatically by xsubpp version 1.9402 from the
60 * contents of SSLeay.xs. Do not edit this file, edit SSLeay.xs instead.
61 *
62 * ANY CHANGES MADE HERE WILL BE LOST!
63 *
64 */
65
66#line 1 "SSLeay.xs"
67#ifdef __cplusplus
68extern "C" {
69#endif
70#include "EXTERN.h"
71#include "perl.h"
72#include "XSUB.h"
73#ifdef __cplusplus
74}
75#endif
76
77typedef struct datum_st
78 {
79 char *dptr;
80 int dsize;
81 } datum;
82
83#include "crypto.h"
84#include "buffer.h"
85#include "bio.h"
86#include "evp.h"
87#include "err.h"
88#include "x509.h"
89#include "ssl.h"
90
91#if 0
92#define pr_name(name) printf("%s\n",name)
93#define pr_name_d(name,p2) printf("%s %d\n",name,p2)
94#define pr_name_dd(name,p2,p3) printf("%s %d %d\n",name,p2,p3)
95#else
96#define pr_name(name)
97#define pr_name_d(name,p2)
98#define pr_name_dd(name,p2,p3)
99#endif
100
101#include "callback.c"
102
diff --git a/src/lib/libssl/src/perl/y.pl b/src/lib/libssl/src/perl/y.pl
new file mode 100644
index 0000000000..fe608a6724
--- /dev/null
+++ b/src/lib/libssl/src/perl/y.pl
@@ -0,0 +1,7 @@
1#!/usr/bin/perl
2use ExtUtils::testlib;
3use SSLeay;
4
5$message=SSLeay::BN::dec2bn("936345681743241125150760694794510965960940252288797108931456691368672287489405603308617928680920874760917824938589009714909675985261365549781893129784821682998948722");
6
7print $message->bn2hex."\n";
diff --git a/src/lib/libssl/src/perl/yy.pl b/src/lib/libssl/src/perl/yy.pl
new file mode 100644
index 0000000000..2e00edb3e9
--- /dev/null
+++ b/src/lib/libssl/src/perl/yy.pl
@@ -0,0 +1,19 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6
7$a=SSLeay::BN::new();
8
9$a+="1234567";
10
11print $a->bn2hex()."\n";
12
13
14for (1 .. 20)
15 {
16 $a*=$a;
17 $b=$a->bn2hex();
18 print " ".$b."\n".length($b)."\n";
19 }
diff --git a/src/lib/libssl/src/perl/z.pl b/src/lib/libssl/src/perl/z.pl
new file mode 100644
index 0000000000..7e2d5285cc
--- /dev/null
+++ b/src/lib/libssl/src/perl/z.pl
@@ -0,0 +1,32 @@
1#!/usr/bin/perl
2
3use ExtUtils::testlib;
4
5use SSLeay;
6use Benchmark;
7
8$buf=('x' x (1024*1024));
9$buf=('x' x (1024*1024));
10
11@md=();
12foreach $name ("md2", "mdc2", "sha", "ripemd160", "sha1", "md5")
13 {
14 if (($name eq "md2") || ($name eq "mdc2"))
15 { $num=5; }
16 else { $num=100; }
17
18 $t=timeit($num,'&hash($name)');
19 printf "%6d000 bytes/sec:$name\n",int(($num*1024*1024)/$t->[1]/1000);
20 }
21
22sub hash
23 {
24 my($name)=@_;
25 my($f,$digest);
26
27 ($f=MD->new($name)) ||
28 die "$_ is an unknown message digest algorithm\n";
29 $f->update($buf);
30 $digest=$f->final();
31 }
32
diff --git a/src/lib/libssl/src/perl/zz.pl b/src/lib/libssl/src/perl/zz.pl
new file mode 100644
index 0000000000..38866c9227
--- /dev/null
+++ b/src/lib/libssl/src/perl/zz.pl
@@ -0,0 +1,22 @@
1#!/usr/bin/perl
2use ExtUtils::testlib;
3use SSLeay;
4
5$a=SSLeay::BN::dec2bn("12345678901234567890");
6$b=SSLeay::BN::dec2bn("98765432109876543210");
7print "a=$a\n";
8print "b=$b\n";
9
10$n=$a*$b;
11$m=$n+"1223123235345634764534567889";
12$l=$m*88888888;
13
14$r=$l/$b;
15
16print "a=$a\n";
17print "b=$b\n";
18print "n=$n\n";
19print "m=$m\n";
20print "l=$l\n";
21print "r=$r\n";
22
diff --git a/src/lib/libssl/src/shlib/linux.sh b/src/lib/libssl/src/shlib/linux.sh
new file mode 100644
index 0000000000..f80292d90c
--- /dev/null
+++ b/src/lib/libssl/src/shlib/linux.sh
@@ -0,0 +1,76 @@
1#!/bin/sh
2
3echo "#define DATE \"`date`\"" >crypto/date.h
4
5major="0"
6minor="8.2"
7slib=libssl
8clib=libcrypto
9CC=gcc
10CPP='gcc -E'
11AS=as
12FLAGS='-DX86_ASM -DTERMIO -O3 -DL_ENDIAN -fomit-frame-pointer -m486 -Wall'
13#FLAGS='-DTERMIO -g2 -ggdb -DL_ENDIAN -m486 -Wall -DREF_CHECK -DCRYPTO_MDEBUG'
14INCLUDE='-Iinclude -Icrypto -Issl'
15SHFLAGS='-DPIC -fpic'
16
17CFLAGS="$FLAGS $INCLUDE $SHFLAGS"
18ASM_OBJ="";
19
20echo compiling bignum assember
21$CPP -DELF crypto/bn/asm/bn86unix.cpp | $AS -o bn_asm.o
22CFLAGS="$CFLAGS -DBN_ASM -DX86_ASM"
23ASM_OBJ="$ASM_OBJ bn_asm.o"
24
25echo compiling des assember
26$CPP -DELF crypto/des/asm/dx86unix.cpp | $AS -o des_enc.o
27$CPP -DELF crypto/des/asm/yx86unix.cpp | $AS -o fcrypt-b.o
28CFLAGS="$CFLAGS -DDES_ASM"
29ASM_OBJ="$ASM_OBJ des_enc.o fcrypt-b.o"
30
31echo compiling blowfish assember
32$CPP -DELF crypto/bf/asm/bx86unix.cpp | $AS -o bf_enc.o
33CFLAGS="$CFLAGS -DBF_ASM"
34ASM_OBJ="$ASM_OBJ bf_enc.o"
35
36echo compiling cast assember
37$CPP -DELF crypto/cast/asm/cx86unix.cpp | $AS -o cast_enc.o
38CFLAGS="$CFLAGS -DCAST_ASM"
39ASM_OBJ="$ASM_OBJ cast_enc.o"
40
41echo compiling rc4 assember
42$CPP -DELF crypto/rc4/asm/rx86unix.cpp | $AS -o rc4_enc.o
43CFLAGS="$CFLAGS -DRC4_ASM"
44ASM_OBJ="$ASM_OBJ rc4_enc.o"
45
46echo compiling md5 assember
47$CPP -DELF crypto/md5/asm/mx86unix.cpp | $AS -o md5_enc.o
48CFLAGS="$CFLAGS -DMD5_ASM"
49ASM_OBJ="$ASM_OBJ md5_enc.o"
50
51echo compiling sha1 assember
52$CPP -DELF crypto/sha/asm/sx86unix.cpp | $AS -o sha1_enc.o
53CFLAGS="$CFLAGS -DSHA1_ASM"
54ASM_OBJ="$ASM_OBJ sha1_enc.o"
55
56echo compiling $clib
57$CC -c $CFLAGS -DCFLAGS="\"$FLAGS\"" -o crypto.o crypto/crypto.c
58
59echo linking $clib.so
60gcc $CFLAGS -shared -Wl,-soname,$clib.so.$major -o $clib.so.$major.$minor crypto.o $ASM_OBJ
61/bin/rm -f $clib.so $clib.so.$major
62ln -s $clib.so.$major.$minor $clib.so
63ln -s $clib.so.$major.$minor $clib.so.$major
64
65echo compiling $slib.so
66$CC -c $CFLAGS -o ssl.o ssl/ssl.c
67
68echo building $slib.so
69gcc $CFLAGS -shared -Wl,-soname,$slib.so.$major -o $slib.so.$major.$minor ssl.o
70/bin/rm -f $slib.so $slib.so.$major
71ln -s $slib.so.$major.$minor $slib.so
72ln -s $slib.so.$major.$minor $slib.so.$major
73
74echo building ssleay executable
75gcc $CFLAGS -o ssleay apps/eay.c -L. -lssl -lcrypto
76
diff --git a/src/lib/libssl/src/ssl/Makefile.ssl b/src/lib/libssl/src/ssl/Makefile.ssl
new file mode 100644
index 0000000000..f4b13bf83b
--- /dev/null
+++ b/src/lib/libssl/src/ssl/Makefile.ssl
@@ -0,0 +1,100 @@
1#
2# SSLeay/ssl/Makefile
3#
4
5DIR= ssl
6TOP= ..
7CC= cc
8INCLUDES= -I../crypto -I../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14AR= ar r
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17
18ERR=ssl
19ERRC=ssl_err
20GENERAL=Makefile README
21TEST=ssltest.c
22APPS=
23
24LIB=$(TOP)/libssl.a
25LIBSRC= \
26 s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \
27 s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \
28 s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \
29 t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \
30 ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \
31 ssl_ciph.c ssl_stat.c ssl_rsa.c \
32 ssl_asn1.c ssl_txt.c ssl_algs.c \
33 bio_ssl.c $(ERRC).c
34LIBOBJ= \
35 s2_meth.o s2_srvr.o s2_clnt.o s2_lib.o s2_enc.o s2_pkt.o \
36 s3_meth.o s3_srvr.o s3_clnt.o s3_lib.o s3_enc.o s3_pkt.o s3_both.o \
37 s23_meth.o s23_srvr.o s23_clnt.o s23_lib.o s23_pkt.o \
38 t1_meth.o t1_srvr.o t1_clnt.o t1_lib.o t1_enc.o \
39 ssl_lib.o ssl_err2.o ssl_cert.o ssl_sess.o \
40 ssl_ciph.o ssl_stat.o ssl_rsa.o \
41 ssl_asn1.o ssl_txt.o ssl_algs.o \
42 bio_ssl.o $(ERRC).o
43
44SRC= $(LIBSRC)
45
46EXHEADER= ssl.h ssl2.h ssl3.h ssl23.h tls1.h
47HEADER= $(EXHEADER) ssl_locl.h
48
49ALL= $(GENERAL) $(SRC) $(HEADER)
50
51top:
52 (cd ..; $(MAKE) DIRS=$(DIR) all)
53
54all: lib
55
56lib: $(LIBOBJ)
57 $(AR) $(LIB) $(LIBOBJ)
58 sh $(TOP)/util/ranlib.sh $(LIB)
59 @touch lib
60
61files:
62 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
63
64links:
65 /bin/rm -f Makefile
66 $(TOP)/util/point.sh Makefile.ssl Makefile ;
67 $(TOP)/util/mklink.sh ../include $(EXHEADER)
68 $(TOP)/util/mklink.sh ../test $(TEST)
69 $(TOP)/util/mklink.sh ../apps $(APPS)
70
71install:
72 @for i in $(EXHEADER) ; \
73 do \
74 (cp $$i $(INSTALLTOP)/include/$$i; \
75 chmod 644 $(INSTALLTOP)/include/$$i ); \
76 done;
77
78tags:
79 ctags $(SRC)
80
81tests:
82
83lint:
84 lint -DLINT $(INCLUDES) $(SRC)>fluff
85
86depend:
87 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
88
89dclean:
90 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
91 mv -f Makefile.new $(MAKEFILE)
92
93clean:
94 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
95
96errors:
97 perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h
98 perl ../crypto/err/err_genc.pl -s $(ERR).h $(ERRC).c
99
100# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/ssl/readme b/src/lib/libssl/src/ssl/readme
new file mode 100644
index 0000000000..ca174848a1
--- /dev/null
+++ b/src/lib/libssl/src/ssl/readme
@@ -0,0 +1,277 @@
122 Jun 1996
2This file belongs in ../apps, but I'll leave it here because it deals
3with SSL :-) It is rather dated but it gives you an idea of how
4things work.
5===
6
717 Jul 1995
8I have been changing things quite a bit and have not fully updated
9this file, so take what you read with a grain of salt
10eric
11===
12The s_client and s_server programs can be used to test SSL capable
13IP/port addresses and the verification of the X509 certificates in use
14by these services. I strongly advise having a look at the code to get
15an idea of how to use the authentication under SSLeay. Any feedback
16on changes and improvements would be greatly accepted.
17
18This file will probably be gibberish unless you have read
19rfc1421, rfc1422, rfc1423 and rfc1424 which describe PEM
20authentication.
21
22A Brief outline (and examples) how to use them to do so.
23
24NOTE:
25The environment variable SSL_CIPER is used to specify the prefered
26cipher to use, play around with setting it's value to combinations of
27RC4-MD5, EXP-RC4-MD5, CBC-DES-MD5, CBC3-DES-MD5, CFB-DES-NULL
28in a : separated list.
29
30This directory contains 3 X509 certificates which can be used by these programs.
31client.pem: a file containing a certificate and private key to be used
32 by s_client.
33server.pem :a file containing a certificate and private key to be used
34 by s_server.
35eay1024.pem:the certificate used to sign client.pem and server.pem.
36 This would be your CA's certificate. There is also a link
37 from the file a8556381.0 to eay1024.PEM. The value a8556381
38 is returned by 'x509 -hash -noout <eay1024.pem' and is the
39 value used by X509 verification routines to 'find' this
40 certificte when search a directory for it.
41 [the above is not true any more, the CA cert is
42 ../certs/testca.pem which is signed by ../certs/mincomca.pem]
43
44When testing the s_server, you may get
45bind: Address already in use
46errors. These indicate the port is still being held by the unix
47kernel and you are going to have to wait for it to let go of it. If
48this is the case, remember to use the port commands on the s_server and
49s_client to talk on an alternative port.
50
51=====
52s_client.
53This program can be used to connect to any IP/hostname:port that is
54talking SSL. Once connected, it will attempt to authenticate the
55certificate it was passed and if everything works as expected, a 2
56directional channel will be open. Any text typed will be sent to the
57other end. type Q<cr> to exit. Flags are as follows.
58-host arg : Arg is the host or IP address to connect to.
59-port arg : Arg is the port to connect to (https is 443).
60-verify arg : Turn on authentication of the server certificate.
61 : Arg specifies the 'depth', this will covered below.
62-cert arg : The optional certificate to use. This certificate
63 : will be returned to the server if the server
64 : requests it for client authentication.
65-key arg : The private key that matches the certificate
66 : specified by the -cert option. If this is not
67 : specified (but -cert is), the -cert file will be
68 : searched for the Private key. Both files are
69 : assumed to be in PEM format.
70-CApath arg : When to look for certificates when 'verifying' the
71 : certificate from the server.
72-CAfile arg : A file containing certificates to be used for
73 : 'verifying' the server certificate.
74-reconnect : Once a connection has been made, drop it and
75 : reconnect with same session-id. This is for testing :-).
76
77The '-verify n' parameter specifies not only to verify the servers
78certificate but to also only take notice of 'n' levels. The best way
79to explain is to show via examples.
80Given
81s_server -cert server.PEM is running.
82
83s_client
84 CONNECTED
85 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server
86 issuer= /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
87 verify error:num=1:unable to get issuer certificate
88 verify return:1
89 CIPHER is CBC-DES-MD5
90What has happened is that the 'SSLeay demo server' certificate's
91issuer ('CA') could not be found but because verify is not on, we
92don't care and the connection has been made anyway. It is now 'up'
93using CBC-DES-MD5 mode. This is an unauthenticate secure channel.
94You may not be talking to the right person but the data going to them
95is encrypted.
96
97s_client -verify 0
98 CONNECTED
99 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server
100 issuer= /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
101 verify error:num=1:unable to get issuer certificate
102 verify return:1
103 CIPHER is CBC-DES-MD5
104We are 'verifying' but only to depth 0, so since the 'SSLeay demo server'
105certificate passed the date and checksum, we are happy to proceed.
106
107s_client -verify 1
108 CONNECTED
109 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server
110 issuer= /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
111 verify error:num=1:unable to get issuer certificate
112 verify return:0
113 ERROR
114 verify error:unable to get issuer certificate
115In this case we failed to make the connection because we could not
116authenticate the certificate because we could not find the
117'CA' certificate.
118
119s_client -verify 1 -CAfile eay1024.PEM
120 CONNECTED
121 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server
122 verify return:1
123 depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
124 verify return:1
125 CIPHER is CBC-DES-MD5
126We loaded the certificates from the file eay1024.PEM. Everything
127checked out and so we made the connection.
128
129s_client -verify 1 -CApath .
130 CONNECTED
131 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server
132 verify return:1
133 depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
134 verify return:1
135 CIPHER is CBC-DES-MD5
136We looked in out local directory for issuer certificates and 'found'
137a8556381.0 and so everything is ok.
138
139It is worth noting that 'CA' is a self certified certificate. If you
140are passed one of these, it will fail to 'verify' at depth 0 because
141we need to lookup the certifier of a certificate from some information
142that we trust and keep locally.
143
144SSL_CIPHER=CBC3-DES-MD5:RC4-MD5
145export SSL_CIPHER
146s_client -verify 10 -CApath . -reconnect
147 CONNECTED
148 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server
149 verify return:1
150 depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
151 verify return:1
152 drop the connection and reconnect with the same session id
153 CIPHER is CBC3-DES-MD5
154This has done a full connection and then re-estabished it with the
155same session id but a new socket. No RSA stuff occures on the second
156connection. Note that we said we would prefer to use CBC3-DES-MD5
157encryption and so, since the server supports it, we are.
158
159=====
160s_server
161This program accepts SSL connections on a specified port
162Once connected, it will estabish an SSL connection and optionaly
163attempt to authenticate the client. A 2 directional channel will be
164open. Any text typed will be sent to the other end. Type Q<cr> to exit.
165Flags are as follows.
166-port arg : Arg is the port to listen on.
167-verify arg : Turn on authentication of the client if they have a
168 : certificate. Arg specifies the 'depth'.
169-Verify arg : Turn on authentication of the client. If they don't
170 : have a valid certificate, drop the connection.
171-cert arg : The certificate to use. This certificate
172 : will be passed to the client. If it is not
173 : specified, it will default to server.PEM
174-key arg : The private key that matches the certificate
175 : specified by the -cert option. If this is not
176 : specified (but -cert is), the -cert file will be
177 : searched for the Private key. Both files are
178 : assumed to be in PEM format. Default is server.PEM
179-CApath arg : When to look for certificates when 'verifying' the
180 : certificate from the client.
181-CAfile arg : A file containing certificates to be used for
182 : 'verifying' the client certificate.
183
184For the following 'demo' I will specify the s_server command and
185the s_client command and then list the output from the s_server.
186s_server
187s_client
188 CONNECTED
189 CIPHER is CBC-DES-MD5
190Everything up and running
191
192s_server -verify 0
193s_client
194 CONNECTED
195 CIPHER is CBC-DES-MD5
196Ok since no certificate was returned and we don't care.
197
198s_server -verify 0
199./s_client -cert client.PEM
200 CONNECTED
201 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo client
202 issuer= /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
203 verify error:num=1:unable to get issuer certificate
204 verify return:1
205 CIPHER is CBC-DES-MD5
206Ok since we were only verifying to level 0
207
208s_server -verify 4
209s_client -cert client.PEM
210 CONNECTED
211 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo client
212 issuer= /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
213 verify error:num=1:unable to get issuer certificate
214 verify return:0
215 ERROR
216 verify error:unable to get issuer certificate
217Bad because we could not authenticate the returned certificate.
218
219s_server -verify 4 -CApath .
220s_client -cert client.PEM
221 CONNECTED
222 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo client
223 verify return:1
224 depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
225 verify return:1
226 CIPHER is CBC-DES-MD5
227Ok because we could authenticate the returned certificate :-).
228
229s_server -Verify 0 -CApath .
230s_client
231 CONNECTED
232 ERROR
233 SSL error:function is:REQUEST_CERTIFICATE
234 :error is :client end did not return a certificate
235Error because no certificate returned.
236
237s_server -Verify 4 -CApath .
238s_client -cert client.PEM
239 CONNECTED
240 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo client
241 verify return:1
242 depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
243 verify return:1
244 CIPHER is CBC-DES-MD5
245Full authentication of the client.
246
247So in summary to do full authentication of both ends
248s_server -Verify 9 -CApath .
249s_client -cert client.PEM -CApath . -verify 9
250From the server side
251 CONNECTED
252 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo client
253 verify return:1
254 depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
255 verify return:1
256 CIPHER is CBC-DES-MD5
257From the client side
258 CONNECTED
259 depth=0 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=SSLeay demo server
260 verify return:1
261 depth=1 /C=AU/SOP=QLD/O=Mincom Pty. Ltd./OU=CS/CN=CA
262 verify return:1
263 CIPHER is CBC-DES-MD5
264
265For general probing of the 'internet https' servers for the
266distribution area, run
267s_client -host www.netscape.com -port 443 -verify 4 -CApath ../rsa/hash
268Then enter
269GET /
270and you should be talking to the https server on that host.
271
272www.rsa.com was refusing to respond to connections on 443 when I was
273testing.
274
275have fun :-).
276
277eric
diff --git a/src/lib/libssl/src/ssl/ssl.c b/src/lib/libssl/src/ssl/ssl.c
new file mode 100644
index 0000000000..7f506ce48f
--- /dev/null
+++ b/src/lib/libssl/src/ssl/ssl.c
@@ -0,0 +1,172 @@
1/* ssl/ssl.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62
63#define USE_SOCKETS
64#include "../e_os.h"
65
66#include "buffer.h"
67#include "stack.h"
68#include "lhash.h"
69
70#include "bio.h"
71#include "err.h"
72
73#include "bn.h"
74
75#include "rand.h"
76#include "conf.h"
77#include "txt_db.h"
78
79#include "err.h"
80#include "evp.h"
81
82#include "x509.h"
83#include "pkcs7.h"
84#include "pem.h"
85#include "asn1.h"
86#include "objects.h"
87
88#include "ssl_locl.h"
89
90#if !(BUILD_SSLV23) && !defined(BUILD_SSLV2) && !defined(BUILD_SSLV3) && !defined(BUILD_SSL_COMMON) && !defined(BUILD_SSL_BIO) && !defined(BUILD_SSL_OPTIONAL)
91#define BUILD_SSLV23
92#define BUILD_SSLV2
93#define BUILD_SSLV3
94#define BUILD_TLS1
95#define BUILD_SSL_COMMON
96#define BUILD_SSL_BIO
97#define BUILD_SSL_OPTIONAL
98#endif
99
100#ifdef NO_RSA
101#undef BUILD_SSLV2
102#undef BUILD_SSLV23
103#endif
104
105#ifdef NO_SSL2
106#undef BUILD_SSLV2
107#undef BUILD_SSLV23
108#endif
109
110#ifdef NO_SSL3
111#undef BUILD_SSL3
112#undef BUILD_SSLV23
113#endif
114
115#ifdef BUILD_SSLV23
116#include "s23_clnt.c"
117#include "s23_srvr.c"
118#include "s23_pkt.c"
119#include "s23_lib.c"
120#include "s23_meth.c"
121#endif
122
123#ifdef BUILD_SSLV2
124#include "s2_clnt.c"
125#include "s2_srvr.c"
126#include "s2_pkt.c"
127#include "s2_enc.c"
128#include "s2_lib.c"
129#include "s2_meth.c"
130#endif
131
132#ifdef BUILD_SSLV3
133#include "s3_clnt.c"
134#include "s3_both.c"
135#include "s3_srvr.c"
136#include "s3_pkt.c"
137#include "s3_enc.c"
138#include "s3_lib.c"
139#include "s3_meth.c"
140#endif
141
142#ifdef BUILD_TLS1
143#include "t1_clnt.c"
144#include "t1_enc.c"
145#include "t1_lib.c"
146#include "t1_meth.c"
147#include "t1_srvr.c"
148#endif
149
150
151#ifdef BUILD_SSL_COMMON
152#include "ssl_lib.c"
153#include "ssl_algs.c"
154#include "ssl_cert.c"
155#include "ssl_ciph.c"
156#include "ssl_sess.c"
157#include "ssl_rsa.c"
158#endif
159
160/* Extra things */
161#ifdef BUILD_SSL_BIO
162#include "bio_ssl.c"
163#endif
164
165#ifdef BUILD_SSL_OPTIONAL
166#include "ssl_asn1.c"
167#include "ssl_txt.c"
168#include "ssl_stat.c"
169#include "ssl_err.c"
170#include "ssl_err2.c"
171#endif
172
diff --git a/src/lib/libssl/src/ssl/ssl.err b/src/lib/libssl/src/ssl/ssl.err
new file mode 100644
index 0000000000..c54326c624
--- /dev/null
+++ b/src/lib/libssl/src/ssl/ssl.err
@@ -0,0 +1,290 @@
1/* Error codes for the SSL functions. */
2
3/* Function codes. */
4#define SSL_F_CLIENT_CERTIFICATE 100
5#define SSL_F_CLIENT_HELLO 101
6#define SSL_F_CLIENT_MASTER_KEY 102
7#define SSL_F_D2I_SSL_SESSION 103
8#define SSL_F_DO_SSL3_WRITE 104
9#define SSL_F_GET_CLIENT_FINISHED 105
10#define SSL_F_GET_CLIENT_HELLO 106
11#define SSL_F_GET_CLIENT_MASTER_KEY 107
12#define SSL_F_GET_SERVER_FINISHED 108
13#define SSL_F_GET_SERVER_HELLO 109
14#define SSL_F_GET_SERVER_VERIFY 110
15#define SSL_F_I2D_SSL_SESSION 111
16#define SSL_F_READ_N 112
17#define SSL_F_REQUEST_CERTIFICATE 113
18#define SSL_F_SERVER_HELLO 114
19#define SSL_F_SSL23_ACCEPT 115
20#define SSL_F_SSL23_CLIENT_HELLO 116
21#define SSL_F_SSL23_CONNECT 117
22#define SSL_F_SSL23_GET_CLIENT_HELLO 118
23#define SSL_F_SSL23_GET_SERVER_HELLO 119
24#define SSL_F_SSL23_READ 120
25#define SSL_F_SSL23_WRITE 121
26#define SSL_F_SSL2_ACCEPT 122
27#define SSL_F_SSL2_CONNECT 123
28#define SSL_F_SSL2_ENC_INIT 124
29#define SSL_F_SSL2_READ 125
30#define SSL_F_SSL2_SET_CERTIFICATE 126
31#define SSL_F_SSL2_WRITE 127
32#define SSL_F_SSL3_ACCEPT 128
33#define SSL_F_SSL3_CHANGE_CIPHER_STATE 129
34#define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130
35#define SSL_F_SSL3_CLIENT_HELLO 131
36#define SSL_F_SSL3_CONNECT 132
37#define SSL_F_SSL3_CTX_CTRL 133
38#define SSL_F_SSL3_ENC 134
39#define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135
40#define SSL_F_SSL3_GET_CERT_VERIFY 136
41#define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137
42#define SSL_F_SSL3_GET_CLIENT_HELLO 138
43#define SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE 139
44#define SSL_F_SSL3_GET_FINISHED 140
45#define SSL_F_SSL3_GET_KEY_EXCHANGE 141
46#define SSL_F_SSL3_GET_MESSAGE 142
47#define SSL_F_SSL3_GET_RECORD 143
48#define SSL_F_SSL3_GET_SERVER_CERTIFICATE 144
49#define SSL_F_SSL3_GET_SERVER_DONE 145
50#define SSL_F_SSL3_GET_SERVER_HELLO 146
51#define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147
52#define SSL_F_SSL3_READ_BYTES 148
53#define SSL_F_SSL3_READ_N 149
54#define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST 150
55#define SSL_F_SSL3_SEND_CLIENT_CERTIFICATE 151
56#define SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE 152
57#define SSL_F_SSL3_SEND_CLIENT_VERIFY 153
58#define SSL_F_SSL3_SEND_SERVER_CERTIFICATE 154
59#define SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE 155
60#define SSL_F_SSL3_SETUP_BUFFERS 156
61#define SSL_F_SSL3_SETUP_KEY_BLOCK 157
62#define SSL_F_SSL3_WRITE_BYTES 158
63#define SSL_F_SSL3_WRITE_PENDING 159
64#define SSL_F_SSL_BAD_METHOD 160
65#define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161
66#define SSL_F_SSL_CERT_NEW 162
67#define SSL_F_SSL_CHECK_PRIVATE_KEY 163
68#define SSL_F_SSL_CREATE_CIPHER_LIST 164
69#define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 165
70#define SSL_F_SSL_CTX_NEW 166
71#define SSL_F_SSL_CTX_SET_SSL_VERSION 167
72#define SSL_F_SSL_CTX_USE_CERTIFICATE 168
73#define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 169
74#define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 170
75#define SSL_F_SSL_CTX_USE_PRIVATEKEY 171
76#define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 172
77#define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 173
78#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 174
79#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 175
80#define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 176
81#define SSL_F_SSL_DO_HANDSHAKE 177
82#define SSL_F_SSL_GET_NEW_SESSION 178
83#define SSL_F_SSL_GET_SERVER_SEND_CERT 179
84#define SSL_F_SSL_GET_SIGN_PKEY 180
85#define SSL_F_SSL_INIT_WBIO_BUFFER 181
86#define SSL_F_SSL_LOAD_CLIENT_CA_FILE 182
87#define SSL_F_SSL_NEW 183
88#define SSL_F_SSL_RSA_PRIVATE_DECRYPT 184
89#define SSL_F_SSL_RSA_PUBLIC_ENCRYPT 185
90#define SSL_F_SSL_SESSION_NEW 186
91#define SSL_F_SSL_SESSION_PRINT_FP 187
92#define SSL_F_SSL_SET_CERT 188
93#define SSL_F_SSL_SET_FD 189
94#define SSL_F_SSL_SET_PKEY 190
95#define SSL_F_SSL_SET_RFD 191
96#define SSL_F_SSL_SET_SESSION 192
97#define SSL_F_SSL_SET_WFD 193
98#define SSL_F_SSL_UNDEFINED_FUNCTION 194
99#define SSL_F_SSL_USE_CERTIFICATE 195
100#define SSL_F_SSL_USE_CERTIFICATE_ASN1 196
101#define SSL_F_SSL_USE_CERTIFICATE_FILE 197
102#define SSL_F_SSL_USE_PRIVATEKEY 198
103#define SSL_F_SSL_USE_PRIVATEKEY_ASN1 199
104#define SSL_F_SSL_USE_PRIVATEKEY_FILE 200
105#define SSL_F_SSL_USE_RSAPRIVATEKEY 201
106#define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 202
107#define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 203
108#define SSL_F_SSL_WRITE 204
109#define SSL_F_TLS1_CHANGE_CIPHER_STATE 205
110#define SSL_F_TLS1_ENC 206
111#define SSL_F_TLS1_SETUP_KEY_BLOCK 207
112#define SSL_F_WRITE_PENDING 208
113
114/* Reason codes. */
115#define SSL_R_APP_DATA_IN_HANDSHAKE 100
116#define SSL_R_BAD_ALERT_RECORD 101
117#define SSL_R_BAD_AUTHENTICATION_TYPE 102
118#define SSL_R_BAD_CHANGE_CIPHER_SPEC 103
119#define SSL_R_BAD_CHECKSUM 104
120#define SSL_R_BAD_CLIENT_REQUEST 105
121#define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106
122#define SSL_R_BAD_DECOMPRESSION 107
123#define SSL_R_BAD_DH_G_LENGTH 108
124#define SSL_R_BAD_DH_PUB_KEY_LENGTH 109
125#define SSL_R_BAD_DH_P_LENGTH 110
126#define SSL_R_BAD_DIGEST_LENGTH 111
127#define SSL_R_BAD_DSA_SIGNATURE 112
128#define SSL_R_BAD_MAC_DECODE 113
129#define SSL_R_BAD_MESSAGE_TYPE 114
130#define SSL_R_BAD_PACKET_LENGTH 115
131#define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116
132#define SSL_R_BAD_RESPONSE_ARGUMENT 117
133#define SSL_R_BAD_RSA_DECRYPT 118
134#define SSL_R_BAD_RSA_ENCRYPT 119
135#define SSL_R_BAD_RSA_E_LENGTH 120
136#define SSL_R_BAD_RSA_MODULUS_LENGTH 121
137#define SSL_R_BAD_RSA_SIGNATURE 122
138#define SSL_R_BAD_SIGNATURE 123
139#define SSL_R_BAD_SSL_FILETYPE 124
140#define SSL_R_BAD_SSL_SESSION_ID_LENGTH 125
141#define SSL_R_BAD_STATE 126
142#define SSL_R_BAD_WRITE_RETRY 127
143#define SSL_R_BIO_NOT_SET 128
144#define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129
145#define SSL_R_BN_LIB 130
146#define SSL_R_CA_DN_LENGTH_MISMATCH 131
147#define SSL_R_CA_DN_TOO_LONG 132
148#define SSL_R_CCS_RECEIVED_EARLY 133
149#define SSL_R_CERTIFICATE_VERIFY_FAILED 134
150#define SSL_R_CERT_LENGTH_MISMATCH 135
151#define SSL_R_CHALLENGE_IS_DIFFERENT 136
152#define SSL_R_CIPHER_CODE_WRONG_LENGTH 137
153#define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 138
154#define SSL_R_CIPHER_TABLE_SRC_ERROR 139
155#define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140
156#define SSL_R_COMPRESSION_FAILURE 141
157#define SSL_R_CONNECTION_ID_IS_DIFFERENT 142
158#define SSL_R_CONNECTION_TYPE_NOT_SET 143
159#define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 144
160#define SSL_R_DATA_LENGTH_TOO_LONG 145
161#define SSL_R_DECRYPTION_FAILED 146
162#define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 147
163#define SSL_R_DIGEST_CHECK_FAILED 148
164#define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 149
165#define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 150
166#define SSL_R_EXCESSIVE_MESSAGE_SIZE 151
167#define SSL_R_EXTRA_DATA_IN_MESSAGE 152
168#define SSL_R_GOT_A_FIN_BEFORE_A_CCS 153
169#define SSL_R_HTTPS_PROXY_REQUEST 154
170#define SSL_R_HTTP_REQUEST 155
171#define SSL_R_INTERNAL_ERROR 156
172#define SSL_R_INVALID_CHALLENGE_LENGTH 157
173#define SSL_R_LENGTH_MISMATCH 158
174#define SSL_R_LENGTH_TOO_SHORT 159
175#define SSL_R_LIBRARY_HAS_NO_CIPHERS 160
176#define SSL_R_MISSING_DH_DSA_CERT 161
177#define SSL_R_MISSING_DH_KEY 162
178#define SSL_R_MISSING_DH_RSA_CERT 163
179#define SSL_R_MISSING_DSA_SIGNING_CERT 164
180#define SSL_R_MISSING_EXPORT_TMP_DH_KEY 165
181#define SSL_R_MISSING_EXPORT_TMP_RSA_KEY 166
182#define SSL_R_MISSING_RSA_CERTIFICATE 167
183#define SSL_R_MISSING_RSA_ENCRYPTING_CERT 168
184#define SSL_R_MISSING_RSA_SIGNING_CERT 169
185#define SSL_R_MISSING_TMP_DH_KEY 170
186#define SSL_R_MISSING_TMP_RSA_KEY 171
187#define SSL_R_MISSING_TMP_RSA_PKEY 172
188#define SSL_R_MISSING_VERIFY_MESSAGE 173
189#define SSL_R_NON_SSLV2_INITIAL_PACKET 174
190#define SSL_R_NO_CERTIFICATES_RETURNED 175
191#define SSL_R_NO_CERTIFICATE_ASSIGNED 176
192#define SSL_R_NO_CERTIFICATE_RETURNED 177
193#define SSL_R_NO_CERTIFICATE_SET 178
194#define SSL_R_NO_CERTIFICATE_SPECIFIED 179
195#define SSL_R_NO_CIPHERS_AVAILABLE 180
196#define SSL_R_NO_CIPHERS_PASSED 181
197#define SSL_R_NO_CIPHERS_SPECIFIED 182
198#define SSL_R_NO_CIPHER_LIST 183
199#define SSL_R_NO_CIPHER_MATCH 184
200#define SSL_R_NO_CLIENT_CERT_RECEIVED 185
201#define SSL_R_NO_COMPRESSION_SPECIFIED 186
202#define SSL_R_NO_PRIVATEKEY 187
203#define SSL_R_NO_PRIVATE_KEY_ASSIGNED 188
204#define SSL_R_NO_PROTOCOLS_AVAILABLE 189
205#define SSL_R_NO_PUBLICKEY 190
206#define SSL_R_NO_SHARED_CIPHER 191
207#define SSL_R_NULL_SSL_CTX 192
208#define SSL_R_NULL_SSL_METHOD_PASSED 193
209#define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 194
210#define SSL_R_PACKET_LENGTH_TOO_LONG 195
211#define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 196
212#define SSL_R_PEER_ERROR 197
213#define SSL_R_PEER_ERROR_CERTIFICATE 198
214#define SSL_R_PEER_ERROR_NO_CERTIFICATE 199
215#define SSL_R_PEER_ERROR_NO_CIPHER 200
216#define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 201
217#define SSL_R_PRE_MAC_LENGTH_TOO_LONG 202
218#define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS 203
219#define SSL_R_PROTOCOL_IS_SHUTDOWN 204
220#define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR 205
221#define SSL_R_PUBLIC_KEY_IS_NOT_RSA 206
222#define SSL_R_PUBLIC_KEY_NOT_RSA 207
223#define SSL_R_READ_BIO_NOT_SET 208
224#define SSL_R_READ_WRONG_PACKET_TYPE 209
225#define SSL_R_RECORD_LENGTH_MISMATCH 210
226#define SSL_R_RECORD_TOO_LARGE 211
227#define SSL_R_REQUIRED_CIPHER_MISSING 212
228#define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO 213
229#define SSL_R_REUSE_CERT_TYPE_NOT_ZERO 214
230#define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO 215
231#define SSL_R_SHORT_READ 216
232#define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 217
233#define SSL_R_SSL3_SESSION_ID_TOO_SHORT 218
234#define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042
235#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020
236#define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045
237#define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044
238#define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046
239#define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030
240#define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040
241#define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047
242#define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041
243#define SSL_R_SSLV3_ALERT_PEER_ERROR_CERTIFICATE 219
244#define SSL_R_SSLV3_ALERT_PEER_ERROR_NO_CERTIFICATE 220
245#define SSL_R_SSLV3_ALERT_PEER_ERROR_NO_CIPHER 221
246#define SSL_R_SSLV3_ALERT_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 222
247#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010
248#define SSL_R_SSLV3_ALERT_UNKNOWN_REMOTE_ERROR_TYPE 223
249#define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043
250#define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 224
251#define SSL_R_SSL_HANDSHAKE_FAILURE 225
252#define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 226
253#define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 227
254#define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 228
255#define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 229
256#define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 230
257#define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER 231
258#define SSL_R_UNABLE_TO_DECODE_DH_CERTS 232
259#define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY 233
260#define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS 234
261#define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 235
262#define SSL_R_UNABLE_TO_FIND_SSL_METHOD 236
263#define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES 237
264#define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 238
265#define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 239
266#define SSL_R_UNEXPECTED_MESSAGE 240
267#define SSL_R_UNEXPECTED_RECORD 241
268#define SSL_R_UNKNOWN_ALERT_TYPE 242
269#define SSL_R_UNKNOWN_CERTIFICATE_TYPE 243
270#define SSL_R_UNKNOWN_CIPHER_RETURNED 244
271#define SSL_R_UNKNOWN_CIPHER_TYPE 245
272#define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 246
273#define SSL_R_UNKNOWN_PKEY_TYPE 247
274#define SSL_R_UNKNOWN_PROTOCOL 248
275#define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE 249
276#define SSL_R_UNKNOWN_SSL_VERSION 250
277#define SSL_R_UNKNOWN_STATE 251
278#define SSL_R_UNSUPPORTED_CIPHER 252
279#define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 253
280#define SSL_R_UNSUPPORTED_PROTOCOL 254
281#define SSL_R_UNSUPPORTED_SSL_VERSION 255
282#define SSL_R_WRITE_BIO_NOT_SET 256
283#define SSL_R_WRONG_CIPHER_RETURNED 257
284#define SSL_R_WRONG_MESSAGE_TYPE 258
285#define SSL_R_WRONG_NUMBER_OF_KEY_BITS 259
286#define SSL_R_WRONG_SIGNATURE_LENGTH 260
287#define SSL_R_WRONG_SIGNATURE_SIZE 261
288#define SSL_R_WRONG_SSL_VERSION 262
289#define SSL_R_WRONG_VERSION_NUMBER 263
290#define SSL_R_X509_LIB 264
diff --git a/src/lib/libssl/src/test/.rnd b/src/lib/libssl/src/test/.rnd
new file mode 100644
index 0000000000..234970e241
--- /dev/null
+++ b/src/lib/libssl/src/test/.rnd
Binary files differ
diff --git a/src/lib/libssl/src/test/Makefile.ssl b/src/lib/libssl/src/test/Makefile.ssl
new file mode 100644
index 0000000000..b3de76751e
--- /dev/null
+++ b/src/lib/libssl/src/test/Makefile.ssl
@@ -0,0 +1,294 @@
1#
2# test/Makefile.ssl
3#
4
5DIR= test
6TOP= ..
7CC= cc
8INCLUDES= -I../include
9CFLAG= -g
10INSTALLTOP= /usr/local/ssl
11MAKEFILE= Makefile.ssl
12MAKE= make -f $(MAKEFILE)
13MAKEDEPEND= makedepend -f$(MAKEFILE)
14
15PEX_LIBS=
16EX_LIBS= #-lnsl -lsocket
17
18CFLAGS= $(INCLUDES) $(CFLAG)
19
20GENERAL=Makefile.ssl
21
22DLIBCRYPTO= ../libcrypto.a
23DLIBSSL= ../libssl.a
24LIBCRYPTO= -L.. -lcrypto
25LIBSSL= -L.. -lssl
26
27BNTEST= bntest
28EXPTEST= exptest
29IDEATEST= ideatest
30SHATEST= shatest
31SHA1TEST= sha1test
32MDC2TEST= mdc2test
33RMDTEST= rmdtest
34MD2TEST= md2test
35MD5TEST= md5test
36HMACTEST= hmactest
37RC2TEST= rc2test
38RC4TEST= rc4test
39RC5TEST= rc5test
40BFTEST= bftest
41CASTTEST= casttest
42DESTEST= destest
43RANDTEST= randtest
44DHTEST= dhtest
45DSATEST= dsatest
46METHTEST= methtest
47SSLTEST= ssltest
48
49EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \
50 $(RC2TEST) $(RC4TEST) $(RC5TEST) \
51 $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \
52 $(RANDTEST) $(DHTEST) \
53 $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST)
54
55# $(METHTEST)
56
57OBJ= $(BNTEST).o $(IDEATEST).o $(MD2TEST).o $(MD5TEST).o $(HMACTEST).o \
58 $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \
59 $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \
60 $(RANDTEST).o $(DHTEST).o $(CASTTEST).o \
61 $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o
62SRC= $(BNTEST).c $(IDEATEST).c $(MD2TEST).c $(MD5TEST).c $(HMACTEST).c \
63 $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \
64 $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \
65 $(RANDTEST).c $(DHTEST).c $(CASTTEST).c \
66 $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c
67
68EXHEADER=
69HEADER= $(EXHEADER)
70
71ALL= $(GENERAL) $(SRC) $(HEADER)
72
73top:
74 (cd ..; $(MAKE) DIRS=$(DIR) all)
75
76all: exe
77
78exe: $(EXE)
79
80files:
81 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
82
83links:
84 /bin/rm -f Makefile
85 $(TOP)/util/point.sh Makefile.ssl Makefile ;
86
87errors:
88
89install:
90
91tags:
92 ctags $(SRC)
93
94tests: exe apps \
95 test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \
96 test_rc2 test_rc4 test_rc5 test_bf test_cast \
97 test_rand test_enc test_x509 test_rsa test_crl test_sid test_req \
98 test_pkcs7 test_bn test_verify test_dh test_dsa test_reqgen \
99 test_ss test_ssl test_ca
100
101apps:
102 @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all)
103
104test_des:
105 #./$(DESTEST)
106
107test_idea:
108 ./$(IDEATEST)
109
110test_sha:
111 ./$(SHATEST)
112 ./$(SHA1TEST)
113
114test_mdc2:
115 ./$(MDC2TEST)
116
117test_md5:
118 ./$(MD5TEST)
119
120test_hmac:
121 ./$(HMACTEST)
122
123test_md2:
124 ./$(MD2TEST)
125
126test_rmd:
127 ./$(RMDTEST)
128
129test_bf:
130 ./$(BFTEST)
131
132test_cast:
133 ./$(CASTTEST)
134
135test_rc2:
136 ./$(RC2TEST)
137
138test_rc4:
139 ./$(RC4TEST)
140
141test_rc5:
142 ./$(RC5TEST)
143
144test_rand:
145 ./$(RANDTEST)
146
147test_enc:
148 @sh ./testenc
149
150test_x509:
151 echo test normal x509v1 certificate
152 sh ./tx509 2>/dev/null
153 echo test first x509v3 certificate
154 sh ./tx509 v3-cert1.pem 2>/dev/null
155 echo test second x509v3 certificate
156 sh ./tx509 v3-cert2.pem 2>/dev/null
157
158test_rsa:
159 @sh ./trsa 2>/dev/null
160
161test_crl:
162 @sh ./tcrl 2>/dev/null
163
164test_sid:
165 @sh ./tsid 2>/dev/null
166
167test_req:
168 @sh ./treq 2>/dev/null
169 @sh ./treq testreq2.pem 2>/dev/null
170
171test_pkcs7:
172 @sh ./tpkcs7 2>/dev/null
173 @sh ./tpkcs7d 2>/dev/null
174
175test_bn:
176 @echo 'test a^b%c implementations'
177 ./$(EXPTEST)
178 @echo starting big number library test, could take a while...
179 @(./$(BNTEST)|bc) | awk '{ \
180if ($$0 != "0") {print "error"; exit(1); } \
181if (((NR+1)%64) == 0) print NR+1," tests done"; }'
182
183test_verify:
184 @echo "The following command should have some OK's and some failures"
185 @echo "There are definitly a few expired certificates"
186 ../apps/ssleay verify -CApath ../certs ../certs/*.pem
187
188test_dh:
189 @echo "Generate as set of DH parameters"
190 ./$(DHTEST)
191
192test_dsa:
193 @echo "Generate as set of DSA parameters"
194 ./$(DSATEST)
195
196test_reqgen:
197 @echo "Generate and verify a certificate request"
198 @sh ./testgen
199
200test_ss:
201 @echo "Generate and certify a test certificate"
202 @sh ./testss
203
204test_ssl:
205 @echo "test SSL protocol"
206 @sh ./testssl
207
208test_ca:
209 @echo "Generate and certify a test certificate via the 'ca' program"
210 @sh ./testca
211
212lint:
213 lint -DLINT $(INCLUDES) $(SRC)>fluff
214
215depend:
216 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(SRC)
217
218dclean:
219 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
220 mv -f Makefile.new $(MAKEFILE)
221
222clean:
223 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log
224
225$(DLIBSSL):
226 (cd ../ssl; $(MAKE))
227
228$(DLIBCRYPTO):
229 (cd ../crypto; $(MAKE))
230
231$(BNTEST): $(BNTEST).o $(DLIBCRYPTO)
232 $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
233
234$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO)
235 $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
236
237$(IDEATEST): $(IDEATEST).o $(DLIBCRYPTO)
238 $(CC) -o $(IDEATEST) $(CFLAGS) $(IDEATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
239
240$(MD2TEST): $(MD2TEST).o $(DLIBCRYPTO)
241 $(CC) -o $(MD2TEST) $(CFLAGS) $(MD2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
242
243$(SHATEST): $(SHATEST).o $(DLIBCRYPTO)
244 $(CC) -o $(SHATEST) $(CFLAGS) $(SHATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
245
246$(SHA1TEST): $(SHA1TEST).o $(DLIBCRYPTO)
247 $(CC) -o $(SHA1TEST) $(CFLAGS) $(SHA1TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
248
249$(RMDTEST): $(RMDTEST).o $(DLIBCRYPTO)
250 $(CC) -o $(RMDTEST) $(CFLAGS) $(RMDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
251
252$(MDC2TEST): $(MDC2TEST).o $(DLIBCRYPTO)
253 $(CC) -o $(MDC2TEST) $(CFLAGS) $(MDC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
254
255$(MD5TEST): $(MD5TEST).o $(DLIBCRYPTO)
256 $(CC) -o $(MD5TEST) $(CFLAGS) $(MD5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
257
258$(HMACTEST): $(HMACTEST).o $(DLIBCRYPTO)
259 $(CC) -o $(HMACTEST) $(CFLAGS) $(HMACTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
260
261$(RC2TEST): $(RC2TEST).o $(DLIBCRYPTO)
262 $(CC) -o $(RC2TEST) $(CFLAGS) $(RC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
263
264$(BFTEST): $(BFTEST).o $(DLIBCRYPTO)
265 $(CC) -o $(BFTEST) $(CFLAGS) $(BFTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
266
267$(CASTTEST): $(CASTTEST).o $(DLIBCRYPTO)
268 $(CC) -o $(CASTTEST) $(CFLAGS) $(CASTTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
269
270$(RC4TEST): $(RC4TEST).o $(DLIBCRYPTO)
271 $(CC) -o $(RC4TEST) $(CFLAGS) $(RC4TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
272
273$(RC5TEST): $(RC5TEST).o $(DLIBCRYPTO)
274 $(CC) -o $(RC5TEST) $(CFLAGS) $(RC5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
275
276$(DESTEST): $(DESTEST).o $(DLIBCRYPTO)
277 $(CC) -o $(DESTEST) $(CFLAGS) $(DESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
278
279$(RANDTEST): $(RANDTEST).o $(DLIBCRYPTO)
280 $(CC) -o $(RANDTEST) $(CFLAGS) $(RANDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
281
282$(DHTEST): $(DHTEST).o $(DLIBCRYPTO)
283 $(CC) -o $(DHTEST) $(CFLAGS) $(DHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
284
285$(DSATEST): $(DSATEST).o $(DLIBCRYPTO)
286 $(CC) -o $(DSATEST) $(CFLAGS) $(DSATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
287
288$(METHTEST): $(METHTEST).o $(DLIBCRYPTO)
289 $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
290
291$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO)
292 $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS)
293
294# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/test/certCA.srl b/src/lib/libssl/src/test/certCA.srl
new file mode 100644
index 0000000000..39f5b69311
--- /dev/null
+++ b/src/lib/libssl/src/test/certCA.srl
@@ -0,0 +1 @@
71
diff --git a/src/lib/libssl/src/test/demoCA/index.txt b/src/lib/libssl/src/test/demoCA/index.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/src/lib/libssl/src/test/demoCA/index.txt
diff --git a/src/lib/libssl/src/test/demoCA/private/cakey.pem b/src/lib/libssl/src/test/demoCA/private/cakey.pem
new file mode 100644
index 0000000000..edd5a5773f
--- /dev/null
+++ b/src/lib/libssl/src/test/demoCA/private/cakey.pem
@@ -0,0 +1,2 @@
1-----BEGIN RSA PRIVATE KEY-----
2-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libssl/src/test/demoCA/serial b/src/lib/libssl/src/test/demoCA/serial
new file mode 100644
index 0000000000..8a0f05e166
--- /dev/null
+++ b/src/lib/libssl/src/test/demoCA/serial
@@ -0,0 +1 @@
01
diff --git a/src/lib/libssl/src/test/dsa-ca.pem b/src/lib/libssl/src/test/dsa-ca.pem
new file mode 100644
index 0000000000..9eb08f3ddd
--- /dev/null
+++ b/src/lib/libssl/src/test/dsa-ca.pem
@@ -0,0 +1,43 @@
1-----BEGIN DSA PRIVATE KEY-----
2Proc-Type: 4,ENCRYPTED
3DEK-Info: DES-EDE3-CBC,C5B6C7CC9E1FE2C0
4
5svCXBcBRhMuU22UXOfiKZA+thmz6KYXpt1Yg5Rd+TYQcQ1MdvNy0B0tkP1SxzDq0
6Xh1eMeTML9/9/0rKakgNXXXbpi5RB8t6BmwRSyej89F7nn1mtR3qzoyPRpp15SDl
7Tn67C+2v+HDF3MFk88hiNCYkNbcmi7TWvChsl8N1r7wdZwtIox56yXdgxw6ZIpa/
8par0oUCzN7fiavPgCWz1kfPNSaBQSdxwH7TZi5tMHAr0J3C7a7QRnZfE09R59Uqr
9zslrq+ndIw1BZAxoY0SlBu+iFOVaBVlwToC4AsHkv7j7l8ITtr7f42YbBa44D9TO
10uOhONmkk/v3Fso4RaOEzdKZC+hnmmzvHs6TiTWm6yzJgSFwyOUK0eGmKEeVxpcH5
11rUOlHOwzen+FFtocZDZAfdFnb7QY7L/boQvyA5A+ZbRG4DUpmBQeQsSaICHM5Rxx
121QaLF413VNPXTLPbW0ilSc2H8x2iZTIVKfd33oSO6NhXPtSYQgfecEF4BvNHY5c4
13HovjT4mckbK95bcBzoCHu43vuSQkmZzdYo/ydSZt6zoPavbBLueTpgSbdXiDi827
14MVqOsYxGCb+kez0FoDSTgw==
15-----END DSA PRIVATE KEY-----
16-----BEGIN CERTIFICATE REQUEST-----
17MIICUjCCAhECAQAwUjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
18ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDELMAkGA1UEAxMCQ0Ew
19ggG0MIIBKQYFKw4DAgwwggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaW
20sxXgUy6P4FmCc5A+dTGZR3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5m
21rmuINvvsKNzC16W75Sw5JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHk
22cJVbUM1JAhUA9wcx7fpsBgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVo
23bzDjaeHls12YuyiGSPzemQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqR
24CZ228U2cVA9YBu5JdAfOVX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxB
25F5WS6wG1c6Vqftgy7Q4CuAOBhAACgYAapll6iqz9XrZFlk2GCVcB+KihxWnH7IuH
26vSLw9YUrJahcBHmbpvt494lF4gC5w3WPM+vXJofbusk4GoQEEsQNMDaah4m49uUq
27AylOVFJJJXuirVJ+o+0TtOFDITEAl+YZZariXOD7tdOSOl9RLMPC6+daHKS9e68u
283enxhqnDGaAAMAkGBSsOAwIbBQADMAAwLQIVAJGVuFsG/0DBuSZ0jF7ypdU0/G0v
29AhQfeF5BoMMDbX/kidUVpQ6gadPlZA==
30-----END CERTIFICATE REQUEST-----
31-----BEGIN CERTIFICATE-----
32MIIBrjCCAWwCAQswCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
33U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww
34CgYDVQQDEwNQQ0EwHhcNOTcwNjE1MDIxNDI5WhcNOTcwNzE1MDIxNDI5WjBSMQsw
35CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
36ZXQgV2lkZ2l0cyBQdHkgTHRkMQswCQYDVQQDEwJDQTCBkjAJBgUrDgMCDAUAA4GE
37AAKBgBqmWXqKrP1etkWWTYYJVwH4qKHFacfsi4e9IvD1hSslqFwEeZum+3j3iUXi
38ALnDdY8z69cmh9u6yTgahAQSxA0wNpqHibj25SoDKU5UUkkle6KtUn6j7RO04UMh
39MQCX5hllquJc4Pu105I6X1Esw8Lr51ocpL17ry7d6fGGqcMZMAkGBSsOAwIbBQAD
40MQAwLgIVAJ4wtQsANPxHo7Q4IQZYsL12SKdbAhUAjJ9n38zxT+iai2164xS+LIfa
41C1Q=
42-----END CERTIFICATE-----
43
diff --git a/src/lib/libssl/src/test/dsa-pca.pem b/src/lib/libssl/src/test/dsa-pca.pem
new file mode 100644
index 0000000000..e3641ad47e
--- /dev/null
+++ b/src/lib/libssl/src/test/dsa-pca.pem
@@ -0,0 +1,49 @@
1-----BEGIN DSA PRIVATE KEY-----
2Proc-Type: 4,ENCRYPTED
3DEK-Info: DES-EDE3-CBC,F80EEEBEEA7386C4
4
5GZ9zgFcHOlnhPoiSbVi/yXc9mGoj44A6IveD4UlpSEUt6Xbse3Fr0KHIUyQ3oGnS
6mClKoAp/eOTb5Frhto85SzdsxYtac+X1v5XwdzAMy2KowHVk1N8A5jmE2OlkNPNt
7of132MNlo2cyIRYaa35PPYBGNCmUm7YcYS8O90YtkrQZZTf4+2C4kllhMcdkQwkr
8FWSWC8YOQ7w0LHb4cX1FejHHom9Nd/0PN3vn3UyySvfOqoR7nbXkrpHXmPIr0hxX
9RcF0aXcV/CzZ1/nfXWQf4o3+oD0T22SDoVcZY60IzI0oIc3pNCbDV3uKNmgekrFd
10qOUJ+QW8oWp7oefRx62iBfIeC8DZunohMXaWAQCU0sLQOR4yEdeUCnzCSywe0bG1
11diD0KYaEe+Yub1BQH4aLsBgDjardgpJRTQLq0DUvw0/QGO1irKTJzegEDNVBKrVn
12V4AHOKT1CUKqvGNRP1UnccUDTF6miOAtaj/qpzra7sSk7dkGBvIEeFoAg84kfh9h
13hVvF1YyzC9bwZepruoqoUwke/WdNIR5ymOVZ/4Liw0JdIOcq+atbdRX08niqIRkf
14dsZrUj4leo3zdefYUQ7w4N2Ns37yDFq7
15-----END DSA PRIVATE KEY-----
16-----BEGIN CERTIFICATE REQUEST-----
17MIICVTCCAhMCAQAwUzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
18ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEMMAoGA1UEAxMDUENB
19MIIBtTCCASkGBSsOAwIMMIIBHgKBgQCnP26Fv0FqKX3wn0cZMJCaCR3aajMexT2G
20lrMV4FMuj+BZgnOQPnUxmUd6UvuF5NmmezibaIqEm4fGHrV+hktTW1nPcWUZiG7O
21Zq5riDb77Cjcwtelu+UsOSZL2ppwGJU3lRBWI/YV7boEXt45T/23Qx+1pGVvzYAR
225HCVW1DNSQIVAPcHMe36bAYD1YWKHKycZedQZmVvAoGATd9MA6aRivUZb1BGJZnl
23aG8w42nh5bNdmLsohkj83pkEP1+IDJxzJA0gXbkqmj8YlifkYofBe3RiU/xhJ6h6
24kQmdtvFNnFQPWAbuSXQHzlV+I84W9srcWmEBfslxtU323DQph2j2XiCTs9v15Als
25QReVkusBtXOlan7YMu0OArgDgYUAAoGBAKbtuR5AdW+ICjCFe2ixjUiJJzM2IKwe
266NZEMXg39+HQ1UTPTmfLZLps+rZfolHDXuRKMXbGFdSF0nXYzotPCzi7GauwEJTZ
27yr27ZZjA1C6apGSQ9GzuwNvZ4rCXystVEagAS8OQ4H3D4dWS17Zg31ICb5o4E5r0
28z09o/Uz46u0VoAAwCQYFKw4DAhsFAAMxADAuAhUArRubTxsbIXy3AhtjQ943AbNB
29nSICFQCu+g1iW3jwF+gOcbroD4S/ZcvB3w==
30-----END CERTIFICATE REQUEST-----
31-----BEGIN CERTIFICATE-----
32MIIC0zCCApECAQAwCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
33U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww
34CgYDVQQDEwNQQ0EwHhcNOTcwNjE0MjI1NDQ1WhcNOTcwNzE0MjI1NDQ1WjBTMQsw
35CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
36ZXQgV2lkZ2l0cyBQdHkgTHRkMQwwCgYDVQQDEwNQQ0EwggG1MIIBKQYFKw4DAgww
37ggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaWsxXgUy6P4FmCc5A+dTGZ
38R3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5mrmuINvvsKNzC16W75Sw5
39JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHkcJVbUM1JAhUA9wcx7fps
40BgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVobzDjaeHls12YuyiGSPze
41mQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqRCZ228U2cVA9YBu5JdAfO
42VX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxBF5WS6wG1c6Vqftgy7Q4C
43uAOBhQACgYEApu25HkB1b4gKMIV7aLGNSIknMzYgrB7o1kQxeDf34dDVRM9OZ8tk
44umz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQlNnKvbtlmMDULpqkZJD0bO7A
4529nisJfKy1URqABLw5DgfcPh1ZLXtmDfUgJvmjgTmvTPT2j9TPjq7RUwCQYFKw4D
46AhsFAAMxADAuAhUAvtv6AkMolix1Jvy3UnVEIUqdCUICFQC+jq8P49mwrY9oJ24n
475rKUjNBhSg==
48-----END CERTIFICATE-----
49
diff --git a/src/lib/libssl/src/test/p b/src/lib/libssl/src/test/p
new file mode 100644
index 0000000000..b3de76751e
--- /dev/null
+++ b/src/lib/libssl/src/test/p
@@ -0,0 +1,294 @@
1#
2# test/Makefile.ssl
3#
4
5DIR= test
6TOP= ..
7CC= cc
8INCLUDES= -I../include
9CFLAG= -g
10INSTALLTOP= /usr/local/ssl
11MAKEFILE= Makefile.ssl
12MAKE= make -f $(MAKEFILE)
13MAKEDEPEND= makedepend -f$(MAKEFILE)
14
15PEX_LIBS=
16EX_LIBS= #-lnsl -lsocket
17
18CFLAGS= $(INCLUDES) $(CFLAG)
19
20GENERAL=Makefile.ssl
21
22DLIBCRYPTO= ../libcrypto.a
23DLIBSSL= ../libssl.a
24LIBCRYPTO= -L.. -lcrypto
25LIBSSL= -L.. -lssl
26
27BNTEST= bntest
28EXPTEST= exptest
29IDEATEST= ideatest
30SHATEST= shatest
31SHA1TEST= sha1test
32MDC2TEST= mdc2test
33RMDTEST= rmdtest
34MD2TEST= md2test
35MD5TEST= md5test
36HMACTEST= hmactest
37RC2TEST= rc2test
38RC4TEST= rc4test
39RC5TEST= rc5test
40BFTEST= bftest
41CASTTEST= casttest
42DESTEST= destest
43RANDTEST= randtest
44DHTEST= dhtest
45DSATEST= dsatest
46METHTEST= methtest
47SSLTEST= ssltest
48
49EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \
50 $(RC2TEST) $(RC4TEST) $(RC5TEST) \
51 $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \
52 $(RANDTEST) $(DHTEST) \
53 $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST)
54
55# $(METHTEST)
56
57OBJ= $(BNTEST).o $(IDEATEST).o $(MD2TEST).o $(MD5TEST).o $(HMACTEST).o \
58 $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \
59 $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \
60 $(RANDTEST).o $(DHTEST).o $(CASTTEST).o \
61 $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o
62SRC= $(BNTEST).c $(IDEATEST).c $(MD2TEST).c $(MD5TEST).c $(HMACTEST).c \
63 $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \
64 $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \
65 $(RANDTEST).c $(DHTEST).c $(CASTTEST).c \
66 $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c
67
68EXHEADER=
69HEADER= $(EXHEADER)
70
71ALL= $(GENERAL) $(SRC) $(HEADER)
72
73top:
74 (cd ..; $(MAKE) DIRS=$(DIR) all)
75
76all: exe
77
78exe: $(EXE)
79
80files:
81 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
82
83links:
84 /bin/rm -f Makefile
85 $(TOP)/util/point.sh Makefile.ssl Makefile ;
86
87errors:
88
89install:
90
91tags:
92 ctags $(SRC)
93
94tests: exe apps \
95 test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \
96 test_rc2 test_rc4 test_rc5 test_bf test_cast \
97 test_rand test_enc test_x509 test_rsa test_crl test_sid test_req \
98 test_pkcs7 test_bn test_verify test_dh test_dsa test_reqgen \
99 test_ss test_ssl test_ca
100
101apps:
102 @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all)
103
104test_des:
105 #./$(DESTEST)
106
107test_idea:
108 ./$(IDEATEST)
109
110test_sha:
111 ./$(SHATEST)
112 ./$(SHA1TEST)
113
114test_mdc2:
115 ./$(MDC2TEST)
116
117test_md5:
118 ./$(MD5TEST)
119
120test_hmac:
121 ./$(HMACTEST)
122
123test_md2:
124 ./$(MD2TEST)
125
126test_rmd:
127 ./$(RMDTEST)
128
129test_bf:
130 ./$(BFTEST)
131
132test_cast:
133 ./$(CASTTEST)
134
135test_rc2:
136 ./$(RC2TEST)
137
138test_rc4:
139 ./$(RC4TEST)
140
141test_rc5:
142 ./$(RC5TEST)
143
144test_rand:
145 ./$(RANDTEST)
146
147test_enc:
148 @sh ./testenc
149
150test_x509:
151 echo test normal x509v1 certificate
152 sh ./tx509 2>/dev/null
153 echo test first x509v3 certificate
154 sh ./tx509 v3-cert1.pem 2>/dev/null
155 echo test second x509v3 certificate
156 sh ./tx509 v3-cert2.pem 2>/dev/null
157
158test_rsa:
159 @sh ./trsa 2>/dev/null
160
161test_crl:
162 @sh ./tcrl 2>/dev/null
163
164test_sid:
165 @sh ./tsid 2>/dev/null
166
167test_req:
168 @sh ./treq 2>/dev/null
169 @sh ./treq testreq2.pem 2>/dev/null
170
171test_pkcs7:
172 @sh ./tpkcs7 2>/dev/null
173 @sh ./tpkcs7d 2>/dev/null
174
175test_bn:
176 @echo 'test a^b%c implementations'
177 ./$(EXPTEST)
178 @echo starting big number library test, could take a while...
179 @(./$(BNTEST)|bc) | awk '{ \
180if ($$0 != "0") {print "error"; exit(1); } \
181if (((NR+1)%64) == 0) print NR+1," tests done"; }'
182
183test_verify:
184 @echo "The following command should have some OK's and some failures"
185 @echo "There are definitly a few expired certificates"
186 ../apps/ssleay verify -CApath ../certs ../certs/*.pem
187
188test_dh:
189 @echo "Generate as set of DH parameters"
190 ./$(DHTEST)
191
192test_dsa:
193 @echo "Generate as set of DSA parameters"
194 ./$(DSATEST)
195
196test_reqgen:
197 @echo "Generate and verify a certificate request"
198 @sh ./testgen
199
200test_ss:
201 @echo "Generate and certify a test certificate"
202 @sh ./testss
203
204test_ssl:
205 @echo "test SSL protocol"
206 @sh ./testssl
207
208test_ca:
209 @echo "Generate and certify a test certificate via the 'ca' program"
210 @sh ./testca
211
212lint:
213 lint -DLINT $(INCLUDES) $(SRC)>fluff
214
215depend:
216 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(SRC)
217
218dclean:
219 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
220 mv -f Makefile.new $(MAKEFILE)
221
222clean:
223 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log
224
225$(DLIBSSL):
226 (cd ../ssl; $(MAKE))
227
228$(DLIBCRYPTO):
229 (cd ../crypto; $(MAKE))
230
231$(BNTEST): $(BNTEST).o $(DLIBCRYPTO)
232 $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
233
234$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO)
235 $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
236
237$(IDEATEST): $(IDEATEST).o $(DLIBCRYPTO)
238 $(CC) -o $(IDEATEST) $(CFLAGS) $(IDEATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
239
240$(MD2TEST): $(MD2TEST).o $(DLIBCRYPTO)
241 $(CC) -o $(MD2TEST) $(CFLAGS) $(MD2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
242
243$(SHATEST): $(SHATEST).o $(DLIBCRYPTO)
244 $(CC) -o $(SHATEST) $(CFLAGS) $(SHATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
245
246$(SHA1TEST): $(SHA1TEST).o $(DLIBCRYPTO)
247 $(CC) -o $(SHA1TEST) $(CFLAGS) $(SHA1TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
248
249$(RMDTEST): $(RMDTEST).o $(DLIBCRYPTO)
250 $(CC) -o $(RMDTEST) $(CFLAGS) $(RMDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
251
252$(MDC2TEST): $(MDC2TEST).o $(DLIBCRYPTO)
253 $(CC) -o $(MDC2TEST) $(CFLAGS) $(MDC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
254
255$(MD5TEST): $(MD5TEST).o $(DLIBCRYPTO)
256 $(CC) -o $(MD5TEST) $(CFLAGS) $(MD5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
257
258$(HMACTEST): $(HMACTEST).o $(DLIBCRYPTO)
259 $(CC) -o $(HMACTEST) $(CFLAGS) $(HMACTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
260
261$(RC2TEST): $(RC2TEST).o $(DLIBCRYPTO)
262 $(CC) -o $(RC2TEST) $(CFLAGS) $(RC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
263
264$(BFTEST): $(BFTEST).o $(DLIBCRYPTO)
265 $(CC) -o $(BFTEST) $(CFLAGS) $(BFTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
266
267$(CASTTEST): $(CASTTEST).o $(DLIBCRYPTO)
268 $(CC) -o $(CASTTEST) $(CFLAGS) $(CASTTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
269
270$(RC4TEST): $(RC4TEST).o $(DLIBCRYPTO)
271 $(CC) -o $(RC4TEST) $(CFLAGS) $(RC4TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
272
273$(RC5TEST): $(RC5TEST).o $(DLIBCRYPTO)
274 $(CC) -o $(RC5TEST) $(CFLAGS) $(RC5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
275
276$(DESTEST): $(DESTEST).o $(DLIBCRYPTO)
277 $(CC) -o $(DESTEST) $(CFLAGS) $(DESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
278
279$(RANDTEST): $(RANDTEST).o $(DLIBCRYPTO)
280 $(CC) -o $(RANDTEST) $(CFLAGS) $(RANDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
281
282$(DHTEST): $(DHTEST).o $(DLIBCRYPTO)
283 $(CC) -o $(DHTEST) $(CFLAGS) $(DHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
284
285$(DSATEST): $(DSATEST).o $(DLIBCRYPTO)
286 $(CC) -o $(DSATEST) $(CFLAGS) $(DSATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
287
288$(METHTEST): $(METHTEST).o $(DLIBCRYPTO)
289 $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
290
291$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO)
292 $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS)
293
294# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/test/riptest b/src/lib/libssl/src/test/riptest
new file mode 100644
index 0000000000..8685d0ce53
--- /dev/null
+++ b/src/lib/libssl/src/test/riptest
Binary files differ
diff --git a/src/lib/libssl/src/test/test.txt b/src/lib/libssl/src/test/test.txt
new file mode 100644
index 0000000000..c6d8d50ba9
--- /dev/null
+++ b/src/lib/libssl/src/test/test.txt
@@ -0,0 +1,31 @@
1#!/bin/sh
2
3test=./test.txt
4
5cat $0 >$test;
6
7for i in rc4 des-cfb des-ofb des-ecb des-cbc des-ede des-ede3 \
8 des-cbc-ede des-cbc-ede3 idea-ecb idea-cfb idea-ofb idea-cbc
9do
10 echo $i
11 ../apps/ssleay $i -e -k test < $test > $test.$i.cipher
12 ../apps/ssleay $i -d -k test < $test.$i.cipher >$test.$i.clear
13 cmp $test $test.$i.clear
14 if [ $? != 0 ]
15 then
16 exit 1
17 else
18 /bin/rm $test.$i.cipher $test.$i.clear
19 fi
20
21 echo $i base64
22 ../apps/ssleay $i -a -e -k test < $test > $test.$i.cipher
23 ../apps/ssleay $i -a -d -k test < $test.$i.cipher >$test.$i.clear
24 cmp $test $test.$i.clear
25 if [ $? != 0 ]
26 then
27 exit 1
28 else
29 /bin/rm $test.$i.cipher $test.$i.clear
30 fi
31done
diff --git a/src/lib/libssl/src/test/testkey.pem b/src/lib/libssl/src/test/testkey.pem
new file mode 100644
index 0000000000..edd5a5773f
--- /dev/null
+++ b/src/lib/libssl/src/test/testkey.pem
@@ -0,0 +1,2 @@
1-----BEGIN RSA PRIVATE KEY-----
2-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libssl/src/test/testreq.pem b/src/lib/libssl/src/test/testreq.pem
new file mode 100644
index 0000000000..1311fa7785
--- /dev/null
+++ b/src/lib/libssl/src/test/testreq.pem
@@ -0,0 +1,9 @@
1-----BEGIN CERTIFICATE REQUEST-----
2MIIBQjCB7QIBADCBhzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx
3ETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDET
4MBEGA1UEAxMKRXJpYyBZb3VuZzEfMB0GCSqGSIb3DQEJARYQZWF5QG1pbmNvbS5v
5ei5hdTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDVKdT5QB2ZojtNQGjA/9J7s2o4
6RNkuSq8l377uWLAyMljtdkcoRsvUy5lZ997UDHFTbVFA038ZBrmw7l5EyHeXAgMB
7AAGgADANBgkqhkiG9w0BAQQFAANBAKnaFr4u7PTdfmpjiX/H8Ho4UWGVRWUlvD2R
8/D9yoTj7TN3uODx2BD0drErVBe/Zjv81vhH6Yo3cJO/hRS3A7jw=
9-----END CERTIFICATE REQUEST-----
diff --git a/src/lib/libssl/src/tools/Makefile.ssl b/src/lib/libssl/src/tools/Makefile.ssl
new file mode 100644
index 0000000000..537e97d268
--- /dev/null
+++ b/src/lib/libssl/src/tools/Makefile.ssl
@@ -0,0 +1,54 @@
1#
2# SSLeay/tools/Makefile
3#
4
5DIR= tools
6TOP= ..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG=-g
10INSTALLTOP=/usr/local/ssl
11MAKE= make -f Makefile.ssl
12MAKEDEPEND= makedepend -f Makefile.ssl
13MAKEFILE= Makefile.ssl
14
15CFLAGS= $(INCLUDES) $(CFLAG)
16
17GENERAL=Makefile.ssl
18TEST=
19APPS= c_hash c_info c_issuer c_name c_rehash
20
21all:
22
23install:
24 @for i in $(APPS) ; \
25 do \
26 (cp $$i $(INSTALLTOP)/bin/$$i; \
27 chmod 755 $(INSTALLTOP)/bin/$$i ); \
28 done;
29
30files:
31 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
32
33links:
34 /bin/rm -f Makefile
35 $(TOP)/util/point.sh Makefile.ssl Makefile ;
36
37lint:
38
39tags:
40
41errors:
42
43depend:
44
45dclean:
46 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
47 mv -f Makefile.new $(MAKEFILE)
48
49clean:
50 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
51
52errors:
53
54# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/src/util/mklink.sh b/src/lib/libssl/src/util/mklink.sh
new file mode 100644
index 0000000000..1e052ed6ee
--- /dev/null
+++ b/src/lib/libssl/src/util/mklink.sh
@@ -0,0 +1,35 @@
1#!/bin/sh
2#
3# A bit of an ugly shell script used to actually 'link' files.
4# Used by 'make links'
5#
6
7PATH=$PATH:.:util:../util:../../util
8export PATH
9
10from=$1
11shift
12
13here=`pwd`
14tmp=`dirname $from`
15while [ "$tmp"x != "x" -a "$tmp"x != ".x" ]
16do
17 t=`basename $here`
18 here=`dirname $here`
19 to="/$t$to"
20 tmp=`dirname $tmp`
21done
22to=..$to
23
24#echo from=$from
25#echo to =$to
26#exit 1
27
28if [ "$*"x != "x" ]; then
29 for i in $*
30 do
31 /bin/rm -f $from/$i
32 point.sh $to/$i $from/$i
33 done
34fi
35exit 0;
diff --git a/src/lib/libssl/src/util/ranlib.sh b/src/lib/libssl/src/util/ranlib.sh
new file mode 100644
index 0000000000..543f712c6b
--- /dev/null
+++ b/src/lib/libssl/src/util/ranlib.sh
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3cwd=`pwd`
4cd /tmp
5
6if [ -s /bin/ranlib ] ; then
7 RL=/bin/ranlib
8else if [ -s /usr/bin/ranlib ] ; then
9 RL=/usr/bin/ranlib
10fi
11fi
12
13if [ "x$RL" != "x" ]
14then
15 case "$1" in
16 /*)
17 $RL "$1"
18 ;;
19 *)
20 $RL "$cwd/$1"
21 ;;
22 esac
23fi
diff --git a/src/lib/libssl/src/util/sep_lib.sh b/src/lib/libssl/src/util/sep_lib.sh
new file mode 100644
index 0000000000..2348db874e
--- /dev/null
+++ b/src/lib/libssl/src/util/sep_lib.sh
@@ -0,0 +1,37 @@
1#!/bin/sh
2
3cwd=`pwd`
4/bin/rm -fr tmp/*
5
6cd crypto/des
7make -f Makefile.uni tar
8make -f Makefile.uni tar_lit
9/bin/mv libdes.tgz $cwd/tmp
10/bin/mv libdes-l.tgz $cwd/tmp
11cd $cwd
12
13for name in md5 sha cast bf idea rc4 rc2
14do
15 echo doing $name
16 (cd crypto; tar cfh - $name)|(cd tmp; tar xf -)
17 cd tmp/$name
18 /bin/rm -f Makefile
19 /bin/rm -f Makefile.ssl
20 /bin/rm -f Makefile.ssl.orig
21 /bin/rm -f *.old
22 /bin/mv Makefile.uni Makefile
23
24 cp $cwd/util/ranlib.sh .
25 chmod +x ranlib.sh
26
27 if [ -d asm ]; then
28 mkdir asm/perlasm
29 cp $cwd/crypto/perlasm/*.pl asm/perlasm
30 fi
31 cd ..
32 tar cf - $name|gzip >$name.tgz
33# /bin/rm -fr $name
34 cd $cwd
35done
36
37
diff --git a/src/lib/libssl/src/util/ssldir.pl b/src/lib/libssl/src/util/ssldir.pl
new file mode 100644
index 0000000000..10584686da
--- /dev/null
+++ b/src/lib/libssl/src/util/ssldir.pl
@@ -0,0 +1,52 @@
1#!/usr/bin/perl
2
3$#ARGV == 0 || die "usage: ssldir.pl /new/path\n";
4@files=('crypto/cryptlib.h',
5 'Makefile.ssl',
6 'tools/c_rehash',
7 'util/mk1mf.pl',
8 );
9
10%cryptlib=(
11 '\sX509_CERT_AREA\s',"#define X509_CERT_AREA\t\t".'"%s"',
12 '\sX509_CERT_DIR\s', "#define X509_CERT_DIR\t\t".'"%s/certs"',
13 '\sX509_CERT_FILE\s', "#define X509_CERT_FILE\t\t".'"%s/cert.pem"',
14 '\sX509_PRIVATE_DIR\s',"#define X509_PRIVATE_DIR\t".'"%s/private"',
15 );
16
17%Makefile_ssl=(
18 '^INSTALLTOP=','INSTALLTOP=%s',
19 );
20
21%c_rehash=(
22 '^DIR=', 'DIR=%s',
23 );
24
25%mk1mf=(
26 '^$INSTALLTOP=','$INSTALLTOP="%s";',
27 );
28
29&dofile("crypto/cryptlib.h",$ARGV[0],%cryptlib);
30&dofile("Makefile.ssl",$ARGV[0],%Makefile_ssl);
31&dofile("tools/c_rehash",$ARGV[0],%c_rehash);
32&dofile("util/mk1mf.pl",$ARGV[0],%mk1mf);
33
34sub dofile
35 {
36 ($f,$p,%m)=@_;
37
38 open(IN,"<$f") || die "unable to open $f:$!\n";
39 @a=<IN>;
40 close(IN);
41 foreach $k (keys %m)
42 {
43 grep(/$k/ && ($_=sprintf($m{$k}."\n",$p)),@a);
44 }
45 ($ff=$f) =~ s/\..*$//;
46 open(OUT,">$ff.new") || die "unable to open $f:$!\n";
47 print OUT @a;
48 close(OUT);
49 rename($f,"$ff.old") || die "unable to rename $f\n";
50 rename("$ff.new",$f) || die "unable to rename $ff.new\n";
51 }
52
diff --git a/src/lib/libssl/src/util/up_ver.pl b/src/lib/libssl/src/util/up_ver.pl
new file mode 100644
index 0000000000..32c086b2aa
--- /dev/null
+++ b/src/lib/libssl/src/util/up_ver.pl
@@ -0,0 +1,79 @@
1#!/usr/bin/perl
2#
3# Up the version numbers in the files.
4#
5
6@files=(
7 "crypto/crypto.h",
8 "crypto/des/ecb_enc.c",
9 "crypto/idea/i_ecb.c",
10 "crypto/lhash/lhash.c",
11 "crypto/conf/conf.c",
12 "crypto/md2/md2_dgst.c",
13 "crypto/md5/md5_dgst.c",
14 "crypto/ripemd/rmd_dgst.c",
15 "crypto/pem/pem_lib.c",
16 "crypto/bn/bn_lib.c",
17 "crypto/dh/dh_lib.c",
18 "crypto/rc2/rc2_ecb.c",
19 "crypto/rc4/rc4_skey.c",
20 "crypto/rc5/rc5_ecb.c",
21 "crypto/bf/bf_ecb.c",
22 "crypto/cast/c_ecb.c",
23 "crypto/rsa/rsa_lib.c",
24 "crypto/dsa/dsa_lib.c",
25 "crypto/sha/sha1dgst.c",
26 "crypto/sha/sha_dgst.c",
27 "crypto/asn1/asn1_lib.c",
28 "crypto/x509/x509_vfy.c",
29 "crypto/evp/evp_enc.c",
30 "crypto/rand/md_rand.c",
31 "crypto/stack/stack.c",
32 "crypto/txt_db/txt_db.c",
33 "crypto/cversion.c",
34 "ssl/ssl_lib.c",
35 "ssl/s2_lib.c",
36 "ssl/s3_lib.c",
37 "ssl/t1_lib.c",
38 "README",
39 );
40
41@month=('Jan','Feb','Mar','Apr','May','Jun',
42 'Jul','Aug','Sep','Oct','Nov','Dec');
43@a=localtime(time());
44$time=sprintf("%02d-%s-%04d",$a[3],$month[$a[4]],$a[5]+1900);
45
46$ver=$ARGV[0];
47($ver ne "") || die "no version number specified\n";
48($a,$b,$c,$d)=unpack('axaxac',$ver);
49$d=defined($d)?$d-96:0;
50$xver=sprintf("%x%x%x%x",$a,$b,$c,$d);
51
52foreach $file (@files)
53 {
54 open(IN,"<$file") || die "unable to open $file:$!\n";
55 open(OUT,">$file.new") || die "unable to open $file.new:$!\n";
56 $found=0;
57
58 print STDERR "$file:";
59
60 while (<IN>)
61 {
62 if ((s/SSLeay \d\.\d.\d[^"]*(\"|\s)/SSLeay $ver $time\1/) ||
63 s/^(\#define\s+SSLEAY_VERSION_NUMBER\s+0x)[0-9a-zA-Z]+(.*)$/$1$xver$2/)
64 {
65 print STDERR " Done";
66 $found++;
67 print OUT;
68 while (<IN>) { print OUT; }
69 last;
70 }
71 print OUT;
72 }
73 print STDERR "\n";
74 close(IN);
75 close(OUT);
76 (!$found) && die "unable to update the version number in $file\n";
77 rename($file,"$file.old") || die "unable to rename $file:$!\n";
78 rename("$file.new",$file) || die "unable to rename $file.new:$!\n";
79 }
diff --git a/src/lib/libssl/ssl-patent/Makefile b/src/lib/libssl/ssl-patent/Makefile
new file mode 100644
index 0000000000..3816de81ea
--- /dev/null
+++ b/src/lib/libssl/ssl-patent/Makefile
@@ -0,0 +1,90 @@
1
2LIB= ssl
3
4SSLEAYDIST= src-patent
5
6LSSL_SRC= ${.CURDIR}/../${SSLEAYDIST}/ssl
7LCRYPTO_SRC= ${.CURDIR}/../${SSLEAYDIST}/crypto
8
9.if ${MACHINE_ARCH} == "i386"
10CFLAGS+= -DL_ENDIAN -DBN_ASM
11.else
12.if ${MACHINE} == "arc"
13CFLAGS+= -DL_ENDIAN
14.else
15.if ${MACHINE} == "galileo"
16CFLAGS+= -DL_ENDIAN
17.else
18.if ${MACHINE} == "pmax"
19CFLAGS+= -DL_ENDIAN
20.else
21.if ${MACHINE_ARCH} == "alpha"
22# no ENDIAN stuff defined for alpha
23.else
24CFLAGS+= -DB_ENDIAN
25.endif
26.endif
27.endif
28.endif
29.endif
30
31CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE
32CFLAGS+= -I${.CURDIR}/../${SSLEAYDIST}
33CFLAGS+= -I${LSSL_SRC} -I${LCRYPTO_SRC}
34CFLAGS+= -I${LCRYPTO_SRC}/md2
35CFLAGS+= -I${LCRYPTO_SRC}/md5
36CFLAGS+= -I${LCRYPTO_SRC}/sha
37CFLAGS+= -I${LCRYPTO_SRC}/mdc2
38CFLAGS+= -I${LCRYPTO_SRC}/hmac
39CFLAGS+= -I${LCRYPTO_SRC}/ripemd
40CFLAGS+= -I${LCRYPTO_SRC}/des
41CFLAGS+= -I${LCRYPTO_SRC}/rc2
42CFLAGS+= -I${LCRYPTO_SRC}/rc4
43CFLAGS+= -I${LCRYPTO_SRC}/rc5
44CFLAGS+= -I${LCRYPTO_SRC}/idea
45CFLAGS+= -I${LCRYPTO_SRC}/bf
46CFLAGS+= -I${LCRYPTO_SRC}/cast
47CFLAGS+= -I${LCRYPTO_SRC}/bn
48CFLAGS+= -I${LCRYPTO_SRC}/rsa
49CFLAGS+= -I${LCRYPTO_SRC}/dsa
50CFLAGS+= -I${LCRYPTO_SRC}/dh
51CFLAGS+= -I${LCRYPTO_SRC}/buffer
52CFLAGS+= -I${LCRYPTO_SRC}/bio
53CFLAGS+= -I${LCRYPTO_SRC}/stack
54CFLAGS+= -I${LCRYPTO_SRC}/lhash
55CFLAGS+= -I${LCRYPTO_SRC}/rand
56CFLAGS+= -I${LCRYPTO_SRC}/err
57CFLAGS+= -I${LCRYPTO_SRC}/objects
58CFLAGS+= -I${LCRYPTO_SRC}/evp
59CFLAGS+= -I${LCRYPTO_SRC}/pem
60CFLAGS+= -I${LCRYPTO_SRC}/asn1
61CFLAGS+= -I${LCRYPTO_SRC}/x509
62CFLAGS+= -I${LCRYPTO_SRC}/conf
63CFLAGS+= -I${LCRYPTO_SRC}/txt_db
64CFLAGS+= -I${LCRYPTO_SRC}/pkcs7
65
66SRCS= s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \
67 s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \
68 s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \
69 t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \
70 ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \
71 ssl_ciph.c ssl_stat.c ssl_rsa.c \
72 ssl_asn1.c ssl_txt.c ssl_algs.c \
73 bio_ssl.c ssl_err.c
74
75HDRS= ssl.h ssl2.h ssl3.h ssl23.h tls1.h
76
77.PATH: ${LSSL_SRC}
78
79includes:
80 @test -d ${DESTDIR}/usr/include/ssl || mkdir ${DESTDIR}/usr/include/ssl
81 @cd ${LSSL_SRC}; for i in $(HDRS); do \
82 j="cmp -s $$i ${DESTDIR}/usr/include/ssl/`basename $$i` || \
83 ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
84 $$i ${DESTDIR}/usr/include/ssl"; \
85 echo $$j; \
86 eval "$$j"; \
87 done
88
89
90.include <bsd.lib.mk>
diff --git a/src/lib/libssl/ssl-patent/shlib_version b/src/lib/libssl/ssl-patent/shlib_version
new file mode 100644
index 0000000000..893819d18f
--- /dev/null
+++ b/src/lib/libssl/ssl-patent/shlib_version
@@ -0,0 +1,2 @@
1major=1
2minor=1
diff --git a/src/lib/libssl/ssl/Makefile b/src/lib/libssl/ssl/Makefile
new file mode 100644
index 0000000000..7a2b6da6e0
--- /dev/null
+++ b/src/lib/libssl/ssl/Makefile
@@ -0,0 +1,90 @@
1
2LIB= ssl
3
4SSLEAYDIST= src
5
6LSSL_SRC= ${.CURDIR}/../${SSLEAYDIST}/ssl
7LCRYPTO_SRC= ${.CURDIR}/../${SSLEAYDIST}/crypto
8
9.if ${MACHINE_ARCH} == "i386"
10CFLAGS+= -DL_ENDIAN -DBN_ASM
11.else
12.if ${MACHINE_ARCH} == "arc"
13CFLAGS+= -DL_ENDIAN
14.else
15.if ${MACHINE_ARCH} == "pmax"
16CFLAGS+= -DL_ENDIAN
17.else
18.if ${MACHINE_ARCH} == "alpha"
19# no ENDIAN stuff defined for alpha
20.else
21CFLAGS+= -DB_ENDIAN
22.endif
23.endif
24.endif
25.endif
26
27CFLAGS+= -DNO_IDEA -DTERMIOS -DANSI_SOURCE
28CFLAGS+= -I${.CURDIR}/../${SSLEAYDIST}
29CFLAGS+= -I${LSSL_SRC} -I${LCRYPTO_SRC}
30CFLAGS+= -I${LCRYPTO_SRC}/md2
31CFLAGS+= -I${LCRYPTO_SRC}/md5
32CFLAGS+= -I${LCRYPTO_SRC}/sha
33CFLAGS+= -I${LCRYPTO_SRC}/mdc2
34CFLAGS+= -I${LCRYPTO_SRC}/hmac
35CFLAGS+= -I${LCRYPTO_SRC}/ripemd
36CFLAGS+= -I${LCRYPTO_SRC}/des
37CFLAGS+= -I${LCRYPTO_SRC}/rc2
38CFLAGS+= -I${LCRYPTO_SRC}/rc4
39CFLAGS+= -I${LCRYPTO_SRC}/rc5
40CFLAGS+= -I${LCRYPTO_SRC}/idea
41CFLAGS+= -I${LCRYPTO_SRC}/bf
42CFLAGS+= -I${LCRYPTO_SRC}/cast
43CFLAGS+= -I${LCRYPTO_SRC}/bn
44CFLAGS+= -I${LCRYPTO_SRC}/rsa
45CFLAGS+= -I${LCRYPTO_SRC}/dsa
46CFLAGS+= -I${LCRYPTO_SRC}/dh
47CFLAGS+= -I${LCRYPTO_SRC}/buffer
48CFLAGS+= -I${LCRYPTO_SRC}/bio
49CFLAGS+= -I${LCRYPTO_SRC}/stack
50CFLAGS+= -I${LCRYPTO_SRC}/lhash
51CFLAGS+= -I${LCRYPTO_SRC}/rand
52CFLAGS+= -I${LCRYPTO_SRC}/err
53CFLAGS+= -I${LCRYPTO_SRC}/objects
54CFLAGS+= -I${LCRYPTO_SRC}/evp
55CFLAGS+= -I${LCRYPTO_SRC}/pem
56CFLAGS+= -I${LCRYPTO_SRC}/asn1
57CFLAGS+= -I${LCRYPTO_SRC}/x509
58CFLAGS+= -I${LCRYPTO_SRC}/conf
59CFLAGS+= -I${LCRYPTO_SRC}/txt_db
60CFLAGS+= -I${LCRYPTO_SRC}/pkcs7
61
62SRCS= s2_meth.c s2_srvr.c s2_clnt.c s2_lib.c s2_enc.c s2_pkt.c \
63 s3_meth.c s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \
64 s23_meth.c s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \
65 t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \
66 ssl_lib.c ssl_err2.c ssl_cert.c ssl_sess.c \
67 ssl_ciph.c ssl_stat.c ssl_rsa.c \
68 ssl_asn1.c ssl_txt.c ssl_algs.c \
69 bio_ssl.c ssl_err.c
70
71HDRS= ssl.h ssl2.h ssl3.h ssl23.h tls1.h
72
73.PATH: ${LSSL_SRC}
74
75includes:
76 @test -d ${DESTDIR}/usr/include/ssl || mkdir ${DESTDIR}/usr/include/ssl
77 @d=`mktemp -d /tmp/libsslXXXXXXXXXX`; \
78 cd ${LSSL_SRC}; for i in $(HDRS); do \
79 f=`basename $$i`; \
80 j="sed 's/#include \"\\([^\"]*\\)\"/#include <ssl\\/\\1>/' \
81 $$i >$$d/$$f && \
82 (cmp -s $$d/$$f ${DESTDIR}/usr/include/ssl/$$f || \
83 ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
84 $$d/$$f ${DESTDIR}/usr/include/ssl)"; \
85 echo $$j; \
86 eval "$$j"; \
87 done; \
88 rm -rf $$d
89
90.include <bsd.lib.mk>
diff --git a/src/lib/libssl/ssl/shlib_version b/src/lib/libssl/ssl/shlib_version
new file mode 100644
index 0000000000..1edea46de9
--- /dev/null
+++ b/src/lib/libssl/ssl/shlib_version
@@ -0,0 +1,2 @@
1major=1
2minor=0
diff --git a/src/lib/libssl/ssleay.cnf b/src/lib/libssl/ssleay.cnf
new file mode 100644
index 0000000000..c6480ee465
--- /dev/null
+++ b/src/lib/libssl/ssleay.cnf
@@ -0,0 +1,65 @@
1#
2# SSLeay example configuration file.
3# This is mostly being used for generation of certificate requests.
4#
5
6RANDFILE = /dev/arandom
7
8####################################################################
9[ req ]
10default_bits = 1024
11default_keyfile = privkey.pem
12distinguished_name = req_distinguished_name
13attributes = req_attributes
14
15[ req_distinguished_name ]
16countryName = Country Name (2 letter code)
17#countryName_default = AU
18countryName_min = 2
19countryName_max = 2
20
21stateOrProvinceName = State or Province Name (full name)
22#stateOrProvinceName_default = Some-State
23
24localityName = Locality Name (eg, city)
25
260.organizationName = Organization Name (eg, company)
27#0.organizationName_default = Internet Widgits Pty Ltd
28
29# we can do this but it is not needed normally :-)
30#1.organizationName = Second Organization Name (eg, company)
31#1.organizationName_default = CryptSoft Pty Ltd
32
33organizationalUnitName = Organizational Unit Name (eg, section)
34#organizationalUnitName_default =
35
36commonName = Common Name (eg, fully qualified host name)
37commonName_max = 64
38
39emailAddress = Email Address
40emailAddress_max = 64
41
42[ req_attributes ]
43challengePassword = A challenge password
44challengePassword_min = 4
45challengePassword_max = 20
46
47unstructuredName = An optional company name
48
49[ x509v3_extensions ]
50
51nsCaRevocationUrl = http://www.cryptsoft.com/ca-crl.pem
52nsComment = "This is a comment"
53
54# under ASN.1, the 0 bit would be encoded as 80
55nsCertType = 0x40
56
57#nsBaseUrl
58#nsRevocationUrl
59#nsRenewalUrl
60#nsCaPolicyUrl
61#nsSslServerName
62#nsCertSequence
63#nsCertExt
64#nsDataType
65
diff --git a/src/lib/libssl/test/.rnd b/src/lib/libssl/test/.rnd
new file mode 100644
index 0000000000..234970e241
--- /dev/null
+++ b/src/lib/libssl/test/.rnd
Binary files differ
diff --git a/src/lib/libssl/test/Makefile.ssl b/src/lib/libssl/test/Makefile.ssl
new file mode 100644
index 0000000000..b3de76751e
--- /dev/null
+++ b/src/lib/libssl/test/Makefile.ssl
@@ -0,0 +1,294 @@
1#
2# test/Makefile.ssl
3#
4
5DIR= test
6TOP= ..
7CC= cc
8INCLUDES= -I../include
9CFLAG= -g
10INSTALLTOP= /usr/local/ssl
11MAKEFILE= Makefile.ssl
12MAKE= make -f $(MAKEFILE)
13MAKEDEPEND= makedepend -f$(MAKEFILE)
14
15PEX_LIBS=
16EX_LIBS= #-lnsl -lsocket
17
18CFLAGS= $(INCLUDES) $(CFLAG)
19
20GENERAL=Makefile.ssl
21
22DLIBCRYPTO= ../libcrypto.a
23DLIBSSL= ../libssl.a
24LIBCRYPTO= -L.. -lcrypto
25LIBSSL= -L.. -lssl
26
27BNTEST= bntest
28EXPTEST= exptest
29IDEATEST= ideatest
30SHATEST= shatest
31SHA1TEST= sha1test
32MDC2TEST= mdc2test
33RMDTEST= rmdtest
34MD2TEST= md2test
35MD5TEST= md5test
36HMACTEST= hmactest
37RC2TEST= rc2test
38RC4TEST= rc4test
39RC5TEST= rc5test
40BFTEST= bftest
41CASTTEST= casttest
42DESTEST= destest
43RANDTEST= randtest
44DHTEST= dhtest
45DSATEST= dsatest
46METHTEST= methtest
47SSLTEST= ssltest
48
49EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \
50 $(RC2TEST) $(RC4TEST) $(RC5TEST) \
51 $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \
52 $(RANDTEST) $(DHTEST) \
53 $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST)
54
55# $(METHTEST)
56
57OBJ= $(BNTEST).o $(IDEATEST).o $(MD2TEST).o $(MD5TEST).o $(HMACTEST).o \
58 $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \
59 $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \
60 $(RANDTEST).o $(DHTEST).o $(CASTTEST).o \
61 $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o
62SRC= $(BNTEST).c $(IDEATEST).c $(MD2TEST).c $(MD5TEST).c $(HMACTEST).c \
63 $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \
64 $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \
65 $(RANDTEST).c $(DHTEST).c $(CASTTEST).c \
66 $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c
67
68EXHEADER=
69HEADER= $(EXHEADER)
70
71ALL= $(GENERAL) $(SRC) $(HEADER)
72
73top:
74 (cd ..; $(MAKE) DIRS=$(DIR) all)
75
76all: exe
77
78exe: $(EXE)
79
80files:
81 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
82
83links:
84 /bin/rm -f Makefile
85 $(TOP)/util/point.sh Makefile.ssl Makefile ;
86
87errors:
88
89install:
90
91tags:
92 ctags $(SRC)
93
94tests: exe apps \
95 test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \
96 test_rc2 test_rc4 test_rc5 test_bf test_cast \
97 test_rand test_enc test_x509 test_rsa test_crl test_sid test_req \
98 test_pkcs7 test_bn test_verify test_dh test_dsa test_reqgen \
99 test_ss test_ssl test_ca
100
101apps:
102 @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all)
103
104test_des:
105 #./$(DESTEST)
106
107test_idea:
108 ./$(IDEATEST)
109
110test_sha:
111 ./$(SHATEST)
112 ./$(SHA1TEST)
113
114test_mdc2:
115 ./$(MDC2TEST)
116
117test_md5:
118 ./$(MD5TEST)
119
120test_hmac:
121 ./$(HMACTEST)
122
123test_md2:
124 ./$(MD2TEST)
125
126test_rmd:
127 ./$(RMDTEST)
128
129test_bf:
130 ./$(BFTEST)
131
132test_cast:
133 ./$(CASTTEST)
134
135test_rc2:
136 ./$(RC2TEST)
137
138test_rc4:
139 ./$(RC4TEST)
140
141test_rc5:
142 ./$(RC5TEST)
143
144test_rand:
145 ./$(RANDTEST)
146
147test_enc:
148 @sh ./testenc
149
150test_x509:
151 echo test normal x509v1 certificate
152 sh ./tx509 2>/dev/null
153 echo test first x509v3 certificate
154 sh ./tx509 v3-cert1.pem 2>/dev/null
155 echo test second x509v3 certificate
156 sh ./tx509 v3-cert2.pem 2>/dev/null
157
158test_rsa:
159 @sh ./trsa 2>/dev/null
160
161test_crl:
162 @sh ./tcrl 2>/dev/null
163
164test_sid:
165 @sh ./tsid 2>/dev/null
166
167test_req:
168 @sh ./treq 2>/dev/null
169 @sh ./treq testreq2.pem 2>/dev/null
170
171test_pkcs7:
172 @sh ./tpkcs7 2>/dev/null
173 @sh ./tpkcs7d 2>/dev/null
174
175test_bn:
176 @echo 'test a^b%c implementations'
177 ./$(EXPTEST)
178 @echo starting big number library test, could take a while...
179 @(./$(BNTEST)|bc) | awk '{ \
180if ($$0 != "0") {print "error"; exit(1); } \
181if (((NR+1)%64) == 0) print NR+1," tests done"; }'
182
183test_verify:
184 @echo "The following command should have some OK's and some failures"
185 @echo "There are definitly a few expired certificates"
186 ../apps/ssleay verify -CApath ../certs ../certs/*.pem
187
188test_dh:
189 @echo "Generate as set of DH parameters"
190 ./$(DHTEST)
191
192test_dsa:
193 @echo "Generate as set of DSA parameters"
194 ./$(DSATEST)
195
196test_reqgen:
197 @echo "Generate and verify a certificate request"
198 @sh ./testgen
199
200test_ss:
201 @echo "Generate and certify a test certificate"
202 @sh ./testss
203
204test_ssl:
205 @echo "test SSL protocol"
206 @sh ./testssl
207
208test_ca:
209 @echo "Generate and certify a test certificate via the 'ca' program"
210 @sh ./testca
211
212lint:
213 lint -DLINT $(INCLUDES) $(SRC)>fluff
214
215depend:
216 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(SRC)
217
218dclean:
219 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
220 mv -f Makefile.new $(MAKEFILE)
221
222clean:
223 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log
224
225$(DLIBSSL):
226 (cd ../ssl; $(MAKE))
227
228$(DLIBCRYPTO):
229 (cd ../crypto; $(MAKE))
230
231$(BNTEST): $(BNTEST).o $(DLIBCRYPTO)
232 $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
233
234$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO)
235 $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
236
237$(IDEATEST): $(IDEATEST).o $(DLIBCRYPTO)
238 $(CC) -o $(IDEATEST) $(CFLAGS) $(IDEATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
239
240$(MD2TEST): $(MD2TEST).o $(DLIBCRYPTO)
241 $(CC) -o $(MD2TEST) $(CFLAGS) $(MD2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
242
243$(SHATEST): $(SHATEST).o $(DLIBCRYPTO)
244 $(CC) -o $(SHATEST) $(CFLAGS) $(SHATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
245
246$(SHA1TEST): $(SHA1TEST).o $(DLIBCRYPTO)
247 $(CC) -o $(SHA1TEST) $(CFLAGS) $(SHA1TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
248
249$(RMDTEST): $(RMDTEST).o $(DLIBCRYPTO)
250 $(CC) -o $(RMDTEST) $(CFLAGS) $(RMDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
251
252$(MDC2TEST): $(MDC2TEST).o $(DLIBCRYPTO)
253 $(CC) -o $(MDC2TEST) $(CFLAGS) $(MDC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
254
255$(MD5TEST): $(MD5TEST).o $(DLIBCRYPTO)
256 $(CC) -o $(MD5TEST) $(CFLAGS) $(MD5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
257
258$(HMACTEST): $(HMACTEST).o $(DLIBCRYPTO)
259 $(CC) -o $(HMACTEST) $(CFLAGS) $(HMACTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
260
261$(RC2TEST): $(RC2TEST).o $(DLIBCRYPTO)
262 $(CC) -o $(RC2TEST) $(CFLAGS) $(RC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
263
264$(BFTEST): $(BFTEST).o $(DLIBCRYPTO)
265 $(CC) -o $(BFTEST) $(CFLAGS) $(BFTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
266
267$(CASTTEST): $(CASTTEST).o $(DLIBCRYPTO)
268 $(CC) -o $(CASTTEST) $(CFLAGS) $(CASTTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
269
270$(RC4TEST): $(RC4TEST).o $(DLIBCRYPTO)
271 $(CC) -o $(RC4TEST) $(CFLAGS) $(RC4TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
272
273$(RC5TEST): $(RC5TEST).o $(DLIBCRYPTO)
274 $(CC) -o $(RC5TEST) $(CFLAGS) $(RC5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
275
276$(DESTEST): $(DESTEST).o $(DLIBCRYPTO)
277 $(CC) -o $(DESTEST) $(CFLAGS) $(DESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
278
279$(RANDTEST): $(RANDTEST).o $(DLIBCRYPTO)
280 $(CC) -o $(RANDTEST) $(CFLAGS) $(RANDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
281
282$(DHTEST): $(DHTEST).o $(DLIBCRYPTO)
283 $(CC) -o $(DHTEST) $(CFLAGS) $(DHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
284
285$(DSATEST): $(DSATEST).o $(DLIBCRYPTO)
286 $(CC) -o $(DSATEST) $(CFLAGS) $(DSATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
287
288$(METHTEST): $(METHTEST).o $(DLIBCRYPTO)
289 $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
290
291$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO)
292 $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS)
293
294# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/test/certCA.srl b/src/lib/libssl/test/certCA.srl
new file mode 100644
index 0000000000..39f5b69311
--- /dev/null
+++ b/src/lib/libssl/test/certCA.srl
@@ -0,0 +1 @@
71
diff --git a/src/lib/libssl/test/demoCA/index.txt b/src/lib/libssl/test/demoCA/index.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/src/lib/libssl/test/demoCA/index.txt
diff --git a/src/lib/libssl/test/demoCA/private/cakey.pem b/src/lib/libssl/test/demoCA/private/cakey.pem
new file mode 100644
index 0000000000..edd5a5773f
--- /dev/null
+++ b/src/lib/libssl/test/demoCA/private/cakey.pem
@@ -0,0 +1,2 @@
1-----BEGIN RSA PRIVATE KEY-----
2-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libssl/test/demoCA/serial b/src/lib/libssl/test/demoCA/serial
new file mode 100644
index 0000000000..8a0f05e166
--- /dev/null
+++ b/src/lib/libssl/test/demoCA/serial
@@ -0,0 +1 @@
01
diff --git a/src/lib/libssl/test/dsa-ca.pem b/src/lib/libssl/test/dsa-ca.pem
new file mode 100644
index 0000000000..9eb08f3ddd
--- /dev/null
+++ b/src/lib/libssl/test/dsa-ca.pem
@@ -0,0 +1,43 @@
1-----BEGIN DSA PRIVATE KEY-----
2Proc-Type: 4,ENCRYPTED
3DEK-Info: DES-EDE3-CBC,C5B6C7CC9E1FE2C0
4
5svCXBcBRhMuU22UXOfiKZA+thmz6KYXpt1Yg5Rd+TYQcQ1MdvNy0B0tkP1SxzDq0
6Xh1eMeTML9/9/0rKakgNXXXbpi5RB8t6BmwRSyej89F7nn1mtR3qzoyPRpp15SDl
7Tn67C+2v+HDF3MFk88hiNCYkNbcmi7TWvChsl8N1r7wdZwtIox56yXdgxw6ZIpa/
8par0oUCzN7fiavPgCWz1kfPNSaBQSdxwH7TZi5tMHAr0J3C7a7QRnZfE09R59Uqr
9zslrq+ndIw1BZAxoY0SlBu+iFOVaBVlwToC4AsHkv7j7l8ITtr7f42YbBa44D9TO
10uOhONmkk/v3Fso4RaOEzdKZC+hnmmzvHs6TiTWm6yzJgSFwyOUK0eGmKEeVxpcH5
11rUOlHOwzen+FFtocZDZAfdFnb7QY7L/boQvyA5A+ZbRG4DUpmBQeQsSaICHM5Rxx
121QaLF413VNPXTLPbW0ilSc2H8x2iZTIVKfd33oSO6NhXPtSYQgfecEF4BvNHY5c4
13HovjT4mckbK95bcBzoCHu43vuSQkmZzdYo/ydSZt6zoPavbBLueTpgSbdXiDi827
14MVqOsYxGCb+kez0FoDSTgw==
15-----END DSA PRIVATE KEY-----
16-----BEGIN CERTIFICATE REQUEST-----
17MIICUjCCAhECAQAwUjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
18ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDELMAkGA1UEAxMCQ0Ew
19ggG0MIIBKQYFKw4DAgwwggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaW
20sxXgUy6P4FmCc5A+dTGZR3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5m
21rmuINvvsKNzC16W75Sw5JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHk
22cJVbUM1JAhUA9wcx7fpsBgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVo
23bzDjaeHls12YuyiGSPzemQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqR
24CZ228U2cVA9YBu5JdAfOVX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxB
25F5WS6wG1c6Vqftgy7Q4CuAOBhAACgYAapll6iqz9XrZFlk2GCVcB+KihxWnH7IuH
26vSLw9YUrJahcBHmbpvt494lF4gC5w3WPM+vXJofbusk4GoQEEsQNMDaah4m49uUq
27AylOVFJJJXuirVJ+o+0TtOFDITEAl+YZZariXOD7tdOSOl9RLMPC6+daHKS9e68u
283enxhqnDGaAAMAkGBSsOAwIbBQADMAAwLQIVAJGVuFsG/0DBuSZ0jF7ypdU0/G0v
29AhQfeF5BoMMDbX/kidUVpQ6gadPlZA==
30-----END CERTIFICATE REQUEST-----
31-----BEGIN CERTIFICATE-----
32MIIBrjCCAWwCAQswCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
33U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww
34CgYDVQQDEwNQQ0EwHhcNOTcwNjE1MDIxNDI5WhcNOTcwNzE1MDIxNDI5WjBSMQsw
35CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
36ZXQgV2lkZ2l0cyBQdHkgTHRkMQswCQYDVQQDEwJDQTCBkjAJBgUrDgMCDAUAA4GE
37AAKBgBqmWXqKrP1etkWWTYYJVwH4qKHFacfsi4e9IvD1hSslqFwEeZum+3j3iUXi
38ALnDdY8z69cmh9u6yTgahAQSxA0wNpqHibj25SoDKU5UUkkle6KtUn6j7RO04UMh
39MQCX5hllquJc4Pu105I6X1Esw8Lr51ocpL17ry7d6fGGqcMZMAkGBSsOAwIbBQAD
40MQAwLgIVAJ4wtQsANPxHo7Q4IQZYsL12SKdbAhUAjJ9n38zxT+iai2164xS+LIfa
41C1Q=
42-----END CERTIFICATE-----
43
diff --git a/src/lib/libssl/test/dsa-pca.pem b/src/lib/libssl/test/dsa-pca.pem
new file mode 100644
index 0000000000..e3641ad47e
--- /dev/null
+++ b/src/lib/libssl/test/dsa-pca.pem
@@ -0,0 +1,49 @@
1-----BEGIN DSA PRIVATE KEY-----
2Proc-Type: 4,ENCRYPTED
3DEK-Info: DES-EDE3-CBC,F80EEEBEEA7386C4
4
5GZ9zgFcHOlnhPoiSbVi/yXc9mGoj44A6IveD4UlpSEUt6Xbse3Fr0KHIUyQ3oGnS
6mClKoAp/eOTb5Frhto85SzdsxYtac+X1v5XwdzAMy2KowHVk1N8A5jmE2OlkNPNt
7of132MNlo2cyIRYaa35PPYBGNCmUm7YcYS8O90YtkrQZZTf4+2C4kllhMcdkQwkr
8FWSWC8YOQ7w0LHb4cX1FejHHom9Nd/0PN3vn3UyySvfOqoR7nbXkrpHXmPIr0hxX
9RcF0aXcV/CzZ1/nfXWQf4o3+oD0T22SDoVcZY60IzI0oIc3pNCbDV3uKNmgekrFd
10qOUJ+QW8oWp7oefRx62iBfIeC8DZunohMXaWAQCU0sLQOR4yEdeUCnzCSywe0bG1
11diD0KYaEe+Yub1BQH4aLsBgDjardgpJRTQLq0DUvw0/QGO1irKTJzegEDNVBKrVn
12V4AHOKT1CUKqvGNRP1UnccUDTF6miOAtaj/qpzra7sSk7dkGBvIEeFoAg84kfh9h
13hVvF1YyzC9bwZepruoqoUwke/WdNIR5ymOVZ/4Liw0JdIOcq+atbdRX08niqIRkf
14dsZrUj4leo3zdefYUQ7w4N2Ns37yDFq7
15-----END DSA PRIVATE KEY-----
16-----BEGIN CERTIFICATE REQUEST-----
17MIICVTCCAhMCAQAwUzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
18ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEMMAoGA1UEAxMDUENB
19MIIBtTCCASkGBSsOAwIMMIIBHgKBgQCnP26Fv0FqKX3wn0cZMJCaCR3aajMexT2G
20lrMV4FMuj+BZgnOQPnUxmUd6UvuF5NmmezibaIqEm4fGHrV+hktTW1nPcWUZiG7O
21Zq5riDb77Cjcwtelu+UsOSZL2ppwGJU3lRBWI/YV7boEXt45T/23Qx+1pGVvzYAR
225HCVW1DNSQIVAPcHMe36bAYD1YWKHKycZedQZmVvAoGATd9MA6aRivUZb1BGJZnl
23aG8w42nh5bNdmLsohkj83pkEP1+IDJxzJA0gXbkqmj8YlifkYofBe3RiU/xhJ6h6
24kQmdtvFNnFQPWAbuSXQHzlV+I84W9srcWmEBfslxtU323DQph2j2XiCTs9v15Als
25QReVkusBtXOlan7YMu0OArgDgYUAAoGBAKbtuR5AdW+ICjCFe2ixjUiJJzM2IKwe
266NZEMXg39+HQ1UTPTmfLZLps+rZfolHDXuRKMXbGFdSF0nXYzotPCzi7GauwEJTZ
27yr27ZZjA1C6apGSQ9GzuwNvZ4rCXystVEagAS8OQ4H3D4dWS17Zg31ICb5o4E5r0
28z09o/Uz46u0VoAAwCQYFKw4DAhsFAAMxADAuAhUArRubTxsbIXy3AhtjQ943AbNB
29nSICFQCu+g1iW3jwF+gOcbroD4S/ZcvB3w==
30-----END CERTIFICATE REQUEST-----
31-----BEGIN CERTIFICATE-----
32MIIC0zCCApECAQAwCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
33U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww
34CgYDVQQDEwNQQ0EwHhcNOTcwNjE0MjI1NDQ1WhcNOTcwNzE0MjI1NDQ1WjBTMQsw
35CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
36ZXQgV2lkZ2l0cyBQdHkgTHRkMQwwCgYDVQQDEwNQQ0EwggG1MIIBKQYFKw4DAgww
37ggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaWsxXgUy6P4FmCc5A+dTGZ
38R3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5mrmuINvvsKNzC16W75Sw5
39JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHkcJVbUM1JAhUA9wcx7fps
40BgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVobzDjaeHls12YuyiGSPze
41mQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqRCZ228U2cVA9YBu5JdAfO
42VX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxBF5WS6wG1c6Vqftgy7Q4C
43uAOBhQACgYEApu25HkB1b4gKMIV7aLGNSIknMzYgrB7o1kQxeDf34dDVRM9OZ8tk
44umz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQlNnKvbtlmMDULpqkZJD0bO7A
4529nisJfKy1URqABLw5DgfcPh1ZLXtmDfUgJvmjgTmvTPT2j9TPjq7RUwCQYFKw4D
46AhsFAAMxADAuAhUAvtv6AkMolix1Jvy3UnVEIUqdCUICFQC+jq8P49mwrY9oJ24n
475rKUjNBhSg==
48-----END CERTIFICATE-----
49
diff --git a/src/lib/libssl/test/p b/src/lib/libssl/test/p
new file mode 100644
index 0000000000..b3de76751e
--- /dev/null
+++ b/src/lib/libssl/test/p
@@ -0,0 +1,294 @@
1#
2# test/Makefile.ssl
3#
4
5DIR= test
6TOP= ..
7CC= cc
8INCLUDES= -I../include
9CFLAG= -g
10INSTALLTOP= /usr/local/ssl
11MAKEFILE= Makefile.ssl
12MAKE= make -f $(MAKEFILE)
13MAKEDEPEND= makedepend -f$(MAKEFILE)
14
15PEX_LIBS=
16EX_LIBS= #-lnsl -lsocket
17
18CFLAGS= $(INCLUDES) $(CFLAG)
19
20GENERAL=Makefile.ssl
21
22DLIBCRYPTO= ../libcrypto.a
23DLIBSSL= ../libssl.a
24LIBCRYPTO= -L.. -lcrypto
25LIBSSL= -L.. -lssl
26
27BNTEST= bntest
28EXPTEST= exptest
29IDEATEST= ideatest
30SHATEST= shatest
31SHA1TEST= sha1test
32MDC2TEST= mdc2test
33RMDTEST= rmdtest
34MD2TEST= md2test
35MD5TEST= md5test
36HMACTEST= hmactest
37RC2TEST= rc2test
38RC4TEST= rc4test
39RC5TEST= rc5test
40BFTEST= bftest
41CASTTEST= casttest
42DESTEST= destest
43RANDTEST= randtest
44DHTEST= dhtest
45DSATEST= dsatest
46METHTEST= methtest
47SSLTEST= ssltest
48
49EXE= $(BNTEST) $(IDEATEST) $(MD2TEST) $(MD5TEST) $(HMACTEST) \
50 $(RC2TEST) $(RC4TEST) $(RC5TEST) \
51 $(DESTEST) $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \
52 $(RANDTEST) $(DHTEST) \
53 $(BFTEST) $(CASTTEST) $(SSLTEST) $(EXPTEST) $(DSATEST)
54
55# $(METHTEST)
56
57OBJ= $(BNTEST).o $(IDEATEST).o $(MD2TEST).o $(MD5TEST).o $(HMACTEST).o \
58 $(RC2TEST).o $(RC4TEST).o $(RC5TEST).o \
59 $(DESTEST).o $(SHATEST).o $(SHA1TEST).o $(MDC2TEST).o $(RMDTEST).o \
60 $(RANDTEST).o $(DHTEST).o $(CASTTEST).o \
61 $(BFTEST).o $(SSLTEST).o $(DSATEST).o $(EXPTEST).o
62SRC= $(BNTEST).c $(IDEATEST).c $(MD2TEST).c $(MD5TEST).c $(HMACTEST).c \
63 $(RC2TEST).c $(RC4TEST).c $(RC5TEST).c \
64 $(DESTEST).c $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \
65 $(RANDTEST).c $(DHTEST).c $(CASTTEST).c \
66 $(BFTEST).c $(SSLTEST).c $(DSATEST).c $(EXPTEST).c
67
68EXHEADER=
69HEADER= $(EXHEADER)
70
71ALL= $(GENERAL) $(SRC) $(HEADER)
72
73top:
74 (cd ..; $(MAKE) DIRS=$(DIR) all)
75
76all: exe
77
78exe: $(EXE)
79
80files:
81 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
82
83links:
84 /bin/rm -f Makefile
85 $(TOP)/util/point.sh Makefile.ssl Makefile ;
86
87errors:
88
89install:
90
91tags:
92 ctags $(SRC)
93
94tests: exe apps \
95 test_des test_idea test_sha test_md5 test_hmac test_md2 test_mdc2 \
96 test_rc2 test_rc4 test_rc5 test_bf test_cast \
97 test_rand test_enc test_x509 test_rsa test_crl test_sid test_req \
98 test_pkcs7 test_bn test_verify test_dh test_dsa test_reqgen \
99 test_ss test_ssl test_ca
100
101apps:
102 @(cd ../apps; $(MAKE) CC='${CC}' CFLAG='${CFLAG}' INSTALLTOP='${INSTALLTOP}' PEX_LIBS='${PEX_LIBS}' EX_LIBS='${EX_LIBS}' all)
103
104test_des:
105 #./$(DESTEST)
106
107test_idea:
108 ./$(IDEATEST)
109
110test_sha:
111 ./$(SHATEST)
112 ./$(SHA1TEST)
113
114test_mdc2:
115 ./$(MDC2TEST)
116
117test_md5:
118 ./$(MD5TEST)
119
120test_hmac:
121 ./$(HMACTEST)
122
123test_md2:
124 ./$(MD2TEST)
125
126test_rmd:
127 ./$(RMDTEST)
128
129test_bf:
130 ./$(BFTEST)
131
132test_cast:
133 ./$(CASTTEST)
134
135test_rc2:
136 ./$(RC2TEST)
137
138test_rc4:
139 ./$(RC4TEST)
140
141test_rc5:
142 ./$(RC5TEST)
143
144test_rand:
145 ./$(RANDTEST)
146
147test_enc:
148 @sh ./testenc
149
150test_x509:
151 echo test normal x509v1 certificate
152 sh ./tx509 2>/dev/null
153 echo test first x509v3 certificate
154 sh ./tx509 v3-cert1.pem 2>/dev/null
155 echo test second x509v3 certificate
156 sh ./tx509 v3-cert2.pem 2>/dev/null
157
158test_rsa:
159 @sh ./trsa 2>/dev/null
160
161test_crl:
162 @sh ./tcrl 2>/dev/null
163
164test_sid:
165 @sh ./tsid 2>/dev/null
166
167test_req:
168 @sh ./treq 2>/dev/null
169 @sh ./treq testreq2.pem 2>/dev/null
170
171test_pkcs7:
172 @sh ./tpkcs7 2>/dev/null
173 @sh ./tpkcs7d 2>/dev/null
174
175test_bn:
176 @echo 'test a^b%c implementations'
177 ./$(EXPTEST)
178 @echo starting big number library test, could take a while...
179 @(./$(BNTEST)|bc) | awk '{ \
180if ($$0 != "0") {print "error"; exit(1); } \
181if (((NR+1)%64) == 0) print NR+1," tests done"; }'
182
183test_verify:
184 @echo "The following command should have some OK's and some failures"
185 @echo "There are definitly a few expired certificates"
186 ../apps/ssleay verify -CApath ../certs ../certs/*.pem
187
188test_dh:
189 @echo "Generate as set of DH parameters"
190 ./$(DHTEST)
191
192test_dsa:
193 @echo "Generate as set of DSA parameters"
194 ./$(DSATEST)
195
196test_reqgen:
197 @echo "Generate and verify a certificate request"
198 @sh ./testgen
199
200test_ss:
201 @echo "Generate and certify a test certificate"
202 @sh ./testss
203
204test_ssl:
205 @echo "test SSL protocol"
206 @sh ./testssl
207
208test_ca:
209 @echo "Generate and certify a test certificate via the 'ca' program"
210 @sh ./testca
211
212lint:
213 lint -DLINT $(INCLUDES) $(SRC)>fluff
214
215depend:
216 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(SRC)
217
218dclean:
219 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
220 mv -f Makefile.new $(MAKEFILE)
221
222clean:
223 /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff $(EXE) *.ss log
224
225$(DLIBSSL):
226 (cd ../ssl; $(MAKE))
227
228$(DLIBCRYPTO):
229 (cd ../crypto; $(MAKE))
230
231$(BNTEST): $(BNTEST).o $(DLIBCRYPTO)
232 $(CC) -o $(BNTEST) $(CFLAGS) $(BNTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
233
234$(EXPTEST): $(EXPTEST).o $(DLIBCRYPTO)
235 $(CC) -o $(EXPTEST) $(CFLAGS) $(EXPTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
236
237$(IDEATEST): $(IDEATEST).o $(DLIBCRYPTO)
238 $(CC) -o $(IDEATEST) $(CFLAGS) $(IDEATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
239
240$(MD2TEST): $(MD2TEST).o $(DLIBCRYPTO)
241 $(CC) -o $(MD2TEST) $(CFLAGS) $(MD2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
242
243$(SHATEST): $(SHATEST).o $(DLIBCRYPTO)
244 $(CC) -o $(SHATEST) $(CFLAGS) $(SHATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
245
246$(SHA1TEST): $(SHA1TEST).o $(DLIBCRYPTO)
247 $(CC) -o $(SHA1TEST) $(CFLAGS) $(SHA1TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
248
249$(RMDTEST): $(RMDTEST).o $(DLIBCRYPTO)
250 $(CC) -o $(RMDTEST) $(CFLAGS) $(RMDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
251
252$(MDC2TEST): $(MDC2TEST).o $(DLIBCRYPTO)
253 $(CC) -o $(MDC2TEST) $(CFLAGS) $(MDC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
254
255$(MD5TEST): $(MD5TEST).o $(DLIBCRYPTO)
256 $(CC) -o $(MD5TEST) $(CFLAGS) $(MD5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
257
258$(HMACTEST): $(HMACTEST).o $(DLIBCRYPTO)
259 $(CC) -o $(HMACTEST) $(CFLAGS) $(HMACTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
260
261$(RC2TEST): $(RC2TEST).o $(DLIBCRYPTO)
262 $(CC) -o $(RC2TEST) $(CFLAGS) $(RC2TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
263
264$(BFTEST): $(BFTEST).o $(DLIBCRYPTO)
265 $(CC) -o $(BFTEST) $(CFLAGS) $(BFTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
266
267$(CASTTEST): $(CASTTEST).o $(DLIBCRYPTO)
268 $(CC) -o $(CASTTEST) $(CFLAGS) $(CASTTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
269
270$(RC4TEST): $(RC4TEST).o $(DLIBCRYPTO)
271 $(CC) -o $(RC4TEST) $(CFLAGS) $(RC4TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
272
273$(RC5TEST): $(RC5TEST).o $(DLIBCRYPTO)
274 $(CC) -o $(RC5TEST) $(CFLAGS) $(RC5TEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
275
276$(DESTEST): $(DESTEST).o $(DLIBCRYPTO)
277 $(CC) -o $(DESTEST) $(CFLAGS) $(DESTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
278
279$(RANDTEST): $(RANDTEST).o $(DLIBCRYPTO)
280 $(CC) -o $(RANDTEST) $(CFLAGS) $(RANDTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
281
282$(DHTEST): $(DHTEST).o $(DLIBCRYPTO)
283 $(CC) -o $(DHTEST) $(CFLAGS) $(DHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
284
285$(DSATEST): $(DSATEST).o $(DLIBCRYPTO)
286 $(CC) -o $(DSATEST) $(CFLAGS) $(DSATEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
287
288$(METHTEST): $(METHTEST).o $(DLIBCRYPTO)
289 $(CC) -o $(METHTEST) $(CFLAGS) $(METHTEST).o $(PEX_LIBS) $(LIBCRYPTO) $(EX_LIBS)
290
291$(SSLTEST): $(SSLTEST).o $(DLIBSSL) $(DLIBCRYPTO)
292 $(CC) -o $(SSLTEST) $(CFLAGS) $(SSLTEST).o $(PEX_LIBS) $(LIBSSL) $(LIBCRYPTO) $(EX_LIBS)
293
294# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/src/lib/libssl/test/riptest b/src/lib/libssl/test/riptest
new file mode 100644
index 0000000000..8685d0ce53
--- /dev/null
+++ b/src/lib/libssl/test/riptest
Binary files differ
diff --git a/src/lib/libssl/test/test.txt b/src/lib/libssl/test/test.txt
new file mode 100644
index 0000000000..c6d8d50ba9
--- /dev/null
+++ b/src/lib/libssl/test/test.txt
@@ -0,0 +1,31 @@
1#!/bin/sh
2
3test=./test.txt
4
5cat $0 >$test;
6
7for i in rc4 des-cfb des-ofb des-ecb des-cbc des-ede des-ede3 \
8 des-cbc-ede des-cbc-ede3 idea-ecb idea-cfb idea-ofb idea-cbc
9do
10 echo $i
11 ../apps/ssleay $i -e -k test < $test > $test.$i.cipher
12 ../apps/ssleay $i -d -k test < $test.$i.cipher >$test.$i.clear
13 cmp $test $test.$i.clear
14 if [ $? != 0 ]
15 then
16 exit 1
17 else
18 /bin/rm $test.$i.cipher $test.$i.clear
19 fi
20
21 echo $i base64
22 ../apps/ssleay $i -a -e -k test < $test > $test.$i.cipher
23 ../apps/ssleay $i -a -d -k test < $test.$i.cipher >$test.$i.clear
24 cmp $test $test.$i.clear
25 if [ $? != 0 ]
26 then
27 exit 1
28 else
29 /bin/rm $test.$i.cipher $test.$i.clear
30 fi
31done
diff --git a/src/lib/libssl/test/testkey.pem b/src/lib/libssl/test/testkey.pem
new file mode 100644
index 0000000000..edd5a5773f
--- /dev/null
+++ b/src/lib/libssl/test/testkey.pem
@@ -0,0 +1,2 @@
1-----BEGIN RSA PRIVATE KEY-----
2-----END RSA PRIVATE KEY-----
diff --git a/src/lib/libssl/test/testreq.pem b/src/lib/libssl/test/testreq.pem
new file mode 100644
index 0000000000..1311fa7785
--- /dev/null
+++ b/src/lib/libssl/test/testreq.pem
@@ -0,0 +1,9 @@
1-----BEGIN CERTIFICATE REQUEST-----
2MIIBQjCB7QIBADCBhzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx
3ETAPBgNVBAcTCEJyaXNiYW5lMRowGAYDVQQKExFDcnlwdFNvZnQgUHR5IEx0ZDET
4MBEGA1UEAxMKRXJpYyBZb3VuZzEfMB0GCSqGSIb3DQEJARYQZWF5QG1pbmNvbS5v
5ei5hdTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDVKdT5QB2ZojtNQGjA/9J7s2o4
6RNkuSq8l377uWLAyMljtdkcoRsvUy5lZ997UDHFTbVFA038ZBrmw7l5EyHeXAgMB
7AAGgADANBgkqhkiG9w0BAQQFAANBAKnaFr4u7PTdfmpjiX/H8Ho4UWGVRWUlvD2R
8/D9yoTj7TN3uODx2BD0drErVBe/Zjv81vhH6Yo3cJO/hRS3A7jw=
9-----END CERTIFICATE REQUEST-----
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile
new file mode 100644
index 0000000000..7b65e2c1c5
--- /dev/null
+++ b/src/regress/lib/libc/Makefile
@@ -0,0 +1,16 @@
1# $NetBSD: Makefile,v 1.6 1995/04/24 05:52:15 cgd Exp $
2
3SUBDIR+= _setjmp db regex setjmp sigsetjmp
4.if (${MACHINE_ARCH} != "vax")
5SUBDIR+= ieeefp
6.endif
7
8.if exists(arch/${MACHINE_ARCH})
9SUBDIR+= arch/${MACHINE_ARCH}
10.endif
11
12regress: _SUBDIRUSE
13
14install:
15
16.include <bsd.subdir.mk>
diff --git a/src/regress/lib/libc/_setjmp/Makefile b/src/regress/lib/libc/_setjmp/Makefile
new file mode 100644
index 0000000000..c2b9dc1aae
--- /dev/null
+++ b/src/regress/lib/libc/_setjmp/Makefile
@@ -0,0 +1,16 @@
1# $NetBSD: Makefile,v 1.2 1995/04/20 22:38:44 cgd Exp $
2
3PROG= _setjmptest
4SRCS= jmptest.c
5NOMAN= noman, no way, man
6
7CFLAGS+= -DTEST_U_SETJMP
8
9.PATH: ${.CURDIR}/../setjmp
10
11install:
12
13regress: ${PROG}
14 ./${PROG}
15
16.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/arch/alpha/Makefile b/src/regress/lib/libc/arch/alpha/Makefile
new file mode 100644
index 0000000000..b79a82b0e2
--- /dev/null
+++ b/src/regress/lib/libc/arch/alpha/Makefile
@@ -0,0 +1,10 @@
1# $NetBSD: Makefile,v 1.1 1995/04/24 05:53:31 cgd Exp $
2
3# do nothing here; none of the tests here can be run automatically
4SUBDIR=
5
6regress: _SUBDIRUSE
7
8install:
9
10.include <bsd.subdir.mk>
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/Makefile b/src/regress/lib/libc/arch/alpha/divremtest/Makefile
new file mode 100644
index 0000000000..bd3b12f537
--- /dev/null
+++ b/src/regress/lib/libc/arch/alpha/divremtest/Makefile
@@ -0,0 +1,29 @@
1# $NetBSD: Makefile,v 1.1 1995/04/24 05:53:34 cgd Exp $
2
3PROG= divremtest
4NOMAN=
5
6CLEANFILES+= mkcases cases.c mktestcases testcases
7
8divremtest.c: cases.c
9
10cases.c: mkcases
11 /bin/rm -f cases.c
12 mkcases > cases.c
13
14# a typical strategy to use this:
15# compile a NetBSD divremtest binary, an OSF/1 divremtest binary, and an
16# OSF/1 mktestcases binary. You then run mktestecases | divremtest -g
17# on an OSF/1 machine, and pipe the output to an rsh to a NetBSD machine
18# which then runs divremtest. You can test an infinite number of random
19# values that way; I like to put a 'dd' in, so I can see how much I've done.
20
21testcases: mktestcases divremtest
22 /bin/rm -f testcases
23 mktestcases | divremtest -g > testcases
24
25regress:
26 @echo THIS TEST CANNOT BE RUN AUTOMATICALLY.
27 @false
28
29.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c b/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c
new file mode 100644
index 0000000000..fcf64c9384
--- /dev/null
+++ b/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c
@@ -0,0 +1,183 @@
1/* $NetBSD: divremtest.c,v 1.1 1995/04/24 05:53:35 cgd Exp $ */
2
3/*
4 * Copyright (c) 1995 Christopher G. Demetriou
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christopher G. Demetriou
18 * for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <stdio.h>
35#include <unistd.h>
36#include <signal.h>
37
38void testfile();
39void usage();
40
41int generate;
42
43int
44main(argc, argv)
45 int argc;
46 char **argv;
47{
48 int c;
49
50 signal(SIGFPE, SIG_IGN);
51
52 while ((c = getopt(argc, argv, "g")) != -1)
53 switch (c) {
54 case 'g':
55 generate = 1;
56 break;
57
58 default:
59 usage();
60 break;
61 }
62
63 argc -= optind;
64 argv += optind;
65
66 if (argc == 0)
67 testfile();
68 else
69 for (; argc != 0; argc--, argv++) {
70 if (freopen(argv[0], "r", stdin) == NULL) {
71 fprintf(stderr,
72 "divremtest: couldn't open %s\n",
73 argv[0]);
74 exit(1);
75 }
76
77 testfile();
78 }
79
80 exit(0);
81}
82
83void
84testfile()
85{
86 union operand {
87 unsigned long input;
88 int op_int;
89 unsigned int op_u_int;
90 long op_long;
91 unsigned long op_u_long;
92 } op1, op2, divres, modres, divwant, modwant;
93 char opspec[6];
94 int encoded, i;
95
96 while (scanf("%6c %lx %lx %lx %lx\n", opspec, &op1.input,
97 &op2.input, &divwant.input, &modwant.input) != EOF) {
98
99 encoded = 0;
100
101 for (i = 0; i < 6; i += 2) {
102 int posval;
103
104 switch (opspec[i]) {
105 case '.':
106 posval = 0;
107 break;
108 case '-':
109 posval = 1;
110 break;
111 default:
112 fprintf(stderr,
113 "unknown signedness spec %c\n",
114 opspec[i]);
115 exit(1);
116 }
117 encoded |= posval << ((5 - i) * 4);
118 }
119
120 for (i = 1; i < 6; i += 2) {
121 int posval;
122
123 switch (opspec[i]) {
124 case 'i':
125 posval = 0;
126 break;
127 case 'l':
128 posval = 1;
129 break;
130 default:
131 fprintf(stderr, "unknown length spec %c\n",
132 opspec[i]);
133 exit(1);
134 }
135 encoded |= posval << ((5 - i) * 4);
136 }
137
138 /* KILL ME!!! */
139 switch (encoded) {
140
141#define TRY_IT(a, b, c) \
142 divres.a = op1.b / op2.c; \
143 modres.a = op1.b % op2.c; \
144 if (generate) { \
145 printf("%6s 0x%016lx 0x%016lx 0x%016lx 0x%016lx\n", \
146 opspec, op1.input, op2.input, \
147 divres.a, modres.a); \
148 } else { \
149 if ((divres.a != divwant.a) || \
150 (modres.a != modwant.a)) { \
151 fprintf(stderr, "%6s 0x%016lx 0x%016lx\n", \
152 opspec, op1.input, op2.input); \
153 fprintf(stderr, "FAILED:\n"); \
154 fprintf(stderr, \
155 "div:\twanted 0x%16lx, got 0x%16lx\n", \
156 divwant.a, divres.a); \
157 fprintf(stderr, \
158 "mod:\twanted 0x%16lx, got 0x%16lx\n", \
159 modwant.a, modres.a); \
160 \
161 exit(1); \
162 } \
163 }
164
165#include "cases.c"
166
167#undef TRY_IT
168
169 default:
170 fprintf(stderr,
171 "INTERNAL ERROR: unknown encoding %x\n", encoded);
172 exit(1);
173 }
174 }
175}
176
177void
178usage()
179{
180
181 fprintf(stderr, "usage: divremtest [-v] [testfile ...]\n");
182 exit(1);
183}
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c b/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c
new file mode 100644
index 0000000000..65ca17af4c
--- /dev/null
+++ b/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c
@@ -0,0 +1,63 @@
1/* $NetBSD: mkcases.c,v 1.1 1995/04/24 05:53:36 cgd Exp $ */
2
3/*
4 * Copyright (c) 1995 Christopher G. Demetriou
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christopher G. Demetriou
18 * for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34char *tab[4] = { "u_int", "int", "u_long", "long" };
35
36int
37main()
38{
39 int i;
40
41 for (i = 0; i < 64; i++) {
42 printf(
43" case 0x%d%d%d%d%d%d: /* %s <= %s op %s */\n",
44 (i >> 5) & 1,
45 (i >> 4) & 1,
46 (i >> 3) & 1,
47 (i >> 2) & 1,
48 (i >> 1) & 1,
49 (i >> 0) & 1,
50 tab[(i >> 4) & 0x3],
51 tab[(i >> 2) & 0x3],
52 tab[(i >> 0) & 0x3]);
53 printf(
54" TRY_IT(op_%s, op_%s, op_%s);\n",
55 tab[(i >> 4) & 0x3],
56 tab[(i >> 2) & 0x3],
57 tab[(i >> 0) & 0x3]);
58 printf(
59" break;\n\n");
60 }
61
62 exit(0);
63}
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c b/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c
new file mode 100644
index 0000000000..ef02d61d70
--- /dev/null
+++ b/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c
@@ -0,0 +1,67 @@
1/* $NetBSD: mktestcases.c,v 1.1 1995/04/24 05:53:37 cgd Exp $ */
2
3/*
4 * Copyright (c) 1995 Christopher G. Demetriou
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christopher G. Demetriou
18 * for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <stdio.h>
35
36int
37main()
38{
39 int i, j;
40 unsigned long n1, n2;
41
42 srandom(time(NULL));
43
44 for (i = 1; /* i < 10240 */ 1; i++) {
45 n1 = (unsigned)
46 (random() & ((random() & random()) | 0x80000000));
47 n1 <<= 32;
48 n1 |= (unsigned)(random() & random() & random());
49
50 n2 = (unsigned)
51 (random() & ((random() & random()) | 0x80000000));
52 n2 <<= 32;
53 n2 |= (unsigned)(random() & random() & random());
54
55 for (j = 0; j < 64; j++) {
56 char *tab[] = { ".i", ".l", "-i", "-l" };
57
58 printf("%s%s%s 0x%lx 0x%lx 0 0\n",
59 tab[(j >> 4) & 0x3],
60 tab[(j >> 2) & 0x3],
61 tab[(j >> 0) & 0x3],
62 n1, n2);
63 }
64 }
65
66 exit(0);
67}
diff --git a/src/regress/lib/libc/db/Makefile b/src/regress/lib/libc/db/Makefile
new file mode 100644
index 0000000000..d42dc96315
--- /dev/null
+++ b/src/regress/lib/libc/db/Makefile
@@ -0,0 +1,17 @@
1# $NetBSD: Makefile,v 1.11 1995/12/12 01:54:15 cgd Exp $
2# @(#)Makefile 8.1 (Berkeley) 6/4/93
3
4PROG= dbtest
5
6# add -DSTATISTICS to CFLAGS to get usage statistics. Note that
7# for this to work, libc must be compiled with -DSTATISTICS as well
8CFLAGS+= -g -D__DBINTERFACE_PRIVATE -DDEBUG
9NOMAN= noman
10CLEANFILES+= t1 t2 t3
11
12install:
13
14regress:
15 sh ${.CURDIR}/run.test
16
17.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/db/README b/src/regress/lib/libc/db/README
new file mode 100644
index 0000000000..fddf5c3d5a
--- /dev/null
+++ b/src/regress/lib/libc/db/README
@@ -0,0 +1,68 @@
1# $NetBSD: README,v 1.5 1996/05/03 21:54:19 cgd Exp $
2# @(#)README 8.8 (Berkeley) 7/31/94
3
4To run the tests, enter "make regress".
5
6Fairly large files (the command files) are built in this directory during
7the test runs, and even larger files (the database files) are created in
8"/var/tmp". If the latter directory doesn't exist, set the environmental
9variable TMPDIR to a directory where the files can be built.
10
11=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
12The script file consists of lines with an initial character which is
13the command for that line, or an initial character indicating a key
14or data entry for a previous command.
15
16Legal command characters are as follows:
17
18c: compare a record
19 + must be followed by [kK][dD]; the data value in the database
20 associated with the specified key is compared to the specified
21 data value.
22e: echo a string
23 + writes out the rest of the line into the output file; if the
24 last character is not a carriage-return, a newline is appended.
25f: set the flags for the next command
26 + no value zero's the flags
27g: do a get command
28 + must be followed by [kK]
29 + writes out the retrieved data DBT.
30o [r]: dump [reverse]
31 + dump the database out, if 'r' is set, in reverse order.
32p: do a put command
33 + must be followed by [kK][dD]
34r: do a del command
35 + must be followed by [kK] unless R_CURSOR flag set.
36S: sync the database
37s: do a seq command
38 + must be followed by [kK] if R_CURSOR flag set.
39 + writes out the retrieved data DBT.
40
41Legal key/data characters are as follows:
42
43D [file]: data file
44 + set the current data value to the contents of the file
45d [data]:
46 + set the current key value to the contents of the line.
47K [file]: key file
48 + set the current key value to the contents of the file
49k [data]:
50 + set the current key value to the contents of the line.
51
52Blank lines, lines with leading white space, and lines with leading
53hash marks (#) are ignored.
54
55Options to dbtest are as follows:
56
57 -d: Set the DB_LOCK flag.
58 -f: Use the file argument as the database file.
59 -i: Use the rest of the argument to set elements in the info
60 structure. If the type is btree, then "-i cachesize=10240"
61 will set BTREEINFO.cachesize to 10240.
62 -o: The rest of the argument is the output file instead of
63 using stdout.
64 -s: Don't delete the database file before opening it, i.e.
65 use the database file from a previous run.
66
67Dbtest requires two arguments, the type of access "hash", "recno"
68or "btree", and the script name or "-" to indicate stdin.
diff --git a/src/regress/lib/libc/db/dbtest.c b/src/regress/lib/libc/db/dbtest.c
new file mode 100644
index 0000000000..6ccfba5011
--- /dev/null
+++ b/src/regress/lib/libc/db/dbtest.c
@@ -0,0 +1,759 @@
1/* $NetBSD: dbtest.c,v 1.8 1996/05/03 21:57:48 cgd Exp $ */
2
3/*-
4 * Copyright (c) 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36#ifndef lint
37static char copyright[] =
38"@(#) Copyright (c) 1992, 1993, 1994\n\
39 The Regents of the University of California. All rights reserved.\n";
40#endif /* not lint */
41
42#ifndef lint
43#if 0
44static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94";
45#else
46static char rcsid[] = "$NetBSD: dbtest.c,v 1.8 1996/05/03 21:57:48 cgd Exp $";
47#endif
48#endif /* not lint */
49
50#include <sys/param.h>
51#include <sys/stat.h>
52
53#include <ctype.h>
54#include <errno.h>
55#include <fcntl.h>
56#include <limits.h>
57#include <stdio.h>
58#include <stdlib.h>
59#include <string.h>
60#include <unistd.h>
61
62#include <db.h>
63
64enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA };
65
66void compare __P((DBT *, DBT *));
67DBTYPE dbtype __P((char *));
68void dump __P((DB *, int));
69void err __P((const char *, ...));
70void get __P((DB *, DBT *));
71void getdata __P((DB *, DBT *, DBT *));
72void put __P((DB *, DBT *, DBT *));
73void rem __P((DB *, DBT *));
74char *sflags __P((int));
75void synk __P((DB *));
76void *rfile __P((char *, size_t *));
77void seq __P((DB *, DBT *));
78u_int setflags __P((char *));
79void *setinfo __P((DBTYPE, char *));
80void usage __P((void));
81void *xmalloc __P((char *, size_t));
82
83DBTYPE type; /* Database type. */
84void *infop; /* Iflags. */
85u_long lineno; /* Current line in test script. */
86u_int flags; /* Current DB flags. */
87int ofd = STDOUT_FILENO; /* Standard output fd. */
88
89DB *XXdbp; /* Global for gdb. */
90int XXlineno; /* Fast breakpoint for gdb. */
91
92int
93main(argc, argv)
94 int argc;
95 char *argv[];
96{
97 extern int optind;
98 extern char *optarg;
99 enum S command, state;
100 DB *dbp;
101 DBT data, key, keydata;
102 size_t len;
103 int ch, oflags, sflag;
104 char *fname, *infoarg, *p, *t, buf[8 * 1024];
105
106 infoarg = NULL;
107 fname = NULL;
108 oflags = O_CREAT | O_RDWR;
109 sflag = 0;
110 while ((ch = getopt(argc, argv, "f:i:lo:s")) != -1)
111 switch (ch) {
112 case 'f':
113 fname = optarg;
114 break;
115 case 'i':
116 infoarg = optarg;
117 break;
118 case 'l':
119 oflags |= DB_LOCK;
120 break;
121 case 'o':
122 if ((ofd = open(optarg,
123 O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
124 err("%s: %s", optarg, strerror(errno));
125 break;
126 case 's':
127 sflag = 1;
128 break;
129 case '?':
130 default:
131 usage();
132 }
133 argc -= optind;
134 argv += optind;
135
136 if (argc != 2)
137 usage();
138
139 /* Set the type. */
140 type = dbtype(*argv++);
141
142 /* Open the descriptor file. */
143 if (strcmp(*argv, "-") && freopen(*argv, "r", stdin) == NULL)
144 err("%s: %s", *argv, strerror(errno));
145
146 /* Set up the db structure as necessary. */
147 if (infoarg == NULL)
148 infop = NULL;
149 else
150 for (p = strtok(infoarg, ",\t "); p != NULL;
151 p = strtok(0, ",\t "))
152 if (*p != '\0')
153 infop = setinfo(type, p);
154
155 /*
156 * Open the DB. Delete any preexisting copy, you almost never
157 * want it around, and it often screws up tests.
158 */
159 if (fname == NULL) {
160 p = getenv("TMPDIR");
161 if (p == NULL)
162 p = "/var/tmp";
163 (void)sprintf(buf, "%s/__dbtest", p);
164 fname = buf;
165 (void)unlink(buf);
166 } else if (!sflag)
167 (void)unlink(fname);
168
169 if ((dbp = dbopen(fname,
170 oflags, S_IRUSR | S_IWUSR, type, infop)) == NULL)
171 err("dbopen: %s", strerror(errno));
172 XXdbp = dbp;
173
174 state = COMMAND;
175 for (lineno = 1;
176 (p = fgets(buf, sizeof(buf), stdin)) != NULL; ++lineno) {
177 /* Delete the newline, displaying the key/data is easier. */
178 if (ofd == STDOUT_FILENO && (t = strchr(p, '\n')) != NULL)
179 *t = '\0';
180 if ((len = strlen(buf)) == 0 || isspace(*p) || *p == '#')
181 continue;
182
183 /* Convenient gdb break point. */
184 if (XXlineno == lineno)
185 XXlineno = 1;
186 switch (*p) {
187 case 'c': /* compare */
188 if (state != COMMAND)
189 err("line %lu: not expecting command", lineno);
190 state = KEY;
191 command = COMPARE;
192 break;
193 case 'e': /* echo */
194 if (state != COMMAND)
195 err("line %lu: not expecting command", lineno);
196 /* Don't display the newline, if CR at EOL. */
197 if (p[len - 2] == '\r')
198 --len;
199 if (write(ofd, p + 1, len - 1) != len - 1 ||
200 write(ofd, "\n", 1) != 1)
201 err("write: %s", strerror(errno));
202 break;
203 case 'g': /* get */
204 if (state != COMMAND)
205 err("line %lu: not expecting command", lineno);
206 state = KEY;
207 command = GET;
208 break;
209 case 'p': /* put */
210 if (state != COMMAND)
211 err("line %lu: not expecting command", lineno);
212 state = KEY;
213 command = PUT;
214 break;
215 case 'r': /* remove */
216 if (state != COMMAND)
217 err("line %lu: not expecting command", lineno);
218 if (flags == R_CURSOR) {
219 rem(dbp, &key);
220 state = COMMAND;
221 } else {
222 state = KEY;
223 command = REMOVE;
224 }
225 break;
226 case 'S': /* sync */
227 if (state != COMMAND)
228 err("line %lu: not expecting command", lineno);
229 synk(dbp);
230 state = COMMAND;
231 break;
232 case 's': /* seq */
233 if (state != COMMAND)
234 err("line %lu: not expecting command", lineno);
235 if (flags == R_CURSOR) {
236 state = KEY;
237 command = SEQ;
238 } else
239 seq(dbp, &key);
240 break;
241 case 'f':
242 flags = setflags(p + 1);
243 break;
244 case 'D': /* data file */
245 if (state != DATA)
246 err("line %lu: not expecting data", lineno);
247 data.data = rfile(p + 1, &data.size);
248 goto ldata;
249 case 'd': /* data */
250 if (state != DATA)
251 err("line %lu: not expecting data", lineno);
252 data.data = xmalloc(p + 1, len - 1);
253 data.size = len - 1;
254ldata: switch (command) {
255 case COMPARE:
256 compare(&keydata, &data);
257 break;
258 case PUT:
259 put(dbp, &key, &data);
260 break;
261 default:
262 err("line %lu: command doesn't take data",
263 lineno);
264 }
265 if (type != DB_RECNO)
266 free(key.data);
267 free(data.data);
268 state = COMMAND;
269 break;
270 case 'K': /* key file */
271 if (state != KEY)
272 err("line %lu: not expecting a key", lineno);
273 if (type == DB_RECNO)
274 err("line %lu: 'K' not available for recno",
275 lineno);
276 key.data = rfile(p + 1, &key.size);
277 goto lkey;
278 case 'k': /* key */
279 if (state != KEY)
280 err("line %lu: not expecting a key", lineno);
281 if (type == DB_RECNO) {
282 static recno_t recno;
283 recno = atoi(p + 1);
284 key.data = &recno;
285 key.size = sizeof(recno);
286 } else {
287 key.data = xmalloc(p + 1, len - 1);
288 key.size = len - 1;
289 }
290lkey: switch (command) {
291 case COMPARE:
292 getdata(dbp, &key, &keydata);
293 state = DATA;
294 break;
295 case GET:
296 get(dbp, &key);
297 if (type != DB_RECNO)
298 free(key.data);
299 state = COMMAND;
300 break;
301 case PUT:
302 state = DATA;
303 break;
304 case REMOVE:
305 rem(dbp, &key);
306 if ((type != DB_RECNO) && (flags != R_CURSOR))
307 free(key.data);
308 state = COMMAND;
309 break;
310 case SEQ:
311 seq(dbp, &key);
312 if ((type != DB_RECNO) && (flags != R_CURSOR))
313 free(key.data);
314 state = COMMAND;
315 break;
316 default:
317 err("line %lu: command doesn't take a key",
318 lineno);
319 }
320 break;
321 case 'o':
322 dump(dbp, p[1] == 'r');
323 break;
324 default:
325 err("line %lu: %s: unknown command character",
326 lineno, p);
327 }
328 }
329#ifdef STATISTICS
330 /*
331 * -l must be used (DB_LOCK must be set) for this to be
332 * used, otherwise a page will be locked and it will fail.
333 */
334 if (type == DB_BTREE && oflags & DB_LOCK)
335 __bt_stat(dbp);
336#endif
337 if (dbp->close(dbp))
338 err("db->close: %s", strerror(errno));
339 (void)close(ofd);
340 exit(0);
341}
342
343#define NOOVERWRITE "put failed, would overwrite key\n"
344
345void
346compare(db1, db2)
347 DBT *db1, *db2;
348{
349 register size_t len;
350 register u_char *p1, *p2;
351
352 if (db1->size != db2->size)
353 printf("compare failed: key->data len %lu != data len %lu\n",
354 db1->size, db2->size);
355
356 len = MIN(db1->size, db2->size);
357 for (p1 = db1->data, p2 = db2->data; len--;)
358 if (*p1++ != *p2++) {
359 printf("compare failed at offset %d\n",
360 p1 - (u_char *)db1->data);
361 break;
362 }
363}
364
365void
366get(dbp, kp)
367 DB *dbp;
368 DBT *kp;
369{
370 DBT data;
371
372 switch (dbp->get(dbp, kp, &data, flags)) {
373 case 0:
374 (void)write(ofd, data.data, data.size);
375 if (ofd == STDOUT_FILENO)
376 (void)write(ofd, "\n", 1);
377 break;
378 case -1:
379 err("line %lu: get: %s", lineno, strerror(errno));
380 /* NOTREACHED */
381 case 1:
382#define NOSUCHKEY "get failed, no such key\n"
383 if (ofd != STDOUT_FILENO)
384 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
385 else
386 (void)fprintf(stderr, "%d: %.*s: %s",
387 lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
388#undef NOSUCHKEY
389 break;
390 }
391}
392
393void
394getdata(dbp, kp, dp)
395 DB *dbp;
396 DBT *kp, *dp;
397{
398 switch (dbp->get(dbp, kp, dp, flags)) {
399 case 0:
400 return;
401 case -1:
402 err("line %lu: getdata: %s", lineno, strerror(errno));
403 /* NOTREACHED */
404 case 1:
405 err("line %lu: getdata failed, no such key", lineno);
406 /* NOTREACHED */
407 }
408}
409
410void
411put(dbp, kp, dp)
412 DB *dbp;
413 DBT *kp, *dp;
414{
415 switch (dbp->put(dbp, kp, dp, flags)) {
416 case 0:
417 break;
418 case -1:
419 err("line %lu: put: %s", lineno, strerror(errno));
420 /* NOTREACHED */
421 case 1:
422 (void)write(ofd, NOOVERWRITE, sizeof(NOOVERWRITE) - 1);
423 break;
424 }
425}
426
427void
428rem(dbp, kp)
429 DB *dbp;
430 DBT *kp;
431{
432 switch (dbp->del(dbp, kp, flags)) {
433 case 0:
434 break;
435 case -1:
436 err("line %lu: rem: %s", lineno, strerror(errno));
437 /* NOTREACHED */
438 case 1:
439#define NOSUCHKEY "rem failed, no such key\n"
440 if (ofd != STDOUT_FILENO)
441 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
442 else if (flags != R_CURSOR)
443 (void)fprintf(stderr, "%d: %.*s: %s",
444 lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
445 else
446 (void)fprintf(stderr,
447 "%d: rem of cursor failed\n", lineno);
448#undef NOSUCHKEY
449 break;
450 }
451}
452
453void
454synk(dbp)
455 DB *dbp;
456{
457 switch (dbp->sync(dbp, flags)) {
458 case 0:
459 break;
460 case -1:
461 err("line %lu: synk: %s", lineno, strerror(errno));
462 /* NOTREACHED */
463 }
464}
465
466void
467seq(dbp, kp)
468 DB *dbp;
469 DBT *kp;
470{
471 DBT data;
472
473 switch (dbp->seq(dbp, kp, &data, flags)) {
474 case 0:
475 (void)write(ofd, data.data, data.size);
476 if (ofd == STDOUT_FILENO)
477 (void)write(ofd, "\n", 1);
478 break;
479 case -1:
480 err("line %lu: seq: %s", lineno, strerror(errno));
481 /* NOTREACHED */
482 case 1:
483#define NOSUCHKEY "seq failed, no such key\n"
484 if (ofd != STDOUT_FILENO)
485 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
486 else if (flags == R_CURSOR)
487 (void)fprintf(stderr, "%d: %.*s: %s",
488 lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
489 else
490 (void)fprintf(stderr,
491 "%d: seq (%s) failed\n", lineno, sflags(flags));
492#undef NOSUCHKEY
493 break;
494 }
495}
496
497void
498dump(dbp, rev)
499 DB *dbp;
500 int rev;
501{
502 DBT key, data;
503 int flags, nflags;
504
505 if (rev) {
506 flags = R_LAST;
507 nflags = R_PREV;
508 } else {
509 flags = R_FIRST;
510 nflags = R_NEXT;
511 }
512 for (;; flags = nflags)
513 switch (dbp->seq(dbp, &key, &data, flags)) {
514 case 0:
515 (void)write(ofd, data.data, data.size);
516 if (ofd == STDOUT_FILENO)
517 (void)write(ofd, "\n", 1);
518 break;
519 case 1:
520 goto done;
521 case -1:
522 err("line %lu: (dump) seq: %s",
523 lineno, strerror(errno));
524 /* NOTREACHED */
525 }
526done: return;
527}
528
529u_int
530setflags(s)
531 char *s;
532{
533 char *p;
534
535 for (; isspace(*s); ++s);
536 if (*s == '\n' || *s == '\0')
537 return (0);
538 if ((p = strchr(s, '\n')) != NULL)
539 *p = '\0';
540 if (!strcmp(s, "R_CURSOR")) return (R_CURSOR);
541 if (!strcmp(s, "R_FIRST")) return (R_FIRST);
542 if (!strcmp(s, "R_IAFTER")) return (R_IAFTER);
543 if (!strcmp(s, "R_IBEFORE")) return (R_IBEFORE);
544 if (!strcmp(s, "R_LAST")) return (R_LAST);
545 if (!strcmp(s, "R_NEXT")) return (R_NEXT);
546 if (!strcmp(s, "R_NOOVERWRITE")) return (R_NOOVERWRITE);
547 if (!strcmp(s, "R_PREV")) return (R_PREV);
548 if (!strcmp(s, "R_SETCURSOR")) return (R_SETCURSOR);
549
550 err("line %lu: %s: unknown flag", lineno, s);
551 /* NOTREACHED */
552}
553
554char *
555sflags(flags)
556 int flags;
557{
558 switch (flags) {
559 case R_CURSOR: return ("R_CURSOR");
560 case R_FIRST: return ("R_FIRST");
561 case R_IAFTER: return ("R_IAFTER");
562 case R_IBEFORE: return ("R_IBEFORE");
563 case R_LAST: return ("R_LAST");
564 case R_NEXT: return ("R_NEXT");
565 case R_NOOVERWRITE: return ("R_NOOVERWRITE");
566 case R_PREV: return ("R_PREV");
567 case R_SETCURSOR: return ("R_SETCURSOR");
568 }
569
570 return ("UNKNOWN!");
571}
572
573DBTYPE
574dbtype(s)
575 char *s;
576{
577 if (!strcmp(s, "btree"))
578 return (DB_BTREE);
579 if (!strcmp(s, "hash"))
580 return (DB_HASH);
581 if (!strcmp(s, "recno"))
582 return (DB_RECNO);
583 err("%s: unknown type (use btree, hash or recno)", s);
584 /* NOTREACHED */
585}
586
587void *
588setinfo(type, s)
589 DBTYPE type;
590 char *s;
591{
592 static BTREEINFO ib;
593 static HASHINFO ih;
594 static RECNOINFO rh;
595 char *eq;
596
597 if ((eq = strchr(s, '=')) == NULL)
598 err("%s: illegal structure set statement", s);
599 *eq++ = '\0';
600 if (!isdigit(*eq))
601 err("%s: structure set statement must be a number", s);
602
603 switch (type) {
604 case DB_BTREE:
605 if (!strcmp("flags", s)) {
606 ib.flags = atoi(eq);
607 return (&ib);
608 }
609 if (!strcmp("cachesize", s)) {
610 ib.cachesize = atoi(eq);
611 return (&ib);
612 }
613 if (!strcmp("maxkeypage", s)) {
614 ib.maxkeypage = atoi(eq);
615 return (&ib);
616 }
617 if (!strcmp("minkeypage", s)) {
618 ib.minkeypage = atoi(eq);
619 return (&ib);
620 }
621 if (!strcmp("lorder", s)) {
622 ib.lorder = atoi(eq);
623 return (&ib);
624 }
625 if (!strcmp("psize", s)) {
626 ib.psize = atoi(eq);
627 return (&ib);
628 }
629 break;
630 case DB_HASH:
631 if (!strcmp("bsize", s)) {
632 ih.bsize = atoi(eq);
633 return (&ih);
634 }
635 if (!strcmp("ffactor", s)) {
636 ih.ffactor = atoi(eq);
637 return (&ih);
638 }
639 if (!strcmp("nelem", s)) {
640 ih.nelem = atoi(eq);
641 return (&ih);
642 }
643 if (!strcmp("cachesize", s)) {
644 ih.cachesize = atoi(eq);
645 return (&ih);
646 }
647 if (!strcmp("lorder", s)) {
648 ih.lorder = atoi(eq);
649 return (&ih);
650 }
651 break;
652 case DB_RECNO:
653 if (!strcmp("flags", s)) {
654 rh.flags = atoi(eq);
655 return (&rh);
656 }
657 if (!strcmp("cachesize", s)) {
658 rh.cachesize = atoi(eq);
659 return (&rh);
660 }
661 if (!strcmp("lorder", s)) {
662 rh.lorder = atoi(eq);
663 return (&rh);
664 }
665 if (!strcmp("reclen", s)) {
666 rh.reclen = atoi(eq);
667 return (&rh);
668 }
669 if (!strcmp("bval", s)) {
670 rh.bval = atoi(eq);
671 return (&rh);
672 }
673 if (!strcmp("psize", s)) {
674 rh.psize = atoi(eq);
675 return (&rh);
676 }
677 break;
678 }
679 err("%s: unknown structure value", s);
680 /* NOTREACHED */
681}
682
683void *
684rfile(name, lenp)
685 char *name;
686 size_t *lenp;
687{
688 struct stat sb;
689 void *p;
690 int fd;
691 char *np;
692
693 for (; isspace(*name); ++name);
694 if ((np = strchr(name, '\n')) != NULL)
695 *np = '\0';
696 if ((fd = open(name, O_RDONLY, 0)) < 0 ||
697 fstat(fd, &sb))
698 err("%s: %s\n", name, strerror(errno));
699#ifdef NOT_PORTABLE
700 if (sb.st_size > (off_t)SIZE_T_MAX)
701 err("%s: %s\n", name, strerror(E2BIG));
702#endif
703 if ((p = (void *)malloc((u_int)sb.st_size)) == NULL)
704 err("%s", strerror(errno));
705 (void)read(fd, p, (int)sb.st_size);
706 *lenp = sb.st_size;
707 (void)close(fd);
708 return (p);
709}
710
711void *
712xmalloc(text, len)
713 char *text;
714 size_t len;
715{
716 void *p;
717
718 if ((p = (void *)malloc(len)) == NULL)
719 err("%s", strerror(errno));
720 memmove(p, text, len);
721 return (p);
722}
723
724void
725usage()
726{
727 (void)fprintf(stderr,
728 "usage: dbtest [-l] [-f file] [-i info] [-o file] type script\n");
729 exit(1);
730}
731
732#ifdef __STDC__
733#include <stdarg.h>
734#else
735#include <varargs.h>
736#endif
737
738void
739#ifdef __STDC__
740err(const char *fmt, ...)
741#else
742err(fmt, va_alist)
743 char *fmt;
744 va_dcl
745#endif
746{
747 va_list ap;
748#ifdef __STDC__
749 va_start(ap, fmt);
750#else
751 va_start(ap);
752#endif
753 (void)fprintf(stderr, "dbtest: ");
754 (void)vfprintf(stderr, fmt, ap);
755 va_end(ap);
756 (void)fprintf(stderr, "\n");
757 exit(1);
758 /* NOTREACHED */
759}
diff --git a/src/regress/lib/libc/db/run.test b/src/regress/lib/libc/db/run.test
new file mode 100644
index 0000000000..acbd3f49e1
--- /dev/null
+++ b/src/regress/lib/libc/db/run.test
@@ -0,0 +1,706 @@
1#!/bin/sh -
2#
3# $NetBSD: run.test,v 1.8 1996/05/03 21:57:51 cgd Exp $
4# @(#)run.test 8.10 (Berkeley) 7/26/94
5#
6
7# db regression tests
8main()
9{
10
11 PROG=./dbtest
12 TMP1=t1
13 TMP2=t2
14 TMP3=t3
15
16 if [ -f /usr/share/dict/words ]; then
17 DICT=/usr/share/dict/words
18 elif [ -f /usr/dict/words ]; then
19 DICT=/usr/dict/words
20 else
21 echo 'run.test: no dictionary'
22 exit 1
23 fi
24
25 if [ $# -eq 0 ]; then
26 for t in 1 2 3 4 5 6 7 8 9 10 11 12 13 20; do
27 test$t
28 done
29 else
30 while [ $# -gt 0 ]
31 do case "$1" in
32 test*)
33 $1;;
34 [0-9]*)
35 test$1;;
36 btree)
37 for t in 1 2 3 7 8 9 10 12 13; do
38 test$t
39 done;;
40 hash)
41 for t in 1 2 3 8 13 20; do
42 test$t
43 done;;
44 recno)
45 for t in 1 2 3 4 5 6 7 10 11; do
46 test$t
47 done;;
48 *)
49 echo "run.test: unknown test $1"
50 echo "usage: run.test test# | type"
51 exit 1
52 esac
53 shift
54 done
55 fi
56 rm -f $TMP1 $TMP2 $TMP3
57 exit 0
58}
59
60# Take the first hundred entries in the dictionary, and make them
61# be key/data pairs.
62test1()
63{
64 echo "Test 1: btree, hash: small key, small data pairs"
65 sed 200q $DICT > $TMP1
66 for type in btree hash; do
67 rm -f $TMP2 $TMP3
68 for i in `sed 200q $DICT`; do
69 echo p
70 echo k$i
71 echo d$i
72 echo g
73 echo k$i
74 done > $TMP2
75 $PROG -o $TMP3 $type $TMP2
76 if (cmp -s $TMP1 $TMP3) ; then :
77 else
78 echo "test1: type $type: failed"
79 exit 1
80 fi
81 done
82 echo "Test 1: recno: small key, small data pairs"
83 rm -f $TMP2 $TMP3
84 sed 200q $DICT |
85 awk '{
86 ++i;
87 printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
88 }' > $TMP2
89 $PROG -o $TMP3 recno $TMP2
90 if (cmp -s $TMP1 $TMP3) ; then :
91 else
92 echo "test1: type recno: failed"
93 exit 1
94 fi
95}
96
97# Take the first 200 entries in the dictionary, and give them
98# each a medium size data entry.
99test2()
100{
101 echo "Test 2: btree, hash: small key, medium data pairs"
102 mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
103 echo $mdata |
104 awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1
105 for type in hash btree; do
106 rm -f $TMP2 $TMP3
107 for i in `sed 200q $DICT`; do
108 echo p
109 echo k$i
110 echo d$mdata
111 echo g
112 echo k$i
113 done > $TMP2
114 $PROG -o $TMP3 $type $TMP2
115 if (cmp -s $TMP1 $TMP3) ; then :
116 else
117 echo "test2: type $type: failed"
118 exit 1
119 fi
120 done
121 echo "Test 2: recno: small key, medium data pairs"
122 rm -f $TMP2 $TMP3
123 echo $mdata |
124 awk '{ for (i = 1; i < 201; ++i)
125 printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
126 }' > $TMP2
127 $PROG -o $TMP3 recno $TMP2
128 if (cmp -s $TMP1 $TMP3) ; then :
129 else
130 echo "test2: type recno: failed"
131 exit 1
132 fi
133}
134
135# Insert the programs in /bin with their paths as their keys.
136test3()
137{
138 echo "Test 3: hash: small key, big data pairs"
139 rm -f $TMP1
140 (find /bin -type f -print | xargs cat) > $TMP1
141 for type in hash; do
142 rm -f $TMP2 $TMP3
143 for i in `find /bin -type f -print`; do
144 echo p
145 echo k$i
146 echo D$i
147 echo g
148 echo k$i
149 done > $TMP2
150 $PROG -o $TMP3 $type $TMP2
151 if (cmp -s $TMP1 $TMP3) ; then :
152 else
153 echo "test3: $type: failed"
154 exit 1
155 fi
156 done
157 echo "Test 3: btree: small key, big data pairs"
158 for psize in 512 16384 65536; do
159 echo " page size $psize"
160 for type in btree; do
161 rm -f $TMP2 $TMP3
162 for i in `find /bin -type f -print`; do
163 echo p
164 echo k$i
165 echo D$i
166 echo g
167 echo k$i
168 done > $TMP2
169 $PROG -i psize=$psize -o $TMP3 $type $TMP2
170 if (cmp -s $TMP1 $TMP3) ; then :
171 else
172 echo "test3: $type: page size $psize: failed"
173 exit 1
174 fi
175 done
176 done
177 echo "Test 3: recno: big data pairs"
178 rm -f $TMP2 $TMP3
179 find /bin -type f -print |
180 awk '{
181 ++i;
182 printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i);
183 }' > $TMP2
184 for psize in 512 16384 65536; do
185 echo " page size $psize"
186 $PROG -i psize=$psize -o $TMP3 recno $TMP2
187 if (cmp -s $TMP1 $TMP3) ; then :
188 else
189 echo "test3: recno: page size $psize: failed"
190 exit 1
191 fi
192 done
193}
194
195# Do random recno entries.
196test4()
197{
198 echo "Test 4: recno: random entries"
199 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
200 awk '{
201 for (i = 37; i <= 37 + 88 * 17; i += 17) {
202 if (i % 41)
203 s = substr($0, 1, i % 41);
204 else
205 s = substr($0, 1);
206 printf("input key %d: %s\n", i, s);
207 }
208 for (i = 1; i <= 15; ++i) {
209 if (i % 41)
210 s = substr($0, 1, i % 41);
211 else
212 s = substr($0, 1);
213 printf("input key %d: %s\n", i, s);
214 }
215 for (i = 19234; i <= 19234 + 61 * 27; i += 27) {
216 if (i % 41)
217 s = substr($0, 1, i % 41);
218 else
219 s = substr($0, 1);
220 printf("input key %d: %s\n", i, s);
221 }
222 exit
223 }' > $TMP1
224 rm -f $TMP2 $TMP3
225 cat $TMP1 |
226 awk 'BEGIN {
227 i = 37;
228 incr = 17;
229 }
230 {
231 printf("p\nk%d\nd%s\n", i, $0);
232 if (i == 19234 + 61 * 27)
233 exit;
234 if (i == 37 + 88 * 17) {
235 i = 1;
236 incr = 1;
237 } else if (i == 15) {
238 i = 19234;
239 incr = 27;
240 } else
241 i += incr;
242 }
243 END {
244 for (i = 37; i <= 37 + 88 * 17; i += 17)
245 printf("g\nk%d\n", i);
246 for (i = 1; i <= 15; ++i)
247 printf("g\nk%d\n", i);
248 for (i = 19234; i <= 19234 + 61 * 27; i += 27)
249 printf("g\nk%d\n", i);
250 }' > $TMP2
251 $PROG -o $TMP3 recno $TMP2
252 if (cmp -s $TMP1 $TMP3) ; then :
253 else
254 echo "test4: type recno: failed"
255 exit 1
256 fi
257}
258
259# Do reverse order recno entries.
260test5()
261{
262 echo "Test 5: recno: reverse order entries"
263 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
264 awk ' {
265 for (i = 1500; i; --i) {
266 if (i % 34)
267 s = substr($0, 1, i % 34);
268 else
269 s = substr($0, 1);
270 printf("input key %d: %s\n", i, s);
271 }
272 exit;
273 }' > $TMP1
274 rm -f $TMP2 $TMP3
275 cat $TMP1 |
276 awk 'BEGIN {
277 i = 1500;
278 }
279 {
280 printf("p\nk%d\nd%s\n", i, $0);
281 --i;
282 }
283 END {
284 for (i = 1500; i; --i)
285 printf("g\nk%d\n", i);
286 }' > $TMP2
287 $PROG -o $TMP3 recno $TMP2
288 if (cmp -s $TMP1 $TMP3) ; then :
289 else
290 echo "test5: type recno: failed"
291 exit 1
292 fi
293}
294
295# Do alternating order recno entries.
296test6()
297{
298 echo "Test 6: recno: alternating order entries"
299 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
300 awk ' {
301 for (i = 1; i < 1200; i += 2) {
302 if (i % 34)
303 s = substr($0, 1, i % 34);
304 else
305 s = substr($0, 1);
306 printf("input key %d: %s\n", i, s);
307 }
308 for (i = 2; i < 1200; i += 2) {
309 if (i % 34)
310 s = substr($0, 1, i % 34);
311 else
312 s = substr($0, 1);
313 printf("input key %d: %s\n", i, s);
314 }
315 exit;
316 }' > $TMP1
317 rm -f $TMP2 $TMP3
318 cat $TMP1 |
319 awk 'BEGIN {
320 i = 1;
321 even = 0;
322 }
323 {
324 printf("p\nk%d\nd%s\n", i, $0);
325 i += 2;
326 if (i >= 1200) {
327 if (even == 1)
328 exit;
329 even = 1;
330 i = 2;
331 }
332 }
333 END {
334 for (i = 1; i < 1200; ++i)
335 printf("g\nk%d\n", i);
336 }' > $TMP2
337 $PROG -o $TMP3 recno $TMP2
338 sort -o $TMP1 $TMP1
339 sort -o $TMP3 $TMP3
340 if (cmp -s $TMP1 $TMP3) ; then :
341 else
342 echo "test6: type recno: failed"
343 exit 1
344 fi
345}
346
347# Delete cursor record
348test7()
349{
350 echo "Test 7: btree, recno: delete cursor record"
351 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
352 awk '{
353 for (i = 1; i <= 120; ++i)
354 printf("%05d: input key %d: %s\n", i, i, $0);
355 printf("%05d: input key %d: %s\n", 120, 120, $0);
356 printf("seq failed, no such key\n");
357 printf("%05d: input key %d: %s\n", 1, 1, $0);
358 printf("%05d: input key %d: %s\n", 2, 2, $0);
359 exit;
360 }' > $TMP1
361 rm -f $TMP2 $TMP3
362
363 for type in btree recno; do
364 cat $TMP1 |
365 awk '{
366 if (i == 120)
367 exit;
368 printf("p\nk%d\nd%s\n", ++i, $0);
369 }
370 END {
371 printf("fR_NEXT\n");
372 for (i = 1; i <= 120; ++i)
373 printf("s\n");
374 printf("fR_CURSOR\ns\nk120\n");
375 printf("r\n");
376 printf("fR_NEXT\ns\n");
377 printf("fR_CURSOR\ns\nk1\n");
378 printf("r\n");
379 printf("fR_FIRST\ns\n");
380 }' > $TMP2
381 $PROG -o $TMP3 recno $TMP2
382 if (cmp -s $TMP1 $TMP3) ; then :
383 else
384 echo "test7: type $type: failed"
385 exit 1
386 fi
387 done
388}
389
390# Make sure that overflow pages are reused.
391test8()
392{
393 echo "Test 8: btree, hash: repeated small key, big data pairs"
394 rm -f $TMP1
395 echo "" |
396 awk 'BEGIN {
397 for (i = 1; i <= 10; ++i) {
398 printf("p\nkkey1\nD/bin/sh\n");
399 printf("p\nkkey2\nD/bin/csh\n");
400 if (i % 8 == 0) {
401 printf("c\nkkey2\nD/bin/csh\n");
402 printf("c\nkkey1\nD/bin/sh\n");
403 printf("e\t%d of 10 (comparison)\n", i);
404 } else
405 printf("e\t%d of 10 \n", i);
406 printf("r\nkkey1\nr\nkkey2\n");
407 }
408 }' > $TMP1
409 $PROG btree $TMP1
410# $PROG hash $TMP1
411 # No explicit test for success.
412}
413
414# Test btree duplicate keys
415test9()
416{
417 echo "Test 9: btree: duplicate keys"
418 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
419 awk '{
420 for (i = 1; i <= 543; ++i)
421 printf("%05d: input key %d: %s\n", i, i, $0);
422 exit;
423 }' > $TMP1
424 rm -f $TMP2 $TMP3
425
426 for type in btree; do
427 cat $TMP1 |
428 awk '{
429 if (i++ % 2)
430 printf("p\nkduplicatekey\nd%s\n", $0);
431 else
432 printf("p\nkunique%dkey\nd%s\n", i, $0);
433 }
434 END {
435 printf("o\n");
436 }' > $TMP2
437 $PROG -iflags=1 -o $TMP3 $type $TMP2
438 sort -o $TMP3 $TMP3
439 if (cmp -s $TMP1 $TMP3) ; then :
440 else
441 echo "test9: type $type: failed"
442 exit 1
443 fi
444 done
445}
446
447# Test use of cursor flags without initialization
448test10()
449{
450 echo "Test 10: btree, recno: test cursor flag use"
451 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
452 awk '{
453 for (i = 1; i <= 20; ++i)
454 printf("%05d: input key %d: %s\n", i, i, $0);
455 exit;
456 }' > $TMP1
457 rm -f $TMP2 $TMP3
458
459 # Test that R_CURSOR doesn't succeed before cursor initialized
460 for type in btree recno; do
461 cat $TMP1 |
462 awk '{
463 if (i == 10)
464 exit;
465 printf("p\nk%d\nd%s\n", ++i, $0);
466 }
467 END {
468 printf("fR_CURSOR\nr\n");
469 printf("eR_CURSOR SHOULD HAVE FAILED\n");
470 }' > $TMP2
471 $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1
472 if [ -s $TMP3 ] ; then
473 echo "Test 10: delete: R_CURSOR SHOULD HAVE FAILED"
474 exit 1
475 fi
476 done
477 for type in btree recno; do
478 cat $TMP1 |
479 awk '{
480 if (i == 10)
481 exit;
482 printf("p\nk%d\nd%s\n", ++i, $0);
483 }
484 END {
485 printf("fR_CURSOR\np\nk1\ndsome data\n");
486 printf("eR_CURSOR SHOULD HAVE FAILED\n");
487 }' > $TMP2
488 $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1
489 if [ -s $TMP3 ] ; then
490 echo "Test 10: put: R_CURSOR SHOULD HAVE FAILED"
491 exit 1
492 fi
493 done
494}
495
496# Test insert in reverse order.
497test11()
498{
499 echo "Test 11: recno: reverse order insert"
500 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
501 awk '{
502 for (i = 1; i <= 779; ++i)
503 printf("%05d: input key %d: %s\n", i, i, $0);
504 exit;
505 }' > $TMP1
506 rm -f $TMP2 $TMP3
507
508 for type in recno; do
509 cat $TMP1 |
510 awk '{
511 if (i == 0) {
512 i = 1;
513 printf("p\nk1\nd%s\n", $0);
514 printf("%s\n", "fR_IBEFORE");
515 } else
516 printf("p\nk1\nd%s\n", $0);
517 }
518 END {
519 printf("or\n");
520 }' > $TMP2
521 $PROG -o $TMP3 $type $TMP2
522 if (cmp -s $TMP1 $TMP3) ; then :
523 else
524 echo "test11: type $type: failed"
525 exit 1
526 fi
527 done
528}
529
530# Take the first 20000 entries in the dictionary, reverse them, and give
531# them each a small size data entry. Use a small page size to make sure
532# the btree split code gets hammered.
533test12()
534{
535 echo "Test 12: btree: lots of keys, small page size"
536 mdata=abcdefghijklmnopqrstuvwxy
537 echo $mdata |
538 awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1
539 for type in btree; do
540 rm -f $TMP2 $TMP3
541 for i in `sed 20000q $DICT | rev`; do
542 echo p
543 echo k$i
544 echo d$mdata
545 echo g
546 echo k$i
547 done > $TMP2
548 $PROG -i psize=512 -o $TMP3 $type $TMP2
549 if (cmp -s $TMP1 $TMP3) ; then :
550 else
551 echo "test12: type $type: failed"
552 exit 1
553 fi
554 done
555}
556
557# Test different byte orders.
558test13()
559{
560 echo "Test 13: btree, hash: differing byte orders"
561 sed 50q $DICT > $TMP1
562 for order in 1234 4321; do
563 for type in btree hash; do
564 rm -f byte.file $TMP2 $TMP3
565 for i in `sed 50q $DICT`; do
566 echo p
567 echo k$i
568 echo d$i
569 echo g
570 echo k$i
571 done > $TMP2
572 $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2
573 if (cmp -s $TMP1 $TMP3) ; then :
574 else
575 echo "test13: $type/$order put failed"
576 exit 1
577 fi
578 for i in `sed 50q $DICT`; do
579 echo g
580 echo k$i
581 done > $TMP2
582 $PROG -s \
583 -ilorder=$order -f byte.file -o $TMP3 $type $TMP2
584 if (cmp -s $TMP1 $TMP3) ; then :
585 else
586 echo "test13: $type/$order get failed"
587 exit 1
588 fi
589 done
590 done
591 rm -f byte.file
592}
593
594# Try a variety of bucketsizes and fill factors for hashing
595test20()
596{
597 echo\
598 "Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536"
599 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
600 awk '{
601 for (i = 1; i <= 10000; ++i) {
602 if (i % 34)
603 s = substr($0, 1, i % 34);
604 else
605 s = substr($0, 1);
606 printf("%s\n", s);
607 }
608 exit;
609 }' > $TMP1
610 sed 10000q $DICT |
611 awk 'BEGIN {
612 ds="abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg"
613 }
614 {
615 if (++i % 34)
616 s = substr(ds, 1, i % 34);
617 else
618 s = substr(ds, 1);
619 printf("p\nk%s\nd%s\n", $0, s);
620 }' > $TMP2
621 sed 10000q $DICT |
622 awk '{
623 ++i;
624 printf("g\nk%s\n", $0);
625 }' >> $TMP2
626 bsize=256
627 for ffactor in 11 14 21; do
628 echo " bucketsize $bsize, fill factor $ffactor"
629 $PROG -o$TMP3 \
630 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
631 hash $TMP2
632 if (cmp -s $TMP1 $TMP3) ; then :
633 else
634 echo "test20: type hash:\
635bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
636 exit 1
637 fi
638 done
639 bsize=512
640 for ffactor in 21 28 43; do
641 echo " bucketsize $bsize, fill factor $ffactor"
642 $PROG -o$TMP3 \
643 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
644 hash $TMP2
645 if (cmp -s $TMP1 $TMP3) ; then :
646 else
647 echo "test20: type hash:\
648bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
649 exit 1
650 fi
651 done
652 bsize=1024
653 for ffactor in 43 57 85; do
654 echo " bucketsize $bsize, fill factor $ffactor"
655 $PROG -o$TMP3 \
656 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
657 hash $TMP2
658 if (cmp -s $TMP1 $TMP3) ; then :
659 else
660 echo "test20: type hash:\
661bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
662 exit 1
663 fi
664 done
665 bsize=2048
666 for ffactor in 85 114 171; do
667 echo " bucketsize $bsize, fill factor $ffactor"
668 $PROG -o$TMP3 \
669 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
670 hash $TMP2
671 if (cmp -s $TMP1 $TMP3) ; then :
672 else
673 echo "test20: type hash:\
674bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
675 exit 1
676 fi
677 done
678 bsize=4096
679 for ffactor in 171 228 341; do
680 echo " bucketsize $bsize, fill factor $ffactor"
681 $PROG -o$TMP3 \
682 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
683 hash $TMP2
684 if (cmp -s $TMP1 $TMP3) ; then :
685 else
686 echo "test20: type hash:\
687bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
688 exit 1
689 fi
690 done
691 bsize=8192
692 for ffactor in 341 455 683; do
693 echo " bucketsize $bsize, fill factor $ffactor"
694 $PROG -o$TMP3 \
695 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
696 hash $TMP2
697 if (cmp -s $TMP1 $TMP3) ; then :
698 else
699 echo "test20: type hash:\
700bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
701 exit 1
702 fi
703 done
704}
705
706main $*
diff --git a/src/regress/lib/libc/ieeefp/Makefile b/src/regress/lib/libc/ieeefp/Makefile
new file mode 100644
index 0000000000..0f453a31e9
--- /dev/null
+++ b/src/regress/lib/libc/ieeefp/Makefile
@@ -0,0 +1,9 @@
1# $NetBSD: Makefile,v 1.5 1996/04/09 16:54:18 phil Exp $
2
3SUBDIR+= except round
4
5regress: _SUBDIRUSE
6
7install:
8
9.include <bsd.subdir.mk>
diff --git a/src/regress/lib/libc/ieeefp/except/Makefile b/src/regress/lib/libc/ieeefp/except/Makefile
new file mode 100644
index 0000000000..91f24f15f6
--- /dev/null
+++ b/src/regress/lib/libc/ieeefp/except/Makefile
@@ -0,0 +1,12 @@
1# $NetBSD: Makefile,v 1.1 1995/04/26 00:27:25 jtc Exp $
2
3PROG= except
4SRCS= except.c
5NOMAN=
6
7install:
8
9regress: ${PROG}
10 ./${PROG}
11
12.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/ieeefp/except/except.c b/src/regress/lib/libc/ieeefp/except/except.c
new file mode 100644
index 0000000000..a2a107a788
--- /dev/null
+++ b/src/regress/lib/libc/ieeefp/except/except.c
@@ -0,0 +1,88 @@
1#include <stdio.h>
2#include <signal.h>
3#include <assert.h>
4#include <ieeefp.h>
5#include <float.h>
6
7void sigfpe();
8volatile sig_atomic_t signal_cought;
9
10static volatile const double one = 1.0;
11static volatile const double zero = 0.0;
12static volatile const double huge = DBL_MAX;
13static volatile const double tiny = DBL_MIN;
14
15int
16main()
17{
18 volatile double x;
19
20 /*
21 * check to make sure that all exceptions are masked and
22 * that the accumulated exception status is clear.
23 */
24 assert(fpgetmask() == 0);
25 assert(fpgetsticky() == 0);
26
27 /* set up signal handler */
28 signal (SIGFPE, sigfpe);
29 signal_cought = 0;
30
31 /* trip divide by zero */
32 x = one / zero;
33 assert (fpgetsticky() & FP_X_DZ);
34 assert (signal_cought == 0);
35 fpsetsticky(0);
36
37 /* trip invalid operation */
38 x = zero / zero;
39 assert (fpgetsticky() & FP_X_INV);
40 assert (signal_cought == 0);
41 fpsetsticky(0);
42
43 /* trip overflow */
44 x = huge * huge;
45 assert (fpgetsticky() & FP_X_OFL);
46 assert (signal_cought == 0);
47 fpsetsticky(0);
48
49 /* trip underflow */
50 x = tiny * tiny;
51 assert (fpgetsticky() & FP_X_UFL);
52 assert (signal_cought == 0);
53 fpsetsticky(0);
54
55#if 0
56 /* unmask and then trip divide by zero */
57 fpsetmask(FP_X_DZ);
58 x = one / zero;
59 assert (signal_cought == 1);
60 signal_cought = 0;
61
62 /* unmask and then trip invalid operation */
63 fpsetmask(FP_X_INV);
64 x = zero / zero;
65 assert (signal_cought == 1);
66 signal_cought = 0;
67
68 /* unmask and then trip overflow */
69 fpsetmask(FP_X_OFL);
70 x = huge * huge;
71 assert (signal_cought == 1);
72 signal_cought = 0;
73
74 /* unmask and then trip underflow */
75 fpsetmask(FP_X_UFL);
76 x = tiny * tiny;
77 assert (signal_cought == 1);
78 signal_cought = 0;
79#endif
80
81 exit(0);
82}
83
84void
85sigfpe()
86{
87 signal_cought = 1;
88}
diff --git a/src/regress/lib/libc/ieeefp/round/Makefile b/src/regress/lib/libc/ieeefp/round/Makefile
new file mode 100644
index 0000000000..571133436c
--- /dev/null
+++ b/src/regress/lib/libc/ieeefp/round/Makefile
@@ -0,0 +1,12 @@
1# $NetBSD: Makefile,v 1.1 1995/04/26 00:27:27 jtc Exp $
2
3PROG= round
4SRCS= round.c
5NOMAN=
6
7install:
8
9regress: ${PROG}
10 ./${PROG}
11
12.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/ieeefp/round/round.c b/src/regress/lib/libc/ieeefp/round/round.c
new file mode 100644
index 0000000000..b9fcd9771e
--- /dev/null
+++ b/src/regress/lib/libc/ieeefp/round/round.c
@@ -0,0 +1,44 @@
1/* $NetBSD: round.c,v 1.1 1995/04/26 00:27:28 jtc Exp $ */
2
3/*
4 * Written by J.T. Conklin, Apr 18, 1995
5 * Public domain.
6 */
7
8#include <assert.h>
9#include <stdlib.h>
10#include <ieeefp.h>
11#include <float.h>
12
13int
14main()
15{
16 /*
17 * This test would be better if it actually performed some
18 * calculations to verify the selected rounding mode. But
19 * this is probably acceptable since the fp{get,set}round
20 * functions usually just get or set the processors fpu
21 * control word.
22 */
23
24 assert(fpgetround() == FP_RN);
25 assert(FLT_ROUNDS == 1);
26
27 assert(fpsetround(FP_RP) == FP_RN);
28 assert(fpgetround() == FP_RP);
29 assert(FLT_ROUNDS == 2);
30
31 assert(fpsetround(FP_RM) == FP_RP);
32 assert(fpgetround() == FP_RM);
33 assert(FLT_ROUNDS == 3);
34
35 assert(fpsetround(FP_RZ) == FP_RM);
36 assert(fpgetround() == FP_RZ);
37 assert(FLT_ROUNDS == 0);
38
39 assert(fpsetround(FP_RN) == FP_RZ);
40 assert(fpgetround() == FP_RN);
41 assert(FLT_ROUNDS == 1);
42
43 exit(0);
44}
diff --git a/src/regress/lib/libc/regex/Makefile b/src/regress/lib/libc/regex/Makefile
new file mode 100644
index 0000000000..93b7bb9052
--- /dev/null
+++ b/src/regress/lib/libc/regex/Makefile
@@ -0,0 +1,16 @@
1# $NetBSD: Makefile,v 1.2 1995/02/16 19:38:45 cgd Exp $
2
3PROG= re
4SRCS= main.c split.c debug.c
5NOMAN=
6
7CFLAGS+= -I${.CURDIR}/../../../../lib/libc/regex
8
9TESTS= ${.CURDIR}/tests
10
11regress:
12 ./re < ${TESTS}
13 ./re -el < ${TESTS}
14 ./re -er < ${TESTS}
15
16.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/regex/debug.c b/src/regress/lib/libc/regex/debug.c
new file mode 100644
index 0000000000..41cd4a557d
--- /dev/null
+++ b/src/regress/lib/libc/regex/debug.c
@@ -0,0 +1,244 @@
1/* $NetBSD: debug.c,v 1.2 1995/04/20 22:39:42 cgd Exp $ */
2
3#include <stdio.h>
4#include <string.h>
5#include <ctype.h>
6#include <limits.h>
7#include <stdlib.h>
8#include <sys/types.h>
9#include <regex.h>
10
11#include "utils.h"
12#include "regex2.h"
13#include "debug.ih"
14
15/*
16 - regprint - print a regexp for debugging
17 == void regprint(regex_t *r, FILE *d);
18 */
19void
20regprint(r, d)
21regex_t *r;
22FILE *d;
23{
24 register struct re_guts *g = r->re_g;
25 register int i;
26 register int c;
27 register int last;
28 int nincat[NC];
29
30 fprintf(d, "%ld states, %d categories", (long)g->nstates,
31 g->ncategories);
32 fprintf(d, ", first %ld last %ld", (long)g->firststate,
33 (long)g->laststate);
34 if (g->iflags&USEBOL)
35 fprintf(d, ", USEBOL");
36 if (g->iflags&USEEOL)
37 fprintf(d, ", USEEOL");
38 if (g->iflags&BAD)
39 fprintf(d, ", BAD");
40 if (g->nsub > 0)
41 fprintf(d, ", nsub=%ld", (long)g->nsub);
42 if (g->must != NULL)
43 fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen,
44 g->must);
45 if (g->backrefs)
46 fprintf(d, ", backrefs");
47 if (g->nplus > 0)
48 fprintf(d, ", nplus %ld", (long)g->nplus);
49 fprintf(d, "\n");
50 s_print(g, d);
51 for (i = 0; i < g->ncategories; i++) {
52 nincat[i] = 0;
53 for (c = CHAR_MIN; c <= CHAR_MAX; c++)
54 if (g->categories[c] == i)
55 nincat[i]++;
56 }
57 fprintf(d, "cc0#%d", nincat[0]);
58 for (i = 1; i < g->ncategories; i++)
59 if (nincat[i] == 1) {
60 for (c = CHAR_MIN; c <= CHAR_MAX; c++)
61 if (g->categories[c] == i)
62 break;
63 fprintf(d, ", %d=%s", i, regchar(c));
64 }
65 fprintf(d, "\n");
66 for (i = 1; i < g->ncategories; i++)
67 if (nincat[i] != 1) {
68 fprintf(d, "cc%d\t", i);
69 last = -1;
70 for (c = CHAR_MIN; c <= CHAR_MAX+1; c++) /* +1 does flush */
71 if (c <= CHAR_MAX && g->categories[c] == i) {
72 if (last < 0) {
73 fprintf(d, "%s", regchar(c));
74 last = c;
75 }
76 } else {
77 if (last >= 0) {
78 if (last != c-1)
79 fprintf(d, "-%s",
80 regchar(c-1));
81 last = -1;
82 }
83 }
84 fprintf(d, "\n");
85 }
86}
87
88/*
89 - s_print - print the strip for debugging
90 == static void s_print(register struct re_guts *g, FILE *d);
91 */
92static void
93s_print(g, d)
94register struct re_guts *g;
95FILE *d;
96{
97 register sop *s;
98 register cset *cs;
99 register int i;
100 register int done = 0;
101 register sop opnd;
102 register int col = 0;
103 register int last;
104 register sopno offset = 2;
105# define GAP() { if (offset % 5 == 0) { \
106 if (col > 40) { \
107 fprintf(d, "\n\t"); \
108 col = 0; \
109 } else { \
110 fprintf(d, " "); \
111 col++; \
112 } \
113 } else \
114 col++; \
115 offset++; \
116 }
117
118 if (OP(g->strip[0]) != OEND)
119 fprintf(d, "missing initial OEND!\n");
120 for (s = &g->strip[1]; !done; s++) {
121 opnd = OPND(*s);
122 switch (OP(*s)) {
123 case OEND:
124 fprintf(d, "\n");
125 done = 1;
126 break;
127 case OCHAR:
128 if (strchr("\\|()^$.[+*?{}!<> ", (char)opnd) != NULL)
129 fprintf(d, "\\%c", (char)opnd);
130 else
131 fprintf(d, "%s", regchar((char)opnd));
132 break;
133 case OBOL:
134 fprintf(d, "^");
135 break;
136 case OEOL:
137 fprintf(d, "$");
138 break;
139 case OBOW:
140 fprintf(d, "\\{");
141 break;
142 case OEOW:
143 fprintf(d, "\\}");
144 break;
145 case OANY:
146 fprintf(d, ".");
147 break;
148 case OANYOF:
149 fprintf(d, "[(%ld)", (long)opnd);
150 cs = &g->sets[opnd];
151 last = -1;
152 for (i = 0; i < g->csetsize+1; i++) /* +1 flushes */
153 if (CHIN(cs, i) && i < g->csetsize) {
154 if (last < 0) {
155 fprintf(d, "%s", regchar(i));
156 last = i;
157 }
158 } else {
159 if (last >= 0) {
160 if (last != i-1)
161 fprintf(d, "-%s",
162 regchar(i-1));
163 last = -1;
164 }
165 }
166 fprintf(d, "]");
167 break;
168 case OBACK_:
169 fprintf(d, "(\\<%ld>", (long)opnd);
170 break;
171 case O_BACK:
172 fprintf(d, "<%ld>\\)", (long)opnd);
173 break;
174 case OPLUS_:
175 fprintf(d, "(+");
176 if (OP(*(s+opnd)) != O_PLUS)
177 fprintf(d, "<%ld>", (long)opnd);
178 break;
179 case O_PLUS:
180 if (OP(*(s-opnd)) != OPLUS_)
181 fprintf(d, "<%ld>", (long)opnd);
182 fprintf(d, "+)");
183 break;
184 case OQUEST_:
185 fprintf(d, "(?");
186 if (OP(*(s+opnd)) != O_QUEST)
187 fprintf(d, "<%ld>", (long)opnd);
188 break;
189 case O_QUEST:
190 if (OP(*(s-opnd)) != OQUEST_)
191 fprintf(d, "<%ld>", (long)opnd);
192 fprintf(d, "?)");
193 break;
194 case OLPAREN:
195 fprintf(d, "((<%ld>", (long)opnd);
196 break;
197 case ORPAREN:
198 fprintf(d, "<%ld>))", (long)opnd);
199 break;
200 case OCH_:
201 fprintf(d, "<");
202 if (OP(*(s+opnd)) != OOR2)
203 fprintf(d, "<%ld>", (long)opnd);
204 break;
205 case OOR1:
206 if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_)
207 fprintf(d, "<%ld>", (long)opnd);
208 fprintf(d, "|");
209 break;
210 case OOR2:
211 fprintf(d, "|");
212 if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH)
213 fprintf(d, "<%ld>", (long)opnd);
214 break;
215 case O_CH:
216 if (OP(*(s-opnd)) != OOR1)
217 fprintf(d, "<%ld>", (long)opnd);
218 fprintf(d, ">");
219 break;
220 default:
221 fprintf(d, "!%ld(%ld)!", (long)OP(*s), (long)opnd);
222 break;
223 }
224 if (!done)
225 GAP();
226 }
227}
228
229/*
230 - regchar - make a character printable
231 == static char *regchar(int ch);
232 */
233static char * /* -> representation */
234regchar(ch)
235int ch;
236{
237 static char buf[10];
238
239 if (isprint(ch) || ch == ' ')
240 sprintf(buf, "%c", ch);
241 else
242 sprintf(buf, "\\%o", ch);
243 return(buf);
244}
diff --git a/src/regress/lib/libc/regex/debug.ih b/src/regress/lib/libc/regex/debug.ih
new file mode 100644
index 0000000000..fb9bac0c75
--- /dev/null
+++ b/src/regress/lib/libc/regex/debug.ih
@@ -0,0 +1,16 @@
1/* $NetBSD: debug.ih,v 1.2 1995/04/20 22:39:47 cgd Exp $ */
2
3/* ========= begin header generated by ./mkh ========= */
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/* === debug.c === */
9void regprint __P((regex_t *r, FILE *d));
10static void s_print __P((register struct re_guts *g, FILE *d));
11static char *regchar __P((int ch));
12
13#ifdef __cplusplus
14}
15#endif
16/* ========= end header generated by ./mkh ========= */
diff --git a/src/regress/lib/libc/regex/main.c b/src/regress/lib/libc/regex/main.c
new file mode 100644
index 0000000000..6e63ffc235
--- /dev/null
+++ b/src/regress/lib/libc/regex/main.c
@@ -0,0 +1,515 @@
1/* $OpenBSD: main.c,v 1.3 1997/01/15 23:41:07 millert Exp $ */
2/* $NetBSD: main.c,v 1.2 1995/04/20 22:39:51 cgd Exp $ */
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <sys/types.h>
8#include <regex.h>
9#include <assert.h>
10#include <unistd.h>
11
12#include "main.ih"
13
14char *progname;
15int debug = 0;
16int line = 0;
17int status = 0;
18
19int copts = REG_EXTENDED;
20int eopts = 0;
21regoff_t startoff = 0;
22regoff_t endoff = 0;
23
24
25extern int split();
26extern void regprint();
27
28/*
29 - main - do the simple case, hand off to regress() for regression
30 */
31int
32main(argc, argv)
33int argc;
34char *argv[];
35{
36 regex_t re;
37# define NS 10
38 regmatch_t subs[NS];
39 char erbuf[100];
40 int err;
41 size_t len;
42 int c;
43 int errflg = 0;
44 register int i;
45 extern int optind;
46 extern char *optarg;
47
48 progname = argv[0];
49
50 while ((c = getopt(argc, argv, "c:e:S:E:x")) != -1)
51 switch (c) {
52 case 'c': /* compile options */
53 copts = options('c', optarg);
54 break;
55 case 'e': /* execute options */
56 eopts = options('e', optarg);
57 break;
58 case 'S': /* start offset */
59 startoff = (regoff_t)atoi(optarg);
60 break;
61 case 'E': /* end offset */
62 endoff = (regoff_t)atoi(optarg);
63 break;
64 case 'x': /* Debugging. */
65 debug++;
66 break;
67 case '?':
68 default:
69 errflg++;
70 break;
71 }
72 if (errflg) {
73 fprintf(stderr, "usage: %s ", progname);
74 fprintf(stderr, "[-c copt][-C][-d] [re]\n");
75 exit(2);
76 }
77
78 if (optind >= argc) {
79 regress(stdin);
80 exit(status);
81 }
82
83 err = regcomp(&re, argv[optind++], copts);
84 if (err) {
85 len = regerror(err, &re, erbuf, sizeof(erbuf));
86 fprintf(stderr, "error %s, %d/%d `%s'\n",
87 eprint(err), len, sizeof(erbuf), erbuf);
88 exit(status);
89 }
90 regprint(&re, stdout);
91
92 if (optind >= argc) {
93 regfree(&re);
94 exit(status);
95 }
96
97 if (eopts&REG_STARTEND) {
98 subs[0].rm_so = startoff;
99 subs[0].rm_eo = strlen(argv[optind]) - endoff;
100 }
101 err = regexec(&re, argv[optind], (size_t)NS, subs, eopts);
102 if (err) {
103 len = regerror(err, &re, erbuf, sizeof(erbuf));
104 fprintf(stderr, "error %s, %d/%d `%s'\n",
105 eprint(err), len, sizeof(erbuf), erbuf);
106 exit(status);
107 }
108 if (!(copts&REG_NOSUB)) {
109 len = (size_t)(subs[0].rm_eo - subs[0].rm_so);
110 if (subs[0].rm_so != -1) {
111 if (len != 0)
112 printf("match `%.*s'\n", (int)len,
113 argv[optind] + subs[0].rm_so);
114 else
115 printf("match `'@%.1s\n",
116 argv[optind] + subs[0].rm_so);
117 }
118 for (i = 1; i < NS; i++)
119 if (subs[i].rm_so != -1)
120 printf("(%d) `%.*s'\n", i,
121 (int)(subs[i].rm_eo - subs[i].rm_so),
122 argv[optind] + subs[i].rm_so);
123 }
124 exit(status);
125}
126
127/*
128 - regress - main loop of regression test
129 == void regress(FILE *in);
130 */
131void
132regress(in)
133FILE *in;
134{
135 char inbuf[1000];
136# define MAXF 10
137 char *f[MAXF];
138 int nf;
139 int i;
140 char erbuf[100];
141 size_t ne;
142 char *badpat = "invalid regular expression";
143# define SHORT 10
144 char *bpname = "REG_BADPAT";
145 regex_t re;
146
147 while (fgets(inbuf, sizeof(inbuf), in) != NULL) {
148 line++;
149 if (inbuf[0] == '#' || inbuf[0] == '\n')
150 continue; /* NOTE CONTINUE */
151 inbuf[strlen(inbuf)-1] = '\0'; /* get rid of stupid \n */
152 if (debug)
153 fprintf(stdout, "%d:\n", line);
154 nf = split(inbuf, f, MAXF, "\t\t");
155 if (nf < 3) {
156 fprintf(stderr, "bad input, line %d\n", line);
157 exit(1);
158 }
159 for (i = 0; i < nf; i++)
160 if (strcmp(f[i], "\"\"") == 0)
161 f[i] = "";
162 if (nf <= 3)
163 f[3] = NULL;
164 if (nf <= 4)
165 f[4] = NULL;
166 try(f[0], f[1], f[2], f[3], f[4], options('c', f[1]));
167 if (opt('&', f[1])) /* try with either type of RE */
168 try(f[0], f[1], f[2], f[3], f[4],
169 options('c', f[1]) &~ REG_EXTENDED);
170 }
171
172 ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
173 if (strcmp(erbuf, badpat) != 0 || ne != strlen(badpat)+1) {
174 fprintf(stderr, "end: regerror() test gave `%s' not `%s'\n",
175 erbuf, badpat);
176 status = 1;
177 }
178 ne = regerror(REG_BADPAT, (regex_t *)NULL, erbuf, (size_t)SHORT);
179 if (strncmp(erbuf, badpat, SHORT-1) != 0 || erbuf[SHORT-1] != '\0' ||
180 ne != strlen(badpat)+1) {
181 fprintf(stderr, "end: regerror() short test gave `%s' not `%.*s'\n",
182 erbuf, SHORT-1, badpat);
183 status = 1;
184 }
185 ne = regerror(REG_ITOA|REG_BADPAT, (regex_t *)NULL, erbuf, sizeof(erbuf));
186 if (strcmp(erbuf, bpname) != 0 || ne != strlen(bpname)+1) {
187 fprintf(stderr, "end: regerror() ITOA test gave `%s' not `%s'\n",
188 erbuf, bpname);
189 status = 1;
190 }
191 re.re_endp = bpname;
192 ne = regerror(REG_ATOI, &re, erbuf, sizeof(erbuf));
193 if (atoi(erbuf) != (int)REG_BADPAT) {
194 fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
195 erbuf, (long)REG_BADPAT);
196 status = 1;
197 } else if (ne != strlen(erbuf)+1) {
198 fprintf(stderr, "end: regerror() ATOI test len(`%s') = %ld\n",
199 erbuf, (long)REG_BADPAT);
200 status = 1;
201 }
202}
203
204/*
205 - try - try it, and report on problems
206 == void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
207 */
208void
209try(f0, f1, f2, f3, f4, opts)
210char *f0;
211char *f1;
212char *f2;
213char *f3;
214char *f4;
215int opts; /* may not match f1 */
216{
217 regex_t re;
218# define NSUBS 10
219 regmatch_t subs[NSUBS];
220# define NSHOULD 15
221 char *should[NSHOULD];
222 int nshould;
223 char erbuf[100];
224 int err;
225 int len;
226 char *type = (opts & REG_EXTENDED) ? "ERE" : "BRE";
227 register int i;
228 char *grump;
229 char f0copy[1000];
230 char f2copy[1000];
231
232 strcpy(f0copy, f0);
233 re.re_endp = (opts&REG_PEND) ? f0copy + strlen(f0copy) : NULL;
234 fixstr(f0copy);
235 err = regcomp(&re, f0copy, opts);
236 if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
237 /* unexpected error or wrong error */
238 len = regerror(err, &re, erbuf, sizeof(erbuf));
239 fprintf(stderr, "%d: %s error %s, %d/%d `%s'\n",
240 line, type, eprint(err), len,
241 sizeof(erbuf), erbuf);
242 status = 1;
243 } else if (err == 0 && opt('C', f1)) {
244 /* unexpected success */
245 fprintf(stderr, "%d: %s should have given REG_%s\n",
246 line, type, f2);
247 status = 1;
248 err = 1; /* so we won't try regexec */
249 }
250
251 if (err != 0) {
252 regfree(&re);
253 return;
254 }
255
256 strcpy(f2copy, f2);
257 fixstr(f2copy);
258
259 if (options('e', f1)&REG_STARTEND) {
260 if (strchr(f2, '(') == NULL || strchr(f2, ')') == NULL)
261 fprintf(stderr, "%d: bad STARTEND syntax\n", line);
262 subs[0].rm_so = strchr(f2, '(') - f2 + 1;
263 subs[0].rm_eo = strchr(f2, ')') - f2;
264 }
265 err = regexec(&re, f2copy, NSUBS, subs, options('e', f1));
266
267 if (err != 0 && (f3 != NULL || err != REG_NOMATCH)) {
268 /* unexpected error or wrong error */
269 len = regerror(err, &re, erbuf, sizeof(erbuf));
270 fprintf(stderr, "%d: %s exec error %s, %d/%d `%s'\n",
271 line, type, eprint(err), len,
272 sizeof(erbuf), erbuf);
273 status = 1;
274 } else if (err != 0) {
275 /* nothing more to check */
276 } else if (f3 == NULL) {
277 /* unexpected success */
278 fprintf(stderr, "%d: %s exec should have failed\n",
279 line, type);
280 status = 1;
281 err = 1; /* just on principle */
282 } else if (opts&REG_NOSUB) {
283 /* nothing more to check */
284 } else if ((grump = check(f2, subs[0], f3)) != NULL) {
285 fprintf(stderr, "%d: %s %s\n", line, type, grump);
286 status = 1;
287 err = 1;
288 }
289
290 if (err != 0 || f4 == NULL) {
291 regfree(&re);
292 return;
293 }
294
295 for (i = 1; i < NSHOULD; i++)
296 should[i] = NULL;
297 nshould = split(f4, should+1, NSHOULD-1, ",");
298 if (nshould == 0) {
299 nshould = 1;
300 should[1] = "";
301 }
302 for (i = 1; i < NSUBS; i++) {
303 grump = check(f2, subs[i], should[i]);
304 if (grump != NULL) {
305 fprintf(stderr, "%d: %s $%d %s\n", line,
306 type, i, grump);
307 status = 1;
308 err = 1;
309 }
310 }
311
312 regfree(&re);
313}
314
315/*
316 - options - pick options out of a regression-test string
317 == int options(int type, char *s);
318 */
319int
320options(type, s)
321int type; /* 'c' compile, 'e' exec */
322char *s;
323{
324 register char *p;
325 register int o = (type == 'c') ? copts : eopts;
326 register char *legal = (type == 'c') ? "bisnmp" : "^$#tl";
327
328 for (p = s; *p != '\0'; p++)
329 if (strchr(legal, *p) != NULL)
330 switch (*p) {
331 case 'b':
332 o &= ~REG_EXTENDED;
333 break;
334 case 'i':
335 o |= REG_ICASE;
336 break;
337 case 's':
338 o |= REG_NOSUB;
339 break;
340 case 'n':
341 o |= REG_NEWLINE;
342 break;
343 case 'm':
344 o &= ~REG_EXTENDED;
345 o |= REG_NOSPEC;
346 break;
347 case 'p':
348 o |= REG_PEND;
349 break;
350 case '^':
351 o |= REG_NOTBOL;
352 break;
353 case '$':
354 o |= REG_NOTEOL;
355 break;
356 case '#':
357 o |= REG_STARTEND;
358 break;
359 case 't': /* trace */
360 o |= REG_TRACE;
361 break;
362 case 'l': /* force long representation */
363 o |= REG_LARGE;
364 break;
365 case 'r': /* force backref use */
366 o |= REG_BACKR;
367 break;
368 }
369 return(o);
370}
371
372/*
373 - opt - is a particular option in a regression string?
374 == int opt(int c, char *s);
375 */
376int /* predicate */
377opt(c, s)
378int c;
379char *s;
380{
381 return(strchr(s, c) != NULL);
382}
383
384/*
385 - fixstr - transform magic characters in strings
386 == void fixstr(register char *p);
387 */
388void
389fixstr(p)
390register char *p;
391{
392 if (p == NULL)
393 return;
394
395 for (; *p != '\0'; p++)
396 if (*p == 'N')
397 *p = '\n';
398 else if (*p == 'T')
399 *p = '\t';
400 else if (*p == 'S')
401 *p = ' ';
402 else if (*p == 'Z')
403 *p = '\0';
404}
405
406/*
407 - check - check a substring match
408 == char *check(char *str, regmatch_t sub, char *should);
409 */
410char * /* NULL or complaint */
411check(str, sub, should)
412char *str;
413regmatch_t sub;
414char *should;
415{
416 register int len;
417 register int shlen;
418 register char *p;
419 static char grump[500];
420 register char *at = NULL;
421
422 if (should != NULL && strcmp(should, "-") == 0)
423 should = NULL;
424 if (should != NULL && should[0] == '@') {
425 at = should + 1;
426 should = "";
427 }
428
429 /* check rm_so and rm_eo for consistency */
430 if (sub.rm_so > sub.rm_eo || (sub.rm_so == -1 && sub.rm_eo != -1) ||
431 (sub.rm_so != -1 && sub.rm_eo == -1) ||
432 (sub.rm_so != -1 && sub.rm_so < 0) ||
433 (sub.rm_eo != -1 && sub.rm_eo < 0) ) {
434 sprintf(grump, "start %ld end %ld", (long)sub.rm_so,
435 (long)sub.rm_eo);
436 return(grump);
437 }
438
439 /* check for no match */
440 if (sub.rm_so == -1 && should == NULL)
441 return(NULL);
442 if (sub.rm_so == -1)
443 return("did not match");
444
445 /* check for in range */
446 if (sub.rm_eo > strlen(str)) {
447 sprintf(grump, "start %ld end %ld, past end of string",
448 (long)sub.rm_so, (long)sub.rm_eo);
449 return(grump);
450 }
451
452 len = (int)(sub.rm_eo - sub.rm_so);
453 shlen = (int)strlen(should);
454 p = str + sub.rm_so;
455
456 /* check for not supposed to match */
457 if (should == NULL) {
458 sprintf(grump, "matched `%.*s'", len, p);
459 return(grump);
460 }
461
462 /* check for wrong match */
463 if (len != shlen || strncmp(p, should, (size_t)shlen) != 0) {
464 sprintf(grump, "matched `%.*s' instead", len, p);
465 return(grump);
466 }
467 if (shlen > 0)
468 return(NULL);
469
470 /* check null match in right place */
471 if (at == NULL)
472 return(NULL);
473 shlen = strlen(at);
474 if (shlen == 0)
475 shlen = 1; /* force check for end-of-string */
476 if (strncmp(p, at, shlen) != 0) {
477 sprintf(grump, "matched null at `%.20s'", p);
478 return(grump);
479 }
480 return(NULL);
481}
482
483/*
484 - eprint - convert error number to name
485 == static char *eprint(int err);
486 */
487static char *
488eprint(err)
489int err;
490{
491 static char epbuf[100];
492 size_t len;
493
494 len = regerror(REG_ITOA|err, (regex_t *)NULL, epbuf, sizeof(epbuf));
495 assert(len <= sizeof(epbuf));
496 return(epbuf);
497}
498
499/*
500 - efind - convert error name to number
501 == static int efind(char *name);
502 */
503static int
504efind(name)
505char *name;
506{
507 static char efbuf[100];
508 regex_t re;
509
510 sprintf(efbuf, "REG_%s", name);
511 assert(strlen(efbuf) < sizeof(efbuf));
512 re.re_endp = efbuf;
513 (void) regerror(REG_ATOI, &re, efbuf, sizeof(efbuf));
514 return(atoi(efbuf));
515}
diff --git a/src/regress/lib/libc/regex/main.ih b/src/regress/lib/libc/regex/main.ih
new file mode 100644
index 0000000000..135e3e792d
--- /dev/null
+++ b/src/regress/lib/libc/regex/main.ih
@@ -0,0 +1,21 @@
1/* $NetBSD: main.ih,v 1.2 1995/04/20 22:39:55 cgd Exp $ */
2
3/* ========= begin header generated by ./mkh ========= */
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/* === main.c === */
9void regress __P((FILE *in));
10void try __P((char *f0, char *f1, char *f2, char *f3, char *f4, int opts));
11int options __P((int type, char *s));
12int opt __P((int c, char *s));
13void fixstr __P((register char *p));
14char *check __P((char *str, regmatch_t sub, char *should));
15static char *eprint __P((int err));
16static int efind __P((char *name));
17
18#ifdef __cplusplus
19}
20#endif
21/* ========= end header generated by ./mkh ========= */
diff --git a/src/regress/lib/libc/regex/split.c b/src/regress/lib/libc/regex/split.c
new file mode 100644
index 0000000000..dd1ca14480
--- /dev/null
+++ b/src/regress/lib/libc/regex/split.c
@@ -0,0 +1,318 @@
1/* $NetBSD: split.c,v 1.2 1995/04/20 22:39:57 cgd Exp $ */
2
3#include <stdio.h>
4#include <string.h>
5
6/*
7 - split - divide a string into fields, like awk split()
8 = int split(char *string, char *fields[], int nfields, char *sep);
9 */
10int /* number of fields, including overflow */
11split(string, fields, nfields, sep)
12char *string;
13char *fields[]; /* list is not NULL-terminated */
14int nfields; /* number of entries available in fields[] */
15char *sep; /* "" white, "c" single char, "ab" [ab]+ */
16{
17 register char *p = string;
18 register char c; /* latest character */
19 register char sepc = sep[0];
20 register char sepc2;
21 register int fn;
22 register char **fp = fields;
23 register char *sepp;
24 register int trimtrail;
25
26 /* white space */
27 if (sepc == '\0') {
28 while ((c = *p++) == ' ' || c == '\t')
29 continue;
30 p--;
31 trimtrail = 1;
32 sep = " \t"; /* note, code below knows this is 2 long */
33 sepc = ' ';
34 } else
35 trimtrail = 0;
36 sepc2 = sep[1]; /* now we can safely pick this up */
37
38 /* catch empties */
39 if (*p == '\0')
40 return(0);
41
42 /* single separator */
43 if (sepc2 == '\0') {
44 fn = nfields;
45 for (;;) {
46 *fp++ = p;
47 fn--;
48 if (fn == 0)
49 break;
50 while ((c = *p++) != sepc)
51 if (c == '\0')
52 return(nfields - fn);
53 *(p-1) = '\0';
54 }
55 /* we have overflowed the fields vector -- just count them */
56 fn = nfields;
57 for (;;) {
58 while ((c = *p++) != sepc)
59 if (c == '\0')
60 return(fn);
61 fn++;
62 }
63 /* not reached */
64 }
65
66 /* two separators */
67 if (sep[2] == '\0') {
68 fn = nfields;
69 for (;;) {
70 *fp++ = p;
71 fn--;
72 while ((c = *p++) != sepc && c != sepc2)
73 if (c == '\0') {
74 if (trimtrail && **(fp-1) == '\0')
75 fn++;
76 return(nfields - fn);
77 }
78 if (fn == 0)
79 break;
80 *(p-1) = '\0';
81 while ((c = *p++) == sepc || c == sepc2)
82 continue;
83 p--;
84 }
85 /* we have overflowed the fields vector -- just count them */
86 fn = nfields;
87 while (c != '\0') {
88 while ((c = *p++) == sepc || c == sepc2)
89 continue;
90 p--;
91 fn++;
92 while ((c = *p++) != '\0' && c != sepc && c != sepc2)
93 continue;
94 }
95 /* might have to trim trailing white space */
96 if (trimtrail) {
97 p--;
98 while ((c = *--p) == sepc || c == sepc2)
99 continue;
100 p++;
101 if (*p != '\0') {
102 if (fn == nfields+1)
103 *p = '\0';
104 fn--;
105 }
106 }
107 return(fn);
108 }
109
110 /* n separators */
111 fn = 0;
112 for (;;) {
113 if (fn < nfields)
114 *fp++ = p;
115 fn++;
116 for (;;) {
117 c = *p++;
118 if (c == '\0')
119 return(fn);
120 sepp = sep;
121 while ((sepc = *sepp++) != '\0' && sepc != c)
122 continue;
123 if (sepc != '\0') /* it was a separator */
124 break;
125 }
126 if (fn < nfields)
127 *(p-1) = '\0';
128 for (;;) {
129 c = *p++;
130 sepp = sep;
131 while ((sepc = *sepp++) != '\0' && sepc != c)
132 continue;
133 if (sepc == '\0') /* it wasn't a separator */
134 break;
135 }
136 p--;
137 }
138
139 /* not reached */
140}
141
142#ifdef TEST_SPLIT
143
144
145/*
146 * test program
147 * pgm runs regression
148 * pgm sep splits stdin lines by sep
149 * pgm str sep splits str by sep
150 * pgm str sep n splits str by sep n times
151 */
152int
153main(argc, argv)
154int argc;
155char *argv[];
156{
157 char buf[512];
158 register int n;
159# define MNF 10
160 char *fields[MNF];
161
162 if (argc > 4)
163 for (n = atoi(argv[3]); n > 0; n--) {
164 (void) strcpy(buf, argv[1]);
165 }
166 else if (argc > 3)
167 for (n = atoi(argv[3]); n > 0; n--) {
168 (void) strcpy(buf, argv[1]);
169 (void) split(buf, fields, MNF, argv[2]);
170 }
171 else if (argc > 2)
172 dosplit(argv[1], argv[2]);
173 else if (argc > 1)
174 while (fgets(buf, sizeof(buf), stdin) != NULL) {
175 buf[strlen(buf)-1] = '\0'; /* stomp newline */
176 dosplit(buf, argv[1]);
177 }
178 else
179 regress();
180
181 exit(0);
182}
183
184dosplit(string, seps)
185char *string;
186char *seps;
187{
188# define NF 5
189 char *fields[NF];
190 register int nf;
191
192 nf = split(string, fields, NF, seps);
193 print(nf, NF, fields);
194}
195
196print(nf, nfp, fields)
197int nf;
198int nfp;
199char *fields[];
200{
201 register int fn;
202 register int bound;
203
204 bound = (nf > nfp) ? nfp : nf;
205 printf("%d:\t", nf);
206 for (fn = 0; fn < bound; fn++)
207 printf("\"%s\"%s", fields[fn], (fn+1 < nf) ? ", " : "\n");
208}
209
210#define RNF 5 /* some table entries know this */
211struct {
212 char *str;
213 char *seps;
214 int nf;
215 char *fi[RNF];
216} tests[] = {
217 "", " ", 0, { "" },
218 " ", " ", 2, { "", "" },
219 "x", " ", 1, { "x" },
220 "xy", " ", 1, { "xy" },
221 "x y", " ", 2, { "x", "y" },
222 "abc def g ", " ", 5, { "abc", "def", "", "g", "" },
223 " a bcd", " ", 4, { "", "", "a", "bcd" },
224 "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" },
225 " a b c d ", " ", 6, { "", "a", "b", "c", "d " },
226
227 "", " _", 0, { "" },
228 " ", " _", 2, { "", "" },
229 "x", " _", 1, { "x" },
230 "x y", " _", 2, { "x", "y" },
231 "ab _ cd", " _", 2, { "ab", "cd" },
232 " a_b c ", " _", 5, { "", "a", "b", "c", "" },
233 "a b c_d e f", " _", 6, { "a", "b", "c", "d", "e f" },
234 " a b c d ", " _", 6, { "", "a", "b", "c", "d " },
235
236 "", " _~", 0, { "" },
237 " ", " _~", 2, { "", "" },
238 "x", " _~", 1, { "x" },
239 "x y", " _~", 2, { "x", "y" },
240 "ab _~ cd", " _~", 2, { "ab", "cd" },
241 " a_b c~", " _~", 5, { "", "a", "b", "c", "" },
242 "a b_c d~e f", " _~", 6, { "a", "b", "c", "d", "e f" },
243 "~a b c d ", " _~", 6, { "", "a", "b", "c", "d " },
244
245 "", " _~-", 0, { "" },
246 " ", " _~-", 2, { "", "" },
247 "x", " _~-", 1, { "x" },
248 "x y", " _~-", 2, { "x", "y" },
249 "ab _~- cd", " _~-", 2, { "ab", "cd" },
250 " a_b c~", " _~-", 5, { "", "a", "b", "c", "" },
251 "a b_c-d~e f", " _~-", 6, { "a", "b", "c", "d", "e f" },
252 "~a-b c d ", " _~-", 6, { "", "a", "b", "c", "d " },
253
254 "", " ", 0, { "" },
255 " ", " ", 2, { "", "" },
256 "x", " ", 1, { "x" },
257 "xy", " ", 1, { "xy" },
258 "x y", " ", 2, { "x", "y" },
259 "abc def g ", " ", 4, { "abc", "def", "g", "" },
260 " a bcd", " ", 3, { "", "a", "bcd" },
261 "a b c d e f", " ", 6, { "a", "b", "c", "d", "e f" },
262 " a b c d ", " ", 6, { "", "a", "b", "c", "d " },
263
264 "", "", 0, { "" },
265 " ", "", 0, { "" },
266 "x", "", 1, { "x" },
267 "xy", "", 1, { "xy" },
268 "x y", "", 2, { "x", "y" },
269 "abc def g ", "", 3, { "abc", "def", "g" },
270 "\t a bcd", "", 2, { "a", "bcd" },
271 " a \tb\t c ", "", 3, { "a", "b", "c" },
272 "a b c d e ", "", 5, { "a", "b", "c", "d", "e" },
273 "a b\tc d e f", "", 6, { "a", "b", "c", "d", "e f" },
274 " a b c d e f ", "", 6, { "a", "b", "c", "d", "e f " },
275
276 NULL, NULL, 0, { NULL },
277};
278
279regress()
280{
281 char buf[512];
282 register int n;
283 char *fields[RNF+1];
284 register int nf;
285 register int i;
286 register int printit;
287 register char *f;
288
289 for (n = 0; tests[n].str != NULL; n++) {
290 (void) strcpy(buf, tests[n].str);
291 fields[RNF] = NULL;
292 nf = split(buf, fields, RNF, tests[n].seps);
293 printit = 0;
294 if (nf != tests[n].nf) {
295 printf("split `%s' by `%s' gave %d fields, not %d\n",
296 tests[n].str, tests[n].seps, nf, tests[n].nf);
297 printit = 1;
298 } else if (fields[RNF] != NULL) {
299 printf("split() went beyond array end\n");
300 printit = 1;
301 } else {
302 for (i = 0; i < nf && i < RNF; i++) {
303 f = fields[i];
304 if (f == NULL)
305 f = "(NULL)";
306 if (strcmp(f, tests[n].fi[i]) != 0) {
307 printf("split `%s' by `%s', field %d is `%s', not `%s'\n",
308 tests[n].str, tests[n].seps,
309 i, fields[i], tests[n].fi[i]);
310 printit = 1;
311 }
312 }
313 }
314 if (printit)
315 print(nf, RNF, fields);
316 }
317}
318#endif
diff --git a/src/regress/lib/libc/regex/tests b/src/regress/lib/libc/regex/tests
new file mode 100644
index 0000000000..8e89f161b1
--- /dev/null
+++ b/src/regress/lib/libc/regex/tests
@@ -0,0 +1,477 @@
1# $NetBSD: tests,v 1.5 1995/04/20 22:40:00 cgd Exp $
2
3# regular expression test set
4# Lines are at least three fields, separated by one or more tabs. "" stands
5# for an empty field. First field is an RE. Second field is flags. If
6# C flag given, regcomp() is expected to fail, and the third field is the
7# error name (minus the leading REG_).
8#
9# Otherwise it is expected to succeed, and the third field is the string to
10# try matching it against. If there is no fourth field, the match is
11# expected to fail. If there is a fourth field, it is the substring that
12# the RE is expected to match. If there is a fifth field, it is a comma-
13# separated list of what the subexpressions should match, with - indicating
14# no match for that one. In both the fourth and fifth fields, a (sub)field
15# starting with @ indicates that the (sub)expression is expected to match
16# a null string followed by the stuff after the @; this provides a way to
17# test where null strings match. The character `N' in REs and strings
18# is newline, `S' is space, `T' is tab, `Z' is NUL.
19#
20# The full list of flags:
21# - placeholder, does nothing
22# b RE is a BRE, not an ERE
23# & try it as both an ERE and a BRE
24# C regcomp() error expected, third field is error name
25# i REG_ICASE
26# m ("mundane") REG_NOSPEC
27# s REG_NOSUB (not really testable)
28# n REG_NEWLINE
29# ^ REG_NOTBOL
30# $ REG_NOTEOL
31# # REG_STARTEND (see below)
32# p REG_PEND
33#
34# For REG_STARTEND, the start/end offsets are those of the substring
35# enclosed in ().
36
37# basics
38a & a a
39abc & abc abc
40abc|de - abc abc
41a|b|c - abc a
42
43# parentheses and perversions thereof
44a(b)c - abc abc
45a\(b\)c b abc abc
46a( C EPAREN
47a( b a( a(
48a\( - a( a(
49a\( bC EPAREN
50a\(b bC EPAREN
51a(b C EPAREN
52a(b b a(b a(b
53# gag me with a right parenthesis -- 1003.2 goofed here (my fault, partly)
54a) - a) a)
55) - ) )
56# end gagging (in a just world, those *should* give EPAREN)
57a) b a) a)
58a\) bC EPAREN
59\) bC EPAREN
60a()b - ab ab
61a\(\)b b ab ab
62
63# anchoring and REG_NEWLINE
64^abc$ & abc abc
65a^b - a^b
66a^b b a^b a^b
67a$b - a$b
68a$b b a$b a$b
69^ & abc @abc
70$ & abc @
71^$ & "" @
72$^ - "" @
73\($\)\(^\) b "" @
74# stop retching, those are legitimate (although disgusting)
75^^ - "" @
76$$ - "" @
77b$ & abNc
78b$ &n abNc b
79^b$ & aNbNc
80^b$ &n aNbNc b
81^$ &n aNNb @Nb
82^$ n abc
83^$ n abcN @
84$^ n aNNb @Nb
85\($\)\(^\) bn aNNb @Nb
86^^ n^ aNNb @Nb
87$$ n aNNb @NN
88^a ^ a
89a$ $ a
90^a ^n aNb
91^b ^n aNb b
92a$ $n bNa
93b$ $n bNa b
94a*(^b$)c* - b b
95a*\(^b$\)c* b b b
96
97# certain syntax errors and non-errors
98| C EMPTY
99| b | |
100* C BADRPT
101* b * *
102+ C BADRPT
103? C BADRPT
104"" &C EMPTY
105() - abc @abc
106\(\) b abc @abc
107a||b C EMPTY
108|ab C EMPTY
109ab| C EMPTY
110(|a)b C EMPTY
111(a|)b C EMPTY
112(*a) C BADRPT
113(+a) C BADRPT
114(?a) C BADRPT
115({1}a) C BADRPT
116\(\{1\}a\) bC BADRPT
117(a|*b) C BADRPT
118(a|+b) C BADRPT
119(a|?b) C BADRPT
120(a|{1}b) C BADRPT
121^* C BADRPT
122^* b * *
123^+ C BADRPT
124^? C BADRPT
125^{1} C BADRPT
126^\{1\} bC BADRPT
127
128# metacharacters, backslashes
129a.c & abc abc
130a[bc]d & abd abd
131a\*c & a*c a*c
132a\\b & a\b a\b
133a\\\*b & a\*b a\*b
134a\bc & abc abc
135a\ &C EESCAPE
136a\\bc & a\bc a\bc
137\{ bC BADRPT
138a\[b & a[b a[b
139a[b &C EBRACK
140# trailing $ is a peculiar special case for the BRE code
141a$ & a a
142a$ & a$
143a\$ & a
144a\$ & a$ a$
145a\\$ & a
146a\\$ & a$
147a\\$ & a\$
148a\\$ & a\ a\
149
150# back references, ugh
151a\(b\)\2c bC ESUBREG
152a\(b\1\)c bC ESUBREG
153a\(b*\)c\1d b abbcbbd abbcbbd bb
154a\(b*\)c\1d b abbcbd
155a\(b*\)c\1d b abbcbbbd
156^\(.\)\1 b abc
157a\([bc]\)\1d b abcdabbd abbd b
158a\(\([bc]\)\2\)*d b abbccd abbccd
159a\(\([bc]\)\2\)*d b abbcbd
160# actually, this next one probably ought to fail, but the spec is unclear
161a\(\(b\)*\2\)*d b abbbd abbbd
162# here is a case that no NFA implementation does right
163\(ab*\)[ab]*\1 b ababaaa ababaaa a
164# check out normal matching in the presence of back refs
165\(a\)\1bcd b aabcd aabcd
166\(a\)\1bc*d b aabcd aabcd
167\(a\)\1bc*d b aabd aabd
168\(a\)\1bc*d b aabcccd aabcccd
169\(a\)\1bc*[ce]d b aabcccd aabcccd
170^\(a\)\1b\(c\)*cd$ b aabcccd aabcccd
171
172# ordinary repetitions
173ab*c & abc abc
174ab+c - abc abc
175ab?c - abc abc
176a\(*\)b b a*b a*b
177a\(**\)b b ab ab
178a\(***\)b bC BADRPT
179*a b *a *a
180**a b a a
181***a bC BADRPT
182
183# the dreaded bounded repetitions
184{ & { {
185{abc & {abc {abc
186{1 C BADRPT
187{1} C BADRPT
188a{b & a{b a{b
189a{1}b - ab ab
190a\{1\}b b ab ab
191a{1,}b - ab ab
192a\{1,\}b b ab ab
193a{1,2}b - aab aab
194a\{1,2\}b b aab aab
195a{1 C EBRACE
196a\{1 bC EBRACE
197a{1a C EBRACE
198a\{1a bC EBRACE
199a{1a} C BADBR
200a\{1a\} bC BADBR
201a{,2} - a{,2} a{,2}
202a\{,2\} bC BADBR
203a{,} - a{,} a{,}
204a\{,\} bC BADBR
205a{1,x} C BADBR
206a\{1,x\} bC BADBR
207a{1,x C EBRACE
208a\{1,x bC EBRACE
209a{300} C BADBR
210a\{300\} bC BADBR
211a{1,0} C BADBR
212a\{1,0\} bC BADBR
213ab{0,0}c - abcac ac
214ab\{0,0\}c b abcac ac
215ab{0,1}c - abcac abc
216ab\{0,1\}c b abcac abc
217ab{0,3}c - abbcac abbc
218ab\{0,3\}c b abbcac abbc
219ab{1,1}c - acabc abc
220ab\{1,1\}c b acabc abc
221ab{1,3}c - acabc abc
222ab\{1,3\}c b acabc abc
223ab{2,2}c - abcabbc abbc
224ab\{2,2\}c b abcabbc abbc
225ab{2,4}c - abcabbc abbc
226ab\{2,4\}c b abcabbc abbc
227((a{1,10}){1,10}){1,10} - a a a,a
228
229# multiple repetitions
230a** &C BADRPT
231a++ C BADRPT
232a?? C BADRPT
233a*+ C BADRPT
234a*? C BADRPT
235a+* C BADRPT
236a+? C BADRPT
237a?* C BADRPT
238a?+ C BADRPT
239a{1}{1} C BADRPT
240a*{1} C BADRPT
241a+{1} C BADRPT
242a?{1} C BADRPT
243a{1}* C BADRPT
244a{1}+ C BADRPT
245a{1}? C BADRPT
246a*{b} - a{b} a{b}
247a\{1\}\{1\} bC BADRPT
248a*\{1\} bC BADRPT
249a\{1\}* bC BADRPT
250
251# brackets, and numerous perversions thereof
252a[b]c & abc abc
253a[ab]c & abc abc
254a[^ab]c & adc adc
255a[]b]c & a]c a]c
256a[[b]c & a[c a[c
257a[-b]c & a-c a-c
258a[^]b]c & adc adc
259a[^-b]c & adc adc
260a[b-]c & a-c a-c
261a[b &C EBRACK
262a[] &C EBRACK
263a[1-3]c & a2c a2c
264a[3-1]c &C ERANGE
265a[1-3-5]c &C ERANGE
266a[[.-.]--]c & a-c a-c
267a[1- &C ERANGE
268a[[. &C EBRACK
269a[[.x &C EBRACK
270a[[.x. &C EBRACK
271a[[.x.] &C EBRACK
272a[[.x.]] & ax ax
273a[[.x,.]] &C ECOLLATE
274a[[.one.]]b & a1b a1b
275a[[.notdef.]]b &C ECOLLATE
276a[[.].]]b & a]b a]b
277a[[:alpha:]]c & abc abc
278a[[:notdef:]]c &C ECTYPE
279a[[: &C EBRACK
280a[[:alpha &C EBRACK
281a[[:alpha:] &C EBRACK
282a[[:alpha,:] &C ECTYPE
283a[[:]:]]b &C ECTYPE
284a[[:-:]]b &C ECTYPE
285a[[:alph:]] &C ECTYPE
286a[[:alphabet:]] &C ECTYPE
287[[:alnum:]]+ - -%@a0X- a0X
288[[:alpha:]]+ - -%@aX0- aX
289[[:blank:]]+ - aSSTb SST
290[[:cntrl:]]+ - aNTb NT
291[[:digit:]]+ - a019b 019
292[[:graph:]]+ - Sa%bS a%b
293[[:lower:]]+ - AabC ab
294[[:print:]]+ - NaSbN aSb
295[[:punct:]]+ - S%-&T %-&
296[[:space:]]+ - aSNTb SNT
297[[:upper:]]+ - aBCd BC
298[[:xdigit:]]+ - p0f3Cq 0f3C
299a[[=b=]]c & abc abc
300a[[= &C EBRACK
301a[[=b &C EBRACK
302a[[=b= &C EBRACK
303a[[=b=] &C EBRACK
304a[[=b,=]] &C ECOLLATE
305a[[=one=]]b & a1b a1b
306
307# complexities
308a(((b)))c - abc abc
309a(b|(c))d - abd abd
310a(b*|c)d - abbd abbd
311# just gotta have one DFA-buster, of course
312a[ab]{20} - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab
313# and an inline expansion in case somebody gets tricky
314a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab] - aaaaabaaaabaaaabaaaab aaaaabaaaabaaaabaaaab
315# and in case somebody just slips in an NFA...
316a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night) - aaaaabaaaabaaaabaaaabweeknights aaaaabaaaabaaaabaaaabweeknights
317# fish for anomalies as the number of states passes 32
31812345678901234567890123456789 - a12345678901234567890123456789b 12345678901234567890123456789
319123456789012345678901234567890 - a123456789012345678901234567890b 123456789012345678901234567890
3201234567890123456789012345678901 - a1234567890123456789012345678901b 1234567890123456789012345678901
32112345678901234567890123456789012 - a12345678901234567890123456789012b 12345678901234567890123456789012
322123456789012345678901234567890123 - a123456789012345678901234567890123b 123456789012345678901234567890123
323# and one really big one, beyond any plausible word width
3241234567890123456789012345678901234567890123456789012345678901234567890 - a1234567890123456789012345678901234567890123456789012345678901234567890b 1234567890123456789012345678901234567890123456789012345678901234567890
325# fish for problems as brackets go past 8
326[ab][cd][ef][gh][ij][kl][mn] - xacegikmoq acegikm
327[ab][cd][ef][gh][ij][kl][mn][op] - xacegikmoq acegikmo
328[ab][cd][ef][gh][ij][kl][mn][op][qr] - xacegikmoqy acegikmoq
329[ab][cd][ef][gh][ij][kl][mn][op][q] - xacegikmoqy acegikmoq
330
331# subtleties of matching
332abc & xabcy abc
333a\(b\)?c\1d b acd
334aBc i Abc Abc
335a[Bc]*d i abBCcd abBCcd
3360[[:upper:]]1 &i 0a1 0a1
3370[[:lower:]]1 &i 0A1 0A1
338a[^b]c &i abc
339a[^b]c &i aBc
340a[^b]c &i adc adc
341[a]b[c] - abc abc
342[a]b[a] - aba aba
343[abc]b[abc] - abc abc
344[abc]b[abd] - abd abd
345a(b?c)+d - accd accd
346(wee|week)(knights|night) - weeknights weeknights
347(we|wee|week|frob)(knights|night|day) - weeknights weeknights
348a[bc]d - xyzaaabcaababdacd abd
349a[ab]c - aaabc abc
350abc s abc abc
351a* & b @b
352
353# Let's have some fun -- try to match a C comment.
354# first the obvious, which looks okay at first glance...
355/\*.*\*/ - /*x*/ /*x*/
356# but...
357/\*.*\*/ - /*x*/y/*z*/ /*x*/y/*z*/
358# okay, we must not match */ inside; try to do that...
359/\*([^*]|\*[^/])*\*/ - /*x*/ /*x*/
360/\*([^*]|\*[^/])*\*/ - /*x*/y/*z*/ /*x*/
361# but...
362/\*([^*]|\*[^/])*\*/ - /*x**/y/*z*/ /*x**/y/*z*/
363# and a still fancier version, which does it right (I think)...
364/\*([^*]|\*+[^*/])*\*+/ - /*x*/ /*x*/
365/\*([^*]|\*+[^*/])*\*+/ - /*x*/y/*z*/ /*x*/
366/\*([^*]|\*+[^*/])*\*+/ - /*x**/y/*z*/ /*x**/
367/\*([^*]|\*+[^*/])*\*+/ - /*x****/y/*z*/ /*x****/
368/\*([^*]|\*+[^*/])*\*+/ - /*x**x*/y/*z*/ /*x**x*/
369/\*([^*]|\*+[^*/])*\*+/ - /*x***x/y/*z*/ /*x***x/y/*z*/
370
371# subexpressions
372a(b)(c)d - abcd abcd b,c
373a(((b)))c - abc abc b,b,b
374a(b|(c))d - abd abd b,-
375a(b*|c|e)d - abbd abbd bb
376a(b*|c|e)d - acd acd c
377a(b*|c|e)d - ad ad @d
378a(b?)c - abc abc b
379a(b?)c - ac ac @c
380a(b+)c - abc abc b
381a(b+)c - abbbc abbbc bbb
382a(b*)c - ac ac @c
383(a|ab)(bc([de]+)f|cde) - abcdef abcdef a,bcdef,de
384# the regression tester only asks for 9 subexpressions
385a(b)(c)(d)(e)(f)(g)(h)(i)(j)k - abcdefghijk abcdefghijk b,c,d,e,f,g,h,i,j
386a(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)l - abcdefghijkl abcdefghijkl b,c,d,e,f,g,h,i,j,k
387a([bc]?)c - abc abc b
388a([bc]?)c - ac ac @c
389a([bc]+)c - abc abc b
390a([bc]+)c - abcc abcc bc
391a([bc]+)bc - abcbc abcbc bc
392a(bb+|b)b - abb abb b
393a(bbb+|bb+|b)b - abb abb b
394a(bbb+|bb+|b)b - abbb abbb bb
395a(bbb+|bb+|b)bb - abbb abbb b
396(.*).* - abcdef abcdef abcdef
397(a*)* - bc @b @b
398
399# do we get the right subexpression when it is used more than once?
400a(b|c)*d - ad ad -
401a(b|c)*d - abcd abcd c
402a(b|c)+d - abd abd b
403a(b|c)+d - abcd abcd c
404a(b|c?)+d - ad ad @d
405a(b|c?)+d - abcd abcd @d
406a(b|c){0,0}d - ad ad -
407a(b|c){0,1}d - ad ad -
408a(b|c){0,1}d - abd abd b
409a(b|c){0,2}d - ad ad -
410a(b|c){0,2}d - abcd abcd c
411a(b|c){0,}d - ad ad -
412a(b|c){0,}d - abcd abcd c
413a(b|c){1,1}d - abd abd b
414a(b|c){1,1}d - acd acd c
415a(b|c){1,2}d - abd abd b
416a(b|c){1,2}d - abcd abcd c
417a(b|c){1,}d - abd abd b
418a(b|c){1,}d - abcd abcd c
419a(b|c){2,2}d - acbd acbd b
420a(b|c){2,2}d - abcd abcd c
421a(b|c){2,4}d - abcd abcd c
422a(b|c){2,4}d - abcbd abcbd b
423a(b|c){2,4}d - abcbcd abcbcd c
424a(b|c){2,}d - abcd abcd c
425a(b|c){2,}d - abcbd abcbd b
426a(b+|((c)*))+d - abd abd @d,@d,-
427a(b+|((c)*))+d - abcd abcd @d,@d,-
428
429# check out the STARTEND option
430[abc] &# a(b)c b
431[abc] &# a(d)c
432[abc] &# a(bc)d b
433[abc] &# a(dc)d c
434. &# a()c
435b.*c &# b(bc)c bc
436b.* &# b(bc)c bc
437.*c &# b(bc)c bc
438
439# plain strings, with the NOSPEC flag
440abc m abc abc
441abc m xabcy abc
442abc m xyz
443a*b m aba*b a*b
444a*b m ab
445"" mC EMPTY
446
447# cases involving NULs
448aZb & a a
449aZb &p a
450aZb &p# (aZb) aZb
451aZ*b &p# (ab) ab
452a.b &# (aZb) aZb
453a.* &# (aZb)c aZb
454
455# word boundaries (ick)
456[[:<:]]a & a a
457[[:<:]]a & ba
458[[:<:]]a & -a a
459a[[:>:]] & a a
460a[[:>:]] & ab
461a[[:>:]] & a- a
462[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc abc
463[[:<:]]a.c[[:>:]] & axcd-dayc-dazce-abc-q abc
464[[:<:]]a.c[[:>:]] & axc-dayc-dazce-abc axc
465[[:<:]]b.c[[:>:]] & a_bxc-byc_d-bzc-q bzc
466[[:<:]].x..[[:>:]] & y_xa_-_xb_y-_xc_-axdc _xc_
467[[:<:]]a_b[[:>:]] & x_a_b
468
469# past problems, and suspected problems
470(A[1])|(A[2])|(A[3])|(A[4])|(A[5])|(A[6])|(A[7])|(A[8])|(A[9])|(A[A]) - A1 A1
471abcdefghijklmnop i abcdefghijklmnop abcdefghijklmnop
472abcdefghijklmnopqrstuv i abcdefghijklmnopqrstuv abcdefghijklmnopqrstuv
473(ALAK)|(ALT[AB])|(CC[123]1)|(CM[123]1)|(GAMC)|(LC[23][EO ])|(SEM[1234])|(SL[ES][12])|(SLWW)|(SLF )|(SLDT)|(VWH[12])|(WH[34][EW])|(WP1[ESN]) - CC11 CC11
474CC[13]1|a{21}[23][EO][123][Es][12]a{15}aa[34][EW]aaaaaaa[X]a - CC11 CC11
475Char \([a-z0-9_]*\)\[.* b Char xyz[k Char xyz[k xyz
476a?b - ab ab
477-\{0,1\}[0-9]*$ b -5 -5
diff --git a/src/regress/lib/libc/setjmp/Makefile b/src/regress/lib/libc/setjmp/Makefile
new file mode 100644
index 0000000000..25bf99d4cb
--- /dev/null
+++ b/src/regress/lib/libc/setjmp/Makefile
@@ -0,0 +1,16 @@
1# $NetBSD: Makefile,v 1.2 1995/04/20 22:40:13 cgd Exp $
2
3PROG= setjmptest
4SRCS= jmptest.c
5NOMAN= noman, no way, man
6
7CFLAGS+= -DTEST_SETJMP
8
9.PATH: ${.CURDIR}/../setjmp
10
11install:
12
13regress: ${PROG}
14 ./${PROG}
15
16.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/setjmp/jmptest.c b/src/regress/lib/libc/setjmp/jmptest.c
new file mode 100644
index 0000000000..16a482640a
--- /dev/null
+++ b/src/regress/lib/libc/setjmp/jmptest.c
@@ -0,0 +1,135 @@
1/* $NetBSD: jmptest.c,v 1.2 1995/01/01 20:55:35 jtc Exp $ */
2
3/*
4 * Copyright (c) 1994 Christopher G. Demetriou
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christopher G. Demetriou
18 * for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <sys/types.h>
35#include <err.h>
36#include <setjmp.h>
37#include <signal.h>
38#include <stdio.h>
39#include <stdlib.h>
40#include <unistd.h>
41
42#if (TEST_SETJMP + TEST_U_SETJMP + TEST_SIGSETJMP) != 1
43#error one of TEST_SETJMP, TEST_U_SETJMP, or TEST_SIGSETJMP must be defined
44#endif
45
46#ifdef TEST_SETJMP
47#define BUF jmp_buf
48#define SET(b, m) setjmp(b)
49#define JMP(b, v) longjmp(b, v)
50#endif
51
52#ifdef TEST_U_SETJMP
53#define BUF jmp_buf
54#define SET(b, m) _setjmp(b)
55#define JMP(b, v) _longjmp(b, v)
56#endif
57
58#ifdef TEST_SIGSETJMP
59#define BUF sigjmp_buf
60#define SET(b, m) sigsetjmp(b, m)
61#define JMP(b, v) siglongjmp(b, v)
62#endif
63
64int expectsignal;
65
66void
67aborthandler(signo)
68 int signo;
69{
70
71 if (expectsignal)
72 exit(0);
73 else
74 errx(1, "kill(SIGABRT) succeeded");
75}
76
77int
78main(argc, argv)
79 int argc;
80 char *argv[];
81{
82 struct sigaction sa;
83 BUF jb;
84 sigset_t ss;
85 int i, x;
86
87 i = getpid();
88
89#ifdef TEST_SETJMP
90 expectsignal = 0;
91#endif
92#ifdef TEST_U_SETJMP
93 expectsignal = 1;
94#endif
95#ifdef TEST_SIGSETJMP
96 if (argc != 2 ||
97 (strcmp(argv[1], "save") && strcmp(argv[1], "nosave"))) {
98 fprintf(stderr, "usage: %s [save|nosave]\n", argv[0]);
99 exit(1);
100 }
101 expectsignal = (strcmp(argv[1], "save") != 0);
102#endif
103
104 sa.sa_handler = aborthandler;
105 sigemptyset(&sa.sa_mask);
106 sa.sa_flags = 0;
107 if (sigaction(SIGABRT, &sa, NULL) == -1)
108 err(1, "sigaction failed");
109
110 if (sigemptyset(&ss) == -1)
111 err(1, "sigemptyset failed");
112 if (sigaddset(&ss, SIGABRT) == -1)
113 err(1, "sigaddset failed");
114 if (sigprocmask(SIG_BLOCK, &ss, NULL) == -1)
115 err(1, "sigprocmask (1) failed");
116
117 x = SET(jb, !expectsignal);
118 if (x != 0) {
119 if (x != i)
120 errx(1, "setjmp returned wrong value");
121
122 kill(i, SIGABRT);
123 if (expectsignal)
124 errx(1, "kill(SIGABRT) failed");
125 else
126 exit(0);
127 }
128
129 if (sigprocmask(SIG_UNBLOCK, &ss, NULL) == -1)
130 err(1, "sigprocmask (2) failed");
131
132 JMP(jb, i);
133
134 errx(1, "jmp failed");
135}
diff --git a/src/regress/lib/libc/sigsetjmp/Makefile b/src/regress/lib/libc/sigsetjmp/Makefile
new file mode 100644
index 0000000000..41682fcb66
--- /dev/null
+++ b/src/regress/lib/libc/sigsetjmp/Makefile
@@ -0,0 +1,17 @@
1# $NetBSD: Makefile,v 1.2 1995/04/20 22:40:40 cgd Exp $
2
3PROG= sigsetjmptest
4SRCS= jmptest.c
5NOMAN= noman, no way, man
6
7CFLAGS+= -DTEST_SIGSETJMP
8
9.PATH: ${.CURDIR}/../setjmp
10
11install:
12
13regress: ${PROG}
14 ./${PROG} save
15 ./${PROG} nosave
16
17.include <bsd.prog.mk>
diff --git a/src/regress/lib/libssl/Makefile b/src/regress/lib/libssl/Makefile
new file mode 100644
index 0000000000..3f7d48fd2e
--- /dev/null
+++ b/src/regress/lib/libssl/Makefile
@@ -0,0 +1,11 @@
1
2CLEANFILES+= testdsa.key testdsa.pem rsakey.pem rsacert.pem dsa512.pem
3
4install:
5
6regress:
7 sh ${.CURDIR}/testenc.sh ${.OBJDIR} ${.CURDIR}
8 sh ${.CURDIR}/testdsa.sh ${.OBJDIR} ${.CURDIR}
9# sh ${.CURDIR}/testrsa.sh ${.OBJDIR} ${.CURDIR}
10
11.include <bsd.prog.mk>
diff --git a/src/regress/lib/libssl/README b/src/regress/lib/libssl/README
new file mode 100644
index 0000000000..b1bab65fd1
--- /dev/null
+++ b/src/regress/lib/libssl/README
@@ -0,0 +1,8 @@
1testenc.sh tests encryption routines
2testdsa.sh tests DSA certificate generation
3test_server.sh starts a tls1 server using the above generated certificate
4test_client.sh starts a client to talk to the server.
5testrsa.sh tests RSA certificate generation - this SHOULD FAIL with the
6 version of the library in openbsd because all the RSA routines
7 are (currently) stubbed.
8
diff --git a/src/regress/lib/libssl/ssleay.cnf b/src/regress/lib/libssl/ssleay.cnf
new file mode 100644
index 0000000000..c8439860c3
--- /dev/null
+++ b/src/regress/lib/libssl/ssleay.cnf
@@ -0,0 +1,27 @@
1#
2# SSLeay example configuration file.
3# This is mostly being used for generation of certificate requests.
4#
5# hacked by iang to do DSA certs - Server
6
7RANDFILE = ./.rnd
8
9####################################################################
10[ req ]
11distinguished_name = req_distinguished_name
12encrypt_rsa_key = no
13
14[ req_distinguished_name ]
15countryName = Country Name (2 letter code)
16countryName_default = CA
17countryName_value = CA
18
19organizationName = Organization Name (eg, company)
20organizationName_value = Shake it Vera
21
220.commonName = Common Name (eg, YOUR name)
230.commonName_value = Wastelandus
24
251.commonName = Common Name (eg, YOUR name)
261.commonName_value = Maximus
27
diff --git a/src/regress/lib/libssl/test_client.sh b/src/regress/lib/libssl/test_client.sh
new file mode 100644
index 0000000000..36a8f84532
--- /dev/null
+++ b/src/regress/lib/libssl/test_client.sh
@@ -0,0 +1,11 @@
1#!/bin/sh
2
3echo
4echo This starts a tls1 mode client to talk to the server run by
5echo ./testserver.sh. You should start the server first.
6echo
7echo type in this window after ssl negotiation and your output should
8echo be echoed by the server.
9echo
10echo
11/usr/sbin/ssleay s_client -tls1
diff --git a/src/regress/lib/libssl/test_server.sh b/src/regress/lib/libssl/test_server.sh
new file mode 100644
index 0000000000..5467c52459
--- /dev/null
+++ b/src/regress/lib/libssl/test_server.sh
@@ -0,0 +1,9 @@
1#!/bin/sh
2
3echo This starts a tls1 mode server using the DSA certificate in ./server.pem
4echo Run ./testclient.sh in another window and type at it, you should
5echo see the results of the ssl negotiation, and stuff you type in the client
6echo should echo in this window
7echo
8echo
9/usr/sbin/ssleay s_server -tls1 -key testdsa.key -cert testdsa.pem
diff --git a/src/regress/lib/libssl/testdsa.sh b/src/regress/lib/libssl/testdsa.sh
new file mode 100644
index 0000000000..dc5d7b97b5
--- /dev/null
+++ b/src/regress/lib/libssl/testdsa.sh
@@ -0,0 +1,27 @@
1#!/bin/sh
2
3#Test DSA certificate generation of ssleay
4
5cd $1
6
7# Generate DSA paramter set
8ssleay dsaparam 512 -out dsa512.pem
9if [ $? != 0 ]; then
10 exit 1;
11fi
12
13
14# Denerate a DSA certificate
15ssleay req -config $2/ssleay.cnf -x509 -newkey dsa:dsa512.pem -out testdsa.pem -keyout testdsa.key
16if [ $? != 0 ]; then
17 exit 1;
18fi
19
20
21# Now check the certificate
22ssleay x509 -text -in testdsa.pem
23if [ $? != 0 ]; then
24 exit 1;
25fi
26
27exit 0
diff --git a/src/regress/lib/libssl/testenc.sh b/src/regress/lib/libssl/testenc.sh
new file mode 100644
index 0000000000..85997bfbe5
--- /dev/null
+++ b/src/regress/lib/libssl/testenc.sh
@@ -0,0 +1,63 @@
1#!/bin/sh
2
3testsrc=$2/ssleay.cnf
4test=$1/p
5cmd=/usr/sbin/ssleay
6
7cd $1
8
9cat $testsrc >$test;
10
11echo cat
12$cmd enc < $test > $test.cipher
13$cmd enc < $test.cipher >$test.clear
14cmp $test $test.clear
15if [ $? != 0 ]
16then
17 exit 1
18else
19 /bin/rm $test.cipher $test.clear
20fi
21echo base64
22$cmd enc -a -e < $test > $test.cipher
23$cmd enc -a -d < $test.cipher >$test.clear
24cmp $test $test.clear
25if [ $? != 0 ]
26then
27 exit 1
28else
29 /bin/rm $test.cipher $test.clear
30fi
31
32for i in rc4 \
33 des-cfb des-ede-cfb des-ede3-cfb \
34 des-ofb des-ede-ofb des-ede3-ofb \
35 des-ecb des-ede des-ede3 desx \
36 des-cbc des-ede-cbc des-ede3-cbc \
37 rc2-ecb rc2-cfb rc2-ofb rc2-cbc \
38 bf-ecb bf-cfb bf-ofb bf-cbc rc4 \
39 cast5-ecb cast5-cfb cast5-ofb cast5-cbc
40do
41 echo $i
42 $cmd $i -bufsize 113 -e -k test < $test > $test.$i.cipher
43 $cmd $i -bufsize 157 -d -k test < $test.$i.cipher >$test.$i.clear
44 cmp $test $test.$i.clear
45 if [ $? != 0 ]
46 then
47 exit 1
48 else
49 /bin/rm $test.$i.cipher $test.$i.clear
50 fi
51
52 echo $i base64
53 $cmd $i -bufsize 113 -a -e -k test < $test > $test.$i.cipher
54 $cmd $i -bufsize 157 -a -d -k test < $test.$i.cipher >$test.$i.clear
55 cmp $test $test.$i.clear
56 if [ $? != 0 ]
57 then
58 exit 1
59 else
60 /bin/rm $test.$i.cipher $test.$i.clear
61 fi
62done
63rm -f $test
diff --git a/src/regress/lib/libssl/testrsa.sh b/src/regress/lib/libssl/testrsa.sh
new file mode 100644
index 0000000000..3f4c328acd
--- /dev/null
+++ b/src/regress/lib/libssl/testrsa.sh
@@ -0,0 +1,36 @@
1#!/bin/sh
2
3#Test RSA certificate generation of ssleay
4
5echo
6echo RSA paramters test - NOTE THAT THIS WILL ONLY WORK IF YOU HAVE
7echo compiled libssl with the src-patent tree, currently living in
8echo ~ryker/src-patent.tar.gz on cvs.
9echo
10echo This will *not* work with what\'s in the tree, rsa is not in that.
11echo
12sleep 3
13
14cd $1
15
16# Generate RSA private key
17ssleay genrsa -out rsakey.pem
18if [ $? != 0 ]; then
19 exit 1;
20fi
21
22
23# Denerate an RSA certificate
24ssleay req -config $2/ssleay.cnf -key rsakey.pem -new -x509 -days 365 -out rsacert.pem
25if [ $? != 0 ]; then
26 exit 1;
27fi
28
29
30# Now check the certificate
31ssleay x509 -text -in rsacert.pem
32if [ $? != 0 ]; then
33 exit 1;
34fi
35
36exit 0
diff --git a/src/usr.bin/nc/Makefile b/src/usr.bin/nc/Makefile
new file mode 100644
index 0000000000..086a9e5ee8
--- /dev/null
+++ b/src/usr.bin/nc/Makefile
@@ -0,0 +1,7 @@
1# $OpenBSD: Makefile,v 1.2 1997/09/21 11:50:13 deraadt Exp $
2
3CFLAGS+= -DTELNET
4PROG= nc
5SRCS= netcat.c
6
7.include <bsd.prog.mk>
diff --git a/src/usr.bin/nc/README b/src/usr.bin/nc/README
new file mode 100644
index 0000000000..4235bc41ac
--- /dev/null
+++ b/src/usr.bin/nc/README
@@ -0,0 +1,946 @@
1Netcat 1.10
2=========== /\_/\
3 / 0 0 \
4Netcat is a simple Unix utility which reads and writes data ====v====
5across network connections, using TCP or UDP protocol. \ W /
6It is designed to be a reliable "back-end" tool that can | | _
7be used directly or easily driven by other programs and / ___ \ /
8scripts. At the same time, it is a feature-rich network / / \ \ |
9debugging and exploration tool, since it can create almost (((-----)))-'
10any kind of connection you would need and has several /
11interesting built-in capabilities. Netcat, or "nc" as the ( ___
12actual program is named, should have been supplied long ago \__.=|___E
13as another one of those cryptic but standard Unix tools. /
14
15In the simplest usage, "nc host port" creates a TCP connection to the given
16port on the given target host. Your standard input is then sent to the host,
17and anything that comes back across the connection is sent to your standard
18output. This continues indefinitely, until the network side of the connection
19shuts down. Note that this behavior is different from most other applications
20which shut everything down and exit after an end-of-file on the standard input.
21
22Netcat can also function as a server, by listening for inbound connections
23on arbitrary ports and then doing the same reading and writing. With minor
24limitations, netcat doesn't really care if it runs in "client" or "server"
25mode -- it still shovels data back and forth until there isn't any more left.
26In either mode, shutdown can be forced after a configurable time of inactivity
27on the network side.
28
29And it can do this via UDP too, so netcat is possibly the "udp telnet-like"
30application you always wanted for testing your UDP-mode servers. UDP, as the
31"U" implies, gives less reliable data transmission than TCP connections and
32some systems may have trouble sending large amounts of data that way, but it's
33still a useful capability to have.
34
35You may be asking "why not just use telnet to connect to arbitrary ports?"
36Valid question, and here are some reasons. Telnet has the "standard input
37EOF" problem, so one must introduce calculated delays in driving scripts to
38allow network output to finish. This is the main reason netcat stays running
39until the *network* side closes. Telnet also will not transfer arbitrary
40binary data, because certain characters are interpreted as telnet options and
41are thus removed from the data stream. Telnet also emits some of its
42diagnostic messages to standard output, where netcat keeps such things
43religiously separated from its *output* and will never modify any of the real
44data in transit unless you *really* want it to. And of course telnet is
45incapable of listening for inbound connections, or using UDP instead. Netcat
46doesn't have any of these limitations, is much smaller and faster than telnet,
47and has many other advantages.
48
49Some of netcat's major features are:
50
51 Outbound or inbound connections, TCP or UDP, to or from any ports
52 Full DNS forward/reverse checking, with appropriate warnings
53 Ability to use any local source port
54 Ability to use any locally-configured network source address
55 Built-in port-scanning capabilities, with randomizer
56 Built-in loose source-routing capability
57 Can read command line arguments from standard input
58 Slow-send mode, one line every N seconds
59 Hex dump of transmitted and received data
60 Optional ability to let another program service established connections
61 Optional telnet-options responder
62
63Efforts have been made to have netcat "do the right thing" in all its various
64modes. If you believe that it is doing the wrong thing under whatever
65circumstances, please notify me and tell me how you think it should behave.
66If netcat is not able to do some task you think up, minor tweaks to the code
67will probably fix that. It provides a basic and easily-modified template for
68writing other network applications, and I certainly encourage people to make
69custom mods and send in any improvements they make to it. This is the second
70release; the overall differences from 1.00 are relatively minor and have mostly
71to do with portability and bugfixes. Many people provided greatly appreciated
72fixes and comments on the 1.00 release. Continued feedback from the Internet
73community is always welcome!
74
75Netcat is entirely my own creation, although plenty of other code was used as
76examples. It is freely given away to the Internet community in the hope that
77it will be useful, with no restrictions except giving credit where it is due.
78No GPLs, Berkeley copyrights or any of that nonsense. The author assumes NO
79responsibility for how anyone uses it. If netcat makes you rich somehow and
80you're feeling generous, mail me a check. If you are affiliated in any way
81with Microsoft Network, get a life. Always ski in control. Comments,
82questions, and patches to hobbit@avian.org.
83
84Building
85========
86
87Compiling is fairly straightforward. Examine the Makefile for a SYSTYPE that
88matches yours, and do "make <systype>". The executable "nc" should appear.
89If there is no relevant SYSTYPE section, try "generic". If you create new
90sections for generic.h and Makefile to support another platform, please follow
91the given format and mail back the diffs.
92
93There are a couple of other settable #defines in netcat.c, which you can
94include as DFLAGS="-DTHIS -DTHAT" to your "make" invocation without having to
95edit the Makefile. See the following discussions for what they are and do.
96
97If you want to link against the resolver library on SunOS [recommended] and
98you have BIND 4.9.x, you may need to change XLIBS=-lresolv in the Makefile to
99XLIBS="-lresolv -l44bsd".
100
101Linux sys/time.h does not really support presetting of FD_SETSIZE; a harmless
102warning is issued.
103
104Some systems may warn about pointer types for signal(). No problem, though.
105
106Exploration of features
107=======================
108
109Where to begin? Netcat is at the same time so simple and versatile, it's like
110trying to describe everything you can do with your Swiss Army knife. This will
111go over the basics; you should also read the usage examples and notes later on
112which may give you even more ideas about what this sort of tool is good for.
113
114If no command arguments are given at all, netcat asks for them, reads a line
115from standard input, and breaks it up into arguments internally. This can be
116useful when driving netcat from certain types of scripts, with the side effect
117of hiding your command line arguments from "ps" displays.
118
119The host argument can be a name or IP address. If -n is specified, netcat
120will only accept numeric IP addresses and do no DNS lookups for anything. If
121-n is not given and -v is turned on, netcat will do a full forward and reverse
122name and address lookup for the host, and warn you about the all-too-common
123problem of mismatched names in the DNS. This often takes a little longer for
124connection setup, but is useful to know about. There are circumstances under
125which this can *save* time, such as when you want to know the name for some IP
126address and also connect there. Netcat will just tell you all about it, saving
127the manual steps of looking up the hostname yourself. Normally mismatch-
128checking is case-insensitive per the DNS spec, but you can define ANAL at
129compile time to make it case-sensitive -- sometimes useful for uncovering minor
130errors in your own DNS files while poking around your networks.
131
132A port argument is required for outbound connections, and can be numeric or a
133name as listed in /etc/services. If -n is specified, only numeric arguments
134are valid. Special syntax and/or more than one port argument cause different
135behavior -- see details below about port-scanning.
136
137The -v switch controls the verbosity level of messages sent to standard error.
138You will probably want to run netcat most of the time with -v turned on, so you
139can see info about the connections it is trying to make. You will probably
140also want to give a smallish -w argument, which limits the time spent trying to
141make a connection. I usually alias "nc" to "nc -v -w 3", which makes it
142function just about the same for things I would otherwise use telnet to do.
143The timeout is easily changed by a subsequent -w argument which overrides the
144earlier one. Specifying -v more than once makes diagnostic output MORE
145verbose. If -v is not specified at all, netcat silently does its work unless
146some error happens, whereupon it describes the error and exits with a nonzero
147status. Refused network connections are generally NOT considered to be errors,
148unless you only asked for a single TCP port and it was refused.
149
150Note that -w also sets the network inactivity timeout. This does not have any
151effect until standard input closes, but then if nothing further arrives from
152the network in the next <timeout> seconds, netcat tries to read the net once
153more for good measure, and then closes and exits. There are a lot of network
154services now that accept a small amount of input and return a large amount of
155output, such as Gopher and Web servers, which is the main reason netcat was
156written to "block" on the network staying open rather than standard input.
157Handling the timeout this way gives uniform behavior with network servers that
158*don't* close by themselves until told to.
159
160UDP connections are opened instead of TCP when -u is specified. These aren't
161really "connections" per se since UDP is a connectionless protocol, although
162netcat does internally use the "connected UDP socket" mechanism that most
163kernels support. Although netcat claims that an outgoing UDP connection is
164"open" immediately, no data is sent until something is read from standard
165input. Only thereafter is it possible to determine whether there really is a
166UDP server on the other end, and often you just can't tell. Most UDP protocols
167use timeouts and retries to do their thing and in many cases won't bother
168answering at all, so you should specify a timeout and hope for the best. You
169will get more out of UDP connections if standard input is fed from a source
170of data that looks like various kinds of server requests.
171
172To obtain a hex dump file of the data sent either way, use "-o logfile". The
173dump lines begin with "<" or ">" to respectively indicate "from the net" or
174"to the net", and contain the total count per direction, and hex and ascii
175representations of the traffic. Capturing a hex dump naturally slows netcat
176down a bit, so don't use it where speed is critical.
177
178Netcat can bind to any local port, subject to privilege restrictions and ports
179that are already in use. It is also possible to use a specific local network
180source address if it is that of a network interface on your machine. [Note:
181this does not work correctly on all platforms.] Use "-p portarg" to grab a
182specific local port, and "-s ip-addr" or "-s name" to have that be your source
183IP address. This is often referred to as "anchoring the socket". Root users
184can grab any unused source port including the "reserved" ones less than 1024.
185Absence of -p will bind to whatever unused port the system gives you, just like
186any other normal client connection, unless you use -r [see below].
187
188Listen mode will cause netcat to wait for an inbound connection, and then the
189same data transfer happens. Thus, you can do "nc -l -p 1234 < filename" and
190when someone else connects to your port 1234, the file is sent to them whether
191they wanted it or not. Listen mode is generally used along with a local port
192argument -- this is required for UDP mode, while TCP mode can have the system
193assign one and tell you what it is if -v is turned on. If you specify a target
194host and optional port in listen mode, netcat will accept an inbound connection
195only from that host and if you specify one, only from that foreign source port.
196In verbose mode you'll be informed about the inbound connection, including what
197address and port it came from, and since listening on "any" applies to several
198possibilities, which address it came *to* on your end. If the system supports
199IP socket options, netcat will attempt to retrieve any such options from an
200inbound connection and print them out in hex.
201
202If netcat is compiled with -DGAPING_SECURITY_HOLE, the -e argument specifies
203a program to exec after making or receiving a successful connection. In the
204listening mode, this works similarly to "inetd" but only for a single instance.
205Use with GREAT CARE. This piece of the code is normally not enabled; if you
206know what you're doing, have fun. This hack also works in UDP mode. Note that
207you can only supply -e with the name of the program, but no arguments. If you
208want to launch something with an argument list, write a two-line wrapper script
209or just use inetd like always.
210
211If netcat is compiled with -DTELNET, the -t argument enables it to respond
212to telnet option negotiation [always in the negative, i.e. DONT or WONT].
213This allows it to connect to a telnetd and get past the initial negotiation
214far enough to get a login prompt from the server. Since this feature has
215the potential to modify the data stream, it is not enabled by default. You
216have to understand why you might need this and turn on the #define yourself.
217
218Data from the network connection is always delivered to standard output as
219efficiently as possible, using large 8K reads and writes. Standard input is
220normally sent to the net the same way, but the -i switch specifies an "interval
221time" which slows this down considerably. Standard input is still read in
222large batches, but netcat then tries to find where line breaks exist and sends
223one line every interval time. Note that if standard input is a terminal, data
224is already read line by line, so unless you make the -i interval rather long,
225what you type will go out at a fairly normal rate. -i is really designed
226for use when you want to "measure out" what is read from files or pipes.
227
228Port-scanning is a popular method for exploring what's out there. Netcat
229accepts its commands with options first, then the target host, and everything
230thereafter is interpreted as port names or numbers, or ranges of ports in M-N
231syntax. CAVEAT: some port names in /etc/services contain hyphens -- netcat
232currently will not correctly parse those, so specify ranges using numbers if
233you can. If more than one port is thus specified, netcat connects to *all* of
234them, sending the same batch of data from standard input [up to 8K worth] to
235each one that is successfully connected to. Specifying multiple ports also
236suppresses diagnostic messages about refused connections, unless -v is
237specified twice for "more verbosity". This way you normally get notified only
238about genuinely open connections. Example: "nc -v -w 2 -z target 20-30" will
239try connecting to every port between 20 and 30 [inclusive] at the target, and
240will likely inform you about an FTP server, telnet server, and mailer along the
241way. The -z switch prevents sending any data to a TCP connection and very
242limited probe data to a UDP connection, and is thus useful as a fast scanning
243mode just to see what ports the target is listening on. To limit scanning
244speed if desired, -i will insert a delay between each port probe. There are
245some pitfalls with regard to UDP scanning, described later, but in general it
246works well.
247
248For each range of ports specified, scanning is normally done downward within
249that range. If the -r switch is used, scanning hops randomly around within
250that range and reports open ports as it finds them. [If you want them listed
251in order regardless, pipe standard error through "sort"...] In addition, if
252random mode is in effect, the local source ports are also randomized. This
253prevents netcat from exhibiting any kind of regular pattern in its scanning.
254You can exert fairly fine control over your scan by judicious use of -r and
255selected port ranges to cover. If you use -r for a single connection, the
256source port will have a random value above 8192, rather than the next one the
257kernel would have assigned you. Note that selecting a specific local port
258with -p overrides any local-port randomization.
259
260Many people are interested in testing network connectivity using IP source
261routing, even if it's only to make sure their own firewalls are blocking
262source-routed packets. On systems that support it, the -g switch can be used
263multiple times [up to 8] to construct a loose-source-routed path for your
264connection, and the -G argument positions the "hop pointer" within the list.
265If your network allows source-routed traffic in and out, you can test
266connectivity to your own services via remote points in the internet. Note that
267although newer BSD-flavor telnets also have source-routing capability, it isn't
268clearly documented and the command syntax is somewhat clumsy. Netcat's
269handling of "-g" is modeled after "traceroute".
270
271Netcat tries its best to behave just like "cat". It currently does nothing to
272terminal input modes, and does no end-of-line conversion. Standard input from
273a terminal is read line by line with normal editing characters in effect. You
274can freely suspend out of an interactive connection and resume. ^C or whatever
275your interrupt character is will make netcat close the network connection and
276exit. A switch to place the terminal in raw mode has been considered, but so
277far has not been necessary. You can send raw binary data by reading it out of
278a file or piping from another program, so more meaningful effort would be spent
279writing an appropriate front-end driver.
280
281Netcat is not an "arbitrary packet generator", but the ability to talk to raw
282sockets and/or nit/bpf/dlpi may appear at some point. Such things are clearly
283useful; I refer you to Darren Reed's excellent ip_filter package, which now
284includes a tool to construct and send raw packets with any contents you want.
285
286Example uses -- the light side
287==============================
288
289Again, this is a very partial list of possibilities, but it may get you to
290think up more applications for netcat. Driving netcat with simple shell or
291expect scripts is an easy and flexible way to do fairly complex tasks,
292especially if you're not into coding network tools in C. My coding isn't
293particularly strong either [although undoubtedly better after writing this
294thing!], so I tend to construct bare-metal tools like this that I can trivially
295plug into other applications. Netcat doubles as a teaching tool -- one can
296learn a great deal about more complex network protocols by trying to simulate
297them through raw connections!
298
299An example of netcat as a backend for something else is the shell-script
300Web browser, which simply asks for the relevant parts of a URL and pipes
301"GET /what/ever" into a netcat connection to the server. I used to do this
302with telnet, and had to use calculated sleep times and other stupidity to
303kludge around telnet's limitations. Netcat guarantees that I get the whole
304page, and since it transfers all the data unmodified, I can even pull down
305binary image files and display them elsewhere later. Some folks may find the
306idea of a shell-script web browser silly and strange, but it starts up and
307gets me my info a hell of a lot faster than a GUI browser and doesn't hide
308any contents of links and forms and such. This is included, as scripts/web,
309along with several other web-related examples.
310
311Netcat is an obvious replacement for telnet as a tool for talking to daemons.
312For example, it is easier to type "nc host 25", talk to someone's mailer, and
313just ^C out than having to type ^]c or QUIT as telnet would require you to do.
314You can quickly catalog the services on your network by telling netcat to
315connect to well-known services and collect greetings, or at least scan for open
316ports. You'll probably want to collect netcat's diagnostic messages in your
317output files, so be sure to include standard error in the output using
318`>& file' in *csh or `> file 2>&1' in bourne shell.
319
320A scanning example: "echo QUIT | nc -v -w 5 target 20-250 500-600 5990-7000"
321will inform you about a target's various well-known TCP servers, including
322r-services, X, IRC, and maybe a few you didn't expect. Sending in QUIT and
323using the timeout will almost guarantee that you see some kind of greeting or
324error from each service, which usually indicates what it is and what version.
325[Beware of the "chargen" port, though...] SATAN uses exactly this technique to
326collect host information, and indeed some of the ideas herein were taken from
327the SATAN backend tools. If you script this up to try every host in your
328subnet space and just let it run, you will not only see all the services,
329you'll find out about hosts that aren't correctly listed in your DNS. Then you
330can compare new snapshots against old snapshots to see changes. For going
331after particular services, a more intrusive example is in scripts/probe.
332
333Netcat can be used as a simple data transfer agent, and it doesn't really
334matter which end is the listener and which end is the client -- input at one
335side arrives at the other side as output. It is helpful to start the listener
336at the receiving side with no timeout specified, and then give the sending side
337a small timeout. That way the listener stays listening until you contact it,
338and after data stops flowing the client will time out, shut down, and take the
339listener with it. Unless the intervening network is fraught with problems,
340this should be completely reliable, and you can always increase the timeout. A
341typical example of something "rsh" is often used for: on one side,
342
343 nc -l -p 1234 | uncompress -c | tar xvfp -
344
345and then on the other side
346
347 tar cfp - /some/dir | compress -c | nc -w 3 othermachine 1234
348
349will transfer the contents of a directory from one machine to another, without
350having to worry about .rhosts files, user accounts, or inetd configurations
351at either end. Again, it matters not which is the listener or receiver; the
352"tarring" machine could just as easily be running the listener instead. One
353could conceivably use a scheme like this for backups, by having cron-jobs fire
354up listeners and backup handlers [which can be restricted to specific addresses
355and ports between each other] and pipe "dump" or "tar" on one machine to "dd
356of=/dev/tapedrive" on another as usual. Since netcat returns a nonzero exit
357status for a denied listener connection, scripts to handle such tasks could
358easily log and reject connect attempts from third parties, and then retry.
359
360Another simple data-transfer example: shipping things to a PC that doesn't have
361any network applications yet except a TCP stack and a web browser. Point the
362browser at an arbitrary port on a Unix server by telling it to download
363something like http://unixbox:4444/foo, and have a listener on the Unix side
364ready to ship out a file when the connect comes in. The browser may pervert
365binary data when told to save the URL, but you can dig the raw data out of
366the on-disk cache.
367
368If you build netcat with GAPING_SECURITY_HOLE defined, you can use it as an
369"inetd" substitute to test experimental network servers that would otherwise
370run under "inetd". A script or program will have its input and output hooked
371to the network the same way, perhaps sans some fancier signal handling. Given
372that most network services do not bind to a particular local address, whether
373they are under "inetd" or not, it is possible for netcat avoid the "address
374already in use" error by binding to a specific address. This lets you [as
375root, for low ports] place netcat "in the way" of a standard service, since
376inbound connections are generally sent to such specifically-bound listeners
377first and fall back to the ones bound to "any". This allows for a one-off
378experimental simulation of some service, without having to screw around with
379inetd.conf. Running with -v turned on and collecting a connection log from
380standard error is recommended.
381
382Netcat as well can make an outbound connection and then run a program or script
383on the originating end, with input and output connected to the same network
384port. This "inverse inetd" capability could enhance the backup-server concept
385described above or help facilitate things such as a "network dialback" concept.
386The possibilities are many and varied here; if such things are intended as
387security mechanisms, it may be best to modify netcat specifically for the
388purpose instead of wrapping such functions in scripts.
389
390Speaking of inetd, netcat will function perfectly well *under* inetd as a TCP
391connection redirector for inbound services, like a "plug-gw" without the
392authentication step. This is very useful for doing stuff like redirecting
393traffic through your firewall out to other places like web servers and mail
394hubs, while posing no risk to the firewall machine itself. Put netcat behind
395inetd and tcp_wrappers, perhaps thusly:
396
397 www stream tcp nowait nobody /etc/tcpd /bin/nc -w 3 realwww 80
398
399and you have a simple and effective "application relay" with access control
400and logging. Note use of the wait time as a "safety" in case realwww isn't
401reachable or the calling user aborts the connection -- otherwise the relay may
402hang there forever.
403
404You can use netcat to generate huge amounts of useless network data for
405various performance testing. For example, doing
406
407 yes AAAAAAAAAAAAAAAAAAAAAA | nc -v -v -l -p 2222 > /dev/null
408
409on one side and then hitting it with
410
411 yes BBBBBBBBBBBBBBBBBBBBBB | nc othermachine 2222 > /dev/null
412
413from another host will saturate your wires with A's and B's. The "very
414verbose" switch usage will tell you how many of each were sent and received
415after you interrupt either side. Using UDP mode produces tremendously MORE
416trash per unit time in the form of fragmented 8 Kbyte mobygrams -- enough to
417stress-test kernels and network interfaces. Firing random binary data into
418various network servers may help expose bugs in their input handling, which
419nowadays is a popular thing to explore. A simple example data-generator is
420given in data/data.c included in this package, along with a small collection
421of canned input files to generate various packet contents. This program is
422documented in its beginning comments, but of interest here is using "%r" to
423generate random bytes at well-chosen points in a data stream. If you can
424crash your daemon, you likely have a security problem.
425
426The hex dump feature may be useful for debugging odd network protocols,
427especially if you don't have any network monitoring equipment handy or aren't
428root where you'd need to run "tcpdump" or something. Bind a listening netcat
429to a local port, and have it run a script which in turn runs another netcat
430to the real service and captures the hex dump to a log file. This sets up a
431transparent relay between your local port and wherever the real service is.
432Be sure that the script-run netcat does *not* use -v, or the extra info it
433sends to standard error may confuse the protocol. Note also that you cannot
434have the "listen/exec" netcat do the data capture, since once the connection
435arrives it is no longer netcat that is running.
436
437Binding to an arbitrary local port allows you to simulate things like r-service
438clients, if you are root locally. For example, feeding "^@root^@joe^@pwd^@"
439[where ^@ is a null, and root/joe could be any other local/remote username
440pair] into a "rsh" or "rlogin" server, FROM your port 1023 for example,
441duplicates what the server expects to receive. Thus, you can test for insecure
442.rhosts files around your network without having to create new user accounts on
443your client machine. The program data/rservice.c can aid this process by
444constructing the "rcmd" protocol bytes. Doing this also prevents "rshd" from
445trying to create that separate standard-error socket and still gives you an
446input path, as opposed to the usual action of "rsh -n". Using netcat for
447things like this can be really useful sometimes, because rsh and rlogin
448generally want a host *name* as an argument and won't accept IP addresses. If
449your client-end DNS is hosed, as may be true when you're trying to extract
450backup sets on to a dumb client, "netcat -n" wins where normal rsh/rlogin is
451useless.
452
453If you are unsure that a remote syslogger is working, test it with netcat.
454Make a UDP connection to port 514 and type in "<0>message", which should
455correspond to "kern.emerg" and cause syslogd to scream into every file it has
456open [and possibly all over users' terminals]. You can tame this down by
457using a different number and use netcat inside routine scripts to send syslog
458messages to places that aren't configured in syslog.conf. For example,
459"echo '<38>message' | nc -w 1 -u loggerhost 514" should send to auth.notice
460on loggerhost. The exact number may vary; check against your syslog.h first.
461
462Netcat provides several ways for you to test your own packet filters. If you
463bind to a port normally protected against outside access and make a connection
464to somewhere outside your own network, the return traffic will be coming to
465your chosen port from the "outside" and should be blocked. TCP may get through
466if your filter passes all "ack syn", but it shouldn't be even doing that to low
467ports on your network. Remember to test with UDP traffic as well! If your
468filter passes at least outbound source-routed IP packets, bouncing a connection
469back to yourself via some gateway outside your network will create "incoming"
470traffic with your source address, which should get dropped by a correctly
471configured anti-spoofing filter. This is a "non-test" if you're also dropping
472source-routing, but it's good to be able to test for that too. Any packet
473filter worth its salt will be blocking source-routed packets in both
474directions, but you never know what interesting quirks you might turn up by
475playing around with source ports and addresses and watching the wires with a
476network monitor.
477
478You can use netcat to protect your own workstation's X server against outside
479access. X is stupid enough to listen for connections on "any" and never tell
480you when new connections arrive, which is one reason it is so vulnerable. Once
481you have all your various X windows up and running you can use netcat to bind
482just to your ethernet address and listen to port 6000. Any new connections
483from outside the machine will hit netcat instead your X server, and you get a
484log of who's trying. You can either tell netcat to drop the connection, or
485perhaps run another copy of itself to relay to your actual X server on
486"localhost". This may not work for dedicated X terminals, but it may be
487possible to authorize your X terminal only for its boot server, and run a relay
488netcat over on the server that will in turn talk to your X terminal. Since
489netcat only handles one listening connection per run, make sure that whatever
490way you rig it causes another one to run and listen on 6000 soon afterward, or
491your real X server will be reachable once again. A very minimal script just
492to protect yourself could be
493
494 while true ; do
495 nc -v -l -s <your-addr> -p 6000 localhost 2
496 done
497
498which causes netcat to accept and then close any inbound connection to your
499workstation's normal ethernet address, and another copy is immediately run by
500the script. Send standard error to a file for a log of connection attempts.
501If your system can't do the "specific bind" thing all is not lost; run your
502X server on display ":1" or port 6001, and netcat can still function as a probe
503alarm by listening on 6000.
504
505Does your shell-account provider allow personal Web pages, but not CGI scripts?
506You can have netcat listen on a particular port to execute a program or script
507of your choosing, and then just point to the port with a URL in your homepage.
508The listener could even exist on a completely different machine, avoiding the
509potential ire of the homepage-host administrators. Since the script will get
510the raw browser query as input it won't look like a typical CGI script, and
511since it's running under your UID you need to write it carefully. You may want
512to write a netcat-based script as a wrapper that reads a query and sets up
513environment variables for a regular CGI script. The possibilities for using
514netcat and scripts to handle Web stuff are almost endless. Again, see the
515examples under scripts/.
516
517Example uses -- the dark side
518=============================
519
520Equal time is deserved here, since a versatile tool like this can be useful
521to any Shade of Hat. I could use my Victorinox to either fix your car or
522disassemble it, right? You can clearly use something like netcat to attack
523or defend -- I don't try to govern anyone's social outlook, I just build tools.
524Regardless of your intentions, you should still be aware of these threats to
525your own systems.
526
527The first obvious thing is scanning someone *else's* network for vulnerable
528services. Files containing preconstructed data, be it exploratory or
529exploitive, can be fed in as standard input, including command-line arguments
530to netcat itself to keep "ps" ignorant of your doings. The more random the
531scanning, the less likelihood of detection by humans, scan-detectors, or
532dynamic filtering, and with -i you'll wait longer but avoid loading down the
533target's network. Some examples for crafting various standard UDP probes are
534given in data/*.d.
535
536Some configurations of packet filters attempt to solve the FTP-data problem by
537just allowing such connections from the outside. These come FROM port 20, TO
538high TCP ports inside -- if you locally bind to port 20, you may find yourself
539able to bypass filtering in some cases. Maybe not to low ports "inside", but
540perhaps to TCP NFS servers, X servers, Prospero, ciscos that listen on 200x
541and 400x... Similar bypassing may be possible for UDP [and maybe TCP too] if a
542connection comes from port 53; a filter may assume it's a nameserver response.
543
544Using -e in conjunction with binding to a specific address can enable "server
545takeover" by getting in ahead of the real ones, whereupon you can snarf data
546sent in and feed your own back out. At the very least you can log a hex dump
547of someone else's session. If you are root, you can certainly use -s and -e to
548run various hacked daemons without having to touch inetd.conf or the real
549daemons themselves. You may not always have the root access to deal with low
550ports, but what if you are on a machine that also happens to be an NFS server?
551You might be able to collect some interesting things from port 2049, including
552local file handles. There are several other servers that run on high ports
553that are likely candidates for takeover, including many of the RPC services on
554some platforms [yppasswdd, anyone?]. Kerberos tickets, X cookies, and IRC
555traffic also come to mind. RADIUS-based terminal servers connect incoming
556users to shell-account machines on a high port, usually 1642 or thereabouts.
557SOCKS servers run on 1080. Do "netstat -a" and get creative.
558
559There are some daemons that are well-written enough to bind separately to all
560the local interfaces, possibly with an eye toward heading off this sort of
561problem. Named from recent BIND releases, and NTP, are two that come to mind.
562Netstat will show these listening on address.53 instead of *.53. You won't
563be able to get in front of these on any of the real interface addresses, which
564of course is especially interesting in the case of named, but these servers
565sometimes forget about things like "alias" interface addresses or interfaces
566that appear later on such as dynamic PPP links. There are some hacked web
567servers and versions of "inetd" floating around that specifically bind as well,
568based on a configuration file -- these generally *are* bound to alias addresses
569to offer several different address-based services from one machine.
570
571Using -e to start a remote backdoor shell is another obvious sort of thing,
572easier than constructing a file for inetd to listen on "ingreslock" or
573something, and you can access-control it against other people by specifying a
574client host and port. Experience with this truly demonstrates how fragile the
575barrier between being "logged in" or not really is, and is further expressed by
576scripts/bsh. If you're already behind a firewall, it may be easier to make an
577*outbound* connection and then run a shell; a small wrapper script can
578periodically try connecting to a known place and port, you can later listen
579there until the inbound connection arrives, and there's your shell. Running
580a shell via UDP has several interesting features, although be aware that once
581"connected", the UDP stub sockets tend to show up in "netstat" just like TCP
582connections and may not be quite as subtle as you wanted. Packets may also be
583lost, so use TCP if you need reliable connections. But since UDP is
584connectionless, a hookup of this sort will stick around almost forever, even if
585you ^C out of netcat or do a reboot on your side, and you only need to remember
586the ports you used on both ends to reestablish. And outbound UDP-plus-exec
587connection creates the connected socket and starts the program immediately. On
588a listening UDP connection, the socket is created once a first packet is
589received. In either case, though, such a "connection" has the interesting side
590effect that only your client-side IP address and [chosen?] source port will
591thereafter be able to talk to it. Instant access control! A non-local third
592party would have to do ALL of the following to take over such a session:
593
594 forge UDP with your source address [trivial to do; see below]
595 guess the port numbers of BOTH ends, or sniff the wire for them
596 arrange to block ICMP or UDP return traffic between it and your real
597 source, so the session doesn't die with a network write error.
598
599The companion program data/rservice.c is helpful in scripting up any sort of
600r-service username or password guessing attack. The arguments to "rservice"
601are simply the strings that get null-terminated and passed over an "rcmd"-style
602connection, with the assumption that the client does not need a separate
603standard-error port. Brute-force password banging is best done via "rexec" if
604it is available since it is less likely to log failed attempts. Thus, doing
605"rservice joe joespass pwd | nc target exec" should return joe's home dir if
606the password is right, or "Permission denied." Plug in a dictionary and go to
607town. If you're attacking rsh/rlogin, remember to be root and bind to a port
608between 512 and 1023 on your end, and pipe in "rservice joe joe pwd" and such.
609
610Netcat can prevent inadvertently sending extra information over a telnet
611connection. Use "nc -t" in place of telnet, and daemons that try to ask for
612things like USER and TERM environment variables will get no useful answers, as
613they otherwise would from a more recent telnet program. Some telnetds actually
614try to collect this stuff and then plug the USER variable into "login" so that
615the caller is then just asked for a password! This mechanism could cause a
616login attempt as YOUR real username to be logged over there if you use a
617Borman-based telnet instead of "nc -t".
618
619Got an unused network interface configured in your kernel [e.g. SLIP], or
620support for alias addresses? Ifconfig one to be any address you like, and bind
621to it with -s to enable all sorts of shenanigans with bogus source addresses.
622The interface probably has to be UP before this works; some SLIP versions
623need a far-end address before this is true. Hammering on UDP services is then
624a no-brainer. What you can do to an unfiltered syslog daemon should be fairly
625obvious; trimming the conf file can help protect against it. Many routers out
626there still blindly believe what they receive via RIP and other routing
627protocols. Although most UDP echo and chargen servers check if an incoming
628packet was sent from *another* "internal" UDP server, there are many that still
629do not, any two of which [or many, for that matter] could keep each other
630entertained for hours at the expense of bandwidth. And you can always make
631someone wonder why she's being probed by nsa.gov.
632
633Your TCP spoofing possibilities are mostly limited to destinations you can
634source-route to while locally bound to your phony address. Many sites block
635source-routed packets these days for precisely this reason. If your kernel
636does oddball things when sending source-routed packets, try moving the pointer
637around with -G. You may also have to fiddle with the routing on your own
638machine before you start receiving packets back. Warning: some machines still
639send out traffic using the source address of the outbound interface, regardless
640of your binding, especially in the case of localhost. Check first. If you can
641open a connection but then get no data back from it, the target host is
642probably killing the IP options on its end [this is an option inside TCP
643wrappers and several other packages], which happens after the 3-way handshake
644is completed. If you send some data and observe the "send-q" side of "netstat"
645for that connection increasing but never getting sent, that's another symptom.
646Beware: if Sendmail 8.7.x detects a source-routed SMTP connection, it extracts
647the hop list and sticks it in the Received: header!
648
649SYN bombing [sometimes called "hosing"] can disable many TCP servers, and if
650you hit one often enough, you can keep it unreachable for days. As is true of
651many other denial-of-service attacks, there is currently no defense against it
652except maybe at the human level. Making kernel SOMAXCONN considerably larger
653than the default and the half-open timeout smaller can help, and indeed some
654people running large high-performance web servers have *had* to do that just to
655handle normal traffic. Taking out mailers and web servers is sociopathic, but
656on the other hand it is sometimes useful to be able to, say, disable a site's
657identd daemon for a few minutes. If someone realizes what is going on,
658backtracing will still be difficult since the packets have a phony source
659address, but calls to enough ISP NOCs might eventually pinpoint the source.
660It is also trivial for a clueful ISP to watch for or even block outgoing
661packets with obviously fake source addresses, but as we know many of them are
662not clueful or willing to get involved in such hassles. Besides, outbound
663packets with an [otherwise unreachable] source address in one of their net
664blocks would look fairly legitimate.
665
666Notes
667=====
668
669A discussion of various caveats, subtleties, and the design of the innards.
670
671As of version 1.07 you can construct a single file containing command arguments
672and then some data to transfer. Netcat is now smart enough to pick out the
673first line and build the argument list, and send any remaining data across the
674net to one or multiple ports. The first release of netcat had trouble with
675this -- it called fgets() for the command line argument, which behind the
676scenes does a large read() from standard input, perhaps 4096 bytes or so, and
677feeds that out to the fgets() library routine. By the time netcat 1.00 started
678directly read()ing stdin for more data, 4096 bytes of it were gone. It now
679uses raw read() everywhere and does the right thing whether reading from files,
680pipes, or ttys. If you use this for multiple-port connections, the single
681block of data will now be a maximum of 8K minus the first line. Improvements
682have been made to the logic in sending the saved chunk to each new port. Note
683that any command-line arguments hidden using this mechanism could still be
684extracted from a core dump.
685
686When netcat receives an inbound UDP connection, it creates a "connected socket"
687back to the source of the connection so that it can also send out data using
688normal write(). Using this mechanism instead of recvfrom/sendto has several
689advantages -- the read/write select loop is simplified, and ICMP errors can in
690effect be received by non-root users. However, it has the subtle side effect
691that if further UDP packets arrive from the caller but from different source
692ports, the listener will not receive them. UDP listen mode on a multihomed
693machine may have similar quirks unless you specifically bind to one of its
694addresses. It is not clear that kernel support for UDP connected sockets
695and/or my understanding of it is entirely complete here, so experiment...
696
697You should be aware of some subtleties concerning UDP scanning. If -z is on,
698netcat attempts to send a single null byte to the target port, twice, with a
699small time in between. You can either use the -w timeout, or netcat will try
700to make a "sideline" TCP connection to the target to introduce a small time
701delay equal to the round-trip time between you and the target. Note that if
702you have a -w timeout and -i timeout set, BOTH take effect and you wait twice
703as long. The TCP connection is to a normally refused port to minimize traffic,
704but if you notice a UDP fast-scan taking somewhat longer than it should, it
705could be that the target is actually listening on the TCP port. Either way,
706any ICMP port-unreachable messages from the target should have arrived in the
707meantime. The second single-byte UDP probe is then sent. Under BSD kernels,
708the ICMP error is delivered to the "connected socket" and the second write
709returns an error, which tells netcat that there is NOT a UDP service there.
710While Linux seems to be a fortunate exception, under many SYSV derived kernels
711the ICMP is not delivered, and netcat starts reporting that *all* the ports are
712"open" -- clearly wrong. [Some systems may not even *have* the "udp connected
713socket" concept, and netcat in its current form will not work for UDP at all.]
714If -z is specified and only one UDP port is probed, netcat's exit status
715reflects whether the connection was "open" or "refused" as with TCP.
716
717It may also be that UDP packets are being blocked by filters with no ICMP error
718returns, in which case everything will time out and return "open". This all
719sounds backwards, but that's how UDP works. If you're not sure, try "echo
720w00gumz | nc -u -w 2 target 7" to see if you can reach its UDP echo port at
721all. You should have no trouble using a BSD-flavor system to scan for UDP
722around your own network, although flooding a target with the high activity that
723-z generates will cause it to occasionally drop packets and indicate false
724"opens". A more "correct" way to do this is collect and analyze the ICMP
725errors, as does SATAN's "udp_scan" backend, but then again there's no guarantee
726that the ICMP gets back to you either. Udp_scan also does the zero-byte
727probes but is excruciatingly careful to calculate its own round-trip timing
728average and dynamically set its own response timeouts along with decoding any
729ICMP received. Netcat uses a much sleazier method which is nonetheless quite
730effective. Cisco routers are known to have a "dead time" in between ICMP
731responses about unreachable UDP ports, so a fast scan of a cisco will show
732almost everything "open". If you are looking for a specific UDP service, you
733can construct a file containing the right bytes to trigger a response from the
734other end and send that as standard input. Netcat will read up to 8K of the
735file and send the same data to every UDP port given. Note that you must use a
736timeout in this case [as would any other UDP client application] since the
737two-write probe only happens if -z is specified.
738
739Many telnet servers insist on a specific set of option negotiations before
740presenting a login banner. On a raw connection you will see this as small
741amount of binary gook. My attempts to create fixed input bytes to make a
742telnetd happy worked some places but failed against newer BSD-flavor ones,
743possibly due to timing problems, but there are a couple of much better
744workarounds. First, compile with -DTELNET and use -t if you just want to get
745past the option negotiation and talk to something on a telnet port. You will
746still see the binary gook -- in fact you'll see a lot more of it as the options
747are responded to behind the scenes. The telnet responder does NOT update the
748total byte count, or show up in the hex dump -- it just responds negatively to
749any options read from the incoming data stream. If you want to use a normal
750full-blown telnet to get to something but also want some of netcat's features
751involved like settable ports or timeouts, construct a tiny "foo" script:
752
753 #! /bin/sh
754 exec nc -otheroptions targethost 23
755
756and then do
757
758 nc -l -p someport -e foo localhost &
759 telnet localhost someport
760
761and your telnet should connect transparently through the exec'ed netcat to
762the target, using whatever options you supplied in the "foo" script. Don't
763use -t inside the script, or you'll wind up sending *two* option responses.
764
765I've observed inconsistent behavior under some Linuxes [perhaps just older
766ones?] when binding in listen mode. Sometimes netcat binds only to "localhost"
767if invoked with no address or port arguments, and sometimes it is unable to
768bind to a specific address for listening if something else is already listening
769on "any". The former problem can be worked around by specifying "-s 0.0.0.0",
770which will do the right thing despite netcat claiming that it's listening on
771[127.0.0.1]. This is a known problem -- for example, there's a mention of it
772in the makefile for SOCKS. On the flip side, binding to localhost and sending
773packets to some other machine doesn't work as you'd expect -- they go out with
774the source address of the sending interface instead. The Linux kernel contains
775a specific check to ensure that packets from 127.0.0.1 are never sent to the
776wire; other kernels may contain similar code. Linux, of course, *still*
777doesn't support source-routing, but they claim that it and many other network
778improvements are at least breathing hard.
779
780There are several possible errors associated with making TCP connections, but
781to specifically see anything other than "refused", one must wait the full
782kernel-defined timeout for a connection to fail. Netcat's mechanism of
783wrapping an alarm timer around the connect prevents the *real* network error
784from being returned -- "errno" at that point indicates "interrupted system
785call" since the connect attempt was interrupted. Some old 4.3 BSD kernels
786would actually return things like "host unreachable" immediately if that was
787the case, but most newer kernels seem to wait the full timeout and *then* pass
788back the real error. Go figure. In this case, I'd argue that the old way was
789better, despite those same kernels generally being the ones that tear down
790*established* TCP connections when ICMP-bombed.
791
792Incoming socket options are passed to applications by the kernel in the
793kernel's own internal format. The socket-options structure for source-routing
794contains the "first-hop" IP address first, followed by the rest of the real
795options list. The kernel uses this as is when sending reply packets -- the
796structure is therefore designed to be more useful to the kernel than to humans,
797but the hex dump of it that netcat produces is still useful to have.
798
799Kernels treat source-routing options somewhat oddly, but it sort of makes sense
800once one understands what's going on internally. The options list of addresses
801must contain hop1, hop2, ..., destination. When a source-routed packet is sent
802by the kernel [at least BSD], the actual destination address becomes irrelevant
803because it is replaced with "hop1", "hop1" is removed from the options list,
804and all the other addresses in the list are shifted up to fill the hole. Thus
805the outbound packet is sent from your chosen source address to the first
806*gateway*, and the options list now contains hop2, ..., destination. During
807all this address shuffling, the kernel does NOT change the pointer value, which
808is why it is useful to be able to set the pointer yourself -- you can construct
809some really bizarre return paths, and send your traffic fairly directly to the
810target but around some larger loop on the way back. Some Sun kernels seem to
811never flip the source-route around if it contains less than three hops, never
812reset the pointer anyway, and tries to send the packet [with options containing
813a "completed" source route!!] directly back to the source. This is way broken,
814of course. [Maybe ipforwarding has to be on? I haven't had an opportunity to
815beat on it thoroughly yet.]
816
817"Credits" section: The original idea for netcat fell out of a long-standing
818desire and fruitless search for a tool resembling it and having the same
819features. After reading some other network code and realizing just how many
820cool things about sockets could be controlled by the calling user, I started
821on the basics and the rest fell together pretty quickly. Some port-scanning
822ideas were taken from Venema/Farmer's SATAN tool kit, and Pluvius' "pscan"
823utility. Healthy amounts of BSD kernel source were perused in an attempt to
824dope out socket options and source-route handling; additional help was obtained
825from Dave Borman's telnet sources. The select loop is loosely based on fairly
826well-known code from "rsh" and Richard Stevens' "sock" program [which itself is
827sort of a "netcat" with more obscure features], with some more paranoid
828sanity-checking thrown in to guard against the distinct likelihood that there
829are subtleties about such things I still don't understand. I found the
830argument-hiding method cleanly implemented in Barrett's "deslogin"; reading the
831line as input allows greater versatility and is much less prone to cause
832bizarre problems than the more common trick of overwriting the argv array.
833After the first release, several people contributed portability fixes; they are
834credited in generic.h and the Makefile. Lauren Burka inspired the ascii art
835for this revised document. Dean Gaudet at Wired supplied a precursor to
836the hex-dump code, and mudge@l0pht.com originally experimented with and
837supplied code for the telnet-options responder. Outbound "-e <prog>" resulted
838from a need to quietly bypass a firewall installation. Other suggestions and
839patches have rolled in for which I am always grateful, but there are only 26
840hours per day and a discussion of feature creep near the end of this document.
841
842Netcat was written with the Russian railroad in mind -- conservatively built
843and solid, but it *will* get you there. While the coding style is fairly
844"tight", I have attempted to present it cleanly [keeping *my* lines under 80
845characters, dammit] and put in plenty of comments as to why certain things
846are done. Items I know to be questionable are clearly marked with "XXX".
847Source code was made to be modified, but determining where to start is
848difficult with some of the tangles of spaghetti code that are out there.
849Here are some of the major points I feel are worth mentioning about netcat's
850internal design, whether or not you agree with my approach.
851
852Except for generic.h, which changes to adapt more platforms, netcat is a single
853source file. This has the distinct advantage of only having to include headers
854once and not having to re-declare all my functions in a billion different
855places. I have attempted to contain all the gross who's-got-what-.h-file
856things in one small dumping ground. Functions are placed "dependencies-first",
857such that when the compiler runs into the calls later, it already knows the
858type and arguments and won't complain. No function prototyping -- not even the
859__P(()) crock -- is used, since it is more portable and a file of this size is
860easy enough to check manually. Each function has a standard-format comment
861ahead of it, which is easily found using the regexp " :$". I freely use gotos.
862Loops and if-clauses are made as small and non-nested as possible, and the ends
863of same *marked* for clarity [I wish everyone would do this!!].
864
865Large structures and buffers are all malloc()ed up on the fly, slightly larger
866than the size asked for and zeroed out. This reduces the chances of damage
867from those "end of the buffer" fencepost errors or runaway pointers escaping
868off the end. These things are permanent per run, so nothing needs to be freed
869until the program exits.
870
871File descriptor zero is always expected to be standard input, even if it is
872closed. If a new network descriptor winds up being zero, a different one is
873asked for which will be nonzero, and fd zero is simply left kicking around
874for the rest of the run. Why? Because everything else assumes that stdin is
875always zero and "netfd" is always positive. This may seem silly, but it was a
876lot easier to code. The new fd is obtained directly as a new socket, because
877trying to simply dup() a new fd broke subsequent socket-style use of the new fd
878under Solaris' stupid streams handling in the socket library.
879
880The catch-all message and error handlers are implemented with an ample list of
881phoney arguments to get around various problems with varargs. Varargs seems
882like deliberate obfuscation in the first place, and using it would also
883require use of vfprintf() which not all platforms support. The trailing
884sleep in bail() is to allow output to flush, which is sometimes needed if
885netcat is already on the other end of a network connection.
886
887The reader may notice that the section that does DNS lookups seems much
888gnarlier and more confusing than other parts. This is NOT MY FAULT. The
889sockaddr and hostent abstractions are an abortion that forces the coder to
890deal with it. Then again, a lot of BSD kernel code looks like similar
891struct-pointer hell. I try to straighten it out somewhat by defining my own
892HINF structure, containing names, ascii-format IP addresses, and binary IP
893addresses. I fill this structure exactly once per host argument, and squirrel
894everything safely away and handy for whatever wants to reference it later.
895
896Where many other network apps use the FIONBIO ioctl to set non-blocking I/O
897on network sockets, netcat uses straightforward blocking I/O everywhere.
898This makes everything very lock-step, relying on the network and filesystem
899layers to feed in data when needed. Data read in is completely written out
900before any more is fetched. This may not be quite the right thing to do under
901some OSes that don't do timed select() right, but this remains to be seen.
902
903The hexdump routine is written to be as fast as possible, which is why it does
904so much work itself instead of just sprintf()ing everything together. Each
905dump line is built into a single buffer and atomically written out using the
906lowest level I/O calls. Further improvements could undoubtedly be made by
907using writev() and eliminating all sprintf()s, but it seems to fly right along
908as is. If both exec-a-prog mode and a hexdump file is asked for, the hexdump
909flag is deliberately turned off to avoid creating random zero-length files.
910Files are opened in "truncate" mode; if you want "append" mode instead, change
911the open flags in main().
912
913main() may look a bit hairy, but that's only because it has to go down the
914argv list and handle multiple ports, random mode, and exit status. Efforts
915have been made to place a minimum of code inside the getopt() loop. Any real
916work is sent off to functions in what is hopefully a straightforward way.
917
918Obligatory vendor-bash: If "nc" had become a standard utility years ago,
919the commercial vendors would have likely packaged it setuid root and with
920-DGAPING_SECURITY_HOLE turned on but not documented. It is hoped that netcat
921will aid people in finding and fixing the no-brainer holes of this sort that
922keep appearing, by allowing easier experimentation with the "bare metal" of
923the network layer.
924
925It could be argued that netcat already has too many features. I have tried
926to avoid "feature creep" by limiting netcat's base functionality only to those
927things which are truly relevant to making network connections and the everyday
928associated DNS lossage we're used to. Option switches already have slightly
929overloaded functionality. Random port mode is sort of pushing it. The
930hex-dump feature went in later because it *is* genuinely useful. The
931telnet-responder code *almost* verges on the gratuitous, especially since it
932mucks with the data stream, and is left as an optional piece. Many people have
933asked for example "how 'bout adding encryption?" and my response is that such
934things should be separate entities that could pipe their data *through* netcat
935instead of having their own networking code. I am therefore not completely
936enthusiastic about adding any more features to this thing, although you are
937still free to send along any mods you think are useful.
938
939Nonetheless, at this point I think of netcat as my tcp/ip swiss army knife,
940and the numerous companion programs and scripts to go with it as duct tape.
941Duct tape of course has a light side and a dark side and binds the universe
942together, and if I wrap enough of it around what I'm trying to accomplish,
943it *will* work. Alternatively, if netcat is a large hammer, there are many
944network protocols that are increasingly looking like nails by now...
945
946_H* 960320 v1.10 RELEASE -- happy spring!
diff --git a/src/usr.bin/nc/data/Makefile b/src/usr.bin/nc/data/Makefile
new file mode 100644
index 0000000000..65cf185358
--- /dev/null
+++ b/src/usr.bin/nc/data/Makefile
@@ -0,0 +1,10 @@
1all: data rservice xor
2
3data: data.c
4 cc -s -O -o data data.c
5rservice: rservice.c
6 cc -s -O -o rservice rservice.c
7xor: xor.c
8 cc -s -O -o xor xor.c
9clean:
10 rm -f *.o data rservice xor
diff --git a/src/usr.bin/nc/data/README b/src/usr.bin/nc/data/README
new file mode 100644
index 0000000000..7e4b9fbf63
--- /dev/null
+++ b/src/usr.bin/nc/data/README
@@ -0,0 +1,9 @@
1For now, read the header comments inside each of these for documentation.
2The programs are simple enough that they don't really need a Makefile any more
3complex than the one given; ymmv. Data and xor may also be useful on DOS,
4which is why there are hooks for it in the code.
5
6data.c a primitive atob / btoa byte generator
7*.d example input to "data -g"
8rservice.c a utility for scripting up rsh/rexec attacks
9xor.c generic xor handler
diff --git a/src/usr.bin/nc/data/data.c b/src/usr.bin/nc/data/data.c
new file mode 100644
index 0000000000..56c167fd96
--- /dev/null
+++ b/src/usr.bin/nc/data/data.c
@@ -0,0 +1,274 @@
1/* primitive arbitrary-data frontend for netcat. 0.9 960226
2 only handles one value per ascii line, but at least parses 0xNN too
3 an input line containing "%r" during "-g" generates a random byte
4
5 todo:
6 make work on msloss jus' for kicks [workin' on it...]
7
8 syntax: data -X [limit]
9 where X is one of
10 d: dump raw bytes to ascii format
11 g: generate raw bytes from ascii input
12 c: generate ??? of value -- NOTYET
13 r: generate all random bytes
14 and limit is how many bytes to generate or dump [unspecified = infinite]
15
16 *Hobbit*, started 951004 or so and randomly screwed around with since */
17
18#include <stdio.h>
19
20#ifdef MSDOS /* for MSC only at the moment... */
21#include <fcntl.h>
22#else /* MSDOS */
23#include <sys/file.h>
24#define HAVE_RANDOM /* XXX: might have to change */
25#endif /* MSDOS */
26
27static char buf_in [128];
28static char buf_raw [8192];
29static char surveysez[] = "survey sez... XXX\n";
30
31/* fgetss :
32 wrapper for fgets, that yanks trailing newlines. Doing the work ourselves
33 instead of calling strchr/strlen/whatever */
34char * fgetss (buf, len, from)
35 char * buf;
36 size_t len;
37 FILE * from;
38{
39 register int x;
40 register char * p, * q;
41 p = fgets (buf, len, from); /* returns ptr to buf */
42 if (! p)
43 return (NULL);
44 q = p;
45 for (x = 0; x < len; x++) {
46 *p = (*p & 0x7f); /* rip parity, just in case */
47 switch (*p) {
48 case '\n':
49 case '\r':
50 case '\0':
51 *p = '\0';
52 return (q);
53 } /* switch */
54 p++;
55 } /* for */
56} /* fgetss */
57
58/* randint:
59 swiped from rndb.c. Generates an INT, you have to mask down to char. */
60int randint()
61{
62 register int q;
63 register int x;
64
65#ifndef HAVE_RANDOM
66 q = rand();
67#else
68 q = random();
69#endif
70 x = ((q >> 8) & 0xff); /* perturb low byte using some higher bits */
71 x = q ^ x;
72 return (x);
73}
74
75main (argc, argv)
76 int argc;
77 char ** argv;
78{
79 register unsigned char * p;
80 register char * q;
81 register int x;
82 int bc = 0;
83 int limit = 0; /* num to gen, or 0 = infinite */
84 register int xlimit; /* running limit */
85 FILE * txt; /* line-by-line ascii file */
86 int raw; /* raw bytes fd */
87 int dumping = 0; /* cmd flags ... */
88 int genning = 0;
89 int randing = 0;
90
91 memset (buf_in, 0, sizeof (buf_in));
92 memset (buf_raw, 0, sizeof (buf_raw));
93
94 xlimit = 1; /* doubles as "exit flag" */
95 bc = 1; /* preload, assuming "dump" */
96 x = getpid() + 687319;
97/* if your library doesnt have srandom/random, use srand/rand. [from rnd.c] */
98#ifndef HAVE_RANDOM
99 srand (time(0) + x);
100#else
101 srandom (time(0) + x);
102#endif
103
104#ifdef O_BINARY
105/* DOS stupidity */
106/* Aha: *here's* where that setmode() lib call conflict in ?BSD came from */
107 x = setmode (0, O_BINARY); /* make stdin raw */
108 if (x < 0) {
109 fprintf (stderr, "stdin binary setmode oops: %d\n", x);
110 exit (1);
111 }
112 x = setmode (1, O_BINARY); /* make stdout raw */
113 if (x < 0) {
114 fprintf (stderr, "stdout binary setmode oops: %d\n", x);
115 exit (1);
116 }
117#endif /* O_BINARY */
118
119 if (argv[1]) {
120 p = argv[1]; /* shit-simple single arg parser... */
121 if (*p == '-') /* dash is optional, we'll deal */
122 p++;
123 if (*p == 'd')
124 dumping++;
125 if (*p == 'g')
126 genning++;
127 if (*p == 'r')
128 randing++;
129 } /* if argv 1 */
130
131/* optional second argument: limit # of bytes shoveled either way */
132 if (argv[2]) {
133 x = atoi (argv[2]);
134 if (x)
135 limit = x;
136 else
137 goto wrong;
138 xlimit = limit;
139 }
140
141/* Since this prog would likely best be written in assmbler, I'm gonna
142 write it *like* assembler. So there. */
143
144 if (randing)
145 goto do_rand;
146
147nextbuf: /* loop sleaze */
148
149 if (dumping) { /* switch off to wherever */
150 if (genning)
151 goto wrong;
152 goto do_dump;
153 }
154 if (genning)
155 goto do_gen;
156wrong:
157 fprintf (stderr, surveysez); /* if both or neither */
158 exit (1);
159
160do_gen:
161/* here if genning -- original functionality */
162 q = buf_raw;
163 bc = 0;
164/* suck up lines until eof or buf_raw is full */
165 while (1) {
166 p = fgetss (buf_in, 120, stdin);
167 if (! p)
168 break; /* EOF */
169/* super-primitive version first: one thingie per line */
170 if (*p == '#') /* comment */
171 continue;
172 if (*p == '\0') /* blank line */
173 continue;
174 if (*p == '%') { /* escape char? */
175 p++;
176 if (*p == 'r') { /* random byte */
177 x = randint();
178 goto stuff;
179 } /* %r */
180 } /* if "%" escape */
181 if (*p == '0')
182 if (*(p+1) == 'x') /* 0x?? */
183 goto hex;
184 x = atoi (p); /* reg'lar decimal number */
185 goto stuff;
186
187hex:
188/* A 65 a 97 */
189/* xxx: use a conversion table for this or something. Since we ripped the
190 parity bit, we only need a preset array of 128 with downconversion factors
191 loaded in *once*. maybe look at scanf... */
192 p++; p++; /* point at hex-chars */
193 x = 0;
194 if ((*p > 96) && (*p < 123)) /* a-z */
195 *p = (*p - 32); /* this is massively clumsy */
196 if ((*p > 64) && (*p < 71)) /* A-F */
197 x = (*p - 55);
198 if ((*p > 47) && (*p < 58)) /* digits */
199 x = (*p - 48);
200 p++;
201 if (*p) /* another digit? */
202 x = (x << 4); /* shift to hi half */
203 if ((*p > 96) && (*p < 123)) /* a-z */
204 *p = (*p - 32);
205 if ((*p > 64) && (*p < 71)) /* A-F */
206 x = (x | (*p - 55)); /* lo half */
207 if ((*p > 47) && (*p < 58)) /* digits */
208 x = (x | (*p - 48));
209
210/* fall thru */
211stuff: /* cvt to byte and add to buffer */
212 *q = (x & 0xff);
213 q++;
214 bc++;
215 if (limit) {
216 xlimit--;
217 if (xlimit == 0) /* max num reached */
218 break;
219 } /* limit */
220 if (bc >= sizeof (buf_raw)) /* buffer full */
221 break;
222 } /* while 1 */
223
224/* now in theory we have our buffer formed; shovel it out */
225 x = write (1, buf_raw, bc);
226 if (x <= 0) {
227 fprintf (stderr, "write oops: %d\n", x);
228 exit (1);
229 }
230 if (xlimit && p)
231 goto nextbuf; /* go get some more */
232 exit (0);
233
234do_dump:
235/* here if dumping raw stuff into an ascii file */
236/* gad, this is *so* much simpler! can we say "don't rewrite printf"? */
237 x = read (0, buf_raw, 8192);
238 if (x <= 0)
239 exit (0);
240 q = buf_raw;
241 for ( ; x > 0; x--) {
242 p = q;
243 printf ("%-3.3d # 0x%-2.2x # ", *p, *p);
244 if ((*p > 31) && (*p < 127))
245 printf ("%c %d\n", *p, bc);
246 else
247 printf (". %d\n", bc);
248 q++;
249 bc++;
250 if (limit) {
251 xlimit--;
252 if (xlimit == 0) {
253 fflush (stdout);
254 exit (0);
255 }
256 } /* limit */
257 } /* for */
258 goto nextbuf;
259
260do_rand:
261/* here if generating all-random bytes. Stays in this loop */
262 p = buf_raw;
263 while (1) {
264 *p = (randint() & 0xff);
265 write (1, p, 1); /* makes very slow! */
266 if (limit) {
267 xlimit--;
268 if (xlimit == 0)
269 break;
270 }
271 } /* while */
272 exit (0);
273
274} /* main */
diff --git a/src/usr.bin/nc/data/dns-any.d b/src/usr.bin/nc/data/dns-any.d
new file mode 100644
index 0000000000..77b014cf70
--- /dev/null
+++ b/src/usr.bin/nc/data/dns-any.d
@@ -0,0 +1,36 @@
1# dns "any for ." query, to udp 53
2# if tcp: precede with 2 bytes of len:
3# 0
4# 17
5# you should get at least *one* record back out
6
7# HEADER:
80 # query id = 2
92
10
111 # flags/opcodes = query, dorecurse
120
13
140 # qdcount, i.e. nqueries: 1
151
16
170 # ancount: answers, 0
180
19
200 # nscount: 0
210
22
230 # addl records: 0
240
25
26# end of fixed header
27
280 # name-len: 0 for ".", lenbyte plus name-bytes otherwise
29
300 # type: any, 255
310xff
32
330 # class: IN
341
35
36# i think that's it..
diff --git a/src/usr.bin/nc/data/nfs-0.d b/src/usr.bin/nc/data/nfs-0.d
new file mode 100644
index 0000000000..0360938227
--- /dev/null
+++ b/src/usr.bin/nc/data/nfs-0.d
@@ -0,0 +1,59 @@
1# UDP NFS null-proc call; finds active NFS listeners on port 2049.
2# If you get *something* back, there's an NFS server there.
3
4000 # XID: 4 trash bytes
5001
6002
7003
8
9000 # CALL: 0
10000
11000
12000
13
14000 # RPC version: 2
15000
16000
17002
18
19000 # nfs: 100003
20001
210x86
220xa3
23
24000 # version: 1
25000
26000
27001
28
29000 # procedure number: 0
30000
31000
32000
33
34000 # port: junk
35000
36000
37000
38
39000 # auth trash
40000
41000
42000
43
44000 # auth trash
45000
46000
47000
48
49000 # auth trash
50000
51000
52000
53
54000 # extra auth trash? probably not needed
55000
56000
57000
58
59# that's it!
diff --git a/src/usr.bin/nc/data/pm.d b/src/usr.bin/nc/data/pm.d
new file mode 100644
index 0000000000..fe327693a9
--- /dev/null
+++ b/src/usr.bin/nc/data/pm.d
@@ -0,0 +1,8 @@
1# obligatory duplicate of dr delete's Livingston portmaster crash, aka
2# telnet break. Fire into its telnet listener. An *old* bug by now, but
3# consider the small window one might obtain from a slightly out-of-rev PM
4# used as a firewall, that starts routing IP traffic BEFORE its filter sets
5# are fully loaded...
6
7255 # 0xff # . 1
8243 # 0xf3 # . 2
diff --git a/src/usr.bin/nc/data/pmap-dump.d b/src/usr.bin/nc/data/pmap-dump.d
new file mode 100644
index 0000000000..bc6b63277d
--- /dev/null
+++ b/src/usr.bin/nc/data/pmap-dump.d
@@ -0,0 +1,60 @@
1# portmap dump request: like "rpcinfo -p" but via UDP instead
2# send to UDP 111 and hope it's not a logging portmapper!
3# split into longwords, since rpc apparently only deals with them
4
5001 # 0x01 # . # XID: 4 trash bytes
6002 # 0x02 # .
7003 # 0x03 # .
8004 # 0x04 # .
9
10000 # 0x00 # . # MSG: int 0=call, 1=reply
11000 # 0x00 # .
12000 # 0x00 # .
13000 # 0x00 # .
14
15000 # 0x00 # . # pmap call body: rpc version=2
16000 # 0x00 # .
17000 # 0x00 # .
18002 # 0x02 # .
19
20000 # 0x00 # . # pmap call body: prog=PMAP, 100000
21001 # 0x01 # .
22134 # 0x86 # .
23160 # 0xa0 # .
24
25000 # 0x00 # . # pmap call body: progversion=2
26000 # 0x00 # .
27000 # 0x00 # .
28002 # 0x02 # .
29
30000 # 0x00 # . # pmap call body: proc=DUMP, 4
31000 # 0x00 # .
32000 # 0x00 # .
33004 # 0x04 # .
34
35# with AUTH_NONE, there are 4 zero integers [16 bytes] here
36
37000 # 0x00 # . # auth junk: cb_cred: auth_unix = 1; NONE = 0
38000 # 0x00 # .
39000 # 0x00 # .
40000 # 0x00 # .
41
42000 # 0x00 # . # auth junk
43000 # 0x00 # .
44000 # 0x00 # .
45000 # 0x00 # .
46
47000 # 0x00 # . # auth junk
48000 # 0x00 # .
49000 # 0x00 # .
50000 # 0x00 # .
51
52000 # 0x00 # . # auth junk
53000 # 0x00 # .
54000 # 0x00 # .
55000 # 0x00 # .
56
57# The reply you get back contains your XID, int 1 if "accepted", and
58# a whole mess of gobbledygook containing program numbers, versions,
59# and ports that rpcinfo knows how to decode. For the moment, you get
60# to wade through it yourself...
diff --git a/src/usr.bin/nc/data/pmap-mnt.d b/src/usr.bin/nc/data/pmap-mnt.d
new file mode 100644
index 0000000000..00588ba41f
--- /dev/null
+++ b/src/usr.bin/nc/data/pmap-mnt.d
@@ -0,0 +1,78 @@
1# portmap request for mountd [or whatever; see where prog=MOUNT]
2# send to UDP 111 and hope it's not a logging portmapper!
3# split into longwords, since rpc apparently only deals with them
4
5001 # 0x01 # . # XID: 4 trash bytes
6002 # 0x02 # .
7003 # 0x03 # .
8004 # 0x04 # .
9
10000 # 0x00 # . # MSG: int 0=call, 1=reply
11000 # 0x00 # .
12000 # 0x00 # .
13000 # 0x00 # .
14
15000 # 0x00 # . # pmap call body: rpc version=2
16000 # 0x00 # .
17000 # 0x00 # .
18002 # 0x02 # .
19
20000 # 0x00 # . # pmap call body: prog=PMAP, 100000
21001 # 0x01 # .
22134 # 0x86 # .
23160 # 0xa0 # .
24
25000 # 0x00 # . # pmap call body: progversion=2
26000 # 0x00 # .
27000 # 0x00 # .
28002 # 0x02 # .
29
30000 # 0x00 # . # pmap call body: proc=GETPORT, 3
31000 # 0x00 # .
32000 # 0x00 # .
33003 # 0x03 # .
34
35# with AUTH_NONE, there are 4 zero integers [16 bytes] here
36
37000 # 0x00 # . # auth junk: cb_cred: auth_unix = 1; NONE = 0
38000 # 0x00 # .
39000 # 0x00 # .
40000 # 0x00 # .
41
42000 # 0x00 # . # auth junk
43000 # 0x00 # .
44000 # 0x00 # .
45000 # 0x00 # .
46
47000 # 0x00 # . # auth junk
48000 # 0x00 # .
49000 # 0x00 # .
50000 # 0x00 # .
51
52000 # 0x00 # . # auth junk
53000 # 0x00 # .
54000 # 0x00 # .
55000 # 0x00 # .
56
57000 # 0x00 # . # prog=MOUNT, 100005
58001 # 0x01 # .
59134 # 0x86 # .
60165 # 0xa5 # .
61
62000 # 0x00 # . # progversion=1
63000 # 0x00 # .
64000 # 0x00 # .
65001 # 0x01 # .
66
67000 # 0x00 # . # protocol=udp, 17
68000 # 0x00 # .
69000 # 0x00 # .
70017 # 0x11 # .
71
72000 # 0x00 # . # proc num = junk
73000 # 0x00 # .
74000 # 0x00 # .
75000 # 0x00 # .
76
77# The reply you get back contains your XID, int 1 if "accepted", and
78# mountd's port number at the end or 0 if not registered.
diff --git a/src/usr.bin/nc/data/rip.d b/src/usr.bin/nc/data/rip.d
new file mode 100644
index 0000000000..da505e2143
--- /dev/null
+++ b/src/usr.bin/nc/data/rip.d
@@ -0,0 +1,52 @@
1# struct netinfo {
2# struct sockaddr rip_dst; /* destination net/host */
3# int rip_metric; /* cost of route */
4# };
5# struct rip {
6# u_char rip_cmd; /* request/response */
7# u_char rip_vers; /* protocol version # */
8# u_char rip_res1[2]; /* pad to 32-bit boundary */
9# union {
10# struct netinfo ru_nets[1]; /* variable length... */
11# char ru_tracefile[1]; /* ditto ... */
12# } ripun;
13#define rip_nets ripun.ru_nets
14#define rip_tracefile ripun.ru_tracefile
15#define RIPCMD_REQUEST 1 /* want info */
16#define RIPCMD_RESPONSE 2 /* responding to request */
17#define RIPCMD_TRACEON 3 /* turn tracing on */
18#define RIPCMD_TRACEOFF 4 /* turn it off */
19#define HOPCNT_INFINITY 16 /* per Xerox NS */
20#define MAXPACKETSIZE 512 /* max broadcast size */
21
22### RIP packet redux
23### UDP send FROM clued-rtr/520 to target/520
242 # RIPCMD_RESPONSE
251 # version
260 # padding
270
28
29# sockaddr-plus-metric structs begin, as many as necessary...
300 # len
312 # AF_INET
320 # port
330
34# addr bytes:
35X
36Y
37Z
38Q
390 # filler, out to 16 bytes [sizeof (sockaddr)] ...
400
410
420
430
440
450
460
470 # metric: net-order integer
480
490
501
51
52## that's it
diff --git a/src/usr.bin/nc/data/rservice.c b/src/usr.bin/nc/data/rservice.c
new file mode 100644
index 0000000000..1085d9cb78
--- /dev/null
+++ b/src/usr.bin/nc/data/rservice.c
@@ -0,0 +1,68 @@
1/* generate ^@string1^@string2^@cmd^@ input to netcat, for scripting up
2 rsh/rexec attacks. Needs to be a prog because shells strip out nulls.
3
4 args:
5 locuser remuser [cmd]
6 remuser passwd [cmd]
7
8 cmd defaults to "pwd".
9
10 ... whatever. _H*/
11
12#include <stdio.h>
13
14/* change if you like; "id" is a good one for figuring out if you won too */
15static char cmd[] = "pwd";
16
17static char buf [256];
18
19main(argc, argv)
20 int argc;
21 char * argv[];
22{
23 register int x;
24 register int y;
25 char * p;
26 char * q;
27
28 p = buf;
29 memset (buf, 0, 256);
30
31 p++; /* first null */
32 y = 1;
33
34 if (! argv[1])
35 goto wrong;
36 x = strlen (argv[1]);
37 memcpy (p, argv[1], x); /* first arg plus another null */
38 x++;
39 p += x;
40 y += x;
41
42 if (! argv[2])
43 goto wrong;
44 x = strlen (argv[2]);
45 memcpy (p, argv[2], x); /* second arg plus null */
46 x++;
47 p += x;
48 y += x;
49
50 q = cmd;
51 if (argv[3])
52 q = argv[3];
53 x = strlen (q); /* not checked -- bfd */
54 memcpy (p, q, x); /* the command, plus final null */
55 x++;
56 p += x;
57 y += x;
58
59 memcpy (p, "\n", 1); /* and a newline, so it goes */
60 y++;
61
62 write (1, buf, y); /* zot! */
63 exit (0);
64
65wrong:
66 fprintf (stderr, "wrong! needs 2 or more args.\n");
67 exit (1);
68}
diff --git a/src/usr.bin/nc/data/showmount.d b/src/usr.bin/nc/data/showmount.d
new file mode 100644
index 0000000000..499794bc8a
--- /dev/null
+++ b/src/usr.bin/nc/data/showmount.d
@@ -0,0 +1,63 @@
1# UDP mountd call. Use as input to find mount daemons and avoid portmap.
2# Useful proc numbers are 2, 5, and 6.
3# UDP-scan around between 600-800 to find most mount daemons.
4# Using this with "2", plugged into "nc -u -v -w 2 victim X-Y" will
5# directly scan *and* dump the current exports when mountd is hit.
6# combine stdout *and* stderr thru "strings" or something to clean it up
7
8000 # XID: 4 trash bytes
9001
10002
11003
12
13000 # CALL: 0
14000
15000
16000
17
18000 # RPC version: 2
19000
20000
21002
22
23000 # mount: 100005
24001
250x86
260xa5
27
28000 # mount version: 1
29000
30000
31001
32
33000 # procedure number -- put what you need here:
34000 # 2 = dump [showmount -e]
35000 # 5 = exportlist [showmount -a]
36xxx # "sed s/xxx/$1/ | data -g | nc ..." or some such...
37
38000 # port: junk
39000
40000
41000
42
43000 # auth trash
44000
45000
46000
47
48000 # auth trash
49000
50000
51000
52
53000 # auth trash
54000
55000
56000
57
58000 # extra auth trash? probably not needed
59000
60000
61000
62
63# that's it!
diff --git a/src/usr.bin/nc/data/xor.c b/src/usr.bin/nc/data/xor.c
new file mode 100644
index 0000000000..9feead0cba
--- /dev/null
+++ b/src/usr.bin/nc/data/xor.c
@@ -0,0 +1,92 @@
1/* Generic xor handler.
2
3 With no args, xors stdin against 0xFF to stdout. A single argument is a
4 file to read xor-bytes out of. Any zero in the xor-bytes array is treated
5 as the end; if you need to xor against a string that *includes* zeros,
6 you're on your own.
7
8 The indirect file can be generated easily with data.c.
9
10 Written because there are so many lame schemes for "masking" plaintext
11 passwords and the like floating around, and it's handy to just run an
12 obscure binary-format configuration file through this and look for strings.
13
14 *Hobbit*, 960208 */
15
16#include <stdio.h>
17#include <fcntl.h>
18
19char buf[8192];
20char bytes[256];
21char * py;
22
23/* do the xor, in place. Uses global ptr "py" to maintain "bytes" state */
24xorb (buf, len)
25 char * buf;
26 int len;
27{
28 register int x;
29 register char * pb;
30
31 pb = buf;
32 x = len;
33 while (x > 0) {
34 *pb = (*pb ^ *py);
35 pb++;
36 py++;
37 if (! *py)
38 py = bytes;
39 x--;
40 }
41} /* xorb */
42
43/* blah */
44main (argc, argv)
45 int argc;
46 char ** argv;
47{
48 register int x = 0;
49 register int y;
50
51/* manually preload; xor-with-0xFF is all too common */
52 memset (bytes, 0, sizeof (bytes));
53 bytes[0] = 0xff;
54
55/* if file named in any arg, reload from that */
56#ifdef O_BINARY /* DOS shit... */
57 x = setmode (0, O_BINARY); /* make stdin raw */
58 if (x < 0) {
59 fprintf (stderr, "stdin binary setmode oops: %d\n", x);
60 exit (1);
61 }
62 x = setmode (1, O_BINARY); /* make stdout raw */
63 if (x < 0) {
64 fprintf (stderr, "stdout binary setmode oops: %d\n", x);
65 exit (1);
66 }
67#endif /* O_BINARY */
68
69 if (argv[1])
70#ifdef O_BINARY
71 x = open (argv[1], O_RDONLY | O_BINARY);
72#else
73 x = open (argv[1], O_RDONLY);
74#endif
75 if (x > 0) {
76 read (x, bytes, 250); /* nothin' fancy here */
77 close (x);
78 }
79 py = bytes;
80 x = 1;
81 while (x > 0) {
82 x = read (0, buf, sizeof (buf));
83 if (x <= 0)
84 break;
85 xorb (buf, x);
86 y = write (1, buf, x);
87 if (y <= 0)
88 exit (1);
89 }
90 exit (0);
91}
92
diff --git a/src/usr.bin/nc/generic.h b/src/usr.bin/nc/generic.h
new file mode 100644
index 0000000000..b3dd5f5dc6
--- /dev/null
+++ b/src/usr.bin/nc/generic.h
@@ -0,0 +1,377 @@
1/* generic.h -- anything you don't #undef at the end remains in effect.
2 The ONLY things that go in here are generic indicator flags; it's up
3 to your programs to declare and call things based on those flags.
4
5 You should only need to make changes via a minimal system-specific section
6 at the end of this file. To build a new section, rip through this and
7 check everything it mentions on your platform, and #undef that which needs
8 it. If you generate a system-specific section you didn't find in here,
9 please mail me a copy so I can update the "master".
10
11 I realize I'm probably inventing another pseudo-standard here, but
12 goddamnit, everybody ELSE has already, and I can't include all of their
13 hairball schemes too. HAVE_xx conforms to the gnu/autoconf usage and
14 seems to be the most common format. In fact, I dug a lot of these out
15 of autoconf and tried to common them all together using "stupidh" to
16 collect data from platforms.
17
18 In disgust... _H* 940910, 941115, 950511. Pseudo-version: 1.3
19
20 Updated 951104 with many patches from netcat feedback, and properly
21 closed a lot of slop in open-ended comments: version 1.4
22 960217 + nextstep: version 1.5
23*/
24
25#ifndef GENERIC_H /* only run through this once */
26#define GENERIC_H
27
28/* =============================== */
29/* System calls, lib routines, etc */
30/* =============================== */
31
32/* How does your system declare malloc, void or char? Usually void, but go
33 ask the SunOS people why they had to be different... */
34#define VOID_MALLOC
35
36/* notably from fwtk/firewall.h: posix locking? */
37#define HAVE_FLOCK /* otherwise it's lockf() */
38
39/* if you don't have setsid(), you might have setpgrp(). */
40#define HAVE_SETSID
41
42/* random() is generally considered better than rand() */
43#define HAVE_RANDOM
44
45/* the srand48/lrand48/etc family is s'posedly even better */
46#define HAVE_RAND48
47/* bmc@telebase and others have suggested these macros if a box *does* have
48 rand48. Will consider for later if we're doing something that really
49 requires stronger random numbers, but netcat and such certainly doesn't.
50#define srandom(seed) srand48((long) seed)
51#define random() lrand48() */
52
53/* if your machine doesn't have lstat(), it should have stat() [dos...] */
54#define HAVE_LSTAT
55
56/* different kinds of term ioctls. How to recognize them, very roughly:
57 sysv/POSIX_ME_HARDER: termio[s].h, struct termio[s], tty.c_*[]
58 bsd/old stuff: sgtty.h, ioctl(TIOCSETP), sgttyb.sg_*, tchars.t_* */
59#define HAVE_TERMIOS
60
61/* dbm vs ndbm */
62#define HAVE_NDBM
63
64/* extended utmp/wtmp stuff. MOST machines still do NOT have this SV-ism */
65#define UTMPX
66
67/* some systems have nice() which takes *relative* values... [resource.h] */
68#define HAVE_SETPRIORITY
69
70/* a sysvism, I think, but ... */
71#define HAVE_SYSINFO
72
73/* ============= */
74/* Include files */
75/* ============= */
76
77/* Presence of these can be determined via a script that sniffs them
78 out if you aren't sure. See "stupidh"... */
79
80/* stdlib comes with most modern compilers, but ya never know */
81#define HAVE_STDLIB_H
82
83/* not on a DOS box! */
84#define HAVE_UNISTD_H
85
86/* stdarg is a weird one */
87#define HAVE_STDARG_H
88
89/* dir.h or maybe ndir.h otherwise. */
90#define HAVE_DIRENT_H
91
92/* string or strings */
93#define HAVE_STRINGS_H
94
95/* if you don't have lastlog.h, what you want might be in login.h */
96#define HAVE_LASTLOG_H
97
98/* predefines for _PATH_various */
99#define HAVE_PATHS_H
100
101/* some SV-flavors break select stuff out separately */
102#define HAVE_SELECT_H
103
104/* assorted others */
105#define HAVE_PARAM_H /* in sys/ */
106#define HAVE_SYSMACROS_H /* in sys/ */
107#define HAVE_TTYENT_H /* securetty et al */
108
109/* ==================== */
110
111/* Still maybe have to do something about the following, if it's even
112 worth it. I just grepped a lot of these out of various code, without
113 looking them up yet:
114
115#define HAVE_EINPROGRESS
116#define HAVE_F_SETOWN
117HAVE_FILIO_H ... fionbio, fiosetown, etc... will need for hairier
118 select loops.
119#define HAVE_SETENV ... now *there's* a hairy one; **environ is portable
120#define BIG_ENDIAN/little_endian ... *please* try to avoid this stupidity
121 and LSBFIRST/MSBFIRST
122#define HAVE_GETUSERSHELL ... you could always pull it out of getpwent()
123#define HAVE_SETE[UG]ID ... lib or syscall, it varies on diff platforms
124#define HAVE_STRCHR ... should actually be handled by string/strings
125#define HAVE_PSTAT
126#define HAVE_ST_BLKSIZE ... a stat() thing?
127#define HAVE_IP_TOS
128#define HAVE_STRFTIME ... screw this, we'll just INCLUDE one for lame
129 old boxes that don't have it [sunos 3.x, early 4.x?]
130#define HAVE_VFPRINTF
131#define HAVE_SHADOW_PASSWD ... in its multitudinous schemes?? ... how
132 about sumpin' like #define SHADOW_PASSWD_TYPE ... could get grody.
133 ... looks like sysv /etc/shadow, getspent() family is common.
134#define SIG* ... what a swamp, punt for now; should all be in signal.h
135#define HAVE_STRCSPN ... see larry wall's comment in the fwtk regex code
136#define ULTRIX_AUTH ... bwahaha.
137#define HAVE_YP or NIS or whatever you wanna call it this week
138randomness about VARARGS??
139--- later stuff to be considered ---
140#define UINT4 ... u-int on alpha/osf, i.e. __alpha/__osf__, ulong elsewhere?
141 dont name it that, though, it'll conflict with extant .h files like md5
142randomness about machine/endian.h, machine/inline.h -- bsdi, net/2
143randomness about _PATH_WTMP vs WTMP_FILE and where they even live!!
144#define HAVE_SYS_ERRLIST ... whether it's in stdio.h or not [bsd 4.4]
145--- still more stuff
146#define HAVE_SETENV
147#define _PATH_UTMP vs UTMP_FILE, a la deslogind?!
148#define HAVE_DAEMON
149#define HAVE_INETADDR [vixie bind?]
150lseek: SEEK_SET vs L_SET and associated lossage [epi-notes, old 386Mach]
151bsdi: ioctl_compat.h ?
152--- takin' some ifdefs from CNS krb:
153F_GETOWN/F_SETOWN
154CRAY: long = 8 bytes, etc [class with alpha?]
155CGETENT
156SIGINFO
157SIGTSTP SIGTTOU SIGWINCH
158SPX?
159SYSV_TERMIO -- covered elsewhere, I hope
160TIOCEXT TIOCFLUSH TIOC[GS]WINSIZ
161NEWINIT: something about init cleaning up dead login processes [telnet?]
162PARENT_DOES_UTMP, too [telnet]
163VDISCARD
164VEOL/VEOL2/VLNEXT VREPRINT -- termios stuff?, and related...
165STREAMSPTY/STREAMSPTYEM
166AF_INET/AF_UNSPEC, PF_*
167ECHOCTL/ECHOKE
168F_ULOCK [?!]
169setpgrp/getpgrp() ONEARG business..
170HAVE_ALLOCA
171HAVE_GETUTENT
172HAVE_SYS_SELECT_H [irix!]
173HAVE_DIRENT [old 386mach has *direct.h*!]
174HAVE_SIGSET
175HAVE_VFORK_H and HAVE_VFORK
176HAVE_VHANGUP
177HAVE_VSPRINTF
178HAVE_IPTOS_*
179HAVE_STRCASECMP, STRNCASECMP
180HAVE_SYS_FCNTL_H
181HAVE_SYS_TIME_H
182HAVE_UTIMES
183NOTTYENT [?]
184HAVE_FCHMOD
185HAVE_GETUSERSHELL
186HAVE_SIGCONTEXT [stack hair, very machine-specific]
187YYLINENO?
188POSIX_SIGNALS
189POSIX_TERMIOS
190SETPROCTITLE -- breaks some places, like fbsd sendmail
191SIG* -- actual signal names? some are missing
192SIOCGIFCONF
193SO_BROADCAST
194SHMEM [krb tickets]
195VARARGS, or HAVE_VARARGS
196CBAUD
197... and B300, B9600, etc etc
198HAVE_BZERO vs memset/memcpy
199HAVE_SETVBUF
200HAVE_STRDUP
201HAVE_GETENV
202HAVE_STRSAVE
203HAVE_STBLKSIZE [stat?]
204HAVE_STREAM_H -- in sys/, ref sendmail 8.7 for IP_SRCROUTE
205FCHMOD
206INITGROUPS -- most machines seem to *have*
207SETREUID
208SNPRINTF
209SETPGRP semantics bsd vs. sys5 style
210
211There's also the issue about WHERE various .h files live, sys/ or otherwise.
212There's a BIG swamp lurking where network code of any sort lives.
213*/
214
215/* ======================== */
216/* System-specific sections */
217/* ======================== */
218
219/* By turning OFF various bits of the above, you can customize for
220 a given platform. Yes, we're ignoring the stock compiler predefines
221 and using our own plugged in via the Makefile. */
222
223/* DOS boxes, with MSC; you may need to adapt to a different compiler. */
224/* looks like later ones *do* have dirent.h, for example */
225#ifdef MSDOS
226#undef HAVE_FLOCK
227#undef HAVE_RANDOM
228#undef HAVE_LSTAT
229#undef HAVE_TERMIOS
230#undef UTMPX
231#undef HAVE_SYSINFO
232#undef HAVE_UNISTD_H
233#undef HAVE_DIRENT_H /* unless you have the k00l little wrapper from L5!! */
234#undef HAVE_STRINGS_H
235#undef HAVE_LASTLOG_H
236#undef HAVE_PATHS_H
237#undef HAVE_PARAM_H
238#undef HAVE_SYSMACROS_H
239#undef HAVE_SELECT_H
240#undef HAVE_TTYENT_H
241#endif /* MSDOS */
242
243/* buglix 4.x; dunno about 3.x on down. should be bsd4.2 */
244#ifdef ULTRIX
245#undef UTMPX
246#undef HAVE_PATHS_H
247#undef HAVE_SYSMACROS_H
248#undef HAVE_SELECT_H
249#endif /* buglix */
250
251/* some of this might still be broken on older sunoses */
252#ifdef SUNOS
253#undef VOID_MALLOC
254#undef UTMPX
255#undef HAVE_PATHS_H
256#undef HAVE_SELECT_H
257#endif /* sunos */
258
259/* "contact your vendor for a fix" */
260#ifdef SOLARIS
261/* has UTMPX */
262#undef HAVE_RANDOM
263#undef HAVE_SETPRIORITY
264#undef HAVE_STRINGS_H /* this is genuinely the case, go figure */
265#undef HAVE_PATHS_H
266#undef HAVE_SELECT_H
267#undef HAVE_TTYENT_H
268#endif /* SOLARIS */
269
270/* whatever aix variant MIT had at the time; 3.2.x?? */
271#ifdef AIX
272#undef UTMPX
273#undef HAVE_LASTLOG_H
274#define HAVE_LOGIN_H /* "special", in the educational sense */
275#endif /* aix */
276
277/* linux, which is trying as desperately as the gnu folks can to be
278 POSIXLY_CORRECT. I think I'm gonna hurl... */
279#ifdef LINUX
280#undef UTMPX
281#undef HAVE_SYSINFO
282#undef HAVE_SELECT_H
283#undef HAVE_TTYENT_H
284#endif /* linux */
285
286/* irix 5.x; may not be correct for earlier ones */
287#ifdef IRIX
288/* wow, does irix really have everything?! */
289#endif /* irix */
290
291/* osf on alphas */
292#ifdef OSF
293#undef UTMPX
294#undef HAVE_SELECT_H
295#endif /* osf */
296
297/* they's some FUCKED UP paths in this one! */
298#ifdef FREEBSD
299#undef UTMPX
300#undef HAVE_SYSINFO
301#undef HAVE_LASTLOG_H
302#undef HAVE_SYSMACROS_H
303#undef HAVE_SELECT_H /* actually a lie, but only for kernel */
304#endif /* freebsd */
305
306/* Originally from the sidewinder site, of all places, but subsequently
307 checked further under a more normal bsdi 2.0 */
308#ifdef BSDI
309#undef UTMPX
310#undef HAVE_LASTLOG_H
311#undef HAVE_SYSMACROS_H
312/* and their malloc.h was in sys/ ?! */
313#undef HAVE_SELECT_H
314#endif /* bsdi */
315
316/* netbsd/44lite, jives with amiga-netbsd from cactus */
317#ifdef NETBSD
318#undef UTMPX
319#undef HAVE_SYSINFO
320#undef HAVE_LASTLOG_H
321#undef HAVE_SELECT_H
322#endif /* netbsd */
323
324/* Hpux 9.0x, from BBN and various patches sent in */
325#ifdef HPUX
326#undef HAVE_RANDOM /* but *does* have ?rand48 -- need to consider.. */
327#undef HAVE_UTMPX
328#undef HAVE_LASTLOG_H /* has utmp/wtmp/btmp nonsense, and pututline() */
329#undef HAVE_PATHS_H
330#undef HAVE_SELECT_H
331#undef HAVE_TTYENT_H
332#endif /* hockeypux */
333
334/* Unixware [a loose definition of "unix", to be sure], 1.1.2 [at least]
335 from Brian Clapper. He wasn't sure about 2.0... */
336#ifdef UNIXWARE
337/* has UTMPX */
338#undef HAVE_SETPRIORITY
339/* NOTE: UnixWare does provide the BSD stuff, in "/usr/ucbinclude" (headers)
340 and "/usr/ucblib" (libraries). However, I've run into problems linking
341 stuff out of that version of the C library, when objects are also coming
342 out of the "regular" C library. My advice: Avoid the BSD compatibility
343 stuff wherever possible. Brian Clapper <bmc@telebase.com> */
344#undef HAVE_STRINGS_H
345#undef HAVE_PATHS_H
346#undef HAVE_TTYENT_H
347#endif /* UNIXWARE */
348
349/* A/UX 3.1.x from darieb@sandia.gov */
350#ifdef AUX
351#undef HAVE_RANDOM
352#undef HAVE_SELECT_H /* xxx: untested */
353#endif /* a/ux */
354
355/* NeXTSTEP 3.2 motorola mudge@l0pht.com xxx should also work with
356 white hardware and Sparc/HPPA. Should work with 3.3 too as it's
357 4.3 / 4.4 bsd wrapped around mach */
358#ifdef NEXT
359#undef UTMPX
360#undef HAVE_SELECT_X
361#endif /* NeXTSTEP 3.2 motorola */
362
363/* Make some "generic" assumptions if all else fails */
364#ifdef GENERIC
365#undef HAVE_FLOCK
366#if defined(SYSV) && (SYSV < 4) /* TW leftover: old SV doesnt have symlinks */
367#undef HAVE_LSTAT
368#endif /* old SYSV */
369#undef HAVE_TERMIOS
370#undef UTMPX
371#undef HAVE_PATHS_H
372#undef HAVE_SELECT_H
373#endif /* generic */
374
375/* ================ */
376#endif /* GENERIC_H */
377
diff --git a/src/usr.bin/nc/nc.1 b/src/usr.bin/nc/nc.1
new file mode 100644
index 0000000000..8d87051c73
--- /dev/null
+++ b/src/usr.bin/nc/nc.1
@@ -0,0 +1,215 @@
1.\" $OpenBSD: nc.1,v 1.5 1998/09/28 06:57:35 millert Exp $
2.\"
3.\" Copyright (c) 1996 David Sacerdote
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
14.\" 3. The name of the author may not be used to endorse or promote products
15.\" derived from this software without specific prior written permission
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.Dd August 1, 1996
29.Dt NC 1
30.Os
31.Sh NAME
32.Nm nc
33.Nd "arbitrary TCP and UDP connections and listens"
34.Sh SYNOPSIS
35.Nm nc
36.Op Fl e Ar command
37.Op Fl g Ar intermediates
38.Op Fl G Ar hopcount
39.Op Fl i Ar interval
40.Op Fl lnrtuvz
41.Op Fl o Ar filename
42.Op Fl p Ar source port
43.Op Fl s Ar ip address
44.Op Fl w Ar timeout
45.Op Ar hostname
46.Op Ar port[s...]
47.Sh DESCRIPTION
48The
49.Nm nc
50(or
51.Nm netcat )
52utility is used for just about anything under the sun
53involving TCP or UDP. It can open TCP connections, send UDP packets,
54listen on arbitrary TCP and UDP ports, do port scanning, and source
55routing. Unlike
56.Xr telnet 1 ,
57.Nm nc
58scripts nicely, and separates error messages onto standard error instead
59of sending them to standard output, as
60.Xr telnet 1
61does with some.
62.Pp
63Destination ports can be single integers, names as listed in
64.Xr services 5 ,
65or ranges. Ranges are in the form nn-mm, and several separate ports and/or
66ranges may be specified on the command line.
67.Pp
68Common uses include:
69.Bl -bullet
70.It
71simple TCP proxies
72.It
73shell\-script based HTTP clients and servers
74.It
75network daemon testing
76.It
77source routing based connectivity testing
78.It
79and much, much more
80.El
81.Pp
82The options are as follows:
83.Bl -tag -width Ds
84.It Fl e Ar command
85Execute the specified command, using data from the network for stdin,
86and sending stdout and stderr to the network. This option is only present if
87.Nm nc
88was compiled with the GAPING_SECURITY_HOLE compile time option, since it
89allows users to make arbitrary programs available to anyone on the network.
90.It Fl g Ar intermediate-host
91Specifies a hop along a loose source routed path. Can be used more than
92once to build a chain of hop points.
93.It Fl G Ar pointer
94Positions the "hop counter" within the list of machines in the path of
95a source routed packet. Must be a multiple of 4.
96.It Fl i Ar seconds
97Specifies a delay time interval between lines of text sent and received.
98Also causes a delay time between connections to multiple ports.
99.It Fl l
100Is used to specify that
101.Nm nc
102should listen for an incoming connection, rather than initiate a
103connection to a remote host. Any hostname/IP address and port arguments
104restrict the source of inbound connections to only that address and
105source port.
106.It Fl n
107Do not do DNS lookups on any of the specified addresses or hostnames, or
108names of port numbers from /etc/services.
109.It Fl o Ar filename
110Create a hexadecimal log of data transferred in the specified file.
111Each line begins with ``<'' or ``>''. ``<'' means "from the net" and ``>''
112means "to the net".
113.It Fl p Ar port
114Specifies the source port
115.Nm nc
116should use, subject to privilege restrictions and availability.
117.It Fl r
118Specifies that source and/or destination ports should be chosen semi-randomly
119instead of sequentially within a range or in the order that the
120system assigns.
121.It Fl s Ar hostname/ip-address
122Specifies the IP of the interface which is used to send the packets.
123On some platforms, this can be used for UDP spoofing by using
124.Xr ifconfig 8
125to bring up a dummy interface with the desired source IP address.
126.It Fl t
127Causes
128.Nm nc
129to send RFC854 DON'T and WON'T responses to RFC854 DO
130and WILL requests. This makes it possible to use
131.Nm nc
132to script telnet sessions. The presence of this option can be
133enabled or disabled as a compile-time option.
134.It Fl u
135Use UDP instead of TCP.
136On most platforms,
137.Nm nc
138will behave as if a connection is established until it receives an
139ICMP packet indicating that there is no program listening to what it
140sends.
141.It Fl v
142Verbose. Cause
143.Nm nc
144to display connection information. Using
145.Fl v
146more than once will cause
147.Nm nc
148to become even more verbose.
149.It Fl w Ar timeout
150Specifies the number of seconds
151.Nm nc
152should wait before deciding that
153an attempt to establish a connection is hopeless.
154Also used to specify how long to wait for more network data after standard
155input closes.
156.It Fl z
157Specifies that
158.Nm nc
159should just scan for listening
160daemons, without sending any data to them. Diagnostic messages about refused
161connections will not be
162displayed unless
163.Fl v
164is specified twice.
165.Sh EXAMPLES
166.Bl -tag -width x
167.It Li "nc"
168Wait for the user to type what would normally be command-line
169arguments in at stdin.
170.It Li "nc example.host 42"
171Open a TCP connection to port 42 of example.host. If the connection
172fails, do not display any error messages, but simply exit.
173.It Li "nc -p 31337 example.host 42"
174Open a TCP connection to port 42 of example.host, and use port 31337
175as the source port.
176.It Li "nc -w 5 example.host 42"
177Open a TCP connection to port 42 of example.host, and time out after
178five seconds while attempting to connect.
179.It Li "nc -u example.host 53"
180Send any data from stdin
181to UDP port 53 of example.host, and display any data returned.
182.It Li "nc -s 10.1.2.3 example.host 42"
183Open a TCP connection to port 42 of example.host using 10.1.2.3 as the
184IP for the local end of the connection.
185.It Li "nc -v example.host 42"
186Open a TCP connection to port 42 of example.host, displaying some
187diagnostic messages on stderr.
188.It Li "nc -v -v example.host 42"
189Open a TCP connection to port 42 of example.host, displaying all
190diagnostic messages on stderr.
191.It Li "nc -v -z example.host 20-30"
192Attempt to open TCP connections to ports 20 through 30 of
193example.host, and report which ones
194.Nm nc
195was able to connect to.
196.It Li "nc -v -u -z -w 3 example.host 20-30"
197Send UDP packets to ports 20-30 of example.host, and report which ones
198did not respond with an ICMP packet after three seconds.
199.It Li "nc -l -p 3000"
200Listen on TCP port 3000, and once there is a connection, send stdin to
201the remote host, and send data from the remote host to stdout.
202.It Li "echo foobar | nc example.host 1000"
203Connect to port 1000 of example.host, send the string "foobar"
204followed by a newline, and move data from port 1000 of example.host to
205stdout until example.host closes the connection.
206.El
207.Sh SEE ALSO
208.Xr cat 1 ,
209.Xr telnet 1
210.Pp
211The
212.Nm netcat
213.Pa README .
214.Sh AUTHOR
215*Hobbit* [hobbit@avian.org]
diff --git a/src/usr.bin/nc/netcat.blurb b/src/usr.bin/nc/netcat.blurb
new file mode 100644
index 0000000000..2c540ad9dc
--- /dev/null
+++ b/src/usr.bin/nc/netcat.blurb
@@ -0,0 +1,61 @@
1Netcat 1.10 is an updated release of Netcat, a simple Unix utility which reads
2and writes data across network connections using TCP or UDP protocol. It is
3designed to be a reliable "back-end" tool that can be used directly or easily
4driven by other programs and scripts. At the same time it is a feature-rich
5network debugging and exploration tool, since it can create almost any kind of
6connection you would need and has several interesting built-in capabilities.
7
8Some of netcat's major features are:
9
10 Outbound or inbound connections, TCP or UDP, to or from any ports
11 Full DNS forward/reverse checking, with appropriate warnings
12 Ability to use any local source port
13 Ability to use any locally-configured network source address
14 Built-in port-scanning capabilities, with randomizer
15 Built-in loose source-routing capability
16 Can read command line arguments from standard input
17 Slow-send mode, one line every N seconds
18 Hex dump of transmitted and received data
19 Optional ability to let another program service established connections
20 Optional telnet-options responder
21
22A very short list of potential uses:
23
24 Script backends
25 Scanning ports and inventorying services, automated probes
26 Backup handlers
27 File transfers
28 Server testing, simulation, debugging, and hijacking
29 Firewall testing
30 Proxy gatewaying
31 Network performance testing
32 Address spoofing tests
33 Protecting X servers
34 1001 other uses you'll likely come up with
35
36Changes between the 1.00 release and this release:
37
38 Better portability -- updated generic.h and Makefile [thanx folks!]
39 Indication of local-end interface address on inbound connections
40 That's *Dave* Borman's telnet, not Paul Borman...
41 Better indication of DNS errors
42 Total byte counts printed if -v -v is used
43 A bunch of front-end driver companion programs and scripts
44 Better handling of stdin arguments-plus-data
45 Hex-dump feature
46 Telnet responder
47 Program exec works inbound or outbound now
48
49Netcat and the associated package is a product of Avian Research, and is freely
50available in full source form with no restrictions save an obligation to give
51credit where due. Get it via anonymous FTP at avian.org:/src/hacks/nc110.tgz
52which is a gzipped tar file and not to be confused with its version 1.00
53precursor, nc100.tgz. Other distribution formats can be accomodated upon
54request. Netcat is also mirrored at the following [faster] sites:
55
56 zippy.telcom.arizona.edu:/pub/mirrors/avian.org/hacks/nc110.tgz
57 ftp.sterling.com:/mirrors/avian.org/src/hacks/nc110.tgz
58 coast.cs.purdue.edu:/pub/tools/unix/netcat/nc110.tgz
59 ftp.rge.com:/pub/security/coast/mirrors/avian.org/netcat/nc110.tgz
60
61_H* 960320
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c
new file mode 100644
index 0000000000..bb0b30749d
--- /dev/null
+++ b/src/usr.bin/nc/netcat.c
@@ -0,0 +1,1670 @@
1/* Netcat 1.10 RELEASE 960320
2
3 A damn useful little "backend" utility begun 950915 or thereabouts,
4 as *Hobbit*'s first real stab at some sockets programming. Something that
5 should have and indeed may have existed ten years ago, but never became a
6 standard Unix utility. IMHO, "nc" could take its place right next to cat,
7 cp, rm, mv, dd, ls, and all those other cryptic and Unix-like things.
8
9 Read the README for the whole story, doc, applications, etc.
10
11 Layout:
12 conditional includes:
13 includes:
14 handy defines:
15 globals:
16 malloced globals:
17 cmd-flag globals:
18 support routines:
19 readwrite select loop:
20 main:
21
22 bluesky:
23 parse ranges of IP address as well as ports, perhaps
24 RAW mode!
25 backend progs to grab a pty and look like a real telnetd?!
26 backend progs to do various encryption modes??!?!
27*/
28
29#include "generic.h" /* same as with L5, skey, etc */
30
31/* conditional includes -- a very messy section which you may have to dink
32 for your own architecture [and please send diffs...]: */
33/* #undef _POSIX_SOURCE /* might need this for something? */
34#define HAVE_BIND /* ASSUMPTION -- seems to work everywhere! */
35#define HAVE_HELP /* undefine if you dont want the help text */
36/* #define ANAL /* if you want case-sensitive DNS matching */
37
38#ifdef HAVE_STDLIB_H
39#include <stdlib.h>
40#else
41#include <malloc.h>
42#endif
43#ifdef HAVE_SELECT_H /* random SV variants need this */
44#include <sys/select.h>
45#endif
46
47/* have to do this *before* including types.h. xxx: Linux still has it wrong */
48#ifdef FD_SETSIZE /* should be in types.h, butcha never know. */
49#undef FD_SETSIZE /* if we ever need more than 16 active */
50#endif /* fd's, something is horribly wrong! */
51#define FD_SETSIZE 16 /* <-- this'll give us a long anyways, wtf */
52#include <sys/types.h> /* *now* do it. Sigh, this is broken */
53
54#ifdef HAVE_RANDOM /* aficionados of ?rand48() should realize */
55#define SRAND srandom /* that this doesn't need *strong* random */
56#define RAND random /* numbers just to mix up port numbers!! */
57#else
58#define SRAND srand
59#define RAND rand
60#endif /* HAVE_RANDOM */
61
62/* includes: */
63#include <sys/time.h> /* timeval, time_t */
64#include <setjmp.h> /* jmp_buf et al */
65#include <sys/socket.h> /* basics, SO_ and AF_ defs, sockaddr, ... */
66#include <netinet/in.h> /* sockaddr_in, htons, in_addr */
67#include <netinet/in_systm.h> /* misc crud that netinet/ip.h references */
68#include <netinet/ip.h> /* IPOPT_LSRR, header stuff */
69#include <netdb.h> /* hostent, gethostby*, getservby* */
70#include <arpa/inet.h> /* inet_ntoa */
71#include <stdio.h>
72#include <string.h> /* strcpy, strchr, yadda yadda */
73#include <errno.h>
74#include <signal.h>
75#include <fcntl.h> /* O_WRONLY et al */
76
77/* handy stuff: */
78#define SA struct sockaddr /* socket overgeneralization braindeath */
79#define SAI struct sockaddr_in /* ... whoever came up with this model */
80#define IA struct in_addr /* ... should be taken out and shot, */
81 /* ... not that TLI is any better. sigh.. */
82#define SLEAZE_PORT 31337 /* for UDP-scan RTT trick, change if ya want */
83#define USHORT unsigned short /* use these for options an' stuff */
84#define BIGSIZ 8192 /* big buffers */
85
86#ifndef INADDR_NONE
87#define INADDR_NONE 0xffffffff
88#endif
89
90struct host_poop {
91 char name[MAXHOSTNAMELEN]; /* dns name */
92 char addrs[8][24]; /* ascii-format IP addresses */
93 struct in_addr iaddrs[8]; /* real addresses: in_addr.s_addr: ulong */
94};
95#define HINF struct host_poop
96
97struct port_poop {
98 char name [64]; /* name in /etc/services */
99 char anum [8]; /* ascii-format number */
100 USHORT num; /* real host-order number */
101};
102#define PINF struct port_poop
103
104/* globals: */
105jmp_buf jbuf; /* timer crud */
106int jval = 0; /* timer crud */
107int netfd = -1;
108int ofd = 0; /* hexdump output fd */
109static char unknown[] = "(UNKNOWN)";
110static char p_tcp[] = "tcp"; /* for getservby* */
111static char p_udp[] = "udp";
112#ifdef HAVE_BIND
113extern int h_errno;
114/* stolen almost wholesale from bsd herror.c */
115static char * h_errs[] = {
116 "Error 0", /* but we *don't* use this */
117 "Unknown host", /* 1 HOST_NOT_FOUND */
118 "Host name lookup failure", /* 2 TRY_AGAIN */
119 "Unknown server error", /* 3 NO_RECOVERY */
120 "No address associated with name", /* 4 NO_ADDRESS */
121};
122#else
123int h_errno; /* just so we *do* have it available */
124#endif /* HAVE_BIND */
125int gatesidx = 0; /* LSRR hop count */
126int gatesptr = 4; /* initial LSRR pointer, settable */
127USHORT Single = 1; /* zero if scanning */
128unsigned int insaved = 0; /* stdin-buffer size for multi-mode */
129unsigned int wrote_out = 0; /* total stdout bytes */
130unsigned int wrote_net = 0; /* total net bytes */
131static char wrote_txt[] = " sent %d, rcvd %d";
132static char hexnibs[20] = "0123456789abcdef ";
133
134/* will malloc up the following globals: */
135struct timeval * timer1 = NULL;
136struct timeval * timer2 = NULL;
137SAI * lclend = NULL; /* sockaddr_in structs */
138SAI * remend = NULL;
139HINF ** gates = NULL; /* LSRR hop hostpoop */
140char * optbuf = NULL; /* LSRR or sockopts */
141char * bigbuf_in; /* data buffers */
142char * bigbuf_net;
143fd_set * ding1; /* for select loop */
144fd_set * ding2;
145PINF * portpoop = NULL; /* for getportpoop / getservby* */
146unsigned char * stage = NULL; /* hexdump line buffer */
147
148/* global cmd flags: */
149USHORT o_alla = 0;
150unsigned int o_interval = 0;
151USHORT o_listen = 0;
152USHORT o_nflag = 0;
153USHORT o_wfile = 0;
154USHORT o_random = 0;
155USHORT o_udpmode = 0;
156USHORT o_verbose = 0;
157unsigned int o_wait = 0;
158USHORT o_zero = 0;
159/* o_tn in optional section */
160
161/* Debug macro: squirt whatever message and sleep a bit so we can see it go
162 by. need to call like Debug ((stuff)) [with no ; ] so macro args match!
163 Beware: writes to stdOUT... */
164#ifdef DEBUG
165#define Debug(x) printf x; printf ("\n"); fflush (stdout); sleep (1);
166#else
167#define Debug(x) /* nil... */
168#endif
169
170
171/* support routines -- the bulk of this thing. Placed in such an order that
172 we don't have to forward-declare anything: */
173
174/* holler :
175 fake varargs -- need to do this way because we wind up calling through
176 more levels of indirection than vanilla varargs can handle, and not all
177 machines have vfprintf/vsyslog/whatever! 6 params oughta be enough. */
178void holler (str, p1, p2, p3, p4, p5, p6)
179 char * str;
180 char * p1, * p2, * p3, * p4, * p5, * p6;
181{
182 if (o_verbose) {
183 fprintf (stderr, str, p1, p2, p3, p4, p5, p6);
184#ifdef HAVE_BIND
185 if (h_errno) { /* if host-lookup variety of error ... */
186 if (h_errno > 4) /* oh no you don't, either */
187 fprintf (stderr, "preposterous h_errno: %d", h_errno);
188 else
189 fprintf (stderr, h_errs[h_errno]); /* handle it here */
190 h_errno = 0; /* and reset for next call */
191 }
192#endif
193 if (errno) { /* this gives funny-looking messages, but */
194 perror (" "); /* it's more portable than sys_errlist[]... */
195 } else /* xxx: do something better? */
196 fprintf (stderr, "\n");
197 fflush (stderr);
198 }
199} /* holler */
200
201/* bail :
202 error-exit handler, callable from anywhere */
203void bail (str, p1, p2, p3, p4, p5, p6)
204 char * str;
205 char * p1, * p2, * p3, * p4, * p5, * p6;
206{
207 o_verbose = 1;
208 holler (str, p1, p2, p3, p4, p5, p6);
209 close (netfd);
210 sleep (1);
211 exit (1);
212} /* bail */
213
214/* catch :
215 no-brainer interrupt handler */
216void catch ()
217{
218 errno = 0;
219 if (o_verbose > 1) /* normally we don't care */
220 bail (wrote_txt, wrote_net, wrote_out);
221 bail (" punt!");
222}
223
224/* timeout and other signal handling cruft */
225void tmtravel ()
226{
227 signal (SIGALRM, SIG_IGN);
228 alarm (0);
229 if (jval == 0)
230 bail ("spurious timer interrupt!");
231 longjmp (jbuf, jval);
232}
233
234/* arm :
235 set the timer. Zero secs arg means unarm */
236void arm (num, secs)
237 unsigned int num;
238 unsigned int secs;
239{
240 if (secs == 0) { /* reset */
241 signal (SIGALRM, SIG_IGN);
242 alarm (0);
243 jval = 0;
244 } else { /* set */
245 signal (SIGALRM, tmtravel);
246 alarm (secs);
247 jval = num;
248 } /* if secs */
249} /* arm */
250
251/* Hmalloc :
252 malloc up what I want, rounded up to *4, and pre-zeroed. Either succeeds
253 or bails out on its own, so that callers don't have to worry about it. */
254char * Hmalloc (size)
255 unsigned int size;
256{
257 unsigned int s = (size + 4) & 0xfffffffc; /* 4GB?! */
258 char * p = malloc (s);
259 if (p != NULL)
260 memset (p, 0, s);
261 else
262 bail ("Hmalloc %d failed", s);
263 return (p);
264} /* Hmalloc */
265
266/* findline :
267 find the next newline in a buffer; return inclusive size of that "line",
268 or the entire buffer size, so the caller knows how much to then write().
269 Not distinguishing \n vs \r\n for the nonce; it just works as is... */
270unsigned int findline (buf, siz)
271 char * buf;
272 unsigned int siz;
273{
274 register char * p;
275 register int x;
276 if (! buf) /* various sanity checks... */
277 return (0);
278 if (siz > BIGSIZ)
279 return (0);
280 x = siz;
281 for (p = buf; x > 0; x--) {
282 if (*p == '\n') {
283 x = (int) (p - buf);
284 x++; /* 'sokay if it points just past the end! */
285Debug (("findline returning %d", x))
286 return (x);
287 }
288 p++;
289 } /* for */
290Debug (("findline returning whole thing: %d", siz))
291 return (siz);
292} /* findline */
293
294/* comparehosts :
295 cross-check the host_poop we have so far against new gethostby*() info,
296 and holler about mismatches. Perhaps gratuitous, but it can't hurt to
297 point out when someone's DNS is fukt. Returns 1 if mismatch, in case
298 someone else wants to do something about it. */
299int comparehosts (poop, hp)
300 HINF * poop;
301 struct hostent * hp;
302{
303 errno = 0;
304 h_errno = 0;
305/* The DNS spec is officially case-insensitive, but for those times when you
306 *really* wanna see any and all discrepancies, by all means define this. */
307#ifdef ANAL
308 if (strcmp (poop->name, hp->h_name) != 0) { /* case-sensitive */
309#else
310 if (strcasecmp (poop->name, hp->h_name) != 0) { /* normal */
311#endif
312 holler ("DNS fwd/rev mismatch: %s != %s", poop->name, hp->h_name);
313 return (1);
314 }
315 return (0);
316/* ... do we need to do anything over and above that?? */
317} /* comparehosts */
318
319/* gethostpoop :
320 resolve a host 8 ways from sunday; return a new host_poop struct with its
321 info. The argument can be a name or [ascii] IP address; it will try its
322 damndest to deal with it. "numeric" governs whether we do any DNS at all,
323 and we also check o_verbose for what's appropriate work to do. */
324HINF * gethostpoop (name, numeric)
325 char * name;
326 USHORT numeric;
327{
328 struct hostent * hostent;
329 struct in_addr iaddr;
330 register HINF * poop = NULL;
331 register int x;
332
333/* I really want to strangle the twit who dreamed up all these sockaddr and
334 hostent abstractions, and then forced them all to be incompatible with
335 each other so you *HAVE* to do all this ridiculous casting back and forth.
336 If that wasn't bad enough, all the doc insists on referring to local ports
337 and addresses as "names", which makes NO sense down at the bare metal.
338
339 What an absolutely horrid paradigm, and to think of all the people who
340 have been wasting significant amounts of time fighting with this stupid
341 deliberate obfuscation over the last 10 years... then again, I like
342 languages wherein a pointer is a pointer, what you put there is your own
343 business, the compiler stays out of your face, and sheep are nervous.
344 Maybe that's why my C code reads like assembler half the time... */
345
346/* If we want to see all the DNS stuff, do the following hair --
347 if inet_addr, do reverse and forward with any warnings; otherwise try
348 to do forward and reverse with any warnings. In other words, as long
349 as we're here, do a complete DNS check on these clowns. Yes, it slows
350 things down a bit for a first run, but once it's cached, who cares? */
351
352 errno = 0;
353 h_errno = 0;
354 if (name)
355 poop = (HINF *) Hmalloc (sizeof (HINF));
356 if (! poop)
357 bail ("gethostpoop fuxored");
358 strcpy (poop->name, unknown); /* preload it */
359/* see wzv:workarounds.c for dg/ux return-a-struct inet_addr lossage */
360 iaddr.s_addr = inet_addr (name);
361
362 if (iaddr.s_addr == INADDR_NONE) { /* here's the great split: names... */
363 if (numeric)
364 bail ("Can't parse %s as an IP address", name);
365 hostent = gethostbyname (name);
366 if (! hostent)
367/* failure to look up a name is fatal, since we can't do anything with it */
368 bail ("%s: forward host lookup failed: ", name);
369 strncpy (poop->name, hostent->h_name, MAXHOSTNAMELEN - 1);
370 poop->name[MAXHOSTNAMELEN - 1] = '\0';
371 for (x = 0; hostent->h_addr_list[x] && (x < 8); x++) {
372 memcpy (&poop->iaddrs[x], hostent->h_addr_list[x], sizeof (IA));
373 strncpy (poop->addrs[x], inet_ntoa (poop->iaddrs[x]),
374 sizeof (poop->addrs[0])-1);
375 poop->addrs[x][sizeof (poop->addrs[0]) - 1] = '\0';
376 } /* for x -> addrs, part A */
377 if (! o_verbose) /* if we didn't want to see the */
378 return (poop); /* inverse stuff, we're done. */
379/* do inverse lookups in separate loop based on our collected forward addrs,
380 since gethostby* tends to crap into the same buffer over and over */
381 for (x = 0; poop->iaddrs[x].s_addr && (x < 8); x++) {
382 hostent = gethostbyaddr ((char *)&poop->iaddrs[x],
383 sizeof (IA), AF_INET);
384 if ((! hostent) || (! hostent-> h_name))
385 holler ("Warning: inverse host lookup failed for %s: ",
386 poop->addrs[x]);
387 else
388 (void) comparehosts (poop, hostent);
389 } /* for x -> addrs, part B */
390
391 } else { /* not INADDR_NONE: numeric addresses... */
392 memcpy (poop->iaddrs, &iaddr, sizeof (IA));
393 strncpy (poop->addrs[0], inet_ntoa (iaddr), sizeof (poop->addrs)-1);
394 poop->addrs[0][sizeof (poop->addrs)-1] = '\0';
395 if (numeric) /* if numeric-only, we're done */
396 return (poop);
397 if (! o_verbose) /* likewise if we don't want */
398 return (poop); /* the full DNS hair */
399 hostent = gethostbyaddr ((char *) &iaddr, sizeof (IA), AF_INET);
400/* numeric or not, failure to look up a PTR is *not* considered fatal */
401 if (! hostent)
402 holler ("%s: inverse host lookup failed: ", name);
403 else {
404 strncpy (poop->name, hostent->h_name, MAXHOSTNAMELEN - 1);
405 poop->name[MAXHOSTNAMELEN-1] = '\0';
406 hostent = gethostbyname (poop->name);
407 if ((! hostent) || (! hostent->h_addr_list[0]))
408 holler ("Warning: forward host lookup failed for %s: ",
409 poop->name);
410 else
411 (void) comparehosts (poop, hostent);
412 } /* if hostent */
413 } /* INADDR_NONE Great Split */
414
415/* whatever-all went down previously, we should now have a host_poop struct
416 with at least one IP address in it. */
417 h_errno = 0;
418 return (poop);
419} /* gethostpoop */
420
421/* getportpoop :
422 Same general idea as gethostpoop -- look up a port in /etc/services, fill
423 in global port_poop, but return the actual port *number*. Pass ONE of:
424 pstring to resolve stuff like "23" or "exec";
425 pnum to reverse-resolve something that's already a number.
426 If o_nflag is on, fill in what we can but skip the getservby??? stuff.
427 Might as well have consistent behavior here, and it *is* faster. */
428USHORT getportpoop (pstring, pnum)
429 char * pstring;
430 unsigned int pnum;
431{
432 struct servent * servent;
433 register int x;
434 register int y;
435 char * whichp = p_tcp;
436 if (o_udpmode)
437 whichp = p_udp;
438 portpoop->name[0] = '?'; /* fast preload */
439 portpoop->name[1] = '\0';
440
441/* case 1: reverse-lookup of a number; placed first since this case is much
442 more frequent if we're scanning */
443 if (pnum) {
444 if (pstring) /* one or the other, pleeze */
445 return (0);
446 x = pnum;
447 if (o_nflag) /* go faster, skip getservbyblah */
448 goto gp_finish;
449 y = htons (x); /* gotta do this -- see Fig.1 below */
450 servent = getservbyport (y, whichp);
451 if (servent) {
452 y = ntohs (servent->s_port);
453 if (x != y) /* "never happen" */
454 holler ("Warning: port-bynum mismatch, %d != %d", x, y);
455 strncpy (portpoop->name, servent->s_name, sizeof (portpoop->name)-1);
456 portpoop->name[sizeof (portpoop->name)-1] = '\0';
457 } /* if servent */
458 goto gp_finish;
459 } /* if pnum */
460
461/* case 2: resolve a string, but we still give preference to numbers instead
462 of trying to resolve conflicts. None of the entries in *my* extensive
463 /etc/services begins with a digit, so this should "always work" unless
464 you're at 3com and have some company-internal services defined... */
465 if (pstring) {
466 if (pnum) /* one or the other, pleeze */
467 return (0);
468 x = atoi (pstring);
469 if (x)
470 return (getportpoop (NULL, x)); /* recurse for numeric-string-arg */
471 if (o_nflag) /* can't use names! */
472 return (0);
473 servent = getservbyname (pstring, whichp);
474 if (servent) {
475 strncpy (portpoop->name, servent->s_name, sizeof (portpoop->name)-1);
476 portpoop->name[sizeof (portpoop->name)-1] = '\0';
477 x = ntohs (servent->s_port);
478 goto gp_finish;
479 } /* if servent */
480 } /* if pstring */
481
482 return (0); /* catches any problems so far */
483
484/* Obligatory netdb.h-inspired rant: servent.s_port is supposed to be an int.
485 Despite this, we still have to treat it as a short when copying it around.
486 Not only that, but we have to convert it *back* into net order for
487 getservbyport to work. Manpages generally aren't clear on all this, but
488 there are plenty of examples in which it is just quietly done. More BSD
489 lossage... since everything getserv* ever deals with is local to our own
490 host, why bother with all this network-order/host-order crap at all?!
491 That should be saved for when we want to actually plug the port[s] into
492 some real network calls -- and guess what, we have to *re*-convert at that
493 point as well. Fuckheads. */
494
495gp_finish:
496/* Fall here whether or not we have a valid servent at this point, with
497 x containing our [host-order and therefore useful, dammit] port number */
498 sprintf (portpoop->anum, "%d", x); /* always load any numeric specs! */
499 portpoop->num = (x & 0xffff); /* ushort, remember... */
500 return (portpoop->num);
501} /* getportpoop */
502
503/* nextport :
504 Come up with the next port to try, be it random or whatever. "block" is
505 a ptr to randports array, whose bytes [so far] carry these meanings:
506 0 ignore
507 1 to be tested
508 2 tested [which is set as we find them here]
509 returns a USHORT random port, or 0 if all the t-b-t ones are used up. */
510USHORT nextport (block)
511 char * block;
512{
513 register unsigned int x;
514 register unsigned int y;
515
516 y = 70000; /* high safety count for rnd-tries */
517 while (y > 0) {
518 x = (RAND() & 0xffff);
519 if (block[x] == 1) { /* try to find a not-done one... */
520 block[x] = 2;
521 break;
522 }
523 x = 0; /* bummer. */
524 y--;
525 } /* while y */
526 if (x)
527 return (x);
528
529 y = 65535; /* no random one, try linear downsearch */
530 while (y > 0) { /* if they're all used, we *must* be sure! */
531 if (block[y] == 1) {
532 block[y] = 2;
533 break;
534 }
535 y--;
536 } /* while y */
537 if (y)
538 return (y); /* at least one left */
539
540 return (0); /* no more left! */
541} /* nextport */
542
543/* loadports :
544 set "to be tested" indications in BLOCK, from LO to HI. Almost too small
545 to be a separate routine, but makes main() a little cleaner... */
546void loadports (block, lo, hi)
547 char * block;
548 USHORT lo;
549 USHORT hi;
550{
551 USHORT x;
552
553 if (! block)
554 bail ("loadports: no block?!");
555 if ((! lo) || (! hi))
556 bail ("loadports: bogus values %d, %d", lo, hi);
557 x = hi;
558 while (lo <= x) {
559 block[x] = 1;
560 x--;
561 }
562} /* loadports */
563
564#ifdef GAPING_SECURITY_HOLE
565char * pr00gie = NULL; /* global ptr to -e arg */
566
567/* doexec :
568 fiddle all the file descriptors around, and hand off to another prog. Sort
569 of like a one-off "poor man's inetd". This is the only section of code
570 that would be security-critical, which is why it's ifdefed out by default.
571 Use at your own hairy risk; if you leave shells lying around behind open
572 listening ports you deserve to lose!! */
573doexec (fd)
574 int fd;
575{
576 register char * p;
577
578 dup2 (fd, 0); /* the precise order of fiddlage */
579 close (fd); /* is apparently crucial; this is */
580 dup2 (0, 1); /* swiped directly out of "inetd". */
581 dup2 (0, 2);
582 p = strrchr (pr00gie, '/'); /* shorter argv[0] */
583 if (p)
584 p++;
585 else
586 p = pr00gie;
587Debug (("gonna exec %s as %s...", pr00gie, p))
588 execl (pr00gie, p, NULL);
589 bail ("exec %s failed", pr00gie); /* this gets sent out. Hmm... */
590} /* doexec */
591#endif /* GAPING_SECURITY_HOLE */
592
593/* doconnect :
594 do all the socket stuff, and return an fd for one of
595 an open outbound TCP connection
596 a UDP stub-socket thingie
597 with appropriate socket options set up if we wanted source-routing, or
598 an unconnected TCP or UDP socket to listen on.
599 Examines various global o_blah flags to figure out what-all to do. */
600int doconnect (rad, rp, lad, lp)
601 IA * rad;
602 USHORT rp;
603 IA * lad;
604 USHORT lp;
605{
606 register int nnetfd;
607 register int rr;
608 int x, y;
609 errno = 0;
610
611/* grab a socket; set opts */
612newskt:
613 if (o_udpmode)
614 nnetfd = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
615 else
616 nnetfd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
617 if (nnetfd < 0)
618 bail ("Can't get socket");
619 if (nnetfd == 0) /* if stdin was closed this might *be* 0, */
620 goto newskt; /* so grab another. See text for why... */
621 x = 1;
622 rr = setsockopt (nnetfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x));
623 if (rr == -1)
624 holler ("nnetfd reuseaddr failed"); /* ??? */
625#ifdef SO_REUSEPORT /* doesnt exist everywhere... */
626 rr = setsockopt (nnetfd, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
627 if (rr == -1)
628 holler ("nnetfd reuseport failed"); /* ??? */
629#endif
630#if 0
631/* If you want to screw with RCVBUF/SNDBUF, do it here. Liudvikas Bukys at
632 Rochester sent this example, which would involve YET MORE options and is
633 just archived here in case you want to mess with it. o_xxxbuf are global
634 integers set in main() getopt loop, and check for rr == 0 afterward. */
635 rr = setsockopt(nnetfd, SOL_SOCKET, SO_RCVBUF, &o_rcvbuf, sizeof o_rcvbuf);
636 rr = setsockopt(nnetfd, SOL_SOCKET, SO_SNDBUF, &o_sndbuf, sizeof o_sndbuf);
637#endif
638
639 /* fill in all the right sockaddr crud */
640 lclend->sin_family = AF_INET;
641
642/* fill in all the right sockaddr crud */
643 lclend->sin_family = AF_INET;
644 remend->sin_family = AF_INET;
645
646/* if lad/lp, do appropriate binding */
647 if (lad)
648 memcpy (&lclend->sin_addr.s_addr, lad, sizeof (IA));
649 if (lp)
650 lclend->sin_port = htons (lp);
651 rr = 0;
652 if (lad || lp) {
653 x = (int) lp;
654/* try a few times for the local bind, a la ftp-data-port... */
655 for (y = 4; y > 0; y--) {
656 rr = bind (nnetfd, (SA *)lclend, sizeof (SA));
657 if (rr == 0)
658 break;
659 if (errno != EADDRINUSE)
660 break;
661 else {
662 holler ("retrying local %s:%d", inet_ntoa (lclend->sin_addr), lp);
663 sleep (2);
664 errno = 0; /* clear from sleep */
665 } /* if EADDRINUSE */
666 } /* for y counter */
667 } /* if lad or lp */
668 if (rr)
669 bail ("Can't grab %s:%d with bind",
670 inet_ntoa(lclend->sin_addr), lp);
671
672 if (o_listen)
673 return (nnetfd); /* thanks, that's all for today */
674
675 memcpy (&remend->sin_addr.s_addr, rad, sizeof (IA));
676 remend->sin_port = htons (rp);
677
678/* rough format of LSRR option and explanation of weirdness.
679Option comes after IP-hdr dest addr in packet, padded to *4, and ihl > 5.
680IHL is multiples of 4, i.e. real len = ip_hl << 2.
681 type 131 1 ; 0x83: copied, option class 0, number 3
682 len 1 ; of *whole* option!
683 pointer 1 ; nxt-hop-addr; 1-relative, not 0-relative
684 addrlist... var ; 4 bytes per hop-addr
685 pad-to-32 var ; ones, i.e. "NOP"
686
687If we want to route A -> B via hops C and D, we must add C, D, *and* B to the
688options list. Why? Because when we hand the kernel A -> B with list C, D, B
689the "send shuffle" inside the kernel changes it into A -> C with list D, B and
690the outbound packet gets sent to C. If B wasn't also in the hops list, the
691final destination would have been lost at this point.
692
693When C gets the packet, it changes it to A -> D with list C', B where C' is
694the interface address that C used to forward the packet. This "records" the
695route hop from B's point of view, i.e. which address points "toward" B. This
696is to make B better able to return the packets. The pointer gets bumped by 4,
697so that D does the right thing instead of trying to forward back to C.
698
699When B finally gets the packet, it sees that the pointer is at the end of the
700LSRR list and is thus "completed". B will then try to use the packet instead
701of forwarding it, i.e. deliver it up to some application.
702
703Note that by moving the pointer yourself, you could send the traffic directly
704to B but have it return via your preconstructed source-route. Playing with
705this and watching "tcpdump -v" is the best way to understand what's going on.
706
707Only works for TCP in BSD-flavor kernels. UDP is a loss; udp_input calls
708stripoptions() early on, and the code to save the srcrt is notdef'ed.
709Linux is also still a loss at 1.3.x it looks like; the lsrr code is { }...
710*/
711
712/* if any -g arguments were given, set up source-routing. We hit this after
713 the gates are all looked up and ready to rock, any -G pointer is set,
714 and gatesidx is now the *number* of hops */
715 if (gatesidx) { /* if we wanted any srcrt hops ... */
716/* don't even bother compiling if we can't do IP options here! */
717#ifdef IP_OPTIONS
718 if (! optbuf) { /* and don't already *have* a srcrt set */
719 char * opp; /* then do all this setup hair */
720 optbuf = Hmalloc (48);
721 opp = optbuf;
722 *opp++ = IPOPT_LSRR; /* option */
723 *opp++ = (char)
724 (((gatesidx + 1) * sizeof (IA)) + 3) & 0xff; /* length */
725 *opp++ = gatesptr; /* pointer */
726/* opp now points at first hop addr -- insert the intermediate gateways */
727 for ( x = 0; x < gatesidx; x++) {
728 memcpy (opp, gates[x]->iaddrs, sizeof (IA));
729 opp += sizeof (IA);
730 }
731/* and tack the final destination on the end [needed!] */
732 memcpy (opp, rad, sizeof (IA));
733 opp += sizeof (IA);
734 *opp = IPOPT_NOP; /* alignment filler */
735 } /* if empty optbuf */
736/* calculate length of whole option mess, which is (3 + [hops] + [final] + 1),
737 and apply it [have to do this every time through, of course] */
738 x = ((gatesidx + 1) * sizeof (IA)) + 4;
739 rr = setsockopt (nnetfd, IPPROTO_IP, IP_OPTIONS, optbuf, x);
740 if (rr == -1)
741 bail ("srcrt setsockopt fuxored");
742#else /* IP_OPTIONS */
743 holler ("Warning: source routing unavailable on this machine, ignoring");
744#endif /* IP_OPTIONS*/
745 } /* if gatesidx */
746
747/* wrap connect inside a timer, and hit it */
748 arm (1, o_wait);
749 if (setjmp (jbuf) == 0) {
750 rr = connect (nnetfd, (SA *)remend, sizeof (SA));
751 } else { /* setjmp: connect failed... */
752 rr = -1;
753 errno = ETIMEDOUT; /* fake it */
754 }
755 arm (0, 0);
756 if (rr == 0)
757 return (nnetfd);
758 close (nnetfd); /* clean up junked socket FD!! */
759 return (-1);
760} /* doconnect */
761
762/* dolisten :
763 just like doconnect, and in fact calls a hunk of doconnect, but listens for
764 incoming and returns an open connection *from* someplace. If we were
765 given host/port args, any connections from elsewhere are rejected. This
766 in conjunction with local-address binding should limit things nicely... */
767int dolisten (rad, rp, lad, lp)
768 IA * rad;
769 USHORT rp;
770 IA * lad;
771 USHORT lp;
772{
773 register int nnetfd;
774 register int rr;
775 HINF * whozis = NULL;
776 int x;
777 char * cp;
778 USHORT z;
779 errno = 0;
780
781/* Pass everything off to doconnect, who in o_listen mode just gets a socket */
782 nnetfd = doconnect (rad, rp, lad, lp);
783 if (nnetfd <= 0)
784 return (-1);
785 if (o_udpmode) { /* apparently UDP can listen ON */
786 if (! lp) /* "port 0", but that's not useful */
787 bail ("UDP listen needs -p arg");
788 } else {
789 rr = listen (nnetfd, 1); /* gotta listen() before we can get */
790 if (rr < 0) /* our local random port. sheesh. */
791 bail ("local listen fuxored");
792 }
793
794/* Various things that follow temporarily trash bigbuf_net, which might contain
795 a copy of any recvfrom()ed packet, but we'll read() another copy later. */
796
797/* I can't believe I have to do all this to get my own goddamn bound address
798 and port number. It should just get filled in during bind() or something.
799 All this is only useful if we didn't say -p for listening, since if we
800 said -p we *know* what port we're listening on. At any rate we won't bother
801 with it all unless we wanted to see it, although listening quietly on a
802 random unknown port is probably not very useful without "netstat". */
803 if (o_verbose) {
804 x = sizeof (SA); /* how 'bout getsockNUM instead, pinheads?! */
805 rr = getsockname (nnetfd, (SA *) lclend, &x);
806 if (rr < 0)
807 holler ("local getsockname failed");
808 strcpy (bigbuf_net, "listening on ["); /* buffer reuse... */
809 if (lclend->sin_addr.s_addr)
810 strcat (bigbuf_net, inet_ntoa (lclend->sin_addr));
811 else
812 strcat (bigbuf_net, "any");
813 strcat (bigbuf_net, "] %d ...");
814 z = ntohs (lclend->sin_port);
815 holler (bigbuf_net, z);
816 } /* verbose -- whew!! */
817
818/* UDP is a speeeeecial case -- we have to do I/O *and* get the calling
819 party's particulars all at once, listen() and accept() don't apply.
820 At least in the BSD universe, however, recvfrom/PEEK is enough to tell
821 us something came in, and we can set things up so straight read/write
822 actually does work after all. Yow. YMMV on strange platforms! */
823 if (o_udpmode) {
824 x = sizeof (SA); /* retval for recvfrom */
825 arm (2, o_wait); /* might as well timeout this, too */
826 if (setjmp (jbuf) == 0) { /* do timeout for initial connect */
827 rr = recvfrom /* and here we block... */
828 (nnetfd, bigbuf_net, BIGSIZ, MSG_PEEK, (SA *) remend, &x);
829Debug (("dolisten/recvfrom ding, rr = %d, netbuf %s ", rr, bigbuf_net))
830 } else
831 goto dol_tmo; /* timeout */
832 arm (0, 0);
833/* I'm not completely clear on how this works -- BSD seems to make UDP
834 just magically work in a connect()ed context, but we'll undoubtedly run
835 into systems this deal doesn't work on. For now, we apparently have to
836 issue a connect() on our just-tickled socket so we can write() back.
837 Again, why the fuck doesn't it just get filled in and taken care of?!
838 This hack is anything but optimal. Basically, if you want your listener
839 to also be able to send data back, you need this connect() line, which
840 also has the side effect that now anything from a different source or even a
841 different port on the other end won't show up and will cause ICMP errors.
842 I guess that's what they meant by "connect".
843 Let's try to remember what the "U" is *really* for, eh? */
844 rr = connect (nnetfd, (SA *)remend, sizeof (SA));
845 goto whoisit;
846 } /* o_udpmode */
847
848/* fall here for TCP */
849 x = sizeof (SA); /* retval for accept */
850 arm (2, o_wait); /* wrap this in a timer, too; 0 = forever */
851 if (setjmp (jbuf) == 0) {
852 rr = accept (nnetfd, (SA *)remend, &x);
853 } else
854 goto dol_tmo; /* timeout */
855 arm (0, 0);
856 close (nnetfd); /* dump the old socket */
857 nnetfd = rr; /* here's our new one */
858
859whoisit:
860 if (rr < 0)
861 goto dol_err; /* bail out if any errors so far */
862
863/* If we can, look for any IP options. Useful for testing the receiving end of
864 such things, and is a good exercise in dealing with it. We do this before
865 the connect message, to ensure that the connect msg is uniformly the LAST
866 thing to emerge after all the intervening crud. Doesn't work for UDP on
867 any machines I've tested, but feel free to surprise me. */
868#ifdef IP_OPTIONS
869 if (! o_verbose) /* if we wont see it, we dont care */
870 goto dol_noop;
871 optbuf = Hmalloc (40);
872 x = 40;
873 rr = getsockopt (nnetfd, IPPROTO_IP, IP_OPTIONS, optbuf, &x);
874 if (rr < 0)
875 holler ("getsockopt failed");
876Debug (("ipoptions ret len %d", x))
877 if (x) { /* we've got options, lessee em... */
878 unsigned char * q = (unsigned char *) optbuf;
879 char * p = bigbuf_net; /* local variables, yuk! */
880 char * pp = &bigbuf_net[128]; /* get random space farther out... */
881 memset (bigbuf_net, 0, 256); /* clear it all first */
882 while (x > 0) {
883 sprintf (pp, "%2.2x ", *q); /* clumsy, but works: turn into hex */
884 strcat (p, pp); /* and build the final string */
885 q++; p++;
886 x--;
887 }
888 holler ("IP options: %s", bigbuf_net);
889 } /* if x, i.e. any options */
890dol_noop:
891#endif /* IP_OPTIONS */
892
893/* find out what address the connection was *to* on our end, in case we're
894 doing a listen-on-any on a multihomed machine. This allows one to
895 offer different services via different alias addresses, such as the
896 "virtual web site" hack. */
897 memset (bigbuf_net, 0, 64);
898 cp = &bigbuf_net[32];
899 x = sizeof (SA);
900 rr = getsockname (nnetfd, (SA *) lclend, &x);
901 if (rr < 0)
902 holler ("post-rcv getsockname failed");
903 strcpy (cp, inet_ntoa (lclend->sin_addr));
904
905/* now check out who it is. We don't care about mismatched DNS names here,
906 but any ADDR and PORT we specified had better fucking well match the caller.
907 Converting from addr to inet_ntoa and back again is a bit of a kludge, but
908 gethostpoop wants a string and there's much gnarlier code out there already,
909 so I don't feel bad.
910 The *real* question is why BFD sockets wasn't designed to allow listens for
911 connections *from* specific hosts/ports, instead of requiring the caller to
912 accept the connection and then reject undesireable ones by closing. In
913 other words, we need a TCP MSG_PEEK. */
914 z = ntohs (remend->sin_port);
915 strcpy (bigbuf_net, inet_ntoa (remend->sin_addr));
916 whozis = gethostpoop (bigbuf_net, o_nflag);
917 errno = 0;
918 x = 0; /* use as a flag... */
919 if (rad) /* xxx: fix to go down the *list* if we have one? */
920 if (memcmp (rad, whozis->iaddrs, sizeof (SA)))
921 x = 1;
922 if (rp)
923 if (z != rp)
924 x = 1;
925 if (x) /* guilty! */
926 bail ("invalid connection to [%s] from %s [%s] %d",
927 cp, whozis->name, whozis->addrs[0], z);
928 holler ("connect to [%s] from %s [%s] %d", /* oh, you're okay.. */
929 cp, whozis->name, whozis->addrs[0], z);
930 return (nnetfd); /* open! */
931
932dol_tmo:
933 errno = ETIMEDOUT; /* fake it */
934dol_err:
935 close (nnetfd);
936 return (-1);
937} /* dolisten */
938
939/* udptest :
940 fire a couple of packets at a UDP target port, just to see if it's really
941 there. On BSD kernels, ICMP host/port-unreachable errors get delivered to
942 our socket as ECONNREFUSED write errors. On SV kernels, we lose; we'll have
943 to collect and analyze raw ICMP ourselves a la satan's probe_udp_ports
944 backend. Guess where one could swipe the appropriate code from...
945
946 Use the time delay between writes if given, otherwise use the "tcp ping"
947 trick for getting the RTT. [I got that idea from pluvius, and warped it.]
948 Return either the original fd, or clean up and return -1. */
949udptest (fd, where)
950 int fd;
951 IA * where;
952{
953 register int rr;
954
955 rr = write (fd, bigbuf_in, 1);
956 if (rr != 1)
957 holler ("udptest first write failed?! errno %d", errno);
958 if (o_wait)
959 sleep (o_wait);
960 else {
961/* use the tcp-ping trick: try connecting to a normally refused port, which
962 causes us to block for the time that SYN gets there and RST gets back.
963 Not completely reliable, but it *does* mostly work. */
964 o_udpmode = 0; /* so doconnect does TCP this time */
965/* Set a temporary connect timeout, so packet filtration doesnt cause
966 us to hang forever, and hit it */
967 o_wait = 5; /* enough that we'll notice?? */
968 rr = doconnect (where, SLEAZE_PORT, 0, 0);
969 if (rr > 0)
970 close (rr); /* in case it *did* open */
971 o_wait = 0; /* reset it */
972 o_udpmode++; /* we *are* still doing UDP, right? */
973 } /* if o_wait */
974 errno = 0; /* clear from sleep */
975 rr = write (fd, bigbuf_in, 1);
976 if (rr == 1) /* if write error, no UDP listener */
977 return (fd);
978 close (fd); /* use it or lose it! */
979 return (-1);
980} /* udptest */
981
982/* oprint :
983 Hexdump bytes shoveled either way to a running logfile, in the format:
984D offset - - - - --- 16 bytes --- - - - - # .... ascii .....
985 where "which" sets the direction indicator, D:
986 0 -- sent to network, or ">"
987 1 -- rcvd and printed to stdout, or "<"
988 and "buf" and "n" are data-block and length. If the current block generates
989 a partial line, so be it; we *want* that lockstep indication of who sent
990 what when. Adapted from dgaudet's original example -- but must be ripping
991 *fast*, since we don't want to be too disk-bound... */
992void oprint (which, buf, n)
993 int which;
994 char * buf;
995 int n;
996{
997 int bc; /* in buffer count */
998 int obc; /* current "global" offset */
999 int soc; /* stage write count */
1000 register unsigned char * p; /* main buf ptr; m.b. unsigned here */
1001 register unsigned char * op; /* out hexdump ptr */
1002 register unsigned char * a; /* out asc-dump ptr */
1003 register int x;
1004 register unsigned int y;
1005
1006 if (! ofd)
1007 bail ("oprint called with no open fd?!");
1008 if (n == 0)
1009 return;
1010
1011 op = stage;
1012 if (which) {
1013 *op = '<';
1014 obc = wrote_out; /* use the globals! */
1015 } else {
1016 *op = '>';
1017 obc = wrote_net;
1018 }
1019 op++; /* preload "direction" */
1020 *op = ' ';
1021 p = (unsigned char *) buf;
1022 bc = n;
1023 stage[59] = '#'; /* preload separator */
1024 stage[60] = ' ';
1025
1026 while (bc) { /* for chunk-o-data ... */
1027 x = 16;
1028 soc = 78; /* len of whole formatted line */
1029 if (bc < x) {
1030 soc = soc - 16 + bc; /* fiddle for however much is left */
1031 x = (bc * 3) + 11; /* 2 digits + space per, after D & offset */
1032 op = &stage[x];
1033 x = 16 - bc;
1034 while (x) {
1035 *op++ = ' '; /* preload filler spaces */
1036 *op++ = ' ';
1037 *op++ = ' ';
1038 x--;
1039 }
1040 x = bc; /* re-fix current linecount */
1041 } /* if bc < x */
1042
1043 bc -= x; /* fix wrt current line size */
1044 sprintf (&stage[2], "%8.8x ", obc); /* xxx: still slow? */
1045 obc += x; /* fix current offset */
1046 op = &stage[11]; /* where hex starts */
1047 a = &stage[61]; /* where ascii starts */
1048
1049 while (x) { /* for line of dump, however long ... */
1050 y = (int)(*p >> 4); /* hi half */
1051 *op = hexnibs[y];
1052 op++;
1053 y = (int)(*p & 0x0f); /* lo half */
1054 *op = hexnibs[y];
1055 op++;
1056 *op = ' ';
1057 op++;
1058 if ((*p > 31) && (*p < 127))
1059 *a = *p; /* printing */
1060 else
1061 *a = '.'; /* nonprinting, loose def */
1062 a++;
1063 p++;
1064 x--;
1065 } /* while x */
1066 *a = '\n'; /* finish the line */
1067 x = write (ofd, stage, soc);
1068 if (x < 0)
1069 bail ("ofd write err");
1070 } /* while bc */
1071} /* oprint */
1072
1073#ifdef TELNET
1074USHORT o_tn = 0; /* global -t option */
1075
1076/* atelnet :
1077 Answer anything that looks like telnet negotiation with don't/won't.
1078 This doesn't modify any data buffers, update the global output count,
1079 or show up in a hexdump -- it just shits into the outgoing stream.
1080 Idea and codebase from Mudge@l0pht.com. */
1081void atelnet (buf, size)
1082 unsigned char * buf; /* has to be unsigned here! */
1083 unsigned int size;
1084{
1085 static unsigned char obuf [4]; /* tiny thing to build responses into */
1086 register int x;
1087 register unsigned char y;
1088 register unsigned char * p;
1089
1090 y = 0;
1091 p = buf;
1092 x = size;
1093 while (x > 0) {
1094 if (*p != 255) /* IAC? */
1095 goto notiac;
1096 obuf[0] = 255;
1097 p++; x--;
1098 if ((*p == 251) || (*p == 252)) /* WILL or WONT */
1099 y = 254; /* -> DONT */
1100 if ((*p == 253) || (*p == 254)) /* DO or DONT */
1101 y = 252; /* -> WONT */
1102 if (y) {
1103 obuf[1] = y;
1104 p++; x--;
1105 obuf[2] = *p; /* copy actual option byte */
1106 (void) write (netfd, obuf, 3);
1107/* if one wanted to bump wrote_net or do a hexdump line, here's the place */
1108 y = 0;
1109 } /* if y */
1110notiac:
1111 p++; x--;
1112 } /* while x */
1113} /* atelnet */
1114#endif /* TELNET */
1115
1116/* readwrite :
1117 handle stdin/stdout/network I/O. Bwahaha!! -- the select loop from hell.
1118 In this instance, return what might become our exit status. */
1119int readwrite (fd)
1120 int fd;
1121{
1122 register int rr;
1123 register char * zp; /* stdin buf ptr */
1124 register char * np; /* net-in buf ptr */
1125 unsigned int rzleft;
1126 unsigned int rnleft;
1127 USHORT netretry; /* net-read retry counter */
1128 USHORT wretry; /* net-write sanity counter */
1129 USHORT wfirst; /* one-shot flag to skip first net read */
1130
1131/* if you don't have all this FD_* macro hair in sys/types.h, you'll have to
1132 either find it or do your own bit-bashing: *ding1 |= (1 << fd), etc... */
1133 if (fd > FD_SETSIZE) {
1134 holler ("Preposterous fd value %d", fd);
1135 return (1);
1136 }
1137 FD_SET (fd, ding1); /* global: the net is open */
1138 netretry = 2;
1139 wfirst = 0;
1140 rzleft = rnleft = 0;
1141 if (insaved) {
1142 rzleft = insaved; /* preload multi-mode fakeouts */
1143 zp = bigbuf_in;
1144 wfirst = 1;
1145 if (Single) /* if not scanning, this is a one-off first */
1146 insaved = 0; /* buffer left over from argv construction, */
1147 else {
1148 FD_CLR (0, ding1); /* OR we've already got our repeat chunk, */
1149 close (0); /* so we won't need any more stdin */
1150 } /* Single */
1151 } /* insaved */
1152 if (o_interval)
1153 sleep (o_interval); /* pause *before* sending stuff, too */
1154 errno = 0; /* clear from sleep, close, whatever */
1155
1156/* and now the big ol' select shoveling loop ... */
1157 while (FD_ISSET (fd, ding1)) { /* i.e. till the *net* closes! */
1158 wretry = 8200; /* more than we'll ever hafta write */
1159 if (wfirst) { /* any saved stdin buffer? */
1160 wfirst = 0; /* clear flag for the duration */
1161 goto shovel; /* and go handle it first */
1162 }
1163 *ding2 = *ding1; /* FD_COPY ain't portable... */
1164/* some systems, notably linux, crap into their select timers on return, so
1165 we create a expendable copy and give *that* to select. *Fuck* me ... */
1166 if (timer1)
1167 memcpy (timer2, timer1, sizeof (struct timeval));
1168 rr = select (16, ding2, 0, 0, timer2); /* here it is, kiddies */
1169 if (rr < 0) {
1170 if (errno != EINTR) { /* might have gotten ^Zed, etc ?*/
1171 holler ("select fuxored");
1172 close (fd);
1173 return (1);
1174 }
1175 } /* select fuckup */
1176/* if we have a timeout AND stdin is closed AND we haven't heard anything
1177 from the net during that time, assume it's dead and close it too. */
1178 if (rr == 0) {
1179 if (! FD_ISSET (0, ding1))
1180 netretry--; /* we actually try a coupla times. */
1181 if (! netretry) {
1182 if (o_verbose > 1) /* normally we don't care */
1183 holler ("net timeout");
1184 close (fd);
1185 return (0); /* not an error! */
1186 }
1187 } /* select timeout */
1188/* xxx: should we check the exception fds too? The read fds seem to give
1189 us the right info, and none of the examples I found bothered. */
1190
1191/* Ding!! Something arrived, go check all the incoming hoppers, net first */
1192 if (FD_ISSET (fd, ding2)) { /* net: ding! */
1193 rr = read (fd, bigbuf_net, BIGSIZ);
1194 if (rr <= 0) {
1195 FD_CLR (fd, ding1); /* net closed, we'll finish up... */
1196 rzleft = 0; /* can't write anymore: broken pipe */
1197 } else {
1198 rnleft = rr;
1199 np = bigbuf_net;
1200#ifdef TELNET
1201 if (o_tn)
1202 atelnet (np, rr); /* fake out telnet stuff */
1203#endif /* TELNET */
1204 } /* if rr */
1205Debug (("got %d from the net, errno %d", rr, errno))
1206 } /* net:ding */
1207
1208/* if we're in "slowly" mode there's probably still stuff in the stdin
1209 buffer, so don't read unless we really need MORE INPUT! MORE INPUT! */
1210 if (rzleft)
1211 goto shovel;
1212
1213/* okay, suck more stdin */
1214 if (FD_ISSET (0, ding2)) { /* stdin: ding! */
1215 rr = read (0, bigbuf_in, BIGSIZ);
1216/* Considered making reads here smaller for UDP mode, but 8192-byte
1217 mobygrams are kinda fun and exercise the reassembler. */
1218 if (rr <= 0) { /* at end, or fukt, or ... */
1219 FD_CLR (0, ding1); /* disable and close stdin */
1220 close (0);
1221 } else {
1222 rzleft = rr;
1223 zp = bigbuf_in;
1224/* special case for multi-mode -- we'll want to send this one buffer to every
1225 open TCP port or every UDP attempt, so save its size and clean up stdin */
1226 if (! Single) { /* we might be scanning... */
1227 insaved = rr; /* save len */
1228 FD_CLR (0, ding1); /* disable further junk from stdin */
1229 close (0); /* really, I mean it */
1230 } /* Single */
1231 } /* if rr/read */
1232 } /* stdin:ding */
1233
1234shovel:
1235/* now that we've dingdonged all our thingdings, send off the results.
1236 Geez, why does this look an awful lot like the big loop in "rsh"? ...
1237 not sure if the order of this matters, but write net -> stdout first. */
1238
1239/* sanity check. Works because they're both unsigned... */
1240 if ((rzleft > 8200) || (rnleft > 8200)) {
1241 holler ("Bogus buffers: %d, %d", rzleft, rnleft);
1242 rzleft = rnleft = 0;
1243 }
1244/* net write retries sometimes happen on UDP connections */
1245 if (! wretry) { /* is something hung? */
1246 holler ("too many output retries");
1247 return (1);
1248 }
1249 if (rnleft) {
1250 rr = write (1, np, rnleft);
1251 if (rr > 0) {
1252 if (o_wfile)
1253 oprint (1, np, rr); /* log the stdout */
1254 np += rr; /* fix up ptrs and whatnot */
1255 rnleft -= rr; /* will get sanity-checked above */
1256 wrote_out += rr; /* global count */
1257 }
1258Debug (("wrote %d to stdout, errno %d", rr, errno))
1259 } /* rnleft */
1260 if (rzleft) {
1261 if (o_interval) /* in "slowly" mode ?? */
1262 rr = findline (zp, rzleft);
1263 else
1264 rr = rzleft;
1265 rr = write (fd, zp, rr); /* one line, or the whole buffer */
1266 if (rr > 0) {
1267 if (o_wfile)
1268 oprint (0, zp, rr); /* log what got sent */
1269 zp += rr;
1270 rzleft -= rr;
1271 wrote_net += rr; /* global count */
1272 }
1273Debug (("wrote %d to net, errno %d", rr, errno))
1274 } /* rzleft */
1275 if (o_interval) { /* cycle between slow lines, or ... */
1276 sleep (o_interval);
1277 errno = 0; /* clear from sleep */
1278 continue; /* ...with hairy select loop... */
1279 }
1280 if ((rzleft) || (rnleft)) { /* shovel that shit till they ain't */
1281 wretry--; /* none left, and get another load */
1282 goto shovel;
1283 }
1284 } /* while ding1:netfd is open */
1285
1286/* XXX: maybe want a more graceful shutdown() here, or screw around with
1287 linger times?? I suspect that I don't need to since I'm always doing
1288 blocking reads and writes and my own manual "last ditch" efforts to read
1289 the net again after a timeout. I haven't seen any screwups yet, but it's
1290 not like my test network is particularly busy... */
1291 close (fd);
1292 return (0);
1293} /* readwrite */
1294
1295/* main :
1296 now we pull it all together... */
1297main (argc, argv)
1298 int argc;
1299 char ** argv;
1300{
1301#ifndef HAVE_GETOPT
1302 extern char * optarg;
1303 extern int optind, optopt;
1304#endif
1305 register int x;
1306 register char *cp;
1307 HINF * gp;
1308 HINF * whereto = NULL;
1309 HINF * wherefrom = NULL;
1310 IA * ouraddr = NULL;
1311 IA * themaddr = NULL;
1312 USHORT o_lport = 0;
1313 USHORT ourport = 0;
1314 USHORT loport = 0; /* for scanning stuff */
1315 USHORT hiport = 0;
1316 USHORT curport = 0;
1317 char * randports = NULL;
1318
1319#ifdef HAVE_BIND
1320/* can *you* say "cc -yaddayadda netcat.c -lresolv -l44bsd" on SunLOSs? */
1321 res_init();
1322#endif
1323/* I was in this barbershop quartet in Skokie IL ... */
1324/* round up the usual suspects, i.e. malloc up all the stuff we need */
1325 lclend = (SAI *) Hmalloc (sizeof (SA));
1326 remend = (SAI *) Hmalloc (sizeof (SA));
1327 bigbuf_in = Hmalloc (BIGSIZ);
1328 bigbuf_net = Hmalloc (BIGSIZ);
1329 ding1 = (fd_set *) Hmalloc (sizeof (fd_set));
1330 ding2 = (fd_set *) Hmalloc (sizeof (fd_set));
1331 portpoop = (PINF *) Hmalloc (sizeof (PINF));
1332
1333 errno = 0;
1334 gatesptr = 4;
1335 h_errno = 0;
1336
1337/* catch a signal or two for cleanup */
1338 signal (SIGINT, catch);
1339 signal (SIGQUIT, catch);
1340 signal (SIGTERM, catch);
1341/* and suppress others... */
1342#ifdef SIGURG
1343 signal (SIGURG, SIG_IGN);
1344#endif
1345#ifdef SIGPIPE
1346 signal (SIGPIPE, SIG_IGN); /* important! */
1347#endif
1348
1349/* if no args given at all, get 'em from stdin, construct an argv, and hand
1350 anything left over to readwrite(). */
1351 if (argc == 1) {
1352 cp = argv[0];
1353 argv = (char **) Hmalloc (128 * sizeof (char *)); /* XXX: 128? */
1354 argv[0] = cp; /* leave old prog name intact */
1355 cp = Hmalloc (BIGSIZ);
1356 argv[1] = cp; /* head of new arg block */
1357 fprintf (stderr, "Cmd line: ");
1358 fflush (stderr); /* I dont care if it's unbuffered or not! */
1359 insaved = read (0, cp, BIGSIZ); /* we're gonna fake fgets() here */
1360 if (insaved <= 0)
1361 bail ("wrong");
1362 x = findline (cp, insaved);
1363 if (x)
1364 insaved -= x; /* remaining chunk size to be sent */
1365 if (insaved) /* which might be zero... */
1366 memcpy (bigbuf_in, &cp[x], insaved);
1367 cp = strchr (argv[1], '\n');
1368 if (cp)
1369 *cp = '\0';
1370 cp = strchr (argv[1], '\r'); /* look for ^M too */
1371 if (cp)
1372 *cp = '\0';
1373
1374/* find and stash pointers to remaining new "args" */
1375 cp = argv[1];
1376 cp++; /* skip past first char */
1377 x = 2; /* we know argv 0 and 1 already */
1378 for (; *cp != '\0'; cp++) {
1379 if (*cp == ' ') {
1380 *cp = '\0'; /* smash all spaces */
1381 continue;
1382 } else {
1383 if (*(cp-1) == '\0') {
1384 argv[x] = cp;
1385 x++;
1386 }
1387 } /* if space */
1388 } /* for cp */
1389 argc = x;
1390 } /* if no args given */
1391
1392/* If your shitbox doesn't have getopt, step into the nineties already. */
1393/* optarg, optind = next-argv-component [i.e. flag arg]; optopt = last-char */
1394 while ((x = getopt (argc, argv, "ae:g:G:hi:lno:p:rs:tuvw:z")) != -1) {
1395/* Debug (("in go: x now %c, optarg %x optind %d", x, optarg, optind)) */
1396 switch (x) {
1397 case 'a':
1398 bail ("all-A-records NIY");
1399 o_alla++; break;
1400#ifdef GAPING_SECURITY_HOLE
1401 case 'e': /* prog to exec */
1402 pr00gie = optarg;
1403 break;
1404#endif
1405 case 'G': /* srcrt gateways pointer val */
1406 x = atoi (optarg);
1407 if ((x) && (x == (x & 0x1c))) /* mask off bits of fukt values */
1408 gatesptr = x;
1409 else
1410 bail ("invalid hop pointer %d, must be multiple of 4 <= 28", x);
1411 break;
1412 case 'g': /* srcroute hop[s] */
1413 if (gatesidx > 8)
1414 bail ("too many -g hops");
1415 if (gates == NULL) /* eat this, Billy-boy */
1416 gates = (HINF **) Hmalloc (sizeof (HINF *) * 10);
1417 gp = gethostpoop (optarg, o_nflag);
1418 if (gp)
1419 gates[gatesidx] = gp;
1420 gatesidx++;
1421 break;
1422 case 'h':
1423 errno = 0;
1424#ifdef HAVE_HELP
1425 helpme(); /* exits by itself */
1426#else
1427 bail ("no help available, dork -- RTFS");
1428#endif
1429 case 'i': /* line-interval time */
1430 o_interval = atoi (optarg) & 0xffff;
1431 if (! o_interval)
1432 bail ("invalid interval time %s", optarg);
1433 break;
1434 case 'l': /* listen mode */
1435 o_listen++; break;
1436 case 'n': /* numeric-only, no DNS lookups */
1437 o_nflag++; break;
1438 case 'o': /* hexdump log */
1439 stage = (unsigned char *) optarg;
1440 o_wfile++; break;
1441 case 'p': /* local source port */
1442 o_lport = getportpoop (optarg, 0);
1443 if (o_lport == 0)
1444 bail ("invalid local port %s", optarg);
1445 break;
1446 case 'r': /* randomize various things */
1447 o_random++; break;
1448 case 's': /* local source address */
1449/* do a full lookup [since everything else goes through the same mill],
1450 unless -n was previously specified. In fact, careful placement of -n can
1451 be useful, so we'll still pass o_nflag here instead of forcing numeric. */
1452 wherefrom = gethostpoop (optarg, o_nflag);
1453 ouraddr = &wherefrom->iaddrs[0];
1454 break;
1455#ifdef TELNET
1456 case 't': /* do telnet fakeout */
1457 o_tn++; break;
1458#endif /* TELNET */
1459 case 'u': /* use UDP */
1460 o_udpmode++; break;
1461 case 'v': /* verbose */
1462 o_verbose++; break;
1463 case 'w': /* wait time */
1464 o_wait = atoi (optarg);
1465 if (o_wait <= 0)
1466 bail ("invalid wait-time %s", optarg);
1467 timer1 = (struct timeval *) Hmalloc (sizeof (struct timeval));
1468 timer2 = (struct timeval *) Hmalloc (sizeof (struct timeval));
1469 timer1->tv_sec = o_wait; /* we need two. see readwrite()... */
1470 break;
1471 case 'z': /* little or no data xfer */
1472 o_zero++;
1473 break;
1474 default:
1475 errno = 0;
1476 bail ("nc -h for help");
1477 } /* switch x */
1478 } /* while getopt */
1479
1480/* other misc initialization */
1481Debug (("fd_set size %d", sizeof (*ding1))) /* how big *is* it? */
1482 FD_SET (0, ding1); /* stdin *is* initially open */
1483 if (o_random) {
1484 SRAND (time (0));
1485 randports = Hmalloc (65536); /* big flag array for ports */
1486 }
1487#ifdef GAPING_SECURITY_HOLE
1488 if (pr00gie) {
1489 close (0); /* won't need stdin */
1490 o_wfile = 0; /* -o with -e is meaningless! */
1491 ofd = 0;
1492 }
1493#endif /* G_S_H */
1494 if (o_wfile) {
1495 ofd = open (stage, O_WRONLY | O_CREAT | O_TRUNC, 0664);
1496 if (ofd <= 0) /* must be > extant 0/1/2 */
1497 bail ("can't open %s", stage);
1498 stage = (unsigned char *) Hmalloc (100);
1499 }
1500
1501/* optind is now index of first non -x arg */
1502Debug (("after go: x now %c, optarg %x optind %d", x, optarg, optind))
1503/* Debug (("optind up to %d at host-arg %s", optind, argv[optind])) */
1504/* gonna only use first addr of host-list, like our IQ was normal; if you wanna
1505 get fancy with addresses, look up the list yourself and plug 'em in for now.
1506 unless we finally implement -a, that is. */
1507 if (argv[optind])
1508 whereto = gethostpoop (argv[optind], o_nflag);
1509 if (whereto && whereto->iaddrs)
1510 themaddr = &whereto->iaddrs[0];
1511 if (themaddr)
1512 optind++; /* skip past valid host lookup */
1513 errno = 0;
1514 h_errno = 0;
1515
1516/* Handle listen mode here, and exit afterward. Only does one connect;
1517 this is arguably the right thing to do. A "persistent listen-and-fork"
1518 mode a la inetd has been thought about, but not implemented. A tiny
1519 wrapper script can handle such things... */
1520 if (o_listen) {
1521 curport = 0; /* rem port *can* be zero here... */
1522 if (argv[optind]) { /* any rem-port-arg? */
1523 curport = getportpoop (argv[optind], 0);
1524 if (curport == 0) /* if given, demand correctness */
1525 bail ("invalid port %s", argv[optind]);
1526 } /* if port-arg */
1527 netfd = dolisten (themaddr, curport, ouraddr, o_lport);
1528/* dolisten does its own connect reporting, so we don't holler anything here */
1529 if (netfd > 0) {
1530#ifdef GAPING_SECURITY_HOLE
1531 if (pr00gie) /* -e given? */
1532 doexec (netfd);
1533#endif /* GAPING_SECURITY_HOLE */
1534 x = readwrite (netfd); /* it even works with UDP! */
1535 if (o_verbose > 1) /* normally we don't care */
1536 holler (wrote_txt, wrote_net, wrote_out);
1537 exit (x); /* "pack out yer trash" */
1538 } else /* if no netfd */
1539 bail ("no connection");
1540 } /* o_listen */
1541
1542/* fall thru to outbound connects. Now we're more picky about args... */
1543 if (! themaddr)
1544 bail ("no destination");
1545 if (argv[optind] == NULL)
1546 bail ("no port[s] to connect to");
1547 if (argv[optind + 1]) /* look ahead: any more port args given? */
1548 Single = 0; /* multi-mode, case A */
1549 ourport = o_lport; /* which can be 0 */
1550
1551/* everything from here down is treated as as ports and/or ranges thereof, so
1552 it's all enclosed in this big ol' argv-parsin' loop. Any randomization is
1553 done within each given *range*, but in separate chunks per each succeeding
1554 argument, so we can control the pattern somewhat. */
1555 while (argv[optind]) {
1556 hiport = loport = 0;
1557 cp = strchr (argv[optind], '-'); /* nn-mm range? */
1558 if (cp) {
1559 *cp = '\0';
1560 cp++;
1561 hiport = getportpoop (cp, 0);
1562 if (hiport == 0)
1563 bail ("invalid port %s", cp);
1564 } /* if found a dash */
1565 loport = getportpoop (argv[optind], 0);
1566 if (loport == 0)
1567 bail ("invalid port %s", argv[optind]);
1568 if (hiport > loport) { /* was it genuinely a range? */
1569 Single = 0; /* multi-mode, case B */
1570 curport = hiport; /* start high by default */
1571 if (o_random) { /* maybe populate the random array */
1572 loadports (randports, loport, hiport);
1573 curport = nextport (randports);
1574 }
1575 } else /* not a range, including args like "25-25" */
1576 curport = loport;
1577Debug (("Single %d, curport %d", Single, curport))
1578
1579/* Now start connecting to these things. curport is already preloaded. */
1580 while (loport <= curport) {
1581 if ((! o_lport) && (o_random)) { /* -p overrides random local-port */
1582 ourport = (RAND() & 0xffff); /* random local-bind -- well above */
1583 if (ourport < 8192) /* resv and any likely listeners??? */
1584 ourport += 8192; /* if it *still* conflicts, use -s. */
1585 }
1586 curport = getportpoop (NULL, curport);
1587 netfd = doconnect (themaddr, curport, ouraddr, ourport);
1588Debug (("netfd %d from port %d to port %d", netfd, ourport, curport))
1589 if (netfd > 0)
1590 if (o_zero && o_udpmode) /* if UDP scanning... */
1591 netfd = udptest (netfd, themaddr);
1592 if (netfd > 0) { /* Yow, are we OPEN YET?! */
1593 x = 0; /* pre-exit status */
1594 holler ("%s [%s] %d (%s) open",
1595 whereto->name, whereto->addrs[0], curport, portpoop->name);
1596#ifdef GAPING_SECURITY_HOLE
1597 if (pr00gie) /* exec is valid for outbound, too */
1598 doexec (netfd);
1599#endif /* GAPING_SECURITY_HOLE */
1600 if (! o_zero)
1601 x = readwrite (netfd); /* go shovel shit */
1602 } else { /* no netfd... */
1603 x = 1; /* preload exit status for later */
1604/* if we're scanning at a "one -v" verbosity level, don't print refusals.
1605 Give it another -v if you want to see everything. */
1606 if ((Single || (o_verbose > 1)) || (errno != ECONNREFUSED))
1607 holler ("%s [%s] %d (%s)",
1608 whereto->name, whereto->addrs[0], curport, portpoop->name);
1609 } /* if netfd */
1610 close (netfd); /* just in case we didn't already */
1611 if (o_interval)
1612 sleep (o_interval); /* if -i, delay between ports too */
1613 if (o_random)
1614 curport = nextport (randports);
1615 else
1616 curport--; /* just decrement... */
1617 } /* while curport within current range */
1618 optind++;
1619 } /* while remaining port-args -- end of big argv-ports loop*/
1620
1621 errno = 0;
1622 if (o_verbose > 1) /* normally we don't care */
1623 holler (wrote_txt, wrote_net, wrote_out);
1624 if (Single)
1625 exit (x); /* give us status on one connection */
1626 exit (0); /* otherwise, we're just done */
1627} /* main */
1628
1629#ifdef HAVE_HELP /* unless we wanna be *really* cryptic */
1630/* helpme :
1631 the obvious */
1632helpme()
1633{
1634 o_verbose = 1;
1635 holler ("[v1.10]\n\
1636connect to somewhere: nc [-options] hostname port[s] [ports] ... \n\
1637listen for inbound: nc -l -p port [-options] [hostname] [port]\n\
1638options:");
1639/* sigh, this necessarily gets messy. And the trailing \ characters may be
1640 interpreted oddly by some compilers, generating or not generating extra
1641 newlines as they bloody please. u-fix... */
1642#ifdef GAPING_SECURITY_HOLE /* needs to be separate holler() */
1643 holler ("\
1644 -e prog program to exec after connect [dangerous!!]");
1645#endif
1646 holler ("\
1647 -g gateway source-routing hop point[s], up to 8\n\
1648 -G num source-routing pointer: 4, 8, 12, ...\n\
1649 -h this cruft\n\
1650 -i secs delay interval for lines sent, ports scanned\n\
1651 -l listen mode, for inbound connects\n\
1652 -n numeric-only IP addresses, no DNS\n\
1653 -o file hex dump of traffic\n\
1654 -p port local port number\n\
1655 -r randomize local and remote ports\n\
1656 -s addr local source address");
1657#ifdef TELNET
1658 holler ("\
1659 -t answer TELNET negotiation");
1660#endif
1661 holler ("\
1662 -u UDP mode\n\
1663 -v verbose [use twice to be more verbose]\n\
1664 -w secs timeout for connects and final net reads\n\
1665 -z zero-I/O mode [used for scanning]");
1666 bail ("port numbers can be individual or ranges: lo-hi [inclusive]");
1667} /* helpme */
1668#endif /* HAVE_HELP */
1669
1670/* None genuine without this seal! _H*/
diff --git a/src/usr.bin/nc/scripts/README b/src/usr.bin/nc/scripts/README
new file mode 100644
index 0000000000..07aee0c8ea
--- /dev/null
+++ b/src/usr.bin/nc/scripts/README
@@ -0,0 +1,5 @@
1A collection of example scripts that use netcat as a backend, each
2documented by its own internal comments.
3
4I'll be the first to admit that some of these are seriously *sick*,
5but they do work and are quite useful to me on a daily basis.
diff --git a/src/usr.bin/nc/scripts/alta b/src/usr.bin/nc/scripts/alta
new file mode 100644
index 0000000000..7a091767e8
--- /dev/null
+++ b/src/usr.bin/nc/scripts/alta
@@ -0,0 +1,33 @@
1#! /bin/sh
2## special handler for altavista, since they only hand out chunks of 10 at
3## a time. Tries to isolate out results without the leading/trailing trash.
4## multiword arguments are foo+bar, as usual.
5## Second optional arg switches the "what" field, to e.g. "news"
6
7test "${1}" = "" && echo 'Needs an argument to search for!' && exit 1
8WHAT="web"
9test "${2}" && WHAT="${2}"
10
11# convert multiple args
12PLUSARG="`echo $* | sed 's/ /+/g'`"
13
14# Plug in arg. only doing simple-q for now; pg=aq for advanced-query
15# embedded quotes define phrases; otherwise it goes wild on multi-words
16QB="GET /cgi-bin/query?pg=q&what=${WHAT}&fmt=c&q=\"${PLUSARG}\""
17
18# ping 'em once, to get the routing warm
19nc -z -w 8 www.altavista.digital.com 24015 2> /dev/null
20echo "=== Altavista ==="
21
22for xx in 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 \
23 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 ; do
24 echo "${QB}&stq=${xx}" | nc -w 15 www.altavista.digital.com 80 | \
25 egrep '^<a href="http://'
26done
27
28exit 0
29
30# old filter stuff
31 sed -e '/Documents .* matching .* query /,/query?.*stq=.* Document/p' \
32 -e d
33
diff --git a/src/usr.bin/nc/scripts/bsh b/src/usr.bin/nc/scripts/bsh
new file mode 100644
index 0000000000..796e480354
--- /dev/null
+++ b/src/usr.bin/nc/scripts/bsh
@@ -0,0 +1,29 @@
1#! /bin/sh
2## a little wrapper to "password" and re-launch a shell-listener.
3## Arg is taken as the port to listen on. Define "NC" to point wherever.
4
5NC=nc
6
7case "$1" in
8 ?* )
9 LPN="$1"
10 export LPN
11 sleep 1
12 echo "-l -p $LPN -e $0" | $NC > /dev/null 2>&1 &
13 echo "launched on port $LPN"
14 exit 0
15 ;;
16esac
17
18# here we play inetd
19echo "-l -p $LPN -e $0" | $NC > /dev/null 2>&1 &
20
21while read qq ; do
22case "$qq" in
23# here's yer password
24 gimme )
25 cd /
26 exec csh -i
27 ;;
28esac
29done
diff --git a/src/usr.bin/nc/scripts/dist.sh b/src/usr.bin/nc/scripts/dist.sh
new file mode 100644
index 0000000000..4d2534a0e3
--- /dev/null
+++ b/src/usr.bin/nc/scripts/dist.sh
@@ -0,0 +1,23 @@
1#! /bin/sh
2## This is a quick example listen-exec server, which was used for a while to
3## distribute netcat prereleases. It illustrates use of netcat both as a
4## "fake inetd" and a syslogger, and how easy it then is to crock up a fairly
5## functional server that restarts its own listener and does full connection
6## logging. In a half-screen of shell script!!
7
8PORT=31337
9
10sleep 1
11SRC=`tail -1 dist.log`
12echo "<36>elite: ${SRC}" | ./nc -u -w 1 localhost 514 > /dev/null 2>&1
13echo ";;; Hi, ${SRC}..."
14echo ";;; This is a PRERELEASE version of 'netcat', tar/gzip/uuencoded."
15echo ";;; Unless you are capturing this somehow, it won't do you much good."
16echo ";;; Ready?? Here it comes! Have phun ..."
17sleep 8
18cat dist.file
19sleep 1
20./nc -v -l -p ${PORT} -e dist.sh < /dev/null >> dist.log 2>&1 &
21sleep 1
22echo "<36>elite: done" | ./nc -u -w 1 localhost 514 > /dev/null 2>&1
23exit 0
diff --git a/src/usr.bin/nc/scripts/irc b/src/usr.bin/nc/scripts/irc
new file mode 100644
index 0000000000..3557d7a0c6
--- /dev/null
+++ b/src/usr.bin/nc/scripts/irc
@@ -0,0 +1,79 @@
1#! /bin/sh
2## Shit-simple script to supply the "privmsg <recipient>" of IRC typein, and
3## keep the connection alive. Pipe this thru "nc -v -w 5 irc-server port".
4## Note that this mechanism makes the script easy to debug without being live,
5## since it just echoes everything bound for the server.
6## if you want autologin-type stuff, construct some appropriate files and
7## shovel them in using the "<" mechanism.
8
9# magic arg: if "tick", do keepalive process instead of main loop
10if test "$1" = "tick" ; then
11# ignore most signals; the parent will nuke the kid
12# doesn't stop ^Z, of course.
13 trap '' 1 2 3 13 14 15 16
14 while true ; do
15 sleep 60
16 echo "PONG !"
17 done
18fi
19
20# top level: fire ourselves off as the keepalive process, and keep track of it
21sh $0 tick &
22ircpp=$!
23echo "[Keepalive: $ircpp]" >&2
24# catch our own batch of signals: hup int quit pipe alrm term urg
25trap 'kill -9 $ircpp ; exit 0' 1 2 3 13 14 15 16
26sleep 2
27
28sender=''
29savecmd=''
30
31# the big honkin' loop...
32while read xx yy ; do
33 case "${xx}" in
34# blank line: do nothing
35 "")
36 continue
37 ;;
38# new channel or recipient; if bare ">", we're back to raw literal mode.
39 ">")
40 if test "${yy}" ; then
41 sender="privmsg ${yy} :"
42 else
43 sender=''
44 fi
45 continue
46 ;;
47# send crud from a file, one line per second. Can you say "skr1pt kidz"??
48# *Note: uses current "recipient" if set.
49 "<")
50 if test -f "${yy}" ; then
51 ( while read zz ; do
52 sleep 1
53 echo "${sender}${zz}"
54 done ) < "$yy"
55 echo "[done]" >&2
56 else
57 echo "[File $yy not found]" >&2
58 fi
59 continue
60 ;;
61# do and save a single command, for quick repeat
62 "/")
63 if test "${yy}" ; then
64 savecmd="${yy}"
65 fi
66 echo "${savecmd}"
67 ;;
68# default case goes to recipient, just like always
69 *)
70 echo "${sender}${xx} ${yy}"
71 continue
72 ;;
73 esac
74done
75
76# parting shot, if you want it
77echo "quit :Bye all!"
78kill -9 $ircpp
79exit 0
diff --git a/src/usr.bin/nc/scripts/iscan b/src/usr.bin/nc/scripts/iscan
new file mode 100644
index 0000000000..6279bc817f
--- /dev/null
+++ b/src/usr.bin/nc/scripts/iscan
@@ -0,0 +1,35 @@
1#! /bin/sh
2## duplicate DaveG's ident-scan thingie using netcat. Oooh, he'll be pissed.
3## args: target port [port port port ...]
4## hose stdout *and* stderr together.
5##
6## advantages: runs slower than ident-scan, giving remote inetd less cause
7## for alarm, and only hits the few known daemon ports you specify.
8## disadvantages: requires numeric-only port args, the output sleazitude,
9## and won't work for r-services when coming from high source ports.
10
11case "${2}" in
12 "" ) echo needs HOST and at least one PORT ; exit 1 ;;
13esac
14
15# ping 'em once and see if they *are* running identd
16nc -z -w 9 "$1" 113 || { echo "oops, $1 isn't running identd" ; exit 0 ; }
17
18# generate a randomish base port
19RP=`expr $$ % 999 + 31337`
20
21TRG="$1"
22shift
23
24while test "$1" ; do
25 nc -v -w 8 -p ${RP} "$TRG" ${1} < /dev/null > /dev/null &
26 PROC=$!
27 sleep 3
28 echo "${1},${RP}" | nc -w 4 -r "$TRG" 113 2>&1
29 sleep 2
30# does this look like a lamer script or what...
31 kill -HUP $PROC
32 RP=`expr ${RP} + 1`
33 shift
34done
35
diff --git a/src/usr.bin/nc/scripts/ncp b/src/usr.bin/nc/scripts/ncp
new file mode 100644
index 0000000000..1931b03385
--- /dev/null
+++ b/src/usr.bin/nc/scripts/ncp
@@ -0,0 +1,46 @@
1#! /bin/sh
2## Like "rcp" but uses netcat on a high port.
3## do "ncp targetfile" on the RECEIVING machine
4## then do "ncp sourcefile receivinghost" on the SENDING machine
5## if invoked as "nzp" instead, compresses transit data.
6
7## pick your own personal favorite port, which will be used on both ends.
8## You should probably change this for your own uses.
9MYPORT=23456
10
11## if "nc" isn't systemwide or in your PATH, add the right place
12# PATH=${HOME}:${PATH} ; export PATH
13
14test "$3" && echo "too many args" && exit 1
15test ! "$1" && echo "no args?" && exit 1
16me=`echo $0 | sed 's+.*/++'`
17test "$me" = "nzp" && echo '[compressed mode]'
18
19# if second arg, it's a host to send an [extant] file to.
20if test "$2" ; then
21 test ! -f "$1" && echo "can't find $1" && exit 1
22 if test "$me" = "nzp" ; then
23 compress -c < "$1" | nc -v -w 2 $2 $MYPORT && exit 0
24 else
25 nc -v -w 2 $2 $MYPORT < "$1" && exit 0
26 fi
27 echo "transfer FAILED!"
28 exit 1
29fi
30
31# fall here for receiver. Ask before trashing existing files
32if test -f "$1" ; then
33 echo -n "Overwrite $1? "
34 read aa
35 test ! "$aa" = "y" && echo "[punted!]" && exit 1
36fi
37# 30 seconds oughta be pleeeeenty of time, but change if you want.
38if test "$me" = "nzp" ; then
39 nc -v -w 30 -p $MYPORT -l < /dev/null | uncompress -c > "$1" && exit 0
40else
41 nc -v -w 30 -p $MYPORT -l < /dev/null > "$1" && exit 0
42fi
43echo "transfer FAILED!"
44# clean up, since even if the transfer failed, $1 is already trashed
45rm -f "$1"
46exit 1
diff --git a/src/usr.bin/nc/scripts/probe b/src/usr.bin/nc/scripts/probe
new file mode 100644
index 0000000000..c47dc3f495
--- /dev/null
+++ b/src/usr.bin/nc/scripts/probe
@@ -0,0 +1,50 @@
1#! /bin/sh
2## launch a whole buncha shit at yon victim in no particular order; capture
3## stderr+stdout in one place. Run as root for rservice and low -p to work.
4## Fairly thorough example of using netcat to collect a lot of host info.
5## Will set off every intrusion alarm in existence on a paranoid machine!
6
7# where .d files are kept; "." if nothing else
8DDIR=../data
9# address of some well-connected router that groks LSRR
10GATE=192.157.69.11
11
12# might conceivably wanna change this for different run styles
13UCMD='nc -v -w 8'
14
15test ! "$1" && echo Needs victim arg && exit 1
16
17echo '' | $UCMD -w 9 -r "$1" 13 79 6667 2>&1
18echo '0' | $UCMD "$1" 79 2>&1
19# if LSRR was passed thru, should get refusal here:
20$UCMD -z -r -g $GATE "$1" 6473 2>&1
21$UCMD -r -z "$1" 6000 4000-4004 111 53 2105 137-140 1-20 540-550 95 87 2>&1
22# -s `hostname` may be wrong for some multihomed machines
23echo 'UDP echoecho!' | nc -u -p 7 -s `hostname` -w 3 "$1" 7 19 2>&1
24echo '113,10158' | $UCMD -p 10158 "$1" 113 2>&1
25rservice bin bin | $UCMD -p 1019 "$1" shell 2>&1
26echo QUIT | $UCMD -w 8 -r "$1" 25 158 159 119 110 109 1109 142-144 220 23 2>&1
27# newline after any telnet trash
28echo ''
29echo PASV | $UCMD -r "$1" 21 2>&1
30echo 'GET /' | $UCMD -w 10 "$1" 80 81 210 70 2>&1
31# sometimes contains useful directory info:
32echo 'GET /robots.txt' | $UCMD -w 10 "$1" 80 2>&1
33# now the big red lights go on
34rservice bin bin 9600/9600 | $UCMD -p 1020 "$1" login 2>&1
35rservice root root | $UCMD -r "$1" exec 2>&1
36echo 'BEGIN big udp -- everything may look "open" if packet-filtered'
37data -g < ${DDIR}/nfs-0.d | $UCMD -i 1 -u "$1" 2049 | od -x 2>&1
38# no wait-time, uses RTT hack
39nc -v -z -u -r "$1" 111 66-70 88 53 87 161-164 121-123 213 49 2>&1
40nc -v -z -u -r "$1" 137-140 694-712 747-770 175-180 2103 510-530 2>&1
41echo 'END big udp'
42$UCMD -r -z "$1" 175-180 2000-2003 530-533 1524 1525 666 213 8000 6250 2>&1
43# Use our identd-sniffer!
44iscan "$1" 21 25 79 80 111 53 6667 6000 2049 119 2>&1
45# this gets pretty intrusive, but what the fuck. Probe for portmap first
46if nc -w 5 -z -u "$1" 111 ; then
47 showmount -e "$1" 2>&1
48 rpcinfo -p "$1" 2>&1
49fi
50exit 0
diff --git a/src/usr.bin/nc/scripts/web b/src/usr.bin/nc/scripts/web
new file mode 100644
index 0000000000..382b18e1e3
--- /dev/null
+++ b/src/usr.bin/nc/scripts/web
@@ -0,0 +1,148 @@
1#! /bin/sh
2## The web sucks. It is a mighty dismal kludge built out of a thousand
3## tiny dismal kludges all band-aided together, and now these bottom-line
4## clueless pinheads who never heard of "TCP handshake" want to run
5## *commerce* over the damn thing. Ye godz. Welcome to TV of the next
6## century -- six million channels of worthless shit to choose from, and
7## about as much security as today's cable industry!
8##
9## Having grown mightily tired of pain in the ass browsers, I decided
10## to build the minimalist client. It doesn't handle POST, just GETs, but
11## the majority of cgi forms handlers apparently ignore the method anyway.
12## A distinct advantage is that it *doesn't* pass on any other information
13## to the server, like Referer: or info about your local machine such as
14## Netscum tries to!
15##
16## Since the first version, this has become the *almost*-minimalist client,
17## but it saves a lot of typing now. And with netcat as its backend, it's
18## totally the balls. Don't have netcat? Get it here in /src/hacks!
19## _H* 950824, updated 951009 et seq.
20##
21## args: hostname [port]. You feed it the filename-parts of URLs.
22## In the loop, HOST, PORT, and SAVE do the right things; a null line
23## gets the previous spec again [useful for initial timeouts]; EOF to exit.
24## Relative URLs behave like a "cd" to wherever the last slash appears, or
25## just use the last component with the saved preceding "directory" part.
26## "\" clears the "filename" part and asks for just the "directory", and
27## ".." goes up one "directory" level while retaining the "filename" part.
28## Play around; you'll get used to it.
29
30if test "$1" = "" ; then
31 echo Needs hostname arg.
32 exit 1
33fi
34umask 022
35
36# optional PATH fixup
37# PATH=${HOME}:${PATH} ; export PATH
38
39test "${PAGER}" || PAGER=more
40BACKEND="nc -v -w 15"
41TMPAGE=/tmp/web$$
42host="$1"
43port="80"
44if test "$2" != "" ; then
45 port="$2"
46fi
47
48spec="/"
49specD="/"
50specF=''
51saving=''
52
53# be vaguely smart about temp file usage. Use your own homedir if you're
54# paranoid about someone symlink-racing your shell script, jeez.
55rm -f ${TMPAGE}
56test -f ${TMPAGE} && echo "Can't use ${TMPAGE}" && exit 1
57
58# get loopy. Yes, I know "echo -n" aint portable. Everything echoed would
59# need "\c" tacked onto the end in an SV universe, which you can fix yourself.
60while echo -n "${specD}${specF} " && read spec ; do
61 case $spec in
62 HOST)
63 echo -n 'New host: '
64 read host
65 continue
66 ;;
67 PORT)
68 echo -n 'New port: '
69 read port
70 continue
71 ;;
72 SAVE)
73 echo -n 'Save file: '
74 read saving
75# if we've already got a page, save it
76 test "${saving}" && test -f ${TMPAGE} &&
77 echo "=== ${host}:${specD}${specF} ===" >> $saving &&
78 cat ${TMPAGE} >> $saving && echo '' >> $saving
79 continue
80 ;;
81# changing the logic a bit here. Keep a state-concept of "current dir"
82# and "current file". Dir is /foo/bar/ ; file is "baz" or null.
83# leading slash: create whole new state.
84 /*)
85 specF=`echo "${spec}" | sed 's|.*/||'`
86 specD=`echo "${spec}" | sed 's|\(.*/\).*|\1|'`
87 spec="${specD}${specF}"
88 ;;
89# embedded slash: adding to the path. "file" part can be blank, too
90 */*)
91 specF=`echo "${spec}" | sed 's|.*/||'`
92 specD=`echo "${specD}${spec}" | sed 's|\(.*/\).*|\1|'`
93 ;;
94# dotdot: jump "up" one level and just reprompt [confirms what it did...]
95 ..)
96 specD=`echo "${specD}" | sed 's|\(.*/\)..*/|\1|'`
97 continue
98 ;;
99# blank line: do nothing, which will re-get the current one
100 '')
101 ;;
102# hack-quoted blank line: "\" means just zero out "file" part
103 '\')
104 specF=''
105 ;;
106# sigh
107 '?')
108 echo Help yourself. Read the script fer krissake.
109 continue
110 ;;
111# anything else is taken as a "file" part
112 *)
113 specF=${spec}
114 ;;
115 esac
116
117# now put it together and stuff it down a connection. Some lame non-unix
118# http servers assume they'll never get simple-query format, and wait till
119# an extra newline arrives. If you're up against one of these, change
120# below to (echo GET "$spec" ; echo '') | $BACKEND ...
121 spec="${specD}${specF}"
122 echo GET "${spec}" | $BACKEND $host $port > ${TMPAGE}
123 ${PAGER} ${TMPAGE}
124
125# save in a format that still shows the URLs we hit after a de-html run
126 if test "${saving}" ; then
127 echo "=== ${host}:${spec} ===" >> $saving
128 cat ${TMPAGE} >> $saving
129 echo '' >> $saving
130 fi
131done
132rm -f ${TMPAGE}
133exit 0
134
135#######
136# Encoding notes, finally from RFC 1738:
137# %XX -- hex-encode of special chars
138# allowed alphas in a URL: $_-.+!*'(),
139# relative names *not* described, but obviously used all over the place
140# transport://user:pass@host:port/path/name?query-string
141# wais: port 210, //host:port/database?search or /database/type/file?
142# cgi-bin/script?arg1=foo&arg2=bar&... scripts have to parse xxx&yyy&zzz
143# ISMAP imagemap stuff: /bin/foobar.map?xxx,yyy -- have to guess at coords!
144# local access-ctl files: ncsa: .htaccess ; cern: .www_acl
145#######
146# SEARCH ENGINES: fortunately, all are GET forms or at least work that way...
147# multi-word args for most cases: foo+bar
148# See 'websearch' for concise results of this research...
diff --git a/src/usr.bin/nc/scripts/webproxy b/src/usr.bin/nc/scripts/webproxy
new file mode 100644
index 0000000000..cee2d29fd1
--- /dev/null
+++ b/src/usr.bin/nc/scripts/webproxy
@@ -0,0 +1,138 @@
1#! /bin/sh
2## Web proxy, following the grand tradition of Web things being handled by
3## gross scripts. Uses netcat to listen on a high port [default 8000],
4## picks apart requests and sends them on to the right place. Point this
5## at the browser client machine you'll be coming from [to limit access to
6## only it], and point the browser's concept of an HTTP proxy to the
7## machine running this. Takes a single argument of the client that will
8## be using it, and rejects connections from elsewhere. LOGS the queries
9## to a configurable logfile, which can be an interesting read later on!
10## If the argument is "reset", the listener and logfile are cleaned up.
11##
12## This works surprisingly fast and well, for a shell script, although may
13## randomly fail when hammered by a browser that tries to open several
14## connections at once. Drop the "maximum connections" in your browser if
15## this is a problem.
16##
17## A more degenerate case of this, or preferably a small C program that
18## does the same thing under inetd, could handle a small site's worth of
19## proxy queries. Given the way browsers are evolving, proxies like this
20## can play an important role in protecting your own privacy.
21##
22## If you grabbed this in ASCII mode, search down for "eew" and make sure
23## the embedded-CR check is intact, or requests might hang.
24##
25## Doesn't handle POST forms. Who cares, if you're just watching HTTV?
26## Dumbness here has a highly desirable side effect: it only sends the first
27## GET line, since that's all you really ever need to send, and suppresses
28## the other somewhat revealing trash that most browsers insist on sending.
29
30# set these as you wish: proxy port...
31PORT=8000
32# logfile spec: a real file or /dev/null if you don't care
33LFILE=${0}.log
34# optional: where to dump connect info, so you can see if anything went wrong
35# CFILE=${0}.conn
36# optional extra args to the listener "nc", for instance "-s inside-net-addr"
37# XNC=''
38
39# functionality switch has to be done fast, so the next listener can start
40# prelaunch check: if no current client and no args, bail.
41case "${1}${CLIENT}" in
42 "")
43 echo needs client hostname
44 exit 1
45 ;;
46esac
47
48case "${1}" in
49 "")
50# Make like inetd, and run the next relayer process NOW. All the redirection
51# is necessary so this shell has NO remaining channel open to the net.
52# This will hang around for 10 minutes, and exit if no new connections arrive.
53# Using -n for speed, avoiding any DNS/port lookups.
54 nc -w 600 -n -l -p $PORT -e "$0" $XNC "$CLIENT" < /dev/null > /dev/null \
55 2> $CFILE &
56 ;;
57esac
58
59# no client yet and had an arg, this checking can be much slower now
60umask 077
61
62if test "$1" ; then
63# if magic arg, just clean up and then hit our own port to cause server exit
64 if test "$1" = "reset" ; then
65 rm -f $LFILE
66 test -f "$CFILE" && rm -f $CFILE
67 nc -w 1 -n 127.0.0.1 $PORT < /dev/null > /dev/null 2>&1
68 exit 0
69 fi
70# find our ass with both hands
71 test ! -f "$0" && echo "Oops, cannot find my own corporeal being" && exit 1
72# correct launch: set up client access control, passed along thru environment.
73 CLIENT="$1"
74 export CLIENT
75 test "$CFILE" || CFILE=/dev/null
76 export CFILE
77 touch "$CFILE"
78# tell us what happened during the last run, if possible
79 if test -f "$CFILE" ; then
80 echo "Last connection results:"
81 cat $CFILE
82 fi
83
84# ping client machine and get its bare IP address
85 CLIENT=`nc -z -v -w 8 "$1" 22000 2>&1 | sed 's/.*\[\(..*\)\].*/\1/'`
86 test ! "$CLIENT" && echo "Can't find address of $1" && exit 1
87
88# if this was an initial launch, be informative about it
89 echo "=== Launch: $CLIENT" >> $LFILE
90 echo "Proxy running -- will accept connections on $PORT from $CLIENT"
91 echo " Logging queries to $LFILE"
92 test -f "$CFILE" && echo " and connection fuckups to $CFILE"
93
94# and run the first listener, showing us output just for the first hit
95 nc -v -w 600 -n -l -p $PORT -e "$0" $XNC "$CLIENT" &
96 exit 0
97fi
98
99# Fall here to handle a page.
100# GET type://host.name:80/file/path HTTP/1.0
101# Additional: trash
102# More: trash
103# <newline>
104
105read x1 x2 x3 x4
106echo "=== query: $x1 $x2 $x3 $x4" >> $LFILE
107test "$x4" && echo "extra junk after request: $x4" && exit 0
108# nuke questionable characters and split up the request
109hurl=`echo "$x2" | sed -e "s+.*//++" -e 's+[\`'\''|$;<>{}\\!*()"]++g'`
110# echo massaged hurl: $hurl >> $LFILE
111hh=`echo "$hurl" | sed -e "s+/.*++" -e "s+:.*++"`
112hp=`echo "$hurl" | sed -e "s+.*:++" -e "s+/.*++"`
113test "$hp" = "$hh" && hp=80
114hf=`echo "$hurl" | sed -e "s+[^/]*++"`
115# echo total split: $hh : $hp : $hf >> $LFILE
116# suck in and log the entire request, because we're curious
117# Fails on multipart stuff like forms; oh well...
118if test "$x3" ; then
119 while read xx ; do
120 echo "${xx}" >> $LFILE
121 test "${xx}" || break
122# eew, buried returns, gross but necessary for DOS stupidity:
123 test "${xx}" = " " && break
124 done
125fi
126# check for non-GET *after* we log the query...
127test "$x1" != "GET" && echo "sorry, this proxy only does GETs" && exit 0
128# no, you can *not* phone home, you miserable piece of shit
129test "`echo $hh | fgrep -i netscap`" && \
130 echo "access to Netscam's servers <b>DENIED.</b>" && exit 0
131# Do it. 30 sec net-wait time oughta be *plenty*...
132# Some braindead servers have forgotten how to handle the simple-query syntax.
133# If necessary, replace below with (echo "$x1 $hf" ; echo '') | nc...
134echo "$x1 $hf" | nc -w 30 "$hh" "$hp" 2> /dev/null || \
135 echo "oops, can't get to $hh : $hp".
136echo "sent \"$x1 $hf\" to $hh : $hp" >> $LFILE
137exit 0
138
diff --git a/src/usr.bin/nc/scripts/webrelay b/src/usr.bin/nc/scripts/webrelay
new file mode 100644
index 0000000000..829a8b0708
--- /dev/null
+++ b/src/usr.bin/nc/scripts/webrelay
@@ -0,0 +1,44 @@
1#! /bin/sh
2## web relay -- a degenerate version of webproxy, usable with browsers that
3## don't understand proxies. This just forwards connections to a given server.
4## No query logging, no access control [although you can add it to XNC for
5## your own run], and full-URL links will undoubtedly confuse the browser
6## if it can't reach the server directly. This was actually written before
7## the full proxy was, and it shows.
8## The arguments in this case are the destination server and optional port.
9## Please flame pinheads who use self-referential absolute links.
10
11# set these as you wish: proxy port...
12PORT=8000
13# any extra args to the listening "nc", for instance "-s inside-net-addr"
14XNC=''
15
16# functionality switch, which has to be done fast to start the next listener
17case "${1}${RDEST}" in
18 "")
19 echo needs hostname
20 exit 1
21 ;;
22esac
23
24case "${1}" in
25 "")
26# no args: fire off new relayer process NOW. Will hang around for 10 minutes
27 nc -w 600 -l -n -p $PORT -e "$0" $XNC < /dev/null > /dev/null 2>&1 &
28# and handle this request, which will simply fail if vars not set yet.
29 exec nc -w 15 $RDEST $RPORT
30 ;;
31esac
32
33# Fall here for setup; this can now be slower.
34RDEST="$1"
35RPORT="$2"
36test "$RPORT" || RPORT=80
37export RDEST RPORT
38
39# Launch the first relayer same as above, but let its error msgs show up
40# will hang around for a minute, and exit if no new connections arrive.
41nc -v -w 600 -l -p $PORT -e "$0" $XNC < /dev/null > /dev/null &
42echo \
43 "Relay to ${RDEST}:${RPORT} running -- point your browser here on port $PORT"
44exit 0
diff --git a/src/usr.bin/nc/scripts/websearch b/src/usr.bin/nc/scripts/websearch
new file mode 100644
index 0000000000..60c3a3356a
--- /dev/null
+++ b/src/usr.bin/nc/scripts/websearch
@@ -0,0 +1,77 @@
1#! /bin/sh
2## Hit the major search engines. Hose the [large] output to a file!
3## autoconverts multiple arguments into the right format for given servers --
4## usually worda+wordb, with certain lame exceptions like dejanews.
5## Extracting and post-sorting the URLs is highly recommended...
6##
7## Altavista currently handled by a separate script; may merge at some point.
8##
9## _H* original 950824, updated 951218 and 960209
10
11test "${1}" = "" && echo 'Needs argument[s] to search for!' && exit 1
12PLUSARG="`echo $* | sed 's/ /+/g'`"
13PIPEARG="`echo ${PLUSARG} | sed 's/+/|/g'`"
14IFILE=/tmp/.webq.$$
15
16# Don't have "nc"? Get "netcat" from avian.org and add it to your toolkit.
17doquery () {
18 echo GET "$1" | nc -v -i 1 -w 30 "$2" "$3"
19}
20
21# changed since original: now supplying port numbers and separator lines...
22
23echo "=== Yahoo ==="
24doquery "/bin/search?p=${PLUSARG}&n=300&w=w&s=a" search.yahoo.com 80
25
26echo '' ; echo "=== Webcrawler ==="
27doquery "/cgi-bin/WebQuery?searchText=${PLUSARG}&maxHits=300" webcrawler.com 80
28
29# the infoseek lamers want "registration" before they do a real search, but...
30echo '' ; echo "=== Infoseek ==="
31echo " is broken."
32# doquery "WW/IS/Titles?qt=${PLUSARG}" www2.infoseek.com 80
33# ... which doesn't work cuz their lame server wants the extra newlines, WITH
34# CRLF pairs ferkrissake. Fuck 'em for now, they're hopelessly broken. If
35# you want to play, the basic idea and query formats follow.
36# echo "GET /WW/IS/Titles?qt=${PLUSARG}" > $IFILE
37# echo "" >> $IFILE
38# nc -v -w 30 guide-p.infoseek.com 80 < $IFILE
39
40# this is kinda flakey; might have to do twice??
41echo '' ; echo "=== Opentext ==="
42doquery "/omw/simplesearch?SearchFor=${PLUSARG}&mode=phrase" \
43 search.opentext.com 80
44
45# looks like inktomi will only take hits=100, or defaults back to 30
46# we try to suppress all the stupid rating dots here, too
47echo '' ; echo "=== Inktomi ==="
48doquery "/query/?query=${PLUSARG}&hits=100" ink3.cs.berkeley.edu 1234 | \
49 sed '/^<IMG ALT.*inktomi.*\.gif">$/d'
50
51#djnews lame shit limits hits to 120 and has nonstandard format
52echo '' ; echo "=== Dejanews ==="
53doquery "/cgi-bin/nph-dnquery?query=${PIPEARG}+maxhits=110+format=terse+defaultOp=AND" \
54 smithers.dejanews.com 80
55
56# OLD lycos: used to work until they fucking BROKE it...
57# doquery "/cgi-bin/pursuit?query=${PLUSARG}&maxhits=300&terse=1" \
58# query5.lycos.cs.cmu.edu 80
59# NEW lycos: wants the User-agent field present in query or it returns nothing
60# 960206: webmaster@lycos duly bitched at
61# 960208: reply received; here's how we will now handle it:
62echo \
63"GET /cgi-bin/pursuit?query=${PLUSARG}&maxhits=300&terse=terse&matchmode=and&minscore=.5 HTTP/1.x" \
64 > $IFILE
65echo "User-agent: *FUCK OFF*" >> $IFILE
66echo "Why: go ask todd@pointcom.com (Todd Whitney)" >> $IFILE
67echo '' >> $IFILE
68echo '' ; echo "=== Lycos ==="
69nc -v -i 1 -w 30 twelve.srv.lycos.com 80 < $IFILE
70
71rm -f $IFILE
72exit 0
73
74# CURRENTLY BROKEN [?]
75# infoseek
76
77# some args need to be redone to ensure whatever "and" mode applies