summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto')
-rw-r--r--src/lib/libcrypto/LPdir_nyi.c42
-rw-r--r--src/lib/libcrypto/LPdir_unix.c127
-rw-r--r--src/lib/libcrypto/LPdir_vms.c206
-rw-r--r--src/lib/libcrypto/LPdir_win.c153
-rw-r--r--src/lib/libcrypto/LPdir_win32.c30
-rw-r--r--src/lib/libcrypto/LPdir_wince.c31
-rw-r--r--src/lib/libcrypto/bio/bio_lcl.h36
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.s3199
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.s.works533
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/add.pl119
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/div.pl144
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/mul.pl116
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/mul_add.pl120
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/mul_c4.pl213
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/mul_c4.works.pl98
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/mul_c8.pl177
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/sqr.pl113
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/sqr_c4.pl109
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/sqr_c8.pl132
-rw-r--r--src/lib/libcrypto/bn/asm/alpha.works/sub.pl108
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/add.pl118
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/div.pl144
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/mul.pl104
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/mul_add.pl123
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/mul_c4.pl215
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/mul_c4.works.pl98
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/mul_c8.pl177
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/sqr.pl113
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/sqr_c4.pl109
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/sqr_c8.pl132
-rw-r--r--src/lib/libcrypto/bn/asm/alpha/sub.pl108
-rw-r--r--src/lib/libcrypto/bn/asm/bn-alpha.pl571
-rw-r--r--src/lib/libcrypto/bn/asm/ca.pl33
-rw-r--r--src/lib/libcrypto/bn/asm/co-alpha.pl116
-rw-r--r--src/lib/libcrypto/bn/asm/mips1.s539
-rw-r--r--src/lib/libcrypto/bn/asm/mips3-mont.pl327
-rw-r--r--src/lib/libcrypto/bn/asm/mo-586.pl603
-rw-r--r--src/lib/libcrypto/bn/asm/pa-risc.s710
-rw-r--r--src/lib/libcrypto/bn/asm/r3000.s646
-rw-r--r--src/lib/libcrypto/camellia/Makefile110
-rw-r--r--src/lib/libcrypto/camellia/cmll_utl.c64
-rw-r--r--src/lib/libcrypto/cmac/Makefile111
-rw-r--r--src/lib/libcrypto/cms/Makefile284
-rw-r--r--src/lib/libcrypto/crypto-lib.com1516
-rw-r--r--src/lib/libcrypto/des/asm/des686.pl230
-rw-r--r--src/lib/libcrypto/des/des-lib.com1005
-rw-r--r--src/lib/libcrypto/dso/dso_beos.c270
-rw-r--r--src/lib/libcrypto/dyn_lck.c428
-rw-r--r--src/lib/libcrypto/ec/ecp_recp.c133
-rw-r--r--src/lib/libcrypto/ecdh/Makefile116
-rw-r--r--src/lib/libcrypto/ecdh/ecdhtest.c374
-rw-r--r--src/lib/libcrypto/ecdh/ech_ossl.c215
-rw-r--r--src/lib/libcrypto/ecdsa/Makefile140
-rw-r--r--src/lib/libcrypto/ecdsa/ecdsatest.c572
-rw-r--r--src/lib/libcrypto/engine/eng_cryptodev.c1450
-rw-r--r--src/lib/libcrypto/engine/eng_rdrand.c (renamed from src/lib/libcrypto/evp/evp_cnf.c)150
-rw-r--r--src/lib/libcrypto/engine/eng_rsax.c668
-rw-r--r--src/lib/libcrypto/engine/hw.ec8
-rw-r--r--src/lib/libcrypto/engine/hw_4758_cca.c969
-rw-r--r--src/lib/libcrypto/engine/hw_4758_cca_err.c149
-rw-r--r--src/lib/libcrypto/engine/hw_4758_cca_err.h93
-rw-r--r--src/lib/libcrypto/engine/hw_aep.c1120
-rw-r--r--src/lib/libcrypto/engine/hw_aep_err.c157
-rw-r--r--src/lib/libcrypto/engine/hw_atalla.c595
-rw-r--r--src/lib/libcrypto/engine/hw_atalla_err.c145
-rw-r--r--src/lib/libcrypto/engine/hw_cswift.c1109
-rw-r--r--src/lib/libcrypto/engine/hw_cswift_err.c149
-rw-r--r--src/lib/libcrypto/engine/hw_cswift_err.h93
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher.c1388
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher_err.c157
-rw-r--r--src/lib/libcrypto/engine/hw_ncipher_err.h101
-rw-r--r--src/lib/libcrypto/engine/hw_nuron.c418
-rw-r--r--src/lib/libcrypto/engine/hw_sureware.c1039
-rw-r--r--src/lib/libcrypto/engine/hw_sureware_err.c150
-rw-r--r--src/lib/libcrypto/engine/hw_sureware_err.h94
-rw-r--r--src/lib/libcrypto/engine/hw_ubsec.c1061
-rw-r--r--src/lib/libcrypto/engine/hw_ubsec_err.c151
-rw-r--r--src/lib/libcrypto/engine/hw_ubsec_err.h95
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/aep.h178
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/atalla.h48
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/cswift.h234
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/hw_4758_cca.h149
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/hw_ubsec.h100
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/hwcryptohook.h486
-rw-r--r--src/lib/libcrypto/engine/vendor_defns/sureware.h239
-rw-r--r--src/lib/libcrypto/err/err_def.c665
-rw-r--r--src/lib/libcrypto/err/err_str.c295
-rw-r--r--src/lib/libcrypto/evp/e_seed.c (renamed from src/lib/libcrypto/engine/hw_atalla_err.h)54
-rw-r--r--src/lib/libcrypto/evp/enc_min.c390
-rw-r--r--src/lib/libcrypto/evp/evp_fips.c113
-rw-r--r--src/lib/libcrypto/fips_err.h209
-rw-r--r--src/lib/libcrypto/fips_ers.c (renamed from src/lib/libcrypto/fips_err.c)0
-rw-r--r--src/lib/libcrypto/idea/idea_spd.c299
-rwxr-xr-xsrc/lib/libcrypto/install-crypto.com196
-rw-r--r--src/lib/libcrypto/install.com155
-rw-r--r--src/lib/libcrypto/jpake/Makefile64
-rw-r--r--src/lib/libcrypto/jpake/jpake.c511
-rw-r--r--src/lib/libcrypto/jpake/jpake.h131
-rw-r--r--src/lib/libcrypto/jpake/jpake_err.c (renamed from src/lib/libcrypto/engine/hw_nuron_err.c)91
-rw-r--r--src/lib/libcrypto/jpake/jpaketest.c192
-rw-r--r--src/lib/libcrypto/md5/asm/md5-sparcv9.S1031
-rw-r--r--src/lib/libcrypto/mdc2/mdc2_one.c (renamed from src/lib/libcrypto/err/err_bio.c)25
-rw-r--r--src/lib/libcrypto/mdc2/mdc2dgst.c (renamed from src/lib/libcrypto/rand/rand_eng.c)182
-rw-r--r--src/lib/libcrypto/modes/Makefile144
-rw-r--r--src/lib/libcrypto/o_dir.c (renamed from src/lib/libcrypto/engine/hw_nuron_err.h)55
-rw-r--r--src/lib/libcrypto/o_dir.h53
-rw-r--r--src/lib/libcrypto/o_dir_test.c70
-rw-r--r--src/lib/libcrypto/o_fips.c (renamed from src/lib/libcrypto/ec/ec2_smpt.c)54
-rw-r--r--src/lib/libcrypto/objects/obj_dat.h5102
-rw-r--r--src/lib/libcrypto/objects/obj_mac.h4032
-rw-r--r--src/lib/libcrypto/perlasm/alpha.pl434
-rw-r--r--src/lib/libcrypto/perlasm/x86masm.pl198
-rw-r--r--src/lib/libcrypto/perlasm/x86ms.pl472
-rw-r--r--src/lib/libcrypto/perlasm/x86unix.pl725
-rw-r--r--src/lib/libcrypto/pqueue/Makefile83
-rw-r--r--src/lib/libcrypto/pqueue/pq_compat.h152
-rw-r--r--src/lib/libcrypto/pqueue/pq_test.c95
-rw-r--r--src/lib/libcrypto/pqueue/pqueue.c252
-rw-r--r--src/lib/libcrypto/pqueue/pqueue.h94
-rw-r--r--src/lib/libcrypto/rand/rand_nw.c (renamed from src/lib/libcrypto/evp/dig_eng.c)131
-rw-r--r--src/lib/libcrypto/rc4/asm/rc4-ia64.S159
-rw-r--r--src/lib/libcrypto/rc4/rc4_utl.c (renamed from src/lib/libcrypto/rc4/rc4_fblk.c)33
-rw-r--r--src/lib/libcrypto/rc5/asm/rc5-586.pl110
-rw-r--r--src/lib/libcrypto/rc5/rc5_ecb.c (renamed from src/lib/libcrypto/bn/bn_opt.c)43
-rw-r--r--src/lib/libcrypto/rc5/rc5_enc.c (renamed from src/lib/libcrypto/asn1/a_hdr.c)184
-rw-r--r--src/lib/libcrypto/rc5/rc5_skey.c (renamed from src/lib/libcrypto/des/des_lib.c)89
-rw-r--r--src/lib/libcrypto/rc5/rc5cfb64.c (renamed from src/lib/libcrypto/asn1/a_meth.c)82
-rw-r--r--src/lib/libcrypto/rc5/rc5ofb64.c (renamed from src/lib/libcrypto/dsa/dsa_utl.c)78
-rw-r--r--src/lib/libcrypto/rc5/rc5speed.c (renamed from src/lib/libcrypto/tmdiff.c)319
-rw-r--r--src/lib/libcrypto/rsa/rsa_eng.c348
-rw-r--r--src/lib/libcrypto/rsa/rsa_x931g.c255
-rw-r--r--src/lib/libcrypto/seed/Makefile106
-rw-r--r--src/lib/libcrypto/seed/seed.c336
-rw-r--r--src/lib/libcrypto/seed/seed.h139
-rw-r--r--src/lib/libcrypto/seed/seed_cbc.c63
-rw-r--r--src/lib/libcrypto/seed/seed_cfb.c116
-rw-r--r--src/lib/libcrypto/seed/seed_ecb.c60
-rw-r--r--src/lib/libcrypto/seed/seed_locl.h116
-rw-r--r--src/lib/libcrypto/seed/seed_ofb.c (renamed from src/lib/libcrypto/asn1/p8_key.c)127
-rw-r--r--src/lib/libcrypto/sha/asm/sha512-sse2.pl404
-rw-r--r--src/lib/libcrypto/sha/sha1s.cpp82
-rw-r--r--src/lib/libcrypto/sha/sha256t.c147
-rw-r--r--src/lib/libcrypto/sha/sha512t.c184
-rw-r--r--src/lib/libcrypto/srp/Makefile98
-rw-r--r--src/lib/libcrypto/srp/srp.h172
-rw-r--r--src/lib/libcrypto/srp/srp_grps.h517
-rw-r--r--src/lib/libcrypto/srp/srp_lcl.h83
-rw-r--r--src/lib/libcrypto/srp/srp_lib.c361
-rw-r--r--src/lib/libcrypto/srp/srp_vfy.c658
-rw-r--r--src/lib/libcrypto/srp/srptest.c162
-rw-r--r--src/lib/libcrypto/store/Makefile112
-rw-r--r--src/lib/libcrypto/store/README95
-rw-r--r--src/lib/libcrypto/store/store.h561
-rw-r--r--src/lib/libcrypto/store/str_err.c211
-rw-r--r--src/lib/libcrypto/store/str_lib.c1828
-rw-r--r--src/lib/libcrypto/store/str_locl.h (renamed from src/lib/libcrypto/engine/hw_aep_err.h)101
-rw-r--r--src/lib/libcrypto/store/str_mem.c365
-rw-r--r--src/lib/libcrypto/store/str_meth.c250
-rw-r--r--src/lib/libcrypto/threads/netware.bat79
-rw-r--r--src/lib/libcrypto/threads/pthreads-vms.com14
-rw-r--r--src/lib/libcrypto/tmdiff.h93
-rw-r--r--src/lib/libcrypto/ts/Makefile269
-rw-r--r--src/lib/libcrypto/util/arx.pl15
-rw-r--r--src/lib/libcrypto/util/checkhash.pl222
-rw-r--r--src/lib/libcrypto/util/copy.pl70
-rw-r--r--src/lib/libcrypto/util/deltree.com34
-rw-r--r--src/lib/libcrypto/util/extract-section.pl12
-rw-r--r--src/lib/libcrypto/util/fipslink.pl78
-rwxr-xr-xsrc/lib/libcrypto/util/mkrc.pl71
-rw-r--r--src/lib/libcrypto/util/mksdef.pl87
-rw-r--r--src/lib/libcrypto/util/pl/BC-16.pl151
-rw-r--r--src/lib/libcrypto/util/pl/VC-16.pl177
-rw-r--r--src/lib/libcrypto/util/pl/VC-32-GMAKE.pl222
-rw-r--r--src/lib/libcrypto/util/pl/VC-CE.pl116
-rw-r--r--src/lib/libcrypto/util/pl/netware.pl532
-rwxr-xr-xsrc/lib/libcrypto/vms_rms.h51
-rw-r--r--src/lib/libcrypto/whrlpool/Makefile96
-rw-r--r--src/lib/libcrypto/whrlpool/wp_test.c228
-rw-r--r--src/lib/libcrypto/x509v3/v3_addr.c1338
-rw-r--r--src/lib/libcrypto/x509v3/v3_asid.c890
180 files changed, 17874 insertions, 42177 deletions
diff --git a/src/lib/libcrypto/LPdir_nyi.c b/src/lib/libcrypto/LPdir_nyi.c
new file mode 100644
index 0000000000..6c1a50e6a8
--- /dev/null
+++ b/src/lib/libcrypto/LPdir_nyi.c
@@ -0,0 +1,42 @@
1/* $LP: LPlib/source/LPdir_win.c,v 1.1 2004/06/14 10:07:56 _cvs_levitte Exp $ */
2/*
3 * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
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 *
15 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef LPDIR_H
29#include "LPdir.h"
30#endif
31
32struct LP_dir_context_st { void *dummy; };
33const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
34 {
35 errno = EINVAL;
36 return 0;
37 }
38int LP_find_file_end(LP_DIR_CTX **ctx)
39 {
40 errno = EINVAL;
41 return 0;
42 }
diff --git a/src/lib/libcrypto/LPdir_unix.c b/src/lib/libcrypto/LPdir_unix.c
new file mode 100644
index 0000000000..b004cd99e8
--- /dev/null
+++ b/src/lib/libcrypto/LPdir_unix.c
@@ -0,0 +1,127 @@
1/* $LP: LPlib/source/LPdir_unix.c,v 1.11 2004/09/23 22:07:22 _cvs_levitte Exp $ */
2/*
3 * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
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 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <stddef.h>
29#include <stdlib.h>
30#include <limits.h>
31#include <string.h>
32#include <sys/types.h>
33#include <dirent.h>
34#include <errno.h>
35#ifndef LPDIR_H
36#include "LPdir.h"
37#endif
38
39/* The POSIXly macro for the maximum number of characters in a file path
40 is NAME_MAX. However, some operating systems use PATH_MAX instead.
41 Therefore, it seems natural to first check for PATH_MAX and use that,
42 and if it doesn't exist, use NAME_MAX. */
43#if defined(PATH_MAX)
44# define LP_ENTRY_SIZE PATH_MAX
45#elif defined(NAME_MAX)
46# define LP_ENTRY_SIZE NAME_MAX
47#endif
48
49/* Of course, there's the possibility that neither PATH_MAX nor NAME_MAX
50 exist. It's also possible that NAME_MAX exists but is define to a
51 very small value (HP-UX offers 14), so we need to check if we got a
52 result, and if it meets a minimum standard, and create or change it
53 if not. */
54#if !defined(LP_ENTRY_SIZE) || LP_ENTRY_SIZE<255
55# undef LP_ENTRY_SIZE
56# define LP_ENTRY_SIZE 255
57#endif
58
59struct LP_dir_context_st
60{
61 DIR *dir;
62 char entry_name[LP_ENTRY_SIZE+1];
63};
64
65const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
66{
67 struct dirent *direntry = NULL;
68
69 if (ctx == NULL || directory == NULL)
70 {
71 errno = EINVAL;
72 return 0;
73 }
74
75 errno = 0;
76 if (*ctx == NULL)
77 {
78 *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
79 if (*ctx == NULL)
80 {
81 errno = ENOMEM;
82 return 0;
83 }
84 memset(*ctx, '\0', sizeof(LP_DIR_CTX));
85
86 (*ctx)->dir = opendir(directory);
87 if ((*ctx)->dir == NULL)
88 {
89 int save_errno = errno; /* Probably not needed, but I'm paranoid */
90 free(*ctx);
91 *ctx = NULL;
92 errno = save_errno;
93 return 0;
94 }
95 }
96
97 direntry = readdir((*ctx)->dir);
98 if (direntry == NULL)
99 {
100 return 0;
101 }
102
103 strncpy((*ctx)->entry_name, direntry->d_name, sizeof((*ctx)->entry_name) - 1);
104 (*ctx)->entry_name[sizeof((*ctx)->entry_name) - 1] = '\0';
105 return (*ctx)->entry_name;
106}
107
108int LP_find_file_end(LP_DIR_CTX **ctx)
109{
110 if (ctx != NULL && *ctx != NULL)
111 {
112 int ret = closedir((*ctx)->dir);
113
114 free(*ctx);
115 switch (ret)
116 {
117 case 0:
118 return 1;
119 case -1:
120 return 0;
121 default:
122 break;
123 }
124 }
125 errno = EINVAL;
126 return 0;
127}
diff --git a/src/lib/libcrypto/LPdir_vms.c b/src/lib/libcrypto/LPdir_vms.c
new file mode 100644
index 0000000000..7613bd254e
--- /dev/null
+++ b/src/lib/libcrypto/LPdir_vms.c
@@ -0,0 +1,206 @@
1/* $LP: LPlib/source/LPdir_vms.c,v 1.20 2004/08/26 13:36:05 _cvs_levitte Exp $ */
2/*
3 * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
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 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <stddef.h>
29#include <stdlib.h>
30#include <string.h>
31#include <errno.h>
32#include <descrip.h>
33#include <namdef.h>
34#include <rmsdef.h>
35#include <libfildef.h>
36#include <lib$routines.h>
37#include <strdef.h>
38#include <str$routines.h>
39#include <stsdef.h>
40#ifndef LPDIR_H
41#include "LPdir.h"
42#endif
43#include "vms_rms.h"
44
45/* Some compiler options hide EVMSERR. */
46#ifndef EVMSERR
47# define EVMSERR 65535 /* error for non-translatable VMS errors */
48#endif
49
50struct LP_dir_context_st
51{
52 unsigned long VMS_context;
53 char filespec[ NAMX_MAXRSS+ 1];
54 char result[ NAMX_MAXRSS+ 1];
55 struct dsc$descriptor_d filespec_dsc;
56 struct dsc$descriptor_d result_dsc;
57};
58
59const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
60{
61 int status;
62 char *p, *r;
63 size_t l;
64 unsigned long flags = 0;
65
66/* Arrange 32-bit pointer to (copied) string storage, if needed. */
67#if __INITIAL_POINTER_SIZE == 64
68# pragma pointer_size save
69# pragma pointer_size 32
70 char *ctx_filespec_32p;
71# pragma pointer_size restore
72 char ctx_filespec_32[ NAMX_MAXRSS+ 1];
73#endif /* __INITIAL_POINTER_SIZE == 64 */
74
75#ifdef NAML$C_MAXRSS
76 flags |= LIB$M_FIL_LONG_NAMES;
77#endif
78
79 if (ctx == NULL || directory == NULL)
80 {
81 errno = EINVAL;
82 return 0;
83 }
84
85 errno = 0;
86 if (*ctx == NULL)
87 {
88 size_t filespeclen = strlen(directory);
89 char *filespec = NULL;
90
91 /* MUST be a VMS directory specification! Let's estimate if it is. */
92 if (directory[filespeclen-1] != ']'
93 && directory[filespeclen-1] != '>'
94 && directory[filespeclen-1] != ':')
95 {
96 errno = EINVAL;
97 return 0;
98 }
99
100 filespeclen += 4; /* "*.*;" */
101
102 if (filespeclen > NAMX_MAXRSS)
103 {
104 errno = ENAMETOOLONG;
105 return 0;
106 }
107
108 *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
109 if (*ctx == NULL)
110 {
111 errno = ENOMEM;
112 return 0;
113 }
114 memset(*ctx, '\0', sizeof(LP_DIR_CTX));
115
116 strcpy((*ctx)->filespec,directory);
117 strcat((*ctx)->filespec,"*.*;");
118
119/* Arrange 32-bit pointer to (copied) string storage, if needed. */
120#if __INITIAL_POINTER_SIZE == 64
121# define CTX_FILESPEC ctx_filespec_32p
122 /* Copy the file name to storage with a 32-bit pointer. */
123 ctx_filespec_32p = ctx_filespec_32;
124 strcpy( ctx_filespec_32p, (*ctx)->filespec);
125#else /* __INITIAL_POINTER_SIZE == 64 */
126# define CTX_FILESPEC (*ctx)->filespec
127#endif /* __INITIAL_POINTER_SIZE == 64 [else] */
128
129 (*ctx)->filespec_dsc.dsc$w_length = filespeclen;
130 (*ctx)->filespec_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
131 (*ctx)->filespec_dsc.dsc$b_class = DSC$K_CLASS_S;
132 (*ctx)->filespec_dsc.dsc$a_pointer = CTX_FILESPEC;
133 }
134
135 (*ctx)->result_dsc.dsc$w_length = 0;
136 (*ctx)->result_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
137 (*ctx)->result_dsc.dsc$b_class = DSC$K_CLASS_D;
138 (*ctx)->result_dsc.dsc$a_pointer = 0;
139
140 status = lib$find_file(&(*ctx)->filespec_dsc, &(*ctx)->result_dsc,
141 &(*ctx)->VMS_context, 0, 0, 0, &flags);
142
143 if (status == RMS$_NMF)
144 {
145 errno = 0;
146 vaxc$errno = status;
147 return NULL;
148 }
149
150 if(!$VMS_STATUS_SUCCESS(status))
151 {
152 errno = EVMSERR;
153 vaxc$errno = status;
154 return NULL;
155 }
156
157 /* Quick, cheap and dirty way to discard any device and directory,
158 since we only want file names */
159 l = (*ctx)->result_dsc.dsc$w_length;
160 p = (*ctx)->result_dsc.dsc$a_pointer;
161 r = p;
162 for (; *p; p++)
163 {
164 if (*p == '^' && p[1] != '\0') /* Take care of ODS-5 escapes */
165 {
166 p++;
167 }
168 else if (*p == ':' || *p == '>' || *p == ']')
169 {
170 l -= p + 1 - r;
171 r = p + 1;
172 }
173 else if (*p == ';')
174 {
175 l = p - r;
176 break;
177 }
178 }
179
180 strncpy((*ctx)->result, r, l);
181 (*ctx)->result[l] = '\0';
182 str$free1_dx(&(*ctx)->result_dsc);
183
184 return (*ctx)->result;
185}
186
187int LP_find_file_end(LP_DIR_CTX **ctx)
188{
189 if (ctx != NULL && *ctx != NULL)
190 {
191 int status = lib$find_file_end(&(*ctx)->VMS_context);
192
193 free(*ctx);
194
195 if(!$VMS_STATUS_SUCCESS(status))
196 {
197 errno = EVMSERR;
198 vaxc$errno = status;
199 return 0;
200 }
201 return 1;
202 }
203 errno = EINVAL;
204 return 0;
205}
206
diff --git a/src/lib/libcrypto/LPdir_win.c b/src/lib/libcrypto/LPdir_win.c
new file mode 100644
index 0000000000..702dbc730f
--- /dev/null
+++ b/src/lib/libcrypto/LPdir_win.c
@@ -0,0 +1,153 @@
1/* $LP: LPlib/source/LPdir_win.c,v 1.10 2004/08/26 13:36:05 _cvs_levitte Exp $ */
2/*
3 * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
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 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27#include <windows.h>
28#include <tchar.h>
29#ifndef LPDIR_H
30#include "LPdir.h"
31#endif
32
33/* We're most likely overcautious here, but let's reserve for
34 broken WinCE headers and explicitly opt for UNICODE call.
35 Keep in mind that our WinCE builds are compiled with -DUNICODE
36 [as well as -D_UNICODE]. */
37#if defined(LP_SYS_WINCE) && !defined(FindFirstFile)
38# define FindFirstFile FindFirstFileW
39#endif
40#if defined(LP_SYS_WINCE) && !defined(FindFirstFile)
41# define FindNextFile FindNextFileW
42#endif
43
44#ifndef NAME_MAX
45#define NAME_MAX 255
46#endif
47
48struct LP_dir_context_st
49{
50 WIN32_FIND_DATA ctx;
51 HANDLE handle;
52 char entry_name[NAME_MAX+1];
53};
54
55const char *LP_find_file(LP_DIR_CTX **ctx, const char *directory)
56{
57 if (ctx == NULL || directory == NULL)
58 {
59 errno = EINVAL;
60 return 0;
61 }
62
63 errno = 0;
64 if (*ctx == NULL)
65 {
66 *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
67 if (*ctx == NULL)
68 {
69 errno = ENOMEM;
70 return 0;
71 }
72 memset(*ctx, '\0', sizeof(LP_DIR_CTX));
73
74 if (sizeof(TCHAR) != sizeof(char))
75 {
76 TCHAR *wdir = NULL;
77 /* len_0 denotes string length *with* trailing 0 */
78 size_t index = 0,len_0 = strlen(directory) + 1;
79
80 wdir = (TCHAR *)malloc(len_0 * sizeof(TCHAR));
81 if (wdir == NULL)
82 {
83 free(*ctx);
84 *ctx = NULL;
85 errno = ENOMEM;
86 return 0;
87 }
88
89#ifdef LP_MULTIBYTE_AVAILABLE
90 if (!MultiByteToWideChar(CP_ACP, 0, directory, len_0, (WCHAR *)wdir, len_0))
91#endif
92 for (index = 0; index < len_0; index++)
93 wdir[index] = (TCHAR)directory[index];
94
95 (*ctx)->handle = FindFirstFile(wdir, &(*ctx)->ctx);
96
97 free(wdir);
98 }
99 else
100 (*ctx)->handle = FindFirstFile((TCHAR *)directory, &(*ctx)->ctx);
101
102 if ((*ctx)->handle == INVALID_HANDLE_VALUE)
103 {
104 free(*ctx);
105 *ctx = NULL;
106 errno = EINVAL;
107 return 0;
108 }
109 }
110 else
111 {
112 if (FindNextFile((*ctx)->handle, &(*ctx)->ctx) == FALSE)
113 {
114 return 0;
115 }
116 }
117
118 if (sizeof(TCHAR) != sizeof(char))
119 {
120 TCHAR *wdir = (*ctx)->ctx.cFileName;
121 size_t index, len_0 = 0;
122
123 while (wdir[len_0] && len_0 < (sizeof((*ctx)->entry_name) - 1)) len_0++;
124 len_0++;
125
126#ifdef LP_MULTIBYTE_AVAILABLE
127 if (!WideCharToMultiByte(CP_ACP, 0, (WCHAR *)wdir, len_0, (*ctx)->entry_name,
128 sizeof((*ctx)->entry_name), NULL, 0))
129#endif
130 for (index = 0; index < len_0; index++)
131 (*ctx)->entry_name[index] = (char)wdir[index];
132 }
133 else
134 strncpy((*ctx)->entry_name, (const char *)(*ctx)->ctx.cFileName,
135 sizeof((*ctx)->entry_name)-1);
136
137 (*ctx)->entry_name[sizeof((*ctx)->entry_name)-1] = '\0';
138
139 return (*ctx)->entry_name;
140}
141
142int LP_find_file_end(LP_DIR_CTX **ctx)
143{
144 if (ctx != NULL && *ctx != NULL)
145 {
146 FindClose((*ctx)->handle);
147 free(*ctx);
148 *ctx = NULL;
149 return 1;
150 }
151 errno = EINVAL;
152 return 0;
153}
diff --git a/src/lib/libcrypto/LPdir_win32.c b/src/lib/libcrypto/LPdir_win32.c
new file mode 100644
index 0000000000..e39872da52
--- /dev/null
+++ b/src/lib/libcrypto/LPdir_win32.c
@@ -0,0 +1,30 @@
1/* $LP: LPlib/source/LPdir_win32.c,v 1.3 2004/08/26 13:36:05 _cvs_levitte Exp $ */
2/*
3 * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
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 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#define LP_SYS_WIN32
29#define LP_MULTIBYTE_AVAILABLE
30#include "LPdir_win.c"
diff --git a/src/lib/libcrypto/LPdir_wince.c b/src/lib/libcrypto/LPdir_wince.c
new file mode 100644
index 0000000000..ab0e1e6f4f
--- /dev/null
+++ b/src/lib/libcrypto/LPdir_wince.c
@@ -0,0 +1,31 @@
1/* $LP: LPlib/source/LPdir_wince.c,v 1.3 2004/08/26 13:36:05 _cvs_levitte Exp $ */
2/*
3 * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
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 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#define LP_SYS_WINCE
29/* We might want to define LP_MULTIBYTE_AVAILABLE here. It's currently
30 under investigation what the exact conditions would be */
31#include "LPdir_win.c"
diff --git a/src/lib/libcrypto/bio/bio_lcl.h b/src/lib/libcrypto/bio/bio_lcl.h
new file mode 100644
index 0000000000..e7f7ec8d8b
--- /dev/null
+++ b/src/lib/libcrypto/bio/bio_lcl.h
@@ -0,0 +1,36 @@
1#include <openssl/bio.h>
2
3#if BIO_FLAGS_UPLINK==0
4/* Shortcut UPLINK calls on most platforms... */
5#define UP_stdin stdin
6#define UP_stdout stdout
7#define UP_stderr stderr
8#define UP_fprintf fprintf
9#define UP_fgets fgets
10#define UP_fread fread
11#define UP_fwrite fwrite
12#undef UP_fsetmod
13#define UP_feof feof
14#define UP_fclose fclose
15
16#define UP_fopen fopen
17#define UP_fseek fseek
18#define UP_ftell ftell
19#define UP_fflush fflush
20#define UP_ferror ferror
21#ifdef _WIN32
22#define UP_fileno _fileno
23#define UP_open _open
24#define UP_read _read
25#define UP_write _write
26#define UP_lseek _lseek
27#define UP_close _close
28#else
29#define UP_fileno fileno
30#define UP_open open
31#define UP_read read
32#define UP_write write
33#define UP_lseek lseek
34#define UP_close close
35#endif
36#endif
diff --git a/src/lib/libcrypto/bn/asm/alpha.s b/src/lib/libcrypto/bn/asm/alpha.s
deleted file mode 100644
index 555ff0b92d..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.s
+++ /dev/null
@@ -1,3199 +0,0 @@
1 # DEC Alpha assember
2 # The bn_div_words is actually gcc output but the other parts are hand done.
3 # Thanks to tzeruch@ceddec.com for sending me the gcc output for
4 # bn_div_words.
5 # I've gone back and re-done most of routines.
6 # The key thing to remeber for the 164 CPU is that while a
7 # multiply operation takes 8 cycles, another one can only be issued
8 # after 4 cycles have elapsed. I've done modification to help
9 # improve this. Also, normally, a ld instruction will not be available
10 # for about 3 cycles.
11 .file 1 "bn_asm.c"
12 .set noat
13gcc2_compiled.:
14__gnu_compiled_c:
15 .text
16 .align 3
17 .globl bn_mul_add_words
18 .ent bn_mul_add_words
19bn_mul_add_words:
20bn_mul_add_words..ng:
21 .frame $30,0,$26,0
22 .prologue 0
23 .align 5
24 subq $18,4,$18
25 bis $31,$31,$0
26 blt $18,$43 # if we are -1, -2, -3 or -4 goto tail code
27 ldq $20,0($17) # 1 1
28 ldq $1,0($16) # 1 1
29 .align 3
30$42:
31 mulq $20,$19,$5 # 1 2 1 ######
32 ldq $21,8($17) # 2 1
33 ldq $2,8($16) # 2 1
34 umulh $20,$19,$20 # 1 2 ######
35 ldq $27,16($17) # 3 1
36 ldq $3,16($16) # 3 1
37 mulq $21,$19,$6 # 2 2 1 ######
38 ldq $28,24($17) # 4 1
39 addq $1,$5,$1 # 1 2 2
40 ldq $4,24($16) # 4 1
41 umulh $21,$19,$21 # 2 2 ######
42 cmpult $1,$5,$22 # 1 2 3 1
43 addq $20,$22,$20 # 1 3 1
44 addq $1,$0,$1 # 1 2 3 1
45 mulq $27,$19,$7 # 3 2 1 ######
46 cmpult $1,$0,$0 # 1 2 3 2
47 addq $2,$6,$2 # 2 2 2
48 addq $20,$0,$0 # 1 3 2
49 cmpult $2,$6,$23 # 2 2 3 1
50 addq $21,$23,$21 # 2 3 1
51 umulh $27,$19,$27 # 3 2 ######
52 addq $2,$0,$2 # 2 2 3 1
53 cmpult $2,$0,$0 # 2 2 3 2
54 subq $18,4,$18
55 mulq $28,$19,$8 # 4 2 1 ######
56 addq $21,$0,$0 # 2 3 2
57 addq $3,$7,$3 # 3 2 2
58 addq $16,32,$16
59 cmpult $3,$7,$24 # 3 2 3 1
60 stq $1,-32($16) # 1 2 4
61 umulh $28,$19,$28 # 4 2 ######
62 addq $27,$24,$27 # 3 3 1
63 addq $3,$0,$3 # 3 2 3 1
64 stq $2,-24($16) # 2 2 4
65 cmpult $3,$0,$0 # 3 2 3 2
66 stq $3,-16($16) # 3 2 4
67 addq $4,$8,$4 # 4 2 2
68 addq $27,$0,$0 # 3 3 2
69 cmpult $4,$8,$25 # 4 2 3 1
70 addq $17,32,$17
71 addq $28,$25,$28 # 4 3 1
72 addq $4,$0,$4 # 4 2 3 1
73 cmpult $4,$0,$0 # 4 2 3 2
74 stq $4,-8($16) # 4 2 4
75 addq $28,$0,$0 # 4 3 2
76 blt $18,$43
77
78 ldq $20,0($17) # 1 1
79 ldq $1,0($16) # 1 1
80
81 br $42
82
83 .align 4
84$45:
85 ldq $20,0($17) # 4 1
86 ldq $1,0($16) # 4 1
87 mulq $20,$19,$5 # 4 2 1
88 subq $18,1,$18
89 addq $16,8,$16
90 addq $17,8,$17
91 umulh $20,$19,$20 # 4 2
92 addq $1,$5,$1 # 4 2 2
93 cmpult $1,$5,$22 # 4 2 3 1
94 addq $20,$22,$20 # 4 3 1
95 addq $1,$0,$1 # 4 2 3 1
96 cmpult $1,$0,$0 # 4 2 3 2
97 addq $20,$0,$0 # 4 3 2
98 stq $1,-8($16) # 4 2 4
99 bgt $18,$45
100 ret $31,($26),1 # else exit
101
102 .align 4
103$43:
104 addq $18,4,$18
105 bgt $18,$45 # goto tail code
106 ret $31,($26),1 # else exit
107
108 .end bn_mul_add_words
109 .align 3
110 .globl bn_mul_words
111 .ent bn_mul_words
112bn_mul_words:
113bn_mul_words..ng:
114 .frame $30,0,$26,0
115 .prologue 0
116 .align 5
117 subq $18,4,$18
118 bis $31,$31,$0
119 blt $18,$143 # if we are -1, -2, -3 or -4 goto tail code
120 ldq $20,0($17) # 1 1
121 .align 3
122$142:
123
124 mulq $20,$19,$5 # 1 2 1 #####
125 ldq $21,8($17) # 2 1
126 ldq $27,16($17) # 3 1
127 umulh $20,$19,$20 # 1 2 #####
128 ldq $28,24($17) # 4 1
129 mulq $21,$19,$6 # 2 2 1 #####
130 addq $5,$0,$5 # 1 2 3 1
131 subq $18,4,$18
132 cmpult $5,$0,$0 # 1 2 3 2
133 umulh $21,$19,$21 # 2 2 #####
134 addq $20,$0,$0 # 1 3 2
135 addq $17,32,$17
136 addq $6,$0,$6 # 2 2 3 1
137 mulq $27,$19,$7 # 3 2 1 #####
138 cmpult $6,$0,$0 # 2 2 3 2
139 addq $21,$0,$0 # 2 3 2
140 addq $16,32,$16
141 umulh $27,$19,$27 # 3 2 #####
142 stq $5,-32($16) # 1 2 4
143 mulq $28,$19,$8 # 4 2 1 #####
144 addq $7,$0,$7 # 3 2 3 1
145 stq $6,-24($16) # 2 2 4
146 cmpult $7,$0,$0 # 3 2 3 2
147 umulh $28,$19,$28 # 4 2 #####
148 addq $27,$0,$0 # 3 3 2
149 stq $7,-16($16) # 3 2 4
150 addq $8,$0,$8 # 4 2 3 1
151 cmpult $8,$0,$0 # 4 2 3 2
152
153 addq $28,$0,$0 # 4 3 2
154
155 stq $8,-8($16) # 4 2 4
156
157 blt $18,$143
158
159 ldq $20,0($17) # 1 1
160
161 br $142
162
163 .align 4
164$145:
165 ldq $20,0($17) # 4 1
166 mulq $20,$19,$5 # 4 2 1
167 subq $18,1,$18
168 umulh $20,$19,$20 # 4 2
169 addq $5,$0,$5 # 4 2 3 1
170 addq $16,8,$16
171 cmpult $5,$0,$0 # 4 2 3 2
172 addq $17,8,$17
173 addq $20,$0,$0 # 4 3 2
174 stq $5,-8($16) # 4 2 4
175
176 bgt $18,$145
177 ret $31,($26),1 # else exit
178
179 .align 4
180$143:
181 addq $18,4,$18
182 bgt $18,$145 # goto tail code
183 ret $31,($26),1 # else exit
184
185 .end bn_mul_words
186 .align 3
187 .globl bn_sqr_words
188 .ent bn_sqr_words
189bn_sqr_words:
190bn_sqr_words..ng:
191 .frame $30,0,$26,0
192 .prologue 0
193
194 subq $18,4,$18
195 blt $18,$543 # if we are -1, -2, -3 or -4 goto tail code
196 ldq $20,0($17) # 1 1
197 .align 3
198$542:
199 mulq $20,$20,$5 ######
200 ldq $21,8($17) # 1 1
201 subq $18,4
202 umulh $20,$20,$1 ######
203 ldq $27,16($17) # 1 1
204 mulq $21,$21,$6 ######
205 ldq $28,24($17) # 1 1
206 stq $5,0($16) # r[0]
207 umulh $21,$21,$2 ######
208 stq $1,8($16) # r[1]
209 mulq $27,$27,$7 ######
210 stq $6,16($16) # r[0]
211 umulh $27,$27,$3 ######
212 stq $2,24($16) # r[1]
213 mulq $28,$28,$8 ######
214 stq $7,32($16) # r[0]
215 umulh $28,$28,$4 ######
216 stq $3,40($16) # r[1]
217
218 addq $16,64,$16
219 addq $17,32,$17
220 stq $8,-16($16) # r[0]
221 stq $4,-8($16) # r[1]
222
223 blt $18,$543
224 ldq $20,0($17) # 1 1
225 br $542
226
227$442:
228 ldq $20,0($17) # a[0]
229 mulq $20,$20,$5 # a[0]*w low part r2
230 addq $16,16,$16
231 addq $17,8,$17
232 subq $18,1,$18
233 umulh $20,$20,$1 # a[0]*w high part r3
234 stq $5,-16($16) # r[0]
235 stq $1,-8($16) # r[1]
236
237 bgt $18,$442
238 ret $31,($26),1 # else exit
239
240 .align 4
241$543:
242 addq $18,4,$18
243 bgt $18,$442 # goto tail code
244 ret $31,($26),1 # else exit
245 .end bn_sqr_words
246
247 .align 3
248 .globl bn_add_words
249 .ent bn_add_words
250bn_add_words:
251bn_add_words..ng:
252 .frame $30,0,$26,0
253 .prologue 0
254
255 subq $19,4,$19
256 bis $31,$31,$0 # carry = 0
257 blt $19,$900
258 ldq $5,0($17) # a[0]
259 ldq $1,0($18) # b[1]
260 .align 3
261$901:
262 addq $1,$5,$1 # r=a+b;
263 ldq $6,8($17) # a[1]
264 cmpult $1,$5,$22 # did we overflow?
265 ldq $2,8($18) # b[1]
266 addq $1,$0,$1 # c+= overflow
267 ldq $7,16($17) # a[2]
268 cmpult $1,$0,$0 # overflow?
269 ldq $3,16($18) # b[2]
270 addq $0,$22,$0
271 ldq $8,24($17) # a[3]
272 addq $2,$6,$2 # r=a+b;
273 ldq $4,24($18) # b[3]
274 cmpult $2,$6,$23 # did we overflow?
275 addq $3,$7,$3 # r=a+b;
276 addq $2,$0,$2 # c+= overflow
277 cmpult $3,$7,$24 # did we overflow?
278 cmpult $2,$0,$0 # overflow?
279 addq $4,$8,$4 # r=a+b;
280 addq $0,$23,$0
281 cmpult $4,$8,$25 # did we overflow?
282 addq $3,$0,$3 # c+= overflow
283 stq $1,0($16) # r[0]=c
284 cmpult $3,$0,$0 # overflow?
285 stq $2,8($16) # r[1]=c
286 addq $0,$24,$0
287 stq $3,16($16) # r[2]=c
288 addq $4,$0,$4 # c+= overflow
289 subq $19,4,$19 # loop--
290 cmpult $4,$0,$0 # overflow?
291 addq $17,32,$17 # a++
292 addq $0,$25,$0
293 stq $4,24($16) # r[3]=c
294 addq $18,32,$18 # b++
295 addq $16,32,$16 # r++
296
297 blt $19,$900
298 ldq $5,0($17) # a[0]
299 ldq $1,0($18) # b[1]
300 br $901
301 .align 4
302$945:
303 ldq $5,0($17) # a[0]
304 ldq $1,0($18) # b[1]
305 addq $1,$5,$1 # r=a+b;
306 subq $19,1,$19 # loop--
307 addq $1,$0,$1 # c+= overflow
308 addq $17,8,$17 # a++
309 cmpult $1,$5,$22 # did we overflow?
310 cmpult $1,$0,$0 # overflow?
311 addq $18,8,$18 # b++
312 stq $1,0($16) # r[0]=c
313 addq $0,$22,$0
314 addq $16,8,$16 # r++
315
316 bgt $19,$945
317 ret $31,($26),1 # else exit
318
319$900:
320 addq $19,4,$19
321 bgt $19,$945 # goto tail code
322 ret $31,($26),1 # else exit
323 .end bn_add_words
324
325 #
326 # What follows was taken directly from the C compiler with a few
327 # hacks to redo the lables.
328 #
329.text
330 .align 3
331 .globl bn_div_words
332 .ent bn_div_words
333bn_div_words:
334 ldgp $29,0($27)
335bn_div_words..ng:
336 lda $30,-48($30)
337 .frame $30,48,$26,0
338 stq $26,0($30)
339 stq $9,8($30)
340 stq $10,16($30)
341 stq $11,24($30)
342 stq $12,32($30)
343 stq $13,40($30)
344 .mask 0x4003e00,-48
345 .prologue 1
346 bis $16,$16,$9
347 bis $17,$17,$10
348 bis $18,$18,$11
349 bis $31,$31,$13
350 bis $31,2,$12
351 bne $11,$119
352 lda $0,-1
353 br $31,$136
354 .align 4
355$119:
356 bis $11,$11,$16
357 jsr $26,BN_num_bits_word
358 ldgp $29,0($26)
359 subq $0,64,$1
360 beq $1,$120
361 bis $31,1,$1
362 sll $1,$0,$1
363 cmpule $9,$1,$1
364 bne $1,$120
365 # lda $16,_IO_stderr_
366 # lda $17,$C32
367 # bis $0,$0,$18
368 # jsr $26,fprintf
369 # ldgp $29,0($26)
370 jsr $26,abort
371 ldgp $29,0($26)
372 .align 4
373$120:
374 bis $31,64,$3
375 cmpult $9,$11,$2
376 subq $3,$0,$1
377 addl $1,$31,$0
378 subq $9,$11,$1
379 cmoveq $2,$1,$9
380 beq $0,$122
381 zapnot $0,15,$2
382 subq $3,$0,$1
383 sll $11,$2,$11
384 sll $9,$2,$3
385 srl $10,$1,$1
386 sll $10,$2,$10
387 bis $3,$1,$9
388$122:
389 srl $11,32,$5
390 zapnot $11,15,$6
391 lda $7,-1
392 .align 5
393$123:
394 srl $9,32,$1
395 subq $1,$5,$1
396 bne $1,$126
397 zapnot $7,15,$27
398 br $31,$127
399 .align 4
400$126:
401 bis $9,$9,$24
402 bis $5,$5,$25
403 divqu $24,$25,$27
404$127:
405 srl $10,32,$4
406 .align 5
407$128:
408 mulq $27,$5,$1
409 subq $9,$1,$3
410 zapnot $3,240,$1
411 bne $1,$129
412 mulq $6,$27,$2
413 sll $3,32,$1
414 addq $1,$4,$1
415 cmpule $2,$1,$2
416 bne $2,$129
417 subq $27,1,$27
418 br $31,$128
419 .align 4
420$129:
421 mulq $27,$6,$1
422 mulq $27,$5,$4
423 srl $1,32,$3
424 sll $1,32,$1
425 addq $4,$3,$4
426 cmpult $10,$1,$2
427 subq $10,$1,$10
428 addq $2,$4,$2
429 cmpult $9,$2,$1
430 bis $2,$2,$4
431 beq $1,$134
432 addq $9,$11,$9
433 subq $27,1,$27
434$134:
435 subl $12,1,$12
436 subq $9,$4,$9
437 beq $12,$124
438 sll $27,32,$13
439 sll $9,32,$2
440 srl $10,32,$1
441 sll $10,32,$10
442 bis $2,$1,$9
443 br $31,$123
444 .align 4
445$124:
446 bis $13,$27,$0
447$136:
448 ldq $26,0($30)
449 ldq $9,8($30)
450 ldq $10,16($30)
451 ldq $11,24($30)
452 ldq $12,32($30)
453 ldq $13,40($30)
454 addq $30,48,$30
455 ret $31,($26),1
456 .end bn_div_words
457
458 .set noat
459 .text
460 .align 3
461 .globl bn_sub_words
462 .ent bn_sub_words
463bn_sub_words:
464bn_sub_words..ng:
465 .frame $30,0,$26,0
466 .prologue 0
467
468 subq $19, 4, $19
469 bis $31, $31, $0
470 blt $19, $100
471 ldq $1, 0($17)
472 ldq $2, 0($18)
473$101:
474 ldq $3, 8($17)
475 cmpult $1, $2, $4
476 ldq $5, 8($18)
477 subq $1, $2, $1
478 ldq $6, 16($17)
479 cmpult $1, $0, $2
480 ldq $7, 16($18)
481 subq $1, $0, $23
482 ldq $8, 24($17)
483 addq $2, $4, $0
484 cmpult $3, $5, $24
485 subq $3, $5, $3
486 ldq $22, 24($18)
487 cmpult $3, $0, $5
488 subq $3, $0, $25
489 addq $5, $24, $0
490 cmpult $6, $7, $27
491 subq $6, $7, $6
492 stq $23, 0($16)
493 cmpult $6, $0, $7
494 subq $6, $0, $28
495 addq $7, $27, $0
496 cmpult $8, $22, $21
497 subq $8, $22, $8
498 stq $25, 8($16)
499 cmpult $8, $0, $22
500 subq $8, $0, $20
501 addq $22, $21, $0
502 stq $28, 16($16)
503 subq $19, 4, $19
504 stq $20, 24($16)
505 addq $17, 32, $17
506 addq $18, 32, $18
507 addq $16, 32, $16
508 blt $19, $100
509 ldq $1, 0($17)
510 ldq $2, 0($18)
511 br $101
512$102:
513 ldq $1, 0($17)
514 ldq $2, 0($18)
515 cmpult $1, $2, $27
516 subq $1, $2, $1
517 cmpult $1, $0, $2
518 subq $1, $0, $1
519 stq $1, 0($16)
520 addq $2, $27, $0
521 addq $17, 8, $17
522 addq $18, 8, $18
523 addq $16, 8, $16
524 subq $19, 1, $19
525 bgt $19, $102
526 ret $31,($26),1
527$100:
528 addq $19, 4, $19
529 bgt $19, $102
530$103:
531 ret $31,($26),1
532 .end bn_sub_words
533 .text
534 .align 3
535 .globl bn_mul_comba4
536 .ent bn_mul_comba4
537bn_mul_comba4:
538bn_mul_comba4..ng:
539 .frame $30,0,$26,0
540 .prologue 0
541
542 ldq $0, 0($17)
543 ldq $1, 0($18)
544 ldq $2, 8($17)
545 ldq $3, 8($18)
546 ldq $4, 16($17)
547 ldq $5, 16($18)
548 ldq $6, 24($17)
549 ldq $7, 24($18)
550 bis $31, $31, $23
551 mulq $0, $1, $8
552 umulh $0, $1, $22
553 stq $8, 0($16)
554 bis $31, $31, $8
555 mulq $0, $3, $24
556 umulh $0, $3, $25
557 addq $22, $24, $22
558 cmpult $22, $24, $27
559 addq $27, $25, $25
560 addq $23, $25, $23
561 cmpult $23, $25, $28
562 addq $8, $28, $8
563 mulq $2, $1, $21
564 umulh $2, $1, $20
565 addq $22, $21, $22
566 cmpult $22, $21, $19
567 addq $19, $20, $20
568 addq $23, $20, $23
569 cmpult $23, $20, $17
570 addq $8, $17, $8
571 stq $22, 8($16)
572 bis $31, $31, $22
573 mulq $2, $3, $18
574 umulh $2, $3, $24
575 addq $23, $18, $23
576 cmpult $23, $18, $27
577 addq $27, $24, $24
578 addq $8, $24, $8
579 cmpult $8, $24, $25
580 addq $22, $25, $22
581 mulq $0, $5, $28
582 umulh $0, $5, $21
583 addq $23, $28, $23
584 cmpult $23, $28, $19
585 addq $19, $21, $21
586 addq $8, $21, $8
587 cmpult $8, $21, $20
588 addq $22, $20, $22
589 mulq $4, $1, $17
590 umulh $4, $1, $18
591 addq $23, $17, $23
592 cmpult $23, $17, $27
593 addq $27, $18, $18
594 addq $8, $18, $8
595 cmpult $8, $18, $24
596 addq $22, $24, $22
597 stq $23, 16($16)
598 bis $31, $31, $23
599 mulq $0, $7, $25
600 umulh $0, $7, $28
601 addq $8, $25, $8
602 cmpult $8, $25, $19
603 addq $19, $28, $28
604 addq $22, $28, $22
605 cmpult $22, $28, $21
606 addq $23, $21, $23
607 mulq $2, $5, $20
608 umulh $2, $5, $17
609 addq $8, $20, $8
610 cmpult $8, $20, $27
611 addq $27, $17, $17
612 addq $22, $17, $22
613 cmpult $22, $17, $18
614 addq $23, $18, $23
615 mulq $4, $3, $24
616 umulh $4, $3, $25
617 addq $8, $24, $8
618 cmpult $8, $24, $19
619 addq $19, $25, $25
620 addq $22, $25, $22
621 cmpult $22, $25, $28
622 addq $23, $28, $23
623 mulq $6, $1, $21
624 umulh $6, $1, $0
625 addq $8, $21, $8
626 cmpult $8, $21, $20
627 addq $20, $0, $0
628 addq $22, $0, $22
629 cmpult $22, $0, $27
630 addq $23, $27, $23
631 stq $8, 24($16)
632 bis $31, $31, $8
633 mulq $2, $7, $17
634 umulh $2, $7, $18
635 addq $22, $17, $22
636 cmpult $22, $17, $24
637 addq $24, $18, $18
638 addq $23, $18, $23
639 cmpult $23, $18, $19
640 addq $8, $19, $8
641 mulq $4, $5, $25
642 umulh $4, $5, $28
643 addq $22, $25, $22
644 cmpult $22, $25, $21
645 addq $21, $28, $28
646 addq $23, $28, $23
647 cmpult $23, $28, $20
648 addq $8, $20, $8
649 mulq $6, $3, $0
650 umulh $6, $3, $27
651 addq $22, $0, $22
652 cmpult $22, $0, $1
653 addq $1, $27, $27
654 addq $23, $27, $23
655 cmpult $23, $27, $17
656 addq $8, $17, $8
657 stq $22, 32($16)
658 bis $31, $31, $22
659 mulq $4, $7, $24
660 umulh $4, $7, $18
661 addq $23, $24, $23
662 cmpult $23, $24, $19
663 addq $19, $18, $18
664 addq $8, $18, $8
665 cmpult $8, $18, $2
666 addq $22, $2, $22
667 mulq $6, $5, $25
668 umulh $6, $5, $21
669 addq $23, $25, $23
670 cmpult $23, $25, $28
671 addq $28, $21, $21
672 addq $8, $21, $8
673 cmpult $8, $21, $20
674 addq $22, $20, $22
675 stq $23, 40($16)
676 bis $31, $31, $23
677 mulq $6, $7, $0
678 umulh $6, $7, $1
679 addq $8, $0, $8
680 cmpult $8, $0, $27
681 addq $27, $1, $1
682 addq $22, $1, $22
683 cmpult $22, $1, $17
684 addq $23, $17, $23
685 stq $8, 48($16)
686 stq $22, 56($16)
687 ret $31,($26),1
688 .end bn_mul_comba4
689 .text
690 .align 3
691 .globl bn_mul_comba8
692 .ent bn_mul_comba8
693bn_mul_comba8:
694bn_mul_comba8..ng:
695 .frame $30,0,$26,0
696 .prologue 0
697 ldq $1, 0($17)
698 ldq $2, 0($18)
699 zapnot $1, 15, $7
700 srl $2, 32, $8
701 mulq $8, $7, $22
702 srl $1, 32, $6
703 zapnot $2, 15, $5
704 mulq $5, $6, $4
705 mulq $7, $5, $24
706 addq $22, $4, $22
707 cmpult $22, $4, $1
708 mulq $6, $8, $3
709 beq $1, $173
710 bis $31, 1, $1
711 sll $1, 32, $1
712 addq $3, $1, $3
713$173:
714 sll $22, 32, $4
715 addq $24, $4, $24
716 stq $24, 0($16)
717 ldq $2, 0($17)
718 ldq $1, 8($18)
719 zapnot $2, 15, $7
720 srl $1, 32, $8
721 mulq $8, $7, $25
722 zapnot $1, 15, $5
723 mulq $7, $5, $0
724 srl $2, 32, $6
725 mulq $5, $6, $23
726 mulq $6, $8, $6
727 srl $22, 32, $1
728 cmpult $24, $4, $2
729 addq $3, $1, $3
730 addq $2, $3, $22
731 addq $25, $23, $25
732 cmpult $25, $23, $1
733 bis $31, 1, $2
734 beq $1, $177
735 sll $2, 32, $1
736 addq $6, $1, $6
737$177:
738 sll $25, 32, $23
739 ldq $1, 0($18)
740 addq $0, $23, $0
741 bis $0, $0, $7
742 ldq $3, 8($17)
743 addq $22, $7, $22
744 srl $1, 32, $8
745 cmpult $22, $7, $4
746 zapnot $3, 15, $7
747 mulq $8, $7, $28
748 zapnot $1, 15, $5
749 mulq $7, $5, $21
750 srl $25, 32, $1
751 cmpult $0, $23, $2
752 addq $6, $1, $6
753 addq $2, $6, $6
754 addq $4, $6, $24
755 srl $3, 32, $6
756 mulq $5, $6, $2
757 mulq $6, $8, $6
758 addq $28, $2, $28
759 cmpult $28, $2, $1
760 bis $31, 1, $2
761 beq $1, $181
762 sll $2, 32, $1
763 addq $6, $1, $6
764$181:
765 sll $28, 32, $2
766 addq $21, $2, $21
767 bis $21, $21, $7
768 addq $22, $7, $22
769 stq $22, 8($16)
770 ldq $3, 16($17)
771 ldq $1, 0($18)
772 cmpult $22, $7, $4
773 zapnot $3, 15, $7
774 srl $1, 32, $8
775 mulq $8, $7, $22
776 zapnot $1, 15, $5
777 mulq $7, $5, $20
778 srl $28, 32, $1
779 cmpult $21, $2, $2
780 addq $6, $1, $6
781 addq $2, $6, $6
782 addq $4, $6, $6
783 addq $24, $6, $24
784 cmpult $24, $6, $23
785 srl $3, 32, $6
786 mulq $5, $6, $2
787 mulq $6, $8, $6
788 addq $22, $2, $22
789 cmpult $22, $2, $1
790 bis $31, 1, $2
791 beq $1, $185
792 sll $2, 32, $1
793 addq $6, $1, $6
794$185:
795 sll $22, 32, $2
796 ldq $1, 8($18)
797 addq $20, $2, $20
798 bis $20, $20, $7
799 ldq $4, 8($17)
800 addq $24, $7, $24
801 srl $1, 32, $8
802 cmpult $24, $7, $3
803 zapnot $4, 15, $7
804 mulq $8, $7, $25
805 zapnot $1, 15, $5
806 mulq $7, $5, $0
807 srl $22, 32, $1
808 cmpult $20, $2, $2
809 addq $6, $1, $6
810 addq $2, $6, $6
811 addq $3, $6, $6
812 addq $23, $6, $23
813 cmpult $23, $6, $22
814 srl $4, 32, $6
815 mulq $5, $6, $5
816 bis $31, 1, $21
817 addq $25, $5, $25
818 cmpult $25, $5, $1
819 mulq $6, $8, $6
820 beq $1, $189
821 sll $21, 32, $1
822 addq $6, $1, $6
823$189:
824 sll $25, 32, $5
825 ldq $2, 16($18)
826 addq $0, $5, $0
827 bis $0, $0, $7
828 ldq $4, 0($17)
829 addq $24, $7, $24
830 srl $2, 32, $8
831 cmpult $24, $7, $3
832 zapnot $4, 15, $7
833 mulq $8, $7, $28
834 srl $25, 32, $1
835 addq $6, $1, $6
836 cmpult $0, $5, $1
837 zapnot $2, 15, $5
838 addq $1, $6, $6
839 addq $3, $6, $6
840 addq $23, $6, $23
841 cmpult $23, $6, $1
842 srl $4, 32, $6
843 mulq $5, $6, $25
844 mulq $7, $5, $2
845 addq $1, $22, $22
846 addq $28, $25, $28
847 cmpult $28, $25, $1
848 mulq $6, $8, $6
849 beq $1, $193
850 sll $21, 32, $1
851 addq $6, $1, $6
852$193:
853 sll $28, 32, $25
854 addq $2, $25, $2
855 bis $2, $2, $7
856 addq $24, $7, $24
857 stq $24, 16($16)
858 ldq $4, 0($17)
859 ldq $5, 24($18)
860 cmpult $24, $7, $3
861 zapnot $4, 15, $7
862 srl $5, 32, $8
863 mulq $8, $7, $0
864 srl $28, 32, $1
865 cmpult $2, $25, $2
866 addq $6, $1, $6
867 addq $2, $6, $6
868 addq $3, $6, $6
869 addq $23, $6, $23
870 cmpult $23, $6, $1
871 srl $4, 32, $6
872 zapnot $5, 15, $5
873 mulq $5, $6, $24
874 mulq $7, $5, $2
875 addq $1, $22, $22
876 addq $0, $24, $0
877 cmpult $0, $24, $1
878 mulq $6, $8, $6
879 beq $1, $197
880 sll $21, 32, $1
881 addq $6, $1, $6
882$197:
883 sll $0, 32, $24
884 ldq $1, 16($18)
885 addq $2, $24, $2
886 bis $2, $2, $7
887 ldq $4, 8($17)
888 addq $23, $7, $23
889 srl $1, 32, $8
890 cmpult $23, $7, $3
891 zapnot $4, 15, $7
892 mulq $8, $7, $25
893 zapnot $1, 15, $5
894 mulq $7, $5, $21
895 srl $0, 32, $1
896 cmpult $2, $24, $2
897 addq $6, $1, $6
898 addq $2, $6, $6
899 addq $3, $6, $6
900 addq $22, $6, $22
901 cmpult $22, $6, $24
902 srl $4, 32, $6
903 mulq $5, $6, $5
904 bis $31, 1, $20
905 addq $25, $5, $25
906 cmpult $25, $5, $1
907 mulq $6, $8, $6
908 beq $1, $201
909 sll $20, 32, $1
910 addq $6, $1, $6
911$201:
912 sll $25, 32, $5
913 ldq $2, 8($18)
914 addq $21, $5, $21
915 bis $21, $21, $7
916 ldq $4, 16($17)
917 addq $23, $7, $23
918 srl $2, 32, $8
919 cmpult $23, $7, $3
920 zapnot $4, 15, $7
921 mulq $8, $7, $28
922 srl $25, 32, $1
923 addq $6, $1, $6
924 cmpult $21, $5, $1
925 zapnot $2, 15, $5
926 addq $1, $6, $6
927 addq $3, $6, $6
928 addq $22, $6, $22
929 cmpult $22, $6, $1
930 srl $4, 32, $6
931 mulq $5, $6, $25
932 mulq $7, $5, $5
933 addq $1, $24, $24
934 addq $28, $25, $28
935 cmpult $28, $25, $1
936 mulq $6, $8, $6
937 beq $1, $205
938 sll $20, 32, $1
939 addq $6, $1, $6
940$205:
941 sll $28, 32, $25
942 ldq $2, 0($18)
943 addq $5, $25, $5
944 bis $5, $5, $7
945 ldq $4, 24($17)
946 addq $23, $7, $23
947 srl $2, 32, $8
948 cmpult $23, $7, $3
949 zapnot $4, 15, $7
950 mulq $8, $7, $0
951 srl $28, 32, $1
952 addq $6, $1, $6
953 cmpult $5, $25, $1
954 zapnot $2, 15, $5
955 addq $1, $6, $6
956 addq $3, $6, $6
957 addq $22, $6, $22
958 cmpult $22, $6, $1
959 srl $4, 32, $6
960 mulq $5, $6, $25
961 mulq $7, $5, $2
962 addq $1, $24, $24
963 addq $0, $25, $0
964 cmpult $0, $25, $1
965 mulq $6, $8, $6
966 beq $1, $209
967 sll $20, 32, $1
968 addq $6, $1, $6
969$209:
970 sll $0, 32, $25
971 addq $2, $25, $2
972 bis $2, $2, $7
973 addq $23, $7, $23
974 stq $23, 24($16)
975 ldq $4, 32($17)
976 ldq $5, 0($18)
977 cmpult $23, $7, $3
978 zapnot $4, 15, $7
979 srl $5, 32, $8
980 mulq $8, $7, $28
981 srl $0, 32, $1
982 cmpult $2, $25, $2
983 addq $6, $1, $6
984 addq $2, $6, $6
985 addq $3, $6, $6
986 addq $22, $6, $22
987 cmpult $22, $6, $1
988 srl $4, 32, $6
989 zapnot $5, 15, $5
990 mulq $5, $6, $23
991 mulq $7, $5, $2
992 addq $1, $24, $24
993 addq $28, $23, $28
994 cmpult $28, $23, $1
995 mulq $6, $8, $6
996 beq $1, $213
997 sll $20, 32, $1
998 addq $6, $1, $6
999$213:
1000 sll $28, 32, $23
1001 ldq $1, 8($18)
1002 addq $2, $23, $2
1003 bis $2, $2, $7
1004 ldq $4, 24($17)
1005 addq $22, $7, $22
1006 srl $1, 32, $8
1007 cmpult $22, $7, $3
1008 zapnot $4, 15, $7
1009 mulq $8, $7, $25
1010 zapnot $1, 15, $5
1011 mulq $7, $5, $0
1012 srl $28, 32, $1
1013 cmpult $2, $23, $2
1014 addq $6, $1, $6
1015 addq $2, $6, $6
1016 addq $3, $6, $6
1017 addq $24, $6, $24
1018 cmpult $24, $6, $23
1019 srl $4, 32, $6
1020 mulq $5, $6, $5
1021 bis $31, 1, $21
1022 addq $25, $5, $25
1023 cmpult $25, $5, $1
1024 mulq $6, $8, $6
1025 beq $1, $217
1026 sll $21, 32, $1
1027 addq $6, $1, $6
1028$217:
1029 sll $25, 32, $5
1030 ldq $2, 16($18)
1031 addq $0, $5, $0
1032 bis $0, $0, $7
1033 ldq $4, 16($17)
1034 addq $22, $7, $22
1035 srl $2, 32, $8
1036 cmpult $22, $7, $3
1037 zapnot $4, 15, $7
1038 mulq $8, $7, $28
1039 srl $25, 32, $1
1040 addq $6, $1, $6
1041 cmpult $0, $5, $1
1042 zapnot $2, 15, $5
1043 addq $1, $6, $6
1044 addq $3, $6, $6
1045 addq $24, $6, $24
1046 cmpult $24, $6, $1
1047 srl $4, 32, $6
1048 mulq $5, $6, $25
1049 mulq $7, $5, $5
1050 addq $1, $23, $23
1051 addq $28, $25, $28
1052 cmpult $28, $25, $1
1053 mulq $6, $8, $6
1054 beq $1, $221
1055 sll $21, 32, $1
1056 addq $6, $1, $6
1057$221:
1058 sll $28, 32, $25
1059 ldq $2, 24($18)
1060 addq $5, $25, $5
1061 bis $5, $5, $7
1062 ldq $4, 8($17)
1063 addq $22, $7, $22
1064 srl $2, 32, $8
1065 cmpult $22, $7, $3
1066 zapnot $4, 15, $7
1067 mulq $8, $7, $0
1068 srl $28, 32, $1
1069 addq $6, $1, $6
1070 cmpult $5, $25, $1
1071 zapnot $2, 15, $5
1072 addq $1, $6, $6
1073 addq $3, $6, $6
1074 addq $24, $6, $24
1075 cmpult $24, $6, $1
1076 srl $4, 32, $6
1077 mulq $5, $6, $25
1078 mulq $7, $5, $5
1079 addq $1, $23, $23
1080 addq $0, $25, $0
1081 cmpult $0, $25, $1
1082 mulq $6, $8, $6
1083 beq $1, $225
1084 sll $21, 32, $1
1085 addq $6, $1, $6
1086$225:
1087 sll $0, 32, $25
1088 ldq $2, 32($18)
1089 addq $5, $25, $5
1090 bis $5, $5, $7
1091 ldq $4, 0($17)
1092 addq $22, $7, $22
1093 srl $2, 32, $8
1094 cmpult $22, $7, $3
1095 zapnot $4, 15, $7
1096 mulq $8, $7, $28
1097 srl $0, 32, $1
1098 addq $6, $1, $6
1099 cmpult $5, $25, $1
1100 zapnot $2, 15, $5
1101 addq $1, $6, $6
1102 addq $3, $6, $6
1103 addq $24, $6, $24
1104 cmpult $24, $6, $1
1105 srl $4, 32, $6
1106 mulq $5, $6, $25
1107 mulq $7, $5, $2
1108 addq $1, $23, $23
1109 addq $28, $25, $28
1110 cmpult $28, $25, $1
1111 mulq $6, $8, $6
1112 beq $1, $229
1113 sll $21, 32, $1
1114 addq $6, $1, $6
1115$229:
1116 sll $28, 32, $25
1117 addq $2, $25, $2
1118 bis $2, $2, $7
1119 addq $22, $7, $22
1120 stq $22, 32($16)
1121 ldq $4, 0($17)
1122 ldq $5, 40($18)
1123 cmpult $22, $7, $3
1124 zapnot $4, 15, $7
1125 srl $5, 32, $8
1126 mulq $8, $7, $0
1127 srl $28, 32, $1
1128 cmpult $2, $25, $2
1129 addq $6, $1, $6
1130 addq $2, $6, $6
1131 addq $3, $6, $6
1132 addq $24, $6, $24
1133 cmpult $24, $6, $1
1134 srl $4, 32, $6
1135 zapnot $5, 15, $5
1136 mulq $5, $6, $22
1137 mulq $7, $5, $2
1138 addq $1, $23, $23
1139 addq $0, $22, $0
1140 cmpult $0, $22, $1
1141 mulq $6, $8, $6
1142 beq $1, $233
1143 sll $21, 32, $1
1144 addq $6, $1, $6
1145$233:
1146 sll $0, 32, $22
1147 ldq $1, 32($18)
1148 addq $2, $22, $2
1149 bis $2, $2, $7
1150 ldq $4, 8($17)
1151 addq $24, $7, $24
1152 srl $1, 32, $8
1153 cmpult $24, $7, $3
1154 zapnot $4, 15, $7
1155 mulq $8, $7, $25
1156 zapnot $1, 15, $5
1157 mulq $7, $5, $21
1158 srl $0, 32, $1
1159 cmpult $2, $22, $2
1160 addq $6, $1, $6
1161 addq $2, $6, $6
1162 addq $3, $6, $6
1163 addq $23, $6, $23
1164 cmpult $23, $6, $22
1165 srl $4, 32, $6
1166 mulq $5, $6, $5
1167 bis $31, 1, $20
1168 addq $25, $5, $25
1169 cmpult $25, $5, $1
1170 mulq $6, $8, $6
1171 beq $1, $237
1172 sll $20, 32, $1
1173 addq $6, $1, $6
1174$237:
1175 sll $25, 32, $5
1176 ldq $2, 24($18)
1177 addq $21, $5, $21
1178 bis $21, $21, $7
1179 ldq $4, 16($17)
1180 addq $24, $7, $24
1181 srl $2, 32, $8
1182 cmpult $24, $7, $3
1183 zapnot $4, 15, $7
1184 mulq $8, $7, $28
1185 srl $25, 32, $1
1186 addq $6, $1, $6
1187 cmpult $21, $5, $1
1188 zapnot $2, 15, $5
1189 addq $1, $6, $6
1190 addq $3, $6, $6
1191 addq $23, $6, $23
1192 cmpult $23, $6, $1
1193 srl $4, 32, $6
1194 mulq $5, $6, $25
1195 mulq $7, $5, $5
1196 addq $1, $22, $22
1197 addq $28, $25, $28
1198 cmpult $28, $25, $1
1199 mulq $6, $8, $6
1200 beq $1, $241
1201 sll $20, 32, $1
1202 addq $6, $1, $6
1203$241:
1204 sll $28, 32, $25
1205 ldq $2, 16($18)
1206 addq $5, $25, $5
1207 bis $5, $5, $7
1208 ldq $4, 24($17)
1209 addq $24, $7, $24
1210 srl $2, 32, $8
1211 cmpult $24, $7, $3
1212 zapnot $4, 15, $7
1213 mulq $8, $7, $0
1214 srl $28, 32, $1
1215 addq $6, $1, $6
1216 cmpult $5, $25, $1
1217 zapnot $2, 15, $5
1218 addq $1, $6, $6
1219 addq $3, $6, $6
1220 addq $23, $6, $23
1221 cmpult $23, $6, $1
1222 srl $4, 32, $6
1223 mulq $5, $6, $25
1224 mulq $7, $5, $5
1225 addq $1, $22, $22
1226 addq $0, $25, $0
1227 cmpult $0, $25, $1
1228 mulq $6, $8, $6
1229 beq $1, $245
1230 sll $20, 32, $1
1231 addq $6, $1, $6
1232$245:
1233 sll $0, 32, $25
1234 ldq $2, 8($18)
1235 addq $5, $25, $5
1236 bis $5, $5, $7
1237 ldq $4, 32($17)
1238 addq $24, $7, $24
1239 srl $2, 32, $8
1240 cmpult $24, $7, $3
1241 zapnot $4, 15, $7
1242 mulq $8, $7, $28
1243 srl $0, 32, $1
1244 addq $6, $1, $6
1245 cmpult $5, $25, $1
1246 zapnot $2, 15, $5
1247 addq $1, $6, $6
1248 addq $3, $6, $6
1249 addq $23, $6, $23
1250 cmpult $23, $6, $1
1251 srl $4, 32, $6
1252 mulq $5, $6, $25
1253 mulq $7, $5, $5
1254 addq $1, $22, $22
1255 addq $28, $25, $28
1256 cmpult $28, $25, $1
1257 mulq $6, $8, $6
1258 beq $1, $249
1259 sll $20, 32, $1
1260 addq $6, $1, $6
1261$249:
1262 sll $28, 32, $25
1263 ldq $2, 0($18)
1264 addq $5, $25, $5
1265 bis $5, $5, $7
1266 ldq $4, 40($17)
1267 addq $24, $7, $24
1268 srl $2, 32, $8
1269 cmpult $24, $7, $3
1270 zapnot $4, 15, $7
1271 mulq $8, $7, $0
1272 srl $28, 32, $1
1273 addq $6, $1, $6
1274 cmpult $5, $25, $1
1275 zapnot $2, 15, $5
1276 addq $1, $6, $6
1277 addq $3, $6, $6
1278 addq $23, $6, $23
1279 cmpult $23, $6, $1
1280 srl $4, 32, $6
1281 mulq $5, $6, $25
1282 mulq $7, $5, $2
1283 addq $1, $22, $22
1284 addq $0, $25, $0
1285 cmpult $0, $25, $1
1286 mulq $6, $8, $6
1287 beq $1, $253
1288 sll $20, 32, $1
1289 addq $6, $1, $6
1290$253:
1291 sll $0, 32, $25
1292 addq $2, $25, $2
1293 bis $2, $2, $7
1294 addq $24, $7, $24
1295 stq $24, 40($16)
1296 ldq $4, 48($17)
1297 ldq $5, 0($18)
1298 cmpult $24, $7, $3
1299 zapnot $4, 15, $7
1300 srl $5, 32, $8
1301 mulq $8, $7, $28
1302 srl $0, 32, $1
1303 cmpult $2, $25, $2
1304 addq $6, $1, $6
1305 addq $2, $6, $6
1306 addq $3, $6, $6
1307 addq $23, $6, $23
1308 cmpult $23, $6, $1
1309 srl $4, 32, $6
1310 zapnot $5, 15, $5
1311 mulq $5, $6, $24
1312 mulq $7, $5, $2
1313 addq $1, $22, $22
1314 addq $28, $24, $28
1315 cmpult $28, $24, $1
1316 mulq $6, $8, $6
1317 beq $1, $257
1318 sll $20, 32, $1
1319 addq $6, $1, $6
1320$257:
1321 sll $28, 32, $24
1322 ldq $1, 8($18)
1323 addq $2, $24, $2
1324 bis $2, $2, $7
1325 ldq $4, 40($17)
1326 addq $23, $7, $23
1327 srl $1, 32, $8
1328 cmpult $23, $7, $3
1329 zapnot $4, 15, $7
1330 mulq $8, $7, $25
1331 zapnot $1, 15, $5
1332 mulq $7, $5, $0
1333 srl $28, 32, $1
1334 cmpult $2, $24, $2
1335 addq $6, $1, $6
1336 addq $2, $6, $6
1337 addq $3, $6, $6
1338 addq $22, $6, $22
1339 cmpult $22, $6, $24
1340 srl $4, 32, $6
1341 mulq $5, $6, $5
1342 bis $31, 1, $21
1343 addq $25, $5, $25
1344 cmpult $25, $5, $1
1345 mulq $6, $8, $6
1346 beq $1, $261
1347 sll $21, 32, $1
1348 addq $6, $1, $6
1349$261:
1350 sll $25, 32, $5
1351 ldq $2, 16($18)
1352 addq $0, $5, $0
1353 bis $0, $0, $7
1354 ldq $4, 32($17)
1355 addq $23, $7, $23
1356 srl $2, 32, $8
1357 cmpult $23, $7, $3
1358 zapnot $4, 15, $7
1359 mulq $8, $7, $28
1360 srl $25, 32, $1
1361 addq $6, $1, $6
1362 cmpult $0, $5, $1
1363 zapnot $2, 15, $5
1364 addq $1, $6, $6
1365 addq $3, $6, $6
1366 addq $22, $6, $22
1367 cmpult $22, $6, $1
1368 srl $4, 32, $6
1369 mulq $5, $6, $25
1370 mulq $7, $5, $5
1371 addq $1, $24, $24
1372 addq $28, $25, $28
1373 cmpult $28, $25, $1
1374 mulq $6, $8, $6
1375 beq $1, $265
1376 sll $21, 32, $1
1377 addq $6, $1, $6
1378$265:
1379 sll $28, 32, $25
1380 ldq $2, 24($18)
1381 addq $5, $25, $5
1382 bis $5, $5, $7
1383 ldq $4, 24($17)
1384 addq $23, $7, $23
1385 srl $2, 32, $8
1386 cmpult $23, $7, $3
1387 zapnot $4, 15, $7
1388 mulq $8, $7, $0
1389 srl $28, 32, $1
1390 addq $6, $1, $6
1391 cmpult $5, $25, $1
1392 zapnot $2, 15, $5
1393 addq $1, $6, $6
1394 addq $3, $6, $6
1395 addq $22, $6, $22
1396 cmpult $22, $6, $1
1397 srl $4, 32, $6
1398 mulq $5, $6, $25
1399 mulq $7, $5, $5
1400 addq $1, $24, $24
1401 addq $0, $25, $0
1402 cmpult $0, $25, $1
1403 mulq $6, $8, $6
1404 beq $1, $269
1405 sll $21, 32, $1
1406 addq $6, $1, $6
1407$269:
1408 sll $0, 32, $25
1409 ldq $2, 32($18)
1410 addq $5, $25, $5
1411 bis $5, $5, $7
1412 ldq $4, 16($17)
1413 addq $23, $7, $23
1414 srl $2, 32, $8
1415 cmpult $23, $7, $3
1416 zapnot $4, 15, $7
1417 mulq $8, $7, $28
1418 srl $0, 32, $1
1419 addq $6, $1, $6
1420 cmpult $5, $25, $1
1421 zapnot $2, 15, $5
1422 addq $1, $6, $6
1423 addq $3, $6, $6
1424 addq $22, $6, $22
1425 cmpult $22, $6, $1
1426 srl $4, 32, $6
1427 mulq $5, $6, $25
1428 mulq $7, $5, $5
1429 addq $1, $24, $24
1430 addq $28, $25, $28
1431 cmpult $28, $25, $1
1432 mulq $6, $8, $6
1433 beq $1, $273
1434 sll $21, 32, $1
1435 addq $6, $1, $6
1436$273:
1437 sll $28, 32, $25
1438 ldq $2, 40($18)
1439 addq $5, $25, $5
1440 bis $5, $5, $7
1441 ldq $4, 8($17)
1442 addq $23, $7, $23
1443 srl $2, 32, $8
1444 cmpult $23, $7, $3
1445 zapnot $4, 15, $7
1446 mulq $8, $7, $0
1447 srl $28, 32, $1
1448 addq $6, $1, $6
1449 cmpult $5, $25, $1
1450 zapnot $2, 15, $5
1451 addq $1, $6, $6
1452 addq $3, $6, $6
1453 addq $22, $6, $22
1454 cmpult $22, $6, $1
1455 srl $4, 32, $6
1456 mulq $5, $6, $25
1457 mulq $7, $5, $5
1458 addq $1, $24, $24
1459 addq $0, $25, $0
1460 cmpult $0, $25, $1
1461 mulq $6, $8, $6
1462 beq $1, $277
1463 sll $21, 32, $1
1464 addq $6, $1, $6
1465$277:
1466 sll $0, 32, $25
1467 ldq $2, 48($18)
1468 addq $5, $25, $5
1469 bis $5, $5, $7
1470 ldq $4, 0($17)
1471 addq $23, $7, $23
1472 srl $2, 32, $8
1473 cmpult $23, $7, $3
1474 zapnot $4, 15, $7
1475 mulq $8, $7, $28
1476 srl $0, 32, $1
1477 addq $6, $1, $6
1478 cmpult $5, $25, $1
1479 zapnot $2, 15, $5
1480 addq $1, $6, $6
1481 addq $3, $6, $6
1482 addq $22, $6, $22
1483 cmpult $22, $6, $1
1484 srl $4, 32, $6
1485 mulq $5, $6, $25
1486 mulq $7, $5, $2
1487 addq $1, $24, $24
1488 addq $28, $25, $28
1489 cmpult $28, $25, $1
1490 mulq $6, $8, $6
1491 beq $1, $281
1492 sll $21, 32, $1
1493 addq $6, $1, $6
1494$281:
1495 sll $28, 32, $25
1496 addq $2, $25, $2
1497 bis $2, $2, $7
1498 addq $23, $7, $23
1499 stq $23, 48($16)
1500 ldq $4, 0($17)
1501 ldq $5, 56($18)
1502 cmpult $23, $7, $3
1503 zapnot $4, 15, $7
1504 srl $5, 32, $8
1505 mulq $8, $7, $0
1506 srl $28, 32, $1
1507 cmpult $2, $25, $2
1508 addq $6, $1, $6
1509 addq $2, $6, $6
1510 addq $3, $6, $6
1511 addq $22, $6, $22
1512 cmpult $22, $6, $1
1513 srl $4, 32, $6
1514 zapnot $5, 15, $5
1515 mulq $5, $6, $23
1516 mulq $7, $5, $2
1517 addq $1, $24, $24
1518 addq $0, $23, $0
1519 cmpult $0, $23, $1
1520 mulq $6, $8, $6
1521 beq $1, $285
1522 sll $21, 32, $1
1523 addq $6, $1, $6
1524$285:
1525 sll $0, 32, $23
1526 ldq $1, 48($18)
1527 addq $2, $23, $2
1528 bis $2, $2, $7
1529 ldq $4, 8($17)
1530 addq $22, $7, $22
1531 srl $1, 32, $8
1532 cmpult $22, $7, $3
1533 zapnot $4, 15, $7
1534 mulq $8, $7, $25
1535 zapnot $1, 15, $5
1536 mulq $7, $5, $21
1537 srl $0, 32, $1
1538 cmpult $2, $23, $2
1539 addq $6, $1, $6
1540 addq $2, $6, $6
1541 addq $3, $6, $6
1542 addq $24, $6, $24
1543 cmpult $24, $6, $23
1544 srl $4, 32, $6
1545 mulq $5, $6, $5
1546 bis $31, 1, $20
1547 addq $25, $5, $25
1548 cmpult $25, $5, $1
1549 mulq $6, $8, $6
1550 beq $1, $289
1551 sll $20, 32, $1
1552 addq $6, $1, $6
1553$289:
1554 sll $25, 32, $5
1555 ldq $2, 40($18)
1556 addq $21, $5, $21
1557 bis $21, $21, $7
1558 ldq $4, 16($17)
1559 addq $22, $7, $22
1560 srl $2, 32, $8
1561 cmpult $22, $7, $3
1562 zapnot $4, 15, $7
1563 mulq $8, $7, $28
1564 srl $25, 32, $1
1565 addq $6, $1, $6
1566 cmpult $21, $5, $1
1567 zapnot $2, 15, $5
1568 addq $1, $6, $6
1569 addq $3, $6, $6
1570 addq $24, $6, $24
1571 cmpult $24, $6, $1
1572 srl $4, 32, $6
1573 mulq $5, $6, $25
1574 mulq $7, $5, $5
1575 addq $1, $23, $23
1576 addq $28, $25, $28
1577 cmpult $28, $25, $1
1578 mulq $6, $8, $6
1579 beq $1, $293
1580 sll $20, 32, $1
1581 addq $6, $1, $6
1582$293:
1583 sll $28, 32, $25
1584 ldq $2, 32($18)
1585 addq $5, $25, $5
1586 bis $5, $5, $7
1587 ldq $4, 24($17)
1588 addq $22, $7, $22
1589 srl $2, 32, $8
1590 cmpult $22, $7, $3
1591 zapnot $4, 15, $7
1592 mulq $8, $7, $0
1593 srl $28, 32, $1
1594 addq $6, $1, $6
1595 cmpult $5, $25, $1
1596 zapnot $2, 15, $5
1597 addq $1, $6, $6
1598 addq $3, $6, $6
1599 addq $24, $6, $24
1600 cmpult $24, $6, $1
1601 srl $4, 32, $6
1602 mulq $5, $6, $25
1603 mulq $7, $5, $5
1604 addq $1, $23, $23
1605 addq $0, $25, $0
1606 cmpult $0, $25, $1
1607 mulq $6, $8, $6
1608 beq $1, $297
1609 sll $20, 32, $1
1610 addq $6, $1, $6
1611$297:
1612 sll $0, 32, $25
1613 ldq $2, 24($18)
1614 addq $5, $25, $5
1615 bis $5, $5, $7
1616 ldq $4, 32($17)
1617 addq $22, $7, $22
1618 srl $2, 32, $8
1619 cmpult $22, $7, $3
1620 zapnot $4, 15, $7
1621 mulq $8, $7, $28
1622 srl $0, 32, $1
1623 addq $6, $1, $6
1624 cmpult $5, $25, $1
1625 zapnot $2, 15, $5
1626 addq $1, $6, $6
1627 addq $3, $6, $6
1628 addq $24, $6, $24
1629 cmpult $24, $6, $1
1630 srl $4, 32, $6
1631 mulq $5, $6, $25
1632 mulq $7, $5, $5
1633 addq $1, $23, $23
1634 addq $28, $25, $28
1635 cmpult $28, $25, $1
1636 mulq $6, $8, $6
1637 beq $1, $301
1638 sll $20, 32, $1
1639 addq $6, $1, $6
1640$301:
1641 sll $28, 32, $25
1642 ldq $2, 16($18)
1643 addq $5, $25, $5
1644 bis $5, $5, $7
1645 ldq $4, 40($17)
1646 addq $22, $7, $22
1647 srl $2, 32, $8
1648 cmpult $22, $7, $3
1649 zapnot $4, 15, $7
1650 mulq $8, $7, $0
1651 srl $28, 32, $1
1652 addq $6, $1, $6
1653 cmpult $5, $25, $1
1654 zapnot $2, 15, $5
1655 addq $1, $6, $6
1656 addq $3, $6, $6
1657 addq $24, $6, $24
1658 cmpult $24, $6, $1
1659 srl $4, 32, $6
1660 mulq $5, $6, $25
1661 mulq $7, $5, $5
1662 addq $1, $23, $23
1663 addq $0, $25, $0
1664 cmpult $0, $25, $1
1665 mulq $6, $8, $6
1666 beq $1, $305
1667 sll $20, 32, $1
1668 addq $6, $1, $6
1669$305:
1670 sll $0, 32, $25
1671 ldq $2, 8($18)
1672 addq $5, $25, $5
1673 bis $5, $5, $7
1674 ldq $4, 48($17)
1675 addq $22, $7, $22
1676 srl $2, 32, $8
1677 cmpult $22, $7, $3
1678 zapnot $4, 15, $7
1679 mulq $8, $7, $28
1680 srl $0, 32, $1
1681 addq $6, $1, $6
1682 cmpult $5, $25, $1
1683 zapnot $2, 15, $5
1684 addq $1, $6, $6
1685 addq $3, $6, $6
1686 addq $24, $6, $24
1687 cmpult $24, $6, $1
1688 srl $4, 32, $6
1689 mulq $5, $6, $25
1690 mulq $7, $5, $5
1691 addq $1, $23, $23
1692 addq $28, $25, $28
1693 cmpult $28, $25, $1
1694 mulq $6, $8, $6
1695 beq $1, $309
1696 sll $20, 32, $1
1697 addq $6, $1, $6
1698$309:
1699 sll $28, 32, $25
1700 ldq $2, 0($18)
1701 addq $5, $25, $5
1702 bis $5, $5, $7
1703 ldq $4, 56($17)
1704 addq $22, $7, $22
1705 srl $2, 32, $8
1706 cmpult $22, $7, $3
1707 zapnot $4, 15, $7
1708 mulq $8, $7, $0
1709 srl $28, 32, $1
1710 addq $6, $1, $6
1711 cmpult $5, $25, $1
1712 zapnot $2, 15, $5
1713 addq $1, $6, $6
1714 addq $3, $6, $6
1715 addq $24, $6, $24
1716 cmpult $24, $6, $1
1717 srl $4, 32, $6
1718 mulq $5, $6, $25
1719 mulq $7, $5, $2
1720 addq $1, $23, $23
1721 addq $0, $25, $0
1722 cmpult $0, $25, $1
1723 mulq $6, $8, $6
1724 beq $1, $313
1725 sll $20, 32, $1
1726 addq $6, $1, $6
1727$313:
1728 sll $0, 32, $25
1729 addq $2, $25, $2
1730 bis $2, $2, $7
1731 addq $22, $7, $22
1732 stq $22, 56($16)
1733 ldq $4, 56($17)
1734 ldq $5, 8($18)
1735 cmpult $22, $7, $3
1736 zapnot $4, 15, $7
1737 srl $5, 32, $8
1738 mulq $8, $7, $28
1739 srl $0, 32, $1
1740 cmpult $2, $25, $2
1741 addq $6, $1, $6
1742 addq $2, $6, $6
1743 addq $3, $6, $6
1744 addq $24, $6, $24
1745 cmpult $24, $6, $1
1746 srl $4, 32, $6
1747 zapnot $5, 15, $5
1748 mulq $5, $6, $22
1749 mulq $7, $5, $2
1750 addq $1, $23, $23
1751 addq $28, $22, $28
1752 cmpult $28, $22, $1
1753 mulq $6, $8, $6
1754 beq $1, $317
1755 sll $20, 32, $1
1756 addq $6, $1, $6
1757$317:
1758 sll $28, 32, $22
1759 ldq $1, 16($18)
1760 addq $2, $22, $2
1761 bis $2, $2, $7
1762 ldq $4, 48($17)
1763 addq $24, $7, $24
1764 srl $1, 32, $8
1765 cmpult $24, $7, $3
1766 zapnot $4, 15, $7
1767 mulq $8, $7, $25
1768 zapnot $1, 15, $5
1769 mulq $7, $5, $0
1770 srl $28, 32, $1
1771 cmpult $2, $22, $2
1772 addq $6, $1, $6
1773 addq $2, $6, $6
1774 addq $3, $6, $6
1775 addq $23, $6, $23
1776 cmpult $23, $6, $22
1777 srl $4, 32, $6
1778 mulq $5, $6, $5
1779 bis $31, 1, $21
1780 addq $25, $5, $25
1781 cmpult $25, $5, $1
1782 mulq $6, $8, $6
1783 beq $1, $321
1784 sll $21, 32, $1
1785 addq $6, $1, $6
1786$321:
1787 sll $25, 32, $5
1788 ldq $2, 24($18)
1789 addq $0, $5, $0
1790 bis $0, $0, $7
1791 ldq $4, 40($17)
1792 addq $24, $7, $24
1793 srl $2, 32, $8
1794 cmpult $24, $7, $3
1795 zapnot $4, 15, $7
1796 mulq $8, $7, $28
1797 srl $25, 32, $1
1798 addq $6, $1, $6
1799 cmpult $0, $5, $1
1800 zapnot $2, 15, $5
1801 addq $1, $6, $6
1802 addq $3, $6, $6
1803 addq $23, $6, $23
1804 cmpult $23, $6, $1
1805 srl $4, 32, $6
1806 mulq $5, $6, $25
1807 mulq $7, $5, $5
1808 addq $1, $22, $22
1809 addq $28, $25, $28
1810 cmpult $28, $25, $1
1811 mulq $6, $8, $6
1812 beq $1, $325
1813 sll $21, 32, $1
1814 addq $6, $1, $6
1815$325:
1816 sll $28, 32, $25
1817 ldq $2, 32($18)
1818 addq $5, $25, $5
1819 bis $5, $5, $7
1820 ldq $4, 32($17)
1821 addq $24, $7, $24
1822 srl $2, 32, $8
1823 cmpult $24, $7, $3
1824 zapnot $4, 15, $7
1825 mulq $8, $7, $0
1826 srl $28, 32, $1
1827 addq $6, $1, $6
1828 cmpult $5, $25, $1
1829 zapnot $2, 15, $5
1830 addq $1, $6, $6
1831 addq $3, $6, $6
1832 addq $23, $6, $23
1833 cmpult $23, $6, $1
1834 srl $4, 32, $6
1835 mulq $5, $6, $25
1836 mulq $7, $5, $5
1837 addq $1, $22, $22
1838 addq $0, $25, $0
1839 cmpult $0, $25, $1
1840 mulq $6, $8, $6
1841 beq $1, $329
1842 sll $21, 32, $1
1843 addq $6, $1, $6
1844$329:
1845 sll $0, 32, $25
1846 ldq $2, 40($18)
1847 addq $5, $25, $5
1848 bis $5, $5, $7
1849 ldq $4, 24($17)
1850 addq $24, $7, $24
1851 srl $2, 32, $8
1852 cmpult $24, $7, $3
1853 zapnot $4, 15, $7
1854 mulq $8, $7, $28
1855 srl $0, 32, $1
1856 addq $6, $1, $6
1857 cmpult $5, $25, $1
1858 zapnot $2, 15, $5
1859 addq $1, $6, $6
1860 addq $3, $6, $6
1861 addq $23, $6, $23
1862 cmpult $23, $6, $1
1863 srl $4, 32, $6
1864 mulq $5, $6, $25
1865 mulq $7, $5, $5
1866 addq $1, $22, $22
1867 addq $28, $25, $28
1868 cmpult $28, $25, $1
1869 mulq $6, $8, $6
1870 beq $1, $333
1871 sll $21, 32, $1
1872 addq $6, $1, $6
1873$333:
1874 sll $28, 32, $25
1875 ldq $2, 48($18)
1876 addq $5, $25, $5
1877 bis $5, $5, $7
1878 ldq $4, 16($17)
1879 addq $24, $7, $24
1880 srl $2, 32, $8
1881 cmpult $24, $7, $3
1882 zapnot $4, 15, $7
1883 mulq $8, $7, $0
1884 srl $28, 32, $1
1885 addq $6, $1, $6
1886 cmpult $5, $25, $1
1887 zapnot $2, 15, $5
1888 addq $1, $6, $6
1889 addq $3, $6, $6
1890 addq $23, $6, $23
1891 cmpult $23, $6, $1
1892 srl $4, 32, $6
1893 mulq $5, $6, $25
1894 mulq $7, $5, $5
1895 addq $1, $22, $22
1896 addq $0, $25, $0
1897 cmpult $0, $25, $1
1898 mulq $6, $8, $6
1899 beq $1, $337
1900 sll $21, 32, $1
1901 addq $6, $1, $6
1902$337:
1903 sll $0, 32, $25
1904 ldq $2, 56($18)
1905 addq $5, $25, $5
1906 bis $5, $5, $7
1907 ldq $4, 8($17)
1908 addq $24, $7, $24
1909 srl $2, 32, $8
1910 cmpult $24, $7, $3
1911 zapnot $4, 15, $7
1912 mulq $8, $7, $28
1913 srl $0, 32, $1
1914 addq $6, $1, $6
1915 cmpult $5, $25, $1
1916 zapnot $2, 15, $5
1917 addq $1, $6, $6
1918 addq $3, $6, $6
1919 addq $23, $6, $23
1920 cmpult $23, $6, $1
1921 srl $4, 32, $6
1922 mulq $5, $6, $25
1923 mulq $7, $5, $2
1924 addq $1, $22, $22
1925 addq $28, $25, $28
1926 cmpult $28, $25, $1
1927 mulq $6, $8, $6
1928 beq $1, $341
1929 sll $21, 32, $1
1930 addq $6, $1, $6
1931$341:
1932 sll $28, 32, $25
1933 addq $2, $25, $2
1934 bis $2, $2, $7
1935 addq $24, $7, $24
1936 stq $24, 64($16)
1937 ldq $4, 16($17)
1938 ldq $5, 56($18)
1939 cmpult $24, $7, $3
1940 zapnot $4, 15, $7
1941 srl $5, 32, $8
1942 mulq $8, $7, $0
1943 srl $28, 32, $1
1944 cmpult $2, $25, $2
1945 addq $6, $1, $6
1946 addq $2, $6, $6
1947 addq $3, $6, $6
1948 addq $23, $6, $23
1949 cmpult $23, $6, $1
1950 srl $4, 32, $6
1951 zapnot $5, 15, $5
1952 mulq $5, $6, $24
1953 mulq $7, $5, $2
1954 addq $1, $22, $22
1955 addq $0, $24, $0
1956 cmpult $0, $24, $1
1957 mulq $6, $8, $6
1958 beq $1, $345
1959 sll $21, 32, $1
1960 addq $6, $1, $6
1961$345:
1962 sll $0, 32, $24
1963 ldq $1, 48($18)
1964 addq $2, $24, $2
1965 bis $2, $2, $7
1966 ldq $4, 24($17)
1967 addq $23, $7, $23
1968 srl $1, 32, $8
1969 cmpult $23, $7, $3
1970 zapnot $4, 15, $7
1971 mulq $8, $7, $25
1972 zapnot $1, 15, $5
1973 mulq $7, $5, $21
1974 srl $0, 32, $1
1975 cmpult $2, $24, $2
1976 addq $6, $1, $6
1977 addq $2, $6, $6
1978 addq $3, $6, $6
1979 addq $22, $6, $22
1980 cmpult $22, $6, $24
1981 srl $4, 32, $6
1982 mulq $5, $6, $5
1983 bis $31, 1, $20
1984 addq $25, $5, $25
1985 cmpult $25, $5, $1
1986 mulq $6, $8, $6
1987 beq $1, $349
1988 sll $20, 32, $1
1989 addq $6, $1, $6
1990$349:
1991 sll $25, 32, $5
1992 ldq $2, 40($18)
1993 addq $21, $5, $21
1994 bis $21, $21, $7
1995 ldq $4, 32($17)
1996 addq $23, $7, $23
1997 srl $2, 32, $8
1998 cmpult $23, $7, $3
1999 zapnot $4, 15, $7
2000 mulq $8, $7, $28
2001 srl $25, 32, $1
2002 addq $6, $1, $6
2003 cmpult $21, $5, $1
2004 zapnot $2, 15, $5
2005 addq $1, $6, $6
2006 addq $3, $6, $6
2007 addq $22, $6, $22
2008 cmpult $22, $6, $1
2009 srl $4, 32, $6
2010 mulq $5, $6, $25
2011 mulq $7, $5, $5
2012 addq $1, $24, $24
2013 addq $28, $25, $28
2014 cmpult $28, $25, $1
2015 mulq $6, $8, $6
2016 beq $1, $353
2017 sll $20, 32, $1
2018 addq $6, $1, $6
2019$353:
2020 sll $28, 32, $25
2021 ldq $2, 32($18)
2022 addq $5, $25, $5
2023 bis $5, $5, $7
2024 ldq $4, 40($17)
2025 addq $23, $7, $23
2026 srl $2, 32, $8
2027 cmpult $23, $7, $3
2028 zapnot $4, 15, $7
2029 mulq $8, $7, $0
2030 srl $28, 32, $1
2031 addq $6, $1, $6
2032 cmpult $5, $25, $1
2033 zapnot $2, 15, $5
2034 addq $1, $6, $6
2035 addq $3, $6, $6
2036 addq $22, $6, $22
2037 cmpult $22, $6, $1
2038 srl $4, 32, $6
2039 mulq $5, $6, $25
2040 mulq $7, $5, $5
2041 addq $1, $24, $24
2042 addq $0, $25, $0
2043 cmpult $0, $25, $1
2044 mulq $6, $8, $6
2045 beq $1, $357
2046 sll $20, 32, $1
2047 addq $6, $1, $6
2048$357:
2049 sll $0, 32, $25
2050 ldq $2, 24($18)
2051 addq $5, $25, $5
2052 bis $5, $5, $7
2053 ldq $4, 48($17)
2054 addq $23, $7, $23
2055 srl $2, 32, $8
2056 cmpult $23, $7, $3
2057 zapnot $4, 15, $7
2058 mulq $8, $7, $28
2059 srl $0, 32, $1
2060 addq $6, $1, $6
2061 cmpult $5, $25, $1
2062 zapnot $2, 15, $5
2063 addq $1, $6, $6
2064 addq $3, $6, $6
2065 addq $22, $6, $22
2066 cmpult $22, $6, $1
2067 srl $4, 32, $6
2068 mulq $5, $6, $25
2069 mulq $7, $5, $5
2070 addq $1, $24, $24
2071 addq $28, $25, $28
2072 cmpult $28, $25, $1
2073 mulq $6, $8, $6
2074 beq $1, $361
2075 sll $20, 32, $1
2076 addq $6, $1, $6
2077$361:
2078 sll $28, 32, $25
2079 ldq $2, 16($18)
2080 addq $5, $25, $5
2081 bis $5, $5, $7
2082 ldq $4, 56($17)
2083 addq $23, $7, $23
2084 srl $2, 32, $8
2085 cmpult $23, $7, $3
2086 zapnot $4, 15, $7
2087 mulq $8, $7, $0
2088 srl $28, 32, $1
2089 addq $6, $1, $6
2090 cmpult $5, $25, $1
2091 zapnot $2, 15, $5
2092 addq $1, $6, $6
2093 addq $3, $6, $6
2094 addq $22, $6, $22
2095 cmpult $22, $6, $1
2096 srl $4, 32, $6
2097 mulq $5, $6, $25
2098 mulq $7, $5, $2
2099 addq $1, $24, $24
2100 addq $0, $25, $0
2101 cmpult $0, $25, $1
2102 mulq $6, $8, $6
2103 beq $1, $365
2104 sll $20, 32, $1
2105 addq $6, $1, $6
2106$365:
2107 sll $0, 32, $25
2108 addq $2, $25, $2
2109 bis $2, $2, $7
2110 addq $23, $7, $23
2111 stq $23, 72($16)
2112 ldq $4, 56($17)
2113 ldq $5, 24($18)
2114 cmpult $23, $7, $3
2115 zapnot $4, 15, $7
2116 srl $5, 32, $8
2117 mulq $8, $7, $28
2118 srl $0, 32, $1
2119 cmpult $2, $25, $2
2120 addq $6, $1, $6
2121 addq $2, $6, $6
2122 addq $3, $6, $6
2123 addq $22, $6, $22
2124 cmpult $22, $6, $1
2125 srl $4, 32, $6
2126 zapnot $5, 15, $5
2127 mulq $5, $6, $23
2128 mulq $7, $5, $2
2129 addq $1, $24, $24
2130 addq $28, $23, $28
2131 cmpult $28, $23, $1
2132 mulq $6, $8, $6
2133 beq $1, $369
2134 sll $20, 32, $1
2135 addq $6, $1, $6
2136$369:
2137 sll $28, 32, $23
2138 ldq $1, 32($18)
2139 addq $2, $23, $2
2140 bis $2, $2, $7
2141 ldq $4, 48($17)
2142 addq $22, $7, $22
2143 srl $1, 32, $8
2144 cmpult $22, $7, $3
2145 zapnot $4, 15, $7
2146 mulq $8, $7, $25
2147 zapnot $1, 15, $5
2148 mulq $7, $5, $0
2149 srl $28, 32, $1
2150 cmpult $2, $23, $2
2151 addq $6, $1, $6
2152 addq $2, $6, $6
2153 addq $3, $6, $6
2154 addq $24, $6, $24
2155 cmpult $24, $6, $23
2156 srl $4, 32, $6
2157 mulq $5, $6, $5
2158 bis $31, 1, $21
2159 addq $25, $5, $25
2160 cmpult $25, $5, $1
2161 mulq $6, $8, $6
2162 beq $1, $373
2163 sll $21, 32, $1
2164 addq $6, $1, $6
2165$373:
2166 sll $25, 32, $5
2167 ldq $2, 40($18)
2168 addq $0, $5, $0
2169 bis $0, $0, $7
2170 ldq $4, 40($17)
2171 addq $22, $7, $22
2172 srl $2, 32, $8
2173 cmpult $22, $7, $3
2174 zapnot $4, 15, $7
2175 mulq $8, $7, $28
2176 srl $25, 32, $1
2177 addq $6, $1, $6
2178 cmpult $0, $5, $1
2179 zapnot $2, 15, $5
2180 addq $1, $6, $6
2181 addq $3, $6, $6
2182 addq $24, $6, $24
2183 cmpult $24, $6, $1
2184 srl $4, 32, $6
2185 mulq $5, $6, $25
2186 mulq $7, $5, $5
2187 addq $1, $23, $23
2188 addq $28, $25, $28
2189 cmpult $28, $25, $1
2190 mulq $6, $8, $6
2191 beq $1, $377
2192 sll $21, 32, $1
2193 addq $6, $1, $6
2194$377:
2195 sll $28, 32, $25
2196 ldq $2, 48($18)
2197 addq $5, $25, $5
2198 bis $5, $5, $7
2199 ldq $4, 32($17)
2200 addq $22, $7, $22
2201 srl $2, 32, $8
2202 cmpult $22, $7, $3
2203 zapnot $4, 15, $7
2204 mulq $8, $7, $0
2205 srl $28, 32, $1
2206 addq $6, $1, $6
2207 cmpult $5, $25, $1
2208 zapnot $2, 15, $5
2209 addq $1, $6, $6
2210 addq $3, $6, $6
2211 addq $24, $6, $24
2212 cmpult $24, $6, $1
2213 srl $4, 32, $6
2214 mulq $5, $6, $25
2215 mulq $7, $5, $5
2216 addq $1, $23, $23
2217 addq $0, $25, $0
2218 cmpult $0, $25, $1
2219 mulq $6, $8, $6
2220 beq $1, $381
2221 sll $21, 32, $1
2222 addq $6, $1, $6
2223$381:
2224 sll $0, 32, $25
2225 ldq $2, 56($18)
2226 addq $5, $25, $5
2227 bis $5, $5, $7
2228 ldq $4, 24($17)
2229 addq $22, $7, $22
2230 srl $2, 32, $8
2231 cmpult $22, $7, $3
2232 zapnot $4, 15, $7
2233 mulq $8, $7, $28
2234 srl $0, 32, $1
2235 addq $6, $1, $6
2236 cmpult $5, $25, $1
2237 zapnot $2, 15, $5
2238 addq $1, $6, $6
2239 addq $3, $6, $6
2240 addq $24, $6, $24
2241 cmpult $24, $6, $1
2242 srl $4, 32, $6
2243 mulq $5, $6, $25
2244 mulq $7, $5, $2
2245 addq $1, $23, $23
2246 addq $28, $25, $28
2247 cmpult $28, $25, $1
2248 mulq $6, $8, $6
2249 beq $1, $385
2250 sll $21, 32, $1
2251 addq $6, $1, $6
2252$385:
2253 sll $28, 32, $25
2254 addq $2, $25, $2
2255 bis $2, $2, $7
2256 addq $22, $7, $22
2257 stq $22, 80($16)
2258 ldq $4, 32($17)
2259 ldq $5, 56($18)
2260 cmpult $22, $7, $3
2261 zapnot $4, 15, $7
2262 srl $5, 32, $8
2263 mulq $8, $7, $0
2264 srl $28, 32, $1
2265 cmpult $2, $25, $2
2266 addq $6, $1, $6
2267 addq $2, $6, $6
2268 addq $3, $6, $6
2269 addq $24, $6, $24
2270 cmpult $24, $6, $1
2271 srl $4, 32, $6
2272 zapnot $5, 15, $5
2273 mulq $5, $6, $22
2274 mulq $7, $5, $2
2275 addq $1, $23, $23
2276 addq $0, $22, $0
2277 cmpult $0, $22, $1
2278 mulq $6, $8, $6
2279 beq $1, $389
2280 sll $21, 32, $1
2281 addq $6, $1, $6
2282$389:
2283 sll $0, 32, $22
2284 ldq $1, 48($18)
2285 addq $2, $22, $2
2286 bis $2, $2, $7
2287 ldq $4, 40($17)
2288 addq $24, $7, $24
2289 srl $1, 32, $8
2290 cmpult $24, $7, $3
2291 zapnot $4, 15, $7
2292 mulq $8, $7, $25
2293 zapnot $1, 15, $5
2294 mulq $7, $5, $21
2295 srl $0, 32, $1
2296 cmpult $2, $22, $2
2297 addq $6, $1, $6
2298 addq $2, $6, $6
2299 addq $3, $6, $6
2300 addq $23, $6, $23
2301 cmpult $23, $6, $22
2302 srl $4, 32, $6
2303 mulq $5, $6, $5
2304 bis $31, 1, $20
2305 addq $25, $5, $25
2306 cmpult $25, $5, $1
2307 mulq $6, $8, $6
2308 beq $1, $393
2309 sll $20, 32, $1
2310 addq $6, $1, $6
2311$393:
2312 sll $25, 32, $5
2313 ldq $2, 40($18)
2314 addq $21, $5, $21
2315 bis $21, $21, $7
2316 ldq $4, 48($17)
2317 addq $24, $7, $24
2318 srl $2, 32, $8
2319 cmpult $24, $7, $3
2320 zapnot $4, 15, $7
2321 mulq $8, $7, $28
2322 srl $25, 32, $1
2323 addq $6, $1, $6
2324 cmpult $21, $5, $1
2325 zapnot $2, 15, $5
2326 addq $1, $6, $6
2327 addq $3, $6, $6
2328 addq $23, $6, $23
2329 cmpult $23, $6, $1
2330 srl $4, 32, $6
2331 mulq $5, $6, $25
2332 mulq $7, $5, $5
2333 addq $1, $22, $22
2334 addq $28, $25, $28
2335 cmpult $28, $25, $1
2336 mulq $6, $8, $6
2337 beq $1, $397
2338 sll $20, 32, $1
2339 addq $6, $1, $6
2340$397:
2341 sll $28, 32, $25
2342 ldq $2, 32($18)
2343 addq $5, $25, $5
2344 bis $5, $5, $7
2345 ldq $4, 56($17)
2346 addq $24, $7, $24
2347 srl $2, 32, $8
2348 cmpult $24, $7, $3
2349 zapnot $4, 15, $7
2350 mulq $8, $7, $21
2351 srl $28, 32, $1
2352 addq $6, $1, $6
2353 cmpult $5, $25, $1
2354 zapnot $2, 15, $5
2355 addq $1, $6, $6
2356 addq $3, $6, $6
2357 addq $23, $6, $23
2358 cmpult $23, $6, $1
2359 srl $4, 32, $6
2360 mulq $5, $6, $25
2361 mulq $7, $5, $2
2362 addq $1, $22, $22
2363 addq $21, $25, $21
2364 cmpult $21, $25, $1
2365 mulq $6, $8, $6
2366 beq $1, $401
2367 sll $20, 32, $1
2368 addq $6, $1, $6
2369$401:
2370 sll $21, 32, $25
2371 addq $2, $25, $2
2372 bis $2, $2, $7
2373 addq $24, $7, $24
2374 stq $24, 88($16)
2375 ldq $4, 56($17)
2376 ldq $5, 40($18)
2377 cmpult $24, $7, $3
2378 zapnot $4, 15, $7
2379 srl $5, 32, $8
2380 mulq $8, $7, $0
2381 srl $21, 32, $1
2382 cmpult $2, $25, $2
2383 addq $6, $1, $6
2384 addq $2, $6, $6
2385 addq $3, $6, $6
2386 addq $23, $6, $23
2387 cmpult $23, $6, $1
2388 srl $4, 32, $6
2389 zapnot $5, 15, $5
2390 mulq $5, $6, $24
2391 mulq $7, $5, $5
2392 addq $1, $22, $22
2393 addq $0, $24, $0
2394 cmpult $0, $24, $1
2395 mulq $6, $8, $6
2396 beq $1, $405
2397 sll $20, 32, $1
2398 addq $6, $1, $6
2399$405:
2400 sll $0, 32, $24
2401 ldq $2, 48($18)
2402 addq $5, $24, $5
2403 bis $5, $5, $7
2404 ldq $4, 48($17)
2405 addq $23, $7, $23
2406 srl $2, 32, $8
2407 cmpult $23, $7, $3
2408 zapnot $4, 15, $7
2409 mulq $8, $7, $28
2410 srl $0, 32, $1
2411 addq $6, $1, $6
2412 cmpult $5, $24, $1
2413 zapnot $2, 15, $5
2414 addq $1, $6, $6
2415 addq $3, $6, $6
2416 addq $22, $6, $22
2417 cmpult $22, $6, $24
2418 srl $4, 32, $6
2419 mulq $5, $6, $25
2420 mulq $7, $5, $5
2421 addq $28, $25, $28
2422 cmpult $28, $25, $1
2423 mulq $6, $8, $6
2424 beq $1, $409
2425 sll $20, 32, $1
2426 addq $6, $1, $6
2427$409:
2428 sll $28, 32, $25
2429 ldq $2, 56($18)
2430 addq $5, $25, $5
2431 bis $5, $5, $7
2432 ldq $4, 40($17)
2433 addq $23, $7, $23
2434 srl $2, 32, $8
2435 cmpult $23, $7, $3
2436 zapnot $4, 15, $7
2437 mulq $8, $7, $0
2438 srl $28, 32, $1
2439 addq $6, $1, $6
2440 cmpult $5, $25, $1
2441 zapnot $2, 15, $5
2442 addq $1, $6, $6
2443 addq $3, $6, $6
2444 addq $22, $6, $22
2445 cmpult $22, $6, $1
2446 srl $4, 32, $6
2447 mulq $5, $6, $25
2448 mulq $7, $5, $2
2449 addq $1, $24, $24
2450 addq $0, $25, $0
2451 cmpult $0, $25, $1
2452 mulq $6, $8, $6
2453 beq $1, $413
2454 sll $20, 32, $1
2455 addq $6, $1, $6
2456$413:
2457 sll $0, 32, $25
2458 addq $2, $25, $2
2459 bis $2, $2, $7
2460 addq $23, $7, $23
2461 stq $23, 96($16)
2462 ldq $4, 48($17)
2463 ldq $5, 56($18)
2464 cmpult $23, $7, $3
2465 zapnot $4, 15, $7
2466 srl $5, 32, $8
2467 mulq $8, $7, $28
2468 srl $0, 32, $1
2469 cmpult $2, $25, $2
2470 addq $6, $1, $6
2471 addq $2, $6, $6
2472 addq $3, $6, $6
2473 addq $22, $6, $22
2474 cmpult $22, $6, $1
2475 srl $4, 32, $6
2476 zapnot $5, 15, $5
2477 mulq $5, $6, $23
2478 mulq $7, $5, $5
2479 addq $1, $24, $24
2480 addq $28, $23, $28
2481 cmpult $28, $23, $1
2482 mulq $6, $8, $6
2483 beq $1, $417
2484 sll $20, 32, $1
2485 addq $6, $1, $6
2486$417:
2487 sll $28, 32, $23
2488 ldq $2, 48($18)
2489 addq $5, $23, $5
2490 bis $5, $5, $7
2491 ldq $4, 56($17)
2492 addq $22, $7, $22
2493 srl $2, 32, $8
2494 cmpult $22, $7, $3
2495 zapnot $4, 15, $7
2496 mulq $8, $7, $0
2497 srl $28, 32, $1
2498 addq $6, $1, $6
2499 cmpult $5, $23, $1
2500 zapnot $2, 15, $5
2501 addq $1, $6, $6
2502 addq $3, $6, $6
2503 addq $24, $6, $24
2504 cmpult $24, $6, $23
2505 srl $4, 32, $6
2506 mulq $5, $6, $25
2507 mulq $7, $5, $2
2508 addq $0, $25, $0
2509 cmpult $0, $25, $1
2510 mulq $6, $8, $6
2511 beq $1, $421
2512 sll $20, 32, $1
2513 addq $6, $1, $6
2514$421:
2515 sll $0, 32, $25
2516 addq $2, $25, $2
2517 bis $2, $2, $7
2518 addq $22, $7, $22
2519 stq $22, 104($16)
2520 ldq $4, 56($17)
2521 ldq $5, 56($18)
2522 cmpult $22, $7, $3
2523 zapnot $4, 15, $7
2524 srl $5, 32, $8
2525 mulq $8, $7, $28
2526 srl $0, 32, $1
2527 cmpult $2, $25, $2
2528 addq $6, $1, $6
2529 addq $2, $6, $6
2530 addq $3, $6, $6
2531 addq $24, $6, $24
2532 cmpult $24, $6, $1
2533 srl $4, 32, $6
2534 zapnot $5, 15, $5
2535 mulq $5, $6, $22
2536 mulq $7, $5, $2
2537 addq $1, $23, $23
2538 addq $28, $22, $28
2539 cmpult $28, $22, $1
2540 mulq $6, $8, $3
2541 beq $1, $425
2542 sll $20, 32, $1
2543 addq $3, $1, $3
2544$425:
2545 sll $28, 32, $22
2546 srl $28, 32, $1
2547 addq $2, $22, $2
2548 addq $3, $1, $3
2549 bis $2, $2, $7
2550 addq $24, $7, $24
2551 cmpult $7, $22, $1
2552 cmpult $24, $7, $2
2553 addq $1, $3, $6
2554 addq $2, $6, $6
2555 stq $24, 112($16)
2556 addq $23, $6, $23
2557 stq $23, 120($16)
2558 ret $31, ($26), 1
2559 .end bn_mul_comba8
2560 .text
2561 .align 3
2562 .globl bn_sqr_comba4
2563 .ent bn_sqr_comba4
2564bn_sqr_comba4:
2565bn_sqr_comba4..ng:
2566 .frame $30,0,$26,0
2567 .prologue 0
2568
2569 ldq $0, 0($17)
2570 ldq $1, 8($17)
2571 ldq $2, 16($17)
2572 ldq $3, 24($17)
2573 bis $31, $31, $6
2574 mulq $0, $0, $4
2575 umulh $0, $0, $5
2576 stq $4, 0($16)
2577 bis $31, $31, $4
2578 mulq $0, $1, $7
2579 umulh $0, $1, $8
2580 cmplt $7, $31, $22
2581 cmplt $8, $31, $23
2582 addq $7, $7, $7
2583 addq $8, $8, $8
2584 addq $8, $22, $8
2585 addq $4, $23, $4
2586 addq $5, $7, $5
2587 addq $6, $8, $6
2588 cmpult $5, $7, $24
2589 cmpult $6, $8, $25
2590 addq $6, $24, $6
2591 addq $4, $25, $4
2592 stq $5, 8($16)
2593 bis $31, $31, $5
2594 mulq $1, $1, $27
2595 umulh $1, $1, $28
2596 addq $6, $27, $6
2597 addq $4, $28, $4
2598 cmpult $6, $27, $21
2599 cmpult $4, $28, $20
2600 addq $4, $21, $4
2601 addq $5, $20, $5
2602 mulq $2, $0, $19
2603 umulh $2, $0, $18
2604 cmplt $19, $31, $17
2605 cmplt $18, $31, $22
2606 addq $19, $19, $19
2607 addq $18, $18, $18
2608 addq $18, $17, $18
2609 addq $5, $22, $5
2610 addq $6, $19, $6
2611 addq $4, $18, $4
2612 cmpult $6, $19, $23
2613 cmpult $4, $18, $7
2614 addq $4, $23, $4
2615 addq $5, $7, $5
2616 stq $6, 16($16)
2617 bis $31, $31, $6
2618 mulq $3, $0, $8
2619 umulh $3, $0, $24
2620 cmplt $8, $31, $25
2621 cmplt $24, $31, $27
2622 addq $8, $8, $8
2623 addq $24, $24, $24
2624 addq $24, $25, $24
2625 addq $6, $27, $6
2626 addq $4, $8, $4
2627 addq $5, $24, $5
2628 cmpult $4, $8, $28
2629 cmpult $5, $24, $21
2630 addq $5, $28, $5
2631 addq $6, $21, $6
2632 mulq $2, $1, $20
2633 umulh $2, $1, $17
2634 cmplt $20, $31, $22
2635 cmplt $17, $31, $19
2636 addq $20, $20, $20
2637 addq $17, $17, $17
2638 addq $17, $22, $17
2639 addq $6, $19, $6
2640 addq $4, $20, $4
2641 addq $5, $17, $5
2642 cmpult $4, $20, $18
2643 cmpult $5, $17, $23
2644 addq $5, $18, $5
2645 addq $6, $23, $6
2646 stq $4, 24($16)
2647 bis $31, $31, $4
2648 mulq $2, $2, $7
2649 umulh $2, $2, $25
2650 addq $5, $7, $5
2651 addq $6, $25, $6
2652 cmpult $5, $7, $27
2653 cmpult $6, $25, $8
2654 addq $6, $27, $6
2655 addq $4, $8, $4
2656 mulq $3, $1, $24
2657 umulh $3, $1, $28
2658 cmplt $24, $31, $21
2659 cmplt $28, $31, $22
2660 addq $24, $24, $24
2661 addq $28, $28, $28
2662 addq $28, $21, $28
2663 addq $4, $22, $4
2664 addq $5, $24, $5
2665 addq $6, $28, $6
2666 cmpult $5, $24, $19
2667 cmpult $6, $28, $20
2668 addq $6, $19, $6
2669 addq $4, $20, $4
2670 stq $5, 32($16)
2671 bis $31, $31, $5
2672 mulq $3, $2, $17
2673 umulh $3, $2, $18
2674 cmplt $17, $31, $23
2675 cmplt $18, $31, $7
2676 addq $17, $17, $17
2677 addq $18, $18, $18
2678 addq $18, $23, $18
2679 addq $5, $7, $5
2680 addq $6, $17, $6
2681 addq $4, $18, $4
2682 cmpult $6, $17, $25
2683 cmpult $4, $18, $27
2684 addq $4, $25, $4
2685 addq $5, $27, $5
2686 stq $6, 40($16)
2687 bis $31, $31, $6
2688 mulq $3, $3, $8
2689 umulh $3, $3, $21
2690 addq $4, $8, $4
2691 addq $5, $21, $5
2692 cmpult $4, $8, $22
2693 cmpult $5, $21, $24
2694 addq $5, $22, $5
2695 addq $6, $24, $6
2696 stq $4, 48($16)
2697 stq $5, 56($16)
2698 ret $31,($26),1
2699 .end bn_sqr_comba4
2700 .text
2701 .align 3
2702 .globl bn_sqr_comba8
2703 .ent bn_sqr_comba8
2704bn_sqr_comba8:
2705bn_sqr_comba8..ng:
2706 .frame $30,0,$26,0
2707 .prologue 0
2708
2709 ldq $0, 0($17)
2710 ldq $1, 8($17)
2711 ldq $2, 16($17)
2712 ldq $3, 24($17)
2713 ldq $4, 32($17)
2714 ldq $5, 40($17)
2715 ldq $6, 48($17)
2716 ldq $7, 56($17)
2717 bis $31, $31, $23
2718 mulq $0, $0, $8
2719 umulh $0, $0, $22
2720 stq $8, 0($16)
2721 bis $31, $31, $8
2722 mulq $1, $0, $24
2723 umulh $1, $0, $25
2724 cmplt $24, $31, $27
2725 cmplt $25, $31, $28
2726 addq $24, $24, $24
2727 addq $25, $25, $25
2728 addq $25, $27, $25
2729 addq $8, $28, $8
2730 addq $22, $24, $22
2731 addq $23, $25, $23
2732 cmpult $22, $24, $21
2733 cmpult $23, $25, $20
2734 addq $23, $21, $23
2735 addq $8, $20, $8
2736 stq $22, 8($16)
2737 bis $31, $31, $22
2738 mulq $1, $1, $19
2739 umulh $1, $1, $18
2740 addq $23, $19, $23
2741 addq $8, $18, $8
2742 cmpult $23, $19, $17
2743 cmpult $8, $18, $27
2744 addq $8, $17, $8
2745 addq $22, $27, $22
2746 mulq $2, $0, $28
2747 umulh $2, $0, $24
2748 cmplt $28, $31, $25
2749 cmplt $24, $31, $21
2750 addq $28, $28, $28
2751 addq $24, $24, $24
2752 addq $24, $25, $24
2753 addq $22, $21, $22
2754 addq $23, $28, $23
2755 addq $8, $24, $8
2756 cmpult $23, $28, $20
2757 cmpult $8, $24, $19
2758 addq $8, $20, $8
2759 addq $22, $19, $22
2760 stq $23, 16($16)
2761 bis $31, $31, $23
2762 mulq $2, $1, $18
2763 umulh $2, $1, $17
2764 cmplt $18, $31, $27
2765 cmplt $17, $31, $25
2766 addq $18, $18, $18
2767 addq $17, $17, $17
2768 addq $17, $27, $17
2769 addq $23, $25, $23
2770 addq $8, $18, $8
2771 addq $22, $17, $22
2772 cmpult $8, $18, $21
2773 cmpult $22, $17, $28
2774 addq $22, $21, $22
2775 addq $23, $28, $23
2776 mulq $3, $0, $24
2777 umulh $3, $0, $20
2778 cmplt $24, $31, $19
2779 cmplt $20, $31, $27
2780 addq $24, $24, $24
2781 addq $20, $20, $20
2782 addq $20, $19, $20
2783 addq $23, $27, $23
2784 addq $8, $24, $8
2785 addq $22, $20, $22
2786 cmpult $8, $24, $25
2787 cmpult $22, $20, $18
2788 addq $22, $25, $22
2789 addq $23, $18, $23
2790 stq $8, 24($16)
2791 bis $31, $31, $8
2792 mulq $2, $2, $17
2793 umulh $2, $2, $21
2794 addq $22, $17, $22
2795 addq $23, $21, $23
2796 cmpult $22, $17, $28
2797 cmpult $23, $21, $19
2798 addq $23, $28, $23
2799 addq $8, $19, $8
2800 mulq $3, $1, $27
2801 umulh $3, $1, $24
2802 cmplt $27, $31, $20
2803 cmplt $24, $31, $25
2804 addq $27, $27, $27
2805 addq $24, $24, $24
2806 addq $24, $20, $24
2807 addq $8, $25, $8
2808 addq $22, $27, $22
2809 addq $23, $24, $23
2810 cmpult $22, $27, $18
2811 cmpult $23, $24, $17
2812 addq $23, $18, $23
2813 addq $8, $17, $8
2814 mulq $4, $0, $21
2815 umulh $4, $0, $28
2816 cmplt $21, $31, $19
2817 cmplt $28, $31, $20
2818 addq $21, $21, $21
2819 addq $28, $28, $28
2820 addq $28, $19, $28
2821 addq $8, $20, $8
2822 addq $22, $21, $22
2823 addq $23, $28, $23
2824 cmpult $22, $21, $25
2825 cmpult $23, $28, $27
2826 addq $23, $25, $23
2827 addq $8, $27, $8
2828 stq $22, 32($16)
2829 bis $31, $31, $22
2830 mulq $3, $2, $24
2831 umulh $3, $2, $18
2832 cmplt $24, $31, $17
2833 cmplt $18, $31, $19
2834 addq $24, $24, $24
2835 addq $18, $18, $18
2836 addq $18, $17, $18
2837 addq $22, $19, $22
2838 addq $23, $24, $23
2839 addq $8, $18, $8
2840 cmpult $23, $24, $20
2841 cmpult $8, $18, $21
2842 addq $8, $20, $8
2843 addq $22, $21, $22
2844 mulq $4, $1, $28
2845 umulh $4, $1, $25
2846 cmplt $28, $31, $27
2847 cmplt $25, $31, $17
2848 addq $28, $28, $28
2849 addq $25, $25, $25
2850 addq $25, $27, $25
2851 addq $22, $17, $22
2852 addq $23, $28, $23
2853 addq $8, $25, $8
2854 cmpult $23, $28, $19
2855 cmpult $8, $25, $24
2856 addq $8, $19, $8
2857 addq $22, $24, $22
2858 mulq $5, $0, $18
2859 umulh $5, $0, $20
2860 cmplt $18, $31, $21
2861 cmplt $20, $31, $27
2862 addq $18, $18, $18
2863 addq $20, $20, $20
2864 addq $20, $21, $20
2865 addq $22, $27, $22
2866 addq $23, $18, $23
2867 addq $8, $20, $8
2868 cmpult $23, $18, $17
2869 cmpult $8, $20, $28
2870 addq $8, $17, $8
2871 addq $22, $28, $22
2872 stq $23, 40($16)
2873 bis $31, $31, $23
2874 mulq $3, $3, $25
2875 umulh $3, $3, $19
2876 addq $8, $25, $8
2877 addq $22, $19, $22
2878 cmpult $8, $25, $24
2879 cmpult $22, $19, $21
2880 addq $22, $24, $22
2881 addq $23, $21, $23
2882 mulq $4, $2, $27
2883 umulh $4, $2, $18
2884 cmplt $27, $31, $20
2885 cmplt $18, $31, $17
2886 addq $27, $27, $27
2887 addq $18, $18, $18
2888 addq $18, $20, $18
2889 addq $23, $17, $23
2890 addq $8, $27, $8
2891 addq $22, $18, $22
2892 cmpult $8, $27, $28
2893 cmpult $22, $18, $25
2894 addq $22, $28, $22
2895 addq $23, $25, $23
2896 mulq $5, $1, $19
2897 umulh $5, $1, $24
2898 cmplt $19, $31, $21
2899 cmplt $24, $31, $20
2900 addq $19, $19, $19
2901 addq $24, $24, $24
2902 addq $24, $21, $24
2903 addq $23, $20, $23
2904 addq $8, $19, $8
2905 addq $22, $24, $22
2906 cmpult $8, $19, $17
2907 cmpult $22, $24, $27
2908 addq $22, $17, $22
2909 addq $23, $27, $23
2910 mulq $6, $0, $18
2911 umulh $6, $0, $28
2912 cmplt $18, $31, $25
2913 cmplt $28, $31, $21
2914 addq $18, $18, $18
2915 addq $28, $28, $28
2916 addq $28, $25, $28
2917 addq $23, $21, $23
2918 addq $8, $18, $8
2919 addq $22, $28, $22
2920 cmpult $8, $18, $20
2921 cmpult $22, $28, $19
2922 addq $22, $20, $22
2923 addq $23, $19, $23
2924 stq $8, 48($16)
2925 bis $31, $31, $8
2926 mulq $4, $3, $24
2927 umulh $4, $3, $17
2928 cmplt $24, $31, $27
2929 cmplt $17, $31, $25
2930 addq $24, $24, $24
2931 addq $17, $17, $17
2932 addq $17, $27, $17
2933 addq $8, $25, $8
2934 addq $22, $24, $22
2935 addq $23, $17, $23
2936 cmpult $22, $24, $21
2937 cmpult $23, $17, $18
2938 addq $23, $21, $23
2939 addq $8, $18, $8
2940 mulq $5, $2, $28
2941 umulh $5, $2, $20
2942 cmplt $28, $31, $19
2943 cmplt $20, $31, $27
2944 addq $28, $28, $28
2945 addq $20, $20, $20
2946 addq $20, $19, $20
2947 addq $8, $27, $8
2948 addq $22, $28, $22
2949 addq $23, $20, $23
2950 cmpult $22, $28, $25
2951 cmpult $23, $20, $24
2952 addq $23, $25, $23
2953 addq $8, $24, $8
2954 mulq $6, $1, $17
2955 umulh $6, $1, $21
2956 cmplt $17, $31, $18
2957 cmplt $21, $31, $19
2958 addq $17, $17, $17
2959 addq $21, $21, $21
2960 addq $21, $18, $21
2961 addq $8, $19, $8
2962 addq $22, $17, $22
2963 addq $23, $21, $23
2964 cmpult $22, $17, $27
2965 cmpult $23, $21, $28
2966 addq $23, $27, $23
2967 addq $8, $28, $8
2968 mulq $7, $0, $20
2969 umulh $7, $0, $25
2970 cmplt $20, $31, $24
2971 cmplt $25, $31, $18
2972 addq $20, $20, $20
2973 addq $25, $25, $25
2974 addq $25, $24, $25
2975 addq $8, $18, $8
2976 addq $22, $20, $22
2977 addq $23, $25, $23
2978 cmpult $22, $20, $19
2979 cmpult $23, $25, $17
2980 addq $23, $19, $23
2981 addq $8, $17, $8
2982 stq $22, 56($16)
2983 bis $31, $31, $22
2984 mulq $4, $4, $21
2985 umulh $4, $4, $27
2986 addq $23, $21, $23
2987 addq $8, $27, $8
2988 cmpult $23, $21, $28
2989 cmpult $8, $27, $24
2990 addq $8, $28, $8
2991 addq $22, $24, $22
2992 mulq $5, $3, $18
2993 umulh $5, $3, $20
2994 cmplt $18, $31, $25
2995 cmplt $20, $31, $19
2996 addq $18, $18, $18
2997 addq $20, $20, $20
2998 addq $20, $25, $20
2999 addq $22, $19, $22
3000 addq $23, $18, $23
3001 addq $8, $20, $8
3002 cmpult $23, $18, $17
3003 cmpult $8, $20, $21
3004 addq $8, $17, $8
3005 addq $22, $21, $22
3006 mulq $6, $2, $27
3007 umulh $6, $2, $28
3008 cmplt $27, $31, $24
3009 cmplt $28, $31, $25
3010 addq $27, $27, $27
3011 addq $28, $28, $28
3012 addq $28, $24, $28
3013 addq $22, $25, $22
3014 addq $23, $27, $23
3015 addq $8, $28, $8
3016 cmpult $23, $27, $19
3017 cmpult $8, $28, $18
3018 addq $8, $19, $8
3019 addq $22, $18, $22
3020 mulq $7, $1, $20
3021 umulh $7, $1, $17
3022 cmplt $20, $31, $21
3023 cmplt $17, $31, $24
3024 addq $20, $20, $20
3025 addq $17, $17, $17
3026 addq $17, $21, $17
3027 addq $22, $24, $22
3028 addq $23, $20, $23
3029 addq $8, $17, $8
3030 cmpult $23, $20, $25
3031 cmpult $8, $17, $27
3032 addq $8, $25, $8
3033 addq $22, $27, $22
3034 stq $23, 64($16)
3035 bis $31, $31, $23
3036 mulq $5, $4, $28
3037 umulh $5, $4, $19
3038 cmplt $28, $31, $18
3039 cmplt $19, $31, $21
3040 addq $28, $28, $28
3041 addq $19, $19, $19
3042 addq $19, $18, $19
3043 addq $23, $21, $23
3044 addq $8, $28, $8
3045 addq $22, $19, $22
3046 cmpult $8, $28, $24
3047 cmpult $22, $19, $20
3048 addq $22, $24, $22
3049 addq $23, $20, $23
3050 mulq $6, $3, $17
3051 umulh $6, $3, $25
3052 cmplt $17, $31, $27
3053 cmplt $25, $31, $18
3054 addq $17, $17, $17
3055 addq $25, $25, $25
3056 addq $25, $27, $25
3057 addq $23, $18, $23
3058 addq $8, $17, $8
3059 addq $22, $25, $22
3060 cmpult $8, $17, $21
3061 cmpult $22, $25, $28
3062 addq $22, $21, $22
3063 addq $23, $28, $23
3064 mulq $7, $2, $19
3065 umulh $7, $2, $24
3066 cmplt $19, $31, $20
3067 cmplt $24, $31, $27
3068 addq $19, $19, $19
3069 addq $24, $24, $24
3070 addq $24, $20, $24
3071 addq $23, $27, $23
3072 addq $8, $19, $8
3073 addq $22, $24, $22
3074 cmpult $8, $19, $18
3075 cmpult $22, $24, $17
3076 addq $22, $18, $22
3077 addq $23, $17, $23
3078 stq $8, 72($16)
3079 bis $31, $31, $8
3080 mulq $5, $5, $25
3081 umulh $5, $5, $21
3082 addq $22, $25, $22
3083 addq $23, $21, $23
3084 cmpult $22, $25, $28
3085 cmpult $23, $21, $20
3086 addq $23, $28, $23
3087 addq $8, $20, $8
3088 mulq $6, $4, $27
3089 umulh $6, $4, $19
3090 cmplt $27, $31, $24
3091 cmplt $19, $31, $18
3092 addq $27, $27, $27
3093 addq $19, $19, $19
3094 addq $19, $24, $19
3095 addq $8, $18, $8
3096 addq $22, $27, $22
3097 addq $23, $19, $23
3098 cmpult $22, $27, $17
3099 cmpult $23, $19, $25
3100 addq $23, $17, $23
3101 addq $8, $25, $8
3102 mulq $7, $3, $21
3103 umulh $7, $3, $28
3104 cmplt $21, $31, $20
3105 cmplt $28, $31, $24
3106 addq $21, $21, $21
3107 addq $28, $28, $28
3108 addq $28, $20, $28
3109 addq $8, $24, $8
3110 addq $22, $21, $22
3111 addq $23, $28, $23
3112 cmpult $22, $21, $18
3113 cmpult $23, $28, $27
3114 addq $23, $18, $23
3115 addq $8, $27, $8
3116 stq $22, 80($16)
3117 bis $31, $31, $22
3118 mulq $6, $5, $19
3119 umulh $6, $5, $17
3120 cmplt $19, $31, $25
3121 cmplt $17, $31, $20
3122 addq $19, $19, $19
3123 addq $17, $17, $17
3124 addq $17, $25, $17
3125 addq $22, $20, $22
3126 addq $23, $19, $23
3127 addq $8, $17, $8
3128 cmpult $23, $19, $24
3129 cmpult $8, $17, $21
3130 addq $8, $24, $8
3131 addq $22, $21, $22
3132 mulq $7, $4, $28
3133 umulh $7, $4, $18
3134 cmplt $28, $31, $27
3135 cmplt $18, $31, $25
3136 addq $28, $28, $28
3137 addq $18, $18, $18
3138 addq $18, $27, $18
3139 addq $22, $25, $22
3140 addq $23, $28, $23
3141 addq $8, $18, $8
3142 cmpult $23, $28, $20
3143 cmpult $8, $18, $19
3144 addq $8, $20, $8
3145 addq $22, $19, $22
3146 stq $23, 88($16)
3147 bis $31, $31, $23
3148 mulq $6, $6, $17
3149 umulh $6, $6, $24
3150 addq $8, $17, $8
3151 addq $22, $24, $22
3152 cmpult $8, $17, $21
3153 cmpult $22, $24, $27
3154 addq $22, $21, $22
3155 addq $23, $27, $23
3156 mulq $7, $5, $25
3157 umulh $7, $5, $28
3158 cmplt $25, $31, $18
3159 cmplt $28, $31, $20
3160 addq $25, $25, $25
3161 addq $28, $28, $28
3162 addq $28, $18, $28
3163 addq $23, $20, $23
3164 addq $8, $25, $8
3165 addq $22, $28, $22
3166 cmpult $8, $25, $19
3167 cmpult $22, $28, $17
3168 addq $22, $19, $22
3169 addq $23, $17, $23
3170 stq $8, 96($16)
3171 bis $31, $31, $8
3172 mulq $7, $6, $24
3173 umulh $7, $6, $21
3174 cmplt $24, $31, $27
3175 cmplt $21, $31, $18
3176 addq $24, $24, $24
3177 addq $21, $21, $21
3178 addq $21, $27, $21
3179 addq $8, $18, $8
3180 addq $22, $24, $22
3181 addq $23, $21, $23
3182 cmpult $22, $24, $20
3183 cmpult $23, $21, $25
3184 addq $23, $20, $23
3185 addq $8, $25, $8
3186 stq $22, 104($16)
3187 bis $31, $31, $22
3188 mulq $7, $7, $28
3189 umulh $7, $7, $19
3190 addq $23, $28, $23
3191 addq $8, $19, $8
3192 cmpult $23, $28, $17
3193 cmpult $8, $19, $27
3194 addq $8, $17, $8
3195 addq $22, $27, $22
3196 stq $23, 112($16)
3197 stq $8, 120($16)
3198 ret $31,($26),1
3199 .end bn_sqr_comba8
diff --git a/src/lib/libcrypto/bn/asm/alpha.s.works b/src/lib/libcrypto/bn/asm/alpha.s.works
deleted file mode 100644
index ee6c587809..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.s.works
+++ /dev/null
@@ -1,533 +0,0 @@
1
2 # DEC Alpha assember
3 # The bn_div64 is actually gcc output but the other parts are hand done.
4 # Thanks to tzeruch@ceddec.com for sending me the gcc output for
5 # bn_div64.
6 # I've gone back and re-done most of routines.
7 # The key thing to remeber for the 164 CPU is that while a
8 # multiply operation takes 8 cycles, another one can only be issued
9 # after 4 cycles have elapsed. I've done modification to help
10 # improve this. Also, normally, a ld instruction will not be available
11 # for about 3 cycles.
12 .file 1 "bn_asm.c"
13 .set noat
14gcc2_compiled.:
15__gnu_compiled_c:
16 .text
17 .align 3
18 .globl bn_mul_add_words
19 .ent bn_mul_add_words
20bn_mul_add_words:
21bn_mul_add_words..ng:
22 .frame $30,0,$26,0
23 .prologue 0
24 .align 5
25 subq $18,4,$18
26 bis $31,$31,$0
27 blt $18,$43 # if we are -1, -2, -3 or -4 goto tail code
28 ldq $20,0($17) # 1 1
29 ldq $1,0($16) # 1 1
30 .align 3
31$42:
32 mulq $20,$19,$5 # 1 2 1 ######
33 ldq $21,8($17) # 2 1
34 ldq $2,8($16) # 2 1
35 umulh $20,$19,$20 # 1 2 ######
36 ldq $27,16($17) # 3 1
37 ldq $3,16($16) # 3 1
38 mulq $21,$19,$6 # 2 2 1 ######
39 ldq $28,24($17) # 4 1
40 addq $1,$5,$1 # 1 2 2
41 ldq $4,24($16) # 4 1
42 umulh $21,$19,$21 # 2 2 ######
43 cmpult $1,$5,$22 # 1 2 3 1
44 addq $20,$22,$20 # 1 3 1
45 addq $1,$0,$1 # 1 2 3 1
46 mulq $27,$19,$7 # 3 2 1 ######
47 cmpult $1,$0,$0 # 1 2 3 2
48 addq $2,$6,$2 # 2 2 2
49 addq $20,$0,$0 # 1 3 2
50 cmpult $2,$6,$23 # 2 2 3 1
51 addq $21,$23,$21 # 2 3 1
52 umulh $27,$19,$27 # 3 2 ######
53 addq $2,$0,$2 # 2 2 3 1
54 cmpult $2,$0,$0 # 2 2 3 2
55 subq $18,4,$18
56 mulq $28,$19,$8 # 4 2 1 ######
57 addq $21,$0,$0 # 2 3 2
58 addq $3,$7,$3 # 3 2 2
59 addq $16,32,$16
60 cmpult $3,$7,$24 # 3 2 3 1
61 stq $1,-32($16) # 1 2 4
62 umulh $28,$19,$28 # 4 2 ######
63 addq $27,$24,$27 # 3 3 1
64 addq $3,$0,$3 # 3 2 3 1
65 stq $2,-24($16) # 2 2 4
66 cmpult $3,$0,$0 # 3 2 3 2
67 stq $3,-16($16) # 3 2 4
68 addq $4,$8,$4 # 4 2 2
69 addq $27,$0,$0 # 3 3 2
70 cmpult $4,$8,$25 # 4 2 3 1
71 addq $17,32,$17
72 addq $28,$25,$28 # 4 3 1
73 addq $4,$0,$4 # 4 2 3 1
74 cmpult $4,$0,$0 # 4 2 3 2
75 stq $4,-8($16) # 4 2 4
76 addq $28,$0,$0 # 4 3 2
77 blt $18,$43
78
79 ldq $20,0($17) # 1 1
80 ldq $1,0($16) # 1 1
81
82 br $42
83
84 .align 4
85$45:
86 ldq $20,0($17) # 4 1
87 ldq $1,0($16) # 4 1
88 mulq $20,$19,$5 # 4 2 1
89 subq $18,1,$18
90 addq $16,8,$16
91 addq $17,8,$17
92 umulh $20,$19,$20 # 4 2
93 addq $1,$5,$1 # 4 2 2
94 cmpult $1,$5,$22 # 4 2 3 1
95 addq $20,$22,$20 # 4 3 1
96 addq $1,$0,$1 # 4 2 3 1
97 cmpult $1,$0,$0 # 4 2 3 2
98 addq $20,$0,$0 # 4 3 2
99 stq $1,-8($16) # 4 2 4
100 bgt $18,$45
101 ret $31,($26),1 # else exit
102
103 .align 4
104$43:
105 addq $18,4,$18
106 bgt $18,$45 # goto tail code
107 ret $31,($26),1 # else exit
108
109 .end bn_mul_add_words
110 .align 3
111 .globl bn_mul_words
112 .ent bn_mul_words
113bn_mul_words:
114bn_mul_words..ng:
115 .frame $30,0,$26,0
116 .prologue 0
117 .align 5
118 subq $18,4,$18
119 bis $31,$31,$0
120 blt $18,$143 # if we are -1, -2, -3 or -4 goto tail code
121 ldq $20,0($17) # 1 1
122 .align 3
123$142:
124
125 mulq $20,$19,$5 # 1 2 1 #####
126 ldq $21,8($17) # 2 1
127 ldq $27,16($17) # 3 1
128 umulh $20,$19,$20 # 1 2 #####
129 ldq $28,24($17) # 4 1
130 mulq $21,$19,$6 # 2 2 1 #####
131 addq $5,$0,$5 # 1 2 3 1
132 subq $18,4,$18
133 cmpult $5,$0,$0 # 1 2 3 2
134 umulh $21,$19,$21 # 2 2 #####
135 addq $20,$0,$0 # 1 3 2
136 addq $17,32,$17
137 addq $6,$0,$6 # 2 2 3 1
138 mulq $27,$19,$7 # 3 2 1 #####
139 cmpult $6,$0,$0 # 2 2 3 2
140 addq $21,$0,$0 # 2 3 2
141 addq $16,32,$16
142 umulh $27,$19,$27 # 3 2 #####
143 stq $5,-32($16) # 1 2 4
144 mulq $28,$19,$8 # 4 2 1 #####
145 addq $7,$0,$7 # 3 2 3 1
146 stq $6,-24($16) # 2 2 4
147 cmpult $7,$0,$0 # 3 2 3 2
148 umulh $28,$19,$28 # 4 2 #####
149 addq $27,$0,$0 # 3 3 2
150 stq $7,-16($16) # 3 2 4
151 addq $8,$0,$8 # 4 2 3 1
152 cmpult $8,$0,$0 # 4 2 3 2
153
154 addq $28,$0,$0 # 4 3 2
155
156 stq $8,-8($16) # 4 2 4
157
158 blt $18,$143
159
160 ldq $20,0($17) # 1 1
161
162 br $142
163
164 .align 4
165$145:
166 ldq $20,0($17) # 4 1
167 mulq $20,$19,$5 # 4 2 1
168 subq $18,1,$18
169 umulh $20,$19,$20 # 4 2
170 addq $5,$0,$5 # 4 2 3 1
171 addq $16,8,$16
172 cmpult $5,$0,$0 # 4 2 3 2
173 addq $17,8,$17
174 addq $20,$0,$0 # 4 3 2
175 stq $5,-8($16) # 4 2 4
176
177 bgt $18,$145
178 ret $31,($26),1 # else exit
179
180 .align 4
181$143:
182 addq $18,4,$18
183 bgt $18,$145 # goto tail code
184 ret $31,($26),1 # else exit
185
186 .end bn_mul_words
187 .align 3
188 .globl bn_sqr_words
189 .ent bn_sqr_words
190bn_sqr_words:
191bn_sqr_words..ng:
192 .frame $30,0,$26,0
193 .prologue 0
194
195 subq $18,4,$18
196 blt $18,$543 # if we are -1, -2, -3 or -4 goto tail code
197 ldq $20,0($17) # 1 1
198 .align 3
199$542:
200 mulq $20,$20,$5 ######
201 ldq $21,8($17) # 1 1
202 subq $18,4
203 umulh $20,$20,$1 ######
204 ldq $27,16($17) # 1 1
205 mulq $21,$21,$6 ######
206 ldq $28,24($17) # 1 1
207 stq $5,0($16) # r[0]
208 umulh $21,$21,$2 ######
209 stq $1,8($16) # r[1]
210 mulq $27,$27,$7 ######
211 stq $6,16($16) # r[0]
212 umulh $27,$27,$3 ######
213 stq $2,24($16) # r[1]
214 mulq $28,$28,$8 ######
215 stq $7,32($16) # r[0]
216 umulh $28,$28,$4 ######
217 stq $3,40($16) # r[1]
218
219 addq $16,64,$16
220 addq $17,32,$17
221 stq $8,-16($16) # r[0]
222 stq $4,-8($16) # r[1]
223
224 blt $18,$543
225 ldq $20,0($17) # 1 1
226 br $542
227
228$442:
229 ldq $20,0($17) # a[0]
230 mulq $20,$20,$5 # a[0]*w low part r2
231 addq $16,16,$16
232 addq $17,8,$17
233 subq $18,1,$18
234 umulh $20,$20,$1 # a[0]*w high part r3
235 stq $5,-16($16) # r[0]
236 stq $1,-8($16) # r[1]
237
238 bgt $18,$442
239 ret $31,($26),1 # else exit
240
241 .align 4
242$543:
243 addq $18,4,$18
244 bgt $18,$442 # goto tail code
245 ret $31,($26),1 # else exit
246 .end bn_sqr_words
247
248 .align 3
249 .globl bn_add_words
250 .ent bn_add_words
251bn_add_words:
252bn_add_words..ng:
253 .frame $30,0,$26,0
254 .prologue 0
255
256 subq $19,4,$19
257 bis $31,$31,$0 # carry = 0
258 blt $19,$900
259 ldq $5,0($17) # a[0]
260 ldq $1,0($18) # b[1]
261 .align 3
262$901:
263 addq $1,$5,$1 # r=a+b;
264 ldq $6,8($17) # a[1]
265 cmpult $1,$5,$22 # did we overflow?
266 ldq $2,8($18) # b[1]
267 addq $1,$0,$1 # c+= overflow
268 ldq $7,16($17) # a[2]
269 cmpult $1,$0,$0 # overflow?
270 ldq $3,16($18) # b[2]
271 addq $0,$22,$0
272 ldq $8,24($17) # a[3]
273 addq $2,$6,$2 # r=a+b;
274 ldq $4,24($18) # b[3]
275 cmpult $2,$6,$23 # did we overflow?
276 addq $3,$7,$3 # r=a+b;
277 addq $2,$0,$2 # c+= overflow
278 cmpult $3,$7,$24 # did we overflow?
279 cmpult $2,$0,$0 # overflow?
280 addq $4,$8,$4 # r=a+b;
281 addq $0,$23,$0
282 cmpult $4,$8,$25 # did we overflow?
283 addq $3,$0,$3 # c+= overflow
284 stq $1,0($16) # r[0]=c
285 cmpult $3,$0,$0 # overflow?
286 stq $2,8($16) # r[1]=c
287 addq $0,$24,$0
288 stq $3,16($16) # r[2]=c
289 addq $4,$0,$4 # c+= overflow
290 subq $19,4,$19 # loop--
291 cmpult $4,$0,$0 # overflow?
292 addq $17,32,$17 # a++
293 addq $0,$25,$0
294 stq $4,24($16) # r[3]=c
295 addq $18,32,$18 # b++
296 addq $16,32,$16 # r++
297
298 blt $19,$900
299 ldq $5,0($17) # a[0]
300 ldq $1,0($18) # b[1]
301 br $901
302 .align 4
303$945:
304 ldq $5,0($17) # a[0]
305 ldq $1,0($18) # b[1]
306 addq $1,$5,$1 # r=a+b;
307 subq $19,1,$19 # loop--
308 addq $1,$0,$1 # c+= overflow
309 addq $17,8,$17 # a++
310 cmpult $1,$5,$22 # did we overflow?
311 cmpult $1,$0,$0 # overflow?
312 addq $18,8,$18 # b++
313 stq $1,0($16) # r[0]=c
314 addq $0,$22,$0
315 addq $16,8,$16 # r++
316
317 bgt $19,$945
318 ret $31,($26),1 # else exit
319
320$900:
321 addq $19,4,$19
322 bgt $19,$945 # goto tail code
323 ret $31,($26),1 # else exit
324 .end bn_add_words
325
326 #
327 # What follows was taken directly from the C compiler with a few
328 # hacks to redo the lables.
329 #
330.text
331 .align 3
332 .globl bn_div64
333 .ent bn_div64
334bn_div64:
335 ldgp $29,0($27)
336bn_div64..ng:
337 lda $30,-48($30)
338 .frame $30,48,$26,0
339 stq $26,0($30)
340 stq $9,8($30)
341 stq $10,16($30)
342 stq $11,24($30)
343 stq $12,32($30)
344 stq $13,40($30)
345 .mask 0x4003e00,-48
346 .prologue 1
347 bis $16,$16,$9
348 bis $17,$17,$10
349 bis $18,$18,$11
350 bis $31,$31,$13
351 bis $31,2,$12
352 bne $11,$119
353 lda $0,-1
354 br $31,$136
355 .align 4
356$119:
357 bis $11,$11,$16
358 jsr $26,BN_num_bits_word
359 ldgp $29,0($26)
360 subq $0,64,$1
361 beq $1,$120
362 bis $31,1,$1
363 sll $1,$0,$1
364 cmpule $9,$1,$1
365 bne $1,$120
366 # lda $16,_IO_stderr_
367 # lda $17,$C32
368 # bis $0,$0,$18
369 # jsr $26,fprintf
370 # ldgp $29,0($26)
371 jsr $26,abort
372 ldgp $29,0($26)
373 .align 4
374$120:
375 bis $31,64,$3
376 cmpult $9,$11,$2
377 subq $3,$0,$1
378 addl $1,$31,$0
379 subq $9,$11,$1
380 cmoveq $2,$1,$9
381 beq $0,$122
382 zapnot $0,15,$2
383 subq $3,$0,$1
384 sll $11,$2,$11
385 sll $9,$2,$3
386 srl $10,$1,$1
387 sll $10,$2,$10
388 bis $3,$1,$9
389$122:
390 srl $11,32,$5
391 zapnot $11,15,$6
392 lda $7,-1
393 .align 5
394$123:
395 srl $9,32,$1
396 subq $1,$5,$1
397 bne $1,$126
398 zapnot $7,15,$27
399 br $31,$127
400 .align 4
401$126:
402 bis $9,$9,$24
403 bis $5,$5,$25
404 divqu $24,$25,$27
405$127:
406 srl $10,32,$4
407 .align 5
408$128:
409 mulq $27,$5,$1
410 subq $9,$1,$3
411 zapnot $3,240,$1
412 bne $1,$129
413 mulq $6,$27,$2
414 sll $3,32,$1
415 addq $1,$4,$1
416 cmpule $2,$1,$2
417 bne $2,$129
418 subq $27,1,$27
419 br $31,$128
420 .align 4
421$129:
422 mulq $27,$6,$1
423 mulq $27,$5,$4
424 srl $1,32,$3
425 sll $1,32,$1
426 addq $4,$3,$4
427 cmpult $10,$1,$2
428 subq $10,$1,$10
429 addq $2,$4,$2
430 cmpult $9,$2,$1
431 bis $2,$2,$4
432 beq $1,$134
433 addq $9,$11,$9
434 subq $27,1,$27
435$134:
436 subl $12,1,$12
437 subq $9,$4,$9
438 beq $12,$124
439 sll $27,32,$13
440 sll $9,32,$2
441 srl $10,32,$1
442 sll $10,32,$10
443 bis $2,$1,$9
444 br $31,$123
445 .align 4
446$124:
447 bis $13,$27,$0
448$136:
449 ldq $26,0($30)
450 ldq $9,8($30)
451 ldq $10,16($30)
452 ldq $11,24($30)
453 ldq $12,32($30)
454 ldq $13,40($30)
455 addq $30,48,$30
456 ret $31,($26),1
457 .end bn_div64
458
459 .set noat
460 .text
461 .align 3
462 .globl bn_sub_words
463 .ent bn_sub_words
464bn_sub_words:
465bn_sub_words..ng:
466 .frame $30,0,$26,0
467 .prologue 0
468
469 subq $19, 4, $19
470 bis $31, $31, $0
471 blt $19, $100
472 ldq $1, 0($17)
473 ldq $2, 0($18)
474$101:
475 ldq $3, 8($17)
476 cmpult $1, $2, $4
477 ldq $5, 8($18)
478 subq $1, $2, $1
479 ldq $6, 16($17)
480 cmpult $1, $0, $2
481 ldq $7, 16($18)
482 subq $1, $0, $23
483 ldq $8, 24($17)
484 addq $2, $4, $0
485 cmpult $3, $5, $24
486 subq $3, $5, $3
487 ldq $22, 24($18)
488 cmpult $3, $0, $5
489 subq $3, $0, $25
490 addq $5, $24, $0
491 cmpult $6, $7, $27
492 subq $6, $7, $6
493 stq $23, 0($16)
494 cmpult $6, $0, $7
495 subq $6, $0, $28
496 addq $7, $27, $0
497 cmpult $8, $22, $21
498 subq $8, $22, $8
499 stq $25, 8($16)
500 cmpult $8, $0, $22
501 subq $8, $0, $20
502 addq $22, $21, $0
503 stq $28, 16($16)
504 subq $19, 4, $19
505 stq $20, 24($16)
506 addq $17, 32, $17
507 addq $18, 32, $18
508 addq $16, 32, $16
509 blt $19, $100
510 ldq $1, 0($17)
511 ldq $2, 0($18)
512 br $101
513$102:
514 ldq $1, 0($17)
515 ldq $2, 0($18)
516 cmpult $1, $2, $27
517 subq $1, $2, $1
518 cmpult $1, $0, $2
519 subq $1, $0, $1
520 stq $1, 0($16)
521 addq $2, $27, $0
522 addq $17, 8, $17
523 addq $18, 8, $18
524 addq $16, 8, $16
525 subq $19, 1, $19
526 bgt $19, $102
527 ret $31,($26),1
528$100:
529 addq $19, 4, $19
530 bgt $19, $102
531$103:
532 ret $31,($26),1
533 .end bn_sub_words
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/add.pl b/src/lib/libcrypto/bn/asm/alpha.works/add.pl
deleted file mode 100644
index 4dc76e6b69..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/add.pl
+++ /dev/null
@@ -1,119 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_add_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15 $count=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &br(&label("finish"));
23 &blt($count,&label("finish"));
24
25 ($a0,$b0)=&NR(2);
26 &ld($a0,&QWPw(0,$ap));
27 &ld($b0,&QWPw(0,$bp));
28
29##########################################################
30 &set_label("loop");
31
32 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
33 ($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
34 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
35 ($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
36 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
37 ($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
38
39 ($o0,$t0)=&NR(2);
40 &add($a0,$b0,$o0);
41 &cmpult($o0,$b0,$t0);
42 &add($o0,$cc,$o0);
43 &cmpult($o0,$cc,$cc);
44 &add($cc,$t0,$cc); &FR($t0);
45
46 ($t1,$o1)=&NR(2);
47
48 &add($a1,$b1,$o1); &FR($a1);
49 &cmpult($o1,$b1,$t1); &FR($b1);
50 &add($o1,$cc,$o1);
51 &cmpult($o1,$cc,$cc);
52 &add($cc,$t1,$cc); &FR($t1);
53
54 ($t2,$o2)=&NR(2);
55
56 &add($a2,$b2,$o2); &FR($a2);
57 &cmpult($o2,$b2,$t2); &FR($b2);
58 &add($o2,$cc,$o2);
59 &cmpult($o2,$cc,$cc);
60 &add($cc,$t2,$cc); &FR($t2);
61
62 ($t3,$o3)=&NR(2);
63
64 &add($a3,$b3,$o3); &FR($a3);
65 &cmpult($o3,$b3,$t3); &FR($b3);
66 &add($o3,$cc,$o3);
67 &cmpult($o3,$cc,$cc);
68 &add($cc,$t3,$cc); &FR($t3);
69
70 &st($o0,&QWPw(0,$rp)); &FR($o0);
71 &st($o1,&QWPw(0,$rp)); &FR($o1);
72 &st($o2,&QWPw(0,$rp)); &FR($o2);
73 &st($o3,&QWPw(0,$rp)); &FR($o3);
74
75 &sub($count,4,$count); # count-=4
76 &add($ap,4*$QWS,$ap); # count+=4
77 &add($bp,4*$QWS,$bp); # count+=4
78 &add($rp,4*$QWS,$rp); # count+=4
79
80 &blt($count,&label("finish"));
81 &ld($a0,&QWPw(0,$ap));
82 &ld($b0,&QWPw(0,$bp));
83 &br(&label("loop"));
84##################################################
85 # Do the last 0..3 words
86
87 ($t0,$o0)=&NR(2);
88 &set_label("last_loop");
89
90 &ld($a0,&QWPw(0,$ap)); # get a
91 &ld($b0,&QWPw(0,$bp)); # get b
92
93 &add($a0,$b0,$o0);
94 &cmpult($o0,$b0,$t0); # will we borrow?
95 &add($o0,$cc,$o0); # will we borrow?
96 &cmpult($o0,$cc,$cc); # will we borrow?
97 &add($cc,$t0,$cc); # add the borrows
98 &st($o0,&QWPw(0,$rp)); # save
99
100 &add($ap,$QWS,$ap);
101 &add($bp,$QWS,$bp);
102 &add($rp,$QWS,$rp);
103 &sub($count,1,$count);
104 &bgt($count,&label("last_loop"));
105 &function_end_A($name);
106
107######################################################
108 &set_label("finish");
109 &add($count,4,$count);
110 &bgt($count,&label("last_loop"));
111
112 &FR($o0,$t0,$a0,$b0);
113 &set_label("end");
114 &function_end($name);
115
116 &fin_pool;
117 }
118
1191;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/div.pl b/src/lib/libcrypto/bn/asm/alpha.works/div.pl
deleted file mode 100644
index 7ec144377f..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/div.pl
+++ /dev/null
@@ -1,144 +0,0 @@
1#!/usr/local/bin/perl
2
3sub bn_div64
4 {
5 local($data)=<<'EOF';
6 #
7 # What follows was taken directly from the C compiler with a few
8 # hacks to redo the lables.
9 #
10.text
11 .set noreorder
12 .set volatile
13 .align 3
14 .globl bn_div64
15 .ent bn_div64
16bn_div64:
17 ldgp $29,0($27)
18bn_div64..ng:
19 lda $30,-48($30)
20 .frame $30,48,$26,0
21 stq $26,0($30)
22 stq $9,8($30)
23 stq $10,16($30)
24 stq $11,24($30)
25 stq $12,32($30)
26 stq $13,40($30)
27 .mask 0x4003e00,-48
28 .prologue 1
29 bis $16,$16,$9
30 bis $17,$17,$10
31 bis $18,$18,$11
32 bis $31,$31,$13
33 bis $31,2,$12
34 bne $11,$9119
35 lda $0,-1
36 br $31,$9136
37 .align 4
38$9119:
39 bis $11,$11,$16
40 jsr $26,BN_num_bits_word
41 ldgp $29,0($26)
42 subq $0,64,$1
43 beq $1,$9120
44 bis $31,1,$1
45 sll $1,$0,$1
46 cmpule $9,$1,$1
47 bne $1,$9120
48 # lda $16,_IO_stderr_
49 # lda $17,$C32
50 # bis $0,$0,$18
51 # jsr $26,fprintf
52 # ldgp $29,0($26)
53 jsr $26,abort
54 ldgp $29,0($26)
55 .align 4
56$9120:
57 bis $31,64,$3
58 cmpult $9,$11,$2
59 subq $3,$0,$1
60 addl $1,$31,$0
61 subq $9,$11,$1
62 cmoveq $2,$1,$9
63 beq $0,$9122
64 zapnot $0,15,$2
65 subq $3,$0,$1
66 sll $11,$2,$11
67 sll $9,$2,$3
68 srl $10,$1,$1
69 sll $10,$2,$10
70 bis $3,$1,$9
71$9122:
72 srl $11,32,$5
73 zapnot $11,15,$6
74 lda $7,-1
75 .align 5
76$9123:
77 srl $9,32,$1
78 subq $1,$5,$1
79 bne $1,$9126
80 zapnot $7,15,$27
81 br $31,$9127
82 .align 4
83$9126:
84 bis $9,$9,$24
85 bis $5,$5,$25
86 divqu $24,$25,$27
87$9127:
88 srl $10,32,$4
89 .align 5
90$9128:
91 mulq $27,$5,$1
92 subq $9,$1,$3
93 zapnot $3,240,$1
94 bne $1,$9129
95 mulq $6,$27,$2
96 sll $3,32,$1
97 addq $1,$4,$1
98 cmpule $2,$1,$2
99 bne $2,$9129
100 subq $27,1,$27
101 br $31,$9128
102 .align 4
103$9129:
104 mulq $27,$6,$1
105 mulq $27,$5,$4
106 srl $1,32,$3
107 sll $1,32,$1
108 addq $4,$3,$4
109 cmpult $10,$1,$2
110 subq $10,$1,$10
111 addq $2,$4,$2
112 cmpult $9,$2,$1
113 bis $2,$2,$4
114 beq $1,$9134
115 addq $9,$11,$9
116 subq $27,1,$27
117$9134:
118 subl $12,1,$12
119 subq $9,$4,$9
120 beq $12,$9124
121 sll $27,32,$13
122 sll $9,32,$2
123 srl $10,32,$1
124 sll $10,32,$10
125 bis $2,$1,$9
126 br $31,$9123
127 .align 4
128$9124:
129 bis $13,$27,$0
130$9136:
131 ldq $26,0($30)
132 ldq $9,8($30)
133 ldq $10,16($30)
134 ldq $11,24($30)
135 ldq $12,32($30)
136 ldq $13,40($30)
137 addq $30,48,$30
138 ret $31,($26),1
139 .end bn_div64
140EOF
141 &asm_add($data);
142 }
143
1441;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/mul.pl b/src/lib/libcrypto/bn/asm/alpha.works/mul.pl
deleted file mode 100644
index b182bae452..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/mul.pl
+++ /dev/null
@@ -1,116 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15 $word=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &br(&label("finish"));
23 &blt($count,&label("finish"));
24
25 ($a0,$r0)=&NR(2);
26 &ld($a0,&QWPw(0,$ap));
27 &ld($r0,&QWPw(0,$rp));
28
29$a=<<'EOF';
30##########################################################
31 &set_label("loop");
32
33 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
34 ($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
35 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
36 ($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
37 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
38 ($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
39
40 ($o0,$t0)=&NR(2);
41 &add($a0,$b0,$o0);
42 &cmpult($o0,$b0,$t0);
43 &add($o0,$cc,$o0);
44 &cmpult($o0,$cc,$cc);
45 &add($cc,$t0,$cc); &FR($t0);
46
47 ($t1,$o1)=&NR(2);
48
49 &add($a1,$b1,$o1); &FR($a1);
50 &cmpult($o1,$b1,$t1); &FR($b1);
51 &add($o1,$cc,$o1);
52 &cmpult($o1,$cc,$cc);
53 &add($cc,$t1,$cc); &FR($t1);
54
55 ($t2,$o2)=&NR(2);
56
57 &add($a2,$b2,$o2); &FR($a2);
58 &cmpult($o2,$b2,$t2); &FR($b2);
59 &add($o2,$cc,$o2);
60 &cmpult($o2,$cc,$cc);
61 &add($cc,$t2,$cc); &FR($t2);
62
63 ($t3,$o3)=&NR(2);
64
65 &add($a3,$b3,$o3); &FR($a3);
66 &cmpult($o3,$b3,$t3); &FR($b3);
67 &add($o3,$cc,$o3);
68 &cmpult($o3,$cc,$cc);
69 &add($cc,$t3,$cc); &FR($t3);
70
71 &st($o0,&QWPw(0,$rp)); &FR($o0);
72 &st($o1,&QWPw(0,$rp)); &FR($o1);
73 &st($o2,&QWPw(0,$rp)); &FR($o2);
74 &st($o3,&QWPw(0,$rp)); &FR($o3);
75
76 &sub($count,4,$count); # count-=4
77 &add($ap,4*$QWS,$ap); # count+=4
78 &add($bp,4*$QWS,$bp); # count+=4
79 &add($rp,4*$QWS,$rp); # count+=4
80
81 &blt($count,&label("finish"));
82 &ld($a0,&QWPw(0,$ap));
83 &ld($b0,&QWPw(0,$bp));
84 &br(&label("loop"));
85EOF
86##################################################
87 # Do the last 0..3 words
88
89 &set_label("last_loop");
90
91 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
92 &mul($a0,$word,($l0)=&NR(1));
93 &add($ap,$QWS,$ap);
94 &muh($a0,$word,($h0)=&NR(1)); &FR($a0);
95 &add($l0,$cc,$l0);
96 &add($rp,$QWS,$rp);
97 &sub($count,1,$count);
98 &cmpult($l0,$cc,$cc);
99 &st($l0,&QWPw(-1,$rp)); &FR($l0);
100 &add($h0,$cc,$cc); &FR($h0);
101
102 &bgt($count,&label("last_loop"));
103 &function_end_A($name);
104
105######################################################
106 &set_label("finish");
107 &add($count,4,$count);
108 &bgt($count,&label("last_loop"));
109
110 &set_label("end");
111 &function_end($name);
112
113 &fin_pool;
114 }
115
1161;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/mul_add.pl b/src/lib/libcrypto/bn/asm/alpha.works/mul_add.pl
deleted file mode 100644
index e37f6315fb..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/mul_add.pl
+++ /dev/null
@@ -1,120 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_add_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15 $word=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &br(&label("finish"));
23 &blt($count,&label("finish"));
24
25 ($a0,$r0)=&NR(2);
26 &ld($a0,&QWPw(0,$ap));
27 &ld($r0,&QWPw(0,$rp));
28
29$a=<<'EOF';
30##########################################################
31 &set_label("loop");
32
33 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
34 ($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
35 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
36 ($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
37 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
38 ($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
39
40 ($o0,$t0)=&NR(2);
41 &add($a0,$b0,$o0);
42 &cmpult($o0,$b0,$t0);
43 &add($o0,$cc,$o0);
44 &cmpult($o0,$cc,$cc);
45 &add($cc,$t0,$cc); &FR($t0);
46
47 ($t1,$o1)=&NR(2);
48
49 &add($a1,$b1,$o1); &FR($a1);
50 &cmpult($o1,$b1,$t1); &FR($b1);
51 &add($o1,$cc,$o1);
52 &cmpult($o1,$cc,$cc);
53 &add($cc,$t1,$cc); &FR($t1);
54
55 ($t2,$o2)=&NR(2);
56
57 &add($a2,$b2,$o2); &FR($a2);
58 &cmpult($o2,$b2,$t2); &FR($b2);
59 &add($o2,$cc,$o2);
60 &cmpult($o2,$cc,$cc);
61 &add($cc,$t2,$cc); &FR($t2);
62
63 ($t3,$o3)=&NR(2);
64
65 &add($a3,$b3,$o3); &FR($a3);
66 &cmpult($o3,$b3,$t3); &FR($b3);
67 &add($o3,$cc,$o3);
68 &cmpult($o3,$cc,$cc);
69 &add($cc,$t3,$cc); &FR($t3);
70
71 &st($o0,&QWPw(0,$rp)); &FR($o0);
72 &st($o1,&QWPw(0,$rp)); &FR($o1);
73 &st($o2,&QWPw(0,$rp)); &FR($o2);
74 &st($o3,&QWPw(0,$rp)); &FR($o3);
75
76 &sub($count,4,$count); # count-=4
77 &add($ap,4*$QWS,$ap); # count+=4
78 &add($bp,4*$QWS,$bp); # count+=4
79 &add($rp,4*$QWS,$rp); # count+=4
80
81 &blt($count,&label("finish"));
82 &ld($a0,&QWPw(0,$ap));
83 &ld($b0,&QWPw(0,$bp));
84 &br(&label("loop"));
85EOF
86##################################################
87 # Do the last 0..3 words
88
89 &set_label("last_loop");
90
91 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
92 &ld(($r0)=&NR(1),&QWPw(0,$rp)); # get b
93 &mul($a0,$word,($l0)=&NR(1));
94 &sub($count,1,$count);
95 &add($ap,$QWS,$ap);
96 &muh($a0,$word,($h0)=&NR(1)); &FR($a0);
97 &add($r0,$l0,$r0);
98 &add($rp,$QWS,$rp);
99 &cmpult($r0,$l0,($t0)=&NR(1)); &FR($l0);
100 &add($r0,$cc,$r0);
101 &add($h0,$t0,$h0); &FR($t0);
102 &cmpult($r0,$cc,$cc);
103 &st($r0,&QWPw(-1,$rp)); &FR($r0);
104 &add($h0,$cc,$cc); &FR($h0);
105
106 &bgt($count,&label("last_loop"));
107 &function_end_A($name);
108
109######################################################
110 &set_label("finish");
111 &add($count,4,$count);
112 &bgt($count,&label("last_loop"));
113
114 &set_label("end");
115 &function_end($name);
116
117 &fin_pool;
118 }
119
1201;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.pl b/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.pl
deleted file mode 100644
index 5efd201281..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.pl
+++ /dev/null
@@ -1,213 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub mul_add_c
5 {
6 local($a,$b,$c0,$c1,$c2)=@_;
7 local($l1,$h1,$t1,$t2);
8
9 &mul($a,$b,($l1)=&NR(1));
10 &muh($a,$b,($h1)=&NR(1));
11 &add($c0,$l1,$c0);
12 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
13 &add($t1,$h1,$h1); &FR($t1);
14 &add($c1,$h1,$c1);
15 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
16 &add($c2,$t2,$c2); &FR($t2);
17 }
18
19sub bn_mul_comba4
20 {
21 local($name)=@_;
22 local(@a,@b,$r,$c0,$c1,$c2);
23
24 $cnt=1;
25 &init_pool(3);
26
27 $rp=&wparam(0);
28 $ap=&wparam(1);
29 $bp=&wparam(2);
30
31 &function_begin($name,"");
32
33 &comment("");
34
35 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
36 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
37 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
38 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
39 &mul($a[0],$b[0],($r00)=&NR(1));
40 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
41 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
42 &muh($a[0],$b[0],($r01)=&NR(1));
43 &FR($ap); &ld(($a[3])=&NR(1),&QWPw(3,$ap));
44 &FR($bp); &ld(($b[3])=&NR(1),&QWPw(3,$bp));
45 &mul($a[0],$b[1],($r02)=&NR(1));
46
47 ($R,$H1,$H2)=&NR(3);
48
49 &st($r00,&QWPw(0,$rp)); &FR($r00);
50
51 &mov("zero",$R);
52 &mul($a[1],$b[0],($r03)=&NR(1));
53
54 &mov("zero",$H1);
55 &mov("zero",$H0);
56 &add($R,$r01,$R);
57 &muh($a[0],$b[1],($r04)=&NR(1));
58 &cmpult($R,$r01,($t01)=&NR(1)); &FR($r01);
59 &add($R,$r02,$R);
60 &add($H1,$t01,$H1) &FR($t01);
61 &muh($a[1],$b[0],($r05)=&NR(1));
62 &cmpult($R,$r02,($t02)=&NR(1)); &FR($r02);
63 &add($R,$r03,$R);
64 &add($H2,$t02,$H2) &FR($t02);
65 &mul($a[0],$b[2],($r06)=&NR(1));
66 &cmpult($R,$r03,($t03)=&NR(1)); &FR($r03);
67 &add($H1,$t03,$H1) &FR($t03);
68 &st($R,&QWPw(1,$rp));
69 &add($H1,$H2,$R);
70
71 &mov("zero",$H1);
72 &add($R,$r04,$R);
73 &mov("zero",$H2);
74 &mul($a[1],$b[1],($r07)=&NR(1));
75 &cmpult($R,$r04,($t04)=&NR(1)); &FR($r04);
76 &add($R,$r05,$R);
77 &add($H1,$t04,$H1) &FR($t04);
78 &mul($a[2],$b[0],($r08)=&NR(1));
79 &cmpult($R,$r05,($t05)=&NR(1)); &FR($r05);
80 &add($R,$r01,$R);
81 &add($H2,$t05,$H2) &FR($t05);
82 &muh($a[0],$b[2],($r09)=&NR(1));
83 &cmpult($R,$r06,($t06)=&NR(1)); &FR($r06);
84 &add($R,$r07,$R);
85 &add($H1,$t06,$H1) &FR($t06);
86 &muh($a[1],$b[1],($r10)=&NR(1));
87 &cmpult($R,$r07,($t07)=&NR(1)); &FR($r07);
88 &add($R,$r08,$R);
89 &add($H2,$t07,$H2) &FR($t07);
90 &muh($a[2],$b[0],($r11)=&NR(1));
91 &cmpult($R,$r08,($t08)=&NR(1)); &FR($r08);
92 &add($H1,$t08,$H1) &FR($t08);
93 &st($R,&QWPw(2,$rp));
94 &add($H1,$H2,$R);
95
96 &mov("zero",$H1);
97 &add($R,$r09,$R);
98 &mov("zero",$H2);
99 &mul($a[0],$b[3],($r12)=&NR(1));
100 &cmpult($R,$r09,($t09)=&NR(1)); &FR($r09);
101 &add($R,$r10,$R);
102 &add($H1,$t09,$H1) &FR($t09);
103 &mul($a[1],$b[2],($r13)=&NR(1));
104 &cmpult($R,$r10,($t10)=&NR(1)); &FR($r10);
105 &add($R,$r11,$R);
106 &add($H1,$t10,$H1) &FR($t10);
107 &mul($a[2],$b[1],($r14)=&NR(1));
108 &cmpult($R,$r11,($t11)=&NR(1)); &FR($r11);
109 &add($R,$r12,$R);
110 &add($H1,$t11,$H1) &FR($t11);
111 &mul($a[3],$b[0],($r15)=&NR(1));
112 &cmpult($R,$r12,($t12)=&NR(1)); &FR($r12);
113 &add($R,$r13,$R);
114 &add($H1,$t12,$H1) &FR($t12);
115 &muh($a[0],$b[3],($r16)=&NR(1));
116 &cmpult($R,$r13,($t13)=&NR(1)); &FR($r13);
117 &add($R,$r14,$R);
118 &add($H1,$t13,$H1) &FR($t13);
119 &muh($a[1],$b[2],($r17)=&NR(1));
120 &cmpult($R,$r14,($t14)=&NR(1)); &FR($r14);
121 &add($R,$r15,$R);
122 &add($H1,$t14,$H1) &FR($t14);
123 &muh($a[2],$b[1],($r18)=&NR(1));
124 &cmpult($R,$r15,($t15)=&NR(1)); &FR($r15);
125 &add($H1,$t15,$H1) &FR($t15);
126 &st($R,&QWPw(3,$rp));
127 &add($H1,$H2,$R);
128
129 &mov("zero",$H1);
130 &add($R,$r16,$R);
131 &mov("zero",$H2);
132 &muh($a[3],$b[0],($r19)=&NR(1));
133 &cmpult($R,$r16,($t16)=&NR(1)); &FR($r16);
134 &add($R,$r17,$R);
135 &add($H1,$t16,$H1) &FR($t16);
136 &mul($a[1],$b[3],($r20)=&NR(1));
137 &cmpult($R,$r17,($t17)=&NR(1)); &FR($r17);
138 &add($R,$r18,$R);
139 &add($H1,$t17,$H1) &FR($t17);
140 &mul($a[2],$b[2],($r21)=&NR(1));
141 &cmpult($R,$r18,($t18)=&NR(1)); &FR($r18);
142 &add($R,$r19,$R);
143 &add($H1,$t18,$H1) &FR($t18);
144 &mul($a[3],$b[1],($r22)=&NR(1));
145 &cmpult($R,$r19,($t19)=&NR(1)); &FR($r19);
146 &add($R,$r20,$R);
147 &add($H1,$t19,$H1) &FR($t19);
148 &muh($a[1],$b[3],($r23)=&NR(1));
149 &cmpult($R,$r20,($t20)=&NR(1)); &FR($r20);
150 &add($R,$r21,$R);
151 &add($H1,$t20,$H1) &FR($t20);
152 &muh($a[2],$b[2],($r24)=&NR(1));
153 &cmpult($R,$r21,($t21)=&NR(1)); &FR($r21);
154 &add($R,$r22,$R);
155 &add($H1,$t21,$H1) &FR($t21);
156 &muh($a[3],$b[1],($r25)=&NR(1));
157 &cmpult($R,$r22,($t22)=&NR(1)); &FR($r22);
158 &add($H1,$t22,$H1) &FR($t22);
159 &st($R,&QWPw(4,$rp));
160 &add($H1,$H2,$R);
161
162 &mov("zero",$H1);
163 &add($R,$r23,$R);
164 &mov("zero",$H2);
165 &mul($a[2],$b[3],($r26)=&NR(1));
166 &cmpult($R,$r23,($t23)=&NR(1)); &FR($r23);
167 &add($R,$r24,$R);
168 &add($H1,$t23,$H1) &FR($t23);
169 &mul($a[3],$b[2],($r27)=&NR(1));
170 &cmpult($R,$r24,($t24)=&NR(1)); &FR($r24);
171 &add($R,$r25,$R);
172 &add($H1,$t24,$H1) &FR($t24);
173 &muh($a[2],$b[3],($r28)=&NR(1));
174 &cmpult($R,$r25,($t25)=&NR(1)); &FR($r25);
175 &add($R,$r26,$R);
176 &add($H1,$t25,$H1) &FR($t25);
177 &muh($a[3],$b[2],($r29)=&NR(1));
178 &cmpult($R,$r26,($t26)=&NR(1)); &FR($r26);
179 &add($R,$r27,$R);
180 &add($H1,$t26,$H1) &FR($t26);
181 &mul($a[3],$b[3],($r30)=&NR(1));
182 &cmpult($R,$r27,($t27)=&NR(1)); &FR($r27);
183 &add($H1,$t27,$H1) &FR($t27);
184 &st($R,&QWPw(5,$rp));
185 &add($H1,$H2,$R);
186
187 &mov("zero",$H1);
188 &add($R,$r28,$R);
189 &mov("zero",$H2);
190 &muh($a[3],$b[3],($r31)=&NR(1));
191 &cmpult($R,$r28,($t28)=&NR(1)); &FR($r28);
192 &add($R,$r29,$R);
193 &add($H1,$t28,$H1) &FR($t28);
194 ############
195 &cmpult($R,$r29,($t29)=&NR(1)); &FR($r29);
196 &add($R,$r30,$R);
197 &add($H1,$t29,$H1) &FR($t29);
198 ############
199 &cmpult($R,$r30,($t30)=&NR(1)); &FR($r30);
200 &add($H1,$t30,$H1) &FR($t30);
201 &st($R,&QWPw(6,$rp));
202 &add($H1,$H2,$R);
203
204 &add($R,$r31,$R); &FR($r31);
205 &st($R,&QWPw(7,$rp));
206
207 &FR($R,$H1,$H2);
208 &function_end($name);
209
210 &fin_pool;
211 }
212
2131;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.works.pl b/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.works.pl
deleted file mode 100644
index 79d86dd25c..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/mul_c4.works.pl
+++ /dev/null
@@ -1,98 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub mul_add_c
5 {
6 local($a,$b,$c0,$c1,$c2)=@_;
7 local($l1,$h1,$t1,$t2);
8
9print STDERR "count=$cnt\n"; $cnt++;
10 &mul($a,$b,($l1)=&NR(1));
11 &muh($a,$b,($h1)=&NR(1));
12 &add($c0,$l1,$c0);
13 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
14 &add($t1,$h1,$h1); &FR($t1);
15 &add($c1,$h1,$c1);
16 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
17 &add($c2,$t2,$c2); &FR($t2);
18 }
19
20sub bn_mul_comba4
21 {
22 local($name)=@_;
23 local(@a,@b,$r,$c0,$c1,$c2);
24
25 $cnt=1;
26 &init_pool(3);
27
28 $rp=&wparam(0);
29 $ap=&wparam(1);
30 $bp=&wparam(2);
31
32 &function_begin($name,"");
33
34 &comment("");
35
36 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
37 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
38 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
39 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
40 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
41 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
42 &ld(($a[3])=&NR(1),&QWPw(3,$ap)); &FR($ap);
43 &ld(($b[3])=&NR(1),&QWPw(3,$bp)); &FR($bp);
44
45 ($c0,$c1,$c2)=&NR(3);
46 &mov("zero",$c2);
47 &mul($a[0],$b[0],$c0);
48 &muh($a[0],$b[0],$c1);
49 &st($c0,&QWPw(0,$rp)); &FR($c0); ($c0)=&NR($c0);
50 ($c0,$c1,$c2)=($c1,$c2,$c0);
51 &mov("zero",$c2);
52
53 &mul_add_c($a[0],$b[1],$c0,$c1,$c2);
54 &mul_add_c($a[1],$b[0],$c0,$c1,$c2);
55 &st($c0,&QWPw(1,$rp)); &FR($c0); ($c0)=&NR($c0);
56 ($c0,$c1,$c2)=($c1,$c2,$c0);
57 &mov("zero",$c2);
58
59 &mul_add_c($a[1],$b[1],$c0,$c1,$c2);
60 &mul_add_c($a[0],$b[2],$c0,$c1,$c2);
61 &mul_add_c($a[2],$b[0],$c0,$c1,$c2);
62 &st($c0,&QWPw(2,$rp)); &FR($c0); ($c0)=&NR($c0);
63 ($c0,$c1,$c2)=($c1,$c2,$c0);
64 &mov("zero",$c2);
65
66 &mul_add_c($a[0],$b[3],$c0,$c1,$c2); &FR($a[0]);
67 &mul_add_c($a[1],$b[2],$c0,$c1,$c2);
68 &mul_add_c($a[2],$b[1],$c0,$c1,$c2);
69 &mul_add_c($a[3],$b[0],$c0,$c1,$c2); &FR($b[0]);
70 &st($c0,&QWPw(3,$rp)); &FR($c0); ($c0)=&NR($c0);
71 ($c0,$c1,$c2)=($c1,$c2,$c0);
72 &mov("zero",$c2);
73
74 &mul_add_c($a[1],$b[3],$c0,$c1,$c2); &FR($a[1]);
75 &mul_add_c($a[2],$b[2],$c0,$c1,$c2);
76 &mul_add_c($a[3],$b[1],$c0,$c1,$c2); &FR($b[1]);
77 &st($c0,&QWPw(4,$rp)); &FR($c0); ($c0)=&NR($c0);
78 ($c0,$c1,$c2)=($c1,$c2,$c0);
79 &mov("zero",$c2);
80
81 &mul_add_c($a[2],$b[3],$c0,$c1,$c2); &FR($a[2]);
82 &mul_add_c($a[3],$b[2],$c0,$c1,$c2); &FR($b[2]);
83 &st($c0,&QWPw(5,$rp)); &FR($c0); ($c0)=&NR($c0);
84 ($c0,$c1,$c2)=($c1,$c2,$c0);
85 &mov("zero",$c2);
86
87 &mul_add_c($a[3],$b[3],$c0,$c1,$c2); &FR($a[3],$b[3]);
88 &st($c0,&QWPw(6,$rp));
89 &st($c1,&QWPw(7,$rp));
90
91 &FR($c0,$c1,$c2);
92
93 &function_end($name);
94
95 &fin_pool;
96 }
97
981;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/mul_c8.pl b/src/lib/libcrypto/bn/asm/alpha.works/mul_c8.pl
deleted file mode 100644
index 525ca7494b..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/mul_c8.pl
+++ /dev/null
@@ -1,177 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_comba8
5 {
6 local($name)=@_;
7 local(@a,@b,$r,$c0,$c1,$c2);
8
9 $cnt=1;
10 &init_pool(3);
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15
16 &function_begin($name,"");
17
18 &comment("");
19
20 &stack_push(2);
21 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
22 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
23 &st($reg_s0,&swtmp(0)); &FR($reg_s0);
24 &st($reg_s1,&swtmp(1)); &FR($reg_s1);
25 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
26 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
27 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
28 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
29 &ld(($a[3])=&NR(1),&QWPw(3,$ap));
30 &ld(($b[3])=&NR(1),&QWPw(3,$bp));
31 &ld(($a[4])=&NR(1),&QWPw(1,$ap));
32 &ld(($b[4])=&NR(1),&QWPw(1,$bp));
33 &ld(($a[5])=&NR(1),&QWPw(1,$ap));
34 &ld(($b[5])=&NR(1),&QWPw(1,$bp));
35 &ld(($a[6])=&NR(1),&QWPw(1,$ap));
36 &ld(($b[6])=&NR(1),&QWPw(1,$bp));
37 &ld(($a[7])=&NR(1),&QWPw(1,$ap)); &FR($ap);
38 &ld(($b[7])=&NR(1),&QWPw(1,$bp)); &FR($bp);
39
40 ($c0,$c1,$c2)=&NR(3);
41 &mov("zero",$c2);
42 &mul($a[0],$b[0],$c0);
43 &muh($a[0],$b[0],$c1);
44 &st($c0,&QWPw(0,$rp)); &FR($c0); ($c0)=&NR(1);
45 ($c0,$c1,$c2)=($c1,$c2,$c0);
46 &mov("zero",$c2);
47
48 &mul_add_c($a[0],$b[1],$c0,$c1,$c2);
49 &mul_add_c($a[1],$b[0],$c0,$c1,$c2);
50 &st($c0,&QWPw(1,$rp)); &FR($c0); ($c0)=&NR(1);
51 ($c0,$c1,$c2)=($c1,$c2,$c0);
52 &mov("zero",$c2);
53
54 &mul_add_c($a[0],$b[2],$c0,$c1,$c2);
55 &mul_add_c($a[1],$b[1],$c0,$c1,$c2);
56 &mul_add_c($a[2],$b[0],$c0,$c1,$c2);
57 &st($c0,&QWPw(2,$rp)); &FR($c0); ($c0)=&NR(1);
58 ($c0,$c1,$c2)=($c1,$c2,$c0);
59 &mov("zero",$c2);
60
61 &mul_add_c($a[0],$b[3],$c0,$c1,$c2);
62 &mul_add_c($a[1],$b[2],$c0,$c1,$c2);
63 &mul_add_c($a[2],$b[1],$c0,$c1,$c2);
64 &mul_add_c($a[3],$b[0],$c0,$c1,$c2);
65 &st($c0,&QWPw(3,$rp)); &FR($c0); ($c0)=&NR(1);
66 ($c0,$c1,$c2)=($c1,$c2,$c0);
67 &mov("zero",$c2);
68
69 &mul_add_c($a[0],$b[4],$c0,$c1,$c2);
70 &mul_add_c($a[1],$b[3],$c0,$c1,$c2);
71 &mul_add_c($a[2],$b[2],$c0,$c1,$c2);
72 &mul_add_c($a[3],$b[1],$c0,$c1,$c2);
73 &mul_add_c($a[4],$b[0],$c0,$c1,$c2);
74 &st($c0,&QWPw(4,$rp)); &FR($c0); ($c0)=&NR(1);
75 ($c0,$c1,$c2)=($c1,$c2,$c0);
76 &mov("zero",$c2);
77
78 &mul_add_c($a[0],$b[5],$c0,$c1,$c2);
79 &mul_add_c($a[1],$b[4],$c0,$c1,$c2);
80 &mul_add_c($a[2],$b[3],$c0,$c1,$c2);
81 &mul_add_c($a[3],$b[2],$c0,$c1,$c2);
82 &mul_add_c($a[4],$b[1],$c0,$c1,$c2);
83 &mul_add_c($a[5],$b[0],$c0,$c1,$c2);
84 &st($c0,&QWPw(5,$rp)); &FR($c0); ($c0)=&NR(1);
85 ($c0,$c1,$c2)=($c1,$c2,$c0);
86 &mov("zero",$c2);
87
88 &mul_add_c($a[0],$b[6],$c0,$c1,$c2);
89 &mul_add_c($a[1],$b[5],$c0,$c1,$c2);
90 &mul_add_c($a[2],$b[4],$c0,$c1,$c2);
91 &mul_add_c($a[3],$b[3],$c0,$c1,$c2);
92 &mul_add_c($a[4],$b[2],$c0,$c1,$c2);
93 &mul_add_c($a[5],$b[1],$c0,$c1,$c2);
94 &mul_add_c($a[6],$b[0],$c0,$c1,$c2);
95 &st($c0,&QWPw(6,$rp)); &FR($c0); ($c0)=&NR(1);
96 ($c0,$c1,$c2)=($c1,$c2,$c0);
97 &mov("zero",$c2);
98
99 &mul_add_c($a[0],$b[7],$c0,$c1,$c2); &FR($a[0]);
100 &mul_add_c($a[1],$b[6],$c0,$c1,$c2);
101 &mul_add_c($a[2],$b[5],$c0,$c1,$c2);
102 &mul_add_c($a[3],$b[4],$c0,$c1,$c2);
103 &mul_add_c($a[4],$b[3],$c0,$c1,$c2);
104 &mul_add_c($a[5],$b[2],$c0,$c1,$c2);
105 &mul_add_c($a[6],$b[1],$c0,$c1,$c2);
106 &mul_add_c($a[7],$b[0],$c0,$c1,$c2); &FR($b[0]);
107 &st($c0,&QWPw(7,$rp)); &FR($c0); ($c0)=&NR(1);
108 ($c0,$c1,$c2)=($c1,$c2,$c0);
109 &mov("zero",$c2);
110
111 &mul_add_c($a[1],$b[7],$c0,$c1,$c2); &FR($a[1]);
112 &mul_add_c($a[2],$b[6],$c0,$c1,$c2);
113 &mul_add_c($a[3],$b[5],$c0,$c1,$c2);
114 &mul_add_c($a[4],$b[4],$c0,$c1,$c2);
115 &mul_add_c($a[5],$b[3],$c0,$c1,$c2);
116 &mul_add_c($a[6],$b[2],$c0,$c1,$c2);
117 &mul_add_c($a[7],$b[1],$c0,$c1,$c2); &FR($b[1]);
118 &st($c0,&QWPw(8,$rp)); &FR($c0); ($c0)=&NR(1);
119 ($c0,$c1,$c2)=($c1,$c2,$c0);
120 &mov("zero",$c2);
121
122 &mul_add_c($a[2],$b[7],$c0,$c1,$c2); &FR($a[2]);
123 &mul_add_c($a[3],$b[6],$c0,$c1,$c2);
124 &mul_add_c($a[4],$b[5],$c0,$c1,$c2);
125 &mul_add_c($a[5],$b[4],$c0,$c1,$c2);
126 &mul_add_c($a[6],$b[3],$c0,$c1,$c2);
127 &mul_add_c($a[7],$b[2],$c0,$c1,$c2); &FR($b[2]);
128 &st($c0,&QWPw(9,$rp)); &FR($c0); ($c0)=&NR(1);
129 ($c0,$c1,$c2)=($c1,$c2,$c0);
130 &mov("zero",$c2);
131
132 &mul_add_c($a[3],$b[7],$c0,$c1,$c2); &FR($a[3]);
133 &mul_add_c($a[4],$b[6],$c0,$c1,$c2);
134 &mul_add_c($a[5],$b[5],$c0,$c1,$c2);
135 &mul_add_c($a[6],$b[4],$c0,$c1,$c2);
136 &mul_add_c($a[7],$b[3],$c0,$c1,$c2); &FR($b[3]);
137 &st($c0,&QWPw(10,$rp)); &FR($c0); ($c0)=&NR(1);
138 ($c0,$c1,$c2)=($c1,$c2,$c0);
139 &mov("zero",$c2);
140
141 &mul_add_c($a[4],$b[7],$c0,$c1,$c2); &FR($a[4]);
142 &mul_add_c($a[5],$b[6],$c0,$c1,$c2);
143 &mul_add_c($a[6],$b[5],$c0,$c1,$c2);
144 &mul_add_c($a[7],$b[4],$c0,$c1,$c2); &FR($b[4]);
145 &st($c0,&QWPw(11,$rp)); &FR($c0); ($c0)=&NR(1);
146 ($c0,$c1,$c2)=($c1,$c2,$c0);
147 &mov("zero",$c2);
148
149 &mul_add_c($a[5],$b[7],$c0,$c1,$c2); &FR($a[5]);
150 &mul_add_c($a[6],$b[6],$c0,$c1,$c2);
151 &mul_add_c($a[7],$b[5],$c0,$c1,$c2); &FR($b[5]);
152 &st($c0,&QWPw(12,$rp)); &FR($c0); ($c0)=&NR(1);
153 ($c0,$c1,$c2)=($c1,$c2,$c0);
154 &mov("zero",$c2);
155
156 &mul_add_c($a[6],$b[7],$c0,$c1,$c2); &FR($a[6]);
157 &mul_add_c($a[7],$b[6],$c0,$c1,$c2); &FR($b[6]);
158 &st($c0,&QWPw(13,$rp)); &FR($c0); ($c0)=&NR(1);
159 ($c0,$c1,$c2)=($c1,$c2,$c0);
160 &mov("zero",$c2);
161
162 &mul_add_c($a[7],$b[7],$c0,$c1,$c2); &FR($a[7],$b[7]);
163 &st($c0,&QWPw(14,$rp));
164 &st($c1,&QWPw(15,$rp));
165
166 &FR($c0,$c1,$c2);
167
168 &ld($reg_s0,&swtmp(0));
169 &ld($reg_s1,&swtmp(1));
170 &stack_pop(2);
171
172 &function_end($name);
173
174 &fin_pool;
175 }
176
1771;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/sqr.pl b/src/lib/libcrypto/bn/asm/alpha.works/sqr.pl
deleted file mode 100644
index a55b696906..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/sqr.pl
+++ /dev/null
@@ -1,113 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sqr_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(3);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15
16 &function_begin($name,"");
17
18 &comment("");
19 &sub($count,4,$count);
20 &mov("zero",$cc);
21 &br(&label("finish"));
22 &blt($count,&label("finish"));
23
24 ($a0,$r0)=&NR(2);
25 &ld($a0,&QWPw(0,$ap));
26 &ld($r0,&QWPw(0,$rp));
27
28$a=<<'EOF';
29##########################################################
30 &set_label("loop");
31
32 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
33 ($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
34 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
35 ($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
36 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
37 ($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
38
39 ($o0,$t0)=&NR(2);
40 &add($a0,$b0,$o0);
41 &cmpult($o0,$b0,$t0);
42 &add($o0,$cc,$o0);
43 &cmpult($o0,$cc,$cc);
44 &add($cc,$t0,$cc); &FR($t0);
45
46 ($t1,$o1)=&NR(2);
47
48 &add($a1,$b1,$o1); &FR($a1);
49 &cmpult($o1,$b1,$t1); &FR($b1);
50 &add($o1,$cc,$o1);
51 &cmpult($o1,$cc,$cc);
52 &add($cc,$t1,$cc); &FR($t1);
53
54 ($t2,$o2)=&NR(2);
55
56 &add($a2,$b2,$o2); &FR($a2);
57 &cmpult($o2,$b2,$t2); &FR($b2);
58 &add($o2,$cc,$o2);
59 &cmpult($o2,$cc,$cc);
60 &add($cc,$t2,$cc); &FR($t2);
61
62 ($t3,$o3)=&NR(2);
63
64 &add($a3,$b3,$o3); &FR($a3);
65 &cmpult($o3,$b3,$t3); &FR($b3);
66 &add($o3,$cc,$o3);
67 &cmpult($o3,$cc,$cc);
68 &add($cc,$t3,$cc); &FR($t3);
69
70 &st($o0,&QWPw(0,$rp)); &FR($o0);
71 &st($o1,&QWPw(0,$rp)); &FR($o1);
72 &st($o2,&QWPw(0,$rp)); &FR($o2);
73 &st($o3,&QWPw(0,$rp)); &FR($o3);
74
75 &sub($count,4,$count); # count-=4
76 &add($ap,4*$QWS,$ap); # count+=4
77 &add($bp,4*$QWS,$bp); # count+=4
78 &add($rp,4*$QWS,$rp); # count+=4
79
80 &blt($count,&label("finish"));
81 &ld($a0,&QWPw(0,$ap));
82 &ld($b0,&QWPw(0,$bp));
83 &br(&label("loop"));
84EOF
85##################################################
86 # Do the last 0..3 words
87
88 &set_label("last_loop");
89
90 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
91 &mul($a0,$a0,($l0)=&NR(1));
92 &add($ap,$QWS,$ap);
93 &add($rp,2*$QWS,$rp);
94 &sub($count,1,$count);
95 &muh($a0,$a0,($h0)=&NR(1)); &FR($a0);
96 &st($l0,&QWPw(-2,$rp)); &FR($l0);
97 &st($h0,&QWPw(-1,$rp)); &FR($h0);
98
99 &bgt($count,&label("last_loop"));
100 &function_end_A($name);
101
102######################################################
103 &set_label("finish");
104 &add($count,4,$count);
105 &bgt($count,&label("last_loop"));
106
107 &set_label("end");
108 &function_end($name);
109
110 &fin_pool;
111 }
112
1131;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/sqr_c4.pl b/src/lib/libcrypto/bn/asm/alpha.works/sqr_c4.pl
deleted file mode 100644
index bf33f5b503..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/sqr_c4.pl
+++ /dev/null
@@ -1,109 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub sqr_add_c
5 {
6 local($a,$c0,$c1,$c2)=@_;
7 local($l1,$h1,$t1,$t2);
8
9 &mul($a,$a,($l1)=&NR(1));
10 &muh($a,$a,($h1)=&NR(1));
11 &add($c0,$l1,$c0);
12 &add($c1,$h1,$c1);
13 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
14 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
15 &add($c1,$t1,$c1); &FR($t1);
16 &add($c2,$t2,$c2); &FR($t2);
17 }
18
19sub sqr_add_c2
20 {
21 local($a,$b,$c0,$c1,$c2)=@_;
22 local($l1,$h1,$t1,$t2);
23
24 &mul($a,$b,($l1)=&NR(1));
25 &muh($a,$b,($h1)=&NR(1));
26 &cmplt($l1,"zero",($lc1)=&NR(1));
27 &cmplt($h1,"zero",($hc1)=&NR(1));
28 &add($l1,$l1,$l1);
29 &add($h1,$h1,$h1);
30 &add($h1,$lc1,$h1); &FR($lc1);
31 &add($c2,$hc1,$c2); &FR($hc1);
32
33 &add($c0,$l1,$c0);
34 &add($c1,$h1,$c1);
35 &cmpult($c0,$l1,($lc1)=&NR(1)); &FR($l1);
36 &cmpult($c1,$h1,($hc1)=&NR(1)); &FR($h1);
37
38 &add($c1,$lc1,$c1); &FR($lc1);
39 &add($c2,$hc1,$c2); &FR($hc1);
40 }
41
42
43sub bn_sqr_comba4
44 {
45 local($name)=@_;
46 local(@a,@b,$r,$c0,$c1,$c2);
47
48 $cnt=1;
49 &init_pool(2);
50
51 $rp=&wparam(0);
52 $ap=&wparam(1);
53
54 &function_begin($name,"");
55
56 &comment("");
57
58 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
59 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
60 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
61 &ld(($a[3])=&NR(1),&QWPw(3,$ap)); &FR($ap);
62
63 ($c0,$c1,$c2)=&NR(3);
64
65 &mov("zero",$c2);
66 &mul($a[0],$a[0],$c0);
67 &muh($a[0],$a[0],$c1);
68 &st($c0,&QWPw(0,$rp));
69 ($c0,$c1,$c2)=($c1,$c2,$c0);
70 &mov("zero",$c2);
71
72 &sqr_add_c2($a[0],$a[1],$c0,$c1,$c2);
73 &st($c0,&QWPw(1,$rp));
74 ($c0,$c1,$c2)=($c1,$c2,$c0);
75 &mov("zero",$c2);
76
77 &sqr_add_c($a[1],$c0,$c1,$c2);
78 &sqr_add_c2($a[2],$a[0],$c0,$c1,$c2);
79 &st($c0,&QWPw(2,$rp));
80 ($c0,$c1,$c2)=($c1,$c2,$c0);
81 &mov("zero",$c2);
82
83 &sqr_add_c2($a[3],$a[0],$c0,$c1,$c2);
84 &sqr_add_c2($a[2],$a[1],$c0,$c1,$c2);
85 &st($c0,&QWPw(3,$rp));
86 ($c0,$c1,$c2)=($c1,$c2,$c0);
87 &mov("zero",$c2);
88
89 &sqr_add_c($a[2],$c0,$c1,$c2);
90 &sqr_add_c2($a[3],$a[1],$c0,$c1,$c2);
91 &st($c0,&QWPw(4,$rp));
92 ($c0,$c1,$c2)=($c1,$c2,$c0);
93 &mov("zero",$c2);
94
95 &sqr_add_c2($a[3],$a[2],$c0,$c1,$c2);
96 &st($c0,&QWPw(5,$rp));
97 ($c0,$c1,$c2)=($c1,$c2,$c0);
98 &mov("zero",$c2);
99
100 &sqr_add_c($a[3],$c0,$c1,$c2);
101 &st($c0,&QWPw(6,$rp));
102 &st($c1,&QWPw(7,$rp));
103
104 &function_end($name);
105
106 &fin_pool;
107 }
108
1091;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/sqr_c8.pl b/src/lib/libcrypto/bn/asm/alpha.works/sqr_c8.pl
deleted file mode 100644
index b4afe085f1..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/sqr_c8.pl
+++ /dev/null
@@ -1,132 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sqr_comba8
5 {
6 local($name)=@_;
7 local(@a,@b,$r,$c0,$c1,$c2);
8
9 $cnt=1;
10 &init_pool(2);
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14
15 &function_begin($name,"");
16
17 &comment("");
18
19 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
20 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
21 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
22 &ld(($a[3])=&NR(1),&QWPw(3,$ap));
23 &ld(($a[4])=&NR(1),&QWPw(4,$ap));
24 &ld(($a[5])=&NR(1),&QWPw(5,$ap));
25 &ld(($a[6])=&NR(1),&QWPw(6,$ap));
26 &ld(($a[7])=&NR(1),&QWPw(7,$ap)); &FR($ap);
27
28 ($c0,$c1,$c2)=&NR(3);
29
30 &mov("zero",$c2);
31 &mul($a[0],$a[0],$c0);
32 &muh($a[0],$a[0],$c1);
33 &st($c0,&QWPw(0,$rp));
34 ($c0,$c1,$c2)=($c1,$c2,$c0);
35 &mov("zero",$c2);
36
37 &sqr_add_c2($a[1],$a[0],$c0,$c1,$c2);
38 &st($c0,&QWPw(1,$rp));
39 ($c0,$c1,$c2)=($c1,$c2,$c0);
40 &mov("zero",$c2);
41
42 &sqr_add_c($a[1],$c0,$c1,$c2);
43 &sqr_add_c2($a[2],$a[0],$c0,$c1,$c2);
44 &st($c0,&QWPw(2,$rp));
45 ($c0,$c1,$c2)=($c1,$c2,$c0);
46 &mov("zero",$c2);
47
48 &sqr_add_c2($a[2],$a[1],$c0,$c1,$c2);
49 &sqr_add_c2($a[3],$a[0],$c0,$c1,$c2);
50 &st($c0,&QWPw(3,$rp));
51 ($c0,$c1,$c2)=($c1,$c2,$c0);
52 &mov("zero",$c2);
53
54 &sqr_add_c($a[2],$c0,$c1,$c2);
55 &sqr_add_c2($a[3],$a[1],$c0,$c1,$c2);
56 &sqr_add_c2($a[4],$a[0],$c0,$c1,$c2);
57 &st($c0,&QWPw(4,$rp));
58 ($c0,$c1,$c2)=($c1,$c2,$c0);
59 &mov("zero",$c2);
60
61 &sqr_add_c2($a[3],$a[2],$c0,$c1,$c2);
62 &sqr_add_c2($a[4],$a[1],$c0,$c1,$c2);
63 &sqr_add_c2($a[5],$a[0],$c0,$c1,$c2);
64 &st($c0,&QWPw(5,$rp));
65 ($c0,$c1,$c2)=($c1,$c2,$c0);
66 &mov("zero",$c2);
67
68 &sqr_add_c($a[3],$c0,$c1,$c2);
69 &sqr_add_c2($a[4],$a[2],$c0,$c1,$c2);
70 &sqr_add_c2($a[5],$a[1],$c0,$c1,$c2);
71 &sqr_add_c2($a[6],$a[0],$c0,$c1,$c2);
72 &st($c0,&QWPw(6,$rp));
73 ($c0,$c1,$c2)=($c1,$c2,$c0);
74 &mov("zero",$c2);
75
76 &sqr_add_c2($a[4],$a[3],$c0,$c1,$c2);
77 &sqr_add_c2($a[5],$a[2],$c0,$c1,$c2);
78 &sqr_add_c2($a[6],$a[1],$c0,$c1,$c2);
79 &sqr_add_c2($a[7],$a[0],$c0,$c1,$c2);
80 &st($c0,&QWPw(7,$rp));
81 ($c0,$c1,$c2)=($c1,$c2,$c0);
82 &mov("zero",$c2);
83
84 &sqr_add_c($a[4],$c0,$c1,$c2);
85 &sqr_add_c2($a[5],$a[3],$c0,$c1,$c2);
86 &sqr_add_c2($a[6],$a[2],$c0,$c1,$c2);
87 &sqr_add_c2($a[7],$a[1],$c0,$c1,$c2);
88 &st($c0,&QWPw(8,$rp));
89 ($c0,$c1,$c2)=($c1,$c2,$c0);
90 &mov("zero",$c2);
91
92 &sqr_add_c2($a[5],$a[4],$c0,$c1,$c2);
93 &sqr_add_c2($a[6],$a[3],$c0,$c1,$c2);
94 &sqr_add_c2($a[7],$a[2],$c0,$c1,$c2);
95 &st($c0,&QWPw(9,$rp));
96 ($c0,$c1,$c2)=($c1,$c2,$c0);
97 &mov("zero",$c2);
98
99 &sqr_add_c($a[5],$c0,$c1,$c2);
100 &sqr_add_c2($a[6],$a[4],$c0,$c1,$c2);
101 &sqr_add_c2($a[7],$a[3],$c0,$c1,$c2);
102 &st($c0,&QWPw(10,$rp));
103 ($c0,$c1,$c2)=($c1,$c2,$c0);
104 &mov("zero",$c2);
105
106 &sqr_add_c2($a[6],$a[5],$c0,$c1,$c2);
107 &sqr_add_c2($a[7],$a[4],$c0,$c1,$c2);
108 &st($c0,&QWPw(11,$rp));
109 ($c0,$c1,$c2)=($c1,$c2,$c0);
110 &mov("zero",$c2);
111
112 &sqr_add_c($a[6],$c0,$c1,$c2);
113 &sqr_add_c2($a[7],$a[5],$c0,$c1,$c2);
114 &st($c0,&QWPw(12,$rp));
115 ($c0,$c1,$c2)=($c1,$c2,$c0);
116 &mov("zero",$c2);
117
118 &sqr_add_c2($a[7],$a[6],$c0,$c1,$c2);
119 &st($c0,&QWPw(13,$rp));
120 ($c0,$c1,$c2)=($c1,$c2,$c0);
121 &mov("zero",$c2);
122
123 &sqr_add_c($a[7],$c0,$c1,$c2);
124 &st($c0,&QWPw(14,$rp));
125 &st($c1,&QWPw(15,$rp));
126
127 &function_end($name);
128
129 &fin_pool;
130 }
131
1321;
diff --git a/src/lib/libcrypto/bn/asm/alpha.works/sub.pl b/src/lib/libcrypto/bn/asm/alpha.works/sub.pl
deleted file mode 100644
index d998da5c21..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha.works/sub.pl
+++ /dev/null
@@ -1,108 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sub_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15 $count=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &blt($count,&label("finish"));
23
24 ($a0,$b0)=&NR(2);
25 &ld($a0,&QWPw(0,$ap));
26 &ld($b0,&QWPw(0,$bp));
27
28##########################################################
29 &set_label("loop");
30
31 ($a1,$tmp,$b1,$a2,$b2,$a3,$b3,$o0)=&NR(8);
32 &ld($a1,&QWPw(1,$ap));
33 &cmpult($a0,$b0,$tmp); # will we borrow?
34 &ld($b1,&QWPw(1,$bp));
35 &sub($a0,$b0,$a0); # do the subtract
36 &ld($a2,&QWPw(2,$ap));
37 &cmpult($a0,$cc,$b0); # will we borrow?
38 &ld($b2,&QWPw(2,$bp));
39 &sub($a0,$cc,$o0); # will we borrow?
40 &ld($a3,&QWPw(3,$ap));
41 &add($b0,$tmp,$cc); ($t1,$o1)=&NR(2); &FR($tmp);
42
43 &cmpult($a1,$b1,$t1); # will we borrow?
44 &sub($a1,$b1,$a1); # do the subtract
45 &ld($b3,&QWPw(3,$bp));
46 &cmpult($a1,$cc,$b1); # will we borrow?
47 &sub($a1,$cc,$o1); # will we borrow?
48 &add($b1,$t1,$cc); ($tmp,$o2)=&NR(2); &FR($t1,$a1,$b1);
49
50 &cmpult($a2,$b2,$tmp); # will we borrow?
51 &sub($a2,$b2,$a2); # do the subtract
52 &st($o0,&QWPw(0,$rp)); &FR($o0); # save
53 &cmpult($a2,$cc,$b2); # will we borrow?
54 &sub($a2,$cc,$o2); # will we borrow?
55 &add($b2,$tmp,$cc); ($t3,$o3)=&NR(2); &FR($tmp,$a2,$b2);
56
57 &cmpult($a3,$b3,$t3); # will we borrow?
58 &sub($a3,$b3,$a3); # do the subtract
59 &st($o1,&QWPw(1,$rp)); &FR($o1);
60 &cmpult($a3,$cc,$b3); # will we borrow?
61 &sub($a3,$cc,$o3); # will we borrow?
62 &add($b3,$t3,$cc); &FR($t3,$a3,$b3);
63
64 &st($o2,&QWPw(2,$rp)); &FR($o2);
65 &sub($count,4,$count); # count-=4
66 &st($o3,&QWPw(3,$rp)); &FR($o3);
67 &add($ap,4*$QWS,$ap); # count+=4
68 &add($bp,4*$QWS,$bp); # count+=4
69 &add($rp,4*$QWS,$rp); # count+=4
70
71 &blt($count,&label("finish"));
72 &ld($a0,&QWPw(0,$ap));
73 &ld($b0,&QWPw(0,$bp));
74 &br(&label("loop"));
75##################################################
76 # Do the last 0..3 words
77
78 &set_label("last_loop");
79
80 &ld($a0,&QWPw(0,$ap)); # get a
81 &ld($b0,&QWPw(0,$bp)); # get b
82 &cmpult($a0,$b0,$tmp); # will we borrow?
83 &sub($a0,$b0,$a0); # do the subtract
84 &cmpult($a0,$cc,$b0); # will we borrow?
85 &sub($a0,$cc,$a0); # will we borrow?
86 &st($a0,&QWPw(0,$rp)); # save
87 &add($b0,$tmp,$cc); # add the borrows
88
89 &add($ap,$QWS,$ap);
90 &add($bp,$QWS,$bp);
91 &add($rp,$QWS,$rp);
92 &sub($count,1,$count);
93 &bgt($count,&label("last_loop"));
94 &function_end_A($name);
95
96######################################################
97 &set_label("finish");
98 &add($count,4,$count);
99 &bgt($count,&label("last_loop"));
100
101 &FR($a0,$b0);
102 &set_label("end");
103 &function_end($name);
104
105 &fin_pool;
106 }
107
1081;
diff --git a/src/lib/libcrypto/bn/asm/alpha/add.pl b/src/lib/libcrypto/bn/asm/alpha/add.pl
deleted file mode 100644
index 13bf516428..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/add.pl
+++ /dev/null
@@ -1,118 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_add_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15 $count=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &blt($count,&label("finish"));
23
24 ($a0,$b0)=&NR(2);
25
26##########################################################
27 &set_label("loop");
28
29 &ld(($a0)=&NR(1),&QWPw(0,$ap));
30 &ld(($b0)=&NR(1),&QWPw(0,$bp));
31 &ld(($a1)=&NR(1),&QWPw(1,$ap));
32 &ld(($b1)=&NR(1),&QWPw(1,$bp));
33
34 ($o0,$t0)=&NR(2);
35 &add($a0,$b0,$o0);
36 &ld(($a2)=&NR(1),&QWPw(2,$ap));
37 &cmpult($o0,$b0,$t0);
38 &add($o0,$cc,$o0);
39 &cmpult($o0,$cc,$cc);
40 &ld(($b2)=&NR(1),&QWPw(2,$bp));
41 &add($cc,$t0,$cc); &FR($t0);
42
43 ($t1,$o1)=&NR(2);
44
45 &add($a1,$b1,$o1); &FR($a1);
46 &cmpult($o1,$b1,$t1); &FR($b1);
47 &add($o1,$cc,$o1);
48 &cmpult($o1,$cc,$cc);
49 &ld(($a3)=&NR(1),&QWPw(3,$ap));
50 &add($cc,$t1,$cc); &FR($t1);
51
52 ($t2,$o2)=&NR(2);
53
54 &add($a2,$b2,$o2); &FR($a2);
55 &cmpult($o2,$b2,$t2); &FR($b2);
56 &add($o2,$cc,$o2);
57 &cmpult($o2,$cc,$cc);
58 &ld(($b3)=&NR(1),&QWPw(3,$bp));
59 &st($o0,&QWPw(0,$rp)); &FR($o0);
60 &add($cc,$t2,$cc); &FR($t2);
61
62 ($t3,$o3)=&NR(2);
63
64 &st($o1,&QWPw(0,$rp)); &FR($o1);
65 &add($a3,$b3,$o3); &FR($a3);
66 &cmpult($o3,$b3,$t3); &FR($b3);
67 &add($o3,$cc,$o3);
68 &st($o2,&QWPw(0,$rp)); &FR($o2);
69 &cmpult($o3,$cc,$cc);
70 &st($o3,&QWPw(0,$rp)); &FR($o3);
71 &add($cc,$t3,$cc); &FR($t3);
72
73
74 &sub($count,4,$count); # count-=4
75 &add($ap,4*$QWS,$ap); # count+=4
76 &add($bp,4*$QWS,$bp); # count+=4
77 &add($rp,4*$QWS,$rp); # count+=4
78
79 ###
80 &bge($count,&label("loop"));
81 ###
82 &br(&label("finish"));
83##################################################
84 # Do the last 0..3 words
85
86 ($t0,$o0)=&NR(2);
87 &set_label("last_loop");
88
89 &ld($a0,&QWPw(0,$ap)); # get a
90 &ld($b0,&QWPw(0,$bp)); # get b
91 &add($ap,$QWS,$ap);
92 &add($bp,$QWS,$bp);
93 &add($a0,$b0,$o0);
94 &sub($count,1,$count);
95 &cmpult($o0,$b0,$t0); # will we borrow?
96 &add($o0,$cc,$o0); # will we borrow?
97 &cmpult($o0,$cc,$cc); # will we borrow?
98 &add($rp,$QWS,$rp);
99 &st($o0,&QWPw(-1,$rp)); # save
100 &add($cc,$t0,$cc); # add the borrows
101
102 ###
103 &bgt($count,&label("last_loop"));
104 &function_end_A($name);
105
106######################################################
107 &set_label("finish");
108 &add($count,4,$count);
109 &bgt($count,&label("last_loop"));
110
111 &FR($o0,$t0,$a0,$b0);
112 &set_label("end");
113 &function_end($name);
114
115 &fin_pool;
116 }
117
1181;
diff --git a/src/lib/libcrypto/bn/asm/alpha/div.pl b/src/lib/libcrypto/bn/asm/alpha/div.pl
deleted file mode 100644
index e9e680897a..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/div.pl
+++ /dev/null
@@ -1,144 +0,0 @@
1#!/usr/local/bin/perl
2
3sub bn_div_words
4 {
5 local($data)=<<'EOF';
6 #
7 # What follows was taken directly from the C compiler with a few
8 # hacks to redo the lables.
9 #
10.text
11 .set noreorder
12 .set volatile
13 .align 3
14 .globl bn_div_words
15 .ent bn_div_words
16bn_div_words
17 ldgp $29,0($27)
18bn_div_words.ng:
19 lda $30,-48($30)
20 .frame $30,48,$26,0
21 stq $26,0($30)
22 stq $9,8($30)
23 stq $10,16($30)
24 stq $11,24($30)
25 stq $12,32($30)
26 stq $13,40($30)
27 .mask 0x4003e00,-48
28 .prologue 1
29 bis $16,$16,$9
30 bis $17,$17,$10
31 bis $18,$18,$11
32 bis $31,$31,$13
33 bis $31,2,$12
34 bne $11,$9119
35 lda $0,-1
36 br $31,$9136
37 .align 4
38$9119:
39 bis $11,$11,$16
40 jsr $26,BN_num_bits_word
41 ldgp $29,0($26)
42 subq $0,64,$1
43 beq $1,$9120
44 bis $31,1,$1
45 sll $1,$0,$1
46 cmpule $9,$1,$1
47 bne $1,$9120
48 # lda $16,_IO_stderr_
49 # lda $17,$C32
50 # bis $0,$0,$18
51 # jsr $26,fprintf
52 # ldgp $29,0($26)
53 jsr $26,abort
54 ldgp $29,0($26)
55 .align 4
56$9120:
57 bis $31,64,$3
58 cmpult $9,$11,$2
59 subq $3,$0,$1
60 addl $1,$31,$0
61 subq $9,$11,$1
62 cmoveq $2,$1,$9
63 beq $0,$9122
64 zapnot $0,15,$2
65 subq $3,$0,$1
66 sll $11,$2,$11
67 sll $9,$2,$3
68 srl $10,$1,$1
69 sll $10,$2,$10
70 bis $3,$1,$9
71$9122:
72 srl $11,32,$5
73 zapnot $11,15,$6
74 lda $7,-1
75 .align 5
76$9123:
77 srl $9,32,$1
78 subq $1,$5,$1
79 bne $1,$9126
80 zapnot $7,15,$27
81 br $31,$9127
82 .align 4
83$9126:
84 bis $9,$9,$24
85 bis $5,$5,$25
86 divqu $24,$25,$27
87$9127:
88 srl $10,32,$4
89 .align 5
90$9128:
91 mulq $27,$5,$1
92 subq $9,$1,$3
93 zapnot $3,240,$1
94 bne $1,$9129
95 mulq $6,$27,$2
96 sll $3,32,$1
97 addq $1,$4,$1
98 cmpule $2,$1,$2
99 bne $2,$9129
100 subq $27,1,$27
101 br $31,$9128
102 .align 4
103$9129:
104 mulq $27,$6,$1
105 mulq $27,$5,$4
106 srl $1,32,$3
107 sll $1,32,$1
108 addq $4,$3,$4
109 cmpult $10,$1,$2
110 subq $10,$1,$10
111 addq $2,$4,$2
112 cmpult $9,$2,$1
113 bis $2,$2,$4
114 beq $1,$9134
115 addq $9,$11,$9
116 subq $27,1,$27
117$9134:
118 subl $12,1,$12
119 subq $9,$4,$9
120 beq $12,$9124
121 sll $27,32,$13
122 sll $9,32,$2
123 srl $10,32,$1
124 sll $10,32,$10
125 bis $2,$1,$9
126 br $31,$9123
127 .align 4
128$9124:
129 bis $13,$27,$0
130$9136:
131 ldq $26,0($30)
132 ldq $9,8($30)
133 ldq $10,16($30)
134 ldq $11,24($30)
135 ldq $12,32($30)
136 ldq $13,40($30)
137 addq $30,48,$30
138 ret $31,($26),1
139 .end bn_div_words
140EOF
141 &asm_add($data);
142 }
143
1441;
diff --git a/src/lib/libcrypto/bn/asm/alpha/mul.pl b/src/lib/libcrypto/bn/asm/alpha/mul.pl
deleted file mode 100644
index 76c926566c..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/mul.pl
+++ /dev/null
@@ -1,104 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15 $word=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 ###
23 &blt($count,&label("finish"));
24
25 ($a0)=&NR(1); &ld($a0,&QWPw(0,$ap));
26
27 &set_label("loop");
28
29 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
30 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
31
32 &muh($a0,$word,($h0)=&NR(1)); &FR($a0);
33 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
34 ### wait 8
35 &mul($a0,$word,($l0)=&NR(1)); &FR($a0);
36 ### wait 8
37 &muh($a1,$word,($h1)=&NR(1)); &FR($a1);
38 &add($l0,$cc,$l0); ### wait 8
39 &mul($a1,$word,($l1)=&NR(1)); &FR($a1);
40 &cmpult($l0,$cc,$cc); ### wait 8
41 &muh($a2,$word,($h2)=&NR(1)); &FR($a2);
42 &add($h0,$cc,$cc); &FR($h0); ### wait 8
43 &mul($a2,$word,($l2)=&NR(1)); &FR($a2);
44 &add($l1,$cc,$l1); ### wait 8
45 &st($l0,&QWPw(0,$rp)); &FR($l0);
46 &cmpult($l1,$cc,$cc); ### wait 8
47 &muh($a3,$word,($h3)=&NR(1)); &FR($a3);
48 &add($h1,$cc,$cc); &FR($h1);
49 &mul($a3,$word,($l3)=&NR(1)); &FR($a3);
50 &add($l2,$cc,$l2);
51 &st($l1,&QWPw(1,$rp)); &FR($l1);
52 &cmpult($l2,$cc,$cc);
53 &add($h2,$cc,$cc); &FR($h2);
54 &sub($count,4,$count); # count-=4
55 &st($l2,&QWPw(2,$rp)); &FR($l2);
56 &add($l3,$cc,$l3);
57 &cmpult($l3,$cc,$cc);
58 &add($bp,4*$QWS,$bp); # count+=4
59 &add($h3,$cc,$cc); &FR($h3);
60 &add($ap,4*$QWS,$ap); # count+=4
61 &st($l3,&QWPw(3,$rp)); &FR($l3);
62 &add($rp,4*$QWS,$rp); # count+=4
63 ###
64 &blt($count,&label("finish"));
65 ($a0)=&NR(1); &ld($a0,&QWPw(0,$ap));
66 &br(&label("finish"));
67##################################################
68
69##################################################
70 # Do the last 0..3 words
71
72 &set_label("last_loop");
73
74 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
75 ###
76 ###
77 ###
78 &muh($a0,$word,($h0)=&NR(1));
79 ### Wait 8 for next mul issue
80 &mul($a0,$word,($l0)=&NR(1)); &FR($a0)
81 &add($ap,$QWS,$ap);
82 ### Loose 12 until result is available
83 &add($rp,$QWS,$rp);
84 &sub($count,1,$count);
85 &add($l0,$cc,$l0);
86 ###
87 &st($l0,&QWPw(-1,$rp)); &FR($l0);
88 &cmpult($l0,$cc,$cc);
89 &add($h0,$cc,$cc); &FR($h0);
90 &bgt($count,&label("last_loop"));
91 &function_end_A($name);
92
93######################################################
94 &set_label("finish");
95 &add($count,4,$count);
96 &bgt($count,&label("last_loop"));
97
98 &set_label("end");
99 &function_end($name);
100
101 &fin_pool;
102 }
103
1041;
diff --git a/src/lib/libcrypto/bn/asm/alpha/mul_add.pl b/src/lib/libcrypto/bn/asm/alpha/mul_add.pl
deleted file mode 100644
index 0d6df69bc4..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/mul_add.pl
+++ /dev/null
@@ -1,123 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_add_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15 $word=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 ###
23 &blt($count,&label("finish"));
24
25 &ld(($a0)=&NR(1),&QWPw(0,$ap));
26
27$a=<<'EOF';
28##########################################################
29 &set_label("loop");
30
31 &ld(($r0)=&NR(1),&QWPw(0,$rp));
32 &ld(($a1)=&NR(1),&QWPw(1,$ap));
33 &muh($a0,$word,($h0)=&NR(1));
34 &ld(($r1)=&NR(1),&QWPw(1,$rp));
35 &ld(($a2)=&NR(1),&QWPw(2,$ap));
36 ###
37 &mul($a0,$word,($l0)=&NR(1)); &FR($a0);
38 &ld(($r2)=&NR(1),&QWPw(2,$rp));
39 &muh($a1,$word,($h1)=&NR(1));
40 &ld(($a3)=&NR(1),&QWPw(3,$ap));
41 &mul($a1,$word,($l1)=&NR(1)); &FR($a1);
42 &ld(($r3)=&NR(1),&QWPw(3,$rp));
43 &add($r0,$l0,$r0);
44 &add($r1,$l1,$r1);
45 &cmpult($r0,$l0,($t0)=&NR(1)); &FR($l0);
46 &cmpult($r1,$l1,($t1)=&NR(1)); &FR($l1);
47 &muh($a2,$word,($h2)=&NR(1));
48 &add($r0,$cc,$r0);
49 &add($h0,$t0,$h0); &FR($t0);
50 &cmpult($r0,$cc,$cc);
51 &add($h1,$t1,$h1); &FR($t1);
52 &add($h0,$cc,$cc); &FR($h0);
53 &mul($a2,$word,($l2)=&NR(1)); &FR($a2);
54 &add($r1,$cc,$r1);
55 &cmpult($r1,$cc,$cc);
56 &add($r2,$l2,$r2);
57 &add($h1,$cc,$cc); &FR($h1);
58 &cmpult($r2,$l2,($t2)=&NR(1)); &FR($l2);
59 &muh($a3,$word,($h3)=&NR(1));
60 &add($r2,$cc,$r2);
61 &st($r0,&QWPw(0,$rp)); &FR($r0);
62 &add($h2,$t2,$h2); &FR($t2);
63 &st($r1,&QWPw(1,$rp)); &FR($r1);
64 &cmpult($r2,$cc,$cc);
65 &mul($a3,$word,($l3)=&NR(1)); &FR($a3);
66 &add($h2,$cc,$cc); &FR($h2);
67 &st($r2,&QWPw(2,$rp)); &FR($r2);
68 &sub($count,4,$count); # count-=4
69 &add($rp,4*$QWS,$rp); # count+=4
70 &add($r3,$l3,$r3);
71 &add($ap,4*$QWS,$ap); # count+=4
72 &cmpult($r3,$l3,($t3)=&NR(1)); &FR($l3);
73 &add($r3,$cc,$r3);
74 &add($h3,$t3,$h3); &FR($t3);
75 &cmpult($r3,$cc,$cc);
76 &st($r3,&QWPw(-1,$rp)); &FR($r3);
77 &add($h3,$cc,$cc); &FR($h3);
78
79 ###
80 &blt($count,&label("finish"));
81 &ld(($a0)=&NR(1),&QWPw(0,$ap));
82 &br(&label("loop"));
83EOF
84##################################################
85 # Do the last 0..3 words
86
87 &set_label("last_loop");
88
89 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
90 &ld(($r0)=&NR(1),&QWPw(0,$rp)); # get b
91 ###
92 ###
93 &muh($a0,$word,($h0)=&NR(1)); &FR($a0);
94 ### wait 8
95 &mul($a0,$word,($l0)=&NR(1)); &FR($a0);
96 &add($rp,$QWS,$rp);
97 &add($ap,$QWS,$ap);
98 &sub($count,1,$count);
99 ### wait 3 until l0 is available
100 &add($r0,$l0,$r0);
101 ###
102 &cmpult($r0,$l0,($t0)=&NR(1)); &FR($l0);
103 &add($r0,$cc,$r0);
104 &add($h0,$t0,$h0); &FR($t0);
105 &cmpult($r0,$cc,$cc);
106 &add($h0,$cc,$cc); &FR($h0);
107
108 &st($r0,&QWPw(-1,$rp)); &FR($r0);
109 &bgt($count,&label("last_loop"));
110 &function_end_A($name);
111
112######################################################
113 &set_label("finish");
114 &add($count,4,$count);
115 &bgt($count,&label("last_loop"));
116
117 &set_label("end");
118 &function_end($name);
119
120 &fin_pool;
121 }
122
1231;
diff --git a/src/lib/libcrypto/bn/asm/alpha/mul_c4.pl b/src/lib/libcrypto/bn/asm/alpha/mul_c4.pl
deleted file mode 100644
index 9cc876ded4..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/mul_c4.pl
+++ /dev/null
@@ -1,215 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4# upto
5
6sub mul_add_c
7 {
8 local($a,$b,$c0,$c1,$c2)=@_;
9 local($l1,$h1,$t1,$t2);
10
11 &mul($a,$b,($l1)=&NR(1));
12 &muh($a,$b,($h1)=&NR(1));
13 &add($c0,$l1,$c0);
14 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
15 &add($t1,$h1,$h1); &FR($t1);
16 &add($c1,$h1,$c1);
17 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
18 &add($c2,$t2,$c2); &FR($t2);
19 }
20
21sub bn_mul_comba4
22 {
23 local($name)=@_;
24 local(@a,@b,$r,$c0,$c1,$c2);
25
26 $cnt=1;
27 &init_pool(3);
28
29 $rp=&wparam(0);
30 $ap=&wparam(1);
31 $bp=&wparam(2);
32
33 &function_begin($name,"");
34
35 &comment("");
36
37 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
38 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
39 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
40 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
41 &mul($a[0],$b[0],($r00)=&NR(1));
42 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
43 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
44 &muh($a[0],$b[0],($r01)=&NR(1));
45 &FR($ap); &ld(($a[3])=&NR(1),&QWPw(3,$ap));
46 &FR($bp); &ld(($b[3])=&NR(1),&QWPw(3,$bp));
47 &mul($a[0],$b[1],($r02)=&NR(1));
48
49 ($R,$H1,$H2)=&NR(3);
50
51 &st($r00,&QWPw(0,$rp)); &FR($r00);
52
53 &mov("zero",$R);
54 &mul($a[1],$b[0],($r03)=&NR(1));
55
56 &mov("zero",$H1);
57 &mov("zero",$H0);
58 &add($R,$r01,$R);
59 &muh($a[0],$b[1],($r04)=&NR(1));
60 &cmpult($R,$r01,($t01)=&NR(1)); &FR($r01);
61 &add($R,$r02,$R);
62 &add($H1,$t01,$H1) &FR($t01);
63 &muh($a[1],$b[0],($r05)=&NR(1));
64 &cmpult($R,$r02,($t02)=&NR(1)); &FR($r02);
65 &add($R,$r03,$R);
66 &add($H2,$t02,$H2) &FR($t02);
67 &mul($a[0],$b[2],($r06)=&NR(1));
68 &cmpult($R,$r03,($t03)=&NR(1)); &FR($r03);
69 &add($H1,$t03,$H1) &FR($t03);
70 &st($R,&QWPw(1,$rp));
71 &add($H1,$H2,$R);
72
73 &mov("zero",$H1);
74 &add($R,$r04,$R);
75 &mov("zero",$H2);
76 &mul($a[1],$b[1],($r07)=&NR(1));
77 &cmpult($R,$r04,($t04)=&NR(1)); &FR($r04);
78 &add($R,$r05,$R);
79 &add($H1,$t04,$H1) &FR($t04);
80 &mul($a[2],$b[0],($r08)=&NR(1));
81 &cmpult($R,$r05,($t05)=&NR(1)); &FR($r05);
82 &add($R,$r01,$R);
83 &add($H2,$t05,$H2) &FR($t05);
84 &muh($a[0],$b[2],($r09)=&NR(1));
85 &cmpult($R,$r06,($t06)=&NR(1)); &FR($r06);
86 &add($R,$r07,$R);
87 &add($H1,$t06,$H1) &FR($t06);
88 &muh($a[1],$b[1],($r10)=&NR(1));
89 &cmpult($R,$r07,($t07)=&NR(1)); &FR($r07);
90 &add($R,$r08,$R);
91 &add($H2,$t07,$H2) &FR($t07);
92 &muh($a[2],$b[0],($r11)=&NR(1));
93 &cmpult($R,$r08,($t08)=&NR(1)); &FR($r08);
94 &add($H1,$t08,$H1) &FR($t08);
95 &st($R,&QWPw(2,$rp));
96 &add($H1,$H2,$R);
97
98 &mov("zero",$H1);
99 &add($R,$r09,$R);
100 &mov("zero",$H2);
101 &mul($a[0],$b[3],($r12)=&NR(1));
102 &cmpult($R,$r09,($t09)=&NR(1)); &FR($r09);
103 &add($R,$r10,$R);
104 &add($H1,$t09,$H1) &FR($t09);
105 &mul($a[1],$b[2],($r13)=&NR(1));
106 &cmpult($R,$r10,($t10)=&NR(1)); &FR($r10);
107 &add($R,$r11,$R);
108 &add($H1,$t10,$H1) &FR($t10);
109 &mul($a[2],$b[1],($r14)=&NR(1));
110 &cmpult($R,$r11,($t11)=&NR(1)); &FR($r11);
111 &add($R,$r12,$R);
112 &add($H1,$t11,$H1) &FR($t11);
113 &mul($a[3],$b[0],($r15)=&NR(1));
114 &cmpult($R,$r12,($t12)=&NR(1)); &FR($r12);
115 &add($R,$r13,$R);
116 &add($H1,$t12,$H1) &FR($t12);
117 &muh($a[0],$b[3],($r16)=&NR(1));
118 &cmpult($R,$r13,($t13)=&NR(1)); &FR($r13);
119 &add($R,$r14,$R);
120 &add($H1,$t13,$H1) &FR($t13);
121 &muh($a[1],$b[2],($r17)=&NR(1));
122 &cmpult($R,$r14,($t14)=&NR(1)); &FR($r14);
123 &add($R,$r15,$R);
124 &add($H1,$t14,$H1) &FR($t14);
125 &muh($a[2],$b[1],($r18)=&NR(1));
126 &cmpult($R,$r15,($t15)=&NR(1)); &FR($r15);
127 &add($H1,$t15,$H1) &FR($t15);
128 &st($R,&QWPw(3,$rp));
129 &add($H1,$H2,$R);
130
131 &mov("zero",$H1);
132 &add($R,$r16,$R);
133 &mov("zero",$H2);
134 &muh($a[3],$b[0],($r19)=&NR(1));
135 &cmpult($R,$r16,($t16)=&NR(1)); &FR($r16);
136 &add($R,$r17,$R);
137 &add($H1,$t16,$H1) &FR($t16);
138 &mul($a[1],$b[3],($r20)=&NR(1));
139 &cmpult($R,$r17,($t17)=&NR(1)); &FR($r17);
140 &add($R,$r18,$R);
141 &add($H1,$t17,$H1) &FR($t17);
142 &mul($a[2],$b[2],($r21)=&NR(1));
143 &cmpult($R,$r18,($t18)=&NR(1)); &FR($r18);
144 &add($R,$r19,$R);
145 &add($H1,$t18,$H1) &FR($t18);
146 &mul($a[3],$b[1],($r22)=&NR(1));
147 &cmpult($R,$r19,($t19)=&NR(1)); &FR($r19);
148 &add($R,$r20,$R);
149 &add($H1,$t19,$H1) &FR($t19);
150 &muh($a[1],$b[3],($r23)=&NR(1));
151 &cmpult($R,$r20,($t20)=&NR(1)); &FR($r20);
152 &add($R,$r21,$R);
153 &add($H1,$t20,$H1) &FR($t20);
154 &muh($a[2],$b[2],($r24)=&NR(1));
155 &cmpult($R,$r21,($t21)=&NR(1)); &FR($r21);
156 &add($R,$r22,$R);
157 &add($H1,$t21,$H1) &FR($t21);
158 &muh($a[3],$b[1],($r25)=&NR(1));
159 &cmpult($R,$r22,($t22)=&NR(1)); &FR($r22);
160 &add($H1,$t22,$H1) &FR($t22);
161 &st($R,&QWPw(4,$rp));
162 &add($H1,$H2,$R);
163
164 &mov("zero",$H1);
165 &add($R,$r23,$R);
166 &mov("zero",$H2);
167 &mul($a[2],$b[3],($r26)=&NR(1));
168 &cmpult($R,$r23,($t23)=&NR(1)); &FR($r23);
169 &add($R,$r24,$R);
170 &add($H1,$t23,$H1) &FR($t23);
171 &mul($a[3],$b[2],($r27)=&NR(1));
172 &cmpult($R,$r24,($t24)=&NR(1)); &FR($r24);
173 &add($R,$r25,$R);
174 &add($H1,$t24,$H1) &FR($t24);
175 &muh($a[2],$b[3],($r28)=&NR(1));
176 &cmpult($R,$r25,($t25)=&NR(1)); &FR($r25);
177 &add($R,$r26,$R);
178 &add($H1,$t25,$H1) &FR($t25);
179 &muh($a[3],$b[2],($r29)=&NR(1));
180 &cmpult($R,$r26,($t26)=&NR(1)); &FR($r26);
181 &add($R,$r27,$R);
182 &add($H1,$t26,$H1) &FR($t26);
183 &mul($a[3],$b[3],($r30)=&NR(1));
184 &cmpult($R,$r27,($t27)=&NR(1)); &FR($r27);
185 &add($H1,$t27,$H1) &FR($t27);
186 &st($R,&QWPw(5,$rp));
187 &add($H1,$H2,$R);
188
189 &mov("zero",$H1);
190 &add($R,$r28,$R);
191 &mov("zero",$H2);
192 &muh($a[3],$b[3],($r31)=&NR(1));
193 &cmpult($R,$r28,($t28)=&NR(1)); &FR($r28);
194 &add($R,$r29,$R);
195 &add($H1,$t28,$H1) &FR($t28);
196 ############
197 &cmpult($R,$r29,($t29)=&NR(1)); &FR($r29);
198 &add($R,$r30,$R);
199 &add($H1,$t29,$H1) &FR($t29);
200 ############
201 &cmpult($R,$r30,($t30)=&NR(1)); &FR($r30);
202 &add($H1,$t30,$H1) &FR($t30);
203 &st($R,&QWPw(6,$rp));
204 &add($H1,$H2,$R);
205
206 &add($R,$r31,$R); &FR($r31);
207 &st($R,&QWPw(7,$rp));
208
209 &FR($R,$H1,$H2);
210 &function_end($name);
211
212 &fin_pool;
213 }
214
2151;
diff --git a/src/lib/libcrypto/bn/asm/alpha/mul_c4.works.pl b/src/lib/libcrypto/bn/asm/alpha/mul_c4.works.pl
deleted file mode 100644
index 79d86dd25c..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/mul_c4.works.pl
+++ /dev/null
@@ -1,98 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub mul_add_c
5 {
6 local($a,$b,$c0,$c1,$c2)=@_;
7 local($l1,$h1,$t1,$t2);
8
9print STDERR "count=$cnt\n"; $cnt++;
10 &mul($a,$b,($l1)=&NR(1));
11 &muh($a,$b,($h1)=&NR(1));
12 &add($c0,$l1,$c0);
13 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
14 &add($t1,$h1,$h1); &FR($t1);
15 &add($c1,$h1,$c1);
16 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
17 &add($c2,$t2,$c2); &FR($t2);
18 }
19
20sub bn_mul_comba4
21 {
22 local($name)=@_;
23 local(@a,@b,$r,$c0,$c1,$c2);
24
25 $cnt=1;
26 &init_pool(3);
27
28 $rp=&wparam(0);
29 $ap=&wparam(1);
30 $bp=&wparam(2);
31
32 &function_begin($name,"");
33
34 &comment("");
35
36 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
37 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
38 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
39 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
40 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
41 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
42 &ld(($a[3])=&NR(1),&QWPw(3,$ap)); &FR($ap);
43 &ld(($b[3])=&NR(1),&QWPw(3,$bp)); &FR($bp);
44
45 ($c0,$c1,$c2)=&NR(3);
46 &mov("zero",$c2);
47 &mul($a[0],$b[0],$c0);
48 &muh($a[0],$b[0],$c1);
49 &st($c0,&QWPw(0,$rp)); &FR($c0); ($c0)=&NR($c0);
50 ($c0,$c1,$c2)=($c1,$c2,$c0);
51 &mov("zero",$c2);
52
53 &mul_add_c($a[0],$b[1],$c0,$c1,$c2);
54 &mul_add_c($a[1],$b[0],$c0,$c1,$c2);
55 &st($c0,&QWPw(1,$rp)); &FR($c0); ($c0)=&NR($c0);
56 ($c0,$c1,$c2)=($c1,$c2,$c0);
57 &mov("zero",$c2);
58
59 &mul_add_c($a[1],$b[1],$c0,$c1,$c2);
60 &mul_add_c($a[0],$b[2],$c0,$c1,$c2);
61 &mul_add_c($a[2],$b[0],$c0,$c1,$c2);
62 &st($c0,&QWPw(2,$rp)); &FR($c0); ($c0)=&NR($c0);
63 ($c0,$c1,$c2)=($c1,$c2,$c0);
64 &mov("zero",$c2);
65
66 &mul_add_c($a[0],$b[3],$c0,$c1,$c2); &FR($a[0]);
67 &mul_add_c($a[1],$b[2],$c0,$c1,$c2);
68 &mul_add_c($a[2],$b[1],$c0,$c1,$c2);
69 &mul_add_c($a[3],$b[0],$c0,$c1,$c2); &FR($b[0]);
70 &st($c0,&QWPw(3,$rp)); &FR($c0); ($c0)=&NR($c0);
71 ($c0,$c1,$c2)=($c1,$c2,$c0);
72 &mov("zero",$c2);
73
74 &mul_add_c($a[1],$b[3],$c0,$c1,$c2); &FR($a[1]);
75 &mul_add_c($a[2],$b[2],$c0,$c1,$c2);
76 &mul_add_c($a[3],$b[1],$c0,$c1,$c2); &FR($b[1]);
77 &st($c0,&QWPw(4,$rp)); &FR($c0); ($c0)=&NR($c0);
78 ($c0,$c1,$c2)=($c1,$c2,$c0);
79 &mov("zero",$c2);
80
81 &mul_add_c($a[2],$b[3],$c0,$c1,$c2); &FR($a[2]);
82 &mul_add_c($a[3],$b[2],$c0,$c1,$c2); &FR($b[2]);
83 &st($c0,&QWPw(5,$rp)); &FR($c0); ($c0)=&NR($c0);
84 ($c0,$c1,$c2)=($c1,$c2,$c0);
85 &mov("zero",$c2);
86
87 &mul_add_c($a[3],$b[3],$c0,$c1,$c2); &FR($a[3],$b[3]);
88 &st($c0,&QWPw(6,$rp));
89 &st($c1,&QWPw(7,$rp));
90
91 &FR($c0,$c1,$c2);
92
93 &function_end($name);
94
95 &fin_pool;
96 }
97
981;
diff --git a/src/lib/libcrypto/bn/asm/alpha/mul_c8.pl b/src/lib/libcrypto/bn/asm/alpha/mul_c8.pl
deleted file mode 100644
index 525ca7494b..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/mul_c8.pl
+++ /dev/null
@@ -1,177 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_mul_comba8
5 {
6 local($name)=@_;
7 local(@a,@b,$r,$c0,$c1,$c2);
8
9 $cnt=1;
10 &init_pool(3);
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15
16 &function_begin($name,"");
17
18 &comment("");
19
20 &stack_push(2);
21 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
22 &ld(($b[0])=&NR(1),&QWPw(0,$bp));
23 &st($reg_s0,&swtmp(0)); &FR($reg_s0);
24 &st($reg_s1,&swtmp(1)); &FR($reg_s1);
25 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
26 &ld(($b[1])=&NR(1),&QWPw(1,$bp));
27 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
28 &ld(($b[2])=&NR(1),&QWPw(2,$bp));
29 &ld(($a[3])=&NR(1),&QWPw(3,$ap));
30 &ld(($b[3])=&NR(1),&QWPw(3,$bp));
31 &ld(($a[4])=&NR(1),&QWPw(1,$ap));
32 &ld(($b[4])=&NR(1),&QWPw(1,$bp));
33 &ld(($a[5])=&NR(1),&QWPw(1,$ap));
34 &ld(($b[5])=&NR(1),&QWPw(1,$bp));
35 &ld(($a[6])=&NR(1),&QWPw(1,$ap));
36 &ld(($b[6])=&NR(1),&QWPw(1,$bp));
37 &ld(($a[7])=&NR(1),&QWPw(1,$ap)); &FR($ap);
38 &ld(($b[7])=&NR(1),&QWPw(1,$bp)); &FR($bp);
39
40 ($c0,$c1,$c2)=&NR(3);
41 &mov("zero",$c2);
42 &mul($a[0],$b[0],$c0);
43 &muh($a[0],$b[0],$c1);
44 &st($c0,&QWPw(0,$rp)); &FR($c0); ($c0)=&NR(1);
45 ($c0,$c1,$c2)=($c1,$c2,$c0);
46 &mov("zero",$c2);
47
48 &mul_add_c($a[0],$b[1],$c0,$c1,$c2);
49 &mul_add_c($a[1],$b[0],$c0,$c1,$c2);
50 &st($c0,&QWPw(1,$rp)); &FR($c0); ($c0)=&NR(1);
51 ($c0,$c1,$c2)=($c1,$c2,$c0);
52 &mov("zero",$c2);
53
54 &mul_add_c($a[0],$b[2],$c0,$c1,$c2);
55 &mul_add_c($a[1],$b[1],$c0,$c1,$c2);
56 &mul_add_c($a[2],$b[0],$c0,$c1,$c2);
57 &st($c0,&QWPw(2,$rp)); &FR($c0); ($c0)=&NR(1);
58 ($c0,$c1,$c2)=($c1,$c2,$c0);
59 &mov("zero",$c2);
60
61 &mul_add_c($a[0],$b[3],$c0,$c1,$c2);
62 &mul_add_c($a[1],$b[2],$c0,$c1,$c2);
63 &mul_add_c($a[2],$b[1],$c0,$c1,$c2);
64 &mul_add_c($a[3],$b[0],$c0,$c1,$c2);
65 &st($c0,&QWPw(3,$rp)); &FR($c0); ($c0)=&NR(1);
66 ($c0,$c1,$c2)=($c1,$c2,$c0);
67 &mov("zero",$c2);
68
69 &mul_add_c($a[0],$b[4],$c0,$c1,$c2);
70 &mul_add_c($a[1],$b[3],$c0,$c1,$c2);
71 &mul_add_c($a[2],$b[2],$c0,$c1,$c2);
72 &mul_add_c($a[3],$b[1],$c0,$c1,$c2);
73 &mul_add_c($a[4],$b[0],$c0,$c1,$c2);
74 &st($c0,&QWPw(4,$rp)); &FR($c0); ($c0)=&NR(1);
75 ($c0,$c1,$c2)=($c1,$c2,$c0);
76 &mov("zero",$c2);
77
78 &mul_add_c($a[0],$b[5],$c0,$c1,$c2);
79 &mul_add_c($a[1],$b[4],$c0,$c1,$c2);
80 &mul_add_c($a[2],$b[3],$c0,$c1,$c2);
81 &mul_add_c($a[3],$b[2],$c0,$c1,$c2);
82 &mul_add_c($a[4],$b[1],$c0,$c1,$c2);
83 &mul_add_c($a[5],$b[0],$c0,$c1,$c2);
84 &st($c0,&QWPw(5,$rp)); &FR($c0); ($c0)=&NR(1);
85 ($c0,$c1,$c2)=($c1,$c2,$c0);
86 &mov("zero",$c2);
87
88 &mul_add_c($a[0],$b[6],$c0,$c1,$c2);
89 &mul_add_c($a[1],$b[5],$c0,$c1,$c2);
90 &mul_add_c($a[2],$b[4],$c0,$c1,$c2);
91 &mul_add_c($a[3],$b[3],$c0,$c1,$c2);
92 &mul_add_c($a[4],$b[2],$c0,$c1,$c2);
93 &mul_add_c($a[5],$b[1],$c0,$c1,$c2);
94 &mul_add_c($a[6],$b[0],$c0,$c1,$c2);
95 &st($c0,&QWPw(6,$rp)); &FR($c0); ($c0)=&NR(1);
96 ($c0,$c1,$c2)=($c1,$c2,$c0);
97 &mov("zero",$c2);
98
99 &mul_add_c($a[0],$b[7],$c0,$c1,$c2); &FR($a[0]);
100 &mul_add_c($a[1],$b[6],$c0,$c1,$c2);
101 &mul_add_c($a[2],$b[5],$c0,$c1,$c2);
102 &mul_add_c($a[3],$b[4],$c0,$c1,$c2);
103 &mul_add_c($a[4],$b[3],$c0,$c1,$c2);
104 &mul_add_c($a[5],$b[2],$c0,$c1,$c2);
105 &mul_add_c($a[6],$b[1],$c0,$c1,$c2);
106 &mul_add_c($a[7],$b[0],$c0,$c1,$c2); &FR($b[0]);
107 &st($c0,&QWPw(7,$rp)); &FR($c0); ($c0)=&NR(1);
108 ($c0,$c1,$c2)=($c1,$c2,$c0);
109 &mov("zero",$c2);
110
111 &mul_add_c($a[1],$b[7],$c0,$c1,$c2); &FR($a[1]);
112 &mul_add_c($a[2],$b[6],$c0,$c1,$c2);
113 &mul_add_c($a[3],$b[5],$c0,$c1,$c2);
114 &mul_add_c($a[4],$b[4],$c0,$c1,$c2);
115 &mul_add_c($a[5],$b[3],$c0,$c1,$c2);
116 &mul_add_c($a[6],$b[2],$c0,$c1,$c2);
117 &mul_add_c($a[7],$b[1],$c0,$c1,$c2); &FR($b[1]);
118 &st($c0,&QWPw(8,$rp)); &FR($c0); ($c0)=&NR(1);
119 ($c0,$c1,$c2)=($c1,$c2,$c0);
120 &mov("zero",$c2);
121
122 &mul_add_c($a[2],$b[7],$c0,$c1,$c2); &FR($a[2]);
123 &mul_add_c($a[3],$b[6],$c0,$c1,$c2);
124 &mul_add_c($a[4],$b[5],$c0,$c1,$c2);
125 &mul_add_c($a[5],$b[4],$c0,$c1,$c2);
126 &mul_add_c($a[6],$b[3],$c0,$c1,$c2);
127 &mul_add_c($a[7],$b[2],$c0,$c1,$c2); &FR($b[2]);
128 &st($c0,&QWPw(9,$rp)); &FR($c0); ($c0)=&NR(1);
129 ($c0,$c1,$c2)=($c1,$c2,$c0);
130 &mov("zero",$c2);
131
132 &mul_add_c($a[3],$b[7],$c0,$c1,$c2); &FR($a[3]);
133 &mul_add_c($a[4],$b[6],$c0,$c1,$c2);
134 &mul_add_c($a[5],$b[5],$c0,$c1,$c2);
135 &mul_add_c($a[6],$b[4],$c0,$c1,$c2);
136 &mul_add_c($a[7],$b[3],$c0,$c1,$c2); &FR($b[3]);
137 &st($c0,&QWPw(10,$rp)); &FR($c0); ($c0)=&NR(1);
138 ($c0,$c1,$c2)=($c1,$c2,$c0);
139 &mov("zero",$c2);
140
141 &mul_add_c($a[4],$b[7],$c0,$c1,$c2); &FR($a[4]);
142 &mul_add_c($a[5],$b[6],$c0,$c1,$c2);
143 &mul_add_c($a[6],$b[5],$c0,$c1,$c2);
144 &mul_add_c($a[7],$b[4],$c0,$c1,$c2); &FR($b[4]);
145 &st($c0,&QWPw(11,$rp)); &FR($c0); ($c0)=&NR(1);
146 ($c0,$c1,$c2)=($c1,$c2,$c0);
147 &mov("zero",$c2);
148
149 &mul_add_c($a[5],$b[7],$c0,$c1,$c2); &FR($a[5]);
150 &mul_add_c($a[6],$b[6],$c0,$c1,$c2);
151 &mul_add_c($a[7],$b[5],$c0,$c1,$c2); &FR($b[5]);
152 &st($c0,&QWPw(12,$rp)); &FR($c0); ($c0)=&NR(1);
153 ($c0,$c1,$c2)=($c1,$c2,$c0);
154 &mov("zero",$c2);
155
156 &mul_add_c($a[6],$b[7],$c0,$c1,$c2); &FR($a[6]);
157 &mul_add_c($a[7],$b[6],$c0,$c1,$c2); &FR($b[6]);
158 &st($c0,&QWPw(13,$rp)); &FR($c0); ($c0)=&NR(1);
159 ($c0,$c1,$c2)=($c1,$c2,$c0);
160 &mov("zero",$c2);
161
162 &mul_add_c($a[7],$b[7],$c0,$c1,$c2); &FR($a[7],$b[7]);
163 &st($c0,&QWPw(14,$rp));
164 &st($c1,&QWPw(15,$rp));
165
166 &FR($c0,$c1,$c2);
167
168 &ld($reg_s0,&swtmp(0));
169 &ld($reg_s1,&swtmp(1));
170 &stack_pop(2);
171
172 &function_end($name);
173
174 &fin_pool;
175 }
176
1771;
diff --git a/src/lib/libcrypto/bn/asm/alpha/sqr.pl b/src/lib/libcrypto/bn/asm/alpha/sqr.pl
deleted file mode 100644
index a55b696906..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/sqr.pl
+++ /dev/null
@@ -1,113 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sqr_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r,$couny);
8
9 &init_pool(3);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $count=&wparam(2);
15
16 &function_begin($name,"");
17
18 &comment("");
19 &sub($count,4,$count);
20 &mov("zero",$cc);
21 &br(&label("finish"));
22 &blt($count,&label("finish"));
23
24 ($a0,$r0)=&NR(2);
25 &ld($a0,&QWPw(0,$ap));
26 &ld($r0,&QWPw(0,$rp));
27
28$a=<<'EOF';
29##########################################################
30 &set_label("loop");
31
32 ($a1)=&NR(1); &ld($a1,&QWPw(1,$ap));
33 ($b1)=&NR(1); &ld($b1,&QWPw(1,$bp));
34 ($a2)=&NR(1); &ld($a2,&QWPw(2,$ap));
35 ($b2)=&NR(1); &ld($b2,&QWPw(2,$bp));
36 ($a3)=&NR(1); &ld($a3,&QWPw(3,$ap));
37 ($b3)=&NR(1); &ld($b3,&QWPw(3,$bp));
38
39 ($o0,$t0)=&NR(2);
40 &add($a0,$b0,$o0);
41 &cmpult($o0,$b0,$t0);
42 &add($o0,$cc,$o0);
43 &cmpult($o0,$cc,$cc);
44 &add($cc,$t0,$cc); &FR($t0);
45
46 ($t1,$o1)=&NR(2);
47
48 &add($a1,$b1,$o1); &FR($a1);
49 &cmpult($o1,$b1,$t1); &FR($b1);
50 &add($o1,$cc,$o1);
51 &cmpult($o1,$cc,$cc);
52 &add($cc,$t1,$cc); &FR($t1);
53
54 ($t2,$o2)=&NR(2);
55
56 &add($a2,$b2,$o2); &FR($a2);
57 &cmpult($o2,$b2,$t2); &FR($b2);
58 &add($o2,$cc,$o2);
59 &cmpult($o2,$cc,$cc);
60 &add($cc,$t2,$cc); &FR($t2);
61
62 ($t3,$o3)=&NR(2);
63
64 &add($a3,$b3,$o3); &FR($a3);
65 &cmpult($o3,$b3,$t3); &FR($b3);
66 &add($o3,$cc,$o3);
67 &cmpult($o3,$cc,$cc);
68 &add($cc,$t3,$cc); &FR($t3);
69
70 &st($o0,&QWPw(0,$rp)); &FR($o0);
71 &st($o1,&QWPw(0,$rp)); &FR($o1);
72 &st($o2,&QWPw(0,$rp)); &FR($o2);
73 &st($o3,&QWPw(0,$rp)); &FR($o3);
74
75 &sub($count,4,$count); # count-=4
76 &add($ap,4*$QWS,$ap); # count+=4
77 &add($bp,4*$QWS,$bp); # count+=4
78 &add($rp,4*$QWS,$rp); # count+=4
79
80 &blt($count,&label("finish"));
81 &ld($a0,&QWPw(0,$ap));
82 &ld($b0,&QWPw(0,$bp));
83 &br(&label("loop"));
84EOF
85##################################################
86 # Do the last 0..3 words
87
88 &set_label("last_loop");
89
90 &ld(($a0)=&NR(1),&QWPw(0,$ap)); # get a
91 &mul($a0,$a0,($l0)=&NR(1));
92 &add($ap,$QWS,$ap);
93 &add($rp,2*$QWS,$rp);
94 &sub($count,1,$count);
95 &muh($a0,$a0,($h0)=&NR(1)); &FR($a0);
96 &st($l0,&QWPw(-2,$rp)); &FR($l0);
97 &st($h0,&QWPw(-1,$rp)); &FR($h0);
98
99 &bgt($count,&label("last_loop"));
100 &function_end_A($name);
101
102######################################################
103 &set_label("finish");
104 &add($count,4,$count);
105 &bgt($count,&label("last_loop"));
106
107 &set_label("end");
108 &function_end($name);
109
110 &fin_pool;
111 }
112
1131;
diff --git a/src/lib/libcrypto/bn/asm/alpha/sqr_c4.pl b/src/lib/libcrypto/bn/asm/alpha/sqr_c4.pl
deleted file mode 100644
index bf33f5b503..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/sqr_c4.pl
+++ /dev/null
@@ -1,109 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub sqr_add_c
5 {
6 local($a,$c0,$c1,$c2)=@_;
7 local($l1,$h1,$t1,$t2);
8
9 &mul($a,$a,($l1)=&NR(1));
10 &muh($a,$a,($h1)=&NR(1));
11 &add($c0,$l1,$c0);
12 &add($c1,$h1,$c1);
13 &cmpult($c0,$l1,($t1)=&NR(1)); &FR($l1);
14 &cmpult($c1,$h1,($t2)=&NR(1)); &FR($h1);
15 &add($c1,$t1,$c1); &FR($t1);
16 &add($c2,$t2,$c2); &FR($t2);
17 }
18
19sub sqr_add_c2
20 {
21 local($a,$b,$c0,$c1,$c2)=@_;
22 local($l1,$h1,$t1,$t2);
23
24 &mul($a,$b,($l1)=&NR(1));
25 &muh($a,$b,($h1)=&NR(1));
26 &cmplt($l1,"zero",($lc1)=&NR(1));
27 &cmplt($h1,"zero",($hc1)=&NR(1));
28 &add($l1,$l1,$l1);
29 &add($h1,$h1,$h1);
30 &add($h1,$lc1,$h1); &FR($lc1);
31 &add($c2,$hc1,$c2); &FR($hc1);
32
33 &add($c0,$l1,$c0);
34 &add($c1,$h1,$c1);
35 &cmpult($c0,$l1,($lc1)=&NR(1)); &FR($l1);
36 &cmpult($c1,$h1,($hc1)=&NR(1)); &FR($h1);
37
38 &add($c1,$lc1,$c1); &FR($lc1);
39 &add($c2,$hc1,$c2); &FR($hc1);
40 }
41
42
43sub bn_sqr_comba4
44 {
45 local($name)=@_;
46 local(@a,@b,$r,$c0,$c1,$c2);
47
48 $cnt=1;
49 &init_pool(2);
50
51 $rp=&wparam(0);
52 $ap=&wparam(1);
53
54 &function_begin($name,"");
55
56 &comment("");
57
58 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
59 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
60 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
61 &ld(($a[3])=&NR(1),&QWPw(3,$ap)); &FR($ap);
62
63 ($c0,$c1,$c2)=&NR(3);
64
65 &mov("zero",$c2);
66 &mul($a[0],$a[0],$c0);
67 &muh($a[0],$a[0],$c1);
68 &st($c0,&QWPw(0,$rp));
69 ($c0,$c1,$c2)=($c1,$c2,$c0);
70 &mov("zero",$c2);
71
72 &sqr_add_c2($a[0],$a[1],$c0,$c1,$c2);
73 &st($c0,&QWPw(1,$rp));
74 ($c0,$c1,$c2)=($c1,$c2,$c0);
75 &mov("zero",$c2);
76
77 &sqr_add_c($a[1],$c0,$c1,$c2);
78 &sqr_add_c2($a[2],$a[0],$c0,$c1,$c2);
79 &st($c0,&QWPw(2,$rp));
80 ($c0,$c1,$c2)=($c1,$c2,$c0);
81 &mov("zero",$c2);
82
83 &sqr_add_c2($a[3],$a[0],$c0,$c1,$c2);
84 &sqr_add_c2($a[2],$a[1],$c0,$c1,$c2);
85 &st($c0,&QWPw(3,$rp));
86 ($c0,$c1,$c2)=($c1,$c2,$c0);
87 &mov("zero",$c2);
88
89 &sqr_add_c($a[2],$c0,$c1,$c2);
90 &sqr_add_c2($a[3],$a[1],$c0,$c1,$c2);
91 &st($c0,&QWPw(4,$rp));
92 ($c0,$c1,$c2)=($c1,$c2,$c0);
93 &mov("zero",$c2);
94
95 &sqr_add_c2($a[3],$a[2],$c0,$c1,$c2);
96 &st($c0,&QWPw(5,$rp));
97 ($c0,$c1,$c2)=($c1,$c2,$c0);
98 &mov("zero",$c2);
99
100 &sqr_add_c($a[3],$c0,$c1,$c2);
101 &st($c0,&QWPw(6,$rp));
102 &st($c1,&QWPw(7,$rp));
103
104 &function_end($name);
105
106 &fin_pool;
107 }
108
1091;
diff --git a/src/lib/libcrypto/bn/asm/alpha/sqr_c8.pl b/src/lib/libcrypto/bn/asm/alpha/sqr_c8.pl
deleted file mode 100644
index b4afe085f1..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/sqr_c8.pl
+++ /dev/null
@@ -1,132 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sqr_comba8
5 {
6 local($name)=@_;
7 local(@a,@b,$r,$c0,$c1,$c2);
8
9 $cnt=1;
10 &init_pool(2);
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14
15 &function_begin($name,"");
16
17 &comment("");
18
19 &ld(($a[0])=&NR(1),&QWPw(0,$ap));
20 &ld(($a[1])=&NR(1),&QWPw(1,$ap));
21 &ld(($a[2])=&NR(1),&QWPw(2,$ap));
22 &ld(($a[3])=&NR(1),&QWPw(3,$ap));
23 &ld(($a[4])=&NR(1),&QWPw(4,$ap));
24 &ld(($a[5])=&NR(1),&QWPw(5,$ap));
25 &ld(($a[6])=&NR(1),&QWPw(6,$ap));
26 &ld(($a[7])=&NR(1),&QWPw(7,$ap)); &FR($ap);
27
28 ($c0,$c1,$c2)=&NR(3);
29
30 &mov("zero",$c2);
31 &mul($a[0],$a[0],$c0);
32 &muh($a[0],$a[0],$c1);
33 &st($c0,&QWPw(0,$rp));
34 ($c0,$c1,$c2)=($c1,$c2,$c0);
35 &mov("zero",$c2);
36
37 &sqr_add_c2($a[1],$a[0],$c0,$c1,$c2);
38 &st($c0,&QWPw(1,$rp));
39 ($c0,$c1,$c2)=($c1,$c2,$c0);
40 &mov("zero",$c2);
41
42 &sqr_add_c($a[1],$c0,$c1,$c2);
43 &sqr_add_c2($a[2],$a[0],$c0,$c1,$c2);
44 &st($c0,&QWPw(2,$rp));
45 ($c0,$c1,$c2)=($c1,$c2,$c0);
46 &mov("zero",$c2);
47
48 &sqr_add_c2($a[2],$a[1],$c0,$c1,$c2);
49 &sqr_add_c2($a[3],$a[0],$c0,$c1,$c2);
50 &st($c0,&QWPw(3,$rp));
51 ($c0,$c1,$c2)=($c1,$c2,$c0);
52 &mov("zero",$c2);
53
54 &sqr_add_c($a[2],$c0,$c1,$c2);
55 &sqr_add_c2($a[3],$a[1],$c0,$c1,$c2);
56 &sqr_add_c2($a[4],$a[0],$c0,$c1,$c2);
57 &st($c0,&QWPw(4,$rp));
58 ($c0,$c1,$c2)=($c1,$c2,$c0);
59 &mov("zero",$c2);
60
61 &sqr_add_c2($a[3],$a[2],$c0,$c1,$c2);
62 &sqr_add_c2($a[4],$a[1],$c0,$c1,$c2);
63 &sqr_add_c2($a[5],$a[0],$c0,$c1,$c2);
64 &st($c0,&QWPw(5,$rp));
65 ($c0,$c1,$c2)=($c1,$c2,$c0);
66 &mov("zero",$c2);
67
68 &sqr_add_c($a[3],$c0,$c1,$c2);
69 &sqr_add_c2($a[4],$a[2],$c0,$c1,$c2);
70 &sqr_add_c2($a[5],$a[1],$c0,$c1,$c2);
71 &sqr_add_c2($a[6],$a[0],$c0,$c1,$c2);
72 &st($c0,&QWPw(6,$rp));
73 ($c0,$c1,$c2)=($c1,$c2,$c0);
74 &mov("zero",$c2);
75
76 &sqr_add_c2($a[4],$a[3],$c0,$c1,$c2);
77 &sqr_add_c2($a[5],$a[2],$c0,$c1,$c2);
78 &sqr_add_c2($a[6],$a[1],$c0,$c1,$c2);
79 &sqr_add_c2($a[7],$a[0],$c0,$c1,$c2);
80 &st($c0,&QWPw(7,$rp));
81 ($c0,$c1,$c2)=($c1,$c2,$c0);
82 &mov("zero",$c2);
83
84 &sqr_add_c($a[4],$c0,$c1,$c2);
85 &sqr_add_c2($a[5],$a[3],$c0,$c1,$c2);
86 &sqr_add_c2($a[6],$a[2],$c0,$c1,$c2);
87 &sqr_add_c2($a[7],$a[1],$c0,$c1,$c2);
88 &st($c0,&QWPw(8,$rp));
89 ($c0,$c1,$c2)=($c1,$c2,$c0);
90 &mov("zero",$c2);
91
92 &sqr_add_c2($a[5],$a[4],$c0,$c1,$c2);
93 &sqr_add_c2($a[6],$a[3],$c0,$c1,$c2);
94 &sqr_add_c2($a[7],$a[2],$c0,$c1,$c2);
95 &st($c0,&QWPw(9,$rp));
96 ($c0,$c1,$c2)=($c1,$c2,$c0);
97 &mov("zero",$c2);
98
99 &sqr_add_c($a[5],$c0,$c1,$c2);
100 &sqr_add_c2($a[6],$a[4],$c0,$c1,$c2);
101 &sqr_add_c2($a[7],$a[3],$c0,$c1,$c2);
102 &st($c0,&QWPw(10,$rp));
103 ($c0,$c1,$c2)=($c1,$c2,$c0);
104 &mov("zero",$c2);
105
106 &sqr_add_c2($a[6],$a[5],$c0,$c1,$c2);
107 &sqr_add_c2($a[7],$a[4],$c0,$c1,$c2);
108 &st($c0,&QWPw(11,$rp));
109 ($c0,$c1,$c2)=($c1,$c2,$c0);
110 &mov("zero",$c2);
111
112 &sqr_add_c($a[6],$c0,$c1,$c2);
113 &sqr_add_c2($a[7],$a[5],$c0,$c1,$c2);
114 &st($c0,&QWPw(12,$rp));
115 ($c0,$c1,$c2)=($c1,$c2,$c0);
116 &mov("zero",$c2);
117
118 &sqr_add_c2($a[7],$a[6],$c0,$c1,$c2);
119 &st($c0,&QWPw(13,$rp));
120 ($c0,$c1,$c2)=($c1,$c2,$c0);
121 &mov("zero",$c2);
122
123 &sqr_add_c($a[7],$c0,$c1,$c2);
124 &st($c0,&QWPw(14,$rp));
125 &st($c1,&QWPw(15,$rp));
126
127 &function_end($name);
128
129 &fin_pool;
130 }
131
1321;
diff --git a/src/lib/libcrypto/bn/asm/alpha/sub.pl b/src/lib/libcrypto/bn/asm/alpha/sub.pl
deleted file mode 100644
index d998da5c21..0000000000
--- a/src/lib/libcrypto/bn/asm/alpha/sub.pl
+++ /dev/null
@@ -1,108 +0,0 @@
1#!/usr/local/bin/perl
2# alpha assember
3
4sub bn_sub_words
5 {
6 local($name)=@_;
7 local($cc,$a,$b,$r);
8
9 &init_pool(4);
10 ($cc)=GR("r0");
11
12 $rp=&wparam(0);
13 $ap=&wparam(1);
14 $bp=&wparam(2);
15 $count=&wparam(3);
16
17 &function_begin($name,"");
18
19 &comment("");
20 &sub($count,4,$count);
21 &mov("zero",$cc);
22 &blt($count,&label("finish"));
23
24 ($a0,$b0)=&NR(2);
25 &ld($a0,&QWPw(0,$ap));
26 &ld($b0,&QWPw(0,$bp));
27
28##########################################################
29 &set_label("loop");
30
31 ($a1,$tmp,$b1,$a2,$b2,$a3,$b3,$o0)=&NR(8);
32 &ld($a1,&QWPw(1,$ap));
33 &cmpult($a0,$b0,$tmp); # will we borrow?
34 &ld($b1,&QWPw(1,$bp));
35 &sub($a0,$b0,$a0); # do the subtract
36 &ld($a2,&QWPw(2,$ap));
37 &cmpult($a0,$cc,$b0); # will we borrow?
38 &ld($b2,&QWPw(2,$bp));
39 &sub($a0,$cc,$o0); # will we borrow?
40 &ld($a3,&QWPw(3,$ap));
41 &add($b0,$tmp,$cc); ($t1,$o1)=&NR(2); &FR($tmp);
42
43 &cmpult($a1,$b1,$t1); # will we borrow?
44 &sub($a1,$b1,$a1); # do the subtract
45 &ld($b3,&QWPw(3,$bp));
46 &cmpult($a1,$cc,$b1); # will we borrow?
47 &sub($a1,$cc,$o1); # will we borrow?
48 &add($b1,$t1,$cc); ($tmp,$o2)=&NR(2); &FR($t1,$a1,$b1);
49
50 &cmpult($a2,$b2,$tmp); # will we borrow?
51 &sub($a2,$b2,$a2); # do the subtract
52 &st($o0,&QWPw(0,$rp)); &FR($o0); # save
53 &cmpult($a2,$cc,$b2); # will we borrow?
54 &sub($a2,$cc,$o2); # will we borrow?
55 &add($b2,$tmp,$cc); ($t3,$o3)=&NR(2); &FR($tmp,$a2,$b2);
56
57 &cmpult($a3,$b3,$t3); # will we borrow?
58 &sub($a3,$b3,$a3); # do the subtract
59 &st($o1,&QWPw(1,$rp)); &FR($o1);
60 &cmpult($a3,$cc,$b3); # will we borrow?
61 &sub($a3,$cc,$o3); # will we borrow?
62 &add($b3,$t3,$cc); &FR($t3,$a3,$b3);
63
64 &st($o2,&QWPw(2,$rp)); &FR($o2);
65 &sub($count,4,$count); # count-=4
66 &st($o3,&QWPw(3,$rp)); &FR($o3);
67 &add($ap,4*$QWS,$ap); # count+=4
68 &add($bp,4*$QWS,$bp); # count+=4
69 &add($rp,4*$QWS,$rp); # count+=4
70
71 &blt($count,&label("finish"));
72 &ld($a0,&QWPw(0,$ap));
73 &ld($b0,&QWPw(0,$bp));
74 &br(&label("loop"));
75##################################################
76 # Do the last 0..3 words
77
78 &set_label("last_loop");
79
80 &ld($a0,&QWPw(0,$ap)); # get a
81 &ld($b0,&QWPw(0,$bp)); # get b
82 &cmpult($a0,$b0,$tmp); # will we borrow?
83 &sub($a0,$b0,$a0); # do the subtract
84 &cmpult($a0,$cc,$b0); # will we borrow?
85 &sub($a0,$cc,$a0); # will we borrow?
86 &st($a0,&QWPw(0,$rp)); # save
87 &add($b0,$tmp,$cc); # add the borrows
88
89 &add($ap,$QWS,$ap);
90 &add($bp,$QWS,$bp);
91 &add($rp,$QWS,$rp);
92 &sub($count,1,$count);
93 &bgt($count,&label("last_loop"));
94 &function_end_A($name);
95
96######################################################
97 &set_label("finish");
98 &add($count,4,$count);
99 &bgt($count,&label("last_loop"));
100
101 &FR($a0,$b0);
102 &set_label("end");
103 &function_end($name);
104
105 &fin_pool;
106 }
107
1081;
diff --git a/src/lib/libcrypto/bn/asm/bn-alpha.pl b/src/lib/libcrypto/bn/asm/bn-alpha.pl
deleted file mode 100644
index 302edf2376..0000000000
--- a/src/lib/libcrypto/bn/asm/bn-alpha.pl
+++ /dev/null
@@ -1,571 +0,0 @@
1#!/usr/local/bin/perl
2# I have this in perl so I can use more usefull register names and then convert
3# them into alpha registers.
4#
5
6$d=&data();
7$d =~ s/CC/0/g;
8$d =~ s/R1/1/g;
9$d =~ s/R2/2/g;
10$d =~ s/R3/3/g;
11$d =~ s/R4/4/g;
12$d =~ s/L1/5/g;
13$d =~ s/L2/6/g;
14$d =~ s/L3/7/g;
15$d =~ s/L4/8/g;
16$d =~ s/O1/22/g;
17$d =~ s/O2/23/g;
18$d =~ s/O3/24/g;
19$d =~ s/O4/25/g;
20$d =~ s/A1/20/g;
21$d =~ s/A2/21/g;
22$d =~ s/A3/27/g;
23$d =~ s/A4/28/g;
24if (0){
25}
26
27print $d;
28
29sub data
30 {
31 local($data)=<<'EOF';
32
33 # DEC Alpha assember
34 # The bn_div_words is actually gcc output but the other parts are hand done.
35 # Thanks to tzeruch@ceddec.com for sending me the gcc output for
36 # bn_div_words.
37 # I've gone back and re-done most of routines.
38 # The key thing to remeber for the 164 CPU is that while a
39 # multiply operation takes 8 cycles, another one can only be issued
40 # after 4 cycles have elapsed. I've done modification to help
41 # improve this. Also, normally, a ld instruction will not be available
42 # for about 3 cycles.
43 .file 1 "bn_asm.c"
44 .set noat
45gcc2_compiled.:
46__gnu_compiled_c:
47 .text
48 .align 3
49 .globl bn_mul_add_words
50 .ent bn_mul_add_words
51bn_mul_add_words:
52bn_mul_add_words..ng:
53 .frame $30,0,$26,0
54 .prologue 0
55 .align 5
56 subq $18,4,$18
57 bis $31,$31,$CC
58 blt $18,$43 # if we are -1, -2, -3 or -4 goto tail code
59 ldq $A1,0($17) # 1 1
60 ldq $R1,0($16) # 1 1
61 .align 3
62$42:
63 mulq $A1,$19,$L1 # 1 2 1 ######
64 ldq $A2,8($17) # 2 1
65 ldq $R2,8($16) # 2 1
66 umulh $A1,$19,$A1 # 1 2 ######
67 ldq $A3,16($17) # 3 1
68 ldq $R3,16($16) # 3 1
69 mulq $A2,$19,$L2 # 2 2 1 ######
70 ldq $A4,24($17) # 4 1
71 addq $R1,$L1,$R1 # 1 2 2
72 ldq $R4,24($16) # 4 1
73 umulh $A2,$19,$A2 # 2 2 ######
74 cmpult $R1,$L1,$O1 # 1 2 3 1
75 addq $A1,$O1,$A1 # 1 3 1
76 addq $R1,$CC,$R1 # 1 2 3 1
77 mulq $A3,$19,$L3 # 3 2 1 ######
78 cmpult $R1,$CC,$CC # 1 2 3 2
79 addq $R2,$L2,$R2 # 2 2 2
80 addq $A1,$CC,$CC # 1 3 2
81 cmpult $R2,$L2,$O2 # 2 2 3 1
82 addq $A2,$O2,$A2 # 2 3 1
83 umulh $A3,$19,$A3 # 3 2 ######
84 addq $R2,$CC,$R2 # 2 2 3 1
85 cmpult $R2,$CC,$CC # 2 2 3 2
86 subq $18,4,$18
87 mulq $A4,$19,$L4 # 4 2 1 ######
88 addq $A2,$CC,$CC # 2 3 2
89 addq $R3,$L3,$R3 # 3 2 2
90 addq $16,32,$16
91 cmpult $R3,$L3,$O3 # 3 2 3 1
92 stq $R1,-32($16) # 1 2 4
93 umulh $A4,$19,$A4 # 4 2 ######
94 addq $A3,$O3,$A3 # 3 3 1
95 addq $R3,$CC,$R3 # 3 2 3 1
96 stq $R2,-24($16) # 2 2 4
97 cmpult $R3,$CC,$CC # 3 2 3 2
98 stq $R3,-16($16) # 3 2 4
99 addq $R4,$L4,$R4 # 4 2 2
100 addq $A3,$CC,$CC # 3 3 2
101 cmpult $R4,$L4,$O4 # 4 2 3 1
102 addq $17,32,$17
103 addq $A4,$O4,$A4 # 4 3 1
104 addq $R4,$CC,$R4 # 4 2 3 1
105 cmpult $R4,$CC,$CC # 4 2 3 2
106 stq $R4,-8($16) # 4 2 4
107 addq $A4,$CC,$CC # 4 3 2
108 blt $18,$43
109
110 ldq $A1,0($17) # 1 1
111 ldq $R1,0($16) # 1 1
112
113 br $42
114
115 .align 4
116$45:
117 ldq $A1,0($17) # 4 1
118 ldq $R1,0($16) # 4 1
119 mulq $A1,$19,$L1 # 4 2 1
120 subq $18,1,$18
121 addq $16,8,$16
122 addq $17,8,$17
123 umulh $A1,$19,$A1 # 4 2
124 addq $R1,$L1,$R1 # 4 2 2
125 cmpult $R1,$L1,$O1 # 4 2 3 1
126 addq $A1,$O1,$A1 # 4 3 1
127 addq $R1,$CC,$R1 # 4 2 3 1
128 cmpult $R1,$CC,$CC # 4 2 3 2
129 addq $A1,$CC,$CC # 4 3 2
130 stq $R1,-8($16) # 4 2 4
131 bgt $18,$45
132 ret $31,($26),1 # else exit
133
134 .align 4
135$43:
136 addq $18,4,$18
137 bgt $18,$45 # goto tail code
138 ret $31,($26),1 # else exit
139
140 .end bn_mul_add_words
141 .align 3
142 .globl bn_mul_words
143 .ent bn_mul_words
144bn_mul_words:
145bn_mul_words..ng:
146 .frame $30,0,$26,0
147 .prologue 0
148 .align 5
149 subq $18,4,$18
150 bis $31,$31,$CC
151 blt $18,$143 # if we are -1, -2, -3 or -4 goto tail code
152 ldq $A1,0($17) # 1 1
153 .align 3
154$142:
155
156 mulq $A1,$19,$L1 # 1 2 1 #####
157 ldq $A2,8($17) # 2 1
158 ldq $A3,16($17) # 3 1
159 umulh $A1,$19,$A1 # 1 2 #####
160 ldq $A4,24($17) # 4 1
161 mulq $A2,$19,$L2 # 2 2 1 #####
162 addq $L1,$CC,$L1 # 1 2 3 1
163 subq $18,4,$18
164 cmpult $L1,$CC,$CC # 1 2 3 2
165 umulh $A2,$19,$A2 # 2 2 #####
166 addq $A1,$CC,$CC # 1 3 2
167 addq $17,32,$17
168 addq $L2,$CC,$L2 # 2 2 3 1
169 mulq $A3,$19,$L3 # 3 2 1 #####
170 cmpult $L2,$CC,$CC # 2 2 3 2
171 addq $A2,$CC,$CC # 2 3 2
172 addq $16,32,$16
173 umulh $A3,$19,$A3 # 3 2 #####
174 stq $L1,-32($16) # 1 2 4
175 mulq $A4,$19,$L4 # 4 2 1 #####
176 addq $L3,$CC,$L3 # 3 2 3 1
177 stq $L2,-24($16) # 2 2 4
178 cmpult $L3,$CC,$CC # 3 2 3 2
179 umulh $A4,$19,$A4 # 4 2 #####
180 addq $A3,$CC,$CC # 3 3 2
181 stq $L3,-16($16) # 3 2 4
182 addq $L4,$CC,$L4 # 4 2 3 1
183 cmpult $L4,$CC,$CC # 4 2 3 2
184
185 addq $A4,$CC,$CC # 4 3 2
186
187 stq $L4,-8($16) # 4 2 4
188
189 blt $18,$143
190
191 ldq $A1,0($17) # 1 1
192
193 br $142
194
195 .align 4
196$145:
197 ldq $A1,0($17) # 4 1
198 mulq $A1,$19,$L1 # 4 2 1
199 subq $18,1,$18
200 umulh $A1,$19,$A1 # 4 2
201 addq $L1,$CC,$L1 # 4 2 3 1
202 addq $16,8,$16
203 cmpult $L1,$CC,$CC # 4 2 3 2
204 addq $17,8,$17
205 addq $A1,$CC,$CC # 4 3 2
206 stq $L1,-8($16) # 4 2 4
207
208 bgt $18,$145
209 ret $31,($26),1 # else exit
210
211 .align 4
212$143:
213 addq $18,4,$18
214 bgt $18,$145 # goto tail code
215 ret $31,($26),1 # else exit
216
217 .end bn_mul_words
218 .align 3
219 .globl bn_sqr_words
220 .ent bn_sqr_words
221bn_sqr_words:
222bn_sqr_words..ng:
223 .frame $30,0,$26,0
224 .prologue 0
225
226 subq $18,4,$18
227 blt $18,$543 # if we are -1, -2, -3 or -4 goto tail code
228 ldq $A1,0($17) # 1 1
229 .align 3
230$542:
231 mulq $A1,$A1,$L1 ######
232 ldq $A2,8($17) # 1 1
233 subq $18,4
234 umulh $A1,$A1,$R1 ######
235 ldq $A3,16($17) # 1 1
236 mulq $A2,$A2,$L2 ######
237 ldq $A4,24($17) # 1 1
238 stq $L1,0($16) # r[0]
239 umulh $A2,$A2,$R2 ######
240 stq $R1,8($16) # r[1]
241 mulq $A3,$A3,$L3 ######
242 stq $L2,16($16) # r[0]
243 umulh $A3,$A3,$R3 ######
244 stq $R2,24($16) # r[1]
245 mulq $A4,$A4,$L4 ######
246 stq $L3,32($16) # r[0]
247 umulh $A4,$A4,$R4 ######
248 stq $R3,40($16) # r[1]
249
250 addq $16,64,$16
251 addq $17,32,$17
252 stq $L4,-16($16) # r[0]
253 stq $R4,-8($16) # r[1]
254
255 blt $18,$543
256 ldq $A1,0($17) # 1 1
257 br $542
258
259$442:
260 ldq $A1,0($17) # a[0]
261 mulq $A1,$A1,$L1 # a[0]*w low part r2
262 addq $16,16,$16
263 addq $17,8,$17
264 subq $18,1,$18
265 umulh $A1,$A1,$R1 # a[0]*w high part r3
266 stq $L1,-16($16) # r[0]
267 stq $R1,-8($16) # r[1]
268
269 bgt $18,$442
270 ret $31,($26),1 # else exit
271
272 .align 4
273$543:
274 addq $18,4,$18
275 bgt $18,$442 # goto tail code
276 ret $31,($26),1 # else exit
277 .end bn_sqr_words
278
279 .align 3
280 .globl bn_add_words
281 .ent bn_add_words
282bn_add_words:
283bn_add_words..ng:
284 .frame $30,0,$26,0
285 .prologue 0
286
287 subq $19,4,$19
288 bis $31,$31,$CC # carry = 0
289 blt $19,$900
290 ldq $L1,0($17) # a[0]
291 ldq $R1,0($18) # b[1]
292 .align 3
293$901:
294 addq $R1,$L1,$R1 # r=a+b;
295 ldq $L2,8($17) # a[1]
296 cmpult $R1,$L1,$O1 # did we overflow?
297 ldq $R2,8($18) # b[1]
298 addq $R1,$CC,$R1 # c+= overflow
299 ldq $L3,16($17) # a[2]
300 cmpult $R1,$CC,$CC # overflow?
301 ldq $R3,16($18) # b[2]
302 addq $CC,$O1,$CC
303 ldq $L4,24($17) # a[3]
304 addq $R2,$L2,$R2 # r=a+b;
305 ldq $R4,24($18) # b[3]
306 cmpult $R2,$L2,$O2 # did we overflow?
307 addq $R3,$L3,$R3 # r=a+b;
308 addq $R2,$CC,$R2 # c+= overflow
309 cmpult $R3,$L3,$O3 # did we overflow?
310 cmpult $R2,$CC,$CC # overflow?
311 addq $R4,$L4,$R4 # r=a+b;
312 addq $CC,$O2,$CC
313 cmpult $R4,$L4,$O4 # did we overflow?
314 addq $R3,$CC,$R3 # c+= overflow
315 stq $R1,0($16) # r[0]=c
316 cmpult $R3,$CC,$CC # overflow?
317 stq $R2,8($16) # r[1]=c
318 addq $CC,$O3,$CC
319 stq $R3,16($16) # r[2]=c
320 addq $R4,$CC,$R4 # c+= overflow
321 subq $19,4,$19 # loop--
322 cmpult $R4,$CC,$CC # overflow?
323 addq $17,32,$17 # a++
324 addq $CC,$O4,$CC
325 stq $R4,24($16) # r[3]=c
326 addq $18,32,$18 # b++
327 addq $16,32,$16 # r++
328
329 blt $19,$900
330 ldq $L1,0($17) # a[0]
331 ldq $R1,0($18) # b[1]
332 br $901
333 .align 4
334$945:
335 ldq $L1,0($17) # a[0]
336 ldq $R1,0($18) # b[1]
337 addq $R1,$L1,$R1 # r=a+b;
338 subq $19,1,$19 # loop--
339 addq $R1,$CC,$R1 # c+= overflow
340 addq $17,8,$17 # a++
341 cmpult $R1,$L1,$O1 # did we overflow?
342 cmpult $R1,$CC,$CC # overflow?
343 addq $18,8,$18 # b++
344 stq $R1,0($16) # r[0]=c
345 addq $CC,$O1,$CC
346 addq $16,8,$16 # r++
347
348 bgt $19,$945
349 ret $31,($26),1 # else exit
350
351$900:
352 addq $19,4,$19
353 bgt $19,$945 # goto tail code
354 ret $31,($26),1 # else exit
355 .end bn_add_words
356
357 .align 3
358 .globl bn_sub_words
359 .ent bn_sub_words
360bn_sub_words:
361bn_sub_words..ng:
362 .frame $30,0,$26,0
363 .prologue 0
364
365 subq $19,4,$19
366 bis $31,$31,$CC # carry = 0
367 br $800
368 blt $19,$800
369 ldq $L1,0($17) # a[0]
370 ldq $R1,0($18) # b[1]
371 .align 3
372$801:
373 addq $R1,$L1,$R1 # r=a+b;
374 ldq $L2,8($17) # a[1]
375 cmpult $R1,$L1,$O1 # did we overflow?
376 ldq $R2,8($18) # b[1]
377 addq $R1,$CC,$R1 # c+= overflow
378 ldq $L3,16($17) # a[2]
379 cmpult $R1,$CC,$CC # overflow?
380 ldq $R3,16($18) # b[2]
381 addq $CC,$O1,$CC
382 ldq $L4,24($17) # a[3]
383 addq $R2,$L2,$R2 # r=a+b;
384 ldq $R4,24($18) # b[3]
385 cmpult $R2,$L2,$O2 # did we overflow?
386 addq $R3,$L3,$R3 # r=a+b;
387 addq $R2,$CC,$R2 # c+= overflow
388 cmpult $R3,$L3,$O3 # did we overflow?
389 cmpult $R2,$CC,$CC # overflow?
390 addq $R4,$L4,$R4 # r=a+b;
391 addq $CC,$O2,$CC
392 cmpult $R4,$L4,$O4 # did we overflow?
393 addq $R3,$CC,$R3 # c+= overflow
394 stq $R1,0($16) # r[0]=c
395 cmpult $R3,$CC,$CC # overflow?
396 stq $R2,8($16) # r[1]=c
397 addq $CC,$O3,$CC
398 stq $R3,16($16) # r[2]=c
399 addq $R4,$CC,$R4 # c+= overflow
400 subq $19,4,$19 # loop--
401 cmpult $R4,$CC,$CC # overflow?
402 addq $17,32,$17 # a++
403 addq $CC,$O4,$CC
404 stq $R4,24($16) # r[3]=c
405 addq $18,32,$18 # b++
406 addq $16,32,$16 # r++
407
408 blt $19,$800
409 ldq $L1,0($17) # a[0]
410 ldq $R1,0($18) # b[1]
411 br $801
412 .align 4
413$845:
414 ldq $L1,0($17) # a[0]
415 ldq $R1,0($18) # b[1]
416 cmpult $L1,$R1,$O1 # will we borrow?
417 subq $L1,$R1,$R1 # r=a-b;
418 subq $19,1,$19 # loop--
419 cmpult $R1,$CC,$O2 # will we borrow?
420 subq $R1,$CC,$R1 # c+= overflow
421 addq $17,8,$17 # a++
422 addq $18,8,$18 # b++
423 stq $R1,0($16) # r[0]=c
424 addq $O2,$O1,$CC
425 addq $16,8,$16 # r++
426
427 bgt $19,$845
428 ret $31,($26),1 # else exit
429
430$800:
431 addq $19,4,$19
432 bgt $19,$845 # goto tail code
433 ret $31,($26),1 # else exit
434 .end bn_sub_words
435
436 #
437 # What follows was taken directly from the C compiler with a few
438 # hacks to redo the lables.
439 #
440.text
441 .align 3
442 .globl bn_div_words
443 .ent bn_div_words
444bn_div_words:
445 ldgp $29,0($27)
446bn_div_words..ng:
447 lda $30,-48($30)
448 .frame $30,48,$26,0
449 stq $26,0($30)
450 stq $9,8($30)
451 stq $10,16($30)
452 stq $11,24($30)
453 stq $12,32($30)
454 stq $13,40($30)
455 .mask 0x4003e00,-48
456 .prologue 1
457 bis $16,$16,$9
458 bis $17,$17,$10
459 bis $18,$18,$11
460 bis $31,$31,$13
461 bis $31,2,$12
462 bne $11,$119
463 lda $0,-1
464 br $31,$136
465 .align 4
466$119:
467 bis $11,$11,$16
468 jsr $26,BN_num_bits_word
469 ldgp $29,0($26)
470 subq $0,64,$1
471 beq $1,$120
472 bis $31,1,$1
473 sll $1,$0,$1
474 cmpule $9,$1,$1
475 bne $1,$120
476 # lda $16,_IO_stderr_
477 # lda $17,$C32
478 # bis $0,$0,$18
479 # jsr $26,fprintf
480 # ldgp $29,0($26)
481 jsr $26,abort
482 ldgp $29,0($26)
483 .align 4
484$120:
485 bis $31,64,$3
486 cmpult $9,$11,$2
487 subq $3,$0,$1
488 addl $1,$31,$0
489 subq $9,$11,$1
490 cmoveq $2,$1,$9
491 beq $0,$122
492 zapnot $0,15,$2
493 subq $3,$0,$1
494 sll $11,$2,$11
495 sll $9,$2,$3
496 srl $10,$1,$1
497 sll $10,$2,$10
498 bis $3,$1,$9
499$122:
500 srl $11,32,$5
501 zapnot $11,15,$6
502 lda $7,-1
503 .align 5
504$123:
505 srl $9,32,$1
506 subq $1,$5,$1
507 bne $1,$126
508 zapnot $7,15,$27
509 br $31,$127
510 .align 4
511$126:
512 bis $9,$9,$24
513 bis $5,$5,$25
514 divqu $24,$25,$27
515$127:
516 srl $10,32,$4
517 .align 5
518$128:
519 mulq $27,$5,$1
520 subq $9,$1,$3
521 zapnot $3,240,$1
522 bne $1,$129
523 mulq $6,$27,$2
524 sll $3,32,$1
525 addq $1,$4,$1
526 cmpule $2,$1,$2
527 bne $2,$129
528 subq $27,1,$27
529 br $31,$128
530 .align 4
531$129:
532 mulq $27,$6,$1
533 mulq $27,$5,$4
534 srl $1,32,$3
535 sll $1,32,$1
536 addq $4,$3,$4
537 cmpult $10,$1,$2
538 subq $10,$1,$10
539 addq $2,$4,$2
540 cmpult $9,$2,$1
541 bis $2,$2,$4
542 beq $1,$134
543 addq $9,$11,$9
544 subq $27,1,$27
545$134:
546 subl $12,1,$12
547 subq $9,$4,$9
548 beq $12,$124
549 sll $27,32,$13
550 sll $9,32,$2
551 srl $10,32,$1
552 sll $10,32,$10
553 bis $2,$1,$9
554 br $31,$123
555 .align 4
556$124:
557 bis $13,$27,$0
558$136:
559 ldq $26,0($30)
560 ldq $9,8($30)
561 ldq $10,16($30)
562 ldq $11,24($30)
563 ldq $12,32($30)
564 ldq $13,40($30)
565 addq $30,48,$30
566 ret $31,($26),1
567 .end bn_div_words
568EOF
569 return($data);
570 }
571
diff --git a/src/lib/libcrypto/bn/asm/ca.pl b/src/lib/libcrypto/bn/asm/ca.pl
deleted file mode 100644
index c1ce67a6b4..0000000000
--- a/src/lib/libcrypto/bn/asm/ca.pl
+++ /dev/null
@@ -1,33 +0,0 @@
1#!/usr/local/bin/perl
2# I have this in perl so I can use more usefull register names and then convert
3# them into alpha registers.
4#
5
6push(@INC,"perlasm","../../perlasm");
7require "alpha.pl";
8require "alpha/mul_add.pl";
9require "alpha/mul.pl";
10require "alpha/sqr.pl";
11require "alpha/add.pl";
12require "alpha/sub.pl";
13require "alpha/mul_c8.pl";
14require "alpha/mul_c4.pl";
15require "alpha/sqr_c4.pl";
16require "alpha/sqr_c8.pl";
17require "alpha/div.pl";
18
19&asm_init($ARGV[0],$0);
20
21&bn_mul_words("bn_mul_words");
22&bn_sqr_words("bn_sqr_words");
23&bn_mul_add_words("bn_mul_add_words");
24&bn_add_words("bn_add_words");
25&bn_sub_words("bn_sub_words");
26&bn_div_words("bn_div_words");
27&bn_mul_comba8("bn_mul_comba8");
28&bn_mul_comba4("bn_mul_comba4");
29&bn_sqr_comba4("bn_sqr_comba4");
30&bn_sqr_comba8("bn_sqr_comba8");
31
32&asm_finish();
33
diff --git a/src/lib/libcrypto/bn/asm/co-alpha.pl b/src/lib/libcrypto/bn/asm/co-alpha.pl
deleted file mode 100644
index 67dad3e3d5..0000000000
--- a/src/lib/libcrypto/bn/asm/co-alpha.pl
+++ /dev/null
@@ -1,116 +0,0 @@
1#!/usr/local/bin/perl
2# I have this in perl so I can use more usefull register names and then convert
3# them into alpha registers.
4#
5
6push(@INC,"perlasm","../../perlasm");
7require "alpha.pl";
8
9&asm_init($ARGV[0],$0);
10
11print &bn_sub_words("bn_sub_words");
12
13&asm_finish();
14
15sub bn_sub_words
16 {
17 local($name)=@_;
18 local($cc,$a,$b,$r);
19
20 $cc="r0";
21 $a0="r1"; $b0="r5"; $r0="r9"; $tmp="r13";
22 $a1="r2"; $b1="r6"; $r1="r10"; $t1="r14";
23 $a2="r3"; $b2="r7"; $r2="r11";
24 $a3="r4"; $b3="r8"; $r3="r12"; $t3="r15";
25
26 $rp=&wparam(0);
27 $ap=&wparam(1);
28 $bp=&wparam(2);
29 $count=&wparam(3);
30
31 &function_begin($name,"");
32
33 &comment("");
34 &sub($count,4,$count);
35 &mov("zero",$cc);
36 &blt($count,&label("finish"));
37
38 &ld($a0,&QWPw(0,$ap));
39 &ld($b0,&QWPw(0,$bp));
40
41##########################################################
42 &set_label("loop");
43
44 &ld($a1,&QWPw(1,$ap));
45 &cmpult($a0,$b0,$tmp); # will we borrow?
46 &ld($b1,&QWPw(1,$bp));
47 &sub($a0,$b0,$a0); # do the subtract
48 &ld($a2,&QWPw(2,$ap));
49 &cmpult($a0,$cc,$b0); # will we borrow?
50 &ld($b2,&QWPw(2,$bp));
51 &sub($a0,$cc,$a0); # will we borrow?
52 &ld($a3,&QWPw(3,$ap));
53 &add($b0,$tmp,$cc); # add the borrows
54
55 &cmpult($a1,$b1,$t1); # will we borrow?
56 &sub($a1,$b1,$a1); # do the subtract
57 &ld($b3,&QWPw(3,$bp));
58 &cmpult($a1,$cc,$b1); # will we borrow?
59 &sub($a1,$cc,$a1); # will we borrow?
60 &add($b1,$t1,$cc); # add the borrows
61
62 &cmpult($a2,$b2,$tmp); # will we borrow?
63 &sub($a2,$b2,$a2); # do the subtract
64 &st($a0,&QWPw(0,$rp)); # save
65 &cmpult($a2,$cc,$b2); # will we borrow?
66 &sub($a2,$cc,$a2); # will we borrow?
67 &add($b2,$tmp,$cc); # add the borrows
68
69 &cmpult($a3,$b3,$t3); # will we borrow?
70 &sub($a3,$b3,$a3); # do the subtract
71 &st($a1,&QWPw(1,$rp)); # save
72 &cmpult($a3,$cc,$b3); # will we borrow?
73 &sub($a3,$cc,$a3); # will we borrow?
74 &add($b3,$t3,$cc); # add the borrows
75
76 &st($a2,&QWPw(2,$rp)); # save
77 &sub($count,4,$count); # count-=4
78 &st($a3,&QWPw(3,$rp)); # save
79 &add($ap,4*$QWS,$ap); # count+=4
80 &add($bp,4*$QWS,$bp); # count+=4
81 &add($rp,4*$QWS,$rp); # count+=4
82
83 &blt($count,&label("finish"));
84 &ld($a0,&QWPw(0,$ap));
85 &ld($b0,&QWPw(0,$bp));
86 &br(&label("loop"));
87##################################################
88 # Do the last 0..3 words
89
90 &set_label("last_loop");
91
92 &ld($a0,&QWPw(0,$ap)); # get a
93 &ld($b0,&QWPw(0,$bp)); # get b
94 &cmpult($a0,$b0,$tmp); # will we borrow?
95 &sub($a0,$b0,$a0); # do the subtract
96 &cmpult($a0,$cc,$b0); # will we borrow?
97 &sub($a0,$cc,$a0); # will we borrow?
98 &st($a0,&QWPw(0,$rp)); # save
99 &add($b0,$tmp,$cc); # add the borrows
100
101 &add($ap,$QWS,$ap);
102 &add($bp,$QWS,$bp);
103 &add($rp,$QWS,$rp);
104 &sub($count,1,$count);
105 &bgt($count,&label("last_loop"));
106 &function_end_A($name);
107
108######################################################
109 &set_label("finish");
110 &add($count,4,$count);
111 &bgt($count,&label("last_loop"));
112
113 &set_label("end");
114 &function_end($name);
115 }
116
diff --git a/src/lib/libcrypto/bn/asm/mips1.s b/src/lib/libcrypto/bn/asm/mips1.s
deleted file mode 100644
index 44fa1254c7..0000000000
--- a/src/lib/libcrypto/bn/asm/mips1.s
+++ /dev/null
@@ -1,539 +0,0 @@
1/* This assember is for R2000/R3000 machines, or higher ones that do
2 * no want to do any 64 bit arithmatic.
3 * Make sure that the SSLeay bignum library is compiled with
4 * THIRTY_TWO_BIT set.
5 * This must either be compiled with the system CC, or, if you use GNU gas,
6 * cc -E mips1.s|gas -o mips1.o
7 */
8 .set reorder
9 .set noat
10
11#define R1 $1
12#define CC $2
13#define R2 $3
14#define R3 $8
15#define R4 $9
16#define L1 $10
17#define L2 $11
18#define L3 $12
19#define L4 $13
20#define H1 $14
21#define H2 $15
22#define H3 $24
23#define H4 $25
24
25#define P1 $4
26#define P2 $5
27#define P3 $6
28#define P4 $7
29
30 .align 2
31 .ent bn_mul_add_words
32 .globl bn_mul_add_words
33.text
34bn_mul_add_words:
35 .frame $sp,0,$31
36 .mask 0x00000000,0
37 .fmask 0x00000000,0
38
39 #blt P3,4,$lab34
40
41 subu R1,P3,4
42 move CC,$0
43 bltz R1,$lab34
44$lab2:
45 lw R1,0(P1)
46 lw L1,0(P2)
47 lw R2,4(P1)
48 lw L2,4(P2)
49 lw R3,8(P1)
50 lw L3,8(P2)
51 lw R4,12(P1)
52 lw L4,12(P2)
53 multu L1,P4
54 addu R1,R1,CC
55 mflo L1
56 sltu CC,R1,CC
57 addu R1,R1,L1
58 mfhi H1
59 sltu L1,R1,L1
60 sw R1,0(P1)
61 addu CC,CC,L1
62 multu L2,P4
63 addu CC,H1,CC
64 mflo L2
65 addu R2,R2,CC
66 sltu CC,R2,CC
67 mfhi H2
68 addu R2,R2,L2
69 addu P2,P2,16
70 sltu L2,R2,L2
71 sw R2,4(P1)
72 addu CC,CC,L2
73 multu L3,P4
74 addu CC,H2,CC
75 mflo L3
76 addu R3,R3,CC
77 sltu CC,R3,CC
78 mfhi H3
79 addu R3,R3,L3
80 addu P1,P1,16
81 sltu L3,R3,L3
82 sw R3,-8(P1)
83 addu CC,CC,L3
84 multu L4,P4
85 addu CC,H3,CC
86 mflo L4
87 addu R4,R4,CC
88 sltu CC,R4,CC
89 mfhi H4
90 addu R4,R4,L4
91 subu P3,P3,4
92 sltu L4,R4,L4
93 addu CC,CC,L4
94 addu CC,H4,CC
95
96 subu R1,P3,4
97 sw R4,-4(P1) # delay slot
98 bgez R1,$lab2
99
100 bleu P3,0,$lab3
101 .align 2
102$lab33:
103 lw L1,0(P2)
104 lw R1,0(P1)
105 multu L1,P4
106 addu R1,R1,CC
107 sltu CC,R1,CC
108 addu P1,P1,4
109 mflo L1
110 mfhi H1
111 addu R1,R1,L1
112 addu P2,P2,4
113 sltu L1,R1,L1
114 subu P3,P3,1
115 addu CC,CC,L1
116 sw R1,-4(P1)
117 addu CC,H1,CC
118 bgtz P3,$lab33
119 j $31
120 .align 2
121$lab3:
122 j $31
123 .align 2
124$lab34:
125 bgt P3,0,$lab33
126 j $31
127 .end bn_mul_add_words
128
129 .align 2
130 # Program Unit: bn_mul_words
131 .ent bn_mul_words
132 .globl bn_mul_words
133.text
134bn_mul_words:
135 .frame $sp,0,$31
136 .mask 0x00000000,0
137 .fmask 0x00000000,0
138
139 subu P3,P3,4
140 move CC,$0
141 bltz P3,$lab45
142$lab44:
143 lw L1,0(P2)
144 lw L2,4(P2)
145 lw L3,8(P2)
146 lw L4,12(P2)
147 multu L1,P4
148 subu P3,P3,4
149 mflo L1
150 mfhi H1
151 addu L1,L1,CC
152 multu L2,P4
153 sltu CC,L1,CC
154 sw L1,0(P1)
155 addu CC,H1,CC
156 mflo L2
157 mfhi H2
158 addu L2,L2,CC
159 multu L3,P4
160 sltu CC,L2,CC
161 sw L2,4(P1)
162 addu CC,H2,CC
163 mflo L3
164 mfhi H3
165 addu L3,L3,CC
166 multu L4,P4
167 sltu CC,L3,CC
168 sw L3,8(P1)
169 addu CC,H3,CC
170 mflo L4
171 mfhi H4
172 addu L4,L4,CC
173 addu P1,P1,16
174 sltu CC,L4,CC
175 addu P2,P2,16
176 addu CC,H4,CC
177 sw L4,-4(P1)
178
179 bgez P3,$lab44
180 b $lab45
181$lab46:
182 lw L1,0(P2)
183 addu P1,P1,4
184 multu L1,P4
185 addu P2,P2,4
186 mflo L1
187 mfhi H1
188 addu L1,L1,CC
189 subu P3,P3,1
190 sltu CC,L1,CC
191 sw L1,-4(P1)
192 addu CC,H1,CC
193 bgtz P3,$lab46
194 j $31
195$lab45:
196 addu P3,P3,4
197 bgtz P3,$lab46
198 j $31
199 .align 2
200 .end bn_mul_words
201
202 # Program Unit: bn_sqr_words
203 .ent bn_sqr_words
204 .globl bn_sqr_words
205.text
206bn_sqr_words:
207 .frame $sp,0,$31
208 .mask 0x00000000,0
209 .fmask 0x00000000,0
210
211 subu P3,P3,4
212 bltz P3,$lab55
213$lab54:
214 lw L1,0(P2)
215 lw L2,4(P2)
216 lw L3,8(P2)
217 lw L4,12(P2)
218
219 multu L1,L1
220 subu P3,P3,4
221 mflo L1
222 mfhi H1
223 sw L1,0(P1)
224 sw H1,4(P1)
225
226 multu L2,L2
227 addu P1,P1,32
228 mflo L2
229 mfhi H2
230 sw L2,-24(P1)
231 sw H2,-20(P1)
232
233 multu L3,L3
234 addu P2,P2,16
235 mflo L3
236 mfhi H3
237 sw L3,-16(P1)
238 sw H3,-12(P1)
239
240 multu L4,L4
241
242 mflo L4
243 mfhi H4
244 sw L4,-8(P1)
245 sw H4,-4(P1)
246
247 bgtz P3,$lab54
248 b $lab55
249$lab56:
250 lw L1,0(P2)
251 addu P1,P1,8
252 multu L1,L1
253 addu P2,P2,4
254 subu P3,P3,1
255 mflo L1
256 mfhi H1
257 sw L1,-8(P1)
258 sw H1,-4(P1)
259
260 bgtz P3,$lab56
261 j $31
262$lab55:
263 addu P3,P3,4
264 bgtz P3,$lab56
265 j $31
266 .align 2
267 .end bn_sqr_words
268
269 # Program Unit: bn_add_words
270 .ent bn_add_words
271 .globl bn_add_words
272.text
273bn_add_words: # 0x590
274 .frame $sp,0,$31
275 .mask 0x00000000,0
276 .fmask 0x00000000,0
277
278 subu P4,P4,4
279 move CC,$0
280 bltz P4,$lab65
281$lab64:
282 lw L1,0(P2)
283 lw R1,0(P3)
284 lw L2,4(P2)
285 lw R2,4(P3)
286
287 addu L1,L1,CC
288 lw L3,8(P2)
289 sltu CC,L1,CC
290 addu L1,L1,R1
291 sltu R1,L1,R1
292 lw R3,8(P3)
293 addu CC,CC,R1
294 lw L4,12(P2)
295
296 addu L2,L2,CC
297 lw R4,12(P3)
298 sltu CC,L2,CC
299 addu L2,L2,R2
300 sltu R2,L2,R2
301 sw L1,0(P1)
302 addu CC,CC,R2
303 addu P1,P1,16
304 addu L3,L3,CC
305 sw L2,-12(P1)
306
307 sltu CC,L3,CC
308 addu L3,L3,R3
309 sltu R3,L3,R3
310 addu P2,P2,16
311 addu CC,CC,R3
312
313 addu L4,L4,CC
314 addu P3,P3,16
315 sltu CC,L4,CC
316 addu L4,L4,R4
317 subu P4,P4,4
318 sltu R4,L4,R4
319 sw L3,-8(P1)
320 addu CC,CC,R4
321 sw L4,-4(P1)
322
323 bgtz P4,$lab64
324 b $lab65
325$lab66:
326 lw L1,0(P2)
327 lw R1,0(P3)
328 addu L1,L1,CC
329 addu P1,P1,4
330 sltu CC,L1,CC
331 addu P2,P2,4
332 addu P3,P3,4
333 addu L1,L1,R1
334 subu P4,P4,1
335 sltu R1,L1,R1
336 sw L1,-4(P1)
337 addu CC,CC,R1
338
339 bgtz P4,$lab66
340 j $31
341$lab65:
342 addu P4,P4,4
343 bgtz P4,$lab66
344 j $31
345 .end bn_add_words
346
347 # Program Unit: bn_div64
348 .set at
349 .set reorder
350 .text
351 .align 2
352 .globl bn_div64
353 # 321 {
354 .ent bn_div64 2
355bn_div64:
356 subu $sp, 64
357 sw $31, 56($sp)
358 sw $16, 48($sp)
359 .mask 0x80010000, -56
360 .frame $sp, 64, $31
361 move $9, $4
362 move $12, $5
363 move $16, $6
364 # 322 BN_ULONG dh,dl,q,ret=0,th,tl,t;
365 move $31, $0
366 # 323 int i,count=2;
367 li $13, 2
368 # 324
369 # 325 if (d == 0) return(BN_MASK2);
370 bne $16, 0, $80
371 li $2, -1
372 b $93
373$80:
374 # 326
375 # 327 i=BN_num_bits_word(d);
376 move $4, $16
377 sw $31, 16($sp)
378 sw $9, 24($sp)
379 sw $12, 32($sp)
380 sw $13, 40($sp)
381 .livereg 0x800ff0e,0xfff
382 jal BN_num_bits_word
383 li $4, 32
384 lw $31, 16($sp)
385 lw $9, 24($sp)
386 lw $12, 32($sp)
387 lw $13, 40($sp)
388 move $3, $2
389 # 328 if ((i != BN_BITS2) && (h > (BN_ULONG)1<<i))
390 beq $2, $4, $81
391 li $14, 1
392 sll $15, $14, $2
393 bleu $9, $15, $81
394 # 329 {
395 # 330 #if !defined(NO_STDIO) && !defined(WIN16)
396 # 331 fprintf(stderr,"Division would overflow (%d)\n",i);
397 # 332 #endif
398 # 333 abort();
399 sw $3, 8($sp)
400 sw $9, 24($sp)
401 sw $12, 32($sp)
402 sw $13, 40($sp)
403 sw $31, 26($sp)
404 .livereg 0xff0e,0xfff
405 jal abort
406 lw $3, 8($sp)
407 li $4, 32
408 lw $9, 24($sp)
409 lw $12, 32($sp)
410 lw $13, 40($sp)
411 lw $31, 26($sp)
412 # 334 }
413$81:
414 # 335 i=BN_BITS2-i;
415 subu $3, $4, $3
416 # 336 if (h >= d) h-=d;
417 bltu $9, $16, $82
418 subu $9, $9, $16
419$82:
420 # 337
421 # 338 if (i)
422 beq $3, 0, $83
423 # 339 {
424 # 340 d<<=i;
425 sll $16, $16, $3
426 # 341 h=(h<<i)|(l>>(BN_BITS2-i));
427 sll $24, $9, $3
428 subu $25, $4, $3
429 srl $14, $12, $25
430 or $9, $24, $14
431 # 342 l<<=i;
432 sll $12, $12, $3
433 # 343 }
434$83:
435 # 344 dh=(d&BN_MASK2h)>>BN_BITS4;
436 # 345 dl=(d&BN_MASK2l);
437 and $8, $16, -65536
438 srl $8, $8, 16
439 and $10, $16, 65535
440 li $6, -65536
441$84:
442 # 346 for (;;)
443 # 347 {
444 # 348 if ((h>>BN_BITS4) == dh)
445 srl $15, $9, 16
446 bne $8, $15, $85
447 # 349 q=BN_MASK2l;
448 li $5, 65535
449 b $86
450$85:
451 # 350 else
452 # 351 q=h/dh;
453 divu $5, $9, $8
454$86:
455 # 352
456 # 353 for (;;)
457 # 354 {
458 # 355 t=(h-q*dh);
459 mul $4, $5, $8
460 subu $2, $9, $4
461 move $3, $2
462 # 356 if ((t&BN_MASK2h) ||
463 # 357 ((dl*q) <= (
464 # 358 (t<<BN_BITS4)+
465 # 359 ((l&BN_MASK2h)>>BN_BITS4))))
466 and $25, $2, $6
467 bne $25, $0, $87
468 mul $24, $10, $5
469 sll $14, $3, 16
470 and $15, $12, $6
471 srl $25, $15, 16
472 addu $15, $14, $25
473 bgtu $24, $15, $88
474$87:
475 # 360 break;
476 mul $3, $10, $5
477 b $89
478$88:
479 # 361 q--;
480 addu $5, $5, -1
481 # 362 }
482 b $86
483$89:
484 # 363 th=q*dh;
485 # 364 tl=q*dl;
486 # 365 t=(tl>>BN_BITS4);
487 # 366 tl=(tl<<BN_BITS4)&BN_MASK2h;
488 sll $14, $3, 16
489 and $2, $14, $6
490 move $11, $2
491 # 367 th+=t;
492 srl $25, $3, 16
493 addu $7, $4, $25
494 # 368
495 # 369 if (l < tl) th++;
496 bgeu $12, $2, $90
497 addu $7, $7, 1
498$90:
499 # 370 l-=tl;
500 subu $12, $12, $11
501 # 371 if (h < th)
502 bgeu $9, $7, $91
503 # 372 {
504 # 373 h+=d;
505 addu $9, $9, $16
506 # 374 q--;
507 addu $5, $5, -1
508 # 375 }
509$91:
510 # 376 h-=th;
511 subu $9, $9, $7
512 # 377
513 # 378 if (--count == 0) break;
514 addu $13, $13, -1
515 beq $13, 0, $92
516 # 379
517 # 380 ret=q<<BN_BITS4;
518 sll $31, $5, 16
519 # 381 h=((h<<BN_BITS4)|(l>>BN_BITS4))&BN_MASK2;
520 sll $24, $9, 16
521 srl $15, $12, 16
522 or $9, $24, $15
523 # 382 l=(l&BN_MASK2l)<<BN_BITS4;
524 and $12, $12, 65535
525 sll $12, $12, 16
526 # 383 }
527 b $84
528$92:
529 # 384 ret|=q;
530 or $31, $31, $5
531 # 385 return(ret);
532 move $2, $31
533$93:
534 lw $16, 48($sp)
535 lw $31, 56($sp)
536 addu $sp, 64
537 j $31
538 .end bn_div64
539
diff --git a/src/lib/libcrypto/bn/asm/mips3-mont.pl b/src/lib/libcrypto/bn/asm/mips3-mont.pl
new file mode 100644
index 0000000000..8f9156e02a
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/mips3-mont.pl
@@ -0,0 +1,327 @@
1#!/usr/bin/env perl
2#
3# ====================================================================
4# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
5# project. The module is, however, dual licensed under OpenSSL and
6# CRYPTOGAMS licenses depending on where you obtain it. For further
7# details see http://www.openssl.org/~appro/cryptogams/.
8# ====================================================================
9
10# This module doesn't present direct interest for OpenSSL, because it
11# doesn't provide better performance for longer keys. While 512-bit
12# RSA private key operations are 40% faster, 1024-bit ones are hardly
13# faster at all, while longer key operations are slower by up to 20%.
14# It might be of interest to embedded system developers though, as
15# it's smaller than 1KB, yet offers ~3x improvement over compiler
16# generated code.
17#
18# The module targets N32 and N64 MIPS ABIs and currently is a bit
19# IRIX-centric, i.e. is likely to require adaptation for other OSes.
20
21# int bn_mul_mont(
22$rp="a0"; # BN_ULONG *rp,
23$ap="a1"; # const BN_ULONG *ap,
24$bp="a2"; # const BN_ULONG *bp,
25$np="a3"; # const BN_ULONG *np,
26$n0="a4"; # const BN_ULONG *n0,
27$num="a5"; # int num);
28
29$lo0="a6";
30$hi0="a7";
31$lo1="v0";
32$hi1="v1";
33$aj="t0";
34$bi="t1";
35$nj="t2";
36$tp="t3";
37$alo="s0";
38$ahi="s1";
39$nlo="s2";
40$nhi="s3";
41$tj="s4";
42$i="s5";
43$j="s6";
44$fp="t8";
45$m1="t9";
46
47$FRAME=8*(2+8);
48
49$code=<<___;
50#include <asm.h>
51#include <regdef.h>
52
53.text
54
55.set noat
56.set reorder
57
58.align 5
59.globl bn_mul_mont
60.ent bn_mul_mont
61bn_mul_mont:
62 .set noreorder
63 PTR_SUB sp,64
64 move $fp,sp
65 .frame $fp,64,ra
66 slt AT,$num,4
67 li v0,0
68 beqzl AT,.Lproceed
69 nop
70 jr ra
71 PTR_ADD sp,$fp,64
72 .set reorder
73.align 5
74.Lproceed:
75 ld $n0,0($n0)
76 ld $bi,0($bp) # bp[0]
77 ld $aj,0($ap) # ap[0]
78 ld $nj,0($np) # np[0]
79 PTR_SUB sp,16 # place for two extra words
80 sll $num,3
81 li AT,-4096
82 PTR_SUB sp,$num
83 and sp,AT
84
85 sd s0,0($fp)
86 sd s1,8($fp)
87 sd s2,16($fp)
88 sd s3,24($fp)
89 sd s4,32($fp)
90 sd s5,40($fp)
91 sd s6,48($fp)
92 sd s7,56($fp)
93
94 dmultu $aj,$bi
95 ld $alo,8($ap)
96 ld $nlo,8($np)
97 mflo $lo0
98 mfhi $hi0
99 dmultu $lo0,$n0
100 mflo $m1
101
102 dmultu $alo,$bi
103 mflo $alo
104 mfhi $ahi
105
106 dmultu $nj,$m1
107 mflo $lo1
108 mfhi $hi1
109 dmultu $nlo,$m1
110 daddu $lo1,$lo0
111 sltu AT,$lo1,$lo0
112 daddu $hi1,AT
113 mflo $nlo
114 mfhi $nhi
115
116 move $tp,sp
117 li $j,16
118.align 4
119.L1st:
120 .set noreorder
121 PTR_ADD $aj,$ap,$j
122 ld $aj,($aj)
123 PTR_ADD $nj,$np,$j
124 ld $nj,($nj)
125
126 dmultu $aj,$bi
127 daddu $lo0,$alo,$hi0
128 daddu $lo1,$nlo,$hi1
129 sltu AT,$lo0,$hi0
130 sltu s7,$lo1,$hi1
131 daddu $hi0,$ahi,AT
132 daddu $hi1,$nhi,s7
133 mflo $alo
134 mfhi $ahi
135
136 daddu $lo1,$lo0
137 sltu AT,$lo1,$lo0
138 dmultu $nj,$m1
139 daddu $hi1,AT
140 addu $j,8
141 sd $lo1,($tp)
142 sltu s7,$j,$num
143 mflo $nlo
144 mfhi $nhi
145
146 bnez s7,.L1st
147 PTR_ADD $tp,8
148 .set reorder
149
150 daddu $lo0,$alo,$hi0
151 sltu AT,$lo0,$hi0
152 daddu $hi0,$ahi,AT
153
154 daddu $lo1,$nlo,$hi1
155 sltu s7,$lo1,$hi1
156 daddu $hi1,$nhi,s7
157 daddu $lo1,$lo0
158 sltu AT,$lo1,$lo0
159 daddu $hi1,AT
160
161 sd $lo1,($tp)
162
163 daddu $hi1,$hi0
164 sltu AT,$hi1,$hi0
165 sd $hi1,8($tp)
166 sd AT,16($tp)
167
168 li $i,8
169.align 4
170.Louter:
171 PTR_ADD $bi,$bp,$i
172 ld $bi,($bi)
173 ld $aj,($ap)
174 ld $alo,8($ap)
175 ld $tj,(sp)
176
177 dmultu $aj,$bi
178 ld $nj,($np)
179 ld $nlo,8($np)
180 mflo $lo0
181 mfhi $hi0
182 daddu $lo0,$tj
183 dmultu $lo0,$n0
184 sltu AT,$lo0,$tj
185 daddu $hi0,AT
186 mflo $m1
187
188 dmultu $alo,$bi
189 mflo $alo
190 mfhi $ahi
191
192 dmultu $nj,$m1
193 mflo $lo1
194 mfhi $hi1
195
196 dmultu $nlo,$m1
197 daddu $lo1,$lo0
198 sltu AT,$lo1,$lo0
199 daddu $hi1,AT
200 mflo $nlo
201 mfhi $nhi
202
203 move $tp,sp
204 li $j,16
205 ld $tj,8($tp)
206.align 4
207.Linner:
208 .set noreorder
209 PTR_ADD $aj,$ap,$j
210 ld $aj,($aj)
211 PTR_ADD $nj,$np,$j
212 ld $nj,($nj)
213
214 dmultu $aj,$bi
215 daddu $lo0,$alo,$hi0
216 daddu $lo1,$nlo,$hi1
217 sltu AT,$lo0,$hi0
218 sltu s7,$lo1,$hi1
219 daddu $hi0,$ahi,AT
220 daddu $hi1,$nhi,s7
221 mflo $alo
222 mfhi $ahi
223
224 daddu $lo0,$tj
225 addu $j,8
226 dmultu $nj,$m1
227 sltu AT,$lo0,$tj
228 daddu $lo1,$lo0
229 daddu $hi0,AT
230 sltu s7,$lo1,$lo0
231 ld $tj,16($tp)
232 daddu $hi1,s7
233 sltu AT,$j,$num
234 mflo $nlo
235 mfhi $nhi
236 sd $lo1,($tp)
237 bnez AT,.Linner
238 PTR_ADD $tp,8
239 .set reorder
240
241 daddu $lo0,$alo,$hi0
242 sltu AT,$lo0,$hi0
243 daddu $hi0,$ahi,AT
244 daddu $lo0,$tj
245 sltu s7,$lo0,$tj
246 daddu $hi0,s7
247
248 ld $tj,16($tp)
249 daddu $lo1,$nlo,$hi1
250 sltu AT,$lo1,$hi1
251 daddu $hi1,$nhi,AT
252 daddu $lo1,$lo0
253 sltu s7,$lo1,$lo0
254 daddu $hi1,s7
255 sd $lo1,($tp)
256
257 daddu $lo1,$hi1,$hi0
258 sltu $hi1,$lo1,$hi0
259 daddu $lo1,$tj
260 sltu AT,$lo1,$tj
261 daddu $hi1,AT
262 sd $lo1,8($tp)
263 sd $hi1,16($tp)
264
265 addu $i,8
266 sltu s7,$i,$num
267 bnez s7,.Louter
268
269 .set noreorder
270 PTR_ADD $tj,sp,$num # &tp[num]
271 move $tp,sp
272 move $ap,sp
273 li $hi0,0 # clear borrow bit
274
275.align 4
276.Lsub: ld $lo0,($tp)
277 ld $lo1,($np)
278 PTR_ADD $tp,8
279 PTR_ADD $np,8
280 dsubu $lo1,$lo0,$lo1 # tp[i]-np[i]
281 sgtu AT,$lo1,$lo0
282 dsubu $lo0,$lo1,$hi0
283 sgtu $hi0,$lo0,$lo1
284 sd $lo0,($rp)
285 or $hi0,AT
286 sltu AT,$tp,$tj
287 bnez AT,.Lsub
288 PTR_ADD $rp,8
289
290 dsubu $hi0,$hi1,$hi0 # handle upmost overflow bit
291 move $tp,sp
292 PTR_SUB $rp,$num # restore rp
293 not $hi1,$hi0
294
295 and $ap,$hi0,sp
296 and $bp,$hi1,$rp
297 or $ap,$ap,$bp # ap=borrow?tp:rp
298
299.align 4
300.Lcopy: ld $aj,($ap)
301 PTR_ADD $ap,8
302 PTR_ADD $tp,8
303 sd zero,-8($tp)
304 sltu AT,$tp,$tj
305 sd $aj,($rp)
306 bnez AT,.Lcopy
307 PTR_ADD $rp,8
308
309 ld s0,0($fp)
310 ld s1,8($fp)
311 ld s2,16($fp)
312 ld s3,24($fp)
313 ld s4,32($fp)
314 ld s5,40($fp)
315 ld s6,48($fp)
316 ld s7,56($fp)
317 li v0,1
318 jr ra
319 PTR_ADD sp,$fp,64
320 .set reorder
321END(bn_mul_mont)
322.rdata
323.asciiz "Montgomery Multiplication for MIPS III/IV, CRYPTOGAMS by <appro\@openssl.org>"
324___
325
326print $code;
327close STDOUT;
diff --git a/src/lib/libcrypto/bn/asm/mo-586.pl b/src/lib/libcrypto/bn/asm/mo-586.pl
deleted file mode 100644
index 0982293094..0000000000
--- a/src/lib/libcrypto/bn/asm/mo-586.pl
+++ /dev/null
@@ -1,603 +0,0 @@
1#!/usr/bin/env perl
2
3# This is crypto/bn/asm/x86-mont.pl (with asciz from crypto/perlasm/x86asm.pl)
4# from OpenSSL 0.9.9-dev
5
6sub ::asciz
7{ my @str=unpack("C*",shift);
8 push @str,0;
9 while ($#str>15) {
10 &data_byte(@str[0..15]);
11 foreach (0..15) { shift @str; }
12 }
13 &data_byte(@str) if (@str);
14}
15
16# ====================================================================
17# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
18# project. The module is, however, dual licensed under OpenSSL and
19# CRYPTOGAMS licenses depending on where you obtain it. For further
20# details see http://www.openssl.org/~appro/cryptogams/.
21# ====================================================================
22
23# October 2005
24#
25# This is a "teaser" code, as it can be improved in several ways...
26# First of all non-SSE2 path should be implemented (yes, for now it
27# performs Montgomery multiplication/convolution only on SSE2-capable
28# CPUs such as P4, others fall down to original code). Then inner loop
29# can be unrolled and modulo-scheduled to improve ILP and possibly
30# moved to 128-bit XMM register bank (though it would require input
31# rearrangement and/or increase bus bandwidth utilization). Dedicated
32# squaring procedure should give further performance improvement...
33# Yet, for being draft, the code improves rsa512 *sign* benchmark by
34# 110%(!), rsa1024 one - by 70% and rsa4096 - by 20%:-)
35
36# December 2006
37#
38# Modulo-scheduling SSE2 loops results in further 15-20% improvement.
39# Integer-only code [being equipped with dedicated squaring procedure]
40# gives ~40% on rsa512 sign benchmark...
41
42push(@INC,"perlasm","../../perlasm");
43require "x86asm.pl";
44
45&asm_init($ARGV[0],$0);
46
47$sse2=0;
48for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
49
50&external_label("OPENSSL_ia32cap_P") if ($sse2);
51
52&function_begin("bn_mul_mont");
53
54$i="edx";
55$j="ecx";
56$ap="esi"; $tp="esi"; # overlapping variables!!!
57$rp="edi"; $bp="edi"; # overlapping variables!!!
58$np="ebp";
59$num="ebx";
60
61$_num=&DWP(4*0,"esp"); # stack top layout
62$_rp=&DWP(4*1,"esp");
63$_ap=&DWP(4*2,"esp");
64$_bp=&DWP(4*3,"esp");
65$_np=&DWP(4*4,"esp");
66$_n0=&DWP(4*5,"esp"); $_n0q=&QWP(4*5,"esp");
67$_sp=&DWP(4*6,"esp");
68$_bpend=&DWP(4*7,"esp");
69$frame=32; # size of above frame rounded up to 16n
70
71 &xor ("eax","eax");
72 &mov ("edi",&wparam(5)); # int num
73 &cmp ("edi",4);
74 &jl (&label("just_leave"));
75
76 &lea ("esi",&wparam(0)); # put aside pointer to argument block
77 &lea ("edx",&wparam(1)); # load ap
78 &mov ("ebp","esp"); # saved stack pointer!
79 &add ("edi",2); # extra two words on top of tp
80 &neg ("edi");
81 &lea ("esp",&DWP(-$frame,"esp","edi",4)); # alloca($frame+4*(num+2))
82 &neg ("edi");
83
84 # minimize cache contention by arraning 2K window between stack
85 # pointer and ap argument [np is also position sensitive vector,
86 # but it's assumed to be near ap, as it's allocated at ~same
87 # time].
88 &mov ("eax","esp");
89 &sub ("eax","edx");
90 &and ("eax",2047);
91 &sub ("esp","eax"); # this aligns sp and ap modulo 2048
92
93 &xor ("edx","esp");
94 &and ("edx",2048);
95 &xor ("edx",2048);
96 &sub ("esp","edx"); # this splits them apart modulo 4096
97
98 &and ("esp",-64); # align to cache line
99
100 ################################# load argument block...
101 &mov ("eax",&DWP(0*4,"esi"));# BN_ULONG *rp
102 &mov ("ebx",&DWP(1*4,"esi"));# const BN_ULONG *ap
103 &mov ("ecx",&DWP(2*4,"esi"));# const BN_ULONG *bp
104 &mov ("edx",&DWP(3*4,"esi"));# const BN_ULONG *np
105 &mov ("esi",&DWP(4*4,"esi"));# const BN_ULONG *n0
106 #&mov ("edi",&DWP(5*4,"esi"));# int num
107
108 &mov ("esi",&DWP(0,"esi")); # pull n0[0]
109 &mov ($_rp,"eax"); # ... save a copy of argument block
110 &mov ($_ap,"ebx");
111 &mov ($_bp,"ecx");
112 &mov ($_np,"edx");
113 &mov ($_n0,"esi");
114 &lea ($num,&DWP(-3,"edi")); # num=num-1 to assist modulo-scheduling
115 #&mov ($_num,$num); # redundant as $num is not reused
116 &mov ($_sp,"ebp"); # saved stack pointer!
117
118if($sse2) {
119$acc0="mm0"; # mmx register bank layout
120$acc1="mm1";
121$car0="mm2";
122$car1="mm3";
123$mul0="mm4";
124$mul1="mm5";
125$temp="mm6";
126$mask="mm7";
127
128 &picmeup("eax","OPENSSL_ia32cap_P");
129 &bt (&DWP(0,"eax"),26);
130 &jnc (&label("non_sse2"));
131
132 &mov ("eax",-1);
133 &movd ($mask,"eax"); # mask 32 lower bits
134
135 &mov ($ap,$_ap); # load input pointers
136 &mov ($bp,$_bp);
137 &mov ($np,$_np);
138
139 &xor ($i,$i); # i=0
140 &xor ($j,$j); # j=0
141
142 &movd ($mul0,&DWP(0,$bp)); # bp[0]
143 &movd ($mul1,&DWP(0,$ap)); # ap[0]
144 &movd ($car1,&DWP(0,$np)); # np[0]
145
146 &pmuludq($mul1,$mul0); # ap[0]*bp[0]
147 &movq ($car0,$mul1);
148 &movq ($acc0,$mul1); # I wish movd worked for
149 &pand ($acc0,$mask); # inter-register transfers
150
151 &pmuludq($mul1,$_n0q); # *=n0
152
153 &pmuludq($car1,$mul1); # "t[0]"*np[0]*n0
154 &paddq ($car1,$acc0);
155
156 &movd ($acc1,&DWP(4,$np)); # np[1]
157 &movd ($acc0,&DWP(4,$ap)); # ap[1]
158
159 &psrlq ($car0,32);
160 &psrlq ($car1,32);
161
162 &inc ($j); # j++
163&set_label("1st",16);
164 &pmuludq($acc0,$mul0); # ap[j]*bp[0]
165 &pmuludq($acc1,$mul1); # np[j]*m1
166 &paddq ($car0,$acc0); # +=c0
167 &paddq ($car1,$acc1); # +=c1
168
169 &movq ($acc0,$car0);
170 &pand ($acc0,$mask);
171 &movd ($acc1,&DWP(4,$np,$j,4)); # np[j+1]
172 &paddq ($car1,$acc0); # +=ap[j]*bp[0];
173 &movd ($acc0,&DWP(4,$ap,$j,4)); # ap[j+1]
174 &psrlq ($car0,32);
175 &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[j-1]=
176 &psrlq ($car1,32);
177
178 &lea ($j,&DWP(1,$j));
179 &cmp ($j,$num);
180 &jl (&label("1st"));
181
182 &pmuludq($acc0,$mul0); # ap[num-1]*bp[0]
183 &pmuludq($acc1,$mul1); # np[num-1]*m1
184 &paddq ($car0,$acc0); # +=c0
185 &paddq ($car1,$acc1); # +=c1
186
187 &movq ($acc0,$car0);
188 &pand ($acc0,$mask);
189 &paddq ($car1,$acc0); # +=ap[num-1]*bp[0];
190 &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[num-2]=
191
192 &psrlq ($car0,32);
193 &psrlq ($car1,32);
194
195 &paddq ($car1,$car0);
196 &movq (&QWP($frame,"esp",$num,4),$car1); # tp[num].tp[num-1]
197
198 &inc ($i); # i++
199&set_label("outer");
200 &xor ($j,$j); # j=0
201
202 &movd ($mul0,&DWP(0,$bp,$i,4)); # bp[i]
203 &movd ($mul1,&DWP(0,$ap)); # ap[0]
204 &movd ($temp,&DWP($frame,"esp")); # tp[0]
205 &movd ($car1,&DWP(0,$np)); # np[0]
206 &pmuludq($mul1,$mul0); # ap[0]*bp[i]
207
208 &paddq ($mul1,$temp); # +=tp[0]
209 &movq ($acc0,$mul1);
210 &movq ($car0,$mul1);
211 &pand ($acc0,$mask);
212
213 &pmuludq($mul1,$_n0q); # *=n0
214
215 &pmuludq($car1,$mul1);
216 &paddq ($car1,$acc0);
217
218 &movd ($temp,&DWP($frame+4,"esp")); # tp[1]
219 &movd ($acc1,&DWP(4,$np)); # np[1]
220 &movd ($acc0,&DWP(4,$ap)); # ap[1]
221
222 &psrlq ($car0,32);
223 &psrlq ($car1,32);
224 &paddq ($car0,$temp); # +=tp[1]
225
226 &inc ($j); # j++
227 &dec ($num);
228&set_label("inner");
229 &pmuludq($acc0,$mul0); # ap[j]*bp[i]
230 &pmuludq($acc1,$mul1); # np[j]*m1
231 &paddq ($car0,$acc0); # +=c0
232 &paddq ($car1,$acc1); # +=c1
233
234 &movq ($acc0,$car0);
235 &movd ($temp,&DWP($frame+4,"esp",$j,4));# tp[j+1]
236 &pand ($acc0,$mask);
237 &movd ($acc1,&DWP(4,$np,$j,4)); # np[j+1]
238 &paddq ($car1,$acc0); # +=ap[j]*bp[i]+tp[j]
239 &movd ($acc0,&DWP(4,$ap,$j,4)); # ap[j+1]
240 &psrlq ($car0,32);
241 &movd (&DWP($frame-4,"esp",$j,4),$car1);# tp[j-1]=
242 &psrlq ($car1,32);
243 &paddq ($car0,$temp); # +=tp[j+1]
244
245 &dec ($num);
246 &lea ($j,&DWP(1,$j)); # j++
247 &jnz (&label("inner"));
248
249 &mov ($num,$j);
250 &pmuludq($acc0,$mul0); # ap[num-1]*bp[i]
251 &pmuludq($acc1,$mul1); # np[num-1]*m1
252 &paddq ($car0,$acc0); # +=c0
253 &paddq ($car1,$acc1); # +=c1
254
255 &movq ($acc0,$car0);
256 &pand ($acc0,$mask);
257 &paddq ($car1,$acc0); # +=ap[num-1]*bp[i]+tp[num-1]
258 &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[num-2]=
259 &psrlq ($car0,32);
260 &psrlq ($car1,32);
261
262 &movd ($temp,&DWP($frame+4,"esp",$num,4)); # += tp[num]
263 &paddq ($car1,$car0);
264 &paddq ($car1,$temp);
265 &movq (&QWP($frame,"esp",$num,4),$car1); # tp[num].tp[num-1]
266
267 &lea ($i,&DWP(1,$i)); # i++
268 &cmp ($i,$num);
269 &jle (&label("outer"));
270
271 &emms (); # done with mmx bank
272 &jmp (&label("common_tail"));
273
274&set_label("non_sse2",16);
275}
276
277if (0) {
278 &mov ("esp",$_sp);
279 &xor ("eax","eax"); # signal "not fast enough [yet]"
280 &jmp (&label("just_leave"));
281 # While the below code provides competitive performance for
282 # all key lengthes on modern Intel cores, it's still more
283 # than 10% slower for 4096-bit key elsewhere:-( "Competitive"
284 # means compared to the original integer-only assembler.
285 # 512-bit RSA sign is better by ~40%, but that's about all
286 # one can say about all CPUs...
287} else {
288$inp="esi"; # integer path uses these registers differently
289$word="edi";
290$carry="ebp";
291
292 &mov ($inp,$_ap);
293 &lea ($carry,&DWP(1,$num));
294 &mov ($word,$_bp);
295 &xor ($j,$j); # j=0
296 &mov ("edx",$inp);
297 &and ($carry,1); # see if num is even
298 &sub ("edx",$word); # see if ap==bp
299 &lea ("eax",&DWP(4,$word,$num,4)); # &bp[num]
300 &or ($carry,"edx");
301 &mov ($word,&DWP(0,$word)); # bp[0]
302 &jz (&label("bn_sqr_mont"));
303 &mov ($_bpend,"eax");
304 &mov ("eax",&DWP(0,$inp));
305 &xor ("edx","edx");
306
307&set_label("mull",16);
308 &mov ($carry,"edx");
309 &mul ($word); # ap[j]*bp[0]
310 &add ($carry,"eax");
311 &lea ($j,&DWP(1,$j));
312 &adc ("edx",0);
313 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j+1]
314 &cmp ($j,$num);
315 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
316 &jl (&label("mull"));
317
318 &mov ($carry,"edx");
319 &mul ($word); # ap[num-1]*bp[0]
320 &mov ($word,$_n0);
321 &add ("eax",$carry);
322 &mov ($inp,$_np);
323 &adc ("edx",0);
324 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
325
326 &mov (&DWP($frame,"esp",$num,4),"eax"); # tp[num-1]=
327 &xor ($j,$j);
328 &mov (&DWP($frame+4,"esp",$num,4),"edx"); # tp[num]=
329 &mov (&DWP($frame+8,"esp",$num,4),$j); # tp[num+1]=
330
331 &mov ("eax",&DWP(0,$inp)); # np[0]
332 &mul ($word); # np[0]*m
333 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
334 &mov ("eax",&DWP(4,$inp)); # np[1]
335 &adc ("edx",0);
336 &inc ($j);
337
338 &jmp (&label("2ndmadd"));
339
340&set_label("1stmadd",16);
341 &mov ($carry,"edx");
342 &mul ($word); # ap[j]*bp[i]
343 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
344 &lea ($j,&DWP(1,$j));
345 &adc ("edx",0);
346 &add ($carry,"eax");
347 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j+1]
348 &adc ("edx",0);
349 &cmp ($j,$num);
350 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
351 &jl (&label("1stmadd"));
352
353 &mov ($carry,"edx");
354 &mul ($word); # ap[num-1]*bp[i]
355 &add ("eax",&DWP($frame,"esp",$num,4)); # +=tp[num-1]
356 &mov ($word,$_n0);
357 &adc ("edx",0);
358 &mov ($inp,$_np);
359 &add ($carry,"eax");
360 &adc ("edx",0);
361 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
362
363 &xor ($j,$j);
364 &add ("edx",&DWP($frame+4,"esp",$num,4)); # carry+=tp[num]
365 &mov (&DWP($frame,"esp",$num,4),$carry); # tp[num-1]=
366 &adc ($j,0);
367 &mov ("eax",&DWP(0,$inp)); # np[0]
368 &mov (&DWP($frame+4,"esp",$num,4),"edx"); # tp[num]=
369 &mov (&DWP($frame+8,"esp",$num,4),$j); # tp[num+1]=
370
371 &mul ($word); # np[0]*m
372 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
373 &mov ("eax",&DWP(4,$inp)); # np[1]
374 &adc ("edx",0);
375 &mov ($j,1);
376
377&set_label("2ndmadd",16);
378 &mov ($carry,"edx");
379 &mul ($word); # np[j]*m
380 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
381 &lea ($j,&DWP(1,$j));
382 &adc ("edx",0);
383 &add ($carry,"eax");
384 &mov ("eax",&DWP(0,$inp,$j,4)); # np[j+1]
385 &adc ("edx",0);
386 &cmp ($j,$num);
387 &mov (&DWP($frame-8,"esp",$j,4),$carry); # tp[j-1]=
388 &jl (&label("2ndmadd"));
389
390 &mov ($carry,"edx");
391 &mul ($word); # np[j]*m
392 &add ($carry,&DWP($frame,"esp",$num,4)); # +=tp[num-1]
393 &adc ("edx",0);
394 &add ($carry,"eax");
395 &adc ("edx",0);
396 &mov (&DWP($frame-4,"esp",$num,4),$carry); # tp[num-2]=
397
398 &xor ("eax","eax");
399 &mov ($j,$_bp); # &bp[i]
400 &add ("edx",&DWP($frame+4,"esp",$num,4)); # carry+=tp[num]
401 &adc ("eax",&DWP($frame+8,"esp",$num,4)); # +=tp[num+1]
402 &lea ($j,&DWP(4,$j));
403 &mov (&DWP($frame,"esp",$num,4),"edx"); # tp[num-1]=
404 &cmp ($j,$_bpend);
405 &mov (&DWP($frame+4,"esp",$num,4),"eax"); # tp[num]=
406 &je (&label("common_tail"));
407
408 &mov ($word,&DWP(0,$j)); # bp[i+1]
409 &mov ($inp,$_ap);
410 &mov ($_bp,$j); # &bp[++i]
411 &xor ($j,$j);
412 &xor ("edx","edx");
413 &mov ("eax",&DWP(0,$inp));
414 &jmp (&label("1stmadd"));
415
416&set_label("bn_sqr_mont",16);
417$sbit=$num;
418 &mov ($_num,$num);
419 &mov ($_bp,$j); # i=0
420
421 &mov ("eax",$word); # ap[0]
422 &mul ($word); # ap[0]*ap[0]
423 &mov (&DWP($frame,"esp"),"eax"); # tp[0]=
424 &mov ($sbit,"edx");
425 &shr ("edx",1);
426 &and ($sbit,1);
427 &inc ($j);
428&set_label("sqr",16);
429 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j]
430 &mov ($carry,"edx");
431 &mul ($word); # ap[j]*ap[0]
432 &add ("eax",$carry);
433 &lea ($j,&DWP(1,$j));
434 &adc ("edx",0);
435 &lea ($carry,&DWP(0,$sbit,"eax",2));
436 &shr ("eax",31);
437 &cmp ($j,$_num);
438 &mov ($sbit,"eax");
439 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
440 &jl (&label("sqr"));
441
442 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[num-1]
443 &mov ($carry,"edx");
444 &mul ($word); # ap[num-1]*ap[0]
445 &add ("eax",$carry);
446 &mov ($word,$_n0);
447 &adc ("edx",0);
448 &mov ($inp,$_np);
449 &lea ($carry,&DWP(0,$sbit,"eax",2));
450 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
451 &shr ("eax",31);
452 &mov (&DWP($frame,"esp",$j,4),$carry); # tp[num-1]=
453
454 &lea ($carry,&DWP(0,"eax","edx",2));
455 &mov ("eax",&DWP(0,$inp)); # np[0]
456 &shr ("edx",31);
457 &mov (&DWP($frame+4,"esp",$j,4),$carry); # tp[num]=
458 &mov (&DWP($frame+8,"esp",$j,4),"edx"); # tp[num+1]=
459
460 &mul ($word); # np[0]*m
461 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
462 &mov ($num,$j);
463 &adc ("edx",0);
464 &mov ("eax",&DWP(4,$inp)); # np[1]
465 &mov ($j,1);
466
467&set_label("3rdmadd",16);
468 &mov ($carry,"edx");
469 &mul ($word); # np[j]*m
470 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
471 &adc ("edx",0);
472 &add ($carry,"eax");
473 &mov ("eax",&DWP(4,$inp,$j,4)); # np[j+1]
474 &adc ("edx",0);
475 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j-1]=
476
477 &mov ($carry,"edx");
478 &mul ($word); # np[j+1]*m
479 &add ($carry,&DWP($frame+4,"esp",$j,4)); # +=tp[j+1]
480 &lea ($j,&DWP(2,$j));
481 &adc ("edx",0);
482 &add ($carry,"eax");
483 &mov ("eax",&DWP(0,$inp,$j,4)); # np[j+2]
484 &adc ("edx",0);
485 &cmp ($j,$num);
486 &mov (&DWP($frame-8,"esp",$j,4),$carry); # tp[j]=
487 &jl (&label("3rdmadd"));
488
489 &mov ($carry,"edx");
490 &mul ($word); # np[j]*m
491 &add ($carry,&DWP($frame,"esp",$num,4)); # +=tp[num-1]
492 &adc ("edx",0);
493 &add ($carry,"eax");
494 &adc ("edx",0);
495 &mov (&DWP($frame-4,"esp",$num,4),$carry); # tp[num-2]=
496
497 &mov ($j,$_bp); # i
498 &xor ("eax","eax");
499 &mov ($inp,$_ap);
500 &add ("edx",&DWP($frame+4,"esp",$num,4)); # carry+=tp[num]
501 &adc ("eax",&DWP($frame+8,"esp",$num,4)); # +=tp[num+1]
502 &mov (&DWP($frame,"esp",$num,4),"edx"); # tp[num-1]=
503 &cmp ($j,$num);
504 &mov (&DWP($frame+4,"esp",$num,4),"eax"); # tp[num]=
505 &je (&label("common_tail"));
506
507 &mov ($word,&DWP(4,$inp,$j,4)); # ap[i]
508 &lea ($j,&DWP(1,$j));
509 &mov ("eax",$word);
510 &mov ($_bp,$j); # ++i
511 &mul ($word); # ap[i]*ap[i]
512 &add ("eax",&DWP($frame,"esp",$j,4)); # +=tp[i]
513 &adc ("edx",0);
514 &mov (&DWP($frame,"esp",$j,4),"eax"); # tp[i]=
515 &xor ($carry,$carry);
516 &cmp ($j,$num);
517 &lea ($j,&DWP(1,$j));
518 &je (&label("sqrlast"));
519
520 &mov ($sbit,"edx"); # zaps $num
521 &shr ("edx",1);
522 &and ($sbit,1);
523&set_label("sqradd",16);
524 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j]
525 &mov ($carry,"edx");
526 &mul ($word); # ap[j]*ap[i]
527 &add ("eax",$carry);
528 &lea ($carry,&DWP(0,"eax","eax"));
529 &adc ("edx",0);
530 &shr ("eax",31);
531 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
532 &lea ($j,&DWP(1,$j));
533 &adc ("eax",0);
534 &add ($carry,$sbit);
535 &adc ("eax",0);
536 &cmp ($j,$_num);
537 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
538 &mov ($sbit,"eax");
539 &jle (&label("sqradd"));
540
541 &mov ($carry,"edx");
542 &lea ("edx",&DWP(0,$sbit,"edx",2));
543 &shr ($carry,31);
544&set_label("sqrlast");
545 &mov ($word,$_n0);
546 &mov ($inp,$_np);
547 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
548
549 &add ("edx",&DWP($frame,"esp",$j,4)); # +=tp[num]
550 &mov ("eax",&DWP(0,$inp)); # np[0]
551 &adc ($carry,0);
552 &mov (&DWP($frame,"esp",$j,4),"edx"); # tp[num]=
553 &mov (&DWP($frame+4,"esp",$j,4),$carry); # tp[num+1]=
554
555 &mul ($word); # np[0]*m
556 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
557 &lea ($num,&DWP(-1,$j));
558 &adc ("edx",0);
559 &mov ($j,1);
560 &mov ("eax",&DWP(4,$inp)); # np[1]
561
562 &jmp (&label("3rdmadd"));
563}
564
565&set_label("common_tail",16);
566 &mov ($np,$_np); # load modulus pointer
567 &mov ($rp,$_rp); # load result pointer
568 &lea ($tp,&DWP($frame,"esp")); # [$ap and $bp are zapped]
569
570 &mov ("eax",&DWP(0,$tp)); # tp[0]
571 &mov ($j,$num); # j=num-1
572 &xor ($i,$i); # i=0 and clear CF!
573
574&set_label("sub",16);
575 &sbb ("eax",&DWP(0,$np,$i,4));
576 &mov (&DWP(0,$rp,$i,4),"eax"); # rp[i]=tp[i]-np[i]
577 &dec ($j); # doesn't affect CF!
578 &mov ("eax",&DWP(4,$tp,$i,4)); # tp[i+1]
579 &lea ($i,&DWP(1,$i)); # i++
580 &jge (&label("sub"));
581
582 &sbb ("eax",0); # handle upmost overflow bit
583 &and ($tp,"eax");
584 &not ("eax");
585 &mov ($np,$rp);
586 &and ($np,"eax");
587 &or ($tp,$np); # tp=carry?tp:rp
588
589&set_label("copy",16); # copy or in-place refresh
590 &mov ("eax",&DWP(0,$tp,$num,4));
591 &mov (&DWP(0,$rp,$num,4),"eax"); # rp[i]=tp[i]
592 &mov (&DWP($frame,"esp",$num,4),$j); # zap temporary vector
593 &dec ($num);
594 &jge (&label("copy"));
595
596 &mov ("esp",$_sp); # pull saved stack pointer
597 &mov ("eax",1);
598&set_label("just_leave");
599&function_end("bn_mul_mont");
600
601&asciz("Montgomery Multiplication for x86, CRYPTOGAMS by <appro\@openssl.org>");
602
603&asm_finish();
diff --git a/src/lib/libcrypto/bn/asm/pa-risc.s b/src/lib/libcrypto/bn/asm/pa-risc.s
deleted file mode 100644
index 775130a191..0000000000
--- a/src/lib/libcrypto/bn/asm/pa-risc.s
+++ /dev/null
@@ -1,710 +0,0 @@
1 .SPACE $PRIVATE$
2 .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31
3 .SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82
4 .SPACE $TEXT$
5 .SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44
6 .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY
7 .IMPORT $global$,DATA
8 .IMPORT $$dyncall,MILLICODE
9; gcc_compiled.:
10 .SPACE $TEXT$
11 .SUBSPA $CODE$
12
13 .align 4
14 .EXPORT bn_mul_add_words,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR,RTNVAL=GR
15bn_mul_add_words
16 .PROC
17 .CALLINFO FRAME=0,CALLS,SAVE_RP
18 .ENTRY
19 stw %r2,-20(0,%r30)
20 ldi 0,%r28
21 extru %r23,31,16,%r2
22 stw %r2,-16(0,%r30)
23 extru %r23,15,16,%r23
24 ldil L'65536,%r31
25 fldws -16(0,%r30),%fr11R
26 stw %r23,-16(0,%r30)
27 ldo 12(%r25),%r29
28 ldo 12(%r26),%r23
29 fldws -16(0,%r30),%fr11L
30L$0002
31 ldw 0(0,%r25),%r19
32 extru %r19,31,16,%r20
33 stw %r20,-16(0,%r30)
34 extru %r19,15,16,%r19
35 fldws -16(0,%r30),%fr22L
36 stw %r19,-16(0,%r30)
37 xmpyu %fr22L,%fr11R,%fr8
38 fldws -16(0,%r30),%fr22L
39 fstws %fr8R,-16(0,%r30)
40 xmpyu %fr11R,%fr22L,%fr10
41 ldw -16(0,%r30),%r2
42 stw %r20,-16(0,%r30)
43 xmpyu %fr22L,%fr11L,%fr9
44 fldws -16(0,%r30),%fr22L
45 fstws %fr10R,-16(0,%r30)
46 copy %r2,%r22
47 ldw -16(0,%r30),%r2
48 fstws %fr9R,-16(0,%r30)
49 xmpyu %fr11L,%fr22L,%fr8
50 copy %r2,%r19
51 ldw -16(0,%r30),%r2
52 fstws %fr8R,-16(0,%r30)
53 copy %r2,%r20
54 ldw -16(0,%r30),%r2
55 addl %r2,%r19,%r21
56 comclr,<<= %r19,%r21,0
57 addl %r20,%r31,%r20
58L$0005
59 extru %r21,15,16,%r19
60 addl %r20,%r19,%r20
61 zdep %r21,15,16,%r19
62 addl %r22,%r19,%r22
63 comclr,<<= %r19,%r22,0
64 addi,tr 1,%r20,%r19
65 copy %r20,%r19
66 addl %r22,%r28,%r20
67 comclr,<<= %r28,%r20,0
68 addi 1,%r19,%r19
69 ldw 0(0,%r26),%r28
70 addl %r20,%r28,%r20
71 comclr,<<= %r28,%r20,0
72 addi,tr 1,%r19,%r28
73 copy %r19,%r28
74 addib,= -1,%r24,L$0003
75 stw %r20,0(0,%r26)
76 ldw -8(0,%r29),%r19
77 extru %r19,31,16,%r20
78 stw %r20,-16(0,%r30)
79 extru %r19,15,16,%r19
80 fldws -16(0,%r30),%fr22L
81 stw %r19,-16(0,%r30)
82 xmpyu %fr22L,%fr11R,%fr8
83 fldws -16(0,%r30),%fr22L
84 fstws %fr8R,-16(0,%r30)
85 xmpyu %fr11R,%fr22L,%fr10
86 ldw -16(0,%r30),%r2
87 stw %r20,-16(0,%r30)
88 xmpyu %fr22L,%fr11L,%fr9
89 fldws -16(0,%r30),%fr22L
90 fstws %fr10R,-16(0,%r30)
91 copy %r2,%r22
92 ldw -16(0,%r30),%r2
93 fstws %fr9R,-16(0,%r30)
94 xmpyu %fr11L,%fr22L,%fr8
95 copy %r2,%r19
96 ldw -16(0,%r30),%r2
97 fstws %fr8R,-16(0,%r30)
98 copy %r2,%r20
99 ldw -16(0,%r30),%r2
100 addl %r2,%r19,%r21
101 comclr,<<= %r19,%r21,0
102 addl %r20,%r31,%r20
103L$0010
104 extru %r21,15,16,%r19
105 addl %r20,%r19,%r20
106 zdep %r21,15,16,%r19
107 addl %r22,%r19,%r22
108 comclr,<<= %r19,%r22,0
109 addi,tr 1,%r20,%r19
110 copy %r20,%r19
111 addl %r22,%r28,%r20
112 comclr,<<= %r28,%r20,0
113 addi 1,%r19,%r19
114 ldw -8(0,%r23),%r28
115 addl %r20,%r28,%r20
116 comclr,<<= %r28,%r20,0
117 addi,tr 1,%r19,%r28
118 copy %r19,%r28
119 addib,= -1,%r24,L$0003
120 stw %r20,-8(0,%r23)
121 ldw -4(0,%r29),%r19
122 extru %r19,31,16,%r20
123 stw %r20,-16(0,%r30)
124 extru %r19,15,16,%r19
125 fldws -16(0,%r30),%fr22L
126 stw %r19,-16(0,%r30)
127 xmpyu %fr22L,%fr11R,%fr8
128 fldws -16(0,%r30),%fr22L
129 fstws %fr8R,-16(0,%r30)
130 xmpyu %fr11R,%fr22L,%fr10
131 ldw -16(0,%r30),%r2
132 stw %r20,-16(0,%r30)
133 xmpyu %fr22L,%fr11L,%fr9
134 fldws -16(0,%r30),%fr22L
135 fstws %fr10R,-16(0,%r30)
136 copy %r2,%r22
137 ldw -16(0,%r30),%r2
138 fstws %fr9R,-16(0,%r30)
139 xmpyu %fr11L,%fr22L,%fr8
140 copy %r2,%r19
141 ldw -16(0,%r30),%r2
142 fstws %fr8R,-16(0,%r30)
143 copy %r2,%r20
144 ldw -16(0,%r30),%r2
145 addl %r2,%r19,%r21
146 comclr,<<= %r19,%r21,0
147 addl %r20,%r31,%r20
148L$0015
149 extru %r21,15,16,%r19
150 addl %r20,%r19,%r20
151 zdep %r21,15,16,%r19
152 addl %r22,%r19,%r22
153 comclr,<<= %r19,%r22,0
154 addi,tr 1,%r20,%r19
155 copy %r20,%r19
156 addl %r22,%r28,%r20
157 comclr,<<= %r28,%r20,0
158 addi 1,%r19,%r19
159 ldw -4(0,%r23),%r28
160 addl %r20,%r28,%r20
161 comclr,<<= %r28,%r20,0
162 addi,tr 1,%r19,%r28
163 copy %r19,%r28
164 addib,= -1,%r24,L$0003
165 stw %r20,-4(0,%r23)
166 ldw 0(0,%r29),%r19
167 extru %r19,31,16,%r20
168 stw %r20,-16(0,%r30)
169 extru %r19,15,16,%r19
170 fldws -16(0,%r30),%fr22L
171 stw %r19,-16(0,%r30)
172 xmpyu %fr22L,%fr11R,%fr8
173 fldws -16(0,%r30),%fr22L
174 fstws %fr8R,-16(0,%r30)
175 xmpyu %fr11R,%fr22L,%fr10
176 ldw -16(0,%r30),%r2
177 stw %r20,-16(0,%r30)
178 xmpyu %fr22L,%fr11L,%fr9
179 fldws -16(0,%r30),%fr22L
180 fstws %fr10R,-16(0,%r30)
181 copy %r2,%r22
182 ldw -16(0,%r30),%r2
183 fstws %fr9R,-16(0,%r30)
184 xmpyu %fr11L,%fr22L,%fr8
185 copy %r2,%r19
186 ldw -16(0,%r30),%r2
187 fstws %fr8R,-16(0,%r30)
188 copy %r2,%r20
189 ldw -16(0,%r30),%r2
190 addl %r2,%r19,%r21
191 comclr,<<= %r19,%r21,0
192 addl %r20,%r31,%r20
193L$0020
194 extru %r21,15,16,%r19
195 addl %r20,%r19,%r20
196 zdep %r21,15,16,%r19
197 addl %r22,%r19,%r22
198 comclr,<<= %r19,%r22,0
199 addi,tr 1,%r20,%r19
200 copy %r20,%r19
201 addl %r22,%r28,%r20
202 comclr,<<= %r28,%r20,0
203 addi 1,%r19,%r19
204 ldw 0(0,%r23),%r28
205 addl %r20,%r28,%r20
206 comclr,<<= %r28,%r20,0
207 addi,tr 1,%r19,%r28
208 copy %r19,%r28
209 addib,= -1,%r24,L$0003
210 stw %r20,0(0,%r23)
211 ldo 16(%r29),%r29
212 ldo 16(%r25),%r25
213 ldo 16(%r23),%r23
214 bl L$0002,0
215 ldo 16(%r26),%r26
216L$0003
217 ldw -20(0,%r30),%r2
218 bv,n 0(%r2)
219 .EXIT
220 .PROCEND
221 .align 4
222 .EXPORT bn_mul_words,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR,RTNVAL=GR
223bn_mul_words
224 .PROC
225 .CALLINFO FRAME=0,CALLS,SAVE_RP
226 .ENTRY
227 stw %r2,-20(0,%r30)
228 ldi 0,%r28
229 extru %r23,31,16,%r2
230 stw %r2,-16(0,%r30)
231 extru %r23,15,16,%r23
232 ldil L'65536,%r31
233 fldws -16(0,%r30),%fr11R
234 stw %r23,-16(0,%r30)
235 ldo 12(%r26),%r29
236 ldo 12(%r25),%r23
237 fldws -16(0,%r30),%fr11L
238L$0026
239 ldw 0(0,%r25),%r19
240 extru %r19,31,16,%r20
241 stw %r20,-16(0,%r30)
242 extru %r19,15,16,%r19
243 fldws -16(0,%r30),%fr22L
244 stw %r19,-16(0,%r30)
245 xmpyu %fr22L,%fr11R,%fr8
246 fldws -16(0,%r30),%fr22L
247 fstws %fr8R,-16(0,%r30)
248 xmpyu %fr11R,%fr22L,%fr10
249 ldw -16(0,%r30),%r2
250 stw %r20,-16(0,%r30)
251 xmpyu %fr22L,%fr11L,%fr9
252 fldws -16(0,%r30),%fr22L
253 fstws %fr10R,-16(0,%r30)
254 copy %r2,%r22
255 ldw -16(0,%r30),%r2
256 fstws %fr9R,-16(0,%r30)
257 xmpyu %fr11L,%fr22L,%fr8
258 copy %r2,%r19
259 ldw -16(0,%r30),%r2
260 fstws %fr8R,-16(0,%r30)
261 copy %r2,%r20
262 ldw -16(0,%r30),%r2
263 addl %r2,%r19,%r21
264 comclr,<<= %r19,%r21,0
265 addl %r20,%r31,%r20
266L$0029
267 extru %r21,15,16,%r19
268 addl %r20,%r19,%r20
269 zdep %r21,15,16,%r19
270 addl %r22,%r19,%r22
271 comclr,<<= %r19,%r22,0
272 addi,tr 1,%r20,%r19
273 copy %r20,%r19
274 addl %r22,%r28,%r20
275 comclr,<<= %r28,%r20,0
276 addi,tr 1,%r19,%r28
277 copy %r19,%r28
278 addib,= -1,%r24,L$0027
279 stw %r20,0(0,%r26)
280 ldw -8(0,%r23),%r19
281 extru %r19,31,16,%r20
282 stw %r20,-16(0,%r30)
283 extru %r19,15,16,%r19
284 fldws -16(0,%r30),%fr22L
285 stw %r19,-16(0,%r30)
286 xmpyu %fr22L,%fr11R,%fr8
287 fldws -16(0,%r30),%fr22L
288 fstws %fr8R,-16(0,%r30)
289 xmpyu %fr11R,%fr22L,%fr10
290 ldw -16(0,%r30),%r2
291 stw %r20,-16(0,%r30)
292 xmpyu %fr22L,%fr11L,%fr9
293 fldws -16(0,%r30),%fr22L
294 fstws %fr10R,-16(0,%r30)
295 copy %r2,%r22
296 ldw -16(0,%r30),%r2
297 fstws %fr9R,-16(0,%r30)
298 xmpyu %fr11L,%fr22L,%fr8
299 copy %r2,%r19
300 ldw -16(0,%r30),%r2
301 fstws %fr8R,-16(0,%r30)
302 copy %r2,%r20
303 ldw -16(0,%r30),%r2
304 addl %r2,%r19,%r21
305 comclr,<<= %r19,%r21,0
306 addl %r20,%r31,%r20
307L$0033
308 extru %r21,15,16,%r19
309 addl %r20,%r19,%r20
310 zdep %r21,15,16,%r19
311 addl %r22,%r19,%r22
312 comclr,<<= %r19,%r22,0
313 addi,tr 1,%r20,%r19
314 copy %r20,%r19
315 addl %r22,%r28,%r20
316 comclr,<<= %r28,%r20,0
317 addi,tr 1,%r19,%r28
318 copy %r19,%r28
319 addib,= -1,%r24,L$0027
320 stw %r20,-8(0,%r29)
321 ldw -4(0,%r23),%r19
322 extru %r19,31,16,%r20
323 stw %r20,-16(0,%r30)
324 extru %r19,15,16,%r19
325 fldws -16(0,%r30),%fr22L
326 stw %r19,-16(0,%r30)
327 xmpyu %fr22L,%fr11R,%fr8
328 fldws -16(0,%r30),%fr22L
329 fstws %fr8R,-16(0,%r30)
330 xmpyu %fr11R,%fr22L,%fr10
331 ldw -16(0,%r30),%r2
332 stw %r20,-16(0,%r30)
333 xmpyu %fr22L,%fr11L,%fr9
334 fldws -16(0,%r30),%fr22L
335 fstws %fr10R,-16(0,%r30)
336 copy %r2,%r22
337 ldw -16(0,%r30),%r2
338 fstws %fr9R,-16(0,%r30)
339 xmpyu %fr11L,%fr22L,%fr8
340 copy %r2,%r19
341 ldw -16(0,%r30),%r2
342 fstws %fr8R,-16(0,%r30)
343 copy %r2,%r20
344 ldw -16(0,%r30),%r2
345 addl %r2,%r19,%r21
346 comclr,<<= %r19,%r21,0
347 addl %r20,%r31,%r20
348L$0037
349 extru %r21,15,16,%r19
350 addl %r20,%r19,%r20
351 zdep %r21,15,16,%r19
352 addl %r22,%r19,%r22
353 comclr,<<= %r19,%r22,0
354 addi,tr 1,%r20,%r19
355 copy %r20,%r19
356 addl %r22,%r28,%r20
357 comclr,<<= %r28,%r20,0
358 addi,tr 1,%r19,%r28
359 copy %r19,%r28
360 addib,= -1,%r24,L$0027
361 stw %r20,-4(0,%r29)
362 ldw 0(0,%r23),%r19
363 extru %r19,31,16,%r20
364 stw %r20,-16(0,%r30)
365 extru %r19,15,16,%r19
366 fldws -16(0,%r30),%fr22L
367 stw %r19,-16(0,%r30)
368 xmpyu %fr22L,%fr11R,%fr8
369 fldws -16(0,%r30),%fr22L
370 fstws %fr8R,-16(0,%r30)
371 xmpyu %fr11R,%fr22L,%fr10
372 ldw -16(0,%r30),%r2
373 stw %r20,-16(0,%r30)
374 xmpyu %fr22L,%fr11L,%fr9
375 fldws -16(0,%r30),%fr22L
376 fstws %fr10R,-16(0,%r30)
377 copy %r2,%r22
378 ldw -16(0,%r30),%r2
379 fstws %fr9R,-16(0,%r30)
380 xmpyu %fr11L,%fr22L,%fr8
381 copy %r2,%r19
382 ldw -16(0,%r30),%r2
383 fstws %fr8R,-16(0,%r30)
384 copy %r2,%r20
385 ldw -16(0,%r30),%r2
386 addl %r2,%r19,%r21
387 comclr,<<= %r19,%r21,0
388 addl %r20,%r31,%r20
389L$0041
390 extru %r21,15,16,%r19
391 addl %r20,%r19,%r20
392 zdep %r21,15,16,%r19
393 addl %r22,%r19,%r22
394 comclr,<<= %r19,%r22,0
395 addi,tr 1,%r20,%r19
396 copy %r20,%r19
397 addl %r22,%r28,%r20
398 comclr,<<= %r28,%r20,0
399 addi,tr 1,%r19,%r28
400 copy %r19,%r28
401 addib,= -1,%r24,L$0027
402 stw %r20,0(0,%r29)
403 ldo 16(%r23),%r23
404 ldo 16(%r25),%r25
405 ldo 16(%r29),%r29
406 bl L$0026,0
407 ldo 16(%r26),%r26
408L$0027
409 ldw -20(0,%r30),%r2
410 bv,n 0(%r2)
411 .EXIT
412 .PROCEND
413 .align 4
414 .EXPORT bn_sqr_words,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR
415bn_sqr_words
416 .PROC
417 .CALLINFO FRAME=0,NO_CALLS
418 .ENTRY
419 ldo 28(%r26),%r23
420 ldo 12(%r25),%r28
421L$0046
422 ldw 0(0,%r25),%r21
423 extru %r21,31,16,%r22
424 stw %r22,-16(0,%r30)
425 extru %r21,15,16,%r21
426 fldws -16(0,%r30),%fr10L
427 stw %r21,-16(0,%r30)
428 fldws -16(0,%r30),%fr10R
429 xmpyu %fr10L,%fr10R,%fr8
430 fstws %fr8R,-16(0,%r30)
431 ldw -16(0,%r30),%r29
432 stw %r22,-16(0,%r30)
433 fldws -16(0,%r30),%fr10R
434 stw %r21,-16(0,%r30)
435 copy %r29,%r19
436 xmpyu %fr10L,%fr10R,%fr8
437 fldws -16(0,%r30),%fr10L
438 stw %r21,-16(0,%r30)
439 fldws -16(0,%r30),%fr10R
440 fstws %fr8R,-16(0,%r30)
441 extru %r19,16,17,%r20
442 zdep %r19,14,15,%r19
443 ldw -16(0,%r30),%r29
444 xmpyu %fr10L,%fr10R,%fr9
445 addl %r29,%r19,%r22
446 stw %r22,0(0,%r26)
447 fstws %fr9R,-16(0,%r30)
448 ldw -16(0,%r30),%r29
449 addl %r29,%r20,%r21
450 comclr,<<= %r19,%r22,0
451 addi 1,%r21,%r21
452 addib,= -1,%r24,L$0057
453 stw %r21,-24(0,%r23)
454 ldw -8(0,%r28),%r21
455 extru %r21,31,16,%r22
456 stw %r22,-16(0,%r30)
457 extru %r21,15,16,%r21
458 fldws -16(0,%r30),%fr10L
459 stw %r21,-16(0,%r30)
460 fldws -16(0,%r30),%fr10R
461 xmpyu %fr10L,%fr10R,%fr8
462 fstws %fr8R,-16(0,%r30)
463 ldw -16(0,%r30),%r29
464 stw %r22,-16(0,%r30)
465 fldws -16(0,%r30),%fr10R
466 stw %r21,-16(0,%r30)
467 copy %r29,%r19
468 xmpyu %fr10L,%fr10R,%fr8
469 fldws -16(0,%r30),%fr10L
470 stw %r21,-16(0,%r30)
471 fldws -16(0,%r30),%fr10R
472 fstws %fr8R,-16(0,%r30)
473 extru %r19,16,17,%r20
474 zdep %r19,14,15,%r19
475 ldw -16(0,%r30),%r29
476 xmpyu %fr10L,%fr10R,%fr9
477 addl %r29,%r19,%r22
478 stw %r22,-20(0,%r23)
479 fstws %fr9R,-16(0,%r30)
480 ldw -16(0,%r30),%r29
481 addl %r29,%r20,%r21
482 comclr,<<= %r19,%r22,0
483 addi 1,%r21,%r21
484 addib,= -1,%r24,L$0057
485 stw %r21,-16(0,%r23)
486 ldw -4(0,%r28),%r21
487 extru %r21,31,16,%r22
488 stw %r22,-16(0,%r30)
489 extru %r21,15,16,%r21
490 fldws -16(0,%r30),%fr10L
491 stw %r21,-16(0,%r30)
492 fldws -16(0,%r30),%fr10R
493 xmpyu %fr10L,%fr10R,%fr8
494 fstws %fr8R,-16(0,%r30)
495 ldw -16(0,%r30),%r29
496 stw %r22,-16(0,%r30)
497 fldws -16(0,%r30),%fr10R
498 stw %r21,-16(0,%r30)
499 copy %r29,%r19
500 xmpyu %fr10L,%fr10R,%fr8
501 fldws -16(0,%r30),%fr10L
502 stw %r21,-16(0,%r30)
503 fldws -16(0,%r30),%fr10R
504 fstws %fr8R,-16(0,%r30)
505 extru %r19,16,17,%r20
506 zdep %r19,14,15,%r19
507 ldw -16(0,%r30),%r29
508 xmpyu %fr10L,%fr10R,%fr9
509 addl %r29,%r19,%r22
510 stw %r22,-12(0,%r23)
511 fstws %fr9R,-16(0,%r30)
512 ldw -16(0,%r30),%r29
513 addl %r29,%r20,%r21
514 comclr,<<= %r19,%r22,0
515 addi 1,%r21,%r21
516 addib,= -1,%r24,L$0057
517 stw %r21,-8(0,%r23)
518 ldw 0(0,%r28),%r21
519 extru %r21,31,16,%r22
520 stw %r22,-16(0,%r30)
521 extru %r21,15,16,%r21
522 fldws -16(0,%r30),%fr10L
523 stw %r21,-16(0,%r30)
524 fldws -16(0,%r30),%fr10R
525 xmpyu %fr10L,%fr10R,%fr8
526 fstws %fr8R,-16(0,%r30)
527 ldw -16(0,%r30),%r29
528 stw %r22,-16(0,%r30)
529 fldws -16(0,%r30),%fr10R
530 stw %r21,-16(0,%r30)
531 copy %r29,%r19
532 xmpyu %fr10L,%fr10R,%fr8
533 fldws -16(0,%r30),%fr10L
534 stw %r21,-16(0,%r30)
535 fldws -16(0,%r30),%fr10R
536 fstws %fr8R,-16(0,%r30)
537 extru %r19,16,17,%r20
538 zdep %r19,14,15,%r19
539 ldw -16(0,%r30),%r29
540 xmpyu %fr10L,%fr10R,%fr9
541 addl %r29,%r19,%r22
542 stw %r22,-4(0,%r23)
543 fstws %fr9R,-16(0,%r30)
544 ldw -16(0,%r30),%r29
545 addl %r29,%r20,%r21
546 comclr,<<= %r19,%r22,0
547 addi 1,%r21,%r21
548 addib,= -1,%r24,L$0057
549 stw %r21,0(0,%r23)
550 ldo 16(%r28),%r28
551 ldo 16(%r25),%r25
552 ldo 32(%r23),%r23
553 bl L$0046,0
554 ldo 32(%r26),%r26
555L$0057
556 bv,n 0(%r2)
557 .EXIT
558 .PROCEND
559 .IMPORT BN_num_bits_word,CODE
560 .IMPORT fprintf,CODE
561 .IMPORT __iob,DATA
562 .SPACE $TEXT$
563 .SUBSPA $LIT$
564
565 .align 4
566L$C0000
567 .STRING "Division would overflow\x0a\x00"
568 .IMPORT abort,CODE
569 .SPACE $TEXT$
570 .SUBSPA $CODE$
571
572 .align 4
573 .EXPORT bn_div64,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,ARGW2=GR,RTNVAL=GR
574bn_div64
575 .PROC
576 .CALLINFO FRAME=128,CALLS,SAVE_RP,ENTRY_GR=8
577 .ENTRY
578 stw %r2,-20(0,%r30)
579 stwm %r8,128(0,%r30)
580 stw %r7,-124(0,%r30)
581 stw %r4,-112(0,%r30)
582 stw %r3,-108(0,%r30)
583 copy %r26,%r3
584 copy %r25,%r4
585 stw %r6,-120(0,%r30)
586 ldi 0,%r7
587 stw %r5,-116(0,%r30)
588 movb,<> %r24,%r5,L$0059
589 ldi 2,%r6
590 bl L$0076,0
591 ldi -1,%r28
592L$0059
593 .CALL ARGW0=GR
594 bl BN_num_bits_word,%r2
595 copy %r5,%r26
596 ldi 32,%r19
597 comb,= %r19,%r28,L$0060
598 subi 31,%r28,%r19
599 mtsar %r19
600 zvdepi 1,32,%r19
601 comb,>>= %r19,%r3,L$0060
602 addil LR'__iob-$global$+32,%r27
603 ldo RR'__iob-$global$+32(%r1),%r26
604 ldil LR'L$C0000,%r25
605 .CALL ARGW0=GR,ARGW1=GR
606 bl fprintf,%r2
607 ldo RR'L$C0000(%r25),%r25
608 .CALL
609 bl abort,%r2
610 nop
611L$0060
612 comb,>> %r5,%r3,L$0061
613 subi 32,%r28,%r28
614 sub %r3,%r5,%r3
615L$0061
616 comib,= 0,%r28,L$0062
617 subi 31,%r28,%r19
618 mtsar %r19
619 zvdep %r5,32,%r5
620 zvdep %r3,32,%r21
621 subi 32,%r28,%r20
622 mtsar %r20
623 vshd 0,%r4,%r20
624 or %r21,%r20,%r3
625 mtsar %r19
626 zvdep %r4,32,%r4
627L$0062
628 extru %r5,15,16,%r23
629 extru %r5,31,16,%r28
630L$0063
631 extru %r3,15,16,%r19
632 comb,<> %r23,%r19,L$0066
633 copy %r3,%r26
634 bl L$0067,0
635 zdepi -1,31,16,%r29
636L$0066
637 .IMPORT $$divU,MILLICODE
638 bl $$divU,%r31
639 copy %r23,%r25
640L$0067
641 stw %r29,-16(0,%r30)
642 fldws -16(0,%r30),%fr10L
643 stw %r28,-16(0,%r30)
644 fldws -16(0,%r30),%fr10R
645 stw %r23,-16(0,%r30)
646 xmpyu %fr10L,%fr10R,%fr8
647 fldws -16(0,%r30),%fr10R
648 fstws %fr8R,-16(0,%r30)
649 xmpyu %fr10L,%fr10R,%fr9
650 ldw -16(0,%r30),%r8
651 fstws %fr9R,-16(0,%r30)
652 copy %r8,%r22
653 ldw -16(0,%r30),%r8
654 extru %r4,15,16,%r24
655 copy %r8,%r21
656L$0068
657 sub %r3,%r21,%r20
658 copy %r20,%r19
659 depi 0,31,16,%r19
660 comib,<> 0,%r19,L$0069
661 zdep %r20,15,16,%r19
662 addl %r19,%r24,%r19
663 comb,>>= %r19,%r22,L$0069
664 sub %r22,%r28,%r22
665 sub %r21,%r23,%r21
666 bl L$0068,0
667 ldo -1(%r29),%r29
668L$0069
669 stw %r29,-16(0,%r30)
670 fldws -16(0,%r30),%fr10L
671 stw %r28,-16(0,%r30)
672 fldws -16(0,%r30),%fr10R
673 xmpyu %fr10L,%fr10R,%fr8
674 fstws %fr8R,-16(0,%r30)
675 ldw -16(0,%r30),%r8
676 stw %r23,-16(0,%r30)
677 fldws -16(0,%r30),%fr10R
678 copy %r8,%r19
679 xmpyu %fr10L,%fr10R,%fr8
680 fstws %fr8R,-16(0,%r30)
681 extru %r19,15,16,%r20
682 ldw -16(0,%r30),%r8
683 zdep %r19,15,16,%r19
684 addl %r8,%r20,%r20
685 comclr,<<= %r19,%r4,0
686 addi 1,%r20,%r20
687 comb,<<= %r20,%r3,L$0074
688 sub %r4,%r19,%r4
689 addl %r3,%r5,%r3
690 ldo -1(%r29),%r29
691L$0074
692 addib,= -1,%r6,L$0064
693 sub %r3,%r20,%r3
694 zdep %r29,15,16,%r7
695 shd %r3,%r4,16,%r3
696 bl L$0063,0
697 zdep %r4,15,16,%r4
698L$0064
699 or %r7,%r29,%r28
700L$0076
701 ldw -148(0,%r30),%r2
702 ldw -124(0,%r30),%r7
703 ldw -120(0,%r30),%r6
704 ldw -116(0,%r30),%r5
705 ldw -112(0,%r30),%r4
706 ldw -108(0,%r30),%r3
707 bv 0(%r2)
708 ldwm -128(0,%r30),%r8
709 .EXIT
710 .PROCEND
diff --git a/src/lib/libcrypto/bn/asm/r3000.s b/src/lib/libcrypto/bn/asm/r3000.s
deleted file mode 100644
index e95269afa3..0000000000
--- a/src/lib/libcrypto/bn/asm/r3000.s
+++ /dev/null
@@ -1,646 +0,0 @@
1 .file 1 "../bn_mulw.c"
2 .set nobopt
3 .option pic2
4
5 # GNU C 2.6.3 [AL 1.1, MM 40] SGI running IRIX 5.0 compiled by GNU C
6
7 # Cc1 defaults:
8 # -mabicalls
9
10 # Cc1 arguments (-G value = 0, Cpu = 3000, ISA = 1):
11 # -quiet -dumpbase -O2 -o
12
13gcc2_compiled.:
14__gnu_compiled_c:
15 .rdata
16
17 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
18 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x34,0x39,0x20
19 .byte 0x24,0x0
20
21 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
22 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x33,0x34,0x20
23 .byte 0x24,0x0
24
25 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
26 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x35,0x20,0x24
27 .byte 0x0
28
29 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
30 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x38,0x20,0x24
31 .byte 0x0
32
33 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
34 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x32,0x33,0x20
35 .byte 0x24,0x0
36
37 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
38 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x37,0x38,0x20
39 .byte 0x24,0x0
40
41 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
42 .byte 0x6e,0x3a,0x20,0x33,0x2e,0x37,0x30,0x20
43 .byte 0x24,0x0
44
45 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
46 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x32,0x20,0x24
47 .byte 0x0
48
49 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
50 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x34,0x20,0x24
51 .byte 0x0
52
53 .byte 0x24,0x52,0x65,0x76,0x69,0x73,0x69,0x6f
54 .byte 0x6e,0x3a,0x20,0x31,0x2e,0x38,0x20,0x24
55 .byte 0x0
56 .text
57 .align 2
58 .globl bn_mul_add_words
59 .ent bn_mul_add_words
60bn_mul_add_words:
61 .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
62 .mask 0x00000000,0
63 .fmask 0x00000000,0
64 .set noreorder
65 .cpload $25
66 .set reorder
67 move $12,$4
68 move $14,$5
69 move $9,$6
70 move $13,$7
71 move $8,$0
72 addu $10,$12,12
73 addu $11,$14,12
74$L2:
75 lw $6,0($14)
76 #nop
77 multu $13,$6
78 mfhi $6
79 mflo $7
80 #nop
81 move $5,$8
82 move $4,$0
83 lw $3,0($12)
84 addu $9,$9,-1
85 move $2,$0
86 addu $7,$7,$3
87 sltu $8,$7,$3
88 addu $6,$6,$2
89 addu $6,$6,$8
90 addu $7,$7,$5
91 sltu $2,$7,$5
92 addu $6,$6,$4
93 addu $6,$6,$2
94 srl $3,$6,0
95 move $2,$0
96 move $8,$3
97 .set noreorder
98 .set nomacro
99 beq $9,$0,$L3
100 sw $7,0($12)
101 .set macro
102 .set reorder
103
104 lw $6,-8($11)
105 #nop
106 multu $13,$6
107 mfhi $6
108 mflo $7
109 #nop
110 move $5,$8
111 move $4,$0
112 lw $3,-8($10)
113 addu $9,$9,-1
114 move $2,$0
115 addu $7,$7,$3
116 sltu $8,$7,$3
117 addu $6,$6,$2
118 addu $6,$6,$8
119 addu $7,$7,$5
120 sltu $2,$7,$5
121 addu $6,$6,$4
122 addu $6,$6,$2
123 srl $3,$6,0
124 move $2,$0
125 move $8,$3
126 .set noreorder
127 .set nomacro
128 beq $9,$0,$L3
129 sw $7,-8($10)
130 .set macro
131 .set reorder
132
133 lw $6,-4($11)
134 #nop
135 multu $13,$6
136 mfhi $6
137 mflo $7
138 #nop
139 move $5,$8
140 move $4,$0
141 lw $3,-4($10)
142 addu $9,$9,-1
143 move $2,$0
144 addu $7,$7,$3
145 sltu $8,$7,$3
146 addu $6,$6,$2
147 addu $6,$6,$8
148 addu $7,$7,$5
149 sltu $2,$7,$5
150 addu $6,$6,$4
151 addu $6,$6,$2
152 srl $3,$6,0
153 move $2,$0
154 move $8,$3
155 .set noreorder
156 .set nomacro
157 beq $9,$0,$L3
158 sw $7,-4($10)
159 .set macro
160 .set reorder
161
162 lw $6,0($11)
163 #nop
164 multu $13,$6
165 mfhi $6
166 mflo $7
167 #nop
168 move $5,$8
169 move $4,$0
170 lw $3,0($10)
171 addu $9,$9,-1
172 move $2,$0
173 addu $7,$7,$3
174 sltu $8,$7,$3
175 addu $6,$6,$2
176 addu $6,$6,$8
177 addu $7,$7,$5
178 sltu $2,$7,$5
179 addu $6,$6,$4
180 addu $6,$6,$2
181 srl $3,$6,0
182 move $2,$0
183 move $8,$3
184 .set noreorder
185 .set nomacro
186 beq $9,$0,$L3
187 sw $7,0($10)
188 .set macro
189 .set reorder
190
191 addu $11,$11,16
192 addu $14,$14,16
193 addu $10,$10,16
194 .set noreorder
195 .set nomacro
196 j $L2
197 addu $12,$12,16
198 .set macro
199 .set reorder
200
201$L3:
202 .set noreorder
203 .set nomacro
204 j $31
205 move $2,$8
206 .set macro
207 .set reorder
208
209 .end bn_mul_add_words
210 .align 2
211 .globl bn_mul_words
212 .ent bn_mul_words
213bn_mul_words:
214 .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
215 .mask 0x00000000,0
216 .fmask 0x00000000,0
217 .set noreorder
218 .cpload $25
219 .set reorder
220 move $11,$4
221 move $12,$5
222 move $8,$6
223 move $6,$0
224 addu $10,$11,12
225 addu $9,$12,12
226$L10:
227 lw $4,0($12)
228 #nop
229 multu $7,$4
230 mfhi $4
231 mflo $5
232 #nop
233 move $3,$6
234 move $2,$0
235 addu $8,$8,-1
236 addu $5,$5,$3
237 sltu $6,$5,$3
238 addu $4,$4,$2
239 addu $4,$4,$6
240 srl $3,$4,0
241 move $2,$0
242 move $6,$3
243 .set noreorder
244 .set nomacro
245 beq $8,$0,$L11
246 sw $5,0($11)
247 .set macro
248 .set reorder
249
250 lw $4,-8($9)
251 #nop
252 multu $7,$4
253 mfhi $4
254 mflo $5
255 #nop
256 move $3,$6
257 move $2,$0
258 addu $8,$8,-1
259 addu $5,$5,$3
260 sltu $6,$5,$3
261 addu $4,$4,$2
262 addu $4,$4,$6
263 srl $3,$4,0
264 move $2,$0
265 move $6,$3
266 .set noreorder
267 .set nomacro
268 beq $8,$0,$L11
269 sw $5,-8($10)
270 .set macro
271 .set reorder
272
273 lw $4,-4($9)
274 #nop
275 multu $7,$4
276 mfhi $4
277 mflo $5
278 #nop
279 move $3,$6
280 move $2,$0
281 addu $8,$8,-1
282 addu $5,$5,$3
283 sltu $6,$5,$3
284 addu $4,$4,$2
285 addu $4,$4,$6
286 srl $3,$4,0
287 move $2,$0
288 move $6,$3
289 .set noreorder
290 .set nomacro
291 beq $8,$0,$L11
292 sw $5,-4($10)
293 .set macro
294 .set reorder
295
296 lw $4,0($9)
297 #nop
298 multu $7,$4
299 mfhi $4
300 mflo $5
301 #nop
302 move $3,$6
303 move $2,$0
304 addu $8,$8,-1
305 addu $5,$5,$3
306 sltu $6,$5,$3
307 addu $4,$4,$2
308 addu $4,$4,$6
309 srl $3,$4,0
310 move $2,$0
311 move $6,$3
312 .set noreorder
313 .set nomacro
314 beq $8,$0,$L11
315 sw $5,0($10)
316 .set macro
317 .set reorder
318
319 addu $9,$9,16
320 addu $12,$12,16
321 addu $10,$10,16
322 .set noreorder
323 .set nomacro
324 j $L10
325 addu $11,$11,16
326 .set macro
327 .set reorder
328
329$L11:
330 .set noreorder
331 .set nomacro
332 j $31
333 move $2,$6
334 .set macro
335 .set reorder
336
337 .end bn_mul_words
338 .align 2
339 .globl bn_sqr_words
340 .ent bn_sqr_words
341bn_sqr_words:
342 .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, extra= 0
343 .mask 0x00000000,0
344 .fmask 0x00000000,0
345 .set noreorder
346 .cpload $25
347 .set reorder
348 move $9,$4
349 addu $7,$9,28
350 addu $8,$5,12
351$L18:
352 lw $2,0($5)
353 #nop
354 multu $2,$2
355 mfhi $2
356 mflo $3
357 #nop
358 addu $6,$6,-1
359 sw $3,0($9)
360 srl $3,$2,0
361 move $2,$0
362 .set noreorder
363 .set nomacro
364 beq $6,$0,$L19
365 sw $3,-24($7)
366 .set macro
367 .set reorder
368
369 lw $2,-8($8)
370 #nop
371 multu $2,$2
372 mfhi $2
373 mflo $3
374 #nop
375 addu $6,$6,-1
376 sw $3,-20($7)
377 srl $3,$2,0
378 move $2,$0
379 .set noreorder
380 .set nomacro
381 beq $6,$0,$L19
382 sw $3,-16($7)
383 .set macro
384 .set reorder
385
386 lw $2,-4($8)
387 #nop
388 multu $2,$2
389 mfhi $2
390 mflo $3
391 #nop
392 addu $6,$6,-1
393 sw $3,-12($7)
394 srl $3,$2,0
395 move $2,$0
396 .set noreorder
397 .set nomacro
398 beq $6,$0,$L19
399 sw $3,-8($7)
400 .set macro
401 .set reorder
402
403 lw $2,0($8)
404 #nop
405 multu $2,$2
406 mfhi $2
407 mflo $3
408 #nop
409 addu $6,$6,-1
410 sw $3,-4($7)
411 srl $3,$2,0
412 move $2,$0
413 .set noreorder
414 .set nomacro
415 beq $6,$0,$L19
416 sw $3,0($7)
417 .set macro
418 .set reorder
419
420 addu $8,$8,16
421 addu $5,$5,16
422 addu $7,$7,32
423 .set noreorder
424 .set nomacro
425 j $L18
426 addu $9,$9,32
427 .set macro
428 .set reorder
429
430$L19:
431 j $31
432 .end bn_sqr_words
433 .rdata
434 .align 2
435$LC0:
436
437 .byte 0x44,0x69,0x76,0x69,0x73,0x69,0x6f,0x6e
438 .byte 0x20,0x77,0x6f,0x75,0x6c,0x64,0x20,0x6f
439 .byte 0x76,0x65,0x72,0x66,0x6c,0x6f,0x77,0xa
440 .byte 0x0
441 .text
442 .align 2
443 .globl bn_div64
444 .ent bn_div64
445bn_div64:
446 .frame $sp,56,$31 # vars= 0, regs= 7/0, args= 16, extra= 8
447 .mask 0x901f0000,-8
448 .fmask 0x00000000,0
449 .set noreorder
450 .cpload $25
451 .set reorder
452 subu $sp,$sp,56
453 .cprestore 16
454 sw $16,24($sp)
455 move $16,$4
456 sw $17,28($sp)
457 move $17,$5
458 sw $18,32($sp)
459 move $18,$6
460 sw $20,40($sp)
461 move $20,$0
462 sw $19,36($sp)
463 li $19,0x00000002 # 2
464 sw $31,48($sp)
465 .set noreorder
466 .set nomacro
467 bne $18,$0,$L26
468 sw $28,44($sp)
469 .set macro
470 .set reorder
471
472 .set noreorder
473 .set nomacro
474 j $L43
475 li $2,-1 # 0xffffffff
476 .set macro
477 .set reorder
478
479$L26:
480 move $4,$18
481 jal BN_num_bits_word
482 move $4,$2
483 li $2,0x00000020 # 32
484 .set noreorder
485 .set nomacro
486 beq $4,$2,$L27
487 li $2,0x00000001 # 1
488 .set macro
489 .set reorder
490
491 sll $2,$2,$4
492 sltu $2,$2,$16
493 .set noreorder
494 .set nomacro
495 beq $2,$0,$L44
496 li $5,0x00000020 # 32
497 .set macro
498 .set reorder
499
500 la $4,__iob+32
501 la $5,$LC0
502 jal fprintf
503 jal abort
504$L27:
505 li $5,0x00000020 # 32
506$L44:
507 sltu $2,$16,$18
508 .set noreorder
509 .set nomacro
510 bne $2,$0,$L28
511 subu $4,$5,$4
512 .set macro
513 .set reorder
514
515 subu $16,$16,$18
516$L28:
517 .set noreorder
518 .set nomacro
519 beq $4,$0,$L29
520 li $10,-65536 # 0xffff0000
521 .set macro
522 .set reorder
523
524 sll $18,$18,$4
525 sll $3,$16,$4
526 subu $2,$5,$4
527 srl $2,$17,$2
528 or $16,$3,$2
529 sll $17,$17,$4
530$L29:
531 srl $7,$18,16
532 andi $9,$18,0xffff
533$L30:
534 srl $2,$16,16
535 .set noreorder
536 .set nomacro
537 beq $2,$7,$L34
538 li $6,0x0000ffff # 65535
539 .set macro
540 .set reorder
541
542 divu $6,$16,$7
543$L34:
544 mult $6,$9
545 mflo $5
546 #nop
547 #nop
548 mult $6,$7
549 and $2,$17,$10
550 srl $8,$2,16
551 mflo $4
552$L35:
553 subu $3,$16,$4
554 and $2,$3,$10
555 .set noreorder
556 .set nomacro
557 bne $2,$0,$L36
558 sll $2,$3,16
559 .set macro
560 .set reorder
561
562 addu $2,$2,$8
563 sltu $2,$2,$5
564 .set noreorder
565 .set nomacro
566 beq $2,$0,$L36
567 subu $5,$5,$9
568 .set macro
569 .set reorder
570
571 subu $4,$4,$7
572 .set noreorder
573 .set nomacro
574 j $L35
575 addu $6,$6,-1
576 .set macro
577 .set reorder
578
579$L36:
580 mult $6,$7
581 mflo $5
582 #nop
583 #nop
584 mult $6,$9
585 mflo $4
586 #nop
587 #nop
588 srl $3,$4,16
589 sll $2,$4,16
590 and $4,$2,$10
591 sltu $2,$17,$4
592 .set noreorder
593 .set nomacro
594 beq $2,$0,$L40
595 addu $5,$5,$3
596 .set macro
597 .set reorder
598
599 addu $5,$5,1
600$L40:
601 sltu $2,$16,$5
602 .set noreorder
603 .set nomacro
604 beq $2,$0,$L41
605 subu $17,$17,$4
606 .set macro
607 .set reorder
608
609 addu $16,$16,$18
610 addu $6,$6,-1
611$L41:
612 addu $19,$19,-1
613 .set noreorder
614 .set nomacro
615 beq $19,$0,$L31
616 subu $16,$16,$5
617 .set macro
618 .set reorder
619
620 sll $20,$6,16
621 sll $3,$16,16
622 srl $2,$17,16
623 or $16,$3,$2
624 .set noreorder
625 .set nomacro
626 j $L30
627 sll $17,$17,16
628 .set macro
629 .set reorder
630
631$L31:
632 or $2,$20,$6
633$L43:
634 lw $31,48($sp)
635 lw $20,40($sp)
636 lw $19,36($sp)
637 lw $18,32($sp)
638 lw $17,28($sp)
639 lw $16,24($sp)
640 addu $sp,$sp,56
641 j $31
642 .end bn_div64
643
644 .globl abort .text
645 .globl fprintf .text
646 .globl BN_num_bits_word .text
diff --git a/src/lib/libcrypto/camellia/Makefile b/src/lib/libcrypto/camellia/Makefile
new file mode 100644
index 0000000000..6ce6fc99cd
--- /dev/null
+++ b/src/lib/libcrypto/camellia/Makefile
@@ -0,0 +1,110 @@
1#
2# crypto/camellia/Makefile
3#
4
5DIR= camellia
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11MAKEFILE= Makefile
12AR= ar r
13
14CMLL_ENC= camellia.o cmll_misc.o cmll_cbc.o
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17ASFLAGS= $(INCLUDES) $(ASFLAG)
18AFLAGS= $(ASFLAGS)
19
20GENERAL=Makefile
21#TEST=camelliatest.c
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC=camellia.c cmll_misc.c cmll_ecb.c cmll_cbc.c cmll_ofb.c \
26 cmll_cfb.c cmll_ctr.c cmll_utl.c
27
28LIBOBJ= cmll_ecb.o cmll_ofb.o cmll_cfb.o cmll_ctr.o cmll_utl.o $(CMLL_ENC)
29
30SRC= $(LIBSRC)
31
32EXHEADER= camellia.h
33HEADER= cmll_locl.h $(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 $(RANLIB) $(LIB) || echo Never mind.
45 @touch lib
46
47cmll-x86.s: asm/cmll-x86.pl ../perlasm/x86asm.pl
48 $(PERL) asm/cmll-x86.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@
49cmll-x86_64.s: asm/cmll-x86_64.pl
50 $(PERL) asm/cmll-x86_64.pl $(PERLASM_SCHEME) > $@
51
52files:
53 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
54
55links:
56 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
57 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
58 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
59
60install:
61 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
62 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
63 do \
64 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
65 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
66 done;
67
68tags:
69 ctags $(SRC)
70
71tests:
72
73lint:
74 lint -DLINT $(INCLUDES) $(SRC)>fluff
75
76depend:
77 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
78 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
79
80dclean:
81 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
82 mv -f Makefile.new $(MAKEFILE)
83
84clean:
85 rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
86
87# DO NOT DELETE THIS LINE -- make depend depends on it.
88
89camellia.o: ../../include/openssl/opensslconf.h camellia.c camellia.h
90camellia.o: cmll_locl.h
91cmll_cbc.o: ../../include/openssl/camellia.h ../../include/openssl/modes.h
92cmll_cbc.o: ../../include/openssl/opensslconf.h cmll_cbc.c
93cmll_cfb.o: ../../include/openssl/camellia.h ../../include/openssl/modes.h
94cmll_cfb.o: ../../include/openssl/opensslconf.h cmll_cfb.c
95cmll_ctr.o: ../../include/openssl/camellia.h ../../include/openssl/modes.h
96cmll_ctr.o: ../../include/openssl/opensslconf.h cmll_ctr.c
97cmll_ecb.o: ../../include/openssl/camellia.h
98cmll_ecb.o: ../../include/openssl/opensslconf.h cmll_ecb.c cmll_locl.h
99cmll_misc.o: ../../include/openssl/camellia.h ../../include/openssl/crypto.h
100cmll_misc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
101cmll_misc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
102cmll_misc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
103cmll_misc.o: ../../include/openssl/symhacks.h cmll_locl.h cmll_misc.c
104cmll_ofb.o: ../../include/openssl/camellia.h ../../include/openssl/modes.h
105cmll_ofb.o: ../../include/openssl/opensslconf.h cmll_ofb.c
106cmll_utl.o: ../../include/openssl/camellia.h ../../include/openssl/crypto.h
107cmll_utl.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
108cmll_utl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
109cmll_utl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
110cmll_utl.o: ../../include/openssl/symhacks.h cmll_locl.h cmll_utl.c
diff --git a/src/lib/libcrypto/camellia/cmll_utl.c b/src/lib/libcrypto/camellia/cmll_utl.c
new file mode 100644
index 0000000000..7a35711ec1
--- /dev/null
+++ b/src/lib/libcrypto/camellia/cmll_utl.c
@@ -0,0 +1,64 @@
1/* crypto/camellia/cmll_utl.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 2011 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 */
51
52#include <openssl/opensslv.h>
53#include <openssl/crypto.h>
54#include <openssl/camellia.h>
55#include "cmll_locl.h"
56
57int Camellia_set_key(const unsigned char *userKey, const int bits,
58 CAMELLIA_KEY *key)
59 {
60#ifdef OPENSSL_FIPS
61 fips_cipher_abort(Camellia);
62#endif
63 return private_Camellia_set_key(userKey, bits, key);
64 }
diff --git a/src/lib/libcrypto/cmac/Makefile b/src/lib/libcrypto/cmac/Makefile
new file mode 100644
index 0000000000..54e7cc39d5
--- /dev/null
+++ b/src/lib/libcrypto/cmac/Makefile
@@ -0,0 +1,111 @@
1#
2# OpenSSL/crypto/cmac/Makefile
3#
4
5DIR= cmac
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10MAKEFILE= Makefile
11AR= ar r
12
13CFLAGS= $(INCLUDES) $(CFLAG)
14
15GENERAL=Makefile
16TEST=
17APPS=
18
19LIB=$(TOP)/libcrypto.a
20LIBSRC=cmac.c cm_ameth.c cm_pmeth.c
21LIBOBJ=cmac.o cm_ameth.o cm_pmeth.o
22
23SRC= $(LIBSRC)
24
25EXHEADER= cmac.h
26HEADER= $(EXHEADER)
27
28ALL= $(GENERAL) $(SRC) $(HEADER)
29
30top:
31 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
32
33all: lib
34
35lib: $(LIBOBJ)
36 $(AR) $(LIB) $(LIBOBJ)
37 $(RANLIB) $(LIB) || echo Never mind.
38 @touch lib
39
40files:
41 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
42
43links:
44 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
45 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
46 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
47
48install:
49 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
50 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
51 do \
52 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
53 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
54 done;
55
56tags:
57 ctags $(SRC)
58
59tests:
60
61lint:
62 lint -DLINT $(INCLUDES) $(SRC)>fluff
63
64depend:
65 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
66 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
67
68dclean:
69 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
70 mv -f Makefile.new $(MAKEFILE)
71
72clean:
73 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
74
75# DO NOT DELETE THIS LINE -- make depend depends on it.
76
77cm_ameth.o: ../../e_os.h ../../include/openssl/asn1.h
78cm_ameth.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
79cm_ameth.o: ../../include/openssl/cmac.h ../../include/openssl/crypto.h
80cm_ameth.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
81cm_ameth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
82cm_ameth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
83cm_ameth.o: ../../include/openssl/opensslconf.h
84cm_ameth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
85cm_ameth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
86cm_ameth.o: ../../include/openssl/symhacks.h ../asn1/asn1_locl.h ../cryptlib.h
87cm_ameth.o: cm_ameth.c
88cm_pmeth.o: ../../e_os.h ../../include/openssl/asn1.h
89cm_pmeth.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
90cm_pmeth.o: ../../include/openssl/cmac.h ../../include/openssl/conf.h
91cm_pmeth.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
92cm_pmeth.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
93cm_pmeth.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
94cm_pmeth.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
95cm_pmeth.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
96cm_pmeth.o: ../../include/openssl/opensslconf.h
97cm_pmeth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
98cm_pmeth.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
99cm_pmeth.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
100cm_pmeth.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
101cm_pmeth.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
102cm_pmeth.o: ../cryptlib.h ../evp/evp_locl.h cm_pmeth.c
103cmac.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
104cmac.o: ../../include/openssl/buffer.h ../../include/openssl/cmac.h
105cmac.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
106cmac.o: ../../include/openssl/err.h ../../include/openssl/evp.h
107cmac.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
108cmac.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
109cmac.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
110cmac.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
111cmac.o: ../../include/openssl/symhacks.h ../cryptlib.h cmac.c
diff --git a/src/lib/libcrypto/cms/Makefile b/src/lib/libcrypto/cms/Makefile
new file mode 100644
index 0000000000..9820adb212
--- /dev/null
+++ b/src/lib/libcrypto/cms/Makefile
@@ -0,0 +1,284 @@
1#
2# OpenSSL/crypto/cms/Makefile
3#
4
5DIR= cms
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10MAKEFILE= Makefile
11AR= ar r
12
13CFLAGS= $(INCLUDES) $(CFLAG)
14
15GENERAL=Makefile
16TEST=
17APPS=
18
19LIB=$(TOP)/libcrypto.a
20LIBSRC= cms_lib.c cms_asn1.c cms_att.c cms_io.c cms_smime.c cms_err.c \
21 cms_sd.c cms_dd.c cms_cd.c cms_env.c cms_enc.c cms_ess.c \
22 cms_pwri.c
23LIBOBJ= cms_lib.o cms_asn1.o cms_att.o cms_io.o cms_smime.o cms_err.o \
24 cms_sd.o cms_dd.o cms_cd.o cms_env.o cms_enc.o cms_ess.o \
25 cms_pwri.o
26
27SRC= $(LIBSRC)
28
29EXHEADER= cms.h
30HEADER= cms_lcl.h $(EXHEADER)
31
32ALL= $(GENERAL) $(SRC) $(HEADER)
33
34top:
35 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
36
37test:
38
39all: lib
40
41lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ)
43 $(RANLIB) $(LIB) || echo Never mind.
44 @touch lib
45
46files:
47 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
48
49links:
50 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
51 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
52 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
53
54install:
55 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
56 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
57 do \
58 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
59 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
60 done;
61
62tags:
63 ctags $(SRC)
64
65tests:
66
67lint:
68 lint -DLINT $(INCLUDES) $(SRC)>fluff
69
70depend:
71 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
72 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(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 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
80
81# DO NOT DELETE THIS LINE -- make depend depends on it.
82
83cms_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
84cms_asn1.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
85cms_asn1.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
86cms_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
87cms_asn1.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
88cms_asn1.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
89cms_asn1.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
90cms_asn1.o: ../../include/openssl/opensslconf.h
91cms_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
92cms_asn1.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
93cms_asn1.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
94cms_asn1.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
95cms_asn1.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
96cms_asn1.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
97cms_asn1.o: cms.h cms_asn1.c cms_lcl.h
98cms_att.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
99cms_att.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
100cms_att.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
101cms_att.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
102cms_att.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
103cms_att.o: ../../include/openssl/err.h ../../include/openssl/evp.h
104cms_att.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
105cms_att.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
106cms_att.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
107cms_att.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
108cms_att.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
109cms_att.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
110cms_att.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
111cms_att.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
112cms_att.o: cms.h cms_att.c cms_lcl.h
113cms_cd.o: ../../e_os.h ../../include/openssl/asn1.h
114cms_cd.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
115cms_cd.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
116cms_cd.o: ../../include/openssl/comp.h ../../include/openssl/conf.h
117cms_cd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
118cms_cd.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
119cms_cd.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
120cms_cd.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
121cms_cd.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
122cms_cd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
123cms_cd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
124cms_cd.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
125cms_cd.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
126cms_cd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
127cms_cd.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
128cms_cd.o: ../../include/openssl/x509v3.h ../cryptlib.h cms_cd.c cms_lcl.h
129cms_dd.o: ../../e_os.h ../../include/openssl/asn1.h
130cms_dd.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
131cms_dd.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
132cms_dd.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
133cms_dd.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
134cms_dd.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
135cms_dd.o: ../../include/openssl/err.h ../../include/openssl/evp.h
136cms_dd.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
137cms_dd.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
138cms_dd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
139cms_dd.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
140cms_dd.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
141cms_dd.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
142cms_dd.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
143cms_dd.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
144cms_dd.o: ../cryptlib.h cms_dd.c cms_lcl.h
145cms_enc.o: ../../e_os.h ../../include/openssl/asn1.h
146cms_enc.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
147cms_enc.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
148cms_enc.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
149cms_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
150cms_enc.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
151cms_enc.o: ../../include/openssl/err.h ../../include/openssl/evp.h
152cms_enc.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
153cms_enc.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
154cms_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
155cms_enc.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
156cms_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
157cms_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
158cms_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
159cms_enc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
160cms_enc.o: ../../include/openssl/x509v3.h ../cryptlib.h cms_enc.c cms_lcl.h
161cms_env.o: ../../e_os.h ../../include/openssl/aes.h
162cms_env.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
163cms_env.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
164cms_env.o: ../../include/openssl/cms.h ../../include/openssl/conf.h
165cms_env.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
166cms_env.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
167cms_env.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
168cms_env.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
169cms_env.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
170cms_env.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
171cms_env.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
172cms_env.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
173cms_env.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
174cms_env.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
175cms_env.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
176cms_env.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
177cms_env.o: ../asn1/asn1_locl.h ../cryptlib.h cms_env.c cms_lcl.h
178cms_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
179cms_err.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
180cms_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
181cms_err.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
182cms_err.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
183cms_err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
184cms_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
185cms_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
186cms_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
187cms_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
188cms_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
189cms_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
190cms_err.o: cms_err.c
191cms_ess.o: ../../e_os.h ../../include/openssl/asn1.h
192cms_ess.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
193cms_ess.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
194cms_ess.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
195cms_ess.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
196cms_ess.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
197cms_ess.o: ../../include/openssl/err.h ../../include/openssl/evp.h
198cms_ess.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
199cms_ess.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
200cms_ess.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
201cms_ess.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
202cms_ess.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
203cms_ess.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
204cms_ess.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
205cms_ess.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
206cms_ess.o: ../../include/openssl/x509v3.h ../cryptlib.h cms_ess.c cms_lcl.h
207cms_io.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
208cms_io.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
209cms_io.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
210cms_io.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
211cms_io.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
212cms_io.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
213cms_io.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
214cms_io.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
215cms_io.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
216cms_io.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
217cms_io.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
218cms_io.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
219cms_io.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h cms.h
220cms_io.o: cms_io.c cms_lcl.h
221cms_lib.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
222cms_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
223cms_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
224cms_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
225cms_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
226cms_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
227cms_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
228cms_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
229cms_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
230cms_lib.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
231cms_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
232cms_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
233cms_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h cms.h
234cms_lib.o: cms_lcl.h cms_lib.c
235cms_pwri.o: ../../e_os.h ../../include/openssl/aes.h
236cms_pwri.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
237cms_pwri.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
238cms_pwri.o: ../../include/openssl/cms.h ../../include/openssl/conf.h
239cms_pwri.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
240cms_pwri.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
241cms_pwri.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
242cms_pwri.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
243cms_pwri.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
244cms_pwri.o: ../../include/openssl/opensslconf.h
245cms_pwri.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
246cms_pwri.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
247cms_pwri.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
248cms_pwri.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
249cms_pwri.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
250cms_pwri.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
251cms_pwri.o: ../../include/openssl/x509v3.h ../asn1/asn1_locl.h ../cryptlib.h
252cms_pwri.o: cms_lcl.h cms_pwri.c
253cms_sd.o: ../../e_os.h ../../include/openssl/asn1.h
254cms_sd.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
255cms_sd.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
256cms_sd.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
257cms_sd.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
258cms_sd.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
259cms_sd.o: ../../include/openssl/err.h ../../include/openssl/evp.h
260cms_sd.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
261cms_sd.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
262cms_sd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
263cms_sd.o: ../../include/openssl/pem.h ../../include/openssl/pem2.h
264cms_sd.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
265cms_sd.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
266cms_sd.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
267cms_sd.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
268cms_sd.o: ../asn1/asn1_locl.h ../cryptlib.h cms_lcl.h cms_sd.c
269cms_smime.o: ../../e_os.h ../../include/openssl/asn1.h
270cms_smime.o: ../../include/openssl/asn1t.h ../../include/openssl/bio.h
271cms_smime.o: ../../include/openssl/buffer.h ../../include/openssl/cms.h
272cms_smime.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
273cms_smime.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
274cms_smime.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
275cms_smime.o: ../../include/openssl/err.h ../../include/openssl/evp.h
276cms_smime.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
277cms_smime.o: ../../include/openssl/objects.h
278cms_smime.o: ../../include/openssl/opensslconf.h
279cms_smime.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
280cms_smime.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
281cms_smime.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
282cms_smime.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
283cms_smime.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
284cms_smime.o: ../cryptlib.h cms_lcl.h cms_smime.c
diff --git a/src/lib/libcrypto/crypto-lib.com b/src/lib/libcrypto/crypto-lib.com
deleted file mode 100644
index c280aa03a8..0000000000
--- a/src/lib/libcrypto/crypto-lib.com
+++ /dev/null
@@ -1,1516 +0,0 @@
1$!
2$! CRYPTO-LIB.COM
3$! Written By: Robert Byer
4$! Vice-President
5$! A-Com Computing, Inc.
6$! byer@mail.all-net.net
7$!
8$! Changes by Richard Levitte <richard@levitte.org>
9$! Zoltan Arpadffy <arpadffy@polarhome.com>
10$!
11$! This command files compiles and creates the "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB"
12$! library for OpenSSL. The "xxx" denotes the machine architecture, ALPHA,
13$! IA64 or VAX.
14$!
15$! It was re-written so it would try to determine what "C" compiler to use
16$! or you can specify which "C" compiler to use.
17$!
18$! Specify the following as P1 to build just that part or ALL to just
19$! build everything.
20$!
21$! LIBRARY To just compile the [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library.
22$! APPS To just compile the [.xxx.EXE.CRYPTO]*.EXE
23$! ALL To do both LIBRARY and APPS
24$!
25$! Specify DEBUG or NODEBUG as P2 to compile with or without debugger
26$! information.
27$!
28$! Specify which compiler at P3 to try to compile under.
29$!
30$! VAXC For VAX C.
31$! DECC For DEC C.
32$! GNUC For GNU C.
33$!
34$! If you don't specify a compiler, it will try to determine which
35$! "C" compiler to use.
36$!
37$! P4, if defined, sets a TCP/IP library to use, through one of the following
38$! keywords:
39$!
40$! UCX For UCX
41$! TCPIP For TCPIP (post UCX)
42$! SOCKETSHR For SOCKETSHR+NETLIB
43$!
44$! P5, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
45$!
46$! P6, if defined, sets a choice of crypto methods to compile.
47$! WARNING: this should only be done to recompile some part of an already
48$! fully compiled library.
49$!
50$! P7, if defined, specifies the C pointer size. Ignored on VAX.
51$! ("64=ARGV" gives more efficient code with HP C V7.3 or newer.)
52$! Supported values are:
53$!
54$! "" Compile with default (/NOPOINTER_SIZE)
55$! 32 Compile with /POINTER_SIZE=32 (SHORT)
56$! 64 Compile with /POINTER_SIZE=64[=ARGV] (LONG[=ARGV]).
57$! (Automatically select ARGV if compiler supports it.)
58$! 64= Compile with /POINTER_SIZE=64 (LONG).
59$! 64=ARGV Compile with /POINTER_SIZE=64=ARGV (LONG=ARGV).
60$!
61$! P8, if defined, specifies a directory where ZLIB files (zlib.h,
62$! libz.olb) may be found. Optionally, a non-default object library
63$! name may be included ("dev:[dir]libz_64.olb", for example).
64$!
65$!
66$! Announce/identify.
67$!
68$ proc = f$environment( "procedure")
69$ write sys$output "@@@ "+ -
70 f$parse( proc, , , "name")+ f$parse( proc, , , "type")
71$!
72$! Define A TCP/IP Library That We Will Need To Link To.
73$! (That Is, If We Need To Link To One.)
74$!
75$ TCPIP_LIB = ""
76$ ZLIB_LIB = ""
77$!
78$! Check Which Architecture We Are Using.
79$!
80$ IF (F$GETSYI("CPU").LT.128)
81$ THEN
82$!
83$! The Architecture Is VAX
84$!
85$ ARCH = "VAX"
86$!
87$! Else...
88$!
89$ ELSE
90$!
91$! The Architecture Is Alpha, IA64 or whatever comes in the future.
92$!
93$ ARCH = F$EDIT( F$GETSYI( "ARCH_NAME"), "UPCASE")
94$ IF (ARCH .EQS. "") THEN ARCH = "UNK"
95$!
96$! End The Architecture Check.
97$!
98$ ENDIF
99$!
100$ ARCHD = ARCH
101$ LIB32 = "32"
102$ OPT_FILE = ""
103$ POINTER_SIZE = ""
104$!
105$! Define The Different Encryption Types.
106$! NOTE: Some might think this list ugly. However, it's made this way to
107$! reflect the SDIRS variable in [-]Makefile.org as closely as possible,
108$! thereby making it fairly easy to verify that the lists are the same.
109$!
110$ ET_WHIRLPOOL = "WHRLPOOL"
111$ IF ARCH .EQS. "VAX" THEN ET_WHIRLPOOL = ""
112$ ENCRYPT_TYPES = "Basic,"+ -
113 "OBJECTS,"+ -
114 "MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,"+ET_WHIRLPOOL+","+ -
115 "DES,AES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,SEED,MODES,"+ -
116 "BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,"+ -
117 "BUFFER,BIO,STACK,LHASH,RAND,ERR,"+ -
118 "EVP,EVP_2,EVP_3,ASN1,ASN1_2,PEM,X509,X509V3,"+ -
119 "CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,UI,KRB5,"+ -
120 "CMS,PQUEUE,TS,JPAKE,SRP,STORE,CMAC"
121$!
122$! Check To Make Sure We Have Valid Command Line Parameters.
123$!
124$ GOSUB CHECK_OPTIONS
125$!
126$! Define The OBJ and EXE Directories.
127$!
128$ OBJ_DIR := SYS$DISK:[-.'ARCHD'.OBJ.CRYPTO]
129$ EXE_DIR := SYS$DISK:[-.'ARCHD'.EXE.CRYPTO]
130$!
131$! Specify the destination directory in any /MAP option.
132$!
133$ if (LINKMAP .eqs. "MAP")
134$ then
135$ LINKMAP = LINKMAP+ "=''EXE_DIR'"
136$ endif
137$!
138$! Add the location prefix to the linker options file name.
139$!
140$ if (OPT_FILE .nes. "")
141$ then
142$ OPT_FILE = EXE_DIR+ OPT_FILE
143$ endif
144$!
145$! Initialise logical names and such
146$!
147$ GOSUB INITIALISE
148$!
149$! Tell The User What Kind of Machine We Run On.
150$!
151$ WRITE SYS$OUTPUT "Host system architecture: ''ARCHD'"
152$!
153$!
154$! Check To See If The Architecture Specific OBJ Directory Exists.
155$!
156$ IF (F$PARSE(OBJ_DIR).EQS."")
157$ THEN
158$!
159$! It Dosen't Exist, So Create It.
160$!
161$ CREATE/DIR 'OBJ_DIR'
162$!
163$! End The Architecture Specific OBJ Directory Check.
164$!
165$ ENDIF
166$!
167$! Check To See If The Architecture Specific Directory Exists.
168$!
169$ IF (F$PARSE(EXE_DIR).EQS."")
170$ THEN
171$!
172$! It Dosen't Exist, So Create It.
173$!
174$ CREATE/DIRECTORY 'EXE_DIR'
175$!
176$! End The Architecture Specific Directory Check.
177$!
178$ ENDIF
179$!
180$! Define The Library Name.
181$!
182$ LIB_NAME := 'EXE_DIR'SSL_LIBCRYPTO'LIB32'.OLB
183$!
184$! Define The CRYPTO-LIB We Are To Use.
185$!
186$ CRYPTO_LIB := 'EXE_DIR'SSL_LIBCRYPTO'LIB32'.OLB
187$!
188$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO]LIBCRYPTO.OLB" Library...
189$!
190$ IF (F$SEARCH(LIB_NAME).EQS."")
191$ THEN
192$!
193$! Guess Not, Create The Library.
194$!
195$ LIBRARY/CREATE/OBJECT 'LIB_NAME'
196$!
197$! End The Library Check.
198$!
199$ ENDIF
200$!
201$! Build our options file for the application
202$!
203$ GOSUB CHECK_OPT_FILE
204$!
205$! Define The Different Encryption "library" Strings.
206$!
207$ APPS_DES = "DES/DES,CBC3_ENC"
208$ APPS_PKCS7 = "ENC/ENC;DEC/DEC;SIGN/SIGN;VERIFY/VERIFY,EXAMPLE"
209$
210$ LIB_ = "cryptlib,mem,mem_clr,mem_dbg,cversion,ex_data,cpt_err,"+ -
211 "ebcdic,uid,o_time,o_str,o_dir,o_fips.c,o_init,fips_ers"
212$ LIB_MD2 = "md2_dgst,md2_one"
213$ LIB_MD4 = "md4_dgst,md4_one"
214$ LIB_MD5 = "md5_dgst,md5_one"
215$ LIB_SHA = "sha_dgst,sha1dgst,sha_one,sha1_one,sha256,sha512"
216$ LIB_MDC2 = "mdc2dgst,mdc2_one"
217$ LIB_HMAC = "hmac,hm_ameth,hm_pmeth"
218$ LIB_RIPEMD = "rmd_dgst,rmd_one"
219$ LIB_WHRLPOOL = "wp_dgst,wp_block"
220$ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
221 "ecb3_enc,cfb64enc,cfb64ede,cfb_enc,ofb64ede,"+ -
222 "enc_read,enc_writ,ofb64enc,"+ -
223 "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ -
224 "des_enc,fcrypt_b,"+ -
225 "fcrypt,xcbc_enc,rpc_enc,cbc_cksm,"+ -
226 "ede_cbcm_enc,des_old,des_old2,read2pwd"
227$ LIB_RC2 = "rc2_ecb,rc2_skey,rc2_cbc,rc2cfb64,rc2ofb64"
228$ LIB_RC4 = "rc4_skey,rc4_enc,rc4_utl"
229$ LIB_RC5 = "rc5_skey,rc5_ecb,rc5_enc,rc5cfb64,rc5ofb64"
230$ LIB_IDEA = "i_cbc,i_cfb64,i_ofb64,i_ecb,i_skey"
231$ LIB_BF = "bf_skey,bf_ecb,bf_enc,bf_cfb64,bf_ofb64"
232$ LIB_CAST = "c_skey,c_ecb,c_enc,c_cfb64,c_ofb64"
233$ LIB_CAMELLIA = "camellia,cmll_misc,cmll_ecb,cmll_cbc,cmll_ofb,"+ -
234 "cmll_cfb,cmll_ctr,cmll_utl"
235$ LIB_SEED = "seed,seed_ecb,seed_cbc,seed_cfb,seed_ofb"
236$ LIB_MODES = "cbc128,ctr128,cts128,cfb128,ofb128,gcm128,"+ -
237 "ccm128,xts128"
238$ LIB_BN_ASM = "[.asm]vms.mar,vms-helper"
239$ IF F$TRNLNM("OPENSSL_NO_ASM") .OR. ARCH .NES. "VAX" THEN -
240 LIB_BN_ASM = "bn_asm"
241$ LIB_BN = "bn_add,bn_div,bn_exp,bn_lib,bn_ctx,bn_mul,bn_mod,"+ -
242 "bn_print,bn_rand,bn_shift,bn_word,bn_blind,"+ -
243 "bn_kron,bn_sqrt,bn_gcd,bn_prime,bn_err,bn_sqr,"+LIB_BN_ASM+","+ -
244 "bn_recp,bn_mont,bn_mpi,bn_exp2,bn_gf2m,bn_nist,"+ -
245 "bn_depr,bn_const,bn_x931p"
246$ LIB_EC = "ec_lib,ecp_smpl,ecp_mont,ecp_nist,ec_cvt,ec_mult,"+ -
247 "ec_err,ec_curve,ec_check,ec_print,ec_asn1,ec_key,"+ -
248 "ec2_smpl,ec2_mult,ec_ameth,ec_pmeth,eck_prn,"+ -
249 "ecp_nistp224,ecp_nistp256,ecp_nistp521,ecp_nistputil,"+ -
250 "ecp_oct,ec2_oct,ec_oct"
251$ LIB_RSA = "rsa_eay,rsa_gen,rsa_lib,rsa_sign,rsa_saos,rsa_err,"+ -
252 "rsa_pk1,rsa_ssl,rsa_none,rsa_oaep,rsa_chk,rsa_null,"+ -
253 "rsa_pss,rsa_x931,rsa_asn1,rsa_depr,rsa_ameth,rsa_prn,"+ -
254 "rsa_pmeth,rsa_crpt"
255$ LIB_DSA = "dsa_gen,dsa_key,dsa_lib,dsa_asn1,dsa_vrf,dsa_sign,"+ -
256 "dsa_err,dsa_ossl,dsa_depr,dsa_ameth,dsa_pmeth,dsa_prn"
257$ LIB_ECDSA = "ecs_lib,ecs_asn1,ecs_ossl,ecs_sign,ecs_vrf,ecs_err"
258$ LIB_DH = "dh_asn1,dh_gen,dh_key,dh_lib,dh_check,dh_err,dh_depr,"+ -
259 "dh_ameth,dh_pmeth,dh_prn"
260$ LIB_ECDH = "ech_lib,ech_ossl,ech_key,ech_err"
261$ LIB_DSO = "dso_dl,dso_dlfcn,dso_err,dso_lib,dso_null,"+ -
262 "dso_openssl,dso_win32,dso_vms,dso_beos"
263$ LIB_ENGINE = "eng_err,eng_lib,eng_list,eng_init,eng_ctrl,"+ -
264 "eng_table,eng_pkey,eng_fat,eng_all,"+ -
265 "tb_rsa,tb_dsa,tb_ecdsa,tb_dh,tb_ecdh,tb_rand,tb_store,"+ -
266 "tb_cipher,tb_digest,tb_pkmeth,tb_asnmth,"+ -
267 "eng_openssl,eng_dyn,eng_cnf,eng_cryptodev,"+ -
268 "eng_rsax,eng_rdrand"
269$ LIB_AES = "aes_core,aes_misc,aes_ecb,aes_cbc,aes_cfb,aes_ofb,aes_ctr,"+ -
270 "aes_ige,aes_wrap"
271$ LIB_BUFFER = "buffer,buf_str,buf_err"
272$ LIB_BIO = "bio_lib,bio_cb,bio_err,"+ -
273 "bss_mem,bss_null,bss_fd,"+ -
274 "bss_file,bss_sock,bss_conn,"+ -
275 "bf_null,bf_buff,b_print,b_dump,"+ -
276 "b_sock,bss_acpt,bf_nbio,bss_rtcp,bss_bio,bss_log,"+ -
277 "bss_dgram,"+ -
278 "bf_lbuf"
279$ LIB_STACK = "stack"
280$ LIB_LHASH = "lhash,lh_stats"
281$ LIB_RAND = "md_rand,randfile,rand_lib,rand_err,rand_egd,"+ -
282 "rand_vms"
283$ LIB_ERR = "err,err_all,err_prn"
284$ LIB_OBJECTS = "o_names,obj_dat,obj_lib,obj_err,obj_xref"
285$ LIB_EVP = "encode,digest,evp_enc,evp_key,evp_acnf,"+ -
286 "e_des,e_bf,e_idea,e_des3,e_camellia,"+ -
287 "e_rc4,e_aes,names,e_seed,"+ -
288 "e_xcbc_d,e_rc2,e_cast,e_rc5"
289$ LIB_EVP_2 = "m_null,m_md2,m_md4,m_md5,m_sha,m_sha1,m_wp," + -
290 "m_dss,m_dss1,m_mdc2,m_ripemd,m_ecdsa,"+ -
291 "p_open,p_seal,p_sign,p_verify,p_lib,p_enc,p_dec,"+ -
292 "bio_md,bio_b64,bio_enc,evp_err,e_null,"+ -
293 "c_all,c_allc,c_alld,evp_lib,bio_ok,"+-
294 "evp_pkey,evp_pbe,p5_crpt,p5_crpt2"
295$ LIB_EVP_3 = "e_old,pmeth_lib,pmeth_fn,pmeth_gn,m_sigver,evp_fips,"+ -
296 "e_aes_cbc_hmac_sha1,e_rc4_hmac_md5"
297$ LIB_ASN1 = "a_object,a_bitstr,a_utctm,a_gentm,a_time,a_int,a_octet,"+ -
298 "a_print,a_type,a_set,a_dup,a_d2i_fp,a_i2d_fp,"+ -
299 "a_enum,a_utf8,a_sign,a_digest,a_verify,a_mbstr,a_strex,"+ -
300 "x_algor,x_val,x_pubkey,x_sig,x_req,x_attrib,x_bignum,"+ -
301 "x_long,x_name,x_x509,x_x509a,x_crl,x_info,x_spki,nsseq,"+ -
302 "x_nx509,d2i_pu,d2i_pr,i2d_pu,i2d_pr"
303$ LIB_ASN1_2 = "t_req,t_x509,t_x509a,t_crl,t_pkey,t_spki,t_bitst,"+ -
304 "tasn_new,tasn_fre,tasn_enc,tasn_dec,tasn_utl,tasn_typ,"+ -
305 "tasn_prn,ameth_lib,"+ -
306 "f_int,f_string,n_pkey,"+ -
307 "f_enum,x_pkey,a_bool,x_exten,bio_asn1,bio_ndef,asn_mime,"+ -
308 "asn1_gen,asn1_par,asn1_lib,asn1_err,a_bytes,a_strnid,"+ -
309 "evp_asn1,asn_pack,p5_pbe,p5_pbev2,p8_pkey,asn_moid"
310$ LIB_PEM = "pem_sign,pem_seal,pem_info,pem_lib,pem_all,pem_err,"+ -
311 "pem_x509,pem_xaux,pem_oth,pem_pk8,pem_pkey,pvkfmt"
312$ LIB_X509 = "x509_def,x509_d2,x509_r2x,x509_cmp,"+ -
313 "x509_obj,x509_req,x509spki,x509_vfy,"+ -
314 "x509_set,x509cset,x509rset,x509_err,"+ -
315 "x509name,x509_v3,x509_ext,x509_att,"+ -
316 "x509type,x509_lu,x_all,x509_txt,"+ -
317 "x509_trs,by_file,by_dir,x509_vpm"
318$ LIB_X509V3 = "v3_bcons,v3_bitst,v3_conf,v3_extku,v3_ia5,v3_lib,"+ -
319 "v3_prn,v3_utl,v3err,v3_genn,v3_alt,v3_skey,v3_akey,v3_pku,"+ -
320 "v3_int,v3_enum,v3_sxnet,v3_cpols,v3_crld,v3_purp,v3_info,"+ -
321 "v3_ocsp,v3_akeya,v3_pmaps,v3_pcons,v3_ncons,v3_pcia,v3_pci,"+ -
322 "pcy_cache,pcy_node,pcy_data,pcy_map,pcy_tree,pcy_lib,"+ -
323 "v3_asid,v3_addr"
324$ LIB_CONF = "conf_err,conf_lib,conf_api,conf_def,conf_mod,conf_mall,conf_sap"
325$ LIB_TXT_DB = "txt_db"
326$ LIB_PKCS7 = "pk7_asn1,pk7_lib,pkcs7err,pk7_doit,pk7_smime,pk7_attr,"+ -
327 "pk7_mime,bio_pk7"
328$ LIB_PKCS12 = "p12_add,p12_asn,p12_attr,p12_crpt,p12_crt,p12_decr,"+ -
329 "p12_init,p12_key,p12_kiss,p12_mutl,"+ -
330 "p12_utl,p12_npas,pk12err,p12_p8d,p12_p8e"
331$ LIB_COMP = "comp_lib,comp_err,"+ -
332 "c_rle,c_zlib"
333$ LIB_OCSP = "ocsp_asn,ocsp_ext,ocsp_ht,ocsp_lib,ocsp_cl,"+ -
334 "ocsp_srv,ocsp_prn,ocsp_vfy,ocsp_err"
335$ LIB_UI_COMPAT = ",ui_compat"
336$ LIB_UI = "ui_err,ui_lib,ui_openssl,ui_util"+LIB_UI_COMPAT
337$ LIB_KRB5 = "krb5_asn"
338$ LIB_CMS = "cms_lib,cms_asn1,cms_att,cms_io,cms_smime,cms_err,"+ -
339 "cms_sd,cms_dd,cms_cd,cms_env,cms_enc,cms_ess,"+ -
340 "cms_pwri"
341$ LIB_PQUEUE = "pqueue"
342$ LIB_TS = "ts_err,ts_req_utils,ts_req_print,ts_rsp_utils,ts_rsp_print,"+ -
343 "ts_rsp_sign,ts_rsp_verify,ts_verify_ctx,ts_lib,ts_conf,"+ -
344 "ts_asn1"
345$ LIB_JPAKE = "jpake,jpake_err"
346$ LIB_SRP = "srp_lib,srp_vfy"
347$ LIB_STORE = "str_err,str_lib,str_meth,str_mem"
348$ LIB_CMAC = "cmac,cm_ameth.c,cm_pmeth"
349$!
350$! Setup exceptional compilations
351$!
352$ CC3_SHOWN = 0
353$ CC4_SHOWN = 0
354$ CC5_SHOWN = 0
355$ CC6_SHOWN = 0
356$!
357$! The following lists must have leading and trailing commas, and no
358$! embedded spaces. (They are scanned for ",name,".)
359$!
360$ ! Add definitions for no threads on OpenVMS 7.1 and higher.
361$ COMPILEWITH_CC3 = ",bss_rtcp,"
362$ ! Disable the DOLLARID warning. Not needed with /STANDARD=RELAXED.
363$ COMPILEWITH_CC4 = "" !!! ",a_utctm,bss_log,o_time,o_dir,"
364$ ! Disable disjoint optimization on VAX with DECC.
365$ COMPILEWITH_CC5 = ",md2_dgst,md4_dgst,md5_dgst,mdc2dgst," + -
366 "seed,sha_dgst,sha1dgst,rmd_dgst,bf_enc,"
367$ ! Disable the MIXLINKAGE warning.
368$ COMPILEWITH_CC6 = "" !!! ",enc_read,set_key,"
369$!
370$! Figure Out What Other Modules We Are To Build.
371$!
372$ BUILD_SET:
373$!
374$! Define A Module Counter.
375$!
376$ MODULE_COUNTER = 0
377$!
378$! Top Of The Loop.
379$!
380$ MODULE_NEXT:
381$!
382$! Extract The Module Name From The Encryption List.
383$!
384$ MODULE_NAME = F$ELEMENT(MODULE_COUNTER,",",ENCRYPT_TYPES)
385$ IF MODULE_NAME.EQS."Basic" THEN MODULE_NAME = ""
386$ MODULE_NAME1 = MODULE_NAME
387$!
388$! Check To See If We Are At The End Of The Module List.
389$!
390$ IF (MODULE_NAME.EQS.",")
391$ THEN
392$!
393$! We Are At The End Of The Module List, Go To MODULE_DONE.
394$!
395$ GOTO MODULE_DONE
396$!
397$! End The Module List Check.
398$!
399$ ENDIF
400$!
401$! Increment The Moudle Counter.
402$!
403$ MODULE_COUNTER = MODULE_COUNTER + 1
404$!
405$! Create The Library and Apps Module Names.
406$!
407$ LIB_MODULE = "LIB_" + MODULE_NAME
408$ APPS_MODULE = "APPS_" + MODULE_NAME
409$ IF (F$EXTRACT(0,5,MODULE_NAME).EQS."ASN1_")
410$ THEN
411$ MODULE_NAME = "ASN1"
412$ ENDIF
413$ IF (F$EXTRACT(0,4,MODULE_NAME).EQS."EVP_")
414$ THEN
415$ MODULE_NAME = "EVP"
416$ ENDIF
417$!
418$! Set state (can be LIB and APPS)
419$!
420$ STATE = "LIB"
421$ IF BUILDALL .EQS. "APPS" THEN STATE = "APPS"
422$!
423$! Check if the library module name actually is defined
424$!
425$ IF F$TYPE('LIB_MODULE') .EQS. ""
426$ THEN
427$ WRITE SYS$ERROR ""
428$ WRITE SYS$ERROR "The module ",MODULE_NAME1," does not exist. Continuing..."
429$ WRITE SYS$ERROR ""
430$ GOTO MODULE_NEXT
431$ ENDIF
432$!
433$! Top Of The Module Loop.
434$!
435$ MODULE_AGAIN:
436$!
437$! Tell The User What Module We Are Building.
438$!
439$ IF (MODULE_NAME1.NES."")
440$ THEN
441$ IF STATE .EQS. "LIB"
442$ THEN
443$ WRITE SYS$OUTPUT "Compiling The ",MODULE_NAME1," Library Files. (",BUILDALL,",",STATE,")"
444$ ELSE IF F$TYPE('APPS_MODULE') .NES. ""
445$ THEN
446$ WRITE SYS$OUTPUT "Compiling The ",MODULE_NAME1," Applications. (",BUILDALL,",",STATE,")"
447$ ENDIF
448$ ENDIF
449$ ENDIF
450$!
451$! Define A File Counter And Set It To "0".
452$!
453$ FILE_COUNTER = 0
454$ APPLICATION = ""
455$ APPLICATION_COUNTER = 0
456$!
457$! Top Of The File Loop.
458$!
459$ NEXT_FILE:
460$!
461$! Look in the LIB_MODULE is we're in state LIB
462$!
463$ IF STATE .EQS. "LIB"
464$ THEN
465$!
466$! O.K, Extract The File Name From The File List.
467$!
468$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",'LIB_MODULE')
469$!
470$! else
471$!
472$ ELSE
473$ FILE_NAME = ","
474$!
475$ IF F$TYPE('APPS_MODULE') .NES. ""
476$ THEN
477$!
478$! Extract The File Name From The File List.
479$! This part is a bit more complicated.
480$!
481$ IF APPLICATION .EQS. ""
482$ THEN
483$ APPLICATION = F$ELEMENT(APPLICATION_COUNTER,";",'APPS_MODULE')
484$ APPLICATION_COUNTER = APPLICATION_COUNTER + 1
485$ APPLICATION_OBJECTS = F$ELEMENT(1,"/",APPLICATION)
486$ APPLICATION = F$ELEMENT(0,"/",APPLICATION)
487$ FILE_COUNTER = 0
488$ ENDIF
489$
490$! WRITE SYS$OUTPUT "DEBUG: SHOW SYMBOL APPLICATION*"
491$! SHOW SYMBOL APPLICATION*
492$!
493$ IF APPLICATION .NES. ";"
494$ THEN
495$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",APPLICATION_OBJECTS)
496$ IF FILE_NAME .EQS. ","
497$ THEN
498$ APPLICATION = ""
499$ GOTO NEXT_FILE
500$ ENDIF
501$ ENDIF
502$ ENDIF
503$ ENDIF
504$!
505$! Check To See If We Are At The End Of The File List.
506$!
507$ IF (FILE_NAME.EQS.",")
508$ THEN
509$!
510$! We Are At The End Of The File List, Change State Or Goto FILE_DONE.
511$!
512$ IF STATE .EQS. "LIB" .AND. BUILDALL .NES. "LIBRARY"
513$ THEN
514$ STATE = "APPS"
515$ GOTO MODULE_AGAIN
516$ ELSE
517$ GOTO FILE_DONE
518$ ENDIF
519$!
520$! End The File List Check.
521$!
522$ ENDIF
523$!
524$! Increment The Counter.
525$!
526$ FILE_COUNTER = FILE_COUNTER + 1
527$!
528$! Create The Source File Name.
529$!
530$ TMP_FILE_NAME = F$ELEMENT(1,"]",FILE_NAME)
531$ IF TMP_FILE_NAME .EQS. "]" THEN TMP_FILE_NAME = FILE_NAME
532$ IF F$ELEMENT(0,".",TMP_FILE_NAME) .EQS. TMP_FILE_NAME THEN -
533 FILE_NAME = FILE_NAME + ".c"
534$ IF (MODULE_NAME.NES."")
535$ THEN
536$ SOURCE_FILE = "SYS$DISK:[." + MODULE_NAME+ "]" + FILE_NAME
537$ ELSE
538$ SOURCE_FILE = "SYS$DISK:[]" + FILE_NAME
539$ ENDIF
540$ SOURCE_FILE = SOURCE_FILE - "]["
541$!
542$! Create The Object File Name.
543$!
544$ OBJECT_FILE = OBJ_DIR + F$PARSE(FILE_NAME,,,"NAME","SYNTAX_ONLY") + ".OBJ"
545$ ON WARNING THEN GOTO NEXT_FILE
546$!
547$! Check To See If The File We Want To Compile Is Actually There.
548$!
549$ IF (F$SEARCH(SOURCE_FILE).EQS."")
550$ THEN
551$!
552$! Tell The User That The File Doesn't Exist.
553$!
554$ WRITE SYS$OUTPUT ""
555$ WRITE SYS$OUTPUT "The File ",SOURCE_FILE," Doesn't Exist."
556$ WRITE SYS$OUTPUT ""
557$!
558$! Exit The Build.
559$!
560$ GOTO EXIT
561$!
562$! End The File Exist Check.
563$!
564$ ENDIF
565$!
566$! Tell The User We Are Compiling The File.
567$!
568$ IF (MODULE_NAME.EQS."")
569$ THEN
570$ WRITE SYS$OUTPUT "Compiling The ",FILE_NAME," File. (",BUILDALL,",",STATE,")"
571$ ENDIF
572$ IF (MODULE_NAME.NES."")
573$ THEN
574$ WRITE SYS$OUTPUT " ",FILE_NAME,""
575$ ENDIF
576$!
577$! Compile The File.
578$!
579$ ON ERROR THEN GOTO NEXT_FILE
580$ FILE_NAME0 = ","+ F$ELEMENT(0,".",FILE_NAME)+ ","
581$ IF FILE_NAME - ".mar" .NES. FILE_NAME
582$ THEN
583$ MACRO/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
584$ ELSE
585$ IF COMPILEWITH_CC3 - FILE_NAME0 .NES. COMPILEWITH_CC3
586$ THEN
587$ write sys$output " \Using special rule (3)"
588$ if (.not. CC3_SHOWN)
589$ then
590$ CC3_SHOWN = 1
591$ x = " "+ CC3
592$ write /symbol sys$output x
593$ endif
594$ CC3/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
595$ ELSE
596$ IF COMPILEWITH_CC4 - FILE_NAME0 .NES. COMPILEWITH_CC4
597$ THEN
598$ write /symbol sys$output " \Using special rule (4)"
599$ if (.not. CC4_SHOWN)
600$ then
601$ CC4_SHOWN = 1
602$ x = " "+ CC4
603$ write /symbol sys$output x
604$ endif
605$ CC4/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
606$ ELSE
607$ IF CC5_DIFFERENT .AND. -
608 (COMPILEWITH_CC5 - FILE_NAME0 .NES. COMPILEWITH_CC5)
609$ THEN
610$ write sys$output " \Using special rule (5)"
611$ if (.not. CC5_SHOWN)
612$ then
613$ CC5_SHOWN = 1
614$ x = " "+ CC5
615$ write /symbol sys$output x
616$ endif
617$ CC5/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
618$ ELSE
619$ IF COMPILEWITH_CC6 - FILE_NAME0 .NES. COMPILEWITH_CC6
620$ THEN
621$ write sys$output " \Using special rule (6)"
622$ if (.not. CC6_SHOWN)
623$ then
624$ CC6_SHOWN = 1
625$ x = " "+ CC6
626$ write /symbol sys$output x
627$ endif
628$ CC6/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
629$ ELSE
630$ CC/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
631$ ENDIF
632$ ENDIF
633$ ENDIF
634$ ENDIF
635$ ENDIF
636$ IF STATE .EQS. "LIB"
637$ THEN
638$!
639$! Add It To The Library.
640$!
641$ LIBRARY/REPLACE 'LIB_NAME' 'OBJECT_FILE'
642$!
643$! Time To Clean Up The Object File.
644$!
645$ DELETE 'OBJECT_FILE';*
646$ ENDIF
647$!
648$! Go Back And Do It Again.
649$!
650$ GOTO NEXT_FILE
651$!
652$! All Done With This Library Part.
653$!
654$ FILE_DONE:
655$!
656$! Time To Build Some Applications
657$!
658$ IF F$TYPE('APPS_MODULE') .NES. "" .AND. BUILDALL .NES. "LIBRARY"
659$ THEN
660$ APPLICATION_COUNTER = 0
661$ NEXT_APPLICATION:
662$ APPLICATION = F$ELEMENT(APPLICATION_COUNTER,";",'APPS_MODULE')
663$ IF APPLICATION .EQS. ";" THEN GOTO APPLICATION_DONE
664$
665$ APPLICATION_COUNTER = APPLICATION_COUNTER + 1
666$ APPLICATION_OBJECTS = F$ELEMENT(1,"/",APPLICATION)
667$ APPLICATION = F$ELEMENT(0,"/",APPLICATION)
668$
669$! WRITE SYS$OUTPUT "DEBUG: SHOW SYMBOL APPLICATION*"
670$! SHOW SYMBOL APPLICATION*
671$!
672$! Tell the user what happens
673$!
674$ WRITE SYS$OUTPUT " ",APPLICATION,".exe"
675$!
676$! Link The Program.
677$!
678$ ON ERROR THEN GOTO NEXT_APPLICATION
679$!
680$! Link With A TCP/IP Library.
681$!
682$ LINK /'DEBUGGER' /'LINKMAP' /'TRACEBACK' -
683 /EXE='EXE_DIR''APPLICATION'.EXE -
684 'OBJ_DIR''APPLICATION_OBJECTS', -
685 'CRYPTO_LIB'/LIBRARY -
686 'TCPIP_LIB' -
687 'ZLIB_LIB' -
688 ,'OPT_FILE' /OPTIONS
689$!
690$ GOTO NEXT_APPLICATION
691$ APPLICATION_DONE:
692$ ENDIF
693$!
694$! Go Back And Get The Next Module.
695$!
696$ GOTO MODULE_NEXT
697$!
698$! All Done With This Module.
699$!
700$ MODULE_DONE:
701$!
702$! Tell The User That We Are All Done.
703$!
704$ WRITE SYS$OUTPUT "All Done..."
705$ EXIT:
706$ GOSUB CLEANUP
707$ EXIT
708$!
709$! Check For The Link Option FIle.
710$!
711$ CHECK_OPT_FILE:
712$!
713$! Check To See If We Need To Make A VAX C Option File.
714$!
715$ IF (COMPILER.EQS."VAXC")
716$ THEN
717$!
718$! Check To See If We Already Have A VAX C Linker Option File.
719$!
720$ IF (F$SEARCH(OPT_FILE).EQS."")
721$ THEN
722$!
723$! We Need A VAX C Linker Option File.
724$!
725$ CREATE 'OPT_FILE'
726$DECK
727!
728! Default System Options File To Link Against
729! The Sharable VAX C Runtime Library.
730!
731SYS$SHARE:VAXCRTL.EXE/SHARE
732$EOD
733$!
734$! End The Option File Check.
735$!
736$ ENDIF
737$!
738$! End The VAXC Check.
739$!
740$ ENDIF
741$!
742$! Check To See If We Need A GNU C Option File.
743$!
744$ IF (COMPILER.EQS."GNUC")
745$ THEN
746$!
747$! Check To See If We Already Have A GNU C Linker Option File.
748$!
749$ IF (F$SEARCH(OPT_FILE).EQS."")
750$ THEN
751$!
752$! We Need A GNU C Linker Option File.
753$!
754$ CREATE 'OPT_FILE'
755$DECK
756!
757! Default System Options File To Link Against
758! The Sharable C Runtime Library.
759!
760GNU_CC:[000000]GCCLIB/LIBRARY
761SYS$SHARE:VAXCRTL/SHARE
762$EOD
763$!
764$! End The Option File Check.
765$!
766$ ENDIF
767$!
768$! End The GNU C Check.
769$!
770$ ENDIF
771$!
772$! Check To See If We Need A DEC C Option File.
773$!
774$ IF (COMPILER.EQS."DECC")
775$ THEN
776$!
777$! Check To See If We Already Have A DEC C Linker Option File.
778$!
779$ IF (F$SEARCH(OPT_FILE).EQS."")
780$ THEN
781$!
782$! Figure Out If We Need A non-VAX Or A VAX Linker Option File.
783$!
784$ IF ARCH .EQS. "VAX"
785$ THEN
786$!
787$! We Need A DEC C Linker Option File For VAX.
788$!
789$ CREATE 'OPT_FILE'
790$DECK
791!
792! Default System Options File To Link Against
793! The Sharable DEC C Runtime Library.
794!
795SYS$SHARE:DECC$SHR.EXE/SHARE
796$EOD
797$!
798$! Else...
799$!
800$ ELSE
801$!
802$! Create The non-VAX Linker Option File.
803$!
804$ CREATE 'OPT_FILE'
805$DECK
806!
807! Default System Options File For non-VAX To Link Against
808! The Sharable C Runtime Library.
809!
810SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE
811SYS$SHARE:CMA$OPEN_RTL/SHARE
812$EOD
813$!
814$! End The DEC C Option File Check.
815$!
816$ ENDIF
817$!
818$! End The Option File Search.
819$!
820$ ENDIF
821$!
822$! End The DEC C Check.
823$!
824$ ENDIF
825$!
826$! Tell The User What Linker Option File We Are Using.
827$!
828$ WRITE SYS$OUTPUT "Using Linker Option File ",OPT_FILE,"."
829$!
830$! Time To RETURN.
831$!
832$ RETURN
833$!
834$! Check The User's Options.
835$!
836$ CHECK_OPTIONS:
837$!
838$! Check To See If P1 Is Blank.
839$!
840$ IF (P1.EQS."ALL")
841$ THEN
842$!
843$! P1 Is Blank, So Build Everything.
844$!
845$ BUILDALL = "TRUE"
846$!
847$! Else...
848$!
849$ ELSE
850$!
851$! Else, Check To See If P1 Has A Valid Argument.
852$!
853$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."APPS")
854$ THEN
855$!
856$! A Valid Argument.
857$!
858$ BUILDALL = P1
859$!
860$! Else...
861$!
862$ ELSE
863$!
864$! Tell The User We Don't Know What They Want.
865$!
866$ WRITE SYS$OUTPUT ""
867$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
868$ WRITE SYS$OUTPUT ""
869$ WRITE SYS$OUTPUT " ALL : Just Build Everything."
870$ WRITE SYS$OUTPUT " LIBRARY : To Compile Just The [.xxx.EXE.CRYPTO]LIBCRYPTO.OLB Library."
871$ WRITE SYS$OUTPUT " APPS : To Compile Just The [.xxx.EXE.CRYPTO]*.EXE Programs."
872$ WRITE SYS$OUTPUT ""
873$ WRITE SYS$OUTPUT " Where 'xxx' Stands For:"
874$ WRITE SYS$OUTPUT ""
875$ WRITE SYS$OUTPUT " ALPHA[64]: Alpha Architecture."
876$ WRITE SYS$OUTPUT " IA64[64] : IA64 Architecture."
877$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
878$ WRITE SYS$OUTPUT ""
879$!
880$! Time To EXIT.
881$!
882$ EXIT
883$!
884$! End The Valid Argument Check.
885$!
886$ ENDIF
887$!
888$! End The P1 Check.
889$!
890$ ENDIF
891$!
892$! Check To See If P2 Is Blank.
893$!
894$ IF (P2.EQS."NODEBUG")
895$ THEN
896$!
897$! P2 Is NODEBUG, So Compile Without The Debugger Information.
898$!
899$ DEBUGGER = "NODEBUG"
900$ LINKMAP = "NOMAP"
901$ TRACEBACK = "NOTRACEBACK"
902$ GCC_OPTIMIZE = "OPTIMIZE"
903$ CC_OPTIMIZE = "OPTIMIZE"
904$ MACRO_OPTIMIZE = "OPTIMIZE"
905$ WRITE SYS$OUTPUT "No Debugger Information Will Be Produced During Compile."
906$ WRITE SYS$OUTPUT "Compiling With Compiler Optimization."
907$ ELSE
908$!
909$! Check To See If We Are To Compile With Debugger Information.
910$!
911$ IF (P2.EQS."DEBUG")
912$ THEN
913$!
914$! Compile With Debugger Information.
915$!
916$ DEBUGGER = "DEBUG"
917$ LINKMAP = "MAP"
918$ TRACEBACK = "TRACEBACK"
919$ GCC_OPTIMIZE = "NOOPTIMIZE"
920$ CC_OPTIMIZE = "NOOPTIMIZE"
921$ MACRO_OPTIMIZE = "NOOPTIMIZE"
922$ WRITE SYS$OUTPUT "Debugger Information Will Be Produced During Compile."
923$ WRITE SYS$OUTPUT "Compiling Without Compiler Optimization."
924$ ELSE
925$!
926$! They Entered An Invalid Option.
927$!
928$ WRITE SYS$OUTPUT ""
929$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
930$ WRITE SYS$OUTPUT ""
931$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
932$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
933$ WRITE SYS$OUTPUT ""
934$!
935$! Time To EXIT.
936$!
937$ EXIT
938$!
939$! End The Valid Argument Check.
940$!
941$ ENDIF
942$!
943$! End The P2 Check.
944$!
945$ ENDIF
946$!
947$! Special Threads For OpenVMS v7.1 Or Later
948$!
949$! Written By: Richard Levitte
950$! richard@levitte.org
951$!
952$!
953$! Check To See If We Have A Option For P5.
954$!
955$ IF (P5.EQS."")
956$ THEN
957$!
958$! Get The Version Of VMS We Are Using.
959$!
960$ ISSEVEN :=
961$ TMP = F$ELEMENT(0,"-",F$EXTRACT(1,4,F$GETSYI("VERSION")))
962$ TMP = F$INTEGER(F$ELEMENT(0,".",TMP)+F$ELEMENT(1,".",TMP))
963$!
964$! Check To See If The VMS Version Is v7.1 Or Later.
965$!
966$ IF (TMP.GE.71)
967$ THEN
968$!
969$! We Have OpenVMS v7.1 Or Later, So Use The Special Threads.
970$!
971$ ISSEVEN := ,PTHREAD_USE_D4
972$!
973$! End The VMS Version Check.
974$!
975$ ENDIF
976$!
977$! End The P5 Check.
978$!
979$ ENDIF
980$!
981$! Check P7 (POINTER_SIZE).
982$!
983$ IF (P7 .NES. "") .AND. (ARCH .NES. "VAX")
984$ THEN
985$!
986$ IF (P7 .EQS. "32")
987$ THEN
988$ POINTER_SIZE = " /POINTER_SIZE=32"
989$ ELSE
990$ POINTER_SIZE = F$EDIT( P7, "COLLAPSE, UPCASE")
991$ IF ((POINTER_SIZE .EQS. "64") .OR. -
992 (POINTER_SIZE .EQS. "64=") .OR. -
993 (POINTER_SIZE .EQS. "64=ARGV"))
994$ THEN
995$ ARCHD = ARCH+ "_64"
996$ LIB32 = ""
997$ POINTER_SIZE = " /POINTER_SIZE=64"
998$ ELSE
999$!
1000$! Tell The User Entered An Invalid Option.
1001$!
1002$ WRITE SYS$OUTPUT ""
1003$ WRITE SYS$OUTPUT "The Option ", P7, -
1004 " Is Invalid. The Valid Options Are:"
1005$ WRITE SYS$OUTPUT ""
1006$ WRITE SYS$OUTPUT -
1007 " """" : Compile with default (short) pointers."
1008$ WRITE SYS$OUTPUT -
1009 " 32 : Compile with 32-bit (short) pointers."
1010$ WRITE SYS$OUTPUT -
1011 " 64 : Compile with 64-bit (long) pointers (auto ARGV)."
1012$ WRITE SYS$OUTPUT -
1013 " 64= : Compile with 64-bit (long) pointers (no ARGV)."
1014$ WRITE SYS$OUTPUT -
1015 " 64=ARGV : Compile with 64-bit (long) pointers (ARGV)."
1016$ WRITE SYS$OUTPUT ""
1017$!
1018$! Time To EXIT.
1019$!
1020$ EXIT
1021$!
1022$ ENDIF
1023$!
1024$ ENDIF
1025$!
1026$! End The P7 (POINTER_SIZE) Check.
1027$!
1028$ ENDIF
1029$!
1030$! Set basic C compiler /INCLUDE directories.
1031$!
1032$ CC_INCLUDES = "SYS$DISK:[.''ARCHD'],SYS$DISK:[],SYS$DISK:[-],"+ -
1033 "SYS$DISK:[.ENGINE.VENDOR_DEFNS],SYS$DISK:[.MODES],SYS$DISK:[.ASN1],SYS$DISK:[.EVP]"
1034$!
1035$! Check To See If P3 Is Blank.
1036$!
1037$ IF (P3.EQS."")
1038$ THEN
1039$!
1040$! O.K., The User Didn't Specify A Compiler, Let's Try To
1041$! Find Out Which One To Use.
1042$!
1043$! Check To See If We Have GNU C.
1044$!
1045$ IF (F$TRNLNM("GNU_CC").NES."")
1046$ THEN
1047$!
1048$! Looks Like GNUC, Set To Use GNUC.
1049$!
1050$ P3 = "GNUC"
1051$!
1052$! Else...
1053$!
1054$ ELSE
1055$!
1056$! Check To See If We Have VAXC Or DECC.
1057$!
1058$ IF (ARCH.NES."VAX").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."")
1059$ THEN
1060$!
1061$! Looks Like DECC, Set To Use DECC.
1062$!
1063$ P3 = "DECC"
1064$!
1065$! Else...
1066$!
1067$ ELSE
1068$!
1069$! Looks Like VAXC, Set To Use VAXC.
1070$!
1071$ P3 = "VAXC"
1072$!
1073$! End The VAXC Compiler Check.
1074$!
1075$ ENDIF
1076$!
1077$! End The DECC & VAXC Compiler Check.
1078$!
1079$ ENDIF
1080$!
1081$! End The Compiler Check.
1082$!
1083$ ENDIF
1084$!
1085$! Check To See If We Have A Option For P4.
1086$!
1087$ IF (P4.EQS."")
1088$ THEN
1089$!
1090$! Find out what socket library we have available
1091$!
1092$ IF F$PARSE("SOCKETSHR:") .NES. ""
1093$ THEN
1094$!
1095$! We have SOCKETSHR, and it is my opinion that it's the best to use.
1096$!
1097$ P4 = "SOCKETSHR"
1098$!
1099$! Tell the user
1100$!
1101$ WRITE SYS$OUTPUT "Using SOCKETSHR for TCP/IP"
1102$!
1103$! Else, let's look for something else
1104$!
1105$ ELSE
1106$!
1107$! Like UCX (the reason to do this before Multinet is that the UCX
1108$! emulation is easier to use...)
1109$!
1110$ IF F$TRNLNM("UCX$IPC_SHR") .NES. "" -
1111 .OR. F$PARSE("SYS$SHARE:UCX$IPC_SHR.EXE") .NES. "" -
1112 .OR. F$PARSE("SYS$LIBRARY:UCX$IPC.OLB") .NES. ""
1113$ THEN
1114$!
1115$! Last resort: a UCX or UCX-compatible library
1116$!
1117$ P4 = "UCX"
1118$!
1119$! Tell the user
1120$!
1121$ WRITE SYS$OUTPUT "Using UCX or an emulation thereof for TCP/IP"
1122$!
1123$! That was all...
1124$!
1125$ ENDIF
1126$ ENDIF
1127$ ENDIF
1128$!
1129$! Set Up Initial CC Definitions, Possibly With User Ones
1130$!
1131$ CCDEFS = "TCPIP_TYPE_''P4',DSO_VMS"
1132$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
1133$ CCEXTRAFLAGS = ""
1134$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
1135$ CCDISABLEWARNINGS = "" !!! "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR"
1136$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
1137 CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
1138$!
1139$! Check To See If We Have A ZLIB Option.
1140$!
1141$ ZLIB = P8
1142$ IF (ZLIB .NES. "")
1143$ THEN
1144$!
1145$! Check for expected ZLIB files.
1146$!
1147$ err = 0
1148$ file1 = f$parse( "zlib.h", ZLIB, , , "SYNTAX_ONLY")
1149$ if (f$search( file1) .eqs. "")
1150$ then
1151$ WRITE SYS$OUTPUT ""
1152$ WRITE SYS$OUTPUT "The Option ", ZLIB, " Is Invalid."
1153$ WRITE SYS$OUTPUT " Can't find header: ''file1'"
1154$ err = 1
1155$ endif
1156$ file1 = f$parse( "A.;", ZLIB)- "A.;"
1157$!
1158$ file2 = f$parse( ZLIB, "libz.olb", , , "SYNTAX_ONLY")
1159$ if (f$search( file2) .eqs. "")
1160$ then
1161$ if (err .eq. 0)
1162$ then
1163$ WRITE SYS$OUTPUT ""
1164$ WRITE SYS$OUTPUT "The Option ", ZLIB, " Is Invalid."
1165$ endif
1166$ WRITE SYS$OUTPUT " Can't find library: ''file2'"
1167$ WRITE SYS$OUTPUT ""
1168$ err = err+ 2
1169$ endif
1170$ if (err .eq. 1)
1171$ then
1172$ WRITE SYS$OUTPUT ""
1173$ endif
1174$!
1175$ if (err .ne. 0)
1176$ then
1177$ EXIT
1178$ endif
1179$!
1180$ CCDEFS = """ZLIB=1"", "+ CCDEFS
1181$ CC_INCLUDES = CC_INCLUDES+ ", "+ file1
1182$ ZLIB_LIB = ", ''file2' /library"
1183$!
1184$! Print info
1185$!
1186$ WRITE SYS$OUTPUT "ZLIB library spec: ", file2
1187$!
1188$! End The ZLIB Check.
1189$!
1190$ ENDIF
1191$!
1192$! Check To See If The User Entered A Valid Parameter.
1193$!
1194$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC")
1195$ THEN
1196$!
1197$! Check To See If The User Wanted DECC.
1198$!
1199$ IF (P3.EQS."DECC")
1200$ THEN
1201$!
1202$! Looks Like DECC, Set To Use DECC.
1203$!
1204$ COMPILER = "DECC"
1205$!
1206$! Tell The User We Are Using DECC.
1207$!
1208$ WRITE SYS$OUTPUT "Using DECC 'C' Compiler."
1209$!
1210$! Use DECC...
1211$!
1212$ CC = "CC"
1213$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
1214 THEN CC = "CC/DECC"
1215$ CC = CC + " /''CC_OPTIMIZE' /''DEBUGGER' /STANDARD=RELAXED"+ -
1216 "''POINTER_SIZE' /NOLIST /PREFIX=ALL" + -
1217 " /INCLUDE=(''CC_INCLUDES')"+ -
1218 CCEXTRAFLAGS
1219$!
1220$! Define The Linker Options File Name.
1221$!
1222$ OPT_FILE = "VAX_DECC_OPTIONS.OPT"
1223$!
1224$! End DECC Check.
1225$!
1226$ ENDIF
1227$!
1228$! Check To See If We Are To Use VAXC.
1229$!
1230$ IF (P3.EQS."VAXC")
1231$ THEN
1232$!
1233$! Looks Like VAXC, Set To Use VAXC.
1234$!
1235$ COMPILER = "VAXC"
1236$!
1237$! Tell The User We Are Using VAX C.
1238$!
1239$ WRITE SYS$OUTPUT "Using VAXC 'C' Compiler."
1240$!
1241$! Compile Using VAXC.
1242$!
1243$ CC = "CC"
1244$ IF ARCH.NES."VAX"
1245$ THEN
1246$ WRITE SYS$OUTPUT "There is no VAX C on ''ARCH'!"
1247$ EXIT
1248$ ENDIF
1249$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
1250$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
1251 "/INCLUDE=(''CC_INCLUDES')"+ -
1252 CCEXTRAFLAGS
1253$ CCDEFS = """VAXC""," + CCDEFS
1254$!
1255$! Define <sys> As SYS$COMMON:[SYSLIB]
1256$!
1257$ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB]
1258$!
1259$! Define The Linker Options File Name.
1260$!
1261$ OPT_FILE = "VAX_VAXC_OPTIONS.OPT"
1262$!
1263$! End VAXC Check
1264$!
1265$ ENDIF
1266$!
1267$! Check To See If We Are To Use GNU C.
1268$!
1269$ IF (P3.EQS."GNUC")
1270$ THEN
1271$!
1272$! Looks Like GNUC, Set To Use GNUC.
1273$!
1274$ COMPILER = "GNUC"
1275$!
1276$! Tell The User We Are Using GNUC.
1277$!
1278$ WRITE SYS$OUTPUT "Using GNU 'C' Compiler."
1279$!
1280$! Use GNU C...
1281$!
1282$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
1283 "/INCLUDE=(''CC_INCLUDES')"+ -
1284 CCEXTRAFLAGS
1285$!
1286$! Define The Linker Options File Name.
1287$!
1288$ OPT_FILE = "VAX_GNUC_OPTIONS.OPT"
1289$!
1290$! End The GNU C Check.
1291$!
1292$ ENDIF
1293$!
1294$! Set up default defines
1295$!
1296$ CCDEFS = """FLAT_INC=1""," + CCDEFS
1297$!
1298$! Finish up the definition of CC.
1299$!
1300$ IF COMPILER .EQS. "DECC"
1301$ THEN
1302$ IF CCDISABLEWARNINGS .EQS. ""
1303$ THEN
1304$ CC4DISABLEWARNINGS = "DOLLARID"
1305$ CC6DISABLEWARNINGS = "MIXLINKAGE"
1306$ ELSE
1307$ CC4DISABLEWARNINGS = CCDISABLEWARNINGS + ",DOLLARID"
1308$ CC6DISABLEWARNINGS = CCDISABLEWARNINGS + ",MIXLINKAGE"
1309$ CCDISABLEWARNINGS = " /WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))"
1310$ ENDIF
1311$ CC4DISABLEWARNINGS = " /WARNING=(DISABLE=(" + CC4DISABLEWARNINGS + "))"
1312$ CC6DISABLEWARNINGS = " /WARNING=(DISABLE=(" + CC6DISABLEWARNINGS + "))"
1313$ ELSE
1314$ CCDISABLEWARNINGS = ""
1315$ CC4DISABLEWARNINGS = ""
1316$ CC6DISABLEWARNINGS = ""
1317$ ENDIF
1318$ CC3 = CC + " /DEFINE=(" + CCDEFS + ISSEVEN + ")" + CCDISABLEWARNINGS
1319$ CC = CC + " /DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS
1320$ IF ARCH .EQS. "VAX" .AND. COMPILER .EQS. "DECC" .AND. P2 .NES. "DEBUG"
1321$ THEN
1322$ CC5 = CC + " /OPTIMIZE=NODISJOINT"
1323$ CC5_DIFFERENT = 1
1324$ ELSE
1325$ CC5 = CC
1326$ CC5_DIFFERENT = 0
1327$ ENDIF
1328$ CC4 = CC - CCDISABLEWARNINGS + CC4DISABLEWARNINGS
1329$ CC6 = CC - CCDISABLEWARNINGS + CC6DISABLEWARNINGS
1330$!
1331$! Show user the result
1332$!
1333$ WRITE/SYMBOL SYS$OUTPUT "Main C Compiling Command: ",CC
1334$!
1335$! Else The User Entered An Invalid Argument.
1336$!
1337$ ELSE
1338$!
1339$! Tell The User We Don't Know What They Want.
1340$!
1341$ WRITE SYS$OUTPUT ""
1342$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
1343$ WRITE SYS$OUTPUT ""
1344$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
1345$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
1346$ WRITE SYS$OUTPUT " GNUC : To Compile With GNU C."
1347$ WRITE SYS$OUTPUT ""
1348$!
1349$! Time To EXIT.
1350$!
1351$ EXIT
1352$!
1353$! End The Valid Argument Check.
1354$!
1355$ ENDIF
1356$!
1357$! Build a MACRO command for the architecture at hand
1358$!
1359$ IF ARCH .EQS. "VAX" THEN MACRO = "MACRO/''DEBUGGER'"
1360$ IF ARCH .NES. "VAX" THEN MACRO = "MACRO/MIGRATION/''DEBUGGER'/''MACRO_OPTIMIZE'"
1361$!
1362$! Show user the result
1363$!
1364$ WRITE/SYMBOL SYS$OUTPUT "Main MACRO Compiling Command: ",MACRO
1365$!
1366$! Time to check the contents, and to make sure we get the correct library.
1367$!
1368$ IF P4.EQS."SOCKETSHR" .OR. P4.EQS."MULTINET" .OR. P4.EQS."UCX" -
1369 .OR. P4.EQS."TCPIP" .OR. P4.EQS."NONE"
1370$ THEN
1371$!
1372$! Check to see if SOCKETSHR was chosen
1373$!
1374$ IF P4.EQS."SOCKETSHR"
1375$ THEN
1376$!
1377$! Set the library to use SOCKETSHR
1378$!
1379$ TCPIP_LIB = ",SYS$DISK:[-.VMS]SOCKETSHR_SHR.OPT /OPTIONS"
1380$!
1381$! Done with SOCKETSHR
1382$!
1383$ ENDIF
1384$!
1385$! Check to see if MULTINET was chosen
1386$!
1387$ IF P4.EQS."MULTINET"
1388$ THEN
1389$!
1390$! Set the library to use UCX emulation.
1391$!
1392$ P4 = "UCX"
1393$!
1394$! Done with MULTINET
1395$!
1396$ ENDIF
1397$!
1398$! Check to see if UCX was chosen
1399$!
1400$ IF P4.EQS."UCX"
1401$ THEN
1402$!
1403$! Set the library to use UCX.
1404$!
1405$ TCPIP_LIB = ",SYS$DISK:[-.VMS]UCX_SHR_DECC.OPT /OPTIONS"
1406$ IF F$TRNLNM("UCX$IPC_SHR") .NES. ""
1407$ THEN
1408$ TCPIP_LIB = ",SYS$DISK:[-.VMS]UCX_SHR_DECC_LOG.OPT /OPTIONS"
1409$ ELSE
1410$ IF COMPILER .NES. "DECC" .AND. ARCH .EQS. "VAX" THEN -
1411 TCPIP_LIB = ",SYS$DISK:[-.VMS]UCX_SHR_VAXC.OPT /OPTIONS"
1412$ ENDIF
1413$!
1414$! Done with UCX
1415$!
1416$ ENDIF
1417$!
1418$! Check to see if TCPIP was chosen
1419$!
1420$ IF P4.EQS."TCPIP"
1421$ THEN
1422$!
1423$! Set the library to use TCPIP (post UCX).
1424$!
1425$ TCPIP_LIB = ",SYS$DISK:[-.VMS]TCPIP_SHR_DECC.OPT /OPTIONS"
1426$!
1427$! Done with TCPIP
1428$!
1429$ ENDIF
1430$!
1431$! Check to see if NONE was chosen
1432$!
1433$ IF P4.EQS."NONE"
1434$ THEN
1435$!
1436$! Do not use a TCPIP library.
1437$!
1438$ TCPIP_LIB = ""
1439$!
1440$! Done with TCPIP
1441$!
1442$ ENDIF
1443$!
1444$! Print info
1445$!
1446$ WRITE SYS$OUTPUT "TCP/IP library spec: ", TCPIP_LIB- ","
1447$!
1448$! Else The User Entered An Invalid Argument.
1449$!
1450$ ELSE
1451$!
1452$! Tell The User We Don't Know What They Want.
1453$!
1454$ WRITE SYS$OUTPUT ""
1455$ WRITE SYS$OUTPUT "The Option ",P4," Is Invalid. The Valid Options Are:"
1456$ WRITE SYS$OUTPUT ""
1457$ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library."
1458$ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library."
1459$ WRITE SYS$OUTPUT " TCPIP : To link with TCPIP (post UCX) TCP/IP library."
1460$ WRITE SYS$OUTPUT ""
1461$!
1462$! Time To EXIT.
1463$!
1464$ EXIT
1465$!
1466$! Done with TCP/IP libraries
1467$!
1468$ ENDIF
1469$!
1470$! Check if the user wanted to compile just a subset of all the encryption
1471$! methods.
1472$!
1473$ IF P6 .NES. ""
1474$ THEN
1475$ ENCRYPT_TYPES = P6
1476$ ENDIF
1477$!
1478$! Time To RETURN...
1479$!
1480$ RETURN
1481$!
1482$ INITIALISE:
1483$!
1484$! Save old value of the logical name OPENSSL
1485$!
1486$ __SAVE_OPENSSL = F$TRNLNM("OPENSSL","LNM$PROCESS_TABLE")
1487$!
1488$! Save directory information
1489$!
1490$ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;"
1491$ __HERE = F$EDIT(__HERE,"UPCASE")
1492$ __TOP = __HERE - "CRYPTO]"
1493$ __INCLUDE = __TOP + "INCLUDE.OPENSSL]"
1494$!
1495$! Set up the logical name OPENSSL to point at the include directory
1496$!
1497$ DEFINE OPENSSL/NOLOG '__INCLUDE'
1498$!
1499$! Done
1500$!
1501$ RETURN
1502$!
1503$ CLEANUP:
1504$!
1505$! Restore the logical name OPENSSL if it had a value
1506$!
1507$ IF __SAVE_OPENSSL .EQS. ""
1508$ THEN
1509$ DEASSIGN OPENSSL
1510$ ELSE
1511$ DEFINE/NOLOG OPENSSL '__SAVE_OPENSSL'
1512$ ENDIF
1513$!
1514$! Done
1515$!
1516$ RETURN
diff --git a/src/lib/libcrypto/des/asm/des686.pl b/src/lib/libcrypto/des/asm/des686.pl
deleted file mode 100644
index d3ad5d5edd..0000000000
--- a/src/lib/libcrypto/des/asm/des686.pl
+++ /dev/null
@@ -1,230 +0,0 @@
1#!/usr/local/bin/perl
2
3$prog="des686.pl";
4
5# base code is in microsft
6# op dest, source
7# format.
8#
9
10# WILL NOT WORK ANYMORE WITH desboth.pl
11require "desboth.pl";
12
13if ( ($ARGV[0] eq "elf"))
14 { require "x86unix.pl"; }
15elsif ( ($ARGV[0] eq "a.out"))
16 { $aout=1; require "x86unix.pl"; }
17elsif ( ($ARGV[0] eq "sol"))
18 { $sol=1; require "x86unix.pl"; }
19elsif ( ($ARGV[0] eq "cpp"))
20 { $cpp=1; require "x86unix.pl"; }
21elsif ( ($ARGV[0] eq "win32"))
22 { require "x86ms.pl"; }
23else
24 {
25 print STDERR <<"EOF";
26Pick one target type from
27 elf - linux, FreeBSD etc
28 a.out - old linux
29 sol - x86 solaris
30 cpp - format so x86unix.cpp can be used
31 win32 - Windows 95/Windows NT
32EOF
33 exit(1);
34 }
35
36&comment("Don't even think of reading this code");
37&comment("It was automatically generated by $prog");
38&comment("Which is a perl program used to generate the x86 assember for");
39&comment("any of elf, a.out, Win32, or Solaris");
40&comment("It can be found in SSLeay 0.6.5+ or in libdes 3.26+");
41&comment("eric <eay\@cryptsoft.com>");
42&comment("");
43
44&file("dx86xxxx");
45
46$L="edi";
47$R="esi";
48
49&DES_encrypt("DES_encrypt1",1);
50&DES_encrypt("DES_encrypt2",0);
51
52&DES_encrypt3("DES_encrypt3",1);
53&DES_encrypt3("DES_decrypt3",0);
54
55&file_end();
56
57sub DES_encrypt
58 {
59 local($name,$do_ip)=@_;
60
61 &function_begin($name,"EXTRN _DES_SPtrans:DWORD");
62
63 &comment("");
64 &comment("Load the 2 words");
65 &mov("eax",&wparam(0));
66 &mov($L,&DWP(0,"eax","",0));
67 &mov($R,&DWP(4,"eax","",0));
68
69 $ksp=&wparam(1);
70
71 if ($do_ip)
72 {
73 &comment("");
74 &comment("IP");
75 &IP_new($L,$R,"eax");
76 }
77
78 &comment("");
79 &comment("fixup rotate");
80 &rotl($R,3);
81 &rotl($L,3);
82 &exch($L,$R);
83
84 &comment("");
85 &comment("load counter, key_schedule and enc flag");
86 &mov("eax",&wparam(2)); # get encrypt flag
87 &mov("ebp",&wparam(1)); # get ks
88 &cmp("eax","0");
89 &je(&label("start_decrypt"));
90
91 # encrypting part
92
93 for ($i=0; $i<16; $i+=2)
94 {
95 &comment("");
96 &comment("Round $i");
97 &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
98
99 &comment("");
100 &comment("Round ".sprintf("%d",$i+1));
101 &D_ENCRYPT($R,$L,($i+1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
102 }
103 &jmp(&label("end"));
104
105 &set_label("start_decrypt");
106
107 for ($i=15; $i>0; $i-=2)
108 {
109 &comment("");
110 &comment("Round $i");
111 &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
112 &comment("");
113 &comment("Round ".sprintf("%d",$i-1));
114 &D_ENCRYPT($R,$L,($i-1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx");
115 }
116
117 &set_label("end");
118
119 &comment("");
120 &comment("Fixup");
121 &rotr($L,3); # r
122 &rotr($R,3); # l
123
124 if ($do_ip)
125 {
126 &comment("");
127 &comment("FP");
128 &FP_new($R,$L,"eax");
129 }
130
131 &mov("eax",&wparam(0));
132 &mov(&DWP(0,"eax","",0),$L);
133 &mov(&DWP(4,"eax","",0),$R);
134
135 &function_end($name);
136 }
137
138
139# The logic is to load R into 2 registers and operate on both at the same time.
140# We also load the 2 R's into 2 more registers so we can do the 'move word down a byte'
141# while also masking the other copy and doing a lookup. We then also accumulate the
142# L value in 2 registers then combine them at the end.
143sub D_ENCRYPT
144 {
145 local($L,$R,$S,$ks,$desSP,$u,$t,$tmp1,$tmp2,$tmp3)=@_;
146
147 &mov( $u, &DWP(&n2a($S*4),$ks,"",0));
148 &mov( $t, &DWP(&n2a(($S+1)*4),$ks,"",0));
149 &xor( $u, $R );
150 &xor( $t, $R );
151 &rotr( $t, 4 );
152
153 # the numbers at the end of the line are origional instruction order
154 &mov( $tmp2, $u ); # 1 2
155 &mov( $tmp1, $t ); # 1 1
156 &and( $tmp2, "0xfc" ); # 1 4
157 &and( $tmp1, "0xfc" ); # 1 3
158 &shr( $t, 8 ); # 1 5
159 &xor( $L, &DWP("0x100+$desSP",$tmp1,"",0)); # 1 7
160 &shr( $u, 8 ); # 1 6
161 &mov( $tmp1, &DWP(" $desSP",$tmp2,"",0)); # 1 8
162
163 &mov( $tmp2, $u ); # 2 2
164 &xor( $L, $tmp1 ); # 1 9
165 &and( $tmp2, "0xfc" ); # 2 4
166 &mov( $tmp1, $t ); # 2 1
167 &and( $tmp1, "0xfc" ); # 2 3
168 &shr( $t, 8 ); # 2 5
169 &xor( $L, &DWP("0x300+$desSP",$tmp1,"",0)); # 2 7
170 &shr( $u, 8 ); # 2 6
171 &mov( $tmp1, &DWP("0x200+$desSP",$tmp2,"",0)); # 2 8
172 &mov( $tmp2, $u ); # 3 2
173
174 &xor( $L, $tmp1 ); # 2 9
175 &and( $tmp2, "0xfc" ); # 3 4
176
177 &mov( $tmp1, $t ); # 3 1
178 &shr( $u, 8 ); # 3 6
179 &and( $tmp1, "0xfc" ); # 3 3
180 &shr( $t, 8 ); # 3 5
181 &xor( $L, &DWP("0x500+$desSP",$tmp1,"",0)); # 3 7
182 &mov( $tmp1, &DWP("0x400+$desSP",$tmp2,"",0)); # 3 8
183
184 &and( $t, "0xfc" ); # 4 1
185 &xor( $L, $tmp1 ); # 3 9
186
187 &and( $u, "0xfc" ); # 4 2
188 &xor( $L, &DWP("0x700+$desSP",$t,"",0)); # 4 3
189 &xor( $L, &DWP("0x600+$desSP",$u,"",0)); # 4 4
190 }
191
192sub PERM_OP
193 {
194 local($a,$b,$tt,$shift,$mask)=@_;
195
196 &mov( $tt, $a );
197 &shr( $tt, $shift );
198 &xor( $tt, $b );
199 &and( $tt, $mask );
200 &xor( $b, $tt );
201 &shl( $tt, $shift );
202 &xor( $a, $tt );
203 }
204
205sub IP_new
206 {
207 local($l,$r,$tt)=@_;
208
209 &PERM_OP($r,$l,$tt, 4,"0x0f0f0f0f");
210 &PERM_OP($l,$r,$tt,16,"0x0000ffff");
211 &PERM_OP($r,$l,$tt, 2,"0x33333333");
212 &PERM_OP($l,$r,$tt, 8,"0x00ff00ff");
213 &PERM_OP($r,$l,$tt, 1,"0x55555555");
214 }
215
216sub FP_new
217 {
218 local($l,$r,$tt)=@_;
219
220 &PERM_OP($l,$r,$tt, 1,"0x55555555");
221 &PERM_OP($r,$l,$tt, 8,"0x00ff00ff");
222 &PERM_OP($l,$r,$tt, 2,"0x33333333");
223 &PERM_OP($r,$l,$tt,16,"0x0000ffff");
224 &PERM_OP($l,$r,$tt, 4,"0x0f0f0f0f");
225 }
226
227sub n2a
228 {
229 sprintf("%d",$_[0]);
230 }
diff --git a/src/lib/libcrypto/des/des-lib.com b/src/lib/libcrypto/des/des-lib.com
deleted file mode 100644
index 348f1c0470..0000000000
--- a/src/lib/libcrypto/des/des-lib.com
+++ /dev/null
@@ -1,1005 +0,0 @@
1$!
2$! DES-LIB.COM
3$! Written By: Robert Byer
4$! Vice-President
5$! A-Com Computing, Inc.
6$! byer@mail.all-net.net
7$!
8$! Changes by Richard Levitte <richard@levitte.org>
9$!
10$! This command files compiles and creates the
11$! "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" library. The "xxx" denotes the machine
12$! architecture of ALPHA, IA64 or VAX.
13$!
14$! It was re-written to try to determine which "C" compiler to try to use
15$! or the user can specify a compiler in P3.
16$!
17$! Specify one of the following to build just that part, specify "ALL" to
18$! just build everything.
19$!
20$! ALL To Just Build "Everything".
21$! LIBRARY To Just Build The [.xxx.EXE.CRYPTO.DES]LIBDES.OLB Library.
22$! DESTEST To Just Build The [.xxx.EXE.CRYPTO.DES]DESTEST.EXE Program.
23$! SPEED To Just Build The [.xxx.EXE.CRYPTO.DES]SPEED.EXE Program.
24$! RPW To Just Build The [.xxx.EXE.CRYPTO.DES]RPW.EXE Program.
25$! DES To Just Build The [.xxx.EXE.CRYPTO.DES]DES.EXE Program.
26$! DES_OPTS To Just Build The [.xxx.EXE.CRYPTO.DES]DES_OPTS.EXE Program.
27$!
28$! Specify either DEBUG or NODEBUG as P2 to compile with or without
29$! debugging information.
30$!
31$! Specify which compiler at P3 to try to compile under.
32$!
33$! VAXC For VAX C.
34$! DECC For DEC C.
35$! GNUC For GNU C.
36$!
37$! If you don't speficy a compiler, it will try to determine which
38$! "C" compiler to try to use.
39$!
40$! P4, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
41$!
42$!
43$! Make sure we know what architecture we run on.
44$!
45$!
46$! Check Which Architecture We Are Using.
47$!
48$ IF (F$GETSYI("CPU").LT.128)
49$ THEN
50$!
51$! The Architecture Is VAX
52$!
53$ ARCH := VAX
54$!
55$! Else...
56$!
57$ ELSE
58$!
59$! The Architecture Is Alpha, IA64 or whatever comes in the future.
60$!
61$ ARCH = F$EDIT( F$GETSYI( "ARCH_NAME"), "UPCASE")
62$ IF (ARCH .EQS. "") THEN ARCH = "UNK"
63$!
64$! End The Architecture Check.
65$!
66$ ENDIF
67$!
68$! Define The OBJ Directory Name.
69$!
70$ OBJ_DIR := SYS$DISK:[--.'ARCH'.OBJ.CRYPTO.DES]
71$!
72$! Define The EXE Directory Name.
73$!
74$ EXE_DIR :== SYS$DISK:[--.'ARCH'.EXE.CRYPTO.DES]
75$!
76$! Check To Make Sure We Have Valid Command Line Parameters.
77$!
78$ GOSUB CHECK_OPTIONS
79$!
80$! Tell The User What Kind of Machine We Run On.
81$!
82$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine."
83$!
84$! Check To See If The Architecture Specific OBJ Directory Exists.
85$!
86$ IF (F$PARSE(OBJ_DIR).EQS."")
87$ THEN
88$!
89$! It Dosen't Exist, So Create It.
90$!
91$ CREATE/DIR 'OBJ_DIR'
92$!
93$! End The Architecture Specific OBJ Directory Check.
94$!
95$ ENDIF
96$!
97$! Check To See If The Architecture Specific Directory Exists.
98$!
99$ IF (F$PARSE(EXE_DIR).EQS."")
100$ THEN
101$!
102$! It Dosen't Exist, So Create It.
103$!
104$ CREATE/DIR 'EXE_DIR'
105$!
106$! End The Architecture Specific Directory Check.
107$!
108$ ENDIF
109$!
110$! Define The Library Name.
111$!
112$ LIB_NAME := 'EXE_DIR'LIBDES.OLB
113$!
114$! Check To See What We Are To Do.
115$!
116$ IF (BUILDALL.EQS."TRUE")
117$ THEN
118$!
119$! Since Nothing Special Was Specified, Do Everything.
120$!
121$ GOSUB LIBRARY
122$ GOSUB DESTEST
123$ GOSUB SPEED
124$ GOSUB RPW
125$ GOSUB DES
126$ GOSUB DES_OPTS
127$!
128$! Else...
129$!
130$ ELSE
131$!
132$! Build Just What The User Wants Us To Build.
133$!
134$ GOSUB 'BUILDALL'
135$!
136$! End The BUILDALL Check.
137$!
138$ ENDIF
139$!
140$! Time To EXIT.
141$!
142$ EXIT
143$ LIBRARY:
144$!
145$! Tell The User That We Are Compiling.
146$!
147$ WRITE SYS$OUTPUT "Compiling The ",LIB_NAME," Files."
148$!
149$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" Library...
150$!
151$ IF (F$SEARCH(LIB_NAME).EQS."")
152$ THEN
153$!
154$! Guess Not, Create The Library.
155$!
156$ LIBRARY/CREATE/OBJECT 'LIB_NAME'
157$!
158$! End The Library Exist Check.
159$!
160$ ENDIF
161$!
162$! Define The DES Library Files.
163$!
164$ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
165 "ecb3_enc,cfb64enc,cfb64ede,cfb_enc,ofb64ede,"+ -
166 "enc_read,enc_writ,ofb64enc,"+ -
167 "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ -
168 "des_enc,fcrypt_b,read2pwd,"+ -
169 "fcrypt,xcbc_enc,read_pwd,rpc_enc,cbc_cksm,supp"
170$!
171$! Define A File Counter And Set It To "0".
172$!
173$ FILE_COUNTER = 0
174$!
175$! Top Of The File Loop.
176$!
177$ NEXT_FILE:
178$!
179$! O.K, Extract The File Name From The File List.
180$!
181$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",LIB_DES)
182$!
183$! Check To See If We Are At The End Of The File List.
184$!
185$ IF (FILE_NAME.EQS.",") THEN GOTO FILE_DONE
186$!
187$! Increment The Counter.
188$!
189$ FILE_COUNTER = FILE_COUNTER + 1
190$!
191$! Create The Source File Name.
192$!
193$ SOURCE_FILE = "SYS$DISK:[]" + FILE_NAME + ".C"
194$!
195$! Tell The User We Are Compiling The Source File.
196$!
197$ WRITE SYS$OUTPUT " ",FILE_NAME,".C"
198$!
199$! Create The Object File Name.
200$!
201$ OBJECT_FILE = OBJ_DIR + FILE_NAME + "." + ARCH + "OBJ"
202$ ON WARNING THEN GOTO NEXT_FILE
203$!
204$! Check To See If The File We Want To Compile Actually Exists.
205$!
206$ IF (F$SEARCH(SOURCE_FILE).EQS."")
207$ THEN
208$!
209$! Tell The User That The File Dosen't Exist.
210$!
211$ WRITE SYS$OUTPUT ""
212$ WRITE SYS$OUTPUT "The File ",SOURCE_FILE," Dosen't Exist."
213$ WRITE SYS$OUTPUT ""
214$!
215$! Exit The Build.
216$!
217$ EXIT
218$!
219$! End The File Exists Check.
220$!
221$ ENDIF
222$!
223$! Compile The File.
224$!
225$ ON ERROR THEN GOTO NEXT_FILE
226$ CC/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
227$!
228$! Add It To The Library.
229$!
230$ LIBRARY/REPLACE/OBJECT 'LIB_NAME' 'OBJECT_FILE'
231$!
232$! Time To Clean Up The Object File.
233$!
234$ DELETE 'OBJECT_FILE';*
235$!
236$! Go Back And Do It Again.
237$!
238$ GOTO NEXT_FILE
239$!
240$! All Done With This Library Part.
241$!
242$ FILE_DONE:
243$!
244$! Tell The User That We Are All Done.
245$!
246$ WRITE SYS$OUTPUT "Library ",LIB_NAME," Built."
247$!
248$! All Done, Time To Return.
249$!
250$ RETURN
251$!
252$! Compile The DESTEST Program.
253$!
254$ DESTEST:
255$!
256$! Check To See If We Have The Proper Libraries.
257$!
258$ GOSUB LIB_CHECK
259$!
260$! Check To See If We Have A Linker Option File.
261$!
262$ GOSUB CHECK_OPT_FILE
263$!
264$! Check To See If The File We Want To Compile Actually Exists.
265$!
266$ IF (F$SEARCH("SYS$DISK:[]DESTEST.C").EQS."")
267$ THEN
268$!
269$! Tell The User That The File Dosen't Exist.
270$!
271$ WRITE SYS$OUTPUT ""
272$ WRITE SYS$OUTPUT "The File DESTEST.C Dosen't Exist."
273$ WRITE SYS$OUTPUT ""
274$!
275$! Exit The Build.
276$!
277$ EXIT
278$!
279$! End The DESTEST.C File Check.
280$!
281$ ENDIF
282$!
283$! Tell The User What We Are Building.
284$!
285$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DESTEST.EXE"
286$!
287$! Compile The DESTEST Program.
288$!
289$ CC/OBJECT='OBJ_DIR'DESTEST.OBJ SYS$DISK:[]DESTEST.C
290$!
291$! Link The DESTEST Program.
292$!
293$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DESTEST.EXE -
294 'OBJ_DIR'DESTEST.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
295$!
296$! All Done, Time To Return.
297$!
298$ RETURN
299$!
300$! Compile The SPEED Program.
301$!
302$ SPEED:
303$!
304$! Check To See If We Have The Proper Libraries.
305$!
306$ GOSUB LIB_CHECK
307$!
308$! Check To See If We Have A Linker Option File.
309$!
310$ GOSUB CHECK_OPT_FILE
311$!
312$! Check To See If The File We Want To Compile Actually Exists.
313$!
314$ IF (F$SEARCH("SYS$DISK:[]SPEED.C").EQS."")
315$ THEN
316$!
317$! Tell The User That The File Dosen't Exist.
318$!
319$ WRITE SYS$OUTPUT ""
320$ WRITE SYS$OUTPUT "The File SPEED.C Dosen't Exist."
321$ WRITE SYS$OUTPUT ""
322$!
323$! Exit The Build.
324$!
325$ EXIT
326$!
327$! End The SPEED.C File Check.
328$!
329$ ENDIF
330$!
331$! Tell The User What We Are Building.
332$!
333$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"SPEED.EXE"
334$!
335$! Compile The SPEED Program.
336$!
337$ CC/OBJECT='OBJ_DIR'SPEED.OBJ SYS$DISK:[]SPEED.C
338$!
339$! Link The SPEED Program.
340$!
341$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'SPEED.EXE -
342 'OBJ_DIR'SPEED.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
343$!
344$! All Done, Time To Return.
345$!
346$ RETURN
347$!
348$! Compile The RPW Program.
349$!
350$ RPW:
351$!
352$! Check To See If We Have The Proper Libraries.
353$!
354$ GOSUB LIB_CHECK
355$!
356$! Check To See If We Have A Linker Option File.
357$!
358$ GOSUB CHECK_OPT_FILE
359$!
360$! Check To See If The File We Want To Compile Actually Exists.
361$!
362$ IF (F$SEARCH("SYS$DISK:[]RPW.C").EQS."")
363$ THEN
364$!
365$! Tell The User That The File Dosen't Exist.
366$!
367$ WRITE SYS$OUTPUT ""
368$ WRITE SYS$OUTPUT "The File RPW.C Dosen't Exist."
369$ WRITE SYS$OUTPUT ""
370$!
371$! Exit The Build.
372$!
373$ EXIT
374$!
375$! End The RPW.C File Check.
376$!
377$ ENDIF
378$!
379$! Tell The User What We Are Building.
380$!
381$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"RPW.EXE"
382$!
383$! Compile The RPW Program.
384$!
385$ CC/OBJECT='OBJ_DIR'RPW.OBJ SYS$DISK:[]RPW.C
386$!
387$! Link The RPW Program.
388$!
389$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'RPW.EXE -
390 'OBJ_DIR'RPW.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
391$!
392$! All Done, Time To Return.
393$!
394$ RETURN
395$!
396$! Compile The DES Program.
397$!
398$ DES:
399$!
400$! Check To See If We Have The Proper Libraries.
401$!
402$ GOSUB LIB_CHECK
403$!
404$! Check To See If We Have A Linker Option File.
405$!
406$ GOSUB CHECK_OPT_FILE
407$!
408$! Check To See If The File We Want To Compile Actually Exists.
409$!
410$ IF (F$SEARCH("SYS$DISK:[]DES.C").EQS."")
411$ THEN
412$!
413$! Tell The User That The File Dosen't Exist.
414$!
415$ WRITE SYS$OUTPUT ""
416$ WRITE SYS$OUTPUT "The File DES.C Dosen't Exist."
417$ WRITE SYS$OUTPUT ""
418$!
419$! Exit The Build.
420$!
421$ EXIT
422$!
423$! End The DES.C File Check.
424$!
425$ ENDIF
426$!
427$! Tell The User What We Are Building.
428$!
429$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DES.EXE"
430$!
431$! Compile The DES Program.
432$!
433$ CC/OBJECT='OBJ_DIR'DES.OBJ SYS$DISK:[]DES.C
434$ CC/OBJECT='OBJ_DIR'DES.OBJ SYS$DISK:[]CBC3_ENC.C
435$!
436$! Link The DES Program.
437$!
438$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DES.EXE -
439 'OBJ_DIR'DES.OBJ,'OBJ_DIR'CBC3_ENC.OBJ,-
440 'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
441$!
442$! All Done, Time To Return.
443$!
444$ RETURN
445$!
446$! Compile The DES_OPTS Program.
447$!
448$ DES_OPTS:
449$!
450$! Check To See If We Have The Proper Libraries.
451$!
452$ GOSUB LIB_CHECK
453$!
454$! Check To See If We Have A Linker Option File.
455$!
456$ GOSUB CHECK_OPT_FILE
457$!
458$! Check To See If The File We Want To Compile Actually Exists.
459$!
460$ IF (F$SEARCH("SYS$DISK:[]DES_OPTS.C").EQS."")
461$ THEN
462$!
463$! Tell The User That The File Dosen't Exist.
464$!
465$ WRITE SYS$OUTPUT ""
466$ WRITE SYS$OUTPUT "The File DES_OPTS.C Dosen't Exist."
467$ WRITE SYS$OUTPUT ""
468$!
469$! Exit The Build.
470$!
471$ EXIT
472$!
473$! End The DES_OPTS.C File Check.
474$!
475$ ENDIF
476$!
477$! Tell The User What We Are Building.
478$!
479$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DES_OPTS.EXE"
480$!
481$! Compile The DES_OPTS Program.
482$!
483$ CC/OBJECT='OBJ_DIR'DES_OPTS.OBJ SYS$DISK:[]DES_OPTS.C
484$!
485$! Link The DES_OPTS Program.
486$!
487$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DES_OPTS.EXE -
488 'OBJ_DIR'DES_OPTS.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
489$!
490$! All Done, Time To Return.
491$!
492$ RETURN
493$ EXIT
494$!
495$! Check For The Link Option FIle.
496$!
497$ CHECK_OPT_FILE:
498$!
499$! Check To See If We Need To Make A VAX C Option File.
500$!
501$ IF (COMPILER.EQS."VAXC")
502$ THEN
503$!
504$! Check To See If We Already Have A VAX C Linker Option File.
505$!
506$ IF (F$SEARCH(OPT_FILE).EQS."")
507$ THEN
508$!
509$! We Need A VAX C Linker Option File.
510$!
511$ CREATE 'OPT_FILE'
512$DECK
513!
514! Default System Options File To Link Agianst
515! The Sharable VAX C Runtime Library.
516!
517SYS$SHARE:VAXCRTL.EXE/SHARE
518$EOD
519$!
520$! End The Option File Check.
521$!
522$ ENDIF
523$!
524$! End The VAXC Check.
525$!
526$ ENDIF
527$!
528$! Check To See If We Need A GNU C Option File.
529$!
530$ IF (COMPILER.EQS."GNUC")
531$ THEN
532$!
533$! Check To See If We Already Have A GNU C Linker Option File.
534$!
535$ IF (F$SEARCH(OPT_FILE).EQS."")
536$ THEN
537$!
538$! We Need A GNU C Linker Option File.
539$!
540$ CREATE 'OPT_FILE'
541$DECK
542!
543! Default System Options File To Link Agianst
544! The Sharable C Runtime Library.
545!
546GNU_CC:[000000]GCCLIB/LIBRARY
547SYS$SHARE:VAXCRTL/SHARE
548$EOD
549$!
550$! End The Option File Check.
551$!
552$ ENDIF
553$!
554$! End The GNU C Check.
555$!
556$ ENDIF
557$!
558$! Check To See If We Need A DEC C Option File.
559$!
560$ IF (COMPILER.EQS."DECC")
561$ THEN
562$!
563$! Check To See If We Already Have A DEC C Linker Option File.
564$!
565$ IF (F$SEARCH(OPT_FILE).EQS."")
566$ THEN
567$!
568$! Figure Out If We Need An non-VAX Or A VAX Linker Option File.
569$!
570$ IF (F$GETSYI("CPU").LT.128)
571$ THEN
572$!
573$! We Need A DEC C Linker Option File For VAX.
574$!
575$ CREATE 'OPT_FILE'
576$DECK
577!
578! Default System Options File To Link Agianst
579! The Sharable DEC C Runtime Library.
580!
581SYS$SHARE:DECC$SHR.EXE/SHARE
582$EOD
583$!
584$! Else...
585$!
586$ ELSE
587$!
588$! Create The non-VAX Linker Option File.
589$!
590$ CREATE 'OPT_FILE'
591$DECK
592!
593! Default System Options File For non-VAX To Link Agianst
594! The Sharable C Runtime Library.
595!
596SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE
597SYS$SHARE:CMA$OPEN_RTL/SHARE
598$EOD
599$!
600$! End The DEC C Option File Check.
601$!
602$ ENDIF
603$!
604$! End The Option File Search.
605$!
606$ ENDIF
607$!
608$! End The DEC C Check.
609$!
610$ ENDIF
611$!
612$! Tell The User What Linker Option File We Are Using.
613$!
614$ WRITE SYS$OUTPUT "Using Linker Option File ",OPT_FILE,"."
615$!
616$! Time To RETURN.
617$!
618$ RETURN
619$!
620$! Library Check.
621$!
622$ LIB_CHECK:
623$!
624$! Look For The Library LIBDES.OLB.
625$!
626$ IF (F$SEARCH(LIB_NAME).EQS."")
627$ THEN
628$!
629$! Tell The User We Can't Find The [.xxx.CRYPTO.DES]LIBDES.OLB Library.
630$!
631$ WRITE SYS$OUTPUT ""
632$ WRITE SYS$OUTPUT "Can't Find The Library ",LIB_NAME,"."
633$ WRITE SYS$OUTPUT "We Can't Link Without It."
634$ WRITE SYS$OUTPUT ""
635$!
636$! Since We Can't Link Without It, Exit.
637$!
638$ EXIT
639$ ENDIF
640$!
641$! Time To Return.
642$!
643$ RETURN
644$!
645$! Check The User's Options.
646$!
647$ CHECK_OPTIONS:
648$!
649$! Check To See If We Are To "Just Build Everything".
650$!
651$ IF (P1.EQS."ALL")
652$ THEN
653$!
654$! P1 Is "ALL", So Build Everything.
655$!
656$ BUILDALL = "TRUE"
657$!
658$! Else...
659$!
660$ ELSE
661$!
662$! Else, Check To See If P1 Has A Valid Argument.
663$!
664$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."DESTEST").OR.(P1.EQS."SPEED") -
665 .OR.(P1.EQS."RPW").OR.(P1.EQS."DES").OR.(P1.EQS."DES_OPTS")
666$ THEN
667$!
668$! A Valid Argument.
669$!
670$ BUILDALL = P1
671$!
672$! Else...
673$!
674$ ELSE
675$!
676$! Tell The User We Don't Know What They Want.
677$!
678$ WRITE SYS$OUTPUT ""
679$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
680$ WRITE SYS$OUTPUT ""
681$ WRITE SYS$OUTPUT " ALL : Just Build Everything."
682$ WRITE SYS$OUTPUT " LIBRARY : To Compile Just The [.xxx.EXE.CRYPTO.DES]LIBDES.OLB Library."
683$ WRITE SYS$OUTPUT " DESTEST : To Compile Just The [.xxx.EXE.CRYPTO.DES]DESTEST.EXE Program."
684$ WRITE SYS$OUTPUT " SPEED : To Compile Just The [.xxx.EXE.CRYPTO.DES]SPEED.EXE Program."
685$ WRITE SYS$OUTPUT " RPW : To Compile Just The [.xxx.EXE.CRYPTO.DES]RPW.EXE Program."
686$ WRITE SYS$OUTPUT " DES : To Compile Just The [.xxx.EXE.CRYPTO.DES]DES.EXE Program."
687$ WRITE SYS$OUTPUT " DES_OPTS : To Compile Just The [.xxx.EXE.CRYTPO.DES]DES_OPTS.EXE Program."
688$ WRITE SYS$OUTPUT ""
689$ WRITE SYS$OUTPUT " Where 'xxx' Stands For: "
690$ WRITE SYS$OUTPUT ""
691$ WRITE SYS$OUTPUT " ALPHA : Alpha Architecture."
692$ WRITE SYS$OUTPUT " IA64 : IA64 Architecture."
693$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
694$ WRITE SYS$OUTPUT ""
695$!
696$! Time To EXIT.
697$!
698$ EXIT
699$!
700$! End The Valid Argument Check.
701$!
702$ ENDIF
703$!
704$! End The P1 Check.
705$!
706$ ENDIF
707$!
708$! Check To See If We Are To Compile Without Debugger Information.
709$!
710$ IF (P2.EQS."NODEBUG")
711$ THEN
712$!
713$! P2 Is Blank, So Compile Without Debugger Information.
714$!
715$ DEBUGGER = "NODEBUG"
716$ TRACEBACK = "NOTRACEBACK"
717$ GCC_OPTIMIZE = "OPTIMIZE"
718$ CC_OPTIMIZE = "OPTIMIZE"
719$ WRITE SYS$OUTPUT "No Debugger Information Will Be Produced During Compile."
720$ WRITE SYS$OUTPUT "Compiling With Compiler Optimization."
721$!
722$! Else...
723$!
724$ ELSE
725$!
726$! Check To See If We Are To Compile With Debugger Information.
727$!
728$ IF (P2.EQS."DEBUG")
729$ THEN
730$!
731$! Compile With Debugger Information.
732$!
733$ DEBUGGER = "DEBUG"
734$ TRACEBACK = "TRACEBACK"
735$ GCC_OPTIMIZE = "NOOPTIMIZE"
736$ CC_OPTIMIZE = "NOOPTIMIZE"
737$ WRITE SYS$OUTPUT "Debugger Information Will Be Produced During Compile."
738$ WRITE SYS$OUTPUT "Compiling Without Compiler Optimization."
739$!
740$! Else...
741$!
742$ ELSE
743$!
744$! Tell The User Entered An Invalid Option..
745$!
746$ WRITE SYS$OUTPUT ""
747$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
748$ WRITE SYS$OUTPUT ""
749$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
750$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
751$ WRITE SYS$OUTPUT ""
752$!
753$! Time To EXIT.
754$!
755$ EXIT
756$!
757$! End The Valid Argument Check.
758$!
759$ ENDIF
760$!
761$! End The P2 Check.
762$!
763$ ENDIF
764$!
765$! Special Threads For OpenVMS v7.1 Or Later.
766$!
767$! Written By: Richard Levitte
768$! richard@levitte.org
769$!
770$!
771$! Check To See If We Have A Option For P4.
772$!
773$ IF (P4.EQS."")
774$ THEN
775$!
776$! Get The Version Of VMS We Are Using.
777$!
778$ ISSEVEN := ""
779$ TMP = F$ELEMENT(0,"-",F$EXTRACT(1,4,F$GETSYI("VERSION")))
780$ TMP = F$INTEGER(F$ELEMENT(0,".",TMP)+F$ELEMENT(1,".",TMP))
781$!
782$! Check To See If The VMS Version Is v7.1 Or Later.
783$!
784$ IF (TMP.GE.71)
785$ THEN
786$!
787$! We Have OpenVMS v7.1 Or Later, So Use The Special Threads.
788$!
789$ ISSEVEN := ,PTHREAD_USE_D4
790$!
791$! End The VMS Version Check.
792$!
793$ ENDIF
794$!
795$! End The P4 Check.
796$!
797$ ENDIF
798$!
799$! Check To See If P3 Is Blank.
800$!
801$ IF (P3.EQS."")
802$ THEN
803$!
804$! O.K., The User Didn't Specify A Compiler, Let's Try To
805$! Find Out Which One To Use.
806$!
807$! Check To See If We Have GNU C.
808$!
809$ IF (F$TRNLNM("GNU_CC").NES."")
810$ THEN
811$!
812$! Looks Like GNUC, Set To Use GNUC.
813$!
814$ P3 = "GNUC"
815$!
816$! Else...
817$!
818$ ELSE
819$!
820$! Check To See If We Have VAXC Or DECC.
821$!
822$ IF (ARCH.NES."VAX").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."")
823$ THEN
824$!
825$! Looks Like DECC, Set To Use DECC.
826$!
827$ P3 = "DECC"
828$!
829$! Else...
830$!
831$ ELSE
832$!
833$! Looks Like VAXC, Set To Use VAXC.
834$!
835$ P3 = "VAXC"
836$!
837$! End The VAXC Compiler Check.
838$!
839$ ENDIF
840$!
841$! End The DECC & VAXC Compiler Check.
842$!
843$ ENDIF
844$!
845$! End The Compiler Check.
846$!
847$ ENDIF
848$!
849$! Set Up Initial CC Definitions, Possibly With User Ones
850$!
851$ CCDEFS = ""
852$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = USER_CCDEFS
853$ CCEXTRAFLAGS = ""
854$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
855$ CCDISABLEWARNINGS = ""
856$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
857 CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS
858$!
859$! Check To See If The User Entered A Valid Paramter.
860$!
861$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC")
862$ THEN
863$!
864$! Check To See If The User Wanted DECC.
865$!
866$ IF (P3.EQS."DECC")
867$ THEN
868$!
869$! Looks Like DECC, Set To Use DECC.
870$!
871$ COMPILER = "DECC"
872$!
873$! Tell The User We Are Using DECC.
874$!
875$ WRITE SYS$OUTPUT "Using DECC 'C' Compiler."
876$!
877$! Use DECC...
878$!
879$ CC = "CC"
880$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
881 THEN CC = "CC/DECC"
882$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
883 "/NOLIST/PREFIX=ALL" + CCEXTRAFLAGS
884$!
885$! Define The Linker Options File Name.
886$!
887$ OPT_FILE = "''EXE_DIR'VAX_DECC_OPTIONS.OPT"
888$!
889$! End DECC Check.
890$!
891$ ENDIF
892$!
893$! Check To See If We Are To Use VAXC.
894$!
895$ IF (P3.EQS."VAXC")
896$ THEN
897$!
898$! Looks Like VAXC, Set To Use VAXC.
899$!
900$ COMPILER = "VAXC"
901$!
902$! Tell The User We Are Using VAX C.
903$!
904$ WRITE SYS$OUTPUT "Using VAXC 'C' Compiler."
905$!
906$! Compile Using VAXC.
907$!
908$ CC = "CC"
909$ IF ARCH.NES."VAX"
910$ THEN
911$ WRITE SYS$OUTPUT "There is no VAX C on ''ARCH'!"
912$ EXIT
913$ ENDIF
914$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
915$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
916$ CCDEFS = """VAXC""," + CCDEFS
917$!
918$! Define <sys> As SYS$COMMON:[SYSLIB]
919$!
920$ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB]
921$!
922$! Define The Linker Options File Name.
923$!
924$ OPT_FILE = "''EXE_DIR'VAX_VAXC_OPTIONS.OPT"
925$!
926$! End VAXC Check
927$!
928$ ENDIF
929$!
930$! Check To See If We Are To Use GNU C.
931$!
932$ IF (P3.EQS."GNUC")
933$ THEN
934$!
935$! Looks Like GNUC, Set To Use GNUC.
936$!
937$ COMPILER = "GNUC"
938$!
939$! Tell The User We Are Using GNUC.
940$!
941$ WRITE SYS$OUTPUT "Using GNU 'C' Compiler."
942$!
943$! Use GNU C...
944$!
945$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
946$!
947$! Define The Linker Options File Name.
948$!
949$ OPT_FILE = "''EXE_DIR'VAX_GNUC_OPTIONS.OPT"
950$!
951$! End The GNU C Check.
952$!
953$ ENDIF
954$!
955$! Set up default defines
956$!
957$ CCDEFS = """FLAT_INC=1""," + CCDEFS
958$!
959$! Finish up the definition of CC.
960$!
961$ IF COMPILER .EQS. "DECC"
962$ THEN
963$ IF CCDISABLEWARNINGS .EQS. ""
964$ THEN
965$ CC4DISABLEWARNINGS = "DOLLARID"
966$ ELSE
967$ CC4DISABLEWARNINGS = CCDISABLEWARNINGS + ",DOLLARID"
968$ CCDISABLEWARNINGS = "/WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))"
969$ ENDIF
970$ CC4DISABLEWARNINGS = "/WARNING=(DISABLE=(" + CC4DISABLEWARNINGS + "))"
971$ ELSE
972$ CCDISABLEWARNINGS = ""
973$ CC4DISABLEWARNINGS = ""
974$ ENDIF
975$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS
976$!
977$! Show user the result
978$!
979$ WRITE SYS$OUTPUT "Main Compiling Command: ",CC
980$!
981$! Else The User Entered An Invalid Argument.
982$!
983$ ELSE
984$!
985$! Tell The User We Don't Know What They Want.
986$!
987$ WRITE SYS$OUTPUT ""
988$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
989$ WRITE SYS$OUTPUT ""
990$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
991$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
992$ WRITE SYS$OUTPUT " GNUC : To Compile With GNU C."
993$ WRITE SYS$OUTPUT ""
994$!
995$! Time To EXIT.
996$!
997$ EXIT
998$!
999$! End The P3 Check.
1000$!
1001$ ENDIF
1002$!
1003$! Time To RETURN...
1004$!
1005$ RETURN
diff --git a/src/lib/libcrypto/dso/dso_beos.c b/src/lib/libcrypto/dso/dso_beos.c
new file mode 100644
index 0000000000..553966e699
--- /dev/null
+++ b/src/lib/libcrypto/dso/dso_beos.c
@@ -0,0 +1,270 @@
1/* dso_beos.c */
2/* Written by Marcin Konicki (ahwayakchih@neoni.net) for the OpenSSL
3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 2000 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include <string.h>
61#include "cryptlib.h"
62#include <openssl/dso.h>
63
64#if !defined(OPENSSL_SYS_BEOS)
65DSO_METHOD *DSO_METHOD_beos(void)
66 {
67 return NULL;
68 }
69#else
70
71#include <kernel/image.h>
72
73static int beos_load(DSO *dso);
74static int beos_unload(DSO *dso);
75static void *beos_bind_var(DSO *dso, const char *symname);
76static DSO_FUNC_TYPE beos_bind_func(DSO *dso, const char *symname);
77#if 0
78static int beos_unbind_var(DSO *dso, char *symname, void *symptr);
79static int beos_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr);
80static int beos_init(DSO *dso);
81static int beos_finish(DSO *dso);
82static long beos_ctrl(DSO *dso, int cmd, long larg, void *parg);
83#endif
84static char *beos_name_converter(DSO *dso, const char *filename);
85
86static DSO_METHOD dso_meth_beos = {
87 "OpenSSL 'beos' shared library method",
88 beos_load,
89 beos_unload,
90 beos_bind_var,
91 beos_bind_func,
92/* For now, "unbind" doesn't exist */
93#if 0
94 NULL, /* unbind_var */
95 NULL, /* unbind_func */
96#endif
97 NULL, /* ctrl */
98 beos_name_converter,
99 NULL, /* init */
100 NULL /* finish */
101 };
102
103DSO_METHOD *DSO_METHOD_beos(void)
104 {
105 return(&dso_meth_beos);
106 }
107
108/* For this DSO_METHOD, our meth_data STACK will contain;
109 * (i) a pointer to the handle (image_id) returned from
110 * load_add_on().
111 */
112
113static int beos_load(DSO *dso)
114 {
115 image_id id;
116 /* See applicable comments from dso_dl.c */
117 char *filename = DSO_convert_filename(dso, NULL);
118
119 if(filename == NULL)
120 {
121 DSOerr(DSO_F_BEOS_LOAD,DSO_R_NO_FILENAME);
122 goto err;
123 }
124 id = load_add_on(filename);
125 if(id < 1)
126 {
127 DSOerr(DSO_F_BEOS_LOAD,DSO_R_LOAD_FAILED);
128 ERR_add_error_data(3, "filename(", filename, ")");
129 goto err;
130 }
131 if(!sk_push(dso->meth_data, (char *)id))
132 {
133 DSOerr(DSO_F_BEOS_LOAD,DSO_R_STACK_ERROR);
134 goto err;
135 }
136 /* Success */
137 dso->loaded_filename = filename;
138 return(1);
139err:
140 /* Cleanup !*/
141 if(filename != NULL)
142 OPENSSL_free(filename);
143 if(id > 0)
144 unload_add_on(id);
145 return(0);
146 }
147
148static int beos_unload(DSO *dso)
149 {
150 image_id id;
151 if(dso == NULL)
152 {
153 DSOerr(DSO_F_BEOS_UNLOAD,ERR_R_PASSED_NULL_PARAMETER);
154 return(0);
155 }
156 if(sk_num(dso->meth_data) < 1)
157 return(1);
158 id = (image_id)sk_pop(dso->meth_data);
159 if(id < 1)
160 {
161 DSOerr(DSO_F_BEOS_UNLOAD,DSO_R_NULL_HANDLE);
162 return(0);
163 }
164 if(unload_add_on(id) != B_OK)
165 {
166 DSOerr(DSO_F_BEOS_UNLOAD,DSO_R_UNLOAD_FAILED);
167 /* We should push the value back onto the stack in
168 * case of a retry. */
169 sk_push(dso->meth_data, (char *)id);
170 return(0);
171 }
172 return(1);
173 }
174
175static void *beos_bind_var(DSO *dso, const char *symname)
176 {
177 image_id id;
178 void *sym;
179
180 if((dso == NULL) || (symname == NULL))
181 {
182 DSOerr(DSO_F_BEOS_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER);
183 return(NULL);
184 }
185 if(sk_num(dso->meth_data) < 1)
186 {
187 DSOerr(DSO_F_BEOS_BIND_VAR,DSO_R_STACK_ERROR);
188 return(NULL);
189 }
190 id = (image_id)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
191 if(id < 1)
192 {
193 DSOerr(DSO_F_BEOS_BIND_VAR,DSO_R_NULL_HANDLE);
194 return(NULL);
195 }
196 if(get_image_symbol(id, symname, B_SYMBOL_TYPE_DATA, &sym) != B_OK)
197 {
198 DSOerr(DSO_F_BEOS_BIND_VAR,DSO_R_SYM_FAILURE);
199 ERR_add_error_data(3, "symname(", symname, ")");
200 return(NULL);
201 }
202 return(sym);
203 }
204
205static DSO_FUNC_TYPE beos_bind_func(DSO *dso, const char *symname)
206 {
207 image_id id;
208 void *sym;
209
210 if((dso == NULL) || (symname == NULL))
211 {
212 DSOerr(DSO_F_BEOS_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER);
213 return(NULL);
214 }
215 if(sk_num(dso->meth_data) < 1)
216 {
217 DSOerr(DSO_F_BEOS_BIND_FUNC,DSO_R_STACK_ERROR);
218 return(NULL);
219 }
220 id = (image_id)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
221 if(id < 1)
222 {
223 DSOerr(DSO_F_BEOS_BIND_FUNC,DSO_R_NULL_HANDLE);
224 return(NULL);
225 }
226 if(get_image_symbol(id, symname, B_SYMBOL_TYPE_TEXT, &sym) != B_OK)
227 {
228 DSOerr(DSO_F_BEOS_BIND_FUNC,DSO_R_SYM_FAILURE);
229 ERR_add_error_data(3, "symname(", symname, ")");
230 return(NULL);
231 }
232 return((DSO_FUNC_TYPE)sym);
233 }
234
235/* This one is the same as the one in dlfcn */
236static char *beos_name_converter(DSO *dso, const char *filename)
237 {
238 char *translated;
239 int len, rsize, transform;
240
241 len = strlen(filename);
242 rsize = len + 1;
243 transform = (strstr(filename, "/") == NULL);
244 if(transform)
245 {
246 /* We will convert this to "%s.so" or "lib%s.so" */
247 rsize += 3; /* The length of ".so" */
248 if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
249 rsize += 3; /* The length of "lib" */
250 }
251 translated = OPENSSL_malloc(rsize);
252 if(translated == NULL)
253 {
254 DSOerr(DSO_F_BEOS_NAME_CONVERTER,
255 DSO_R_NAME_TRANSLATION_FAILED);
256 return(NULL);
257 }
258 if(transform)
259 {
260 if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
261 sprintf(translated, "lib%s.so", filename);
262 else
263 sprintf(translated, "%s.so", filename);
264 }
265 else
266 sprintf(translated, "%s", filename);
267 return(translated);
268 }
269
270#endif
diff --git a/src/lib/libcrypto/dyn_lck.c b/src/lib/libcrypto/dyn_lck.c
deleted file mode 100644
index 7f82c41264..0000000000
--- a/src/lib/libcrypto/dyn_lck.c
+++ /dev/null
@@ -1,428 +0,0 @@
1/* crypto/cryptlib.c */
2/* ====================================================================
3 * Copyright (c) 1998-2003 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
56 * All rights reserved.
57 *
58 * This package is an SSL implementation written
59 * by Eric Young (eay@cryptsoft.com).
60 * The implementation was written so as to conform with Netscapes SSL.
61 *
62 * This library is free for commercial and non-commercial use as long as
63 * the following conditions are aheared to. The following conditions
64 * apply to all code found in this distribution, be it the RC4, RSA,
65 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
66 * included with this distribution is covered by the same copyright terms
67 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
68 *
69 * Copyright remains Eric Young's, and as such any Copyright notices in
70 * the code are not to be removed.
71 * If this package is used in a product, Eric Young should be given attribution
72 * as the author of the parts of the library used.
73 * This can be in the form of a textual message at program startup or
74 * in documentation (online or textual) provided with the package.
75 *
76 * Redistribution and use in source and binary forms, with or without
77 * modification, are permitted provided that the following conditions
78 * are met:
79 * 1. Redistributions of source code must retain the copyright
80 * notice, this list of conditions and the following disclaimer.
81 * 2. Redistributions in binary form must reproduce the above copyright
82 * notice, this list of conditions and the following disclaimer in the
83 * documentation and/or other materials provided with the distribution.
84 * 3. All advertising materials mentioning features or use of this software
85 * must display the following acknowledgement:
86 * "This product includes cryptographic software written by
87 * Eric Young (eay@cryptsoft.com)"
88 * The word 'cryptographic' can be left out if the rouines from the library
89 * being used are not cryptographic related :-).
90 * 4. If you include any Windows specific code (or a derivative thereof) from
91 * the apps directory (application code) you must include an acknowledgement:
92 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
93 *
94 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
95 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
97 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
98 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
99 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
100 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
101 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
102 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
103 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
104 * SUCH DAMAGE.
105 *
106 * The licence and distribution terms for any publically available version or
107 * derivative of this code cannot be changed. i.e. this code cannot simply be
108 * copied and put under another distribution licence
109 * [including the GNU Public Licence.]
110 */
111/* ====================================================================
112 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
113 * ECDH support in OpenSSL originally developed by
114 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
115 */
116
117#include "cryptlib.h"
118#include <openssl/safestack.h>
119
120#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
121static double SSLeay_MSVC5_hack=0.0; /* and for VC1.5 */
122#endif
123
124DECLARE_STACK_OF(CRYPTO_dynlock)
125IMPLEMENT_STACK_OF(CRYPTO_dynlock)
126
127/* real #defines in crypto.h, keep these upto date */
128static const char* const lock_names[CRYPTO_NUM_LOCKS] =
129 {
130 "<<ERROR>>",
131 "err",
132 "ex_data",
133 "x509",
134 "x509_info",
135 "x509_pkey",
136 "x509_crl",
137 "x509_req",
138 "dsa",
139 "rsa",
140 "evp_pkey",
141 "x509_store",
142 "ssl_ctx",
143 "ssl_cert",
144 "ssl_session",
145 "ssl_sess_cert",
146 "ssl",
147 "ssl_method",
148 "rand",
149 "rand2",
150 "debug_malloc",
151 "BIO",
152 "gethostbyname",
153 "getservbyname",
154 "readdir",
155 "RSA_blinding",
156 "dh",
157 "debug_malloc2",
158 "dso",
159 "dynlock",
160 "engine",
161 "ui",
162 "ecdsa",
163 "ec",
164 "ecdh",
165 "bn",
166 "ec_pre_comp",
167 "store",
168 "comp",
169#ifndef OPENSSL_FIPS
170# if CRYPTO_NUM_LOCKS != 39
171# error "Inconsistency between crypto.h and cryptlib.c"
172# endif
173#else
174 "fips",
175 "fips2",
176# if CRYPTO_NUM_LOCKS != 41
177# error "Inconsistency between crypto.h and cryptlib.c"
178# endif
179#endif
180 };
181
182/* This is for applications to allocate new type names in the non-dynamic
183 array of lock names. These are numbered with positive numbers. */
184static STACK *app_locks=NULL;
185
186/* For applications that want a more dynamic way of handling threads, the
187 following stack is used. These are externally numbered with negative
188 numbers. */
189static STACK_OF(CRYPTO_dynlock) *dyn_locks=NULL;
190
191
192static struct CRYPTO_dynlock_value *(MS_FAR *dynlock_create_callback)
193 (const char *file,int line)=NULL;
194static void (MS_FAR *dynlock_lock_callback)(int mode,
195 struct CRYPTO_dynlock_value *l, const char *file,int line)=NULL;
196static void (MS_FAR *dynlock_destroy_callback)(struct CRYPTO_dynlock_value *l,
197 const char *file,int line)=NULL;
198
199int CRYPTO_get_new_lockid(char *name)
200 {
201 char *str;
202 int i;
203
204#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16)
205 /* A hack to make Visual C++ 5.0 work correctly when linking as
206 * a DLL using /MT. Without this, the application cannot use
207 * and floating point printf's.
208 * It also seems to be needed for Visual C 1.5 (win16) */
209 SSLeay_MSVC5_hack=(double)name[0]*(double)name[1];
210#endif
211
212 if ((app_locks == NULL) && ((app_locks=sk_new_null()) == NULL))
213 {
214 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
215 return(0);
216 }
217 if ((str=BUF_strdup(name)) == NULL)
218 {
219 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID,ERR_R_MALLOC_FAILURE);
220 return(0);
221 }
222 i=sk_push(app_locks,str);
223 if (!i)
224 OPENSSL_free(str);
225 else
226 i+=CRYPTO_NUM_LOCKS; /* gap of one :-) */
227 return(i);
228 }
229
230int CRYPTO_get_new_dynlockid(void)
231 {
232 int i = 0;
233 CRYPTO_dynlock *pointer = NULL;
234
235 if (dynlock_create_callback == NULL)
236 {
237 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK);
238 return(0);
239 }
240 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
241 if ((dyn_locks == NULL)
242 && ((dyn_locks=sk_CRYPTO_dynlock_new_null()) == NULL))
243 {
244 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
245 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
246 return(0);
247 }
248 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
249
250 pointer = (CRYPTO_dynlock *)OPENSSL_malloc(sizeof(CRYPTO_dynlock));
251 if (pointer == NULL)
252 {
253 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
254 return(0);
255 }
256 pointer->references = 1;
257 pointer->data = dynlock_create_callback(__FILE__,__LINE__);
258 if (pointer->data == NULL)
259 {
260 OPENSSL_free(pointer);
261 CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID,ERR_R_MALLOC_FAILURE);
262 return(0);
263 }
264
265 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
266 /* First, try to find an existing empty slot */
267 i=sk_CRYPTO_dynlock_find(dyn_locks,NULL);
268 /* If there was none, push, thereby creating a new one */
269 if (i == -1)
270 /* Since sk_push() returns the number of items on the
271 stack, not the location of the pushed item, we need
272 to transform the returned number into a position,
273 by decreasing it. */
274 i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1;
275 else
276 /* If we found a place with a NULL pointer, put our pointer
277 in it. */
278 (void)sk_CRYPTO_dynlock_set(dyn_locks,i,pointer);
279 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
280
281 if (i == -1)
282 {
283 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
284 OPENSSL_free(pointer);
285 }
286 else
287 i += 1; /* to avoid 0 */
288 return -i;
289 }
290
291void CRYPTO_destroy_dynlockid(int i)
292 {
293 CRYPTO_dynlock *pointer = NULL;
294 if (i)
295 i = -i-1;
296 if (dynlock_destroy_callback == NULL)
297 return;
298
299 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
300
301 if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks))
302 {
303 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
304 return;
305 }
306 pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
307 if (pointer != NULL)
308 {
309 --pointer->references;
310#ifdef REF_CHECK
311 if (pointer->references < 0)
312 {
313 fprintf(stderr,"CRYPTO_destroy_dynlockid, bad reference count\n");
314 abort();
315 }
316 else
317#endif
318 if (pointer->references <= 0)
319 {
320 (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);
321 }
322 else
323 pointer = NULL;
324 }
325 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
326
327 if (pointer)
328 {
329 dynlock_destroy_callback(pointer->data,__FILE__,__LINE__);
330 OPENSSL_free(pointer);
331 }
332 }
333
334struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i)
335 {
336 CRYPTO_dynlock *pointer = NULL;
337 if (i)
338 i = -i-1;
339
340 CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
341
342 if (dyn_locks != NULL && i < sk_CRYPTO_dynlock_num(dyn_locks))
343 pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
344 if (pointer)
345 pointer->references++;
346
347 CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
348
349 if (pointer)
350 return pointer->data;
351 return NULL;
352 }
353
354struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))
355 (const char *file,int line)
356 {
357 return(dynlock_create_callback);
358 }
359
360void (*CRYPTO_get_dynlock_lock_callback(void))(int mode,
361 struct CRYPTO_dynlock_value *l, const char *file,int line)
362 {
363 return(dynlock_lock_callback);
364 }
365
366void (*CRYPTO_get_dynlock_destroy_callback(void))
367 (struct CRYPTO_dynlock_value *l, const char *file,int line)
368 {
369 return(dynlock_destroy_callback);
370 }
371
372void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*func)
373 (const char *file, int line))
374 {
375 dynlock_create_callback=func;
376 }
377
378static void do_dynlock(int mode, int type, const char *file, int line)
379 {
380 if (dynlock_lock_callback != NULL)
381 {
382 struct CRYPTO_dynlock_value *pointer
383 = CRYPTO_get_dynlock_value(type);
384
385 OPENSSL_assert(pointer != NULL);
386
387 dynlock_lock_callback(mode, pointer, file, line);
388
389 CRYPTO_destroy_dynlockid(type);
390 }
391 }
392
393void CRYPTO_set_dynlock_lock_callback(void (*func)(int mode,
394 struct CRYPTO_dynlock_value *l, const char *file, int line))
395 {
396 /* Set callback so CRYPTO_lock() can now handle dynamic locks.
397 * This is OK because at this point and application shouldn't be using
398 * OpenSSL from multiple threads because it is setting up the locking
399 * callbacks.
400 */
401 static int done = 0;
402 if (!done)
403 {
404 int_CRYPTO_set_do_dynlock_callback(do_dynlock);
405 done = 1;
406 }
407
408 dynlock_lock_callback=func;
409 }
410
411void CRYPTO_set_dynlock_destroy_callback(void (*func)
412 (struct CRYPTO_dynlock_value *l, const char *file, int line))
413 {
414 dynlock_destroy_callback=func;
415 }
416
417const char *CRYPTO_get_lock_name(int type)
418 {
419 if (type < 0)
420 return("dynamic");
421 else if (type < CRYPTO_NUM_LOCKS)
422 return(lock_names[type]);
423 else if (type-CRYPTO_NUM_LOCKS > sk_num(app_locks))
424 return("ERROR");
425 else
426 return(sk_value(app_locks,type-CRYPTO_NUM_LOCKS));
427 }
428
diff --git a/src/lib/libcrypto/ec/ecp_recp.c b/src/lib/libcrypto/ec/ecp_recp.c
deleted file mode 100644
index fec843b5c8..0000000000
--- a/src/lib/libcrypto/ec/ecp_recp.c
+++ /dev/null
@@ -1,133 +0,0 @@
1/* crypto/ec/ecp_recp.c */
2/* ====================================================================
3 * Copyright (c) 1998-2001 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56#include "ec_lcl.h"
57
58#if 0
59const EC_METHOD *EC_GFp_recp_method(void)
60 {
61 static const EC_METHOD ret = {
62 ec_GFp_recp_group_init,
63 ec_GFp_recp_group_finish,
64 ec_GFp_recp_group_clear_finish,
65 ec_GFp_recp_group_copy,
66 ec_GFp_recp_group_set_curve_GFp,
67 ec_GFp_simple_group_get_curve_GFp,
68 ec_GFp_simple_group_set_generator,
69 ec_GFp_simple_group_get0_generator,
70 ec_GFp_simple_group_get_order,
71 ec_GFp_simple_group_get_cofactor,
72 ec_GFp_simple_point_init,
73 ec_GFp_simple_point_finish,
74 ec_GFp_simple_point_clear_finish,
75 ec_GFp_simple_point_copy,
76 ec_GFp_simple_point_set_to_infinity,
77 ec_GFp_simple_set_Jprojective_coordinates_GFp,
78 ec_GFp_simple_get_Jprojective_coordinates_GFp,
79 ec_GFp_simple_point_set_affine_coordinates_GFp,
80 ec_GFp_simple_point_get_affine_coordinates_GFp,
81 ec_GFp_simple_set_compressed_coordinates_GFp,
82 ec_GFp_simple_point2oct,
83 ec_GFp_simple_oct2point,
84 ec_GFp_simple_add,
85 ec_GFp_simple_dbl,
86 ec_GFp_simple_invert,
87 ec_GFp_simple_is_at_infinity,
88 ec_GFp_simple_is_on_curve,
89 ec_GFp_simple_cmp,
90 ec_GFp_simple_make_affine,
91 ec_GFp_simple_points_make_affine,
92 ec_GFp_recp_field_mul,
93 ec_GFp_recp_field_sqr,
94 0 /* field_encode */,
95 0 /* field_decode */,
96 0 /* field_set_to_one */ };
97
98 return &ret;
99 }
100#endif
101
102int ec_GFp_recp_group_init(EC_GROUP *group)
103 {
104 int ok;
105
106 ok = ec_GFp_simple_group_init(group);
107 group->field_data1 = NULL;
108 return ok;
109 }
110
111
112int ec_GFp_recp_group_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
113/* TODO */
114
115
116void ec_GFp_recp_group_finish(EC_GROUP *group);
117/* TODO */
118
119
120void ec_GFp_recp_group_clear_finish(EC_GROUP *group);
121/* TODO */
122
123
124int ec_GFp_recp_group_copy(EC_GROUP *dest, const EC_GROUP *src);
125/* TODO */
126
127
128int ec_GFp_recp_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
129/* TODO */
130
131
132int ec_GFp_recp_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
133/* TODO */
diff --git a/src/lib/libcrypto/ecdh/Makefile b/src/lib/libcrypto/ecdh/Makefile
new file mode 100644
index 0000000000..ba05fea05c
--- /dev/null
+++ b/src/lib/libcrypto/ecdh/Makefile
@@ -0,0 +1,116 @@
1#
2# crypto/ecdh/Makefile
3#
4
5DIR= ecdh
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g -Wall
10MAKEFILE= Makefile
11AR= ar r
12
13CFLAGS= $(INCLUDES) $(CFLAG)
14
15GENERAL=Makefile
16TEST=ecdhtest.c
17APPS=
18
19LIB=$(TOP)/libcrypto.a
20LIBSRC= ech_lib.c ech_ossl.c ech_key.c ech_err.c
21
22LIBOBJ= ech_lib.o ech_ossl.o ech_key.o ech_err.o
23
24SRC= $(LIBSRC)
25
26EXHEADER= ecdh.h
27HEADER= ech_locl.h $(EXHEADER)
28
29ALL= $(GENERAL) $(SRC) $(HEADER)
30
31top:
32 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
33
34all: lib
35
36lib: $(LIBOBJ)
37 $(AR) $(LIB) $(LIBOBJ)
38 $(RANLIB) $(LIB) || echo Never mind.
39 @touch lib
40
41files:
42 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
43
44links:
45 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
46 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
47 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
48
49install:
50 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
51 @headerlist="$(EXHEADER)"; for i in $$headerlist; \
52 do \
53 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
54 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
55 done;
56
57tags:
58 ctags $(SRC)
59
60tests:
61
62lint:
63 lint -DLINT $(INCLUDES) $(SRC)>fluff
64
65depend:
66 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
67 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
68
69dclean:
70 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
71 mv -f Makefile.new $(MAKEFILE)
72
73clean:
74 rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
75
76# DO NOT DELETE THIS LINE -- make depend depends on it.
77
78ech_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
79ech_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
80ech_err.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
81ech_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
82ech_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
83ech_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
84ech_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
85ech_err.o: ech_err.c
86ech_key.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
87ech_key.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88ech_key.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
89ech_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
90ech_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
91ech_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
92ech_key.o: ech_key.c ech_locl.h
93ech_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
94ech_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
95ech_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
96ech_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
97ech_lib.o: ../../include/openssl/engine.h ../../include/openssl/err.h
98ech_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
99ech_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
100ech_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
101ech_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
102ech_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
103ech_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
104ech_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
105ech_lib.o: ech_lib.c ech_locl.h
106ech_ossl.o: ../../e_os.h ../../include/openssl/asn1.h
107ech_ossl.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
108ech_ossl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
109ech_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
110ech_ossl.o: ../../include/openssl/ecdh.h ../../include/openssl/err.h
111ech_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
112ech_ossl.o: ../../include/openssl/opensslconf.h
113ech_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
114ech_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
115ech_ossl.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
116ech_ossl.o: ../cryptlib.h ech_locl.h ech_ossl.c
diff --git a/src/lib/libcrypto/ecdh/ecdhtest.c b/src/lib/libcrypto/ecdh/ecdhtest.c
new file mode 100644
index 0000000000..823d7baa65
--- /dev/null
+++ b/src/lib/libcrypto/ecdh/ecdhtest.c
@@ -0,0 +1,374 @@
1/* crypto/ecdh/ecdhtest.c */
2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 *
5 * The Elliptic Curve Public-Key Crypto Library (ECC Code) included
6 * herein is developed by SUN MICROSYSTEMS, INC., and is contributed
7 * to the OpenSSL project.
8 *
9 * The ECC Code is licensed pursuant to the OpenSSL open source
10 * license provided below.
11 *
12 * The ECDH software is originally written by Douglas Stebila of
13 * Sun Microsystems Laboratories.
14 *
15 */
16/* ====================================================================
17 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
21 * are met:
22 *
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 *
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in
28 * the documentation and/or other materials provided with the
29 * distribution.
30 *
31 * 3. All advertising materials mentioning features or use of this
32 * software must display the following acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
35 *
36 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
37 * endorse or promote products derived from this software without
38 * prior written permission. For written permission, please contact
39 * openssl-core@openssl.org.
40 *
41 * 5. Products derived from this software may not be called "OpenSSL"
42 * nor may "OpenSSL" appear in their names without prior written
43 * permission of the OpenSSL Project.
44 *
45 * 6. Redistributions of any form whatsoever must retain the following
46 * acknowledgment:
47 * "This product includes software developed by the OpenSSL Project
48 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
51 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
54 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
56 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
57 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
59 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
60 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
61 * OF THE POSSIBILITY OF SUCH DAMAGE.
62 * ====================================================================
63 *
64 * This product includes cryptographic software written by Eric Young
65 * (eay@cryptsoft.com). This product includes software written by Tim
66 * Hudson (tjh@cryptsoft.com).
67 *
68 */
69
70#include <stdio.h>
71#include <stdlib.h>
72#include <string.h>
73
74#include "../e_os.h"
75
76#include <openssl/opensslconf.h> /* for OPENSSL_NO_ECDH */
77#include <openssl/crypto.h>
78#include <openssl/bio.h>
79#include <openssl/bn.h>
80#include <openssl/objects.h>
81#include <openssl/rand.h>
82#include <openssl/sha.h>
83#include <openssl/err.h>
84
85#ifdef OPENSSL_NO_ECDH
86int main(int argc, char *argv[])
87{
88 printf("No ECDH support\n");
89 return(0);
90}
91#else
92#include <openssl/ec.h>
93#include <openssl/ecdh.h>
94
95#ifdef OPENSSL_SYS_WIN16
96#define MS_CALLBACK _far _loadds
97#else
98#define MS_CALLBACK
99#endif
100
101#if 0
102static void MS_CALLBACK cb(int p, int n, void *arg);
103#endif
104
105static const char rnd_seed[] = "string to make the random number generator think it has entropy";
106
107
108static const int KDF1_SHA1_len = 20;
109static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen)
110 {
111#ifndef OPENSSL_NO_SHA
112 if (*outlen < SHA_DIGEST_LENGTH)
113 return NULL;
114 else
115 *outlen = SHA_DIGEST_LENGTH;
116 return SHA1(in, inlen, out);
117#else
118 return NULL;
119#endif
120 }
121
122
123static int test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out)
124 {
125 EC_KEY *a=NULL;
126 EC_KEY *b=NULL;
127 BIGNUM *x_a=NULL, *y_a=NULL,
128 *x_b=NULL, *y_b=NULL;
129 char buf[12];
130 unsigned char *abuf=NULL,*bbuf=NULL;
131 int i,alen,blen,aout,bout,ret=0;
132 const EC_GROUP *group;
133
134 a = EC_KEY_new_by_curve_name(nid);
135 b = EC_KEY_new_by_curve_name(nid);
136 if (a == NULL || b == NULL)
137 goto err;
138
139 group = EC_KEY_get0_group(a);
140
141 if ((x_a=BN_new()) == NULL) goto err;
142 if ((y_a=BN_new()) == NULL) goto err;
143 if ((x_b=BN_new()) == NULL) goto err;
144 if ((y_b=BN_new()) == NULL) goto err;
145
146 BIO_puts(out,"Testing key generation with ");
147 BIO_puts(out,text);
148#ifdef NOISY
149 BIO_puts(out,"\n");
150#else
151 (void)BIO_flush(out);
152#endif
153
154 if (!EC_KEY_generate_key(a)) goto err;
155
156 if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field)
157 {
158 if (!EC_POINT_get_affine_coordinates_GFp(group,
159 EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err;
160 }
161#ifndef OPENSSL_NO_EC2M
162 else
163 {
164 if (!EC_POINT_get_affine_coordinates_GF2m(group,
165 EC_KEY_get0_public_key(a), x_a, y_a, ctx)) goto err;
166 }
167#endif
168#ifdef NOISY
169 BIO_puts(out," pri 1=");
170 BN_print(out,a->priv_key);
171 BIO_puts(out,"\n pub 1=");
172 BN_print(out,x_a);
173 BIO_puts(out,",");
174 BN_print(out,y_a);
175 BIO_puts(out,"\n");
176#else
177 BIO_printf(out," .");
178 (void)BIO_flush(out);
179#endif
180
181 if (!EC_KEY_generate_key(b)) goto err;
182
183 if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field)
184 {
185 if (!EC_POINT_get_affine_coordinates_GFp(group,
186 EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err;
187 }
188#ifndef OPENSSL_NO_EC2M
189 else
190 {
191 if (!EC_POINT_get_affine_coordinates_GF2m(group,
192 EC_KEY_get0_public_key(b), x_b, y_b, ctx)) goto err;
193 }
194#endif
195
196#ifdef NOISY
197 BIO_puts(out," pri 2=");
198 BN_print(out,b->priv_key);
199 BIO_puts(out,"\n pub 2=");
200 BN_print(out,x_b);
201 BIO_puts(out,",");
202 BN_print(out,y_b);
203 BIO_puts(out,"\n");
204#else
205 BIO_printf(out,".");
206 (void)BIO_flush(out);
207#endif
208
209 alen=KDF1_SHA1_len;
210 abuf=(unsigned char *)OPENSSL_malloc(alen);
211 aout=ECDH_compute_key(abuf,alen,EC_KEY_get0_public_key(b),a,KDF1_SHA1);
212
213#ifdef NOISY
214 BIO_puts(out," key1 =");
215 for (i=0; i<aout; i++)
216 {
217 sprintf(buf,"%02X",abuf[i]);
218 BIO_puts(out,buf);
219 }
220 BIO_puts(out,"\n");
221#else
222 BIO_printf(out,".");
223 (void)BIO_flush(out);
224#endif
225
226 blen=KDF1_SHA1_len;
227 bbuf=(unsigned char *)OPENSSL_malloc(blen);
228 bout=ECDH_compute_key(bbuf,blen,EC_KEY_get0_public_key(a),b,KDF1_SHA1);
229
230#ifdef NOISY
231 BIO_puts(out," key2 =");
232 for (i=0; i<bout; i++)
233 {
234 sprintf(buf,"%02X",bbuf[i]);
235 BIO_puts(out,buf);
236 }
237 BIO_puts(out,"\n");
238#else
239 BIO_printf(out,".");
240 (void)BIO_flush(out);
241#endif
242
243 if ((aout < 4) || (bout != aout) || (memcmp(abuf,bbuf,aout) != 0))
244 {
245#ifndef NOISY
246 BIO_printf(out, " failed\n\n");
247 BIO_printf(out, "key a:\n");
248 BIO_printf(out, "private key: ");
249 BN_print(out, EC_KEY_get0_private_key(a));
250 BIO_printf(out, "\n");
251 BIO_printf(out, "public key (x,y): ");
252 BN_print(out, x_a);
253 BIO_printf(out, ",");
254 BN_print(out, y_a);
255 BIO_printf(out, "\nkey b:\n");
256 BIO_printf(out, "private key: ");
257 BN_print(out, EC_KEY_get0_private_key(b));
258 BIO_printf(out, "\n");
259 BIO_printf(out, "public key (x,y): ");
260 BN_print(out, x_b);
261 BIO_printf(out, ",");
262 BN_print(out, y_b);
263 BIO_printf(out, "\n");
264 BIO_printf(out, "generated key a: ");
265 for (i=0; i<bout; i++)
266 {
267 sprintf(buf, "%02X", bbuf[i]);
268 BIO_puts(out, buf);
269 }
270 BIO_printf(out, "\n");
271 BIO_printf(out, "generated key b: ");
272 for (i=0; i<aout; i++)
273 {
274 sprintf(buf, "%02X", abuf[i]);
275 BIO_puts(out,buf);
276 }
277 BIO_printf(out, "\n");
278#endif
279 fprintf(stderr,"Error in ECDH routines\n");
280 ret=0;
281 }
282 else
283 {
284#ifndef NOISY
285 BIO_printf(out, " ok\n");
286#endif
287 ret=1;
288 }
289err:
290 ERR_print_errors_fp(stderr);
291
292 if (abuf != NULL) OPENSSL_free(abuf);
293 if (bbuf != NULL) OPENSSL_free(bbuf);
294 if (x_a) BN_free(x_a);
295 if (y_a) BN_free(y_a);
296 if (x_b) BN_free(x_b);
297 if (y_b) BN_free(y_b);
298 if (b) EC_KEY_free(b);
299 if (a) EC_KEY_free(a);
300 return(ret);
301 }
302
303int main(int argc, char *argv[])
304 {
305 BN_CTX *ctx=NULL;
306 int ret=1;
307 BIO *out;
308
309 CRYPTO_malloc_debug_init();
310 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
311 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
312
313#ifdef OPENSSL_SYS_WIN32
314 CRYPTO_malloc_init();
315#endif
316
317 RAND_seed(rnd_seed, sizeof rnd_seed);
318
319 out=BIO_new(BIO_s_file());
320 if (out == NULL) EXIT(1);
321 BIO_set_fp(out,stdout,BIO_NOCLOSE);
322
323 if ((ctx=BN_CTX_new()) == NULL) goto err;
324
325 /* NIST PRIME CURVES TESTS */
326 if (!test_ecdh_curve(NID_X9_62_prime192v1, "NIST Prime-Curve P-192", ctx, out)) goto err;
327 if (!test_ecdh_curve(NID_secp224r1, "NIST Prime-Curve P-224", ctx, out)) goto err;
328 if (!test_ecdh_curve(NID_X9_62_prime256v1, "NIST Prime-Curve P-256", ctx, out)) goto err;
329 if (!test_ecdh_curve(NID_secp384r1, "NIST Prime-Curve P-384", ctx, out)) goto err;
330 if (!test_ecdh_curve(NID_secp521r1, "NIST Prime-Curve P-521", ctx, out)) goto err;
331#ifndef OPENSSL_NO_EC2M
332 /* NIST BINARY CURVES TESTS */
333 if (!test_ecdh_curve(NID_sect163k1, "NIST Binary-Curve K-163", ctx, out)) goto err;
334 if (!test_ecdh_curve(NID_sect163r2, "NIST Binary-Curve B-163", ctx, out)) goto err;
335 if (!test_ecdh_curve(NID_sect233k1, "NIST Binary-Curve K-233", ctx, out)) goto err;
336 if (!test_ecdh_curve(NID_sect233r1, "NIST Binary-Curve B-233", ctx, out)) goto err;
337 if (!test_ecdh_curve(NID_sect283k1, "NIST Binary-Curve K-283", ctx, out)) goto err;
338 if (!test_ecdh_curve(NID_sect283r1, "NIST Binary-Curve B-283", ctx, out)) goto err;
339 if (!test_ecdh_curve(NID_sect409k1, "NIST Binary-Curve K-409", ctx, out)) goto err;
340 if (!test_ecdh_curve(NID_sect409r1, "NIST Binary-Curve B-409", ctx, out)) goto err;
341 if (!test_ecdh_curve(NID_sect571k1, "NIST Binary-Curve K-571", ctx, out)) goto err;
342 if (!test_ecdh_curve(NID_sect571r1, "NIST Binary-Curve B-571", ctx, out)) goto err;
343#endif
344
345 ret = 0;
346
347err:
348 ERR_print_errors_fp(stderr);
349 if (ctx) BN_CTX_free(ctx);
350 BIO_free(out);
351 CRYPTO_cleanup_all_ex_data();
352 ERR_remove_thread_state(NULL);
353 CRYPTO_mem_leaks_fp(stderr);
354 EXIT(ret);
355 return(ret);
356 }
357
358#if 0
359static void MS_CALLBACK cb(int p, int n, void *arg)
360 {
361 char c='*';
362
363 if (p == 0) c='.';
364 if (p == 1) c='+';
365 if (p == 2) c='*';
366 if (p == 3) c='\n';
367 BIO_write((BIO *)arg,&c,1);
368 (void)BIO_flush((BIO *)arg);
369#ifdef LINT
370 p=n;
371#endif
372 }
373#endif
374#endif
diff --git a/src/lib/libcrypto/ecdh/ech_ossl.c b/src/lib/libcrypto/ecdh/ech_ossl.c
new file mode 100644
index 0000000000..4a30628fbc
--- /dev/null
+++ b/src/lib/libcrypto/ecdh/ech_ossl.c
@@ -0,0 +1,215 @@
1/* crypto/ecdh/ech_ossl.c */
2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 *
5 * The Elliptic Curve Public-Key Crypto Library (ECC Code) included
6 * herein is developed by SUN MICROSYSTEMS, INC., and is contributed
7 * to the OpenSSL project.
8 *
9 * The ECC Code is licensed pursuant to the OpenSSL open source
10 * license provided below.
11 *
12 * The ECDH software is originally written by Douglas Stebila of
13 * Sun Microsystems Laboratories.
14 *
15 */
16/* ====================================================================
17 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
21 * are met:
22 *
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 *
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in
28 * the documentation and/or other materials provided with the
29 * distribution.
30 *
31 * 3. All advertising materials mentioning features or use of this
32 * software must display the following acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
35 *
36 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
37 * endorse or promote products derived from this software without
38 * prior written permission. For written permission, please contact
39 * openssl-core@OpenSSL.org.
40 *
41 * 5. Products derived from this software may not be called "OpenSSL"
42 * nor may "OpenSSL" appear in their names without prior written
43 * permission of the OpenSSL Project.
44 *
45 * 6. Redistributions of any form whatsoever must retain the following
46 * acknowledgment:
47 * "This product includes software developed by the OpenSSL Project
48 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
51 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
54 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
56 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
57 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
59 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
60 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
61 * OF THE POSSIBILITY OF SUCH DAMAGE.
62 * ====================================================================
63 *
64 * This product includes cryptographic software written by Eric Young
65 * (eay@cryptsoft.com). This product includes software written by Tim
66 * Hudson (tjh@cryptsoft.com).
67 *
68 */
69
70
71#include <string.h>
72#include <limits.h>
73
74#include "cryptlib.h"
75
76#include "ech_locl.h"
77#include <openssl/err.h>
78#include <openssl/sha.h>
79#include <openssl/obj_mac.h>
80#include <openssl/bn.h>
81
82static int ecdh_compute_key(void *out, size_t len, const EC_POINT *pub_key,
83 EC_KEY *ecdh,
84 void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen));
85
86static ECDH_METHOD openssl_ecdh_meth = {
87 "OpenSSL ECDH method",
88 ecdh_compute_key,
89#if 0
90 NULL, /* init */
91 NULL, /* finish */
92#endif
93 0, /* flags */
94 NULL /* app_data */
95};
96
97const ECDH_METHOD *ECDH_OpenSSL(void)
98 {
99 return &openssl_ecdh_meth;
100 }
101
102
103/* This implementation is based on the following primitives in the IEEE 1363 standard:
104 * - ECKAS-DH1
105 * - ECSVDP-DH
106 * Finally an optional KDF is applied.
107 */
108static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
109 EC_KEY *ecdh,
110 void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen))
111 {
112 BN_CTX *ctx;
113 EC_POINT *tmp=NULL;
114 BIGNUM *x=NULL, *y=NULL;
115 const BIGNUM *priv_key;
116 const EC_GROUP* group;
117 int ret= -1;
118 size_t buflen, len;
119 unsigned char *buf=NULL;
120
121 if (outlen > INT_MAX)
122 {
123 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE); /* sort of, anyway */
124 return -1;
125 }
126
127 if ((ctx = BN_CTX_new()) == NULL) goto err;
128 BN_CTX_start(ctx);
129 x = BN_CTX_get(ctx);
130 y = BN_CTX_get(ctx);
131
132 priv_key = EC_KEY_get0_private_key(ecdh);
133 if (priv_key == NULL)
134 {
135 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_NO_PRIVATE_VALUE);
136 goto err;
137 }
138
139 group = EC_KEY_get0_group(ecdh);
140 if ((tmp=EC_POINT_new(group)) == NULL)
141 {
142 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE);
143 goto err;
144 }
145
146 if (!EC_POINT_mul(group, tmp, NULL, pub_key, priv_key, ctx))
147 {
148 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_POINT_ARITHMETIC_FAILURE);
149 goto err;
150 }
151
152 if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field)
153 {
154 if (!EC_POINT_get_affine_coordinates_GFp(group, tmp, x, y, ctx))
155 {
156 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_POINT_ARITHMETIC_FAILURE);
157 goto err;
158 }
159 }
160#ifndef OPENSSL_NO_EC2M
161 else
162 {
163 if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, y, ctx))
164 {
165 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_POINT_ARITHMETIC_FAILURE);
166 goto err;
167 }
168 }
169#endif
170
171 buflen = (EC_GROUP_get_degree(group) + 7)/8;
172 len = BN_num_bytes(x);
173 if (len > buflen)
174 {
175 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_INTERNAL_ERROR);
176 goto err;
177 }
178 if ((buf = OPENSSL_malloc(buflen)) == NULL)
179 {
180 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE);
181 goto err;
182 }
183
184 memset(buf, 0, buflen - len);
185 if (len != (size_t)BN_bn2bin(x, buf + buflen - len))
186 {
187 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_BN_LIB);
188 goto err;
189 }
190
191 if (KDF != 0)
192 {
193 if (KDF(buf, buflen, out, &outlen) == NULL)
194 {
195 ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ECDH_R_KDF_FAILED);
196 goto err;
197 }
198 ret = outlen;
199 }
200 else
201 {
202 /* no KDF, just copy as much as we can */
203 if (outlen > buflen)
204 outlen = buflen;
205 memcpy(out, buf, outlen);
206 ret = outlen;
207 }
208
209err:
210 if (tmp) EC_POINT_free(tmp);
211 if (ctx) BN_CTX_end(ctx);
212 if (ctx) BN_CTX_free(ctx);
213 if (buf) OPENSSL_free(buf);
214 return(ret);
215 }
diff --git a/src/lib/libcrypto/ecdsa/Makefile b/src/lib/libcrypto/ecdsa/Makefile
new file mode 100644
index 0000000000..e89e0c010c
--- /dev/null
+++ b/src/lib/libcrypto/ecdsa/Makefile
@@ -0,0 +1,140 @@
1#
2# crypto/ecdsa/Makefile
3#
4
5DIR= ecdsa
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g -Wall
10MAKEFILE= Makefile
11AR= ar r
12
13CFLAGS= $(INCLUDES) $(CFLAG)
14
15GENERAL=Makefile
16TEST=ecdsatest.c
17APPS=
18
19LIB=$(TOP)/libcrypto.a
20LIBSRC= ecs_lib.c ecs_asn1.c ecs_ossl.c ecs_sign.c ecs_vrf.c ecs_err.c
21
22LIBOBJ= ecs_lib.o ecs_asn1.o ecs_ossl.o ecs_sign.o ecs_vrf.o ecs_err.o
23
24SRC= $(LIBSRC)
25
26EXHEADER= ecdsa.h
27HEADER= ecs_locl.h $(EXHEADER)
28
29ALL= $(GENERAL) $(SRC) $(HEADER)
30
31top:
32 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
33
34all: lib
35
36lib: $(LIBOBJ)
37 $(AR) $(LIB) $(LIBOBJ)
38 $(RANLIB) $(LIB) || echo Never mind.
39 @touch lib
40
41files:
42 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
43
44links:
45 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
46 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
47 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
48
49install:
50 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
51 @headerlist="$(EXHEADER)"; for i in $$headerlist; \
52 do \
53 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
54 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
55 done;
56
57tags:
58 ctags $(SRC)
59
60tests:
61
62lint:
63 lint -DLINT $(INCLUDES) $(SRC)>fluff
64
65depend:
66 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
67 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
68
69dclean:
70 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
71 mv -f Makefile.new $(MAKEFILE)
72
73clean:
74 rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
75
76# DO NOT DELETE THIS LINE -- make depend depends on it.
77
78ecs_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
79ecs_asn1.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
80ecs_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
81ecs_asn1.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
82ecs_asn1.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
83ecs_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
84ecs_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
85ecs_asn1.o: ../../include/openssl/symhacks.h ecs_asn1.c ecs_locl.h
86ecs_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
87ecs_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
88ecs_err.o: ../../include/openssl/ec.h ../../include/openssl/ecdsa.h
89ecs_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
90ecs_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
91ecs_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
92ecs_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
93ecs_err.o: ecs_err.c
94ecs_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
95ecs_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
96ecs_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
97ecs_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
98ecs_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
99ecs_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
100ecs_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
101ecs_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
102ecs_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
103ecs_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
104ecs_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
105ecs_lib.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
106ecs_lib.o: ../../include/openssl/x509_vfy.h ecs_lib.c ecs_locl.h
107ecs_ossl.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
108ecs_ossl.o: ../../include/openssl/bn.h ../../include/openssl/crypto.h
109ecs_ossl.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
110ecs_ossl.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
111ecs_ossl.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
112ecs_ossl.o: ../../include/openssl/opensslconf.h
113ecs_ossl.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
114ecs_ossl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
115ecs_ossl.o: ../../include/openssl/symhacks.h ecs_locl.h ecs_ossl.c
116ecs_sign.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
117ecs_sign.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
118ecs_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
119ecs_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
120ecs_sign.o: ../../include/openssl/engine.h ../../include/openssl/evp.h
121ecs_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
122ecs_sign.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
123ecs_sign.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
124ecs_sign.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
125ecs_sign.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
126ecs_sign.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
127ecs_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
128ecs_sign.o: ecs_locl.h ecs_sign.c
129ecs_vrf.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
130ecs_vrf.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
131ecs_vrf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
132ecs_vrf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
133ecs_vrf.o: ../../include/openssl/engine.h ../../include/openssl/evp.h
134ecs_vrf.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
135ecs_vrf.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
136ecs_vrf.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
137ecs_vrf.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
138ecs_vrf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
139ecs_vrf.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
140ecs_vrf.o: ../../include/openssl/x509_vfy.h ecs_locl.h ecs_vrf.c
diff --git a/src/lib/libcrypto/ecdsa/ecdsatest.c b/src/lib/libcrypto/ecdsa/ecdsatest.c
new file mode 100644
index 0000000000..537bb30362
--- /dev/null
+++ b/src/lib/libcrypto/ecdsa/ecdsatest.c
@@ -0,0 +1,572 @@
1/* crypto/ecdsa/ecdsatest.c */
2/*
3 * Written by Nils Larsch for the OpenSSL project.
4 */
5/* ====================================================================
6 * Copyright (c) 2000-2005 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58/* ====================================================================
59 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
60 *
61 * Portions of the attached software ("Contribution") are developed by
62 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
63 *
64 * The Contribution is licensed pursuant to the OpenSSL open source
65 * license provided above.
66 *
67 * The elliptic curve binary polynomial software is originally written by
68 * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
69 *
70 */
71
72#include <stdio.h>
73#include <stdlib.h>
74#include <string.h>
75
76#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_ECDSA is defined */
77
78#ifdef OPENSSL_NO_ECDSA
79int main(int argc, char * argv[])
80 {
81 puts("Elliptic curves are disabled.");
82 return 0;
83 }
84#else
85
86#include <openssl/crypto.h>
87#include <openssl/bio.h>
88#include <openssl/evp.h>
89#include <openssl/bn.h>
90#include <openssl/ecdsa.h>
91#ifndef OPENSSL_NO_ENGINE
92#include <openssl/engine.h>
93#endif
94#include <openssl/err.h>
95#include <openssl/rand.h>
96
97static const char rnd_seed[] = "string to make the random number generator "
98 "think it has entropy";
99
100/* declaration of the test functions */
101int x9_62_tests(BIO *);
102int x9_62_test_internal(BIO *out, int nid, const char *r, const char *s);
103int test_builtin(BIO *);
104
105/* functions to change the RAND_METHOD */
106int change_rand(void);
107int restore_rand(void);
108int fbytes(unsigned char *buf, int num);
109
110RAND_METHOD fake_rand;
111const RAND_METHOD *old_rand;
112
113int change_rand(void)
114 {
115 /* save old rand method */
116 if ((old_rand = RAND_get_rand_method()) == NULL)
117 return 0;
118
119 fake_rand.seed = old_rand->seed;
120 fake_rand.cleanup = old_rand->cleanup;
121 fake_rand.add = old_rand->add;
122 fake_rand.status = old_rand->status;
123 /* use own random function */
124 fake_rand.bytes = fbytes;
125 fake_rand.pseudorand = old_rand->bytes;
126 /* set new RAND_METHOD */
127 if (!RAND_set_rand_method(&fake_rand))
128 return 0;
129 return 1;
130 }
131
132int restore_rand(void)
133 {
134 if (!RAND_set_rand_method(old_rand))
135 return 0;
136 else
137 return 1;
138 }
139
140static int fbytes_counter = 0;
141static const char *numbers[8] = {
142 "651056770906015076056810763456358567190100156695615665659",
143 "6140507067065001063065065565667405560006161556565665656654",
144 "8763001015071075675010661307616710783570106710677817767166"
145 "71676178726717",
146 "7000000175690566466555057817571571075705015757757057795755"
147 "55657156756655",
148 "1275552191113212300012030439187146164646146646466749494799",
149 "1542725565216523985789236956265265265235675811949404040041",
150 "1456427555219115346513212300075341203043918714616464614664"
151 "64667494947990",
152 "1712787255652165239672857892369562652652652356758119494040"
153 "40041670216363"};
154
155int fbytes(unsigned char *buf, int num)
156 {
157 int ret;
158 BIGNUM *tmp = NULL;
159
160 if (fbytes_counter >= 8)
161 return 0;
162 tmp = BN_new();
163 if (!tmp)
164 return 0;
165 if (!BN_dec2bn(&tmp, numbers[fbytes_counter]))
166 {
167 BN_free(tmp);
168 return 0;
169 }
170 fbytes_counter ++;
171 if (num != BN_num_bytes(tmp) || !BN_bn2bin(tmp, buf))
172 ret = 0;
173 else
174 ret = 1;
175 if (tmp)
176 BN_free(tmp);
177 return ret;
178 }
179
180/* some tests from the X9.62 draft */
181int x9_62_test_internal(BIO *out, int nid, const char *r_in, const char *s_in)
182 {
183 int ret = 0;
184 const char message[] = "abc";
185 unsigned char digest[20];
186 unsigned int dgst_len = 0;
187 EVP_MD_CTX md_ctx;
188 EC_KEY *key = NULL;
189 ECDSA_SIG *signature = NULL;
190 BIGNUM *r = NULL, *s = NULL;
191
192 EVP_MD_CTX_init(&md_ctx);
193 /* get the message digest */
194 EVP_DigestInit(&md_ctx, EVP_ecdsa());
195 EVP_DigestUpdate(&md_ctx, (const void*)message, 3);
196 EVP_DigestFinal(&md_ctx, digest, &dgst_len);
197
198 BIO_printf(out, "testing %s: ", OBJ_nid2sn(nid));
199 /* create the key */
200 if ((key = EC_KEY_new_by_curve_name(nid)) == NULL)
201 goto x962_int_err;
202 if (!EC_KEY_generate_key(key))
203 goto x962_int_err;
204 BIO_printf(out, ".");
205 (void)BIO_flush(out);
206 /* create the signature */
207 signature = ECDSA_do_sign(digest, 20, key);
208 if (signature == NULL)
209 goto x962_int_err;
210 BIO_printf(out, ".");
211 (void)BIO_flush(out);
212 /* compare the created signature with the expected signature */
213 if ((r = BN_new()) == NULL || (s = BN_new()) == NULL)
214 goto x962_int_err;
215 if (!BN_dec2bn(&r, r_in) ||
216 !BN_dec2bn(&s, s_in))
217 goto x962_int_err;
218 if (BN_cmp(signature->r ,r) || BN_cmp(signature->s, s))
219 goto x962_int_err;
220 BIO_printf(out, ".");
221 (void)BIO_flush(out);
222 /* verify the signature */
223 if (ECDSA_do_verify(digest, 20, signature, key) != 1)
224 goto x962_int_err;
225 BIO_printf(out, ".");
226 (void)BIO_flush(out);
227
228 BIO_printf(out, " ok\n");
229 ret = 1;
230x962_int_err:
231 if (!ret)
232 BIO_printf(out, " failed\n");
233 if (key)
234 EC_KEY_free(key);
235 if (signature)
236 ECDSA_SIG_free(signature);
237 if (r)
238 BN_free(r);
239 if (s)
240 BN_free(s);
241 EVP_MD_CTX_cleanup(&md_ctx);
242 return ret;
243 }
244
245int x9_62_tests(BIO *out)
246 {
247 int ret = 0;
248
249 BIO_printf(out, "some tests from X9.62:\n");
250
251 /* set own rand method */
252 if (!change_rand())
253 goto x962_err;
254
255 if (!x9_62_test_internal(out, NID_X9_62_prime192v1,
256 "3342403536405981729393488334694600415596881826869351677613",
257 "5735822328888155254683894997897571951568553642892029982342"))
258 goto x962_err;
259 if (!x9_62_test_internal(out, NID_X9_62_prime239v1,
260 "3086361431751678114926225473006680188549593787585317781474"
261 "62058306432176",
262 "3238135532097973577080787768312505059318910517550078427819"
263 "78505179448783"))
264 goto x962_err;
265#ifndef OPENSSL_NO_EC2M
266 if (!x9_62_test_internal(out, NID_X9_62_c2tnb191v1,
267 "87194383164871543355722284926904419997237591535066528048",
268 "308992691965804947361541664549085895292153777025772063598"))
269 goto x962_err;
270 if (!x9_62_test_internal(out, NID_X9_62_c2tnb239v1,
271 "2159633321041961198501834003903461262881815148684178964245"
272 "5876922391552",
273 "1970303740007316867383349976549972270528498040721988191026"
274 "49413465737174"))
275 goto x962_err;
276#endif
277 ret = 1;
278x962_err:
279 if (!restore_rand())
280 ret = 0;
281 return ret;
282 }
283
284int test_builtin(BIO *out)
285 {
286 EC_builtin_curve *curves = NULL;
287 size_t crv_len = 0, n = 0;
288 EC_KEY *eckey = NULL, *wrong_eckey = NULL;
289 EC_GROUP *group;
290 ECDSA_SIG *ecdsa_sig = NULL;
291 unsigned char digest[20], wrong_digest[20];
292 unsigned char *signature = NULL;
293 const unsigned char *sig_ptr;
294 unsigned char *sig_ptr2;
295 unsigned char *raw_buf = NULL;
296 unsigned int sig_len, degree, r_len, s_len, bn_len, buf_len;
297 int nid, ret = 0;
298
299 /* fill digest values with some random data */
300 if (!RAND_pseudo_bytes(digest, 20) ||
301 !RAND_pseudo_bytes(wrong_digest, 20))
302 {
303 BIO_printf(out, "ERROR: unable to get random data\n");
304 goto builtin_err;
305 }
306
307 /* create and verify a ecdsa signature with every availble curve
308 * (with ) */
309 BIO_printf(out, "\ntesting ECDSA_sign() and ECDSA_verify() "
310 "with some internal curves:\n");
311
312 /* get a list of all internal curves */
313 crv_len = EC_get_builtin_curves(NULL, 0);
314
315 curves = OPENSSL_malloc(sizeof(EC_builtin_curve) * crv_len);
316
317 if (curves == NULL)
318 {
319 BIO_printf(out, "malloc error\n");
320 goto builtin_err;
321 }
322
323 if (!EC_get_builtin_curves(curves, crv_len))
324 {
325 BIO_printf(out, "unable to get internal curves\n");
326 goto builtin_err;
327 }
328
329 /* now create and verify a signature for every curve */
330 for (n = 0; n < crv_len; n++)
331 {
332 unsigned char dirt, offset;
333
334 nid = curves[n].nid;
335 if (nid == NID_ipsec4)
336 continue;
337 /* create new ecdsa key (== EC_KEY) */
338 if ((eckey = EC_KEY_new()) == NULL)
339 goto builtin_err;
340 group = EC_GROUP_new_by_curve_name(nid);
341 if (group == NULL)
342 goto builtin_err;
343 if (EC_KEY_set_group(eckey, group) == 0)
344 goto builtin_err;
345 EC_GROUP_free(group);
346 degree = EC_GROUP_get_degree(EC_KEY_get0_group(eckey));
347 if (degree < 160)
348 /* drop the curve */
349 {
350 EC_KEY_free(eckey);
351 eckey = NULL;
352 continue;
353 }
354 BIO_printf(out, "%s: ", OBJ_nid2sn(nid));
355 /* create key */
356 if (!EC_KEY_generate_key(eckey))
357 {
358 BIO_printf(out, " failed\n");
359 goto builtin_err;
360 }
361 /* create second key */
362 if ((wrong_eckey = EC_KEY_new()) == NULL)
363 goto builtin_err;
364 group = EC_GROUP_new_by_curve_name(nid);
365 if (group == NULL)
366 goto builtin_err;
367 if (EC_KEY_set_group(wrong_eckey, group) == 0)
368 goto builtin_err;
369 EC_GROUP_free(group);
370 if (!EC_KEY_generate_key(wrong_eckey))
371 {
372 BIO_printf(out, " failed\n");
373 goto builtin_err;
374 }
375
376 BIO_printf(out, ".");
377 (void)BIO_flush(out);
378 /* check key */
379 if (!EC_KEY_check_key(eckey))
380 {
381 BIO_printf(out, " failed\n");
382 goto builtin_err;
383 }
384 BIO_printf(out, ".");
385 (void)BIO_flush(out);
386 /* create signature */
387 sig_len = ECDSA_size(eckey);
388 if ((signature = OPENSSL_malloc(sig_len)) == NULL)
389 goto builtin_err;
390 if (!ECDSA_sign(0, digest, 20, signature, &sig_len, eckey))
391 {
392 BIO_printf(out, " failed\n");
393 goto builtin_err;
394 }
395 BIO_printf(out, ".");
396 (void)BIO_flush(out);
397 /* verify signature */
398 if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) != 1)
399 {
400 BIO_printf(out, " failed\n");
401 goto builtin_err;
402 }
403 BIO_printf(out, ".");
404 (void)BIO_flush(out);
405 /* verify signature with the wrong key */
406 if (ECDSA_verify(0, digest, 20, signature, sig_len,
407 wrong_eckey) == 1)
408 {
409 BIO_printf(out, " failed\n");
410 goto builtin_err;
411 }
412 BIO_printf(out, ".");
413 (void)BIO_flush(out);
414 /* wrong digest */
415 if (ECDSA_verify(0, wrong_digest, 20, signature, sig_len,
416 eckey) == 1)
417 {
418 BIO_printf(out, " failed\n");
419 goto builtin_err;
420 }
421 BIO_printf(out, ".");
422 (void)BIO_flush(out);
423 /* wrong length */
424 if (ECDSA_verify(0, digest, 20, signature, sig_len - 1,
425 eckey) == 1)
426 {
427 BIO_printf(out, " failed\n");
428 goto builtin_err;
429 }
430 BIO_printf(out, ".");
431 (void)BIO_flush(out);
432
433 /* Modify a single byte of the signature: to ensure we don't
434 * garble the ASN1 structure, we read the raw signature and
435 * modify a byte in one of the bignums directly. */
436 sig_ptr = signature;
437 if ((ecdsa_sig = d2i_ECDSA_SIG(NULL, &sig_ptr, sig_len)) == NULL)
438 {
439 BIO_printf(out, " failed\n");
440 goto builtin_err;
441 }
442
443 /* Store the two BIGNUMs in raw_buf. */
444 r_len = BN_num_bytes(ecdsa_sig->r);
445 s_len = BN_num_bytes(ecdsa_sig->s);
446 bn_len = (degree + 7) / 8;
447 if ((r_len > bn_len) || (s_len > bn_len))
448 {
449 BIO_printf(out, " failed\n");
450 goto builtin_err;
451 }
452 buf_len = 2 * bn_len;
453 if ((raw_buf = OPENSSL_malloc(buf_len)) == NULL)
454 goto builtin_err;
455 /* Pad the bignums with leading zeroes. */
456 memset(raw_buf, 0, buf_len);
457 BN_bn2bin(ecdsa_sig->r, raw_buf + bn_len - r_len);
458 BN_bn2bin(ecdsa_sig->s, raw_buf + buf_len - s_len);
459
460 /* Modify a single byte in the buffer. */
461 offset = raw_buf[10] % buf_len;
462 dirt = raw_buf[11] ? raw_buf[11] : 1;
463 raw_buf[offset] ^= dirt;
464 /* Now read the BIGNUMs back in from raw_buf. */
465 if ((BN_bin2bn(raw_buf, bn_len, ecdsa_sig->r) == NULL) ||
466 (BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL))
467 goto builtin_err;
468
469 sig_ptr2 = signature;
470 sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr2);
471 if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) == 1)
472 {
473 BIO_printf(out, " failed\n");
474 goto builtin_err;
475 }
476 /* Sanity check: undo the modification and verify signature. */
477 raw_buf[offset] ^= dirt;
478 if ((BN_bin2bn(raw_buf, bn_len, ecdsa_sig->r) == NULL) ||
479 (BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL))
480 goto builtin_err;
481
482 sig_ptr2 = signature;
483 sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr2);
484 if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) != 1)
485 {
486 BIO_printf(out, " failed\n");
487 goto builtin_err;
488 }
489 BIO_printf(out, ".");
490 (void)BIO_flush(out);
491
492 BIO_printf(out, " ok\n");
493 /* cleanup */
494 /* clean bogus errors */
495 ERR_clear_error();
496 OPENSSL_free(signature);
497 signature = NULL;
498 EC_KEY_free(eckey);
499 eckey = NULL;
500 EC_KEY_free(wrong_eckey);
501 wrong_eckey = NULL;
502 ECDSA_SIG_free(ecdsa_sig);
503 ecdsa_sig = NULL;
504 OPENSSL_free(raw_buf);
505 raw_buf = NULL;
506 }
507
508 ret = 1;
509builtin_err:
510 if (eckey)
511 EC_KEY_free(eckey);
512 if (wrong_eckey)
513 EC_KEY_free(wrong_eckey);
514 if (ecdsa_sig)
515 ECDSA_SIG_free(ecdsa_sig);
516 if (signature)
517 OPENSSL_free(signature);
518 if (raw_buf)
519 OPENSSL_free(raw_buf);
520 if (curves)
521 OPENSSL_free(curves);
522
523 return ret;
524 }
525
526int main(void)
527 {
528 int ret = 1;
529 BIO *out;
530
531 out = BIO_new_fp(stdout, BIO_NOCLOSE);
532
533 /* enable memory leak checking unless explicitly disabled */
534 if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) &&
535 (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
536 {
537 CRYPTO_malloc_debug_init();
538 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
539 }
540 else
541 {
542 /* OPENSSL_DEBUG_MEMORY=off */
543 CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
544 }
545 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
546
547 ERR_load_crypto_strings();
548
549 /* initialize the prng */
550 RAND_seed(rnd_seed, sizeof(rnd_seed));
551
552 /* the tests */
553 if (!x9_62_tests(out)) goto err;
554 if (!test_builtin(out)) goto err;
555
556 ret = 0;
557err:
558 if (ret)
559 BIO_printf(out, "\nECDSA test failed\n");
560 else
561 BIO_printf(out, "\nECDSA test passed\n");
562 if (ret)
563 ERR_print_errors(out);
564 CRYPTO_cleanup_all_ex_data();
565 ERR_remove_thread_state(NULL);
566 ERR_free_strings();
567 CRYPTO_mem_leaks(out);
568 if (out != NULL)
569 BIO_free(out);
570 return ret;
571 }
572#endif
diff --git a/src/lib/libcrypto/engine/eng_cryptodev.c b/src/lib/libcrypto/engine/eng_cryptodev.c
deleted file mode 100644
index 5a715aca4f..0000000000
--- a/src/lib/libcrypto/engine/eng_cryptodev.c
+++ /dev/null
@@ -1,1450 +0,0 @@
1/*
2 * Copyright (c) 2002 Bob Beck <beck@openbsd.org>
3 * Copyright (c) 2002 Theo de Raadt
4 * Copyright (c) 2002 Markus Friedl
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 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
29#include <openssl/objects.h>
30#include <openssl/engine.h>
31#include <openssl/evp.h>
32#include <openssl/bn.h>
33
34#if (defined(__unix__) || defined(unix)) && !defined(USG) && \
35 (defined(OpenBSD) || defined(__FreeBSD__))
36#include <sys/param.h>
37# if (OpenBSD >= 200112) || ((__FreeBSD_version >= 470101 && __FreeBSD_version < 500000) || __FreeBSD_version >= 500041)
38# define HAVE_CRYPTODEV
39# endif
40# if (OpenBSD >= 200110)
41# define HAVE_SYSLOG_R
42# endif
43#endif
44
45#ifndef HAVE_CRYPTODEV
46
47void
48ENGINE_load_cryptodev(void)
49{
50 /* This is a NOP on platforms without /dev/crypto */
51 return;
52}
53
54#else
55
56#include <sys/types.h>
57#include <crypto/cryptodev.h>
58#include <crypto/dh/dh.h>
59#include <crypto/dsa/dsa.h>
60#include <crypto/err/err.h>
61#include <crypto/rsa/rsa.h>
62#include <sys/ioctl.h>
63#include <errno.h>
64#include <stdio.h>
65#include <unistd.h>
66#include <fcntl.h>
67#include <stdarg.h>
68#include <syslog.h>
69#include <errno.h>
70#include <string.h>
71
72struct dev_crypto_state {
73 struct session_op d_sess;
74 int d_fd;
75
76#ifdef USE_CRYPTODEV_DIGESTS
77 char dummy_mac_key[HASH_MAX_LEN];
78
79 unsigned char digest_res[HASH_MAX_LEN];
80 char *mac_data;
81 int mac_len;
82#endif
83};
84
85static u_int32_t cryptodev_asymfeat = 0;
86
87static int get_asym_dev_crypto(void);
88static int open_dev_crypto(void);
89static int get_dev_crypto(void);
90static int get_cryptodev_ciphers(const int **cnids);
91#ifdef USE_CRYPTODEV_DIGESTS
92static int get_cryptodev_digests(const int **cnids);
93#endif
94static int cryptodev_usable_ciphers(const int **nids);
95static int cryptodev_usable_digests(const int **nids);
96static int cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
97 const unsigned char *in, size_t inl);
98static int cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
99 const unsigned char *iv, int enc);
100static int cryptodev_cleanup(EVP_CIPHER_CTX *ctx);
101static int cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
102 const int **nids, int nid);
103static int cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
104 const int **nids, int nid);
105static int bn2crparam(const BIGNUM *a, struct crparam *crp);
106static int crparam2bn(struct crparam *crp, BIGNUM *a);
107static void zapparams(struct crypt_kop *kop);
108static int cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r,
109 int slen, BIGNUM *s);
110
111static int cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a,
112 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
113static int cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I,
114 RSA *rsa, BN_CTX *ctx);
115static int cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
116static int cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a,
117 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
118static int cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
119 BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
120 BN_CTX *ctx, BN_MONT_CTX *mont);
121static DSA_SIG *cryptodev_dsa_do_sign(const unsigned char *dgst,
122 int dlen, DSA *dsa);
123static int cryptodev_dsa_verify(const unsigned char *dgst, int dgst_len,
124 DSA_SIG *sig, DSA *dsa);
125static int cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
126 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
127 BN_MONT_CTX *m_ctx);
128static int cryptodev_dh_compute_key(unsigned char *key,
129 const BIGNUM *pub_key, DH *dh);
130static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
131 void (*f)(void));
132void ENGINE_load_cryptodev(void);
133
134static const ENGINE_CMD_DEFN cryptodev_defns[] = {
135 { 0, NULL, NULL, 0 }
136};
137
138static struct {
139 int id;
140 int nid;
141 int ivmax;
142 int keylen;
143} ciphers[] = {
144 { CRYPTO_ARC4, NID_rc4, 0, 16, },
145 { CRYPTO_DES_CBC, NID_des_cbc, 8, 8, },
146 { CRYPTO_3DES_CBC, NID_des_ede3_cbc, 8, 24, },
147 { CRYPTO_AES_CBC, NID_aes_128_cbc, 16, 16, },
148 { CRYPTO_AES_CBC, NID_aes_192_cbc, 16, 24, },
149 { CRYPTO_AES_CBC, NID_aes_256_cbc, 16, 32, },
150 { CRYPTO_BLF_CBC, NID_bf_cbc, 8, 16, },
151 { CRYPTO_CAST_CBC, NID_cast5_cbc, 8, 16, },
152 { CRYPTO_SKIPJACK_CBC, NID_undef, 0, 0, },
153 { 0, NID_undef, 0, 0, },
154};
155
156#ifdef USE_CRYPTODEV_DIGESTS
157static struct {
158 int id;
159 int nid;
160 int keylen;
161} digests[] = {
162 { CRYPTO_MD5_HMAC, NID_hmacWithMD5, 16},
163 { CRYPTO_SHA1_HMAC, NID_hmacWithSHA1, 20},
164 { CRYPTO_RIPEMD160_HMAC, NID_ripemd160, 16/*?*/},
165 { CRYPTO_MD5_KPDK, NID_undef, 0},
166 { CRYPTO_SHA1_KPDK, NID_undef, 0},
167 { CRYPTO_MD5, NID_md5, 16},
168 { CRYPTO_SHA1, NID_sha1, 20},
169 { 0, NID_undef, 0},
170};
171#endif
172
173/*
174 * Return a fd if /dev/crypto seems usable, 0 otherwise.
175 */
176static int
177open_dev_crypto(void)
178{
179 static int fd = -1;
180
181 if (fd == -1) {
182 if ((fd = open("/dev/crypto", O_RDWR, 0)) == -1)
183 return (-1);
184 /* close on exec */
185 if (fcntl(fd, F_SETFD, 1) == -1) {
186 close(fd);
187 fd = -1;
188 return (-1);
189 }
190 }
191 return (fd);
192}
193
194static int
195get_dev_crypto(void)
196{
197 int fd, retfd;
198
199 if ((fd = open_dev_crypto()) == -1)
200 return (-1);
201#ifndef CRIOGET_NOT_NEEDED
202 if (ioctl(fd, CRIOGET, &retfd) == -1)
203 return (-1);
204
205 /* close on exec */
206 if (fcntl(retfd, F_SETFD, 1) == -1) {
207 close(retfd);
208 return (-1);
209 }
210#else
211 retfd = fd;
212#endif
213 return (retfd);
214}
215
216static void put_dev_crypto(int fd)
217{
218#ifndef CRIOGET_NOT_NEEDED
219 close(fd);
220#endif
221}
222
223/* Caching version for asym operations */
224static int
225get_asym_dev_crypto(void)
226{
227 static int fd = -1;
228
229 if (fd == -1)
230 fd = get_dev_crypto();
231 return fd;
232}
233
234/*
235 * Find out what ciphers /dev/crypto will let us have a session for.
236 * XXX note, that some of these openssl doesn't deal with yet!
237 * returning them here is harmless, as long as we return NULL
238 * when asked for a handler in the cryptodev_engine_ciphers routine
239 */
240static int
241get_cryptodev_ciphers(const int **cnids)
242{
243 static int nids[CRYPTO_ALGORITHM_MAX];
244 struct session_op sess;
245 int fd, i, count = 0;
246
247 if ((fd = get_dev_crypto()) < 0) {
248 *cnids = NULL;
249 return (0);
250 }
251 memset(&sess, 0, sizeof(sess));
252 sess.key = (caddr_t)"123456789abcdefghijklmno";
253
254 for (i = 0; ciphers[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
255 if (ciphers[i].nid == NID_undef)
256 continue;
257 sess.cipher = ciphers[i].id;
258 sess.keylen = ciphers[i].keylen;
259 sess.mac = 0;
260 if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
261 ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
262 nids[count++] = ciphers[i].nid;
263 }
264 put_dev_crypto(fd);
265
266 if (count > 0)
267 *cnids = nids;
268 else
269 *cnids = NULL;
270 return (count);
271}
272
273#ifdef USE_CRYPTODEV_DIGESTS
274/*
275 * Find out what digests /dev/crypto will let us have a session for.
276 * XXX note, that some of these openssl doesn't deal with yet!
277 * returning them here is harmless, as long as we return NULL
278 * when asked for a handler in the cryptodev_engine_digests routine
279 */
280static int
281get_cryptodev_digests(const int **cnids)
282{
283 static int nids[CRYPTO_ALGORITHM_MAX];
284 struct session_op sess;
285 int fd, i, count = 0;
286
287 if ((fd = get_dev_crypto()) < 0) {
288 *cnids = NULL;
289 return (0);
290 }
291 memset(&sess, 0, sizeof(sess));
292 sess.mackey = (caddr_t)"123456789abcdefghijklmno";
293 for (i = 0; digests[i].id && count < CRYPTO_ALGORITHM_MAX; i++) {
294 if (digests[i].nid == NID_undef)
295 continue;
296 sess.mac = digests[i].id;
297 sess.mackeylen = digests[i].keylen;
298 sess.cipher = 0;
299 if (ioctl(fd, CIOCGSESSION, &sess) != -1 &&
300 ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
301 nids[count++] = digests[i].nid;
302 }
303 put_dev_crypto(fd);
304
305 if (count > 0)
306 *cnids = nids;
307 else
308 *cnids = NULL;
309 return (count);
310}
311#endif /* 0 */
312
313/*
314 * Find the useable ciphers|digests from dev/crypto - this is the first
315 * thing called by the engine init crud which determines what it
316 * can use for ciphers from this engine. We want to return
317 * only what we can do, anythine else is handled by software.
318 *
319 * If we can't initialize the device to do anything useful for
320 * any reason, we want to return a NULL array, and 0 length,
321 * which forces everything to be done is software. By putting
322 * the initalization of the device in here, we ensure we can
323 * use this engine as the default, and if for whatever reason
324 * /dev/crypto won't do what we want it will just be done in
325 * software
326 *
327 * This can (should) be greatly expanded to perhaps take into
328 * account speed of the device, and what we want to do.
329 * (although the disabling of particular alg's could be controlled
330 * by the device driver with sysctl's.) - this is where we
331 * want most of the decisions made about what we actually want
332 * to use from /dev/crypto.
333 */
334static int
335cryptodev_usable_ciphers(const int **nids)
336{
337 return (get_cryptodev_ciphers(nids));
338}
339
340static int
341cryptodev_usable_digests(const int **nids)
342{
343#ifdef USE_CRYPTODEV_DIGESTS
344 return (get_cryptodev_digests(nids));
345#else
346 /*
347 * XXXX just disable all digests for now, because it sucks.
348 * we need a better way to decide this - i.e. I may not
349 * want digests on slow cards like hifn on fast machines,
350 * but might want them on slow or loaded machines, etc.
351 * will also want them when using crypto cards that don't
352 * suck moose gonads - would be nice to be able to decide something
353 * as reasonable default without having hackery that's card dependent.
354 * of course, the default should probably be just do everything,
355 * with perhaps a sysctl to turn algoritms off (or have them off
356 * by default) on cards that generally suck like the hifn.
357 */
358 *nids = NULL;
359 return (0);
360#endif
361}
362
363static int
364cryptodev_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
365 const unsigned char *in, size_t inl)
366{
367 struct crypt_op cryp;
368 struct dev_crypto_state *state = ctx->cipher_data;
369 struct session_op *sess = &state->d_sess;
370 const void *iiv;
371 unsigned char save_iv[EVP_MAX_IV_LENGTH];
372
373 if (state->d_fd < 0)
374 return (0);
375 if (!inl)
376 return (1);
377 if ((inl % ctx->cipher->block_size) != 0)
378 return (0);
379
380 memset(&cryp, 0, sizeof(cryp));
381
382 cryp.ses = sess->ses;
383 cryp.flags = 0;
384 cryp.len = inl;
385 cryp.src = (caddr_t) in;
386 cryp.dst = (caddr_t) out;
387 cryp.mac = 0;
388
389 cryp.op = ctx->encrypt ? COP_ENCRYPT : COP_DECRYPT;
390
391 if (ctx->cipher->iv_len) {
392 cryp.iv = (caddr_t) ctx->iv;
393 if (!ctx->encrypt) {
394 iiv = in + inl - ctx->cipher->iv_len;
395 memcpy(save_iv, iiv, ctx->cipher->iv_len);
396 }
397 } else
398 cryp.iv = NULL;
399
400 if (ioctl(state->d_fd, CIOCCRYPT, &cryp) == -1) {
401 /* XXX need better errror handling
402 * this can fail for a number of different reasons.
403 */
404 return (0);
405 }
406
407 if (ctx->cipher->iv_len) {
408 if (ctx->encrypt)
409 iiv = out + inl - ctx->cipher->iv_len;
410 else
411 iiv = save_iv;
412 memcpy(ctx->iv, iiv, ctx->cipher->iv_len);
413 }
414 return (1);
415}
416
417static int
418cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
419 const unsigned char *iv, int enc)
420{
421 struct dev_crypto_state *state = ctx->cipher_data;
422 struct session_op *sess = &state->d_sess;
423 int cipher = -1, i;
424
425 for (i = 0; ciphers[i].id; i++)
426 if (ctx->cipher->nid == ciphers[i].nid &&
427 ctx->cipher->iv_len <= ciphers[i].ivmax &&
428 ctx->key_len == ciphers[i].keylen) {
429 cipher = ciphers[i].id;
430 break;
431 }
432
433 if (!ciphers[i].id) {
434 state->d_fd = -1;
435 return (0);
436 }
437
438 memset(sess, 0, sizeof(struct session_op));
439
440 if ((state->d_fd = get_dev_crypto()) < 0)
441 return (0);
442
443 sess->key = (caddr_t)key;
444 sess->keylen = ctx->key_len;
445 sess->cipher = cipher;
446
447 if (ioctl(state->d_fd, CIOCGSESSION, sess) == -1) {
448 put_dev_crypto(state->d_fd);
449 state->d_fd = -1;
450 return (0);
451 }
452 return (1);
453}
454
455/*
456 * free anything we allocated earlier when initting a
457 * session, and close the session.
458 */
459static int
460cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
461{
462 int ret = 0;
463 struct dev_crypto_state *state = ctx->cipher_data;
464 struct session_op *sess = &state->d_sess;
465
466 if (state->d_fd < 0)
467 return (0);
468
469 /* XXX if this ioctl fails, someting's wrong. the invoker
470 * may have called us with a bogus ctx, or we could
471 * have a device that for whatever reason just doesn't
472 * want to play ball - it's not clear what's right
473 * here - should this be an error? should it just
474 * increase a counter, hmm. For right now, we return
475 * 0 - I don't believe that to be "right". we could
476 * call the gorpy openssl lib error handlers that
477 * print messages to users of the library. hmm..
478 */
479
480 if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) == -1) {
481 ret = 0;
482 } else {
483 ret = 1;
484 }
485 put_dev_crypto(state->d_fd);
486 state->d_fd = -1;
487
488 return (ret);
489}
490
491/*
492 * libcrypto EVP stuff - this is how we get wired to EVP so the engine
493 * gets called when libcrypto requests a cipher NID.
494 */
495
496/* RC4 */
497const EVP_CIPHER cryptodev_rc4 = {
498 NID_rc4,
499 1, 16, 0,
500 EVP_CIPH_VARIABLE_LENGTH,
501 cryptodev_init_key,
502 cryptodev_cipher,
503 cryptodev_cleanup,
504 sizeof(struct dev_crypto_state),
505 NULL,
506 NULL,
507 NULL
508};
509
510/* DES CBC EVP */
511const EVP_CIPHER cryptodev_des_cbc = {
512 NID_des_cbc,
513 8, 8, 8,
514 EVP_CIPH_CBC_MODE,
515 cryptodev_init_key,
516 cryptodev_cipher,
517 cryptodev_cleanup,
518 sizeof(struct dev_crypto_state),
519 EVP_CIPHER_set_asn1_iv,
520 EVP_CIPHER_get_asn1_iv,
521 NULL
522};
523
524/* 3DES CBC EVP */
525const EVP_CIPHER cryptodev_3des_cbc = {
526 NID_des_ede3_cbc,
527 8, 24, 8,
528 EVP_CIPH_CBC_MODE,
529 cryptodev_init_key,
530 cryptodev_cipher,
531 cryptodev_cleanup,
532 sizeof(struct dev_crypto_state),
533 EVP_CIPHER_set_asn1_iv,
534 EVP_CIPHER_get_asn1_iv,
535 NULL
536};
537
538const EVP_CIPHER cryptodev_bf_cbc = {
539 NID_bf_cbc,
540 8, 16, 8,
541 EVP_CIPH_CBC_MODE,
542 cryptodev_init_key,
543 cryptodev_cipher,
544 cryptodev_cleanup,
545 sizeof(struct dev_crypto_state),
546 EVP_CIPHER_set_asn1_iv,
547 EVP_CIPHER_get_asn1_iv,
548 NULL
549};
550
551const EVP_CIPHER cryptodev_cast_cbc = {
552 NID_cast5_cbc,
553 8, 16, 8,
554 EVP_CIPH_CBC_MODE,
555 cryptodev_init_key,
556 cryptodev_cipher,
557 cryptodev_cleanup,
558 sizeof(struct dev_crypto_state),
559 EVP_CIPHER_set_asn1_iv,
560 EVP_CIPHER_get_asn1_iv,
561 NULL
562};
563
564const EVP_CIPHER cryptodev_aes_cbc = {
565 NID_aes_128_cbc,
566 16, 16, 16,
567 EVP_CIPH_CBC_MODE,
568 cryptodev_init_key,
569 cryptodev_cipher,
570 cryptodev_cleanup,
571 sizeof(struct dev_crypto_state),
572 EVP_CIPHER_set_asn1_iv,
573 EVP_CIPHER_get_asn1_iv,
574 NULL
575};
576
577const EVP_CIPHER cryptodev_aes_192_cbc = {
578 NID_aes_192_cbc,
579 16, 24, 16,
580 EVP_CIPH_CBC_MODE,
581 cryptodev_init_key,
582 cryptodev_cipher,
583 cryptodev_cleanup,
584 sizeof(struct dev_crypto_state),
585 EVP_CIPHER_set_asn1_iv,
586 EVP_CIPHER_get_asn1_iv,
587 NULL
588};
589
590const EVP_CIPHER cryptodev_aes_256_cbc = {
591 NID_aes_256_cbc,
592 16, 32, 16,
593 EVP_CIPH_CBC_MODE,
594 cryptodev_init_key,
595 cryptodev_cipher,
596 cryptodev_cleanup,
597 sizeof(struct dev_crypto_state),
598 EVP_CIPHER_set_asn1_iv,
599 EVP_CIPHER_get_asn1_iv,
600 NULL
601};
602
603/*
604 * Registered by the ENGINE when used to find out how to deal with
605 * a particular NID in the ENGINE. this says what we'll do at the
606 * top level - note, that list is restricted by what we answer with
607 */
608static int
609cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
610 const int **nids, int nid)
611{
612 if (!cipher)
613 return (cryptodev_usable_ciphers(nids));
614
615 switch (nid) {
616 case NID_rc4:
617 *cipher = &cryptodev_rc4;
618 break;
619 case NID_des_ede3_cbc:
620 *cipher = &cryptodev_3des_cbc;
621 break;
622 case NID_des_cbc:
623 *cipher = &cryptodev_des_cbc;
624 break;
625 case NID_bf_cbc:
626 *cipher = &cryptodev_bf_cbc;
627 break;
628 case NID_cast5_cbc:
629 *cipher = &cryptodev_cast_cbc;
630 break;
631 case NID_aes_128_cbc:
632 *cipher = &cryptodev_aes_cbc;
633 break;
634 case NID_aes_192_cbc:
635 *cipher = &cryptodev_aes_192_cbc;
636 break;
637 case NID_aes_256_cbc:
638 *cipher = &cryptodev_aes_256_cbc;
639 break;
640 default:
641 *cipher = NULL;
642 break;
643 }
644 return (*cipher != NULL);
645}
646
647
648#ifdef USE_CRYPTODEV_DIGESTS
649
650/* convert digest type to cryptodev */
651static int
652digest_nid_to_cryptodev(int nid)
653{
654 int i;
655
656 for (i = 0; digests[i].id; i++)
657 if (digests[i].nid == nid)
658 return (digests[i].id);
659 return (0);
660}
661
662
663static int
664digest_key_length(int nid)
665{
666 int i;
667
668 for (i = 0; digests[i].id; i++)
669 if (digests[i].nid == nid)
670 return digests[i].keylen;
671 return (0);
672}
673
674
675static int cryptodev_digest_init(EVP_MD_CTX *ctx)
676{
677 struct dev_crypto_state *state = ctx->md_data;
678 struct session_op *sess = &state->d_sess;
679 int digest;
680
681 if ((digest = digest_nid_to_cryptodev(ctx->digest->type)) == NID_undef){
682 printf("cryptodev_digest_init: Can't get digest \n");
683 return (0);
684 }
685
686 memset(state, 0, sizeof(struct dev_crypto_state));
687
688 if ((state->d_fd = get_dev_crypto()) < 0) {
689 printf("cryptodev_digest_init: Can't get Dev \n");
690 return (0);
691 }
692
693 sess->mackey = state->dummy_mac_key;
694 sess->mackeylen = digest_key_length(ctx->digest->type);
695 sess->mac = digest;
696
697 if (ioctl(state->d_fd, CIOCGSESSION, sess) < 0) {
698 put_dev_crypto(state->d_fd);
699 state->d_fd = -1;
700 printf("cryptodev_digest_init: Open session failed\n");
701 return (0);
702 }
703
704 return (1);
705}
706
707static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
708 size_t count)
709{
710 struct crypt_op cryp;
711 struct dev_crypto_state *state = ctx->md_data;
712 struct session_op *sess = &state->d_sess;
713
714 if (!data || state->d_fd < 0) {
715 printf("cryptodev_digest_update: illegal inputs \n");
716 return (0);
717 }
718
719 if (!count) {
720 return (0);
721 }
722
723 if (!(ctx->flags & EVP_MD_CTX_FLAG_ONESHOT)) {
724 /* if application doesn't support one buffer */
725 state->mac_data = OPENSSL_realloc(state->mac_data, state->mac_len + count);
726
727 if (!state->mac_data) {
728 printf("cryptodev_digest_update: realloc failed\n");
729 return (0);
730 }
731
732 memcpy(state->mac_data + state->mac_len, data, count);
733 state->mac_len += count;
734
735 return (1);
736 }
737
738 memset(&cryp, 0, sizeof(cryp));
739
740 cryp.ses = sess->ses;
741 cryp.flags = 0;
742 cryp.len = count;
743 cryp.src = (caddr_t) data;
744 cryp.dst = NULL;
745 cryp.mac = (caddr_t) state->digest_res;
746 if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
747 printf("cryptodev_digest_update: digest failed\n");
748 return (0);
749 }
750 return (1);
751}
752
753
754static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
755{
756 struct crypt_op cryp;
757 struct dev_crypto_state *state = ctx->md_data;
758 struct session_op *sess = &state->d_sess;
759
760 int ret = 1;
761
762 if (!md || state->d_fd < 0) {
763 printf("cryptodev_digest_final: illegal input\n");
764 return(0);
765 }
766
767 if (! (ctx->flags & EVP_MD_CTX_FLAG_ONESHOT) ) {
768 /* if application doesn't support one buffer */
769 memset(&cryp, 0, sizeof(cryp));
770 cryp.ses = sess->ses;
771 cryp.flags = 0;
772 cryp.len = state->mac_len;
773 cryp.src = state->mac_data;
774 cryp.dst = NULL;
775 cryp.mac = (caddr_t)md;
776 if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
777 printf("cryptodev_digest_final: digest failed\n");
778 return (0);
779 }
780
781 return 1;
782 }
783
784 memcpy(md, state->digest_res, ctx->digest->md_size);
785
786 return (ret);
787}
788
789
790static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
791{
792 int ret = 1;
793 struct dev_crypto_state *state = ctx->md_data;
794 struct session_op *sess = &state->d_sess;
795
796 if (state == NULL)
797 return 0;
798
799 if (state->d_fd < 0) {
800 printf("cryptodev_digest_cleanup: illegal input\n");
801 return (0);
802 }
803
804 if (state->mac_data) {
805 OPENSSL_free(state->mac_data);
806 state->mac_data = NULL;
807 state->mac_len = 0;
808 }
809
810 if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
811 printf("cryptodev_digest_cleanup: failed to close session\n");
812 ret = 0;
813 } else {
814 ret = 1;
815 }
816 put_dev_crypto(state->d_fd);
817 state->d_fd = -1;
818
819 return (ret);
820}
821
822static int cryptodev_digest_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
823{
824 struct dev_crypto_state *fstate = from->md_data;
825 struct dev_crypto_state *dstate = to->md_data;
826 struct session_op *sess;
827 int digest;
828
829 if (dstate == NULL || fstate == NULL)
830 return 1;
831
832 memcpy(dstate, fstate, sizeof(struct dev_crypto_state));
833
834 sess = &dstate->d_sess;
835
836 digest = digest_nid_to_cryptodev(to->digest->type);
837
838 sess->mackey = dstate->dummy_mac_key;
839 sess->mackeylen = digest_key_length(to->digest->type);
840 sess->mac = digest;
841
842 dstate->d_fd = get_dev_crypto();
843
844 if (ioctl(dstate->d_fd, CIOCGSESSION, sess) < 0) {
845 put_dev_crypto(dstate->d_fd);
846 dstate->d_fd = -1;
847 printf("cryptodev_digest_init: Open session failed\n");
848 return (0);
849 }
850
851 if (fstate->mac_len != 0) {
852 if (fstate->mac_data != NULL)
853 {
854 dstate->mac_data = OPENSSL_malloc(fstate->mac_len);
855 memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len);
856 dstate->mac_len = fstate->mac_len;
857 }
858 }
859
860 return 1;
861}
862
863
864const EVP_MD cryptodev_sha1 = {
865 NID_sha1,
866 NID_undef,
867 SHA_DIGEST_LENGTH,
868 EVP_MD_FLAG_ONESHOT,
869 cryptodev_digest_init,
870 cryptodev_digest_update,
871 cryptodev_digest_final,
872 cryptodev_digest_copy,
873 cryptodev_digest_cleanup,
874 EVP_PKEY_NULL_method,
875 SHA_CBLOCK,
876 sizeof(struct dev_crypto_state),
877};
878
879const EVP_MD cryptodev_md5 = {
880 NID_md5,
881 NID_undef,
882 16 /* MD5_DIGEST_LENGTH */,
883 EVP_MD_FLAG_ONESHOT,
884 cryptodev_digest_init,
885 cryptodev_digest_update,
886 cryptodev_digest_final,
887 cryptodev_digest_copy,
888 cryptodev_digest_cleanup,
889 EVP_PKEY_NULL_method,
890 64 /* MD5_CBLOCK */,
891 sizeof(struct dev_crypto_state),
892};
893
894#endif /* USE_CRYPTODEV_DIGESTS */
895
896
897static int
898cryptodev_engine_digests(ENGINE *e, const EVP_MD **digest,
899 const int **nids, int nid)
900{
901 if (!digest)
902 return (cryptodev_usable_digests(nids));
903
904 switch (nid) {
905#ifdef USE_CRYPTODEV_DIGESTS
906 case NID_md5:
907 *digest = &cryptodev_md5;
908 break;
909 case NID_sha1:
910 *digest = &cryptodev_sha1;
911 break;
912 default:
913#endif /* USE_CRYPTODEV_DIGESTS */
914 *digest = NULL;
915 break;
916 }
917 return (*digest != NULL);
918}
919
920/*
921 * Convert a BIGNUM to the representation that /dev/crypto needs.
922 * Upon completion of use, the caller is responsible for freeing
923 * crp->crp_p.
924 */
925static int
926bn2crparam(const BIGNUM *a, struct crparam *crp)
927{
928 int i, j, k;
929 ssize_t bytes, bits;
930 u_char *b;
931
932 crp->crp_p = NULL;
933 crp->crp_nbits = 0;
934
935 bits = BN_num_bits(a);
936 bytes = (bits + 7) / 8;
937
938 b = malloc(bytes);
939 if (b == NULL)
940 return (1);
941 memset(b, 0, bytes);
942
943 crp->crp_p = (caddr_t) b;
944 crp->crp_nbits = bits;
945
946 for (i = 0, j = 0; i < a->top; i++) {
947 for (k = 0; k < BN_BITS2 / 8; k++) {
948 if ((j + k) >= bytes)
949 return (0);
950 b[j + k] = a->d[i] >> (k * 8);
951 }
952 j += BN_BITS2 / 8;
953 }
954 return (0);
955}
956
957/* Convert a /dev/crypto parameter to a BIGNUM */
958static int
959crparam2bn(struct crparam *crp, BIGNUM *a)
960{
961 u_int8_t *pd;
962 int i, bytes;
963
964 bytes = (crp->crp_nbits + 7) / 8;
965
966 if (bytes == 0)
967 return (-1);
968
969 if ((pd = (u_int8_t *) malloc(bytes)) == NULL)
970 return (-1);
971
972 for (i = 0; i < bytes; i++)
973 pd[i] = crp->crp_p[bytes - i - 1];
974
975 BN_bin2bn(pd, bytes, a);
976 free(pd);
977
978 return (0);
979}
980
981static void
982zapparams(struct crypt_kop *kop)
983{
984 int i;
985
986 for (i = 0; i < kop->crk_iparams + kop->crk_oparams; i++) {
987 if (kop->crk_param[i].crp_p)
988 free(kop->crk_param[i].crp_p);
989 kop->crk_param[i].crp_p = NULL;
990 kop->crk_param[i].crp_nbits = 0;
991 }
992}
993
994static int
995cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r, int slen, BIGNUM *s)
996{
997 int fd, ret = -1;
998
999 if ((fd = get_asym_dev_crypto()) < 0)
1000 return (ret);
1001
1002 if (r) {
1003 kop->crk_param[kop->crk_iparams].crp_p = calloc(rlen, sizeof(char));
1004 kop->crk_param[kop->crk_iparams].crp_nbits = rlen * 8;
1005 kop->crk_oparams++;
1006 }
1007 if (s) {
1008 kop->crk_param[kop->crk_iparams+1].crp_p = calloc(slen, sizeof(char));
1009 kop->crk_param[kop->crk_iparams+1].crp_nbits = slen * 8;
1010 kop->crk_oparams++;
1011 }
1012
1013 if (ioctl(fd, CIOCKEY, kop) == 0) {
1014 if (r)
1015 crparam2bn(&kop->crk_param[kop->crk_iparams], r);
1016 if (s)
1017 crparam2bn(&kop->crk_param[kop->crk_iparams+1], s);
1018 ret = 0;
1019 }
1020
1021 return (ret);
1022}
1023
1024static int
1025cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
1026 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
1027{
1028 struct crypt_kop kop;
1029 int ret = 1;
1030
1031 /* Currently, we know we can do mod exp iff we can do any
1032 * asymmetric operations at all.
1033 */
1034 if (cryptodev_asymfeat == 0) {
1035 ret = BN_mod_exp(r, a, p, m, ctx);
1036 return (ret);
1037 }
1038
1039 memset(&kop, 0, sizeof kop);
1040 kop.crk_op = CRK_MOD_EXP;
1041
1042 /* inputs: a^p % m */
1043 if (bn2crparam(a, &kop.crk_param[0]))
1044 goto err;
1045 if (bn2crparam(p, &kop.crk_param[1]))
1046 goto err;
1047 if (bn2crparam(m, &kop.crk_param[2]))
1048 goto err;
1049 kop.crk_iparams = 3;
1050
1051 if (cryptodev_asym(&kop, BN_num_bytes(m), r, 0, NULL)) {
1052 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
1053 printf("OCF asym process failed, Running in software\n");
1054 ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
1055
1056 } else if (ECANCELED == kop.crk_status) {
1057 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
1058 printf("OCF hardware operation cancelled. Running in Software\n");
1059 ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
1060 }
1061 /* else cryptodev operation worked ok ==> ret = 1*/
1062
1063err:
1064 zapparams(&kop);
1065 return (ret);
1066}
1067
1068static int
1069cryptodev_rsa_nocrt_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
1070{
1071 int r;
1072 ctx = BN_CTX_new();
1073 r = cryptodev_bn_mod_exp(r0, I, rsa->d, rsa->n, ctx, NULL);
1074 BN_CTX_free(ctx);
1075 return (r);
1076}
1077
1078static int
1079cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
1080{
1081 struct crypt_kop kop;
1082 int ret = 1;
1083
1084 if (!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp) {
1085 /* XXX 0 means failure?? */
1086 return (0);
1087 }
1088
1089 memset(&kop, 0, sizeof kop);
1090 kop.crk_op = CRK_MOD_EXP_CRT;
1091 /* inputs: rsa->p rsa->q I rsa->dmp1 rsa->dmq1 rsa->iqmp */
1092 if (bn2crparam(rsa->p, &kop.crk_param[0]))
1093 goto err;
1094 if (bn2crparam(rsa->q, &kop.crk_param[1]))
1095 goto err;
1096 if (bn2crparam(I, &kop.crk_param[2]))
1097 goto err;
1098 if (bn2crparam(rsa->dmp1, &kop.crk_param[3]))
1099 goto err;
1100 if (bn2crparam(rsa->dmq1, &kop.crk_param[4]))
1101 goto err;
1102 if (bn2crparam(rsa->iqmp, &kop.crk_param[5]))
1103 goto err;
1104 kop.crk_iparams = 6;
1105
1106 if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL)) {
1107 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
1108 printf("OCF asym process failed, running in Software\n");
1109 ret = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
1110
1111 } else if (ECANCELED == kop.crk_status) {
1112 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
1113 printf("OCF hardware operation cancelled. Running in Software\n");
1114 ret = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
1115 }
1116 /* else cryptodev operation worked ok ==> ret = 1*/
1117
1118err:
1119 zapparams(&kop);
1120 return (ret);
1121}
1122
1123static RSA_METHOD cryptodev_rsa = {
1124 "cryptodev RSA method",
1125 NULL, /* rsa_pub_enc */
1126 NULL, /* rsa_pub_dec */
1127 NULL, /* rsa_priv_enc */
1128 NULL, /* rsa_priv_dec */
1129 NULL,
1130 NULL,
1131 NULL, /* init */
1132 NULL, /* finish */
1133 0, /* flags */
1134 NULL, /* app_data */
1135 NULL, /* rsa_sign */
1136 NULL /* rsa_verify */
1137};
1138
1139static int
1140cryptodev_dsa_bn_mod_exp(DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
1141 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1142{
1143 return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
1144}
1145
1146static int
1147cryptodev_dsa_dsa_mod_exp(DSA *dsa, BIGNUM *t1, BIGNUM *g,
1148 BIGNUM *u1, BIGNUM *pub_key, BIGNUM *u2, BIGNUM *p,
1149 BN_CTX *ctx, BN_MONT_CTX *mont)
1150{
1151 BIGNUM t2;
1152 int ret = 0;
1153
1154 BN_init(&t2);
1155
1156 /* v = ( g^u1 * y^u2 mod p ) mod q */
1157 /* let t1 = g ^ u1 mod p */
1158 ret = 0;
1159
1160 if (!dsa->meth->bn_mod_exp(dsa,t1,dsa->g,u1,dsa->p,ctx,mont))
1161 goto err;
1162
1163 /* let t2 = y ^ u2 mod p */
1164 if (!dsa->meth->bn_mod_exp(dsa,&t2,dsa->pub_key,u2,dsa->p,ctx,mont))
1165 goto err;
1166 /* let u1 = t1 * t2 mod p */
1167 if (!BN_mod_mul(u1,t1,&t2,dsa->p,ctx))
1168 goto err;
1169
1170 BN_copy(t1,u1);
1171
1172 ret = 1;
1173err:
1174 BN_free(&t2);
1175 return(ret);
1176}
1177
1178static DSA_SIG *
1179cryptodev_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
1180{
1181 struct crypt_kop kop;
1182 BIGNUM *r = NULL, *s = NULL;
1183 DSA_SIG *dsaret = NULL;
1184
1185 if ((r = BN_new()) == NULL)
1186 goto err;
1187 if ((s = BN_new()) == NULL) {
1188 BN_free(r);
1189 goto err;
1190 }
1191
1192 memset(&kop, 0, sizeof kop);
1193 kop.crk_op = CRK_DSA_SIGN;
1194
1195 /* inputs: dgst dsa->p dsa->q dsa->g dsa->priv_key */
1196 kop.crk_param[0].crp_p = (caddr_t)dgst;
1197 kop.crk_param[0].crp_nbits = dlen * 8;
1198 if (bn2crparam(dsa->p, &kop.crk_param[1]))
1199 goto err;
1200 if (bn2crparam(dsa->q, &kop.crk_param[2]))
1201 goto err;
1202 if (bn2crparam(dsa->g, &kop.crk_param[3]))
1203 goto err;
1204 if (bn2crparam(dsa->priv_key, &kop.crk_param[4]))
1205 goto err;
1206 kop.crk_iparams = 5;
1207
1208 if (cryptodev_asym(&kop, BN_num_bytes(dsa->q), r,
1209 BN_num_bytes(dsa->q), s) == 0) {
1210 dsaret = DSA_SIG_new();
1211 dsaret->r = r;
1212 dsaret->s = s;
1213 } else {
1214 const DSA_METHOD *meth = DSA_OpenSSL();
1215 BN_free(r);
1216 BN_free(s);
1217 dsaret = (meth->dsa_do_sign)(dgst, dlen, dsa);
1218 }
1219err:
1220 kop.crk_param[0].crp_p = NULL;
1221 zapparams(&kop);
1222 return (dsaret);
1223}
1224
1225static int
1226cryptodev_dsa_verify(const unsigned char *dgst, int dlen,
1227 DSA_SIG *sig, DSA *dsa)
1228{
1229 struct crypt_kop kop;
1230 int dsaret = 1;
1231
1232 memset(&kop, 0, sizeof kop);
1233 kop.crk_op = CRK_DSA_VERIFY;
1234
1235 /* inputs: dgst dsa->p dsa->q dsa->g dsa->pub_key sig->r sig->s */
1236 kop.crk_param[0].crp_p = (caddr_t)dgst;
1237 kop.crk_param[0].crp_nbits = dlen * 8;
1238 if (bn2crparam(dsa->p, &kop.crk_param[1]))
1239 goto err;
1240 if (bn2crparam(dsa->q, &kop.crk_param[2]))
1241 goto err;
1242 if (bn2crparam(dsa->g, &kop.crk_param[3]))
1243 goto err;
1244 if (bn2crparam(dsa->pub_key, &kop.crk_param[4]))
1245 goto err;
1246 if (bn2crparam(sig->r, &kop.crk_param[5]))
1247 goto err;
1248 if (bn2crparam(sig->s, &kop.crk_param[6]))
1249 goto err;
1250 kop.crk_iparams = 7;
1251
1252 if (cryptodev_asym(&kop, 0, NULL, 0, NULL) == 0) {
1253/*OCF success value is 0, if not zero, change dsaret to fail*/
1254 if(0 != kop.crk_status) dsaret = 0;
1255 } else {
1256 const DSA_METHOD *meth = DSA_OpenSSL();
1257
1258 dsaret = (meth->dsa_do_verify)(dgst, dlen, sig, dsa);
1259 }
1260err:
1261 kop.crk_param[0].crp_p = NULL;
1262 zapparams(&kop);
1263 return (dsaret);
1264}
1265
1266static DSA_METHOD cryptodev_dsa = {
1267 "cryptodev DSA method",
1268 NULL,
1269 NULL, /* dsa_sign_setup */
1270 NULL,
1271 NULL, /* dsa_mod_exp */
1272 NULL,
1273 NULL, /* init */
1274 NULL, /* finish */
1275 0, /* flags */
1276 NULL /* app_data */
1277};
1278
1279static int
1280cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
1281 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
1282 BN_MONT_CTX *m_ctx)
1283{
1284 return (cryptodev_bn_mod_exp(r, a, p, m, ctx, m_ctx));
1285}
1286
1287static int
1288cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
1289{
1290 struct crypt_kop kop;
1291 int dhret = 1;
1292 int fd, keylen;
1293
1294 if ((fd = get_asym_dev_crypto()) < 0) {
1295 const DH_METHOD *meth = DH_OpenSSL();
1296
1297 return ((meth->compute_key)(key, pub_key, dh));
1298 }
1299
1300 keylen = BN_num_bits(dh->p);
1301
1302 memset(&kop, 0, sizeof kop);
1303 kop.crk_op = CRK_DH_COMPUTE_KEY;
1304
1305 /* inputs: dh->priv_key pub_key dh->p key */
1306 if (bn2crparam(dh->priv_key, &kop.crk_param[0]))
1307 goto err;
1308 if (bn2crparam(pub_key, &kop.crk_param[1]))
1309 goto err;
1310 if (bn2crparam(dh->p, &kop.crk_param[2]))
1311 goto err;
1312 kop.crk_iparams = 3;
1313
1314 kop.crk_param[3].crp_p = (caddr_t) key;
1315 kop.crk_param[3].crp_nbits = keylen * 8;
1316 kop.crk_oparams = 1;
1317
1318 if (ioctl(fd, CIOCKEY, &kop) == -1) {
1319 const DH_METHOD *meth = DH_OpenSSL();
1320
1321 dhret = (meth->compute_key)(key, pub_key, dh);
1322 }
1323err:
1324 kop.crk_param[3].crp_p = NULL;
1325 zapparams(&kop);
1326 return (dhret);
1327}
1328
1329static DH_METHOD cryptodev_dh = {
1330 "cryptodev DH method",
1331 NULL, /* cryptodev_dh_generate_key */
1332 NULL,
1333 NULL,
1334 NULL,
1335 NULL,
1336 0, /* flags */
1337 NULL /* app_data */
1338};
1339
1340/*
1341 * ctrl right now is just a wrapper that doesn't do much
1342 * but I expect we'll want some options soon.
1343 */
1344static int
1345cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
1346{
1347#ifdef HAVE_SYSLOG_R
1348 struct syslog_data sd = SYSLOG_DATA_INIT;
1349#endif
1350
1351 switch (cmd) {
1352 default:
1353#ifdef HAVE_SYSLOG_R
1354 syslog_r(LOG_ERR, &sd,
1355 "cryptodev_ctrl: unknown command %d", cmd);
1356#else
1357 syslog(LOG_ERR, "cryptodev_ctrl: unknown command %d", cmd);
1358#endif
1359 break;
1360 }
1361 return (1);
1362}
1363
1364void
1365ENGINE_load_cryptodev(void)
1366{
1367 ENGINE *engine = ENGINE_new();
1368 int fd;
1369
1370 if (engine == NULL)
1371 return;
1372 if ((fd = get_dev_crypto()) < 0) {
1373 ENGINE_free(engine);
1374 return;
1375 }
1376
1377 /*
1378 * find out what asymmetric crypto algorithms we support
1379 */
1380 if (ioctl(fd, CIOCASYMFEAT, &cryptodev_asymfeat) == -1) {
1381 put_dev_crypto(fd);
1382 ENGINE_free(engine);
1383 return;
1384 }
1385 put_dev_crypto(fd);
1386
1387 if (!ENGINE_set_id(engine, "cryptodev") ||
1388 !ENGINE_set_name(engine, "BSD cryptodev engine") ||
1389 !ENGINE_set_ciphers(engine, cryptodev_engine_ciphers) ||
1390 !ENGINE_set_digests(engine, cryptodev_engine_digests) ||
1391 !ENGINE_set_ctrl_function(engine, cryptodev_ctrl) ||
1392 !ENGINE_set_cmd_defns(engine, cryptodev_defns)) {
1393 ENGINE_free(engine);
1394 return;
1395 }
1396
1397 if (ENGINE_set_RSA(engine, &cryptodev_rsa)) {
1398 const RSA_METHOD *rsa_meth = RSA_PKCS1_SSLeay();
1399
1400 cryptodev_rsa.bn_mod_exp = rsa_meth->bn_mod_exp;
1401 cryptodev_rsa.rsa_mod_exp = rsa_meth->rsa_mod_exp;
1402 cryptodev_rsa.rsa_pub_enc = rsa_meth->rsa_pub_enc;
1403 cryptodev_rsa.rsa_pub_dec = rsa_meth->rsa_pub_dec;
1404 cryptodev_rsa.rsa_priv_enc = rsa_meth->rsa_priv_enc;
1405 cryptodev_rsa.rsa_priv_dec = rsa_meth->rsa_priv_dec;
1406 if (cryptodev_asymfeat & CRF_MOD_EXP) {
1407 cryptodev_rsa.bn_mod_exp = cryptodev_bn_mod_exp;
1408 if (cryptodev_asymfeat & CRF_MOD_EXP_CRT)
1409 cryptodev_rsa.rsa_mod_exp =
1410 cryptodev_rsa_mod_exp;
1411 else
1412 cryptodev_rsa.rsa_mod_exp =
1413 cryptodev_rsa_nocrt_mod_exp;
1414 }
1415 }
1416
1417 if (ENGINE_set_DSA(engine, &cryptodev_dsa)) {
1418 const DSA_METHOD *meth = DSA_OpenSSL();
1419
1420 memcpy(&cryptodev_dsa, meth, sizeof(DSA_METHOD));
1421 if (cryptodev_asymfeat & CRF_DSA_SIGN)
1422 cryptodev_dsa.dsa_do_sign = cryptodev_dsa_do_sign;
1423 if (cryptodev_asymfeat & CRF_MOD_EXP) {
1424 cryptodev_dsa.bn_mod_exp = cryptodev_dsa_bn_mod_exp;
1425 cryptodev_dsa.dsa_mod_exp = cryptodev_dsa_dsa_mod_exp;
1426 }
1427 if (cryptodev_asymfeat & CRF_DSA_VERIFY)
1428 cryptodev_dsa.dsa_do_verify = cryptodev_dsa_verify;
1429 }
1430
1431 if (ENGINE_set_DH(engine, &cryptodev_dh)){
1432 const DH_METHOD *dh_meth = DH_OpenSSL();
1433
1434 cryptodev_dh.generate_key = dh_meth->generate_key;
1435 cryptodev_dh.compute_key = dh_meth->compute_key;
1436 cryptodev_dh.bn_mod_exp = dh_meth->bn_mod_exp;
1437 if (cryptodev_asymfeat & CRF_MOD_EXP) {
1438 cryptodev_dh.bn_mod_exp = cryptodev_mod_exp_dh;
1439 if (cryptodev_asymfeat & CRF_DH_COMPUTE_KEY)
1440 cryptodev_dh.compute_key =
1441 cryptodev_dh_compute_key;
1442 }
1443 }
1444
1445 ENGINE_add(engine);
1446 ENGINE_free(engine);
1447 ERR_clear_error();
1448}
1449
1450#endif /* HAVE_CRYPTODEV */
diff --git a/src/lib/libcrypto/evp/evp_cnf.c b/src/lib/libcrypto/engine/eng_rdrand.c
index 2e4db30235..4e9e91d54b 100644
--- a/src/lib/libcrypto/evp/evp_cnf.c
+++ b/src/lib/libcrypto/engine/eng_rdrand.c
@@ -1,16 +1,12 @@
1/* evp_cnf.c */
2/* Written by Stephen Henson (steve@openssl.org) for the OpenSSL
3 * project 2007.
4 */
5/* ==================================================================== 1/* ====================================================================
6 * Copyright (c) 2007 The OpenSSL Project. All rights reserved. 2 * Copyright (c) 2011 The OpenSSL Project. All rights reserved.
7 * 3 *
8 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
10 * are met: 6 * are met:
11 * 7 *
12 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
14 * 10 *
15 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 12 * notice, this list of conditions and the following disclaimer in
@@ -49,77 +45,99 @@
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE. 46 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ==================================================================== 47 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */ 48 */
58 49
50#include <openssl/opensslconf.h>
51
59#include <stdio.h> 52#include <stdio.h>
60#include <ctype.h> 53#include <string.h>
61#include <openssl/crypto.h> 54#include <openssl/engine.h>
62#include "cryptlib.h" 55#include <openssl/rand.h>
63#include <openssl/conf.h> 56#include <openssl/err.h>
64#include <openssl/dso.h>
65#include <openssl/x509.h>
66#include <openssl/x509v3.h>
67#ifdef OPENSSL_FIPS
68#include <openssl/fips.h>
69#endif
70 57
58#if (defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
59 defined(__x86_64) || defined(__x86_64__) || \
60 defined(_M_AMD64) || defined (_M_X64)) && defined(OPENSSL_CPUID_OBJ)
71 61
72/* Algorithm configuration module. */ 62size_t OPENSSL_ia32_rdrand(void);
73 63
74static int alg_module_init(CONF_IMODULE *md, const CONF *cnf) 64static int get_random_bytes (unsigned char *buf, int num)
75 { 65 {
76 int i; 66 size_t rnd;
77 const char *oid_section; 67
78 STACK_OF(CONF_VALUE) *sktmp; 68 while (num>=(int)sizeof(size_t)) {
79 CONF_VALUE *oval; 69 if ((rnd = OPENSSL_ia32_rdrand()) == 0) return 0;
80 oid_section = CONF_imodule_get_value(md); 70
81 if(!(sktmp = NCONF_get_section(cnf, oid_section))) 71 *((size_t *)buf) = rnd;
82 { 72 buf += sizeof(size_t);
83 EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_ERROR_LOADING_SECTION); 73 num -= sizeof(size_t);
74 }
75 if (num) {
76 if ((rnd = OPENSSL_ia32_rdrand()) == 0) return 0;
77
78 memcpy (buf,&rnd,num);
79 }
80
81 return 1;
82 }
83
84static int random_status (void)
85{ return 1; }
86
87static RAND_METHOD rdrand_meth =
88 {
89 NULL, /* seed */
90 get_random_bytes,
91 NULL, /* cleanup */
92 NULL, /* add */
93 get_random_bytes,
94 random_status,
95 };
96
97static int rdrand_init(ENGINE *e)
98{ return 1; }
99
100static const char *engine_e_rdrand_id = "rdrand";
101static const char *engine_e_rdrand_name = "Intel RDRAND engine";
102
103static int bind_helper(ENGINE *e)
104 {
105 if (!ENGINE_set_id(e, engine_e_rdrand_id) ||
106 !ENGINE_set_name(e, engine_e_rdrand_name) ||
107 !ENGINE_set_flags(e, ENGINE_FLAGS_NO_REGISTER_ALL) ||
108 !ENGINE_set_init_function(e, rdrand_init) ||
109 !ENGINE_set_RAND(e, &rdrand_meth) )
84 return 0; 110 return 0;
85 } 111
86 for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++) 112 return 1;
113 }
114
115static ENGINE *ENGINE_rdrand(void)
116 {
117 ENGINE *ret = ENGINE_new();
118 if(!ret)
119 return NULL;
120 if(!bind_helper(ret))
87 { 121 {
88 oval = sk_CONF_VALUE_value(sktmp, i); 122 ENGINE_free(ret);
89 if (!strcmp(oval->name, "fips_mode")) 123 return NULL;
90 {
91 int m;
92 if (!X509V3_get_value_bool(oval, &m))
93 {
94 EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_INVALID_FIPS_MODE);
95 return 0;
96 }
97 if (m > 0)
98 {
99#ifdef OPENSSL_FIPS
100 if (!FIPS_mode() && !FIPS_mode_set(1))
101 {
102 EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_ERROR_SETTING_FIPS_MODE);
103 return 0;
104 }
105#else
106 EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_FIPS_MODE_NOT_SUPPORTED);
107 return 0;
108#endif
109 }
110 }
111 else
112 {
113 EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_UNKNOWN_OPTION);
114 ERR_add_error_data(4, "name=", oval->name,
115 ", value=", oval->value);
116 }
117
118 } 124 }
119 return 1; 125 return ret;
120 } 126 }
121 127
122void EVP_add_alg_module(void) 128void ENGINE_load_rdrand (void)
123 { 129 {
124 CONF_module_add("alg_section", alg_module_init, 0); 130 extern unsigned int OPENSSL_ia32cap_P[];
131
132 if (OPENSSL_ia32cap_P[1] & (1<<(62-32)))
133 {
134 ENGINE *toadd = ENGINE_rdrand();
135 if(!toadd) return;
136 ENGINE_add(toadd);
137 ENGINE_free(toadd);
138 ERR_clear_error();
139 }
125 } 140 }
141#else
142void ENGINE_load_rdrand (void) {}
143#endif
diff --git a/src/lib/libcrypto/engine/eng_rsax.c b/src/lib/libcrypto/engine/eng_rsax.c
new file mode 100644
index 0000000000..96e63477ee
--- /dev/null
+++ b/src/lib/libcrypto/engine/eng_rsax.c
@@ -0,0 +1,668 @@
1/* crypto/engine/eng_rsax.c */
2/* Copyright (c) 2010-2010 Intel Corp.
3 * Author: Vinodh.Gopal@intel.com
4 * Jim Guilford
5 * Erdinc.Ozturk@intel.com
6 * Maxim.Perminov@intel.com
7 * Ying.Huang@intel.com
8 *
9 * More information about algorithm used can be found at:
10 * http://www.cse.buffalo.edu/srds2009/escs2009_submission_Gopal.pdf
11 */
12/* ====================================================================
13 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 *
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 *
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in
24 * the documentation and/or other materials provided with the
25 * distribution.
26 *
27 * 3. All advertising materials mentioning features or use of this
28 * software must display the following acknowledgment:
29 * "This product includes software developed by the OpenSSL Project
30 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
31 *
32 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
33 * endorse or promote products derived from this software without
34 * prior written permission. For written permission, please contact
35 * licensing@OpenSSL.org.
36 *
37 * 5. Products derived from this software may not be called "OpenSSL"
38 * nor may "OpenSSL" appear in their names without prior written
39 * permission of the OpenSSL Project.
40 *
41 * 6. Redistributions of any form whatsoever must retain the following
42 * acknowledgment:
43 * "This product includes software developed by the OpenSSL Project
44 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
45 *
46 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
47 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
49 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
50 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
52 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
55 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
57 * OF THE POSSIBILITY OF SUCH DAMAGE.
58 * ====================================================================
59 *
60 * This product includes cryptographic software written by Eric Young
61 * (eay@cryptsoft.com). This product includes software written by Tim
62 * Hudson (tjh@cryptsoft.com).
63 */
64
65#include <openssl/opensslconf.h>
66
67#include <stdio.h>
68#include <string.h>
69#include <openssl/crypto.h>
70#include <openssl/buffer.h>
71#include <openssl/engine.h>
72#ifndef OPENSSL_NO_RSA
73#include <openssl/rsa.h>
74#endif
75#include <openssl/bn.h>
76#include <openssl/err.h>
77
78/* RSAX is available **ONLY* on x86_64 CPUs */
79#undef COMPILE_RSAX
80
81#if (defined(__x86_64) || defined(__x86_64__) || \
82 defined(_M_AMD64) || defined (_M_X64)) && !defined(OPENSSL_NO_ASM)
83#define COMPILE_RSAX
84static ENGINE *ENGINE_rsax (void);
85#endif
86
87void ENGINE_load_rsax (void)
88 {
89/* On non-x86 CPUs it just returns. */
90#ifdef COMPILE_RSAX
91 ENGINE *toadd = ENGINE_rsax();
92 if(!toadd) return;
93 ENGINE_add(toadd);
94 ENGINE_free(toadd);
95 ERR_clear_error();
96#endif
97 }
98
99#ifdef COMPILE_RSAX
100#define E_RSAX_LIB_NAME "rsax engine"
101
102static int e_rsax_destroy(ENGINE *e);
103static int e_rsax_init(ENGINE *e);
104static int e_rsax_finish(ENGINE *e);
105static int e_rsax_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void));
106
107#ifndef OPENSSL_NO_RSA
108/* RSA stuff */
109static int e_rsax_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
110static int e_rsax_rsa_finish(RSA *r);
111#endif
112
113static const ENGINE_CMD_DEFN e_rsax_cmd_defns[] = {
114 {0, NULL, NULL, 0}
115 };
116
117#ifndef OPENSSL_NO_RSA
118/* Our internal RSA_METHOD that we provide pointers to */
119static RSA_METHOD e_rsax_rsa =
120 {
121 "Intel RSA-X method",
122 NULL,
123 NULL,
124 NULL,
125 NULL,
126 e_rsax_rsa_mod_exp,
127 NULL,
128 NULL,
129 e_rsax_rsa_finish,
130 RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE,
131 NULL,
132 NULL,
133 NULL
134 };
135#endif
136
137/* Constants used when creating the ENGINE */
138static const char *engine_e_rsax_id = "rsax";
139static const char *engine_e_rsax_name = "RSAX engine support";
140
141/* This internal function is used by ENGINE_rsax() */
142static int bind_helper(ENGINE *e)
143 {
144#ifndef OPENSSL_NO_RSA
145 const RSA_METHOD *meth1;
146#endif
147 if(!ENGINE_set_id(e, engine_e_rsax_id) ||
148 !ENGINE_set_name(e, engine_e_rsax_name) ||
149#ifndef OPENSSL_NO_RSA
150 !ENGINE_set_RSA(e, &e_rsax_rsa) ||
151#endif
152 !ENGINE_set_destroy_function(e, e_rsax_destroy) ||
153 !ENGINE_set_init_function(e, e_rsax_init) ||
154 !ENGINE_set_finish_function(e, e_rsax_finish) ||
155 !ENGINE_set_ctrl_function(e, e_rsax_ctrl) ||
156 !ENGINE_set_cmd_defns(e, e_rsax_cmd_defns))
157 return 0;
158
159#ifndef OPENSSL_NO_RSA
160 meth1 = RSA_PKCS1_SSLeay();
161 e_rsax_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
162 e_rsax_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
163 e_rsax_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
164 e_rsax_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
165 e_rsax_rsa.bn_mod_exp = meth1->bn_mod_exp;
166#endif
167 return 1;
168 }
169
170static ENGINE *ENGINE_rsax(void)
171 {
172 ENGINE *ret = ENGINE_new();
173 if(!ret)
174 return NULL;
175 if(!bind_helper(ret))
176 {
177 ENGINE_free(ret);
178 return NULL;
179 }
180 return ret;
181 }
182
183#ifndef OPENSSL_NO_RSA
184/* Used to attach our own key-data to an RSA structure */
185static int rsax_ex_data_idx = -1;
186#endif
187
188static int e_rsax_destroy(ENGINE *e)
189 {
190 return 1;
191 }
192
193/* (de)initialisation functions. */
194static int e_rsax_init(ENGINE *e)
195 {
196#ifndef OPENSSL_NO_RSA
197 if (rsax_ex_data_idx == -1)
198 rsax_ex_data_idx = RSA_get_ex_new_index(0,
199 NULL,
200 NULL, NULL, NULL);
201#endif
202 if (rsax_ex_data_idx == -1)
203 return 0;
204 return 1;
205 }
206
207static int e_rsax_finish(ENGINE *e)
208 {
209 return 1;
210 }
211
212static int e_rsax_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
213 {
214 int to_return = 1;
215
216 switch(cmd)
217 {
218 /* The command isn't understood by this engine */
219 default:
220 to_return = 0;
221 break;
222 }
223
224 return to_return;
225 }
226
227
228#ifndef OPENSSL_NO_RSA
229
230#ifdef _WIN32
231typedef unsigned __int64 UINT64;
232#else
233typedef unsigned long long UINT64;
234#endif
235typedef unsigned short UINT16;
236
237/* Table t is interleaved in the following manner:
238 * The order in memory is t[0][0], t[0][1], ..., t[0][7], t[1][0], ...
239 * A particular 512-bit value is stored in t[][index] rather than the more
240 * normal t[index][]; i.e. the qwords of a particular entry in t are not
241 * adjacent in memory
242 */
243
244/* Init BIGNUM b from the interleaved UINT64 array */
245static int interleaved_array_to_bn_512(BIGNUM* b, UINT64 *array);
246
247/* Extract array elements from BIGNUM b
248 * To set the whole array from b, call with n=8
249 */
250static int bn_extract_to_array_512(const BIGNUM* b, unsigned int n, UINT64 *array);
251
252struct mod_ctx_512 {
253 UINT64 t[8][8];
254 UINT64 m[8];
255 UINT64 m1[8]; /* 2^278 % m */
256 UINT64 m2[8]; /* 2^640 % m */
257 UINT64 k1[2]; /* (- 1/m) % 2^128 */
258};
259
260static int mod_exp_pre_compute_data_512(UINT64 *m, struct mod_ctx_512 *data);
261
262void mod_exp_512(UINT64 *result, /* 512 bits, 8 qwords */
263 UINT64 *g, /* 512 bits, 8 qwords */
264 UINT64 *exp, /* 512 bits, 8 qwords */
265 struct mod_ctx_512 *data);
266
267typedef struct st_e_rsax_mod_ctx
268{
269 UINT64 type;
270 union {
271 struct mod_ctx_512 b512;
272 } ctx;
273
274} E_RSAX_MOD_CTX;
275
276static E_RSAX_MOD_CTX *e_rsax_get_ctx(RSA *rsa, int idx, BIGNUM* m)
277{
278 E_RSAX_MOD_CTX *hptr;
279
280 if (idx < 0 || idx > 2)
281 return NULL;
282
283 hptr = RSA_get_ex_data(rsa, rsax_ex_data_idx);
284 if (!hptr) {
285 hptr = OPENSSL_malloc(3*sizeof(E_RSAX_MOD_CTX));
286 if (!hptr) return NULL;
287 hptr[2].type = hptr[1].type= hptr[0].type = 0;
288 RSA_set_ex_data(rsa, rsax_ex_data_idx, hptr);
289 }
290
291 if (hptr[idx].type == (UINT64)BN_num_bits(m))
292 return hptr+idx;
293
294 if (BN_num_bits(m) == 512) {
295 UINT64 _m[8];
296 bn_extract_to_array_512(m, 8, _m);
297 memset( &hptr[idx].ctx.b512, 0, sizeof(struct mod_ctx_512));
298 mod_exp_pre_compute_data_512(_m, &hptr[idx].ctx.b512);
299 }
300
301 hptr[idx].type = BN_num_bits(m);
302 return hptr+idx;
303}
304
305static int e_rsax_rsa_finish(RSA *rsa)
306 {
307 E_RSAX_MOD_CTX *hptr = RSA_get_ex_data(rsa, rsax_ex_data_idx);
308 if(hptr)
309 {
310 OPENSSL_free(hptr);
311 RSA_set_ex_data(rsa, rsax_ex_data_idx, NULL);
312 }
313 if (rsa->_method_mod_n)
314 BN_MONT_CTX_free(rsa->_method_mod_n);
315 if (rsa->_method_mod_p)
316 BN_MONT_CTX_free(rsa->_method_mod_p);
317 if (rsa->_method_mod_q)
318 BN_MONT_CTX_free(rsa->_method_mod_q);
319 return 1;
320 }
321
322
323static int e_rsax_bn_mod_exp(BIGNUM *r, const BIGNUM *g, const BIGNUM *e,
324 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont, E_RSAX_MOD_CTX* rsax_mod_ctx )
325{
326 if (rsax_mod_ctx && BN_get_flags(e, BN_FLG_CONSTTIME) != 0) {
327 if (BN_num_bits(m) == 512) {
328 UINT64 _r[8];
329 UINT64 _g[8];
330 UINT64 _e[8];
331
332 /* Init the arrays from the BIGNUMs */
333 bn_extract_to_array_512(g, 8, _g);
334 bn_extract_to_array_512(e, 8, _e);
335
336 mod_exp_512(_r, _g, _e, &rsax_mod_ctx->ctx.b512);
337 /* Return the result in the BIGNUM */
338 interleaved_array_to_bn_512(r, _r);
339 return 1;
340 }
341 }
342
343 return BN_mod_exp_mont(r, g, e, m, ctx, in_mont);
344}
345
346/* Declares for the Intel CIAP 512-bit / CRT / 1024 bit RSA modular
347 * exponentiation routine precalculations and a structure to hold the
348 * necessary values. These files are meant to live in crypto/rsa/ in
349 * the target openssl.
350 */
351
352/*
353 * Local method: extracts a piece from a BIGNUM, to fit it into
354 * an array. Call with n=8 to extract an entire 512-bit BIGNUM
355 */
356static int bn_extract_to_array_512(const BIGNUM* b, unsigned int n, UINT64 *array)
357{
358 int i;
359 UINT64 tmp;
360 unsigned char bn_buff[64];
361 memset(bn_buff, 0, 64);
362 if (BN_num_bytes(b) > 64) {
363 printf ("Can't support this byte size\n");
364 return 0; }
365 if (BN_num_bytes(b)!=0) {
366 if (!BN_bn2bin(b, bn_buff+(64-BN_num_bytes(b)))) {
367 printf ("Error's in bn2bin\n");
368 /* We have to error, here */
369 return 0; } }
370 while (n-- > 0) {
371 array[n] = 0;
372 for (i=7; i>=0; i--) {
373 tmp = bn_buff[63-(n*8+i)];
374 array[n] |= tmp << (8*i); } }
375 return 1;
376}
377
378/* Init a 512-bit BIGNUM from the UINT64*_ (8 * 64) interleaved array */
379static int interleaved_array_to_bn_512(BIGNUM* b, UINT64 *array)
380{
381 unsigned char tmp[64];
382 int n=8;
383 int i;
384 while (n-- > 0) {
385 for (i = 7; i>=0; i--) {
386 tmp[63-(n*8+i)] = (unsigned char)(array[n]>>(8*i)); } }
387 BN_bin2bn(tmp, 64, b);
388 return 0;
389}
390
391
392/* The main 512bit precompute call */
393static int mod_exp_pre_compute_data_512(UINT64 *m, struct mod_ctx_512 *data)
394 {
395 BIGNUM two_768, two_640, two_128, two_512, tmp, _m, tmp2;
396
397 /* We need a BN_CTX for the modulo functions */
398 BN_CTX* ctx;
399 /* Some tmps */
400 UINT64 _t[8];
401 int i, j, ret = 0;
402
403 /* Init _m with m */
404 BN_init(&_m);
405 interleaved_array_to_bn_512(&_m, m);
406 memset(_t, 0, 64);
407
408 /* Inits */
409 BN_init(&two_768);
410 BN_init(&two_640);
411 BN_init(&two_128);
412 BN_init(&two_512);
413 BN_init(&tmp);
414 BN_init(&tmp2);
415
416 /* Create our context */
417 if ((ctx=BN_CTX_new()) == NULL) { goto err; }
418 BN_CTX_start(ctx);
419
420 /*
421 * For production, if you care, these only need to be set once,
422 * and may be made constants.
423 */
424 BN_lshift(&two_768, BN_value_one(), 768);
425 BN_lshift(&two_640, BN_value_one(), 640);
426 BN_lshift(&two_128, BN_value_one(), 128);
427 BN_lshift(&two_512, BN_value_one(), 512);
428
429 if (0 == (m[7] & 0x8000000000000000)) {
430 exit(1);
431 }
432 if (0 == (m[0] & 0x1)) { /* Odd modulus required for Mont */
433 exit(1);
434 }
435
436 /* Precompute m1 */
437 BN_mod(&tmp, &two_768, &_m, ctx);
438 if (!bn_extract_to_array_512(&tmp, 8, &data->m1[0])) {
439 goto err; }
440
441 /* Precompute m2 */
442 BN_mod(&tmp, &two_640, &_m, ctx);
443 if (!bn_extract_to_array_512(&tmp, 8, &data->m2[0])) {
444 goto err;
445 }
446
447 /*
448 * Precompute k1, a 128b number = ((-1)* m-1 ) mod 2128; k1 should
449 * be non-negative.
450 */
451 BN_mod_inverse(&tmp, &_m, &two_128, ctx);
452 if (!BN_is_zero(&tmp)) { BN_sub(&tmp, &two_128, &tmp); }
453 if (!bn_extract_to_array_512(&tmp, 2, &data->k1[0])) {
454 goto err; }
455
456 /* Precompute t */
457 for (i=0; i<8; i++) {
458 BN_zero(&tmp);
459 if (i & 1) { BN_add(&tmp, &two_512, &tmp); }
460 if (i & 2) { BN_add(&tmp, &two_512, &tmp); }
461 if (i & 4) { BN_add(&tmp, &two_640, &tmp); }
462
463 BN_nnmod(&tmp2, &tmp, &_m, ctx);
464 if (!bn_extract_to_array_512(&tmp2, 8, _t)) {
465 goto err; }
466 for (j=0; j<8; j++) data->t[j][i] = _t[j]; }
467
468 /* Precompute m */
469 for (i=0; i<8; i++) {
470 data->m[i] = m[i]; }
471
472 ret = 1;
473
474err:
475 /* Cleanup */
476 if (ctx != NULL) {
477 BN_CTX_end(ctx); BN_CTX_free(ctx); }
478 BN_free(&two_768);
479 BN_free(&two_640);
480 BN_free(&two_128);
481 BN_free(&two_512);
482 BN_free(&tmp);
483 BN_free(&tmp2);
484 BN_free(&_m);
485
486 return ret;
487}
488
489
490static int e_rsax_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
491 {
492 BIGNUM *r1,*m1,*vrfy;
493 BIGNUM local_dmp1,local_dmq1,local_c,local_r1;
494 BIGNUM *dmp1,*dmq1,*c,*pr1;
495 int ret=0;
496
497 BN_CTX_start(ctx);
498 r1 = BN_CTX_get(ctx);
499 m1 = BN_CTX_get(ctx);
500 vrfy = BN_CTX_get(ctx);
501
502 {
503 BIGNUM local_p, local_q;
504 BIGNUM *p = NULL, *q = NULL;
505 int error = 0;
506
507 /* Make sure BN_mod_inverse in Montgomery
508 * intialization uses the BN_FLG_CONSTTIME flag
509 * (unless RSA_FLAG_NO_CONSTTIME is set)
510 */
511 if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME))
512 {
513 BN_init(&local_p);
514 p = &local_p;
515 BN_with_flags(p, rsa->p, BN_FLG_CONSTTIME);
516
517 BN_init(&local_q);
518 q = &local_q;
519 BN_with_flags(q, rsa->q, BN_FLG_CONSTTIME);
520 }
521 else
522 {
523 p = rsa->p;
524 q = rsa->q;
525 }
526
527 if (rsa->flags & RSA_FLAG_CACHE_PRIVATE)
528 {
529 if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_p, CRYPTO_LOCK_RSA, p, ctx))
530 error = 1;
531 if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_q, CRYPTO_LOCK_RSA, q, ctx))
532 error = 1;
533 }
534
535 /* clean up */
536 if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME))
537 {
538 BN_free(&local_p);
539 BN_free(&local_q);
540 }
541 if ( error )
542 goto err;
543 }
544
545 if (rsa->flags & RSA_FLAG_CACHE_PUBLIC)
546 if (!BN_MONT_CTX_set_locked(&rsa->_method_mod_n, CRYPTO_LOCK_RSA, rsa->n, ctx))
547 goto err;
548
549 /* compute I mod q */
550 if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME))
551 {
552 c = &local_c;
553 BN_with_flags(c, I, BN_FLG_CONSTTIME);
554 if (!BN_mod(r1,c,rsa->q,ctx)) goto err;
555 }
556 else
557 {
558 if (!BN_mod(r1,I,rsa->q,ctx)) goto err;
559 }
560
561 /* compute r1^dmq1 mod q */
562 if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME))
563 {
564 dmq1 = &local_dmq1;
565 BN_with_flags(dmq1, rsa->dmq1, BN_FLG_CONSTTIME);
566 }
567 else
568 dmq1 = rsa->dmq1;
569
570 if (!e_rsax_bn_mod_exp(m1,r1,dmq1,rsa->q,ctx,
571 rsa->_method_mod_q, e_rsax_get_ctx(rsa, 0, rsa->q) )) goto err;
572
573 /* compute I mod p */
574 if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME))
575 {
576 c = &local_c;
577 BN_with_flags(c, I, BN_FLG_CONSTTIME);
578 if (!BN_mod(r1,c,rsa->p,ctx)) goto err;
579 }
580 else
581 {
582 if (!BN_mod(r1,I,rsa->p,ctx)) goto err;
583 }
584
585 /* compute r1^dmp1 mod p */
586 if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME))
587 {
588 dmp1 = &local_dmp1;
589 BN_with_flags(dmp1, rsa->dmp1, BN_FLG_CONSTTIME);
590 }
591 else
592 dmp1 = rsa->dmp1;
593
594 if (!e_rsax_bn_mod_exp(r0,r1,dmp1,rsa->p,ctx,
595 rsa->_method_mod_p, e_rsax_get_ctx(rsa, 1, rsa->p) )) goto err;
596
597 if (!BN_sub(r0,r0,m1)) goto err;
598 /* This will help stop the size of r0 increasing, which does
599 * affect the multiply if it optimised for a power of 2 size */
600 if (BN_is_negative(r0))
601 if (!BN_add(r0,r0,rsa->p)) goto err;
602
603 if (!BN_mul(r1,r0,rsa->iqmp,ctx)) goto err;
604
605 /* Turn BN_FLG_CONSTTIME flag on before division operation */
606 if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME))
607 {
608 pr1 = &local_r1;
609 BN_with_flags(pr1, r1, BN_FLG_CONSTTIME);
610 }
611 else
612 pr1 = r1;
613 if (!BN_mod(r0,pr1,rsa->p,ctx)) goto err;
614
615 /* If p < q it is occasionally possible for the correction of
616 * adding 'p' if r0 is negative above to leave the result still
617 * negative. This can break the private key operations: the following
618 * second correction should *always* correct this rare occurrence.
619 * This will *never* happen with OpenSSL generated keys because
620 * they ensure p > q [steve]
621 */
622 if (BN_is_negative(r0))
623 if (!BN_add(r0,r0,rsa->p)) goto err;
624 if (!BN_mul(r1,r0,rsa->q,ctx)) goto err;
625 if (!BN_add(r0,r1,m1)) goto err;
626
627 if (rsa->e && rsa->n)
628 {
629 if (!e_rsax_bn_mod_exp(vrfy,r0,rsa->e,rsa->n,ctx,rsa->_method_mod_n, e_rsax_get_ctx(rsa, 2, rsa->n) ))
630 goto err;
631
632 /* If 'I' was greater than (or equal to) rsa->n, the operation
633 * will be equivalent to using 'I mod n'. However, the result of
634 * the verify will *always* be less than 'n' so we don't check
635 * for absolute equality, just congruency. */
636 if (!BN_sub(vrfy, vrfy, I)) goto err;
637 if (!BN_mod(vrfy, vrfy, rsa->n, ctx)) goto err;
638 if (BN_is_negative(vrfy))
639 if (!BN_add(vrfy, vrfy, rsa->n)) goto err;
640 if (!BN_is_zero(vrfy))
641 {
642 /* 'I' and 'vrfy' aren't congruent mod n. Don't leak
643 * miscalculated CRT output, just do a raw (slower)
644 * mod_exp and return that instead. */
645
646 BIGNUM local_d;
647 BIGNUM *d = NULL;
648
649 if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME))
650 {
651 d = &local_d;
652 BN_with_flags(d, rsa->d, BN_FLG_CONSTTIME);
653 }
654 else
655 d = rsa->d;
656 if (!e_rsax_bn_mod_exp(r0,I,d,rsa->n,ctx,
657 rsa->_method_mod_n, e_rsax_get_ctx(rsa, 2, rsa->n) )) goto err;
658 }
659 }
660 ret=1;
661
662err:
663 BN_CTX_end(ctx);
664
665 return ret;
666 }
667#endif /* !OPENSSL_NO_RSA */
668#endif /* !COMPILE_RSAX */
diff --git a/src/lib/libcrypto/engine/hw.ec b/src/lib/libcrypto/engine/hw.ec
deleted file mode 100644
index 5481a43918..0000000000
--- a/src/lib/libcrypto/engine/hw.ec
+++ /dev/null
@@ -1,8 +0,0 @@
1L AEPHK hw_aep_err.h hw_aep_err.c
2L ATALLA hw_atalla_err.h hw_atalla_err.c
3L CSWIFT hw_cswift_err.h hw_cswift_err.c
4L HWCRHK hw_ncipher_err.h hw_ncipher_err.c
5L NURON hw_nuron_err.h hw_nuron_err.c
6L SUREWARE hw_sureware_err.h hw_sureware_err.c
7L UBSEC hw_ubsec_err.h hw_ubsec_err.c
8L CCA4758 hw_4758_cca_err.h hw_4758_cca_err.c
diff --git a/src/lib/libcrypto/engine/hw_4758_cca.c b/src/lib/libcrypto/engine/hw_4758_cca.c
deleted file mode 100644
index 4f5ae8a46d..0000000000
--- a/src/lib/libcrypto/engine/hw_4758_cca.c
+++ /dev/null
@@ -1,969 +0,0 @@
1/* Author: Maurice Gittens <maurice@gittens.nl> */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * licensing@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56#include <stdio.h>
57#include <openssl/crypto.h>
58/* #include <openssl/pem.h> */
59#include "cryptlib.h"
60#include <openssl/dso.h>
61#include <openssl/x509.h>
62#include <openssl/objects.h>
63#include <openssl/engine.h>
64
65#ifndef OPENSSL_NO_HW
66#ifndef OPENSSL_NO_HW_4758_CCA
67
68#ifdef FLAT_INC
69#include "hw_4758_cca.h"
70#else
71#include "vendor_defns/hw_4758_cca.h"
72#endif
73
74#include "hw_4758_cca_err.c"
75
76static int ibm_4758_cca_destroy(ENGINE *e);
77static int ibm_4758_cca_init(ENGINE *e);
78static int ibm_4758_cca_finish(ENGINE *e);
79static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
80
81/* rsa functions */
82/*---------------*/
83#ifndef OPENSSL_NO_RSA
84static int cca_rsa_pub_enc(int flen, const unsigned char *from,
85 unsigned char *to, RSA *rsa,int padding);
86static int cca_rsa_priv_dec(int flen, const unsigned char *from,
87 unsigned char *to, RSA *rsa,int padding);
88static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
89 unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
90static int cca_rsa_verify(int dtype, const unsigned char *m, unsigned int m_len,
91 unsigned char *sigbuf, unsigned int siglen, const RSA *rsa);
92
93/* utility functions */
94/*-----------------------*/
95static EVP_PKEY *ibm_4758_load_privkey(ENGINE*, const char*,
96 UI_METHOD *ui_method, void *callback_data);
97static EVP_PKEY *ibm_4758_load_pubkey(ENGINE*, const char*,
98 UI_METHOD *ui_method, void *callback_data);
99
100static int getModulusAndExponent(const unsigned char *token, long *exponentLength,
101 unsigned char *exponent, long *modulusLength,
102 long *modulusFieldLength, unsigned char *modulus);
103#endif
104
105/* RAND number functions */
106/*-----------------------*/
107static int cca_get_random_bytes(unsigned char*, int );
108static int cca_random_status(void);
109
110static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
111 int idx,long argl, void *argp);
112
113/* Function pointers for CCA verbs */
114/*---------------------------------*/
115#ifndef OPENSSL_NO_RSA
116static F_KEYRECORDREAD keyRecordRead;
117static F_DIGITALSIGNATUREGENERATE digitalSignatureGenerate;
118static F_DIGITALSIGNATUREVERIFY digitalSignatureVerify;
119static F_PUBLICKEYEXTRACT publicKeyExtract;
120static F_PKAENCRYPT pkaEncrypt;
121static F_PKADECRYPT pkaDecrypt;
122#endif
123static F_RANDOMNUMBERGENERATE randomNumberGenerate;
124
125/* static variables */
126/*------------------*/
127static const char *CCA4758_LIB_NAME = NULL;
128static const char *get_CCA4758_LIB_NAME(void)
129 {
130 if(CCA4758_LIB_NAME)
131 return CCA4758_LIB_NAME;
132 return CCA_LIB_NAME;
133 }
134static void free_CCA4758_LIB_NAME(void)
135 {
136 if(CCA4758_LIB_NAME)
137 OPENSSL_free((void*)CCA4758_LIB_NAME);
138 CCA4758_LIB_NAME = NULL;
139 }
140static long set_CCA4758_LIB_NAME(const char *name)
141 {
142 free_CCA4758_LIB_NAME();
143 return (((CCA4758_LIB_NAME = BUF_strdup(name)) != NULL) ? 1 : 0);
144 }
145#ifndef OPENSSL_NO_RSA
146static const char* n_keyRecordRead = CSNDKRR;
147static const char* n_digitalSignatureGenerate = CSNDDSG;
148static const char* n_digitalSignatureVerify = CSNDDSV;
149static const char* n_publicKeyExtract = CSNDPKX;
150static const char* n_pkaEncrypt = CSNDPKE;
151static const char* n_pkaDecrypt = CSNDPKD;
152#endif
153static const char* n_randomNumberGenerate = CSNBRNG;
154
155static int hndidx = -1;
156static DSO *dso = NULL;
157
158/* openssl engine initialization structures */
159/*------------------------------------------*/
160
161#define CCA4758_CMD_SO_PATH ENGINE_CMD_BASE
162static const ENGINE_CMD_DEFN cca4758_cmd_defns[] = {
163 {CCA4758_CMD_SO_PATH,
164 "SO_PATH",
165 "Specifies the path to the '4758cca' shared library",
166 ENGINE_CMD_FLAG_STRING},
167 {0, NULL, NULL, 0}
168 };
169
170#ifndef OPENSSL_NO_RSA
171static RSA_METHOD ibm_4758_cca_rsa =
172 {
173 "IBM 4758 CCA RSA method",
174 cca_rsa_pub_enc,
175 NULL,
176 NULL,
177 cca_rsa_priv_dec,
178 NULL, /*rsa_mod_exp,*/
179 NULL, /*mod_exp_mont,*/
180 NULL, /* init */
181 NULL, /* finish */
182 RSA_FLAG_SIGN_VER, /* flags */
183 NULL, /* app_data */
184 cca_rsa_sign, /* rsa_sign */
185 cca_rsa_verify /* rsa_verify */
186 };
187#endif
188
189static RAND_METHOD ibm_4758_cca_rand =
190 {
191 /* "IBM 4758 RAND method", */
192 NULL, /* seed */
193 cca_get_random_bytes, /* get random bytes from the card */
194 NULL, /* cleanup */
195 NULL, /* add */
196 cca_get_random_bytes, /* pseudo rand */
197 cca_random_status, /* status */
198 };
199
200static const char *engine_4758_cca_id = "4758cca";
201static const char *engine_4758_cca_name = "IBM 4758 CCA hardware engine support";
202
203/* engine implementation */
204/*-----------------------*/
205static int bind_helper(ENGINE *e)
206 {
207 if(!ENGINE_set_id(e, engine_4758_cca_id) ||
208 !ENGINE_set_name(e, engine_4758_cca_name) ||
209#ifndef OPENSSL_NO_RSA
210 !ENGINE_set_RSA(e, &ibm_4758_cca_rsa) ||
211#endif
212 !ENGINE_set_RAND(e, &ibm_4758_cca_rand) ||
213 !ENGINE_set_destroy_function(e, ibm_4758_cca_destroy) ||
214 !ENGINE_set_init_function(e, ibm_4758_cca_init) ||
215 !ENGINE_set_finish_function(e, ibm_4758_cca_finish) ||
216 !ENGINE_set_ctrl_function(e, ibm_4758_cca_ctrl) ||
217 !ENGINE_set_load_privkey_function(e, ibm_4758_load_privkey) ||
218 !ENGINE_set_load_pubkey_function(e, ibm_4758_load_pubkey) ||
219 !ENGINE_set_cmd_defns(e, cca4758_cmd_defns))
220 return 0;
221 /* Ensure the error handling is set up */
222 ERR_load_CCA4758_strings();
223 return 1;
224 }
225
226#ifndef ENGINE_DYNAMIC_SUPPORT
227static ENGINE *engine_4758_cca(void)
228 {
229 ENGINE *ret = ENGINE_new();
230 if(!ret)
231 return NULL;
232 if(!bind_helper(ret))
233 {
234 ENGINE_free(ret);
235 return NULL;
236 }
237 return ret;
238 }
239
240void ENGINE_load_4758cca(void)
241 {
242 ENGINE *e_4758 = engine_4758_cca();
243 if (!e_4758) return;
244 ENGINE_add(e_4758);
245 ENGINE_free(e_4758);
246 ERR_clear_error();
247 }
248#endif
249
250static int ibm_4758_cca_destroy(ENGINE *e)
251 {
252 ERR_unload_CCA4758_strings();
253 free_CCA4758_LIB_NAME();
254 return 1;
255 }
256
257static int ibm_4758_cca_init(ENGINE *e)
258 {
259 if(dso)
260 {
261 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_ALREADY_LOADED);
262 goto err;
263 }
264
265 dso = DSO_load(NULL, get_CCA4758_LIB_NAME(), NULL, 0);
266 if(!dso)
267 {
268 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
269 goto err;
270 }
271
272#ifndef OPENSSL_NO_RSA
273 if(!(keyRecordRead = (F_KEYRECORDREAD)
274 DSO_bind_func(dso, n_keyRecordRead)) ||
275 !(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
276 DSO_bind_func(dso, n_randomNumberGenerate)) ||
277 !(digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)
278 DSO_bind_func(dso, n_digitalSignatureGenerate)) ||
279 !(digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)
280 DSO_bind_func(dso, n_digitalSignatureVerify)) ||
281 !(publicKeyExtract = (F_PUBLICKEYEXTRACT)
282 DSO_bind_func(dso, n_publicKeyExtract)) ||
283 !(pkaEncrypt = (F_PKAENCRYPT)
284 DSO_bind_func(dso, n_pkaEncrypt)) ||
285 !(pkaDecrypt = (F_PKADECRYPT)
286 DSO_bind_func(dso, n_pkaDecrypt)))
287 {
288 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
289 goto err;
290 }
291#else
292 if(!(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
293 DSO_bind_func(dso, n_randomNumberGenerate)))
294 {
295 CCA4758err(CCA4758_F_IBM_4758_CCA_INIT,CCA4758_R_DSO_FAILURE);
296 goto err;
297 }
298#endif
299
300 hndidx = RSA_get_ex_new_index(0, "IBM 4758 CCA RSA key handle",
301 NULL, NULL, cca_ex_free);
302
303 return 1;
304err:
305 if(dso)
306 DSO_free(dso);
307 dso = NULL;
308
309 keyRecordRead = (F_KEYRECORDREAD)0;
310 randomNumberGenerate = (F_RANDOMNUMBERGENERATE)0;
311 digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)0;
312 digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)0;
313 publicKeyExtract = (F_PUBLICKEYEXTRACT)0;
314 pkaEncrypt = (F_PKAENCRYPT)0;
315 pkaDecrypt = (F_PKADECRYPT)0;
316 return 0;
317 }
318
319static int ibm_4758_cca_finish(ENGINE *e)
320 {
321 free_CCA4758_LIB_NAME();
322 if(!dso)
323 {
324 CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH,
325 CCA4758_R_NOT_LOADED);
326 return 0;
327 }
328 if(!DSO_free(dso))
329 {
330 CCA4758err(CCA4758_F_IBM_4758_CCA_FINISH,
331 CCA4758_R_UNIT_FAILURE);
332 return 0;
333 }
334 dso = NULL;
335 keyRecordRead = (F_KEYRECORDREAD)0;
336 randomNumberGenerate = (F_RANDOMNUMBERGENERATE)0;
337 digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)0;
338 digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)0;
339 publicKeyExtract = (F_PUBLICKEYEXTRACT)0;
340 pkaEncrypt = (F_PKAENCRYPT)0;
341 pkaDecrypt = (F_PKADECRYPT)0;
342 return 1;
343 }
344
345static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
346 {
347 int initialised = ((dso == NULL) ? 0 : 1);
348 switch(cmd)
349 {
350 case CCA4758_CMD_SO_PATH:
351 if(p == NULL)
352 {
353 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
354 ERR_R_PASSED_NULL_PARAMETER);
355 return 0;
356 }
357 if(initialised)
358 {
359 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
360 CCA4758_R_ALREADY_LOADED);
361 return 0;
362 }
363 return set_CCA4758_LIB_NAME((const char *)p);
364 default:
365 break;
366 }
367 CCA4758err(CCA4758_F_IBM_4758_CCA_CTRL,
368 CCA4758_R_COMMAND_NOT_IMPLEMENTED);
369 return 0;
370 }
371
372#ifndef OPENSSL_NO_RSA
373
374#define MAX_CCA_PKA_TOKEN_SIZE 2500
375
376static EVP_PKEY *ibm_4758_load_privkey(ENGINE* e, const char* key_id,
377 UI_METHOD *ui_method, void *callback_data)
378 {
379 RSA *rtmp = NULL;
380 EVP_PKEY *res = NULL;
381 unsigned char* keyToken = NULL;
382 unsigned char pubKeyToken[MAX_CCA_PKA_TOKEN_SIZE];
383 long pubKeyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
384 long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
385 long returnCode;
386 long reasonCode;
387 long exitDataLength = 0;
388 long ruleArrayLength = 0;
389 unsigned char exitData[8];
390 unsigned char ruleArray[8];
391 unsigned char keyLabel[64];
392 long keyLabelLength = strlen(key_id);
393 unsigned char modulus[256];
394 long modulusFieldLength = sizeof(modulus);
395 long modulusLength = 0;
396 unsigned char exponent[256];
397 long exponentLength = sizeof(exponent);
398
399 if (keyLabelLength > sizeof(keyLabel))
400 {
401 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
402 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
403 return NULL;
404 }
405
406 memset(keyLabel,' ', sizeof(keyLabel));
407 memcpy(keyLabel, key_id, keyLabelLength);
408
409 keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
410 if (!keyToken)
411 {
412 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
413 ERR_R_MALLOC_FAILURE);
414 goto err;
415 }
416
417 keyRecordRead(&returnCode, &reasonCode, &exitDataLength,
418 exitData, &ruleArrayLength, ruleArray, keyLabel,
419 &keyTokenLength, keyToken+sizeof(long));
420
421 if (returnCode)
422 {
423 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
424 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
425 goto err;
426 }
427
428 publicKeyExtract(&returnCode, &reasonCode, &exitDataLength,
429 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
430 keyToken+sizeof(long), &pubKeyTokenLength, pubKeyToken);
431
432 if (returnCode)
433 {
434 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
435 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
436 goto err;
437 }
438
439 if (!getModulusAndExponent(pubKeyToken, &exponentLength,
440 exponent, &modulusLength, &modulusFieldLength,
441 modulus))
442 {
443 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
444 CCA4758_R_FAILED_LOADING_PRIVATE_KEY);
445 goto err;
446 }
447
448 (*(long*)keyToken) = keyTokenLength;
449 rtmp = RSA_new_method(e);
450 RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
451
452 rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
453 rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);
454 rtmp->flags |= RSA_FLAG_EXT_PKEY;
455
456 res = EVP_PKEY_new();
457 EVP_PKEY_assign_RSA(res, rtmp);
458
459 return res;
460err:
461 if (keyToken)
462 OPENSSL_free(keyToken);
463 if (res)
464 EVP_PKEY_free(res);
465 if (rtmp)
466 RSA_free(rtmp);
467 return NULL;
468 }
469
470static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,
471 UI_METHOD *ui_method, void *callback_data)
472 {
473 RSA *rtmp = NULL;
474 EVP_PKEY *res = NULL;
475 unsigned char* keyToken = NULL;
476 long keyTokenLength = MAX_CCA_PKA_TOKEN_SIZE;
477 long returnCode;
478 long reasonCode;
479 long exitDataLength = 0;
480 long ruleArrayLength = 0;
481 unsigned char exitData[8];
482 unsigned char ruleArray[8];
483 unsigned char keyLabel[64];
484 long keyLabelLength = strlen(key_id);
485 unsigned char modulus[512];
486 long modulusFieldLength = sizeof(modulus);
487 long modulusLength = 0;
488 unsigned char exponent[512];
489 long exponentLength = sizeof(exponent);
490
491 if (keyLabelLength > sizeof(keyLabel))
492 {
493 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
494 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
495 return NULL;
496 }
497
498 memset(keyLabel,' ', sizeof(keyLabel));
499 memcpy(keyLabel, key_id, keyLabelLength);
500
501 keyToken = OPENSSL_malloc(MAX_CCA_PKA_TOKEN_SIZE + sizeof(long));
502 if (!keyToken)
503 {
504 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PUBKEY,
505 ERR_R_MALLOC_FAILURE);
506 goto err;
507 }
508
509 keyRecordRead(&returnCode, &reasonCode, &exitDataLength, exitData,
510 &ruleArrayLength, ruleArray, keyLabel, &keyTokenLength,
511 keyToken+sizeof(long));
512
513 if (returnCode)
514 {
515 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
516 ERR_R_MALLOC_FAILURE);
517 goto err;
518 }
519
520 if (!getModulusAndExponent(keyToken+sizeof(long), &exponentLength,
521 exponent, &modulusLength, &modulusFieldLength, modulus))
522 {
523 CCA4758err(CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,
524 CCA4758_R_FAILED_LOADING_PUBLIC_KEY);
525 goto err;
526 }
527
528 (*(long*)keyToken) = keyTokenLength;
529 rtmp = RSA_new_method(e);
530 RSA_set_ex_data(rtmp, hndidx, (char *)keyToken);
531 rtmp->e = BN_bin2bn(exponent, exponentLength, NULL);
532 rtmp->n = BN_bin2bn(modulus, modulusFieldLength, NULL);
533 rtmp->flags |= RSA_FLAG_EXT_PKEY;
534 res = EVP_PKEY_new();
535 EVP_PKEY_assign_RSA(res, rtmp);
536
537 return res;
538err:
539 if (keyToken)
540 OPENSSL_free(keyToken);
541 if (res)
542 EVP_PKEY_free(res);
543 if (rtmp)
544 RSA_free(rtmp);
545 return NULL;
546 }
547
548static int cca_rsa_pub_enc(int flen, const unsigned char *from,
549 unsigned char *to, RSA *rsa,int padding)
550 {
551 long returnCode;
552 long reasonCode;
553 long lflen = flen;
554 long exitDataLength = 0;
555 unsigned char exitData[8];
556 long ruleArrayLength = 1;
557 unsigned char ruleArray[8] = "PKCS-1.2";
558 long dataStructureLength = 0;
559 unsigned char dataStructure[8];
560 long outputLength = RSA_size(rsa);
561 long keyTokenLength;
562 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
563
564 keyTokenLength = *(long*)keyToken;
565 keyToken+=sizeof(long);
566
567 pkaEncrypt(&returnCode, &reasonCode, &exitDataLength, exitData,
568 &ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,
569 &dataStructureLength, dataStructure, &keyTokenLength,
570 keyToken, &outputLength, to);
571
572 if (returnCode || reasonCode)
573 return -(returnCode << 16 | reasonCode);
574 return outputLength;
575 }
576
577static int cca_rsa_priv_dec(int flen, const unsigned char *from,
578 unsigned char *to, RSA *rsa,int padding)
579 {
580 long returnCode;
581 long reasonCode;
582 long lflen = flen;
583 long exitDataLength = 0;
584 unsigned char exitData[8];
585 long ruleArrayLength = 1;
586 unsigned char ruleArray[8] = "PKCS-1.2";
587 long dataStructureLength = 0;
588 unsigned char dataStructure[8];
589 long outputLength = RSA_size(rsa);
590 long keyTokenLength;
591 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
592
593 keyTokenLength = *(long*)keyToken;
594 keyToken+=sizeof(long);
595
596 pkaDecrypt(&returnCode, &reasonCode, &exitDataLength, exitData,
597 &ruleArrayLength, ruleArray, &lflen, (unsigned char*)from,
598 &dataStructureLength, dataStructure, &keyTokenLength,
599 keyToken, &outputLength, to);
600
601 return (returnCode | reasonCode) ? 0 : 1;
602 }
603
604#define SSL_SIG_LEN 36
605
606static int cca_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
607 unsigned char *sigbuf, unsigned int siglen, const RSA *rsa)
608 {
609 long returnCode;
610 long reasonCode;
611 long lsiglen = siglen;
612 long exitDataLength = 0;
613 unsigned char exitData[8];
614 long ruleArrayLength = 1;
615 unsigned char ruleArray[8] = "PKCS-1.1";
616 long keyTokenLength;
617 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
618 long length = SSL_SIG_LEN;
619 long keyLength ;
620 unsigned char *hashBuffer = NULL;
621 X509_SIG sig;
622 ASN1_TYPE parameter;
623 X509_ALGOR algorithm;
624 ASN1_OCTET_STRING digest;
625
626 keyTokenLength = *(long*)keyToken;
627 keyToken+=sizeof(long);
628
629 if (type == NID_md5 || type == NID_sha1)
630 {
631 sig.algor = &algorithm;
632 algorithm.algorithm = OBJ_nid2obj(type);
633
634 if (!algorithm.algorithm)
635 {
636 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
637 CCA4758_R_UNKNOWN_ALGORITHM_TYPE);
638 return 0;
639 }
640
641 if (!algorithm.algorithm->length)
642 {
643 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
644 CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD);
645 return 0;
646 }
647
648 parameter.type = V_ASN1_NULL;
649 parameter.value.ptr = NULL;
650 algorithm.parameter = &parameter;
651
652 sig.digest = &digest;
653 sig.digest->data = (unsigned char*)m;
654 sig.digest->length = m_len;
655
656 length = i2d_X509_SIG(&sig, NULL);
657 }
658
659 keyLength = RSA_size(rsa);
660
661 if (length - RSA_PKCS1_PADDING > keyLength)
662 {
663 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
664 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
665 return 0;
666 }
667
668 switch (type)
669 {
670 case NID_md5_sha1 :
671 if (m_len != SSL_SIG_LEN)
672 {
673 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
674 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
675 return 0;
676 }
677
678 hashBuffer = (unsigned char *)m;
679 length = m_len;
680 break;
681 case NID_md5 :
682 {
683 unsigned char *ptr;
684 ptr = hashBuffer = OPENSSL_malloc(
685 (unsigned int)keyLength+1);
686 if (!hashBuffer)
687 {
688 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
689 ERR_R_MALLOC_FAILURE);
690 return 0;
691 }
692
693 i2d_X509_SIG(&sig, &ptr);
694 }
695 break;
696 case NID_sha1 :
697 {
698 unsigned char *ptr;
699 ptr = hashBuffer = OPENSSL_malloc(
700 (unsigned int)keyLength+1);
701 if (!hashBuffer)
702 {
703 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
704 ERR_R_MALLOC_FAILURE);
705 return 0;
706 }
707 i2d_X509_SIG(&sig, &ptr);
708 }
709 break;
710 default:
711 return 0;
712 }
713
714 digitalSignatureVerify(&returnCode, &reasonCode, &exitDataLength,
715 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
716 keyToken, &length, hashBuffer, &lsiglen, sigbuf);
717
718 if (type == NID_sha1 || type == NID_md5)
719 {
720 OPENSSL_cleanse(hashBuffer, keyLength+1);
721 OPENSSL_free(hashBuffer);
722 }
723
724 return ((returnCode || reasonCode) ? 0 : 1);
725 }
726
727#define SSL_SIG_LEN 36
728
729static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
730 unsigned char *sigret, unsigned int *siglen, const RSA *rsa)
731 {
732 long returnCode;
733 long reasonCode;
734 long exitDataLength = 0;
735 unsigned char exitData[8];
736 long ruleArrayLength = 1;
737 unsigned char ruleArray[8] = "PKCS-1.1";
738 long outputLength=256;
739 long outputBitLength;
740 long keyTokenLength;
741 unsigned char *hashBuffer = NULL;
742 unsigned char* keyToken = (unsigned char*)RSA_get_ex_data(rsa, hndidx);
743 long length = SSL_SIG_LEN;
744 long keyLength ;
745 X509_SIG sig;
746 ASN1_TYPE parameter;
747 X509_ALGOR algorithm;
748 ASN1_OCTET_STRING digest;
749
750 keyTokenLength = *(long*)keyToken;
751 keyToken+=sizeof(long);
752
753 if (type == NID_md5 || type == NID_sha1)
754 {
755 sig.algor = &algorithm;
756 algorithm.algorithm = OBJ_nid2obj(type);
757
758 if (!algorithm.algorithm)
759 {
760 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
761 CCA4758_R_UNKNOWN_ALGORITHM_TYPE);
762 return 0;
763 }
764
765 if (!algorithm.algorithm->length)
766 {
767 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
768 CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD);
769 return 0;
770 }
771
772 parameter.type = V_ASN1_NULL;
773 parameter.value.ptr = NULL;
774 algorithm.parameter = &parameter;
775
776 sig.digest = &digest;
777 sig.digest->data = (unsigned char*)m;
778 sig.digest->length = m_len;
779
780 length = i2d_X509_SIG(&sig, NULL);
781 }
782
783 keyLength = RSA_size(rsa);
784
785 if (length - RSA_PKCS1_PADDING > keyLength)
786 {
787 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
788 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
789 return 0;
790 }
791
792 switch (type)
793 {
794 case NID_md5_sha1 :
795 if (m_len != SSL_SIG_LEN)
796 {
797 CCA4758err(CCA4758_F_IBM_4758_CCA_SIGN,
798 CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
799 return 0;
800 }
801 hashBuffer = (unsigned char*)m;
802 length = m_len;
803 break;
804 case NID_md5 :
805 {
806 unsigned char *ptr;
807 ptr = hashBuffer = OPENSSL_malloc(
808 (unsigned int)keyLength+1);
809 if (!hashBuffer)
810 {
811 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
812 ERR_R_MALLOC_FAILURE);
813 return 0;
814 }
815 i2d_X509_SIG(&sig, &ptr);
816 }
817 break;
818 case NID_sha1 :
819 {
820 unsigned char *ptr;
821 ptr = hashBuffer = OPENSSL_malloc(
822 (unsigned int)keyLength+1);
823 if (!hashBuffer)
824 {
825 CCA4758err(CCA4758_F_IBM_4758_CCA_VERIFY,
826 ERR_R_MALLOC_FAILURE);
827 return 0;
828 }
829 i2d_X509_SIG(&sig, &ptr);
830 }
831 break;
832 default:
833 return 0;
834 }
835
836 digitalSignatureGenerate(&returnCode, &reasonCode, &exitDataLength,
837 exitData, &ruleArrayLength, ruleArray, &keyTokenLength,
838 keyToken, &length, hashBuffer, &outputLength, &outputBitLength,
839 sigret);
840
841 if (type == NID_sha1 || type == NID_md5)
842 {
843 OPENSSL_cleanse(hashBuffer, keyLength+1);
844 OPENSSL_free(hashBuffer);
845 }
846
847 *siglen = outputLength;
848
849 return ((returnCode || reasonCode) ? 0 : 1);
850 }
851
852static int getModulusAndExponent(const unsigned char*token, long *exponentLength,
853 unsigned char *exponent, long *modulusLength, long *modulusFieldLength,
854 unsigned char *modulus)
855 {
856 unsigned long len;
857
858 if (*token++ != (char)0x1E) /* internal PKA token? */
859 return 0;
860
861 if (*token++) /* token version must be zero */
862 return 0;
863
864 len = *token++;
865 len = len << 8;
866 len |= (unsigned char)*token++;
867
868 token += 4; /* skip reserved bytes */
869
870 if (*token++ == (char)0x04)
871 {
872 if (*token++) /* token version must be zero */
873 return 0;
874
875 len = *token++;
876 len = len << 8;
877 len |= (unsigned char)*token++;
878
879 token+=2; /* skip reserved section */
880
881 len = *token++;
882 len = len << 8;
883 len |= (unsigned char)*token++;
884
885 *exponentLength = len;
886
887 len = *token++;
888 len = len << 8;
889 len |= (unsigned char)*token++;
890
891 *modulusLength = len;
892
893 len = *token++;
894 len = len << 8;
895 len |= (unsigned char)*token++;
896
897 *modulusFieldLength = len;
898
899 memcpy(exponent, token, *exponentLength);
900 token+= *exponentLength;
901
902 memcpy(modulus, token, *modulusFieldLength);
903 return 1;
904 }
905 return 0;
906 }
907
908#endif /* OPENSSL_NO_RSA */
909
910static int cca_random_status(void)
911 {
912 return 1;
913 }
914
915static int cca_get_random_bytes(unsigned char* buf, int num)
916 {
917 long ret_code;
918 long reason_code;
919 long exit_data_length;
920 unsigned char exit_data[4];
921 unsigned char form[] = "RANDOM ";
922 unsigned char rand_buf[8];
923
924 while(num >= sizeof(rand_buf))
925 {
926 randomNumberGenerate(&ret_code, &reason_code, &exit_data_length,
927 exit_data, form, rand_buf);
928 if (ret_code)
929 return 0;
930 num -= sizeof(rand_buf);
931 memcpy(buf, rand_buf, sizeof(rand_buf));
932 buf += sizeof(rand_buf);
933 }
934
935 if (num)
936 {
937 randomNumberGenerate(&ret_code, &reason_code, NULL, NULL,
938 form, rand_buf);
939 if (ret_code)
940 return 0;
941 memcpy(buf, rand_buf, num);
942 }
943
944 return 1;
945 }
946
947static void cca_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int idx,
948 long argl, void *argp)
949 {
950 if (item)
951 OPENSSL_free(item);
952 }
953
954/* Goo to handle building as a dynamic engine */
955#ifdef ENGINE_DYNAMIC_SUPPORT
956static int bind_fn(ENGINE *e, const char *id)
957 {
958 if(id && (strcmp(id, engine_4758_cca_id) != 0))
959 return 0;
960 if(!bind_helper(e))
961 return 0;
962 return 1;
963 }
964IMPLEMENT_DYNAMIC_CHECK_FN()
965IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
966#endif /* ENGINE_DYNAMIC_SUPPORT */
967
968#endif /* !OPENSSL_NO_HW_4758_CCA */
969#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_4758_cca_err.c b/src/lib/libcrypto/engine/hw_4758_cca_err.c
deleted file mode 100644
index 7ea5c63707..0000000000
--- a/src/lib/libcrypto/engine/hw_4758_cca_err.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/* hw_4758_cca_err.c */
2/* ====================================================================
3 * Copyright (c) 1999-2002 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_4758_cca_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA CCA4758_str_functs[]=
68 {
69{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_CTRL,0), "IBM_4758_CCA_CTRL"},
70{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_FINISH,0), "IBM_4758_CCA_FINISH"},
71{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_INIT,0), "IBM_4758_CCA_INIT"},
72{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY,0), "IBM_4758_CCA_LOAD_PRIVKEY"},
73{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_LOAD_PUBKEY,0), "IBM_4758_CCA_LOAD_PUBKEY"},
74{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_SIGN,0), "IBM_4758_CCA_SIGN"},
75{ERR_PACK(0,CCA4758_F_IBM_4758_CCA_VERIFY,0), "IBM_4758_CCA_VERIFY"},
76{0,NULL}
77 };
78
79static ERR_STRING_DATA CCA4758_str_reasons[]=
80 {
81{CCA4758_R_ALREADY_LOADED ,"already loaded"},
82{CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD ,"asn1 oid unknown for md"},
83{CCA4758_R_COMMAND_NOT_IMPLEMENTED ,"command not implemented"},
84{CCA4758_R_DSO_FAILURE ,"dso failure"},
85{CCA4758_R_FAILED_LOADING_PRIVATE_KEY ,"failed loading private key"},
86{CCA4758_R_FAILED_LOADING_PUBLIC_KEY ,"failed loading public key"},
87{CCA4758_R_NOT_LOADED ,"not loaded"},
88{CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL ,"size too large or too small"},
89{CCA4758_R_UNIT_FAILURE ,"unit failure"},
90{CCA4758_R_UNKNOWN_ALGORITHM_TYPE ,"unknown algorithm type"},
91{0,NULL}
92 };
93
94#endif
95
96#ifdef CCA4758_LIB_NAME
97static ERR_STRING_DATA CCA4758_lib_name[]=
98 {
99{0 ,CCA4758_LIB_NAME},
100{0,NULL}
101 };
102#endif
103
104
105static int CCA4758_lib_error_code=0;
106static int CCA4758_error_init=1;
107
108static void ERR_load_CCA4758_strings(void)
109 {
110 if (CCA4758_lib_error_code == 0)
111 CCA4758_lib_error_code=ERR_get_next_error_library();
112
113 if (CCA4758_error_init)
114 {
115 CCA4758_error_init=0;
116#ifndef OPENSSL_NO_ERR
117 ERR_load_strings(CCA4758_lib_error_code,CCA4758_str_functs);
118 ERR_load_strings(CCA4758_lib_error_code,CCA4758_str_reasons);
119#endif
120
121#ifdef CCA4758_LIB_NAME
122 CCA4758_lib_name->error = ERR_PACK(CCA4758_lib_error_code,0,0);
123 ERR_load_strings(0,CCA4758_lib_name);
124#endif
125 }
126 }
127
128static void ERR_unload_CCA4758_strings(void)
129 {
130 if (CCA4758_error_init == 0)
131 {
132#ifndef OPENSSL_NO_ERR
133 ERR_unload_strings(CCA4758_lib_error_code,CCA4758_str_functs);
134 ERR_unload_strings(CCA4758_lib_error_code,CCA4758_str_reasons);
135#endif
136
137#ifdef CCA4758_LIB_NAME
138 ERR_unload_strings(0,CCA4758_lib_name);
139#endif
140 CCA4758_error_init=1;
141 }
142 }
143
144static void ERR_CCA4758_error(int function, int reason, char *file, int line)
145 {
146 if (CCA4758_lib_error_code == 0)
147 CCA4758_lib_error_code=ERR_get_next_error_library();
148 ERR_PUT_error(CCA4758_lib_error_code,function,reason,file,line);
149 }
diff --git a/src/lib/libcrypto/engine/hw_4758_cca_err.h b/src/lib/libcrypto/engine/hw_4758_cca_err.h
deleted file mode 100644
index 2fc563ab11..0000000000
--- a/src/lib/libcrypto/engine/hw_4758_cca_err.h
+++ /dev/null
@@ -1,93 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. 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 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the OpenSSL Project
19 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
20 *
21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
24 * openssl-core@openssl.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_CCA4758_ERR_H
56#define HEADER_CCA4758_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_CCA4758_strings(void);
63static void ERR_unload_CCA4758_strings(void);
64static void ERR_CCA4758_error(int function, int reason, char *file, int line);
65#define CCA4758err(f,r) ERR_CCA4758_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the CCA4758 functions. */
68
69/* Function codes. */
70#define CCA4758_F_IBM_4758_CCA_CTRL 100
71#define CCA4758_F_IBM_4758_CCA_FINISH 101
72#define CCA4758_F_IBM_4758_CCA_INIT 102
73#define CCA4758_F_IBM_4758_CCA_LOAD_PRIVKEY 103
74#define CCA4758_F_IBM_4758_CCA_LOAD_PUBKEY 104
75#define CCA4758_F_IBM_4758_CCA_SIGN 105
76#define CCA4758_F_IBM_4758_CCA_VERIFY 106
77
78/* Reason codes. */
79#define CCA4758_R_ALREADY_LOADED 100
80#define CCA4758_R_ASN1_OID_UNKNOWN_FOR_MD 101
81#define CCA4758_R_COMMAND_NOT_IMPLEMENTED 102
82#define CCA4758_R_DSO_FAILURE 103
83#define CCA4758_R_FAILED_LOADING_PRIVATE_KEY 104
84#define CCA4758_R_FAILED_LOADING_PUBLIC_KEY 105
85#define CCA4758_R_NOT_LOADED 106
86#define CCA4758_R_SIZE_TOO_LARGE_OR_TOO_SMALL 107
87#define CCA4758_R_UNIT_FAILURE 108
88#define CCA4758_R_UNKNOWN_ALGORITHM_TYPE 109
89
90#ifdef __cplusplus
91}
92#endif
93#endif
diff --git a/src/lib/libcrypto/engine/hw_aep.c b/src/lib/libcrypto/engine/hw_aep.c
deleted file mode 100644
index 5f1772ea99..0000000000
--- a/src/lib/libcrypto/engine/hw_aep.c
+++ /dev/null
@@ -1,1120 +0,0 @@
1/* crypto/engine/hw_aep.c */
2/*
3 */
4/* ====================================================================
5 * Copyright (c) 1999 The OpenSSL Project. 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 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 *
19 * 3. All advertising materials mentioning features or use of this
20 * software must display the following acknowledgment:
21 * "This product includes software developed by the OpenSSL Project
22 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
23 *
24 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 * endorse or promote products derived from this software without
26 * prior written permission. For written permission, please contact
27 * licensing@OpenSSL.org.
28 *
29 * 5. Products derived from this software may not be called "OpenSSL"
30 * nor may "OpenSSL" appear in their names without prior written
31 * permission of the OpenSSL Project.
32 *
33 * 6. Redistributions of any form whatsoever must retain the following
34 * acknowledgment:
35 * "This product includes software developed by the OpenSSL Project
36 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
37 *
38 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 * OF THE POSSIBILITY OF SUCH DAMAGE.
50 * ====================================================================
51 *
52 * This product includes cryptographic software written by Eric Young
53 * (eay@cryptsoft.com). This product includes software written by Tim
54 * Hudson (tjh@cryptsoft.com).
55 *
56 */
57
58#include <stdio.h>
59#include <openssl/bn.h>
60#include <string.h>
61
62#include <openssl/e_os2.h>
63#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__)
64#include <sys/types.h>
65#include <unistd.h>
66#else
67#include <process.h>
68typedef int pid_t;
69#endif
70
71#include <openssl/crypto.h>
72#include <openssl/dso.h>
73#include <openssl/engine.h>
74#include <openssl/buffer.h>
75
76#ifndef OPENSSL_NO_HW
77#ifndef OPENSSL_NO_HW_AEP
78#ifdef FLAT_INC
79#include "aep.h"
80#else
81#include "vendor_defns/aep.h"
82#endif
83
84#define AEP_LIB_NAME "aep engine"
85#define FAIL_TO_SW 0x10101010
86
87#include "hw_aep_err.c"
88
89static int aep_init(ENGINE *e);
90static int aep_finish(ENGINE *e);
91static int aep_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
92static int aep_destroy(ENGINE *e);
93
94static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR hConnection);
95static AEP_RV aep_return_connection(AEP_CONNECTION_HNDL hConnection);
96static AEP_RV aep_close_connection(AEP_CONNECTION_HNDL hConnection);
97static AEP_RV aep_close_all_connections(int use_engine_lock, int *in_use);
98
99/* BIGNUM stuff */
100static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
101 const BIGNUM *m, BN_CTX *ctx);
102
103static AEP_RV aep_mod_exp_crt(BIGNUM *r,const BIGNUM *a, const BIGNUM *p,
104 const BIGNUM *q, const BIGNUM *dmp1,const BIGNUM *dmq1,
105 const BIGNUM *iqmp, BN_CTX *ctx);
106
107/* RSA stuff */
108#ifndef OPENSSL_NO_RSA
109static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
110#endif
111
112/* This function is aliased to mod_exp (with the mont stuff dropped). */
113static int aep_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
114 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
115
116/* DSA stuff */
117#ifndef OPENSSL_NO_DSA
118static int aep_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
119 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
120 BN_CTX *ctx, BN_MONT_CTX *in_mont);
121
122static int aep_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
123 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
124 BN_MONT_CTX *m_ctx);
125#endif
126
127/* DH stuff */
128/* This function is aliased to mod_exp (with the DH and mont dropped). */
129#ifndef OPENSSL_NO_DH
130static int aep_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
131 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
132#endif
133
134/* rand stuff */
135#ifdef AEPRAND
136static int aep_rand(unsigned char *buf, int num);
137static int aep_rand_status(void);
138#endif
139
140/* Bignum conversion stuff */
141static AEP_RV GetBigNumSize(AEP_VOID_PTR ArbBigNum, AEP_U32* BigNumSize);
142static AEP_RV MakeAEPBigNum(AEP_VOID_PTR ArbBigNum, AEP_U32 BigNumSize,
143 unsigned char* AEP_BigNum);
144static AEP_RV ConvertAEPBigNum(void* ArbBigNum, AEP_U32 BigNumSize,
145 unsigned char* AEP_BigNum);
146
147/* The definitions for control commands specific to this engine */
148#define AEP_CMD_SO_PATH ENGINE_CMD_BASE
149static const ENGINE_CMD_DEFN aep_cmd_defns[] =
150 {
151 { AEP_CMD_SO_PATH,
152 "SO_PATH",
153 "Specifies the path to the 'aep' shared library",
154 ENGINE_CMD_FLAG_STRING
155 },
156 {0, NULL, NULL, 0}
157 };
158
159#ifndef OPENSSL_NO_RSA
160/* Our internal RSA_METHOD that we provide pointers to */
161static RSA_METHOD aep_rsa =
162 {
163 "Aep RSA method",
164 NULL, /*rsa_pub_encrypt*/
165 NULL, /*rsa_pub_decrypt*/
166 NULL, /*rsa_priv_encrypt*/
167 NULL, /*rsa_priv_encrypt*/
168 aep_rsa_mod_exp, /*rsa_mod_exp*/
169 aep_mod_exp_mont, /*bn_mod_exp*/
170 NULL, /*init*/
171 NULL, /*finish*/
172 0, /*flags*/
173 NULL, /*app_data*/
174 NULL, /*rsa_sign*/
175 NULL /*rsa_verify*/
176 };
177#endif
178
179#ifndef OPENSSL_NO_DSA
180/* Our internal DSA_METHOD that we provide pointers to */
181static DSA_METHOD aep_dsa =
182 {
183 "Aep DSA method",
184 NULL, /* dsa_do_sign */
185 NULL, /* dsa_sign_setup */
186 NULL, /* dsa_do_verify */
187 aep_dsa_mod_exp, /* dsa_mod_exp */
188 aep_mod_exp_dsa, /* bn_mod_exp */
189 NULL, /* init */
190 NULL, /* finish */
191 0, /* flags */
192 NULL /* app_data */
193 };
194#endif
195
196#ifndef OPENSSL_NO_DH
197/* Our internal DH_METHOD that we provide pointers to */
198static DH_METHOD aep_dh =
199 {
200 "Aep DH method",
201 NULL,
202 NULL,
203 aep_mod_exp_dh,
204 NULL,
205 NULL,
206 0,
207 NULL
208 };
209#endif
210
211#ifdef AEPRAND
212/* our internal RAND_method that we provide pointers to */
213static RAND_METHOD aep_random =
214 {
215 /*"AEP RAND method", */
216 NULL,
217 aep_rand,
218 NULL,
219 NULL,
220 aep_rand,
221 aep_rand_status,
222 };
223#endif
224
225/*Define an array of structures to hold connections*/
226static AEP_CONNECTION_ENTRY aep_app_conn_table[MAX_PROCESS_CONNECTIONS];
227
228/*Used to determine if this is a new process*/
229static pid_t recorded_pid = 0;
230
231#ifdef AEPRAND
232static AEP_U8 rand_block[RAND_BLK_SIZE];
233static AEP_U32 rand_block_bytes = 0;
234#endif
235
236/* Constants used when creating the ENGINE */
237static const char *engine_aep_id = "aep";
238static const char *engine_aep_name = "Aep hardware engine support";
239
240static int max_key_len = 2176;
241
242
243/* This internal function is used by ENGINE_aep() and possibly by the
244 * "dynamic" ENGINE support too */
245static int bind_aep(ENGINE *e)
246 {
247#ifndef OPENSSL_NO_RSA
248 const RSA_METHOD *meth1;
249#endif
250#ifndef OPENSSL_NO_DSA
251 const DSA_METHOD *meth2;
252#endif
253#ifndef OPENSSL_NO_DH
254 const DH_METHOD *meth3;
255#endif
256
257 if(!ENGINE_set_id(e, engine_aep_id) ||
258 !ENGINE_set_name(e, engine_aep_name) ||
259#ifndef OPENSSL_NO_RSA
260 !ENGINE_set_RSA(e, &aep_rsa) ||
261#endif
262#ifndef OPENSSL_NO_DSA
263 !ENGINE_set_DSA(e, &aep_dsa) ||
264#endif
265#ifndef OPENSSL_NO_DH
266 !ENGINE_set_DH(e, &aep_dh) ||
267#endif
268#ifdef AEPRAND
269 !ENGINE_set_RAND(e, &aep_random) ||
270#endif
271 !ENGINE_set_init_function(e, aep_init) ||
272 !ENGINE_set_destroy_function(e, aep_destroy) ||
273 !ENGINE_set_finish_function(e, aep_finish) ||
274 !ENGINE_set_ctrl_function(e, aep_ctrl) ||
275 !ENGINE_set_cmd_defns(e, aep_cmd_defns))
276 return 0;
277
278#ifndef OPENSSL_NO_RSA
279 /* We know that the "PKCS1_SSLeay()" functions hook properly
280 * to the aep-specific mod_exp and mod_exp_crt so we use
281 * those functions. NB: We don't use ENGINE_openssl() or
282 * anything "more generic" because something like the RSAref
283 * code may not hook properly, and if you own one of these
284 * cards then you have the right to do RSA operations on it
285 * anyway! */
286 meth1 = RSA_PKCS1_SSLeay();
287 aep_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
288 aep_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
289 aep_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
290 aep_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
291#endif
292
293
294#ifndef OPENSSL_NO_DSA
295 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
296 * bits. */
297 meth2 = DSA_OpenSSL();
298 aep_dsa.dsa_do_sign = meth2->dsa_do_sign;
299 aep_dsa.dsa_sign_setup = meth2->dsa_sign_setup;
300 aep_dsa.dsa_do_verify = meth2->dsa_do_verify;
301
302 aep_dsa = *DSA_get_default_method();
303 aep_dsa.dsa_mod_exp = aep_dsa_mod_exp;
304 aep_dsa.bn_mod_exp = aep_mod_exp_dsa;
305#endif
306
307#ifndef OPENSSL_NO_DH
308 /* Much the same for Diffie-Hellman */
309 meth3 = DH_OpenSSL();
310 aep_dh.generate_key = meth3->generate_key;
311 aep_dh.compute_key = meth3->compute_key;
312 aep_dh.bn_mod_exp = meth3->bn_mod_exp;
313#endif
314
315 /* Ensure the aep error handling is set up */
316 ERR_load_AEPHK_strings();
317
318 return 1;
319}
320
321#ifdef ENGINE_DYNAMIC_SUPPORT
322static int bind_helper(ENGINE *e, const char *id)
323 {
324 if(id && (strcmp(id, engine_aep_id) != 0))
325 return 0;
326 if(!bind_aep(e))
327 return 0;
328 return 1;
329 }
330IMPLEMENT_DYNAMIC_CHECK_FN()
331IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)
332#else
333static ENGINE *engine_aep(void)
334 {
335 ENGINE *ret = ENGINE_new();
336 if(!ret)
337 return NULL;
338 if(!bind_aep(ret))
339 {
340 ENGINE_free(ret);
341 return NULL;
342 }
343 return ret;
344 }
345
346void ENGINE_load_aep(void)
347 {
348 /* Copied from eng_[openssl|dyn].c */
349 ENGINE *toadd = engine_aep();
350 if(!toadd) return;
351 ENGINE_add(toadd);
352 ENGINE_free(toadd);
353 ERR_clear_error();
354 }
355#endif
356
357/* This is a process-global DSO handle used for loading and unloading
358 * the Aep library. NB: This is only set (or unset) during an
359 * init() or finish() call (reference counts permitting) and they're
360 * operating with global locks, so this should be thread-safe
361 * implicitly. */
362static DSO *aep_dso = NULL;
363
364/* These are the static string constants for the DSO file name and the function
365 * symbol names to bind to.
366*/
367static const char *AEP_LIBNAME = NULL;
368static const char *get_AEP_LIBNAME(void)
369 {
370 if(AEP_LIBNAME)
371 return AEP_LIBNAME;
372 return "aep";
373 }
374static void free_AEP_LIBNAME(void)
375 {
376 if(AEP_LIBNAME)
377 OPENSSL_free((void*)AEP_LIBNAME);
378 AEP_LIBNAME = NULL;
379 }
380static long set_AEP_LIBNAME(const char *name)
381 {
382 free_AEP_LIBNAME();
383 return ((AEP_LIBNAME = BUF_strdup(name)) != NULL ? 1 : 0);
384 }
385
386static const char *AEP_F1 = "AEP_ModExp";
387static const char *AEP_F2 = "AEP_ModExpCrt";
388#ifdef AEPRAND
389static const char *AEP_F3 = "AEP_GenRandom";
390#endif
391static const char *AEP_F4 = "AEP_Finalize";
392static const char *AEP_F5 = "AEP_Initialize";
393static const char *AEP_F6 = "AEP_OpenConnection";
394static const char *AEP_F7 = "AEP_SetBNCallBacks";
395static const char *AEP_F8 = "AEP_CloseConnection";
396
397/* These are the function pointers that are (un)set when the library has
398 * successfully (un)loaded. */
399static t_AEP_OpenConnection *p_AEP_OpenConnection = NULL;
400static t_AEP_CloseConnection *p_AEP_CloseConnection = NULL;
401static t_AEP_ModExp *p_AEP_ModExp = NULL;
402static t_AEP_ModExpCrt *p_AEP_ModExpCrt = NULL;
403#ifdef AEPRAND
404static t_AEP_GenRandom *p_AEP_GenRandom = NULL;
405#endif
406static t_AEP_Initialize *p_AEP_Initialize = NULL;
407static t_AEP_Finalize *p_AEP_Finalize = NULL;
408static t_AEP_SetBNCallBacks *p_AEP_SetBNCallBacks = NULL;
409
410/* (de)initialisation functions. */
411static int aep_init(ENGINE *e)
412 {
413 t_AEP_ModExp *p1;
414 t_AEP_ModExpCrt *p2;
415#ifdef AEPRAND
416 t_AEP_GenRandom *p3;
417#endif
418 t_AEP_Finalize *p4;
419 t_AEP_Initialize *p5;
420 t_AEP_OpenConnection *p6;
421 t_AEP_SetBNCallBacks *p7;
422 t_AEP_CloseConnection *p8;
423
424 int to_return = 0;
425
426 if(aep_dso != NULL)
427 {
428 AEPHKerr(AEPHK_F_AEP_INIT,AEPHK_R_ALREADY_LOADED);
429 goto err;
430 }
431 /* Attempt to load libaep.so. */
432
433 aep_dso = DSO_load(NULL, get_AEP_LIBNAME(), NULL, 0);
434
435 if(aep_dso == NULL)
436 {
437 AEPHKerr(AEPHK_F_AEP_INIT,AEPHK_R_NOT_LOADED);
438 goto err;
439 }
440
441 if( !(p1 = (t_AEP_ModExp *) DSO_bind_func( aep_dso,AEP_F1)) ||
442 !(p2 = (t_AEP_ModExpCrt*) DSO_bind_func( aep_dso,AEP_F2)) ||
443#ifdef AEPRAND
444 !(p3 = (t_AEP_GenRandom*) DSO_bind_func( aep_dso,AEP_F3)) ||
445#endif
446 !(p4 = (t_AEP_Finalize*) DSO_bind_func( aep_dso,AEP_F4)) ||
447 !(p5 = (t_AEP_Initialize*) DSO_bind_func( aep_dso,AEP_F5)) ||
448 !(p6 = (t_AEP_OpenConnection*) DSO_bind_func( aep_dso,AEP_F6)) ||
449 !(p7 = (t_AEP_SetBNCallBacks*) DSO_bind_func( aep_dso,AEP_F7)) ||
450 !(p8 = (t_AEP_CloseConnection*) DSO_bind_func( aep_dso,AEP_F8)))
451 {
452 AEPHKerr(AEPHK_F_AEP_INIT,AEPHK_R_NOT_LOADED);
453 goto err;
454 }
455
456 /* Copy the pointers */
457
458 p_AEP_ModExp = p1;
459 p_AEP_ModExpCrt = p2;
460#ifdef AEPRAND
461 p_AEP_GenRandom = p3;
462#endif
463 p_AEP_Finalize = p4;
464 p_AEP_Initialize = p5;
465 p_AEP_OpenConnection = p6;
466 p_AEP_SetBNCallBacks = p7;
467 p_AEP_CloseConnection = p8;
468
469 to_return = 1;
470
471 return to_return;
472
473 err:
474
475 if(aep_dso)
476 DSO_free(aep_dso);
477 aep_dso = NULL;
478
479 p_AEP_OpenConnection = NULL;
480 p_AEP_ModExp = NULL;
481 p_AEP_ModExpCrt = NULL;
482#ifdef AEPRAND
483 p_AEP_GenRandom = NULL;
484#endif
485 p_AEP_Initialize = NULL;
486 p_AEP_Finalize = NULL;
487 p_AEP_SetBNCallBacks = NULL;
488 p_AEP_CloseConnection = NULL;
489
490 return to_return;
491 }
492
493/* Destructor (complements the "ENGINE_aep()" constructor) */
494static int aep_destroy(ENGINE *e)
495 {
496 free_AEP_LIBNAME();
497 ERR_unload_AEPHK_strings();
498 return 1;
499 }
500
501static int aep_finish(ENGINE *e)
502 {
503 int to_return = 0, in_use;
504 AEP_RV rv;
505
506 if(aep_dso == NULL)
507 {
508 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_NOT_LOADED);
509 goto err;
510 }
511
512 rv = aep_close_all_connections(0, &in_use);
513 if (rv != AEP_R_OK)
514 {
515 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_CLOSE_HANDLES_FAILED);
516 goto err;
517 }
518 if (in_use)
519 {
520 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_CONNECTIONS_IN_USE);
521 goto err;
522 }
523
524 rv = p_AEP_Finalize();
525 if (rv != AEP_R_OK)
526 {
527 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_FINALIZE_FAILED);
528 goto err;
529 }
530
531 if(!DSO_free(aep_dso))
532 {
533 AEPHKerr(AEPHK_F_AEP_FINISH,AEPHK_R_UNIT_FAILURE);
534 goto err;
535 }
536
537 aep_dso = NULL;
538 p_AEP_CloseConnection = NULL;
539 p_AEP_OpenConnection = NULL;
540 p_AEP_ModExp = NULL;
541 p_AEP_ModExpCrt = NULL;
542#ifdef AEPRAND
543 p_AEP_GenRandom = NULL;
544#endif
545 p_AEP_Initialize = NULL;
546 p_AEP_Finalize = NULL;
547 p_AEP_SetBNCallBacks = NULL;
548
549 to_return = 1;
550 err:
551 return to_return;
552 }
553
554static int aep_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
555 {
556 int initialised = ((aep_dso == NULL) ? 0 : 1);
557 switch(cmd)
558 {
559 case AEP_CMD_SO_PATH:
560 if(p == NULL)
561 {
562 AEPHKerr(AEPHK_F_AEP_CTRL,
563 ERR_R_PASSED_NULL_PARAMETER);
564 return 0;
565 }
566 if(initialised)
567 {
568 AEPHKerr(AEPHK_F_AEP_CTRL,
569 AEPHK_R_ALREADY_LOADED);
570 return 0;
571 }
572 return set_AEP_LIBNAME((const char*)p);
573 default:
574 break;
575 }
576 AEPHKerr(AEPHK_F_AEP_CTRL,AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
577 return 0;
578 }
579
580static int aep_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
581 const BIGNUM *m, BN_CTX *ctx)
582 {
583 int to_return = 0;
584 int r_len = 0;
585 AEP_CONNECTION_HNDL hConnection;
586 AEP_RV rv;
587
588 r_len = BN_num_bits(m);
589
590 /* Perform in software if modulus is too large for hardware. */
591
592 if (r_len > max_key_len){
593 AEPHKerr(AEPHK_F_AEP_MOD_EXP, AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
594 return BN_mod_exp(r, a, p, m, ctx);
595 }
596
597 /*Grab a connection from the pool*/
598 rv = aep_get_connection(&hConnection);
599 if (rv != AEP_R_OK)
600 {
601 AEPHKerr(AEPHK_F_AEP_MOD_EXP,AEPHK_R_GET_HANDLE_FAILED);
602 return BN_mod_exp(r, a, p, m, ctx);
603 }
604
605 /*To the card with the mod exp*/
606 rv = p_AEP_ModExp(hConnection,(void*)a, (void*)p,(void*)m, (void*)r,NULL);
607
608 if (rv != AEP_R_OK)
609 {
610 AEPHKerr(AEPHK_F_AEP_MOD_EXP,AEPHK_R_MOD_EXP_FAILED);
611 rv = aep_close_connection(hConnection);
612 return BN_mod_exp(r, a, p, m, ctx);
613 }
614
615 /*Return the connection to the pool*/
616 rv = aep_return_connection(hConnection);
617 if (rv != AEP_R_OK)
618 {
619 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
620 goto err;
621 }
622
623 to_return = 1;
624 err:
625 return to_return;
626 }
627
628static AEP_RV aep_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
629 const BIGNUM *q, const BIGNUM *dmp1,
630 const BIGNUM *dmq1,const BIGNUM *iqmp, BN_CTX *ctx)
631 {
632 AEP_RV rv = AEP_R_OK;
633 AEP_CONNECTION_HNDL hConnection;
634
635 /*Grab a connection from the pool*/
636 rv = aep_get_connection(&hConnection);
637 if (rv != AEP_R_OK)
638 {
639 AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT,AEPHK_R_GET_HANDLE_FAILED);
640 return FAIL_TO_SW;
641 }
642
643 /*To the card with the mod exp*/
644 rv = p_AEP_ModExpCrt(hConnection,(void*)a, (void*)p, (void*)q, (void*)dmp1,(void*)dmq1,
645 (void*)iqmp,(void*)r,NULL);
646 if (rv != AEP_R_OK)
647 {
648 AEPHKerr(AEPHK_F_AEP_MOD_EXP_CRT,AEPHK_R_MOD_EXP_CRT_FAILED);
649 rv = aep_close_connection(hConnection);
650 return FAIL_TO_SW;
651 }
652
653 /*Return the connection to the pool*/
654 rv = aep_return_connection(hConnection);
655 if (rv != AEP_R_OK)
656 {
657 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
658 goto err;
659 }
660
661 err:
662 return rv;
663 }
664
665
666#ifdef AEPRAND
667static int aep_rand(unsigned char *buf,int len )
668 {
669 AEP_RV rv = AEP_R_OK;
670 AEP_CONNECTION_HNDL hConnection;
671
672 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
673
674 /*Can the request be serviced with what's already in the buffer?*/
675 if (len <= rand_block_bytes)
676 {
677 memcpy(buf, &rand_block[RAND_BLK_SIZE - rand_block_bytes], len);
678 rand_block_bytes -= len;
679 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
680 }
681 else
682 /*If not the get another block of random bytes*/
683 {
684 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
685
686 rv = aep_get_connection(&hConnection);
687 if (rv != AEP_R_OK)
688 {
689 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_HANDLE_FAILED);
690 goto err_nounlock;
691 }
692
693 if (len > RAND_BLK_SIZE)
694 {
695 rv = p_AEP_GenRandom(hConnection, len, 2, buf, NULL);
696 if (rv != AEP_R_OK)
697 {
698 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_RANDOM_FAILED);
699 goto err_nounlock;
700 }
701 }
702 else
703 {
704 CRYPTO_w_lock(CRYPTO_LOCK_RAND);
705
706 rv = p_AEP_GenRandom(hConnection, RAND_BLK_SIZE, 2, &rand_block[0], NULL);
707 if (rv != AEP_R_OK)
708 {
709 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_GET_RANDOM_FAILED);
710
711 goto err;
712 }
713
714 rand_block_bytes = RAND_BLK_SIZE;
715
716 memcpy(buf, &rand_block[RAND_BLK_SIZE - rand_block_bytes], len);
717 rand_block_bytes -= len;
718
719 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
720 }
721
722 rv = aep_return_connection(hConnection);
723 if (rv != AEP_R_OK)
724 {
725 AEPHKerr(AEPHK_F_AEP_RAND,AEPHK_R_RETURN_CONNECTION_FAILED);
726
727 goto err_nounlock;
728 }
729 }
730
731 return 1;
732 err:
733 CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
734 err_nounlock:
735 return 0;
736 }
737
738static int aep_rand_status(void)
739{
740 return 1;
741}
742#endif
743
744#ifndef OPENSSL_NO_RSA
745static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
746 {
747 BN_CTX *ctx = NULL;
748 int to_return = 0;
749 AEP_RV rv = AEP_R_OK;
750
751 if ((ctx = BN_CTX_new()) == NULL)
752 goto err;
753
754 if (!aep_dso)
755 {
756 AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_NOT_LOADED);
757 goto err;
758 }
759
760 /*See if we have all the necessary bits for a crt*/
761 if (rsa->q && rsa->dmp1 && rsa->dmq1 && rsa->iqmp)
762 {
763 rv = aep_mod_exp_crt(r0,I,rsa->p,rsa->q, rsa->dmp1,rsa->dmq1,rsa->iqmp,ctx);
764
765 if (rv == FAIL_TO_SW){
766 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
767 to_return = (*meth->rsa_mod_exp)(r0, I, rsa);
768 goto err;
769 }
770 else if (rv != AEP_R_OK)
771 goto err;
772 }
773 else
774 {
775 if (!rsa->d || !rsa->n)
776 {
777 AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_MISSING_KEY_COMPONENTS);
778 goto err;
779 }
780
781 rv = aep_mod_exp(r0,I,rsa->d,rsa->n,ctx);
782 if (rv != AEP_R_OK)
783 goto err;
784
785 }
786
787 to_return = 1;
788
789 err:
790 if(ctx)
791 BN_CTX_free(ctx);
792 return to_return;
793}
794#endif
795
796#ifndef OPENSSL_NO_DSA
797static int aep_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
798 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
799 BN_CTX *ctx, BN_MONT_CTX *in_mont)
800 {
801 BIGNUM t;
802 int to_return = 0;
803 BN_init(&t);
804
805 /* let rr = a1 ^ p1 mod m */
806 if (!aep_mod_exp(rr,a1,p1,m,ctx)) goto end;
807 /* let t = a2 ^ p2 mod m */
808 if (!aep_mod_exp(&t,a2,p2,m,ctx)) goto end;
809 /* let rr = rr * t mod m */
810 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
811 to_return = 1;
812 end:
813 BN_free(&t);
814 return to_return;
815 }
816
817static int aep_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
818 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
819 BN_MONT_CTX *m_ctx)
820 {
821 return aep_mod_exp(r, a, p, m, ctx);
822 }
823#endif
824
825/* This function is aliased to mod_exp (with the mont stuff dropped). */
826static int aep_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
827 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
828 {
829 return aep_mod_exp(r, a, p, m, ctx);
830 }
831
832#ifndef OPENSSL_NO_DH
833/* This function is aliased to mod_exp (with the dh and mont dropped). */
834static int aep_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
835 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
836 BN_MONT_CTX *m_ctx)
837 {
838 return aep_mod_exp(r, a, p, m, ctx);
839 }
840#endif
841
842static AEP_RV aep_get_connection(AEP_CONNECTION_HNDL_PTR phConnection)
843 {
844 int count;
845 AEP_RV rv = AEP_R_OK;
846
847 /*Get the current process id*/
848 pid_t curr_pid;
849
850 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
851
852 curr_pid = getpid();
853
854 /*Check if this is the first time this is being called from the current
855 process*/
856 if (recorded_pid != curr_pid)
857 {
858 /*Remember our pid so we can check if we're in a new process*/
859 recorded_pid = curr_pid;
860
861 /*Call Finalize to make sure we have not inherited some data
862 from a parent process*/
863 p_AEP_Finalize();
864
865 /*Initialise the AEP API*/
866 rv = p_AEP_Initialize(NULL);
867
868 if (rv != AEP_R_OK)
869 {
870 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_INIT_FAILURE);
871 recorded_pid = 0;
872 goto end;
873 }
874
875 /*Set the AEP big num call back functions*/
876 rv = p_AEP_SetBNCallBacks(&GetBigNumSize, &MakeAEPBigNum,
877 &ConvertAEPBigNum);
878
879 if (rv != AEP_R_OK)
880 {
881 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_SETBNCALLBACK_FAILURE);
882 recorded_pid = 0;
883 goto end;
884 }
885
886#ifdef AEPRAND
887 /*Reset the rand byte count*/
888 rand_block_bytes = 0;
889#endif
890
891 /*Init the structures*/
892 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
893 {
894 aep_app_conn_table[count].conn_state = NotConnected;
895 aep_app_conn_table[count].conn_hndl = 0;
896 }
897
898 /*Open a connection*/
899 rv = p_AEP_OpenConnection(phConnection);
900
901 if (rv != AEP_R_OK)
902 {
903 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_UNIT_FAILURE);
904 recorded_pid = 0;
905 goto end;
906 }
907
908 aep_app_conn_table[0].conn_state = InUse;
909 aep_app_conn_table[0].conn_hndl = *phConnection;
910 goto end;
911 }
912 /*Check the existing connections to see if we can find a free one*/
913 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
914 {
915 if (aep_app_conn_table[count].conn_state == Connected)
916 {
917 aep_app_conn_table[count].conn_state = InUse;
918 *phConnection = aep_app_conn_table[count].conn_hndl;
919 goto end;
920 }
921 }
922 /*If no connections available, we're going to have to try
923 to open a new one*/
924 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
925 {
926 if (aep_app_conn_table[count].conn_state == NotConnected)
927 {
928 /*Open a connection*/
929 rv = p_AEP_OpenConnection(phConnection);
930
931 if (rv != AEP_R_OK)
932 {
933 AEPHKerr(AEPHK_F_AEP_GET_CONNECTION,AEPHK_R_UNIT_FAILURE);
934 goto end;
935 }
936
937 aep_app_conn_table[count].conn_state = InUse;
938 aep_app_conn_table[count].conn_hndl = *phConnection;
939 goto end;
940 }
941 }
942 rv = AEP_R_GENERAL_ERROR;
943 end:
944 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
945 return rv;
946 }
947
948
949static AEP_RV aep_return_connection(AEP_CONNECTION_HNDL hConnection)
950 {
951 int count;
952
953 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
954
955 /*Find the connection item that matches this connection handle*/
956 for(count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
957 {
958 if (aep_app_conn_table[count].conn_hndl == hConnection)
959 {
960 aep_app_conn_table[count].conn_state = Connected;
961 break;
962 }
963 }
964
965 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
966
967 return AEP_R_OK;
968 }
969
970static AEP_RV aep_close_connection(AEP_CONNECTION_HNDL hConnection)
971 {
972 int count;
973 AEP_RV rv = AEP_R_OK;
974
975 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
976
977 /*Find the connection item that matches this connection handle*/
978 for(count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
979 {
980 if (aep_app_conn_table[count].conn_hndl == hConnection)
981 {
982 rv = p_AEP_CloseConnection(aep_app_conn_table[count].conn_hndl);
983 if (rv != AEP_R_OK)
984 goto end;
985 aep_app_conn_table[count].conn_state = NotConnected;
986 aep_app_conn_table[count].conn_hndl = 0;
987 break;
988 }
989 }
990
991 end:
992 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
993 return rv;
994 }
995
996static AEP_RV aep_close_all_connections(int use_engine_lock, int *in_use)
997 {
998 int count;
999 AEP_RV rv = AEP_R_OK;
1000
1001 *in_use = 0;
1002 if (use_engine_lock) CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
1003 for (count = 0;count < MAX_PROCESS_CONNECTIONS;count ++)
1004 {
1005 switch (aep_app_conn_table[count].conn_state)
1006 {
1007 case Connected:
1008 rv = p_AEP_CloseConnection(aep_app_conn_table[count].conn_hndl);
1009 if (rv != AEP_R_OK)
1010 goto end;
1011 aep_app_conn_table[count].conn_state = NotConnected;
1012 aep_app_conn_table[count].conn_hndl = 0;
1013 break;
1014 case InUse:
1015 (*in_use)++;
1016 break;
1017 case NotConnected:
1018 break;
1019 }
1020 }
1021 end:
1022 if (use_engine_lock) CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
1023 return rv;
1024 }
1025
1026/*BigNum call back functions, used to convert OpenSSL bignums into AEP bignums.
1027 Note only 32bit Openssl build support*/
1028
1029static AEP_RV GetBigNumSize(AEP_VOID_PTR ArbBigNum, AEP_U32* BigNumSize)
1030 {
1031 BIGNUM* bn;
1032
1033 /*Cast the ArbBigNum pointer to our BIGNUM struct*/
1034 bn = (BIGNUM*) ArbBigNum;
1035
1036#ifdef SIXTY_FOUR_BIT_LONG
1037 *BigNumSize = bn->top << 3;
1038#else
1039 /*Size of the bignum in bytes is equal to the bn->top (no of 32 bit
1040 words) multiplies by 4*/
1041 *BigNumSize = bn->top << 2;
1042#endif
1043
1044 return AEP_R_OK;
1045 }
1046
1047static AEP_RV MakeAEPBigNum(AEP_VOID_PTR ArbBigNum, AEP_U32 BigNumSize,
1048 unsigned char* AEP_BigNum)
1049 {
1050 BIGNUM* bn;
1051
1052#ifndef SIXTY_FOUR_BIT_LONG
1053 unsigned char* buf;
1054 int i;
1055#endif
1056
1057 /*Cast the ArbBigNum pointer to our BIGNUM struct*/
1058 bn = (BIGNUM*) ArbBigNum;
1059
1060#ifdef SIXTY_FOUR_BIT_LONG
1061 memcpy(AEP_BigNum, bn->d, BigNumSize);
1062#else
1063 /*Must copy data into a (monotone) least significant byte first format
1064 performing endian conversion if necessary*/
1065 for(i=0;i<bn->top;i++)
1066 {
1067 buf = (unsigned char*)&bn->d[i];
1068
1069 *((AEP_U32*)AEP_BigNum) = (AEP_U32)
1070 ((unsigned) buf[1] << 8 | buf[0]) |
1071 ((unsigned) buf[3] << 8 | buf[2]) << 16;
1072
1073 AEP_BigNum += 4;
1074 }
1075#endif
1076
1077 return AEP_R_OK;
1078 }
1079
1080/*Turn an AEP Big Num back to a user big num*/
1081static AEP_RV ConvertAEPBigNum(void* ArbBigNum, AEP_U32 BigNumSize,
1082 unsigned char* AEP_BigNum)
1083 {
1084 BIGNUM* bn;
1085#ifndef SIXTY_FOUR_BIT_LONG
1086 int i;
1087#endif
1088
1089 bn = (BIGNUM*)ArbBigNum;
1090
1091 /*Expand the result bn so that it can hold our big num.
1092 Size is in bits*/
1093 bn_expand(bn, (int)(BigNumSize << 3));
1094
1095#ifdef SIXTY_FOUR_BIT_LONG
1096 bn->top = BigNumSize >> 3;
1097
1098 if((BigNumSize & 7) != 0)
1099 bn->top++;
1100
1101 memset(bn->d, 0, bn->top << 3);
1102
1103 memcpy(bn->d, AEP_BigNum, BigNumSize);
1104#else
1105 bn->top = BigNumSize >> 2;
1106
1107 for(i=0;i<bn->top;i++)
1108 {
1109 bn->d[i] = (AEP_U32)
1110 ((unsigned) AEP_BigNum[3] << 8 | AEP_BigNum[2]) << 16 |
1111 ((unsigned) AEP_BigNum[1] << 8 | AEP_BigNum[0]);
1112 AEP_BigNum += 4;
1113 }
1114#endif
1115
1116 return AEP_R_OK;
1117}
1118
1119#endif /* !OPENSSL_NO_HW_AEP */
1120#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_aep_err.c b/src/lib/libcrypto/engine/hw_aep_err.c
deleted file mode 100644
index 092f532946..0000000000
--- a/src/lib/libcrypto/engine/hw_aep_err.c
+++ /dev/null
@@ -1,157 +0,0 @@
1/* hw_aep_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_aep_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA AEPHK_str_functs[]=
68 {
69{ERR_PACK(0,AEPHK_F_AEP_CTRL,0), "AEP_CTRL"},
70{ERR_PACK(0,AEPHK_F_AEP_FINISH,0), "AEP_FINISH"},
71{ERR_PACK(0,AEPHK_F_AEP_GET_CONNECTION,0), "AEP_GET_CONNECTION"},
72{ERR_PACK(0,AEPHK_F_AEP_INIT,0), "AEP_INIT"},
73{ERR_PACK(0,AEPHK_F_AEP_MOD_EXP,0), "AEP_MOD_EXP"},
74{ERR_PACK(0,AEPHK_F_AEP_MOD_EXP_CRT,0), "AEP_MOD_EXP_CRT"},
75{ERR_PACK(0,AEPHK_F_AEP_RAND,0), "AEP_RAND"},
76{ERR_PACK(0,AEPHK_F_AEP_RSA_MOD_EXP,0), "AEP_RSA_MOD_EXP"},
77{0,NULL}
78 };
79
80static ERR_STRING_DATA AEPHK_str_reasons[]=
81 {
82{AEPHK_R_ALREADY_LOADED ,"already loaded"},
83{AEPHK_R_CLOSE_HANDLES_FAILED ,"close handles failed"},
84{AEPHK_R_CONNECTIONS_IN_USE ,"connections in use"},
85{AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
86{AEPHK_R_FINALIZE_FAILED ,"finalize failed"},
87{AEPHK_R_GET_HANDLE_FAILED ,"get handle failed"},
88{AEPHK_R_GET_RANDOM_FAILED ,"get random failed"},
89{AEPHK_R_INIT_FAILURE ,"init failure"},
90{AEPHK_R_MISSING_KEY_COMPONENTS ,"missing key components"},
91{AEPHK_R_MOD_EXP_CRT_FAILED ,"mod exp crt failed"},
92{AEPHK_R_MOD_EXP_FAILED ,"mod exp failed"},
93{AEPHK_R_NOT_LOADED ,"not loaded"},
94{AEPHK_R_OK ,"ok"},
95{AEPHK_R_RETURN_CONNECTION_FAILED ,"return connection failed"},
96{AEPHK_R_SETBNCALLBACK_FAILURE ,"setbncallback failure"},
97{AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL ,"size too large or too small"},
98{AEPHK_R_UNIT_FAILURE ,"unit failure"},
99{0,NULL}
100 };
101
102#endif
103
104#ifdef AEPHK_LIB_NAME
105static ERR_STRING_DATA AEPHK_lib_name[]=
106 {
107{0 ,AEPHK_LIB_NAME},
108{0,NULL}
109 };
110#endif
111
112
113static int AEPHK_lib_error_code=0;
114static int AEPHK_error_init=1;
115
116static void ERR_load_AEPHK_strings(void)
117 {
118 if (AEPHK_lib_error_code == 0)
119 AEPHK_lib_error_code=ERR_get_next_error_library();
120
121 if (AEPHK_error_init)
122 {
123 AEPHK_error_init=0;
124#ifndef OPENSSL_NO_ERR
125 ERR_load_strings(AEPHK_lib_error_code,AEPHK_str_functs);
126 ERR_load_strings(AEPHK_lib_error_code,AEPHK_str_reasons);
127#endif
128
129#ifdef AEPHK_LIB_NAME
130 AEPHK_lib_name->error = ERR_PACK(AEPHK_lib_error_code,0,0);
131 ERR_load_strings(0,AEPHK_lib_name);
132#endif
133 }
134 }
135
136static void ERR_unload_AEPHK_strings(void)
137 {
138 if (AEPHK_error_init == 0)
139 {
140#ifndef OPENSSL_NO_ERR
141 ERR_unload_strings(AEPHK_lib_error_code,AEPHK_str_functs);
142 ERR_unload_strings(AEPHK_lib_error_code,AEPHK_str_reasons);
143#endif
144
145#ifdef AEPHK_LIB_NAME
146 ERR_unload_strings(0,AEPHK_lib_name);
147#endif
148 AEPHK_error_init=1;
149 }
150 }
151
152static void ERR_AEPHK_error(int function, int reason, char *file, int line)
153 {
154 if (AEPHK_lib_error_code == 0)
155 AEPHK_lib_error_code=ERR_get_next_error_library();
156 ERR_PUT_error(AEPHK_lib_error_code,function,reason,file,line);
157 }
diff --git a/src/lib/libcrypto/engine/hw_atalla.c b/src/lib/libcrypto/engine/hw_atalla.c
deleted file mode 100644
index 2b8342bbdd..0000000000
--- a/src/lib/libcrypto/engine/hw_atalla.c
+++ /dev/null
@@ -1,595 +0,0 @@
1/* crypto/engine/hw_atalla.c */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 1999-2001 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/dso.h>
63#include <openssl/engine.h>
64
65#ifndef OPENSSL_NO_HW
66#ifndef OPENSSL_NO_HW_ATALLA
67
68#ifdef FLAT_INC
69#include "atalla.h"
70#else
71#include "vendor_defns/atalla.h"
72#endif
73
74#define ATALLA_LIB_NAME "atalla engine"
75#include "hw_atalla_err.c"
76
77static int atalla_destroy(ENGINE *e);
78static int atalla_init(ENGINE *e);
79static int atalla_finish(ENGINE *e);
80static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
81
82/* BIGNUM stuff */
83static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
84 const BIGNUM *m, BN_CTX *ctx);
85
86#ifndef OPENSSL_NO_RSA
87/* RSA stuff */
88static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
89#endif
90/* This function is aliased to mod_exp (with the mont stuff dropped). */
91static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
92 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
93
94#ifndef OPENSSL_NO_DSA
95/* DSA stuff */
96static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
97 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
98 BN_CTX *ctx, BN_MONT_CTX *in_mont);
99static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
100 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
101 BN_MONT_CTX *m_ctx);
102#endif
103
104#ifndef OPENSSL_NO_DH
105/* DH stuff */
106/* This function is alised to mod_exp (with the DH and mont dropped). */
107static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r,
108 const BIGNUM *a, const BIGNUM *p,
109 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
110#endif
111
112/* The definitions for control commands specific to this engine */
113#define ATALLA_CMD_SO_PATH ENGINE_CMD_BASE
114static const ENGINE_CMD_DEFN atalla_cmd_defns[] = {
115 {ATALLA_CMD_SO_PATH,
116 "SO_PATH",
117 "Specifies the path to the 'atasi' shared library",
118 ENGINE_CMD_FLAG_STRING},
119 {0, NULL, NULL, 0}
120 };
121
122#ifndef OPENSSL_NO_RSA
123/* Our internal RSA_METHOD that we provide pointers to */
124static RSA_METHOD atalla_rsa =
125 {
126 "Atalla RSA method",
127 NULL,
128 NULL,
129 NULL,
130 NULL,
131 atalla_rsa_mod_exp,
132 atalla_mod_exp_mont,
133 NULL,
134 NULL,
135 0,
136 NULL,
137 NULL,
138 NULL
139 };
140#endif
141
142#ifndef OPENSSL_NO_DSA
143/* Our internal DSA_METHOD that we provide pointers to */
144static DSA_METHOD atalla_dsa =
145 {
146 "Atalla DSA method",
147 NULL, /* dsa_do_sign */
148 NULL, /* dsa_sign_setup */
149 NULL, /* dsa_do_verify */
150 atalla_dsa_mod_exp, /* dsa_mod_exp */
151 atalla_mod_exp_dsa, /* bn_mod_exp */
152 NULL, /* init */
153 NULL, /* finish */
154 0, /* flags */
155 NULL /* app_data */
156 };
157#endif
158
159#ifndef OPENSSL_NO_DH
160/* Our internal DH_METHOD that we provide pointers to */
161static DH_METHOD atalla_dh =
162 {
163 "Atalla DH method",
164 NULL,
165 NULL,
166 atalla_mod_exp_dh,
167 NULL,
168 NULL,
169 0,
170 NULL
171 };
172#endif
173
174/* Constants used when creating the ENGINE */
175static const char *engine_atalla_id = "atalla";
176static const char *engine_atalla_name = "Atalla hardware engine support";
177
178/* This internal function is used by ENGINE_atalla() and possibly by the
179 * "dynamic" ENGINE support too */
180static int bind_helper(ENGINE *e)
181 {
182#ifndef OPENSSL_NO_RSA
183 const RSA_METHOD *meth1;
184#endif
185#ifndef OPENSSL_NO_DSA
186 const DSA_METHOD *meth2;
187#endif
188#ifndef OPENSSL_NO_DH
189 const DH_METHOD *meth3;
190#endif
191 if(!ENGINE_set_id(e, engine_atalla_id) ||
192 !ENGINE_set_name(e, engine_atalla_name) ||
193#ifndef OPENSSL_NO_RSA
194 !ENGINE_set_RSA(e, &atalla_rsa) ||
195#endif
196#ifndef OPENSSL_NO_DSA
197 !ENGINE_set_DSA(e, &atalla_dsa) ||
198#endif
199#ifndef OPENSSL_NO_DH
200 !ENGINE_set_DH(e, &atalla_dh) ||
201#endif
202 !ENGINE_set_destroy_function(e, atalla_destroy) ||
203 !ENGINE_set_init_function(e, atalla_init) ||
204 !ENGINE_set_finish_function(e, atalla_finish) ||
205 !ENGINE_set_ctrl_function(e, atalla_ctrl) ||
206 !ENGINE_set_cmd_defns(e, atalla_cmd_defns))
207 return 0;
208
209#ifndef OPENSSL_NO_RSA
210 /* We know that the "PKCS1_SSLeay()" functions hook properly
211 * to the atalla-specific mod_exp and mod_exp_crt so we use
212 * those functions. NB: We don't use ENGINE_openssl() or
213 * anything "more generic" because something like the RSAref
214 * code may not hook properly, and if you own one of these
215 * cards then you have the right to do RSA operations on it
216 * anyway! */
217 meth1 = RSA_PKCS1_SSLeay();
218 atalla_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
219 atalla_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
220 atalla_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
221 atalla_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
222#endif
223
224#ifndef OPENSSL_NO_DSA
225 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
226 * bits. */
227 meth2 = DSA_OpenSSL();
228 atalla_dsa.dsa_do_sign = meth2->dsa_do_sign;
229 atalla_dsa.dsa_sign_setup = meth2->dsa_sign_setup;
230 atalla_dsa.dsa_do_verify = meth2->dsa_do_verify;
231#endif
232
233#ifndef OPENSSL_NO_DH
234 /* Much the same for Diffie-Hellman */
235 meth3 = DH_OpenSSL();
236 atalla_dh.generate_key = meth3->generate_key;
237 atalla_dh.compute_key = meth3->compute_key;
238#endif
239
240 /* Ensure the atalla error handling is set up */
241 ERR_load_ATALLA_strings();
242 return 1;
243 }
244
245#ifndef ENGINE_DYNAMIC_SUPPORT
246static ENGINE *engine_atalla(void)
247 {
248 ENGINE *ret = ENGINE_new();
249 if(!ret)
250 return NULL;
251 if(!bind_helper(ret))
252 {
253 ENGINE_free(ret);
254 return NULL;
255 }
256 return ret;
257 }
258
259void ENGINE_load_atalla(void)
260 {
261 /* Copied from eng_[openssl|dyn].c */
262 ENGINE *toadd = engine_atalla();
263 if(!toadd) return;
264 ENGINE_add(toadd);
265 ENGINE_free(toadd);
266 ERR_clear_error();
267 }
268#endif
269
270/* This is a process-global DSO handle used for loading and unloading
271 * the Atalla library. NB: This is only set (or unset) during an
272 * init() or finish() call (reference counts permitting) and they're
273 * operating with global locks, so this should be thread-safe
274 * implicitly. */
275static DSO *atalla_dso = NULL;
276
277/* These are the function pointers that are (un)set when the library has
278 * successfully (un)loaded. */
279static tfnASI_GetHardwareConfig *p_Atalla_GetHardwareConfig = NULL;
280static tfnASI_RSAPrivateKeyOpFn *p_Atalla_RSAPrivateKeyOpFn = NULL;
281static tfnASI_GetPerformanceStatistics *p_Atalla_GetPerformanceStatistics = NULL;
282
283/* These are the static string constants for the DSO file name and the function
284 * symbol names to bind to. Regrettably, the DSO name on *nix appears to be
285 * "atasi.so" rather than something more consistent like "libatasi.so". At the
286 * time of writing, I'm not sure what the file name on win32 is but clearly
287 * native name translation is not possible (eg libatasi.so on *nix, and
288 * atasi.dll on win32). For the purposes of testing, I have created a symbollic
289 * link called "libatasi.so" so that we can use native name-translation - a
290 * better solution will be needed. */
291static const char *ATALLA_LIBNAME = NULL;
292static const char *get_ATALLA_LIBNAME(void)
293 {
294 if(ATALLA_LIBNAME)
295 return ATALLA_LIBNAME;
296 return "atasi";
297 }
298static void free_ATALLA_LIBNAME(void)
299 {
300 if(ATALLA_LIBNAME)
301 OPENSSL_free((void*)ATALLA_LIBNAME);
302 ATALLA_LIBNAME = NULL;
303 }
304static long set_ATALLA_LIBNAME(const char *name)
305 {
306 free_ATALLA_LIBNAME();
307 return (((ATALLA_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
308 }
309static const char *ATALLA_F1 = "ASI_GetHardwareConfig";
310static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn";
311static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics";
312
313/* Destructor (complements the "ENGINE_atalla()" constructor) */
314static int atalla_destroy(ENGINE *e)
315 {
316 free_ATALLA_LIBNAME();
317 /* Unload the atalla error strings so any error state including our
318 * functs or reasons won't lead to a segfault (they simply get displayed
319 * without corresponding string data because none will be found). */
320 ERR_unload_ATALLA_strings();
321 return 1;
322 }
323
324/* (de)initialisation functions. */
325static int atalla_init(ENGINE *e)
326 {
327 tfnASI_GetHardwareConfig *p1;
328 tfnASI_RSAPrivateKeyOpFn *p2;
329 tfnASI_GetPerformanceStatistics *p3;
330 /* Not sure of the origin of this magic value, but Ben's code had it
331 * and it seemed to have been working for a few people. :-) */
332 unsigned int config_buf[1024];
333
334 if(atalla_dso != NULL)
335 {
336 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_ALREADY_LOADED);
337 goto err;
338 }
339 /* Attempt to load libatasi.so/atasi.dll/whatever. Needs to be
340 * changed unfortunately because the Atalla drivers don't have
341 * standard library names that can be platform-translated well. */
342 /* TODO: Work out how to actually map to the names the Atalla
343 * drivers really use - for now a symbollic link needs to be
344 * created on the host system from libatasi.so to atasi.so on
345 * unix variants. */
346 atalla_dso = DSO_load(NULL, get_ATALLA_LIBNAME(), NULL, 0);
347 if(atalla_dso == NULL)
348 {
349 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_NOT_LOADED);
350 goto err;
351 }
352 if(!(p1 = (tfnASI_GetHardwareConfig *)DSO_bind_func(
353 atalla_dso, ATALLA_F1)) ||
354 !(p2 = (tfnASI_RSAPrivateKeyOpFn *)DSO_bind_func(
355 atalla_dso, ATALLA_F2)) ||
356 !(p3 = (tfnASI_GetPerformanceStatistics *)DSO_bind_func(
357 atalla_dso, ATALLA_F3)))
358 {
359 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_NOT_LOADED);
360 goto err;
361 }
362 /* Copy the pointers */
363 p_Atalla_GetHardwareConfig = p1;
364 p_Atalla_RSAPrivateKeyOpFn = p2;
365 p_Atalla_GetPerformanceStatistics = p3;
366 /* Perform a basic test to see if there's actually any unit
367 * running. */
368 if(p1(0L, config_buf) != 0)
369 {
370 ATALLAerr(ATALLA_F_ATALLA_INIT,ATALLA_R_UNIT_FAILURE);
371 goto err;
372 }
373 /* Everything's fine. */
374 return 1;
375err:
376 if(atalla_dso)
377 DSO_free(atalla_dso);
378 atalla_dso = NULL;
379 p_Atalla_GetHardwareConfig = NULL;
380 p_Atalla_RSAPrivateKeyOpFn = NULL;
381 p_Atalla_GetPerformanceStatistics = NULL;
382 return 0;
383 }
384
385static int atalla_finish(ENGINE *e)
386 {
387 free_ATALLA_LIBNAME();
388 if(atalla_dso == NULL)
389 {
390 ATALLAerr(ATALLA_F_ATALLA_FINISH,ATALLA_R_NOT_LOADED);
391 return 0;
392 }
393 if(!DSO_free(atalla_dso))
394 {
395 ATALLAerr(ATALLA_F_ATALLA_FINISH,ATALLA_R_UNIT_FAILURE);
396 return 0;
397 }
398 atalla_dso = NULL;
399 p_Atalla_GetHardwareConfig = NULL;
400 p_Atalla_RSAPrivateKeyOpFn = NULL;
401 p_Atalla_GetPerformanceStatistics = NULL;
402 return 1;
403 }
404
405static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
406 {
407 int initialised = ((atalla_dso == NULL) ? 0 : 1);
408 switch(cmd)
409 {
410 case ATALLA_CMD_SO_PATH:
411 if(p == NULL)
412 {
413 ATALLAerr(ATALLA_F_ATALLA_CTRL,ERR_R_PASSED_NULL_PARAMETER);
414 return 0;
415 }
416 if(initialised)
417 {
418 ATALLAerr(ATALLA_F_ATALLA_CTRL,ATALLA_R_ALREADY_LOADED);
419 return 0;
420 }
421 return set_ATALLA_LIBNAME((const char *)p);
422 default:
423 break;
424 }
425 ATALLAerr(ATALLA_F_ATALLA_CTRL,ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED);
426 return 0;
427 }
428
429static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
430 const BIGNUM *m, BN_CTX *ctx)
431 {
432 /* I need somewhere to store temporary serialised values for
433 * use with the Atalla API calls. A neat cheat - I'll use
434 * BIGNUMs from the BN_CTX but access their arrays directly as
435 * byte arrays <grin>. This way I don't have to clean anything
436 * up. */
437 BIGNUM *modulus;
438 BIGNUM *exponent;
439 BIGNUM *argument;
440 BIGNUM *result;
441 RSAPrivateKey keydata;
442 int to_return, numbytes;
443
444 modulus = exponent = argument = result = NULL;
445 to_return = 0; /* expect failure */
446
447 if(!atalla_dso)
448 {
449 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_NOT_LOADED);
450 goto err;
451 }
452 /* Prepare the params */
453 BN_CTX_start(ctx);
454 modulus = BN_CTX_get(ctx);
455 exponent = BN_CTX_get(ctx);
456 argument = BN_CTX_get(ctx);
457 result = BN_CTX_get(ctx);
458 if (!result)
459 {
460 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_BN_CTX_FULL);
461 goto err;
462 }
463 if(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, m->top) ||
464 !bn_wexpand(argument, m->top) || !bn_wexpand(result, m->top))
465 {
466 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_BN_EXPAND_FAIL);
467 goto err;
468 }
469 /* Prepare the key-data */
470 memset(&keydata, 0,sizeof keydata);
471 numbytes = BN_num_bytes(m);
472 memset(exponent->d, 0, numbytes);
473 memset(modulus->d, 0, numbytes);
474 BN_bn2bin(p, (unsigned char *)exponent->d + numbytes - BN_num_bytes(p));
475 BN_bn2bin(m, (unsigned char *)modulus->d + numbytes - BN_num_bytes(m));
476 keydata.privateExponent.data = (unsigned char *)exponent->d;
477 keydata.privateExponent.len = numbytes;
478 keydata.modulus.data = (unsigned char *)modulus->d;
479 keydata.modulus.len = numbytes;
480 /* Prepare the argument */
481 memset(argument->d, 0, numbytes);
482 memset(result->d, 0, numbytes);
483 BN_bn2bin(a, (unsigned char *)argument->d + numbytes - BN_num_bytes(a));
484 /* Perform the operation */
485 if(p_Atalla_RSAPrivateKeyOpFn(&keydata, (unsigned char *)result->d,
486 (unsigned char *)argument->d,
487 keydata.modulus.len) != 0)
488 {
489 ATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_REQUEST_FAILED);
490 goto err;
491 }
492 /* Convert the response */
493 BN_bin2bn((unsigned char *)result->d, numbytes, r);
494 to_return = 1;
495err:
496 BN_CTX_end(ctx);
497 return to_return;
498 }
499
500#ifndef OPENSSL_NO_RSA
501static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
502 {
503 BN_CTX *ctx = NULL;
504 int to_return = 0;
505
506 if(!atalla_dso)
507 {
508 ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,ATALLA_R_NOT_LOADED);
509 goto err;
510 }
511 if((ctx = BN_CTX_new()) == NULL)
512 goto err;
513 if(!rsa->d || !rsa->n)
514 {
515 ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,ATALLA_R_MISSING_KEY_COMPONENTS);
516 goto err;
517 }
518 to_return = atalla_mod_exp(r0, I, rsa->d, rsa->n, ctx);
519err:
520 if(ctx)
521 BN_CTX_free(ctx);
522 return to_return;
523 }
524#endif
525
526#ifndef OPENSSL_NO_DSA
527/* This code was liberated and adapted from the commented-out code in
528 * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration
529 * (it doesn't have a CRT form for RSA), this function means that an
530 * Atalla system running with a DSA server certificate can handshake
531 * around 5 or 6 times faster/more than an equivalent system running with
532 * RSA. Just check out the "signs" statistics from the RSA and DSA parts
533 * of "openssl speed -engine atalla dsa1024 rsa1024". */
534static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
535 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
536 BN_CTX *ctx, BN_MONT_CTX *in_mont)
537 {
538 BIGNUM t;
539 int to_return = 0;
540
541 BN_init(&t);
542 /* let rr = a1 ^ p1 mod m */
543 if (!atalla_mod_exp(rr,a1,p1,m,ctx)) goto end;
544 /* let t = a2 ^ p2 mod m */
545 if (!atalla_mod_exp(&t,a2,p2,m,ctx)) goto end;
546 /* let rr = rr * t mod m */
547 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
548 to_return = 1;
549end:
550 BN_free(&t);
551 return to_return;
552 }
553
554static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
555 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
556 BN_MONT_CTX *m_ctx)
557 {
558 return atalla_mod_exp(r, a, p, m, ctx);
559 }
560#endif
561
562/* This function is aliased to mod_exp (with the mont stuff dropped). */
563static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
564 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
565 {
566 return atalla_mod_exp(r, a, p, m, ctx);
567 }
568
569#ifndef OPENSSL_NO_DH
570/* This function is aliased to mod_exp (with the dh and mont dropped). */
571static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r,
572 const BIGNUM *a, const BIGNUM *p,
573 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
574 {
575 return atalla_mod_exp(r, a, p, m, ctx);
576 }
577#endif
578
579/* This stuff is needed if this ENGINE is being compiled into a self-contained
580 * shared-library. */
581#ifdef ENGINE_DYNAMIC_SUPPORT
582static int bind_fn(ENGINE *e, const char *id)
583 {
584 if(id && (strcmp(id, engine_atalla_id) != 0))
585 return 0;
586 if(!bind_helper(e))
587 return 0;
588 return 1;
589 }
590IMPLEMENT_DYNAMIC_CHECK_FN()
591IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
592#endif /* ENGINE_DYNAMIC_SUPPORT */
593
594#endif /* !OPENSSL_NO_HW_ATALLA */
595#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_atalla_err.c b/src/lib/libcrypto/engine/hw_atalla_err.c
deleted file mode 100644
index 1df9c4570c..0000000000
--- a/src/lib/libcrypto/engine/hw_atalla_err.c
+++ /dev/null
@@ -1,145 +0,0 @@
1/* hw_atalla_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_atalla_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA ATALLA_str_functs[]=
68 {
69{ERR_PACK(0,ATALLA_F_ATALLA_CTRL,0), "ATALLA_CTRL"},
70{ERR_PACK(0,ATALLA_F_ATALLA_FINISH,0), "ATALLA_FINISH"},
71{ERR_PACK(0,ATALLA_F_ATALLA_INIT,0), "ATALLA_INIT"},
72{ERR_PACK(0,ATALLA_F_ATALLA_MOD_EXP,0), "ATALLA_MOD_EXP"},
73{ERR_PACK(0,ATALLA_F_ATALLA_RSA_MOD_EXP,0), "ATALLA_RSA_MOD_EXP"},
74{0,NULL}
75 };
76
77static ERR_STRING_DATA ATALLA_str_reasons[]=
78 {
79{ATALLA_R_ALREADY_LOADED ,"already loaded"},
80{ATALLA_R_BN_CTX_FULL ,"bn ctx full"},
81{ATALLA_R_BN_EXPAND_FAIL ,"bn expand fail"},
82{ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
83{ATALLA_R_MISSING_KEY_COMPONENTS ,"missing key components"},
84{ATALLA_R_NOT_LOADED ,"not loaded"},
85{ATALLA_R_REQUEST_FAILED ,"request failed"},
86{ATALLA_R_UNIT_FAILURE ,"unit failure"},
87{0,NULL}
88 };
89
90#endif
91
92#ifdef ATALLA_LIB_NAME
93static ERR_STRING_DATA ATALLA_lib_name[]=
94 {
95{0 ,ATALLA_LIB_NAME},
96{0,NULL}
97 };
98#endif
99
100
101static int ATALLA_lib_error_code=0;
102static int ATALLA_error_init=1;
103
104static void ERR_load_ATALLA_strings(void)
105 {
106 if (ATALLA_lib_error_code == 0)
107 ATALLA_lib_error_code=ERR_get_next_error_library();
108
109 if (ATALLA_error_init)
110 {
111 ATALLA_error_init=0;
112#ifndef OPENSSL_NO_ERR
113 ERR_load_strings(ATALLA_lib_error_code,ATALLA_str_functs);
114 ERR_load_strings(ATALLA_lib_error_code,ATALLA_str_reasons);
115#endif
116
117#ifdef ATALLA_LIB_NAME
118 ATALLA_lib_name->error = ERR_PACK(ATALLA_lib_error_code,0,0);
119 ERR_load_strings(0,ATALLA_lib_name);
120#endif
121 }
122 }
123
124static void ERR_unload_ATALLA_strings(void)
125 {
126 if (ATALLA_error_init == 0)
127 {
128#ifndef OPENSSL_NO_ERR
129 ERR_unload_strings(ATALLA_lib_error_code,ATALLA_str_functs);
130 ERR_unload_strings(ATALLA_lib_error_code,ATALLA_str_reasons);
131#endif
132
133#ifdef ATALLA_LIB_NAME
134 ERR_unload_strings(0,ATALLA_lib_name);
135#endif
136 ATALLA_error_init=1;
137 }
138 }
139
140static void ERR_ATALLA_error(int function, int reason, char *file, int line)
141 {
142 if (ATALLA_lib_error_code == 0)
143 ATALLA_lib_error_code=ERR_get_next_error_library();
144 ERR_PUT_error(ATALLA_lib_error_code,function,reason,file,line);
145 }
diff --git a/src/lib/libcrypto/engine/hw_cswift.c b/src/lib/libcrypto/engine/hw_cswift.c
deleted file mode 100644
index 1411fd8333..0000000000
--- a/src/lib/libcrypto/engine/hw_cswift.c
+++ /dev/null
@@ -1,1109 +0,0 @@
1/* crypto/engine/hw_cswift.c */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000.
4 */
5/* ====================================================================
6 * Copyright (c) 1999-2001 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/dso.h>
63#include <openssl/engine.h>
64
65#ifndef OPENSSL_NO_HW
66#ifndef OPENSSL_NO_HW_CSWIFT
67
68/* Attribution notice: Rainbow have generously allowed me to reproduce
69 * the necessary definitions here from their API. This means the support
70 * can build independently of whether application builders have the
71 * API or hardware. This will allow developers to easily produce software
72 * that has latent hardware support for any users that have accelerators
73 * installed, without the developers themselves needing anything extra.
74 *
75 * I have only clipped the parts from the CryptoSwift header files that
76 * are (or seem) relevant to the CryptoSwift support code. This is
77 * simply to keep the file sizes reasonable.
78 * [Geoff]
79 */
80#ifdef FLAT_INC
81#include "cswift.h"
82#else
83#include "vendor_defns/cswift.h"
84#endif
85
86#define CSWIFT_LIB_NAME "cswift engine"
87#include "hw_cswift_err.c"
88
89static int cswift_destroy(ENGINE *e);
90static int cswift_init(ENGINE *e);
91static int cswift_finish(ENGINE *e);
92static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
93static int cswift_bn_32copy(SW_LARGENUMBER * out, const BIGNUM * in);
94
95/* BIGNUM stuff */
96static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
97 const BIGNUM *m, BN_CTX *ctx);
98static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
99 const BIGNUM *q, const BIGNUM *dmp1, const BIGNUM *dmq1,
100 const BIGNUM *iqmp, BN_CTX *ctx);
101
102#ifndef OPENSSL_NO_RSA
103/* RSA stuff */
104static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
105#endif
106/* This function is aliased to mod_exp (with the mont stuff dropped). */
107static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
108 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
109
110#ifndef OPENSSL_NO_DSA
111/* DSA stuff */
112static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa);
113static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
114 DSA_SIG *sig, DSA *dsa);
115#endif
116
117#ifndef OPENSSL_NO_DH
118/* DH stuff */
119/* This function is alised to mod_exp (with the DH and mont dropped). */
120static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r,
121 const BIGNUM *a, const BIGNUM *p,
122 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
123#endif
124
125/* RAND stuff */
126static int cswift_rand_bytes(unsigned char *buf, int num);
127static int cswift_rand_status(void);
128
129/* The definitions for control commands specific to this engine */
130#define CSWIFT_CMD_SO_PATH ENGINE_CMD_BASE
131static const ENGINE_CMD_DEFN cswift_cmd_defns[] = {
132 {CSWIFT_CMD_SO_PATH,
133 "SO_PATH",
134 "Specifies the path to the 'cswift' shared library",
135 ENGINE_CMD_FLAG_STRING},
136 {0, NULL, NULL, 0}
137 };
138
139#ifndef OPENSSL_NO_RSA
140/* Our internal RSA_METHOD that we provide pointers to */
141static RSA_METHOD cswift_rsa =
142 {
143 "CryptoSwift RSA method",
144 NULL,
145 NULL,
146 NULL,
147 NULL,
148 cswift_rsa_mod_exp,
149 cswift_mod_exp_mont,
150 NULL,
151 NULL,
152 0,
153 NULL,
154 NULL,
155 NULL
156 };
157#endif
158
159#ifndef OPENSSL_NO_DSA
160/* Our internal DSA_METHOD that we provide pointers to */
161static DSA_METHOD cswift_dsa =
162 {
163 "CryptoSwift DSA method",
164 cswift_dsa_sign,
165 NULL, /* dsa_sign_setup */
166 cswift_dsa_verify,
167 NULL, /* dsa_mod_exp */
168 NULL, /* bn_mod_exp */
169 NULL, /* init */
170 NULL, /* finish */
171 0, /* flags */
172 NULL /* app_data */
173 };
174#endif
175
176#ifndef OPENSSL_NO_DH
177/* Our internal DH_METHOD that we provide pointers to */
178static DH_METHOD cswift_dh =
179 {
180 "CryptoSwift DH method",
181 NULL,
182 NULL,
183 cswift_mod_exp_dh,
184 NULL,
185 NULL,
186 0,
187 NULL
188 };
189#endif
190
191static RAND_METHOD cswift_random =
192 {
193 /* "CryptoSwift RAND method", */
194 NULL,
195 cswift_rand_bytes,
196 NULL,
197 NULL,
198 cswift_rand_bytes,
199 cswift_rand_status,
200 };
201
202
203/* Constants used when creating the ENGINE */
204static const char *engine_cswift_id = "cswift";
205static const char *engine_cswift_name = "CryptoSwift hardware engine support";
206
207/* This internal function is used by ENGINE_cswift() and possibly by the
208 * "dynamic" ENGINE support too */
209static int bind_helper(ENGINE *e)
210 {
211#ifndef OPENSSL_NO_RSA
212 const RSA_METHOD *meth1;
213#endif
214#ifndef OPENSSL_NO_DH
215 const DH_METHOD *meth2;
216#endif
217 if(!ENGINE_set_id(e, engine_cswift_id) ||
218 !ENGINE_set_name(e, engine_cswift_name) ||
219#ifndef OPENSSL_NO_RSA
220 !ENGINE_set_RSA(e, &cswift_rsa) ||
221#endif
222#ifndef OPENSSL_NO_DSA
223 !ENGINE_set_DSA(e, &cswift_dsa) ||
224#endif
225#ifndef OPENSSL_NO_DH
226 !ENGINE_set_DH(e, &cswift_dh) ||
227#endif
228 !ENGINE_set_RAND(e, &cswift_random) ||
229 !ENGINE_set_destroy_function(e, cswift_destroy) ||
230 !ENGINE_set_init_function(e, cswift_init) ||
231 !ENGINE_set_finish_function(e, cswift_finish) ||
232 !ENGINE_set_ctrl_function(e, cswift_ctrl) ||
233 !ENGINE_set_cmd_defns(e, cswift_cmd_defns))
234 return 0;
235
236#ifndef OPENSSL_NO_RSA
237 /* We know that the "PKCS1_SSLeay()" functions hook properly
238 * to the cswift-specific mod_exp and mod_exp_crt so we use
239 * those functions. NB: We don't use ENGINE_openssl() or
240 * anything "more generic" because something like the RSAref
241 * code may not hook properly, and if you own one of these
242 * cards then you have the right to do RSA operations on it
243 * anyway! */
244 meth1 = RSA_PKCS1_SSLeay();
245 cswift_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
246 cswift_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
247 cswift_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
248 cswift_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
249#endif
250
251#ifndef OPENSSL_NO_DH
252 /* Much the same for Diffie-Hellman */
253 meth2 = DH_OpenSSL();
254 cswift_dh.generate_key = meth2->generate_key;
255 cswift_dh.compute_key = meth2->compute_key;
256#endif
257
258 /* Ensure the cswift error handling is set up */
259 ERR_load_CSWIFT_strings();
260 return 1;
261 }
262
263#ifndef ENGINE_DYNAMIC_SUPPORT
264static ENGINE *engine_cswift(void)
265 {
266 ENGINE *ret = ENGINE_new();
267 if(!ret)
268 return NULL;
269 if(!bind_helper(ret))
270 {
271 ENGINE_free(ret);
272 return NULL;
273 }
274 return ret;
275 }
276
277void ENGINE_load_cswift(void)
278 {
279 /* Copied from eng_[openssl|dyn].c */
280 ENGINE *toadd = engine_cswift();
281 if(!toadd) return;
282 ENGINE_add(toadd);
283 ENGINE_free(toadd);
284 ERR_clear_error();
285 }
286#endif
287
288/* This is a process-global DSO handle used for loading and unloading
289 * the CryptoSwift library. NB: This is only set (or unset) during an
290 * init() or finish() call (reference counts permitting) and they're
291 * operating with global locks, so this should be thread-safe
292 * implicitly. */
293static DSO *cswift_dso = NULL;
294
295/* These are the function pointers that are (un)set when the library has
296 * successfully (un)loaded. */
297t_swAcquireAccContext *p_CSwift_AcquireAccContext = NULL;
298t_swAttachKeyParam *p_CSwift_AttachKeyParam = NULL;
299t_swSimpleRequest *p_CSwift_SimpleRequest = NULL;
300t_swReleaseAccContext *p_CSwift_ReleaseAccContext = NULL;
301
302/* Used in the DSO operations. */
303static const char *CSWIFT_LIBNAME = NULL;
304static const char *get_CSWIFT_LIBNAME(void)
305 {
306 if(CSWIFT_LIBNAME)
307 return CSWIFT_LIBNAME;
308 return "swift";
309 }
310static void free_CSWIFT_LIBNAME(void)
311 {
312 if(CSWIFT_LIBNAME)
313 OPENSSL_free((void*)CSWIFT_LIBNAME);
314 CSWIFT_LIBNAME = NULL;
315 }
316static long set_CSWIFT_LIBNAME(const char *name)
317 {
318 free_CSWIFT_LIBNAME();
319 return (((CSWIFT_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
320 }
321static const char *CSWIFT_F1 = "swAcquireAccContext";
322static const char *CSWIFT_F2 = "swAttachKeyParam";
323static const char *CSWIFT_F3 = "swSimpleRequest";
324static const char *CSWIFT_F4 = "swReleaseAccContext";
325
326
327/* CryptoSwift library functions and mechanics - these are used by the
328 * higher-level functions further down. NB: As and where there's no
329 * error checking, take a look lower down where these functions are
330 * called, the checking and error handling is probably down there. */
331
332/* utility function to obtain a context */
333static int get_context(SW_CONTEXT_HANDLE *hac)
334 {
335 SW_STATUS status;
336
337 status = p_CSwift_AcquireAccContext(hac);
338 if(status != SW_OK)
339 return 0;
340 return 1;
341 }
342
343/* similarly to release one. */
344static void release_context(SW_CONTEXT_HANDLE hac)
345 {
346 p_CSwift_ReleaseAccContext(hac);
347 }
348
349/* Destructor (complements the "ENGINE_cswift()" constructor) */
350static int cswift_destroy(ENGINE *e)
351 {
352 free_CSWIFT_LIBNAME();
353 ERR_unload_CSWIFT_strings();
354 return 1;
355 }
356
357/* (de)initialisation functions. */
358static int cswift_init(ENGINE *e)
359 {
360 SW_CONTEXT_HANDLE hac;
361 t_swAcquireAccContext *p1;
362 t_swAttachKeyParam *p2;
363 t_swSimpleRequest *p3;
364 t_swReleaseAccContext *p4;
365
366 if(cswift_dso != NULL)
367 {
368 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_ALREADY_LOADED);
369 goto err;
370 }
371 /* Attempt to load libswift.so/swift.dll/whatever. */
372 cswift_dso = DSO_load(NULL, get_CSWIFT_LIBNAME(), NULL, 0);
373 if(cswift_dso == NULL)
374 {
375 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_NOT_LOADED);
376 goto err;
377 }
378 if(!(p1 = (t_swAcquireAccContext *)
379 DSO_bind_func(cswift_dso, CSWIFT_F1)) ||
380 !(p2 = (t_swAttachKeyParam *)
381 DSO_bind_func(cswift_dso, CSWIFT_F2)) ||
382 !(p3 = (t_swSimpleRequest *)
383 DSO_bind_func(cswift_dso, CSWIFT_F3)) ||
384 !(p4 = (t_swReleaseAccContext *)
385 DSO_bind_func(cswift_dso, CSWIFT_F4)))
386 {
387 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_NOT_LOADED);
388 goto err;
389 }
390 /* Copy the pointers */
391 p_CSwift_AcquireAccContext = p1;
392 p_CSwift_AttachKeyParam = p2;
393 p_CSwift_SimpleRequest = p3;
394 p_CSwift_ReleaseAccContext = p4;
395 /* Try and get a context - if not, we may have a DSO but no
396 * accelerator! */
397 if(!get_context(&hac))
398 {
399 CSWIFTerr(CSWIFT_F_CSWIFT_INIT,CSWIFT_R_UNIT_FAILURE);
400 goto err;
401 }
402 release_context(hac);
403 /* Everything's fine. */
404 return 1;
405err:
406 if(cswift_dso)
407 {
408 DSO_free(cswift_dso);
409 cswift_dso = NULL;
410 }
411 p_CSwift_AcquireAccContext = NULL;
412 p_CSwift_AttachKeyParam = NULL;
413 p_CSwift_SimpleRequest = NULL;
414 p_CSwift_ReleaseAccContext = NULL;
415 return 0;
416 }
417
418static int cswift_finish(ENGINE *e)
419 {
420 free_CSWIFT_LIBNAME();
421 if(cswift_dso == NULL)
422 {
423 CSWIFTerr(CSWIFT_F_CSWIFT_FINISH,CSWIFT_R_NOT_LOADED);
424 return 0;
425 }
426 if(!DSO_free(cswift_dso))
427 {
428 CSWIFTerr(CSWIFT_F_CSWIFT_FINISH,CSWIFT_R_UNIT_FAILURE);
429 return 0;
430 }
431 cswift_dso = NULL;
432 p_CSwift_AcquireAccContext = NULL;
433 p_CSwift_AttachKeyParam = NULL;
434 p_CSwift_SimpleRequest = NULL;
435 p_CSwift_ReleaseAccContext = NULL;
436 return 1;
437 }
438
439static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
440 {
441 int initialised = ((cswift_dso == NULL) ? 0 : 1);
442 switch(cmd)
443 {
444 case CSWIFT_CMD_SO_PATH:
445 if(p == NULL)
446 {
447 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,ERR_R_PASSED_NULL_PARAMETER);
448 return 0;
449 }
450 if(initialised)
451 {
452 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,CSWIFT_R_ALREADY_LOADED);
453 return 0;
454 }
455 return set_CSWIFT_LIBNAME((const char *)p);
456 default:
457 break;
458 }
459 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL,CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED);
460 return 0;
461 }
462
463/* Un petit mod_exp */
464static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
465 const BIGNUM *m, BN_CTX *ctx)
466 {
467 /* I need somewhere to store temporary serialised values for
468 * use with the CryptoSwift API calls. A neat cheat - I'll use
469 * BIGNUMs from the BN_CTX but access their arrays directly as
470 * byte arrays <grin>. This way I don't have to clean anything
471 * up. */
472 BIGNUM *modulus;
473 BIGNUM *exponent;
474 BIGNUM *argument;
475 BIGNUM *result;
476 SW_STATUS sw_status;
477 SW_LARGENUMBER arg, res;
478 SW_PARAM sw_param;
479 SW_CONTEXT_HANDLE hac;
480 int to_return, acquired;
481
482 modulus = exponent = argument = result = NULL;
483 to_return = 0; /* expect failure */
484 acquired = 0;
485
486 if(!get_context(&hac))
487 {
488 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_UNIT_FAILURE);
489 goto err;
490 }
491 acquired = 1;
492 /* Prepare the params */
493 BN_CTX_start(ctx);
494 modulus = BN_CTX_get(ctx);
495 exponent = BN_CTX_get(ctx);
496 argument = BN_CTX_get(ctx);
497 result = BN_CTX_get(ctx);
498 if(!result)
499 {
500 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BN_CTX_FULL);
501 goto err;
502 }
503 if(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, p->top) ||
504 !bn_wexpand(argument, a->top) || !bn_wexpand(result, m->top))
505 {
506 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BN_EXPAND_FAIL);
507 goto err;
508 }
509 sw_param.type = SW_ALG_EXP;
510 sw_param.up.exp.modulus.nbytes = BN_bn2bin(m,
511 (unsigned char *)modulus->d);
512 sw_param.up.exp.modulus.value = (unsigned char *)modulus->d;
513 sw_param.up.exp.exponent.nbytes = BN_bn2bin(p,
514 (unsigned char *)exponent->d);
515 sw_param.up.exp.exponent.value = (unsigned char *)exponent->d;
516 /* Attach the key params */
517 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
518 switch(sw_status)
519 {
520 case SW_OK:
521 break;
522 case SW_ERR_INPUT_SIZE:
523 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_BAD_KEY_SIZE);
524 goto err;
525 default:
526 {
527 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
528 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED);
529 sprintf(tmpbuf, "%ld", sw_status);
530 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
531 }
532 goto err;
533 }
534 /* Prepare the argument and response */
535 arg.nbytes = BN_bn2bin(a, (unsigned char *)argument->d);
536 arg.value = (unsigned char *)argument->d;
537 res.nbytes = BN_num_bytes(m);
538 memset(result->d, 0, res.nbytes);
539 res.value = (unsigned char *)result->d;
540 /* Perform the operation */
541 if((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP, &arg, 1,
542 &res, 1)) != SW_OK)
543 {
544 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
545 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP,CSWIFT_R_REQUEST_FAILED);
546 sprintf(tmpbuf, "%ld", sw_status);
547 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
548 goto err;
549 }
550 /* Convert the response */
551 BN_bin2bn((unsigned char *)result->d, res.nbytes, r);
552 to_return = 1;
553err:
554 if(acquired)
555 release_context(hac);
556 BN_CTX_end(ctx);
557 return to_return;
558 }
559
560
561int cswift_bn_32copy(SW_LARGENUMBER * out, const BIGNUM * in)
562{
563 int mod;
564 int numbytes = BN_num_bytes(in);
565
566 mod = 0;
567 while( ((out->nbytes = (numbytes+mod)) % 32) )
568 {
569 mod++;
570 }
571 out->value = (unsigned char*)OPENSSL_malloc(out->nbytes);
572 if(!out->value)
573 {
574 return 0;
575 }
576 BN_bn2bin(in, &out->value[mod]);
577 if(mod)
578 memset(out->value, 0, mod);
579
580 return 1;
581}
582
583/* Un petit mod_exp chinois */
584static int cswift_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
585 const BIGNUM *q, const BIGNUM *dmp1,
586 const BIGNUM *dmq1, const BIGNUM *iqmp, BN_CTX *ctx)
587 {
588 SW_STATUS sw_status;
589 SW_LARGENUMBER arg, res;
590 SW_PARAM sw_param;
591 SW_CONTEXT_HANDLE hac;
592 BIGNUM *result = NULL;
593 BIGNUM *argument = NULL;
594 int to_return = 0; /* expect failure */
595 int acquired = 0;
596
597 sw_param.up.crt.p.value = NULL;
598 sw_param.up.crt.q.value = NULL;
599 sw_param.up.crt.dmp1.value = NULL;
600 sw_param.up.crt.dmq1.value = NULL;
601 sw_param.up.crt.iqmp.value = NULL;
602
603 if(!get_context(&hac))
604 {
605 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_UNIT_FAILURE);
606 goto err;
607 }
608 acquired = 1;
609
610 /* Prepare the params */
611 argument = BN_new();
612 result = BN_new();
613 if(!result || !argument)
614 {
615 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_CTX_FULL);
616 goto err;
617 }
618
619
620 sw_param.type = SW_ALG_CRT;
621 /************************************************************************/
622 /* 04/02/2003 */
623 /* Modified by Frederic Giudicelli (deny-all.com) to overcome the */
624 /* limitation of cswift with values not a multiple of 32 */
625 /************************************************************************/
626 if(!cswift_bn_32copy(&sw_param.up.crt.p, p))
627 {
628 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
629 goto err;
630 }
631 if(!cswift_bn_32copy(&sw_param.up.crt.q, q))
632 {
633 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
634 goto err;
635 }
636 if(!cswift_bn_32copy(&sw_param.up.crt.dmp1, dmp1))
637 {
638 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
639 goto err;
640 }
641 if(!cswift_bn_32copy(&sw_param.up.crt.dmq1, dmq1))
642 {
643 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
644 goto err;
645 }
646 if(!cswift_bn_32copy(&sw_param.up.crt.iqmp, iqmp))
647 {
648 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
649 goto err;
650 }
651 if( !bn_wexpand(argument, a->top) ||
652 !bn_wexpand(result, p->top + q->top))
653 {
654 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BN_EXPAND_FAIL);
655 goto err;
656 }
657
658 /* Attach the key params */
659 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
660 switch(sw_status)
661 {
662 case SW_OK:
663 break;
664 case SW_ERR_INPUT_SIZE:
665 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_BAD_KEY_SIZE);
666 goto err;
667 default:
668 {
669 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
670 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED);
671 sprintf(tmpbuf, "%ld", sw_status);
672 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
673 }
674 goto err;
675 }
676 /* Prepare the argument and response */
677 arg.nbytes = BN_bn2bin(a, (unsigned char *)argument->d);
678 arg.value = (unsigned char *)argument->d;
679 res.nbytes = 2 * BN_num_bytes(p);
680 memset(result->d, 0, res.nbytes);
681 res.value = (unsigned char *)result->d;
682 /* Perform the operation */
683 if((sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_MODEXP_CRT, &arg, 1,
684 &res, 1)) != SW_OK)
685 {
686 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
687 CSWIFTerr(CSWIFT_F_CSWIFT_MOD_EXP_CRT,CSWIFT_R_REQUEST_FAILED);
688 sprintf(tmpbuf, "%ld", sw_status);
689 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
690 goto err;
691 }
692 /* Convert the response */
693 BN_bin2bn((unsigned char *)result->d, res.nbytes, r);
694 to_return = 1;
695err:
696 if(sw_param.up.crt.p.value)
697 OPENSSL_free(sw_param.up.crt.p.value);
698 if(sw_param.up.crt.q.value)
699 OPENSSL_free(sw_param.up.crt.q.value);
700 if(sw_param.up.crt.dmp1.value)
701 OPENSSL_free(sw_param.up.crt.dmp1.value);
702 if(sw_param.up.crt.dmq1.value)
703 OPENSSL_free(sw_param.up.crt.dmq1.value);
704 if(sw_param.up.crt.iqmp.value)
705 OPENSSL_free(sw_param.up.crt.iqmp.value);
706 if(result)
707 BN_free(result);
708 if(argument)
709 BN_free(argument);
710 if(acquired)
711 release_context(hac);
712 return to_return;
713 }
714
715#ifndef OPENSSL_NO_RSA
716static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
717 {
718 BN_CTX *ctx;
719 int to_return = 0;
720 const RSA_METHOD * def_rsa_method;
721
722 /* Try the limits of RSA (2048 bits) */
723 if(BN_num_bytes(rsa->p) > 128 ||
724 BN_num_bytes(rsa->q) > 128 ||
725 BN_num_bytes(rsa->dmp1) > 128 ||
726 BN_num_bytes(rsa->dmq1) > 128 ||
727 BN_num_bytes(rsa->iqmp) > 128)
728 {
729#ifdef RSA_NULL
730 def_rsa_method=RSA_null_method();
731#else
732#if 0
733 def_rsa_method=RSA_PKCS1_RSAref();
734#else
735 def_rsa_method=RSA_PKCS1_SSLeay();
736#endif
737#endif
738 if(def_rsa_method)
739 return def_rsa_method->rsa_mod_exp(r0, I, rsa);
740 }
741
742 if((ctx = BN_CTX_new()) == NULL)
743 goto err;
744 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
745 {
746 CSWIFTerr(CSWIFT_F_CSWIFT_RSA_MOD_EXP,CSWIFT_R_MISSING_KEY_COMPONENTS);
747 goto err;
748 }
749 to_return = cswift_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
750 rsa->dmq1, rsa->iqmp, ctx);
751err:
752 if(ctx)
753 BN_CTX_free(ctx);
754 return to_return;
755 }
756#endif
757
758/* This function is aliased to mod_exp (with the mont stuff dropped). */
759static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
760 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
761 {
762 const RSA_METHOD * def_rsa_method;
763
764 /* Try the limits of RSA (2048 bits) */
765 if(BN_num_bytes(r) > 256 ||
766 BN_num_bytes(a) > 256 ||
767 BN_num_bytes(m) > 256)
768 {
769#ifdef RSA_NULL
770 def_rsa_method=RSA_null_method();
771#else
772#if 0
773 def_rsa_method=RSA_PKCS1_RSAref();
774#else
775 def_rsa_method=RSA_PKCS1_SSLeay();
776#endif
777#endif
778 if(def_rsa_method)
779 return def_rsa_method->bn_mod_exp(r, a, p, m, ctx, m_ctx);
780 }
781
782 return cswift_mod_exp(r, a, p, m, ctx);
783 }
784
785#ifndef OPENSSL_NO_DSA
786static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
787 {
788 SW_CONTEXT_HANDLE hac;
789 SW_PARAM sw_param;
790 SW_STATUS sw_status;
791 SW_LARGENUMBER arg, res;
792 unsigned char *ptr;
793 BN_CTX *ctx;
794 BIGNUM *dsa_p = NULL;
795 BIGNUM *dsa_q = NULL;
796 BIGNUM *dsa_g = NULL;
797 BIGNUM *dsa_key = NULL;
798 BIGNUM *result = NULL;
799 DSA_SIG *to_return = NULL;
800 int acquired = 0;
801
802 if((ctx = BN_CTX_new()) == NULL)
803 goto err;
804 if(!get_context(&hac))
805 {
806 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_UNIT_FAILURE);
807 goto err;
808 }
809 acquired = 1;
810 /* Prepare the params */
811 BN_CTX_start(ctx);
812 dsa_p = BN_CTX_get(ctx);
813 dsa_q = BN_CTX_get(ctx);
814 dsa_g = BN_CTX_get(ctx);
815 dsa_key = BN_CTX_get(ctx);
816 result = BN_CTX_get(ctx);
817 if(!result)
818 {
819 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BN_CTX_FULL);
820 goto err;
821 }
822 if(!bn_wexpand(dsa_p, dsa->p->top) ||
823 !bn_wexpand(dsa_q, dsa->q->top) ||
824 !bn_wexpand(dsa_g, dsa->g->top) ||
825 !bn_wexpand(dsa_key, dsa->priv_key->top) ||
826 !bn_wexpand(result, dsa->p->top))
827 {
828 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BN_EXPAND_FAIL);
829 goto err;
830 }
831 sw_param.type = SW_ALG_DSA;
832 sw_param.up.dsa.p.nbytes = BN_bn2bin(dsa->p,
833 (unsigned char *)dsa_p->d);
834 sw_param.up.dsa.p.value = (unsigned char *)dsa_p->d;
835 sw_param.up.dsa.q.nbytes = BN_bn2bin(dsa->q,
836 (unsigned char *)dsa_q->d);
837 sw_param.up.dsa.q.value = (unsigned char *)dsa_q->d;
838 sw_param.up.dsa.g.nbytes = BN_bn2bin(dsa->g,
839 (unsigned char *)dsa_g->d);
840 sw_param.up.dsa.g.value = (unsigned char *)dsa_g->d;
841 sw_param.up.dsa.key.nbytes = BN_bn2bin(dsa->priv_key,
842 (unsigned char *)dsa_key->d);
843 sw_param.up.dsa.key.value = (unsigned char *)dsa_key->d;
844 /* Attach the key params */
845 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
846 switch(sw_status)
847 {
848 case SW_OK:
849 break;
850 case SW_ERR_INPUT_SIZE:
851 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_BAD_KEY_SIZE);
852 goto err;
853 default:
854 {
855 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
856 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED);
857 sprintf(tmpbuf, "%ld", sw_status);
858 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
859 }
860 goto err;
861 }
862 /* Prepare the argument and response */
863 arg.nbytes = dlen;
864 arg.value = (unsigned char *)dgst;
865 res.nbytes = BN_num_bytes(dsa->p);
866 memset(result->d, 0, res.nbytes);
867 res.value = (unsigned char *)result->d;
868 /* Perform the operation */
869 sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_DSS_SIGN, &arg, 1,
870 &res, 1);
871 if(sw_status != SW_OK)
872 {
873 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
874 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_SIGN,CSWIFT_R_REQUEST_FAILED);
875 sprintf(tmpbuf, "%ld", sw_status);
876 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
877 goto err;
878 }
879 /* Convert the response */
880 ptr = (unsigned char *)result->d;
881 if((to_return = DSA_SIG_new()) == NULL)
882 goto err;
883 to_return->r = BN_bin2bn((unsigned char *)result->d, 20, NULL);
884 to_return->s = BN_bin2bn((unsigned char *)result->d + 20, 20, NULL);
885
886err:
887 if(acquired)
888 release_context(hac);
889 if(ctx)
890 {
891 BN_CTX_end(ctx);
892 BN_CTX_free(ctx);
893 }
894 return to_return;
895 }
896
897static int cswift_dsa_verify(const unsigned char *dgst, int dgst_len,
898 DSA_SIG *sig, DSA *dsa)
899 {
900 SW_CONTEXT_HANDLE hac;
901 SW_PARAM sw_param;
902 SW_STATUS sw_status;
903 SW_LARGENUMBER arg[2], res;
904 unsigned long sig_result;
905 BN_CTX *ctx;
906 BIGNUM *dsa_p = NULL;
907 BIGNUM *dsa_q = NULL;
908 BIGNUM *dsa_g = NULL;
909 BIGNUM *dsa_key = NULL;
910 BIGNUM *argument = NULL;
911 int to_return = -1;
912 int acquired = 0;
913
914 if((ctx = BN_CTX_new()) == NULL)
915 goto err;
916 if(!get_context(&hac))
917 {
918 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_UNIT_FAILURE);
919 goto err;
920 }
921 acquired = 1;
922 /* Prepare the params */
923 BN_CTX_start(ctx);
924 dsa_p = BN_CTX_get(ctx);
925 dsa_q = BN_CTX_get(ctx);
926 dsa_g = BN_CTX_get(ctx);
927 dsa_key = BN_CTX_get(ctx);
928 argument = BN_CTX_get(ctx);
929 if(!argument)
930 {
931 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_BN_CTX_FULL);
932 goto err;
933 }
934 if(!bn_wexpand(dsa_p, dsa->p->top) ||
935 !bn_wexpand(dsa_q, dsa->q->top) ||
936 !bn_wexpand(dsa_g, dsa->g->top) ||
937 !bn_wexpand(dsa_key, dsa->pub_key->top) ||
938 !bn_wexpand(argument, 40))
939 {
940 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_BN_EXPAND_FAIL);
941 goto err;
942 }
943 sw_param.type = SW_ALG_DSA;
944 sw_param.up.dsa.p.nbytes = BN_bn2bin(dsa->p,
945 (unsigned char *)dsa_p->d);
946 sw_param.up.dsa.p.value = (unsigned char *)dsa_p->d;
947 sw_param.up.dsa.q.nbytes = BN_bn2bin(dsa->q,
948 (unsigned char *)dsa_q->d);
949 sw_param.up.dsa.q.value = (unsigned char *)dsa_q->d;
950 sw_param.up.dsa.g.nbytes = BN_bn2bin(dsa->g,
951 (unsigned char *)dsa_g->d);
952 sw_param.up.dsa.g.value = (unsigned char *)dsa_g->d;
953 sw_param.up.dsa.key.nbytes = BN_bn2bin(dsa->pub_key,
954 (unsigned char *)dsa_key->d);
955 sw_param.up.dsa.key.value = (unsigned char *)dsa_key->d;
956 /* Attach the key params */
957 sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
958 switch(sw_status)
959 {
960 case SW_OK:
961 break;
962 case SW_ERR_INPUT_SIZE:
963 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_BAD_KEY_SIZE);
964 goto err;
965 default:
966 {
967 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
968 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED);
969 sprintf(tmpbuf, "%ld", sw_status);
970 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
971 }
972 goto err;
973 }
974 /* Prepare the argument and response */
975 arg[0].nbytes = dgst_len;
976 arg[0].value = (unsigned char *)dgst;
977 arg[1].nbytes = 40;
978 arg[1].value = (unsigned char *)argument->d;
979 memset(arg[1].value, 0, 40);
980 BN_bn2bin(sig->r, arg[1].value + 20 - BN_num_bytes(sig->r));
981 BN_bn2bin(sig->s, arg[1].value + 40 - BN_num_bytes(sig->s));
982 res.nbytes = 4; /* unsigned long */
983 res.value = (unsigned char *)(&sig_result);
984 /* Perform the operation */
985 sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_DSS_VERIFY, arg, 2,
986 &res, 1);
987 if(sw_status != SW_OK)
988 {
989 char tmpbuf[DECIMAL_SIZE(sw_status)+1];
990 CSWIFTerr(CSWIFT_F_CSWIFT_DSA_VERIFY,CSWIFT_R_REQUEST_FAILED);
991 sprintf(tmpbuf, "%ld", sw_status);
992 ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
993 goto err;
994 }
995 /* Convert the response */
996 to_return = ((sig_result == 0) ? 0 : 1);
997
998err:
999 if(acquired)
1000 release_context(hac);
1001 if(ctx)
1002 {
1003 BN_CTX_end(ctx);
1004 BN_CTX_free(ctx);
1005 }
1006 return to_return;
1007 }
1008#endif
1009
1010#ifndef OPENSSL_NO_DH
1011/* This function is aliased to mod_exp (with the dh and mont dropped). */
1012static int cswift_mod_exp_dh(const DH *dh, BIGNUM *r,
1013 const BIGNUM *a, const BIGNUM *p,
1014 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1015 {
1016 return cswift_mod_exp(r, a, p, m, ctx);
1017 }
1018#endif
1019
1020/* Random bytes are good */
1021static int cswift_rand_bytes(unsigned char *buf, int num)
1022{
1023 SW_CONTEXT_HANDLE hac;
1024 SW_STATUS swrc;
1025 SW_LARGENUMBER largenum;
1026 int acquired = 0;
1027 int to_return = 0; /* assume failure */
1028 unsigned char buf32[1024];
1029
1030
1031 if (!get_context(&hac))
1032 {
1033 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_UNIT_FAILURE);
1034 goto err;
1035 }
1036 acquired = 1;
1037
1038 /************************************************************************/
1039 /* 04/02/2003 */
1040 /* Modified by Frederic Giudicelli (deny-all.com) to overcome the */
1041 /* limitation of cswift with values not a multiple of 32 */
1042 /************************************************************************/
1043
1044 while(num >= sizeof(buf32))
1045 {
1046 largenum.value = buf;
1047 largenum.nbytes = sizeof(buf32);
1048 /* tell CryptoSwift how many bytes we want and where we want it.
1049 * Note: - CryptoSwift cannot do more than 4096 bytes at a time.
1050 * - CryptoSwift can only do multiple of 32-bits. */
1051 swrc = p_CSwift_SimpleRequest(hac, SW_CMD_RAND, NULL, 0, &largenum, 1);
1052 if (swrc != SW_OK)
1053 {
1054 char tmpbuf[20];
1055 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_REQUEST_FAILED);
1056 sprintf(tmpbuf, "%ld", swrc);
1057 ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf);
1058 goto err;
1059 }
1060 buf += sizeof(buf32);
1061 num -= sizeof(buf32);
1062 }
1063 if(num)
1064 {
1065 largenum.nbytes = sizeof(buf32);
1066 largenum.value = buf32;
1067 swrc = p_CSwift_SimpleRequest(hac, SW_CMD_RAND, NULL, 0, &largenum, 1);
1068 if (swrc != SW_OK)
1069 {
1070 char tmpbuf[20];
1071 CSWIFTerr(CSWIFT_F_CSWIFT_CTRL, CSWIFT_R_REQUEST_FAILED);
1072 sprintf(tmpbuf, "%ld", swrc);
1073 ERR_add_error_data(2, "CryptoSwift error number is ", tmpbuf);
1074 goto err;
1075 }
1076 memcpy(buf, largenum.value, num);
1077 }
1078
1079 to_return = 1; /* success */
1080err:
1081 if (acquired)
1082 release_context(hac);
1083
1084 return to_return;
1085}
1086
1087static int cswift_rand_status(void)
1088{
1089 return 1;
1090}
1091
1092
1093/* This stuff is needed if this ENGINE is being compiled into a self-contained
1094 * shared-library. */
1095#ifdef ENGINE_DYNAMIC_SUPPORT
1096static int bind_fn(ENGINE *e, const char *id)
1097 {
1098 if(id && (strcmp(id, engine_cswift_id) != 0))
1099 return 0;
1100 if(!bind_helper(e))
1101 return 0;
1102 return 1;
1103 }
1104IMPLEMENT_DYNAMIC_CHECK_FN()
1105IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
1106#endif /* ENGINE_DYNAMIC_SUPPORT */
1107
1108#endif /* !OPENSSL_NO_HW_CSWIFT */
1109#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_cswift_err.c b/src/lib/libcrypto/engine/hw_cswift_err.c
deleted file mode 100644
index 684f53bf27..0000000000
--- a/src/lib/libcrypto/engine/hw_cswift_err.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/* hw_cswift_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_cswift_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA CSWIFT_str_functs[]=
68 {
69{ERR_PACK(0,CSWIFT_F_CSWIFT_CTRL,0), "CSWIFT_CTRL"},
70{ERR_PACK(0,CSWIFT_F_CSWIFT_DSA_SIGN,0), "CSWIFT_DSA_SIGN"},
71{ERR_PACK(0,CSWIFT_F_CSWIFT_DSA_VERIFY,0), "CSWIFT_DSA_VERIFY"},
72{ERR_PACK(0,CSWIFT_F_CSWIFT_FINISH,0), "CSWIFT_FINISH"},
73{ERR_PACK(0,CSWIFT_F_CSWIFT_INIT,0), "CSWIFT_INIT"},
74{ERR_PACK(0,CSWIFT_F_CSWIFT_MOD_EXP,0), "CSWIFT_MOD_EXP"},
75{ERR_PACK(0,CSWIFT_F_CSWIFT_MOD_EXP_CRT,0), "CSWIFT_MOD_EXP_CRT"},
76{ERR_PACK(0,CSWIFT_F_CSWIFT_RSA_MOD_EXP,0), "CSWIFT_RSA_MOD_EXP"},
77{0,NULL}
78 };
79
80static ERR_STRING_DATA CSWIFT_str_reasons[]=
81 {
82{CSWIFT_R_ALREADY_LOADED ,"already loaded"},
83{CSWIFT_R_BAD_KEY_SIZE ,"bad key size"},
84{CSWIFT_R_BN_CTX_FULL ,"bn ctx full"},
85{CSWIFT_R_BN_EXPAND_FAIL ,"bn expand fail"},
86{CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
87{CSWIFT_R_MISSING_KEY_COMPONENTS ,"missing key components"},
88{CSWIFT_R_NOT_LOADED ,"not loaded"},
89{CSWIFT_R_REQUEST_FAILED ,"request failed"},
90{CSWIFT_R_UNIT_FAILURE ,"unit failure"},
91{0,NULL}
92 };
93
94#endif
95
96#ifdef CSWIFT_LIB_NAME
97static ERR_STRING_DATA CSWIFT_lib_name[]=
98 {
99{0 ,CSWIFT_LIB_NAME},
100{0,NULL}
101 };
102#endif
103
104
105static int CSWIFT_lib_error_code=0;
106static int CSWIFT_error_init=1;
107
108static void ERR_load_CSWIFT_strings(void)
109 {
110 if (CSWIFT_lib_error_code == 0)
111 CSWIFT_lib_error_code=ERR_get_next_error_library();
112
113 if (CSWIFT_error_init)
114 {
115 CSWIFT_error_init=0;
116#ifndef OPENSSL_NO_ERR
117 ERR_load_strings(CSWIFT_lib_error_code,CSWIFT_str_functs);
118 ERR_load_strings(CSWIFT_lib_error_code,CSWIFT_str_reasons);
119#endif
120
121#ifdef CSWIFT_LIB_NAME
122 CSWIFT_lib_name->error = ERR_PACK(CSWIFT_lib_error_code,0,0);
123 ERR_load_strings(0,CSWIFT_lib_name);
124#endif
125 }
126 }
127
128static void ERR_unload_CSWIFT_strings(void)
129 {
130 if (CSWIFT_error_init == 0)
131 {
132#ifndef OPENSSL_NO_ERR
133 ERR_unload_strings(CSWIFT_lib_error_code,CSWIFT_str_functs);
134 ERR_unload_strings(CSWIFT_lib_error_code,CSWIFT_str_reasons);
135#endif
136
137#ifdef CSWIFT_LIB_NAME
138 ERR_unload_strings(0,CSWIFT_lib_name);
139#endif
140 CSWIFT_error_init=1;
141 }
142 }
143
144static void ERR_CSWIFT_error(int function, int reason, char *file, int line)
145 {
146 if (CSWIFT_lib_error_code == 0)
147 CSWIFT_lib_error_code=ERR_get_next_error_library();
148 ERR_PUT_error(CSWIFT_lib_error_code,function,reason,file,line);
149 }
diff --git a/src/lib/libcrypto/engine/hw_cswift_err.h b/src/lib/libcrypto/engine/hw_cswift_err.h
deleted file mode 100644
index 7120c3216f..0000000000
--- a/src/lib/libcrypto/engine/hw_cswift_err.h
+++ /dev/null
@@ -1,93 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. 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 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the OpenSSL Project
19 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
20 *
21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
24 * openssl-core@openssl.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_CSWIFT_ERR_H
56#define HEADER_CSWIFT_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_CSWIFT_strings(void);
63static void ERR_unload_CSWIFT_strings(void);
64static void ERR_CSWIFT_error(int function, int reason, char *file, int line);
65#define CSWIFTerr(f,r) ERR_CSWIFT_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the CSWIFT functions. */
68
69/* Function codes. */
70#define CSWIFT_F_CSWIFT_CTRL 100
71#define CSWIFT_F_CSWIFT_DSA_SIGN 101
72#define CSWIFT_F_CSWIFT_DSA_VERIFY 102
73#define CSWIFT_F_CSWIFT_FINISH 103
74#define CSWIFT_F_CSWIFT_INIT 104
75#define CSWIFT_F_CSWIFT_MOD_EXP 105
76#define CSWIFT_F_CSWIFT_MOD_EXP_CRT 106
77#define CSWIFT_F_CSWIFT_RSA_MOD_EXP 107
78
79/* Reason codes. */
80#define CSWIFT_R_ALREADY_LOADED 100
81#define CSWIFT_R_BAD_KEY_SIZE 101
82#define CSWIFT_R_BN_CTX_FULL 102
83#define CSWIFT_R_BN_EXPAND_FAIL 103
84#define CSWIFT_R_CTRL_COMMAND_NOT_IMPLEMENTED 104
85#define CSWIFT_R_MISSING_KEY_COMPONENTS 105
86#define CSWIFT_R_NOT_LOADED 106
87#define CSWIFT_R_REQUEST_FAILED 107
88#define CSWIFT_R_UNIT_FAILURE 108
89
90#ifdef __cplusplus
91}
92#endif
93#endif
diff --git a/src/lib/libcrypto/engine/hw_ncipher.c b/src/lib/libcrypto/engine/hw_ncipher.c
deleted file mode 100644
index 0d1c6b8df0..0000000000
--- a/src/lib/libcrypto/engine/hw_ncipher.c
+++ /dev/null
@@ -1,1388 +0,0 @@
1/* crypto/engine/hw_ncipher.c -*- mode: C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org), Geoff Thorpe
3 * (geoff@geoffthorpe.net) and Dr Stephen N Henson (shenson@bigfoot.com)
4 * for the OpenSSL project 2000.
5 */
6/* ====================================================================
7 * Copyright (c) 1999-2001 The OpenSSL Project. 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 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * licensing@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#include <stdio.h>
61#include <string.h>
62#include "cryptlib.h"
63#include <openssl/crypto.h>
64#include <openssl/pem.h>
65#include <openssl/dso.h>
66#include <openssl/engine.h>
67#include <openssl/ui.h>
68
69#ifndef OPENSSL_NO_HW
70#ifndef OPENSSL_NO_HW_NCIPHER
71
72/* Attribution notice: nCipher have said several times that it's OK for
73 * us to implement a general interface to their boxes, and recently declared
74 * their HWCryptoHook to be public, and therefore available for us to use.
75 * Thanks, nCipher.
76 *
77 * The hwcryptohook.h included here is from May 2000.
78 * [Richard Levitte]
79 */
80#ifdef FLAT_INC
81#include "hwcryptohook.h"
82#else
83#include "vendor_defns/hwcryptohook.h"
84#endif
85
86#define HWCRHK_LIB_NAME "hwcrhk engine"
87#include "hw_ncipher_err.c"
88
89static int hwcrhk_destroy(ENGINE *e);
90static int hwcrhk_init(ENGINE *e);
91static int hwcrhk_finish(ENGINE *e);
92static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
93
94/* Functions to handle mutexes if have dynamic locks */
95static int hwcrhk_mutex_init(HWCryptoHook_Mutex*, HWCryptoHook_CallerContext*);
96static int hwcrhk_mutex_lock(HWCryptoHook_Mutex*);
97static void hwcrhk_mutex_unlock(HWCryptoHook_Mutex*);
98static void hwcrhk_mutex_destroy(HWCryptoHook_Mutex*);
99#if 1 /* This is a HACK which will disappear in 0.9.8 */
100/* Functions to handle mutexes if only have static locks */
101static int hwcrhk_static_mutex_init(HWCryptoHook_Mutex *m,
102 HWCryptoHook_CallerContext *c);
103static int hwcrhk_static_mutex_lock(HWCryptoHook_Mutex *m);
104static void hwcrhk_static_mutex_unlock(HWCryptoHook_Mutex *m);
105static void hwcrhk_static_mutex_destroy(HWCryptoHook_Mutex *m);
106#endif
107
108/* BIGNUM stuff */
109static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
110 const BIGNUM *m, BN_CTX *ctx);
111
112#ifndef OPENSSL_NO_RSA
113/* RSA stuff */
114static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa);
115#endif
116/* This function is aliased to mod_exp (with the mont stuff dropped). */
117static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
118 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
119
120#ifndef OPENSSL_NO_DH
121/* DH stuff */
122/* This function is alised to mod_exp (with the DH and mont dropped). */
123static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r,
124 const BIGNUM *a, const BIGNUM *p,
125 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
126#endif
127
128/* RAND stuff */
129static int hwcrhk_rand_bytes(unsigned char *buf, int num);
130static int hwcrhk_rand_status(void);
131
132/* KM stuff */
133static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
134 UI_METHOD *ui_method, void *callback_data);
135static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
136 UI_METHOD *ui_method, void *callback_data);
137static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
138 int ind,long argl, void *argp);
139
140/* Interaction stuff */
141static int hwcrhk_insert_card(const char *prompt_info,
142 const char *wrong_info,
143 HWCryptoHook_PassphraseContext *ppctx,
144 HWCryptoHook_CallerContext *cactx);
145static int hwcrhk_get_pass(const char *prompt_info,
146 int *len_io, char *buf,
147 HWCryptoHook_PassphraseContext *ppctx,
148 HWCryptoHook_CallerContext *cactx);
149static void hwcrhk_log_message(void *logstr, const char *message);
150
151/* The definitions for control commands specific to this engine */
152#define HWCRHK_CMD_SO_PATH ENGINE_CMD_BASE
153#define HWCRHK_CMD_FORK_CHECK (ENGINE_CMD_BASE + 1)
154#define HWCRHK_CMD_THREAD_LOCKING (ENGINE_CMD_BASE + 2)
155#define HWCRHK_CMD_SET_USER_INTERFACE (ENGINE_CMD_BASE + 3)
156#define HWCRHK_CMD_SET_CALLBACK_DATA (ENGINE_CMD_BASE + 4)
157static const ENGINE_CMD_DEFN hwcrhk_cmd_defns[] = {
158 {HWCRHK_CMD_SO_PATH,
159 "SO_PATH",
160 "Specifies the path to the 'hwcrhk' shared library",
161 ENGINE_CMD_FLAG_STRING},
162 {HWCRHK_CMD_FORK_CHECK,
163 "FORK_CHECK",
164 "Turns fork() checking on or off (boolean)",
165 ENGINE_CMD_FLAG_NUMERIC},
166 {HWCRHK_CMD_THREAD_LOCKING,
167 "THREAD_LOCKING",
168 "Turns thread-safe locking on or off (boolean)",
169 ENGINE_CMD_FLAG_NUMERIC},
170 {HWCRHK_CMD_SET_USER_INTERFACE,
171 "SET_USER_INTERFACE",
172 "Set the global user interface (internal)",
173 ENGINE_CMD_FLAG_INTERNAL},
174 {HWCRHK_CMD_SET_CALLBACK_DATA,
175 "SET_CALLBACK_DATA",
176 "Set the global user interface extra data (internal)",
177 ENGINE_CMD_FLAG_INTERNAL},
178 {0, NULL, NULL, 0}
179 };
180
181#ifndef OPENSSL_NO_RSA
182/* Our internal RSA_METHOD that we provide pointers to */
183static RSA_METHOD hwcrhk_rsa =
184 {
185 "nCipher RSA method",
186 NULL,
187 NULL,
188 NULL,
189 NULL,
190 hwcrhk_rsa_mod_exp,
191 hwcrhk_mod_exp_mont,
192 NULL,
193 NULL,
194 0,
195 NULL,
196 NULL,
197 NULL
198 };
199#endif
200
201#ifndef OPENSSL_NO_DH
202/* Our internal DH_METHOD that we provide pointers to */
203static DH_METHOD hwcrhk_dh =
204 {
205 "nCipher DH method",
206 NULL,
207 NULL,
208 hwcrhk_mod_exp_dh,
209 NULL,
210 NULL,
211 0,
212 NULL
213 };
214#endif
215
216static RAND_METHOD hwcrhk_rand =
217 {
218 /* "nCipher RAND method", */
219 NULL,
220 hwcrhk_rand_bytes,
221 NULL,
222 NULL,
223 hwcrhk_rand_bytes,
224 hwcrhk_rand_status,
225 };
226
227/* Constants used when creating the ENGINE */
228static const char *engine_hwcrhk_id = "chil";
229static const char *engine_hwcrhk_name = "nCipher hardware engine support";
230
231/* Internal stuff for HWCryptoHook */
232
233/* Some structures needed for proper use of thread locks */
234/* hwcryptohook.h has some typedefs that turn struct HWCryptoHook_MutexValue
235 into HWCryptoHook_Mutex */
236struct HWCryptoHook_MutexValue
237 {
238 int lockid;
239 };
240
241/* hwcryptohook.h has some typedefs that turn
242 struct HWCryptoHook_PassphraseContextValue
243 into HWCryptoHook_PassphraseContext */
244struct HWCryptoHook_PassphraseContextValue
245 {
246 UI_METHOD *ui_method;
247 void *callback_data;
248 };
249
250/* hwcryptohook.h has some typedefs that turn
251 struct HWCryptoHook_CallerContextValue
252 into HWCryptoHook_CallerContext */
253struct HWCryptoHook_CallerContextValue
254 {
255 pem_password_cb *password_callback; /* Deprecated! Only present for
256 backward compatibility! */
257 UI_METHOD *ui_method;
258 void *callback_data;
259 };
260
261/* The MPI structure in HWCryptoHook is pretty compatible with OpenSSL
262 BIGNUM's, so lets define a couple of conversion macros */
263#define BN2MPI(mp, bn) \
264 {mp.size = bn->top * sizeof(BN_ULONG); mp.buf = (unsigned char *)bn->d;}
265#define MPI2BN(bn, mp) \
266 {mp.size = bn->dmax * sizeof(BN_ULONG); mp.buf = (unsigned char *)bn->d;}
267
268static BIO *logstream = NULL;
269static int disable_mutex_callbacks = 0;
270
271/* One might wonder why these are needed, since one can pass down at least
272 a UI_METHOD and a pointer to callback data to the key-loading functions.
273 The thing is that the ModExp and RSAImmed functions can load keys as well,
274 if the data they get is in a special, nCipher-defined format (hint: if you
275 look at the private exponent of the RSA data as a string, you'll see this
276 string: "nCipher KM tool key id", followed by some bytes, followed a key
277 identity string, followed by more bytes. This happens when you use "embed"
278 keys instead of "hwcrhk" keys). Unfortunately, those functions do not take
279 any passphrase or caller context, and our functions can't really take any
280 callback data either. Still, the "insert_card" and "get_passphrase"
281 callbacks may be called down the line, and will need to know what user
282 interface callbacks to call, and having callback data from the application
283 may be a nice thing as well, so we need to keep track of that globally. */
284static HWCryptoHook_CallerContext password_context = { NULL, NULL, NULL };
285
286/* Stuff to pass to the HWCryptoHook library */
287static HWCryptoHook_InitInfo hwcrhk_globals = {
288 HWCryptoHook_InitFlags_SimpleForkCheck, /* Flags */
289 &logstream, /* logstream */
290 sizeof(BN_ULONG), /* limbsize */
291 0, /* mslimb first: false for BNs */
292 -1, /* msbyte first: use native */
293 0, /* Max mutexes, 0 = no small limit */
294 0, /* Max simultaneous, 0 = default */
295
296 /* The next few are mutex stuff: we write wrapper functions
297 around the OS mutex functions. We initialise them to 0
298 here, and change that to actual function pointers in hwcrhk_init()
299 if dynamic locks are supported (that is, if the application
300 programmer has made sure of setting up callbacks bafore starting
301 this engine) *and* if disable_mutex_callbacks hasn't been set by
302 a call to ENGINE_ctrl(ENGINE_CTRL_CHIL_NO_LOCKING). */
303 sizeof(HWCryptoHook_Mutex),
304 0,
305 0,
306 0,
307 0,
308
309 /* The next few are condvar stuff: we write wrapper functions
310 round the OS functions. Currently not implemented and not
311 and absolute necessity even in threaded programs, therefore
312 0'ed. Will hopefully be implemented some day, since it
313 enhances the efficiency of HWCryptoHook. */
314 0, /* sizeof(HWCryptoHook_CondVar), */
315 0, /* hwcrhk_cv_init, */
316 0, /* hwcrhk_cv_wait, */
317 0, /* hwcrhk_cv_signal, */
318 0, /* hwcrhk_cv_broadcast, */
319 0, /* hwcrhk_cv_destroy, */
320
321 hwcrhk_get_pass, /* pass phrase */
322 hwcrhk_insert_card, /* insert a card */
323 hwcrhk_log_message /* Log message */
324};
325
326
327/* Now, to our own code */
328
329/* This internal function is used by ENGINE_ncipher() and possibly by the
330 * "dynamic" ENGINE support too */
331static int bind_helper(ENGINE *e)
332 {
333#ifndef OPENSSL_NO_RSA
334 const RSA_METHOD *meth1;
335#endif
336#ifndef OPENSSL_NO_DH
337 const DH_METHOD *meth2;
338#endif
339 if(!ENGINE_set_id(e, engine_hwcrhk_id) ||
340 !ENGINE_set_name(e, engine_hwcrhk_name) ||
341#ifndef OPENSSL_NO_RSA
342 !ENGINE_set_RSA(e, &hwcrhk_rsa) ||
343#endif
344#ifndef OPENSSL_NO_DH
345 !ENGINE_set_DH(e, &hwcrhk_dh) ||
346#endif
347 !ENGINE_set_RAND(e, &hwcrhk_rand) ||
348 !ENGINE_set_destroy_function(e, hwcrhk_destroy) ||
349 !ENGINE_set_init_function(e, hwcrhk_init) ||
350 !ENGINE_set_finish_function(e, hwcrhk_finish) ||
351 !ENGINE_set_ctrl_function(e, hwcrhk_ctrl) ||
352 !ENGINE_set_load_privkey_function(e, hwcrhk_load_privkey) ||
353 !ENGINE_set_load_pubkey_function(e, hwcrhk_load_pubkey) ||
354 !ENGINE_set_cmd_defns(e, hwcrhk_cmd_defns))
355 return 0;
356
357#ifndef OPENSSL_NO_RSA
358 /* We know that the "PKCS1_SSLeay()" functions hook properly
359 * to the cswift-specific mod_exp and mod_exp_crt so we use
360 * those functions. NB: We don't use ENGINE_openssl() or
361 * anything "more generic" because something like the RSAref
362 * code may not hook properly, and if you own one of these
363 * cards then you have the right to do RSA operations on it
364 * anyway! */
365 meth1 = RSA_PKCS1_SSLeay();
366 hwcrhk_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
367 hwcrhk_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
368 hwcrhk_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
369 hwcrhk_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
370#endif
371
372#ifndef OPENSSL_NO_DH
373 /* Much the same for Diffie-Hellman */
374 meth2 = DH_OpenSSL();
375 hwcrhk_dh.generate_key = meth2->generate_key;
376 hwcrhk_dh.compute_key = meth2->compute_key;
377#endif
378
379 /* Ensure the hwcrhk error handling is set up */
380 ERR_load_HWCRHK_strings();
381 return 1;
382 }
383
384#ifndef ENGINE_DYNAMIC_SUPPORT
385static ENGINE *engine_ncipher(void)
386 {
387 ENGINE *ret = ENGINE_new();
388 if(!ret)
389 return NULL;
390 if(!bind_helper(ret))
391 {
392 ENGINE_free(ret);
393 return NULL;
394 }
395 return ret;
396 }
397
398void ENGINE_load_chil(void)
399 {
400 /* Copied from eng_[openssl|dyn].c */
401 ENGINE *toadd = engine_ncipher();
402 if(!toadd) return;
403 ENGINE_add(toadd);
404 ENGINE_free(toadd);
405 ERR_clear_error();
406 }
407#endif
408
409/* This is a process-global DSO handle used for loading and unloading
410 * the HWCryptoHook library. NB: This is only set (or unset) during an
411 * init() or finish() call (reference counts permitting) and they're
412 * operating with global locks, so this should be thread-safe
413 * implicitly. */
414static DSO *hwcrhk_dso = NULL;
415static HWCryptoHook_ContextHandle hwcrhk_context = 0;
416#ifndef OPENSSL_NO_RSA
417static int hndidx_rsa = -1; /* Index for KM handle. Not really used yet. */
418#endif
419
420/* These are the function pointers that are (un)set when the library has
421 * successfully (un)loaded. */
422static HWCryptoHook_Init_t *p_hwcrhk_Init = NULL;
423static HWCryptoHook_Finish_t *p_hwcrhk_Finish = NULL;
424static HWCryptoHook_ModExp_t *p_hwcrhk_ModExp = NULL;
425#ifndef OPENSSL_NO_RSA
426static HWCryptoHook_RSA_t *p_hwcrhk_RSA = NULL;
427#endif
428static HWCryptoHook_RandomBytes_t *p_hwcrhk_RandomBytes = NULL;
429#ifndef OPENSSL_NO_RSA
430static HWCryptoHook_RSALoadKey_t *p_hwcrhk_RSALoadKey = NULL;
431static HWCryptoHook_RSAGetPublicKey_t *p_hwcrhk_RSAGetPublicKey = NULL;
432static HWCryptoHook_RSAUnloadKey_t *p_hwcrhk_RSAUnloadKey = NULL;
433#endif
434static HWCryptoHook_ModExpCRT_t *p_hwcrhk_ModExpCRT = NULL;
435
436/* Used in the DSO operations. */
437static const char *HWCRHK_LIBNAME = NULL;
438static void free_HWCRHK_LIBNAME(void)
439 {
440 if(HWCRHK_LIBNAME)
441 OPENSSL_free((void*)HWCRHK_LIBNAME);
442 HWCRHK_LIBNAME = NULL;
443 }
444static const char *get_HWCRHK_LIBNAME(void)
445 {
446 if(HWCRHK_LIBNAME)
447 return HWCRHK_LIBNAME;
448 return "nfhwcrhk";
449 }
450static long set_HWCRHK_LIBNAME(const char *name)
451 {
452 free_HWCRHK_LIBNAME();
453 return (((HWCRHK_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
454 }
455static const char *n_hwcrhk_Init = "HWCryptoHook_Init";
456static const char *n_hwcrhk_Finish = "HWCryptoHook_Finish";
457static const char *n_hwcrhk_ModExp = "HWCryptoHook_ModExp";
458#ifndef OPENSSL_NO_RSA
459static const char *n_hwcrhk_RSA = "HWCryptoHook_RSA";
460#endif
461static const char *n_hwcrhk_RandomBytes = "HWCryptoHook_RandomBytes";
462#ifndef OPENSSL_NO_RSA
463static const char *n_hwcrhk_RSALoadKey = "HWCryptoHook_RSALoadKey";
464static const char *n_hwcrhk_RSAGetPublicKey = "HWCryptoHook_RSAGetPublicKey";
465static const char *n_hwcrhk_RSAUnloadKey = "HWCryptoHook_RSAUnloadKey";
466#endif
467static const char *n_hwcrhk_ModExpCRT = "HWCryptoHook_ModExpCRT";
468
469/* HWCryptoHook library functions and mechanics - these are used by the
470 * higher-level functions further down. NB: As and where there's no
471 * error checking, take a look lower down where these functions are
472 * called, the checking and error handling is probably down there. */
473
474/* utility function to obtain a context */
475static int get_context(HWCryptoHook_ContextHandle *hac,
476 HWCryptoHook_CallerContext *cac)
477 {
478 char tempbuf[1024];
479 HWCryptoHook_ErrMsgBuf rmsg;
480
481 rmsg.buf = tempbuf;
482 rmsg.size = sizeof(tempbuf);
483
484 *hac = p_hwcrhk_Init(&hwcrhk_globals, sizeof(hwcrhk_globals), &rmsg,
485 cac);
486 if (!*hac)
487 return 0;
488 return 1;
489 }
490
491/* similarly to release one. */
492static void release_context(HWCryptoHook_ContextHandle hac)
493 {
494 p_hwcrhk_Finish(hac);
495 }
496
497/* Destructor (complements the "ENGINE_ncipher()" constructor) */
498static int hwcrhk_destroy(ENGINE *e)
499 {
500 free_HWCRHK_LIBNAME();
501 ERR_unload_HWCRHK_strings();
502 return 1;
503 }
504
505/* (de)initialisation functions. */
506static int hwcrhk_init(ENGINE *e)
507 {
508 HWCryptoHook_Init_t *p1;
509 HWCryptoHook_Finish_t *p2;
510 HWCryptoHook_ModExp_t *p3;
511#ifndef OPENSSL_NO_RSA
512 HWCryptoHook_RSA_t *p4;
513 HWCryptoHook_RSALoadKey_t *p5;
514 HWCryptoHook_RSAGetPublicKey_t *p6;
515 HWCryptoHook_RSAUnloadKey_t *p7;
516#endif
517 HWCryptoHook_RandomBytes_t *p8;
518 HWCryptoHook_ModExpCRT_t *p9;
519
520 if(hwcrhk_dso != NULL)
521 {
522 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_ALREADY_LOADED);
523 goto err;
524 }
525 /* Attempt to load libnfhwcrhk.so/nfhwcrhk.dll/whatever. */
526 hwcrhk_dso = DSO_load(NULL, get_HWCRHK_LIBNAME(), NULL, 0);
527 if(hwcrhk_dso == NULL)
528 {
529 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DSO_FAILURE);
530 goto err;
531 }
532 if(!(p1 = (HWCryptoHook_Init_t *)
533 DSO_bind_func(hwcrhk_dso, n_hwcrhk_Init)) ||
534 !(p2 = (HWCryptoHook_Finish_t *)
535 DSO_bind_func(hwcrhk_dso, n_hwcrhk_Finish)) ||
536 !(p3 = (HWCryptoHook_ModExp_t *)
537 DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExp)) ||
538#ifndef OPENSSL_NO_RSA
539 !(p4 = (HWCryptoHook_RSA_t *)
540 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSA)) ||
541 !(p5 = (HWCryptoHook_RSALoadKey_t *)
542 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSALoadKey)) ||
543 !(p6 = (HWCryptoHook_RSAGetPublicKey_t *)
544 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAGetPublicKey)) ||
545 !(p7 = (HWCryptoHook_RSAUnloadKey_t *)
546 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAUnloadKey)) ||
547#endif
548 !(p8 = (HWCryptoHook_RandomBytes_t *)
549 DSO_bind_func(hwcrhk_dso, n_hwcrhk_RandomBytes)) ||
550 !(p9 = (HWCryptoHook_ModExpCRT_t *)
551 DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExpCRT)))
552 {
553 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DSO_FAILURE);
554 goto err;
555 }
556 /* Copy the pointers */
557 p_hwcrhk_Init = p1;
558 p_hwcrhk_Finish = p2;
559 p_hwcrhk_ModExp = p3;
560#ifndef OPENSSL_NO_RSA
561 p_hwcrhk_RSA = p4;
562 p_hwcrhk_RSALoadKey = p5;
563 p_hwcrhk_RSAGetPublicKey = p6;
564 p_hwcrhk_RSAUnloadKey = p7;
565#endif
566 p_hwcrhk_RandomBytes = p8;
567 p_hwcrhk_ModExpCRT = p9;
568
569 /* Check if the application decided to support dynamic locks,
570 and if it does, use them. */
571 if (disable_mutex_callbacks == 0)
572 {
573 if (CRYPTO_get_dynlock_create_callback() != NULL &&
574 CRYPTO_get_dynlock_lock_callback() != NULL &&
575 CRYPTO_get_dynlock_destroy_callback() != NULL)
576 {
577 hwcrhk_globals.mutex_init = hwcrhk_mutex_init;
578 hwcrhk_globals.mutex_acquire = hwcrhk_mutex_lock;
579 hwcrhk_globals.mutex_release = hwcrhk_mutex_unlock;
580 hwcrhk_globals.mutex_destroy = hwcrhk_mutex_destroy;
581 }
582 else if (CRYPTO_get_locking_callback() != NULL)
583 {
584 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_DYNAMIC_LOCKING_MISSING);
585 ERR_add_error_data(1,"You HAVE to add dynamic locking callbacks via CRYPTO_set_dynlock_{create,lock,destroy}_callback()");
586#if 1 /* This is a HACK which will disappear in 0.9.8 */
587 hwcrhk_globals.maxmutexes = 1; /* Only have one lock */
588 hwcrhk_globals.mutex_init = hwcrhk_static_mutex_init;
589 hwcrhk_globals.mutex_acquire = hwcrhk_static_mutex_lock;
590 hwcrhk_globals.mutex_release = hwcrhk_static_mutex_unlock;
591 hwcrhk_globals.mutex_destroy = hwcrhk_static_mutex_destroy;
592#else
593 goto err;
594#endif
595 }
596 }
597
598 /* Try and get a context - if not, we may have a DSO but no
599 * accelerator! */
600 if(!get_context(&hwcrhk_context, &password_context))
601 {
602 HWCRHKerr(HWCRHK_F_HWCRHK_INIT,HWCRHK_R_UNIT_FAILURE);
603 goto err;
604 }
605 /* Everything's fine. */
606#ifndef OPENSSL_NO_RSA
607 if (hndidx_rsa == -1)
608 hndidx_rsa = RSA_get_ex_new_index(0,
609 "nFast HWCryptoHook RSA key handle",
610 NULL, NULL, hwcrhk_ex_free);
611#endif
612 return 1;
613err:
614 if(hwcrhk_dso)
615 DSO_free(hwcrhk_dso);
616 hwcrhk_dso = NULL;
617 p_hwcrhk_Init = NULL;
618 p_hwcrhk_Finish = NULL;
619 p_hwcrhk_ModExp = NULL;
620#ifndef OPENSSL_NO_RSA
621 p_hwcrhk_RSA = NULL;
622 p_hwcrhk_RSALoadKey = NULL;
623 p_hwcrhk_RSAGetPublicKey = NULL;
624 p_hwcrhk_RSAUnloadKey = NULL;
625#endif
626 p_hwcrhk_ModExpCRT = NULL;
627 p_hwcrhk_RandomBytes = NULL;
628 return 0;
629 }
630
631static int hwcrhk_finish(ENGINE *e)
632 {
633 int to_return = 1;
634 free_HWCRHK_LIBNAME();
635 if(hwcrhk_dso == NULL)
636 {
637 HWCRHKerr(HWCRHK_F_HWCRHK_FINISH,HWCRHK_R_NOT_LOADED);
638 to_return = 0;
639 goto err;
640 }
641 release_context(hwcrhk_context);
642 if(!DSO_free(hwcrhk_dso))
643 {
644 HWCRHKerr(HWCRHK_F_HWCRHK_FINISH,HWCRHK_R_DSO_FAILURE);
645 to_return = 0;
646 goto err;
647 }
648 err:
649 if (logstream)
650 BIO_free(logstream);
651 hwcrhk_dso = NULL;
652 p_hwcrhk_Init = NULL;
653 p_hwcrhk_Finish = NULL;
654 p_hwcrhk_ModExp = NULL;
655#ifndef OPENSSL_NO_RSA
656 p_hwcrhk_RSA = NULL;
657 p_hwcrhk_RSALoadKey = NULL;
658 p_hwcrhk_RSAGetPublicKey = NULL;
659 p_hwcrhk_RSAUnloadKey = NULL;
660#endif
661 p_hwcrhk_ModExpCRT = NULL;
662 p_hwcrhk_RandomBytes = NULL;
663 return to_return;
664 }
665
666static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
667 {
668 int to_return = 1;
669
670 switch(cmd)
671 {
672 case HWCRHK_CMD_SO_PATH:
673 if(hwcrhk_dso)
674 {
675 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,HWCRHK_R_ALREADY_LOADED);
676 return 0;
677 }
678 if(p == NULL)
679 {
680 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,ERR_R_PASSED_NULL_PARAMETER);
681 return 0;
682 }
683 return set_HWCRHK_LIBNAME((const char *)p);
684 case ENGINE_CTRL_SET_LOGSTREAM:
685 {
686 BIO *bio = (BIO *)p;
687
688 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
689 if (logstream)
690 {
691 BIO_free(logstream);
692 logstream = NULL;
693 }
694 if (CRYPTO_add(&bio->references,1,CRYPTO_LOCK_BIO) > 1)
695 logstream = bio;
696 else
697 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,HWCRHK_R_BIO_WAS_FREED);
698 }
699 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
700 break;
701 case ENGINE_CTRL_SET_PASSWORD_CALLBACK:
702 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
703 password_context.password_callback = (pem_password_cb *)f;
704 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
705 break;
706 case ENGINE_CTRL_SET_USER_INTERFACE:
707 case HWCRHK_CMD_SET_USER_INTERFACE:
708 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
709 password_context.ui_method = (UI_METHOD *)p;
710 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
711 break;
712 case ENGINE_CTRL_SET_CALLBACK_DATA:
713 case HWCRHK_CMD_SET_CALLBACK_DATA:
714 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
715 password_context.callback_data = p;
716 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
717 break;
718 /* this enables or disables the "SimpleForkCheck" flag used in the
719 * initialisation structure. */
720 case ENGINE_CTRL_CHIL_SET_FORKCHECK:
721 case HWCRHK_CMD_FORK_CHECK:
722 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
723 if(i)
724 hwcrhk_globals.flags |=
725 HWCryptoHook_InitFlags_SimpleForkCheck;
726 else
727 hwcrhk_globals.flags &=
728 ~HWCryptoHook_InitFlags_SimpleForkCheck;
729 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
730 break;
731 /* This will prevent the initialisation function from "installing"
732 * the mutex-handling callbacks, even if they are available from
733 * within the library (or were provided to the library from the
734 * calling application). This is to remove any baggage for
735 * applications not using multithreading. */
736 case ENGINE_CTRL_CHIL_NO_LOCKING:
737 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
738 disable_mutex_callbacks = 1;
739 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
740 break;
741 case HWCRHK_CMD_THREAD_LOCKING:
742 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
743 disable_mutex_callbacks = ((i == 0) ? 0 : 1);
744 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
745 break;
746
747 /* The command isn't understood by this engine */
748 default:
749 HWCRHKerr(HWCRHK_F_HWCRHK_CTRL,
750 HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
751 to_return = 0;
752 break;
753 }
754
755 return to_return;
756 }
757
758static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
759 UI_METHOD *ui_method, void *callback_data)
760 {
761#ifndef OPENSSL_NO_RSA
762 RSA *rtmp = NULL;
763#endif
764 EVP_PKEY *res = NULL;
765#ifndef OPENSSL_NO_RSA
766 HWCryptoHook_MPI e, n;
767 HWCryptoHook_RSAKeyHandle *hptr;
768#endif
769#if !defined(OPENSSL_NO_RSA)
770 char tempbuf[1024];
771 HWCryptoHook_ErrMsgBuf rmsg;
772#endif
773 HWCryptoHook_PassphraseContext ppctx;
774
775#if !defined(OPENSSL_NO_RSA)
776 rmsg.buf = tempbuf;
777 rmsg.size = sizeof(tempbuf);
778#endif
779
780 if(!hwcrhk_context)
781 {
782 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
783 HWCRHK_R_NOT_INITIALISED);
784 goto err;
785 }
786#ifndef OPENSSL_NO_RSA
787 hptr = OPENSSL_malloc(sizeof(HWCryptoHook_RSAKeyHandle));
788 if (!hptr)
789 {
790 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
791 ERR_R_MALLOC_FAILURE);
792 goto err;
793 }
794 ppctx.ui_method = ui_method;
795 ppctx.callback_data = callback_data;
796 if (p_hwcrhk_RSALoadKey(hwcrhk_context, key_id, hptr,
797 &rmsg, &ppctx))
798 {
799 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
800 HWCRHK_R_CHIL_ERROR);
801 ERR_add_error_data(1,rmsg.buf);
802 goto err;
803 }
804 if (!*hptr)
805 {
806 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY,
807 HWCRHK_R_NO_KEY);
808 goto err;
809 }
810#endif
811#ifndef OPENSSL_NO_RSA
812 rtmp = RSA_new_method(eng);
813 RSA_set_ex_data(rtmp, hndidx_rsa, (char *)hptr);
814 rtmp->e = BN_new();
815 rtmp->n = BN_new();
816 rtmp->flags |= RSA_FLAG_EXT_PKEY;
817 MPI2BN(rtmp->e, e);
818 MPI2BN(rtmp->n, n);
819 if (p_hwcrhk_RSAGetPublicKey(*hptr, &n, &e, &rmsg)
820 != HWCRYPTOHOOK_ERROR_MPISIZE)
821 {
822 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,HWCRHK_R_CHIL_ERROR);
823 ERR_add_error_data(1,rmsg.buf);
824 goto err;
825 }
826
827 bn_expand2(rtmp->e, e.size/sizeof(BN_ULONG));
828 bn_expand2(rtmp->n, n.size/sizeof(BN_ULONG));
829 MPI2BN(rtmp->e, e);
830 MPI2BN(rtmp->n, n);
831
832 if (p_hwcrhk_RSAGetPublicKey(*hptr, &n, &e, &rmsg))
833 {
834 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
835 HWCRHK_R_CHIL_ERROR);
836 ERR_add_error_data(1,rmsg.buf);
837 goto err;
838 }
839 rtmp->e->top = e.size / sizeof(BN_ULONG);
840 bn_fix_top(rtmp->e);
841 rtmp->n->top = n.size / sizeof(BN_ULONG);
842 bn_fix_top(rtmp->n);
843
844 res = EVP_PKEY_new();
845 EVP_PKEY_assign_RSA(res, rtmp);
846#endif
847
848 if (!res)
849 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
850 HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED);
851
852 return res;
853 err:
854 if (res)
855 EVP_PKEY_free(res);
856#ifndef OPENSSL_NO_RSA
857 if (rtmp)
858 RSA_free(rtmp);
859#endif
860 return NULL;
861 }
862
863static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
864 UI_METHOD *ui_method, void *callback_data)
865 {
866 EVP_PKEY *res = NULL;
867
868#ifndef OPENSSL_NO_RSA
869 res = hwcrhk_load_privkey(eng, key_id,
870 ui_method, callback_data);
871#endif
872
873 if (res)
874 switch(res->type)
875 {
876#ifndef OPENSSL_NO_RSA
877 case EVP_PKEY_RSA:
878 {
879 RSA *rsa = NULL;
880
881 CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
882 rsa = res->pkey.rsa;
883 res->pkey.rsa = RSA_new();
884 res->pkey.rsa->n = rsa->n;
885 res->pkey.rsa->e = rsa->e;
886 rsa->n = NULL;
887 rsa->e = NULL;
888 CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
889 RSA_free(rsa);
890 }
891 break;
892#endif
893 default:
894 HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PUBKEY,
895 HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED);
896 goto err;
897 }
898
899 return res;
900 err:
901 if (res)
902 EVP_PKEY_free(res);
903 return NULL;
904 }
905
906/* A little mod_exp */
907static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
908 const BIGNUM *m, BN_CTX *ctx)
909 {
910 char tempbuf[1024];
911 HWCryptoHook_ErrMsgBuf rmsg;
912 /* Since HWCryptoHook_MPI is pretty compatible with BIGNUM's,
913 we use them directly, plus a little macro magic. We only
914 thing we need to make sure of is that enough space is allocated. */
915 HWCryptoHook_MPI m_a, m_p, m_n, m_r;
916 int to_return, ret;
917
918 to_return = 0; /* expect failure */
919 rmsg.buf = tempbuf;
920 rmsg.size = sizeof(tempbuf);
921
922 if(!hwcrhk_context)
923 {
924 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_NOT_INITIALISED);
925 goto err;
926 }
927 /* Prepare the params */
928 bn_expand2(r, m->top); /* Check for error !! */
929 BN2MPI(m_a, a);
930 BN2MPI(m_p, p);
931 BN2MPI(m_n, m);
932 MPI2BN(r, m_r);
933
934 /* Perform the operation */
935 ret = p_hwcrhk_ModExp(hwcrhk_context, m_a, m_p, m_n, &m_r, &rmsg);
936
937 /* Convert the response */
938 r->top = m_r.size / sizeof(BN_ULONG);
939 bn_fix_top(r);
940
941 if (ret < 0)
942 {
943 /* FIXME: When this error is returned, HWCryptoHook is
944 telling us that falling back to software computation
945 might be a good thing. */
946 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
947 {
948 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_REQUEST_FALLBACK);
949 }
950 else
951 {
952 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_REQUEST_FAILED);
953 }
954 ERR_add_error_data(1,rmsg.buf);
955 goto err;
956 }
957
958 to_return = 1;
959err:
960 return to_return;
961 }
962
963#ifndef OPENSSL_NO_RSA
964static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa)
965 {
966 char tempbuf[1024];
967 HWCryptoHook_ErrMsgBuf rmsg;
968 HWCryptoHook_RSAKeyHandle *hptr;
969 int to_return = 0, ret;
970
971 rmsg.buf = tempbuf;
972 rmsg.size = sizeof(tempbuf);
973
974 if(!hwcrhk_context)
975 {
976 HWCRHKerr(HWCRHK_F_HWCRHK_MOD_EXP,HWCRHK_R_NOT_INITIALISED);
977 goto err;
978 }
979
980 /* This provides support for nForce keys. Since that's opaque data
981 all we do is provide a handle to the proper key and let HWCryptoHook
982 take care of the rest. */
983 if ((hptr = (HWCryptoHook_RSAKeyHandle *) RSA_get_ex_data(rsa, hndidx_rsa))
984 != NULL)
985 {
986 HWCryptoHook_MPI m_a, m_r;
987
988 if(!rsa->n)
989 {
990 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
991 HWCRHK_R_MISSING_KEY_COMPONENTS);
992 goto err;
993 }
994
995 /* Prepare the params */
996 bn_expand2(r, rsa->n->top); /* Check for error !! */
997 BN2MPI(m_a, I);
998 MPI2BN(r, m_r);
999
1000 /* Perform the operation */
1001 ret = p_hwcrhk_RSA(m_a, *hptr, &m_r, &rmsg);
1002
1003 /* Convert the response */
1004 r->top = m_r.size / sizeof(BN_ULONG);
1005 bn_fix_top(r);
1006
1007 if (ret < 0)
1008 {
1009 /* FIXME: When this error is returned, HWCryptoHook is
1010 telling us that falling back to software computation
1011 might be a good thing. */
1012 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
1013 {
1014 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1015 HWCRHK_R_REQUEST_FALLBACK);
1016 }
1017 else
1018 {
1019 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1020 HWCRHK_R_REQUEST_FAILED);
1021 }
1022 ERR_add_error_data(1,rmsg.buf);
1023 goto err;
1024 }
1025 }
1026 else
1027 {
1028 HWCryptoHook_MPI m_a, m_p, m_q, m_dmp1, m_dmq1, m_iqmp, m_r;
1029
1030 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
1031 {
1032 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1033 HWCRHK_R_MISSING_KEY_COMPONENTS);
1034 goto err;
1035 }
1036
1037 /* Prepare the params */
1038 bn_expand2(r, rsa->n->top); /* Check for error !! */
1039 BN2MPI(m_a, I);
1040 BN2MPI(m_p, rsa->p);
1041 BN2MPI(m_q, rsa->q);
1042 BN2MPI(m_dmp1, rsa->dmp1);
1043 BN2MPI(m_dmq1, rsa->dmq1);
1044 BN2MPI(m_iqmp, rsa->iqmp);
1045 MPI2BN(r, m_r);
1046
1047 /* Perform the operation */
1048 ret = p_hwcrhk_ModExpCRT(hwcrhk_context, m_a, m_p, m_q,
1049 m_dmp1, m_dmq1, m_iqmp, &m_r, &rmsg);
1050
1051 /* Convert the response */
1052 r->top = m_r.size / sizeof(BN_ULONG);
1053 bn_fix_top(r);
1054
1055 if (ret < 0)
1056 {
1057 /* FIXME: When this error is returned, HWCryptoHook is
1058 telling us that falling back to software computation
1059 might be a good thing. */
1060 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
1061 {
1062 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1063 HWCRHK_R_REQUEST_FALLBACK);
1064 }
1065 else
1066 {
1067 HWCRHKerr(HWCRHK_F_HWCRHK_RSA_MOD_EXP,
1068 HWCRHK_R_REQUEST_FAILED);
1069 }
1070 ERR_add_error_data(1,rmsg.buf);
1071 goto err;
1072 }
1073 }
1074 /* If we're here, we must be here with some semblance of success :-) */
1075 to_return = 1;
1076err:
1077 return to_return;
1078 }
1079#endif
1080
1081/* This function is aliased to mod_exp (with the mont stuff dropped). */
1082static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
1083 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1084 {
1085 return hwcrhk_mod_exp(r, a, p, m, ctx);
1086 }
1087
1088#ifndef OPENSSL_NO_DH
1089/* This function is aliased to mod_exp (with the dh and mont dropped). */
1090static int hwcrhk_mod_exp_dh(const DH *dh, BIGNUM *r,
1091 const BIGNUM *a, const BIGNUM *p,
1092 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
1093 {
1094 return hwcrhk_mod_exp(r, a, p, m, ctx);
1095 }
1096#endif
1097
1098/* Random bytes are good */
1099static int hwcrhk_rand_bytes(unsigned char *buf, int num)
1100 {
1101 char tempbuf[1024];
1102 HWCryptoHook_ErrMsgBuf rmsg;
1103 int to_return = 0; /* assume failure */
1104 int ret;
1105
1106 rmsg.buf = tempbuf;
1107 rmsg.size = sizeof(tempbuf);
1108
1109 if(!hwcrhk_context)
1110 {
1111 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,HWCRHK_R_NOT_INITIALISED);
1112 goto err;
1113 }
1114
1115 ret = p_hwcrhk_RandomBytes(hwcrhk_context, buf, num, &rmsg);
1116 if (ret < 0)
1117 {
1118 /* FIXME: When this error is returned, HWCryptoHook is
1119 telling us that falling back to software computation
1120 might be a good thing. */
1121 if(ret == HWCRYPTOHOOK_ERROR_FALLBACK)
1122 {
1123 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,
1124 HWCRHK_R_REQUEST_FALLBACK);
1125 }
1126 else
1127 {
1128 HWCRHKerr(HWCRHK_F_HWCRHK_RAND_BYTES,
1129 HWCRHK_R_REQUEST_FAILED);
1130 }
1131 ERR_add_error_data(1,rmsg.buf);
1132 goto err;
1133 }
1134 to_return = 1;
1135 err:
1136 return to_return;
1137 }
1138
1139static int hwcrhk_rand_status(void)
1140 {
1141 return 1;
1142 }
1143
1144/* This cleans up an RSA KM key, called when ex_data is freed */
1145
1146static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
1147 int ind,long argl, void *argp)
1148{
1149 char tempbuf[1024];
1150 HWCryptoHook_ErrMsgBuf rmsg;
1151#ifndef OPENSSL_NO_RSA
1152 HWCryptoHook_RSAKeyHandle *hptr;
1153#endif
1154#if !defined(OPENSSL_NO_RSA)
1155 int ret;
1156#endif
1157
1158 rmsg.buf = tempbuf;
1159 rmsg.size = sizeof(tempbuf);
1160
1161#ifndef OPENSSL_NO_RSA
1162 hptr = (HWCryptoHook_RSAKeyHandle *) item;
1163 if(hptr)
1164 {
1165 ret = p_hwcrhk_RSAUnloadKey(*hptr, NULL);
1166 OPENSSL_free(hptr);
1167 }
1168#endif
1169}
1170
1171/* Mutex calls: since the HWCryptoHook model closely follows the POSIX model
1172 * these just wrap the POSIX functions and add some logging.
1173 */
1174
1175static int hwcrhk_mutex_init(HWCryptoHook_Mutex* mt,
1176 HWCryptoHook_CallerContext *cactx)
1177 {
1178 mt->lockid = CRYPTO_get_new_dynlockid();
1179 if (mt->lockid == 0)
1180 return 1; /* failure */
1181 return 0; /* success */
1182 }
1183
1184static int hwcrhk_mutex_lock(HWCryptoHook_Mutex *mt)
1185 {
1186 CRYPTO_w_lock(mt->lockid);
1187 return 0;
1188 }
1189
1190static void hwcrhk_mutex_unlock(HWCryptoHook_Mutex * mt)
1191 {
1192 CRYPTO_w_unlock(mt->lockid);
1193 }
1194
1195static void hwcrhk_mutex_destroy(HWCryptoHook_Mutex *mt)
1196 {
1197 CRYPTO_destroy_dynlockid(mt->lockid);
1198 }
1199
1200/* Mutex upcalls to use if the application does not support dynamic locks */
1201
1202static int hwcrhk_static_mutex_init(HWCryptoHook_Mutex *m,
1203 HWCryptoHook_CallerContext *c)
1204 {
1205 return 0;
1206 }
1207static int hwcrhk_static_mutex_lock(HWCryptoHook_Mutex *m)
1208 {
1209 CRYPTO_w_lock(CRYPTO_LOCK_HWCRHK);
1210 return 0;
1211 }
1212static void hwcrhk_static_mutex_unlock(HWCryptoHook_Mutex *m)
1213 {
1214 CRYPTO_w_unlock(CRYPTO_LOCK_HWCRHK);
1215 }
1216static void hwcrhk_static_mutex_destroy(HWCryptoHook_Mutex *m)
1217 {
1218 }
1219
1220static int hwcrhk_get_pass(const char *prompt_info,
1221 int *len_io, char *buf,
1222 HWCryptoHook_PassphraseContext *ppctx,
1223 HWCryptoHook_CallerContext *cactx)
1224 {
1225 pem_password_cb *callback = NULL;
1226 void *callback_data = NULL;
1227 UI_METHOD *ui_method = NULL;
1228
1229 if (cactx)
1230 {
1231 if (cactx->ui_method)
1232 ui_method = cactx->ui_method;
1233 if (cactx->password_callback)
1234 callback = cactx->password_callback;
1235 if (cactx->callback_data)
1236 callback_data = cactx->callback_data;
1237 }
1238 if (ppctx)
1239 {
1240 if (ppctx->ui_method)
1241 {
1242 ui_method = ppctx->ui_method;
1243 callback = NULL;
1244 }
1245 if (ppctx->callback_data)
1246 callback_data = ppctx->callback_data;
1247 }
1248 if (callback == NULL && ui_method == NULL)
1249 {
1250 HWCRHKerr(HWCRHK_F_HWCRHK_GET_PASS,HWCRHK_R_NO_CALLBACK);
1251 return -1;
1252 }
1253
1254 if (ui_method)
1255 {
1256 UI *ui = UI_new_method(ui_method);
1257 if (ui)
1258 {
1259 int ok;
1260 char *prompt = UI_construct_prompt(ui,
1261 "pass phrase", prompt_info);
1262
1263 ok = UI_add_input_string(ui,prompt,
1264 UI_INPUT_FLAG_DEFAULT_PWD,
1265 buf,0,(*len_io) - 1);
1266 UI_add_user_data(ui, callback_data);
1267 UI_ctrl(ui, UI_CTRL_PRINT_ERRORS, 1, 0, 0);
1268
1269 if (ok >= 0)
1270 do
1271 {
1272 ok=UI_process(ui);
1273 }
1274 while (ok < 0 && UI_ctrl(ui, UI_CTRL_IS_REDOABLE, 0, 0, 0));
1275
1276 if (ok >= 0)
1277 *len_io = strlen(buf);
1278
1279 UI_free(ui);
1280 OPENSSL_free(prompt);
1281 }
1282 }
1283 else
1284 {
1285 *len_io = callback(buf, *len_io, 0, callback_data);
1286 }
1287 if(!*len_io)
1288 return -1;
1289 return 0;
1290 }
1291
1292static int hwcrhk_insert_card(const char *prompt_info,
1293 const char *wrong_info,
1294 HWCryptoHook_PassphraseContext *ppctx,
1295 HWCryptoHook_CallerContext *cactx)
1296 {
1297 int ok = -1;
1298 UI *ui;
1299 void *callback_data = NULL;
1300 UI_METHOD *ui_method = NULL;
1301
1302 if (cactx)
1303 {
1304 if (cactx->ui_method)
1305 ui_method = cactx->ui_method;
1306 if (cactx->callback_data)
1307 callback_data = cactx->callback_data;
1308 }
1309 if (ppctx)
1310 {
1311 if (ppctx->ui_method)
1312 ui_method = ppctx->ui_method;
1313 if (ppctx->callback_data)
1314 callback_data = ppctx->callback_data;
1315 }
1316 if (ui_method == NULL)
1317 {
1318 HWCRHKerr(HWCRHK_F_HWCRHK_INSERT_CARD,
1319 HWCRHK_R_NO_CALLBACK);
1320 return -1;
1321 }
1322
1323 ui = UI_new_method(ui_method);
1324
1325 if (ui)
1326 {
1327 char answer;
1328 char buf[BUFSIZ];
1329
1330 if (wrong_info)
1331 BIO_snprintf(buf, sizeof(buf)-1,
1332 "Current card: \"%s\"\n", wrong_info);
1333 ok = UI_dup_info_string(ui, buf);
1334 if (ok >= 0 && prompt_info)
1335 {
1336 BIO_snprintf(buf, sizeof(buf)-1,
1337 "Insert card \"%s\"", prompt_info);
1338 ok = UI_dup_input_boolean(ui, buf,
1339 "\n then hit <enter> or C<enter> to cancel\n",
1340 "\r\n", "Cc", UI_INPUT_FLAG_ECHO, &answer);
1341 }
1342 UI_add_user_data(ui, callback_data);
1343
1344 if (ok >= 0)
1345 ok = UI_process(ui);
1346 UI_free(ui);
1347
1348 if (ok == -2 || (ok >= 0 && answer == 'C'))
1349 ok = 1;
1350 else if (ok < 0)
1351 ok = -1;
1352 else
1353 ok = 0;
1354 }
1355 return ok;
1356 }
1357
1358static void hwcrhk_log_message(void *logstr, const char *message)
1359 {
1360 BIO *lstream = NULL;
1361
1362 CRYPTO_w_lock(CRYPTO_LOCK_BIO);
1363 if (logstr)
1364 lstream=*(BIO **)logstr;
1365 if (lstream)
1366 {
1367 BIO_printf(lstream, "%s\n", message);
1368 }
1369 CRYPTO_w_unlock(CRYPTO_LOCK_BIO);
1370 }
1371
1372/* This stuff is needed if this ENGINE is being compiled into a self-contained
1373 * shared-library. */
1374#ifdef ENGINE_DYNAMIC_SUPPORT
1375static int bind_fn(ENGINE *e, const char *id)
1376 {
1377 if(id && (strcmp(id, engine_hwcrhk_id) != 0))
1378 return 0;
1379 if(!bind_helper(e))
1380 return 0;
1381 return 1;
1382 }
1383IMPLEMENT_DYNAMIC_CHECK_FN()
1384IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
1385#endif /* ENGINE_DYNAMIC_SUPPORT */
1386
1387#endif /* !OPENSSL_NO_HW_NCIPHER */
1388#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_ncipher_err.c b/src/lib/libcrypto/engine/hw_ncipher_err.c
deleted file mode 100644
index 5bc94581b7..0000000000
--- a/src/lib/libcrypto/engine/hw_ncipher_err.c
+++ /dev/null
@@ -1,157 +0,0 @@
1/* hw_ncipher_err.c */
2/* ====================================================================
3 * Copyright (c) 1999-2002 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_ncipher_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA HWCRHK_str_functs[]=
68 {
69{ERR_PACK(0,HWCRHK_F_HWCRHK_CTRL,0), "HWCRHK_CTRL"},
70{ERR_PACK(0,HWCRHK_F_HWCRHK_FINISH,0), "HWCRHK_FINISH"},
71{ERR_PACK(0,HWCRHK_F_HWCRHK_GET_PASS,0), "HWCRHK_GET_PASS"},
72{ERR_PACK(0,HWCRHK_F_HWCRHK_INIT,0), "HWCRHK_INIT"},
73{ERR_PACK(0,HWCRHK_F_HWCRHK_INSERT_CARD,0), "HWCRHK_INSERT_CARD"},
74{ERR_PACK(0,HWCRHK_F_HWCRHK_LOAD_PRIVKEY,0), "HWCRHK_LOAD_PRIVKEY"},
75{ERR_PACK(0,HWCRHK_F_HWCRHK_LOAD_PUBKEY,0), "HWCRHK_LOAD_PUBKEY"},
76{ERR_PACK(0,HWCRHK_F_HWCRHK_MOD_EXP,0), "HWCRHK_MOD_EXP"},
77{ERR_PACK(0,HWCRHK_F_HWCRHK_RAND_BYTES,0), "HWCRHK_RAND_BYTES"},
78{ERR_PACK(0,HWCRHK_F_HWCRHK_RSA_MOD_EXP,0), "HWCRHK_RSA_MOD_EXP"},
79{0,NULL}
80 };
81
82static ERR_STRING_DATA HWCRHK_str_reasons[]=
83 {
84{HWCRHK_R_ALREADY_LOADED ,"already loaded"},
85{HWCRHK_R_BIO_WAS_FREED ,"bio was freed"},
86{HWCRHK_R_CHIL_ERROR ,"chil error"},
87{HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
88{HWCRHK_R_DSO_FAILURE ,"dso failure"},
89{HWCRHK_R_DYNAMIC_LOCKING_MISSING ,"dynamic locking missing"},
90{HWCRHK_R_MISSING_KEY_COMPONENTS ,"missing key components"},
91{HWCRHK_R_NOT_INITIALISED ,"not initialised"},
92{HWCRHK_R_NOT_LOADED ,"not loaded"},
93{HWCRHK_R_NO_CALLBACK ,"no callback"},
94{HWCRHK_R_NO_KEY ,"no key"},
95{HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED,"private key algorithms disabled"},
96{HWCRHK_R_REQUEST_FAILED ,"request failed"},
97{HWCRHK_R_REQUEST_FALLBACK ,"request fallback"},
98{HWCRHK_R_UNIT_FAILURE ,"unit failure"},
99{0,NULL}
100 };
101
102#endif
103
104#ifdef HWCRHK_LIB_NAME
105static ERR_STRING_DATA HWCRHK_lib_name[]=
106 {
107{0 ,HWCRHK_LIB_NAME},
108{0,NULL}
109 };
110#endif
111
112
113static int HWCRHK_lib_error_code=0;
114static int HWCRHK_error_init=1;
115
116static void ERR_load_HWCRHK_strings(void)
117 {
118 if (HWCRHK_lib_error_code == 0)
119 HWCRHK_lib_error_code=ERR_get_next_error_library();
120
121 if (HWCRHK_error_init)
122 {
123 HWCRHK_error_init=0;
124#ifndef OPENSSL_NO_ERR
125 ERR_load_strings(HWCRHK_lib_error_code,HWCRHK_str_functs);
126 ERR_load_strings(HWCRHK_lib_error_code,HWCRHK_str_reasons);
127#endif
128
129#ifdef HWCRHK_LIB_NAME
130 HWCRHK_lib_name->error = ERR_PACK(HWCRHK_lib_error_code,0,0);
131 ERR_load_strings(0,HWCRHK_lib_name);
132#endif
133 }
134 }
135
136static void ERR_unload_HWCRHK_strings(void)
137 {
138 if (HWCRHK_error_init == 0)
139 {
140#ifndef OPENSSL_NO_ERR
141 ERR_unload_strings(HWCRHK_lib_error_code,HWCRHK_str_functs);
142 ERR_unload_strings(HWCRHK_lib_error_code,HWCRHK_str_reasons);
143#endif
144
145#ifdef HWCRHK_LIB_NAME
146 ERR_unload_strings(0,HWCRHK_lib_name);
147#endif
148 HWCRHK_error_init=1;
149 }
150 }
151
152static void ERR_HWCRHK_error(int function, int reason, char *file, int line)
153 {
154 if (HWCRHK_lib_error_code == 0)
155 HWCRHK_lib_error_code=ERR_get_next_error_library();
156 ERR_PUT_error(HWCRHK_lib_error_code,function,reason,file,line);
157 }
diff --git a/src/lib/libcrypto/engine/hw_ncipher_err.h b/src/lib/libcrypto/engine/hw_ncipher_err.h
deleted file mode 100644
index d232d02319..0000000000
--- a/src/lib/libcrypto/engine/hw_ncipher_err.h
+++ /dev/null
@@ -1,101 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. 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 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the OpenSSL Project
19 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
20 *
21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
24 * openssl-core@openssl.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_HWCRHK_ERR_H
56#define HEADER_HWCRHK_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_HWCRHK_strings(void);
63static void ERR_unload_HWCRHK_strings(void);
64static void ERR_HWCRHK_error(int function, int reason, char *file, int line);
65#define HWCRHKerr(f,r) ERR_HWCRHK_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the HWCRHK functions. */
68
69/* Function codes. */
70#define HWCRHK_F_HWCRHK_CTRL 100
71#define HWCRHK_F_HWCRHK_FINISH 101
72#define HWCRHK_F_HWCRHK_GET_PASS 102
73#define HWCRHK_F_HWCRHK_INIT 103
74#define HWCRHK_F_HWCRHK_INSERT_CARD 104
75#define HWCRHK_F_HWCRHK_LOAD_PRIVKEY 105
76#define HWCRHK_F_HWCRHK_LOAD_PUBKEY 106
77#define HWCRHK_F_HWCRHK_MOD_EXP 107
78#define HWCRHK_F_HWCRHK_RAND_BYTES 108
79#define HWCRHK_F_HWCRHK_RSA_MOD_EXP 109
80
81/* Reason codes. */
82#define HWCRHK_R_ALREADY_LOADED 100
83#define HWCRHK_R_BIO_WAS_FREED 101
84#define HWCRHK_R_CHIL_ERROR 102
85#define HWCRHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 103
86#define HWCRHK_R_DSO_FAILURE 104
87#define HWCRHK_R_DYNAMIC_LOCKING_MISSING 114
88#define HWCRHK_R_MISSING_KEY_COMPONENTS 105
89#define HWCRHK_R_NOT_INITIALISED 106
90#define HWCRHK_R_NOT_LOADED 107
91#define HWCRHK_R_NO_CALLBACK 108
92#define HWCRHK_R_NO_KEY 109
93#define HWCRHK_R_PRIVATE_KEY_ALGORITHMS_DISABLED 110
94#define HWCRHK_R_REQUEST_FAILED 111
95#define HWCRHK_R_REQUEST_FALLBACK 112
96#define HWCRHK_R_UNIT_FAILURE 113
97
98#ifdef __cplusplus
99}
100#endif
101#endif
diff --git a/src/lib/libcrypto/engine/hw_nuron.c b/src/lib/libcrypto/engine/hw_nuron.c
deleted file mode 100644
index fb9188bfe5..0000000000
--- a/src/lib/libcrypto/engine/hw_nuron.c
+++ /dev/null
@@ -1,418 +0,0 @@
1/* crypto/engine/hw_nuron.c */
2/* Written by Ben Laurie for the OpenSSL Project, leaning heavily on Geoff
3 * Thorpe's Atalla implementation.
4 */
5/* ====================================================================
6 * Copyright (c) 2000-2001 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/dso.h>
63#include <openssl/engine.h>
64
65
66#ifndef OPENSSL_NO_HW
67#ifndef OPENSSL_NO_HW_NURON
68
69#define NURON_LIB_NAME "nuron engine"
70#include "hw_nuron_err.c"
71
72static const char *NURON_LIBNAME = NULL;
73static const char *get_NURON_LIBNAME(void)
74 {
75 if(NURON_LIBNAME)
76 return NURON_LIBNAME;
77 return "nuronssl";
78 }
79static void free_NURON_LIBNAME(void)
80 {
81 if(NURON_LIBNAME)
82 OPENSSL_free((void*)NURON_LIBNAME);
83 NURON_LIBNAME = NULL;
84 }
85static long set_NURON_LIBNAME(const char *name)
86 {
87 free_NURON_LIBNAME();
88 return (((NURON_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
89 }
90static const char *NURON_F1 = "nuron_mod_exp";
91
92/* The definitions for control commands specific to this engine */
93#define NURON_CMD_SO_PATH ENGINE_CMD_BASE
94static const ENGINE_CMD_DEFN nuron_cmd_defns[] = {
95 {NURON_CMD_SO_PATH,
96 "SO_PATH",
97 "Specifies the path to the 'nuronssl' shared library",
98 ENGINE_CMD_FLAG_STRING},
99 {0, NULL, NULL, 0}
100 };
101
102typedef int tfnModExp(BIGNUM *r,const BIGNUM *a,const BIGNUM *p,const BIGNUM *m);
103static tfnModExp *pfnModExp = NULL;
104
105static DSO *pvDSOHandle = NULL;
106
107static int nuron_destroy(ENGINE *e)
108 {
109 free_NURON_LIBNAME();
110 ERR_unload_NURON_strings();
111 return 1;
112 }
113
114static int nuron_init(ENGINE *e)
115 {
116 if(pvDSOHandle != NULL)
117 {
118 NURONerr(NURON_F_NURON_INIT,NURON_R_ALREADY_LOADED);
119 return 0;
120 }
121
122 pvDSOHandle = DSO_load(NULL, get_NURON_LIBNAME(), NULL,
123 DSO_FLAG_NAME_TRANSLATION_EXT_ONLY);
124 if(!pvDSOHandle)
125 {
126 NURONerr(NURON_F_NURON_INIT,NURON_R_DSO_NOT_FOUND);
127 return 0;
128 }
129
130 pfnModExp = (tfnModExp *)DSO_bind_func(pvDSOHandle, NURON_F1);
131 if(!pfnModExp)
132 {
133 NURONerr(NURON_F_NURON_INIT,NURON_R_DSO_FUNCTION_NOT_FOUND);
134 return 0;
135 }
136
137 return 1;
138 }
139
140static int nuron_finish(ENGINE *e)
141 {
142 free_NURON_LIBNAME();
143 if(pvDSOHandle == NULL)
144 {
145 NURONerr(NURON_F_NURON_FINISH,NURON_R_NOT_LOADED);
146 return 0;
147 }
148 if(!DSO_free(pvDSOHandle))
149 {
150 NURONerr(NURON_F_NURON_FINISH,NURON_R_DSO_FAILURE);
151 return 0;
152 }
153 pvDSOHandle=NULL;
154 pfnModExp=NULL;
155 return 1;
156 }
157
158static int nuron_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
159 {
160 int initialised = ((pvDSOHandle == NULL) ? 0 : 1);
161 switch(cmd)
162 {
163 case NURON_CMD_SO_PATH:
164 if(p == NULL)
165 {
166 NURONerr(NURON_F_NURON_CTRL,ERR_R_PASSED_NULL_PARAMETER);
167 return 0;
168 }
169 if(initialised)
170 {
171 NURONerr(NURON_F_NURON_CTRL,NURON_R_ALREADY_LOADED);
172 return 0;
173 }
174 return set_NURON_LIBNAME((const char *)p);
175 default:
176 break;
177 }
178 NURONerr(NURON_F_NURON_CTRL,NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED);
179 return 0;
180}
181
182static int nuron_mod_exp(BIGNUM *r,const BIGNUM *a,const BIGNUM *p,
183 const BIGNUM *m,BN_CTX *ctx)
184 {
185 if(!pvDSOHandle)
186 {
187 NURONerr(NURON_F_NURON_MOD_EXP,NURON_R_NOT_LOADED);
188 return 0;
189 }
190 return pfnModExp(r,a,p,m);
191 }
192
193#ifndef OPENSSL_NO_RSA
194static int nuron_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
195 {
196 return nuron_mod_exp(r0,I,rsa->d,rsa->n,NULL);
197 }
198#endif
199
200#ifndef OPENSSL_NO_DSA
201/* This code was liberated and adapted from the commented-out code in
202 * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration
203 * (it doesn't have a CRT form for RSA), this function means that an
204 * Atalla system running with a DSA server certificate can handshake
205 * around 5 or 6 times faster/more than an equivalent system running with
206 * RSA. Just check out the "signs" statistics from the RSA and DSA parts
207 * of "openssl speed -engine atalla dsa1024 rsa1024". */
208static int nuron_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
209 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
210 BN_CTX *ctx, BN_MONT_CTX *in_mont)
211 {
212 BIGNUM t;
213 int to_return = 0;
214
215 BN_init(&t);
216 /* let rr = a1 ^ p1 mod m */
217 if (!nuron_mod_exp(rr,a1,p1,m,ctx))
218 goto end;
219 /* let t = a2 ^ p2 mod m */
220 if (!nuron_mod_exp(&t,a2,p2,m,ctx))
221 goto end;
222 /* let rr = rr * t mod m */
223 if (!BN_mod_mul(rr,rr,&t,m,ctx))
224 goto end;
225 to_return = 1;
226end:
227 BN_free(&t);
228 return to_return;
229 }
230
231
232static int nuron_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
233 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
234 BN_MONT_CTX *m_ctx)
235 {
236 return nuron_mod_exp(r, a, p, m, ctx);
237 }
238#endif
239
240/* This function is aliased to mod_exp (with the mont stuff dropped). */
241static int nuron_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
242 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
243 {
244 return nuron_mod_exp(r, a, p, m, ctx);
245 }
246
247#ifndef OPENSSL_NO_DH
248/* This function is aliased to mod_exp (with the dh and mont dropped). */
249static int nuron_mod_exp_dh(const DH *dh, BIGNUM *r,
250 const BIGNUM *a, const BIGNUM *p,
251 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
252 {
253 return nuron_mod_exp(r, a, p, m, ctx);
254 }
255#endif
256
257#ifndef OPENSSL_NO_RSA
258static RSA_METHOD nuron_rsa =
259 {
260 "Nuron RSA method",
261 NULL,
262 NULL,
263 NULL,
264 NULL,
265 nuron_rsa_mod_exp,
266 nuron_mod_exp_mont,
267 NULL,
268 NULL,
269 0,
270 NULL,
271 NULL,
272 NULL
273 };
274#endif
275
276#ifndef OPENSSL_NO_DSA
277static DSA_METHOD nuron_dsa =
278 {
279 "Nuron DSA method",
280 NULL, /* dsa_do_sign */
281 NULL, /* dsa_sign_setup */
282 NULL, /* dsa_do_verify */
283 nuron_dsa_mod_exp, /* dsa_mod_exp */
284 nuron_mod_exp_dsa, /* bn_mod_exp */
285 NULL, /* init */
286 NULL, /* finish */
287 0, /* flags */
288 NULL /* app_data */
289 };
290#endif
291
292#ifndef OPENSSL_NO_DH
293static DH_METHOD nuron_dh =
294 {
295 "Nuron DH method",
296 NULL,
297 NULL,
298 nuron_mod_exp_dh,
299 NULL,
300 NULL,
301 0,
302 NULL
303 };
304#endif
305
306/* Constants used when creating the ENGINE */
307static const char *engine_nuron_id = "nuron";
308static const char *engine_nuron_name = "Nuron hardware engine support";
309
310/* This internal function is used by ENGINE_nuron() and possibly by the
311 * "dynamic" ENGINE support too */
312static int bind_helper(ENGINE *e)
313 {
314#ifndef OPENSSL_NO_RSA
315 const RSA_METHOD *meth1;
316#endif
317#ifndef OPENSSL_NO_DSA
318 const DSA_METHOD *meth2;
319#endif
320#ifndef OPENSSL_NO_DH
321 const DH_METHOD *meth3;
322#endif
323 if(!ENGINE_set_id(e, engine_nuron_id) ||
324 !ENGINE_set_name(e, engine_nuron_name) ||
325#ifndef OPENSSL_NO_RSA
326 !ENGINE_set_RSA(e, &nuron_rsa) ||
327#endif
328#ifndef OPENSSL_NO_DSA
329 !ENGINE_set_DSA(e, &nuron_dsa) ||
330#endif
331#ifndef OPENSSL_NO_DH
332 !ENGINE_set_DH(e, &nuron_dh) ||
333#endif
334 !ENGINE_set_destroy_function(e, nuron_destroy) ||
335 !ENGINE_set_init_function(e, nuron_init) ||
336 !ENGINE_set_finish_function(e, nuron_finish) ||
337 !ENGINE_set_ctrl_function(e, nuron_ctrl) ||
338 !ENGINE_set_cmd_defns(e, nuron_cmd_defns))
339 return 0;
340
341#ifndef OPENSSL_NO_RSA
342 /* We know that the "PKCS1_SSLeay()" functions hook properly
343 * to the nuron-specific mod_exp and mod_exp_crt so we use
344 * those functions. NB: We don't use ENGINE_openssl() or
345 * anything "more generic" because something like the RSAref
346 * code may not hook properly, and if you own one of these
347 * cards then you have the right to do RSA operations on it
348 * anyway! */
349 meth1=RSA_PKCS1_SSLeay();
350 nuron_rsa.rsa_pub_enc=meth1->rsa_pub_enc;
351 nuron_rsa.rsa_pub_dec=meth1->rsa_pub_dec;
352 nuron_rsa.rsa_priv_enc=meth1->rsa_priv_enc;
353 nuron_rsa.rsa_priv_dec=meth1->rsa_priv_dec;
354#endif
355
356#ifndef OPENSSL_NO_DSA
357 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
358 * bits. */
359 meth2=DSA_OpenSSL();
360 nuron_dsa.dsa_do_sign=meth2->dsa_do_sign;
361 nuron_dsa.dsa_sign_setup=meth2->dsa_sign_setup;
362 nuron_dsa.dsa_do_verify=meth2->dsa_do_verify;
363#endif
364
365#ifndef OPENSSL_NO_DH
366 /* Much the same for Diffie-Hellman */
367 meth3=DH_OpenSSL();
368 nuron_dh.generate_key=meth3->generate_key;
369 nuron_dh.compute_key=meth3->compute_key;
370#endif
371
372 /* Ensure the nuron error handling is set up */
373 ERR_load_NURON_strings();
374 return 1;
375 }
376
377#ifndef ENGINE_DYNAMIC_SUPPORT
378static ENGINE *engine_nuron(void)
379 {
380 ENGINE *ret = ENGINE_new();
381 if(!ret)
382 return NULL;
383 if(!bind_helper(ret))
384 {
385 ENGINE_free(ret);
386 return NULL;
387 }
388 return ret;
389 }
390
391void ENGINE_load_nuron(void)
392 {
393 /* Copied from eng_[openssl|dyn].c */
394 ENGINE *toadd = engine_nuron();
395 if(!toadd) return;
396 ENGINE_add(toadd);
397 ENGINE_free(toadd);
398 ERR_clear_error();
399 }
400#endif
401
402/* This stuff is needed if this ENGINE is being compiled into a self-contained
403 * shared-library. */
404#ifdef ENGINE_DYNAMIC_SUPPORT
405static int bind_fn(ENGINE *e, const char *id)
406 {
407 if(id && (strcmp(id, engine_nuron_id) != 0))
408 return 0;
409 if(!bind_helper(e))
410 return 0;
411 return 1;
412 }
413IMPLEMENT_DYNAMIC_CHECK_FN()
414IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
415#endif /* ENGINE_DYNAMIC_SUPPORT */
416
417#endif /* !OPENSSL_NO_HW_NURON */
418#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_sureware.c b/src/lib/libcrypto/engine/hw_sureware.c
deleted file mode 100644
index fca467e690..0000000000
--- a/src/lib/libcrypto/engine/hw_sureware.c
+++ /dev/null
@@ -1,1039 +0,0 @@
1/* Written by Corinne Dive-Reclus(cdive@baltimore.com)
2*
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*
8* 1. Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10*
11* 2. Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in
13* the documentation and/or other materials provided with the
14* distribution.
15*
16* 3. All advertising materials mentioning features or use of this
17* software must display the following acknowledgment:
18* "This product includes software developed by the OpenSSL Project
19* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
20*
21* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22* endorse or promote products derived from this software without
23* prior written permission. For written permission, please contact
24* licensing@OpenSSL.org.
25*
26* 5. Products derived from this software may not be called "OpenSSL"
27* nor may "OpenSSL" appear in their names without prior written
28* permission of the OpenSSL Project.
29*
30* 6. Redistributions of any form whatsoever must retain the following
31* acknowledgment:
32* "This product includes software developed by the OpenSSL Project
33* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34*
35* Written by Corinne Dive-Reclus(cdive@baltimore.com)
36*
37* Copyright@2001 Baltimore Technologies Ltd.
38* All right Reserved.
39* *
40* THIS FILE IS PROVIDED BY BALTIMORE TECHNOLOGIES ``AS IS'' AND *
41* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
42* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
43* ARE DISCLAIMED. IN NO EVENT SHALL BALTIMORE TECHNOLOGIES BE LIABLE *
44* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
45* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
46* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
47* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
48* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
49* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
50* SUCH DAMAGE. *
51====================================================================*/
52
53#include <stdio.h>
54#include "cryptlib.h"
55#include <openssl/crypto.h>
56#include <openssl/pem.h>
57#include <openssl/dso.h>
58#include "eng_int.h"
59#include "engine.h"
60#include <openssl/engine.h>
61
62#ifndef OPENSSL_NO_HW
63#ifndef OPENSSL_NO_HW_SUREWARE
64
65#ifdef FLAT_INC
66#include "sureware.h"
67#else
68#include "vendor_defns/sureware.h"
69#endif
70
71#define SUREWARE_LIB_NAME "sureware engine"
72#include "hw_sureware_err.c"
73
74static int surewarehk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
75static int surewarehk_destroy(ENGINE *e);
76static int surewarehk_init(ENGINE *e);
77static int surewarehk_finish(ENGINE *e);
78static int surewarehk_modexp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
79 const BIGNUM *m, BN_CTX *ctx);
80
81/* RSA stuff */
82static int surewarehk_rsa_priv_dec(int flen,const unsigned char *from,unsigned char *to,
83 RSA *rsa,int padding);
84static int surewarehk_rsa_sign(int flen,const unsigned char *from,unsigned char *to,
85 RSA *rsa,int padding);
86
87/* RAND stuff */
88static int surewarehk_rand_bytes(unsigned char *buf, int num);
89static void surewarehk_rand_seed(const void *buf, int num);
90static void surewarehk_rand_add(const void *buf, int num, double entropy);
91
92/* KM stuff */
93static EVP_PKEY *surewarehk_load_privkey(ENGINE *e, const char *key_id,
94 UI_METHOD *ui_method, void *callback_data);
95static EVP_PKEY *surewarehk_load_pubkey(ENGINE *e, const char *key_id,
96 UI_METHOD *ui_method, void *callback_data);
97static void surewarehk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
98 int idx,long argl, void *argp);
99#if 0
100static void surewarehk_dh_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
101 int idx,long argl, void *argp);
102#endif
103
104#ifndef OPENSSL_NO_RSA
105/* This function is aliased to mod_exp (with the mont stuff dropped). */
106static int surewarehk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
107 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
108{
109 return surewarehk_modexp(r, a, p, m, ctx);
110}
111
112/* Our internal RSA_METHOD that we provide pointers to */
113static RSA_METHOD surewarehk_rsa =
114 {
115 "SureWare RSA method",
116 NULL, /* pub_enc*/
117 NULL, /* pub_dec*/
118 surewarehk_rsa_sign, /* our rsa_sign is OpenSSL priv_enc*/
119 surewarehk_rsa_priv_dec, /* priv_dec*/
120 NULL, /*mod_exp*/
121 surewarehk_mod_exp_mont, /*mod_exp_mongomery*/
122 NULL, /* init*/
123 NULL, /* finish*/
124 0, /* RSA flag*/
125 NULL,
126 NULL, /* OpenSSL sign*/
127 NULL /* OpenSSL verify*/
128 };
129#endif
130
131#ifndef OPENSSL_NO_DH
132/* Our internal DH_METHOD that we provide pointers to */
133/* This function is aliased to mod_exp (with the dh and mont dropped). */
134static int surewarehk_modexp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
135 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
136{
137 return surewarehk_modexp(r, a, p, m, ctx);
138}
139
140static DH_METHOD surewarehk_dh =
141 {
142 "SureWare DH method",
143 NULL,/*gen_key*/
144 NULL,/*agree,*/
145 surewarehk_modexp_dh, /*dh mod exp*/
146 NULL, /* init*/
147 NULL, /* finish*/
148 0, /* flags*/
149 NULL
150 };
151#endif
152
153static RAND_METHOD surewarehk_rand =
154 {
155 /* "SureWare RAND method", */
156 surewarehk_rand_seed,
157 surewarehk_rand_bytes,
158 NULL,/*cleanup*/
159 surewarehk_rand_add,
160 surewarehk_rand_bytes,
161 NULL,/*rand_status*/
162 };
163
164#ifndef OPENSSL_NO_DSA
165/* DSA stuff */
166static DSA_SIG * surewarehk_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
167static int surewarehk_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
168 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
169 BN_CTX *ctx, BN_MONT_CTX *in_mont)
170{
171 BIGNUM t;
172 int to_return = 0;
173 BN_init(&t);
174 /* let rr = a1 ^ p1 mod m */
175 if (!surewarehk_modexp(rr,a1,p1,m,ctx)) goto end;
176 /* let t = a2 ^ p2 mod m */
177 if (!surewarehk_modexp(&t,a2,p2,m,ctx)) goto end;
178 /* let rr = rr * t mod m */
179 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
180 to_return = 1;
181end:
182 BN_free(&t);
183 return to_return;
184}
185
186static DSA_METHOD surewarehk_dsa =
187 {
188 "SureWare DSA method",
189 surewarehk_dsa_do_sign,
190 NULL,/*sign setup*/
191 NULL,/*verify,*/
192 surewarehk_dsa_mod_exp,/*mod exp*/
193 NULL,/*bn mod exp*/
194 NULL, /*init*/
195 NULL,/*finish*/
196 0,
197 NULL,
198 };
199#endif
200
201static const char *engine_sureware_id = "sureware";
202static const char *engine_sureware_name = "SureWare hardware engine support";
203
204/* Now, to our own code */
205
206/* As this is only ever called once, there's no need for locking
207 * (indeed - the lock will already be held by our caller!!!) */
208static int bind_sureware(ENGINE *e)
209{
210#ifndef OPENSSL_NO_RSA
211 const RSA_METHOD *meth1;
212#endif
213#ifndef OPENSSL_NO_DSA
214 const DSA_METHOD *meth2;
215#endif
216#ifndef OPENSSL_NO_DH
217 const DH_METHOD *meth3;
218#endif
219
220 if(!ENGINE_set_id(e, engine_sureware_id) ||
221 !ENGINE_set_name(e, engine_sureware_name) ||
222#ifndef OPENSSL_NO_RSA
223 !ENGINE_set_RSA(e, &surewarehk_rsa) ||
224#endif
225#ifndef OPENSSL_NO_DSA
226 !ENGINE_set_DSA(e, &surewarehk_dsa) ||
227#endif
228#ifndef OPENSSL_NO_DH
229 !ENGINE_set_DH(e, &surewarehk_dh) ||
230#endif
231 !ENGINE_set_RAND(e, &surewarehk_rand) ||
232 !ENGINE_set_destroy_function(e, surewarehk_destroy) ||
233 !ENGINE_set_init_function(e, surewarehk_init) ||
234 !ENGINE_set_finish_function(e, surewarehk_finish) ||
235 !ENGINE_set_ctrl_function(e, surewarehk_ctrl) ||
236 !ENGINE_set_load_privkey_function(e, surewarehk_load_privkey) ||
237 !ENGINE_set_load_pubkey_function(e, surewarehk_load_pubkey))
238 return 0;
239
240#ifndef OPENSSL_NO_RSA
241 /* We know that the "PKCS1_SSLeay()" functions hook properly
242 * to the cswift-specific mod_exp and mod_exp_crt so we use
243 * those functions. NB: We don't use ENGINE_openssl() or
244 * anything "more generic" because something like the RSAref
245 * code may not hook properly, and if you own one of these
246 * cards then you have the right to do RSA operations on it
247 * anyway! */
248 meth1 = RSA_PKCS1_SSLeay();
249 if (meth1)
250 {
251 surewarehk_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
252 surewarehk_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
253 }
254#endif
255
256#ifndef OPENSSL_NO_DSA
257 /* Use the DSA_OpenSSL() method and just hook the mod_exp-ish
258 * bits. */
259 meth2 = DSA_OpenSSL();
260 if (meth2)
261 {
262 surewarehk_dsa.dsa_do_verify = meth2->dsa_do_verify;
263 }
264#endif
265
266#ifndef OPENSSL_NO_DH
267 /* Much the same for Diffie-Hellman */
268 meth3 = DH_OpenSSL();
269 if (meth3)
270 {
271 surewarehk_dh.generate_key = meth3->generate_key;
272 surewarehk_dh.compute_key = meth3->compute_key;
273 }
274#endif
275
276 /* Ensure the sureware error handling is set up */
277 ERR_load_SUREWARE_strings();
278 return 1;
279}
280
281#ifdef ENGINE_DYNAMIC_SUPPORT
282static int bind_helper(ENGINE *e, const char *id)
283 {
284 if(id && (strcmp(id, engine_sureware_id) != 0))
285 return 0;
286 if(!bind_sureware(e))
287 return 0;
288 return 1;
289 }
290IMPLEMENT_DYNAMIC_CHECK_FN()
291IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)
292#else
293static ENGINE *engine_sureware(void)
294 {
295 ENGINE *ret = ENGINE_new();
296 if(!ret)
297 return NULL;
298 if(!bind_sureware(ret))
299 {
300 ENGINE_free(ret);
301 return NULL;
302 }
303 return ret;
304 }
305
306void ENGINE_load_sureware(void)
307 {
308 /* Copied from eng_[openssl|dyn].c */
309 ENGINE *toadd = engine_sureware();
310 if(!toadd) return;
311 ENGINE_add(toadd);
312 ENGINE_free(toadd);
313 ERR_clear_error();
314 }
315#endif
316
317/* This is a process-global DSO handle used for loading and unloading
318 * the SureWareHook library. NB: This is only set (or unset) during an
319 * init() or finish() call (reference counts permitting) and they're
320 * operating with global locks, so this should be thread-safe
321 * implicitly. */
322static DSO *surewarehk_dso = NULL;
323#ifndef OPENSSL_NO_RSA
324static int rsaHndidx = -1; /* Index for KM handle. Not really used yet. */
325#endif
326#ifndef OPENSSL_NO_DSA
327static int dsaHndidx = -1; /* Index for KM handle. Not really used yet. */
328#endif
329
330/* These are the function pointers that are (un)set when the library has
331 * successfully (un)loaded. */
332static SureWareHook_Init_t *p_surewarehk_Init = NULL;
333static SureWareHook_Finish_t *p_surewarehk_Finish = NULL;
334static SureWareHook_Rand_Bytes_t *p_surewarehk_Rand_Bytes = NULL;
335static SureWareHook_Rand_Seed_t *p_surewarehk_Rand_Seed = NULL;
336static SureWareHook_Load_Privkey_t *p_surewarehk_Load_Privkey = NULL;
337static SureWareHook_Info_Pubkey_t *p_surewarehk_Info_Pubkey = NULL;
338static SureWareHook_Load_Rsa_Pubkey_t *p_surewarehk_Load_Rsa_Pubkey = NULL;
339static SureWareHook_Load_Dsa_Pubkey_t *p_surewarehk_Load_Dsa_Pubkey = NULL;
340static SureWareHook_Free_t *p_surewarehk_Free=NULL;
341static SureWareHook_Rsa_Priv_Dec_t *p_surewarehk_Rsa_Priv_Dec=NULL;
342static SureWareHook_Rsa_Sign_t *p_surewarehk_Rsa_Sign=NULL;
343static SureWareHook_Dsa_Sign_t *p_surewarehk_Dsa_Sign=NULL;
344static SureWareHook_Mod_Exp_t *p_surewarehk_Mod_Exp=NULL;
345
346/* Used in the DSO operations. */
347static const char *surewarehk_LIBNAME = "SureWareHook";
348static const char *n_surewarehk_Init = "SureWareHook_Init";
349static const char *n_surewarehk_Finish = "SureWareHook_Finish";
350static const char *n_surewarehk_Rand_Bytes="SureWareHook_Rand_Bytes";
351static const char *n_surewarehk_Rand_Seed="SureWareHook_Rand_Seed";
352static const char *n_surewarehk_Load_Privkey="SureWareHook_Load_Privkey";
353static const char *n_surewarehk_Info_Pubkey="SureWareHook_Info_Pubkey";
354static const char *n_surewarehk_Load_Rsa_Pubkey="SureWareHook_Load_Rsa_Pubkey";
355static const char *n_surewarehk_Load_Dsa_Pubkey="SureWareHook_Load_Dsa_Pubkey";
356static const char *n_surewarehk_Free="SureWareHook_Free";
357static const char *n_surewarehk_Rsa_Priv_Dec="SureWareHook_Rsa_Priv_Dec";
358static const char *n_surewarehk_Rsa_Sign="SureWareHook_Rsa_Sign";
359static const char *n_surewarehk_Dsa_Sign="SureWareHook_Dsa_Sign";
360static const char *n_surewarehk_Mod_Exp="SureWareHook_Mod_Exp";
361static BIO *logstream = NULL;
362
363/* SureWareHook library functions and mechanics - these are used by the
364 * higher-level functions further down. NB: As and where there's no
365 * error checking, take a look lower down where these functions are
366 * called, the checking and error handling is probably down there.
367*/
368static int threadsafe=1;
369static int surewarehk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
370{
371 int to_return = 1;
372
373 switch(cmd)
374 {
375 case ENGINE_CTRL_SET_LOGSTREAM:
376 {
377 BIO *bio = (BIO *)p;
378 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
379 if (logstream)
380 {
381 BIO_free(logstream);
382 logstream = NULL;
383 }
384 if (CRYPTO_add(&bio->references,1,CRYPTO_LOCK_BIO) > 1)
385 logstream = bio;
386 else
387 SUREWAREerr(SUREWARE_F_SUREWAREHK_CTRL,SUREWARE_R_BIO_WAS_FREED);
388 }
389 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
390 break;
391 /* This will prevent the initialisation function from "installing"
392 * the mutex-handling callbacks, even if they are available from
393 * within the library (or were provided to the library from the
394 * calling application). This is to remove any baggage for
395 * applications not using multithreading. */
396 case ENGINE_CTRL_CHIL_NO_LOCKING:
397 CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
398 threadsafe = 0;
399 CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
400 break;
401
402 /* The command isn't understood by this engine */
403 default:
404 SUREWAREerr(SUREWARE_F_SUREWAREHK_CTRL,
405 ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED);
406 to_return = 0;
407 break;
408 }
409
410 return to_return;
411}
412
413/* Destructor (complements the "ENGINE_surewarehk()" constructor) */
414static int surewarehk_destroy(ENGINE *e)
415{
416 ERR_unload_SUREWARE_strings();
417 return 1;
418}
419
420/* (de)initialisation functions. */
421static int surewarehk_init(ENGINE *e)
422{
423 char msg[64]="ENGINE_init";
424 SureWareHook_Init_t *p1=NULL;
425 SureWareHook_Finish_t *p2=NULL;
426 SureWareHook_Rand_Bytes_t *p3=NULL;
427 SureWareHook_Rand_Seed_t *p4=NULL;
428 SureWareHook_Load_Privkey_t *p5=NULL;
429 SureWareHook_Load_Rsa_Pubkey_t *p6=NULL;
430 SureWareHook_Free_t *p7=NULL;
431 SureWareHook_Rsa_Priv_Dec_t *p8=NULL;
432 SureWareHook_Rsa_Sign_t *p9=NULL;
433 SureWareHook_Dsa_Sign_t *p12=NULL;
434 SureWareHook_Info_Pubkey_t *p13=NULL;
435 SureWareHook_Load_Dsa_Pubkey_t *p14=NULL;
436 SureWareHook_Mod_Exp_t *p15=NULL;
437
438 if(surewarehk_dso != NULL)
439 {
440 SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT,ENGINE_R_ALREADY_LOADED);
441 goto err;
442 }
443 /* Attempt to load libsurewarehk.so/surewarehk.dll/whatever. */
444 surewarehk_dso = DSO_load(NULL, surewarehk_LIBNAME, NULL, 0);
445 if(surewarehk_dso == NULL)
446 {
447 SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT,ENGINE_R_DSO_FAILURE);
448 goto err;
449 }
450 if(!(p1=(SureWareHook_Init_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Init)) ||
451 !(p2=(SureWareHook_Finish_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Finish)) ||
452 !(p3=(SureWareHook_Rand_Bytes_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Rand_Bytes)) ||
453 !(p4=(SureWareHook_Rand_Seed_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Rand_Seed)) ||
454 !(p5=(SureWareHook_Load_Privkey_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Load_Privkey)) ||
455 !(p6=(SureWareHook_Load_Rsa_Pubkey_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Load_Rsa_Pubkey)) ||
456 !(p7=(SureWareHook_Free_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Free)) ||
457 !(p8=(SureWareHook_Rsa_Priv_Dec_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Rsa_Priv_Dec)) ||
458 !(p9=(SureWareHook_Rsa_Sign_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Rsa_Sign)) ||
459 !(p12=(SureWareHook_Dsa_Sign_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Dsa_Sign)) ||
460 !(p13=(SureWareHook_Info_Pubkey_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Info_Pubkey)) ||
461 !(p14=(SureWareHook_Load_Dsa_Pubkey_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Load_Dsa_Pubkey)) ||
462 !(p15=(SureWareHook_Mod_Exp_t*)DSO_bind_func(surewarehk_dso, n_surewarehk_Mod_Exp)))
463 {
464 SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT,ENGINE_R_DSO_FAILURE);
465 goto err;
466 }
467 /* Copy the pointers */
468 p_surewarehk_Init = p1;
469 p_surewarehk_Finish = p2;
470 p_surewarehk_Rand_Bytes = p3;
471 p_surewarehk_Rand_Seed = p4;
472 p_surewarehk_Load_Privkey = p5;
473 p_surewarehk_Load_Rsa_Pubkey = p6;
474 p_surewarehk_Free = p7;
475 p_surewarehk_Rsa_Priv_Dec = p8;
476 p_surewarehk_Rsa_Sign = p9;
477 p_surewarehk_Dsa_Sign = p12;
478 p_surewarehk_Info_Pubkey = p13;
479 p_surewarehk_Load_Dsa_Pubkey = p14;
480 p_surewarehk_Mod_Exp = p15;
481 /* Contact the hardware and initialises it. */
482 if(p_surewarehk_Init(msg,threadsafe)==SUREWAREHOOK_ERROR_UNIT_FAILURE)
483 {
484 SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT,SUREWARE_R_UNIT_FAILURE);
485 goto err;
486 }
487 if(p_surewarehk_Init(msg,threadsafe)==SUREWAREHOOK_ERROR_UNIT_FAILURE)
488 {
489 SUREWAREerr(SUREWARE_F_SUREWAREHK_INIT,SUREWARE_R_UNIT_FAILURE);
490 goto err;
491 }
492 /* try to load the default private key, if failed does not return a failure but
493 wait for an explicit ENGINE_load_privakey */
494 surewarehk_load_privkey(e,NULL,NULL,NULL);
495
496 /* Everything's fine. */
497#ifndef OPENSSL_NO_RSA
498 if (rsaHndidx == -1)
499 rsaHndidx = RSA_get_ex_new_index(0,
500 "SureWareHook RSA key handle",
501 NULL, NULL, surewarehk_ex_free);
502#endif
503#ifndef OPENSSL_NO_DSA
504 if (dsaHndidx == -1)
505 dsaHndidx = DSA_get_ex_new_index(0,
506 "SureWareHook DSA key handle",
507 NULL, NULL, surewarehk_ex_free);
508#endif
509
510 return 1;
511err:
512 if(surewarehk_dso)
513 DSO_free(surewarehk_dso);
514 surewarehk_dso = NULL;
515 p_surewarehk_Init = NULL;
516 p_surewarehk_Finish = NULL;
517 p_surewarehk_Rand_Bytes = NULL;
518 p_surewarehk_Rand_Seed = NULL;
519 p_surewarehk_Load_Privkey = NULL;
520 p_surewarehk_Load_Rsa_Pubkey = NULL;
521 p_surewarehk_Free = NULL;
522 p_surewarehk_Rsa_Priv_Dec = NULL;
523 p_surewarehk_Rsa_Sign = NULL;
524 p_surewarehk_Dsa_Sign = NULL;
525 p_surewarehk_Info_Pubkey = NULL;
526 p_surewarehk_Load_Dsa_Pubkey = NULL;
527 p_surewarehk_Mod_Exp = NULL;
528 return 0;
529}
530
531static int surewarehk_finish(ENGINE *e)
532{
533 int to_return = 1;
534 if(surewarehk_dso == NULL)
535 {
536 SUREWAREerr(SUREWARE_F_SUREWAREHK_FINISH,ENGINE_R_NOT_LOADED);
537 to_return = 0;
538 goto err;
539 }
540 p_surewarehk_Finish();
541 if(!DSO_free(surewarehk_dso))
542 {
543 SUREWAREerr(SUREWARE_F_SUREWAREHK_FINISH,ENGINE_R_DSO_FAILURE);
544 to_return = 0;
545 goto err;
546 }
547 err:
548 if (logstream)
549 BIO_free(logstream);
550 surewarehk_dso = NULL;
551 p_surewarehk_Init = NULL;
552 p_surewarehk_Finish = NULL;
553 p_surewarehk_Rand_Bytes = NULL;
554 p_surewarehk_Rand_Seed = NULL;
555 p_surewarehk_Load_Privkey = NULL;
556 p_surewarehk_Load_Rsa_Pubkey = NULL;
557 p_surewarehk_Free = NULL;
558 p_surewarehk_Rsa_Priv_Dec = NULL;
559 p_surewarehk_Rsa_Sign = NULL;
560 p_surewarehk_Dsa_Sign = NULL;
561 p_surewarehk_Info_Pubkey = NULL;
562 p_surewarehk_Load_Dsa_Pubkey = NULL;
563 p_surewarehk_Mod_Exp = NULL;
564 return to_return;
565}
566
567static void surewarehk_error_handling(char *const msg,int func,int ret)
568{
569 switch (ret)
570 {
571 case SUREWAREHOOK_ERROR_UNIT_FAILURE:
572 ENGINEerr(func,SUREWARE_R_UNIT_FAILURE);
573 break;
574 case SUREWAREHOOK_ERROR_FALLBACK:
575 ENGINEerr(func,SUREWARE_R_REQUEST_FALLBACK);
576 break;
577 case SUREWAREHOOK_ERROR_DATA_SIZE:
578 ENGINEerr(func,SUREWARE_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
579 break;
580 case SUREWAREHOOK_ERROR_INVALID_PAD:
581 ENGINEerr(func,RSA_R_PADDING_CHECK_FAILED);
582 break;
583 default:
584 ENGINEerr(func,SUREWARE_R_REQUEST_FAILED);
585 break;
586 case 1:/*nothing*/
587 msg[0]='\0';
588 }
589 if (*msg)
590 {
591 ERR_add_error_data(1,msg);
592 if (logstream)
593 {
594 CRYPTO_w_lock(CRYPTO_LOCK_BIO);
595 BIO_write(logstream, msg, strlen(msg));
596 CRYPTO_w_unlock(CRYPTO_LOCK_BIO);
597 }
598 }
599}
600
601static int surewarehk_rand_bytes(unsigned char *buf, int num)
602{
603 int ret=0;
604 char msg[64]="ENGINE_rand_bytes";
605 if(!p_surewarehk_Rand_Bytes)
606 {
607 SUREWAREerr(SUREWARE_F_SUREWAREHK_RAND_BYTES,ENGINE_R_NOT_INITIALISED);
608 }
609 else
610 {
611 ret = p_surewarehk_Rand_Bytes(msg,buf, num);
612 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_RAND_BYTES,ret);
613 }
614 return ret==1 ? 1 : 0;
615}
616
617static void surewarehk_rand_seed(const void *buf, int num)
618{
619 int ret=0;
620 char msg[64]="ENGINE_rand_seed";
621 if(!p_surewarehk_Rand_Seed)
622 {
623 SUREWAREerr(SUREWARE_F_SUREWAREHK_RAND_SEED,ENGINE_R_NOT_INITIALISED);
624 }
625 else
626 {
627 ret = p_surewarehk_Rand_Seed(msg,buf, num);
628 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_RAND_SEED,ret);
629 }
630}
631
632static void surewarehk_rand_add(const void *buf, int num, double entropy)
633{
634 surewarehk_rand_seed(buf,num);
635}
636
637static EVP_PKEY* sureware_load_public(ENGINE *e,const char *key_id,char *hptr,unsigned long el,char keytype)
638{
639 EVP_PKEY *res = NULL;
640#ifndef OPENSSL_NO_RSA
641 RSA *rsatmp = NULL;
642#endif
643#ifndef OPENSSL_NO_DSA
644 DSA *dsatmp=NULL;
645#endif
646 char msg[64]="sureware_load_public";
647 int ret=0;
648 if(!p_surewarehk_Load_Rsa_Pubkey || !p_surewarehk_Load_Dsa_Pubkey)
649 {
650 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,ENGINE_R_NOT_INITIALISED);
651 goto err;
652 }
653 switch (keytype)
654 {
655#ifndef OPENSSL_NO_RSA
656 case 1: /*RSA*/
657 /* set private external reference */
658 rsatmp = RSA_new_method(e);
659 RSA_set_ex_data(rsatmp,rsaHndidx,hptr);
660 rsatmp->flags |= RSA_FLAG_EXT_PKEY;
661
662 /* set public big nums*/
663 rsatmp->e = BN_new();
664 rsatmp->n = BN_new();
665 bn_expand2(rsatmp->e, el/sizeof(BN_ULONG));
666 bn_expand2(rsatmp->n, el/sizeof(BN_ULONG));
667 if (!rsatmp->e || rsatmp->e->dmax!=(int)(el/sizeof(BN_ULONG))||
668 !rsatmp->n || rsatmp->n->dmax!=(int)(el/sizeof(BN_ULONG)))
669 goto err;
670 ret=p_surewarehk_Load_Rsa_Pubkey(msg,key_id,el,
671 (unsigned long *)rsatmp->n->d,
672 (unsigned long *)rsatmp->e->d);
673 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,ret);
674 if (ret!=1)
675 {
676 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,ENGINE_R_FAILED_LOADING_PUBLIC_KEY);
677 goto err;
678 }
679 /* normalise pub e and pub n */
680 rsatmp->e->top=el/sizeof(BN_ULONG);
681 bn_fix_top(rsatmp->e);
682 rsatmp->n->top=el/sizeof(BN_ULONG);
683 bn_fix_top(rsatmp->n);
684 /* create an EVP object: engine + rsa key */
685 res = EVP_PKEY_new();
686 EVP_PKEY_assign_RSA(res, rsatmp);
687 break;
688#endif
689
690#ifndef OPENSSL_NO_DSA
691 case 2:/*DSA*/
692 /* set private/public external reference */
693 dsatmp = DSA_new_method(e);
694 DSA_set_ex_data(dsatmp,dsaHndidx,hptr);
695 /*dsatmp->flags |= DSA_FLAG_EXT_PKEY;*/
696
697 /* set public key*/
698 dsatmp->pub_key = BN_new();
699 dsatmp->p = BN_new();
700 dsatmp->q = BN_new();
701 dsatmp->g = BN_new();
702 bn_expand2(dsatmp->pub_key, el/sizeof(BN_ULONG));
703 bn_expand2(dsatmp->p, el/sizeof(BN_ULONG));
704 bn_expand2(dsatmp->q, 20/sizeof(BN_ULONG));
705 bn_expand2(dsatmp->g, el/sizeof(BN_ULONG));
706 if (!dsatmp->pub_key || dsatmp->pub_key->dmax!=(int)(el/sizeof(BN_ULONG))||
707 !dsatmp->p || dsatmp->p->dmax!=(int)(el/sizeof(BN_ULONG)) ||
708 !dsatmp->q || dsatmp->q->dmax!=20/sizeof(BN_ULONG) ||
709 !dsatmp->g || dsatmp->g->dmax!=(int)(el/sizeof(BN_ULONG)))
710 goto err;
711
712 ret=p_surewarehk_Load_Dsa_Pubkey(msg,key_id,el,
713 (unsigned long *)dsatmp->pub_key->d,
714 (unsigned long *)dsatmp->p->d,
715 (unsigned long *)dsatmp->q->d,
716 (unsigned long *)dsatmp->g->d);
717 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,ret);
718 if (ret!=1)
719 {
720 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,ENGINE_R_FAILED_LOADING_PUBLIC_KEY);
721 goto err;
722 }
723 /* set parameters */
724 /* normalise pubkey and parameters in case of */
725 dsatmp->pub_key->top=el/sizeof(BN_ULONG);
726 bn_fix_top(dsatmp->pub_key);
727 dsatmp->p->top=el/sizeof(BN_ULONG);
728 bn_fix_top(dsatmp->p);
729 dsatmp->q->top=20/sizeof(BN_ULONG);
730 bn_fix_top(dsatmp->q);
731 dsatmp->g->top=el/sizeof(BN_ULONG);
732 bn_fix_top(dsatmp->g);
733
734 /* create an EVP object: engine + rsa key */
735 res = EVP_PKEY_new();
736 EVP_PKEY_assign_DSA(res, dsatmp);
737 break;
738#endif
739
740 default:
741 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,ENGINE_R_FAILED_LOADING_PRIVATE_KEY);
742 goto err;
743 }
744 return res;
745 err:
746 if (res)
747 EVP_PKEY_free(res);
748#ifndef OPENSSL_NO_RSA
749 if (rsatmp)
750 RSA_free(rsatmp);
751#endif
752#ifndef OPENSSL_NO_DSA
753 if (dsatmp)
754 DSA_free(dsatmp);
755#endif
756 return NULL;
757}
758
759static EVP_PKEY *surewarehk_load_privkey(ENGINE *e, const char *key_id,
760 UI_METHOD *ui_method, void *callback_data)
761{
762 EVP_PKEY *res = NULL;
763 int ret=0;
764 unsigned long el=0;
765 char *hptr=NULL;
766 char keytype=0;
767 char msg[64]="ENGINE_load_privkey";
768
769 if(!p_surewarehk_Load_Privkey)
770 {
771 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,ENGINE_R_NOT_INITIALISED);
772 }
773 else
774 {
775 ret=p_surewarehk_Load_Privkey(msg,key_id,&hptr,&el,&keytype);
776 if (ret!=1)
777 {
778 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,ENGINE_R_FAILED_LOADING_PRIVATE_KEY);
779 ERR_add_error_data(1,msg);
780 }
781 else
782 res=sureware_load_public(e,key_id,hptr,el,keytype);
783 }
784 return res;
785}
786
787static EVP_PKEY *surewarehk_load_pubkey(ENGINE *e, const char *key_id,
788 UI_METHOD *ui_method, void *callback_data)
789{
790 EVP_PKEY *res = NULL;
791 int ret=0;
792 unsigned long el=0;
793 char *hptr=NULL;
794 char keytype=0;
795 char msg[64]="ENGINE_load_pubkey";
796
797 if(!p_surewarehk_Info_Pubkey)
798 {
799 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,ENGINE_R_NOT_INITIALISED);
800 }
801 else
802 {
803 /* call once to identify if DSA or RSA */
804 ret=p_surewarehk_Info_Pubkey(msg,key_id,&el,&keytype);
805 if (ret!=1)
806 {
807 SUREWAREerr(SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,ENGINE_R_FAILED_LOADING_PUBLIC_KEY);
808 ERR_add_error_data(1,msg);
809 }
810 else
811 res=sureware_load_public(e,key_id,hptr,el,keytype);
812 }
813 return res;
814}
815
816/* This cleans up an RSA/DSA KM key(do not destroy the key into the hardware)
817, called when ex_data is freed */
818static void surewarehk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
819 int idx,long argl, void *argp)
820{
821 if(!p_surewarehk_Free)
822 {
823 SUREWAREerr(SUREWARE_F_SUREWAREHK_EX_FREE,ENGINE_R_NOT_INITIALISED);
824 }
825 else
826 p_surewarehk_Free((char *)item,0);
827}
828
829#if 0
830/* This cleans up an DH KM key (destroys the key into hardware),
831called when ex_data is freed */
832static void surewarehk_dh_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
833 int idx,long argl, void *argp)
834{
835 if(!p_surewarehk_Free)
836 {
837 SUREWAREerr(SUREWARE_F_SUREWAREHK_EX_FREE,ENGINE_R_NOT_INITIALISED);
838 }
839 else
840 p_surewarehk_Free((char *)item,1);
841}
842#endif
843
844/*
845* return number of decrypted bytes
846*/
847#ifndef OPENSSL_NO_RSA
848static int surewarehk_rsa_priv_dec(int flen,const unsigned char *from,unsigned char *to,
849 RSA *rsa,int padding)
850{
851 int ret=0,tlen;
852 char *buf=NULL,*hptr=NULL;
853 char msg[64]="ENGINE_rsa_priv_dec";
854 if (!p_surewarehk_Rsa_Priv_Dec)
855 {
856 SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,ENGINE_R_NOT_INITIALISED);
857 }
858 /* extract ref to private key */
859 else if (!(hptr=RSA_get_ex_data(rsa, rsaHndidx)))
860 {
861 SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,SUREWARE_R_MISSING_KEY_COMPONENTS);
862 goto err;
863 }
864 /* analyse what padding we can do into the hardware */
865 if (padding==RSA_PKCS1_PADDING)
866 {
867 /* do it one shot */
868 ret=p_surewarehk_Rsa_Priv_Dec(msg,flen,(unsigned char *)from,&tlen,to,hptr,SUREWARE_PKCS1_PAD);
869 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,ret);
870 if (ret!=1)
871 goto err;
872 ret=tlen;
873 }
874 else /* do with no padding into hardware */
875 {
876 ret=p_surewarehk_Rsa_Priv_Dec(msg,flen,(unsigned char *)from,&tlen,to,hptr,SUREWARE_NO_PAD);
877 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,ret);
878 if (ret!=1)
879 goto err;
880 /* intermediate buffer for padding */
881 if ((buf=OPENSSL_malloc(tlen)) == NULL)
882 {
883 RSAerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,ERR_R_MALLOC_FAILURE);
884 goto err;
885 }
886 memcpy(buf,to,tlen);/* transfert to into buf */
887 switch (padding) /* check padding in software */
888 {
889#ifndef OPENSSL_NO_SHA
890 case RSA_PKCS1_OAEP_PADDING:
891 ret=RSA_padding_check_PKCS1_OAEP(to,tlen,(unsigned char *)buf,tlen,tlen,NULL,0);
892 break;
893#endif
894 case RSA_SSLV23_PADDING:
895 ret=RSA_padding_check_SSLv23(to,tlen,(unsigned char *)buf,flen,tlen);
896 break;
897 case RSA_NO_PADDING:
898 ret=RSA_padding_check_none(to,tlen,(unsigned char *)buf,flen,tlen);
899 break;
900 default:
901 RSAerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,RSA_R_UNKNOWN_PADDING_TYPE);
902 goto err;
903 }
904 if (ret < 0)
905 RSAerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,RSA_R_PADDING_CHECK_FAILED);
906 }
907err:
908 if (buf)
909 {
910 OPENSSL_cleanse(buf,tlen);
911 OPENSSL_free(buf);
912 }
913 return ret;
914}
915
916/*
917* Does what OpenSSL rsa_priv_enc does.
918*/
919static int surewarehk_rsa_sign(int flen,const unsigned char *from,unsigned char *to,
920 RSA *rsa,int padding)
921{
922 int ret=0,tlen;
923 char *hptr=NULL;
924 char msg[64]="ENGINE_rsa_sign";
925 if (!p_surewarehk_Rsa_Sign)
926 {
927 SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC,ENGINE_R_NOT_INITIALISED);
928 }
929 /* extract ref to private key */
930 else if (!(hptr=RSA_get_ex_data(rsa, rsaHndidx)))
931 {
932 SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC,SUREWARE_R_MISSING_KEY_COMPONENTS);
933 }
934 else
935 {
936 switch (padding)
937 {
938 case RSA_PKCS1_PADDING: /* do it in one shot */
939 ret=p_surewarehk_Rsa_Sign(msg,flen,(unsigned char *)from,&tlen,to,hptr,SUREWARE_PKCS1_PAD);
940 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC,ret);
941 break;
942 case RSA_NO_PADDING:
943 default:
944 RSAerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC,RSA_R_UNKNOWN_PADDING_TYPE);
945 }
946 }
947 return ret==1 ? tlen : ret;
948}
949
950#endif
951
952#ifndef OPENSSL_NO_DSA
953/* DSA sign and verify */
954static DSA_SIG * surewarehk_dsa_do_sign(const unsigned char *from, int flen, DSA *dsa)
955{
956 int ret=0;
957 char *hptr=NULL;
958 DSA_SIG *psign=NULL;
959 char msg[64]="ENGINE_dsa_do_sign";
960 if (!p_surewarehk_Dsa_Sign)
961 {
962 SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ENGINE_R_NOT_INITIALISED);
963 }
964 /* extract ref to private key */
965 else if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))
966 {
967 SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);
968 }
969 else
970 {
971 if((psign = DSA_SIG_new()) == NULL)
972 {
973 SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ERR_R_MALLOC_FAILURE);
974 goto err;
975 }
976 psign->r=BN_new();
977 psign->s=BN_new();
978 bn_expand2(psign->r, 20/sizeof(BN_ULONG));
979 bn_expand2(psign->s, 20/sizeof(BN_ULONG));
980 if (!psign->r || psign->r->dmax!=20/sizeof(BN_ULONG) ||
981 !psign->s || psign->s->dmax!=20/sizeof(BN_ULONG))
982 goto err;
983 ret=p_surewarehk_Dsa_Sign(msg,flen,from,
984 (unsigned long *)psign->r->d,
985 (unsigned long *)psign->s->d,
986 hptr);
987 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ret);
988 }
989 psign->r->top=20/sizeof(BN_ULONG);
990 bn_fix_top(psign->r);
991 psign->s->top=20/sizeof(BN_ULONG);
992 bn_fix_top(psign->s);
993
994err:
995 if (psign)
996 {
997 DSA_SIG_free(psign);
998 psign=NULL;
999 }
1000 return psign;
1001}
1002#endif
1003
1004static int surewarehk_modexp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
1005 const BIGNUM *m, BN_CTX *ctx)
1006{
1007 int ret=0;
1008 char msg[64]="ENGINE_modexp";
1009 if (!p_surewarehk_Mod_Exp)
1010 {
1011 SUREWAREerr(SUREWARE_F_SUREWAREHK_MOD_EXP,ENGINE_R_NOT_INITIALISED);
1012 }
1013 else
1014 {
1015 bn_expand2(r,m->top);
1016 if (r && r->dmax==m->top)
1017 {
1018 /* do it*/
1019 ret=p_surewarehk_Mod_Exp(msg,
1020 m->top*sizeof(BN_ULONG),
1021 (unsigned long *)m->d,
1022 p->top*sizeof(BN_ULONG),
1023 (unsigned long *)p->d,
1024 a->top*sizeof(BN_ULONG),
1025 (unsigned long *)a->d,
1026 (unsigned long *)r->d);
1027 surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_MOD_EXP,ret);
1028 if (ret==1)
1029 {
1030 /* normalise result */
1031 r->top=m->top;
1032 bn_fix_top(r);
1033 }
1034 }
1035 }
1036 return ret;
1037}
1038#endif /* !OPENSSL_NO_HW_SureWare */
1039#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_sureware_err.c b/src/lib/libcrypto/engine/hw_sureware_err.c
deleted file mode 100644
index 69955dadbb..0000000000
--- a/src/lib/libcrypto/engine/hw_sureware_err.c
+++ /dev/null
@@ -1,150 +0,0 @@
1/* hw_sureware_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_sureware_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA SUREWARE_str_functs[]=
68 {
69{ERR_PACK(0,SUREWARE_F_SUREWAREHK_CTRL,0), "SUREWAREHK_CTRL"},
70{ERR_PACK(0,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,0), "SUREWAREHK_DSA_DO_SIGN"},
71{ERR_PACK(0,SUREWARE_F_SUREWAREHK_EX_FREE,0), "SUREWAREHK_EX_FREE"},
72{ERR_PACK(0,SUREWARE_F_SUREWAREHK_FINISH,0), "SUREWAREHK_FINISH"},
73{ERR_PACK(0,SUREWARE_F_SUREWAREHK_INIT,0), "SUREWAREHK_INIT"},
74{ERR_PACK(0,SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY,0), "SUREWAREHK_LOAD_PRIVATE_KEY"},
75{ERR_PACK(0,SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY,0), "SUREWAREHK_LOAD_PUBLIC_KEY"},
76{ERR_PACK(0,SUREWARE_F_SUREWAREHK_MOD_EXP,0), "SUREWAREHK_MOD_EXP"},
77{ERR_PACK(0,SUREWARE_F_SUREWAREHK_RAND_BYTES,0), "SUREWAREHK_RAND_BYTES"},
78{ERR_PACK(0,SUREWARE_F_SUREWAREHK_RAND_SEED,0), "SUREWAREHK_RAND_SEED"},
79{ERR_PACK(0,SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,0), "SUREWAREHK_RSA_PRIV_DEC"},
80{ERR_PACK(0,SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC,0), "SUREWAREHK_RSA_PRIV_ENC"},
81{0,NULL}
82 };
83
84static ERR_STRING_DATA SUREWARE_str_reasons[]=
85 {
86{SUREWARE_R_BIO_WAS_FREED ,"bio was freed"},
87{SUREWARE_R_MISSING_KEY_COMPONENTS ,"missing key components"},
88{SUREWARE_R_REQUEST_FAILED ,"request failed"},
89{SUREWARE_R_REQUEST_FALLBACK ,"request fallback"},
90{SUREWARE_R_SIZE_TOO_LARGE_OR_TOO_SMALL ,"size too large or too small"},
91{SUREWARE_R_UNIT_FAILURE ,"unit failure"},
92{0,NULL}
93 };
94
95#endif
96
97#ifdef SUREWARE_LIB_NAME
98static ERR_STRING_DATA SUREWARE_lib_name[]=
99 {
100{0 ,SUREWARE_LIB_NAME},
101{0,NULL}
102 };
103#endif
104
105
106static int SUREWARE_lib_error_code=0;
107static int SUREWARE_error_init=1;
108
109static void ERR_load_SUREWARE_strings(void)
110 {
111 if (SUREWARE_lib_error_code == 0)
112 SUREWARE_lib_error_code=ERR_get_next_error_library();
113
114 if (SUREWARE_error_init)
115 {
116 SUREWARE_error_init=0;
117#ifndef OPENSSL_NO_ERR
118 ERR_load_strings(SUREWARE_lib_error_code,SUREWARE_str_functs);
119 ERR_load_strings(SUREWARE_lib_error_code,SUREWARE_str_reasons);
120#endif
121
122#ifdef SUREWARE_LIB_NAME
123 SUREWARE_lib_name->error = ERR_PACK(SUREWARE_lib_error_code,0,0);
124 ERR_load_strings(0,SUREWARE_lib_name);
125#endif
126 }
127 }
128
129static void ERR_unload_SUREWARE_strings(void)
130 {
131 if (SUREWARE_error_init == 0)
132 {
133#ifndef OPENSSL_NO_ERR
134 ERR_unload_strings(SUREWARE_lib_error_code,SUREWARE_str_functs);
135 ERR_unload_strings(SUREWARE_lib_error_code,SUREWARE_str_reasons);
136#endif
137
138#ifdef SUREWARE_LIB_NAME
139 ERR_unload_strings(0,SUREWARE_lib_name);
140#endif
141 SUREWARE_error_init=1;
142 }
143 }
144
145static void ERR_SUREWARE_error(int function, int reason, char *file, int line)
146 {
147 if (SUREWARE_lib_error_code == 0)
148 SUREWARE_lib_error_code=ERR_get_next_error_library();
149 ERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);
150 }
diff --git a/src/lib/libcrypto/engine/hw_sureware_err.h b/src/lib/libcrypto/engine/hw_sureware_err.h
deleted file mode 100644
index bc52af5e05..0000000000
--- a/src/lib/libcrypto/engine/hw_sureware_err.h
+++ /dev/null
@@ -1,94 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. 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 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the OpenSSL Project
19 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
20 *
21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
24 * openssl-core@openssl.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_SUREWARE_ERR_H
56#define HEADER_SUREWARE_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_SUREWARE_strings(void);
63static void ERR_unload_SUREWARE_strings(void);
64static void ERR_SUREWARE_error(int function, int reason, char *file, int line);
65#define SUREWAREerr(f,r) ERR_SUREWARE_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the SUREWARE functions. */
68
69/* Function codes. */
70#define SUREWARE_F_SUREWAREHK_CTRL 100
71#define SUREWARE_F_SUREWAREHK_DSA_DO_SIGN 101
72#define SUREWARE_F_SUREWAREHK_EX_FREE 102
73#define SUREWARE_F_SUREWAREHK_FINISH 103
74#define SUREWARE_F_SUREWAREHK_INIT 104
75#define SUREWARE_F_SUREWAREHK_LOAD_PRIVATE_KEY 105
76#define SUREWARE_F_SUREWAREHK_LOAD_PUBLIC_KEY 106
77#define SUREWARE_F_SUREWAREHK_MOD_EXP 107
78#define SUREWARE_F_SUREWAREHK_RAND_BYTES 108
79#define SUREWARE_F_SUREWAREHK_RAND_SEED 109
80#define SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC 110
81#define SUREWARE_F_SUREWAREHK_RSA_PRIV_ENC 111
82
83/* Reason codes. */
84#define SUREWARE_R_BIO_WAS_FREED 100
85#define SUREWARE_R_MISSING_KEY_COMPONENTS 105
86#define SUREWARE_R_REQUEST_FAILED 101
87#define SUREWARE_R_REQUEST_FALLBACK 102
88#define SUREWARE_R_SIZE_TOO_LARGE_OR_TOO_SMALL 103
89#define SUREWARE_R_UNIT_FAILURE 104
90
91#ifdef __cplusplus
92}
93#endif
94#endif
diff --git a/src/lib/libcrypto/engine/hw_ubsec.c b/src/lib/libcrypto/engine/hw_ubsec.c
deleted file mode 100644
index 8fb834af31..0000000000
--- a/src/lib/libcrypto/engine/hw_ubsec.c
+++ /dev/null
@@ -1,1061 +0,0 @@
1/* crypto/engine/hw_ubsec.c */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000.
4 *
5 * Cloned shamelessly by Joe Tardo.
6 */
7/* ====================================================================
8 * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
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 *
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 *
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 *
22 * 3. All advertising materials mentioning features or use of this
23 * software must display the following acknowledgment:
24 * "This product includes software developed by the OpenSSL Project
25 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
26 *
27 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
28 * endorse or promote products derived from this software without
29 * prior written permission. For written permission, please contact
30 * licensing@OpenSSL.org.
31 *
32 * 5. Products derived from this software may not be called "OpenSSL"
33 * nor may "OpenSSL" appear in their names without prior written
34 * permission of the OpenSSL Project.
35 *
36 * 6. Redistributions of any form whatsoever must retain the following
37 * acknowledgment:
38 * "This product includes software developed by the OpenSSL Project
39 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
42 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
45 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52 * OF THE POSSIBILITY OF SUCH DAMAGE.
53 * ====================================================================
54 *
55 * This product includes cryptographic software written by Eric Young
56 * (eay@cryptsoft.com). This product includes software written by Tim
57 * Hudson (tjh@cryptsoft.com).
58 *
59 */
60
61#include <stdio.h>
62#include <openssl/crypto.h>
63#include "cryptlib.h"
64#include <openssl/dso.h>
65#include <openssl/engine.h>
66
67#ifndef OPENSSL_NO_HW
68#ifndef OPENSSL_NO_HW_UBSEC
69
70#ifdef FLAT_INC
71#include "hw_ubsec.h"
72#else
73#include "vendor_defns/hw_ubsec.h"
74#endif
75
76#define UBSEC_LIB_NAME "ubsec engine"
77#include "hw_ubsec_err.c"
78
79#define FAIL_TO_SOFTWARE -15
80
81static int ubsec_destroy(ENGINE *e);
82static int ubsec_init(ENGINE *e);
83static int ubsec_finish(ENGINE *e);
84static int ubsec_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
85static int ubsec_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
86 const BIGNUM *m, BN_CTX *ctx);
87static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
88 const BIGNUM *q, const BIGNUM *dp,
89 const BIGNUM *dq, const BIGNUM *qinv, BN_CTX *ctx);
90#ifndef OPENSSL_NO_RSA
91static int ubsec_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
92#endif
93static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
94 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
95#ifndef OPENSSL_NO_DSA
96#ifdef NOT_USED
97static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
98 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
99 BN_CTX *ctx, BN_MONT_CTX *in_mont);
100static int ubsec_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
101 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
102 BN_MONT_CTX *m_ctx);
103#endif
104static DSA_SIG *ubsec_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa);
105static int ubsec_dsa_verify(const unsigned char *dgst, int dgst_len,
106 DSA_SIG *sig, DSA *dsa);
107#endif
108#ifndef OPENSSL_NO_DH
109static int ubsec_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
110 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
111 BN_MONT_CTX *m_ctx);
112static int ubsec_dh_compute_key(unsigned char *key,const BIGNUM *pub_key,DH *dh);
113static int ubsec_dh_generate_key(DH *dh);
114#endif
115
116#ifdef NOT_USED
117static int ubsec_rand_bytes(unsigned char *buf, int num);
118static int ubsec_rand_status(void);
119#endif
120
121#define UBSEC_CMD_SO_PATH ENGINE_CMD_BASE
122static const ENGINE_CMD_DEFN ubsec_cmd_defns[] = {
123 {UBSEC_CMD_SO_PATH,
124 "SO_PATH",
125 "Specifies the path to the 'ubsec' shared library",
126 ENGINE_CMD_FLAG_STRING},
127 {0, NULL, NULL, 0}
128 };
129
130#ifndef OPENSSL_NO_RSA
131/* Our internal RSA_METHOD that we provide pointers to */
132static RSA_METHOD ubsec_rsa =
133 {
134 "UBSEC RSA method",
135 NULL,
136 NULL,
137 NULL,
138 NULL,
139 ubsec_rsa_mod_exp,
140 ubsec_mod_exp_mont,
141 NULL,
142 NULL,
143 0,
144 NULL,
145 NULL,
146 NULL
147 };
148#endif
149
150#ifndef OPENSSL_NO_DSA
151/* Our internal DSA_METHOD that we provide pointers to */
152static DSA_METHOD ubsec_dsa =
153 {
154 "UBSEC DSA method",
155 ubsec_dsa_do_sign, /* dsa_do_sign */
156 NULL, /* dsa_sign_setup */
157 ubsec_dsa_verify, /* dsa_do_verify */
158 NULL, /* ubsec_dsa_mod_exp */ /* dsa_mod_exp */
159 NULL, /* ubsec_mod_exp_dsa */ /* bn_mod_exp */
160 NULL, /* init */
161 NULL, /* finish */
162 0, /* flags */
163 NULL /* app_data */
164 };
165#endif
166
167#ifndef OPENSSL_NO_DH
168/* Our internal DH_METHOD that we provide pointers to */
169static DH_METHOD ubsec_dh =
170 {
171 "UBSEC DH method",
172 ubsec_dh_generate_key,
173 ubsec_dh_compute_key,
174 ubsec_mod_exp_dh,
175 NULL,
176 NULL,
177 0,
178 NULL
179 };
180#endif
181
182/* Constants used when creating the ENGINE */
183static const char *engine_ubsec_id = "ubsec";
184static const char *engine_ubsec_name = "UBSEC hardware engine support";
185
186/* This internal function is used by ENGINE_ubsec() and possibly by the
187 * "dynamic" ENGINE support too */
188static int bind_helper(ENGINE *e)
189 {
190#ifndef OPENSSL_NO_RSA
191 const RSA_METHOD *meth1;
192#endif
193#ifndef OPENSSL_NO_DH
194#ifndef HAVE_UBSEC_DH
195 const DH_METHOD *meth3;
196#endif /* HAVE_UBSEC_DH */
197#endif
198 if(!ENGINE_set_id(e, engine_ubsec_id) ||
199 !ENGINE_set_name(e, engine_ubsec_name) ||
200#ifndef OPENSSL_NO_RSA
201 !ENGINE_set_RSA(e, &ubsec_rsa) ||
202#endif
203#ifndef OPENSSL_NO_DSA
204 !ENGINE_set_DSA(e, &ubsec_dsa) ||
205#endif
206#ifndef OPENSSL_NO_DH
207 !ENGINE_set_DH(e, &ubsec_dh) ||
208#endif
209 !ENGINE_set_destroy_function(e, ubsec_destroy) ||
210 !ENGINE_set_init_function(e, ubsec_init) ||
211 !ENGINE_set_finish_function(e, ubsec_finish) ||
212 !ENGINE_set_ctrl_function(e, ubsec_ctrl) ||
213 !ENGINE_set_cmd_defns(e, ubsec_cmd_defns))
214 return 0;
215
216#ifndef OPENSSL_NO_RSA
217 /* We know that the "PKCS1_SSLeay()" functions hook properly
218 * to the Broadcom-specific mod_exp and mod_exp_crt so we use
219 * those functions. NB: We don't use ENGINE_openssl() or
220 * anything "more generic" because something like the RSAref
221 * code may not hook properly, and if you own one of these
222 * cards then you have the right to do RSA operations on it
223 * anyway! */
224 meth1 = RSA_PKCS1_SSLeay();
225 ubsec_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
226 ubsec_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
227 ubsec_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
228 ubsec_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
229#endif
230
231#ifndef OPENSSL_NO_DH
232#ifndef HAVE_UBSEC_DH
233 /* Much the same for Diffie-Hellman */
234 meth3 = DH_OpenSSL();
235 ubsec_dh.generate_key = meth3->generate_key;
236 ubsec_dh.compute_key = meth3->compute_key;
237#endif /* HAVE_UBSEC_DH */
238#endif
239
240 /* Ensure the ubsec error handling is set up */
241 ERR_load_UBSEC_strings();
242 return 1;
243 }
244
245#ifndef ENGINE_DYNAMIC_SUPPORT
246static ENGINE *engine_ubsec(void)
247 {
248 ENGINE *ret = ENGINE_new();
249 if(!ret)
250 return NULL;
251 if(!bind_helper(ret))
252 {
253 ENGINE_free(ret);
254 return NULL;
255 }
256 return ret;
257 }
258
259void ENGINE_load_ubsec(void)
260 {
261 /* Copied from eng_[openssl|dyn].c */
262 ENGINE *toadd = engine_ubsec();
263 if(!toadd) return;
264 ENGINE_add(toadd);
265 ENGINE_free(toadd);
266 ERR_clear_error();
267 }
268#endif
269
270/* This is a process-global DSO handle used for loading and unloading
271 * the UBSEC library. NB: This is only set (or unset) during an
272 * init() or finish() call (reference counts permitting) and they're
273 * operating with global locks, so this should be thread-safe
274 * implicitly. */
275
276static DSO *ubsec_dso = NULL;
277
278/* These are the function pointers that are (un)set when the library has
279 * successfully (un)loaded. */
280
281static t_UBSEC_ubsec_bytes_to_bits *p_UBSEC_ubsec_bytes_to_bits = NULL;
282static t_UBSEC_ubsec_bits_to_bytes *p_UBSEC_ubsec_bits_to_bytes = NULL;
283static t_UBSEC_ubsec_open *p_UBSEC_ubsec_open = NULL;
284static t_UBSEC_ubsec_close *p_UBSEC_ubsec_close = NULL;
285#ifndef OPENSSL_NO_DH
286static t_UBSEC_diffie_hellman_generate_ioctl
287 *p_UBSEC_diffie_hellman_generate_ioctl = NULL;
288static t_UBSEC_diffie_hellman_agree_ioctl *p_UBSEC_diffie_hellman_agree_ioctl = NULL;
289#endif
290/* #ifndef OPENSSL_NO_RSA */
291static t_UBSEC_rsa_mod_exp_ioctl *p_UBSEC_rsa_mod_exp_ioctl = NULL;
292static t_UBSEC_rsa_mod_exp_crt_ioctl *p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
293/* #endif */
294#ifndef OPENSSL_NO_DSA
295static t_UBSEC_dsa_sign_ioctl *p_UBSEC_dsa_sign_ioctl = NULL;
296static t_UBSEC_dsa_verify_ioctl *p_UBSEC_dsa_verify_ioctl = NULL;
297#endif
298static t_UBSEC_math_accelerate_ioctl *p_UBSEC_math_accelerate_ioctl = NULL;
299static t_UBSEC_rng_ioctl *p_UBSEC_rng_ioctl = NULL;
300static t_UBSEC_max_key_len_ioctl *p_UBSEC_max_key_len_ioctl = NULL;
301
302static int max_key_len = 1024; /* ??? */
303
304/*
305 * These are the static string constants for the DSO file name and the function
306 * symbol names to bind to.
307 */
308
309static const char *UBSEC_LIBNAME = NULL;
310static const char *get_UBSEC_LIBNAME(void)
311 {
312 if(UBSEC_LIBNAME)
313 return UBSEC_LIBNAME;
314 return "ubsec";
315 }
316static void free_UBSEC_LIBNAME(void)
317 {
318 if(UBSEC_LIBNAME)
319 OPENSSL_free((void*)UBSEC_LIBNAME);
320 UBSEC_LIBNAME = NULL;
321 }
322static long set_UBSEC_LIBNAME(const char *name)
323 {
324 free_UBSEC_LIBNAME();
325 return (((UBSEC_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
326 }
327static const char *UBSEC_F1 = "ubsec_bytes_to_bits";
328static const char *UBSEC_F2 = "ubsec_bits_to_bytes";
329static const char *UBSEC_F3 = "ubsec_open";
330static const char *UBSEC_F4 = "ubsec_close";
331#ifndef OPENSSL_NO_DH
332static const char *UBSEC_F5 = "diffie_hellman_generate_ioctl";
333static const char *UBSEC_F6 = "diffie_hellman_agree_ioctl";
334#endif
335/* #ifndef OPENSSL_NO_RSA */
336static const char *UBSEC_F7 = "rsa_mod_exp_ioctl";
337static const char *UBSEC_F8 = "rsa_mod_exp_crt_ioctl";
338/* #endif */
339#ifndef OPENSSL_NO_DSA
340static const char *UBSEC_F9 = "dsa_sign_ioctl";
341static const char *UBSEC_F10 = "dsa_verify_ioctl";
342#endif
343static const char *UBSEC_F11 = "math_accelerate_ioctl";
344static const char *UBSEC_F12 = "rng_ioctl";
345static const char *UBSEC_F13 = "ubsec_max_key_len_ioctl";
346
347/* Destructor (complements the "ENGINE_ubsec()" constructor) */
348static int ubsec_destroy(ENGINE *e)
349 {
350 free_UBSEC_LIBNAME();
351 ERR_unload_UBSEC_strings();
352 return 1;
353 }
354
355/* (de)initialisation functions. */
356static int ubsec_init(ENGINE *e)
357 {
358 t_UBSEC_ubsec_bytes_to_bits *p1;
359 t_UBSEC_ubsec_bits_to_bytes *p2;
360 t_UBSEC_ubsec_open *p3;
361 t_UBSEC_ubsec_close *p4;
362#ifndef OPENSSL_NO_DH
363 t_UBSEC_diffie_hellman_generate_ioctl *p5;
364 t_UBSEC_diffie_hellman_agree_ioctl *p6;
365#endif
366/* #ifndef OPENSSL_NO_RSA */
367 t_UBSEC_rsa_mod_exp_ioctl *p7;
368 t_UBSEC_rsa_mod_exp_crt_ioctl *p8;
369/* #endif */
370#ifndef OPENSSL_NO_DSA
371 t_UBSEC_dsa_sign_ioctl *p9;
372 t_UBSEC_dsa_verify_ioctl *p10;
373#endif
374 t_UBSEC_math_accelerate_ioctl *p11;
375 t_UBSEC_rng_ioctl *p12;
376 t_UBSEC_max_key_len_ioctl *p13;
377 int fd = 0;
378
379 if(ubsec_dso != NULL)
380 {
381 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_ALREADY_LOADED);
382 goto err;
383 }
384 /*
385 * Attempt to load libubsec.so/ubsec.dll/whatever.
386 */
387 ubsec_dso = DSO_load(NULL, get_UBSEC_LIBNAME(), NULL, 0);
388 if(ubsec_dso == NULL)
389 {
390 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE);
391 goto err;
392 }
393
394 if (
395 !(p1 = (t_UBSEC_ubsec_bytes_to_bits *) DSO_bind_func(ubsec_dso, UBSEC_F1)) ||
396 !(p2 = (t_UBSEC_ubsec_bits_to_bytes *) DSO_bind_func(ubsec_dso, UBSEC_F2)) ||
397 !(p3 = (t_UBSEC_ubsec_open *) DSO_bind_func(ubsec_dso, UBSEC_F3)) ||
398 !(p4 = (t_UBSEC_ubsec_close *) DSO_bind_func(ubsec_dso, UBSEC_F4)) ||
399#ifndef OPENSSL_NO_DH
400 !(p5 = (t_UBSEC_diffie_hellman_generate_ioctl *)
401 DSO_bind_func(ubsec_dso, UBSEC_F5)) ||
402 !(p6 = (t_UBSEC_diffie_hellman_agree_ioctl *)
403 DSO_bind_func(ubsec_dso, UBSEC_F6)) ||
404#endif
405/* #ifndef OPENSSL_NO_RSA */
406 !(p7 = (t_UBSEC_rsa_mod_exp_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F7)) ||
407 !(p8 = (t_UBSEC_rsa_mod_exp_crt_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F8)) ||
408/* #endif */
409#ifndef OPENSSL_NO_DSA
410 !(p9 = (t_UBSEC_dsa_sign_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F9)) ||
411 !(p10 = (t_UBSEC_dsa_verify_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F10)) ||
412#endif
413 !(p11 = (t_UBSEC_math_accelerate_ioctl *)
414 DSO_bind_func(ubsec_dso, UBSEC_F11)) ||
415 !(p12 = (t_UBSEC_rng_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F12)) ||
416 !(p13 = (t_UBSEC_max_key_len_ioctl *) DSO_bind_func(ubsec_dso, UBSEC_F13)))
417 {
418 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE);
419 goto err;
420 }
421
422 /* Copy the pointers */
423 p_UBSEC_ubsec_bytes_to_bits = p1;
424 p_UBSEC_ubsec_bits_to_bytes = p2;
425 p_UBSEC_ubsec_open = p3;
426 p_UBSEC_ubsec_close = p4;
427#ifndef OPENSSL_NO_DH
428 p_UBSEC_diffie_hellman_generate_ioctl = p5;
429 p_UBSEC_diffie_hellman_agree_ioctl = p6;
430#endif
431#ifndef OPENSSL_NO_RSA
432 p_UBSEC_rsa_mod_exp_ioctl = p7;
433 p_UBSEC_rsa_mod_exp_crt_ioctl = p8;
434#endif
435#ifndef OPENSSL_NO_DSA
436 p_UBSEC_dsa_sign_ioctl = p9;
437 p_UBSEC_dsa_verify_ioctl = p10;
438#endif
439 p_UBSEC_math_accelerate_ioctl = p11;
440 p_UBSEC_rng_ioctl = p12;
441 p_UBSEC_max_key_len_ioctl = p13;
442
443 /* Perform an open to see if there's actually any unit running. */
444 if (((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) > 0) && (p_UBSEC_max_key_len_ioctl(fd, &max_key_len) == 0))
445 {
446 p_UBSEC_ubsec_close(fd);
447 return 1;
448 }
449 else
450 {
451 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
452 }
453
454err:
455 if(ubsec_dso)
456 DSO_free(ubsec_dso);
457 ubsec_dso = NULL;
458 p_UBSEC_ubsec_bytes_to_bits = NULL;
459 p_UBSEC_ubsec_bits_to_bytes = NULL;
460 p_UBSEC_ubsec_open = NULL;
461 p_UBSEC_ubsec_close = NULL;
462#ifndef OPENSSL_NO_DH
463 p_UBSEC_diffie_hellman_generate_ioctl = NULL;
464 p_UBSEC_diffie_hellman_agree_ioctl = NULL;
465#endif
466#ifndef OPENSSL_NO_RSA
467 p_UBSEC_rsa_mod_exp_ioctl = NULL;
468 p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
469#endif
470#ifndef OPENSSL_NO_DSA
471 p_UBSEC_dsa_sign_ioctl = NULL;
472 p_UBSEC_dsa_verify_ioctl = NULL;
473#endif
474 p_UBSEC_math_accelerate_ioctl = NULL;
475 p_UBSEC_rng_ioctl = NULL;
476 p_UBSEC_max_key_len_ioctl = NULL;
477
478 return 0;
479 }
480
481static int ubsec_finish(ENGINE *e)
482 {
483 free_UBSEC_LIBNAME();
484 if(ubsec_dso == NULL)
485 {
486 UBSECerr(UBSEC_F_UBSEC_FINISH, UBSEC_R_NOT_LOADED);
487 return 0;
488 }
489 if(!DSO_free(ubsec_dso))
490 {
491 UBSECerr(UBSEC_F_UBSEC_FINISH, UBSEC_R_DSO_FAILURE);
492 return 0;
493 }
494 ubsec_dso = NULL;
495 p_UBSEC_ubsec_bytes_to_bits = NULL;
496 p_UBSEC_ubsec_bits_to_bytes = NULL;
497 p_UBSEC_ubsec_open = NULL;
498 p_UBSEC_ubsec_close = NULL;
499#ifndef OPENSSL_NO_DH
500 p_UBSEC_diffie_hellman_generate_ioctl = NULL;
501 p_UBSEC_diffie_hellman_agree_ioctl = NULL;
502#endif
503#ifndef OPENSSL_NO_RSA
504 p_UBSEC_rsa_mod_exp_ioctl = NULL;
505 p_UBSEC_rsa_mod_exp_crt_ioctl = NULL;
506#endif
507#ifndef OPENSSL_NO_DSA
508 p_UBSEC_dsa_sign_ioctl = NULL;
509 p_UBSEC_dsa_verify_ioctl = NULL;
510#endif
511 p_UBSEC_math_accelerate_ioctl = NULL;
512 p_UBSEC_rng_ioctl = NULL;
513 p_UBSEC_max_key_len_ioctl = NULL;
514 return 1;
515 }
516
517static int ubsec_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
518 {
519 int initialised = ((ubsec_dso == NULL) ? 0 : 1);
520 switch(cmd)
521 {
522 case UBSEC_CMD_SO_PATH:
523 if(p == NULL)
524 {
525 UBSECerr(UBSEC_F_UBSEC_CTRL,ERR_R_PASSED_NULL_PARAMETER);
526 return 0;
527 }
528 if(initialised)
529 {
530 UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_ALREADY_LOADED);
531 return 0;
532 }
533 return set_UBSEC_LIBNAME((const char *)p);
534 default:
535 break;
536 }
537 UBSECerr(UBSEC_F_UBSEC_CTRL,UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED);
538 return 0;
539 }
540
541static int ubsec_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
542 const BIGNUM *m, BN_CTX *ctx)
543 {
544 int y_len = 0;
545 int fd;
546
547 if(ubsec_dso == NULL)
548 {
549 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_NOT_LOADED);
550 return 0;
551 }
552
553 /* Check if hardware can't handle this argument. */
554 y_len = BN_num_bits(m);
555 if (y_len > max_key_len) {
556 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
557 return BN_mod_exp(r, a, p, m, ctx);
558 }
559
560 if(!bn_wexpand(r, m->top))
561 {
562 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_BN_EXPAND_FAIL);
563 return 0;
564 }
565
566 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
567 fd = 0;
568 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
569 return BN_mod_exp(r, a, p, m, ctx);
570 }
571
572 if (p_UBSEC_rsa_mod_exp_ioctl(fd, (unsigned char *)a->d, BN_num_bits(a),
573 (unsigned char *)m->d, BN_num_bits(m), (unsigned char *)p->d,
574 BN_num_bits(p), (unsigned char *)r->d, &y_len) != 0)
575 {
576 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_REQUEST_FAILED);
577 p_UBSEC_ubsec_close(fd);
578
579 return BN_mod_exp(r, a, p, m, ctx);
580 }
581
582 p_UBSEC_ubsec_close(fd);
583
584 r->top = (BN_num_bits(m)+BN_BITS2-1)/BN_BITS2;
585 return 1;
586 }
587
588#ifndef OPENSSL_NO_RSA
589static int ubsec_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
590 {
591 BN_CTX *ctx;
592 int to_return = 0;
593
594 if((ctx = BN_CTX_new()) == NULL)
595 goto err;
596
597 if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
598 {
599 UBSECerr(UBSEC_F_UBSEC_RSA_MOD_EXP, UBSEC_R_MISSING_KEY_COMPONENTS);
600 goto err;
601 }
602
603 to_return = ubsec_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
604 rsa->dmq1, rsa->iqmp, ctx);
605 if (to_return == FAIL_TO_SOFTWARE)
606 {
607 /*
608 * Do in software as hardware failed.
609 */
610 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
611 to_return = (*meth->rsa_mod_exp)(r0, I, rsa);
612 }
613err:
614 if(ctx)
615 BN_CTX_free(ctx);
616 return to_return;
617 }
618#endif
619
620static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
621 const BIGNUM *q, const BIGNUM *dp,
622 const BIGNUM *dq, const BIGNUM *qinv, BN_CTX *ctx)
623 {
624 int y_len,
625 m_len,
626 fd;
627
628 m_len = BN_num_bytes(p) + BN_num_bytes(q) + 1;
629 y_len = BN_num_bits(p) + BN_num_bits(q);
630
631 /* Check if hardware can't handle this argument. */
632 if (y_len > max_key_len) {
633 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
634 return FAIL_TO_SOFTWARE;
635 }
636
637 if (!bn_wexpand(r, p->top + q->top + 1)) {
638 UBSECerr(UBSEC_F_UBSEC_RSA_MOD_EXP_CRT, UBSEC_R_BN_EXPAND_FAIL);
639 return 0;
640 }
641
642 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
643 fd = 0;
644 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
645 return FAIL_TO_SOFTWARE;
646 }
647
648 if (p_UBSEC_rsa_mod_exp_crt_ioctl(fd,
649 (unsigned char *)a->d, BN_num_bits(a),
650 (unsigned char *)qinv->d, BN_num_bits(qinv),
651 (unsigned char *)dp->d, BN_num_bits(dp),
652 (unsigned char *)p->d, BN_num_bits(p),
653 (unsigned char *)dq->d, BN_num_bits(dq),
654 (unsigned char *)q->d, BN_num_bits(q),
655 (unsigned char *)r->d, &y_len) != 0) {
656 UBSECerr(UBSEC_F_UBSEC_MOD_EXP, UBSEC_R_REQUEST_FAILED);
657 p_UBSEC_ubsec_close(fd);
658 return FAIL_TO_SOFTWARE;
659 }
660
661 p_UBSEC_ubsec_close(fd);
662
663 r->top = (BN_num_bits(p) + BN_num_bits(q) + BN_BITS2 - 1)/BN_BITS2;
664 return 1;
665}
666
667#ifndef OPENSSL_NO_DSA
668#ifdef NOT_USED
669static int ubsec_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
670 BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
671 BN_CTX *ctx, BN_MONT_CTX *in_mont)
672 {
673 BIGNUM t;
674 int to_return = 0;
675
676 BN_init(&t);
677 /* let rr = a1 ^ p1 mod m */
678 if (!ubsec_mod_exp(rr,a1,p1,m,ctx)) goto end;
679 /* let t = a2 ^ p2 mod m */
680 if (!ubsec_mod_exp(&t,a2,p2,m,ctx)) goto end;
681 /* let rr = rr * t mod m */
682 if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
683 to_return = 1;
684end:
685 BN_free(&t);
686 return to_return;
687 }
688
689static int ubsec_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
690 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
691 BN_MONT_CTX *m_ctx)
692 {
693 return ubsec_mod_exp(r, a, p, m, ctx);
694 }
695#endif
696#endif
697
698/*
699 * This function is aliased to mod_exp (with the mont stuff dropped).
700 */
701static int ubsec_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
702 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
703 {
704 int ret = 0;
705
706#ifndef OPENSSL_NO_RSA
707 /* Do in software if the key is too large for the hardware. */
708 if (BN_num_bits(m) > max_key_len)
709 {
710 const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
711 ret = (*meth->bn_mod_exp)(r, a, p, m, ctx, m_ctx);
712 }
713 else
714#endif
715 {
716 ret = ubsec_mod_exp(r, a, p, m, ctx);
717 }
718
719 return ret;
720 }
721
722#ifndef OPENSSL_NO_DH
723/* This function is aliased to mod_exp (with the dh and mont dropped). */
724static int ubsec_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
725 const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
726 BN_MONT_CTX *m_ctx)
727 {
728 return ubsec_mod_exp(r, a, p, m, ctx);
729 }
730#endif
731
732#ifndef OPENSSL_NO_DSA
733static DSA_SIG *ubsec_dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
734 {
735 DSA_SIG *to_return = NULL;
736 int s_len = 160, r_len = 160, d_len, fd;
737 BIGNUM m, *r=NULL, *s=NULL;
738
739 BN_init(&m);
740
741 s = BN_new();
742 r = BN_new();
743 if ((s == NULL) || (r==NULL))
744 goto err;
745
746 d_len = p_UBSEC_ubsec_bytes_to_bits((unsigned char *)dgst, dlen);
747
748 if(!bn_wexpand(r, (160+BN_BITS2-1)/BN_BITS2) ||
749 (!bn_wexpand(s, (160+BN_BITS2-1)/BN_BITS2))) {
750 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
751 goto err;
752 }
753
754 if (BN_bin2bn(dgst,dlen,&m) == NULL) {
755 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
756 goto err;
757 }
758
759 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
760 const DSA_METHOD *meth;
761 fd = 0;
762 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
763 meth = DSA_OpenSSL();
764 to_return = meth->dsa_do_sign(dgst, dlen, dsa);
765 goto err;
766 }
767
768 if (p_UBSEC_dsa_sign_ioctl(fd, 0, /* compute hash before signing */
769 (unsigned char *)dgst, d_len,
770 NULL, 0, /* compute random value */
771 (unsigned char *)dsa->p->d, BN_num_bits(dsa->p),
772 (unsigned char *)dsa->q->d, BN_num_bits(dsa->q),
773 (unsigned char *)dsa->g->d, BN_num_bits(dsa->g),
774 (unsigned char *)dsa->priv_key->d, BN_num_bits(dsa->priv_key),
775 (unsigned char *)r->d, &r_len,
776 (unsigned char *)s->d, &s_len ) != 0) {
777 const DSA_METHOD *meth;
778
779 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_REQUEST_FAILED);
780 p_UBSEC_ubsec_close(fd);
781 meth = DSA_OpenSSL();
782 to_return = meth->dsa_do_sign(dgst, dlen, dsa);
783
784 goto err;
785 }
786
787 p_UBSEC_ubsec_close(fd);
788
789 r->top = (160+BN_BITS2-1)/BN_BITS2;
790 s->top = (160+BN_BITS2-1)/BN_BITS2;
791
792 to_return = DSA_SIG_new();
793 if(to_return == NULL) {
794 UBSECerr(UBSEC_F_UBSEC_DSA_SIGN, UBSEC_R_BN_EXPAND_FAIL);
795 goto err;
796 }
797
798 to_return->r = r;
799 to_return->s = s;
800
801err:
802 if (!to_return) {
803 if (r) BN_free(r);
804 if (s) BN_free(s);
805 }
806 BN_clear_free(&m);
807 return to_return;
808}
809
810static int ubsec_dsa_verify(const unsigned char *dgst, int dgst_len,
811 DSA_SIG *sig, DSA *dsa)
812 {
813 int v_len, d_len;
814 int to_return = 0;
815 int fd;
816 BIGNUM v;
817
818 BN_init(&v);
819
820 if(!bn_wexpand(&v, dsa->p->top)) {
821 UBSECerr(UBSEC_F_UBSEC_DSA_VERIFY ,UBSEC_R_BN_EXPAND_FAIL);
822 goto err;
823 }
824
825 v_len = BN_num_bits(dsa->p);
826
827 d_len = p_UBSEC_ubsec_bytes_to_bits((unsigned char *)dgst, dgst_len);
828
829 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0) {
830 const DSA_METHOD *meth;
831 fd = 0;
832 UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
833 meth = DSA_OpenSSL();
834 to_return = meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
835 goto err;
836 }
837
838 if (p_UBSEC_dsa_verify_ioctl(fd, 0, /* compute hash before signing */
839 (unsigned char *)dgst, d_len,
840 (unsigned char *)dsa->p->d, BN_num_bits(dsa->p),
841 (unsigned char *)dsa->q->d, BN_num_bits(dsa->q),
842 (unsigned char *)dsa->g->d, BN_num_bits(dsa->g),
843 (unsigned char *)dsa->pub_key->d, BN_num_bits(dsa->pub_key),
844 (unsigned char *)sig->r->d, BN_num_bits(sig->r),
845 (unsigned char *)sig->s->d, BN_num_bits(sig->s),
846 (unsigned char *)v.d, &v_len) != 0) {
847 const DSA_METHOD *meth;
848 UBSECerr(UBSEC_F_UBSEC_DSA_VERIFY , UBSEC_R_REQUEST_FAILED);
849 p_UBSEC_ubsec_close(fd);
850
851 meth = DSA_OpenSSL();
852 to_return = meth->dsa_do_verify(dgst, dgst_len, sig, dsa);
853
854 goto err;
855 }
856
857 p_UBSEC_ubsec_close(fd);
858
859 to_return = 1;
860err:
861 BN_clear_free(&v);
862 return to_return;
863 }
864#endif
865
866#ifndef OPENSSL_NO_DH
867static int ubsec_dh_compute_key (unsigned char *key,const BIGNUM *pub_key,DH *dh)
868 {
869 int ret = -1,
870 k_len,
871 fd;
872
873 k_len = BN_num_bits(dh->p);
874
875 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
876 {
877 const DH_METHOD *meth;
878 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
879 meth = DH_OpenSSL();
880 ret = meth->compute_key(key, pub_key, dh);
881 goto err;
882 }
883
884 if (p_UBSEC_diffie_hellman_agree_ioctl(fd,
885 (unsigned char *)dh->priv_key->d, BN_num_bits(dh->priv_key),
886 (unsigned char *)pub_key->d, BN_num_bits(pub_key),
887 (unsigned char *)dh->p->d, BN_num_bits(dh->p),
888 key, &k_len) != 0)
889 {
890 /* Hardware's a no go, failover to software */
891 const DH_METHOD *meth;
892 ENGINEerr(UBSEC_F_UBSEC_DH_COMPUTE_KEY, UBSEC_R_REQUEST_FAILED);
893 p_UBSEC_ubsec_close(fd);
894
895 meth = DH_OpenSSL();
896 ret = meth->compute_key(key, pub_key, dh);
897
898 goto err;
899 }
900
901 p_UBSEC_ubsec_close(fd);
902
903 ret = p_UBSEC_ubsec_bits_to_bytes(k_len);
904err:
905 return ret;
906 }
907
908static int ubsec_dh_generate_key (DH *dh)
909 {
910 int ret = 0,
911 random_bits = 0,
912 pub_key_len = 0,
913 priv_key_len = 0,
914 fd;
915 BIGNUM *pub_key = NULL;
916 BIGNUM *priv_key = NULL;
917
918 /*
919 * How many bits should Random x be? dh_key.c
920 * sets the range from 0 to num_bits(modulus) ???
921 */
922
923 if (dh->priv_key == NULL)
924 {
925 priv_key = BN_new();
926 if (priv_key == NULL) goto err;
927 priv_key_len = BN_num_bits(dh->p);
928 bn_wexpand(priv_key, dh->p->top);
929 do
930 if (!BN_rand_range(priv_key, dh->p)) goto err;
931 while (BN_is_zero(priv_key));
932 random_bits = BN_num_bits(priv_key);
933 }
934 else
935 {
936 priv_key = dh->priv_key;
937 }
938
939 if (dh->pub_key == NULL)
940 {
941 pub_key = BN_new();
942 pub_key_len = BN_num_bits(dh->p);
943 bn_wexpand(pub_key, dh->p->top);
944 if(pub_key == NULL) goto err;
945 }
946 else
947 {
948 pub_key = dh->pub_key;
949 }
950
951 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
952 {
953 const DH_METHOD *meth;
954 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
955 meth = DH_OpenSSL();
956 ret = meth->generate_key(dh);
957 goto err;
958 }
959
960 if (p_UBSEC_diffie_hellman_generate_ioctl(fd,
961 (unsigned char *)priv_key->d, &priv_key_len,
962 (unsigned char *)pub_key->d, &pub_key_len,
963 (unsigned char *)dh->g->d, BN_num_bits(dh->g),
964 (unsigned char *)dh->p->d, BN_num_bits(dh->p),
965 0, 0, random_bits) != 0)
966 {
967 /* Hardware's a no go, failover to software */
968 const DH_METHOD *meth;
969
970 ENGINEerr(UBSEC_F_UBSEC_DH_COMPUTE_KEY, UBSEC_R_REQUEST_FAILED);
971 p_UBSEC_ubsec_close(fd);
972
973 meth = DH_OpenSSL();
974 ret = meth->generate_key(dh);
975
976 goto err;
977 }
978
979 p_UBSEC_ubsec_close(fd);
980
981 dh->pub_key = pub_key;
982 dh->pub_key->top = (pub_key_len + BN_BITS2-1) / BN_BITS2;
983 dh->priv_key = priv_key;
984 dh->priv_key->top = (priv_key_len + BN_BITS2-1) / BN_BITS2;
985
986 ret = 1;
987err:
988 return ret;
989 }
990#endif
991
992#ifdef NOT_USED
993static int ubsec_rand_bytes(unsigned char * buf,
994 int num)
995 {
996 int ret = 0,
997 fd;
998
999 if ((fd = p_UBSEC_ubsec_open(UBSEC_KEY_DEVICE_NAME)) <= 0)
1000 {
1001 const RAND_METHOD *meth;
1002 ENGINEerr(UBSEC_F_UBSEC_INIT, UBSEC_R_UNIT_FAILURE);
1003 num = p_UBSEC_ubsec_bits_to_bytes(num);
1004 meth = RAND_SSLeay();
1005 meth->seed(buf, num);
1006 ret = meth->bytes(buf, num);
1007 goto err;
1008 }
1009
1010 num *= 8; /* bytes to bits */
1011
1012 if (p_UBSEC_rng_ioctl(fd,
1013 UBSEC_RNG_DIRECT,
1014 buf,
1015 &num) != 0)
1016 {
1017 /* Hardware's a no go, failover to software */
1018 const RAND_METHOD *meth;
1019
1020 ENGINEerr(UBSEC_F_UBSEC_RNG_BYTES, UBSEC_R_REQUEST_FAILED);
1021 p_UBSEC_ubsec_close(fd);
1022
1023 num = p_UBSEC_ubsec_bits_to_bytes(num);
1024 meth = RAND_SSLeay();
1025 meth->seed(buf, num);
1026 ret = meth->bytes(buf, num);
1027
1028 goto err;
1029 }
1030
1031 p_UBSEC_ubsec_close(fd);
1032
1033 ret = 1;
1034err:
1035 return(ret);
1036 }
1037
1038
1039static int ubsec_rand_status(void)
1040 {
1041 return 0;
1042 }
1043#endif
1044
1045/* This stuff is needed if this ENGINE is being compiled into a self-contained
1046 * shared-library. */
1047#ifdef ENGINE_DYNAMIC_SUPPORT
1048static int bind_fn(ENGINE *e, const char *id)
1049 {
1050 if(id && (strcmp(id, engine_ubsec_id) != 0))
1051 return 0;
1052 if(!bind_helper(e))
1053 return 0;
1054 return 1;
1055 }
1056IMPLEMENT_DYNAMIC_CHECK_FN()
1057IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
1058#endif /* ENGINE_DYNAMIC_SUPPORT */
1059
1060#endif /* !OPENSSL_NO_HW_UBSEC */
1061#endif /* !OPENSSL_NO_HW */
diff --git a/src/lib/libcrypto/engine/hw_ubsec_err.c b/src/lib/libcrypto/engine/hw_ubsec_err.c
deleted file mode 100644
index d707331fc2..0000000000
--- a/src/lib/libcrypto/engine/hw_ubsec_err.c
+++ /dev/null
@@ -1,151 +0,0 @@
1/* hw_ubsec_err.c */
2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include "hw_ubsec_err.h"
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA UBSEC_str_functs[]=
68 {
69{ERR_PACK(0,UBSEC_F_UBSEC_CTRL,0), "UBSEC_CTRL"},
70{ERR_PACK(0,UBSEC_F_UBSEC_DH_COMPUTE_KEY,0), "UBSEC_DH_COMPUTE_KEY"},
71{ERR_PACK(0,UBSEC_F_UBSEC_DSA_SIGN,0), "UBSEC_DSA_SIGN"},
72{ERR_PACK(0,UBSEC_F_UBSEC_DSA_VERIFY,0), "UBSEC_DSA_VERIFY"},
73{ERR_PACK(0,UBSEC_F_UBSEC_FINISH,0), "UBSEC_FINISH"},
74{ERR_PACK(0,UBSEC_F_UBSEC_INIT,0), "UBSEC_INIT"},
75{ERR_PACK(0,UBSEC_F_UBSEC_MOD_EXP,0), "UBSEC_MOD_EXP"},
76{ERR_PACK(0,UBSEC_F_UBSEC_RNG_BYTES,0), "UBSEC_RNG_BYTES"},
77{ERR_PACK(0,UBSEC_F_UBSEC_RSA_MOD_EXP,0), "UBSEC_RSA_MOD_EXP"},
78{ERR_PACK(0,UBSEC_F_UBSEC_RSA_MOD_EXP_CRT,0), "UBSEC_RSA_MOD_EXP_CRT"},
79{0,NULL}
80 };
81
82static ERR_STRING_DATA UBSEC_str_reasons[]=
83 {
84{UBSEC_R_ALREADY_LOADED ,"already loaded"},
85{UBSEC_R_BN_EXPAND_FAIL ,"bn expand fail"},
86{UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"},
87{UBSEC_R_DSO_FAILURE ,"dso failure"},
88{UBSEC_R_MISSING_KEY_COMPONENTS ,"missing key components"},
89{UBSEC_R_NOT_LOADED ,"not loaded"},
90{UBSEC_R_REQUEST_FAILED ,"request failed"},
91{UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL ,"size too large or too small"},
92{UBSEC_R_UNIT_FAILURE ,"unit failure"},
93{0,NULL}
94 };
95
96#endif
97
98#ifdef UBSEC_LIB_NAME
99static ERR_STRING_DATA UBSEC_lib_name[]=
100 {
101{0 ,UBSEC_LIB_NAME},
102{0,NULL}
103 };
104#endif
105
106
107static int UBSEC_lib_error_code=0;
108static int UBSEC_error_init=1;
109
110static void ERR_load_UBSEC_strings(void)
111 {
112 if (UBSEC_lib_error_code == 0)
113 UBSEC_lib_error_code=ERR_get_next_error_library();
114
115 if (UBSEC_error_init)
116 {
117 UBSEC_error_init=0;
118#ifndef OPENSSL_NO_ERR
119 ERR_load_strings(UBSEC_lib_error_code,UBSEC_str_functs);
120 ERR_load_strings(UBSEC_lib_error_code,UBSEC_str_reasons);
121#endif
122
123#ifdef UBSEC_LIB_NAME
124 UBSEC_lib_name->error = ERR_PACK(UBSEC_lib_error_code,0,0);
125 ERR_load_strings(0,UBSEC_lib_name);
126#endif
127 }
128 }
129
130static void ERR_unload_UBSEC_strings(void)
131 {
132 if (UBSEC_error_init == 0)
133 {
134#ifndef OPENSSL_NO_ERR
135 ERR_unload_strings(UBSEC_lib_error_code,UBSEC_str_functs);
136 ERR_unload_strings(UBSEC_lib_error_code,UBSEC_str_reasons);
137#endif
138
139#ifdef UBSEC_LIB_NAME
140 ERR_unload_strings(0,UBSEC_lib_name);
141#endif
142 UBSEC_error_init=1;
143 }
144 }
145
146static void ERR_UBSEC_error(int function, int reason, char *file, int line)
147 {
148 if (UBSEC_lib_error_code == 0)
149 UBSEC_lib_error_code=ERR_get_next_error_library();
150 ERR_PUT_error(UBSEC_lib_error_code,function,reason,file,line);
151 }
diff --git a/src/lib/libcrypto/engine/hw_ubsec_err.h b/src/lib/libcrypto/engine/hw_ubsec_err.h
deleted file mode 100644
index 023d3be771..0000000000
--- a/src/lib/libcrypto/engine/hw_ubsec_err.h
+++ /dev/null
@@ -1,95 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. 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 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the OpenSSL Project
19 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
20 *
21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
24 * openssl-core@openssl.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This product includes cryptographic software written by Eric Young
50 * (eay@cryptsoft.com). This product includes software written by Tim
51 * Hudson (tjh@cryptsoft.com).
52 *
53 */
54
55#ifndef HEADER_UBSEC_ERR_H
56#define HEADER_UBSEC_ERR_H
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_UBSEC_strings(void);
63static void ERR_unload_UBSEC_strings(void);
64static void ERR_UBSEC_error(int function, int reason, char *file, int line);
65#define UBSECerr(f,r) ERR_UBSEC_error((f),(r),__FILE__,__LINE__)
66
67/* Error codes for the UBSEC functions. */
68
69/* Function codes. */
70#define UBSEC_F_UBSEC_CTRL 100
71#define UBSEC_F_UBSEC_DH_COMPUTE_KEY 101
72#define UBSEC_F_UBSEC_DSA_SIGN 102
73#define UBSEC_F_UBSEC_DSA_VERIFY 103
74#define UBSEC_F_UBSEC_FINISH 104
75#define UBSEC_F_UBSEC_INIT 105
76#define UBSEC_F_UBSEC_MOD_EXP 106
77#define UBSEC_F_UBSEC_RNG_BYTES 107
78#define UBSEC_F_UBSEC_RSA_MOD_EXP 108
79#define UBSEC_F_UBSEC_RSA_MOD_EXP_CRT 109
80
81/* Reason codes. */
82#define UBSEC_R_ALREADY_LOADED 100
83#define UBSEC_R_BN_EXPAND_FAIL 101
84#define UBSEC_R_CTRL_COMMAND_NOT_IMPLEMENTED 102
85#define UBSEC_R_DSO_FAILURE 103
86#define UBSEC_R_MISSING_KEY_COMPONENTS 104
87#define UBSEC_R_NOT_LOADED 105
88#define UBSEC_R_REQUEST_FAILED 106
89#define UBSEC_R_SIZE_TOO_LARGE_OR_TOO_SMALL 107
90#define UBSEC_R_UNIT_FAILURE 108
91
92#ifdef __cplusplus
93}
94#endif
95#endif
diff --git a/src/lib/libcrypto/engine/vendor_defns/aep.h b/src/lib/libcrypto/engine/vendor_defns/aep.h
deleted file mode 100644
index 2b2792d2d6..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/aep.h
+++ /dev/null
@@ -1,178 +0,0 @@
1/* This header declares the necessary definitions for using the exponentiation
2 * acceleration capabilities, and rnd number generation of the AEP card.
3 *
4 */
5
6/*
7 *
8 * Some AEP defines
9 *
10 */
11
12/*Successful return value*/
13#define AEP_R_OK 0x00000000
14
15/*Miscelleanous unsuccessful return value*/
16#define AEP_R_GENERAL_ERROR 0x10000001
17
18/*Insufficient host memory*/
19#define AEP_R_HOST_MEMORY 0x10000002
20
21#define AEP_R_FUNCTION_FAILED 0x10000006
22
23/*Invalid arguments in function call*/
24#define AEP_R_ARGUMENTS_BAD 0x10020000
25
26#define AEP_R_NO_TARGET_RESOURCES 0x10030000
27
28/*Error occuring on socket operation*/
29#define AEP_R_SOCKERROR 0x10000010
30
31/*Socket has been closed from the other end*/
32#define AEP_R_SOCKEOF 0x10000011
33
34/*Invalid handles*/
35#define AEP_R_CONNECTION_HANDLE_INVALID 0x100000B3
36
37#define AEP_R_TRANSACTION_HANDLE_INVALID 0x10040000
38
39/*Transaction has not yet returned from accelerator*/
40#define AEP_R_TRANSACTION_NOT_READY 0x00010000
41
42/*There is already a thread waiting on this transaction*/
43#define AEP_R_TRANSACTION_CLAIMED 0x10050000
44
45/*The transaction timed out*/
46#define AEP_R_TIMED_OUT 0x10060000
47
48#define AEP_R_FXN_NOT_IMPLEMENTED 0x10070000
49
50#define AEP_R_TARGET_ERROR 0x10080000
51
52/*Error in the AEP daemon process*/
53#define AEP_R_DAEMON_ERROR 0x10090000
54
55/*Invalid ctx id*/
56#define AEP_R_INVALID_CTX_ID 0x10009000
57
58#define AEP_R_NO_KEY_MANAGER 0x1000a000
59
60/*Error obtaining a mutex*/
61#define AEP_R_MUTEX_BAD 0x000001A0
62
63/*Fxn call before AEP_Initialise ot after AEP_Finialise*/
64#define AEP_R_AEPAPI_NOT_INITIALIZED 0x10000190
65
66/*AEP_Initialise has already been called*/
67#define AEP_R_AEPAPI_ALREADY_INITIALIZED 0x10000191
68
69/*Maximum number of connections to daemon reached*/
70#define AEP_R_NO_MORE_CONNECTION_HNDLS 0x10000200
71
72/*
73 *
74 * Some AEP Type definitions
75 *
76 */
77
78/* an unsigned 8-bit value */
79typedef unsigned char AEP_U8;
80
81/* an unsigned 8-bit character */
82typedef char AEP_CHAR;
83
84/* a BYTE-sized Boolean flag */
85typedef AEP_U8 AEP_BBOOL;
86
87/*Unsigned value, at least 16 bits long*/
88typedef unsigned short AEP_U16;
89
90/* an unsigned value, at least 32 bits long */
91#ifdef SIXTY_FOUR_BIT_LONG
92typedef unsigned int AEP_U32;
93#else
94typedef unsigned long AEP_U32;
95#endif
96
97#ifdef SIXTY_FOUR_BIT_LONG
98typedef unsigned long AEP_U64;
99#else
100typedef struct { unsigned long l1, l2; } AEP_U64;
101#endif
102
103/* at least 32 bits; each bit is a Boolean flag */
104typedef AEP_U32 AEP_FLAGS;
105
106typedef AEP_U8 *AEP_U8_PTR;
107typedef AEP_CHAR *AEP_CHAR_PTR;
108typedef AEP_U32 *AEP_U32_PTR;
109typedef AEP_U64 *AEP_U64_PTR;
110typedef void *AEP_VOID_PTR;
111
112/* Pointer to a AEP_VOID_PTR-- i.e., pointer to pointer to void */
113typedef AEP_VOID_PTR *AEP_VOID_PTR_PTR;
114
115/*Used to identify an AEP connection handle*/
116typedef AEP_U32 AEP_CONNECTION_HNDL;
117
118/*Pointer to an AEP connection handle*/
119typedef AEP_CONNECTION_HNDL *AEP_CONNECTION_HNDL_PTR;
120
121/*Used by an application (in conjunction with the apps process id) to
122identify an individual transaction*/
123typedef AEP_U32 AEP_TRANSACTION_ID;
124
125/*Pointer to an applications transaction identifier*/
126typedef AEP_TRANSACTION_ID *AEP_TRANSACTION_ID_PTR;
127
128/*Return value type*/
129typedef AEP_U32 AEP_RV;
130
131#define MAX_PROCESS_CONNECTIONS 256
132
133#define RAND_BLK_SIZE 1024
134
135typedef enum{
136 NotConnected= 0,
137 Connected= 1,
138 InUse= 2
139} AEP_CONNECTION_STATE;
140
141
142typedef struct AEP_CONNECTION_ENTRY{
143 AEP_CONNECTION_STATE conn_state;
144 AEP_CONNECTION_HNDL conn_hndl;
145} AEP_CONNECTION_ENTRY;
146
147
148typedef AEP_RV t_AEP_OpenConnection(AEP_CONNECTION_HNDL_PTR phConnection);
149typedef AEP_RV t_AEP_CloseConnection(AEP_CONNECTION_HNDL hConnection);
150
151typedef AEP_RV t_AEP_ModExp(AEP_CONNECTION_HNDL hConnection,
152 AEP_VOID_PTR pA, AEP_VOID_PTR pP,
153 AEP_VOID_PTR pN,
154 AEP_VOID_PTR pResult,
155 AEP_TRANSACTION_ID* pidTransID);
156
157typedef AEP_RV t_AEP_ModExpCrt(AEP_CONNECTION_HNDL hConnection,
158 AEP_VOID_PTR pA, AEP_VOID_PTR pP,
159 AEP_VOID_PTR pQ,
160 AEP_VOID_PTR pDmp1, AEP_VOID_PTR pDmq1,
161 AEP_VOID_PTR pIqmp,
162 AEP_VOID_PTR pResult,
163 AEP_TRANSACTION_ID* pidTransID);
164
165#ifdef AEPRAND
166typedef AEP_RV t_AEP_GenRandom(AEP_CONNECTION_HNDL hConnection,
167 AEP_U32 Len,
168 AEP_U32 Type,
169 AEP_VOID_PTR pResult,
170 AEP_TRANSACTION_ID* pidTransID);
171#endif
172
173typedef AEP_RV t_AEP_Initialize(AEP_VOID_PTR pInitArgs);
174typedef AEP_RV t_AEP_Finalize();
175typedef AEP_RV t_AEP_SetBNCallBacks(AEP_RV (*GetBigNumSizeFunc)(),
176 AEP_RV (*MakeAEPBigNumFunc)(),
177 AEP_RV (*ConverAEPBigNumFunc)());
178
diff --git a/src/lib/libcrypto/engine/vendor_defns/atalla.h b/src/lib/libcrypto/engine/vendor_defns/atalla.h
deleted file mode 100644
index 149970d441..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/atalla.h
+++ /dev/null
@@ -1,48 +0,0 @@
1/* This header declares the necessary definitions for using the exponentiation
2 * acceleration capabilities of Atalla cards. The only cryptographic operation
3 * is performed by "ASI_RSAPrivateKeyOpFn" and this takes a structure that
4 * defines an "RSA private key". However, it is really only performing a
5 * regular mod_exp using the supplied modulus and exponent - no CRT form is
6 * being used. Hence, it is a generic mod_exp function in disguise, and we use
7 * it as such.
8 *
9 * Thanks to the people at Atalla for letting me know these definitions are
10 * fine and that they can be reproduced here.
11 *
12 * Geoff.
13 */
14
15typedef struct ItemStr
16 {
17 unsigned char *data;
18 int len;
19 } Item;
20
21typedef struct RSAPrivateKeyStr
22 {
23 void *reserved;
24 Item version;
25 Item modulus;
26 Item publicExponent;
27 Item privateExponent;
28 Item prime[2];
29 Item exponent[2];
30 Item coefficient;
31 } RSAPrivateKey;
32
33/* Predeclare the function pointer types that we dynamically load from the DSO.
34 * These use the same names and form that Ben's original support code had (in
35 * crypto/bn/bn_exp.c) unless of course I've inadvertently changed the style
36 * somewhere along the way!
37 */
38
39typedef int tfnASI_GetPerformanceStatistics(int reset_flag,
40 unsigned int *ret_buf);
41
42typedef int tfnASI_GetHardwareConfig(long card_num, unsigned int *ret_buf);
43
44typedef int tfnASI_RSAPrivateKeyOpFn(RSAPrivateKey * rsaKey,
45 unsigned char *output,
46 unsigned char *input,
47 unsigned int modulus_len);
48
diff --git a/src/lib/libcrypto/engine/vendor_defns/cswift.h b/src/lib/libcrypto/engine/vendor_defns/cswift.h
deleted file mode 100644
index 60079326bb..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/cswift.h
+++ /dev/null
@@ -1,234 +0,0 @@
1/* Attribution notice: Rainbow have generously allowed me to reproduce
2 * the necessary definitions here from their API. This means the support
3 * can build independently of whether application builders have the
4 * API or hardware. This will allow developers to easily produce software
5 * that has latent hardware support for any users that have accelertors
6 * installed, without the developers themselves needing anything extra.
7 *
8 * I have only clipped the parts from the CryptoSwift header files that
9 * are (or seem) relevant to the CryptoSwift support code. This is
10 * simply to keep the file sizes reasonable.
11 * [Geoff]
12 */
13
14
15/* NB: These type widths do *not* seem right in general, in particular
16 * they're not terribly friendly to 64-bit architectures (unsigned long)
17 * will be 64-bit on IA-64 for a start. I'm leaving these alone as they
18 * agree with Rainbow's API and this will only be called into question
19 * on platforms with Rainbow support anyway! ;-) */
20
21#ifdef __cplusplus
22extern "C" {
23#endif /* __cplusplus */
24
25typedef long SW_STATUS; /* status */
26typedef unsigned char SW_BYTE; /* 8 bit byte */
27typedef unsigned short SW_U16; /* 16 bit number */
28#if defined(_IRIX)
29#include <sgidefs.h>
30typedef __uint32_t SW_U32;
31#else
32typedef unsigned long SW_U32; /* 32 bit integer */
33#endif
34
35#if defined(OPENSSL_SYS_WIN32)
36 typedef struct _SW_U64 {
37 SW_U32 low32;
38 SW_U32 high32;
39 } SW_U64; /* 64 bit integer */
40#elif defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
41 typedef longlong SW_U64
42#else /* Unix variants */
43 typedef struct _SW_U64 {
44 SW_U32 low32;
45 SW_U32 high32;
46 } SW_U64; /* 64 bit integer */
47#endif
48
49/* status codes */
50#define SW_OK (0L)
51#define SW_ERR_BASE (-10000L)
52#define SW_ERR_NO_CARD (SW_ERR_BASE-1) /* The Card is not present */
53#define SW_ERR_CARD_NOT_READY (SW_ERR_BASE-2) /* The card has not powered */
54 /* up yet */
55#define SW_ERR_TIME_OUT (SW_ERR_BASE-3) /* Execution of a command */
56 /* time out */
57#define SW_ERR_NO_EXECUTE (SW_ERR_BASE-4) /* The Card failed to */
58 /* execute the command */
59#define SW_ERR_INPUT_NULL_PTR (SW_ERR_BASE-5) /* a required pointer is */
60 /* NULL */
61#define SW_ERR_INPUT_SIZE (SW_ERR_BASE-6) /* size is invalid, too */
62 /* small, too large. */
63#define SW_ERR_INVALID_HANDLE (SW_ERR_BASE-7) /* Invalid SW_ACC_CONTEXT */
64 /* handle */
65#define SW_ERR_PENDING (SW_ERR_BASE-8) /* A request is already out- */
66 /* standing at this */
67 /* context handle */
68#define SW_ERR_AVAILABLE (SW_ERR_BASE-9) /* A result is available. */
69#define SW_ERR_NO_PENDING (SW_ERR_BASE-10)/* No request is pending. */
70#define SW_ERR_NO_MEMORY (SW_ERR_BASE-11)/* Not enough memory */
71#define SW_ERR_BAD_ALGORITHM (SW_ERR_BASE-12)/* Invalid algorithm type */
72 /* in SW_PARAM structure */
73#define SW_ERR_MISSING_KEY (SW_ERR_BASE-13)/* No key is associated with */
74 /* context. */
75 /* swAttachKeyParam() is */
76 /* not called. */
77#define SW_ERR_KEY_CMD_MISMATCH \
78 (SW_ERR_BASE-14)/* Cannot perform requested */
79 /* SW_COMMAND_CODE since */
80 /* key attached via */
81 /* swAttachKeyParam() */
82 /* cannot be used for this*/
83 /* SW_COMMAND_CODE. */
84#define SW_ERR_NOT_IMPLEMENTED \
85 (SW_ERR_BASE-15)/* Not implemented */
86#define SW_ERR_BAD_COMMAND (SW_ERR_BASE-16)/* Bad command code */
87#define SW_ERR_BAD_ITEM_SIZE (SW_ERR_BASE-17)/* too small or too large in */
88 /* the "initems" or */
89 /* "outitems". */
90#define SW_ERR_BAD_ACCNUM (SW_ERR_BASE-18)/* Bad accelerator number */
91#define SW_ERR_SELFTEST_FAIL (SW_ERR_BASE-19)/* At least one of the self */
92 /* test fail, look at the */
93 /* selfTestBitmap in */
94 /* SW_ACCELERATOR_INFO for*/
95 /* details. */
96#define SW_ERR_MISALIGN (SW_ERR_BASE-20)/* Certain alogrithms require*/
97 /* key materials aligned */
98 /* in certain order, e.g. */
99 /* 128 bit for CRT */
100#define SW_ERR_OUTPUT_NULL_PTR \
101 (SW_ERR_BASE-21)/* a required pointer is */
102 /* NULL */
103#define SW_ERR_OUTPUT_SIZE \
104 (SW_ERR_BASE-22)/* size is invalid, too */
105 /* small, too large. */
106#define SW_ERR_FIRMWARE_CHECKSUM \
107 (SW_ERR_BASE-23)/* firmware checksum mismatch*/
108 /* download failed. */
109#define SW_ERR_UNKNOWN_FIRMWARE \
110 (SW_ERR_BASE-24)/* unknown firmware error */
111#define SW_ERR_INTERRUPT (SW_ERR_BASE-25)/* request is abort when */
112 /* it's waiting to be */
113 /* completed. */
114#define SW_ERR_NVWRITE_FAIL (SW_ERR_BASE-26)/* error in writing to Non- */
115 /* volatile memory */
116#define SW_ERR_NVWRITE_RANGE (SW_ERR_BASE-27)/* out of range error in */
117 /* writing to NV memory */
118#define SW_ERR_RNG_ERROR (SW_ERR_BASE-28)/* Random Number Generation */
119 /* failure */
120#define SW_ERR_DSS_FAILURE (SW_ERR_BASE-29)/* DSS Sign or Verify failure*/
121#define SW_ERR_MODEXP_FAILURE (SW_ERR_BASE-30)/* Failure in various math */
122 /* calculations */
123#define SW_ERR_ONBOARD_MEMORY (SW_ERR_BASE-31)/* Error in accessing on - */
124 /* board memory */
125#define SW_ERR_FIRMWARE_VERSION \
126 (SW_ERR_BASE-32)/* Wrong version in firmware */
127 /* update */
128#define SW_ERR_ZERO_WORKING_ACCELERATOR \
129 (SW_ERR_BASE-44)/* All accelerators are bad */
130
131
132 /* algorithm type */
133#define SW_ALG_CRT 1
134#define SW_ALG_EXP 2
135#define SW_ALG_DSA 3
136#define SW_ALG_NVDATA 4
137
138 /* command code */
139#define SW_CMD_MODEXP_CRT 1 /* perform Modular Exponentiation using */
140 /* Chinese Remainder Theorem (CRT) */
141#define SW_CMD_MODEXP 2 /* perform Modular Exponentiation */
142#define SW_CMD_DSS_SIGN 3 /* perform DSS sign */
143#define SW_CMD_DSS_VERIFY 4 /* perform DSS verify */
144#define SW_CMD_RAND 5 /* perform random number generation */
145#define SW_CMD_NVREAD 6 /* perform read to nonvolatile RAM */
146#define SW_CMD_NVWRITE 7 /* perform write to nonvolatile RAM */
147
148typedef SW_U32 SW_ALGTYPE; /* alogrithm type */
149typedef SW_U32 SW_STATE; /* state */
150typedef SW_U32 SW_COMMAND_CODE; /* command code */
151typedef SW_U32 SW_COMMAND_BITMAP[4]; /* bitmap */
152
153typedef struct _SW_LARGENUMBER {
154 SW_U32 nbytes; /* number of bytes in the buffer "value" */
155 SW_BYTE* value; /* the large integer as a string of */
156 /* bytes in network (big endian) order */
157} SW_LARGENUMBER;
158
159#if defined(OPENSSL_SYS_WIN32)
160 #include <windows.h>
161 typedef HANDLE SW_OSHANDLE; /* handle to kernel object */
162 #define SW_OS_INVALID_HANDLE INVALID_HANDLE_VALUE
163 #define SW_CALLCONV _stdcall
164#elif defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
165 /* async callback mechanisms */
166 /* swiftCallbackLevel */
167 #define SW_MAC_CALLBACK_LEVEL_NO 0
168 #define SW_MAC_CALLBACK_LEVEL_HARDWARE 1 /* from the hardware ISR */
169 #define SW_MAC_CALLBACK_LEVEL_SECONDARY 2 /* as secondary ISR */
170 typedef int SW_MAC_CALLBACK_LEVEL;
171 typedef int SW_OSHANDLE;
172 #define SW_OS_INVALID_HANDLE (-1)
173 #define SW_CALLCONV
174#else /* Unix variants */
175 typedef int SW_OSHANDLE; /* handle to driver */
176 #define SW_OS_INVALID_HANDLE (-1)
177 #define SW_CALLCONV
178#endif
179
180typedef struct _SW_CRT {
181 SW_LARGENUMBER p; /* prime number p */
182 SW_LARGENUMBER q; /* prime number q */
183 SW_LARGENUMBER dmp1; /* exponent1 */
184 SW_LARGENUMBER dmq1; /* exponent2 */
185 SW_LARGENUMBER iqmp; /* CRT coefficient */
186} SW_CRT;
187
188typedef struct _SW_EXP {
189 SW_LARGENUMBER modulus; /* modulus */
190 SW_LARGENUMBER exponent;/* exponent */
191} SW_EXP;
192
193typedef struct _SW_DSA {
194 SW_LARGENUMBER p; /* */
195 SW_LARGENUMBER q; /* */
196 SW_LARGENUMBER g; /* */
197 SW_LARGENUMBER key; /* private/public key */
198} SW_DSA;
199
200typedef struct _SW_NVDATA {
201 SW_U32 accnum; /* accelerator board number */
202 SW_U32 offset; /* offset in byte */
203} SW_NVDATA;
204
205typedef struct _SW_PARAM {
206 SW_ALGTYPE type; /* type of the alogrithm */
207 union {
208 SW_CRT crt;
209 SW_EXP exp;
210 SW_DSA dsa;
211 SW_NVDATA nvdata;
212 } up;
213} SW_PARAM;
214
215typedef SW_U32 SW_CONTEXT_HANDLE; /* opaque context handle */
216
217
218/* Now the OpenSSL bits, these function types are the for the function
219 * pointers that will bound into the Rainbow shared libraries. */
220typedef SW_STATUS SW_CALLCONV t_swAcquireAccContext(SW_CONTEXT_HANDLE *hac);
221typedef SW_STATUS SW_CALLCONV t_swAttachKeyParam(SW_CONTEXT_HANDLE hac,
222 SW_PARAM *key_params);
223typedef SW_STATUS SW_CALLCONV t_swSimpleRequest(SW_CONTEXT_HANDLE hac,
224 SW_COMMAND_CODE cmd,
225 SW_LARGENUMBER pin[],
226 SW_U32 pin_count,
227 SW_LARGENUMBER pout[],
228 SW_U32 pout_count);
229typedef SW_STATUS SW_CALLCONV t_swReleaseAccContext(SW_CONTEXT_HANDLE hac);
230
231#ifdef __cplusplus
232}
233#endif /* __cplusplus */
234
diff --git a/src/lib/libcrypto/engine/vendor_defns/hw_4758_cca.h b/src/lib/libcrypto/engine/vendor_defns/hw_4758_cca.h
deleted file mode 100644
index 296636e81a..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/hw_4758_cca.h
+++ /dev/null
@@ -1,149 +0,0 @@
1/**********************************************************************/
2/* */
3/* Prototypes of the CCA verbs used by the 4758 CCA openssl driver */
4/* */
5/* Maurice Gittens <maurice@gittens.nl> */
6/* */
7/**********************************************************************/
8
9#ifndef __HW_4758_CCA__
10#define __HW_4758_CCA__
11
12/*
13 * Only WIN32 support for now
14 */
15#if defined(WIN32)
16
17 #define CCA_LIB_NAME "CSUNSAPI"
18
19 #define CSNDPKX "CSNDPKX_32"
20 #define CSNDKRR "CSNDKRR_32"
21 #define CSNDPKE "CSNDPKE_32"
22 #define CSNDPKD "CSNDPKD_32"
23 #define CSNDDSV "CSNDDSV_32"
24 #define CSNDDSG "CSNDDSG_32"
25 #define CSNBRNG "CSNBRNG_32"
26
27 #define SECURITYAPI __stdcall
28#else
29 /* Fixme!!
30 Find out the values of these constants for other platforms.
31 */
32 #define CCA_LIB_NAME "CSUNSAPI"
33
34 #define CSNDPKX "CSNDPKX"
35 #define CSNDKRR "CSNDKRR"
36 #define CSNDPKE "CSNDPKE"
37 #define CSNDPKD "CSNDPKD"
38 #define CSNDDSV "CSNDDSV"
39 #define CSNDDSG "CSNDDSG"
40 #define CSNBRNG "CSNBRNG"
41
42 #define SECURITYAPI
43#endif
44
45/*
46 * security API prototypes
47 */
48
49/* PKA Key Record Read */
50typedef void (SECURITYAPI *F_KEYRECORDREAD)
51 (long * return_code,
52 long * reason_code,
53 long * exit_data_length,
54 unsigned char * exit_data,
55 long * rule_array_count,
56 unsigned char * rule_array,
57 unsigned char * key_label,
58 long * key_token_length,
59 unsigned char * key_token);
60
61/* Random Number Generate */
62typedef void (SECURITYAPI *F_RANDOMNUMBERGENERATE)
63 (long * return_code,
64 long * reason_code,
65 long * exit_data_length,
66 unsigned char * exit_data,
67 unsigned char * form,
68 unsigned char * random_number);
69
70/* Digital Signature Generate */
71typedef void (SECURITYAPI *F_DIGITALSIGNATUREGENERATE)
72 (long * return_code,
73 long * reason_code,
74 long * exit_data_length,
75 unsigned char * exit_data,
76 long * rule_array_count,
77 unsigned char * rule_array,
78 long * PKA_private_key_id_length,
79 unsigned char * PKA_private_key_id,
80 long * hash_length,
81 unsigned char * hash,
82 long * signature_field_length,
83 long * signature_bit_length,
84 unsigned char * signature_field);
85
86/* Digital Signature Verify */
87typedef void (SECURITYAPI *F_DIGITALSIGNATUREVERIFY)(
88 long * return_code,
89 long * reason_code,
90 long * exit_data_length,
91 unsigned char * exit_data,
92 long * rule_array_count,
93 unsigned char * rule_array,
94 long * PKA_public_key_id_length,
95 unsigned char * PKA_public_key_id,
96 long * hash_length,
97 unsigned char * hash,
98 long * signature_field_length,
99 unsigned char * signature_field);
100
101/* PKA Public Key Extract */
102typedef void (SECURITYAPI *F_PUBLICKEYEXTRACT)(
103 long * return_code,
104 long * reason_code,
105 long * exit_data_length,
106 unsigned char * exit_data,
107 long * rule_array_count,
108 unsigned char * rule_array,
109 long * source_key_identifier_length,
110 unsigned char * source_key_identifier,
111 long * target_key_token_length,
112 unsigned char * target_key_token);
113
114/* PKA Encrypt */
115typedef void (SECURITYAPI *F_PKAENCRYPT)
116 (long * return_code,
117 long * reason_code,
118 long * exit_data_length,
119 unsigned char * exit_data,
120 long * rule_array_count,
121 unsigned char * rule_array,
122 long * key_value_length,
123 unsigned char * key_value,
124 long * data_struct_length,
125 unsigned char * data_struct,
126 long * RSA_public_key_length,
127 unsigned char * RSA_public_key,
128 long * RSA_encipher_length,
129 unsigned char * RSA_encipher );
130
131/* PKA Decrypt */
132typedef void (SECURITYAPI *F_PKADECRYPT)
133 (long * return_code,
134 long * reason_code,
135 long * exit_data_length,
136 unsigned char * exit_data,
137 long * rule_array_count,
138 unsigned char * rule_array,
139 long * enciphered_key_length,
140 unsigned char * enciphered_key,
141 long * data_struct_length,
142 unsigned char * data_struct,
143 long * RSA_private_key_length,
144 unsigned char * RSA_private_key,
145 long * key_value_length,
146 unsigned char * key_value );
147
148
149#endif
diff --git a/src/lib/libcrypto/engine/vendor_defns/hw_ubsec.h b/src/lib/libcrypto/engine/vendor_defns/hw_ubsec.h
deleted file mode 100644
index b6619d40f2..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/hw_ubsec.h
+++ /dev/null
@@ -1,100 +0,0 @@
1/******************************************************************************
2 *
3 * Copyright 2000
4 * Broadcom Corporation
5 * 16215 Alton Parkway
6 * PO Box 57013
7 * Irvine CA 92619-7013
8 *
9 *****************************************************************************/
10/*
11 * Broadcom Corporation uBSec SDK
12 */
13/*
14 * Character device header file.
15 */
16/*
17 * Revision History:
18 *
19 * October 2000 JTT Created.
20 */
21
22#define MAX_PUBLIC_KEY_BITS (1024)
23#define MAX_PUBLIC_KEY_BYTES (1024/8)
24#define SHA_BIT_SIZE (160)
25#define MAX_CRYPTO_KEY_LENGTH 24
26#define MAX_MAC_KEY_LENGTH 64
27#define UBSEC_CRYPTO_DEVICE_NAME ((unsigned char *)"/dev/ubscrypt")
28#define UBSEC_KEY_DEVICE_NAME ((unsigned char *)"/dev/ubskey")
29
30/* Math command types. */
31#define UBSEC_MATH_MODADD 0x0001
32#define UBSEC_MATH_MODSUB 0x0002
33#define UBSEC_MATH_MODMUL 0x0004
34#define UBSEC_MATH_MODEXP 0x0008
35#define UBSEC_MATH_MODREM 0x0010
36#define UBSEC_MATH_MODINV 0x0020
37
38typedef long ubsec_MathCommand_t;
39typedef long ubsec_RNGCommand_t;
40
41typedef struct ubsec_crypto_context_s {
42 unsigned int flags;
43 unsigned char crypto[MAX_CRYPTO_KEY_LENGTH];
44 unsigned char auth[MAX_MAC_KEY_LENGTH];
45} ubsec_crypto_context_t, *ubsec_crypto_context_p;
46
47/*
48 * Predeclare the function pointer types that we dynamically load from the DSO.
49 */
50
51typedef int t_UBSEC_ubsec_bytes_to_bits(unsigned char *n, int bytes);
52
53typedef int t_UBSEC_ubsec_bits_to_bytes(int bits);
54
55typedef int t_UBSEC_ubsec_open(unsigned char *device);
56
57typedef int t_UBSEC_ubsec_close(int fd);
58
59typedef int t_UBSEC_diffie_hellman_generate_ioctl (int fd,
60 unsigned char *x, int *x_len, unsigned char *y, int *y_len,
61 unsigned char *g, int g_len, unsigned char *m, int m_len,
62 unsigned char *userX, int userX_len, int random_bits);
63
64typedef int t_UBSEC_diffie_hellman_agree_ioctl (int fd,
65 unsigned char *x, int x_len, unsigned char *y, int y_len,
66 unsigned char *m, int m_len, unsigned char *k, int *k_len);
67
68typedef int t_UBSEC_rsa_mod_exp_ioctl (int fd,
69 unsigned char *x, int x_len, unsigned char *m, int m_len,
70 unsigned char *e, int e_len, unsigned char *y, int *y_len);
71
72typedef int t_UBSEC_rsa_mod_exp_crt_ioctl (int fd,
73 unsigned char *x, int x_len, unsigned char *qinv, int qinv_len,
74 unsigned char *edq, int edq_len, unsigned char *q, int q_len,
75 unsigned char *edp, int edp_len, unsigned char *p, int p_len,
76 unsigned char *y, int *y_len);
77
78typedef int t_UBSEC_dsa_sign_ioctl (int fd,
79 int hash, unsigned char *data, int data_len,
80 unsigned char *rndom, int random_len,
81 unsigned char *p, int p_len, unsigned char *q, int q_len,
82 unsigned char *g, int g_len, unsigned char *key, int key_len,
83 unsigned char *r, int *r_len, unsigned char *s, int *s_len);
84
85typedef int t_UBSEC_dsa_verify_ioctl (int fd,
86 int hash, unsigned char *data, int data_len,
87 unsigned char *p, int p_len, unsigned char *q, int q_len,
88 unsigned char *g, int g_len, unsigned char *key, int key_len,
89 unsigned char *r, int r_len, unsigned char *s, int s_len,
90 unsigned char *v, int *v_len);
91
92typedef int t_UBSEC_math_accelerate_ioctl(int fd, ubsec_MathCommand_t command,
93 unsigned char *ModN, int *ModN_len, unsigned char *ExpE, int *ExpE_len,
94 unsigned char *ParamA, int *ParamA_len, unsigned char *ParamB, int *ParamB_len,
95 unsigned char *Result, int *Result_len);
96
97typedef int t_UBSEC_rng_ioctl(int fd, ubsec_RNGCommand_t command,
98 unsigned char *Result, int *Result_len);
99
100typedef int t_UBSEC_max_key_len_ioctl(int fd, int *max_key_len);
diff --git a/src/lib/libcrypto/engine/vendor_defns/hwcryptohook.h b/src/lib/libcrypto/engine/vendor_defns/hwcryptohook.h
deleted file mode 100644
index aaa4d4575e..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/hwcryptohook.h
+++ /dev/null
@@ -1,486 +0,0 @@
1/*
2 * ModExp / RSA (with/without KM) plugin API
3 *
4 * The application will load a dynamic library which
5 * exports entrypoint(s) defined in this file.
6 *
7 * This set of entrypoints provides only a multithreaded,
8 * synchronous-within-each-thread, facility.
9 *
10 *
11 * This file is Copyright 1998-2000 nCipher Corporation Limited.
12 *
13 * Redistribution and use in source and binary forms, with opr without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the copyright notice,
18 * this list of conditions, and the following disclaimer.
19 *
20 * 2. Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions, and the following
22 * disclaimer, in the documentation and/or other materials provided
23 * with the distribution
24 *
25 * IN NO EVENT SHALL NCIPHER CORPORATION LIMITED (`NCIPHER') AND/OR
26 * ANY OTHER AUTHORS OR DISTRIBUTORS OF THIS FILE BE LIABLE for any
27 * damages arising directly or indirectly from this file, its use or
28 * this licence. Without prejudice to the generality of the
29 * foregoing: all liability shall be excluded for direct, indirect,
30 * special, incidental, consequential or other damages or any loss of
31 * profits, business, revenue goodwill or anticipated savings;
32 * liability shall be excluded even if nCipher or anyone else has been
33 * advised of the possibility of damage. In any event, if the
34 * exclusion of liability is not effective, the liability of nCipher
35 * or any author or distributor shall be limited to the lesser of the
36 * price paid and 1,000 pounds sterling. This licence only fails to
37 * exclude or limit liability for death or personal injury arising out
38 * of negligence, and only to the extent that such an exclusion or
39 * limitation is not effective.
40 *
41 * NCIPHER AND THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ALL
42 * AND ANY WARRANTIES (WHETHER EXPRESS OR IMPLIED), including, but not
43 * limited to, any implied warranties of merchantability, fitness for
44 * a particular purpose, satisfactory quality, and/or non-infringement
45 * of any third party rights.
46 *
47 * US Government use: This software and documentation is Commercial
48 * Computer Software and Computer Software Documentation, as defined in
49 * sub-paragraphs (a)(1) and (a)(5) of DFAR 252.227-7014, "Rights in
50 * Noncommercial Computer Software and Noncommercial Computer Software
51 * Documentation." Use, duplication or disclosure by the Government is
52 * subject to the terms and conditions specified here.
53 *
54 * By using or distributing this file you will be accepting these
55 * terms and conditions, including the limitation of liability and
56 * lack of warranty. If you do not wish to accept these terms and
57 * conditions, DO NOT USE THE FILE.
58 *
59 *
60 * The actual dynamically loadable plugin, and the library files for
61 * static linking, which are also provided in some distributions, are
62 * not covered by the licence described above. You should have
63 * received a separate licence with terms and conditions for these
64 * library files; if you received the library files without a licence,
65 * please contact nCipher.
66 *
67 *
68 * $Id: hwcryptohook.h,v 1.1.1.1 2003/05/11 21:35:16 markus Exp $
69 */
70
71#ifndef HWCRYPTOHOOK_H
72#define HWCRYPTOHOOK_H
73
74#include <sys/types.h>
75#include <stdio.h>
76
77#ifndef HWCRYPTOHOOK_DECLARE_APPTYPES
78#define HWCRYPTOHOOK_DECLARE_APPTYPES 1
79#endif
80
81#define HWCRYPTOHOOK_ERROR_FAILED -1
82#define HWCRYPTOHOOK_ERROR_FALLBACK -2
83#define HWCRYPTOHOOK_ERROR_MPISIZE -3
84
85#if HWCRYPTOHOOK_DECLARE_APPTYPES
86
87/* These structs are defined by the application and opaque to the
88 * crypto plugin. The application may define these as it sees fit.
89 * Default declarations are provided here, but the application may
90 * #define HWCRYPTOHOOK_DECLARE_APPTYPES 0
91 * to prevent these declarations, and instead provide its own
92 * declarations of these types. (Pointers to them must still be
93 * ordinary pointers to structs or unions, or the resulting combined
94 * program will have a type inconsistency.)
95 */
96typedef struct HWCryptoHook_MutexValue HWCryptoHook_Mutex;
97typedef struct HWCryptoHook_CondVarValue HWCryptoHook_CondVar;
98typedef struct HWCryptoHook_PassphraseContextValue HWCryptoHook_PassphraseContext;
99typedef struct HWCryptoHook_CallerContextValue HWCryptoHook_CallerContext;
100
101#endif /* HWCRYPTOHOOK_DECLARE_APPTYPES */
102
103/* These next two structs are opaque to the application. The crypto
104 * plugin will return pointers to them; the caller simply manipulates
105 * the pointers.
106 */
107typedef struct HWCryptoHook_Context *HWCryptoHook_ContextHandle;
108typedef struct HWCryptoHook_RSAKey *HWCryptoHook_RSAKeyHandle;
109
110typedef struct {
111 char *buf;
112 size_t size;
113} HWCryptoHook_ErrMsgBuf;
114/* Used for error reporting. When a HWCryptoHook function fails it
115 * will return a sentinel value (0 for pointer-valued functions, or a
116 * negative number, usually HWCRYPTOHOOK_ERROR_FAILED, for
117 * integer-valued ones). It will, if an ErrMsgBuf is passed, also put
118 * an error message there.
119 *
120 * size is the size of the buffer, and will not be modified. If you
121 * pass 0 for size you must pass 0 for buf, and nothing will be
122 * recorded (just as if you passed 0 for the struct pointer).
123 * Messages written to the buffer will always be null-terminated, even
124 * when truncated to fit within size bytes.
125 *
126 * The contents of the buffer are not defined if there is no error.
127 */
128
129typedef struct HWCryptoHook_MPIStruct {
130 unsigned char *buf;
131 size_t size;
132} HWCryptoHook_MPI;
133/* When one of these is returned, a pointer is passed to the function.
134 * At call, size is the space available. Afterwards it is updated to
135 * be set to the actual length (which may be more than the space available,
136 * if there was not enough room and the result was truncated).
137 * buf (the pointer) is not updated.
138 *
139 * size is in bytes and may be zero at call or return, but must be a
140 * multiple of the limb size. Zero limbs at the MS end are not
141 * permitted.
142 */
143
144#define HWCryptoHook_InitFlags_FallbackModExp 0x0002UL
145#define HWCryptoHook_InitFlags_FallbackRSAImmed 0x0004UL
146/* Enable requesting fallback to software in case of problems with the
147 * hardware support. This indicates to the crypto provider that the
148 * application is prepared to fall back to software operation if the
149 * ModExp* or RSAImmed* functions return HWCRYPTOHOOK_ERROR_FALLBACK.
150 * Without this flag those calls will never return
151 * HWCRYPTOHOOK_ERROR_FALLBACK. The flag will also cause the crypto
152 * provider to avoid repeatedly attempting to contact dead hardware
153 * within a short interval, if appropriate.
154 */
155
156#define HWCryptoHook_InitFlags_SimpleForkCheck 0x0010UL
157/* Without _SimpleForkCheck the library is allowed to assume that the
158 * application will not fork and call the library in the child(ren).
159 *
160 * When it is specified, this is allowed. However, after a fork
161 * neither parent nor child may unload any loaded keys or call
162 * _Finish. Instead, they should call exit (or die with a signal)
163 * without calling _Finish. After all the children have died the
164 * parent may unload keys or call _Finish.
165 *
166 * This flag only has any effect on UN*X platforms.
167 */
168
169typedef struct {
170 unsigned long flags;
171 void *logstream; /* usually a FILE*. See below. */
172
173 size_t limbsize; /* bignum format - size of radix type, must be power of 2 */
174 int mslimbfirst; /* 0 or 1 */
175 int msbytefirst; /* 0 or 1; -1 = native */
176
177 /* All the callback functions should return 0 on success, or a
178 * nonzero integer (whose value will be visible in the error message
179 * put in the buffer passed to the call).
180 *
181 * If a callback is not available pass a null function pointer.
182 *
183 * The callbacks may not call down again into the crypto plugin.
184 */
185
186 /* For thread-safety. Set everything to 0 if you promise only to be
187 * singlethreaded. maxsimultaneous is the number of calls to
188 * ModExp[Crt]/RSAImmed{Priv,Pub}/RSA. If you don't know what to
189 * put there then say 0 and the hook library will use a default.
190 *
191 * maxmutexes is a small limit on the number of simultaneous mutexes
192 * which will be requested by the library. If there is no small
193 * limit, set it to 0. If the crypto plugin cannot create the
194 * advertised number of mutexes the calls to its functions may fail.
195 * If a low number of mutexes is advertised the plugin will try to
196 * do the best it can. Making larger numbers of mutexes available
197 * may improve performance and parallelism by reducing contention
198 * over critical sections. Unavailability of any mutexes, implying
199 * single-threaded operation, should be indicated by the setting
200 * mutex_init et al to 0.
201 */
202 int maxmutexes;
203 int maxsimultaneous;
204 size_t mutexsize;
205 int (*mutex_init)(HWCryptoHook_Mutex*, HWCryptoHook_CallerContext *cactx);
206 int (*mutex_acquire)(HWCryptoHook_Mutex*);
207 void (*mutex_release)(HWCryptoHook_Mutex*);
208 void (*mutex_destroy)(HWCryptoHook_Mutex*);
209
210 /* For greater efficiency, can use condition vars internally for
211 * synchronisation. In this case maxsimultaneous is ignored, but
212 * the other mutex stuff must be available. In singlethreaded
213 * programs, set everything to 0.
214 */
215 size_t condvarsize;
216 int (*condvar_init)(HWCryptoHook_CondVar*, HWCryptoHook_CallerContext *cactx);
217 int (*condvar_wait)(HWCryptoHook_CondVar*, HWCryptoHook_Mutex*);
218 void (*condvar_signal)(HWCryptoHook_CondVar*);
219 void (*condvar_broadcast)(HWCryptoHook_CondVar*);
220 void (*condvar_destroy)(HWCryptoHook_CondVar*);
221
222 /* The semantics of acquiring and releasing mutexes and broadcasting
223 * and waiting on condition variables are expected to be those from
224 * POSIX threads (pthreads). The mutexes may be (in pthread-speak)
225 * fast mutexes, recursive mutexes, or nonrecursive ones.
226 *
227 * The _release/_signal/_broadcast and _destroy functions must
228 * always succeed when given a valid argument; if they are given an
229 * invalid argument then the program (crypto plugin + application)
230 * has an internal error, and they should abort the program.
231 */
232
233 int (*getpassphrase)(const char *prompt_info,
234 int *len_io, char *buf,
235 HWCryptoHook_PassphraseContext *ppctx,
236 HWCryptoHook_CallerContext *cactx);
237 /* Passphrases and the prompt_info, if they contain high-bit-set
238 * characters, are UTF-8. The prompt_info may be a null pointer if
239 * no prompt information is available (it should not be an empty
240 * string). It will not contain text like `enter passphrase';
241 * instead it might say something like `Operator Card for John
242 * Smith' or `SmartCard in nFast Module #1, Slot #1'.
243 *
244 * buf points to a buffer in which to return the passphrase; on
245 * entry *len_io is the length of the buffer. It should be updated
246 * by the callback. The returned passphrase should not be
247 * null-terminated by the callback.
248 */
249
250 int (*getphystoken)(const char *prompt_info,
251 const char *wrong_info,
252 HWCryptoHook_PassphraseContext *ppctx,
253 HWCryptoHook_CallerContext *cactx);
254 /* Requests that the human user physically insert a different
255 * smartcard, DataKey, etc. The plugin should check whether the
256 * currently inserted token(s) are appropriate, and if they are it
257 * should not make this call.
258 *
259 * prompt_info is as before. wrong_info is a description of the
260 * currently inserted token(s) so that the user is told what
261 * something is. wrong_info, like prompt_info, may be null, but
262 * should not be an empty string. Its contents should be
263 * syntactically similar to that of prompt_info.
264 */
265
266 /* Note that a single LoadKey operation might cause several calls to
267 * getpassphrase and/or requestphystoken. If requestphystoken is
268 * not provided (ie, a null pointer is passed) then the plugin may
269 * not support loading keys for which authorisation by several cards
270 * is required. If getpassphrase is not provided then cards with
271 * passphrases may not be supported.
272 *
273 * getpassphrase and getphystoken do not need to check that the
274 * passphrase has been entered correctly or the correct token
275 * inserted; the crypto plugin will do that. If this is not the
276 * case then the crypto plugin is responsible for calling these
277 * routines again as appropriate until the correct token(s) and
278 * passphrase(s) are supplied as required, or until any retry limits
279 * implemented by the crypto plugin are reached.
280 *
281 * In either case, the application must allow the user to say `no'
282 * or `cancel' to indicate that they do not know the passphrase or
283 * have the appropriate token; this should cause the callback to
284 * return nonzero indicating error.
285 */
286
287 void (*logmessage)(void *logstream, const char *message);
288 /* A log message will be generated at least every time something goes
289 * wrong and an ErrMsgBuf is filled in (or would be if one was
290 * provided). Other diagnostic information may be written there too,
291 * including more detailed reasons for errors which are reported in an
292 * ErrMsgBuf.
293 *
294 * When a log message is generated, this callback is called. It
295 * should write a message to the relevant logging arrangements.
296 *
297 * The message string passed will be null-terminated and may be of arbitrary
298 * length. It will not be prefixed by the time and date, nor by the
299 * name of the library that is generating it - if this is required,
300 * the logmessage callback must do it. The message will not have a
301 * trailing newline (though it may contain internal newlines).
302 *
303 * If a null pointer is passed for logmessage a default function is
304 * used. The default function treats logstream as a FILE* which has
305 * been converted to a void*. If logstream is 0 it does nothing.
306 * Otherwise it prepends the date and time and library name and
307 * writes the message to logstream. Each line will be prefixed by a
308 * descriptive string containing the date, time and identity of the
309 * crypto plugin. Errors on the logstream are not reported
310 * anywhere, and the default function doesn't flush the stream, so
311 * the application must set the buffering how it wants it.
312 *
313 * The crypto plugin may also provide a facility to have copies of
314 * log messages sent elsewhere, and or for adjusting the verbosity
315 * of the log messages; any such facilities will be configured by
316 * external means.
317 */
318
319} HWCryptoHook_InitInfo;
320
321typedef
322HWCryptoHook_ContextHandle HWCryptoHook_Init_t(const HWCryptoHook_InitInfo *initinfo,
323 size_t initinfosize,
324 const HWCryptoHook_ErrMsgBuf *errors,
325 HWCryptoHook_CallerContext *cactx);
326extern HWCryptoHook_Init_t HWCryptoHook_Init;
327
328/* Caller should set initinfosize to the size of the HWCryptoHook struct,
329 * so it can be extended later.
330 *
331 * On success, a message for display or logging by the server,
332 * including the name and version number of the plugin, will be filled
333 * in into *errors; on failure *errors is used for error handling, as
334 * usual.
335 */
336
337/* All these functions return 0 on success, HWCRYPTOHOOK_ERROR_FAILED
338 * on most failures. HWCRYPTOHOOK_ERROR_MPISIZE means at least one of
339 * the output MPI buffer(s) was too small; the sizes of all have been
340 * set to the desired size (and for those where the buffer was large
341 * enough, the value may have been copied in), and no error message
342 * has been recorded.
343 *
344 * You may pass 0 for the errors struct. In any case, unless you set
345 * _NoStderr at init time then messages may be reported to stderr.
346 */
347
348/* The RSAImmed* functions (and key managed RSA) only work with
349 * modules which have an RSA patent licence - currently that means KM
350 * units; the ModExp* ones work with all modules, so you need a patent
351 * licence in the software in the US. They are otherwise identical.
352 */
353
354typedef
355void HWCryptoHook_Finish_t(HWCryptoHook_ContextHandle hwctx);
356extern HWCryptoHook_Finish_t HWCryptoHook_Finish;
357/* You must not have any calls going or keys loaded when you call this. */
358
359typedef
360int HWCryptoHook_RandomBytes_t(HWCryptoHook_ContextHandle hwctx,
361 unsigned char *buf, size_t len,
362 const HWCryptoHook_ErrMsgBuf *errors);
363extern HWCryptoHook_RandomBytes_t HWCryptoHook_RandomBytes;
364
365typedef
366int HWCryptoHook_ModExp_t(HWCryptoHook_ContextHandle hwctx,
367 HWCryptoHook_MPI a,
368 HWCryptoHook_MPI p,
369 HWCryptoHook_MPI n,
370 HWCryptoHook_MPI *r,
371 const HWCryptoHook_ErrMsgBuf *errors);
372extern HWCryptoHook_ModExp_t HWCryptoHook_ModExp;
373
374typedef
375int HWCryptoHook_RSAImmedPub_t(HWCryptoHook_ContextHandle hwctx,
376 HWCryptoHook_MPI m,
377 HWCryptoHook_MPI e,
378 HWCryptoHook_MPI n,
379 HWCryptoHook_MPI *r,
380 const HWCryptoHook_ErrMsgBuf *errors);
381extern HWCryptoHook_RSAImmedPub_t HWCryptoHook_RSAImmedPub;
382
383typedef
384int HWCryptoHook_ModExpCRT_t(HWCryptoHook_ContextHandle hwctx,
385 HWCryptoHook_MPI a,
386 HWCryptoHook_MPI p,
387 HWCryptoHook_MPI q,
388 HWCryptoHook_MPI dmp1,
389 HWCryptoHook_MPI dmq1,
390 HWCryptoHook_MPI iqmp,
391 HWCryptoHook_MPI *r,
392 const HWCryptoHook_ErrMsgBuf *errors);
393extern HWCryptoHook_ModExpCRT_t HWCryptoHook_ModExpCRT;
394
395typedef
396int HWCryptoHook_RSAImmedPriv_t(HWCryptoHook_ContextHandle hwctx,
397 HWCryptoHook_MPI m,
398 HWCryptoHook_MPI p,
399 HWCryptoHook_MPI q,
400 HWCryptoHook_MPI dmp1,
401 HWCryptoHook_MPI dmq1,
402 HWCryptoHook_MPI iqmp,
403 HWCryptoHook_MPI *r,
404 const HWCryptoHook_ErrMsgBuf *errors);
405extern HWCryptoHook_RSAImmedPriv_t HWCryptoHook_RSAImmedPriv;
406
407/* The RSAImmed* and ModExp* functions may return E_FAILED or
408 * E_FALLBACK for failure.
409 *
410 * E_FAILED means the failure is permanent and definite and there
411 * should be no attempt to fall back to software. (Eg, for some
412 * applications, which support only the acceleration-only
413 * functions, the `key material' may actually be an encoded key
414 * identifier, and doing the operation in software would give wrong
415 * answers.)
416 *
417 * E_FALLBACK means that doing the computation in software would seem
418 * reasonable. If an application pays attention to this and is
419 * able to fall back, it should also set the Fallback init flags.
420 */
421
422typedef
423int HWCryptoHook_RSALoadKey_t(HWCryptoHook_ContextHandle hwctx,
424 const char *key_ident,
425 HWCryptoHook_RSAKeyHandle *keyhandle_r,
426 const HWCryptoHook_ErrMsgBuf *errors,
427 HWCryptoHook_PassphraseContext *ppctx);
428extern HWCryptoHook_RSALoadKey_t HWCryptoHook_RSALoadKey;
429/* The key_ident is a null-terminated string configured by the
430 * user via the application's usual configuration mechanisms.
431 * It is provided to the user by the crypto provider's key management
432 * system. The user must be able to enter at least any string of between
433 * 1 and 1023 characters inclusive, consisting of printable 7-bit
434 * ASCII characters. The provider should avoid using
435 * any characters except alphanumerics and the punctuation
436 * characters _ - + . / @ ~ (the user is expected to be able
437 * to enter these without quoting). The string may be case-sensitive.
438 * The application may allow the user to enter other NULL-terminated strings,
439 * and the provider must cope (returning an error if the string is not
440 * valid).
441 *
442 * If the key does not exist, no error is recorded and 0 is returned;
443 * keyhandle_r will be set to 0 instead of to a key handle.
444 */
445
446typedef
447int HWCryptoHook_RSAGetPublicKey_t(HWCryptoHook_RSAKeyHandle k,
448 HWCryptoHook_MPI *n,
449 HWCryptoHook_MPI *e,
450 const HWCryptoHook_ErrMsgBuf *errors);
451extern HWCryptoHook_RSAGetPublicKey_t HWCryptoHook_RSAGetPublicKey;
452/* The crypto plugin will not store certificates.
453 *
454 * Although this function for acquiring the public key value is
455 * provided, it is not the purpose of this API to deal fully with the
456 * handling of the public key.
457 *
458 * It is expected that the crypto supplier's key generation program
459 * will provide general facilities for producing X.509
460 * self-certificates and certificate requests in PEM format. These
461 * will be given to the user so that they can configure them in the
462 * application, send them to CAs, or whatever.
463 *
464 * In case this kind of certificate handling is not appropriate, the
465 * crypto supplier's key generation program should be able to be
466 * configured not to generate such a self-certificate or certificate
467 * request. Then the application will need to do all of this, and
468 * will need to store and handle the public key and certificates
469 * itself.
470 */
471
472typedef
473int HWCryptoHook_RSAUnloadKey_t(HWCryptoHook_RSAKeyHandle k,
474 const HWCryptoHook_ErrMsgBuf *errors);
475extern HWCryptoHook_RSAUnloadKey_t HWCryptoHook_RSAUnloadKey;
476/* Might fail due to locking problems, or other serious internal problems. */
477
478typedef
479int HWCryptoHook_RSA_t(HWCryptoHook_MPI m,
480 HWCryptoHook_RSAKeyHandle k,
481 HWCryptoHook_MPI *r,
482 const HWCryptoHook_ErrMsgBuf *errors);
483extern HWCryptoHook_RSA_t HWCryptoHook_RSA;
484/* RSA private key operation (sign or decrypt) - raw, unpadded. */
485
486#endif /*HWCRYPTOHOOK_H*/
diff --git a/src/lib/libcrypto/engine/vendor_defns/sureware.h b/src/lib/libcrypto/engine/vendor_defns/sureware.h
deleted file mode 100644
index 4bc22027f9..0000000000
--- a/src/lib/libcrypto/engine/vendor_defns/sureware.h
+++ /dev/null
@@ -1,239 +0,0 @@
1/*
2* Written by Corinne Dive-Reclus(cdive@baltimore.com)
3*
4* Copyright@2001 Baltimore Technologies Ltd.
5* *
6* THIS FILE IS PROVIDED BY BALTIMORE TECHNOLOGIES ``AS IS'' AND *
7* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
8* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
9* ARE DISCLAIMED. IN NO EVENT SHALL BALTIMORE TECHNOLOGIES BE LIABLE *
10* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
11* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
12* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
13* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
14* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
15* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
16* SUCH DAMAGE. *
17*
18*
19*/
20#ifdef WIN32
21#define SW_EXPORT __declspec ( dllexport )
22#else
23#define SW_EXPORT
24#endif
25
26/*
27* List of exposed SureWare errors
28*/
29#define SUREWAREHOOK_ERROR_FAILED -1
30#define SUREWAREHOOK_ERROR_FALLBACK -2
31#define SUREWAREHOOK_ERROR_UNIT_FAILURE -3
32#define SUREWAREHOOK_ERROR_DATA_SIZE -4
33#define SUREWAREHOOK_ERROR_INVALID_PAD -5
34/*
35* -----------------WARNING-----------------------------------
36* In all the following functions:
37* msg is a string with at least 24 bytes free.
38* A 24 bytes string will be concatenated to the existing content of msg.
39*/
40/*
41* SureWare Initialisation function
42* in param threadsafe, if !=0, thread safe enabled
43* return SureWareHOOK_ERROR_UNIT_FAILURE if failure, 1 if success
44*/
45typedef int SureWareHook_Init_t(char*const msg,int threadsafe);
46extern SW_EXPORT SureWareHook_Init_t SureWareHook_Init;
47/*
48* SureWare Finish function
49*/
50typedef void SureWareHook_Finish_t();
51extern SW_EXPORT SureWareHook_Finish_t SureWareHook_Finish;
52/*
53* PRE_CONDITION:
54* DO NOT CALL ANY OF THE FOLLOWING FUNCTIONS IN CASE OF INIT FAILURE
55*/
56/*
57* SureWare RAND Bytes function
58* In case of failure, the content of buf is unpredictable.
59* return 1 if success
60* SureWareHOOK_ERROR_FALLBACK if function not available in hardware
61* SureWareHOOK_ERROR_FAILED if error while processing
62* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
63* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
64*
65* in/out param buf : a num bytes long buffer where random bytes will be put
66* in param num : the number of bytes into buf
67*/
68typedef int SureWareHook_Rand_Bytes_t(char*const msg,unsigned char *buf, int num);
69extern SW_EXPORT SureWareHook_Rand_Bytes_t SureWareHook_Rand_Bytes;
70
71/*
72* SureWare RAND Seed function
73* Adds some seed to the Hardware Random Number Generator
74* return 1 if success
75* SureWareHOOK_ERROR_FALLBACK if function not available in hardware
76* SureWareHOOK_ERROR_FAILED if error while processing
77* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
78* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
79*
80* in param buf : the seed to add into the HRNG
81* in param num : the number of bytes into buf
82*/
83typedef int SureWareHook_Rand_Seed_t(char*const msg,const void *buf, int num);
84extern SW_EXPORT SureWareHook_Rand_Seed_t SureWareHook_Rand_Seed;
85
86/*
87* SureWare Load Private Key function
88* return 1 if success
89* SureWareHOOK_ERROR_FAILED if error while processing
90* No hardware is contact for this function.
91*
92* in param key_id :the name of the private protected key file without the extension
93 ".sws"
94* out param hptr : a pointer to a buffer allocated by SureWare_Hook
95* out param num: the effective key length in bytes
96* out param keytype: 1 if RSA 2 if DSA
97*/
98typedef int SureWareHook_Load_Privkey_t(char*const msg,const char *key_id,char **hptr,unsigned long *num,char *keytype);
99extern SW_EXPORT SureWareHook_Load_Privkey_t SureWareHook_Load_Privkey;
100
101/*
102* SureWare Info Public Key function
103* return 1 if success
104* SureWareHOOK_ERROR_FAILED if error while processing
105* No hardware is contact for this function.
106*
107* in param key_id :the name of the private protected key file without the extension
108 ".swp"
109* out param hptr : a pointer to a buffer allocated by SureWare_Hook
110* out param num: the effective key length in bytes
111* out param keytype: 1 if RSA 2 if DSA
112*/
113typedef int SureWareHook_Info_Pubkey_t(char*const msg,const char *key_id,unsigned long *num,
114 char *keytype);
115extern SW_EXPORT SureWareHook_Info_Pubkey_t SureWareHook_Info_Pubkey;
116
117/*
118* SureWare Load Public Key function
119* return 1 if success
120* SureWareHOOK_ERROR_FAILED if error while processing
121* No hardware is contact for this function.
122*
123* in param key_id :the name of the public protected key file without the extension
124 ".swp"
125* in param num : the bytes size of n and e
126* out param n: where to write modulus in bn format
127* out param e: where to write exponent in bn format
128*/
129typedef int SureWareHook_Load_Rsa_Pubkey_t(char*const msg,const char *key_id,unsigned long num,
130 unsigned long *n, unsigned long *e);
131extern SW_EXPORT SureWareHook_Load_Rsa_Pubkey_t SureWareHook_Load_Rsa_Pubkey;
132
133/*
134* SureWare Load DSA Public Key function
135* return 1 if success
136* SureWareHOOK_ERROR_FAILED if error while processing
137* No hardware is contact for this function.
138*
139* in param key_id :the name of the public protected key file without the extension
140 ".swp"
141* in param num : the bytes size of n and e
142* out param pub: where to write pub key in bn format
143* out param p: where to write prime in bn format
144* out param q: where to write sunprime (length 20 bytes) in bn format
145* out param g: where to write base in bn format
146*/
147typedef int SureWareHook_Load_Dsa_Pubkey_t(char*const msg,const char *key_id,unsigned long num,
148 unsigned long *pub, unsigned long *p,unsigned long*q,
149 unsigned long *g);
150extern SW_EXPORT SureWareHook_Load_Dsa_Pubkey_t SureWareHook_Load_Dsa_Pubkey;
151
152/*
153* SureWare Free function
154* Destroy the key into the hardware if destroy==1
155*/
156typedef void SureWareHook_Free_t(char *p,int destroy);
157extern SW_EXPORT SureWareHook_Free_t SureWareHook_Free;
158
159#define SUREWARE_PKCS1_PAD 1
160#define SUREWARE_ISO9796_PAD 2
161#define SUREWARE_NO_PAD 0
162/*
163* SureWare RSA Private Decryption
164* return 1 if success
165* SureWareHOOK_ERROR_FAILED if error while processing
166* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
167* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
168*
169* in param flen : byte size of from and to
170* in param from : encrypted data buffer, should be a not-null valid pointer
171* out param tlen: byte size of decrypted data, if error, unexpected value
172* out param to : decrypted data buffer, should be a not-null valid pointer
173* in param prsa: a protected key pointer, should be a not-null valid pointer
174* int padding: padding id as follow
175* SUREWARE_PKCS1_PAD
176* SUREWARE_NO_PAD
177*
178*/
179typedef int SureWareHook_Rsa_Priv_Dec_t(char*const msg,int flen,unsigned char *from,
180 int *tlen,unsigned char *to,
181 char *prsa,int padding);
182extern SW_EXPORT SureWareHook_Rsa_Priv_Dec_t SureWareHook_Rsa_Priv_Dec;
183/*
184* SureWare RSA Signature
185* return 1 if success
186* SureWareHOOK_ERROR_FAILED if error while processing
187* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
188* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
189*
190* in param flen : byte size of from and to
191* in param from : encrypted data buffer, should be a not-null valid pointer
192* out param tlen: byte size of decrypted data, if error, unexpected value
193* out param to : decrypted data buffer, should be a not-null valid pointer
194* in param prsa: a protected key pointer, should be a not-null valid pointer
195* int padding: padding id as follow
196* SUREWARE_PKCS1_PAD
197* SUREWARE_ISO9796_PAD
198*
199*/
200typedef int SureWareHook_Rsa_Sign_t(char*const msg,int flen,unsigned char *from,
201 int *tlen,unsigned char *to,
202 char *prsa,int padding);
203extern SW_EXPORT SureWareHook_Rsa_Sign_t SureWareHook_Rsa_Sign;
204/*
205* SureWare DSA Signature
206* return 1 if success
207* SureWareHOOK_ERROR_FAILED if error while processing
208* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
209* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
210*
211* in param flen : byte size of from and to
212* in param from : encrypted data buffer, should be a not-null valid pointer
213* out param to : decrypted data buffer, should be a 40bytes valid pointer
214* in param pdsa: a protected key pointer, should be a not-null valid pointer
215*
216*/
217typedef int SureWareHook_Dsa_Sign_t(char*const msg,int flen,const unsigned char *from,
218 unsigned long *r,unsigned long *s,char *pdsa);
219extern SW_EXPORT SureWareHook_Dsa_Sign_t SureWareHook_Dsa_Sign;
220
221
222/*
223* SureWare Mod Exp
224* return 1 if success
225* SureWareHOOK_ERROR_FAILED if error while processing
226* SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
227* SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
228*
229* mod and res are mlen bytes long.
230* exp is elen bytes long
231* data is dlen bytes long
232* mlen,elen and dlen are all multiple of sizeof(unsigned long)
233*/
234typedef int SureWareHook_Mod_Exp_t(char*const msg,int mlen,const unsigned long *mod,
235 int elen,const unsigned long *exponent,
236 int dlen,unsigned long *data,
237 unsigned long *res);
238extern SW_EXPORT SureWareHook_Mod_Exp_t SureWareHook_Mod_Exp;
239
diff --git a/src/lib/libcrypto/err/err_def.c b/src/lib/libcrypto/err/err_def.c
deleted file mode 100644
index 7ed3d84955..0000000000
--- a/src/lib/libcrypto/err/err_def.c
+++ /dev/null
@@ -1,665 +0,0 @@
1/* crypto/err/err_def.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 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111
112#include <stdio.h>
113#include <stdarg.h>
114#include <string.h>
115#include "cryptlib.h"
116#include <openssl/lhash.h>
117#include <openssl/crypto.h>
118#include <openssl/buffer.h>
119#include <openssl/bio.h>
120#include <openssl/err.h>
121
122#define err_clear_data(p,i) \
123 do { \
124 if (((p)->err_data[i] != NULL) && \
125 (p)->err_data_flags[i] & ERR_TXT_MALLOCED) \
126 { \
127 OPENSSL_free((p)->err_data[i]); \
128 (p)->err_data[i]=NULL; \
129 } \
130 (p)->err_data_flags[i]=0; \
131 } while(0)
132
133#define err_clear(p,i) \
134 do { \
135 (p)->err_flags[i]=0; \
136 (p)->err_buffer[i]=0; \
137 err_clear_data(p,i); \
138 (p)->err_file[i]=NULL; \
139 (p)->err_line[i]= -1; \
140 } while(0)
141
142static void err_load_strings(int lib, ERR_STRING_DATA *str);
143
144static void ERR_STATE_free(ERR_STATE *s);
145
146/* Define the predeclared (but externally opaque) "ERR_FNS" type */
147struct st_ERR_FNS
148 {
149 /* Works on the "error_hash" string table */
150 LHASH *(*cb_err_get)(int create);
151 void (*cb_err_del)(void);
152 ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *);
153 ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *);
154 ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *);
155 /* Works on the "thread_hash" error-state table */
156 LHASH *(*cb_thread_get)(int create);
157 void (*cb_thread_release)(LHASH **hash);
158 ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *);
159 ERR_STATE *(*cb_thread_set_item)(ERR_STATE *);
160 void (*cb_thread_del_item)(const ERR_STATE *);
161 /* Returns the next available error "library" numbers */
162 int (*cb_get_next_lib)(void);
163 };
164
165/* Predeclarations of the "err_defaults" functions */
166static LHASH *int_err_get(int create);
167static void int_err_del(void);
168static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
169static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *);
170static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *);
171static LHASH *int_thread_get(int create);
172static void int_thread_release(LHASH **hash);
173static ERR_STATE *int_thread_get_item(const ERR_STATE *);
174static ERR_STATE *int_thread_set_item(ERR_STATE *);
175static void int_thread_del_item(const ERR_STATE *);
176static int int_err_get_next_lib(void);
177/* The static ERR_FNS table using these defaults functions */
178static const ERR_FNS err_defaults =
179 {
180 int_err_get,
181 int_err_del,
182 int_err_get_item,
183 int_err_set_item,
184 int_err_del_item,
185 int_thread_get,
186 int_thread_release,
187 int_thread_get_item,
188 int_thread_set_item,
189 int_thread_del_item,
190 int_err_get_next_lib
191 };
192
193/* The replacable table of ERR_FNS functions we use at run-time */
194static const ERR_FNS *err_fns = NULL;
195
196/* Eg. rather than using "err_get()", use "ERRFN(err_get)()". */
197#define ERRFN(a) err_fns->cb_##a
198
199/* The internal state used by "err_defaults" - as such, the setting, reading,
200 * creating, and deleting of this data should only be permitted via the
201 * "err_defaults" functions. This way, a linked module can completely defer all
202 * ERR state operation (together with requisite locking) to the implementations
203 * and state in the loading application. */
204static LHASH *int_error_hash = NULL;
205static LHASH *int_thread_hash = NULL;
206static int int_thread_hash_references = 0;
207static int int_err_library_number= ERR_LIB_USER;
208
209/* Internal function that checks whether "err_fns" is set and if not, sets it to
210 * the defaults. */
211static void err_fns_check(void)
212 {
213 if (err_fns) return;
214
215 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
216 if (!err_fns)
217 err_fns = &err_defaults;
218 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
219 }
220
221/* API functions to get or set the underlying ERR functions. */
222
223const ERR_FNS *ERR_get_implementation(void)
224 {
225 err_fns_check();
226 return err_fns;
227 }
228
229int ERR_set_implementation(const ERR_FNS *fns)
230 {
231 int ret = 0;
232
233 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
234 /* It's too late if 'err_fns' is non-NULL. BTW: not much point setting
235 * an error is there?! */
236 if (!err_fns)
237 {
238 err_fns = fns;
239 ret = 1;
240 }
241 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
242 return ret;
243 }
244
245/* These are the callbacks provided to "lh_new()" when creating the LHASH tables
246 * internal to the "err_defaults" implementation. */
247
248/* static unsigned long err_hash(ERR_STRING_DATA *a); */
249static unsigned long err_hash(const void *a_void);
250/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b); */
251static int err_cmp(const void *a_void, const void *b_void);
252/* static unsigned long pid_hash(ERR_STATE *pid); */
253static unsigned long pid_hash(const void *pid_void);
254/* static int pid_cmp(ERR_STATE *a,ERR_STATE *pid); */
255static int pid_cmp(const void *a_void,const void *pid_void);
256
257/* The internal functions used in the "err_defaults" implementation */
258
259static LHASH *int_err_get(int create)
260 {
261 LHASH *ret = NULL;
262
263 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
264 if (!int_error_hash && create)
265 {
266 CRYPTO_push_info("int_err_get (err.c)");
267 int_error_hash = lh_new(err_hash, err_cmp);
268 CRYPTO_pop_info();
269 }
270 if (int_error_hash)
271 ret = int_error_hash;
272 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
273
274 return ret;
275 }
276
277static void int_err_del(void)
278 {
279 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
280 if (int_error_hash)
281 {
282 lh_free(int_error_hash);
283 int_error_hash = NULL;
284 }
285 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
286 }
287
288static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
289 {
290 ERR_STRING_DATA *p;
291 LHASH *hash;
292
293 err_fns_check();
294 hash = ERRFN(err_get)(0);
295 if (!hash)
296 return NULL;
297
298 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
299 p = (ERR_STRING_DATA *)lh_retrieve(hash, d);
300 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
301
302 return p;
303 }
304
305static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d)
306 {
307 ERR_STRING_DATA *p;
308 LHASH *hash;
309
310 err_fns_check();
311 hash = ERRFN(err_get)(1);
312 if (!hash)
313 return NULL;
314
315 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
316 p = (ERR_STRING_DATA *)lh_insert(hash, d);
317 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
318
319 return p;
320 }
321
322static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
323 {
324 ERR_STRING_DATA *p;
325 LHASH *hash;
326
327 err_fns_check();
328 hash = ERRFN(err_get)(0);
329 if (!hash)
330 return NULL;
331
332 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
333 p = (ERR_STRING_DATA *)lh_delete(hash, d);
334 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
335
336 return p;
337 }
338
339static LHASH *int_thread_get(int create)
340 {
341 LHASH *ret = NULL;
342
343 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
344 if (!int_thread_hash && create)
345 {
346 CRYPTO_push_info("int_thread_get (err.c)");
347 int_thread_hash = lh_new(pid_hash, pid_cmp);
348 CRYPTO_pop_info();
349 }
350 if (int_thread_hash)
351 {
352 int_thread_hash_references++;
353 ret = int_thread_hash;
354 }
355 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
356 return ret;
357 }
358
359static void int_thread_release(LHASH **hash)
360 {
361 int i;
362
363 if (hash == NULL || *hash == NULL)
364 return;
365
366 i = CRYPTO_add(&int_thread_hash_references, -1, CRYPTO_LOCK_ERR);
367
368#ifdef REF_PRINT
369 fprintf(stderr,"%4d:%s\n",int_thread_hash_references,"ERR");
370#endif
371 if (i > 0) return;
372#ifdef REF_CHECK
373 if (i < 0)
374 {
375 fprintf(stderr,"int_thread_release, bad reference count\n");
376 abort(); /* ok */
377 }
378#endif
379 *hash = NULL;
380 }
381
382static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
383 {
384 ERR_STATE *p;
385 LHASH *hash;
386
387 err_fns_check();
388 hash = ERRFN(thread_get)(0);
389 if (!hash)
390 return NULL;
391
392 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
393 p = (ERR_STATE *)lh_retrieve(hash, d);
394 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
395
396 ERRFN(thread_release)(&hash);
397 return p;
398 }
399
400static ERR_STATE *int_thread_set_item(ERR_STATE *d)
401 {
402 ERR_STATE *p;
403 LHASH *hash;
404
405 err_fns_check();
406 hash = ERRFN(thread_get)(1);
407 if (!hash)
408 return NULL;
409
410 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
411 p = (ERR_STATE *)lh_insert(hash, d);
412 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
413
414 ERRFN(thread_release)(&hash);
415 return p;
416 }
417
418static void int_thread_del_item(const ERR_STATE *d)
419 {
420 ERR_STATE *p;
421 LHASH *hash;
422
423 err_fns_check();
424 hash = ERRFN(thread_get)(0);
425 if (!hash)
426 return;
427
428 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
429 p = (ERR_STATE *)lh_delete(hash, d);
430 /* make sure we don't leak memory */
431 if (int_thread_hash_references == 1
432 && int_thread_hash && (lh_num_items(int_thread_hash) == 0))
433 {
434 lh_free(int_thread_hash);
435 int_thread_hash = NULL;
436 }
437 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
438
439 ERRFN(thread_release)(&hash);
440 if (p)
441 ERR_STATE_free(p);
442 }
443
444static int int_err_get_next_lib(void)
445 {
446 int ret;
447
448 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
449 ret = int_err_library_number++;
450 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
451
452 return ret;
453 }
454
455static void ERR_STATE_free(ERR_STATE *s)
456 {
457 int i;
458
459 if (s == NULL)
460 return;
461
462 for (i=0; i<ERR_NUM_ERRORS; i++)
463 {
464 err_clear_data(s,i);
465 }
466 OPENSSL_free(s);
467 }
468
469static void err_load_strings(int lib, ERR_STRING_DATA *str)
470 {
471 while (str->error)
472 {
473 if (lib)
474 str->error|=ERR_PACK(lib,0,0);
475 ERRFN(err_set_item)(str);
476 str++;
477 }
478 }
479
480void ERR_load_strings(int lib, ERR_STRING_DATA *str)
481 {
482 err_fns_check();
483 err_load_strings(lib, str);
484 }
485
486void ERR_unload_strings(int lib, ERR_STRING_DATA *str)
487 {
488 while (str->error)
489 {
490 if (lib)
491 str->error|=ERR_PACK(lib,0,0);
492 ERRFN(err_del_item)(str);
493 str++;
494 }
495 }
496
497void ERR_free_strings(void)
498 {
499 err_fns_check();
500 ERRFN(err_del)();
501 }
502
503LHASH *ERR_get_string_table(void)
504 {
505 err_fns_check();
506 return ERRFN(err_get)(0);
507 }
508
509LHASH *ERR_get_err_state_table(void)
510 {
511 err_fns_check();
512 return ERRFN(thread_get)(0);
513 }
514
515void ERR_release_err_state_table(LHASH **hash)
516 {
517 err_fns_check();
518 ERRFN(thread_release)(hash);
519 }
520
521const char *ERR_lib_error_string(unsigned long e)
522 {
523 ERR_STRING_DATA d,*p;
524 unsigned long l;
525
526 err_fns_check();
527 l=ERR_GET_LIB(e);
528 d.error=ERR_PACK(l,0,0);
529 p=ERRFN(err_get_item)(&d);
530 return((p == NULL)?NULL:p->string);
531 }
532
533const char *ERR_func_error_string(unsigned long e)
534 {
535 ERR_STRING_DATA d,*p;
536 unsigned long l,f;
537
538 err_fns_check();
539 l=ERR_GET_LIB(e);
540 f=ERR_GET_FUNC(e);
541 d.error=ERR_PACK(l,f,0);
542 p=ERRFN(err_get_item)(&d);
543 return((p == NULL)?NULL:p->string);
544 }
545
546const char *ERR_reason_error_string(unsigned long e)
547 {
548 ERR_STRING_DATA d,*p=NULL;
549 unsigned long l,r;
550
551 err_fns_check();
552 l=ERR_GET_LIB(e);
553 r=ERR_GET_REASON(e);
554 d.error=ERR_PACK(l,0,r);
555 p=ERRFN(err_get_item)(&d);
556 if (!p)
557 {
558 d.error=ERR_PACK(0,0,r);
559 p=ERRFN(err_get_item)(&d);
560 }
561 return((p == NULL)?NULL:p->string);
562 }
563
564/* static unsigned long err_hash(ERR_STRING_DATA *a) */
565static unsigned long err_hash(const void *a_void)
566 {
567 unsigned long ret,l;
568
569 l=((const ERR_STRING_DATA *)a_void)->error;
570 ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
571 return(ret^ret%19*13);
572 }
573
574/* static int err_cmp(ERR_STRING_DATA *a, ERR_STRING_DATA *b) */
575static int err_cmp(const void *a_void, const void *b_void)
576 {
577 return((int)(((const ERR_STRING_DATA *)a_void)->error -
578 ((const ERR_STRING_DATA *)b_void)->error));
579 }
580
581/* static unsigned long pid_hash(ERR_STATE *a) */
582static unsigned long pid_hash(const void *a_void)
583 {
584 return(((const ERR_STATE *)a_void)->pid*13);
585 }
586
587/* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */
588static int pid_cmp(const void *a_void, const void *b_void)
589 {
590 return((int)((long)((const ERR_STATE *)a_void)->pid -
591 (long)((const ERR_STATE *)b_void)->pid));
592 }
593#ifdef OPENSSL_FIPS
594static void int_err_remove_state(unsigned long pid)
595#else
596void ERR_remove_state(unsigned long pid)
597#endif
598 {
599 ERR_STATE tmp;
600
601 err_fns_check();
602 if (pid == 0)
603 pid=(unsigned long)CRYPTO_thread_id();
604 tmp.pid=pid;
605 /* thread_del_item automatically destroys the LHASH if the number of
606 * items reaches zero. */
607 ERRFN(thread_del_item)(&tmp);
608 }
609
610#ifdef OPENSSL_FIPS
611 static ERR_STATE *int_err_get_state(void)
612#else
613ERR_STATE *ERR_get_state(void)
614#endif
615 {
616 static ERR_STATE fallback;
617 ERR_STATE *ret,tmp,*tmpp=NULL;
618 int i;
619 unsigned long pid;
620
621 err_fns_check();
622 pid=(unsigned long)CRYPTO_thread_id();
623 tmp.pid=pid;
624 ret=ERRFN(thread_get_item)(&tmp);
625
626 /* ret == the error state, if NULL, make a new one */
627 if (ret == NULL)
628 {
629 ret=(ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE));
630 if (ret == NULL) return(&fallback);
631 ret->pid=pid;
632 ret->top=0;
633 ret->bottom=0;
634 for (i=0; i<ERR_NUM_ERRORS; i++)
635 {
636 ret->err_data[i]=NULL;
637 ret->err_data_flags[i]=0;
638 }
639 tmpp = ERRFN(thread_set_item)(ret);
640 /* To check if insertion failed, do a get. */
641 if (ERRFN(thread_get_item)(ret) != ret)
642 {
643 ERR_STATE_free(ret); /* could not insert it */
644 return(&fallback);
645 }
646 /* If a race occured in this function and we came second, tmpp
647 * is the first one that we just replaced. */
648 if (tmpp)
649 ERR_STATE_free(tmpp);
650 }
651 return ret;
652 }
653
654#ifdef OPENSSL_FIPS
655void int_ERR_lib_init(void)
656 {
657 int_ERR_set_state_func(int_err_get_state, int_err_remove_state);
658 }
659#endif
660
661int ERR_get_next_error_library(void)
662 {
663 err_fns_check();
664 return ERRFN(get_next_lib)();
665 }
diff --git a/src/lib/libcrypto/err/err_str.c b/src/lib/libcrypto/err/err_str.c
deleted file mode 100644
index d39040888d..0000000000
--- a/src/lib/libcrypto/err/err_str.c
+++ /dev/null
@@ -1,295 +0,0 @@
1/* crypto/err/err_str.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 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111
112#include <stdio.h>
113#include <stdarg.h>
114#include <string.h>
115#include "cryptlib.h"
116#include <openssl/lhash.h>
117#include <openssl/crypto.h>
118#include <openssl/buffer.h>
119#include <openssl/bio.h>
120#include <openssl/err.h>
121
122#ifndef OPENSSL_NO_ERR
123static ERR_STRING_DATA ERR_str_libraries[]=
124 {
125{ERR_PACK(ERR_LIB_NONE,0,0) ,"unknown library"},
126{ERR_PACK(ERR_LIB_SYS,0,0) ,"system library"},
127{ERR_PACK(ERR_LIB_BN,0,0) ,"bignum routines"},
128{ERR_PACK(ERR_LIB_RSA,0,0) ,"rsa routines"},
129{ERR_PACK(ERR_LIB_DH,0,0) ,"Diffie-Hellman routines"},
130{ERR_PACK(ERR_LIB_EVP,0,0) ,"digital envelope routines"},
131{ERR_PACK(ERR_LIB_BUF,0,0) ,"memory buffer routines"},
132{ERR_PACK(ERR_LIB_OBJ,0,0) ,"object identifier routines"},
133{ERR_PACK(ERR_LIB_PEM,0,0) ,"PEM routines"},
134{ERR_PACK(ERR_LIB_DSA,0,0) ,"dsa routines"},
135{ERR_PACK(ERR_LIB_X509,0,0) ,"x509 certificate routines"},
136{ERR_PACK(ERR_LIB_ASN1,0,0) ,"asn1 encoding routines"},
137{ERR_PACK(ERR_LIB_CONF,0,0) ,"configuration file routines"},
138{ERR_PACK(ERR_LIB_CRYPTO,0,0) ,"common libcrypto routines"},
139{ERR_PACK(ERR_LIB_EC,0,0) ,"elliptic curve routines"},
140{ERR_PACK(ERR_LIB_SSL,0,0) ,"SSL routines"},
141{ERR_PACK(ERR_LIB_BIO,0,0) ,"BIO routines"},
142{ERR_PACK(ERR_LIB_PKCS7,0,0) ,"PKCS7 routines"},
143{ERR_PACK(ERR_LIB_X509V3,0,0) ,"X509 V3 routines"},
144{ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"},
145{ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"},
146{ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"},
147{ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"},
148{ERR_PACK(ERR_LIB_OCSP,0,0) ,"OCSP routines"},
149{ERR_PACK(ERR_LIB_FIPS,0,0) ,"FIPS routines"},
150{ERR_PACK(ERR_LIB_CMS,0,0) ,"CMS routines"},
151{ERR_PACK(ERR_LIB_JPAKE,0,0) ,"JPAKE routines"},
152{0,NULL},
153 };
154
155static ERR_STRING_DATA ERR_str_functs[]=
156 {
157 {ERR_PACK(0,SYS_F_FOPEN,0), "fopen"},
158 {ERR_PACK(0,SYS_F_CONNECT,0), "connect"},
159 {ERR_PACK(0,SYS_F_GETSERVBYNAME,0), "getservbyname"},
160 {ERR_PACK(0,SYS_F_SOCKET,0), "socket"},
161 {ERR_PACK(0,SYS_F_IOCTLSOCKET,0), "ioctlsocket"},
162 {ERR_PACK(0,SYS_F_BIND,0), "bind"},
163 {ERR_PACK(0,SYS_F_LISTEN,0), "listen"},
164 {ERR_PACK(0,SYS_F_ACCEPT,0), "accept"},
165#ifdef OPENSSL_SYS_WINDOWS
166 {ERR_PACK(0,SYS_F_WSASTARTUP,0), "WSAstartup"},
167#endif
168 {ERR_PACK(0,SYS_F_OPENDIR,0), "opendir"},
169 {ERR_PACK(0,SYS_F_FREAD,0), "fread"},
170 {0,NULL},
171 };
172
173static ERR_STRING_DATA ERR_str_reasons[]=
174 {
175{ERR_R_SYS_LIB ,"system lib"},
176{ERR_R_BN_LIB ,"BN lib"},
177{ERR_R_RSA_LIB ,"RSA lib"},
178{ERR_R_DH_LIB ,"DH lib"},
179{ERR_R_EVP_LIB ,"EVP lib"},
180{ERR_R_BUF_LIB ,"BUF lib"},
181{ERR_R_OBJ_LIB ,"OBJ lib"},
182{ERR_R_PEM_LIB ,"PEM lib"},
183{ERR_R_DSA_LIB ,"DSA lib"},
184{ERR_R_X509_LIB ,"X509 lib"},
185{ERR_R_ASN1_LIB ,"ASN1 lib"},
186{ERR_R_CONF_LIB ,"CONF lib"},
187{ERR_R_CRYPTO_LIB ,"CRYPTO lib"},
188{ERR_R_EC_LIB ,"EC lib"},
189{ERR_R_SSL_LIB ,"SSL lib"},
190{ERR_R_BIO_LIB ,"BIO lib"},
191{ERR_R_PKCS7_LIB ,"PKCS7 lib"},
192{ERR_R_X509V3_LIB ,"X509V3 lib"},
193{ERR_R_PKCS12_LIB ,"PKCS12 lib"},
194{ERR_R_RAND_LIB ,"RAND lib"},
195{ERR_R_DSO_LIB ,"DSO lib"},
196{ERR_R_ENGINE_LIB ,"ENGINE lib"},
197{ERR_R_OCSP_LIB ,"OCSP lib"},
198
199{ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"},
200{ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"},
201{ERR_R_BAD_GET_ASN1_OBJECT_CALL ,"bad get asn1 object call"},
202{ERR_R_EXPECTING_AN_ASN1_SEQUENCE ,"expecting an asn1 sequence"},
203{ERR_R_ASN1_LENGTH_MISMATCH ,"asn1 length mismatch"},
204{ERR_R_MISSING_ASN1_EOS ,"missing asn1 eos"},
205
206{ERR_R_FATAL ,"fatal"},
207{ERR_R_MALLOC_FAILURE ,"malloc failure"},
208{ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED ,"called a function you should not call"},
209{ERR_R_PASSED_NULL_PARAMETER ,"passed a null parameter"},
210{ERR_R_INTERNAL_ERROR ,"internal error"},
211{ERR_R_DISABLED ,"called a function that was disabled at compile-time"},
212
213{0,NULL},
214 };
215#endif
216
217#ifndef OPENSSL_NO_ERR
218#define NUM_SYS_STR_REASONS 127
219#define LEN_SYS_STR_REASON 32
220
221static ERR_STRING_DATA SYS_str_reasons[NUM_SYS_STR_REASONS + 1];
222/* SYS_str_reasons is filled with copies of strerror() results at
223 * initialization.
224 * 'errno' values up to 127 should cover all usual errors,
225 * others will be displayed numerically by ERR_error_string.
226 * It is crucial that we have something for each reason code
227 * that occurs in ERR_str_reasons, or bogus reason strings
228 * will be returned for SYSerr, which always gets an errno
229 * value and never one of those 'standard' reason codes. */
230
231static void build_SYS_str_reasons(void)
232 {
233 /* OPENSSL_malloc cannot be used here, use static storage instead */
234 static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON];
235 int i;
236 static int init = 1;
237
238 CRYPTO_r_lock(CRYPTO_LOCK_ERR);
239 if (!init)
240 {
241 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
242 return;
243 }
244
245 CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
246 CRYPTO_w_lock(CRYPTO_LOCK_ERR);
247 if (!init)
248 {
249 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
250 return;
251 }
252
253 for (i = 1; i <= NUM_SYS_STR_REASONS; i++)
254 {
255 ERR_STRING_DATA *str = &SYS_str_reasons[i - 1];
256
257 str->error = (unsigned long)i;
258 if (str->string == NULL)
259 {
260 char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]);
261 char *src = strerror(i);
262 if (src != NULL)
263 {
264 strncpy(*dest, src, sizeof *dest);
265 (*dest)[sizeof *dest - 1] = '\0';
266 str->string = *dest;
267 }
268 }
269 if (str->string == NULL)
270 str->string = "unknown";
271 }
272
273 /* Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL},
274 * as required by ERR_load_strings. */
275
276 init = 0;
277
278 CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
279 }
280#endif
281
282void ERR_load_ERR_strings(void)
283 {
284#ifndef OPENSSL_NO_ERR
285 if (ERR_func_error_string(ERR_str_functs[0].error) == NULL)
286 {
287 ERR_load_strings(0,ERR_str_libraries);
288 ERR_load_strings(0,ERR_str_reasons);
289 ERR_load_strings(ERR_LIB_SYS,ERR_str_functs);
290 build_SYS_str_reasons();
291 ERR_load_strings(ERR_LIB_SYS,SYS_str_reasons);
292 }
293#endif
294 }
295
diff --git a/src/lib/libcrypto/engine/hw_atalla_err.h b/src/lib/libcrypto/evp/e_seed.c
index cdac052d8c..2d1759d276 100644
--- a/src/lib/libcrypto/engine/hw_atalla_err.h
+++ b/src/lib/libcrypto/evp/e_seed.c
@@ -1,5 +1,6 @@
1/* crypto/evp/e_seed.c -*- mode:C; c-file-style: "eay" -*- */
1/* ==================================================================== 2/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2007 The OpenSSL Project. All rights reserved.
3 * 4 *
4 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -52,38 +53,31 @@
52 * 53 *
53 */ 54 */
54 55
55#ifndef HEADER_ATALLA_ERR_H 56#include <openssl/opensslconf.h>
56#define HEADER_ATALLA_ERR_H 57#ifndef OPENSSL_NO_SEED
58#include <openssl/evp.h>
59#include <openssl/err.h>
60#include <string.h>
61#include <assert.h>
62#include <openssl/seed.h>
63#include "evp_locl.h"
57 64
58/* BEGIN ERROR CODES */ 65static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc);
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_ATALLA_strings(void);
63static void ERR_unload_ATALLA_strings(void);
64static void ERR_ATALLA_error(int function, int reason, char *file, int line);
65#define ATALLAerr(f,r) ERR_ATALLA_error((f),(r),__FILE__,__LINE__)
66 66
67/* Error codes for the ATALLA functions. */ 67typedef struct
68 {
69 SEED_KEY_SCHEDULE ks;
70 } EVP_SEED_KEY;
68 71
69/* Function codes. */ 72IMPLEMENT_BLOCK_CIPHER(seed, ks, SEED, EVP_SEED_KEY, NID_seed,
70#define ATALLA_F_ATALLA_CTRL 100 73 16, 16, 16, 128,
71#define ATALLA_F_ATALLA_FINISH 101 74 0, seed_init_key, 0, 0, 0, 0)
72#define ATALLA_F_ATALLA_INIT 102
73#define ATALLA_F_ATALLA_MOD_EXP 103
74#define ATALLA_F_ATALLA_RSA_MOD_EXP 104
75 75
76/* Reason codes. */ 76static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
77#define ATALLA_R_ALREADY_LOADED 100 77 const unsigned char *iv, int enc)
78#define ATALLA_R_BN_CTX_FULL 101 78 {
79#define ATALLA_R_BN_EXPAND_FAIL 102 79 SEED_set_key(key, ctx->cipher_data);
80#define ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED 103 80 return 1;
81#define ATALLA_R_MISSING_KEY_COMPONENTS 104 81 }
82#define ATALLA_R_NOT_LOADED 105
83#define ATALLA_R_REQUEST_FAILED 106
84#define ATALLA_R_UNIT_FAILURE 107
85 82
86#ifdef __cplusplus
87}
88#endif
89#endif 83#endif
diff --git a/src/lib/libcrypto/evp/enc_min.c b/src/lib/libcrypto/evp/enc_min.c
deleted file mode 100644
index 7fba38ee24..0000000000
--- a/src/lib/libcrypto/evp/enc_min.c
+++ /dev/null
@@ -1,390 +0,0 @@
1/* crypto/evp/enc_min.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 <openssl/evp.h>
62#include <openssl/err.h>
63#include <openssl/rand.h>
64#ifndef OPENSSL_NO_ENGINE
65#include <openssl/engine.h>
66#endif
67#include "evp_locl.h"
68
69void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
70 {
71#ifdef OPENSSL_FIPS
72 FIPS_selftest_check();
73#endif
74 memset(ctx,0,sizeof(EVP_CIPHER_CTX));
75 /* ctx->cipher=NULL; */
76 }
77
78#ifdef OPENSSL_FIPS
79
80/* The purpose of these is to trap programs that attempt to use non FIPS
81 * algorithms in FIPS mode and ignore the errors.
82 */
83
84static int bad_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
85 const unsigned char *iv, int enc)
86 { FIPS_ERROR_IGNORED("Cipher init"); return 0;}
87
88static int bad_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
89 const unsigned char *in, unsigned int inl)
90 { FIPS_ERROR_IGNORED("Cipher update"); return 0;}
91
92/* NB: no cleanup because it is allowed after failed init */
93
94static int bad_set_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *typ)
95 { FIPS_ERROR_IGNORED("Cipher set_asn1"); return 0;}
96static int bad_get_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *typ)
97 { FIPS_ERROR_IGNORED("Cipher get_asn1"); return 0;}
98static int bad_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
99 { FIPS_ERROR_IGNORED("Cipher ctrl"); return 0;}
100
101static const EVP_CIPHER bad_cipher =
102 {
103 0,
104 0,
105 0,
106 0,
107 0,
108 bad_init,
109 bad_do_cipher,
110 NULL,
111 0,
112 bad_set_asn1,
113 bad_get_asn1,
114 bad_ctrl,
115 NULL
116 };
117
118#endif
119
120#ifndef OPENSSL_NO_ENGINE
121
122#ifdef OPENSSL_FIPS
123
124static int do_engine_null(ENGINE *impl) { return 0;}
125static int do_evp_enc_engine_null(EVP_CIPHER_CTX *ctx,
126 const EVP_CIPHER **pciph, ENGINE *impl)
127 { return 1; }
128
129static int (*do_engine_finish)(ENGINE *impl)
130 = do_engine_null;
131
132static int (*do_evp_enc_engine)
133 (EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pciph, ENGINE *impl)
134 = do_evp_enc_engine_null;
135
136void int_EVP_CIPHER_set_engine_callbacks(
137 int (*eng_ciph_fin)(ENGINE *impl),
138 int (*eng_ciph_evp)
139 (EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pciph, ENGINE *impl))
140 {
141 do_engine_finish = eng_ciph_fin;
142 do_evp_enc_engine = eng_ciph_evp;
143 }
144
145#else
146
147#define do_engine_finish ENGINE_finish
148
149static int do_evp_enc_engine(EVP_CIPHER_CTX *ctx, const EVP_CIPHER **pcipher, ENGINE *impl)
150 {
151 if(impl)
152 {
153 if (!ENGINE_init(impl))
154 {
155 EVPerr(EVP_F_DO_EVP_ENC_ENGINE, EVP_R_INITIALIZATION_ERROR);
156 return 0;
157 }
158 }
159 else
160 /* Ask if an ENGINE is reserved for this job */
161 impl = ENGINE_get_cipher_engine((*pcipher)->nid);
162 if(impl)
163 {
164 /* There's an ENGINE for this job ... (apparently) */
165 const EVP_CIPHER *c = ENGINE_get_cipher(impl, (*pcipher)->nid);
166 if(!c)
167 {
168 /* One positive side-effect of US's export
169 * control history, is that we should at least
170 * be able to avoid using US mispellings of
171 * "initialisation"? */
172 EVPerr(EVP_F_DO_EVP_ENC_ENGINE, EVP_R_INITIALIZATION_ERROR);
173 return 0;
174 }
175 /* We'll use the ENGINE's private cipher definition */
176 *pcipher = c;
177 /* Store the ENGINE functional reference so we know
178 * 'cipher' came from an ENGINE and we need to release
179 * it when done. */
180 ctx->engine = impl;
181 }
182 else
183 ctx->engine = NULL;
184 return 1;
185 }
186
187#endif
188
189#endif
190
191int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
192 const unsigned char *key, const unsigned char *iv, int enc)
193 {
194 if (enc == -1)
195 enc = ctx->encrypt;
196 else
197 {
198 if (enc)
199 enc = 1;
200 ctx->encrypt = enc;
201 }
202#ifdef OPENSSL_FIPS
203 if(FIPS_selftest_failed())
204 {
205 FIPSerr(FIPS_F_EVP_CIPHERINIT_EX,FIPS_R_FIPS_SELFTEST_FAILED);
206 ctx->cipher = &bad_cipher;
207 return 0;
208 }
209#endif
210#ifndef OPENSSL_NO_ENGINE
211 /* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
212 * so this context may already have an ENGINE! Try to avoid releasing
213 * the previous handle, re-querying for an ENGINE, and having a
214 * reinitialisation, when it may all be unecessary. */
215 if (ctx->engine && ctx->cipher && (!cipher ||
216 (cipher && (cipher->nid == ctx->cipher->nid))))
217 goto skip_to_init;
218#endif
219 if (cipher)
220 {
221 /* Ensure a context left lying around from last time is cleared
222 * (the previous check attempted to avoid this if the same
223 * ENGINE and EVP_CIPHER could be used). */
224 EVP_CIPHER_CTX_cleanup(ctx);
225
226 /* Restore encrypt field: it is zeroed by cleanup */
227 ctx->encrypt = enc;
228#ifndef OPENSSL_NO_ENGINE
229 if (!do_evp_enc_engine(ctx, &cipher, impl))
230 return 0;
231#endif
232
233 ctx->cipher=cipher;
234 if (ctx->cipher->ctx_size)
235 {
236 ctx->cipher_data=OPENSSL_malloc(ctx->cipher->ctx_size);
237 if (!ctx->cipher_data)
238 {
239 EVPerr(EVP_F_EVP_CIPHERINIT_EX, ERR_R_MALLOC_FAILURE);
240 return 0;
241 }
242 }
243 else
244 {
245 ctx->cipher_data = NULL;
246 }
247 ctx->key_len = cipher->key_len;
248 ctx->flags = 0;
249 if(ctx->cipher->flags & EVP_CIPH_CTRL_INIT)
250 {
251 if(!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_INIT, 0, NULL))
252 {
253 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_INITIALIZATION_ERROR);
254 return 0;
255 }
256 }
257 }
258 else if(!ctx->cipher)
259 {
260 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_NO_CIPHER_SET);
261 return 0;
262 }
263#ifndef OPENSSL_NO_ENGINE
264skip_to_init:
265#endif
266 /* we assume block size is a power of 2 in *cryptUpdate */
267 OPENSSL_assert(ctx->cipher->block_size == 1
268 || ctx->cipher->block_size == 8
269 || ctx->cipher->block_size == 16);
270
271 if(!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_CUSTOM_IV)) {
272 switch(EVP_CIPHER_CTX_mode(ctx)) {
273
274 case EVP_CIPH_STREAM_CIPHER:
275 case EVP_CIPH_ECB_MODE:
276 break;
277
278 case EVP_CIPH_CFB_MODE:
279 case EVP_CIPH_OFB_MODE:
280
281 ctx->num = 0;
282
283 case EVP_CIPH_CBC_MODE:
284
285 OPENSSL_assert(EVP_CIPHER_CTX_iv_length(ctx) <=
286 (int)sizeof(ctx->iv));
287 if(iv) memcpy(ctx->oiv, iv, EVP_CIPHER_CTX_iv_length(ctx));
288 memcpy(ctx->iv, ctx->oiv, EVP_CIPHER_CTX_iv_length(ctx));
289 break;
290
291 default:
292 return 0;
293 break;
294 }
295 }
296
297#ifdef OPENSSL_FIPS
298 /* After 'key' is set no further parameters changes are permissible.
299 * So only check for non FIPS enabling at this point.
300 */
301 if (key && FIPS_mode())
302 {
303 if (!(ctx->cipher->flags & EVP_CIPH_FLAG_FIPS)
304 & !(ctx->flags & EVP_CIPH_FLAG_NON_FIPS_ALLOW))
305 {
306 EVPerr(EVP_F_EVP_CIPHERINIT_EX, EVP_R_DISABLED_FOR_FIPS);
307#if 0
308 ERR_add_error_data(2, "cipher=",
309 EVP_CIPHER_name(ctx->cipher));
310#endif
311 ctx->cipher = &bad_cipher;
312 return 0;
313 }
314 }
315#endif
316
317 if(key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) {
318 if(!ctx->cipher->init(ctx,key,iv,enc)) return 0;
319 }
320 ctx->buf_len=0;
321 ctx->final_used=0;
322 ctx->block_mask=ctx->cipher->block_size-1;
323 return 1;
324 }
325
326int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
327 {
328 if (c->cipher != NULL)
329 {
330 if(c->cipher->cleanup && !c->cipher->cleanup(c))
331 return 0;
332 /* Cleanse cipher context data */
333 if (c->cipher_data)
334 OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
335 }
336 if (c->cipher_data)
337 OPENSSL_free(c->cipher_data);
338#ifndef OPENSSL_NO_ENGINE
339 if (c->engine)
340 /* The EVP_CIPHER we used belongs to an ENGINE, release the
341 * functional reference we held for this reason. */
342 do_engine_finish(c->engine);
343#endif
344 memset(c,0,sizeof(EVP_CIPHER_CTX));
345 return 1;
346 }
347
348int EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl)
349 {
350#ifdef OPENSSL_FIPS
351 FIPS_selftest_check();
352#endif
353 return ctx->cipher->do_cipher(ctx,out,in,inl);
354 }
355
356int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
357{
358 int ret;
359 if(!ctx->cipher) {
360 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_NO_CIPHER_SET);
361 return 0;
362 }
363
364 if(!ctx->cipher->ctrl) {
365 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_NOT_IMPLEMENTED);
366 return 0;
367 }
368
369 ret = ctx->cipher->ctrl(ctx, type, arg, ptr);
370 if(ret == -1) {
371 EVPerr(EVP_F_EVP_CIPHER_CTX_CTRL, EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED);
372 return 0;
373 }
374 return ret;
375}
376
377unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx)
378 {
379 return ctx->cipher->flags;
380 }
381
382int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx)
383 {
384 return ctx->cipher->iv_len;
385 }
386
387int EVP_CIPHER_nid(const EVP_CIPHER *cipher)
388 {
389 return cipher->nid;
390 }
diff --git a/src/lib/libcrypto/evp/evp_fips.c b/src/lib/libcrypto/evp/evp_fips.c
new file mode 100644
index 0000000000..cb7f4fc0fa
--- /dev/null
+++ b/src/lib/libcrypto/evp/evp_fips.c
@@ -0,0 +1,113 @@
1/* crypto/evp/evp_fips.c */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project.
4 */
5/* ====================================================================
6 * Copyright (c) 2011 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 */
53
54
55#include <openssl/evp.h>
56
57#ifdef OPENSSL_FIPS
58#include <openssl/fips.h>
59
60const EVP_CIPHER *EVP_aes_128_cbc(void) { return FIPS_evp_aes_128_cbc(); }
61const EVP_CIPHER *EVP_aes_128_ccm(void) { return FIPS_evp_aes_128_ccm(); }
62const EVP_CIPHER *EVP_aes_128_cfb1(void) { return FIPS_evp_aes_128_cfb1(); }
63const EVP_CIPHER *EVP_aes_128_cfb128(void) { return FIPS_evp_aes_128_cfb128(); }
64const EVP_CIPHER *EVP_aes_128_cfb8(void) { return FIPS_evp_aes_128_cfb8(); }
65const EVP_CIPHER *EVP_aes_128_ctr(void) { return FIPS_evp_aes_128_ctr(); }
66const EVP_CIPHER *EVP_aes_128_ecb(void) { return FIPS_evp_aes_128_ecb(); }
67const EVP_CIPHER *EVP_aes_128_gcm(void) { return FIPS_evp_aes_128_gcm(); }
68const EVP_CIPHER *EVP_aes_128_ofb(void) { return FIPS_evp_aes_128_ofb(); }
69const EVP_CIPHER *EVP_aes_128_xts(void) { return FIPS_evp_aes_128_xts(); }
70const EVP_CIPHER *EVP_aes_192_cbc(void) { return FIPS_evp_aes_192_cbc(); }
71const EVP_CIPHER *EVP_aes_192_ccm(void) { return FIPS_evp_aes_192_ccm(); }
72const EVP_CIPHER *EVP_aes_192_cfb1(void) { return FIPS_evp_aes_192_cfb1(); }
73const EVP_CIPHER *EVP_aes_192_cfb128(void) { return FIPS_evp_aes_192_cfb128(); }
74const EVP_CIPHER *EVP_aes_192_cfb8(void) { return FIPS_evp_aes_192_cfb8(); }
75const EVP_CIPHER *EVP_aes_192_ctr(void) { return FIPS_evp_aes_192_ctr(); }
76const EVP_CIPHER *EVP_aes_192_ecb(void) { return FIPS_evp_aes_192_ecb(); }
77const EVP_CIPHER *EVP_aes_192_gcm(void) { return FIPS_evp_aes_192_gcm(); }
78const EVP_CIPHER *EVP_aes_192_ofb(void) { return FIPS_evp_aes_192_ofb(); }
79const EVP_CIPHER *EVP_aes_256_cbc(void) { return FIPS_evp_aes_256_cbc(); }
80const EVP_CIPHER *EVP_aes_256_ccm(void) { return FIPS_evp_aes_256_ccm(); }
81const EVP_CIPHER *EVP_aes_256_cfb1(void) { return FIPS_evp_aes_256_cfb1(); }
82const EVP_CIPHER *EVP_aes_256_cfb128(void) { return FIPS_evp_aes_256_cfb128(); }
83const EVP_CIPHER *EVP_aes_256_cfb8(void) { return FIPS_evp_aes_256_cfb8(); }
84const EVP_CIPHER *EVP_aes_256_ctr(void) { return FIPS_evp_aes_256_ctr(); }
85const EVP_CIPHER *EVP_aes_256_ecb(void) { return FIPS_evp_aes_256_ecb(); }
86const EVP_CIPHER *EVP_aes_256_gcm(void) { return FIPS_evp_aes_256_gcm(); }
87const EVP_CIPHER *EVP_aes_256_ofb(void) { return FIPS_evp_aes_256_ofb(); }
88const EVP_CIPHER *EVP_aes_256_xts(void) { return FIPS_evp_aes_256_xts(); }
89const EVP_CIPHER *EVP_des_ede(void) { return FIPS_evp_des_ede(); }
90const EVP_CIPHER *EVP_des_ede3(void) { return FIPS_evp_des_ede3(); }
91const EVP_CIPHER *EVP_des_ede3_cbc(void) { return FIPS_evp_des_ede3_cbc(); }
92const EVP_CIPHER *EVP_des_ede3_cfb1(void) { return FIPS_evp_des_ede3_cfb1(); }
93const EVP_CIPHER *EVP_des_ede3_cfb64(void) { return FIPS_evp_des_ede3_cfb64(); }
94const EVP_CIPHER *EVP_des_ede3_cfb8(void) { return FIPS_evp_des_ede3_cfb8(); }
95const EVP_CIPHER *EVP_des_ede3_ecb(void) { return FIPS_evp_des_ede3_ecb(); }
96const EVP_CIPHER *EVP_des_ede3_ofb(void) { return FIPS_evp_des_ede3_ofb(); }
97const EVP_CIPHER *EVP_des_ede_cbc(void) { return FIPS_evp_des_ede_cbc(); }
98const EVP_CIPHER *EVP_des_ede_cfb64(void) { return FIPS_evp_des_ede_cfb64(); }
99const EVP_CIPHER *EVP_des_ede_ecb(void) { return FIPS_evp_des_ede_ecb(); }
100const EVP_CIPHER *EVP_des_ede_ofb(void) { return FIPS_evp_des_ede_ofb(); }
101const EVP_CIPHER *EVP_enc_null(void) { return FIPS_evp_enc_null(); }
102
103const EVP_MD *EVP_sha1(void) { return FIPS_evp_sha1(); }
104const EVP_MD *EVP_sha224(void) { return FIPS_evp_sha224(); }
105const EVP_MD *EVP_sha256(void) { return FIPS_evp_sha256(); }
106const EVP_MD *EVP_sha384(void) { return FIPS_evp_sha384(); }
107const EVP_MD *EVP_sha512(void) { return FIPS_evp_sha512(); }
108
109const EVP_MD *EVP_dss(void) { return FIPS_evp_dss(); }
110const EVP_MD *EVP_dss1(void) { return FIPS_evp_dss1(); }
111const EVP_MD *EVP_ecdsa(void) { return FIPS_evp_ecdsa(); }
112
113#endif
diff --git a/src/lib/libcrypto/fips_err.h b/src/lib/libcrypto/fips_err.h
new file mode 100644
index 0000000000..c671691b47
--- /dev/null
+++ b/src/lib/libcrypto/fips_err.h
@@ -0,0 +1,209 @@
1/* crypto/fips_err.h */
2/* ====================================================================
3 * Copyright (c) 1999-2011 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include <openssl/fips.h>
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67
68#define ERR_FUNC(func) ERR_PACK(ERR_LIB_FIPS,func,0)
69#define ERR_REASON(reason) ERR_PACK(ERR_LIB_FIPS,0,reason)
70
71static ERR_STRING_DATA FIPS_str_functs[]=
72 {
73{ERR_FUNC(FIPS_F_DH_BUILTIN_GENPARAMS), "DH_BUILTIN_GENPARAMS"},
74{ERR_FUNC(FIPS_F_DH_INIT), "DH_INIT"},
75{ERR_FUNC(FIPS_F_DRBG_RESEED), "DRBG_RESEED"},
76{ERR_FUNC(FIPS_F_DSA_BUILTIN_PARAMGEN), "DSA_BUILTIN_PARAMGEN"},
77{ERR_FUNC(FIPS_F_DSA_BUILTIN_PARAMGEN2), "DSA_BUILTIN_PARAMGEN2"},
78{ERR_FUNC(FIPS_F_DSA_DO_SIGN), "DSA_do_sign"},
79{ERR_FUNC(FIPS_F_DSA_DO_VERIFY), "DSA_do_verify"},
80{ERR_FUNC(FIPS_F_FIPS_CHECK_DSA), "FIPS_CHECK_DSA"},
81{ERR_FUNC(FIPS_F_FIPS_CHECK_DSA_PRNG), "fips_check_dsa_prng"},
82{ERR_FUNC(FIPS_F_FIPS_CHECK_EC), "FIPS_CHECK_EC"},
83{ERR_FUNC(FIPS_F_FIPS_CHECK_EC_PRNG), "fips_check_ec_prng"},
84{ERR_FUNC(FIPS_F_FIPS_CHECK_INCORE_FINGERPRINT), "FIPS_check_incore_fingerprint"},
85{ERR_FUNC(FIPS_F_FIPS_CHECK_RSA), "fips_check_rsa"},
86{ERR_FUNC(FIPS_F_FIPS_CHECK_RSA_PRNG), "fips_check_rsa_prng"},
87{ERR_FUNC(FIPS_F_FIPS_CIPHER), "FIPS_cipher"},
88{ERR_FUNC(FIPS_F_FIPS_CIPHERINIT), "FIPS_cipherinit"},
89{ERR_FUNC(FIPS_F_FIPS_CIPHER_CTX_CTRL), "FIPS_CIPHER_CTX_CTRL"},
90{ERR_FUNC(FIPS_F_FIPS_DIGESTFINAL), "FIPS_digestfinal"},
91{ERR_FUNC(FIPS_F_FIPS_DIGESTINIT), "FIPS_digestinit"},
92{ERR_FUNC(FIPS_F_FIPS_DIGESTUPDATE), "FIPS_digestupdate"},
93{ERR_FUNC(FIPS_F_FIPS_DRBG_BYTES), "FIPS_DRBG_BYTES"},
94{ERR_FUNC(FIPS_F_FIPS_DRBG_CHECK), "FIPS_DRBG_CHECK"},
95{ERR_FUNC(FIPS_F_FIPS_DRBG_CPRNG_TEST), "FIPS_DRBG_CPRNG_TEST"},
96{ERR_FUNC(FIPS_F_FIPS_DRBG_ERROR_CHECK), "FIPS_DRBG_ERROR_CHECK"},
97{ERR_FUNC(FIPS_F_FIPS_DRBG_GENERATE), "FIPS_drbg_generate"},
98{ERR_FUNC(FIPS_F_FIPS_DRBG_INIT), "FIPS_drbg_init"},
99{ERR_FUNC(FIPS_F_FIPS_DRBG_INSTANTIATE), "FIPS_drbg_instantiate"},
100{ERR_FUNC(FIPS_F_FIPS_DRBG_NEW), "FIPS_drbg_new"},
101{ERR_FUNC(FIPS_F_FIPS_DRBG_RESEED), "FIPS_drbg_reseed"},
102{ERR_FUNC(FIPS_F_FIPS_DRBG_SINGLE_KAT), "FIPS_DRBG_SINGLE_KAT"},
103{ERR_FUNC(FIPS_F_FIPS_DSA_SIGN_DIGEST), "FIPS_dsa_sign_digest"},
104{ERR_FUNC(FIPS_F_FIPS_DSA_VERIFY_DIGEST), "FIPS_dsa_verify_digest"},
105{ERR_FUNC(FIPS_F_FIPS_GET_ENTROPY), "FIPS_GET_ENTROPY"},
106{ERR_FUNC(FIPS_F_FIPS_MODULE_MODE_SET), "FIPS_module_mode_set"},
107{ERR_FUNC(FIPS_F_FIPS_PKEY_SIGNATURE_TEST), "fips_pkey_signature_test"},
108{ERR_FUNC(FIPS_F_FIPS_RAND_ADD), "FIPS_rand_add"},
109{ERR_FUNC(FIPS_F_FIPS_RAND_BYTES), "FIPS_rand_bytes"},
110{ERR_FUNC(FIPS_F_FIPS_RAND_PSEUDO_BYTES), "FIPS_rand_pseudo_bytes"},
111{ERR_FUNC(FIPS_F_FIPS_RAND_SEED), "FIPS_rand_seed"},
112{ERR_FUNC(FIPS_F_FIPS_RAND_SET_METHOD), "FIPS_rand_set_method"},
113{ERR_FUNC(FIPS_F_FIPS_RAND_STATUS), "FIPS_rand_status"},
114{ERR_FUNC(FIPS_F_FIPS_RSA_SIGN_DIGEST), "FIPS_rsa_sign_digest"},
115{ERR_FUNC(FIPS_F_FIPS_RSA_VERIFY_DIGEST), "FIPS_rsa_verify_digest"},
116{ERR_FUNC(FIPS_F_FIPS_SELFTEST_AES), "FIPS_selftest_aes"},
117{ERR_FUNC(FIPS_F_FIPS_SELFTEST_AES_CCM), "FIPS_selftest_aes_ccm"},
118{ERR_FUNC(FIPS_F_FIPS_SELFTEST_AES_GCM), "FIPS_selftest_aes_gcm"},
119{ERR_FUNC(FIPS_F_FIPS_SELFTEST_AES_XTS), "FIPS_selftest_aes_xts"},
120{ERR_FUNC(FIPS_F_FIPS_SELFTEST_CMAC), "FIPS_selftest_cmac"},
121{ERR_FUNC(FIPS_F_FIPS_SELFTEST_DES), "FIPS_selftest_des"},
122{ERR_FUNC(FIPS_F_FIPS_SELFTEST_DSA), "FIPS_selftest_dsa"},
123{ERR_FUNC(FIPS_F_FIPS_SELFTEST_ECDSA), "FIPS_selftest_ecdsa"},
124{ERR_FUNC(FIPS_F_FIPS_SELFTEST_HMAC), "FIPS_selftest_hmac"},
125{ERR_FUNC(FIPS_F_FIPS_SELFTEST_SHA1), "FIPS_selftest_sha1"},
126{ERR_FUNC(FIPS_F_FIPS_SELFTEST_X931), "FIPS_selftest_x931"},
127{ERR_FUNC(FIPS_F_FIPS_SET_PRNG_KEY), "FIPS_SET_PRNG_KEY"},
128{ERR_FUNC(FIPS_F_HASH_FINAL), "HASH_FINAL"},
129{ERR_FUNC(FIPS_F_RSA_BUILTIN_KEYGEN), "RSA_BUILTIN_KEYGEN"},
130{ERR_FUNC(FIPS_F_RSA_EAY_INIT), "RSA_EAY_INIT"},
131{ERR_FUNC(FIPS_F_RSA_EAY_PRIVATE_DECRYPT), "RSA_EAY_PRIVATE_DECRYPT"},
132{ERR_FUNC(FIPS_F_RSA_EAY_PRIVATE_ENCRYPT), "RSA_EAY_PRIVATE_ENCRYPT"},
133{ERR_FUNC(FIPS_F_RSA_EAY_PUBLIC_DECRYPT), "RSA_EAY_PUBLIC_DECRYPT"},
134{ERR_FUNC(FIPS_F_RSA_EAY_PUBLIC_ENCRYPT), "RSA_EAY_PUBLIC_ENCRYPT"},
135{ERR_FUNC(FIPS_F_RSA_X931_GENERATE_KEY_EX), "RSA_X931_generate_key_ex"},
136{0,NULL}
137 };
138
139static ERR_STRING_DATA FIPS_str_reasons[]=
140 {
141{ERR_REASON(FIPS_R_ADDITIONAL_INPUT_ERROR_UNDETECTED),"additional input error undetected"},
142{ERR_REASON(FIPS_R_ADDITIONAL_INPUT_TOO_LONG),"additional input too long"},
143{ERR_REASON(FIPS_R_ALREADY_INSTANTIATED) ,"already instantiated"},
144{ERR_REASON(FIPS_R_AUTHENTICATION_FAILURE),"authentication failure"},
145{ERR_REASON(FIPS_R_CONTRADICTING_EVIDENCE),"contradicting evidence"},
146{ERR_REASON(FIPS_R_DRBG_NOT_INITIALISED) ,"drbg not initialised"},
147{ERR_REASON(FIPS_R_DRBG_STUCK) ,"drbg stuck"},
148{ERR_REASON(FIPS_R_ENTROPY_ERROR_UNDETECTED),"entropy error undetected"},
149{ERR_REASON(FIPS_R_ENTROPY_NOT_REQUESTED_FOR_RESEED),"entropy not requested for reseed"},
150{ERR_REASON(FIPS_R_ENTROPY_SOURCE_STUCK) ,"entropy source stuck"},
151{ERR_REASON(FIPS_R_ERROR_INITIALISING_DRBG),"error initialising drbg"},
152{ERR_REASON(FIPS_R_ERROR_INSTANTIATING_DRBG),"error instantiating drbg"},
153{ERR_REASON(FIPS_R_ERROR_RETRIEVING_ADDITIONAL_INPUT),"error retrieving additional input"},
154{ERR_REASON(FIPS_R_ERROR_RETRIEVING_ENTROPY),"error retrieving entropy"},
155{ERR_REASON(FIPS_R_ERROR_RETRIEVING_NONCE),"error retrieving nonce"},
156{ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH),"fingerprint does not match"},
157{ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH_NONPIC_RELOCATED),"fingerprint does not match nonpic relocated"},
158{ERR_REASON(FIPS_R_FINGERPRINT_DOES_NOT_MATCH_SEGMENT_ALIASING),"fingerprint does not match segment aliasing"},
159{ERR_REASON(FIPS_R_FIPS_MODE_ALREADY_SET),"fips mode already set"},
160{ERR_REASON(FIPS_R_FIPS_SELFTEST_FAILED) ,"fips selftest failed"},
161{ERR_REASON(FIPS_R_FUNCTION_ERROR) ,"function error"},
162{ERR_REASON(FIPS_R_GENERATE_ERROR) ,"generate error"},
163{ERR_REASON(FIPS_R_GENERATE_ERROR_UNDETECTED),"generate error undetected"},
164{ERR_REASON(FIPS_R_INSTANTIATE_ERROR) ,"instantiate error"},
165{ERR_REASON(FIPS_R_INSUFFICIENT_SECURITY_STRENGTH),"insufficient security strength"},
166{ERR_REASON(FIPS_R_INTERNAL_ERROR) ,"internal error"},
167{ERR_REASON(FIPS_R_INVALID_KEY_LENGTH) ,"invalid key length"},
168{ERR_REASON(FIPS_R_INVALID_PARAMETERS) ,"invalid parameters"},
169{ERR_REASON(FIPS_R_IN_ERROR_STATE) ,"in error state"},
170{ERR_REASON(FIPS_R_KEY_TOO_SHORT) ,"key too short"},
171{ERR_REASON(FIPS_R_NONCE_ERROR_UNDETECTED),"nonce error undetected"},
172{ERR_REASON(FIPS_R_NON_FIPS_METHOD) ,"non fips method"},
173{ERR_REASON(FIPS_R_NOPR_TEST1_FAILURE) ,"nopr test1 failure"},
174{ERR_REASON(FIPS_R_NOPR_TEST2_FAILURE) ,"nopr test2 failure"},
175{ERR_REASON(FIPS_R_NOT_INSTANTIATED) ,"not instantiated"},
176{ERR_REASON(FIPS_R_PAIRWISE_TEST_FAILED) ,"pairwise test failed"},
177{ERR_REASON(FIPS_R_PERSONALISATION_ERROR_UNDETECTED),"personalisation error undetected"},
178{ERR_REASON(FIPS_R_PERSONALISATION_STRING_TOO_LONG),"personalisation string too long"},
179{ERR_REASON(FIPS_R_PRNG_STRENGTH_TOO_LOW),"prng strength too low"},
180{ERR_REASON(FIPS_R_PR_TEST1_FAILURE) ,"pr test1 failure"},
181{ERR_REASON(FIPS_R_PR_TEST2_FAILURE) ,"pr test2 failure"},
182{ERR_REASON(FIPS_R_REQUEST_LENGTH_ERROR_UNDETECTED),"request length error undetected"},
183{ERR_REASON(FIPS_R_REQUEST_TOO_LARGE_FOR_DRBG),"request too large for drbg"},
184{ERR_REASON(FIPS_R_RESEED_COUNTER_ERROR) ,"reseed counter error"},
185{ERR_REASON(FIPS_R_RESEED_ERROR) ,"reseed error"},
186{ERR_REASON(FIPS_R_SELFTEST_FAILED) ,"selftest failed"},
187{ERR_REASON(FIPS_R_SELFTEST_FAILURE) ,"selftest failure"},
188{ERR_REASON(FIPS_R_STRENGTH_ERROR_UNDETECTED),"strength error undetected"},
189{ERR_REASON(FIPS_R_TEST_FAILURE) ,"test failure"},
190{ERR_REASON(FIPS_R_UNINSTANTIATE_ERROR) ,"uninstantiate error"},
191{ERR_REASON(FIPS_R_UNINSTANTIATE_ZEROISE_ERROR),"uninstantiate zeroise error"},
192{ERR_REASON(FIPS_R_UNSUPPORTED_DRBG_TYPE),"unsupported drbg type"},
193{ERR_REASON(FIPS_R_UNSUPPORTED_PLATFORM) ,"unsupported platform"},
194{0,NULL}
195 };
196
197#endif
198
199void ERR_load_FIPS_strings(void)
200 {
201#ifndef OPENSSL_NO_ERR
202
203 if (ERR_func_error_string(FIPS_str_functs[0].error) == NULL)
204 {
205 ERR_load_strings(0,FIPS_str_functs);
206 ERR_load_strings(0,FIPS_str_reasons);
207 }
208#endif
209 }
diff --git a/src/lib/libcrypto/fips_err.c b/src/lib/libcrypto/fips_ers.c
index 09f11748f6..09f11748f6 100644
--- a/src/lib/libcrypto/fips_err.c
+++ b/src/lib/libcrypto/fips_ers.c
diff --git a/src/lib/libcrypto/idea/idea_spd.c b/src/lib/libcrypto/idea/idea_spd.c
new file mode 100644
index 0000000000..699353e871
--- /dev/null
+++ b/src/lib/libcrypto/idea/idea_spd.c
@@ -0,0 +1,299 @@
1/* crypto/idea/idea_spd.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/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#ifndef OPENSSL_SYS_NETWARE
73#include <signal.h>
74#endif
75
76#ifndef _IRIX
77#include <time.h>
78#endif
79#ifdef TIMES
80#include <sys/types.h>
81#include <sys/times.h>
82#endif
83
84/* Depending on the VMS version, the tms structure is perhaps defined.
85 The __TMS macro will show if it was. If it wasn't defined, we should
86 undefine TIMES, since that tells the rest of the program how things
87 should be handled. -- Richard Levitte */
88#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
89#undef TIMES
90#endif
91
92#ifndef TIMES
93#include <sys/timeb.h>
94#endif
95
96#if defined(sun) || defined(__ultrix)
97#define _POSIX_SOURCE
98#include <limits.h>
99#include <sys/param.h>
100#endif
101
102#include <openssl/idea.h>
103
104/* The following if from times(3) man page. It may need to be changed */
105#ifndef HZ
106#ifndef CLK_TCK
107#define HZ 100.0
108#else /* CLK_TCK */
109#define HZ ((double)CLK_TCK)
110#endif
111#endif
112
113#define BUFSIZE ((long)1024)
114long run=0;
115
116double Time_F(int s);
117#ifdef SIGALRM
118#if defined(__STDC__) || defined(sgi) || defined(_AIX)
119#define SIGRETTYPE void
120#else
121#define SIGRETTYPE int
122#endif
123
124SIGRETTYPE sig_done(int sig);
125SIGRETTYPE sig_done(int sig)
126 {
127 signal(SIGALRM,sig_done);
128 run=0;
129#ifdef LINT
130 sig=sig;
131#endif
132 }
133#endif
134
135#define START 0
136#define STOP 1
137
138double Time_F(int s)
139 {
140 double ret;
141#ifdef TIMES
142 static struct tms tstart,tend;
143
144 if (s == START)
145 {
146 times(&tstart);
147 return(0);
148 }
149 else
150 {
151 times(&tend);
152 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
153 return((ret == 0.0)?1e-6:ret);
154 }
155#else /* !times() */
156 static struct timeb tstart,tend;
157 long i;
158
159 if (s == START)
160 {
161 ftime(&tstart);
162 return(0);
163 }
164 else
165 {
166 ftime(&tend);
167 i=(long)tend.millitm-(long)tstart.millitm;
168 ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
169 return((ret == 0.0)?1e-6:ret);
170 }
171#endif
172 }
173
174int main(int argc, char **argv)
175 {
176 long count;
177 static unsigned char buf[BUFSIZE];
178 static unsigned char key[] ={
179 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
180 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
181 };
182 IDEA_KEY_SCHEDULE sch;
183 double a,aa,b,c,d;
184#ifndef SIGALRM
185 long ca,cca,cb,cc;
186#endif
187
188#ifndef TIMES
189 printf("To get the most accurate results, try to run this\n");
190 printf("program when this computer is idle.\n");
191#endif
192
193#ifndef SIGALRM
194 printf("First we calculate the approximate speed ...\n");
195 idea_set_encrypt_key(key,&sch);
196 count=10;
197 do {
198 long i;
199 IDEA_INT data[2];
200
201 count*=2;
202 Time_F(START);
203 for (i=count; i; i--)
204 idea_encrypt(data,&sch);
205 d=Time_F(STOP);
206 } while (d < 3.0);
207 ca=count/4;
208 cca=count/200;
209 cb=count;
210 cc=count*8/BUFSIZE+1;
211 printf("idea_set_encrypt_key %ld times\n",ca);
212#define COND(d) (count <= (d))
213#define COUNT(d) (d)
214#else
215#define COND(c) (run)
216#define COUNT(d) (count)
217 signal(SIGALRM,sig_done);
218 printf("Doing idea_set_encrypt_key for 10 seconds\n");
219 alarm(10);
220#endif
221
222 Time_F(START);
223 for (count=0,run=1; COND(ca); count+=4)
224 {
225 idea_set_encrypt_key(key,&sch);
226 idea_set_encrypt_key(key,&sch);
227 idea_set_encrypt_key(key,&sch);
228 idea_set_encrypt_key(key,&sch);
229 }
230 d=Time_F(STOP);
231 printf("%ld idea idea_set_encrypt_key's in %.2f seconds\n",count,d);
232 a=((double)COUNT(ca))/d;
233
234#ifdef SIGALRM
235 printf("Doing idea_set_decrypt_key for 10 seconds\n");
236 alarm(10);
237#else
238 printf("Doing idea_set_decrypt_key %ld times\n",cca);
239#endif
240
241 Time_F(START);
242 for (count=0,run=1; COND(cca); count+=4)
243 {
244 idea_set_decrypt_key(&sch,&sch);
245 idea_set_decrypt_key(&sch,&sch);
246 idea_set_decrypt_key(&sch,&sch);
247 idea_set_decrypt_key(&sch,&sch);
248 }
249 d=Time_F(STOP);
250 printf("%ld idea idea_set_decrypt_key's in %.2f seconds\n",count,d);
251 aa=((double)COUNT(cca))/d;
252
253#ifdef SIGALRM
254 printf("Doing idea_encrypt's for 10 seconds\n");
255 alarm(10);
256#else
257 printf("Doing idea_encrypt %ld times\n",cb);
258#endif
259 Time_F(START);
260 for (count=0,run=1; COND(cb); count+=4)
261 {
262 unsigned long data[2];
263
264 idea_encrypt(data,&sch);
265 idea_encrypt(data,&sch);
266 idea_encrypt(data,&sch);
267 idea_encrypt(data,&sch);
268 }
269 d=Time_F(STOP);
270 printf("%ld idea_encrypt's in %.2f second\n",count,d);
271 b=((double)COUNT(cb)*8)/d;
272
273#ifdef SIGALRM
274 printf("Doing idea_cbc_encrypt on %ld byte blocks for 10 seconds\n",
275 BUFSIZE);
276 alarm(10);
277#else
278 printf("Doing idea_cbc_encrypt %ld times on %ld byte blocks\n",cc,
279 BUFSIZE);
280#endif
281 Time_F(START);
282 for (count=0,run=1; COND(cc); count++)
283 idea_cbc_encrypt(buf,buf,BUFSIZE,&sch,
284 &(key[0]),IDEA_ENCRYPT);
285 d=Time_F(STOP);
286 printf("%ld idea_cbc_encrypt's of %ld byte blocks in %.2f second\n",
287 count,BUFSIZE,d);
288 c=((double)COUNT(cc)*BUFSIZE)/d;
289
290 printf("IDEA set_encrypt_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
291 printf("IDEA set_decrypt_key per sec = %12.2f (%9.3fuS)\n",aa,1.0e6/aa);
292 printf("IDEA raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
293 printf("IDEA cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
294 exit(0);
295#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
296 return(0);
297#endif
298 }
299
diff --git a/src/lib/libcrypto/install-crypto.com b/src/lib/libcrypto/install-crypto.com
deleted file mode 100755
index 85b3d583cf..0000000000
--- a/src/lib/libcrypto/install-crypto.com
+++ /dev/null
@@ -1,196 +0,0 @@
1$! INSTALL.COM -- Installs the files in a given directory tree
2$!
3$! Author: Richard Levitte <richard@levitte.org>
4$! Time of creation: 22-MAY-1998 10:13
5$!
6$! Changes by Zoltan Arpadffy <zoli@polarhome.com>
7$!
8$! P1 root of the directory tree
9$! P2 "64" for 64-bit pointers.
10$!
11$!
12$! Announce/identify.
13$!
14$ proc = f$environment( "procedure")
15$ write sys$output "@@@ "+ -
16 f$parse( proc, , , "name")+ f$parse( proc, , , "type")
17$!
18$ on error then goto tidy
19$ on control_c then goto tidy
20$!
21$ if (p1 .eqs. "")
22$ then
23$ write sys$output "First argument missing."
24$ write sys$output -
25 "It should be the directory where you want things installed."
26$ exit
27$ endif
28$!
29$ if (f$getsyi( "cpu") .lt. 128)
30$ then
31$ arch = "VAX"
32$ else
33$ arch = f$edit( f$getsyi( "arch_name"), "upcase")
34$ if (arch .eqs. "") then arch = "UNK"
35$ endif
36$!
37$ archd = arch
38$ lib32 = "32"
39$ shr = "_SHR32"
40$!
41$ if (p2 .nes. "")
42$ then
43$ if (p2 .eqs. "64")
44$ then
45$ archd = arch+ "_64"
46$ lib32 = ""
47$ shr = "_SHR"
48$ else
49$ if (p2 .nes. "32")
50$ then
51$ write sys$output "Second argument invalid."
52$ write sys$output "It should be "32", "64", or nothing."
53$ exit
54$ endif
55$ endif
56$ endif
57$!
58$ root = f$parse( p1, "[]A.;0", , , "syntax_only, no_conceal") - "A.;0"
59$ root_dev = f$parse( root, , , "device", "syntax_only")
60$ root_dir = f$parse( root, , , "directory", "syntax_only") - -
61 "[000000." - "][" - "[" - "]"
62$ root = root_dev + "[" + root_dir
63$!
64$ define /nolog wrk_sslroot 'root'.] /trans=conc
65$ define /nolog wrk_sslinclude wrk_sslroot:[include]
66$ define /nolog wrk_sslxlib wrk_sslroot:['arch'_lib]
67$!
68$ if f$parse("wrk_sslroot:[000000]") .eqs. "" then -
69 create /directory /log wrk_sslroot:[000000]
70$ if f$parse("wrk_sslinclude:") .eqs. "" then -
71 create /directory /log wrk_sslinclude:
72$ if f$parse("wrk_sslxlib:") .eqs. "" then -
73 create /directory /log wrk_sslxlib:
74$!
75$ sdirs := , -
76 'archd', -
77 objects, -
78 md2, md4, md5, sha, mdc2, hmac, ripemd, whrlpool, -
79 des, aes, rc2, rc4, rc5, idea, bf, cast, camellia, seed, -
80 bn, ec, rsa, dsa, ecdsa, dh, ecdh, dso, engine, -
81 buffer, bio, stack, lhash, rand, err, -
82 evp, asn1, pem, x509, x509v3, conf, txt_db, pkcs7, pkcs12, comp, ocsp, -
83 ui, krb5, -
84 store, cms, pqueue, ts, jpake
85$!
86$ exheader_ := crypto.h, opensslv.h, ebcdic.h, symhacks.h, ossl_typ.h
87$ exheader_'archd' := opensslconf.h
88$ exheader_objects := objects.h, obj_mac.h
89$ exheader_md2 := md2.h
90$ exheader_md4 := md4.h
91$ exheader_md5 := md5.h
92$ exheader_sha := sha.h
93$ exheader_mdc2 := mdc2.h
94$ exheader_hmac := hmac.h
95$ exheader_ripemd := ripemd.h
96$ exheader_whrlpool := whrlpool.h
97$ exheader_des := des.h, des_old.h
98$ exheader_aes := aes.h
99$ exheader_rc2 := rc2.h
100$ exheader_rc4 := rc4.h
101$ exheader_rc5 := rc5.h
102$ exheader_idea := idea.h
103$ exheader_bf := blowfish.h
104$ exheader_cast := cast.h
105$ exheader_camellia := camellia.h
106$ exheader_seed := seed.h
107$ exheader_modes := modes.h
108$ exheader_bn := bn.h
109$ exheader_ec := ec.h
110$ exheader_rsa := rsa.h
111$ exheader_dsa := dsa.h
112$ exheader_ecdsa := ecdsa.h
113$ exheader_dh := dh.h
114$ exheader_ecdh := ecdh.h
115$ exheader_dso := dso.h
116$ exheader_engine := engine.h
117$ exheader_buffer := buffer.h
118$ exheader_bio := bio.h
119$ exheader_stack := stack.h, safestack.h
120$ exheader_lhash := lhash.h
121$ exheader_rand := rand.h
122$ exheader_err := err.h
123$ exheader_evp := evp.h
124$ exheader_asn1 := asn1.h, asn1_mac.h, asn1t.h
125$ exheader_pem := pem.h, pem2.h
126$ exheader_x509 := x509.h, x509_vfy.h
127$ exheader_x509v3 := x509v3.h
128$ exheader_conf := conf.h, conf_api.h
129$ exheader_txt_db := txt_db.h
130$ exheader_pkcs7 := pkcs7.h
131$ exheader_pkcs12 := pkcs12.h
132$ exheader_comp := comp.h
133$ exheader_ocsp := ocsp.h
134$ exheader_ui := ui.h, ui_compat.h
135$ exheader_krb5 := krb5_asn.h
136$! exheader_store := store.h, str_compat.h
137$ exheader_store := store.h
138$ exheader_cms := cms.h
139$ exheader_pqueue := pqueue.h
140$ exheader_ts := ts.h
141$ exheader_jpake := jpake.h
142$ libs := ssl_libcrypto
143$!
144$ exe_dir := [-.'archd'.exe.crypto]
145$!
146$! Header files.
147$!
148$ i = 0
149$ loop_sdirs:
150$ d = f$edit( f$element( i, ",", sdirs), "trim")
151$ i = i + 1
152$ if d .eqs. "," then goto loop_sdirs_end
153$ tmp = exheader_'d'
154$ if (d .nes. "") then d = "."+ d
155$ copy /protection = w:re ['d']'tmp' wrk_sslinclude: /log
156$ goto loop_sdirs
157$ loop_sdirs_end:
158$!
159$! Object libraries, shareable images.
160$!
161$ i = 0
162$ loop_lib:
163$ e = f$edit( f$element( i, ",", libs), "trim")
164$ i = i + 1
165$ if e .eqs. "," then goto loop_lib_end
166$ set noon
167$ file = exe_dir+ e+ lib32+ ".olb"
168$ if f$search( file) .nes. ""
169$ then
170$ copy /protection = w:re 'file' wrk_sslxlib: /log
171$ endif
172$!
173$ file = exe_dir+ e+ shr+ ".exe"
174$ if f$search( file) .nes. ""
175$ then
176$ copy /protection = w:re 'file' wrk_sslxlib: /log
177$ endif
178$ set on
179$ goto loop_lib
180$ loop_lib_end:
181$!
182$ tidy:
183$!
184$ call deass wrk_sslroot
185$ call deass wrk_sslinclude
186$ call deass wrk_sslxlib
187$!
188$ exit
189$!
190$ deass: subroutine
191$ if (f$trnlnm( p1, "LNM$PROCESS") .nes. "")
192$ then
193$ deassign /process 'p1'
194$ endif
195$ endsubroutine
196$!
diff --git a/src/lib/libcrypto/install.com b/src/lib/libcrypto/install.com
deleted file mode 100644
index ad3e4d48c7..0000000000
--- a/src/lib/libcrypto/install.com
+++ /dev/null
@@ -1,155 +0,0 @@
1$! INSTALL.COM -- Installs the files in a given directory tree
2$!
3$! Author: Richard Levitte <richard@levitte.org>
4$! Time of creation: 22-MAY-1998 10:13
5$!
6$! Changes by Zoltan Arpadffy <zoli@polarhome.com>
7$!
8$! P1 root of the directory tree
9$!
10$ IF P1 .EQS. ""
11$ THEN
12$ WRITE SYS$OUTPUT "First argument missing."
13$ WRITE SYS$OUTPUT -
14 "It should be the directory where you want things installed."
15$ EXIT
16$ ENDIF
17$
18$ IF (F$GETSYI("CPU").LT.128)
19$ THEN
20$ ARCH := VAX
21$ ELSE
22$ ARCH = F$EDIT( F$GETSYI( "ARCH_NAME"), "UPCASE")
23$ IF (ARCH .EQS. "") THEN ARCH = "UNK"
24$ ENDIF
25$
26$ ROOT = F$PARSE(P1,"[]A.;0",,,"SYNTAX_ONLY,NO_CONCEAL") - "A.;0"
27$ ROOT_DEV = F$PARSE(ROOT,,,"DEVICE","SYNTAX_ONLY")
28$ ROOT_DIR = F$PARSE(ROOT,,,"DIRECTORY","SYNTAX_ONLY") -
29 - "[000000." - "][" - "[" - "]"
30$ ROOT = ROOT_DEV + "[" + ROOT_DIR
31$
32$ DEFINE/NOLOG WRK_SSLROOT 'ROOT'.] /TRANS=CONC
33$ DEFINE/NOLOG WRK_SSLLIB WRK_SSLROOT:['ARCH'_LIB]
34$ DEFINE/NOLOG WRK_SSLINCLUDE WRK_SSLROOT:[INCLUDE]
35$
36$ IF F$PARSE("WRK_SSLROOT:[000000]") .EQS. "" THEN -
37 CREATE/DIR/LOG WRK_SSLROOT:[000000]
38$ IF F$PARSE("WRK_SSLLIB:") .EQS. "" THEN -
39 CREATE/DIR/LOG WRK_SSLLIB:
40$ IF F$PARSE("WRK_SSLINCLUDE:") .EQS. "" THEN -
41 CREATE/DIR/LOG WRK_SSLINCLUDE:
42$
43$ SDIRS := ,-
44 _'ARCH',-
45 OBJECTS,-
46 MD2,MD4,MD5,SHA,MDC2,HMAC,RIPEMD,WHRLPOOL,-
47 DES,AES,RC2,RC4,RC5,IDEA,BF,CAST,CAMELLIA,SEED,-
48 BN,EC,RSA,DSA,ECDSA,DH,ECDH,DSO,ENGINE,-
49 BUFFER,BIO,STACK,LHASH,RAND,ERR,-
50 EVP,ASN1,PEM,X509,X509V3,CONF,TXT_DB,PKCS7,PKCS12,COMP,OCSP,-
51 UI,KRB5,-
52 STORE,CMS,PQUEUE,TS,JPAKE
53$ EXHEADER_ := crypto.h,opensslv.h,ebcdic.h,symhacks.h,ossl_typ.h
54$ EXHEADER__'ARCH' := opensslconf.h
55$ EXHEADER_OBJECTS := objects.h,obj_mac.h
56$ EXHEADER_MD2 := md2.h
57$ EXHEADER_MD4 := md4.h
58$ EXHEADER_MD5 := md5.h
59$ EXHEADER_SHA := sha.h
60$ EXHEADER_MDC2 := mdc2.h
61$ EXHEADER_HMAC := hmac.h
62$ EXHEADER_RIPEMD := ripemd.h
63$ EXHEADER_WHRLPOOL := whrlpool.h
64$ EXHEADER_DES := des.h,des_old.h
65$ EXHEADER_AES := aes.h
66$ EXHEADER_RC2 := rc2.h
67$ EXHEADER_RC4 := rc4.h
68$ EXHEADER_RC5 := rc5.h
69$ EXHEADER_IDEA := idea.h
70$ EXHEADER_BF := blowfish.h
71$ EXHEADER_CAST := cast.h
72$ EXHEADER_CAMELLIA := camellia.h
73$ EXHEADER_SEED := seed.h
74$ EXHEADER_MODES := modes.h
75$ EXHEADER_BN := bn.h
76$ EXHEADER_EC := ec.h
77$ EXHEADER_RSA := rsa.h
78$ EXHEADER_DSA := dsa.h
79$ EXHEADER_ECDSA := ecdsa.h
80$ EXHEADER_DH := dh.h
81$ EXHEADER_ECDH := ecdh.h
82$ EXHEADER_DSO := dso.h
83$ EXHEADER_ENGINE := engine.h
84$ EXHEADER_BUFFER := buffer.h
85$ EXHEADER_BIO := bio.h
86$ EXHEADER_STACK := stack.h,safestack.h
87$ EXHEADER_LHASH := lhash.h
88$ EXHEADER_RAND := rand.h
89$ EXHEADER_ERR := err.h
90$ EXHEADER_EVP := evp.h
91$ EXHEADER_ASN1 := asn1.h,asn1_mac.h,asn1t.h
92$ EXHEADER_PEM := pem.h,pem2.h
93$ EXHEADER_X509 := x509.h,x509_vfy.h
94$ EXHEADER_X509V3 := x509v3.h
95$ EXHEADER_CONF := conf.h,conf_api.h
96$ EXHEADER_TXT_DB := txt_db.h
97$ EXHEADER_PKCS7 := pkcs7.h
98$ EXHEADER_PKCS12 := pkcs12.h
99$ EXHEADER_COMP := comp.h
100$ EXHEADER_OCSP := ocsp.h
101$ EXHEADER_UI := ui.h,ui_compat.h
102$ EXHEADER_KRB5 := krb5_asn.h
103$! EXHEADER_STORE := store.h,str_compat.h
104$ EXHEADER_STORE := store.h
105$ EXHEADER_CMS := cms.h
106$ EXHEADER_PQUEUE := pqueue.h
107$ EXHEADER_TS := ts.h
108$ EXHEADER_JPAKE := jpake.h
109$ LIBS := LIBCRYPTO
110$
111$ EXE_DIR := [-.'ARCH'.EXE.CRYPTO]
112$
113$ I = 0
114$ LOOP_SDIRS:
115$ D = F$EDIT(F$ELEMENT(I, ",", SDIRS),"TRIM")
116$ I = I + 1
117$ IF D .EQS. "," THEN GOTO LOOP_SDIRS_END
118$ tmp = EXHEADER_'D'
119$ IF D .EQS. ""
120$ THEN
121$ COPY 'tmp' WRK_SSLINCLUDE: /LOG
122$ ELSE
123$ IF D .EQS. "_''ARCH'"
124$ THEN
125$ COPY [-.'ARCH'.CRYPTO]'tmp' WRK_SSLINCLUDE: /LOG
126$ ELSE
127$ COPY [.'D']'tmp' WRK_SSLINCLUDE: /LOG
128$ ENDIF
129$ ENDIF
130$ SET FILE/PROT=WORLD:RE WRK_SSLINCLUDE:'tmp'
131$ GOTO LOOP_SDIRS
132$ LOOP_SDIRS_END:
133$
134$ I = 0
135$ LOOP_LIB:
136$ E = F$EDIT(F$ELEMENT(I, ",", LIBS),"TRIM")
137$ I = I + 1
138$ IF E .EQS. "," THEN GOTO LOOP_LIB_END
139$ SET NOON
140$ IF F$SEARCH(EXE_DIR+E+".OLB") .NES. ""
141$ THEN
142$ COPY 'EXE_DIR''E'.OLB WRK_SSLLIB:'E'.OLB/log
143$ SET FILE/PROT=W:RE WRK_SSLLIB:'E'.OLB
144$ ENDIF
145$ ! Preparing for the time when we have shareable images
146$ IF F$SEARCH(EXE_DIR+E+".EXE") .NES. ""
147$ THEN
148$ COPY 'EXE_DIR''E'.EXE WRK_SSLLIB:'E'.EXE/log
149$ SET FILE/PROT=W:RE WRK_SSLLIB:'E'.EXE
150$ ENDIF
151$ SET ON
152$ GOTO LOOP_LIB
153$ LOOP_LIB_END:
154$
155$ EXIT
diff --git a/src/lib/libcrypto/jpake/Makefile b/src/lib/libcrypto/jpake/Makefile
new file mode 100644
index 0000000000..110c49ce0b
--- /dev/null
+++ b/src/lib/libcrypto/jpake/Makefile
@@ -0,0 +1,64 @@
1DIR=jpake
2TOP=../..
3
4CFLAGS= $(INCLUDES) $(CFLAG)
5
6LIB=$(TOP)/libcrypto.a
7LIBOBJ=jpake.o jpake_err.o
8LIBSRC=jpake.c jpake_err.c
9
10EXHEADER=jpake.h
11TEST=jpaketest.c
12
13top:
14 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
15
16all: lib
17
18lib: $(LIBOBJ)
19 $(AR) $(LIB) $(LIBOBJ)
20 $(RANLIB) $(LIB) || echo Never mind.
21 @touch lib
22
23links:
24 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
25 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
26
27install:
28 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
29 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
30 do \
31 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
32 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
33 done;
34
35depend:
36 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
37 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
38
39dclean:
40 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
41 mv -f Makefile.new $(MAKEFILE)
42
43clean:
44 rm -f *.s *.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
45
46jpaketest: top jpaketest.c $(LIB)
47 $(CC) $(CFLAGS) -Wall -Werror -g -o jpaketest jpaketest.c $(LIB)
48# DO NOT DELETE THIS LINE -- make depend depends on it.
49
50jpake.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
51jpake.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
52jpake.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
53jpake.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
54jpake.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
55jpake.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
56jpake.o: ../../include/openssl/symhacks.h jpake.c jpake.h
57jpake_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
58jpake_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
59jpake_err.o: ../../include/openssl/err.h ../../include/openssl/jpake.h
60jpake_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
61jpake_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
62jpake_err.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
63jpake_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
64jpake_err.o: jpake_err.c
diff --git a/src/lib/libcrypto/jpake/jpake.c b/src/lib/libcrypto/jpake/jpake.c
new file mode 100644
index 0000000000..8e4b633ccc
--- /dev/null
+++ b/src/lib/libcrypto/jpake/jpake.c
@@ -0,0 +1,511 @@
1#include "jpake.h"
2
3#include <openssl/crypto.h>
4#include <openssl/sha.h>
5#include <openssl/err.h>
6#include <memory.h>
7
8/*
9 * In the definition, (xa, xb, xc, xd) are Alice's (x1, x2, x3, x4) or
10 * Bob's (x3, x4, x1, x2). If you see what I mean.
11 */
12
13typedef struct
14 {
15 char *name; /* Must be unique */
16 char *peer_name;
17 BIGNUM *p;
18 BIGNUM *g;
19 BIGNUM *q;
20 BIGNUM *gxc; /* Alice's g^{x3} or Bob's g^{x1} */
21 BIGNUM *gxd; /* Alice's g^{x4} or Bob's g^{x2} */
22 } JPAKE_CTX_PUBLIC;
23
24struct JPAKE_CTX
25 {
26 JPAKE_CTX_PUBLIC p;
27 BIGNUM *secret; /* The shared secret */
28 BN_CTX *ctx;
29 BIGNUM *xa; /* Alice's x1 or Bob's x3 */
30 BIGNUM *xb; /* Alice's x2 or Bob's x4 */
31 BIGNUM *key; /* The calculated (shared) key */
32 };
33
34static void JPAKE_ZKP_init(JPAKE_ZKP *zkp)
35 {
36 zkp->gr = BN_new();
37 zkp->b = BN_new();
38 }
39
40static void JPAKE_ZKP_release(JPAKE_ZKP *zkp)
41 {
42 BN_free(zkp->b);
43 BN_free(zkp->gr);
44 }
45
46/* Two birds with one stone - make the global name as expected */
47#define JPAKE_STEP_PART_init JPAKE_STEP2_init
48#define JPAKE_STEP_PART_release JPAKE_STEP2_release
49
50void JPAKE_STEP_PART_init(JPAKE_STEP_PART *p)
51 {
52 p->gx = BN_new();
53 JPAKE_ZKP_init(&p->zkpx);
54 }
55
56void JPAKE_STEP_PART_release(JPAKE_STEP_PART *p)
57 {
58 JPAKE_ZKP_release(&p->zkpx);
59 BN_free(p->gx);
60 }
61
62void JPAKE_STEP1_init(JPAKE_STEP1 *s1)
63 {
64 JPAKE_STEP_PART_init(&s1->p1);
65 JPAKE_STEP_PART_init(&s1->p2);
66 }
67
68void JPAKE_STEP1_release(JPAKE_STEP1 *s1)
69 {
70 JPAKE_STEP_PART_release(&s1->p2);
71 JPAKE_STEP_PART_release(&s1->p1);
72 }
73
74static void JPAKE_CTX_init(JPAKE_CTX *ctx, const char *name,
75 const char *peer_name, const BIGNUM *p,
76 const BIGNUM *g, const BIGNUM *q,
77 const BIGNUM *secret)
78 {
79 ctx->p.name = OPENSSL_strdup(name);
80 ctx->p.peer_name = OPENSSL_strdup(peer_name);
81 ctx->p.p = BN_dup(p);
82 ctx->p.g = BN_dup(g);
83 ctx->p.q = BN_dup(q);
84 ctx->secret = BN_dup(secret);
85
86 ctx->p.gxc = BN_new();
87 ctx->p.gxd = BN_new();
88
89 ctx->xa = BN_new();
90 ctx->xb = BN_new();
91 ctx->key = BN_new();
92 ctx->ctx = BN_CTX_new();
93 }
94
95static void JPAKE_CTX_release(JPAKE_CTX *ctx)
96 {
97 BN_CTX_free(ctx->ctx);
98 BN_clear_free(ctx->key);
99 BN_clear_free(ctx->xb);
100 BN_clear_free(ctx->xa);
101
102 BN_free(ctx->p.gxd);
103 BN_free(ctx->p.gxc);
104
105 BN_clear_free(ctx->secret);
106 BN_free(ctx->p.q);
107 BN_free(ctx->p.g);
108 BN_free(ctx->p.p);
109 OPENSSL_free(ctx->p.peer_name);
110 OPENSSL_free(ctx->p.name);
111
112 memset(ctx, '\0', sizeof *ctx);
113 }
114
115JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name,
116 const BIGNUM *p, const BIGNUM *g, const BIGNUM *q,
117 const BIGNUM *secret)
118 {
119 JPAKE_CTX *ctx = OPENSSL_malloc(sizeof *ctx);
120
121 JPAKE_CTX_init(ctx, name, peer_name, p, g, q, secret);
122
123 return ctx;
124 }
125
126void JPAKE_CTX_free(JPAKE_CTX *ctx)
127 {
128 JPAKE_CTX_release(ctx);
129 OPENSSL_free(ctx);
130 }
131
132static void hashlength(SHA_CTX *sha, size_t l)
133 {
134 unsigned char b[2];
135
136 OPENSSL_assert(l <= 0xffff);
137 b[0] = l >> 8;
138 b[1] = l&0xff;
139 SHA1_Update(sha, b, 2);
140 }
141
142static void hashstring(SHA_CTX *sha, const char *string)
143 {
144 size_t l = strlen(string);
145
146 hashlength(sha, l);
147 SHA1_Update(sha, string, l);
148 }
149
150static void hashbn(SHA_CTX *sha, const BIGNUM *bn)
151 {
152 size_t l = BN_num_bytes(bn);
153 unsigned char *bin = OPENSSL_malloc(l);
154
155 hashlength(sha, l);
156 BN_bn2bin(bn, bin);
157 SHA1_Update(sha, bin, l);
158 OPENSSL_free(bin);
159 }
160
161/* h=hash(g, g^r, g^x, name) */
162static void zkp_hash(BIGNUM *h, const BIGNUM *zkpg, const JPAKE_STEP_PART *p,
163 const char *proof_name)
164 {
165 unsigned char md[SHA_DIGEST_LENGTH];
166 SHA_CTX sha;
167
168 /*
169 * XXX: hash should not allow moving of the boundaries - Java code
170 * is flawed in this respect. Length encoding seems simplest.
171 */
172 SHA1_Init(&sha);
173 hashbn(&sha, zkpg);
174 OPENSSL_assert(!BN_is_zero(p->zkpx.gr));
175 hashbn(&sha, p->zkpx.gr);
176 hashbn(&sha, p->gx);
177 hashstring(&sha, proof_name);
178 SHA1_Final(md, &sha);
179 BN_bin2bn(md, SHA_DIGEST_LENGTH, h);
180 }
181
182/*
183 * Prove knowledge of x
184 * Note that p->gx has already been calculated
185 */
186static void generate_zkp(JPAKE_STEP_PART *p, const BIGNUM *x,
187 const BIGNUM *zkpg, JPAKE_CTX *ctx)
188 {
189 BIGNUM *r = BN_new();
190 BIGNUM *h = BN_new();
191 BIGNUM *t = BN_new();
192
193 /*
194 * r in [0,q)
195 * XXX: Java chooses r in [0, 2^160) - i.e. distribution not uniform
196 */
197 BN_rand_range(r, ctx->p.q);
198 /* g^r */
199 BN_mod_exp(p->zkpx.gr, zkpg, r, ctx->p.p, ctx->ctx);
200
201 /* h=hash... */
202 zkp_hash(h, zkpg, p, ctx->p.name);
203
204 /* b = r - x*h */
205 BN_mod_mul(t, x, h, ctx->p.q, ctx->ctx);
206 BN_mod_sub(p->zkpx.b, r, t, ctx->p.q, ctx->ctx);
207
208 /* cleanup */
209 BN_free(t);
210 BN_free(h);
211 BN_free(r);
212 }
213
214static int verify_zkp(const JPAKE_STEP_PART *p, const BIGNUM *zkpg,
215 JPAKE_CTX *ctx)
216 {
217 BIGNUM *h = BN_new();
218 BIGNUM *t1 = BN_new();
219 BIGNUM *t2 = BN_new();
220 BIGNUM *t3 = BN_new();
221 int ret = 0;
222
223 zkp_hash(h, zkpg, p, ctx->p.peer_name);
224
225 /* t1 = g^b */
226 BN_mod_exp(t1, zkpg, p->zkpx.b, ctx->p.p, ctx->ctx);
227 /* t2 = (g^x)^h = g^{hx} */
228 BN_mod_exp(t2, p->gx, h, ctx->p.p, ctx->ctx);
229 /* t3 = t1 * t2 = g^{hx} * g^b = g^{hx+b} = g^r (allegedly) */
230 BN_mod_mul(t3, t1, t2, ctx->p.p, ctx->ctx);
231
232 /* verify t3 == g^r */
233 if(BN_cmp(t3, p->zkpx.gr) == 0)
234 ret = 1;
235 else
236 JPAKEerr(JPAKE_F_VERIFY_ZKP, JPAKE_R_ZKP_VERIFY_FAILED);
237
238 /* cleanup */
239 BN_free(t3);
240 BN_free(t2);
241 BN_free(t1);
242 BN_free(h);
243
244 return ret;
245 }
246
247static void generate_step_part(JPAKE_STEP_PART *p, const BIGNUM *x,
248 const BIGNUM *g, JPAKE_CTX *ctx)
249 {
250 BN_mod_exp(p->gx, g, x, ctx->p.p, ctx->ctx);
251 generate_zkp(p, x, g, ctx);
252 }
253
254/* Generate each party's random numbers. xa is in [0, q), xb is in [1, q). */
255static void genrand(JPAKE_CTX *ctx)
256 {
257 BIGNUM *qm1;
258
259 /* xa in [0, q) */
260 BN_rand_range(ctx->xa, ctx->p.q);
261
262 /* q-1 */
263 qm1 = BN_new();
264 BN_copy(qm1, ctx->p.q);
265 BN_sub_word(qm1, 1);
266
267 /* ... and xb in [0, q-1) */
268 BN_rand_range(ctx->xb, qm1);
269 /* [1, q) */
270 BN_add_word(ctx->xb, 1);
271
272 /* cleanup */
273 BN_free(qm1);
274 }
275
276int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx)
277 {
278 genrand(ctx);
279 generate_step_part(&send->p1, ctx->xa, ctx->p.g, ctx);
280 generate_step_part(&send->p2, ctx->xb, ctx->p.g, ctx);
281
282 return 1;
283 }
284
285/* g^x is a legal value */
286static int is_legal(const BIGNUM *gx, const JPAKE_CTX *ctx)
287 {
288 BIGNUM *t;
289 int res;
290
291 if(BN_is_negative(gx) || BN_is_zero(gx) || BN_cmp(gx, ctx->p.p) >= 0)
292 return 0;
293
294 t = BN_new();
295 BN_mod_exp(t, gx, ctx->p.q, ctx->p.p, ctx->ctx);
296 res = BN_is_one(t);
297 BN_free(t);
298
299 return res;
300 }
301
302int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received)
303 {
304 if(!is_legal(received->p1.gx, ctx))
305 {
306 JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL);
307 return 0;
308 }
309
310 if(!is_legal(received->p2.gx, ctx))
311 {
312 JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL);
313 return 0;
314 }
315
316 /* verify their ZKP(xc) */
317 if(!verify_zkp(&received->p1, ctx->p.g, ctx))
318 {
319 JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_VERIFY_X3_FAILED);
320 return 0;
321 }
322
323 /* verify their ZKP(xd) */
324 if(!verify_zkp(&received->p2, ctx->p.g, ctx))
325 {
326 JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_VERIFY_X4_FAILED);
327 return 0;
328 }
329
330 /* g^xd != 1 */
331 if(BN_is_one(received->p2.gx))
332 {
333 JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X4_IS_ONE);
334 return 0;
335 }
336
337 /* Save the bits we need for later */
338 BN_copy(ctx->p.gxc, received->p1.gx);
339 BN_copy(ctx->p.gxd, received->p2.gx);
340
341 return 1;
342 }
343
344
345int JPAKE_STEP2_generate(JPAKE_STEP2 *send, JPAKE_CTX *ctx)
346 {
347 BIGNUM *t1 = BN_new();
348 BIGNUM *t2 = BN_new();
349
350 /*
351 * X = g^{(xa + xc + xd) * xb * s}
352 * t1 = g^xa
353 */
354 BN_mod_exp(t1, ctx->p.g, ctx->xa, ctx->p.p, ctx->ctx);
355 /* t2 = t1 * g^{xc} = g^{xa} * g^{xc} = g^{xa + xc} */
356 BN_mod_mul(t2, t1, ctx->p.gxc, ctx->p.p, ctx->ctx);
357 /* t1 = t2 * g^{xd} = g^{xa + xc + xd} */
358 BN_mod_mul(t1, t2, ctx->p.gxd, ctx->p.p, ctx->ctx);
359 /* t2 = xb * s */
360 BN_mod_mul(t2, ctx->xb, ctx->secret, ctx->p.q, ctx->ctx);
361
362 /*
363 * ZKP(xb * s)
364 * XXX: this is kinda funky, because we're using
365 *
366 * g' = g^{xa + xc + xd}
367 *
368 * as the generator, which means X is g'^{xb * s}
369 * X = t1^{t2} = t1^{xb * s} = g^{(xa + xc + xd) * xb * s}
370 */
371 generate_step_part(send, t2, t1, ctx);
372
373 /* cleanup */
374 BN_free(t1);
375 BN_free(t2);
376
377 return 1;
378 }
379
380/* gx = g^{xc + xa + xb} * xd * s */
381static int compute_key(JPAKE_CTX *ctx, const BIGNUM *gx)
382 {
383 BIGNUM *t1 = BN_new();
384 BIGNUM *t2 = BN_new();
385 BIGNUM *t3 = BN_new();
386
387 /*
388 * K = (gx/g^{xb * xd * s})^{xb}
389 * = (g^{(xc + xa + xb) * xd * s - xb * xd *s})^{xb}
390 * = (g^{(xa + xc) * xd * s})^{xb}
391 * = g^{(xa + xc) * xb * xd * s}
392 * [which is the same regardless of who calculates it]
393 */
394
395 /* t1 = (g^{xd})^{xb} = g^{xb * xd} */
396 BN_mod_exp(t1, ctx->p.gxd, ctx->xb, ctx->p.p, ctx->ctx);
397 /* t2 = -s = q-s */
398 BN_sub(t2, ctx->p.q, ctx->secret);
399 /* t3 = t1^t2 = g^{-xb * xd * s} */
400 BN_mod_exp(t3, t1, t2, ctx->p.p, ctx->ctx);
401 /* t1 = gx * t3 = X/g^{xb * xd * s} */
402 BN_mod_mul(t1, gx, t3, ctx->p.p, ctx->ctx);
403 /* K = t1^{xb} */
404 BN_mod_exp(ctx->key, t1, ctx->xb, ctx->p.p, ctx->ctx);
405
406 /* cleanup */
407 BN_free(t3);
408 BN_free(t2);
409 BN_free(t1);
410
411 return 1;
412 }
413
414int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received)
415 {
416 BIGNUM *t1 = BN_new();
417 BIGNUM *t2 = BN_new();
418 int ret = 0;
419
420 /*
421 * g' = g^{xc + xa + xb} [from our POV]
422 * t1 = xa + xb
423 */
424 BN_mod_add(t1, ctx->xa, ctx->xb, ctx->p.q, ctx->ctx);
425 /* t2 = g^{t1} = g^{xa+xb} */
426 BN_mod_exp(t2, ctx->p.g, t1, ctx->p.p, ctx->ctx);
427 /* t1 = g^{xc} * t2 = g^{xc + xa + xb} */
428 BN_mod_mul(t1, ctx->p.gxc, t2, ctx->p.p, ctx->ctx);
429
430 if(verify_zkp(received, t1, ctx))
431 ret = 1;
432 else
433 JPAKEerr(JPAKE_F_JPAKE_STEP2_PROCESS, JPAKE_R_VERIFY_B_FAILED);
434
435 compute_key(ctx, received->gx);
436
437 /* cleanup */
438 BN_free(t2);
439 BN_free(t1);
440
441 return ret;
442 }
443
444static void quickhashbn(unsigned char *md, const BIGNUM *bn)
445 {
446 SHA_CTX sha;
447
448 SHA1_Init(&sha);
449 hashbn(&sha, bn);
450 SHA1_Final(md, &sha);
451 }
452
453void JPAKE_STEP3A_init(JPAKE_STEP3A *s3a)
454 {}
455
456int JPAKE_STEP3A_generate(JPAKE_STEP3A *send, JPAKE_CTX *ctx)
457 {
458 quickhashbn(send->hhk, ctx->key);
459 SHA1(send->hhk, sizeof send->hhk, send->hhk);
460
461 return 1;
462 }
463
464int JPAKE_STEP3A_process(JPAKE_CTX *ctx, const JPAKE_STEP3A *received)
465 {
466 unsigned char hhk[SHA_DIGEST_LENGTH];
467
468 quickhashbn(hhk, ctx->key);
469 SHA1(hhk, sizeof hhk, hhk);
470 if(memcmp(hhk, received->hhk, sizeof hhk))
471 {
472 JPAKEerr(JPAKE_F_JPAKE_STEP3A_PROCESS, JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH);
473 return 0;
474 }
475 return 1;
476 }
477
478void JPAKE_STEP3A_release(JPAKE_STEP3A *s3a)
479 {}
480
481void JPAKE_STEP3B_init(JPAKE_STEP3B *s3b)
482 {}
483
484int JPAKE_STEP3B_generate(JPAKE_STEP3B *send, JPAKE_CTX *ctx)
485 {
486 quickhashbn(send->hk, ctx->key);
487
488 return 1;
489 }
490
491int JPAKE_STEP3B_process(JPAKE_CTX *ctx, const JPAKE_STEP3B *received)
492 {
493 unsigned char hk[SHA_DIGEST_LENGTH];
494
495 quickhashbn(hk, ctx->key);
496 if(memcmp(hk, received->hk, sizeof hk))
497 {
498 JPAKEerr(JPAKE_F_JPAKE_STEP3B_PROCESS, JPAKE_R_HASH_OF_KEY_MISMATCH);
499 return 0;
500 }
501 return 1;
502 }
503
504void JPAKE_STEP3B_release(JPAKE_STEP3B *s3b)
505 {}
506
507const BIGNUM *JPAKE_get_shared_key(JPAKE_CTX *ctx)
508 {
509 return ctx->key;
510 }
511
diff --git a/src/lib/libcrypto/jpake/jpake.h b/src/lib/libcrypto/jpake/jpake.h
new file mode 100644
index 0000000000..fd143b4d9b
--- /dev/null
+++ b/src/lib/libcrypto/jpake/jpake.h
@@ -0,0 +1,131 @@
1/*
2 * Implement J-PAKE, as described in
3 * http://grouper.ieee.org/groups/1363/Research/contributions/hao-ryan-2008.pdf
4 *
5 * With hints from http://www.cl.cam.ac.uk/~fh240/software/JPAKE2.java.
6 */
7
8#ifndef HEADER_JPAKE_H
9#define HEADER_JPAKE_H
10
11#include <openssl/opensslconf.h>
12
13#ifdef OPENSSL_NO_JPAKE
14#error JPAKE is disabled.
15#endif
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#include <openssl/bn.h>
22#include <openssl/sha.h>
23
24typedef struct JPAKE_CTX JPAKE_CTX;
25
26/* Note that "g" in the ZKPs is not necessarily the J-PAKE g. */
27typedef struct
28 {
29 BIGNUM *gr; /* g^r (r random) */
30 BIGNUM *b; /* b = r - x*h, h=hash(g, g^r, g^x, name) */
31 } JPAKE_ZKP;
32
33typedef struct
34 {
35 BIGNUM *gx; /* g^x in step 1, g^(xa + xc + xd) * xb * s in step 2 */
36 JPAKE_ZKP zkpx; /* ZKP(x) or ZKP(xb * s) */
37 } JPAKE_STEP_PART;
38
39typedef struct
40 {
41 JPAKE_STEP_PART p1; /* g^x3, ZKP(x3) or g^x1, ZKP(x1) */
42 JPAKE_STEP_PART p2; /* g^x4, ZKP(x4) or g^x2, ZKP(x2) */
43 } JPAKE_STEP1;
44
45typedef JPAKE_STEP_PART JPAKE_STEP2;
46
47typedef struct
48 {
49 unsigned char hhk[SHA_DIGEST_LENGTH];
50 } JPAKE_STEP3A;
51
52typedef struct
53 {
54 unsigned char hk[SHA_DIGEST_LENGTH];
55 } JPAKE_STEP3B;
56
57/* Parameters are copied */
58JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name,
59 const BIGNUM *p, const BIGNUM *g, const BIGNUM *q,
60 const BIGNUM *secret);
61void JPAKE_CTX_free(JPAKE_CTX *ctx);
62
63/*
64 * Note that JPAKE_STEP1 can be used multiple times before release
65 * without another init.
66 */
67void JPAKE_STEP1_init(JPAKE_STEP1 *s1);
68int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx);
69int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received);
70void JPAKE_STEP1_release(JPAKE_STEP1 *s1);
71
72/*
73 * Note that JPAKE_STEP2 can be used multiple times before release
74 * without another init.
75 */
76void JPAKE_STEP2_init(JPAKE_STEP2 *s2);
77int JPAKE_STEP2_generate(JPAKE_STEP2 *send, JPAKE_CTX *ctx);
78int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received);
79void JPAKE_STEP2_release(JPAKE_STEP2 *s2);
80
81/*
82 * Optionally verify the shared key. If the shared secrets do not
83 * match, the two ends will disagree about the shared key, but
84 * otherwise the protocol will succeed.
85 */
86void JPAKE_STEP3A_init(JPAKE_STEP3A *s3a);
87int JPAKE_STEP3A_generate(JPAKE_STEP3A *send, JPAKE_CTX *ctx);
88int JPAKE_STEP3A_process(JPAKE_CTX *ctx, const JPAKE_STEP3A *received);
89void JPAKE_STEP3A_release(JPAKE_STEP3A *s3a);
90
91void JPAKE_STEP3B_init(JPAKE_STEP3B *s3b);
92int JPAKE_STEP3B_generate(JPAKE_STEP3B *send, JPAKE_CTX *ctx);
93int JPAKE_STEP3B_process(JPAKE_CTX *ctx, const JPAKE_STEP3B *received);
94void JPAKE_STEP3B_release(JPAKE_STEP3B *s3b);
95
96/*
97 * the return value belongs to the library and will be released when
98 * ctx is released, and will change when a new handshake is performed.
99 */
100const BIGNUM *JPAKE_get_shared_key(JPAKE_CTX *ctx);
101
102/* BEGIN ERROR CODES */
103/* The following lines are auto generated by the script mkerr.pl. Any changes
104 * made after this point may be overwritten when the script is next run.
105 */
106void ERR_load_JPAKE_strings(void);
107
108/* Error codes for the JPAKE functions. */
109
110/* Function codes. */
111#define JPAKE_F_JPAKE_STEP1_PROCESS 101
112#define JPAKE_F_JPAKE_STEP2_PROCESS 102
113#define JPAKE_F_JPAKE_STEP3A_PROCESS 103
114#define JPAKE_F_JPAKE_STEP3B_PROCESS 104
115#define JPAKE_F_VERIFY_ZKP 100
116
117/* Reason codes. */
118#define JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL 108
119#define JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL 109
120#define JPAKE_R_G_TO_THE_X4_IS_ONE 105
121#define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH 106
122#define JPAKE_R_HASH_OF_KEY_MISMATCH 107
123#define JPAKE_R_VERIFY_B_FAILED 102
124#define JPAKE_R_VERIFY_X3_FAILED 103
125#define JPAKE_R_VERIFY_X4_FAILED 104
126#define JPAKE_R_ZKP_VERIFY_FAILED 100
127
128#ifdef __cplusplus
129}
130#endif
131#endif
diff --git a/src/lib/libcrypto/engine/hw_nuron_err.c b/src/lib/libcrypto/jpake/jpake_err.c
index df9d7bde76..a9a9dee75c 100644
--- a/src/lib/libcrypto/engine/hw_nuron_err.c
+++ b/src/lib/libcrypto/jpake/jpake_err.c
@@ -1,6 +1,6 @@
1/* hw_nuron_err.c */ 1/* crypto/jpake/jpake_err.c */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1999-2010 The OpenSSL Project. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -60,83 +60,48 @@
60 60
61#include <stdio.h> 61#include <stdio.h>
62#include <openssl/err.h> 62#include <openssl/err.h>
63#include "hw_nuron_err.h" 63#include <openssl/jpake.h>
64 64
65/* BEGIN ERROR CODES */ 65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR 66#ifndef OPENSSL_NO_ERR
67static ERR_STRING_DATA NURON_str_functs[]= 67
68#define ERR_FUNC(func) ERR_PACK(ERR_LIB_JPAKE,func,0)
69#define ERR_REASON(reason) ERR_PACK(ERR_LIB_JPAKE,0,reason)
70
71static ERR_STRING_DATA JPAKE_str_functs[]=
68 { 72 {
69{ERR_PACK(0,NURON_F_NURON_CTRL,0), "NURON_CTRL"}, 73{ERR_FUNC(JPAKE_F_JPAKE_STEP1_PROCESS), "JPAKE_STEP1_process"},
70{ERR_PACK(0,NURON_F_NURON_FINISH,0), "NURON_FINISH"}, 74{ERR_FUNC(JPAKE_F_JPAKE_STEP2_PROCESS), "JPAKE_STEP2_process"},
71{ERR_PACK(0,NURON_F_NURON_INIT,0), "NURON_INIT"}, 75{ERR_FUNC(JPAKE_F_JPAKE_STEP3A_PROCESS), "JPAKE_STEP3A_process"},
72{ERR_PACK(0,NURON_F_NURON_MOD_EXP,0), "NURON_MOD_EXP"}, 76{ERR_FUNC(JPAKE_F_JPAKE_STEP3B_PROCESS), "JPAKE_STEP3B_process"},
77{ERR_FUNC(JPAKE_F_VERIFY_ZKP), "VERIFY_ZKP"},
73{0,NULL} 78{0,NULL}
74 }; 79 };
75 80
76static ERR_STRING_DATA NURON_str_reasons[]= 81static ERR_STRING_DATA JPAKE_str_reasons[]=
77 { 82 {
78{NURON_R_ALREADY_LOADED ,"already loaded"}, 83{ERR_REASON(JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL),"g to the x3 is not legal"},
79{NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED ,"ctrl command not implemented"}, 84{ERR_REASON(JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL),"g to the x4 is not legal"},
80{NURON_R_DSO_FAILURE ,"dso failure"}, 85{ERR_REASON(JPAKE_R_G_TO_THE_X4_IS_ONE) ,"g to the x4 is one"},
81{NURON_R_DSO_FUNCTION_NOT_FOUND ,"dso function not found"}, 86{ERR_REASON(JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH),"hash of hash of key mismatch"},
82{NURON_R_DSO_NOT_FOUND ,"dso not found"}, 87{ERR_REASON(JPAKE_R_HASH_OF_KEY_MISMATCH),"hash of key mismatch"},
83{NURON_R_NOT_LOADED ,"not loaded"}, 88{ERR_REASON(JPAKE_R_VERIFY_B_FAILED) ,"verify b failed"},
89{ERR_REASON(JPAKE_R_VERIFY_X3_FAILED) ,"verify x3 failed"},
90{ERR_REASON(JPAKE_R_VERIFY_X4_FAILED) ,"verify x4 failed"},
91{ERR_REASON(JPAKE_R_ZKP_VERIFY_FAILED) ,"zkp verify failed"},
84{0,NULL} 92{0,NULL}
85 }; 93 };
86 94
87#endif 95#endif
88 96
89#ifdef NURON_LIB_NAME 97void ERR_load_JPAKE_strings(void)
90static ERR_STRING_DATA NURON_lib_name[]=
91 {
92{0 ,NURON_LIB_NAME},
93{0,NULL}
94 };
95#endif
96
97
98static int NURON_lib_error_code=0;
99static int NURON_error_init=1;
100
101static void ERR_load_NURON_strings(void)
102 { 98 {
103 if (NURON_lib_error_code == 0)
104 NURON_lib_error_code=ERR_get_next_error_library();
105
106 if (NURON_error_init)
107 {
108 NURON_error_init=0;
109#ifndef OPENSSL_NO_ERR 99#ifndef OPENSSL_NO_ERR
110 ERR_load_strings(NURON_lib_error_code,NURON_str_functs);
111 ERR_load_strings(NURON_lib_error_code,NURON_str_reasons);
112#endif
113
114#ifdef NURON_LIB_NAME
115 NURON_lib_name->error = ERR_PACK(NURON_lib_error_code,0,0);
116 ERR_load_strings(0,NURON_lib_name);
117#endif
118 }
119 }
120 100
121static void ERR_unload_NURON_strings(void) 101 if (ERR_func_error_string(JPAKE_str_functs[0].error) == NULL)
122 {
123 if (NURON_error_init == 0)
124 { 102 {
125#ifndef OPENSSL_NO_ERR 103 ERR_load_strings(0,JPAKE_str_functs);
126 ERR_unload_strings(NURON_lib_error_code,NURON_str_functs); 104 ERR_load_strings(0,JPAKE_str_reasons);
127 ERR_unload_strings(NURON_lib_error_code,NURON_str_reasons);
128#endif
129
130#ifdef NURON_LIB_NAME
131 ERR_unload_strings(0,NURON_lib_name);
132#endif
133 NURON_error_init=1;
134 } 105 }
135 } 106#endif
136
137static void ERR_NURON_error(int function, int reason, char *file, int line)
138 {
139 if (NURON_lib_error_code == 0)
140 NURON_lib_error_code=ERR_get_next_error_library();
141 ERR_PUT_error(NURON_lib_error_code,function,reason,file,line);
142 } 107 }
diff --git a/src/lib/libcrypto/jpake/jpaketest.c b/src/lib/libcrypto/jpake/jpaketest.c
new file mode 100644
index 0000000000..eaba75ed8a
--- /dev/null
+++ b/src/lib/libcrypto/jpake/jpaketest.c
@@ -0,0 +1,192 @@
1#include <openssl/opensslconf.h>
2
3#ifdef OPENSSL_NO_JPAKE
4
5#include <stdio.h>
6
7int main(int argc, char *argv[])
8{
9 printf("No J-PAKE support\n");
10 return(0);
11}
12
13#else
14
15#include <openssl/jpake.h>
16#include <openssl/err.h>
17
18static void showbn(const char *name, const BIGNUM *bn)
19 {
20 fputs(name, stdout);
21 fputs(" = ", stdout);
22 BN_print_fp(stdout, bn);
23 putc('\n', stdout);
24 }
25
26static int run_jpake(JPAKE_CTX *alice, JPAKE_CTX *bob)
27 {
28 JPAKE_STEP1 alice_s1;
29 JPAKE_STEP1 bob_s1;
30 JPAKE_STEP2 alice_s2;
31 JPAKE_STEP2 bob_s2;
32 JPAKE_STEP3A alice_s3a;
33 JPAKE_STEP3B bob_s3b;
34
35 /* Alice -> Bob: step 1 */
36 puts("A->B s1");
37 JPAKE_STEP1_init(&alice_s1);
38 JPAKE_STEP1_generate(&alice_s1, alice);
39 if(!JPAKE_STEP1_process(bob, &alice_s1))
40 {
41 printf("Bob fails to process Alice's step 1\n");
42 ERR_print_errors_fp(stdout);
43 return 1;
44 }
45 JPAKE_STEP1_release(&alice_s1);
46
47 /* Bob -> Alice: step 1 */
48 puts("B->A s1");
49 JPAKE_STEP1_init(&bob_s1);
50 JPAKE_STEP1_generate(&bob_s1, bob);
51 if(!JPAKE_STEP1_process(alice, &bob_s1))
52 {
53 printf("Alice fails to process Bob's step 1\n");
54 ERR_print_errors_fp(stdout);
55 return 2;
56 }
57 JPAKE_STEP1_release(&bob_s1);
58
59 /* Alice -> Bob: step 2 */
60 puts("A->B s2");
61 JPAKE_STEP2_init(&alice_s2);
62 JPAKE_STEP2_generate(&alice_s2, alice);
63 if(!JPAKE_STEP2_process(bob, &alice_s2))
64 {
65 printf("Bob fails to process Alice's step 2\n");
66 ERR_print_errors_fp(stdout);
67 return 3;
68 }
69 JPAKE_STEP2_release(&alice_s2);
70
71 /* Bob -> Alice: step 2 */
72 puts("B->A s2");
73 JPAKE_STEP2_init(&bob_s2);
74 JPAKE_STEP2_generate(&bob_s2, bob);
75 if(!JPAKE_STEP2_process(alice, &bob_s2))
76 {
77 printf("Alice fails to process Bob's step 2\n");
78 ERR_print_errors_fp(stdout);
79 return 4;
80 }
81 JPAKE_STEP2_release(&bob_s2);
82
83 showbn("Alice's key", JPAKE_get_shared_key(alice));
84 showbn("Bob's key ", JPAKE_get_shared_key(bob));
85
86 /* Alice -> Bob: step 3a */
87 puts("A->B s3a");
88 JPAKE_STEP3A_init(&alice_s3a);
89 JPAKE_STEP3A_generate(&alice_s3a, alice);
90 if(!JPAKE_STEP3A_process(bob, &alice_s3a))
91 {
92 printf("Bob fails to process Alice's step 3a\n");
93 ERR_print_errors_fp(stdout);
94 return 5;
95 }
96 JPAKE_STEP3A_release(&alice_s3a);
97
98 /* Bob -> Alice: step 3b */
99 puts("B->A s3b");
100 JPAKE_STEP3B_init(&bob_s3b);
101 JPAKE_STEP3B_generate(&bob_s3b, bob);
102 if(!JPAKE_STEP3B_process(alice, &bob_s3b))
103 {
104 printf("Alice fails to process Bob's step 3b\n");
105 ERR_print_errors_fp(stdout);
106 return 6;
107 }
108 JPAKE_STEP3B_release(&bob_s3b);
109
110 return 0;
111 }
112
113int main(int argc, char **argv)
114 {
115 JPAKE_CTX *alice;
116 JPAKE_CTX *bob;
117 BIGNUM *p = NULL;
118 BIGNUM *g = NULL;
119 BIGNUM *q = NULL;
120 BIGNUM *secret = BN_new();
121 BIO *bio_err;
122
123 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
124
125 CRYPTO_malloc_debug_init();
126 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
127 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
128
129 ERR_load_crypto_strings();
130
131 /*
132 BN_hex2bn(&p, "fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7");
133 BN_hex2bn(&g, "f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a");
134 BN_hex2bn(&q, "9760508f15230bccb292b982a2eb840bf0581cf5");
135 */
136 /*
137 p = BN_new();
138 BN_generate_prime(p, 1024, 1, NULL, NULL, NULL, NULL);
139 */
140 /* Use a safe prime for p (that we found earlier) */
141 BN_hex2bn(&p, "F9E5B365665EA7A05A9C534502780FEE6F1AB5BD4F49947FD036DBD7E905269AF46EF28B0FC07487EE4F5D20FB3C0AF8E700F3A2FA3414970CBED44FEDFF80CE78D800F184BB82435D137AADA2C6C16523247930A63B85661D1FC817A51ACD96168E95898A1F83A79FFB529368AA7833ABD1B0C3AEDDB14D2E1A2F71D99F763F");
142 showbn("p", p);
143 g = BN_new();
144 BN_set_word(g, 2);
145 showbn("g", g);
146 q = BN_new();
147 BN_rshift1(q, p);
148 showbn("q", q);
149
150 BN_rand(secret, 32, -1, 0);
151
152 /* A normal run, expect this to work... */
153 alice = JPAKE_CTX_new("Alice", "Bob", p, g, q, secret);
154 bob = JPAKE_CTX_new("Bob", "Alice", p, g, q, secret);
155
156 if(run_jpake(alice, bob) != 0)
157 {
158 fprintf(stderr, "Plain JPAKE run failed\n");
159 return 1;
160 }
161
162 JPAKE_CTX_free(bob);
163 JPAKE_CTX_free(alice);
164
165 /* Now give Alice and Bob different secrets */
166 alice = JPAKE_CTX_new("Alice", "Bob", p, g, q, secret);
167 BN_add_word(secret, 1);
168 bob = JPAKE_CTX_new("Bob", "Alice", p, g, q, secret);
169
170 if(run_jpake(alice, bob) != 5)
171 {
172 fprintf(stderr, "Mismatched secret JPAKE run failed\n");
173 return 1;
174 }
175
176 JPAKE_CTX_free(bob);
177 JPAKE_CTX_free(alice);
178
179 BN_free(secret);
180 BN_free(q);
181 BN_free(g);
182 BN_free(p);
183
184 CRYPTO_cleanup_all_ex_data();
185 ERR_remove_thread_state(NULL);
186 ERR_free_strings();
187 CRYPTO_mem_leaks(bio_err);
188
189 return 0;
190 }
191
192#endif
diff --git a/src/lib/libcrypto/md5/asm/md5-sparcv9.S b/src/lib/libcrypto/md5/asm/md5-sparcv9.S
deleted file mode 100644
index db45aa4c97..0000000000
--- a/src/lib/libcrypto/md5/asm/md5-sparcv9.S
+++ /dev/null
@@ -1,1031 +0,0 @@
1.ident "md5-sparcv9.S, Version 1.0"
2.ident "SPARC V9 ISA artwork by Andy Polyakov <appro@fy.chalmers.se>"
3.file "md5-sparcv9.S"
4
5/*
6 * ====================================================================
7 * Copyright (c) 1999 Andy Polyakov <appro@fy.chalmers.se>.
8 *
9 * Rights for redistribution and usage in source and binary forms are
10 * granted as long as above copyright notices are retained. Warranty
11 * of any kind is (of course:-) disclaimed.
12 * ====================================================================
13 */
14
15/*
16 * This is my modest contribution to OpenSSL project (see
17 * http://www.openssl.org/ for more information about it) and is an
18 * assembler implementation of MD5 block hash function. I've hand-coded
19 * this for the sole reason to reach UltraSPARC-specific "load in
20 * little-endian byte order" instruction. This gives up to 15%
21 * performance improvement for cases when input message is aligned at
22 * 32 bits boundary. The module was tested under both 32 *and* 64 bit
23 * kernels. For updates see http://fy.chalmers.se/~appro/hpe/.
24 *
25 * To compile with SC4.x/SC5.x:
26 *
27 * cc -xarch=v[9|8plus] -DOPENSSL_SYSNAME_ULTRASPARC -DMD5_BLOCK_DATA_ORDER \
28 * -c md5-sparcv9.S
29 *
30 * and with gcc:
31 *
32 * gcc -mcpu=ultrasparc -DOPENSSL_SYSNAME_ULTRASPARC -DMD5_BLOCK_DATA_ORDER \
33 * -c md5-sparcv9.S
34 *
35 * or if above fails (it does if you have gas):
36 *
37 * gcc -E -DOPENSSL_SYSNAMEULTRASPARC -DMD5_BLOCK_DATA_ORDER md5_block.sparc.S | \
38 * as -xarch=v8plus /dev/fd/0 -o md5-sparcv9.o
39 */
40
41#include <openssl/e_os2.h>
42
43#define A %o0
44#define B %o1
45#define C %o2
46#define D %o3
47#define T1 %o4
48#define T2 %o5
49
50#define R0 %l0
51#define R1 %l1
52#define R2 %l2
53#define R3 %l3
54#define R4 %l4
55#define R5 %l5
56#define R6 %l6
57#define R7 %l7
58#define R8 %i3
59#define R9 %i4
60#define R10 %i5
61#define R11 %g1
62#define R12 %g2
63#define R13 %g3
64#define RX %g4
65
66#define Aptr %i0+0
67#define Bptr %i0+4
68#define Cptr %i0+8
69#define Dptr %i0+12
70
71#define Aval R5 /* those not used at the end of the last round */
72#define Bval R6
73#define Cval R7
74#define Dval R8
75
76#if defined(MD5_BLOCK_DATA_ORDER)
77# if defined(OPENSSL_SYSNAME_ULTRASPARC)
78# define LOAD lda
79# define X(i) [%i1+i*4]%asi
80# define md5_block md5_block_asm_data_order_aligned
81# define ASI_PRIMARY_LITTLE 0x88
82# else
83# error "MD5_BLOCK_DATA_ORDER is supported only on UltraSPARC!"
84# endif
85#else
86# define LOAD ld
87# define X(i) [%i1+i*4]
88# define md5_block md5_block_asm_host_order
89#endif
90
91.section ".text",#alloc,#execinstr
92
93#if defined(__SUNPRO_C) && defined(__sparcv9)
94 /* They've said -xarch=v9 at command line */
95 .register %g2,#scratch
96 .register %g3,#scratch
97# define FRAME -192
98#elif defined(__GNUC__) && defined(__arch64__)
99 /* They've said -m64 at command line */
100 .register %g2,#scratch
101 .register %g3,#scratch
102# define FRAME -192
103#else
104# define FRAME -96
105#endif
106
107.align 32
108
109.global md5_block
110md5_block:
111 save %sp,FRAME,%sp
112
113 ld [Dptr],D
114 ld [Cptr],C
115 ld [Bptr],B
116 ld [Aptr],A
117#ifdef ASI_PRIMARY_LITTLE
118 rd %asi,%o7 ! How dare I? Well, I just do:-)
119 wr %g0,ASI_PRIMARY_LITTLE,%asi
120#endif
121 LOAD X(0),R0
122
123.Lmd5_block_loop:
124
125!!!!!!!!Round 0
126
127 xor C,D,T1
128 sethi %hi(0xd76aa478),T2
129 and T1,B,T1
130 or T2,%lo(0xd76aa478),T2 !=
131 xor T1,D,T1
132 add T1,R0,T1
133 LOAD X(1),R1
134 add T1,T2,T1 !=
135 add A,T1,A
136 sll A,7,T2
137 srl A,32-7,A
138 or A,T2,A !=
139 xor B,C,T1
140 add A,B,A
141
142 sethi %hi(0xe8c7b756),T2
143 and T1,A,T1 !=
144 or T2,%lo(0xe8c7b756),T2
145 xor T1,C,T1
146 LOAD X(2),R2
147 add T1,R1,T1 !=
148 add T1,T2,T1
149 add D,T1,D
150 sll D,12,T2
151 srl D,32-12,D !=
152 or D,T2,D
153 xor A,B,T1
154 add D,A,D
155
156 sethi %hi(0x242070db),T2 !=
157 and T1,D,T1
158 or T2,%lo(0x242070db),T2
159 xor T1,B,T1
160 add T1,R2,T1 !=
161 LOAD X(3),R3
162 add T1,T2,T1
163 add C,T1,C
164 sll C,17,T2 !=
165 srl C,32-17,C
166 or C,T2,C
167 xor D,A,T1
168 add C,D,C !=
169
170 sethi %hi(0xc1bdceee),T2
171 and T1,C,T1
172 or T2,%lo(0xc1bdceee),T2
173 xor T1,A,T1 !=
174 add T1,R3,T1
175 LOAD X(4),R4
176 add T1,T2,T1
177 add B,T1,B !=
178 sll B,22,T2
179 srl B,32-22,B
180 or B,T2,B
181 xor C,D,T1 !=
182 add B,C,B
183
184 sethi %hi(0xf57c0faf),T2
185 and T1,B,T1
186 or T2,%lo(0xf57c0faf),T2 !=
187 xor T1,D,T1
188 add T1,R4,T1
189 LOAD X(5),R5
190 add T1,T2,T1 !=
191 add A,T1,A
192 sll A,7,T2
193 srl A,32-7,A
194 or A,T2,A !=
195 xor B,C,T1
196 add A,B,A
197
198 sethi %hi(0x4787c62a),T2
199 and T1,A,T1 !=
200 or T2,%lo(0x4787c62a),T2
201 xor T1,C,T1
202 LOAD X(6),R6
203 add T1,R5,T1 !=
204 add T1,T2,T1
205 add D,T1,D
206 sll D,12,T2
207 srl D,32-12,D !=
208 or D,T2,D
209 xor A,B,T1
210 add D,A,D
211
212 sethi %hi(0xa8304613),T2 !=
213 and T1,D,T1
214 or T2,%lo(0xa8304613),T2
215 xor T1,B,T1
216 add T1,R6,T1 !=
217 LOAD X(7),R7
218 add T1,T2,T1
219 add C,T1,C
220 sll C,17,T2 !=
221 srl C,32-17,C
222 or C,T2,C
223 xor D,A,T1
224 add C,D,C !=
225
226 sethi %hi(0xfd469501),T2
227 and T1,C,T1
228 or T2,%lo(0xfd469501),T2
229 xor T1,A,T1 !=
230 add T1,R7,T1
231 LOAD X(8),R8
232 add T1,T2,T1
233 add B,T1,B !=
234 sll B,22,T2
235 srl B,32-22,B
236 or B,T2,B
237 xor C,D,T1 !=
238 add B,C,B
239
240 sethi %hi(0x698098d8),T2
241 and T1,B,T1
242 or T2,%lo(0x698098d8),T2 !=
243 xor T1,D,T1
244 add T1,R8,T1
245 LOAD X(9),R9
246 add T1,T2,T1 !=
247 add A,T1,A
248 sll A,7,T2
249 srl A,32-7,A
250 or A,T2,A !=
251 xor B,C,T1
252 add A,B,A
253
254 sethi %hi(0x8b44f7af),T2
255 and T1,A,T1 !=
256 or T2,%lo(0x8b44f7af),T2
257 xor T1,C,T1
258 LOAD X(10),R10
259 add T1,R9,T1 !=
260 add T1,T2,T1
261 add D,T1,D
262 sll D,12,T2
263 srl D,32-12,D !=
264 or D,T2,D
265 xor A,B,T1
266 add D,A,D
267
268 sethi %hi(0xffff5bb1),T2 !=
269 and T1,D,T1
270 or T2,%lo(0xffff5bb1),T2
271 xor T1,B,T1
272 add T1,R10,T1 !=
273 LOAD X(11),R11
274 add T1,T2,T1
275 add C,T1,C
276 sll C,17,T2 !=
277 srl C,32-17,C
278 or C,T2,C
279 xor D,A,T1
280 add C,D,C !=
281
282 sethi %hi(0x895cd7be),T2
283 and T1,C,T1
284 or T2,%lo(0x895cd7be),T2
285 xor T1,A,T1 !=
286 add T1,R11,T1
287 LOAD X(12),R12
288 add T1,T2,T1
289 add B,T1,B !=
290 sll B,22,T2
291 srl B,32-22,B
292 or B,T2,B
293 xor C,D,T1 !=
294 add B,C,B
295
296 sethi %hi(0x6b901122),T2
297 and T1,B,T1
298 or T2,%lo(0x6b901122),T2 !=
299 xor T1,D,T1
300 add T1,R12,T1
301 LOAD X(13),R13
302 add T1,T2,T1 !=
303 add A,T1,A
304 sll A,7,T2
305 srl A,32-7,A
306 or A,T2,A !=
307 xor B,C,T1
308 add A,B,A
309
310 sethi %hi(0xfd987193),T2
311 and T1,A,T1 !=
312 or T2,%lo(0xfd987193),T2
313 xor T1,C,T1
314 LOAD X(14),RX
315 add T1,R13,T1 !=
316 add T1,T2,T1
317 add D,T1,D
318 sll D,12,T2
319 srl D,32-12,D !=
320 or D,T2,D
321 xor A,B,T1
322 add D,A,D
323
324 sethi %hi(0xa679438e),T2 !=
325 and T1,D,T1
326 or T2,%lo(0xa679438e),T2
327 xor T1,B,T1
328 add T1,RX,T1 !=
329 LOAD X(15),RX
330 add T1,T2,T1
331 add C,T1,C
332 sll C,17,T2 !=
333 srl C,32-17,C
334 or C,T2,C
335 xor D,A,T1
336 add C,D,C !=
337
338 sethi %hi(0x49b40821),T2
339 and T1,C,T1
340 or T2,%lo(0x49b40821),T2
341 xor T1,A,T1 !=
342 add T1,RX,T1
343 !pre-LOADed X(1),R1
344 add T1,T2,T1
345 add B,T1,B
346 sll B,22,T2 !=
347 srl B,32-22,B
348 or B,T2,B
349 add B,C,B
350
351!!!!!!!!Round 1
352
353 xor B,C,T1 !=
354 sethi %hi(0xf61e2562),T2
355 and T1,D,T1
356 or T2,%lo(0xf61e2562),T2
357 xor T1,C,T1 !=
358 add T1,R1,T1
359 !pre-LOADed X(6),R6
360 add T1,T2,T1
361 add A,T1,A
362 sll A,5,T2 !=
363 srl A,32-5,A
364 or A,T2,A
365 add A,B,A
366
367 xor A,B,T1 !=
368 sethi %hi(0xc040b340),T2
369 and T1,C,T1
370 or T2,%lo(0xc040b340),T2
371 xor T1,B,T1 !=
372 add T1,R6,T1
373 !pre-LOADed X(11),R11
374 add T1,T2,T1
375 add D,T1,D
376 sll D,9,T2 !=
377 srl D,32-9,D
378 or D,T2,D
379 add D,A,D
380
381 xor D,A,T1 !=
382 sethi %hi(0x265e5a51),T2
383 and T1,B,T1
384 or T2,%lo(0x265e5a51),T2
385 xor T1,A,T1 !=
386 add T1,R11,T1
387 !pre-LOADed X(0),R0
388 add T1,T2,T1
389 add C,T1,C
390 sll C,14,T2 !=
391 srl C,32-14,C
392 or C,T2,C
393 add C,D,C
394
395 xor C,D,T1 !=
396 sethi %hi(0xe9b6c7aa),T2
397 and T1,A,T1
398 or T2,%lo(0xe9b6c7aa),T2
399 xor T1,D,T1 !=
400 add T1,R0,T1
401 !pre-LOADed X(5),R5
402 add T1,T2,T1
403 add B,T1,B
404 sll B,20,T2 !=
405 srl B,32-20,B
406 or B,T2,B
407 add B,C,B
408
409 xor B,C,T1 !=
410 sethi %hi(0xd62f105d),T2
411 and T1,D,T1
412 or T2,%lo(0xd62f105d),T2
413 xor T1,C,T1 !=
414 add T1,R5,T1
415 !pre-LOADed X(10),R10
416 add T1,T2,T1
417 add A,T1,A
418 sll A,5,T2 !=
419 srl A,32-5,A
420 or A,T2,A
421 add A,B,A
422
423 xor A,B,T1 !=
424 sethi %hi(0x02441453),T2
425 and T1,C,T1
426 or T2,%lo(0x02441453),T2
427 xor T1,B,T1 !=
428 add T1,R10,T1
429 LOAD X(15),RX
430 add T1,T2,T1
431 add D,T1,D !=
432 sll D,9,T2
433 srl D,32-9,D
434 or D,T2,D
435 add D,A,D !=
436
437 xor D,A,T1
438 sethi %hi(0xd8a1e681),T2
439 and T1,B,T1
440 or T2,%lo(0xd8a1e681),T2 !=
441 xor T1,A,T1
442 add T1,RX,T1
443 !pre-LOADed X(4),R4
444 add T1,T2,T1
445 add C,T1,C !=
446 sll C,14,T2
447 srl C,32-14,C
448 or C,T2,C
449 add C,D,C !=
450
451 xor C,D,T1
452 sethi %hi(0xe7d3fbc8),T2
453 and T1,A,T1
454 or T2,%lo(0xe7d3fbc8),T2 !=
455 xor T1,D,T1
456 add T1,R4,T1
457 !pre-LOADed X(9),R9
458 add T1,T2,T1
459 add B,T1,B !=
460 sll B,20,T2
461 srl B,32-20,B
462 or B,T2,B
463 add B,C,B !=
464
465 xor B,C,T1
466 sethi %hi(0x21e1cde6),T2
467 and T1,D,T1
468 or T2,%lo(0x21e1cde6),T2 !=
469 xor T1,C,T1
470 add T1,R9,T1
471 LOAD X(14),RX
472 add T1,T2,T1 !=
473 add A,T1,A
474 sll A,5,T2
475 srl A,32-5,A
476 or A,T2,A !=
477 add A,B,A
478
479 xor A,B,T1
480 sethi %hi(0xc33707d6),T2
481 and T1,C,T1 !=
482 or T2,%lo(0xc33707d6),T2
483 xor T1,B,T1
484 add T1,RX,T1
485 !pre-LOADed X(3),R3
486 add T1,T2,T1 !=
487 add D,T1,D
488 sll D,9,T2
489 srl D,32-9,D
490 or D,T2,D !=
491 add D,A,D
492
493 xor D,A,T1
494 sethi %hi(0xf4d50d87),T2
495 and T1,B,T1 !=
496 or T2,%lo(0xf4d50d87),T2
497 xor T1,A,T1
498 add T1,R3,T1
499 !pre-LOADed X(8),R8
500 add T1,T2,T1 !=
501 add C,T1,C
502 sll C,14,T2
503 srl C,32-14,C
504 or C,T2,C !=
505 add C,D,C
506
507 xor C,D,T1
508 sethi %hi(0x455a14ed),T2
509 and T1,A,T1 !=
510 or T2,%lo(0x455a14ed),T2
511 xor T1,D,T1
512 add T1,R8,T1
513 !pre-LOADed X(13),R13
514 add T1,T2,T1 !=
515 add B,T1,B
516 sll B,20,T2
517 srl B,32-20,B
518 or B,T2,B !=
519 add B,C,B
520
521 xor B,C,T1
522 sethi %hi(0xa9e3e905),T2
523 and T1,D,T1 !=
524 or T2,%lo(0xa9e3e905),T2
525 xor T1,C,T1
526 add T1,R13,T1
527 !pre-LOADed X(2),R2
528 add T1,T2,T1 !=
529 add A,T1,A
530 sll A,5,T2
531 srl A,32-5,A
532 or A,T2,A !=
533 add A,B,A
534
535 xor A,B,T1
536 sethi %hi(0xfcefa3f8),T2
537 and T1,C,T1 !=
538 or T2,%lo(0xfcefa3f8),T2
539 xor T1,B,T1
540 add T1,R2,T1
541 !pre-LOADed X(7),R7
542 add T1,T2,T1 !=
543 add D,T1,D
544 sll D,9,T2
545 srl D,32-9,D
546 or D,T2,D !=
547 add D,A,D
548
549 xor D,A,T1
550 sethi %hi(0x676f02d9),T2
551 and T1,B,T1 !=
552 or T2,%lo(0x676f02d9),T2
553 xor T1,A,T1
554 add T1,R7,T1
555 !pre-LOADed X(12),R12
556 add T1,T2,T1 !=
557 add C,T1,C
558 sll C,14,T2
559 srl C,32-14,C
560 or C,T2,C !=
561 add C,D,C
562
563 xor C,D,T1
564 sethi %hi(0x8d2a4c8a),T2
565 and T1,A,T1 !=
566 or T2,%lo(0x8d2a4c8a),T2
567 xor T1,D,T1
568 add T1,R12,T1
569 !pre-LOADed X(5),R5
570 add T1,T2,T1 !=
571 add B,T1,B
572 sll B,20,T2
573 srl B,32-20,B
574 or B,T2,B !=
575 add B,C,B
576
577!!!!!!!!Round 2
578
579 xor B,C,T1
580 sethi %hi(0xfffa3942),T2
581 xor T1,D,T1 !=
582 or T2,%lo(0xfffa3942),T2
583 add T1,R5,T1
584 !pre-LOADed X(8),R8
585 add T1,T2,T1
586 add A,T1,A !=
587 sll A,4,T2
588 srl A,32-4,A
589 or A,T2,A
590 add A,B,A !=
591
592 xor A,B,T1
593 sethi %hi(0x8771f681),T2
594 xor T1,C,T1
595 or T2,%lo(0x8771f681),T2 !=
596 add T1,R8,T1
597 !pre-LOADed X(11),R11
598 add T1,T2,T1
599 add D,T1,D
600 sll D,11,T2 !=
601 srl D,32-11,D
602 or D,T2,D
603 add D,A,D
604
605 xor D,A,T1 !=
606 sethi %hi(0x6d9d6122),T2
607 xor T1,B,T1
608 or T2,%lo(0x6d9d6122),T2
609 add T1,R11,T1 !=
610 LOAD X(14),RX
611 add T1,T2,T1
612 add C,T1,C
613 sll C,16,T2 !=
614 srl C,32-16,C
615 or C,T2,C
616 add C,D,C
617
618 xor C,D,T1 !=
619 sethi %hi(0xfde5380c),T2
620 xor T1,A,T1
621 or T2,%lo(0xfde5380c),T2
622 add T1,RX,T1 !=
623 !pre-LOADed X(1),R1
624 add T1,T2,T1
625 add B,T1,B
626 sll B,23,T2
627 srl B,32-23,B !=
628 or B,T2,B
629 add B,C,B
630
631 xor B,C,T1
632 sethi %hi(0xa4beea44),T2 !=
633 xor T1,D,T1
634 or T2,%lo(0xa4beea44),T2
635 add T1,R1,T1
636 !pre-LOADed X(4),R4
637 add T1,T2,T1 !=
638 add A,T1,A
639 sll A,4,T2
640 srl A,32-4,A
641 or A,T2,A !=
642 add A,B,A
643
644 xor A,B,T1
645 sethi %hi(0x4bdecfa9),T2
646 xor T1,C,T1 !=
647 or T2,%lo(0x4bdecfa9),T2
648 add T1,R4,T1
649 !pre-LOADed X(7),R7
650 add T1,T2,T1
651 add D,T1,D !=
652 sll D,11,T2
653 srl D,32-11,D
654 or D,T2,D
655 add D,A,D !=
656
657 xor D,A,T1
658 sethi %hi(0xf6bb4b60),T2
659 xor T1,B,T1
660 or T2,%lo(0xf6bb4b60),T2 !=
661 add T1,R7,T1
662 !pre-LOADed X(10),R10
663 add T1,T2,T1
664 add C,T1,C
665 sll C,16,T2 !=
666 srl C,32-16,C
667 or C,T2,C
668 add C,D,C
669
670 xor C,D,T1 !=
671 sethi %hi(0xbebfbc70),T2
672 xor T1,A,T1
673 or T2,%lo(0xbebfbc70),T2
674 add T1,R10,T1 !=
675 !pre-LOADed X(13),R13
676 add T1,T2,T1
677 add B,T1,B
678 sll B,23,T2
679 srl B,32-23,B !=
680 or B,T2,B
681 add B,C,B
682
683 xor B,C,T1
684 sethi %hi(0x289b7ec6),T2 !=
685 xor T1,D,T1
686 or T2,%lo(0x289b7ec6),T2
687 add T1,R13,T1
688 !pre-LOADed X(0),R0
689 add T1,T2,T1 !=
690 add A,T1,A
691 sll A,4,T2
692 srl A,32-4,A
693 or A,T2,A !=
694 add A,B,A
695
696 xor A,B,T1
697 sethi %hi(0xeaa127fa),T2
698 xor T1,C,T1 !=
699 or T2,%lo(0xeaa127fa),T2
700 add T1,R0,T1
701 !pre-LOADed X(3),R3
702 add T1,T2,T1
703 add D,T1,D !=
704 sll D,11,T2
705 srl D,32-11,D
706 or D,T2,D
707 add D,A,D !=
708
709 xor D,A,T1
710 sethi %hi(0xd4ef3085),T2
711 xor T1,B,T1
712 or T2,%lo(0xd4ef3085),T2 !=
713 add T1,R3,T1
714 !pre-LOADed X(6),R6
715 add T1,T2,T1
716 add C,T1,C
717 sll C,16,T2 !=
718 srl C,32-16,C
719 or C,T2,C
720 add C,D,C
721
722 xor C,D,T1 !=
723 sethi %hi(0x04881d05),T2
724 xor T1,A,T1
725 or T2,%lo(0x04881d05),T2
726 add T1,R6,T1 !=
727 !pre-LOADed X(9),R9
728 add T1,T2,T1
729 add B,T1,B
730 sll B,23,T2
731 srl B,32-23,B !=
732 or B,T2,B
733 add B,C,B
734
735 xor B,C,T1
736 sethi %hi(0xd9d4d039),T2 !=
737 xor T1,D,T1
738 or T2,%lo(0xd9d4d039),T2
739 add T1,R9,T1
740 !pre-LOADed X(12),R12
741 add T1,T2,T1 !=
742 add A,T1,A
743 sll A,4,T2
744 srl A,32-4,A
745 or A,T2,A !=
746 add A,B,A
747
748 xor A,B,T1
749 sethi %hi(0xe6db99e5),T2
750 xor T1,C,T1 !=
751 or T2,%lo(0xe6db99e5),T2
752 add T1,R12,T1
753 LOAD X(15),RX
754 add T1,T2,T1 !=
755 add D,T1,D
756 sll D,11,T2
757 srl D,32-11,D
758 or D,T2,D !=
759 add D,A,D
760
761 xor D,A,T1
762 sethi %hi(0x1fa27cf8),T2
763 xor T1,B,T1 !=
764 or T2,%lo(0x1fa27cf8),T2
765 add T1,RX,T1
766 !pre-LOADed X(2),R2
767 add T1,T2,T1
768 add C,T1,C !=
769 sll C,16,T2
770 srl C,32-16,C
771 or C,T2,C
772 add C,D,C !=
773
774 xor C,D,T1
775 sethi %hi(0xc4ac5665),T2
776 xor T1,A,T1
777 or T2,%lo(0xc4ac5665),T2 !=
778 add T1,R2,T1
779 !pre-LOADed X(0),R0
780 add T1,T2,T1
781 add B,T1,B
782 sll B,23,T2 !=
783 srl B,32-23,B
784 or B,T2,B
785 add B,C,B
786
787!!!!!!!!Round 3
788
789 orn B,D,T1 !=
790 sethi %hi(0xf4292244),T2
791 xor T1,C,T1
792 or T2,%lo(0xf4292244),T2
793 add T1,R0,T1 !=
794 !pre-LOADed X(7),R7
795 add T1,T2,T1
796 add A,T1,A
797 sll A,6,T2
798 srl A,32-6,A !=
799 or A,T2,A
800 add A,B,A
801
802 orn A,C,T1
803 sethi %hi(0x432aff97),T2 !=
804 xor T1,B,T1
805 or T2,%lo(0x432aff97),T2
806 LOAD X(14),RX
807 add T1,R7,T1 !=
808 add T1,T2,T1
809 add D,T1,D
810 sll D,10,T2
811 srl D,32-10,D !=
812 or D,T2,D
813 add D,A,D
814
815 orn D,B,T1
816 sethi %hi(0xab9423a7),T2 !=
817 xor T1,A,T1
818 or T2,%lo(0xab9423a7),T2
819 add T1,RX,T1
820 !pre-LOADed X(5),R5
821 add T1,T2,T1 !=
822 add C,T1,C
823 sll C,15,T2
824 srl C,32-15,C
825 or C,T2,C !=
826 add C,D,C
827
828 orn C,A,T1
829 sethi %hi(0xfc93a039),T2
830 xor T1,D,T1 !=
831 or T2,%lo(0xfc93a039),T2
832 add T1,R5,T1
833 !pre-LOADed X(12),R12
834 add T1,T2,T1
835 add B,T1,B !=
836 sll B,21,T2
837 srl B,32-21,B
838 or B,T2,B
839 add B,C,B !=
840
841 orn B,D,T1
842 sethi %hi(0x655b59c3),T2
843 xor T1,C,T1
844 or T2,%lo(0x655b59c3),T2 !=
845 add T1,R12,T1
846 !pre-LOADed X(3),R3
847 add T1,T2,T1
848 add A,T1,A
849 sll A,6,T2 !=
850 srl A,32-6,A
851 or A,T2,A
852 add A,B,A
853
854 orn A,C,T1 !=
855 sethi %hi(0x8f0ccc92),T2
856 xor T1,B,T1
857 or T2,%lo(0x8f0ccc92),T2
858 add T1,R3,T1 !=
859 !pre-LOADed X(10),R10
860 add T1,T2,T1
861 add D,T1,D
862 sll D,10,T2
863 srl D,32-10,D !=
864 or D,T2,D
865 add D,A,D
866
867 orn D,B,T1
868 sethi %hi(0xffeff47d),T2 !=
869 xor T1,A,T1
870 or T2,%lo(0xffeff47d),T2
871 add T1,R10,T1
872 !pre-LOADed X(1),R1
873 add T1,T2,T1 !=
874 add C,T1,C
875 sll C,15,T2
876 srl C,32-15,C
877 or C,T2,C !=
878 add C,D,C
879
880 orn C,A,T1
881 sethi %hi(0x85845dd1),T2
882 xor T1,D,T1 !=
883 or T2,%lo(0x85845dd1),T2
884 add T1,R1,T1
885 !pre-LOADed X(8),R8
886 add T1,T2,T1
887 add B,T1,B !=
888 sll B,21,T2
889 srl B,32-21,B
890 or B,T2,B
891 add B,C,B !=
892
893 orn B,D,T1
894 sethi %hi(0x6fa87e4f),T2
895 xor T1,C,T1
896 or T2,%lo(0x6fa87e4f),T2 !=
897 add T1,R8,T1
898 LOAD X(15),RX
899 add T1,T2,T1
900 add A,T1,A !=
901 sll A,6,T2
902 srl A,32-6,A
903 or A,T2,A
904 add A,B,A !=
905
906 orn A,C,T1
907 sethi %hi(0xfe2ce6e0),T2
908 xor T1,B,T1
909 or T2,%lo(0xfe2ce6e0),T2 !=
910 add T1,RX,T1
911 !pre-LOADed X(6),R6
912 add T1,T2,T1
913 add D,T1,D
914 sll D,10,T2 !=
915 srl D,32-10,D
916 or D,T2,D
917 add D,A,D
918
919 orn D,B,T1 !=
920 sethi %hi(0xa3014314),T2
921 xor T1,A,T1
922 or T2,%lo(0xa3014314),T2
923 add T1,R6,T1 !=
924 !pre-LOADed X(13),R13
925 add T1,T2,T1
926 add C,T1,C
927 sll C,15,T2
928 srl C,32-15,C !=
929 or C,T2,C
930 add C,D,C
931
932 orn C,A,T1
933 sethi %hi(0x4e0811a1),T2 !=
934 xor T1,D,T1
935 or T2,%lo(0x4e0811a1),T2
936 !pre-LOADed X(4),R4
937 ld [Aptr],Aval
938 add T1,R13,T1 !=
939 add T1,T2,T1
940 add B,T1,B
941 sll B,21,T2
942 srl B,32-21,B !=
943 or B,T2,B
944 add B,C,B
945
946 orn B,D,T1
947 sethi %hi(0xf7537e82),T2 !=
948 xor T1,C,T1
949 or T2,%lo(0xf7537e82),T2
950 !pre-LOADed X(11),R11
951 ld [Dptr],Dval
952 add T1,R4,T1 !=
953 add T1,T2,T1
954 add A,T1,A
955 sll A,6,T2
956 srl A,32-6,A !=
957 or A,T2,A
958 add A,B,A
959
960 orn A,C,T1
961 sethi %hi(0xbd3af235),T2 !=
962 xor T1,B,T1
963 or T2,%lo(0xbd3af235),T2
964 !pre-LOADed X(2),R2
965 ld [Cptr],Cval
966 add T1,R11,T1 !=
967 add T1,T2,T1
968 add D,T1,D
969 sll D,10,T2
970 srl D,32-10,D !=
971 or D,T2,D
972 add D,A,D
973
974 orn D,B,T1
975 sethi %hi(0x2ad7d2bb),T2 !=
976 xor T1,A,T1
977 or T2,%lo(0x2ad7d2bb),T2
978 !pre-LOADed X(9),R9
979 ld [Bptr],Bval
980 add T1,R2,T1 !=
981 add Aval,A,Aval
982 add T1,T2,T1
983 st Aval,[Aptr]
984 add C,T1,C !=
985 sll C,15,T2
986 add Dval,D,Dval
987 srl C,32-15,C
988 or C,T2,C !=
989 st Dval,[Dptr]
990 add C,D,C
991
992 orn C,A,T1
993 sethi %hi(0xeb86d391),T2 !=
994 xor T1,D,T1
995 or T2,%lo(0xeb86d391),T2
996 add T1,R9,T1
997 !pre-LOADed X(0),R0
998 mov Aval,A !=
999 add T1,T2,T1
1000 mov Dval,D
1001 add B,T1,B
1002 sll B,21,T2 !=
1003 add Cval,C,Cval
1004 srl B,32-21,B
1005 st Cval,[Cptr]
1006 or B,T2,B !=
1007 add B,C,B
1008
1009 deccc %i2
1010 mov Cval,C
1011 add B,Bval,B !=
1012 inc 64,%i1
1013 nop
1014 st B,[Bptr]
1015 nop !=
1016
1017#ifdef OPENSSL_SYSNAME_ULTRASPARC
1018 bg,a,pt %icc,.Lmd5_block_loop
1019#else
1020 bg,a .Lmd5_block_loop
1021#endif
1022 LOAD X(0),R0
1023
1024#ifdef ASI_PRIMARY_LITTLE
1025 wr %g0,%o7,%asi
1026#endif
1027 ret
1028 restore %g0,0,%o0
1029
1030.type md5_block,#function
1031.size md5_block,(.-md5_block)
diff --git a/src/lib/libcrypto/err/err_bio.c b/src/lib/libcrypto/mdc2/mdc2_one.c
index a42f804840..72647f67ed 100644
--- a/src/lib/libcrypto/err/err_bio.c
+++ b/src/lib/libcrypto/mdc2/mdc2_one.c
@@ -1,4 +1,4 @@
1/* crypto/err/err_prn.c */ 1/* crypto/mdc2/mdc2_one.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -58,18 +58,19 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include "cryptlib.h"
61#include <openssl/lhash.h> 61#include <openssl/mdc2.h>
62#include <openssl/crypto.h>
63#include <openssl/buffer.h>
64#include <openssl/err.h>
65 62
66static int print_bio(const char *str, size_t len, void *bp) 63unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md)
67 { 64 {
68 return BIO_write((BIO *)bp, str, len); 65 MDC2_CTX c;
69 } 66 static unsigned char m[MDC2_DIGEST_LENGTH];
70void ERR_print_errors(BIO *bp) 67
71 { 68 if (md == NULL) md=m;
72 ERR_print_errors_cb(print_bio, bp); 69 if (!MDC2_Init(&c))
70 return NULL;
71 MDC2_Update(&c,d,n);
72 MDC2_Final(md,&c);
73 OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
74 return(md);
73 } 75 }
74 76
75
diff --git a/src/lib/libcrypto/rand/rand_eng.c b/src/lib/libcrypto/mdc2/mdc2dgst.c
index 1669cef43c..d66ed6a1c6 100644
--- a/src/lib/libcrypto/rand/rand_eng.c
+++ b/src/lib/libcrypto/mdc2/mdc2dgst.c
@@ -1,4 +1,4 @@
1/* crypto/rand/rand_lib.c */ 1/* crypto/mdc2/mdc2dgst.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -57,96 +57,144 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <time.h> 60#include <stdlib.h>
61#include "cryptlib.h" 61#include <string.h>
62#include "rand_lcl.h" 62#include <openssl/crypto.h>
63#include <openssl/rand.h> 63#include <openssl/des.h>
64#ifdef OPENSSL_FIPS 64#include <openssl/mdc2.h>
65#include <openssl/fips.h>
66#include <openssl/fips_rand.h>
67#endif
68
69#ifndef OPENSSL_NO_ENGINE
70#include <openssl/engine.h>
71#endif
72 65
73#if defined(OPENSSL_FIPS) && !defined(OPENSSL_NO_ENGINE) 66#undef c2l
67#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
68 l|=((DES_LONG)(*((c)++)))<< 8L, \
69 l|=((DES_LONG)(*((c)++)))<<16L, \
70 l|=((DES_LONG)(*((c)++)))<<24L)
74 71
75/* non-NULL if default_RAND_meth is ENGINE-provided */ 72#undef l2c
76static ENGINE *funct_ref =NULL; 73#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
74 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
75 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
76 *((c)++)=(unsigned char)(((l)>>24L)&0xff))
77 77
78int eng_RAND_set_rand_method(const RAND_METHOD *meth, const RAND_METHOD **pmeth) 78static void mdc2_body(MDC2_CTX *c, const unsigned char *in, size_t len);
79fips_md_init(MDC2)
79 { 80 {
80 if(funct_ref) 81 c->num=0;
81 { 82 c->pad_type=1;
82 ENGINE_finish(funct_ref); 83 memset(&(c->h[0]),0x52,MDC2_BLOCK);
83 funct_ref = NULL; 84 memset(&(c->hh[0]),0x25,MDC2_BLOCK);
84 }
85 *pmeth = meth;
86 return 1; 85 return 1;
87 } 86 }
88 87
89const RAND_METHOD *eng_RAND_get_rand_method(const RAND_METHOD **pmeth) 88int MDC2_Update(MDC2_CTX *c, const unsigned char *in, size_t len)
90 { 89 {
91 if (!*pmeth) 90 size_t i,j;
91
92 i=c->num;
93 if (i != 0)
92 { 94 {
93 ENGINE *e = ENGINE_get_default_RAND(); 95 if (i+len < MDC2_BLOCK)
94 if(e)
95 { 96 {
96 *pmeth = ENGINE_get_RAND(e); 97 /* partial block */
97 if(!*pmeth) 98 memcpy(&(c->data[i]),in,len);
98 { 99 c->num+=(int)len;
99 ENGINE_finish(e); 100 return 1;
100 e = NULL;
101 }
102 } 101 }
103 if(e)
104 funct_ref = e;
105 else 102 else
106 if(FIPS_mode()) 103 {
107 *pmeth=FIPS_rand_method(); 104 /* filled one */
108 else 105 j=MDC2_BLOCK-i;
109 *pmeth = RAND_SSLeay(); 106 memcpy(&(c->data[i]),in,j);
107 len-=j;
108 in+=j;
109 c->num=0;
110 mdc2_body(c,&(c->data[0]),MDC2_BLOCK);
111 }
112 }
113 i=len&~((size_t)MDC2_BLOCK-1);
114 if (i > 0) mdc2_body(c,in,i);
115 j=len-i;
116 if (j > 0)
117 {
118 memcpy(&(c->data[0]),&(in[i]),j);
119 c->num=(int)j;
110 } 120 }
121 return 1;
122 }
111 123
112 if(FIPS_mode() 124static void mdc2_body(MDC2_CTX *c, const unsigned char *in, size_t len)
113 && *pmeth != FIPS_rand_check()) 125 {
114 { 126 register DES_LONG tin0,tin1;
115 RANDerr(RAND_F_ENG_RAND_GET_RAND_METHOD,RAND_R_NON_FIPS_METHOD); 127 register DES_LONG ttin0,ttin1;
116 return 0; 128 DES_LONG d[2],dd[2];
117 } 129 DES_key_schedule k;
130 unsigned char *p;
131 size_t i;
118 132
119 return *pmeth; 133 for (i=0; i<len; i+=8)
134 {
135 c2l(in,tin0); d[0]=dd[0]=tin0;
136 c2l(in,tin1); d[1]=dd[1]=tin1;
137 c->h[0]=(c->h[0]&0x9f)|0x40;
138 c->hh[0]=(c->hh[0]&0x9f)|0x20;
139
140 DES_set_odd_parity(&c->h);
141 DES_set_key_unchecked(&c->h,&k);
142 DES_encrypt1(d,&k,1);
143
144 DES_set_odd_parity(&c->hh);
145 DES_set_key_unchecked(&c->hh,&k);
146 DES_encrypt1(dd,&k,1);
147
148 ttin0=tin0^dd[0];
149 ttin1=tin1^dd[1];
150 tin0^=d[0];
151 tin1^=d[1];
152
153 p=c->h;
154 l2c(tin0,p);
155 l2c(ttin1,p);
156 p=c->hh;
157 l2c(ttin0,p);
158 l2c(tin1,p);
159 }
120 } 160 }
121 161
122int RAND_set_rand_engine(ENGINE *engine) 162int MDC2_Final(unsigned char *md, MDC2_CTX *c)
123 { 163 {
124 const RAND_METHOD *tmp_meth = NULL; 164 unsigned int i;
125 if(engine) 165 int j;
166
167 i=c->num;
168 j=c->pad_type;
169 if ((i > 0) || (j == 2))
126 { 170 {
127 if(!ENGINE_init(engine)) 171 if (j == 2)
128 return 0; 172 c->data[i++]=0x80;
129 tmp_meth = ENGINE_get_RAND(engine); 173 memset(&(c->data[i]),0,MDC2_BLOCK-i);
130 if(!tmp_meth) 174 mdc2_body(c,c->data,MDC2_BLOCK);
131 {
132 ENGINE_finish(engine);
133 return 0;
134 }
135 } 175 }
136 /* This function releases any prior ENGINE so call it first */ 176 memcpy(md,(char *)c->h,MDC2_BLOCK);
137 RAND_set_rand_method(tmp_meth); 177 memcpy(&(md[MDC2_BLOCK]),(char *)c->hh,MDC2_BLOCK);
138 funct_ref = engine;
139 return 1; 178 return 1;
140 } 179 }
141 180
142void int_RAND_init_engine_callbacks(void) 181#undef TEST
182
183#ifdef TEST
184main()
143 { 185 {
144 static int done = 0; 186 unsigned char md[MDC2_DIGEST_LENGTH];
145 if (done) 187 int i;
146 return; 188 MDC2_CTX c;
147 int_RAND_set_callbacks(eng_RAND_set_rand_method, 189 static char *text="Now is the time for all ";
148 eng_RAND_get_rand_method); 190
149 done = 1; 191 MDC2_Init(&c);
192 MDC2_Update(&c,text,strlen(text));
193 MDC2_Final(&(md[0]),&c);
194
195 for (i=0; i<MDC2_DIGEST_LENGTH; i++)
196 printf("%02X",md[i]);
197 printf("\n");
150 } 198 }
151 199
152#endif 200#endif
diff --git a/src/lib/libcrypto/modes/Makefile b/src/lib/libcrypto/modes/Makefile
new file mode 100644
index 0000000000..3d8bafd571
--- /dev/null
+++ b/src/lib/libcrypto/modes/Makefile
@@ -0,0 +1,144 @@
1#
2# OpenSSL/crypto/modes/Makefile
3#
4
5DIR= modes
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10MAKEFILE= Makefile
11AR= ar r
12
13MODES_ASM_OBJ=
14
15CFLAGS= $(INCLUDES) $(CFLAG)
16ASFLAGS= $(INCLUDES) $(ASFLAG)
17AFLAGS= $(ASFLAGS)
18
19GENERAL=Makefile
20TEST=
21APPS=
22
23LIB=$(TOP)/libcrypto.a
24LIBSRC= cbc128.c ctr128.c cts128.c cfb128.c ofb128.c gcm128.c \
25 ccm128.c xts128.c
26LIBOBJ= cbc128.o ctr128.o cts128.o cfb128.o ofb128.o gcm128.o \
27 ccm128.o xts128.o $(MODES_ASM_OBJ)
28
29SRC= $(LIBSRC)
30
31#EXHEADER= store.h str_compat.h
32EXHEADER= modes.h
33HEADER= modes_lcl.h $(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 $(RANLIB) $(LIB) || echo Never mind.
45 @touch lib
46
47ghash-ia64.s: asm/ghash-ia64.pl
48 $(PERL) asm/ghash-ia64.pl $@ $(CFLAGS)
49ghash-x86.s: asm/ghash-x86.pl
50 $(PERL) asm/ghash-x86.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@
51ghash-x86_64.s: asm/ghash-x86_64.pl
52 $(PERL) asm/ghash-x86_64.pl $(PERLASM_SCHEME) > $@
53ghash-sparcv9.s: asm/ghash-sparcv9.pl
54 $(PERL) asm/ghash-sparcv9.pl $@ $(CFLAGS)
55ghash-alpha.s: asm/ghash-alpha.pl
56 (preproc=/tmp/$$$$.$@; trap "rm $$preproc" INT; \
57 $(PERL) asm/ghash-alpha.pl > $$preproc && \
58 $(CC) -E $$preproc > $@ && rm $$preproc)
59
60ghash-parisc.s: asm/ghash-parisc.pl
61 $(PERL) asm/ghash-parisc.pl $(PERLASM_SCHEME) $@
62
63# GNU make "catch all"
64ghash-%.S: asm/ghash-%.pl; $(PERL) $< $(PERLASM_SCHEME) $@
65
66ghash-armv4.o: ghash-armv4.S
67
68files:
69 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
70
71links:
72 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
73 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
74 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
75
76install:
77 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
78 @headerlist="$(EXHEADER)"; for i in $$headerlist; \
79 do \
80 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
81 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
82 done;
83
84tags:
85 ctags $(SRC)
86
87tests:
88
89lint:
90 lint -DLINT $(INCLUDES) $(SRC)>fluff
91
92depend:
93 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
94 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
95
96dclean:
97 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
98 mv -f Makefile.new $(MAKEFILE)
99
100clean:
101 rm -f *.s *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
102
103# DO NOT DELETE THIS LINE -- make depend depends on it.
104
105cbc128.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
106cbc128.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
107cbc128.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
108cbc128.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
109cbc128.o: ../../include/openssl/symhacks.h cbc128.c modes_lcl.h
110ccm128.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
111ccm128.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
112ccm128.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
113ccm128.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
114ccm128.o: ../../include/openssl/symhacks.h ccm128.c modes_lcl.h
115cfb128.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
116cfb128.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
117cfb128.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
118cfb128.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
119cfb128.o: ../../include/openssl/symhacks.h cfb128.c modes_lcl.h
120ctr128.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
121ctr128.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
122ctr128.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
123ctr128.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
124ctr128.o: ../../include/openssl/symhacks.h ctr128.c modes_lcl.h
125cts128.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
126cts128.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
127cts128.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
128cts128.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
129cts128.o: ../../include/openssl/symhacks.h cts128.c modes_lcl.h
130gcm128.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
131gcm128.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
132gcm128.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
133gcm128.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
134gcm128.o: ../../include/openssl/symhacks.h gcm128.c modes_lcl.h
135ofb128.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
136ofb128.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
137ofb128.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
138ofb128.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
139ofb128.o: ../../include/openssl/symhacks.h modes_lcl.h ofb128.c
140xts128.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
141xts128.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
142xts128.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
143xts128.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
144xts128.o: ../../include/openssl/symhacks.h modes_lcl.h xts128.c
diff --git a/src/lib/libcrypto/engine/hw_nuron_err.h b/src/lib/libcrypto/o_dir.c
index a56bfdf303..42891ea459 100644
--- a/src/lib/libcrypto/engine/hw_nuron_err.h
+++ b/src/lib/libcrypto/o_dir.c
@@ -1,5 +1,9 @@
1/* crypto/o_dir.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2004.
4 */
1/* ==================================================================== 5/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2004 The OpenSSL Project. All rights reserved.
3 * 7 *
4 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -52,35 +56,28 @@
52 * 56 *
53 */ 57 */
54 58
55#ifndef HEADER_NURON_ERR_H 59#include <errno.h>
56#define HEADER_NURON_ERR_H 60#include <e_os.h>
57
58/* BEGIN ERROR CODES */
59/* The following lines are auto generated by the script mkerr.pl. Any changes
60 * made after this point may be overwritten when the script is next run.
61 */
62static void ERR_load_NURON_strings(void);
63static void ERR_unload_NURON_strings(void);
64static void ERR_NURON_error(int function, int reason, char *file, int line);
65#define NURONerr(f,r) ERR_NURON_error((f),(r),__FILE__,__LINE__)
66 61
67/* Error codes for the NURON functions. */ 62/* The routines really come from the Levitte Programming, so to make
63 life simple, let's just use the raw files and hack the symbols to
64 fit our namespace. */
65#define LP_DIR_CTX OPENSSL_DIR_CTX
66#define LP_dir_context_st OPENSSL_dir_context_st
67#define LP_find_file OPENSSL_DIR_read
68#define LP_find_file_end OPENSSL_DIR_end
68 69
69/* Function codes. */ 70#include "o_dir.h"
70#define NURON_F_NURON_CTRL 100
71#define NURON_F_NURON_FINISH 101
72#define NURON_F_NURON_INIT 102
73#define NURON_F_NURON_MOD_EXP 103
74 71
75/* Reason codes. */ 72#define LPDIR_H
76#define NURON_R_ALREADY_LOADED 100 73#if defined OPENSSL_SYS_UNIX || defined DJGPP
77#define NURON_R_CTRL_COMMAND_NOT_IMPLEMENTED 101 74#include "LPdir_unix.c"
78#define NURON_R_DSO_FAILURE 102 75#elif defined OPENSSL_SYS_VMS
79#define NURON_R_DSO_FUNCTION_NOT_FOUND 103 76#include "LPdir_vms.c"
80#define NURON_R_DSO_NOT_FOUND 104 77#elif defined OPENSSL_SYS_WIN32
81#define NURON_R_NOT_LOADED 105 78#include "LPdir_win32.c"
82 79#elif defined OPENSSL_SYS_WINCE
83#ifdef __cplusplus 80#include "LPdir_wince.c"
84} 81#else
85#endif 82#include "LPdir_nyi.c"
86#endif 83#endif
diff --git a/src/lib/libcrypto/o_dir.h b/src/lib/libcrypto/o_dir.h
new file mode 100644
index 0000000000..4b725c0312
--- /dev/null
+++ b/src/lib/libcrypto/o_dir.h
@@ -0,0 +1,53 @@
1/* crypto/o_dir.h -*- mode:C; c-file-style: "eay" -*- */
2/* Copied from Richard Levitte's (richard@levitte.org) LP library. All
3 * symbol names have been changed, with permission from the author.
4 */
5
6/* $LP: LPlib/source/LPdir.h,v 1.1 2004/06/14 08:56:04 _cvs_levitte Exp $ */
7/*
8 * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
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
33
34#ifndef O_DIR_H
35#define O_DIR_H
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41 typedef struct OPENSSL_dir_context_st OPENSSL_DIR_CTX;
42
43 /* returns NULL on error or end-of-directory.
44 If it is end-of-directory, errno will be zero */
45 const char *OPENSSL_DIR_read(OPENSSL_DIR_CTX **ctx, const char *directory);
46 /* returns 1 on success, 0 on error */
47 int OPENSSL_DIR_end(OPENSSL_DIR_CTX **ctx);
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif /* LPDIR_H */
diff --git a/src/lib/libcrypto/o_dir_test.c b/src/lib/libcrypto/o_dir_test.c
new file mode 100644
index 0000000000..3d75ecb005
--- /dev/null
+++ b/src/lib/libcrypto/o_dir_test.c
@@ -0,0 +1,70 @@
1/* crypto/o_dir.h -*- mode:C; c-file-style: "eay" -*- */
2/* Copied from Richard Levitte's (richard@levitte.org) LP library. All
3 * symbol names have been changed, with permission from the author.
4 */
5
6/* $LP: LPlib/test/test_dir.c,v 1.1 2004/06/16 22:59:47 _cvs_levitte Exp $ */
7/*
8 * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
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
33#include <stddef.h>
34#include <stdlib.h>
35#include <stdio.h>
36#include <errno.h>
37#include "e_os2.h"
38#include "o_dir.h"
39
40#if defined OPENSSL_SYS_UNIX || defined OPENSSL_SYS_WIN32 || defined OPENSSL_SYS_WINCE
41#define CURRDIR "."
42#elif defined OPENSSL_SYS_VMS
43#define CURRDIR "SYS$DISK:[]"
44#else
45#error "No supported platform defined!"
46#endif
47
48int main()
49{
50 OPENSSL_DIR_CTX *ctx = NULL;
51 const char *result;
52
53 while((result = OPENSSL_DIR_read(&ctx, CURRDIR)) != NULL)
54 {
55 printf("%s\n", result);
56 }
57
58 if (errno)
59 {
60 perror("test_dir");
61 exit(1);
62 }
63
64 if (!OPENSSL_DIR_end(&ctx))
65 {
66 perror("test_dir");
67 exit(2);
68 }
69 exit(0);
70}
diff --git a/src/lib/libcrypto/ec/ec2_smpt.c b/src/lib/libcrypto/o_fips.c
index 59d52bf663..f6d1b21855 100644
--- a/src/lib/libcrypto/ec/ec2_smpt.c
+++ b/src/lib/libcrypto/o_fips.c
@@ -1,9 +1,8 @@
1/* crypto/ec/ec2_smpt.c */ 1/* Written by Stephen henson (steve@openssl.org) for the OpenSSL
2/* This code was originally written by Douglas Stebila 2 * project 2011.
3 * <dstebila@student.math.uwaterloo.ca> for the OpenSSL project.
4 */ 3 */
5/* ==================================================================== 4/* ====================================================================
6 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 5 * Copyright (c) 2011 The OpenSSL Project. All rights reserved.
7 * 6 *
8 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
@@ -56,19 +55,42 @@
56 * 55 *
57 */ 56 */
58 57
58#include "cryptlib.h"
59#ifdef OPENSSL_FIPS
60#include <openssl/fips.h>
61#include <openssl/fips_rand.h>
62#include <openssl/rand.h>
63#endif
59 64
60/* Calaculates and sets the affine coordinates of an EC_POINT from the given 65int FIPS_mode(void)
61 * compressed coordinates. Uses algorithm 2.3.4 of SEC 1.
62 * Note that the simple implementation only uses affine coordinates.
63 *
64 * This algorithm is patented by Certicom Corp. under US Patent 6,141,420
65 * (for licensing information, contact licensing@certicom.com).
66 * This function is disabled by default and can be enabled by defining the
67 * preprocessor macro OPENSSL_EC_BIN_PT_COMP at Configure-time.
68 */
69int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
70 const BIGNUM *x_, int y_bit, BN_CTX *ctx)
71 { 66 {
72 ECerr(EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES, ERR_R_DISABLED); 67 OPENSSL_init();
68#ifdef OPENSSL_FIPS
69 return FIPS_module_mode();
70#else
73 return 0; 71 return 0;
72#endif
74 } 73 }
74
75int FIPS_mode_set(int r)
76 {
77 OPENSSL_init();
78#ifdef OPENSSL_FIPS
79#ifndef FIPS_AUTH_USER_PASS
80#define FIPS_AUTH_USER_PASS "Default FIPS Crypto User Password"
81#endif
82 if (!FIPS_module_mode_set(r, FIPS_AUTH_USER_PASS))
83 return 0;
84 if (r)
85 RAND_set_rand_method(FIPS_rand_get_method());
86 else
87 RAND_set_rand_method(NULL);
88 return 1;
89#else
90 if (r == 0)
91 return 1;
92 CRYPTOerr(CRYPTO_F_FIPS_MODE_SET, CRYPTO_R_FIPS_MODE_NOT_SUPPORTED);
93 return 0;
94#endif
95 }
96
diff --git a/src/lib/libcrypto/objects/obj_dat.h b/src/lib/libcrypto/objects/obj_dat.h
deleted file mode 100644
index d404ad07c9..0000000000
--- a/src/lib/libcrypto/objects/obj_dat.h
+++ /dev/null
@@ -1,5102 +0,0 @@
1/* crypto/objects/obj_dat.h */
2
3/* THIS FILE IS GENERATED FROM objects.h by obj_dat.pl via the
4 * following command:
5 * perl obj_dat.pl obj_mac.h obj_dat.h
6 */
7
8/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
9 * All rights reserved.
10 *
11 * This package is an SSL implementation written
12 * by Eric Young (eay@cryptsoft.com).
13 * The implementation was written so as to conform with Netscapes SSL.
14 *
15 * This library is free for commercial and non-commercial use as long as
16 * the following conditions are aheared to. The following conditions
17 * apply to all code found in this distribution, be it the RC4, RSA,
18 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
19 * included with this distribution is covered by the same copyright terms
20 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
21 *
22 * Copyright remains Eric Young's, and as such any Copyright notices in
23 * the code are not to be removed.
24 * If this package is used in a product, Eric Young should be given attribution
25 * as the author of the parts of the library used.
26 * This can be in the form of a textual message at program startup or
27 * in documentation (online or textual) provided with the package.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 * 1. Redistributions of source code must retain the copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
37 * 3. All advertising materials mentioning features or use of this software
38 * must display the following acknowledgement:
39 * "This product includes cryptographic software written by
40 * Eric Young (eay@cryptsoft.com)"
41 * The word 'cryptographic' can be left out if the rouines from the library
42 * being used are not cryptographic related :-).
43 * 4. If you include any Windows specific code (or a derivative thereof) from
44 * the apps directory (application code) you must include an acknowledgement:
45 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
46 *
47 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 *
59 * The licence and distribution terms for any publically available version or
60 * derivative of this code cannot be changed. i.e. this code cannot simply be
61 * copied and put under another distribution licence
62 * [including the GNU Public Licence.]
63 */
64
65#define NUM_NID 920
66#define NUM_SN 913
67#define NUM_LN 913
68#define NUM_OBJ 857
69
70static const unsigned char lvalues[5980]={
710x00, /* [ 0] OBJ_undef */
720x2A,0x86,0x48,0x86,0xF7,0x0D, /* [ 1] OBJ_rsadsi */
730x2A,0x86,0x48,0x86,0xF7,0x0D,0x01, /* [ 7] OBJ_pkcs */
740x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x02, /* [ 14] OBJ_md2 */
750x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x05, /* [ 22] OBJ_md5 */
760x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x04, /* [ 30] OBJ_rc4 */
770x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,/* [ 38] OBJ_rsaEncryption */
780x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,/* [ 47] OBJ_md2WithRSAEncryption */
790x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,/* [ 56] OBJ_md5WithRSAEncryption */
800x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x01,/* [ 65] OBJ_pbeWithMD2AndDES_CBC */
810x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x03,/* [ 74] OBJ_pbeWithMD5AndDES_CBC */
820x55, /* [ 83] OBJ_X500 */
830x55,0x04, /* [ 84] OBJ_X509 */
840x55,0x04,0x03, /* [ 86] OBJ_commonName */
850x55,0x04,0x06, /* [ 89] OBJ_countryName */
860x55,0x04,0x07, /* [ 92] OBJ_localityName */
870x55,0x04,0x08, /* [ 95] OBJ_stateOrProvinceName */
880x55,0x04,0x0A, /* [ 98] OBJ_organizationName */
890x55,0x04,0x0B, /* [101] OBJ_organizationalUnitName */
900x55,0x08,0x01,0x01, /* [104] OBJ_rsa */
910x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07, /* [108] OBJ_pkcs7 */
920x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x01,/* [116] OBJ_pkcs7_data */
930x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x02,/* [125] OBJ_pkcs7_signed */
940x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x03,/* [134] OBJ_pkcs7_enveloped */
950x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x04,/* [143] OBJ_pkcs7_signedAndEnveloped */
960x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x05,/* [152] OBJ_pkcs7_digest */
970x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x07,0x06,/* [161] OBJ_pkcs7_encrypted */
980x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x03, /* [170] OBJ_pkcs3 */
990x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x03,0x01,/* [178] OBJ_dhKeyAgreement */
1000x2B,0x0E,0x03,0x02,0x06, /* [187] OBJ_des_ecb */
1010x2B,0x0E,0x03,0x02,0x09, /* [192] OBJ_des_cfb64 */
1020x2B,0x0E,0x03,0x02,0x07, /* [197] OBJ_des_cbc */
1030x2B,0x0E,0x03,0x02,0x11, /* [202] OBJ_des_ede_ecb */
1040x2B,0x06,0x01,0x04,0x01,0x81,0x3C,0x07,0x01,0x01,0x02,/* [207] OBJ_idea_cbc */
1050x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x02, /* [218] OBJ_rc2_cbc */
1060x2B,0x0E,0x03,0x02,0x12, /* [226] OBJ_sha */
1070x2B,0x0E,0x03,0x02,0x0F, /* [231] OBJ_shaWithRSAEncryption */
1080x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x07, /* [236] OBJ_des_ede3_cbc */
1090x2B,0x0E,0x03,0x02,0x08, /* [244] OBJ_des_ofb64 */
1100x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09, /* [249] OBJ_pkcs9 */
1110x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x01,/* [257] OBJ_pkcs9_emailAddress */
1120x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x02,/* [266] OBJ_pkcs9_unstructuredName */
1130x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x03,/* [275] OBJ_pkcs9_contentType */
1140x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x04,/* [284] OBJ_pkcs9_messageDigest */
1150x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x05,/* [293] OBJ_pkcs9_signingTime */
1160x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x06,/* [302] OBJ_pkcs9_countersignature */
1170x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x07,/* [311] OBJ_pkcs9_challengePassword */
1180x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x08,/* [320] OBJ_pkcs9_unstructuredAddress */
1190x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x09,/* [329] OBJ_pkcs9_extCertAttributes */
1200x60,0x86,0x48,0x01,0x86,0xF8,0x42, /* [338] OBJ_netscape */
1210x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01, /* [345] OBJ_netscape_cert_extension */
1220x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x02, /* [353] OBJ_netscape_data_type */
1230x2B,0x0E,0x03,0x02,0x1A, /* [361] OBJ_sha1 */
1240x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,/* [366] OBJ_sha1WithRSAEncryption */
1250x2B,0x0E,0x03,0x02,0x0D, /* [375] OBJ_dsaWithSHA */
1260x2B,0x0E,0x03,0x02,0x0C, /* [380] OBJ_dsa_2 */
1270x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0B,/* [385] OBJ_pbeWithSHA1AndRC2_CBC */
1280x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0C,/* [394] OBJ_id_pbkdf2 */
1290x2B,0x0E,0x03,0x02,0x1B, /* [403] OBJ_dsaWithSHA1_2 */
1300x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x01,/* [408] OBJ_netscape_cert_type */
1310x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x02,/* [417] OBJ_netscape_base_url */
1320x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x03,/* [426] OBJ_netscape_revocation_url */
1330x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x04,/* [435] OBJ_netscape_ca_revocation_url */
1340x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x07,/* [444] OBJ_netscape_renewal_url */
1350x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x08,/* [453] OBJ_netscape_ca_policy_url */
1360x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0C,/* [462] OBJ_netscape_ssl_server_name */
1370x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x01,0x0D,/* [471] OBJ_netscape_comment */
1380x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x02,0x05,/* [480] OBJ_netscape_cert_sequence */
1390x55,0x1D, /* [489] OBJ_id_ce */
1400x55,0x1D,0x0E, /* [491] OBJ_subject_key_identifier */
1410x55,0x1D,0x0F, /* [494] OBJ_key_usage */
1420x55,0x1D,0x10, /* [497] OBJ_private_key_usage_period */
1430x55,0x1D,0x11, /* [500] OBJ_subject_alt_name */
1440x55,0x1D,0x12, /* [503] OBJ_issuer_alt_name */
1450x55,0x1D,0x13, /* [506] OBJ_basic_constraints */
1460x55,0x1D,0x14, /* [509] OBJ_crl_number */
1470x55,0x1D,0x20, /* [512] OBJ_certificate_policies */
1480x55,0x1D,0x23, /* [515] OBJ_authority_key_identifier */
1490x2B,0x06,0x01,0x04,0x01,0x97,0x55,0x01,0x02,/* [518] OBJ_bf_cbc */
1500x55,0x08,0x03,0x65, /* [527] OBJ_mdc2 */
1510x55,0x08,0x03,0x64, /* [531] OBJ_mdc2WithRSA */
1520x55,0x04,0x2A, /* [535] OBJ_givenName */
1530x55,0x04,0x04, /* [538] OBJ_surname */
1540x55,0x04,0x2B, /* [541] OBJ_initials */
1550x55,0x1D,0x1F, /* [544] OBJ_crl_distribution_points */
1560x2B,0x0E,0x03,0x02,0x03, /* [547] OBJ_md5WithRSA */
1570x55,0x04,0x05, /* [552] OBJ_serialNumber */
1580x55,0x04,0x0C, /* [555] OBJ_title */
1590x55,0x04,0x0D, /* [558] OBJ_description */
1600x2A,0x86,0x48,0x86,0xF6,0x7D,0x07,0x42,0x0A,/* [561] OBJ_cast5_cbc */
1610x2A,0x86,0x48,0x86,0xF6,0x7D,0x07,0x42,0x0C,/* [570] OBJ_pbeWithMD5AndCast5_CBC */
1620x2A,0x86,0x48,0xCE,0x38,0x04,0x03, /* [579] OBJ_dsaWithSHA1 */
1630x2B,0x0E,0x03,0x02,0x1D, /* [586] OBJ_sha1WithRSA */
1640x2A,0x86,0x48,0xCE,0x38,0x04,0x01, /* [591] OBJ_dsa */
1650x2B,0x24,0x03,0x02,0x01, /* [598] OBJ_ripemd160 */
1660x2B,0x24,0x03,0x03,0x01,0x02, /* [603] OBJ_ripemd160WithRSA */
1670x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x08, /* [609] OBJ_rc5_cbc */
1680x29,0x01,0x01,0x85,0x1A,0x01, /* [617] OBJ_rle_compression */
1690x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x08,/* [623] OBJ_zlib_compression */
1700x55,0x1D,0x25, /* [634] OBJ_ext_key_usage */
1710x2B,0x06,0x01,0x05,0x05,0x07, /* [637] OBJ_id_pkix */
1720x2B,0x06,0x01,0x05,0x05,0x07,0x03, /* [643] OBJ_id_kp */
1730x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x01, /* [650] OBJ_server_auth */
1740x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x02, /* [658] OBJ_client_auth */
1750x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x03, /* [666] OBJ_code_sign */
1760x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x04, /* [674] OBJ_email_protect */
1770x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x08, /* [682] OBJ_time_stamp */
1780x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x15,/* [690] OBJ_ms_code_ind */
1790x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x16,/* [700] OBJ_ms_code_com */
1800x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x0A,0x03,0x01,/* [710] OBJ_ms_ctl_sign */
1810x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x0A,0x03,0x03,/* [720] OBJ_ms_sgc */
1820x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x0A,0x03,0x04,/* [730] OBJ_ms_efs */
1830x60,0x86,0x48,0x01,0x86,0xF8,0x42,0x04,0x01,/* [740] OBJ_ns_sgc */
1840x55,0x1D,0x1B, /* [749] OBJ_delta_crl */
1850x55,0x1D,0x15, /* [752] OBJ_crl_reason */
1860x55,0x1D,0x18, /* [755] OBJ_invalidity_date */
1870x2B,0x65,0x01,0x04,0x01, /* [758] OBJ_sxnet */
1880x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x01,/* [763] OBJ_pbe_WithSHA1And128BitRC4 */
1890x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x02,/* [773] OBJ_pbe_WithSHA1And40BitRC4 */
1900x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x03,/* [783] OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC */
1910x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x04,/* [793] OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC */
1920x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x05,/* [803] OBJ_pbe_WithSHA1And128BitRC2_CBC */
1930x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x01,0x06,/* [813] OBJ_pbe_WithSHA1And40BitRC2_CBC */
1940x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x01,/* [823] OBJ_keyBag */
1950x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x02,/* [834] OBJ_pkcs8ShroudedKeyBag */
1960x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x03,/* [845] OBJ_certBag */
1970x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x04,/* [856] OBJ_crlBag */
1980x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x05,/* [867] OBJ_secretBag */
1990x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x0C,0x0A,0x01,0x06,/* [878] OBJ_safeContentsBag */
2000x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x14,/* [889] OBJ_friendlyName */
2010x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x15,/* [898] OBJ_localKeyID */
2020x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x16,0x01,/* [907] OBJ_x509Certificate */
2030x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x16,0x02,/* [917] OBJ_sdsiCertificate */
2040x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x17,0x01,/* [927] OBJ_x509Crl */
2050x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0D,/* [937] OBJ_pbes2 */
2060x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0E,/* [946] OBJ_pbmac1 */
2070x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x07, /* [955] OBJ_hmacWithSHA1 */
2080x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x01, /* [963] OBJ_id_qt_cps */
2090x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x02, /* [971] OBJ_id_qt_unotice */
2100x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x0F,/* [979] OBJ_SMIMECapabilities */
2110x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x04,/* [988] OBJ_pbeWithMD2AndRC2_CBC */
2120x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x06,/* [997] OBJ_pbeWithMD5AndRC2_CBC */
2130x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05,0x0A,/* [1006] OBJ_pbeWithSHA1AndDES_CBC */
2140x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x02,0x01,0x0E,/* [1015] OBJ_ms_ext_req */
2150x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x0E,/* [1025] OBJ_ext_req */
2160x55,0x04,0x29, /* [1034] OBJ_name */
2170x55,0x04,0x2E, /* [1037] OBJ_dnQualifier */
2180x2B,0x06,0x01,0x05,0x05,0x07,0x01, /* [1040] OBJ_id_pe */
2190x2B,0x06,0x01,0x05,0x05,0x07,0x30, /* [1047] OBJ_id_ad */
2200x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x01, /* [1054] OBJ_info_access */
2210x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01, /* [1062] OBJ_ad_OCSP */
2220x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x02, /* [1070] OBJ_ad_ca_issuers */
2230x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x09, /* [1078] OBJ_OCSP_sign */
2240x28, /* [1086] OBJ_iso */
2250x2A, /* [1087] OBJ_member_body */
2260x2A,0x86,0x48, /* [1088] OBJ_ISO_US */
2270x2A,0x86,0x48,0xCE,0x38, /* [1091] OBJ_X9_57 */
2280x2A,0x86,0x48,0xCE,0x38,0x04, /* [1096] OBJ_X9cm */
2290x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01, /* [1102] OBJ_pkcs1 */
2300x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x05, /* [1110] OBJ_pkcs5 */
2310x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,/* [1118] OBJ_SMIME */
2320x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,/* [1127] OBJ_id_smime_mod */
2330x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,/* [1137] OBJ_id_smime_ct */
2340x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,/* [1147] OBJ_id_smime_aa */
2350x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,/* [1157] OBJ_id_smime_alg */
2360x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x04,/* [1167] OBJ_id_smime_cd */
2370x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x05,/* [1177] OBJ_id_smime_spq */
2380x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,/* [1187] OBJ_id_smime_cti */
2390x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x01,/* [1197] OBJ_id_smime_mod_cms */
2400x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x02,/* [1208] OBJ_id_smime_mod_ess */
2410x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x03,/* [1219] OBJ_id_smime_mod_oid */
2420x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x04,/* [1230] OBJ_id_smime_mod_msg_v3 */
2430x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x05,/* [1241] OBJ_id_smime_mod_ets_eSignature_88 */
2440x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x06,/* [1252] OBJ_id_smime_mod_ets_eSignature_97 */
2450x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x07,/* [1263] OBJ_id_smime_mod_ets_eSigPolicy_88 */
2460x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x00,0x08,/* [1274] OBJ_id_smime_mod_ets_eSigPolicy_97 */
2470x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x01,/* [1285] OBJ_id_smime_ct_receipt */
2480x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x02,/* [1296] OBJ_id_smime_ct_authData */
2490x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x03,/* [1307] OBJ_id_smime_ct_publishCert */
2500x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x04,/* [1318] OBJ_id_smime_ct_TSTInfo */
2510x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x05,/* [1329] OBJ_id_smime_ct_TDTInfo */
2520x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x06,/* [1340] OBJ_id_smime_ct_contentInfo */
2530x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x07,/* [1351] OBJ_id_smime_ct_DVCSRequestData */
2540x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x08,/* [1362] OBJ_id_smime_ct_DVCSResponseData */
2550x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x01,/* [1373] OBJ_id_smime_aa_receiptRequest */
2560x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x02,/* [1384] OBJ_id_smime_aa_securityLabel */
2570x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x03,/* [1395] OBJ_id_smime_aa_mlExpandHistory */
2580x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x04,/* [1406] OBJ_id_smime_aa_contentHint */
2590x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x05,/* [1417] OBJ_id_smime_aa_msgSigDigest */
2600x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x06,/* [1428] OBJ_id_smime_aa_encapContentType */
2610x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x07,/* [1439] OBJ_id_smime_aa_contentIdentifier */
2620x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x08,/* [1450] OBJ_id_smime_aa_macValue */
2630x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x09,/* [1461] OBJ_id_smime_aa_equivalentLabels */
2640x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0A,/* [1472] OBJ_id_smime_aa_contentReference */
2650x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0B,/* [1483] OBJ_id_smime_aa_encrypKeyPref */
2660x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0C,/* [1494] OBJ_id_smime_aa_signingCertificate */
2670x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0D,/* [1505] OBJ_id_smime_aa_smimeEncryptCerts */
2680x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0E,/* [1516] OBJ_id_smime_aa_timeStampToken */
2690x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x0F,/* [1527] OBJ_id_smime_aa_ets_sigPolicyId */
2700x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x10,/* [1538] OBJ_id_smime_aa_ets_commitmentType */
2710x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x11,/* [1549] OBJ_id_smime_aa_ets_signerLocation */
2720x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x12,/* [1560] OBJ_id_smime_aa_ets_signerAttr */
2730x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x13,/* [1571] OBJ_id_smime_aa_ets_otherSigCert */
2740x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x14,/* [1582] OBJ_id_smime_aa_ets_contentTimestamp */
2750x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x15,/* [1593] OBJ_id_smime_aa_ets_CertificateRefs */
2760x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x16,/* [1604] OBJ_id_smime_aa_ets_RevocationRefs */
2770x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x17,/* [1615] OBJ_id_smime_aa_ets_certValues */
2780x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x18,/* [1626] OBJ_id_smime_aa_ets_revocationValues */
2790x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x19,/* [1637] OBJ_id_smime_aa_ets_escTimeStamp */
2800x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1A,/* [1648] OBJ_id_smime_aa_ets_certCRLTimestamp */
2810x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1B,/* [1659] OBJ_id_smime_aa_ets_archiveTimeStamp */
2820x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1C,/* [1670] OBJ_id_smime_aa_signatureType */
2830x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x02,0x1D,/* [1681] OBJ_id_smime_aa_dvcs_dvc */
2840x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x01,/* [1692] OBJ_id_smime_alg_ESDHwith3DES */
2850x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x02,/* [1703] OBJ_id_smime_alg_ESDHwithRC2 */
2860x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x03,/* [1714] OBJ_id_smime_alg_3DESwrap */
2870x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x04,/* [1725] OBJ_id_smime_alg_RC2wrap */
2880x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x05,/* [1736] OBJ_id_smime_alg_ESDH */
2890x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x06,/* [1747] OBJ_id_smime_alg_CMS3DESwrap */
2900x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x07,/* [1758] OBJ_id_smime_alg_CMSRC2wrap */
2910x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x04,0x01,/* [1769] OBJ_id_smime_cd_ldap */
2920x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x05,0x01,/* [1780] OBJ_id_smime_spq_ets_sqt_uri */
2930x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x05,0x02,/* [1791] OBJ_id_smime_spq_ets_sqt_unotice */
2940x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x01,/* [1802] OBJ_id_smime_cti_ets_proofOfOrigin */
2950x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x02,/* [1813] OBJ_id_smime_cti_ets_proofOfReceipt */
2960x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x03,/* [1824] OBJ_id_smime_cti_ets_proofOfDelivery */
2970x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x04,/* [1835] OBJ_id_smime_cti_ets_proofOfSender */
2980x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x05,/* [1846] OBJ_id_smime_cti_ets_proofOfApproval */
2990x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x06,0x06,/* [1857] OBJ_id_smime_cti_ets_proofOfCreation */
3000x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x04, /* [1868] OBJ_md4 */
3010x2B,0x06,0x01,0x05,0x05,0x07,0x00, /* [1876] OBJ_id_pkix_mod */
3020x2B,0x06,0x01,0x05,0x05,0x07,0x02, /* [1883] OBJ_id_qt */
3030x2B,0x06,0x01,0x05,0x05,0x07,0x04, /* [1890] OBJ_id_it */
3040x2B,0x06,0x01,0x05,0x05,0x07,0x05, /* [1897] OBJ_id_pkip */
3050x2B,0x06,0x01,0x05,0x05,0x07,0x06, /* [1904] OBJ_id_alg */
3060x2B,0x06,0x01,0x05,0x05,0x07,0x07, /* [1911] OBJ_id_cmc */
3070x2B,0x06,0x01,0x05,0x05,0x07,0x08, /* [1918] OBJ_id_on */
3080x2B,0x06,0x01,0x05,0x05,0x07,0x09, /* [1925] OBJ_id_pda */
3090x2B,0x06,0x01,0x05,0x05,0x07,0x0A, /* [1932] OBJ_id_aca */
3100x2B,0x06,0x01,0x05,0x05,0x07,0x0B, /* [1939] OBJ_id_qcs */
3110x2B,0x06,0x01,0x05,0x05,0x07,0x0C, /* [1946] OBJ_id_cct */
3120x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x01, /* [1953] OBJ_id_pkix1_explicit_88 */
3130x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x02, /* [1961] OBJ_id_pkix1_implicit_88 */
3140x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x03, /* [1969] OBJ_id_pkix1_explicit_93 */
3150x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x04, /* [1977] OBJ_id_pkix1_implicit_93 */
3160x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x05, /* [1985] OBJ_id_mod_crmf */
3170x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x06, /* [1993] OBJ_id_mod_cmc */
3180x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x07, /* [2001] OBJ_id_mod_kea_profile_88 */
3190x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x08, /* [2009] OBJ_id_mod_kea_profile_93 */
3200x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x09, /* [2017] OBJ_id_mod_cmp */
3210x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0A, /* [2025] OBJ_id_mod_qualified_cert_88 */
3220x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0B, /* [2033] OBJ_id_mod_qualified_cert_93 */
3230x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0C, /* [2041] OBJ_id_mod_attribute_cert */
3240x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0D, /* [2049] OBJ_id_mod_timestamp_protocol */
3250x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0E, /* [2057] OBJ_id_mod_ocsp */
3260x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x0F, /* [2065] OBJ_id_mod_dvcs */
3270x2B,0x06,0x01,0x05,0x05,0x07,0x00,0x10, /* [2073] OBJ_id_mod_cmp2000 */
3280x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x02, /* [2081] OBJ_biometricInfo */
3290x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x03, /* [2089] OBJ_qcStatements */
3300x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x04, /* [2097] OBJ_ac_auditEntity */
3310x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x05, /* [2105] OBJ_ac_targeting */
3320x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x06, /* [2113] OBJ_aaControls */
3330x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x07, /* [2121] OBJ_sbgp_ipAddrBlock */
3340x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x08, /* [2129] OBJ_sbgp_autonomousSysNum */
3350x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x09, /* [2137] OBJ_sbgp_routerIdentifier */
3360x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x03, /* [2145] OBJ_textNotice */
3370x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x05, /* [2153] OBJ_ipsecEndSystem */
3380x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x06, /* [2161] OBJ_ipsecTunnel */
3390x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x07, /* [2169] OBJ_ipsecUser */
3400x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x0A, /* [2177] OBJ_dvcs */
3410x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x01, /* [2185] OBJ_id_it_caProtEncCert */
3420x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x02, /* [2193] OBJ_id_it_signKeyPairTypes */
3430x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x03, /* [2201] OBJ_id_it_encKeyPairTypes */
3440x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x04, /* [2209] OBJ_id_it_preferredSymmAlg */
3450x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x05, /* [2217] OBJ_id_it_caKeyUpdateInfo */
3460x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x06, /* [2225] OBJ_id_it_currentCRL */
3470x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x07, /* [2233] OBJ_id_it_unsupportedOIDs */
3480x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x08, /* [2241] OBJ_id_it_subscriptionRequest */
3490x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x09, /* [2249] OBJ_id_it_subscriptionResponse */
3500x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0A, /* [2257] OBJ_id_it_keyPairParamReq */
3510x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0B, /* [2265] OBJ_id_it_keyPairParamRep */
3520x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0C, /* [2273] OBJ_id_it_revPassphrase */
3530x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0D, /* [2281] OBJ_id_it_implicitConfirm */
3540x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0E, /* [2289] OBJ_id_it_confirmWaitTime */
3550x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x0F, /* [2297] OBJ_id_it_origPKIMessage */
3560x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01, /* [2305] OBJ_id_regCtrl */
3570x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x02, /* [2313] OBJ_id_regInfo */
3580x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x01,/* [2321] OBJ_id_regCtrl_regToken */
3590x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x02,/* [2330] OBJ_id_regCtrl_authenticator */
3600x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x03,/* [2339] OBJ_id_regCtrl_pkiPublicationInfo */
3610x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x04,/* [2348] OBJ_id_regCtrl_pkiArchiveOptions */
3620x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x05,/* [2357] OBJ_id_regCtrl_oldCertID */
3630x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x01,0x06,/* [2366] OBJ_id_regCtrl_protocolEncrKey */
3640x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x02,0x01,/* [2375] OBJ_id_regInfo_utf8Pairs */
3650x2B,0x06,0x01,0x05,0x05,0x07,0x05,0x02,0x02,/* [2384] OBJ_id_regInfo_certReq */
3660x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x01, /* [2393] OBJ_id_alg_des40 */
3670x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x02, /* [2401] OBJ_id_alg_noSignature */
3680x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x03, /* [2409] OBJ_id_alg_dh_sig_hmac_sha1 */
3690x2B,0x06,0x01,0x05,0x05,0x07,0x06,0x04, /* [2417] OBJ_id_alg_dh_pop */
3700x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x01, /* [2425] OBJ_id_cmc_statusInfo */
3710x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x02, /* [2433] OBJ_id_cmc_identification */
3720x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x03, /* [2441] OBJ_id_cmc_identityProof */
3730x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x04, /* [2449] OBJ_id_cmc_dataReturn */
3740x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x05, /* [2457] OBJ_id_cmc_transactionId */
3750x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x06, /* [2465] OBJ_id_cmc_senderNonce */
3760x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x07, /* [2473] OBJ_id_cmc_recipientNonce */
3770x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x08, /* [2481] OBJ_id_cmc_addExtensions */
3780x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x09, /* [2489] OBJ_id_cmc_encryptedPOP */
3790x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x0A, /* [2497] OBJ_id_cmc_decryptedPOP */
3800x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x0B, /* [2505] OBJ_id_cmc_lraPOPWitness */
3810x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x0F, /* [2513] OBJ_id_cmc_getCert */
3820x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x10, /* [2521] OBJ_id_cmc_getCRL */
3830x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x11, /* [2529] OBJ_id_cmc_revokeRequest */
3840x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x12, /* [2537] OBJ_id_cmc_regInfo */
3850x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x13, /* [2545] OBJ_id_cmc_responseInfo */
3860x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x15, /* [2553] OBJ_id_cmc_queryPending */
3870x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x16, /* [2561] OBJ_id_cmc_popLinkRandom */
3880x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x17, /* [2569] OBJ_id_cmc_popLinkWitness */
3890x2B,0x06,0x01,0x05,0x05,0x07,0x07,0x18, /* [2577] OBJ_id_cmc_confirmCertAcceptance */
3900x2B,0x06,0x01,0x05,0x05,0x07,0x08,0x01, /* [2585] OBJ_id_on_personalData */
3910x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x01, /* [2593] OBJ_id_pda_dateOfBirth */
3920x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x02, /* [2601] OBJ_id_pda_placeOfBirth */
3930x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x03, /* [2609] OBJ_id_pda_gender */
3940x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x04, /* [2617] OBJ_id_pda_countryOfCitizenship */
3950x2B,0x06,0x01,0x05,0x05,0x07,0x09,0x05, /* [2625] OBJ_id_pda_countryOfResidence */
3960x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x01, /* [2633] OBJ_id_aca_authenticationInfo */
3970x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x02, /* [2641] OBJ_id_aca_accessIdentity */
3980x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x03, /* [2649] OBJ_id_aca_chargingIdentity */
3990x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x04, /* [2657] OBJ_id_aca_group */
4000x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x05, /* [2665] OBJ_id_aca_role */
4010x2B,0x06,0x01,0x05,0x05,0x07,0x0B,0x01, /* [2673] OBJ_id_qcs_pkixQCSyntax_v1 */
4020x2B,0x06,0x01,0x05,0x05,0x07,0x0C,0x01, /* [2681] OBJ_id_cct_crs */
4030x2B,0x06,0x01,0x05,0x05,0x07,0x0C,0x02, /* [2689] OBJ_id_cct_PKIData */
4040x2B,0x06,0x01,0x05,0x05,0x07,0x0C,0x03, /* [2697] OBJ_id_cct_PKIResponse */
4050x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x03, /* [2705] OBJ_ad_timeStamping */
4060x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x04, /* [2713] OBJ_ad_dvcs */
4070x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x01,/* [2721] OBJ_id_pkix_OCSP_basic */
4080x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x02,/* [2730] OBJ_id_pkix_OCSP_Nonce */
4090x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x03,/* [2739] OBJ_id_pkix_OCSP_CrlID */
4100x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x04,/* [2748] OBJ_id_pkix_OCSP_acceptableResponses */
4110x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x05,/* [2757] OBJ_id_pkix_OCSP_noCheck */
4120x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x06,/* [2766] OBJ_id_pkix_OCSP_archiveCutoff */
4130x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x07,/* [2775] OBJ_id_pkix_OCSP_serviceLocator */
4140x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x08,/* [2784] OBJ_id_pkix_OCSP_extendedStatus */
4150x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x09,/* [2793] OBJ_id_pkix_OCSP_valid */
4160x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x0A,/* [2802] OBJ_id_pkix_OCSP_path */
4170x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x01,0x0B,/* [2811] OBJ_id_pkix_OCSP_trustRoot */
4180x2B,0x0E,0x03,0x02, /* [2820] OBJ_algorithm */
4190x2B,0x0E,0x03,0x02,0x0B, /* [2824] OBJ_rsaSignature */
4200x55,0x08, /* [2829] OBJ_X500algorithms */
4210x2B, /* [2831] OBJ_org */
4220x2B,0x06, /* [2832] OBJ_dod */
4230x2B,0x06,0x01, /* [2834] OBJ_iana */
4240x2B,0x06,0x01,0x01, /* [2837] OBJ_Directory */
4250x2B,0x06,0x01,0x02, /* [2841] OBJ_Management */
4260x2B,0x06,0x01,0x03, /* [2845] OBJ_Experimental */
4270x2B,0x06,0x01,0x04, /* [2849] OBJ_Private */
4280x2B,0x06,0x01,0x05, /* [2853] OBJ_Security */
4290x2B,0x06,0x01,0x06, /* [2857] OBJ_SNMPv2 */
4300x2B,0x06,0x01,0x07, /* [2861] OBJ_Mail */
4310x2B,0x06,0x01,0x04,0x01, /* [2865] OBJ_Enterprises */
4320x2B,0x06,0x01,0x04,0x01,0x8B,0x3A,0x82,0x58,/* [2870] OBJ_dcObject */
4330x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x19,/* [2879] OBJ_domainComponent */
4340x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x0D,/* [2889] OBJ_Domain */
4350x00, /* [2899] OBJ_joint_iso_ccitt */
4360x55,0x01,0x05, /* [2900] OBJ_selected_attribute_types */
4370x55,0x01,0x05,0x37, /* [2903] OBJ_clearance */
4380x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x03,/* [2907] OBJ_md4WithRSAEncryption */
4390x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x0A, /* [2916] OBJ_ac_proxying */
4400x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x0B, /* [2924] OBJ_sinfo_access */
4410x2B,0x06,0x01,0x05,0x05,0x07,0x0A,0x06, /* [2932] OBJ_id_aca_encAttrs */
4420x55,0x04,0x48, /* [2940] OBJ_role */
4430x55,0x1D,0x24, /* [2943] OBJ_policy_constraints */
4440x55,0x1D,0x37, /* [2946] OBJ_target_information */
4450x55,0x1D,0x38, /* [2949] OBJ_no_rev_avail */
4460x00, /* [2952] OBJ_ccitt */
4470x2A,0x86,0x48,0xCE,0x3D, /* [2953] OBJ_ansi_X9_62 */
4480x2A,0x86,0x48,0xCE,0x3D,0x01,0x01, /* [2958] OBJ_X9_62_prime_field */
4490x2A,0x86,0x48,0xCE,0x3D,0x01,0x02, /* [2965] OBJ_X9_62_characteristic_two_field */
4500x2A,0x86,0x48,0xCE,0x3D,0x02,0x01, /* [2972] OBJ_X9_62_id_ecPublicKey */
4510x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x01, /* [2979] OBJ_X9_62_prime192v1 */
4520x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x02, /* [2987] OBJ_X9_62_prime192v2 */
4530x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x03, /* [2995] OBJ_X9_62_prime192v3 */
4540x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x04, /* [3003] OBJ_X9_62_prime239v1 */
4550x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x05, /* [3011] OBJ_X9_62_prime239v2 */
4560x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x06, /* [3019] OBJ_X9_62_prime239v3 */
4570x2A,0x86,0x48,0xCE,0x3D,0x03,0x01,0x07, /* [3027] OBJ_X9_62_prime256v1 */
4580x2A,0x86,0x48,0xCE,0x3D,0x04,0x01, /* [3035] OBJ_ecdsa_with_SHA1 */
4590x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x11,0x01,/* [3042] OBJ_ms_csp_name */
4600x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x01,/* [3051] OBJ_aes_128_ecb */
4610x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x02,/* [3060] OBJ_aes_128_cbc */
4620x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x03,/* [3069] OBJ_aes_128_ofb128 */
4630x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x04,/* [3078] OBJ_aes_128_cfb128 */
4640x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x15,/* [3087] OBJ_aes_192_ecb */
4650x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x16,/* [3096] OBJ_aes_192_cbc */
4660x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x17,/* [3105] OBJ_aes_192_ofb128 */
4670x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x18,/* [3114] OBJ_aes_192_cfb128 */
4680x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x29,/* [3123] OBJ_aes_256_ecb */
4690x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2A,/* [3132] OBJ_aes_256_cbc */
4700x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2B,/* [3141] OBJ_aes_256_ofb128 */
4710x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2C,/* [3150] OBJ_aes_256_cfb128 */
4720x55,0x1D,0x17, /* [3159] OBJ_hold_instruction_code */
4730x2A,0x86,0x48,0xCE,0x38,0x02,0x01, /* [3162] OBJ_hold_instruction_none */
4740x2A,0x86,0x48,0xCE,0x38,0x02,0x02, /* [3169] OBJ_hold_instruction_call_issuer */
4750x2A,0x86,0x48,0xCE,0x38,0x02,0x03, /* [3176] OBJ_hold_instruction_reject */
4760x09, /* [3183] OBJ_data */
4770x09,0x92,0x26, /* [3184] OBJ_pss */
4780x09,0x92,0x26,0x89,0x93,0xF2,0x2C, /* [3187] OBJ_ucl */
4790x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64, /* [3194] OBJ_pilot */
4800x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,/* [3202] OBJ_pilotAttributeType */
4810x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x03,/* [3211] OBJ_pilotAttributeSyntax */
4820x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,/* [3220] OBJ_pilotObjectClass */
4830x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x0A,/* [3229] OBJ_pilotGroups */
4840x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x03,0x04,/* [3238] OBJ_iA5StringSyntax */
4850x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x03,0x05,/* [3248] OBJ_caseIgnoreIA5StringSyntax */
4860x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x03,/* [3258] OBJ_pilotObject */
4870x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x04,/* [3268] OBJ_pilotPerson */
4880x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x05,/* [3278] OBJ_account */
4890x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x06,/* [3288] OBJ_document */
4900x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x07,/* [3298] OBJ_room */
4910x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x09,/* [3308] OBJ_documentSeries */
4920x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x0E,/* [3318] OBJ_rFC822localPart */
4930x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x0F,/* [3328] OBJ_dNSDomain */
4940x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x11,/* [3338] OBJ_domainRelatedObject */
4950x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x12,/* [3348] OBJ_friendlyCountry */
4960x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x13,/* [3358] OBJ_simpleSecurityObject */
4970x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x14,/* [3368] OBJ_pilotOrganization */
4980x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x15,/* [3378] OBJ_pilotDSA */
4990x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x04,0x16,/* [3388] OBJ_qualityLabelledData */
5000x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x01,/* [3398] OBJ_userId */
5010x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x02,/* [3408] OBJ_textEncodedORAddress */
5020x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x03,/* [3418] OBJ_rfc822Mailbox */
5030x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x04,/* [3428] OBJ_info */
5040x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x05,/* [3438] OBJ_favouriteDrink */
5050x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x06,/* [3448] OBJ_roomNumber */
5060x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x07,/* [3458] OBJ_photo */
5070x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x08,/* [3468] OBJ_userClass */
5080x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x09,/* [3478] OBJ_host */
5090x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0A,/* [3488] OBJ_manager */
5100x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0B,/* [3498] OBJ_documentIdentifier */
5110x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0C,/* [3508] OBJ_documentTitle */
5120x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0D,/* [3518] OBJ_documentVersion */
5130x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0E,/* [3528] OBJ_documentAuthor */
5140x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x0F,/* [3538] OBJ_documentLocation */
5150x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x14,/* [3548] OBJ_homeTelephoneNumber */
5160x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x15,/* [3558] OBJ_secretary */
5170x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x16,/* [3568] OBJ_otherMailbox */
5180x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x17,/* [3578] OBJ_lastModifiedTime */
5190x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x18,/* [3588] OBJ_lastModifiedBy */
5200x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1A,/* [3598] OBJ_aRecord */
5210x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1B,/* [3608] OBJ_pilotAttributeType27 */
5220x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1C,/* [3618] OBJ_mXRecord */
5230x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1D,/* [3628] OBJ_nSRecord */
5240x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1E,/* [3638] OBJ_sOARecord */
5250x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x1F,/* [3648] OBJ_cNAMERecord */
5260x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x25,/* [3658] OBJ_associatedDomain */
5270x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x26,/* [3668] OBJ_associatedName */
5280x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x27,/* [3678] OBJ_homePostalAddress */
5290x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x28,/* [3688] OBJ_personalTitle */
5300x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x29,/* [3698] OBJ_mobileTelephoneNumber */
5310x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2A,/* [3708] OBJ_pagerTelephoneNumber */
5320x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2B,/* [3718] OBJ_friendlyCountryName */
5330x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2D,/* [3728] OBJ_organizationalStatus */
5340x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2E,/* [3738] OBJ_janetMailbox */
5350x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x2F,/* [3748] OBJ_mailPreferenceOption */
5360x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x30,/* [3758] OBJ_buildingName */
5370x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x31,/* [3768] OBJ_dSAQuality */
5380x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x32,/* [3778] OBJ_singleLevelQuality */
5390x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x33,/* [3788] OBJ_subtreeMinimumQuality */
5400x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x34,/* [3798] OBJ_subtreeMaximumQuality */
5410x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x35,/* [3808] OBJ_personalSignature */
5420x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x36,/* [3818] OBJ_dITRedirect */
5430x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x37,/* [3828] OBJ_audio */
5440x09,0x92,0x26,0x89,0x93,0xF2,0x2C,0x64,0x01,0x38,/* [3838] OBJ_documentPublisher */
5450x55,0x04,0x2D, /* [3848] OBJ_x500UniqueIdentifier */
5460x2B,0x06,0x01,0x07,0x01, /* [3851] OBJ_mime_mhs */
5470x2B,0x06,0x01,0x07,0x01,0x01, /* [3856] OBJ_mime_mhs_headings */
5480x2B,0x06,0x01,0x07,0x01,0x02, /* [3862] OBJ_mime_mhs_bodies */
5490x2B,0x06,0x01,0x07,0x01,0x01,0x01, /* [3868] OBJ_id_hex_partial_message */
5500x2B,0x06,0x01,0x07,0x01,0x01,0x02, /* [3875] OBJ_id_hex_multipart_message */
5510x55,0x04,0x2C, /* [3882] OBJ_generationQualifier */
5520x55,0x04,0x41, /* [3885] OBJ_pseudonym */
5530x67,0x2A, /* [3888] OBJ_id_set */
5540x67,0x2A,0x00, /* [3890] OBJ_set_ctype */
5550x67,0x2A,0x01, /* [3893] OBJ_set_msgExt */
5560x67,0x2A,0x03, /* [3896] OBJ_set_attr */
5570x67,0x2A,0x05, /* [3899] OBJ_set_policy */
5580x67,0x2A,0x07, /* [3902] OBJ_set_certExt */
5590x67,0x2A,0x08, /* [3905] OBJ_set_brand */
5600x67,0x2A,0x00,0x00, /* [3908] OBJ_setct_PANData */
5610x67,0x2A,0x00,0x01, /* [3912] OBJ_setct_PANToken */
5620x67,0x2A,0x00,0x02, /* [3916] OBJ_setct_PANOnly */
5630x67,0x2A,0x00,0x03, /* [3920] OBJ_setct_OIData */
5640x67,0x2A,0x00,0x04, /* [3924] OBJ_setct_PI */
5650x67,0x2A,0x00,0x05, /* [3928] OBJ_setct_PIData */
5660x67,0x2A,0x00,0x06, /* [3932] OBJ_setct_PIDataUnsigned */
5670x67,0x2A,0x00,0x07, /* [3936] OBJ_setct_HODInput */
5680x67,0x2A,0x00,0x08, /* [3940] OBJ_setct_AuthResBaggage */
5690x67,0x2A,0x00,0x09, /* [3944] OBJ_setct_AuthRevReqBaggage */
5700x67,0x2A,0x00,0x0A, /* [3948] OBJ_setct_AuthRevResBaggage */
5710x67,0x2A,0x00,0x0B, /* [3952] OBJ_setct_CapTokenSeq */
5720x67,0x2A,0x00,0x0C, /* [3956] OBJ_setct_PInitResData */
5730x67,0x2A,0x00,0x0D, /* [3960] OBJ_setct_PI_TBS */
5740x67,0x2A,0x00,0x0E, /* [3964] OBJ_setct_PResData */
5750x67,0x2A,0x00,0x10, /* [3968] OBJ_setct_AuthReqTBS */
5760x67,0x2A,0x00,0x11, /* [3972] OBJ_setct_AuthResTBS */
5770x67,0x2A,0x00,0x12, /* [3976] OBJ_setct_AuthResTBSX */
5780x67,0x2A,0x00,0x13, /* [3980] OBJ_setct_AuthTokenTBS */
5790x67,0x2A,0x00,0x14, /* [3984] OBJ_setct_CapTokenData */
5800x67,0x2A,0x00,0x15, /* [3988] OBJ_setct_CapTokenTBS */
5810x67,0x2A,0x00,0x16, /* [3992] OBJ_setct_AcqCardCodeMsg */
5820x67,0x2A,0x00,0x17, /* [3996] OBJ_setct_AuthRevReqTBS */
5830x67,0x2A,0x00,0x18, /* [4000] OBJ_setct_AuthRevResData */
5840x67,0x2A,0x00,0x19, /* [4004] OBJ_setct_AuthRevResTBS */
5850x67,0x2A,0x00,0x1A, /* [4008] OBJ_setct_CapReqTBS */
5860x67,0x2A,0x00,0x1B, /* [4012] OBJ_setct_CapReqTBSX */
5870x67,0x2A,0x00,0x1C, /* [4016] OBJ_setct_CapResData */
5880x67,0x2A,0x00,0x1D, /* [4020] OBJ_setct_CapRevReqTBS */
5890x67,0x2A,0x00,0x1E, /* [4024] OBJ_setct_CapRevReqTBSX */
5900x67,0x2A,0x00,0x1F, /* [4028] OBJ_setct_CapRevResData */
5910x67,0x2A,0x00,0x20, /* [4032] OBJ_setct_CredReqTBS */
5920x67,0x2A,0x00,0x21, /* [4036] OBJ_setct_CredReqTBSX */
5930x67,0x2A,0x00,0x22, /* [4040] OBJ_setct_CredResData */
5940x67,0x2A,0x00,0x23, /* [4044] OBJ_setct_CredRevReqTBS */
5950x67,0x2A,0x00,0x24, /* [4048] OBJ_setct_CredRevReqTBSX */
5960x67,0x2A,0x00,0x25, /* [4052] OBJ_setct_CredRevResData */
5970x67,0x2A,0x00,0x26, /* [4056] OBJ_setct_PCertReqData */
5980x67,0x2A,0x00,0x27, /* [4060] OBJ_setct_PCertResTBS */
5990x67,0x2A,0x00,0x28, /* [4064] OBJ_setct_BatchAdminReqData */
6000x67,0x2A,0x00,0x29, /* [4068] OBJ_setct_BatchAdminResData */
6010x67,0x2A,0x00,0x2A, /* [4072] OBJ_setct_CardCInitResTBS */
6020x67,0x2A,0x00,0x2B, /* [4076] OBJ_setct_MeAqCInitResTBS */
6030x67,0x2A,0x00,0x2C, /* [4080] OBJ_setct_RegFormResTBS */
6040x67,0x2A,0x00,0x2D, /* [4084] OBJ_setct_CertReqData */
6050x67,0x2A,0x00,0x2E, /* [4088] OBJ_setct_CertReqTBS */
6060x67,0x2A,0x00,0x2F, /* [4092] OBJ_setct_CertResData */
6070x67,0x2A,0x00,0x30, /* [4096] OBJ_setct_CertInqReqTBS */
6080x67,0x2A,0x00,0x31, /* [4100] OBJ_setct_ErrorTBS */
6090x67,0x2A,0x00,0x32, /* [4104] OBJ_setct_PIDualSignedTBE */
6100x67,0x2A,0x00,0x33, /* [4108] OBJ_setct_PIUnsignedTBE */
6110x67,0x2A,0x00,0x34, /* [4112] OBJ_setct_AuthReqTBE */
6120x67,0x2A,0x00,0x35, /* [4116] OBJ_setct_AuthResTBE */
6130x67,0x2A,0x00,0x36, /* [4120] OBJ_setct_AuthResTBEX */
6140x67,0x2A,0x00,0x37, /* [4124] OBJ_setct_AuthTokenTBE */
6150x67,0x2A,0x00,0x38, /* [4128] OBJ_setct_CapTokenTBE */
6160x67,0x2A,0x00,0x39, /* [4132] OBJ_setct_CapTokenTBEX */
6170x67,0x2A,0x00,0x3A, /* [4136] OBJ_setct_AcqCardCodeMsgTBE */
6180x67,0x2A,0x00,0x3B, /* [4140] OBJ_setct_AuthRevReqTBE */
6190x67,0x2A,0x00,0x3C, /* [4144] OBJ_setct_AuthRevResTBE */
6200x67,0x2A,0x00,0x3D, /* [4148] OBJ_setct_AuthRevResTBEB */
6210x67,0x2A,0x00,0x3E, /* [4152] OBJ_setct_CapReqTBE */
6220x67,0x2A,0x00,0x3F, /* [4156] OBJ_setct_CapReqTBEX */
6230x67,0x2A,0x00,0x40, /* [4160] OBJ_setct_CapResTBE */
6240x67,0x2A,0x00,0x41, /* [4164] OBJ_setct_CapRevReqTBE */
6250x67,0x2A,0x00,0x42, /* [4168] OBJ_setct_CapRevReqTBEX */
6260x67,0x2A,0x00,0x43, /* [4172] OBJ_setct_CapRevResTBE */
6270x67,0x2A,0x00,0x44, /* [4176] OBJ_setct_CredReqTBE */
6280x67,0x2A,0x00,0x45, /* [4180] OBJ_setct_CredReqTBEX */
6290x67,0x2A,0x00,0x46, /* [4184] OBJ_setct_CredResTBE */
6300x67,0x2A,0x00,0x47, /* [4188] OBJ_setct_CredRevReqTBE */
6310x67,0x2A,0x00,0x48, /* [4192] OBJ_setct_CredRevReqTBEX */
6320x67,0x2A,0x00,0x49, /* [4196] OBJ_setct_CredRevResTBE */
6330x67,0x2A,0x00,0x4A, /* [4200] OBJ_setct_BatchAdminReqTBE */
6340x67,0x2A,0x00,0x4B, /* [4204] OBJ_setct_BatchAdminResTBE */
6350x67,0x2A,0x00,0x4C, /* [4208] OBJ_setct_RegFormReqTBE */
6360x67,0x2A,0x00,0x4D, /* [4212] OBJ_setct_CertReqTBE */
6370x67,0x2A,0x00,0x4E, /* [4216] OBJ_setct_CertReqTBEX */
6380x67,0x2A,0x00,0x4F, /* [4220] OBJ_setct_CertResTBE */
6390x67,0x2A,0x00,0x50, /* [4224] OBJ_setct_CRLNotificationTBS */
6400x67,0x2A,0x00,0x51, /* [4228] OBJ_setct_CRLNotificationResTBS */
6410x67,0x2A,0x00,0x52, /* [4232] OBJ_setct_BCIDistributionTBS */
6420x67,0x2A,0x01,0x01, /* [4236] OBJ_setext_genCrypt */
6430x67,0x2A,0x01,0x03, /* [4240] OBJ_setext_miAuth */
6440x67,0x2A,0x01,0x04, /* [4244] OBJ_setext_pinSecure */
6450x67,0x2A,0x01,0x05, /* [4248] OBJ_setext_pinAny */
6460x67,0x2A,0x01,0x07, /* [4252] OBJ_setext_track2 */
6470x67,0x2A,0x01,0x08, /* [4256] OBJ_setext_cv */
6480x67,0x2A,0x05,0x00, /* [4260] OBJ_set_policy_root */
6490x67,0x2A,0x07,0x00, /* [4264] OBJ_setCext_hashedRoot */
6500x67,0x2A,0x07,0x01, /* [4268] OBJ_setCext_certType */
6510x67,0x2A,0x07,0x02, /* [4272] OBJ_setCext_merchData */
6520x67,0x2A,0x07,0x03, /* [4276] OBJ_setCext_cCertRequired */
6530x67,0x2A,0x07,0x04, /* [4280] OBJ_setCext_tunneling */
6540x67,0x2A,0x07,0x05, /* [4284] OBJ_setCext_setExt */
6550x67,0x2A,0x07,0x06, /* [4288] OBJ_setCext_setQualf */
6560x67,0x2A,0x07,0x07, /* [4292] OBJ_setCext_PGWYcapabilities */
6570x67,0x2A,0x07,0x08, /* [4296] OBJ_setCext_TokenIdentifier */
6580x67,0x2A,0x07,0x09, /* [4300] OBJ_setCext_Track2Data */
6590x67,0x2A,0x07,0x0A, /* [4304] OBJ_setCext_TokenType */
6600x67,0x2A,0x07,0x0B, /* [4308] OBJ_setCext_IssuerCapabilities */
6610x67,0x2A,0x03,0x00, /* [4312] OBJ_setAttr_Cert */
6620x67,0x2A,0x03,0x01, /* [4316] OBJ_setAttr_PGWYcap */
6630x67,0x2A,0x03,0x02, /* [4320] OBJ_setAttr_TokenType */
6640x67,0x2A,0x03,0x03, /* [4324] OBJ_setAttr_IssCap */
6650x67,0x2A,0x03,0x00,0x00, /* [4328] OBJ_set_rootKeyThumb */
6660x67,0x2A,0x03,0x00,0x01, /* [4333] OBJ_set_addPolicy */
6670x67,0x2A,0x03,0x02,0x01, /* [4338] OBJ_setAttr_Token_EMV */
6680x67,0x2A,0x03,0x02,0x02, /* [4343] OBJ_setAttr_Token_B0Prime */
6690x67,0x2A,0x03,0x03,0x03, /* [4348] OBJ_setAttr_IssCap_CVM */
6700x67,0x2A,0x03,0x03,0x04, /* [4353] OBJ_setAttr_IssCap_T2 */
6710x67,0x2A,0x03,0x03,0x05, /* [4358] OBJ_setAttr_IssCap_Sig */
6720x67,0x2A,0x03,0x03,0x03,0x01, /* [4363] OBJ_setAttr_GenCryptgrm */
6730x67,0x2A,0x03,0x03,0x04,0x01, /* [4369] OBJ_setAttr_T2Enc */
6740x67,0x2A,0x03,0x03,0x04,0x02, /* [4375] OBJ_setAttr_T2cleartxt */
6750x67,0x2A,0x03,0x03,0x05,0x01, /* [4381] OBJ_setAttr_TokICCsig */
6760x67,0x2A,0x03,0x03,0x05,0x02, /* [4387] OBJ_setAttr_SecDevSig */
6770x67,0x2A,0x08,0x01, /* [4393] OBJ_set_brand_IATA_ATA */
6780x67,0x2A,0x08,0x1E, /* [4397] OBJ_set_brand_Diners */
6790x67,0x2A,0x08,0x22, /* [4401] OBJ_set_brand_AmericanExpress */
6800x67,0x2A,0x08,0x23, /* [4405] OBJ_set_brand_JCB */
6810x67,0x2A,0x08,0x04, /* [4409] OBJ_set_brand_Visa */
6820x67,0x2A,0x08,0x05, /* [4413] OBJ_set_brand_MasterCard */
6830x67,0x2A,0x08,0xAE,0x7B, /* [4417] OBJ_set_brand_Novus */
6840x2A,0x86,0x48,0x86,0xF7,0x0D,0x03,0x0A, /* [4422] OBJ_des_cdmf */
6850x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x06,/* [4430] OBJ_rsaOAEPEncryptionSET */
6860x00, /* [4439] OBJ_itu_t */
6870x50, /* [4440] OBJ_joint_iso_itu_t */
6880x67, /* [4441] OBJ_international_organizations */
6890x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x14,0x02,0x02,/* [4442] OBJ_ms_smartcard_login */
6900x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x14,0x02,0x03,/* [4452] OBJ_ms_upn */
6910x55,0x04,0x09, /* [4462] OBJ_streetAddress */
6920x55,0x04,0x11, /* [4465] OBJ_postalCode */
6930x2B,0x06,0x01,0x05,0x05,0x07,0x15, /* [4468] OBJ_id_ppl */
6940x2B,0x06,0x01,0x05,0x05,0x07,0x01,0x0E, /* [4475] OBJ_proxyCertInfo */
6950x2B,0x06,0x01,0x05,0x05,0x07,0x15,0x00, /* [4483] OBJ_id_ppl_anyLanguage */
6960x2B,0x06,0x01,0x05,0x05,0x07,0x15,0x01, /* [4491] OBJ_id_ppl_inheritAll */
6970x55,0x1D,0x1E, /* [4499] OBJ_name_constraints */
6980x2B,0x06,0x01,0x05,0x05,0x07,0x15,0x02, /* [4502] OBJ_Independent */
6990x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0B,/* [4510] OBJ_sha256WithRSAEncryption */
7000x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0C,/* [4519] OBJ_sha384WithRSAEncryption */
7010x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0D,/* [4528] OBJ_sha512WithRSAEncryption */
7020x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0E,/* [4537] OBJ_sha224WithRSAEncryption */
7030x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,/* [4546] OBJ_sha256 */
7040x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,/* [4555] OBJ_sha384 */
7050x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,/* [4564] OBJ_sha512 */
7060x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,/* [4573] OBJ_sha224 */
7070x2B, /* [4582] OBJ_identified_organization */
7080x2B,0x81,0x04, /* [4583] OBJ_certicom_arc */
7090x67,0x2B, /* [4586] OBJ_wap */
7100x67,0x2B,0x01, /* [4588] OBJ_wap_wsg */
7110x2A,0x86,0x48,0xCE,0x3D,0x01,0x02,0x03, /* [4591] OBJ_X9_62_id_characteristic_two_basis */
7120x2A,0x86,0x48,0xCE,0x3D,0x01,0x02,0x03,0x01,/* [4599] OBJ_X9_62_onBasis */
7130x2A,0x86,0x48,0xCE,0x3D,0x01,0x02,0x03,0x02,/* [4608] OBJ_X9_62_tpBasis */
7140x2A,0x86,0x48,0xCE,0x3D,0x01,0x02,0x03,0x03,/* [4617] OBJ_X9_62_ppBasis */
7150x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x01, /* [4626] OBJ_X9_62_c2pnb163v1 */
7160x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x02, /* [4634] OBJ_X9_62_c2pnb163v2 */
7170x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x03, /* [4642] OBJ_X9_62_c2pnb163v3 */
7180x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x04, /* [4650] OBJ_X9_62_c2pnb176v1 */
7190x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x05, /* [4658] OBJ_X9_62_c2tnb191v1 */
7200x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x06, /* [4666] OBJ_X9_62_c2tnb191v2 */
7210x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x07, /* [4674] OBJ_X9_62_c2tnb191v3 */
7220x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x08, /* [4682] OBJ_X9_62_c2onb191v4 */
7230x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x09, /* [4690] OBJ_X9_62_c2onb191v5 */
7240x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0A, /* [4698] OBJ_X9_62_c2pnb208w1 */
7250x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0B, /* [4706] OBJ_X9_62_c2tnb239v1 */
7260x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0C, /* [4714] OBJ_X9_62_c2tnb239v2 */
7270x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0D, /* [4722] OBJ_X9_62_c2tnb239v3 */
7280x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0E, /* [4730] OBJ_X9_62_c2onb239v4 */
7290x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x0F, /* [4738] OBJ_X9_62_c2onb239v5 */
7300x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x10, /* [4746] OBJ_X9_62_c2pnb272w1 */
7310x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x11, /* [4754] OBJ_X9_62_c2pnb304w1 */
7320x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x12, /* [4762] OBJ_X9_62_c2tnb359v1 */
7330x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x13, /* [4770] OBJ_X9_62_c2pnb368w1 */
7340x2A,0x86,0x48,0xCE,0x3D,0x03,0x00,0x14, /* [4778] OBJ_X9_62_c2tnb431r1 */
7350x2B,0x81,0x04,0x00,0x06, /* [4786] OBJ_secp112r1 */
7360x2B,0x81,0x04,0x00,0x07, /* [4791] OBJ_secp112r2 */
7370x2B,0x81,0x04,0x00,0x1C, /* [4796] OBJ_secp128r1 */
7380x2B,0x81,0x04,0x00,0x1D, /* [4801] OBJ_secp128r2 */
7390x2B,0x81,0x04,0x00,0x09, /* [4806] OBJ_secp160k1 */
7400x2B,0x81,0x04,0x00,0x08, /* [4811] OBJ_secp160r1 */
7410x2B,0x81,0x04,0x00,0x1E, /* [4816] OBJ_secp160r2 */
7420x2B,0x81,0x04,0x00,0x1F, /* [4821] OBJ_secp192k1 */
7430x2B,0x81,0x04,0x00,0x20, /* [4826] OBJ_secp224k1 */
7440x2B,0x81,0x04,0x00,0x21, /* [4831] OBJ_secp224r1 */
7450x2B,0x81,0x04,0x00,0x0A, /* [4836] OBJ_secp256k1 */
7460x2B,0x81,0x04,0x00,0x22, /* [4841] OBJ_secp384r1 */
7470x2B,0x81,0x04,0x00,0x23, /* [4846] OBJ_secp521r1 */
7480x2B,0x81,0x04,0x00,0x04, /* [4851] OBJ_sect113r1 */
7490x2B,0x81,0x04,0x00,0x05, /* [4856] OBJ_sect113r2 */
7500x2B,0x81,0x04,0x00,0x16, /* [4861] OBJ_sect131r1 */
7510x2B,0x81,0x04,0x00,0x17, /* [4866] OBJ_sect131r2 */
7520x2B,0x81,0x04,0x00,0x01, /* [4871] OBJ_sect163k1 */
7530x2B,0x81,0x04,0x00,0x02, /* [4876] OBJ_sect163r1 */
7540x2B,0x81,0x04,0x00,0x0F, /* [4881] OBJ_sect163r2 */
7550x2B,0x81,0x04,0x00,0x18, /* [4886] OBJ_sect193r1 */
7560x2B,0x81,0x04,0x00,0x19, /* [4891] OBJ_sect193r2 */
7570x2B,0x81,0x04,0x00,0x1A, /* [4896] OBJ_sect233k1 */
7580x2B,0x81,0x04,0x00,0x1B, /* [4901] OBJ_sect233r1 */
7590x2B,0x81,0x04,0x00,0x03, /* [4906] OBJ_sect239k1 */
7600x2B,0x81,0x04,0x00,0x10, /* [4911] OBJ_sect283k1 */
7610x2B,0x81,0x04,0x00,0x11, /* [4916] OBJ_sect283r1 */
7620x2B,0x81,0x04,0x00,0x24, /* [4921] OBJ_sect409k1 */
7630x2B,0x81,0x04,0x00,0x25, /* [4926] OBJ_sect409r1 */
7640x2B,0x81,0x04,0x00,0x26, /* [4931] OBJ_sect571k1 */
7650x2B,0x81,0x04,0x00,0x27, /* [4936] OBJ_sect571r1 */
7660x67,0x2B,0x01,0x04,0x01, /* [4941] OBJ_wap_wsg_idm_ecid_wtls1 */
7670x67,0x2B,0x01,0x04,0x03, /* [4946] OBJ_wap_wsg_idm_ecid_wtls3 */
7680x67,0x2B,0x01,0x04,0x04, /* [4951] OBJ_wap_wsg_idm_ecid_wtls4 */
7690x67,0x2B,0x01,0x04,0x05, /* [4956] OBJ_wap_wsg_idm_ecid_wtls5 */
7700x67,0x2B,0x01,0x04,0x06, /* [4961] OBJ_wap_wsg_idm_ecid_wtls6 */
7710x67,0x2B,0x01,0x04,0x07, /* [4966] OBJ_wap_wsg_idm_ecid_wtls7 */
7720x67,0x2B,0x01,0x04,0x08, /* [4971] OBJ_wap_wsg_idm_ecid_wtls8 */
7730x67,0x2B,0x01,0x04,0x09, /* [4976] OBJ_wap_wsg_idm_ecid_wtls9 */
7740x67,0x2B,0x01,0x04,0x0A, /* [4981] OBJ_wap_wsg_idm_ecid_wtls10 */
7750x67,0x2B,0x01,0x04,0x0B, /* [4986] OBJ_wap_wsg_idm_ecid_wtls11 */
7760x67,0x2B,0x01,0x04,0x0C, /* [4991] OBJ_wap_wsg_idm_ecid_wtls12 */
7770x55,0x1D,0x20,0x00, /* [4996] OBJ_any_policy */
7780x55,0x1D,0x21, /* [5000] OBJ_policy_mappings */
7790x55,0x1D,0x36, /* [5003] OBJ_inhibit_any_policy */
7800x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x01,0x02,/* [5006] OBJ_camellia_128_cbc */
7810x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x01,0x03,/* [5017] OBJ_camellia_192_cbc */
7820x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x01,0x04,/* [5028] OBJ_camellia_256_cbc */
7830x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x01, /* [5039] OBJ_camellia_128_ecb */
7840x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x15, /* [5047] OBJ_camellia_192_ecb */
7850x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x29, /* [5055] OBJ_camellia_256_ecb */
7860x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x04, /* [5063] OBJ_camellia_128_cfb128 */
7870x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x18, /* [5071] OBJ_camellia_192_cfb128 */
7880x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x2C, /* [5079] OBJ_camellia_256_cfb128 */
7890x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x03, /* [5087] OBJ_camellia_128_ofb128 */
7900x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x17, /* [5095] OBJ_camellia_192_ofb128 */
7910x03,0xA2,0x31,0x05,0x03,0x01,0x09,0x2B, /* [5103] OBJ_camellia_256_ofb128 */
7920x55,0x1D,0x09, /* [5111] OBJ_subject_directory_attributes */
7930x55,0x1D,0x1C, /* [5114] OBJ_issuing_distribution_point */
7940x55,0x1D,0x1D, /* [5117] OBJ_certificate_issuer */
7950x2A,0x83,0x1A,0x8C,0x9A,0x44, /* [5120] OBJ_kisa */
7960x2A,0x83,0x1A,0x8C,0x9A,0x44,0x01,0x03, /* [5126] OBJ_seed_ecb */
7970x2A,0x83,0x1A,0x8C,0x9A,0x44,0x01,0x04, /* [5134] OBJ_seed_cbc */
7980x2A,0x83,0x1A,0x8C,0x9A,0x44,0x01,0x06, /* [5142] OBJ_seed_ofb128 */
7990x2A,0x83,0x1A,0x8C,0x9A,0x44,0x01,0x05, /* [5150] OBJ_seed_cfb128 */
8000x2B,0x06,0x01,0x05,0x05,0x08,0x01,0x01, /* [5158] OBJ_hmac_md5 */
8010x2B,0x06,0x01,0x05,0x05,0x08,0x01,0x02, /* [5166] OBJ_hmac_sha1 */
8020x2A,0x86,0x48,0x86,0xF6,0x7D,0x07,0x42,0x0D,/* [5174] OBJ_id_PasswordBasedMAC */
8030x2A,0x86,0x48,0x86,0xF6,0x7D,0x07,0x42,0x1E,/* [5183] OBJ_id_DHBasedMac */
8040x2B,0x06,0x01,0x05,0x05,0x07,0x04,0x10, /* [5192] OBJ_id_it_suppLangTags */
8050x2B,0x06,0x01,0x05,0x05,0x07,0x30,0x05, /* [5200] OBJ_caRepository */
8060x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x09,/* [5208] OBJ_id_smime_ct_compressedData */
8070x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x01,0x1B,/* [5219] OBJ_id_ct_asciiTextWithCRLF */
8080x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x05,/* [5230] OBJ_id_aes128_wrap */
8090x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x19,/* [5239] OBJ_id_aes192_wrap */
8100x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2D,/* [5248] OBJ_id_aes256_wrap */
8110x2A,0x86,0x48,0xCE,0x3D,0x04,0x02, /* [5257] OBJ_ecdsa_with_Recommended */
8120x2A,0x86,0x48,0xCE,0x3D,0x04,0x03, /* [5264] OBJ_ecdsa_with_Specified */
8130x2A,0x86,0x48,0xCE,0x3D,0x04,0x03,0x01, /* [5271] OBJ_ecdsa_with_SHA224 */
8140x2A,0x86,0x48,0xCE,0x3D,0x04,0x03,0x02, /* [5279] OBJ_ecdsa_with_SHA256 */
8150x2A,0x86,0x48,0xCE,0x3D,0x04,0x03,0x03, /* [5287] OBJ_ecdsa_with_SHA384 */
8160x2A,0x86,0x48,0xCE,0x3D,0x04,0x03,0x04, /* [5295] OBJ_ecdsa_with_SHA512 */
8170x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x06, /* [5303] OBJ_hmacWithMD5 */
8180x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x08, /* [5311] OBJ_hmacWithSHA224 */
8190x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x09, /* [5319] OBJ_hmacWithSHA256 */
8200x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0A, /* [5327] OBJ_hmacWithSHA384 */
8210x2A,0x86,0x48,0x86,0xF7,0x0D,0x02,0x0B, /* [5335] OBJ_hmacWithSHA512 */
8220x60,0x86,0x48,0x01,0x65,0x03,0x04,0x03,0x01,/* [5343] OBJ_dsa_with_SHA224 */
8230x60,0x86,0x48,0x01,0x65,0x03,0x04,0x03,0x02,/* [5352] OBJ_dsa_with_SHA256 */
8240x28,0xCF,0x06,0x03,0x00,0x37, /* [5361] OBJ_whirlpool */
8250x2A,0x85,0x03,0x02,0x02, /* [5367] OBJ_cryptopro */
8260x2A,0x85,0x03,0x02,0x09, /* [5372] OBJ_cryptocom */
8270x2A,0x85,0x03,0x02,0x02,0x03, /* [5377] OBJ_id_GostR3411_94_with_GostR3410_2001 */
8280x2A,0x85,0x03,0x02,0x02,0x04, /* [5383] OBJ_id_GostR3411_94_with_GostR3410_94 */
8290x2A,0x85,0x03,0x02,0x02,0x09, /* [5389] OBJ_id_GostR3411_94 */
8300x2A,0x85,0x03,0x02,0x02,0x0A, /* [5395] OBJ_id_HMACGostR3411_94 */
8310x2A,0x85,0x03,0x02,0x02,0x13, /* [5401] OBJ_id_GostR3410_2001 */
8320x2A,0x85,0x03,0x02,0x02,0x14, /* [5407] OBJ_id_GostR3410_94 */
8330x2A,0x85,0x03,0x02,0x02,0x15, /* [5413] OBJ_id_Gost28147_89 */
8340x2A,0x85,0x03,0x02,0x02,0x16, /* [5419] OBJ_id_Gost28147_89_MAC */
8350x2A,0x85,0x03,0x02,0x02,0x17, /* [5425] OBJ_id_GostR3411_94_prf */
8360x2A,0x85,0x03,0x02,0x02,0x62, /* [5431] OBJ_id_GostR3410_2001DH */
8370x2A,0x85,0x03,0x02,0x02,0x63, /* [5437] OBJ_id_GostR3410_94DH */
8380x2A,0x85,0x03,0x02,0x02,0x0E,0x01, /* [5443] OBJ_id_Gost28147_89_CryptoPro_KeyMeshing */
8390x2A,0x85,0x03,0x02,0x02,0x0E,0x00, /* [5450] OBJ_id_Gost28147_89_None_KeyMeshing */
8400x2A,0x85,0x03,0x02,0x02,0x1E,0x00, /* [5457] OBJ_id_GostR3411_94_TestParamSet */
8410x2A,0x85,0x03,0x02,0x02,0x1E,0x01, /* [5464] OBJ_id_GostR3411_94_CryptoProParamSet */
8420x2A,0x85,0x03,0x02,0x02,0x1F,0x00, /* [5471] OBJ_id_Gost28147_89_TestParamSet */
8430x2A,0x85,0x03,0x02,0x02,0x1F,0x01, /* [5478] OBJ_id_Gost28147_89_CryptoPro_A_ParamSet */
8440x2A,0x85,0x03,0x02,0x02,0x1F,0x02, /* [5485] OBJ_id_Gost28147_89_CryptoPro_B_ParamSet */
8450x2A,0x85,0x03,0x02,0x02,0x1F,0x03, /* [5492] OBJ_id_Gost28147_89_CryptoPro_C_ParamSet */
8460x2A,0x85,0x03,0x02,0x02,0x1F,0x04, /* [5499] OBJ_id_Gost28147_89_CryptoPro_D_ParamSet */
8470x2A,0x85,0x03,0x02,0x02,0x1F,0x05, /* [5506] OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet */
8480x2A,0x85,0x03,0x02,0x02,0x1F,0x06, /* [5513] OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet */
8490x2A,0x85,0x03,0x02,0x02,0x1F,0x07, /* [5520] OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet */
8500x2A,0x85,0x03,0x02,0x02,0x20,0x00, /* [5527] OBJ_id_GostR3410_94_TestParamSet */
8510x2A,0x85,0x03,0x02,0x02,0x20,0x02, /* [5534] OBJ_id_GostR3410_94_CryptoPro_A_ParamSet */
8520x2A,0x85,0x03,0x02,0x02,0x20,0x03, /* [5541] OBJ_id_GostR3410_94_CryptoPro_B_ParamSet */
8530x2A,0x85,0x03,0x02,0x02,0x20,0x04, /* [5548] OBJ_id_GostR3410_94_CryptoPro_C_ParamSet */
8540x2A,0x85,0x03,0x02,0x02,0x20,0x05, /* [5555] OBJ_id_GostR3410_94_CryptoPro_D_ParamSet */
8550x2A,0x85,0x03,0x02,0x02,0x21,0x01, /* [5562] OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet */
8560x2A,0x85,0x03,0x02,0x02,0x21,0x02, /* [5569] OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet */
8570x2A,0x85,0x03,0x02,0x02,0x21,0x03, /* [5576] OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet */
8580x2A,0x85,0x03,0x02,0x02,0x23,0x00, /* [5583] OBJ_id_GostR3410_2001_TestParamSet */
8590x2A,0x85,0x03,0x02,0x02,0x23,0x01, /* [5590] OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet */
8600x2A,0x85,0x03,0x02,0x02,0x23,0x02, /* [5597] OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet */
8610x2A,0x85,0x03,0x02,0x02,0x23,0x03, /* [5604] OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet */
8620x2A,0x85,0x03,0x02,0x02,0x24,0x00, /* [5611] OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet */
8630x2A,0x85,0x03,0x02,0x02,0x24,0x01, /* [5618] OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet */
8640x2A,0x85,0x03,0x02,0x02,0x14,0x01, /* [5625] OBJ_id_GostR3410_94_a */
8650x2A,0x85,0x03,0x02,0x02,0x14,0x02, /* [5632] OBJ_id_GostR3410_94_aBis */
8660x2A,0x85,0x03,0x02,0x02,0x14,0x03, /* [5639] OBJ_id_GostR3410_94_b */
8670x2A,0x85,0x03,0x02,0x02,0x14,0x04, /* [5646] OBJ_id_GostR3410_94_bBis */
8680x2A,0x85,0x03,0x02,0x09,0x01,0x06,0x01, /* [5653] OBJ_id_Gost28147_89_cc */
8690x2A,0x85,0x03,0x02,0x09,0x01,0x05,0x03, /* [5661] OBJ_id_GostR3410_94_cc */
8700x2A,0x85,0x03,0x02,0x09,0x01,0x05,0x04, /* [5669] OBJ_id_GostR3410_2001_cc */
8710x2A,0x85,0x03,0x02,0x09,0x01,0x03,0x03, /* [5677] OBJ_id_GostR3411_94_with_GostR3410_94_cc */
8720x2A,0x85,0x03,0x02,0x09,0x01,0x03,0x04, /* [5685] OBJ_id_GostR3411_94_with_GostR3410_2001_cc */
8730x2A,0x85,0x03,0x02,0x09,0x01,0x08,0x01, /* [5693] OBJ_id_GostR3410_2001_ParamSet_cc */
8740x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x11,0x02,/* [5701] OBJ_LocalKeySet */
8750x55,0x1D,0x2E, /* [5710] OBJ_freshest_crl */
8760x2B,0x06,0x01,0x05,0x05,0x07,0x08,0x03, /* [5713] OBJ_id_on_permanentIdentifier */
8770x55,0x04,0x0E, /* [5721] OBJ_searchGuide */
8780x55,0x04,0x0F, /* [5724] OBJ_businessCategory */
8790x55,0x04,0x10, /* [5727] OBJ_postalAddress */
8800x55,0x04,0x12, /* [5730] OBJ_postOfficeBox */
8810x55,0x04,0x13, /* [5733] OBJ_physicalDeliveryOfficeName */
8820x55,0x04,0x14, /* [5736] OBJ_telephoneNumber */
8830x55,0x04,0x15, /* [5739] OBJ_telexNumber */
8840x55,0x04,0x16, /* [5742] OBJ_teletexTerminalIdentifier */
8850x55,0x04,0x17, /* [5745] OBJ_facsimileTelephoneNumber */
8860x55,0x04,0x18, /* [5748] OBJ_x121Address */
8870x55,0x04,0x19, /* [5751] OBJ_internationaliSDNNumber */
8880x55,0x04,0x1A, /* [5754] OBJ_registeredAddress */
8890x55,0x04,0x1B, /* [5757] OBJ_destinationIndicator */
8900x55,0x04,0x1C, /* [5760] OBJ_preferredDeliveryMethod */
8910x55,0x04,0x1D, /* [5763] OBJ_presentationAddress */
8920x55,0x04,0x1E, /* [5766] OBJ_supportedApplicationContext */
8930x55,0x04,0x1F, /* [5769] OBJ_member */
8940x55,0x04,0x20, /* [5772] OBJ_owner */
8950x55,0x04,0x21, /* [5775] OBJ_roleOccupant */
8960x55,0x04,0x22, /* [5778] OBJ_seeAlso */
8970x55,0x04,0x23, /* [5781] OBJ_userPassword */
8980x55,0x04,0x24, /* [5784] OBJ_userCertificate */
8990x55,0x04,0x25, /* [5787] OBJ_cACertificate */
9000x55,0x04,0x26, /* [5790] OBJ_authorityRevocationList */
9010x55,0x04,0x27, /* [5793] OBJ_certificateRevocationList */
9020x55,0x04,0x28, /* [5796] OBJ_crossCertificatePair */
9030x55,0x04,0x2F, /* [5799] OBJ_enhancedSearchGuide */
9040x55,0x04,0x30, /* [5802] OBJ_protocolInformation */
9050x55,0x04,0x31, /* [5805] OBJ_distinguishedName */
9060x55,0x04,0x32, /* [5808] OBJ_uniqueMember */
9070x55,0x04,0x33, /* [5811] OBJ_houseIdentifier */
9080x55,0x04,0x34, /* [5814] OBJ_supportedAlgorithms */
9090x55,0x04,0x35, /* [5817] OBJ_deltaRevocationList */
9100x55,0x04,0x36, /* [5820] OBJ_dmdName */
9110x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x09,0x10,0x03,0x09,/* [5823] OBJ_id_alg_PWRI_KEK */
9120x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x06,/* [5834] OBJ_aes_128_gcm */
9130x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x07,/* [5843] OBJ_aes_128_ccm */
9140x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x08,/* [5852] OBJ_id_aes128_wrap_pad */
9150x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x1A,/* [5861] OBJ_aes_192_gcm */
9160x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x1B,/* [5870] OBJ_aes_192_ccm */
9170x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x1C,/* [5879] OBJ_id_aes192_wrap_pad */
9180x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2E,/* [5888] OBJ_aes_256_gcm */
9190x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x2F,/* [5897] OBJ_aes_256_ccm */
9200x60,0x86,0x48,0x01,0x65,0x03,0x04,0x01,0x30,/* [5906] OBJ_id_aes256_wrap_pad */
9210x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x03,0x02,/* [5915] OBJ_id_camellia128_wrap */
9220x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x03,0x03,/* [5926] OBJ_id_camellia192_wrap */
9230x2A,0x83,0x08,0x8C,0x9A,0x4B,0x3D,0x01,0x01,0x03,0x04,/* [5937] OBJ_id_camellia256_wrap */
9240x55,0x1D,0x25,0x00, /* [5948] OBJ_anyExtendedKeyUsage */
9250x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x08,/* [5952] OBJ_mgf1 */
9260x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x0A,/* [5961] OBJ_rsassaPss */
9270x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x07,/* [5970] OBJ_rsaesOaep */
928};
929
930static const ASN1_OBJECT nid_objs[NUM_NID]={
931{"UNDEF","undefined",NID_undef,1,&(lvalues[0]),0},
932{"rsadsi","RSA Data Security, Inc.",NID_rsadsi,6,&(lvalues[1]),0},
933{"pkcs","RSA Data Security, Inc. PKCS",NID_pkcs,7,&(lvalues[7]),0},
934{"MD2","md2",NID_md2,8,&(lvalues[14]),0},
935{"MD5","md5",NID_md5,8,&(lvalues[22]),0},
936{"RC4","rc4",NID_rc4,8,&(lvalues[30]),0},
937{"rsaEncryption","rsaEncryption",NID_rsaEncryption,9,&(lvalues[38]),0},
938{"RSA-MD2","md2WithRSAEncryption",NID_md2WithRSAEncryption,9,
939 &(lvalues[47]),0},
940{"RSA-MD5","md5WithRSAEncryption",NID_md5WithRSAEncryption,9,
941 &(lvalues[56]),0},
942{"PBE-MD2-DES","pbeWithMD2AndDES-CBC",NID_pbeWithMD2AndDES_CBC,9,
943 &(lvalues[65]),0},
944{"PBE-MD5-DES","pbeWithMD5AndDES-CBC",NID_pbeWithMD5AndDES_CBC,9,
945 &(lvalues[74]),0},
946{"X500","directory services (X.500)",NID_X500,1,&(lvalues[83]),0},
947{"X509","X509",NID_X509,2,&(lvalues[84]),0},
948{"CN","commonName",NID_commonName,3,&(lvalues[86]),0},
949{"C","countryName",NID_countryName,3,&(lvalues[89]),0},
950{"L","localityName",NID_localityName,3,&(lvalues[92]),0},
951{"ST","stateOrProvinceName",NID_stateOrProvinceName,3,&(lvalues[95]),0},
952{"O","organizationName",NID_organizationName,3,&(lvalues[98]),0},
953{"OU","organizationalUnitName",NID_organizationalUnitName,3,
954 &(lvalues[101]),0},
955{"RSA","rsa",NID_rsa,4,&(lvalues[104]),0},
956{"pkcs7","pkcs7",NID_pkcs7,8,&(lvalues[108]),0},
957{"pkcs7-data","pkcs7-data",NID_pkcs7_data,9,&(lvalues[116]),0},
958{"pkcs7-signedData","pkcs7-signedData",NID_pkcs7_signed,9,
959 &(lvalues[125]),0},
960{"pkcs7-envelopedData","pkcs7-envelopedData",NID_pkcs7_enveloped,9,
961 &(lvalues[134]),0},
962{"pkcs7-signedAndEnvelopedData","pkcs7-signedAndEnvelopedData",
963 NID_pkcs7_signedAndEnveloped,9,&(lvalues[143]),0},
964{"pkcs7-digestData","pkcs7-digestData",NID_pkcs7_digest,9,
965 &(lvalues[152]),0},
966{"pkcs7-encryptedData","pkcs7-encryptedData",NID_pkcs7_encrypted,9,
967 &(lvalues[161]),0},
968{"pkcs3","pkcs3",NID_pkcs3,8,&(lvalues[170]),0},
969{"dhKeyAgreement","dhKeyAgreement",NID_dhKeyAgreement,9,
970 &(lvalues[178]),0},
971{"DES-ECB","des-ecb",NID_des_ecb,5,&(lvalues[187]),0},
972{"DES-CFB","des-cfb",NID_des_cfb64,5,&(lvalues[192]),0},
973{"DES-CBC","des-cbc",NID_des_cbc,5,&(lvalues[197]),0},
974{"DES-EDE","des-ede",NID_des_ede_ecb,5,&(lvalues[202]),0},
975{"DES-EDE3","des-ede3",NID_des_ede3_ecb,0,NULL,0},
976{"IDEA-CBC","idea-cbc",NID_idea_cbc,11,&(lvalues[207]),0},
977{"IDEA-CFB","idea-cfb",NID_idea_cfb64,0,NULL,0},
978{"IDEA-ECB","idea-ecb",NID_idea_ecb,0,NULL,0},
979{"RC2-CBC","rc2-cbc",NID_rc2_cbc,8,&(lvalues[218]),0},
980{"RC2-ECB","rc2-ecb",NID_rc2_ecb,0,NULL,0},
981{"RC2-CFB","rc2-cfb",NID_rc2_cfb64,0,NULL,0},
982{"RC2-OFB","rc2-ofb",NID_rc2_ofb64,0,NULL,0},
983{"SHA","sha",NID_sha,5,&(lvalues[226]),0},
984{"RSA-SHA","shaWithRSAEncryption",NID_shaWithRSAEncryption,5,
985 &(lvalues[231]),0},
986{"DES-EDE-CBC","des-ede-cbc",NID_des_ede_cbc,0,NULL,0},
987{"DES-EDE3-CBC","des-ede3-cbc",NID_des_ede3_cbc,8,&(lvalues[236]),0},
988{"DES-OFB","des-ofb",NID_des_ofb64,5,&(lvalues[244]),0},
989{"IDEA-OFB","idea-ofb",NID_idea_ofb64,0,NULL,0},
990{"pkcs9","pkcs9",NID_pkcs9,8,&(lvalues[249]),0},
991{"emailAddress","emailAddress",NID_pkcs9_emailAddress,9,
992 &(lvalues[257]),0},
993{"unstructuredName","unstructuredName",NID_pkcs9_unstructuredName,9,
994 &(lvalues[266]),0},
995{"contentType","contentType",NID_pkcs9_contentType,9,&(lvalues[275]),0},
996{"messageDigest","messageDigest",NID_pkcs9_messageDigest,9,
997 &(lvalues[284]),0},
998{"signingTime","signingTime",NID_pkcs9_signingTime,9,&(lvalues[293]),0},
999{"countersignature","countersignature",NID_pkcs9_countersignature,9,
1000 &(lvalues[302]),0},
1001{"challengePassword","challengePassword",NID_pkcs9_challengePassword,
1002 9,&(lvalues[311]),0},
1003{"unstructuredAddress","unstructuredAddress",
1004 NID_pkcs9_unstructuredAddress,9,&(lvalues[320]),0},
1005{"extendedCertificateAttributes","extendedCertificateAttributes",
1006 NID_pkcs9_extCertAttributes,9,&(lvalues[329]),0},
1007{"Netscape","Netscape Communications Corp.",NID_netscape,7,
1008 &(lvalues[338]),0},
1009{"nsCertExt","Netscape Certificate Extension",
1010 NID_netscape_cert_extension,8,&(lvalues[345]),0},
1011{"nsDataType","Netscape Data Type",NID_netscape_data_type,8,
1012 &(lvalues[353]),0},
1013{"DES-EDE-CFB","des-ede-cfb",NID_des_ede_cfb64,0,NULL,0},
1014{"DES-EDE3-CFB","des-ede3-cfb",NID_des_ede3_cfb64,0,NULL,0},
1015{"DES-EDE-OFB","des-ede-ofb",NID_des_ede_ofb64,0,NULL,0},
1016{"DES-EDE3-OFB","des-ede3-ofb",NID_des_ede3_ofb64,0,NULL,0},
1017{"SHA1","sha1",NID_sha1,5,&(lvalues[361]),0},
1018{"RSA-SHA1","sha1WithRSAEncryption",NID_sha1WithRSAEncryption,9,
1019 &(lvalues[366]),0},
1020{"DSA-SHA","dsaWithSHA",NID_dsaWithSHA,5,&(lvalues[375]),0},
1021{"DSA-old","dsaEncryption-old",NID_dsa_2,5,&(lvalues[380]),0},
1022{"PBE-SHA1-RC2-64","pbeWithSHA1AndRC2-CBC",NID_pbeWithSHA1AndRC2_CBC,
1023 9,&(lvalues[385]),0},
1024{"PBKDF2","PBKDF2",NID_id_pbkdf2,9,&(lvalues[394]),0},
1025{"DSA-SHA1-old","dsaWithSHA1-old",NID_dsaWithSHA1_2,5,&(lvalues[403]),0},
1026{"nsCertType","Netscape Cert Type",NID_netscape_cert_type,9,
1027 &(lvalues[408]),0},
1028{"nsBaseUrl","Netscape Base Url",NID_netscape_base_url,9,
1029 &(lvalues[417]),0},
1030{"nsRevocationUrl","Netscape Revocation Url",
1031 NID_netscape_revocation_url,9,&(lvalues[426]),0},
1032{"nsCaRevocationUrl","Netscape CA Revocation Url",
1033 NID_netscape_ca_revocation_url,9,&(lvalues[435]),0},
1034{"nsRenewalUrl","Netscape Renewal Url",NID_netscape_renewal_url,9,
1035 &(lvalues[444]),0},
1036{"nsCaPolicyUrl","Netscape CA Policy Url",NID_netscape_ca_policy_url,
1037 9,&(lvalues[453]),0},
1038{"nsSslServerName","Netscape SSL Server Name",
1039 NID_netscape_ssl_server_name,9,&(lvalues[462]),0},
1040{"nsComment","Netscape Comment",NID_netscape_comment,9,&(lvalues[471]),0},
1041{"nsCertSequence","Netscape Certificate Sequence",
1042 NID_netscape_cert_sequence,9,&(lvalues[480]),0},
1043{"DESX-CBC","desx-cbc",NID_desx_cbc,0,NULL,0},
1044{"id-ce","id-ce",NID_id_ce,2,&(lvalues[489]),0},
1045{"subjectKeyIdentifier","X509v3 Subject Key Identifier",
1046 NID_subject_key_identifier,3,&(lvalues[491]),0},
1047{"keyUsage","X509v3 Key Usage",NID_key_usage,3,&(lvalues[494]),0},
1048{"privateKeyUsagePeriod","X509v3 Private Key Usage Period",
1049 NID_private_key_usage_period,3,&(lvalues[497]),0},
1050{"subjectAltName","X509v3 Subject Alternative Name",
1051 NID_subject_alt_name,3,&(lvalues[500]),0},
1052{"issuerAltName","X509v3 Issuer Alternative Name",NID_issuer_alt_name,
1053 3,&(lvalues[503]),0},
1054{"basicConstraints","X509v3 Basic Constraints",NID_basic_constraints,
1055 3,&(lvalues[506]),0},
1056{"crlNumber","X509v3 CRL Number",NID_crl_number,3,&(lvalues[509]),0},
1057{"certificatePolicies","X509v3 Certificate Policies",
1058 NID_certificate_policies,3,&(lvalues[512]),0},
1059{"authorityKeyIdentifier","X509v3 Authority Key Identifier",
1060 NID_authority_key_identifier,3,&(lvalues[515]),0},
1061{"BF-CBC","bf-cbc",NID_bf_cbc,9,&(lvalues[518]),0},
1062{"BF-ECB","bf-ecb",NID_bf_ecb,0,NULL,0},
1063{"BF-CFB","bf-cfb",NID_bf_cfb64,0,NULL,0},
1064{"BF-OFB","bf-ofb",NID_bf_ofb64,0,NULL,0},
1065{"MDC2","mdc2",NID_mdc2,4,&(lvalues[527]),0},
1066{"RSA-MDC2","mdc2WithRSA",NID_mdc2WithRSA,4,&(lvalues[531]),0},
1067{"RC4-40","rc4-40",NID_rc4_40,0,NULL,0},
1068{"RC2-40-CBC","rc2-40-cbc",NID_rc2_40_cbc,0,NULL,0},
1069{"GN","givenName",NID_givenName,3,&(lvalues[535]),0},
1070{"SN","surname",NID_surname,3,&(lvalues[538]),0},
1071{"initials","initials",NID_initials,3,&(lvalues[541]),0},
1072{NULL,NULL,NID_undef,0,NULL,0},
1073{"crlDistributionPoints","X509v3 CRL Distribution Points",
1074 NID_crl_distribution_points,3,&(lvalues[544]),0},
1075{"RSA-NP-MD5","md5WithRSA",NID_md5WithRSA,5,&(lvalues[547]),0},
1076{"serialNumber","serialNumber",NID_serialNumber,3,&(lvalues[552]),0},
1077{"title","title",NID_title,3,&(lvalues[555]),0},
1078{"description","description",NID_description,3,&(lvalues[558]),0},
1079{"CAST5-CBC","cast5-cbc",NID_cast5_cbc,9,&(lvalues[561]),0},
1080{"CAST5-ECB","cast5-ecb",NID_cast5_ecb,0,NULL,0},
1081{"CAST5-CFB","cast5-cfb",NID_cast5_cfb64,0,NULL,0},
1082{"CAST5-OFB","cast5-ofb",NID_cast5_ofb64,0,NULL,0},
1083{"pbeWithMD5AndCast5CBC","pbeWithMD5AndCast5CBC",
1084 NID_pbeWithMD5AndCast5_CBC,9,&(lvalues[570]),0},
1085{"DSA-SHA1","dsaWithSHA1",NID_dsaWithSHA1,7,&(lvalues[579]),0},
1086{"MD5-SHA1","md5-sha1",NID_md5_sha1,0,NULL,0},
1087{"RSA-SHA1-2","sha1WithRSA",NID_sha1WithRSA,5,&(lvalues[586]),0},
1088{"DSA","dsaEncryption",NID_dsa,7,&(lvalues[591]),0},
1089{"RIPEMD160","ripemd160",NID_ripemd160,5,&(lvalues[598]),0},
1090{NULL,NULL,NID_undef,0,NULL,0},
1091{"RSA-RIPEMD160","ripemd160WithRSA",NID_ripemd160WithRSA,6,
1092 &(lvalues[603]),0},
1093{"RC5-CBC","rc5-cbc",NID_rc5_cbc,8,&(lvalues[609]),0},
1094{"RC5-ECB","rc5-ecb",NID_rc5_ecb,0,NULL,0},
1095{"RC5-CFB","rc5-cfb",NID_rc5_cfb64,0,NULL,0},
1096{"RC5-OFB","rc5-ofb",NID_rc5_ofb64,0,NULL,0},
1097{"RLE","run length compression",NID_rle_compression,6,&(lvalues[617]),0},
1098{"ZLIB","zlib compression",NID_zlib_compression,11,&(lvalues[623]),0},
1099{"extendedKeyUsage","X509v3 Extended Key Usage",NID_ext_key_usage,3,
1100 &(lvalues[634]),0},
1101{"PKIX","PKIX",NID_id_pkix,6,&(lvalues[637]),0},
1102{"id-kp","id-kp",NID_id_kp,7,&(lvalues[643]),0},
1103{"serverAuth","TLS Web Server Authentication",NID_server_auth,8,
1104 &(lvalues[650]),0},
1105{"clientAuth","TLS Web Client Authentication",NID_client_auth,8,
1106 &(lvalues[658]),0},
1107{"codeSigning","Code Signing",NID_code_sign,8,&(lvalues[666]),0},
1108{"emailProtection","E-mail Protection",NID_email_protect,8,
1109 &(lvalues[674]),0},
1110{"timeStamping","Time Stamping",NID_time_stamp,8,&(lvalues[682]),0},
1111{"msCodeInd","Microsoft Individual Code Signing",NID_ms_code_ind,10,
1112 &(lvalues[690]),0},
1113{"msCodeCom","Microsoft Commercial Code Signing",NID_ms_code_com,10,
1114 &(lvalues[700]),0},
1115{"msCTLSign","Microsoft Trust List Signing",NID_ms_ctl_sign,10,
1116 &(lvalues[710]),0},
1117{"msSGC","Microsoft Server Gated Crypto",NID_ms_sgc,10,&(lvalues[720]),0},
1118{"msEFS","Microsoft Encrypted File System",NID_ms_efs,10,
1119 &(lvalues[730]),0},
1120{"nsSGC","Netscape Server Gated Crypto",NID_ns_sgc,9,&(lvalues[740]),0},
1121{"deltaCRL","X509v3 Delta CRL Indicator",NID_delta_crl,3,
1122 &(lvalues[749]),0},
1123{"CRLReason","X509v3 CRL Reason Code",NID_crl_reason,3,&(lvalues[752]),0},
1124{"invalidityDate","Invalidity Date",NID_invalidity_date,3,
1125 &(lvalues[755]),0},
1126{"SXNetID","Strong Extranet ID",NID_sxnet,5,&(lvalues[758]),0},
1127{"PBE-SHA1-RC4-128","pbeWithSHA1And128BitRC4",
1128 NID_pbe_WithSHA1And128BitRC4,10,&(lvalues[763]),0},
1129{"PBE-SHA1-RC4-40","pbeWithSHA1And40BitRC4",
1130 NID_pbe_WithSHA1And40BitRC4,10,&(lvalues[773]),0},
1131{"PBE-SHA1-3DES","pbeWithSHA1And3-KeyTripleDES-CBC",
1132 NID_pbe_WithSHA1And3_Key_TripleDES_CBC,10,&(lvalues[783]),0},
1133{"PBE-SHA1-2DES","pbeWithSHA1And2-KeyTripleDES-CBC",
1134 NID_pbe_WithSHA1And2_Key_TripleDES_CBC,10,&(lvalues[793]),0},
1135{"PBE-SHA1-RC2-128","pbeWithSHA1And128BitRC2-CBC",
1136 NID_pbe_WithSHA1And128BitRC2_CBC,10,&(lvalues[803]),0},
1137{"PBE-SHA1-RC2-40","pbeWithSHA1And40BitRC2-CBC",
1138 NID_pbe_WithSHA1And40BitRC2_CBC,10,&(lvalues[813]),0},
1139{"keyBag","keyBag",NID_keyBag,11,&(lvalues[823]),0},
1140{"pkcs8ShroudedKeyBag","pkcs8ShroudedKeyBag",NID_pkcs8ShroudedKeyBag,
1141 11,&(lvalues[834]),0},
1142{"certBag","certBag",NID_certBag,11,&(lvalues[845]),0},
1143{"crlBag","crlBag",NID_crlBag,11,&(lvalues[856]),0},
1144{"secretBag","secretBag",NID_secretBag,11,&(lvalues[867]),0},
1145{"safeContentsBag","safeContentsBag",NID_safeContentsBag,11,
1146 &(lvalues[878]),0},
1147{"friendlyName","friendlyName",NID_friendlyName,9,&(lvalues[889]),0},
1148{"localKeyID","localKeyID",NID_localKeyID,9,&(lvalues[898]),0},
1149{"x509Certificate","x509Certificate",NID_x509Certificate,10,
1150 &(lvalues[907]),0},
1151{"sdsiCertificate","sdsiCertificate",NID_sdsiCertificate,10,
1152 &(lvalues[917]),0},
1153{"x509Crl","x509Crl",NID_x509Crl,10,&(lvalues[927]),0},
1154{"PBES2","PBES2",NID_pbes2,9,&(lvalues[937]),0},
1155{"PBMAC1","PBMAC1",NID_pbmac1,9,&(lvalues[946]),0},
1156{"hmacWithSHA1","hmacWithSHA1",NID_hmacWithSHA1,8,&(lvalues[955]),0},
1157{"id-qt-cps","Policy Qualifier CPS",NID_id_qt_cps,8,&(lvalues[963]),0},
1158{"id-qt-unotice","Policy Qualifier User Notice",NID_id_qt_unotice,8,
1159 &(lvalues[971]),0},
1160{"RC2-64-CBC","rc2-64-cbc",NID_rc2_64_cbc,0,NULL,0},
1161{"SMIME-CAPS","S/MIME Capabilities",NID_SMIMECapabilities,9,
1162 &(lvalues[979]),0},
1163{"PBE-MD2-RC2-64","pbeWithMD2AndRC2-CBC",NID_pbeWithMD2AndRC2_CBC,9,
1164 &(lvalues[988]),0},
1165{"PBE-MD5-RC2-64","pbeWithMD5AndRC2-CBC",NID_pbeWithMD5AndRC2_CBC,9,
1166 &(lvalues[997]),0},
1167{"PBE-SHA1-DES","pbeWithSHA1AndDES-CBC",NID_pbeWithSHA1AndDES_CBC,9,
1168 &(lvalues[1006]),0},
1169{"msExtReq","Microsoft Extension Request",NID_ms_ext_req,10,
1170 &(lvalues[1015]),0},
1171{"extReq","Extension Request",NID_ext_req,9,&(lvalues[1025]),0},
1172{"name","name",NID_name,3,&(lvalues[1034]),0},
1173{"dnQualifier","dnQualifier",NID_dnQualifier,3,&(lvalues[1037]),0},
1174{"id-pe","id-pe",NID_id_pe,7,&(lvalues[1040]),0},
1175{"id-ad","id-ad",NID_id_ad,7,&(lvalues[1047]),0},
1176{"authorityInfoAccess","Authority Information Access",NID_info_access,
1177 8,&(lvalues[1054]),0},
1178{"OCSP","OCSP",NID_ad_OCSP,8,&(lvalues[1062]),0},
1179{"caIssuers","CA Issuers",NID_ad_ca_issuers,8,&(lvalues[1070]),0},
1180{"OCSPSigning","OCSP Signing",NID_OCSP_sign,8,&(lvalues[1078]),0},
1181{"ISO","iso",NID_iso,1,&(lvalues[1086]),0},
1182{"member-body","ISO Member Body",NID_member_body,1,&(lvalues[1087]),0},
1183{"ISO-US","ISO US Member Body",NID_ISO_US,3,&(lvalues[1088]),0},
1184{"X9-57","X9.57",NID_X9_57,5,&(lvalues[1091]),0},
1185{"X9cm","X9.57 CM ?",NID_X9cm,6,&(lvalues[1096]),0},
1186{"pkcs1","pkcs1",NID_pkcs1,8,&(lvalues[1102]),0},
1187{"pkcs5","pkcs5",NID_pkcs5,8,&(lvalues[1110]),0},
1188{"SMIME","S/MIME",NID_SMIME,9,&(lvalues[1118]),0},
1189{"id-smime-mod","id-smime-mod",NID_id_smime_mod,10,&(lvalues[1127]),0},
1190{"id-smime-ct","id-smime-ct",NID_id_smime_ct,10,&(lvalues[1137]),0},
1191{"id-smime-aa","id-smime-aa",NID_id_smime_aa,10,&(lvalues[1147]),0},
1192{"id-smime-alg","id-smime-alg",NID_id_smime_alg,10,&(lvalues[1157]),0},
1193{"id-smime-cd","id-smime-cd",NID_id_smime_cd,10,&(lvalues[1167]),0},
1194{"id-smime-spq","id-smime-spq",NID_id_smime_spq,10,&(lvalues[1177]),0},
1195{"id-smime-cti","id-smime-cti",NID_id_smime_cti,10,&(lvalues[1187]),0},
1196{"id-smime-mod-cms","id-smime-mod-cms",NID_id_smime_mod_cms,11,
1197 &(lvalues[1197]),0},
1198{"id-smime-mod-ess","id-smime-mod-ess",NID_id_smime_mod_ess,11,
1199 &(lvalues[1208]),0},
1200{"id-smime-mod-oid","id-smime-mod-oid",NID_id_smime_mod_oid,11,
1201 &(lvalues[1219]),0},
1202{"id-smime-mod-msg-v3","id-smime-mod-msg-v3",NID_id_smime_mod_msg_v3,
1203 11,&(lvalues[1230]),0},
1204{"id-smime-mod-ets-eSignature-88","id-smime-mod-ets-eSignature-88",
1205 NID_id_smime_mod_ets_eSignature_88,11,&(lvalues[1241]),0},
1206{"id-smime-mod-ets-eSignature-97","id-smime-mod-ets-eSignature-97",
1207 NID_id_smime_mod_ets_eSignature_97,11,&(lvalues[1252]),0},
1208{"id-smime-mod-ets-eSigPolicy-88","id-smime-mod-ets-eSigPolicy-88",
1209 NID_id_smime_mod_ets_eSigPolicy_88,11,&(lvalues[1263]),0},
1210{"id-smime-mod-ets-eSigPolicy-97","id-smime-mod-ets-eSigPolicy-97",
1211 NID_id_smime_mod_ets_eSigPolicy_97,11,&(lvalues[1274]),0},
1212{"id-smime-ct-receipt","id-smime-ct-receipt",NID_id_smime_ct_receipt,
1213 11,&(lvalues[1285]),0},
1214{"id-smime-ct-authData","id-smime-ct-authData",
1215 NID_id_smime_ct_authData,11,&(lvalues[1296]),0},
1216{"id-smime-ct-publishCert","id-smime-ct-publishCert",
1217 NID_id_smime_ct_publishCert,11,&(lvalues[1307]),0},
1218{"id-smime-ct-TSTInfo","id-smime-ct-TSTInfo",NID_id_smime_ct_TSTInfo,
1219 11,&(lvalues[1318]),0},
1220{"id-smime-ct-TDTInfo","id-smime-ct-TDTInfo",NID_id_smime_ct_TDTInfo,
1221 11,&(lvalues[1329]),0},
1222{"id-smime-ct-contentInfo","id-smime-ct-contentInfo",
1223 NID_id_smime_ct_contentInfo,11,&(lvalues[1340]),0},
1224{"id-smime-ct-DVCSRequestData","id-smime-ct-DVCSRequestData",
1225 NID_id_smime_ct_DVCSRequestData,11,&(lvalues[1351]),0},
1226{"id-smime-ct-DVCSResponseData","id-smime-ct-DVCSResponseData",
1227 NID_id_smime_ct_DVCSResponseData,11,&(lvalues[1362]),0},
1228{"id-smime-aa-receiptRequest","id-smime-aa-receiptRequest",
1229 NID_id_smime_aa_receiptRequest,11,&(lvalues[1373]),0},
1230{"id-smime-aa-securityLabel","id-smime-aa-securityLabel",
1231 NID_id_smime_aa_securityLabel,11,&(lvalues[1384]),0},
1232{"id-smime-aa-mlExpandHistory","id-smime-aa-mlExpandHistory",
1233 NID_id_smime_aa_mlExpandHistory,11,&(lvalues[1395]),0},
1234{"id-smime-aa-contentHint","id-smime-aa-contentHint",
1235 NID_id_smime_aa_contentHint,11,&(lvalues[1406]),0},
1236{"id-smime-aa-msgSigDigest","id-smime-aa-msgSigDigest",
1237 NID_id_smime_aa_msgSigDigest,11,&(lvalues[1417]),0},
1238{"id-smime-aa-encapContentType","id-smime-aa-encapContentType",
1239 NID_id_smime_aa_encapContentType,11,&(lvalues[1428]),0},
1240{"id-smime-aa-contentIdentifier","id-smime-aa-contentIdentifier",
1241 NID_id_smime_aa_contentIdentifier,11,&(lvalues[1439]),0},
1242{"id-smime-aa-macValue","id-smime-aa-macValue",
1243 NID_id_smime_aa_macValue,11,&(lvalues[1450]),0},
1244{"id-smime-aa-equivalentLabels","id-smime-aa-equivalentLabels",
1245 NID_id_smime_aa_equivalentLabels,11,&(lvalues[1461]),0},
1246{"id-smime-aa-contentReference","id-smime-aa-contentReference",
1247 NID_id_smime_aa_contentReference,11,&(lvalues[1472]),0},
1248{"id-smime-aa-encrypKeyPref","id-smime-aa-encrypKeyPref",
1249 NID_id_smime_aa_encrypKeyPref,11,&(lvalues[1483]),0},
1250{"id-smime-aa-signingCertificate","id-smime-aa-signingCertificate",
1251 NID_id_smime_aa_signingCertificate,11,&(lvalues[1494]),0},
1252{"id-smime-aa-smimeEncryptCerts","id-smime-aa-smimeEncryptCerts",
1253 NID_id_smime_aa_smimeEncryptCerts,11,&(lvalues[1505]),0},
1254{"id-smime-aa-timeStampToken","id-smime-aa-timeStampToken",
1255 NID_id_smime_aa_timeStampToken,11,&(lvalues[1516]),0},
1256{"id-smime-aa-ets-sigPolicyId","id-smime-aa-ets-sigPolicyId",
1257 NID_id_smime_aa_ets_sigPolicyId,11,&(lvalues[1527]),0},
1258{"id-smime-aa-ets-commitmentType","id-smime-aa-ets-commitmentType",
1259 NID_id_smime_aa_ets_commitmentType,11,&(lvalues[1538]),0},
1260{"id-smime-aa-ets-signerLocation","id-smime-aa-ets-signerLocation",
1261 NID_id_smime_aa_ets_signerLocation,11,&(lvalues[1549]),0},
1262{"id-smime-aa-ets-signerAttr","id-smime-aa-ets-signerAttr",
1263 NID_id_smime_aa_ets_signerAttr,11,&(lvalues[1560]),0},
1264{"id-smime-aa-ets-otherSigCert","id-smime-aa-ets-otherSigCert",
1265 NID_id_smime_aa_ets_otherSigCert,11,&(lvalues[1571]),0},
1266{"id-smime-aa-ets-contentTimestamp",
1267 "id-smime-aa-ets-contentTimestamp",
1268 NID_id_smime_aa_ets_contentTimestamp,11,&(lvalues[1582]),0},
1269{"id-smime-aa-ets-CertificateRefs","id-smime-aa-ets-CertificateRefs",
1270 NID_id_smime_aa_ets_CertificateRefs,11,&(lvalues[1593]),0},
1271{"id-smime-aa-ets-RevocationRefs","id-smime-aa-ets-RevocationRefs",
1272 NID_id_smime_aa_ets_RevocationRefs,11,&(lvalues[1604]),0},
1273{"id-smime-aa-ets-certValues","id-smime-aa-ets-certValues",
1274 NID_id_smime_aa_ets_certValues,11,&(lvalues[1615]),0},
1275{"id-smime-aa-ets-revocationValues",
1276 "id-smime-aa-ets-revocationValues",
1277 NID_id_smime_aa_ets_revocationValues,11,&(lvalues[1626]),0},
1278{"id-smime-aa-ets-escTimeStamp","id-smime-aa-ets-escTimeStamp",
1279 NID_id_smime_aa_ets_escTimeStamp,11,&(lvalues[1637]),0},
1280{"id-smime-aa-ets-certCRLTimestamp",
1281 "id-smime-aa-ets-certCRLTimestamp",
1282 NID_id_smime_aa_ets_certCRLTimestamp,11,&(lvalues[1648]),0},
1283{"id-smime-aa-ets-archiveTimeStamp",
1284 "id-smime-aa-ets-archiveTimeStamp",
1285 NID_id_smime_aa_ets_archiveTimeStamp,11,&(lvalues[1659]),0},
1286{"id-smime-aa-signatureType","id-smime-aa-signatureType",
1287 NID_id_smime_aa_signatureType,11,&(lvalues[1670]),0},
1288{"id-smime-aa-dvcs-dvc","id-smime-aa-dvcs-dvc",
1289 NID_id_smime_aa_dvcs_dvc,11,&(lvalues[1681]),0},
1290{"id-smime-alg-ESDHwith3DES","id-smime-alg-ESDHwith3DES",
1291 NID_id_smime_alg_ESDHwith3DES,11,&(lvalues[1692]),0},
1292{"id-smime-alg-ESDHwithRC2","id-smime-alg-ESDHwithRC2",
1293 NID_id_smime_alg_ESDHwithRC2,11,&(lvalues[1703]),0},
1294{"id-smime-alg-3DESwrap","id-smime-alg-3DESwrap",
1295 NID_id_smime_alg_3DESwrap,11,&(lvalues[1714]),0},
1296{"id-smime-alg-RC2wrap","id-smime-alg-RC2wrap",
1297 NID_id_smime_alg_RC2wrap,11,&(lvalues[1725]),0},
1298{"id-smime-alg-ESDH","id-smime-alg-ESDH",NID_id_smime_alg_ESDH,11,
1299 &(lvalues[1736]),0},
1300{"id-smime-alg-CMS3DESwrap","id-smime-alg-CMS3DESwrap",
1301 NID_id_smime_alg_CMS3DESwrap,11,&(lvalues[1747]),0},
1302{"id-smime-alg-CMSRC2wrap","id-smime-alg-CMSRC2wrap",
1303 NID_id_smime_alg_CMSRC2wrap,11,&(lvalues[1758]),0},
1304{"id-smime-cd-ldap","id-smime-cd-ldap",NID_id_smime_cd_ldap,11,
1305 &(lvalues[1769]),0},
1306{"id-smime-spq-ets-sqt-uri","id-smime-spq-ets-sqt-uri",
1307 NID_id_smime_spq_ets_sqt_uri,11,&(lvalues[1780]),0},
1308{"id-smime-spq-ets-sqt-unotice","id-smime-spq-ets-sqt-unotice",
1309 NID_id_smime_spq_ets_sqt_unotice,11,&(lvalues[1791]),0},
1310{"id-smime-cti-ets-proofOfOrigin","id-smime-cti-ets-proofOfOrigin",
1311 NID_id_smime_cti_ets_proofOfOrigin,11,&(lvalues[1802]),0},
1312{"id-smime-cti-ets-proofOfReceipt","id-smime-cti-ets-proofOfReceipt",
1313 NID_id_smime_cti_ets_proofOfReceipt,11,&(lvalues[1813]),0},
1314{"id-smime-cti-ets-proofOfDelivery",
1315 "id-smime-cti-ets-proofOfDelivery",
1316 NID_id_smime_cti_ets_proofOfDelivery,11,&(lvalues[1824]),0},
1317{"id-smime-cti-ets-proofOfSender","id-smime-cti-ets-proofOfSender",
1318 NID_id_smime_cti_ets_proofOfSender,11,&(lvalues[1835]),0},
1319{"id-smime-cti-ets-proofOfApproval",
1320 "id-smime-cti-ets-proofOfApproval",
1321 NID_id_smime_cti_ets_proofOfApproval,11,&(lvalues[1846]),0},
1322{"id-smime-cti-ets-proofOfCreation",
1323 "id-smime-cti-ets-proofOfCreation",
1324 NID_id_smime_cti_ets_proofOfCreation,11,&(lvalues[1857]),0},
1325{"MD4","md4",NID_md4,8,&(lvalues[1868]),0},
1326{"id-pkix-mod","id-pkix-mod",NID_id_pkix_mod,7,&(lvalues[1876]),0},
1327{"id-qt","id-qt",NID_id_qt,7,&(lvalues[1883]),0},
1328{"id-it","id-it",NID_id_it,7,&(lvalues[1890]),0},
1329{"id-pkip","id-pkip",NID_id_pkip,7,&(lvalues[1897]),0},
1330{"id-alg","id-alg",NID_id_alg,7,&(lvalues[1904]),0},
1331{"id-cmc","id-cmc",NID_id_cmc,7,&(lvalues[1911]),0},
1332{"id-on","id-on",NID_id_on,7,&(lvalues[1918]),0},
1333{"id-pda","id-pda",NID_id_pda,7,&(lvalues[1925]),0},
1334{"id-aca","id-aca",NID_id_aca,7,&(lvalues[1932]),0},
1335{"id-qcs","id-qcs",NID_id_qcs,7,&(lvalues[1939]),0},
1336{"id-cct","id-cct",NID_id_cct,7,&(lvalues[1946]),0},
1337{"id-pkix1-explicit-88","id-pkix1-explicit-88",
1338 NID_id_pkix1_explicit_88,8,&(lvalues[1953]),0},
1339{"id-pkix1-implicit-88","id-pkix1-implicit-88",
1340 NID_id_pkix1_implicit_88,8,&(lvalues[1961]),0},
1341{"id-pkix1-explicit-93","id-pkix1-explicit-93",
1342 NID_id_pkix1_explicit_93,8,&(lvalues[1969]),0},
1343{"id-pkix1-implicit-93","id-pkix1-implicit-93",
1344 NID_id_pkix1_implicit_93,8,&(lvalues[1977]),0},
1345{"id-mod-crmf","id-mod-crmf",NID_id_mod_crmf,8,&(lvalues[1985]),0},
1346{"id-mod-cmc","id-mod-cmc",NID_id_mod_cmc,8,&(lvalues[1993]),0},
1347{"id-mod-kea-profile-88","id-mod-kea-profile-88",
1348 NID_id_mod_kea_profile_88,8,&(lvalues[2001]),0},
1349{"id-mod-kea-profile-93","id-mod-kea-profile-93",
1350 NID_id_mod_kea_profile_93,8,&(lvalues[2009]),0},
1351{"id-mod-cmp","id-mod-cmp",NID_id_mod_cmp,8,&(lvalues[2017]),0},
1352{"id-mod-qualified-cert-88","id-mod-qualified-cert-88",
1353 NID_id_mod_qualified_cert_88,8,&(lvalues[2025]),0},
1354{"id-mod-qualified-cert-93","id-mod-qualified-cert-93",
1355 NID_id_mod_qualified_cert_93,8,&(lvalues[2033]),0},
1356{"id-mod-attribute-cert","id-mod-attribute-cert",
1357 NID_id_mod_attribute_cert,8,&(lvalues[2041]),0},
1358{"id-mod-timestamp-protocol","id-mod-timestamp-protocol",
1359 NID_id_mod_timestamp_protocol,8,&(lvalues[2049]),0},
1360{"id-mod-ocsp","id-mod-ocsp",NID_id_mod_ocsp,8,&(lvalues[2057]),0},
1361{"id-mod-dvcs","id-mod-dvcs",NID_id_mod_dvcs,8,&(lvalues[2065]),0},
1362{"id-mod-cmp2000","id-mod-cmp2000",NID_id_mod_cmp2000,8,
1363 &(lvalues[2073]),0},
1364{"biometricInfo","Biometric Info",NID_biometricInfo,8,&(lvalues[2081]),0},
1365{"qcStatements","qcStatements",NID_qcStatements,8,&(lvalues[2089]),0},
1366{"ac-auditEntity","ac-auditEntity",NID_ac_auditEntity,8,
1367 &(lvalues[2097]),0},
1368{"ac-targeting","ac-targeting",NID_ac_targeting,8,&(lvalues[2105]),0},
1369{"aaControls","aaControls",NID_aaControls,8,&(lvalues[2113]),0},
1370{"sbgp-ipAddrBlock","sbgp-ipAddrBlock",NID_sbgp_ipAddrBlock,8,
1371 &(lvalues[2121]),0},
1372{"sbgp-autonomousSysNum","sbgp-autonomousSysNum",
1373 NID_sbgp_autonomousSysNum,8,&(lvalues[2129]),0},
1374{"sbgp-routerIdentifier","sbgp-routerIdentifier",
1375 NID_sbgp_routerIdentifier,8,&(lvalues[2137]),0},
1376{"textNotice","textNotice",NID_textNotice,8,&(lvalues[2145]),0},
1377{"ipsecEndSystem","IPSec End System",NID_ipsecEndSystem,8,
1378 &(lvalues[2153]),0},
1379{"ipsecTunnel","IPSec Tunnel",NID_ipsecTunnel,8,&(lvalues[2161]),0},
1380{"ipsecUser","IPSec User",NID_ipsecUser,8,&(lvalues[2169]),0},
1381{"DVCS","dvcs",NID_dvcs,8,&(lvalues[2177]),0},
1382{"id-it-caProtEncCert","id-it-caProtEncCert",NID_id_it_caProtEncCert,
1383 8,&(lvalues[2185]),0},
1384{"id-it-signKeyPairTypes","id-it-signKeyPairTypes",
1385 NID_id_it_signKeyPairTypes,8,&(lvalues[2193]),0},
1386{"id-it-encKeyPairTypes","id-it-encKeyPairTypes",
1387 NID_id_it_encKeyPairTypes,8,&(lvalues[2201]),0},
1388{"id-it-preferredSymmAlg","id-it-preferredSymmAlg",
1389 NID_id_it_preferredSymmAlg,8,&(lvalues[2209]),0},
1390{"id-it-caKeyUpdateInfo","id-it-caKeyUpdateInfo",
1391 NID_id_it_caKeyUpdateInfo,8,&(lvalues[2217]),0},
1392{"id-it-currentCRL","id-it-currentCRL",NID_id_it_currentCRL,8,
1393 &(lvalues[2225]),0},
1394{"id-it-unsupportedOIDs","id-it-unsupportedOIDs",
1395 NID_id_it_unsupportedOIDs,8,&(lvalues[2233]),0},
1396{"id-it-subscriptionRequest","id-it-subscriptionRequest",
1397 NID_id_it_subscriptionRequest,8,&(lvalues[2241]),0},
1398{"id-it-subscriptionResponse","id-it-subscriptionResponse",
1399 NID_id_it_subscriptionResponse,8,&(lvalues[2249]),0},
1400{"id-it-keyPairParamReq","id-it-keyPairParamReq",
1401 NID_id_it_keyPairParamReq,8,&(lvalues[2257]),0},
1402{"id-it-keyPairParamRep","id-it-keyPairParamRep",
1403 NID_id_it_keyPairParamRep,8,&(lvalues[2265]),0},
1404{"id-it-revPassphrase","id-it-revPassphrase",NID_id_it_revPassphrase,
1405 8,&(lvalues[2273]),0},
1406{"id-it-implicitConfirm","id-it-implicitConfirm",
1407 NID_id_it_implicitConfirm,8,&(lvalues[2281]),0},
1408{"id-it-confirmWaitTime","id-it-confirmWaitTime",
1409 NID_id_it_confirmWaitTime,8,&(lvalues[2289]),0},
1410{"id-it-origPKIMessage","id-it-origPKIMessage",
1411 NID_id_it_origPKIMessage,8,&(lvalues[2297]),0},
1412{"id-regCtrl","id-regCtrl",NID_id_regCtrl,8,&(lvalues[2305]),0},
1413{"id-regInfo","id-regInfo",NID_id_regInfo,8,&(lvalues[2313]),0},
1414{"id-regCtrl-regToken","id-regCtrl-regToken",NID_id_regCtrl_regToken,
1415 9,&(lvalues[2321]),0},
1416{"id-regCtrl-authenticator","id-regCtrl-authenticator",
1417 NID_id_regCtrl_authenticator,9,&(lvalues[2330]),0},
1418{"id-regCtrl-pkiPublicationInfo","id-regCtrl-pkiPublicationInfo",
1419 NID_id_regCtrl_pkiPublicationInfo,9,&(lvalues[2339]),0},
1420{"id-regCtrl-pkiArchiveOptions","id-regCtrl-pkiArchiveOptions",
1421 NID_id_regCtrl_pkiArchiveOptions,9,&(lvalues[2348]),0},
1422{"id-regCtrl-oldCertID","id-regCtrl-oldCertID",
1423 NID_id_regCtrl_oldCertID,9,&(lvalues[2357]),0},
1424{"id-regCtrl-protocolEncrKey","id-regCtrl-protocolEncrKey",
1425 NID_id_regCtrl_protocolEncrKey,9,&(lvalues[2366]),0},
1426{"id-regInfo-utf8Pairs","id-regInfo-utf8Pairs",
1427 NID_id_regInfo_utf8Pairs,9,&(lvalues[2375]),0},
1428{"id-regInfo-certReq","id-regInfo-certReq",NID_id_regInfo_certReq,9,
1429 &(lvalues[2384]),0},
1430{"id-alg-des40","id-alg-des40",NID_id_alg_des40,8,&(lvalues[2393]),0},
1431{"id-alg-noSignature","id-alg-noSignature",NID_id_alg_noSignature,8,
1432 &(lvalues[2401]),0},
1433{"id-alg-dh-sig-hmac-sha1","id-alg-dh-sig-hmac-sha1",
1434 NID_id_alg_dh_sig_hmac_sha1,8,&(lvalues[2409]),0},
1435{"id-alg-dh-pop","id-alg-dh-pop",NID_id_alg_dh_pop,8,&(lvalues[2417]),0},
1436{"id-cmc-statusInfo","id-cmc-statusInfo",NID_id_cmc_statusInfo,8,
1437 &(lvalues[2425]),0},
1438{"id-cmc-identification","id-cmc-identification",
1439 NID_id_cmc_identification,8,&(lvalues[2433]),0},
1440{"id-cmc-identityProof","id-cmc-identityProof",
1441 NID_id_cmc_identityProof,8,&(lvalues[2441]),0},
1442{"id-cmc-dataReturn","id-cmc-dataReturn",NID_id_cmc_dataReturn,8,
1443 &(lvalues[2449]),0},
1444{"id-cmc-transactionId","id-cmc-transactionId",
1445 NID_id_cmc_transactionId,8,&(lvalues[2457]),0},
1446{"id-cmc-senderNonce","id-cmc-senderNonce",NID_id_cmc_senderNonce,8,
1447 &(lvalues[2465]),0},
1448{"id-cmc-recipientNonce","id-cmc-recipientNonce",
1449 NID_id_cmc_recipientNonce,8,&(lvalues[2473]),0},
1450{"id-cmc-addExtensions","id-cmc-addExtensions",
1451 NID_id_cmc_addExtensions,8,&(lvalues[2481]),0},
1452{"id-cmc-encryptedPOP","id-cmc-encryptedPOP",NID_id_cmc_encryptedPOP,
1453 8,&(lvalues[2489]),0},
1454{"id-cmc-decryptedPOP","id-cmc-decryptedPOP",NID_id_cmc_decryptedPOP,
1455 8,&(lvalues[2497]),0},
1456{"id-cmc-lraPOPWitness","id-cmc-lraPOPWitness",
1457 NID_id_cmc_lraPOPWitness,8,&(lvalues[2505]),0},
1458{"id-cmc-getCert","id-cmc-getCert",NID_id_cmc_getCert,8,
1459 &(lvalues[2513]),0},
1460{"id-cmc-getCRL","id-cmc-getCRL",NID_id_cmc_getCRL,8,&(lvalues[2521]),0},
1461{"id-cmc-revokeRequest","id-cmc-revokeRequest",
1462 NID_id_cmc_revokeRequest,8,&(lvalues[2529]),0},
1463{"id-cmc-regInfo","id-cmc-regInfo",NID_id_cmc_regInfo,8,
1464 &(lvalues[2537]),0},
1465{"id-cmc-responseInfo","id-cmc-responseInfo",NID_id_cmc_responseInfo,
1466 8,&(lvalues[2545]),0},
1467{"id-cmc-queryPending","id-cmc-queryPending",NID_id_cmc_queryPending,
1468 8,&(lvalues[2553]),0},
1469{"id-cmc-popLinkRandom","id-cmc-popLinkRandom",
1470 NID_id_cmc_popLinkRandom,8,&(lvalues[2561]),0},
1471{"id-cmc-popLinkWitness","id-cmc-popLinkWitness",
1472 NID_id_cmc_popLinkWitness,8,&(lvalues[2569]),0},
1473{"id-cmc-confirmCertAcceptance","id-cmc-confirmCertAcceptance",
1474 NID_id_cmc_confirmCertAcceptance,8,&(lvalues[2577]),0},
1475{"id-on-personalData","id-on-personalData",NID_id_on_personalData,8,
1476 &(lvalues[2585]),0},
1477{"id-pda-dateOfBirth","id-pda-dateOfBirth",NID_id_pda_dateOfBirth,8,
1478 &(lvalues[2593]),0},
1479{"id-pda-placeOfBirth","id-pda-placeOfBirth",NID_id_pda_placeOfBirth,
1480 8,&(lvalues[2601]),0},
1481{NULL,NULL,NID_undef,0,NULL,0},
1482{"id-pda-gender","id-pda-gender",NID_id_pda_gender,8,&(lvalues[2609]),0},
1483{"id-pda-countryOfCitizenship","id-pda-countryOfCitizenship",
1484 NID_id_pda_countryOfCitizenship,8,&(lvalues[2617]),0},
1485{"id-pda-countryOfResidence","id-pda-countryOfResidence",
1486 NID_id_pda_countryOfResidence,8,&(lvalues[2625]),0},
1487{"id-aca-authenticationInfo","id-aca-authenticationInfo",
1488 NID_id_aca_authenticationInfo,8,&(lvalues[2633]),0},
1489{"id-aca-accessIdentity","id-aca-accessIdentity",
1490 NID_id_aca_accessIdentity,8,&(lvalues[2641]),0},
1491{"id-aca-chargingIdentity","id-aca-chargingIdentity",
1492 NID_id_aca_chargingIdentity,8,&(lvalues[2649]),0},
1493{"id-aca-group","id-aca-group",NID_id_aca_group,8,&(lvalues[2657]),0},
1494{"id-aca-role","id-aca-role",NID_id_aca_role,8,&(lvalues[2665]),0},
1495{"id-qcs-pkixQCSyntax-v1","id-qcs-pkixQCSyntax-v1",
1496 NID_id_qcs_pkixQCSyntax_v1,8,&(lvalues[2673]),0},
1497{"id-cct-crs","id-cct-crs",NID_id_cct_crs,8,&(lvalues[2681]),0},
1498{"id-cct-PKIData","id-cct-PKIData",NID_id_cct_PKIData,8,
1499 &(lvalues[2689]),0},
1500{"id-cct-PKIResponse","id-cct-PKIResponse",NID_id_cct_PKIResponse,8,
1501 &(lvalues[2697]),0},
1502{"ad_timestamping","AD Time Stamping",NID_ad_timeStamping,8,
1503 &(lvalues[2705]),0},
1504{"AD_DVCS","ad dvcs",NID_ad_dvcs,8,&(lvalues[2713]),0},
1505{"basicOCSPResponse","Basic OCSP Response",NID_id_pkix_OCSP_basic,9,
1506 &(lvalues[2721]),0},
1507{"Nonce","OCSP Nonce",NID_id_pkix_OCSP_Nonce,9,&(lvalues[2730]),0},
1508{"CrlID","OCSP CRL ID",NID_id_pkix_OCSP_CrlID,9,&(lvalues[2739]),0},
1509{"acceptableResponses","Acceptable OCSP Responses",
1510 NID_id_pkix_OCSP_acceptableResponses,9,&(lvalues[2748]),0},
1511{"noCheck","OCSP No Check",NID_id_pkix_OCSP_noCheck,9,&(lvalues[2757]),0},
1512{"archiveCutoff","OCSP Archive Cutoff",NID_id_pkix_OCSP_archiveCutoff,
1513 9,&(lvalues[2766]),0},
1514{"serviceLocator","OCSP Service Locator",
1515 NID_id_pkix_OCSP_serviceLocator,9,&(lvalues[2775]),0},
1516{"extendedStatus","Extended OCSP Status",
1517 NID_id_pkix_OCSP_extendedStatus,9,&(lvalues[2784]),0},
1518{"valid","valid",NID_id_pkix_OCSP_valid,9,&(lvalues[2793]),0},
1519{"path","path",NID_id_pkix_OCSP_path,9,&(lvalues[2802]),0},
1520{"trustRoot","Trust Root",NID_id_pkix_OCSP_trustRoot,9,
1521 &(lvalues[2811]),0},
1522{"algorithm","algorithm",NID_algorithm,4,&(lvalues[2820]),0},
1523{"rsaSignature","rsaSignature",NID_rsaSignature,5,&(lvalues[2824]),0},
1524{"X500algorithms","directory services - algorithms",
1525 NID_X500algorithms,2,&(lvalues[2829]),0},
1526{"ORG","org",NID_org,1,&(lvalues[2831]),0},
1527{"DOD","dod",NID_dod,2,&(lvalues[2832]),0},
1528{"IANA","iana",NID_iana,3,&(lvalues[2834]),0},
1529{"directory","Directory",NID_Directory,4,&(lvalues[2837]),0},
1530{"mgmt","Management",NID_Management,4,&(lvalues[2841]),0},
1531{"experimental","Experimental",NID_Experimental,4,&(lvalues[2845]),0},
1532{"private","Private",NID_Private,4,&(lvalues[2849]),0},
1533{"security","Security",NID_Security,4,&(lvalues[2853]),0},
1534{"snmpv2","SNMPv2",NID_SNMPv2,4,&(lvalues[2857]),0},
1535{"Mail","Mail",NID_Mail,4,&(lvalues[2861]),0},
1536{"enterprises","Enterprises",NID_Enterprises,5,&(lvalues[2865]),0},
1537{"dcobject","dcObject",NID_dcObject,9,&(lvalues[2870]),0},
1538{"DC","domainComponent",NID_domainComponent,10,&(lvalues[2879]),0},
1539{"domain","Domain",NID_Domain,10,&(lvalues[2889]),0},
1540{"NULL","NULL",NID_joint_iso_ccitt,1,&(lvalues[2899]),0},
1541{"selected-attribute-types","Selected Attribute Types",
1542 NID_selected_attribute_types,3,&(lvalues[2900]),0},
1543{"clearance","clearance",NID_clearance,4,&(lvalues[2903]),0},
1544{"RSA-MD4","md4WithRSAEncryption",NID_md4WithRSAEncryption,9,
1545 &(lvalues[2907]),0},
1546{"ac-proxying","ac-proxying",NID_ac_proxying,8,&(lvalues[2916]),0},
1547{"subjectInfoAccess","Subject Information Access",NID_sinfo_access,8,
1548 &(lvalues[2924]),0},
1549{"id-aca-encAttrs","id-aca-encAttrs",NID_id_aca_encAttrs,8,
1550 &(lvalues[2932]),0},
1551{"role","role",NID_role,3,&(lvalues[2940]),0},
1552{"policyConstraints","X509v3 Policy Constraints",
1553 NID_policy_constraints,3,&(lvalues[2943]),0},
1554{"targetInformation","X509v3 AC Targeting",NID_target_information,3,
1555 &(lvalues[2946]),0},
1556{"noRevAvail","X509v3 No Revocation Available",NID_no_rev_avail,3,
1557 &(lvalues[2949]),0},
1558{"NULL","NULL",NID_ccitt,1,&(lvalues[2952]),0},
1559{"ansi-X9-62","ANSI X9.62",NID_ansi_X9_62,5,&(lvalues[2953]),0},
1560{"prime-field","prime-field",NID_X9_62_prime_field,7,&(lvalues[2958]),0},
1561{"characteristic-two-field","characteristic-two-field",
1562 NID_X9_62_characteristic_two_field,7,&(lvalues[2965]),0},
1563{"id-ecPublicKey","id-ecPublicKey",NID_X9_62_id_ecPublicKey,7,
1564 &(lvalues[2972]),0},
1565{"prime192v1","prime192v1",NID_X9_62_prime192v1,8,&(lvalues[2979]),0},
1566{"prime192v2","prime192v2",NID_X9_62_prime192v2,8,&(lvalues[2987]),0},
1567{"prime192v3","prime192v3",NID_X9_62_prime192v3,8,&(lvalues[2995]),0},
1568{"prime239v1","prime239v1",NID_X9_62_prime239v1,8,&(lvalues[3003]),0},
1569{"prime239v2","prime239v2",NID_X9_62_prime239v2,8,&(lvalues[3011]),0},
1570{"prime239v3","prime239v3",NID_X9_62_prime239v3,8,&(lvalues[3019]),0},
1571{"prime256v1","prime256v1",NID_X9_62_prime256v1,8,&(lvalues[3027]),0},
1572{"ecdsa-with-SHA1","ecdsa-with-SHA1",NID_ecdsa_with_SHA1,7,
1573 &(lvalues[3035]),0},
1574{"CSPName","Microsoft CSP Name",NID_ms_csp_name,9,&(lvalues[3042]),0},
1575{"AES-128-ECB","aes-128-ecb",NID_aes_128_ecb,9,&(lvalues[3051]),0},
1576{"AES-128-CBC","aes-128-cbc",NID_aes_128_cbc,9,&(lvalues[3060]),0},
1577{"AES-128-OFB","aes-128-ofb",NID_aes_128_ofb128,9,&(lvalues[3069]),0},
1578{"AES-128-CFB","aes-128-cfb",NID_aes_128_cfb128,9,&(lvalues[3078]),0},
1579{"AES-192-ECB","aes-192-ecb",NID_aes_192_ecb,9,&(lvalues[3087]),0},
1580{"AES-192-CBC","aes-192-cbc",NID_aes_192_cbc,9,&(lvalues[3096]),0},
1581{"AES-192-OFB","aes-192-ofb",NID_aes_192_ofb128,9,&(lvalues[3105]),0},
1582{"AES-192-CFB","aes-192-cfb",NID_aes_192_cfb128,9,&(lvalues[3114]),0},
1583{"AES-256-ECB","aes-256-ecb",NID_aes_256_ecb,9,&(lvalues[3123]),0},
1584{"AES-256-CBC","aes-256-cbc",NID_aes_256_cbc,9,&(lvalues[3132]),0},
1585{"AES-256-OFB","aes-256-ofb",NID_aes_256_ofb128,9,&(lvalues[3141]),0},
1586{"AES-256-CFB","aes-256-cfb",NID_aes_256_cfb128,9,&(lvalues[3150]),0},
1587{"holdInstructionCode","Hold Instruction Code",
1588 NID_hold_instruction_code,3,&(lvalues[3159]),0},
1589{"holdInstructionNone","Hold Instruction None",
1590 NID_hold_instruction_none,7,&(lvalues[3162]),0},
1591{"holdInstructionCallIssuer","Hold Instruction Call Issuer",
1592 NID_hold_instruction_call_issuer,7,&(lvalues[3169]),0},
1593{"holdInstructionReject","Hold Instruction Reject",
1594 NID_hold_instruction_reject,7,&(lvalues[3176]),0},
1595{"data","data",NID_data,1,&(lvalues[3183]),0},
1596{"pss","pss",NID_pss,3,&(lvalues[3184]),0},
1597{"ucl","ucl",NID_ucl,7,&(lvalues[3187]),0},
1598{"pilot","pilot",NID_pilot,8,&(lvalues[3194]),0},
1599{"pilotAttributeType","pilotAttributeType",NID_pilotAttributeType,9,
1600 &(lvalues[3202]),0},
1601{"pilotAttributeSyntax","pilotAttributeSyntax",
1602 NID_pilotAttributeSyntax,9,&(lvalues[3211]),0},
1603{"pilotObjectClass","pilotObjectClass",NID_pilotObjectClass,9,
1604 &(lvalues[3220]),0},
1605{"pilotGroups","pilotGroups",NID_pilotGroups,9,&(lvalues[3229]),0},
1606{"iA5StringSyntax","iA5StringSyntax",NID_iA5StringSyntax,10,
1607 &(lvalues[3238]),0},
1608{"caseIgnoreIA5StringSyntax","caseIgnoreIA5StringSyntax",
1609 NID_caseIgnoreIA5StringSyntax,10,&(lvalues[3248]),0},
1610{"pilotObject","pilotObject",NID_pilotObject,10,&(lvalues[3258]),0},
1611{"pilotPerson","pilotPerson",NID_pilotPerson,10,&(lvalues[3268]),0},
1612{"account","account",NID_account,10,&(lvalues[3278]),0},
1613{"document","document",NID_document,10,&(lvalues[3288]),0},
1614{"room","room",NID_room,10,&(lvalues[3298]),0},
1615{"documentSeries","documentSeries",NID_documentSeries,10,
1616 &(lvalues[3308]),0},
1617{"rFC822localPart","rFC822localPart",NID_rFC822localPart,10,
1618 &(lvalues[3318]),0},
1619{"dNSDomain","dNSDomain",NID_dNSDomain,10,&(lvalues[3328]),0},
1620{"domainRelatedObject","domainRelatedObject",NID_domainRelatedObject,
1621 10,&(lvalues[3338]),0},
1622{"friendlyCountry","friendlyCountry",NID_friendlyCountry,10,
1623 &(lvalues[3348]),0},
1624{"simpleSecurityObject","simpleSecurityObject",
1625 NID_simpleSecurityObject,10,&(lvalues[3358]),0},
1626{"pilotOrganization","pilotOrganization",NID_pilotOrganization,10,
1627 &(lvalues[3368]),0},
1628{"pilotDSA","pilotDSA",NID_pilotDSA,10,&(lvalues[3378]),0},
1629{"qualityLabelledData","qualityLabelledData",NID_qualityLabelledData,
1630 10,&(lvalues[3388]),0},
1631{"UID","userId",NID_userId,10,&(lvalues[3398]),0},
1632{"textEncodedORAddress","textEncodedORAddress",
1633 NID_textEncodedORAddress,10,&(lvalues[3408]),0},
1634{"mail","rfc822Mailbox",NID_rfc822Mailbox,10,&(lvalues[3418]),0},
1635{"info","info",NID_info,10,&(lvalues[3428]),0},
1636{"favouriteDrink","favouriteDrink",NID_favouriteDrink,10,
1637 &(lvalues[3438]),0},
1638{"roomNumber","roomNumber",NID_roomNumber,10,&(lvalues[3448]),0},
1639{"photo","photo",NID_photo,10,&(lvalues[3458]),0},
1640{"userClass","userClass",NID_userClass,10,&(lvalues[3468]),0},
1641{"host","host",NID_host,10,&(lvalues[3478]),0},
1642{"manager","manager",NID_manager,10,&(lvalues[3488]),0},
1643{"documentIdentifier","documentIdentifier",NID_documentIdentifier,10,
1644 &(lvalues[3498]),0},
1645{"documentTitle","documentTitle",NID_documentTitle,10,&(lvalues[3508]),0},
1646{"documentVersion","documentVersion",NID_documentVersion,10,
1647 &(lvalues[3518]),0},
1648{"documentAuthor","documentAuthor",NID_documentAuthor,10,
1649 &(lvalues[3528]),0},
1650{"documentLocation","documentLocation",NID_documentLocation,10,
1651 &(lvalues[3538]),0},
1652{"homeTelephoneNumber","homeTelephoneNumber",NID_homeTelephoneNumber,
1653 10,&(lvalues[3548]),0},
1654{"secretary","secretary",NID_secretary,10,&(lvalues[3558]),0},
1655{"otherMailbox","otherMailbox",NID_otherMailbox,10,&(lvalues[3568]),0},
1656{"lastModifiedTime","lastModifiedTime",NID_lastModifiedTime,10,
1657 &(lvalues[3578]),0},
1658{"lastModifiedBy","lastModifiedBy",NID_lastModifiedBy,10,
1659 &(lvalues[3588]),0},
1660{"aRecord","aRecord",NID_aRecord,10,&(lvalues[3598]),0},
1661{"pilotAttributeType27","pilotAttributeType27",
1662 NID_pilotAttributeType27,10,&(lvalues[3608]),0},
1663{"mXRecord","mXRecord",NID_mXRecord,10,&(lvalues[3618]),0},
1664{"nSRecord","nSRecord",NID_nSRecord,10,&(lvalues[3628]),0},
1665{"sOARecord","sOARecord",NID_sOARecord,10,&(lvalues[3638]),0},
1666{"cNAMERecord","cNAMERecord",NID_cNAMERecord,10,&(lvalues[3648]),0},
1667{"associatedDomain","associatedDomain",NID_associatedDomain,10,
1668 &(lvalues[3658]),0},
1669{"associatedName","associatedName",NID_associatedName,10,
1670 &(lvalues[3668]),0},
1671{"homePostalAddress","homePostalAddress",NID_homePostalAddress,10,
1672 &(lvalues[3678]),0},
1673{"personalTitle","personalTitle",NID_personalTitle,10,&(lvalues[3688]),0},
1674{"mobileTelephoneNumber","mobileTelephoneNumber",
1675 NID_mobileTelephoneNumber,10,&(lvalues[3698]),0},
1676{"pagerTelephoneNumber","pagerTelephoneNumber",
1677 NID_pagerTelephoneNumber,10,&(lvalues[3708]),0},
1678{"friendlyCountryName","friendlyCountryName",NID_friendlyCountryName,
1679 10,&(lvalues[3718]),0},
1680{"organizationalStatus","organizationalStatus",
1681 NID_organizationalStatus,10,&(lvalues[3728]),0},
1682{"janetMailbox","janetMailbox",NID_janetMailbox,10,&(lvalues[3738]),0},
1683{"mailPreferenceOption","mailPreferenceOption",
1684 NID_mailPreferenceOption,10,&(lvalues[3748]),0},
1685{"buildingName","buildingName",NID_buildingName,10,&(lvalues[3758]),0},
1686{"dSAQuality","dSAQuality",NID_dSAQuality,10,&(lvalues[3768]),0},
1687{"singleLevelQuality","singleLevelQuality",NID_singleLevelQuality,10,
1688 &(lvalues[3778]),0},
1689{"subtreeMinimumQuality","subtreeMinimumQuality",
1690 NID_subtreeMinimumQuality,10,&(lvalues[3788]),0},
1691{"subtreeMaximumQuality","subtreeMaximumQuality",
1692 NID_subtreeMaximumQuality,10,&(lvalues[3798]),0},
1693{"personalSignature","personalSignature",NID_personalSignature,10,
1694 &(lvalues[3808]),0},
1695{"dITRedirect","dITRedirect",NID_dITRedirect,10,&(lvalues[3818]),0},
1696{"audio","audio",NID_audio,10,&(lvalues[3828]),0},
1697{"documentPublisher","documentPublisher",NID_documentPublisher,10,
1698 &(lvalues[3838]),0},
1699{"x500UniqueIdentifier","x500UniqueIdentifier",
1700 NID_x500UniqueIdentifier,3,&(lvalues[3848]),0},
1701{"mime-mhs","MIME MHS",NID_mime_mhs,5,&(lvalues[3851]),0},
1702{"mime-mhs-headings","mime-mhs-headings",NID_mime_mhs_headings,6,
1703 &(lvalues[3856]),0},
1704{"mime-mhs-bodies","mime-mhs-bodies",NID_mime_mhs_bodies,6,
1705 &(lvalues[3862]),0},
1706{"id-hex-partial-message","id-hex-partial-message",
1707 NID_id_hex_partial_message,7,&(lvalues[3868]),0},
1708{"id-hex-multipart-message","id-hex-multipart-message",
1709 NID_id_hex_multipart_message,7,&(lvalues[3875]),0},
1710{"generationQualifier","generationQualifier",NID_generationQualifier,
1711 3,&(lvalues[3882]),0},
1712{"pseudonym","pseudonym",NID_pseudonym,3,&(lvalues[3885]),0},
1713{NULL,NULL,NID_undef,0,NULL,0},
1714{"id-set","Secure Electronic Transactions",NID_id_set,2,
1715 &(lvalues[3888]),0},
1716{"set-ctype","content types",NID_set_ctype,3,&(lvalues[3890]),0},
1717{"set-msgExt","message extensions",NID_set_msgExt,3,&(lvalues[3893]),0},
1718{"set-attr","set-attr",NID_set_attr,3,&(lvalues[3896]),0},
1719{"set-policy","set-policy",NID_set_policy,3,&(lvalues[3899]),0},
1720{"set-certExt","certificate extensions",NID_set_certExt,3,
1721 &(lvalues[3902]),0},
1722{"set-brand","set-brand",NID_set_brand,3,&(lvalues[3905]),0},
1723{"setct-PANData","setct-PANData",NID_setct_PANData,4,&(lvalues[3908]),0},
1724{"setct-PANToken","setct-PANToken",NID_setct_PANToken,4,
1725 &(lvalues[3912]),0},
1726{"setct-PANOnly","setct-PANOnly",NID_setct_PANOnly,4,&(lvalues[3916]),0},
1727{"setct-OIData","setct-OIData",NID_setct_OIData,4,&(lvalues[3920]),0},
1728{"setct-PI","setct-PI",NID_setct_PI,4,&(lvalues[3924]),0},
1729{"setct-PIData","setct-PIData",NID_setct_PIData,4,&(lvalues[3928]),0},
1730{"setct-PIDataUnsigned","setct-PIDataUnsigned",
1731 NID_setct_PIDataUnsigned,4,&(lvalues[3932]),0},
1732{"setct-HODInput","setct-HODInput",NID_setct_HODInput,4,
1733 &(lvalues[3936]),0},
1734{"setct-AuthResBaggage","setct-AuthResBaggage",
1735 NID_setct_AuthResBaggage,4,&(lvalues[3940]),0},
1736{"setct-AuthRevReqBaggage","setct-AuthRevReqBaggage",
1737 NID_setct_AuthRevReqBaggage,4,&(lvalues[3944]),0},
1738{"setct-AuthRevResBaggage","setct-AuthRevResBaggage",
1739 NID_setct_AuthRevResBaggage,4,&(lvalues[3948]),0},
1740{"setct-CapTokenSeq","setct-CapTokenSeq",NID_setct_CapTokenSeq,4,
1741 &(lvalues[3952]),0},
1742{"setct-PInitResData","setct-PInitResData",NID_setct_PInitResData,4,
1743 &(lvalues[3956]),0},
1744{"setct-PI-TBS","setct-PI-TBS",NID_setct_PI_TBS,4,&(lvalues[3960]),0},
1745{"setct-PResData","setct-PResData",NID_setct_PResData,4,
1746 &(lvalues[3964]),0},
1747{"setct-AuthReqTBS","setct-AuthReqTBS",NID_setct_AuthReqTBS,4,
1748 &(lvalues[3968]),0},
1749{"setct-AuthResTBS","setct-AuthResTBS",NID_setct_AuthResTBS,4,
1750 &(lvalues[3972]),0},
1751{"setct-AuthResTBSX","setct-AuthResTBSX",NID_setct_AuthResTBSX,4,
1752 &(lvalues[3976]),0},
1753{"setct-AuthTokenTBS","setct-AuthTokenTBS",NID_setct_AuthTokenTBS,4,
1754 &(lvalues[3980]),0},
1755{"setct-CapTokenData","setct-CapTokenData",NID_setct_CapTokenData,4,
1756 &(lvalues[3984]),0},
1757{"setct-CapTokenTBS","setct-CapTokenTBS",NID_setct_CapTokenTBS,4,
1758 &(lvalues[3988]),0},
1759{"setct-AcqCardCodeMsg","setct-AcqCardCodeMsg",
1760 NID_setct_AcqCardCodeMsg,4,&(lvalues[3992]),0},
1761{"setct-AuthRevReqTBS","setct-AuthRevReqTBS",NID_setct_AuthRevReqTBS,
1762 4,&(lvalues[3996]),0},
1763{"setct-AuthRevResData","setct-AuthRevResData",
1764 NID_setct_AuthRevResData,4,&(lvalues[4000]),0},
1765{"setct-AuthRevResTBS","setct-AuthRevResTBS",NID_setct_AuthRevResTBS,
1766 4,&(lvalues[4004]),0},
1767{"setct-CapReqTBS","setct-CapReqTBS",NID_setct_CapReqTBS,4,
1768 &(lvalues[4008]),0},
1769{"setct-CapReqTBSX","setct-CapReqTBSX",NID_setct_CapReqTBSX,4,
1770 &(lvalues[4012]),0},
1771{"setct-CapResData","setct-CapResData",NID_setct_CapResData,4,
1772 &(lvalues[4016]),0},
1773{"setct-CapRevReqTBS","setct-CapRevReqTBS",NID_setct_CapRevReqTBS,4,
1774 &(lvalues[4020]),0},
1775{"setct-CapRevReqTBSX","setct-CapRevReqTBSX",NID_setct_CapRevReqTBSX,
1776 4,&(lvalues[4024]),0},
1777{"setct-CapRevResData","setct-CapRevResData",NID_setct_CapRevResData,
1778 4,&(lvalues[4028]),0},
1779{"setct-CredReqTBS","setct-CredReqTBS",NID_setct_CredReqTBS,4,
1780 &(lvalues[4032]),0},
1781{"setct-CredReqTBSX","setct-CredReqTBSX",NID_setct_CredReqTBSX,4,
1782 &(lvalues[4036]),0},
1783{"setct-CredResData","setct-CredResData",NID_setct_CredResData,4,
1784 &(lvalues[4040]),0},
1785{"setct-CredRevReqTBS","setct-CredRevReqTBS",NID_setct_CredRevReqTBS,
1786 4,&(lvalues[4044]),0},
1787{"setct-CredRevReqTBSX","setct-CredRevReqTBSX",
1788 NID_setct_CredRevReqTBSX,4,&(lvalues[4048]),0},
1789{"setct-CredRevResData","setct-CredRevResData",
1790 NID_setct_CredRevResData,4,&(lvalues[4052]),0},
1791{"setct-PCertReqData","setct-PCertReqData",NID_setct_PCertReqData,4,
1792 &(lvalues[4056]),0},
1793{"setct-PCertResTBS","setct-PCertResTBS",NID_setct_PCertResTBS,4,
1794 &(lvalues[4060]),0},
1795{"setct-BatchAdminReqData","setct-BatchAdminReqData",
1796 NID_setct_BatchAdminReqData,4,&(lvalues[4064]),0},
1797{"setct-BatchAdminResData","setct-BatchAdminResData",
1798 NID_setct_BatchAdminResData,4,&(lvalues[4068]),0},
1799{"setct-CardCInitResTBS","setct-CardCInitResTBS",
1800 NID_setct_CardCInitResTBS,4,&(lvalues[4072]),0},
1801{"setct-MeAqCInitResTBS","setct-MeAqCInitResTBS",
1802 NID_setct_MeAqCInitResTBS,4,&(lvalues[4076]),0},
1803{"setct-RegFormResTBS","setct-RegFormResTBS",NID_setct_RegFormResTBS,
1804 4,&(lvalues[4080]),0},
1805{"setct-CertReqData","setct-CertReqData",NID_setct_CertReqData,4,
1806 &(lvalues[4084]),0},
1807{"setct-CertReqTBS","setct-CertReqTBS",NID_setct_CertReqTBS,4,
1808 &(lvalues[4088]),0},
1809{"setct-CertResData","setct-CertResData",NID_setct_CertResData,4,
1810 &(lvalues[4092]),0},
1811{"setct-CertInqReqTBS","setct-CertInqReqTBS",NID_setct_CertInqReqTBS,
1812 4,&(lvalues[4096]),0},
1813{"setct-ErrorTBS","setct-ErrorTBS",NID_setct_ErrorTBS,4,
1814 &(lvalues[4100]),0},
1815{"setct-PIDualSignedTBE","setct-PIDualSignedTBE",
1816 NID_setct_PIDualSignedTBE,4,&(lvalues[4104]),0},
1817{"setct-PIUnsignedTBE","setct-PIUnsignedTBE",NID_setct_PIUnsignedTBE,
1818 4,&(lvalues[4108]),0},
1819{"setct-AuthReqTBE","setct-AuthReqTBE",NID_setct_AuthReqTBE,4,
1820 &(lvalues[4112]),0},
1821{"setct-AuthResTBE","setct-AuthResTBE",NID_setct_AuthResTBE,4,
1822 &(lvalues[4116]),0},
1823{"setct-AuthResTBEX","setct-AuthResTBEX",NID_setct_AuthResTBEX,4,
1824 &(lvalues[4120]),0},
1825{"setct-AuthTokenTBE","setct-AuthTokenTBE",NID_setct_AuthTokenTBE,4,
1826 &(lvalues[4124]),0},
1827{"setct-CapTokenTBE","setct-CapTokenTBE",NID_setct_CapTokenTBE,4,
1828 &(lvalues[4128]),0},
1829{"setct-CapTokenTBEX","setct-CapTokenTBEX",NID_setct_CapTokenTBEX,4,
1830 &(lvalues[4132]),0},
1831{"setct-AcqCardCodeMsgTBE","setct-AcqCardCodeMsgTBE",
1832 NID_setct_AcqCardCodeMsgTBE,4,&(lvalues[4136]),0},
1833{"setct-AuthRevReqTBE","setct-AuthRevReqTBE",NID_setct_AuthRevReqTBE,
1834 4,&(lvalues[4140]),0},
1835{"setct-AuthRevResTBE","setct-AuthRevResTBE",NID_setct_AuthRevResTBE,
1836 4,&(lvalues[4144]),0},
1837{"setct-AuthRevResTBEB","setct-AuthRevResTBEB",
1838 NID_setct_AuthRevResTBEB,4,&(lvalues[4148]),0},
1839{"setct-CapReqTBE","setct-CapReqTBE",NID_setct_CapReqTBE,4,
1840 &(lvalues[4152]),0},
1841{"setct-CapReqTBEX","setct-CapReqTBEX",NID_setct_CapReqTBEX,4,
1842 &(lvalues[4156]),0},
1843{"setct-CapResTBE","setct-CapResTBE",NID_setct_CapResTBE,4,
1844 &(lvalues[4160]),0},
1845{"setct-CapRevReqTBE","setct-CapRevReqTBE",NID_setct_CapRevReqTBE,4,
1846 &(lvalues[4164]),0},
1847{"setct-CapRevReqTBEX","setct-CapRevReqTBEX",NID_setct_CapRevReqTBEX,
1848 4,&(lvalues[4168]),0},
1849{"setct-CapRevResTBE","setct-CapRevResTBE",NID_setct_CapRevResTBE,4,
1850 &(lvalues[4172]),0},
1851{"setct-CredReqTBE","setct-CredReqTBE",NID_setct_CredReqTBE,4,
1852 &(lvalues[4176]),0},
1853{"setct-CredReqTBEX","setct-CredReqTBEX",NID_setct_CredReqTBEX,4,
1854 &(lvalues[4180]),0},
1855{"setct-CredResTBE","setct-CredResTBE",NID_setct_CredResTBE,4,
1856 &(lvalues[4184]),0},
1857{"setct-CredRevReqTBE","setct-CredRevReqTBE",NID_setct_CredRevReqTBE,
1858 4,&(lvalues[4188]),0},
1859{"setct-CredRevReqTBEX","setct-CredRevReqTBEX",
1860 NID_setct_CredRevReqTBEX,4,&(lvalues[4192]),0},
1861{"setct-CredRevResTBE","setct-CredRevResTBE",NID_setct_CredRevResTBE,
1862 4,&(lvalues[4196]),0},
1863{"setct-BatchAdminReqTBE","setct-BatchAdminReqTBE",
1864 NID_setct_BatchAdminReqTBE,4,&(lvalues[4200]),0},
1865{"setct-BatchAdminResTBE","setct-BatchAdminResTBE",
1866 NID_setct_BatchAdminResTBE,4,&(lvalues[4204]),0},
1867{"setct-RegFormReqTBE","setct-RegFormReqTBE",NID_setct_RegFormReqTBE,
1868 4,&(lvalues[4208]),0},
1869{"setct-CertReqTBE","setct-CertReqTBE",NID_setct_CertReqTBE,4,
1870 &(lvalues[4212]),0},
1871{"setct-CertReqTBEX","setct-CertReqTBEX",NID_setct_CertReqTBEX,4,
1872 &(lvalues[4216]),0},
1873{"setct-CertResTBE","setct-CertResTBE",NID_setct_CertResTBE,4,
1874 &(lvalues[4220]),0},
1875{"setct-CRLNotificationTBS","setct-CRLNotificationTBS",
1876 NID_setct_CRLNotificationTBS,4,&(lvalues[4224]),0},
1877{"setct-CRLNotificationResTBS","setct-CRLNotificationResTBS",
1878 NID_setct_CRLNotificationResTBS,4,&(lvalues[4228]),0},
1879{"setct-BCIDistributionTBS","setct-BCIDistributionTBS",
1880 NID_setct_BCIDistributionTBS,4,&(lvalues[4232]),0},
1881{"setext-genCrypt","generic cryptogram",NID_setext_genCrypt,4,
1882 &(lvalues[4236]),0},
1883{"setext-miAuth","merchant initiated auth",NID_setext_miAuth,4,
1884 &(lvalues[4240]),0},
1885{"setext-pinSecure","setext-pinSecure",NID_setext_pinSecure,4,
1886 &(lvalues[4244]),0},
1887{"setext-pinAny","setext-pinAny",NID_setext_pinAny,4,&(lvalues[4248]),0},
1888{"setext-track2","setext-track2",NID_setext_track2,4,&(lvalues[4252]),0},
1889{"setext-cv","additional verification",NID_setext_cv,4,
1890 &(lvalues[4256]),0},
1891{"set-policy-root","set-policy-root",NID_set_policy_root,4,
1892 &(lvalues[4260]),0},
1893{"setCext-hashedRoot","setCext-hashedRoot",NID_setCext_hashedRoot,4,
1894 &(lvalues[4264]),0},
1895{"setCext-certType","setCext-certType",NID_setCext_certType,4,
1896 &(lvalues[4268]),0},
1897{"setCext-merchData","setCext-merchData",NID_setCext_merchData,4,
1898 &(lvalues[4272]),0},
1899{"setCext-cCertRequired","setCext-cCertRequired",
1900 NID_setCext_cCertRequired,4,&(lvalues[4276]),0},
1901{"setCext-tunneling","setCext-tunneling",NID_setCext_tunneling,4,
1902 &(lvalues[4280]),0},
1903{"setCext-setExt","setCext-setExt",NID_setCext_setExt,4,
1904 &(lvalues[4284]),0},
1905{"setCext-setQualf","setCext-setQualf",NID_setCext_setQualf,4,
1906 &(lvalues[4288]),0},
1907{"setCext-PGWYcapabilities","setCext-PGWYcapabilities",
1908 NID_setCext_PGWYcapabilities,4,&(lvalues[4292]),0},
1909{"setCext-TokenIdentifier","setCext-TokenIdentifier",
1910 NID_setCext_TokenIdentifier,4,&(lvalues[4296]),0},
1911{"setCext-Track2Data","setCext-Track2Data",NID_setCext_Track2Data,4,
1912 &(lvalues[4300]),0},
1913{"setCext-TokenType","setCext-TokenType",NID_setCext_TokenType,4,
1914 &(lvalues[4304]),0},
1915{"setCext-IssuerCapabilities","setCext-IssuerCapabilities",
1916 NID_setCext_IssuerCapabilities,4,&(lvalues[4308]),0},
1917{"setAttr-Cert","setAttr-Cert",NID_setAttr_Cert,4,&(lvalues[4312]),0},
1918{"setAttr-PGWYcap","payment gateway capabilities",NID_setAttr_PGWYcap,
1919 4,&(lvalues[4316]),0},
1920{"setAttr-TokenType","setAttr-TokenType",NID_setAttr_TokenType,4,
1921 &(lvalues[4320]),0},
1922{"setAttr-IssCap","issuer capabilities",NID_setAttr_IssCap,4,
1923 &(lvalues[4324]),0},
1924{"set-rootKeyThumb","set-rootKeyThumb",NID_set_rootKeyThumb,5,
1925 &(lvalues[4328]),0},
1926{"set-addPolicy","set-addPolicy",NID_set_addPolicy,5,&(lvalues[4333]),0},
1927{"setAttr-Token-EMV","setAttr-Token-EMV",NID_setAttr_Token_EMV,5,
1928 &(lvalues[4338]),0},
1929{"setAttr-Token-B0Prime","setAttr-Token-B0Prime",
1930 NID_setAttr_Token_B0Prime,5,&(lvalues[4343]),0},
1931{"setAttr-IssCap-CVM","setAttr-IssCap-CVM",NID_setAttr_IssCap_CVM,5,
1932 &(lvalues[4348]),0},
1933{"setAttr-IssCap-T2","setAttr-IssCap-T2",NID_setAttr_IssCap_T2,5,
1934 &(lvalues[4353]),0},
1935{"setAttr-IssCap-Sig","setAttr-IssCap-Sig",NID_setAttr_IssCap_Sig,5,
1936 &(lvalues[4358]),0},
1937{"setAttr-GenCryptgrm","generate cryptogram",NID_setAttr_GenCryptgrm,
1938 6,&(lvalues[4363]),0},
1939{"setAttr-T2Enc","encrypted track 2",NID_setAttr_T2Enc,6,
1940 &(lvalues[4369]),0},
1941{"setAttr-T2cleartxt","cleartext track 2",NID_setAttr_T2cleartxt,6,
1942 &(lvalues[4375]),0},
1943{"setAttr-TokICCsig","ICC or token signature",NID_setAttr_TokICCsig,6,
1944 &(lvalues[4381]),0},
1945{"setAttr-SecDevSig","secure device signature",NID_setAttr_SecDevSig,
1946 6,&(lvalues[4387]),0},
1947{"set-brand-IATA-ATA","set-brand-IATA-ATA",NID_set_brand_IATA_ATA,4,
1948 &(lvalues[4393]),0},
1949{"set-brand-Diners","set-brand-Diners",NID_set_brand_Diners,4,
1950 &(lvalues[4397]),0},
1951{"set-brand-AmericanExpress","set-brand-AmericanExpress",
1952 NID_set_brand_AmericanExpress,4,&(lvalues[4401]),0},
1953{"set-brand-JCB","set-brand-JCB",NID_set_brand_JCB,4,&(lvalues[4405]),0},
1954{"set-brand-Visa","set-brand-Visa",NID_set_brand_Visa,4,
1955 &(lvalues[4409]),0},
1956{"set-brand-MasterCard","set-brand-MasterCard",
1957 NID_set_brand_MasterCard,4,&(lvalues[4413]),0},
1958{"set-brand-Novus","set-brand-Novus",NID_set_brand_Novus,5,
1959 &(lvalues[4417]),0},
1960{"DES-CDMF","des-cdmf",NID_des_cdmf,8,&(lvalues[4422]),0},
1961{"rsaOAEPEncryptionSET","rsaOAEPEncryptionSET",
1962 NID_rsaOAEPEncryptionSET,9,&(lvalues[4430]),0},
1963{"ITU-T","itu-t",NID_itu_t,1,&(lvalues[4439]),0},
1964{"JOINT-ISO-ITU-T","joint-iso-itu-t",NID_joint_iso_itu_t,1,
1965 &(lvalues[4440]),0},
1966{"international-organizations","International Organizations",
1967 NID_international_organizations,1,&(lvalues[4441]),0},
1968{"msSmartcardLogin","Microsoft Smartcardlogin",NID_ms_smartcard_login,
1969 10,&(lvalues[4442]),0},
1970{"msUPN","Microsoft Universal Principal Name",NID_ms_upn,10,
1971 &(lvalues[4452]),0},
1972{"AES-128-CFB1","aes-128-cfb1",NID_aes_128_cfb1,0,NULL,0},
1973{"AES-192-CFB1","aes-192-cfb1",NID_aes_192_cfb1,0,NULL,0},
1974{"AES-256-CFB1","aes-256-cfb1",NID_aes_256_cfb1,0,NULL,0},
1975{"AES-128-CFB8","aes-128-cfb8",NID_aes_128_cfb8,0,NULL,0},
1976{"AES-192-CFB8","aes-192-cfb8",NID_aes_192_cfb8,0,NULL,0},
1977{"AES-256-CFB8","aes-256-cfb8",NID_aes_256_cfb8,0,NULL,0},
1978{"DES-CFB1","des-cfb1",NID_des_cfb1,0,NULL,0},
1979{"DES-CFB8","des-cfb8",NID_des_cfb8,0,NULL,0},
1980{"DES-EDE3-CFB1","des-ede3-cfb1",NID_des_ede3_cfb1,0,NULL,0},
1981{"DES-EDE3-CFB8","des-ede3-cfb8",NID_des_ede3_cfb8,0,NULL,0},
1982{"street","streetAddress",NID_streetAddress,3,&(lvalues[4462]),0},
1983{"postalCode","postalCode",NID_postalCode,3,&(lvalues[4465]),0},
1984{"id-ppl","id-ppl",NID_id_ppl,7,&(lvalues[4468]),0},
1985{"proxyCertInfo","Proxy Certificate Information",NID_proxyCertInfo,8,
1986 &(lvalues[4475]),0},
1987{"id-ppl-anyLanguage","Any language",NID_id_ppl_anyLanguage,8,
1988 &(lvalues[4483]),0},
1989{"id-ppl-inheritAll","Inherit all",NID_id_ppl_inheritAll,8,
1990 &(lvalues[4491]),0},
1991{"nameConstraints","X509v3 Name Constraints",NID_name_constraints,3,
1992 &(lvalues[4499]),0},
1993{"id-ppl-independent","Independent",NID_Independent,8,&(lvalues[4502]),0},
1994{"RSA-SHA256","sha256WithRSAEncryption",NID_sha256WithRSAEncryption,9,
1995 &(lvalues[4510]),0},
1996{"RSA-SHA384","sha384WithRSAEncryption",NID_sha384WithRSAEncryption,9,
1997 &(lvalues[4519]),0},
1998{"RSA-SHA512","sha512WithRSAEncryption",NID_sha512WithRSAEncryption,9,
1999 &(lvalues[4528]),0},
2000{"RSA-SHA224","sha224WithRSAEncryption",NID_sha224WithRSAEncryption,9,
2001 &(lvalues[4537]),0},
2002{"SHA256","sha256",NID_sha256,9,&(lvalues[4546]),0},
2003{"SHA384","sha384",NID_sha384,9,&(lvalues[4555]),0},
2004{"SHA512","sha512",NID_sha512,9,&(lvalues[4564]),0},
2005{"SHA224","sha224",NID_sha224,9,&(lvalues[4573]),0},
2006{"identified-organization","identified-organization",
2007 NID_identified_organization,1,&(lvalues[4582]),0},
2008{"certicom-arc","certicom-arc",NID_certicom_arc,3,&(lvalues[4583]),0},
2009{"wap","wap",NID_wap,2,&(lvalues[4586]),0},
2010{"wap-wsg","wap-wsg",NID_wap_wsg,3,&(lvalues[4588]),0},
2011{"id-characteristic-two-basis","id-characteristic-two-basis",
2012 NID_X9_62_id_characteristic_two_basis,8,&(lvalues[4591]),0},
2013{"onBasis","onBasis",NID_X9_62_onBasis,9,&(lvalues[4599]),0},
2014{"tpBasis","tpBasis",NID_X9_62_tpBasis,9,&(lvalues[4608]),0},
2015{"ppBasis","ppBasis",NID_X9_62_ppBasis,9,&(lvalues[4617]),0},
2016{"c2pnb163v1","c2pnb163v1",NID_X9_62_c2pnb163v1,8,&(lvalues[4626]),0},
2017{"c2pnb163v2","c2pnb163v2",NID_X9_62_c2pnb163v2,8,&(lvalues[4634]),0},
2018{"c2pnb163v3","c2pnb163v3",NID_X9_62_c2pnb163v3,8,&(lvalues[4642]),0},
2019{"c2pnb176v1","c2pnb176v1",NID_X9_62_c2pnb176v1,8,&(lvalues[4650]),0},
2020{"c2tnb191v1","c2tnb191v1",NID_X9_62_c2tnb191v1,8,&(lvalues[4658]),0},
2021{"c2tnb191v2","c2tnb191v2",NID_X9_62_c2tnb191v2,8,&(lvalues[4666]),0},
2022{"c2tnb191v3","c2tnb191v3",NID_X9_62_c2tnb191v3,8,&(lvalues[4674]),0},
2023{"c2onb191v4","c2onb191v4",NID_X9_62_c2onb191v4,8,&(lvalues[4682]),0},
2024{"c2onb191v5","c2onb191v5",NID_X9_62_c2onb191v5,8,&(lvalues[4690]),0},
2025{"c2pnb208w1","c2pnb208w1",NID_X9_62_c2pnb208w1,8,&(lvalues[4698]),0},
2026{"c2tnb239v1","c2tnb239v1",NID_X9_62_c2tnb239v1,8,&(lvalues[4706]),0},
2027{"c2tnb239v2","c2tnb239v2",NID_X9_62_c2tnb239v2,8,&(lvalues[4714]),0},
2028{"c2tnb239v3","c2tnb239v3",NID_X9_62_c2tnb239v3,8,&(lvalues[4722]),0},
2029{"c2onb239v4","c2onb239v4",NID_X9_62_c2onb239v4,8,&(lvalues[4730]),0},
2030{"c2onb239v5","c2onb239v5",NID_X9_62_c2onb239v5,8,&(lvalues[4738]),0},
2031{"c2pnb272w1","c2pnb272w1",NID_X9_62_c2pnb272w1,8,&(lvalues[4746]),0},
2032{"c2pnb304w1","c2pnb304w1",NID_X9_62_c2pnb304w1,8,&(lvalues[4754]),0},
2033{"c2tnb359v1","c2tnb359v1",NID_X9_62_c2tnb359v1,8,&(lvalues[4762]),0},
2034{"c2pnb368w1","c2pnb368w1",NID_X9_62_c2pnb368w1,8,&(lvalues[4770]),0},
2035{"c2tnb431r1","c2tnb431r1",NID_X9_62_c2tnb431r1,8,&(lvalues[4778]),0},
2036{"secp112r1","secp112r1",NID_secp112r1,5,&(lvalues[4786]),0},
2037{"secp112r2","secp112r2",NID_secp112r2,5,&(lvalues[4791]),0},
2038{"secp128r1","secp128r1",NID_secp128r1,5,&(lvalues[4796]),0},
2039{"secp128r2","secp128r2",NID_secp128r2,5,&(lvalues[4801]),0},
2040{"secp160k1","secp160k1",NID_secp160k1,5,&(lvalues[4806]),0},
2041{"secp160r1","secp160r1",NID_secp160r1,5,&(lvalues[4811]),0},
2042{"secp160r2","secp160r2",NID_secp160r2,5,&(lvalues[4816]),0},
2043{"secp192k1","secp192k1",NID_secp192k1,5,&(lvalues[4821]),0},
2044{"secp224k1","secp224k1",NID_secp224k1,5,&(lvalues[4826]),0},
2045{"secp224r1","secp224r1",NID_secp224r1,5,&(lvalues[4831]),0},
2046{"secp256k1","secp256k1",NID_secp256k1,5,&(lvalues[4836]),0},
2047{"secp384r1","secp384r1",NID_secp384r1,5,&(lvalues[4841]),0},
2048{"secp521r1","secp521r1",NID_secp521r1,5,&(lvalues[4846]),0},
2049{"sect113r1","sect113r1",NID_sect113r1,5,&(lvalues[4851]),0},
2050{"sect113r2","sect113r2",NID_sect113r2,5,&(lvalues[4856]),0},
2051{"sect131r1","sect131r1",NID_sect131r1,5,&(lvalues[4861]),0},
2052{"sect131r2","sect131r2",NID_sect131r2,5,&(lvalues[4866]),0},
2053{"sect163k1","sect163k1",NID_sect163k1,5,&(lvalues[4871]),0},
2054{"sect163r1","sect163r1",NID_sect163r1,5,&(lvalues[4876]),0},
2055{"sect163r2","sect163r2",NID_sect163r2,5,&(lvalues[4881]),0},
2056{"sect193r1","sect193r1",NID_sect193r1,5,&(lvalues[4886]),0},
2057{"sect193r2","sect193r2",NID_sect193r2,5,&(lvalues[4891]),0},
2058{"sect233k1","sect233k1",NID_sect233k1,5,&(lvalues[4896]),0},
2059{"sect233r1","sect233r1",NID_sect233r1,5,&(lvalues[4901]),0},
2060{"sect239k1","sect239k1",NID_sect239k1,5,&(lvalues[4906]),0},
2061{"sect283k1","sect283k1",NID_sect283k1,5,&(lvalues[4911]),0},
2062{"sect283r1","sect283r1",NID_sect283r1,5,&(lvalues[4916]),0},
2063{"sect409k1","sect409k1",NID_sect409k1,5,&(lvalues[4921]),0},
2064{"sect409r1","sect409r1",NID_sect409r1,5,&(lvalues[4926]),0},
2065{"sect571k1","sect571k1",NID_sect571k1,5,&(lvalues[4931]),0},
2066{"sect571r1","sect571r1",NID_sect571r1,5,&(lvalues[4936]),0},
2067{"wap-wsg-idm-ecid-wtls1","wap-wsg-idm-ecid-wtls1",
2068 NID_wap_wsg_idm_ecid_wtls1,5,&(lvalues[4941]),0},
2069{"wap-wsg-idm-ecid-wtls3","wap-wsg-idm-ecid-wtls3",
2070 NID_wap_wsg_idm_ecid_wtls3,5,&(lvalues[4946]),0},
2071{"wap-wsg-idm-ecid-wtls4","wap-wsg-idm-ecid-wtls4",
2072 NID_wap_wsg_idm_ecid_wtls4,5,&(lvalues[4951]),0},
2073{"wap-wsg-idm-ecid-wtls5","wap-wsg-idm-ecid-wtls5",
2074 NID_wap_wsg_idm_ecid_wtls5,5,&(lvalues[4956]),0},
2075{"wap-wsg-idm-ecid-wtls6","wap-wsg-idm-ecid-wtls6",
2076 NID_wap_wsg_idm_ecid_wtls6,5,&(lvalues[4961]),0},
2077{"wap-wsg-idm-ecid-wtls7","wap-wsg-idm-ecid-wtls7",
2078 NID_wap_wsg_idm_ecid_wtls7,5,&(lvalues[4966]),0},
2079{"wap-wsg-idm-ecid-wtls8","wap-wsg-idm-ecid-wtls8",
2080 NID_wap_wsg_idm_ecid_wtls8,5,&(lvalues[4971]),0},
2081{"wap-wsg-idm-ecid-wtls9","wap-wsg-idm-ecid-wtls9",
2082 NID_wap_wsg_idm_ecid_wtls9,5,&(lvalues[4976]),0},
2083{"wap-wsg-idm-ecid-wtls10","wap-wsg-idm-ecid-wtls10",
2084 NID_wap_wsg_idm_ecid_wtls10,5,&(lvalues[4981]),0},
2085{"wap-wsg-idm-ecid-wtls11","wap-wsg-idm-ecid-wtls11",
2086 NID_wap_wsg_idm_ecid_wtls11,5,&(lvalues[4986]),0},
2087{"wap-wsg-idm-ecid-wtls12","wap-wsg-idm-ecid-wtls12",
2088 NID_wap_wsg_idm_ecid_wtls12,5,&(lvalues[4991]),0},
2089{"anyPolicy","X509v3 Any Policy",NID_any_policy,4,&(lvalues[4996]),0},
2090{"policyMappings","X509v3 Policy Mappings",NID_policy_mappings,3,
2091 &(lvalues[5000]),0},
2092{"inhibitAnyPolicy","X509v3 Inhibit Any Policy",
2093 NID_inhibit_any_policy,3,&(lvalues[5003]),0},
2094{"Oakley-EC2N-3","ipsec3",NID_ipsec3,0,NULL,0},
2095{"Oakley-EC2N-4","ipsec4",NID_ipsec4,0,NULL,0},
2096{"CAMELLIA-128-CBC","camellia-128-cbc",NID_camellia_128_cbc,11,
2097 &(lvalues[5006]),0},
2098{"CAMELLIA-192-CBC","camellia-192-cbc",NID_camellia_192_cbc,11,
2099 &(lvalues[5017]),0},
2100{"CAMELLIA-256-CBC","camellia-256-cbc",NID_camellia_256_cbc,11,
2101 &(lvalues[5028]),0},
2102{"CAMELLIA-128-ECB","camellia-128-ecb",NID_camellia_128_ecb,8,
2103 &(lvalues[5039]),0},
2104{"CAMELLIA-192-ECB","camellia-192-ecb",NID_camellia_192_ecb,8,
2105 &(lvalues[5047]),0},
2106{"CAMELLIA-256-ECB","camellia-256-ecb",NID_camellia_256_ecb,8,
2107 &(lvalues[5055]),0},
2108{"CAMELLIA-128-CFB","camellia-128-cfb",NID_camellia_128_cfb128,8,
2109 &(lvalues[5063]),0},
2110{"CAMELLIA-192-CFB","camellia-192-cfb",NID_camellia_192_cfb128,8,
2111 &(lvalues[5071]),0},
2112{"CAMELLIA-256-CFB","camellia-256-cfb",NID_camellia_256_cfb128,8,
2113 &(lvalues[5079]),0},
2114{"CAMELLIA-128-CFB1","camellia-128-cfb1",NID_camellia_128_cfb1,0,NULL,0},
2115{"CAMELLIA-192-CFB1","camellia-192-cfb1",NID_camellia_192_cfb1,0,NULL,0},
2116{"CAMELLIA-256-CFB1","camellia-256-cfb1",NID_camellia_256_cfb1,0,NULL,0},
2117{"CAMELLIA-128-CFB8","camellia-128-cfb8",NID_camellia_128_cfb8,0,NULL,0},
2118{"CAMELLIA-192-CFB8","camellia-192-cfb8",NID_camellia_192_cfb8,0,NULL,0},
2119{"CAMELLIA-256-CFB8","camellia-256-cfb8",NID_camellia_256_cfb8,0,NULL,0},
2120{"CAMELLIA-128-OFB","camellia-128-ofb",NID_camellia_128_ofb128,8,
2121 &(lvalues[5087]),0},
2122{"CAMELLIA-192-OFB","camellia-192-ofb",NID_camellia_192_ofb128,8,
2123 &(lvalues[5095]),0},
2124{"CAMELLIA-256-OFB","camellia-256-ofb",NID_camellia_256_ofb128,8,
2125 &(lvalues[5103]),0},
2126{"subjectDirectoryAttributes","X509v3 Subject Directory Attributes",
2127 NID_subject_directory_attributes,3,&(lvalues[5111]),0},
2128{"issuingDistributionPoint","X509v3 Issuing Distrubution Point",
2129 NID_issuing_distribution_point,3,&(lvalues[5114]),0},
2130{"certificateIssuer","X509v3 Certificate Issuer",
2131 NID_certificate_issuer,3,&(lvalues[5117]),0},
2132{NULL,NULL,NID_undef,0,NULL,0},
2133{"KISA","kisa",NID_kisa,6,&(lvalues[5120]),0},
2134{NULL,NULL,NID_undef,0,NULL,0},
2135{NULL,NULL,NID_undef,0,NULL,0},
2136{"SEED-ECB","seed-ecb",NID_seed_ecb,8,&(lvalues[5126]),0},
2137{"SEED-CBC","seed-cbc",NID_seed_cbc,8,&(lvalues[5134]),0},
2138{"SEED-OFB","seed-ofb",NID_seed_ofb128,8,&(lvalues[5142]),0},
2139{"SEED-CFB","seed-cfb",NID_seed_cfb128,8,&(lvalues[5150]),0},
2140{"HMAC-MD5","hmac-md5",NID_hmac_md5,8,&(lvalues[5158]),0},
2141{"HMAC-SHA1","hmac-sha1",NID_hmac_sha1,8,&(lvalues[5166]),0},
2142{"id-PasswordBasedMAC","password based MAC",NID_id_PasswordBasedMAC,9,
2143 &(lvalues[5174]),0},
2144{"id-DHBasedMac","Diffie-Hellman based MAC",NID_id_DHBasedMac,9,
2145 &(lvalues[5183]),0},
2146{"id-it-suppLangTags","id-it-suppLangTags",NID_id_it_suppLangTags,8,
2147 &(lvalues[5192]),0},
2148{"caRepository","CA Repository",NID_caRepository,8,&(lvalues[5200]),0},
2149{"id-smime-ct-compressedData","id-smime-ct-compressedData",
2150 NID_id_smime_ct_compressedData,11,&(lvalues[5208]),0},
2151{"id-ct-asciiTextWithCRLF","id-ct-asciiTextWithCRLF",
2152 NID_id_ct_asciiTextWithCRLF,11,&(lvalues[5219]),0},
2153{"id-aes128-wrap","id-aes128-wrap",NID_id_aes128_wrap,9,
2154 &(lvalues[5230]),0},
2155{"id-aes192-wrap","id-aes192-wrap",NID_id_aes192_wrap,9,
2156 &(lvalues[5239]),0},
2157{"id-aes256-wrap","id-aes256-wrap",NID_id_aes256_wrap,9,
2158 &(lvalues[5248]),0},
2159{"ecdsa-with-Recommended","ecdsa-with-Recommended",
2160 NID_ecdsa_with_Recommended,7,&(lvalues[5257]),0},
2161{"ecdsa-with-Specified","ecdsa-with-Specified",
2162 NID_ecdsa_with_Specified,7,&(lvalues[5264]),0},
2163{"ecdsa-with-SHA224","ecdsa-with-SHA224",NID_ecdsa_with_SHA224,8,
2164 &(lvalues[5271]),0},
2165{"ecdsa-with-SHA256","ecdsa-with-SHA256",NID_ecdsa_with_SHA256,8,
2166 &(lvalues[5279]),0},
2167{"ecdsa-with-SHA384","ecdsa-with-SHA384",NID_ecdsa_with_SHA384,8,
2168 &(lvalues[5287]),0},
2169{"ecdsa-with-SHA512","ecdsa-with-SHA512",NID_ecdsa_with_SHA512,8,
2170 &(lvalues[5295]),0},
2171{"hmacWithMD5","hmacWithMD5",NID_hmacWithMD5,8,&(lvalues[5303]),0},
2172{"hmacWithSHA224","hmacWithSHA224",NID_hmacWithSHA224,8,
2173 &(lvalues[5311]),0},
2174{"hmacWithSHA256","hmacWithSHA256",NID_hmacWithSHA256,8,
2175 &(lvalues[5319]),0},
2176{"hmacWithSHA384","hmacWithSHA384",NID_hmacWithSHA384,8,
2177 &(lvalues[5327]),0},
2178{"hmacWithSHA512","hmacWithSHA512",NID_hmacWithSHA512,8,
2179 &(lvalues[5335]),0},
2180{"dsa_with_SHA224","dsa_with_SHA224",NID_dsa_with_SHA224,9,
2181 &(lvalues[5343]),0},
2182{"dsa_with_SHA256","dsa_with_SHA256",NID_dsa_with_SHA256,9,
2183 &(lvalues[5352]),0},
2184{"whirlpool","whirlpool",NID_whirlpool,6,&(lvalues[5361]),0},
2185{"cryptopro","cryptopro",NID_cryptopro,5,&(lvalues[5367]),0},
2186{"cryptocom","cryptocom",NID_cryptocom,5,&(lvalues[5372]),0},
2187{"id-GostR3411-94-with-GostR3410-2001",
2188 "GOST R 34.11-94 with GOST R 34.10-2001",
2189 NID_id_GostR3411_94_with_GostR3410_2001,6,&(lvalues[5377]),0},
2190{"id-GostR3411-94-with-GostR3410-94",
2191 "GOST R 34.11-94 with GOST R 34.10-94",
2192 NID_id_GostR3411_94_with_GostR3410_94,6,&(lvalues[5383]),0},
2193{"md_gost94","GOST R 34.11-94",NID_id_GostR3411_94,6,&(lvalues[5389]),0},
2194{"id-HMACGostR3411-94","HMAC GOST 34.11-94",NID_id_HMACGostR3411_94,6,
2195 &(lvalues[5395]),0},
2196{"gost2001","GOST R 34.10-2001",NID_id_GostR3410_2001,6,
2197 &(lvalues[5401]),0},
2198{"gost94","GOST R 34.10-94",NID_id_GostR3410_94,6,&(lvalues[5407]),0},
2199{"gost89","GOST 28147-89",NID_id_Gost28147_89,6,&(lvalues[5413]),0},
2200{"gost89-cnt","gost89-cnt",NID_gost89_cnt,0,NULL,0},
2201{"gost-mac","GOST 28147-89 MAC",NID_id_Gost28147_89_MAC,6,
2202 &(lvalues[5419]),0},
2203{"prf-gostr3411-94","GOST R 34.11-94 PRF",NID_id_GostR3411_94_prf,6,
2204 &(lvalues[5425]),0},
2205{"id-GostR3410-2001DH","GOST R 34.10-2001 DH",NID_id_GostR3410_2001DH,
2206 6,&(lvalues[5431]),0},
2207{"id-GostR3410-94DH","GOST R 34.10-94 DH",NID_id_GostR3410_94DH,6,
2208 &(lvalues[5437]),0},
2209{"id-Gost28147-89-CryptoPro-KeyMeshing",
2210 "id-Gost28147-89-CryptoPro-KeyMeshing",
2211 NID_id_Gost28147_89_CryptoPro_KeyMeshing,7,&(lvalues[5443]),0},
2212{"id-Gost28147-89-None-KeyMeshing","id-Gost28147-89-None-KeyMeshing",
2213 NID_id_Gost28147_89_None_KeyMeshing,7,&(lvalues[5450]),0},
2214{"id-GostR3411-94-TestParamSet","id-GostR3411-94-TestParamSet",
2215 NID_id_GostR3411_94_TestParamSet,7,&(lvalues[5457]),0},
2216{"id-GostR3411-94-CryptoProParamSet",
2217 "id-GostR3411-94-CryptoProParamSet",
2218 NID_id_GostR3411_94_CryptoProParamSet,7,&(lvalues[5464]),0},
2219{"id-Gost28147-89-TestParamSet","id-Gost28147-89-TestParamSet",
2220 NID_id_Gost28147_89_TestParamSet,7,&(lvalues[5471]),0},
2221{"id-Gost28147-89-CryptoPro-A-ParamSet",
2222 "id-Gost28147-89-CryptoPro-A-ParamSet",
2223 NID_id_Gost28147_89_CryptoPro_A_ParamSet,7,&(lvalues[5478]),0},
2224{"id-Gost28147-89-CryptoPro-B-ParamSet",
2225 "id-Gost28147-89-CryptoPro-B-ParamSet",
2226 NID_id_Gost28147_89_CryptoPro_B_ParamSet,7,&(lvalues[5485]),0},
2227{"id-Gost28147-89-CryptoPro-C-ParamSet",
2228 "id-Gost28147-89-CryptoPro-C-ParamSet",
2229 NID_id_Gost28147_89_CryptoPro_C_ParamSet,7,&(lvalues[5492]),0},
2230{"id-Gost28147-89-CryptoPro-D-ParamSet",
2231 "id-Gost28147-89-CryptoPro-D-ParamSet",
2232 NID_id_Gost28147_89_CryptoPro_D_ParamSet,7,&(lvalues[5499]),0},
2233{"id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet",
2234 "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet",
2235 NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet,7,&(lvalues[5506]),
2236 0},
2237{"id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet",
2238 "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet",
2239 NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet,7,&(lvalues[5513]),
2240 0},
2241{"id-Gost28147-89-CryptoPro-RIC-1-ParamSet",
2242 "id-Gost28147-89-CryptoPro-RIC-1-ParamSet",
2243 NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet,7,&(lvalues[5520]),0},
2244{"id-GostR3410-94-TestParamSet","id-GostR3410-94-TestParamSet",
2245 NID_id_GostR3410_94_TestParamSet,7,&(lvalues[5527]),0},
2246{"id-GostR3410-94-CryptoPro-A-ParamSet",
2247 "id-GostR3410-94-CryptoPro-A-ParamSet",
2248 NID_id_GostR3410_94_CryptoPro_A_ParamSet,7,&(lvalues[5534]),0},
2249{"id-GostR3410-94-CryptoPro-B-ParamSet",
2250 "id-GostR3410-94-CryptoPro-B-ParamSet",
2251 NID_id_GostR3410_94_CryptoPro_B_ParamSet,7,&(lvalues[5541]),0},
2252{"id-GostR3410-94-CryptoPro-C-ParamSet",
2253 "id-GostR3410-94-CryptoPro-C-ParamSet",
2254 NID_id_GostR3410_94_CryptoPro_C_ParamSet,7,&(lvalues[5548]),0},
2255{"id-GostR3410-94-CryptoPro-D-ParamSet",
2256 "id-GostR3410-94-CryptoPro-D-ParamSet",
2257 NID_id_GostR3410_94_CryptoPro_D_ParamSet,7,&(lvalues[5555]),0},
2258{"id-GostR3410-94-CryptoPro-XchA-ParamSet",
2259 "id-GostR3410-94-CryptoPro-XchA-ParamSet",
2260 NID_id_GostR3410_94_CryptoPro_XchA_ParamSet,7,&(lvalues[5562]),0},
2261{"id-GostR3410-94-CryptoPro-XchB-ParamSet",
2262 "id-GostR3410-94-CryptoPro-XchB-ParamSet",
2263 NID_id_GostR3410_94_CryptoPro_XchB_ParamSet,7,&(lvalues[5569]),0},
2264{"id-GostR3410-94-CryptoPro-XchC-ParamSet",
2265 "id-GostR3410-94-CryptoPro-XchC-ParamSet",
2266 NID_id_GostR3410_94_CryptoPro_XchC_ParamSet,7,&(lvalues[5576]),0},
2267{"id-GostR3410-2001-TestParamSet","id-GostR3410-2001-TestParamSet",
2268 NID_id_GostR3410_2001_TestParamSet,7,&(lvalues[5583]),0},
2269{"id-GostR3410-2001-CryptoPro-A-ParamSet",
2270 "id-GostR3410-2001-CryptoPro-A-ParamSet",
2271 NID_id_GostR3410_2001_CryptoPro_A_ParamSet,7,&(lvalues[5590]),0},
2272{"id-GostR3410-2001-CryptoPro-B-ParamSet",
2273 "id-GostR3410-2001-CryptoPro-B-ParamSet",
2274 NID_id_GostR3410_2001_CryptoPro_B_ParamSet,7,&(lvalues[5597]),0},
2275{"id-GostR3410-2001-CryptoPro-C-ParamSet",
2276 "id-GostR3410-2001-CryptoPro-C-ParamSet",
2277 NID_id_GostR3410_2001_CryptoPro_C_ParamSet,7,&(lvalues[5604]),0},
2278{"id-GostR3410-2001-CryptoPro-XchA-ParamSet",
2279 "id-GostR3410-2001-CryptoPro-XchA-ParamSet",
2280 NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet,7,&(lvalues[5611]),0},
2281
2282{"id-GostR3410-2001-CryptoPro-XchB-ParamSet",
2283 "id-GostR3410-2001-CryptoPro-XchB-ParamSet",
2284 NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet,7,&(lvalues[5618]),0},
2285
2286{"id-GostR3410-94-a","id-GostR3410-94-a",NID_id_GostR3410_94_a,7,
2287 &(lvalues[5625]),0},
2288{"id-GostR3410-94-aBis","id-GostR3410-94-aBis",
2289 NID_id_GostR3410_94_aBis,7,&(lvalues[5632]),0},
2290{"id-GostR3410-94-b","id-GostR3410-94-b",NID_id_GostR3410_94_b,7,
2291 &(lvalues[5639]),0},
2292{"id-GostR3410-94-bBis","id-GostR3410-94-bBis",
2293 NID_id_GostR3410_94_bBis,7,&(lvalues[5646]),0},
2294{"id-Gost28147-89-cc","GOST 28147-89 Cryptocom ParamSet",
2295 NID_id_Gost28147_89_cc,8,&(lvalues[5653]),0},
2296{"gost94cc","GOST 34.10-94 Cryptocom",NID_id_GostR3410_94_cc,8,
2297 &(lvalues[5661]),0},
2298{"gost2001cc","GOST 34.10-2001 Cryptocom",NID_id_GostR3410_2001_cc,8,
2299 &(lvalues[5669]),0},
2300{"id-GostR3411-94-with-GostR3410-94-cc",
2301 "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom",
2302 NID_id_GostR3411_94_with_GostR3410_94_cc,8,&(lvalues[5677]),0},
2303{"id-GostR3411-94-with-GostR3410-2001-cc",
2304 "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom",
2305 NID_id_GostR3411_94_with_GostR3410_2001_cc,8,&(lvalues[5685]),0},
2306{"id-GostR3410-2001-ParamSet-cc",
2307 "GOST R 3410-2001 Parameter Set Cryptocom",
2308 NID_id_GostR3410_2001_ParamSet_cc,8,&(lvalues[5693]),0},
2309{"HMAC","hmac",NID_hmac,0,NULL,0},
2310{"LocalKeySet","Microsoft Local Key set",NID_LocalKeySet,9,
2311 &(lvalues[5701]),0},
2312{"freshestCRL","X509v3 Freshest CRL",NID_freshest_crl,3,
2313 &(lvalues[5710]),0},
2314{"id-on-permanentIdentifier","Permanent Identifier",
2315 NID_id_on_permanentIdentifier,8,&(lvalues[5713]),0},
2316{"searchGuide","searchGuide",NID_searchGuide,3,&(lvalues[5721]),0},
2317{"businessCategory","businessCategory",NID_businessCategory,3,
2318 &(lvalues[5724]),0},
2319{"postalAddress","postalAddress",NID_postalAddress,3,&(lvalues[5727]),0},
2320{"postOfficeBox","postOfficeBox",NID_postOfficeBox,3,&(lvalues[5730]),0},
2321{"physicalDeliveryOfficeName","physicalDeliveryOfficeName",
2322 NID_physicalDeliveryOfficeName,3,&(lvalues[5733]),0},
2323{"telephoneNumber","telephoneNumber",NID_telephoneNumber,3,
2324 &(lvalues[5736]),0},
2325{"telexNumber","telexNumber",NID_telexNumber,3,&(lvalues[5739]),0},
2326{"teletexTerminalIdentifier","teletexTerminalIdentifier",
2327 NID_teletexTerminalIdentifier,3,&(lvalues[5742]),0},
2328{"facsimileTelephoneNumber","facsimileTelephoneNumber",
2329 NID_facsimileTelephoneNumber,3,&(lvalues[5745]),0},
2330{"x121Address","x121Address",NID_x121Address,3,&(lvalues[5748]),0},
2331{"internationaliSDNNumber","internationaliSDNNumber",
2332 NID_internationaliSDNNumber,3,&(lvalues[5751]),0},
2333{"registeredAddress","registeredAddress",NID_registeredAddress,3,
2334 &(lvalues[5754]),0},
2335{"destinationIndicator","destinationIndicator",
2336 NID_destinationIndicator,3,&(lvalues[5757]),0},
2337{"preferredDeliveryMethod","preferredDeliveryMethod",
2338 NID_preferredDeliveryMethod,3,&(lvalues[5760]),0},
2339{"presentationAddress","presentationAddress",NID_presentationAddress,
2340 3,&(lvalues[5763]),0},
2341{"supportedApplicationContext","supportedApplicationContext",
2342 NID_supportedApplicationContext,3,&(lvalues[5766]),0},
2343{"member","member",NID_member,3,&(lvalues[5769]),0},
2344{"owner","owner",NID_owner,3,&(lvalues[5772]),0},
2345{"roleOccupant","roleOccupant",NID_roleOccupant,3,&(lvalues[5775]),0},
2346{"seeAlso","seeAlso",NID_seeAlso,3,&(lvalues[5778]),0},
2347{"userPassword","userPassword",NID_userPassword,3,&(lvalues[5781]),0},
2348{"userCertificate","userCertificate",NID_userCertificate,3,
2349 &(lvalues[5784]),0},
2350{"cACertificate","cACertificate",NID_cACertificate,3,&(lvalues[5787]),0},
2351{"authorityRevocationList","authorityRevocationList",
2352 NID_authorityRevocationList,3,&(lvalues[5790]),0},
2353{"certificateRevocationList","certificateRevocationList",
2354 NID_certificateRevocationList,3,&(lvalues[5793]),0},
2355{"crossCertificatePair","crossCertificatePair",
2356 NID_crossCertificatePair,3,&(lvalues[5796]),0},
2357{"enhancedSearchGuide","enhancedSearchGuide",NID_enhancedSearchGuide,
2358 3,&(lvalues[5799]),0},
2359{"protocolInformation","protocolInformation",NID_protocolInformation,
2360 3,&(lvalues[5802]),0},
2361{"distinguishedName","distinguishedName",NID_distinguishedName,3,
2362 &(lvalues[5805]),0},
2363{"uniqueMember","uniqueMember",NID_uniqueMember,3,&(lvalues[5808]),0},
2364{"houseIdentifier","houseIdentifier",NID_houseIdentifier,3,
2365 &(lvalues[5811]),0},
2366{"supportedAlgorithms","supportedAlgorithms",NID_supportedAlgorithms,
2367 3,&(lvalues[5814]),0},
2368{"deltaRevocationList","deltaRevocationList",NID_deltaRevocationList,
2369 3,&(lvalues[5817]),0},
2370{"dmdName","dmdName",NID_dmdName,3,&(lvalues[5820]),0},
2371{"id-alg-PWRI-KEK","id-alg-PWRI-KEK",NID_id_alg_PWRI_KEK,11,
2372 &(lvalues[5823]),0},
2373{"CMAC","cmac",NID_cmac,0,NULL,0},
2374{"id-aes128-GCM","aes-128-gcm",NID_aes_128_gcm,9,&(lvalues[5834]),0},
2375{"id-aes128-CCM","aes-128-ccm",NID_aes_128_ccm,9,&(lvalues[5843]),0},
2376{"id-aes128-wrap-pad","id-aes128-wrap-pad",NID_id_aes128_wrap_pad,9,
2377 &(lvalues[5852]),0},
2378{"id-aes192-GCM","aes-192-gcm",NID_aes_192_gcm,9,&(lvalues[5861]),0},
2379{"id-aes192-CCM","aes-192-ccm",NID_aes_192_ccm,9,&(lvalues[5870]),0},
2380{"id-aes192-wrap-pad","id-aes192-wrap-pad",NID_id_aes192_wrap_pad,9,
2381 &(lvalues[5879]),0},
2382{"id-aes256-GCM","aes-256-gcm",NID_aes_256_gcm,9,&(lvalues[5888]),0},
2383{"id-aes256-CCM","aes-256-ccm",NID_aes_256_ccm,9,&(lvalues[5897]),0},
2384{"id-aes256-wrap-pad","id-aes256-wrap-pad",NID_id_aes256_wrap_pad,9,
2385 &(lvalues[5906]),0},
2386{"AES-128-CTR","aes-128-ctr",NID_aes_128_ctr,0,NULL,0},
2387{"AES-192-CTR","aes-192-ctr",NID_aes_192_ctr,0,NULL,0},
2388{"AES-256-CTR","aes-256-ctr",NID_aes_256_ctr,0,NULL,0},
2389{"id-camellia128-wrap","id-camellia128-wrap",NID_id_camellia128_wrap,
2390 11,&(lvalues[5915]),0},
2391{"id-camellia192-wrap","id-camellia192-wrap",NID_id_camellia192_wrap,
2392 11,&(lvalues[5926]),0},
2393{"id-camellia256-wrap","id-camellia256-wrap",NID_id_camellia256_wrap,
2394 11,&(lvalues[5937]),0},
2395{"anyExtendedKeyUsage","Any Extended Key Usage",
2396 NID_anyExtendedKeyUsage,4,&(lvalues[5948]),0},
2397{"MGF1","mgf1",NID_mgf1,9,&(lvalues[5952]),0},
2398{"RSASSA-PSS","rsassaPss",NID_rsassaPss,9,&(lvalues[5961]),0},
2399{"AES-128-XTS","aes-128-xts",NID_aes_128_xts,0,NULL,0},
2400{"AES-256-XTS","aes-256-xts",NID_aes_256_xts,0,NULL,0},
2401{"RC4-HMAC-MD5","rc4-hmac-md5",NID_rc4_hmac_md5,0,NULL,0},
2402{"AES-128-CBC-HMAC-SHA1","aes-128-cbc-hmac-sha1",
2403 NID_aes_128_cbc_hmac_sha1,0,NULL,0},
2404{"AES-192-CBC-HMAC-SHA1","aes-192-cbc-hmac-sha1",
2405 NID_aes_192_cbc_hmac_sha1,0,NULL,0},
2406{"AES-256-CBC-HMAC-SHA1","aes-256-cbc-hmac-sha1",
2407 NID_aes_256_cbc_hmac_sha1,0,NULL,0},
2408{"RSAES-OAEP","rsaesOaep",NID_rsaesOaep,9,&(lvalues[5970]),0},
2409};
2410
2411static const unsigned int sn_objs[NUM_SN]={
2412364, /* "AD_DVCS" */
2413419, /* "AES-128-CBC" */
2414916, /* "AES-128-CBC-HMAC-SHA1" */
2415421, /* "AES-128-CFB" */
2416650, /* "AES-128-CFB1" */
2417653, /* "AES-128-CFB8" */
2418904, /* "AES-128-CTR" */
2419418, /* "AES-128-ECB" */
2420420, /* "AES-128-OFB" */
2421913, /* "AES-128-XTS" */
2422423, /* "AES-192-CBC" */
2423917, /* "AES-192-CBC-HMAC-SHA1" */
2424425, /* "AES-192-CFB" */
2425651, /* "AES-192-CFB1" */
2426654, /* "AES-192-CFB8" */
2427905, /* "AES-192-CTR" */
2428422, /* "AES-192-ECB" */
2429424, /* "AES-192-OFB" */
2430427, /* "AES-256-CBC" */
2431918, /* "AES-256-CBC-HMAC-SHA1" */
2432429, /* "AES-256-CFB" */
2433652, /* "AES-256-CFB1" */
2434655, /* "AES-256-CFB8" */
2435906, /* "AES-256-CTR" */
2436426, /* "AES-256-ECB" */
2437428, /* "AES-256-OFB" */
2438914, /* "AES-256-XTS" */
243991, /* "BF-CBC" */
244093, /* "BF-CFB" */
244192, /* "BF-ECB" */
244294, /* "BF-OFB" */
244314, /* "C" */
2444751, /* "CAMELLIA-128-CBC" */
2445757, /* "CAMELLIA-128-CFB" */
2446760, /* "CAMELLIA-128-CFB1" */
2447763, /* "CAMELLIA-128-CFB8" */
2448754, /* "CAMELLIA-128-ECB" */
2449766, /* "CAMELLIA-128-OFB" */
2450752, /* "CAMELLIA-192-CBC" */
2451758, /* "CAMELLIA-192-CFB" */
2452761, /* "CAMELLIA-192-CFB1" */
2453764, /* "CAMELLIA-192-CFB8" */
2454755, /* "CAMELLIA-192-ECB" */
2455767, /* "CAMELLIA-192-OFB" */
2456753, /* "CAMELLIA-256-CBC" */
2457759, /* "CAMELLIA-256-CFB" */
2458762, /* "CAMELLIA-256-CFB1" */
2459765, /* "CAMELLIA-256-CFB8" */
2460756, /* "CAMELLIA-256-ECB" */
2461768, /* "CAMELLIA-256-OFB" */
2462108, /* "CAST5-CBC" */
2463110, /* "CAST5-CFB" */
2464109, /* "CAST5-ECB" */
2465111, /* "CAST5-OFB" */
2466894, /* "CMAC" */
246713, /* "CN" */
2468141, /* "CRLReason" */
2469417, /* "CSPName" */
2470367, /* "CrlID" */
2471391, /* "DC" */
247231, /* "DES-CBC" */
2473643, /* "DES-CDMF" */
247430, /* "DES-CFB" */
2475656, /* "DES-CFB1" */
2476657, /* "DES-CFB8" */
247729, /* "DES-ECB" */
247832, /* "DES-EDE" */
247943, /* "DES-EDE-CBC" */
248060, /* "DES-EDE-CFB" */
248162, /* "DES-EDE-OFB" */
248233, /* "DES-EDE3" */
248344, /* "DES-EDE3-CBC" */
248461, /* "DES-EDE3-CFB" */
2485658, /* "DES-EDE3-CFB1" */
2486659, /* "DES-EDE3-CFB8" */
248763, /* "DES-EDE3-OFB" */
248845, /* "DES-OFB" */
248980, /* "DESX-CBC" */
2490380, /* "DOD" */
2491116, /* "DSA" */
249266, /* "DSA-SHA" */
2493113, /* "DSA-SHA1" */
249470, /* "DSA-SHA1-old" */
249567, /* "DSA-old" */
2496297, /* "DVCS" */
249799, /* "GN" */
2498855, /* "HMAC" */
2499780, /* "HMAC-MD5" */
2500781, /* "HMAC-SHA1" */
2501381, /* "IANA" */
250234, /* "IDEA-CBC" */
250335, /* "IDEA-CFB" */
250436, /* "IDEA-ECB" */
250546, /* "IDEA-OFB" */
2506181, /* "ISO" */
2507183, /* "ISO-US" */
2508645, /* "ITU-T" */
2509646, /* "JOINT-ISO-ITU-T" */
2510773, /* "KISA" */
251115, /* "L" */
2512856, /* "LocalKeySet" */
2513 3, /* "MD2" */
2514257, /* "MD4" */
2515 4, /* "MD5" */
2516114, /* "MD5-SHA1" */
251795, /* "MDC2" */
2518911, /* "MGF1" */
2519388, /* "Mail" */
2520393, /* "NULL" */
2521404, /* "NULL" */
252257, /* "Netscape" */
2523366, /* "Nonce" */
252417, /* "O" */
2525178, /* "OCSP" */
2526180, /* "OCSPSigning" */
2527379, /* "ORG" */
252818, /* "OU" */
2529749, /* "Oakley-EC2N-3" */
2530750, /* "Oakley-EC2N-4" */
2531 9, /* "PBE-MD2-DES" */
2532168, /* "PBE-MD2-RC2-64" */
253310, /* "PBE-MD5-DES" */
2534169, /* "PBE-MD5-RC2-64" */
2535147, /* "PBE-SHA1-2DES" */
2536146, /* "PBE-SHA1-3DES" */
2537170, /* "PBE-SHA1-DES" */
2538148, /* "PBE-SHA1-RC2-128" */
2539149, /* "PBE-SHA1-RC2-40" */
254068, /* "PBE-SHA1-RC2-64" */
2541144, /* "PBE-SHA1-RC4-128" */
2542145, /* "PBE-SHA1-RC4-40" */
2543161, /* "PBES2" */
254469, /* "PBKDF2" */
2545162, /* "PBMAC1" */
2546127, /* "PKIX" */
254798, /* "RC2-40-CBC" */
2548166, /* "RC2-64-CBC" */
254937, /* "RC2-CBC" */
255039, /* "RC2-CFB" */
255138, /* "RC2-ECB" */
255240, /* "RC2-OFB" */
2553 5, /* "RC4" */
255497, /* "RC4-40" */
2555915, /* "RC4-HMAC-MD5" */
2556120, /* "RC5-CBC" */
2557122, /* "RC5-CFB" */
2558121, /* "RC5-ECB" */
2559123, /* "RC5-OFB" */
2560117, /* "RIPEMD160" */
2561124, /* "RLE" */
256219, /* "RSA" */
2563 7, /* "RSA-MD2" */
2564396, /* "RSA-MD4" */
2565 8, /* "RSA-MD5" */
256696, /* "RSA-MDC2" */
2567104, /* "RSA-NP-MD5" */
2568119, /* "RSA-RIPEMD160" */
256942, /* "RSA-SHA" */
257065, /* "RSA-SHA1" */
2571115, /* "RSA-SHA1-2" */
2572671, /* "RSA-SHA224" */
2573668, /* "RSA-SHA256" */
2574669, /* "RSA-SHA384" */
2575670, /* "RSA-SHA512" */
2576919, /* "RSAES-OAEP" */
2577912, /* "RSASSA-PSS" */
2578777, /* "SEED-CBC" */
2579779, /* "SEED-CFB" */
2580776, /* "SEED-ECB" */
2581778, /* "SEED-OFB" */
258241, /* "SHA" */
258364, /* "SHA1" */
2584675, /* "SHA224" */
2585672, /* "SHA256" */
2586673, /* "SHA384" */
2587674, /* "SHA512" */
2588188, /* "SMIME" */
2589167, /* "SMIME-CAPS" */
2590100, /* "SN" */
259116, /* "ST" */
2592143, /* "SXNetID" */
2593458, /* "UID" */
2594 0, /* "UNDEF" */
259511, /* "X500" */
2596378, /* "X500algorithms" */
259712, /* "X509" */
2598184, /* "X9-57" */
2599185, /* "X9cm" */
2600125, /* "ZLIB" */
2601478, /* "aRecord" */
2602289, /* "aaControls" */
2603287, /* "ac-auditEntity" */
2604397, /* "ac-proxying" */
2605288, /* "ac-targeting" */
2606368, /* "acceptableResponses" */
2607446, /* "account" */
2608363, /* "ad_timestamping" */
2609376, /* "algorithm" */
2610405, /* "ansi-X9-62" */
2611910, /* "anyExtendedKeyUsage" */
2612746, /* "anyPolicy" */
2613370, /* "archiveCutoff" */
2614484, /* "associatedDomain" */
2615485, /* "associatedName" */
2616501, /* "audio" */
2617177, /* "authorityInfoAccess" */
261890, /* "authorityKeyIdentifier" */
2619882, /* "authorityRevocationList" */
262087, /* "basicConstraints" */
2621365, /* "basicOCSPResponse" */
2622285, /* "biometricInfo" */
2623494, /* "buildingName" */
2624860, /* "businessCategory" */
2625691, /* "c2onb191v4" */
2626692, /* "c2onb191v5" */
2627697, /* "c2onb239v4" */
2628698, /* "c2onb239v5" */
2629684, /* "c2pnb163v1" */
2630685, /* "c2pnb163v2" */
2631686, /* "c2pnb163v3" */
2632687, /* "c2pnb176v1" */
2633693, /* "c2pnb208w1" */
2634699, /* "c2pnb272w1" */
2635700, /* "c2pnb304w1" */
2636702, /* "c2pnb368w1" */
2637688, /* "c2tnb191v1" */
2638689, /* "c2tnb191v2" */
2639690, /* "c2tnb191v3" */
2640694, /* "c2tnb239v1" */
2641695, /* "c2tnb239v2" */
2642696, /* "c2tnb239v3" */
2643701, /* "c2tnb359v1" */
2644703, /* "c2tnb431r1" */
2645881, /* "cACertificate" */
2646483, /* "cNAMERecord" */
2647179, /* "caIssuers" */
2648785, /* "caRepository" */
2649443, /* "caseIgnoreIA5StringSyntax" */
2650152, /* "certBag" */
2651677, /* "certicom-arc" */
2652771, /* "certificateIssuer" */
265389, /* "certificatePolicies" */
2654883, /* "certificateRevocationList" */
265554, /* "challengePassword" */
2656407, /* "characteristic-two-field" */
2657395, /* "clearance" */
2658130, /* "clientAuth" */
2659131, /* "codeSigning" */
266050, /* "contentType" */
266153, /* "countersignature" */
2662153, /* "crlBag" */
2663103, /* "crlDistributionPoints" */
266488, /* "crlNumber" */
2665884, /* "crossCertificatePair" */
2666806, /* "cryptocom" */
2667805, /* "cryptopro" */
2668500, /* "dITRedirect" */
2669451, /* "dNSDomain" */
2670495, /* "dSAQuality" */
2671434, /* "data" */
2672390, /* "dcobject" */
2673140, /* "deltaCRL" */
2674891, /* "deltaRevocationList" */
2675107, /* "description" */
2676871, /* "destinationIndicator" */
267728, /* "dhKeyAgreement" */
2678382, /* "directory" */
2679887, /* "distinguishedName" */
2680892, /* "dmdName" */
2681174, /* "dnQualifier" */
2682447, /* "document" */
2683471, /* "documentAuthor" */
2684468, /* "documentIdentifier" */
2685472, /* "documentLocation" */
2686502, /* "documentPublisher" */
2687449, /* "documentSeries" */
2688469, /* "documentTitle" */
2689470, /* "documentVersion" */
2690392, /* "domain" */
2691452, /* "domainRelatedObject" */
2692802, /* "dsa_with_SHA224" */
2693803, /* "dsa_with_SHA256" */
2694791, /* "ecdsa-with-Recommended" */
2695416, /* "ecdsa-with-SHA1" */
2696793, /* "ecdsa-with-SHA224" */
2697794, /* "ecdsa-with-SHA256" */
2698795, /* "ecdsa-with-SHA384" */
2699796, /* "ecdsa-with-SHA512" */
2700792, /* "ecdsa-with-Specified" */
270148, /* "emailAddress" */
2702132, /* "emailProtection" */
2703885, /* "enhancedSearchGuide" */
2704389, /* "enterprises" */
2705384, /* "experimental" */
2706172, /* "extReq" */
270756, /* "extendedCertificateAttributes" */
2708126, /* "extendedKeyUsage" */
2709372, /* "extendedStatus" */
2710867, /* "facsimileTelephoneNumber" */
2711462, /* "favouriteDrink" */
2712857, /* "freshestCRL" */
2713453, /* "friendlyCountry" */
2714490, /* "friendlyCountryName" */
2715156, /* "friendlyName" */
2716509, /* "generationQualifier" */
2717815, /* "gost-mac" */
2718811, /* "gost2001" */
2719851, /* "gost2001cc" */
2720813, /* "gost89" */
2721814, /* "gost89-cnt" */
2722812, /* "gost94" */
2723850, /* "gost94cc" */
2724797, /* "hmacWithMD5" */
2725163, /* "hmacWithSHA1" */
2726798, /* "hmacWithSHA224" */
2727799, /* "hmacWithSHA256" */
2728800, /* "hmacWithSHA384" */
2729801, /* "hmacWithSHA512" */
2730432, /* "holdInstructionCallIssuer" */
2731430, /* "holdInstructionCode" */
2732431, /* "holdInstructionNone" */
2733433, /* "holdInstructionReject" */
2734486, /* "homePostalAddress" */
2735473, /* "homeTelephoneNumber" */
2736466, /* "host" */
2737889, /* "houseIdentifier" */
2738442, /* "iA5StringSyntax" */
2739783, /* "id-DHBasedMac" */
2740824, /* "id-Gost28147-89-CryptoPro-A-ParamSet" */
2741825, /* "id-Gost28147-89-CryptoPro-B-ParamSet" */
2742826, /* "id-Gost28147-89-CryptoPro-C-ParamSet" */
2743827, /* "id-Gost28147-89-CryptoPro-D-ParamSet" */
2744819, /* "id-Gost28147-89-CryptoPro-KeyMeshing" */
2745829, /* "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet" */
2746828, /* "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet" */
2747830, /* "id-Gost28147-89-CryptoPro-RIC-1-ParamSet" */
2748820, /* "id-Gost28147-89-None-KeyMeshing" */
2749823, /* "id-Gost28147-89-TestParamSet" */
2750849, /* "id-Gost28147-89-cc" */
2751840, /* "id-GostR3410-2001-CryptoPro-A-ParamSet" */
2752841, /* "id-GostR3410-2001-CryptoPro-B-ParamSet" */
2753842, /* "id-GostR3410-2001-CryptoPro-C-ParamSet" */
2754843, /* "id-GostR3410-2001-CryptoPro-XchA-ParamSet" */
2755844, /* "id-GostR3410-2001-CryptoPro-XchB-ParamSet" */
2756854, /* "id-GostR3410-2001-ParamSet-cc" */
2757839, /* "id-GostR3410-2001-TestParamSet" */
2758817, /* "id-GostR3410-2001DH" */
2759832, /* "id-GostR3410-94-CryptoPro-A-ParamSet" */
2760833, /* "id-GostR3410-94-CryptoPro-B-ParamSet" */
2761834, /* "id-GostR3410-94-CryptoPro-C-ParamSet" */
2762835, /* "id-GostR3410-94-CryptoPro-D-ParamSet" */
2763836, /* "id-GostR3410-94-CryptoPro-XchA-ParamSet" */
2764837, /* "id-GostR3410-94-CryptoPro-XchB-ParamSet" */
2765838, /* "id-GostR3410-94-CryptoPro-XchC-ParamSet" */
2766831, /* "id-GostR3410-94-TestParamSet" */
2767845, /* "id-GostR3410-94-a" */
2768846, /* "id-GostR3410-94-aBis" */
2769847, /* "id-GostR3410-94-b" */
2770848, /* "id-GostR3410-94-bBis" */
2771818, /* "id-GostR3410-94DH" */
2772822, /* "id-GostR3411-94-CryptoProParamSet" */
2773821, /* "id-GostR3411-94-TestParamSet" */
2774807, /* "id-GostR3411-94-with-GostR3410-2001" */
2775853, /* "id-GostR3411-94-with-GostR3410-2001-cc" */
2776808, /* "id-GostR3411-94-with-GostR3410-94" */
2777852, /* "id-GostR3411-94-with-GostR3410-94-cc" */
2778810, /* "id-HMACGostR3411-94" */
2779782, /* "id-PasswordBasedMAC" */
2780266, /* "id-aca" */
2781355, /* "id-aca-accessIdentity" */
2782354, /* "id-aca-authenticationInfo" */
2783356, /* "id-aca-chargingIdentity" */
2784399, /* "id-aca-encAttrs" */
2785357, /* "id-aca-group" */
2786358, /* "id-aca-role" */
2787176, /* "id-ad" */
2788896, /* "id-aes128-CCM" */
2789895, /* "id-aes128-GCM" */
2790788, /* "id-aes128-wrap" */
2791897, /* "id-aes128-wrap-pad" */
2792899, /* "id-aes192-CCM" */
2793898, /* "id-aes192-GCM" */
2794789, /* "id-aes192-wrap" */
2795900, /* "id-aes192-wrap-pad" */
2796902, /* "id-aes256-CCM" */
2797901, /* "id-aes256-GCM" */
2798790, /* "id-aes256-wrap" */
2799903, /* "id-aes256-wrap-pad" */
2800262, /* "id-alg" */
2801893, /* "id-alg-PWRI-KEK" */
2802323, /* "id-alg-des40" */
2803326, /* "id-alg-dh-pop" */
2804325, /* "id-alg-dh-sig-hmac-sha1" */
2805324, /* "id-alg-noSignature" */
2806907, /* "id-camellia128-wrap" */
2807908, /* "id-camellia192-wrap" */
2808909, /* "id-camellia256-wrap" */
2809268, /* "id-cct" */
2810361, /* "id-cct-PKIData" */
2811362, /* "id-cct-PKIResponse" */
2812360, /* "id-cct-crs" */
281381, /* "id-ce" */
2814680, /* "id-characteristic-two-basis" */
2815263, /* "id-cmc" */
2816334, /* "id-cmc-addExtensions" */
2817346, /* "id-cmc-confirmCertAcceptance" */
2818330, /* "id-cmc-dataReturn" */
2819336, /* "id-cmc-decryptedPOP" */
2820335, /* "id-cmc-encryptedPOP" */
2821339, /* "id-cmc-getCRL" */
2822338, /* "id-cmc-getCert" */
2823328, /* "id-cmc-identification" */
2824329, /* "id-cmc-identityProof" */
2825337, /* "id-cmc-lraPOPWitness" */
2826344, /* "id-cmc-popLinkRandom" */
2827345, /* "id-cmc-popLinkWitness" */
2828343, /* "id-cmc-queryPending" */
2829333, /* "id-cmc-recipientNonce" */
2830341, /* "id-cmc-regInfo" */
2831342, /* "id-cmc-responseInfo" */
2832340, /* "id-cmc-revokeRequest" */
2833332, /* "id-cmc-senderNonce" */
2834327, /* "id-cmc-statusInfo" */
2835331, /* "id-cmc-transactionId" */
2836787, /* "id-ct-asciiTextWithCRLF" */
2837408, /* "id-ecPublicKey" */
2838508, /* "id-hex-multipart-message" */
2839507, /* "id-hex-partial-message" */
2840260, /* "id-it" */
2841302, /* "id-it-caKeyUpdateInfo" */
2842298, /* "id-it-caProtEncCert" */
2843311, /* "id-it-confirmWaitTime" */
2844303, /* "id-it-currentCRL" */
2845300, /* "id-it-encKeyPairTypes" */
2846310, /* "id-it-implicitConfirm" */
2847308, /* "id-it-keyPairParamRep" */
2848307, /* "id-it-keyPairParamReq" */
2849312, /* "id-it-origPKIMessage" */
2850301, /* "id-it-preferredSymmAlg" */
2851309, /* "id-it-revPassphrase" */
2852299, /* "id-it-signKeyPairTypes" */
2853305, /* "id-it-subscriptionRequest" */
2854306, /* "id-it-subscriptionResponse" */
2855784, /* "id-it-suppLangTags" */
2856304, /* "id-it-unsupportedOIDs" */
2857128, /* "id-kp" */
2858280, /* "id-mod-attribute-cert" */
2859274, /* "id-mod-cmc" */
2860277, /* "id-mod-cmp" */
2861284, /* "id-mod-cmp2000" */
2862273, /* "id-mod-crmf" */
2863283, /* "id-mod-dvcs" */
2864275, /* "id-mod-kea-profile-88" */
2865276, /* "id-mod-kea-profile-93" */
2866282, /* "id-mod-ocsp" */
2867278, /* "id-mod-qualified-cert-88" */
2868279, /* "id-mod-qualified-cert-93" */
2869281, /* "id-mod-timestamp-protocol" */
2870264, /* "id-on" */
2871858, /* "id-on-permanentIdentifier" */
2872347, /* "id-on-personalData" */
2873265, /* "id-pda" */
2874352, /* "id-pda-countryOfCitizenship" */
2875353, /* "id-pda-countryOfResidence" */
2876348, /* "id-pda-dateOfBirth" */
2877351, /* "id-pda-gender" */
2878349, /* "id-pda-placeOfBirth" */
2879175, /* "id-pe" */
2880261, /* "id-pkip" */
2881258, /* "id-pkix-mod" */
2882269, /* "id-pkix1-explicit-88" */
2883271, /* "id-pkix1-explicit-93" */
2884270, /* "id-pkix1-implicit-88" */
2885272, /* "id-pkix1-implicit-93" */
2886662, /* "id-ppl" */
2887664, /* "id-ppl-anyLanguage" */
2888667, /* "id-ppl-independent" */
2889665, /* "id-ppl-inheritAll" */
2890267, /* "id-qcs" */
2891359, /* "id-qcs-pkixQCSyntax-v1" */
2892259, /* "id-qt" */
2893164, /* "id-qt-cps" */
2894165, /* "id-qt-unotice" */
2895313, /* "id-regCtrl" */
2896316, /* "id-regCtrl-authenticator" */
2897319, /* "id-regCtrl-oldCertID" */
2898318, /* "id-regCtrl-pkiArchiveOptions" */
2899317, /* "id-regCtrl-pkiPublicationInfo" */
2900320, /* "id-regCtrl-protocolEncrKey" */
2901315, /* "id-regCtrl-regToken" */
2902314, /* "id-regInfo" */
2903322, /* "id-regInfo-certReq" */
2904321, /* "id-regInfo-utf8Pairs" */
2905512, /* "id-set" */
2906191, /* "id-smime-aa" */
2907215, /* "id-smime-aa-contentHint" */
2908218, /* "id-smime-aa-contentIdentifier" */
2909221, /* "id-smime-aa-contentReference" */
2910240, /* "id-smime-aa-dvcs-dvc" */
2911217, /* "id-smime-aa-encapContentType" */
2912222, /* "id-smime-aa-encrypKeyPref" */
2913220, /* "id-smime-aa-equivalentLabels" */
2914232, /* "id-smime-aa-ets-CertificateRefs" */
2915233, /* "id-smime-aa-ets-RevocationRefs" */
2916238, /* "id-smime-aa-ets-archiveTimeStamp" */
2917237, /* "id-smime-aa-ets-certCRLTimestamp" */
2918234, /* "id-smime-aa-ets-certValues" */
2919227, /* "id-smime-aa-ets-commitmentType" */
2920231, /* "id-smime-aa-ets-contentTimestamp" */
2921236, /* "id-smime-aa-ets-escTimeStamp" */
2922230, /* "id-smime-aa-ets-otherSigCert" */
2923235, /* "id-smime-aa-ets-revocationValues" */
2924226, /* "id-smime-aa-ets-sigPolicyId" */
2925229, /* "id-smime-aa-ets-signerAttr" */
2926228, /* "id-smime-aa-ets-signerLocation" */
2927219, /* "id-smime-aa-macValue" */
2928214, /* "id-smime-aa-mlExpandHistory" */
2929216, /* "id-smime-aa-msgSigDigest" */
2930212, /* "id-smime-aa-receiptRequest" */
2931213, /* "id-smime-aa-securityLabel" */
2932239, /* "id-smime-aa-signatureType" */
2933223, /* "id-smime-aa-signingCertificate" */
2934224, /* "id-smime-aa-smimeEncryptCerts" */
2935225, /* "id-smime-aa-timeStampToken" */
2936192, /* "id-smime-alg" */
2937243, /* "id-smime-alg-3DESwrap" */
2938246, /* "id-smime-alg-CMS3DESwrap" */
2939247, /* "id-smime-alg-CMSRC2wrap" */
2940245, /* "id-smime-alg-ESDH" */
2941241, /* "id-smime-alg-ESDHwith3DES" */
2942242, /* "id-smime-alg-ESDHwithRC2" */
2943244, /* "id-smime-alg-RC2wrap" */
2944193, /* "id-smime-cd" */
2945248, /* "id-smime-cd-ldap" */
2946190, /* "id-smime-ct" */
2947210, /* "id-smime-ct-DVCSRequestData" */
2948211, /* "id-smime-ct-DVCSResponseData" */
2949208, /* "id-smime-ct-TDTInfo" */
2950207, /* "id-smime-ct-TSTInfo" */
2951205, /* "id-smime-ct-authData" */
2952786, /* "id-smime-ct-compressedData" */
2953209, /* "id-smime-ct-contentInfo" */
2954206, /* "id-smime-ct-publishCert" */
2955204, /* "id-smime-ct-receipt" */
2956195, /* "id-smime-cti" */
2957255, /* "id-smime-cti-ets-proofOfApproval" */
2958256, /* "id-smime-cti-ets-proofOfCreation" */
2959253, /* "id-smime-cti-ets-proofOfDelivery" */
2960251, /* "id-smime-cti-ets-proofOfOrigin" */
2961252, /* "id-smime-cti-ets-proofOfReceipt" */
2962254, /* "id-smime-cti-ets-proofOfSender" */
2963189, /* "id-smime-mod" */
2964196, /* "id-smime-mod-cms" */
2965197, /* "id-smime-mod-ess" */
2966202, /* "id-smime-mod-ets-eSigPolicy-88" */
2967203, /* "id-smime-mod-ets-eSigPolicy-97" */
2968200, /* "id-smime-mod-ets-eSignature-88" */
2969201, /* "id-smime-mod-ets-eSignature-97" */
2970199, /* "id-smime-mod-msg-v3" */
2971198, /* "id-smime-mod-oid" */
2972194, /* "id-smime-spq" */
2973250, /* "id-smime-spq-ets-sqt-unotice" */
2974249, /* "id-smime-spq-ets-sqt-uri" */
2975676, /* "identified-organization" */
2976461, /* "info" */
2977748, /* "inhibitAnyPolicy" */
2978101, /* "initials" */
2979647, /* "international-organizations" */
2980869, /* "internationaliSDNNumber" */
2981142, /* "invalidityDate" */
2982294, /* "ipsecEndSystem" */
2983295, /* "ipsecTunnel" */
2984296, /* "ipsecUser" */
298586, /* "issuerAltName" */
2986770, /* "issuingDistributionPoint" */
2987492, /* "janetMailbox" */
2988150, /* "keyBag" */
298983, /* "keyUsage" */
2990477, /* "lastModifiedBy" */
2991476, /* "lastModifiedTime" */
2992157, /* "localKeyID" */
2993480, /* "mXRecord" */
2994460, /* "mail" */
2995493, /* "mailPreferenceOption" */
2996467, /* "manager" */
2997809, /* "md_gost94" */
2998875, /* "member" */
2999182, /* "member-body" */
300051, /* "messageDigest" */
3001383, /* "mgmt" */
3002504, /* "mime-mhs" */
3003506, /* "mime-mhs-bodies" */
3004505, /* "mime-mhs-headings" */
3005488, /* "mobileTelephoneNumber" */
3006136, /* "msCTLSign" */
3007135, /* "msCodeCom" */
3008134, /* "msCodeInd" */
3009138, /* "msEFS" */
3010171, /* "msExtReq" */
3011137, /* "msSGC" */
3012648, /* "msSmartcardLogin" */
3013649, /* "msUPN" */
3014481, /* "nSRecord" */
3015173, /* "name" */
3016666, /* "nameConstraints" */
3017369, /* "noCheck" */
3018403, /* "noRevAvail" */
301972, /* "nsBaseUrl" */
302076, /* "nsCaPolicyUrl" */
302174, /* "nsCaRevocationUrl" */
302258, /* "nsCertExt" */
302379, /* "nsCertSequence" */
302471, /* "nsCertType" */
302578, /* "nsComment" */
302659, /* "nsDataType" */
302775, /* "nsRenewalUrl" */
302873, /* "nsRevocationUrl" */
3029139, /* "nsSGC" */
303077, /* "nsSslServerName" */
3031681, /* "onBasis" */
3032491, /* "organizationalStatus" */
3033475, /* "otherMailbox" */
3034876, /* "owner" */
3035489, /* "pagerTelephoneNumber" */
3036374, /* "path" */
3037112, /* "pbeWithMD5AndCast5CBC" */
3038499, /* "personalSignature" */
3039487, /* "personalTitle" */
3040464, /* "photo" */
3041863, /* "physicalDeliveryOfficeName" */
3042437, /* "pilot" */
3043439, /* "pilotAttributeSyntax" */
3044438, /* "pilotAttributeType" */
3045479, /* "pilotAttributeType27" */
3046456, /* "pilotDSA" */
3047441, /* "pilotGroups" */
3048444, /* "pilotObject" */
3049440, /* "pilotObjectClass" */
3050455, /* "pilotOrganization" */
3051445, /* "pilotPerson" */
3052 2, /* "pkcs" */
3053186, /* "pkcs1" */
305427, /* "pkcs3" */
3055187, /* "pkcs5" */
305620, /* "pkcs7" */
305721, /* "pkcs7-data" */
305825, /* "pkcs7-digestData" */
305926, /* "pkcs7-encryptedData" */
306023, /* "pkcs7-envelopedData" */
306124, /* "pkcs7-signedAndEnvelopedData" */
306222, /* "pkcs7-signedData" */
3063151, /* "pkcs8ShroudedKeyBag" */
306447, /* "pkcs9" */
3065401, /* "policyConstraints" */
3066747, /* "policyMappings" */
3067862, /* "postOfficeBox" */
3068861, /* "postalAddress" */
3069661, /* "postalCode" */
3070683, /* "ppBasis" */
3071872, /* "preferredDeliveryMethod" */
3072873, /* "presentationAddress" */
3073816, /* "prf-gostr3411-94" */
3074406, /* "prime-field" */
3075409, /* "prime192v1" */
3076410, /* "prime192v2" */
3077411, /* "prime192v3" */
3078412, /* "prime239v1" */
3079413, /* "prime239v2" */
3080414, /* "prime239v3" */
3081415, /* "prime256v1" */
3082385, /* "private" */
308384, /* "privateKeyUsagePeriod" */
3084886, /* "protocolInformation" */
3085663, /* "proxyCertInfo" */
3086510, /* "pseudonym" */
3087435, /* "pss" */
3088286, /* "qcStatements" */
3089457, /* "qualityLabelledData" */
3090450, /* "rFC822localPart" */
3091870, /* "registeredAddress" */
3092400, /* "role" */
3093877, /* "roleOccupant" */
3094448, /* "room" */
3095463, /* "roomNumber" */
3096 6, /* "rsaEncryption" */
3097644, /* "rsaOAEPEncryptionSET" */
3098377, /* "rsaSignature" */
3099 1, /* "rsadsi" */
3100482, /* "sOARecord" */
3101155, /* "safeContentsBag" */
3102291, /* "sbgp-autonomousSysNum" */
3103290, /* "sbgp-ipAddrBlock" */
3104292, /* "sbgp-routerIdentifier" */
3105159, /* "sdsiCertificate" */
3106859, /* "searchGuide" */
3107704, /* "secp112r1" */
3108705, /* "secp112r2" */
3109706, /* "secp128r1" */
3110707, /* "secp128r2" */
3111708, /* "secp160k1" */
3112709, /* "secp160r1" */
3113710, /* "secp160r2" */
3114711, /* "secp192k1" */
3115712, /* "secp224k1" */
3116713, /* "secp224r1" */
3117714, /* "secp256k1" */
3118715, /* "secp384r1" */
3119716, /* "secp521r1" */
3120154, /* "secretBag" */
3121474, /* "secretary" */
3122717, /* "sect113r1" */
3123718, /* "sect113r2" */
3124719, /* "sect131r1" */
3125720, /* "sect131r2" */
3126721, /* "sect163k1" */
3127722, /* "sect163r1" */
3128723, /* "sect163r2" */
3129724, /* "sect193r1" */
3130725, /* "sect193r2" */
3131726, /* "sect233k1" */
3132727, /* "sect233r1" */
3133728, /* "sect239k1" */
3134729, /* "sect283k1" */
3135730, /* "sect283r1" */
3136731, /* "sect409k1" */
3137732, /* "sect409r1" */
3138733, /* "sect571k1" */
3139734, /* "sect571r1" */
3140386, /* "security" */
3141878, /* "seeAlso" */
3142394, /* "selected-attribute-types" */
3143105, /* "serialNumber" */
3144129, /* "serverAuth" */
3145371, /* "serviceLocator" */
3146625, /* "set-addPolicy" */
3147515, /* "set-attr" */
3148518, /* "set-brand" */
3149638, /* "set-brand-AmericanExpress" */
3150637, /* "set-brand-Diners" */
3151636, /* "set-brand-IATA-ATA" */
3152639, /* "set-brand-JCB" */
3153641, /* "set-brand-MasterCard" */
3154642, /* "set-brand-Novus" */
3155640, /* "set-brand-Visa" */
3156517, /* "set-certExt" */
3157513, /* "set-ctype" */
3158514, /* "set-msgExt" */
3159516, /* "set-policy" */
3160607, /* "set-policy-root" */
3161624, /* "set-rootKeyThumb" */
3162620, /* "setAttr-Cert" */
3163631, /* "setAttr-GenCryptgrm" */
3164623, /* "setAttr-IssCap" */
3165628, /* "setAttr-IssCap-CVM" */
3166630, /* "setAttr-IssCap-Sig" */
3167629, /* "setAttr-IssCap-T2" */
3168621, /* "setAttr-PGWYcap" */
3169635, /* "setAttr-SecDevSig" */
3170632, /* "setAttr-T2Enc" */
3171633, /* "setAttr-T2cleartxt" */
3172634, /* "setAttr-TokICCsig" */
3173627, /* "setAttr-Token-B0Prime" */
3174626, /* "setAttr-Token-EMV" */
3175622, /* "setAttr-TokenType" */
3176619, /* "setCext-IssuerCapabilities" */
3177615, /* "setCext-PGWYcapabilities" */
3178616, /* "setCext-TokenIdentifier" */
3179618, /* "setCext-TokenType" */
3180617, /* "setCext-Track2Data" */
3181611, /* "setCext-cCertRequired" */
3182609, /* "setCext-certType" */
3183608, /* "setCext-hashedRoot" */
3184610, /* "setCext-merchData" */
3185613, /* "setCext-setExt" */
3186614, /* "setCext-setQualf" */
3187612, /* "setCext-tunneling" */
3188540, /* "setct-AcqCardCodeMsg" */
3189576, /* "setct-AcqCardCodeMsgTBE" */
3190570, /* "setct-AuthReqTBE" */
3191534, /* "setct-AuthReqTBS" */
3192527, /* "setct-AuthResBaggage" */
3193571, /* "setct-AuthResTBE" */
3194572, /* "setct-AuthResTBEX" */
3195535, /* "setct-AuthResTBS" */
3196536, /* "setct-AuthResTBSX" */
3197528, /* "setct-AuthRevReqBaggage" */
3198577, /* "setct-AuthRevReqTBE" */
3199541, /* "setct-AuthRevReqTBS" */
3200529, /* "setct-AuthRevResBaggage" */
3201542, /* "setct-AuthRevResData" */
3202578, /* "setct-AuthRevResTBE" */
3203579, /* "setct-AuthRevResTBEB" */
3204543, /* "setct-AuthRevResTBS" */
3205573, /* "setct-AuthTokenTBE" */
3206537, /* "setct-AuthTokenTBS" */
3207600, /* "setct-BCIDistributionTBS" */
3208558, /* "setct-BatchAdminReqData" */
3209592, /* "setct-BatchAdminReqTBE" */
3210559, /* "setct-BatchAdminResData" */
3211593, /* "setct-BatchAdminResTBE" */
3212599, /* "setct-CRLNotificationResTBS" */
3213598, /* "setct-CRLNotificationTBS" */
3214580, /* "setct-CapReqTBE" */
3215581, /* "setct-CapReqTBEX" */
3216544, /* "setct-CapReqTBS" */
3217545, /* "setct-CapReqTBSX" */
3218546, /* "setct-CapResData" */
3219582, /* "setct-CapResTBE" */
3220583, /* "setct-CapRevReqTBE" */
3221584, /* "setct-CapRevReqTBEX" */
3222547, /* "setct-CapRevReqTBS" */
3223548, /* "setct-CapRevReqTBSX" */
3224549, /* "setct-CapRevResData" */
3225585, /* "setct-CapRevResTBE" */
3226538, /* "setct-CapTokenData" */
3227530, /* "setct-CapTokenSeq" */
3228574, /* "setct-CapTokenTBE" */
3229575, /* "setct-CapTokenTBEX" */
3230539, /* "setct-CapTokenTBS" */
3231560, /* "setct-CardCInitResTBS" */
3232566, /* "setct-CertInqReqTBS" */
3233563, /* "setct-CertReqData" */
3234595, /* "setct-CertReqTBE" */
3235596, /* "setct-CertReqTBEX" */
3236564, /* "setct-CertReqTBS" */
3237565, /* "setct-CertResData" */
3238597, /* "setct-CertResTBE" */
3239586, /* "setct-CredReqTBE" */
3240587, /* "setct-CredReqTBEX" */
3241550, /* "setct-CredReqTBS" */
3242551, /* "setct-CredReqTBSX" */
3243552, /* "setct-CredResData" */
3244588, /* "setct-CredResTBE" */
3245589, /* "setct-CredRevReqTBE" */
3246590, /* "setct-CredRevReqTBEX" */
3247553, /* "setct-CredRevReqTBS" */
3248554, /* "setct-CredRevReqTBSX" */
3249555, /* "setct-CredRevResData" */
3250591, /* "setct-CredRevResTBE" */
3251567, /* "setct-ErrorTBS" */
3252526, /* "setct-HODInput" */
3253561, /* "setct-MeAqCInitResTBS" */
3254522, /* "setct-OIData" */
3255519, /* "setct-PANData" */
3256521, /* "setct-PANOnly" */
3257520, /* "setct-PANToken" */
3258556, /* "setct-PCertReqData" */
3259557, /* "setct-PCertResTBS" */
3260523, /* "setct-PI" */
3261532, /* "setct-PI-TBS" */
3262524, /* "setct-PIData" */
3263525, /* "setct-PIDataUnsigned" */
3264568, /* "setct-PIDualSignedTBE" */
3265569, /* "setct-PIUnsignedTBE" */
3266531, /* "setct-PInitResData" */
3267533, /* "setct-PResData" */
3268594, /* "setct-RegFormReqTBE" */
3269562, /* "setct-RegFormResTBS" */
3270606, /* "setext-cv" */
3271601, /* "setext-genCrypt" */
3272602, /* "setext-miAuth" */
3273604, /* "setext-pinAny" */
3274603, /* "setext-pinSecure" */
3275605, /* "setext-track2" */
327652, /* "signingTime" */
3277454, /* "simpleSecurityObject" */
3278496, /* "singleLevelQuality" */
3279387, /* "snmpv2" */
3280660, /* "street" */
328185, /* "subjectAltName" */
3282769, /* "subjectDirectoryAttributes" */
3283398, /* "subjectInfoAccess" */
328482, /* "subjectKeyIdentifier" */
3285498, /* "subtreeMaximumQuality" */
3286497, /* "subtreeMinimumQuality" */
3287890, /* "supportedAlgorithms" */
3288874, /* "supportedApplicationContext" */
3289402, /* "targetInformation" */
3290864, /* "telephoneNumber" */
3291866, /* "teletexTerminalIdentifier" */
3292865, /* "telexNumber" */
3293459, /* "textEncodedORAddress" */
3294293, /* "textNotice" */
3295133, /* "timeStamping" */
3296106, /* "title" */
3297682, /* "tpBasis" */
3298375, /* "trustRoot" */
3299436, /* "ucl" */
3300888, /* "uniqueMember" */
330155, /* "unstructuredAddress" */
330249, /* "unstructuredName" */
3303880, /* "userCertificate" */
3304465, /* "userClass" */
3305879, /* "userPassword" */
3306373, /* "valid" */
3307678, /* "wap" */
3308679, /* "wap-wsg" */
3309735, /* "wap-wsg-idm-ecid-wtls1" */
3310743, /* "wap-wsg-idm-ecid-wtls10" */
3311744, /* "wap-wsg-idm-ecid-wtls11" */
3312745, /* "wap-wsg-idm-ecid-wtls12" */
3313736, /* "wap-wsg-idm-ecid-wtls3" */
3314737, /* "wap-wsg-idm-ecid-wtls4" */
3315738, /* "wap-wsg-idm-ecid-wtls5" */
3316739, /* "wap-wsg-idm-ecid-wtls6" */
3317740, /* "wap-wsg-idm-ecid-wtls7" */
3318741, /* "wap-wsg-idm-ecid-wtls8" */
3319742, /* "wap-wsg-idm-ecid-wtls9" */
3320804, /* "whirlpool" */
3321868, /* "x121Address" */
3322503, /* "x500UniqueIdentifier" */
3323158, /* "x509Certificate" */
3324160, /* "x509Crl" */
3325};
3326
3327static const unsigned int ln_objs[NUM_LN]={
3328363, /* "AD Time Stamping" */
3329405, /* "ANSI X9.62" */
3330368, /* "Acceptable OCSP Responses" */
3331910, /* "Any Extended Key Usage" */
3332664, /* "Any language" */
3333177, /* "Authority Information Access" */
3334365, /* "Basic OCSP Response" */
3335285, /* "Biometric Info" */
3336179, /* "CA Issuers" */
3337785, /* "CA Repository" */
3338131, /* "Code Signing" */
3339783, /* "Diffie-Hellman based MAC" */
3340382, /* "Directory" */
3341392, /* "Domain" */
3342132, /* "E-mail Protection" */
3343389, /* "Enterprises" */
3344384, /* "Experimental" */
3345372, /* "Extended OCSP Status" */
3346172, /* "Extension Request" */
3347813, /* "GOST 28147-89" */
3348849, /* "GOST 28147-89 Cryptocom ParamSet" */
3349815, /* "GOST 28147-89 MAC" */
3350851, /* "GOST 34.10-2001 Cryptocom" */
3351850, /* "GOST 34.10-94 Cryptocom" */
3352811, /* "GOST R 34.10-2001" */
3353817, /* "GOST R 34.10-2001 DH" */
3354812, /* "GOST R 34.10-94" */
3355818, /* "GOST R 34.10-94 DH" */
3356809, /* "GOST R 34.11-94" */
3357816, /* "GOST R 34.11-94 PRF" */
3358807, /* "GOST R 34.11-94 with GOST R 34.10-2001" */
3359853, /* "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom" */
3360808, /* "GOST R 34.11-94 with GOST R 34.10-94" */
3361852, /* "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom" */
3362854, /* "GOST R 3410-2001 Parameter Set Cryptocom" */
3363810, /* "HMAC GOST 34.11-94" */
3364432, /* "Hold Instruction Call Issuer" */
3365430, /* "Hold Instruction Code" */
3366431, /* "Hold Instruction None" */
3367433, /* "Hold Instruction Reject" */
3368634, /* "ICC or token signature" */
3369294, /* "IPSec End System" */
3370295, /* "IPSec Tunnel" */
3371296, /* "IPSec User" */
3372182, /* "ISO Member Body" */
3373183, /* "ISO US Member Body" */
3374667, /* "Independent" */
3375665, /* "Inherit all" */
3376647, /* "International Organizations" */
3377142, /* "Invalidity Date" */
3378504, /* "MIME MHS" */
3379388, /* "Mail" */
3380383, /* "Management" */
3381417, /* "Microsoft CSP Name" */
3382135, /* "Microsoft Commercial Code Signing" */
3383138, /* "Microsoft Encrypted File System" */
3384171, /* "Microsoft Extension Request" */
3385134, /* "Microsoft Individual Code Signing" */
3386856, /* "Microsoft Local Key set" */
3387137, /* "Microsoft Server Gated Crypto" */
3388648, /* "Microsoft Smartcardlogin" */
3389136, /* "Microsoft Trust List Signing" */
3390649, /* "Microsoft Universal Principal Name" */
3391393, /* "NULL" */
3392404, /* "NULL" */
339372, /* "Netscape Base Url" */
339476, /* "Netscape CA Policy Url" */
339574, /* "Netscape CA Revocation Url" */
339671, /* "Netscape Cert Type" */
339758, /* "Netscape Certificate Extension" */
339879, /* "Netscape Certificate Sequence" */
339978, /* "Netscape Comment" */
340057, /* "Netscape Communications Corp." */
340159, /* "Netscape Data Type" */
340275, /* "Netscape Renewal Url" */
340373, /* "Netscape Revocation Url" */
340477, /* "Netscape SSL Server Name" */
3405139, /* "Netscape Server Gated Crypto" */
3406178, /* "OCSP" */
3407370, /* "OCSP Archive Cutoff" */
3408367, /* "OCSP CRL ID" */
3409369, /* "OCSP No Check" */
3410366, /* "OCSP Nonce" */
3411371, /* "OCSP Service Locator" */
3412180, /* "OCSP Signing" */
3413161, /* "PBES2" */
341469, /* "PBKDF2" */
3415162, /* "PBMAC1" */
3416127, /* "PKIX" */
3417858, /* "Permanent Identifier" */
3418164, /* "Policy Qualifier CPS" */
3419165, /* "Policy Qualifier User Notice" */
3420385, /* "Private" */
3421663, /* "Proxy Certificate Information" */
3422 1, /* "RSA Data Security, Inc." */
3423 2, /* "RSA Data Security, Inc. PKCS" */
3424188, /* "S/MIME" */
3425167, /* "S/MIME Capabilities" */
3426387, /* "SNMPv2" */
3427512, /* "Secure Electronic Transactions" */
3428386, /* "Security" */
3429394, /* "Selected Attribute Types" */
3430143, /* "Strong Extranet ID" */
3431398, /* "Subject Information Access" */
3432130, /* "TLS Web Client Authentication" */
3433129, /* "TLS Web Server Authentication" */
3434133, /* "Time Stamping" */
3435375, /* "Trust Root" */
343612, /* "X509" */
3437402, /* "X509v3 AC Targeting" */
3438746, /* "X509v3 Any Policy" */
343990, /* "X509v3 Authority Key Identifier" */
344087, /* "X509v3 Basic Constraints" */
3441103, /* "X509v3 CRL Distribution Points" */
344288, /* "X509v3 CRL Number" */
3443141, /* "X509v3 CRL Reason Code" */
3444771, /* "X509v3 Certificate Issuer" */
344589, /* "X509v3 Certificate Policies" */
3446140, /* "X509v3 Delta CRL Indicator" */
3447126, /* "X509v3 Extended Key Usage" */
3448857, /* "X509v3 Freshest CRL" */
3449748, /* "X509v3 Inhibit Any Policy" */
345086, /* "X509v3 Issuer Alternative Name" */
3451770, /* "X509v3 Issuing Distrubution Point" */
345283, /* "X509v3 Key Usage" */
3453666, /* "X509v3 Name Constraints" */
3454403, /* "X509v3 No Revocation Available" */
3455401, /* "X509v3 Policy Constraints" */
3456747, /* "X509v3 Policy Mappings" */
345784, /* "X509v3 Private Key Usage Period" */
345885, /* "X509v3 Subject Alternative Name" */
3459769, /* "X509v3 Subject Directory Attributes" */
346082, /* "X509v3 Subject Key Identifier" */
3461184, /* "X9.57" */
3462185, /* "X9.57 CM ?" */
3463478, /* "aRecord" */
3464289, /* "aaControls" */
3465287, /* "ac-auditEntity" */
3466397, /* "ac-proxying" */
3467288, /* "ac-targeting" */
3468446, /* "account" */
3469364, /* "ad dvcs" */
3470606, /* "additional verification" */
3471419, /* "aes-128-cbc" */
3472916, /* "aes-128-cbc-hmac-sha1" */
3473896, /* "aes-128-ccm" */
3474421, /* "aes-128-cfb" */
3475650, /* "aes-128-cfb1" */
3476653, /* "aes-128-cfb8" */
3477904, /* "aes-128-ctr" */
3478418, /* "aes-128-ecb" */
3479895, /* "aes-128-gcm" */
3480420, /* "aes-128-ofb" */
3481913, /* "aes-128-xts" */
3482423, /* "aes-192-cbc" */
3483917, /* "aes-192-cbc-hmac-sha1" */
3484899, /* "aes-192-ccm" */
3485425, /* "aes-192-cfb" */
3486651, /* "aes-192-cfb1" */
3487654, /* "aes-192-cfb8" */
3488905, /* "aes-192-ctr" */
3489422, /* "aes-192-ecb" */
3490898, /* "aes-192-gcm" */
3491424, /* "aes-192-ofb" */
3492427, /* "aes-256-cbc" */
3493918, /* "aes-256-cbc-hmac-sha1" */
3494902, /* "aes-256-ccm" */
3495429, /* "aes-256-cfb" */
3496652, /* "aes-256-cfb1" */
3497655, /* "aes-256-cfb8" */
3498906, /* "aes-256-ctr" */
3499426, /* "aes-256-ecb" */
3500901, /* "aes-256-gcm" */
3501428, /* "aes-256-ofb" */
3502914, /* "aes-256-xts" */
3503376, /* "algorithm" */
3504484, /* "associatedDomain" */
3505485, /* "associatedName" */
3506501, /* "audio" */
3507882, /* "authorityRevocationList" */
350891, /* "bf-cbc" */
350993, /* "bf-cfb" */
351092, /* "bf-ecb" */
351194, /* "bf-ofb" */
3512494, /* "buildingName" */
3513860, /* "businessCategory" */
3514691, /* "c2onb191v4" */
3515692, /* "c2onb191v5" */
3516697, /* "c2onb239v4" */
3517698, /* "c2onb239v5" */
3518684, /* "c2pnb163v1" */
3519685, /* "c2pnb163v2" */
3520686, /* "c2pnb163v3" */
3521687, /* "c2pnb176v1" */
3522693, /* "c2pnb208w1" */
3523699, /* "c2pnb272w1" */
3524700, /* "c2pnb304w1" */
3525702, /* "c2pnb368w1" */
3526688, /* "c2tnb191v1" */
3527689, /* "c2tnb191v2" */
3528690, /* "c2tnb191v3" */
3529694, /* "c2tnb239v1" */
3530695, /* "c2tnb239v2" */
3531696, /* "c2tnb239v3" */
3532701, /* "c2tnb359v1" */
3533703, /* "c2tnb431r1" */
3534881, /* "cACertificate" */
3535483, /* "cNAMERecord" */
3536751, /* "camellia-128-cbc" */
3537757, /* "camellia-128-cfb" */
3538760, /* "camellia-128-cfb1" */
3539763, /* "camellia-128-cfb8" */
3540754, /* "camellia-128-ecb" */
3541766, /* "camellia-128-ofb" */
3542752, /* "camellia-192-cbc" */
3543758, /* "camellia-192-cfb" */
3544761, /* "camellia-192-cfb1" */
3545764, /* "camellia-192-cfb8" */
3546755, /* "camellia-192-ecb" */
3547767, /* "camellia-192-ofb" */
3548753, /* "camellia-256-cbc" */
3549759, /* "camellia-256-cfb" */
3550762, /* "camellia-256-cfb1" */
3551765, /* "camellia-256-cfb8" */
3552756, /* "camellia-256-ecb" */
3553768, /* "camellia-256-ofb" */
3554443, /* "caseIgnoreIA5StringSyntax" */
3555108, /* "cast5-cbc" */
3556110, /* "cast5-cfb" */
3557109, /* "cast5-ecb" */
3558111, /* "cast5-ofb" */
3559152, /* "certBag" */
3560677, /* "certicom-arc" */
3561517, /* "certificate extensions" */
3562883, /* "certificateRevocationList" */
356354, /* "challengePassword" */
3564407, /* "characteristic-two-field" */
3565395, /* "clearance" */
3566633, /* "cleartext track 2" */
3567894, /* "cmac" */
356813, /* "commonName" */
3569513, /* "content types" */
357050, /* "contentType" */
357153, /* "countersignature" */
357214, /* "countryName" */
3573153, /* "crlBag" */
3574884, /* "crossCertificatePair" */
3575806, /* "cryptocom" */
3576805, /* "cryptopro" */
3577500, /* "dITRedirect" */
3578451, /* "dNSDomain" */
3579495, /* "dSAQuality" */
3580434, /* "data" */
3581390, /* "dcObject" */
3582891, /* "deltaRevocationList" */
358331, /* "des-cbc" */
3584643, /* "des-cdmf" */
358530, /* "des-cfb" */
3586656, /* "des-cfb1" */
3587657, /* "des-cfb8" */
358829, /* "des-ecb" */
358932, /* "des-ede" */
359043, /* "des-ede-cbc" */
359160, /* "des-ede-cfb" */
359262, /* "des-ede-ofb" */
359333, /* "des-ede3" */
359444, /* "des-ede3-cbc" */
359561, /* "des-ede3-cfb" */
3596658, /* "des-ede3-cfb1" */
3597659, /* "des-ede3-cfb8" */
359863, /* "des-ede3-ofb" */
359945, /* "des-ofb" */
3600107, /* "description" */
3601871, /* "destinationIndicator" */
360280, /* "desx-cbc" */
360328, /* "dhKeyAgreement" */
360411, /* "directory services (X.500)" */
3605378, /* "directory services - algorithms" */
3606887, /* "distinguishedName" */
3607892, /* "dmdName" */
3608174, /* "dnQualifier" */
3609447, /* "document" */
3610471, /* "documentAuthor" */
3611468, /* "documentIdentifier" */
3612472, /* "documentLocation" */
3613502, /* "documentPublisher" */
3614449, /* "documentSeries" */
3615469, /* "documentTitle" */
3616470, /* "documentVersion" */
3617380, /* "dod" */
3618391, /* "domainComponent" */
3619452, /* "domainRelatedObject" */
3620116, /* "dsaEncryption" */
362167, /* "dsaEncryption-old" */
362266, /* "dsaWithSHA" */
3623113, /* "dsaWithSHA1" */
362470, /* "dsaWithSHA1-old" */
3625802, /* "dsa_with_SHA224" */
3626803, /* "dsa_with_SHA256" */
3627297, /* "dvcs" */
3628791, /* "ecdsa-with-Recommended" */
3629416, /* "ecdsa-with-SHA1" */
3630793, /* "ecdsa-with-SHA224" */
3631794, /* "ecdsa-with-SHA256" */
3632795, /* "ecdsa-with-SHA384" */
3633796, /* "ecdsa-with-SHA512" */
3634792, /* "ecdsa-with-Specified" */
363548, /* "emailAddress" */
3636632, /* "encrypted track 2" */
3637885, /* "enhancedSearchGuide" */
363856, /* "extendedCertificateAttributes" */
3639867, /* "facsimileTelephoneNumber" */
3640462, /* "favouriteDrink" */
3641453, /* "friendlyCountry" */
3642490, /* "friendlyCountryName" */
3643156, /* "friendlyName" */
3644631, /* "generate cryptogram" */
3645509, /* "generationQualifier" */
3646601, /* "generic cryptogram" */
364799, /* "givenName" */
3648814, /* "gost89-cnt" */
3649855, /* "hmac" */
3650780, /* "hmac-md5" */
3651781, /* "hmac-sha1" */
3652797, /* "hmacWithMD5" */
3653163, /* "hmacWithSHA1" */
3654798, /* "hmacWithSHA224" */
3655799, /* "hmacWithSHA256" */
3656800, /* "hmacWithSHA384" */
3657801, /* "hmacWithSHA512" */
3658486, /* "homePostalAddress" */
3659473, /* "homeTelephoneNumber" */
3660466, /* "host" */
3661889, /* "houseIdentifier" */
3662442, /* "iA5StringSyntax" */
3663381, /* "iana" */
3664824, /* "id-Gost28147-89-CryptoPro-A-ParamSet" */
3665825, /* "id-Gost28147-89-CryptoPro-B-ParamSet" */
3666826, /* "id-Gost28147-89-CryptoPro-C-ParamSet" */
3667827, /* "id-Gost28147-89-CryptoPro-D-ParamSet" */
3668819, /* "id-Gost28147-89-CryptoPro-KeyMeshing" */
3669829, /* "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet" */
3670828, /* "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet" */
3671830, /* "id-Gost28147-89-CryptoPro-RIC-1-ParamSet" */
3672820, /* "id-Gost28147-89-None-KeyMeshing" */
3673823, /* "id-Gost28147-89-TestParamSet" */
3674840, /* "id-GostR3410-2001-CryptoPro-A-ParamSet" */
3675841, /* "id-GostR3410-2001-CryptoPro-B-ParamSet" */
3676842, /* "id-GostR3410-2001-CryptoPro-C-ParamSet" */
3677843, /* "id-GostR3410-2001-CryptoPro-XchA-ParamSet" */
3678844, /* "id-GostR3410-2001-CryptoPro-XchB-ParamSet" */
3679839, /* "id-GostR3410-2001-TestParamSet" */
3680832, /* "id-GostR3410-94-CryptoPro-A-ParamSet" */
3681833, /* "id-GostR3410-94-CryptoPro-B-ParamSet" */
3682834, /* "id-GostR3410-94-CryptoPro-C-ParamSet" */
3683835, /* "id-GostR3410-94-CryptoPro-D-ParamSet" */
3684836, /* "id-GostR3410-94-CryptoPro-XchA-ParamSet" */
3685837, /* "id-GostR3410-94-CryptoPro-XchB-ParamSet" */
3686838, /* "id-GostR3410-94-CryptoPro-XchC-ParamSet" */
3687831, /* "id-GostR3410-94-TestParamSet" */
3688845, /* "id-GostR3410-94-a" */
3689846, /* "id-GostR3410-94-aBis" */
3690847, /* "id-GostR3410-94-b" */
3691848, /* "id-GostR3410-94-bBis" */
3692822, /* "id-GostR3411-94-CryptoProParamSet" */
3693821, /* "id-GostR3411-94-TestParamSet" */
3694266, /* "id-aca" */
3695355, /* "id-aca-accessIdentity" */
3696354, /* "id-aca-authenticationInfo" */
3697356, /* "id-aca-chargingIdentity" */
3698399, /* "id-aca-encAttrs" */
3699357, /* "id-aca-group" */
3700358, /* "id-aca-role" */
3701176, /* "id-ad" */
3702788, /* "id-aes128-wrap" */
3703897, /* "id-aes128-wrap-pad" */
3704789, /* "id-aes192-wrap" */
3705900, /* "id-aes192-wrap-pad" */
3706790, /* "id-aes256-wrap" */
3707903, /* "id-aes256-wrap-pad" */
3708262, /* "id-alg" */
3709893, /* "id-alg-PWRI-KEK" */
3710323, /* "id-alg-des40" */
3711326, /* "id-alg-dh-pop" */
3712325, /* "id-alg-dh-sig-hmac-sha1" */
3713324, /* "id-alg-noSignature" */
3714907, /* "id-camellia128-wrap" */
3715908, /* "id-camellia192-wrap" */
3716909, /* "id-camellia256-wrap" */
3717268, /* "id-cct" */
3718361, /* "id-cct-PKIData" */
3719362, /* "id-cct-PKIResponse" */
3720360, /* "id-cct-crs" */
372181, /* "id-ce" */
3722680, /* "id-characteristic-two-basis" */
3723263, /* "id-cmc" */
3724334, /* "id-cmc-addExtensions" */
3725346, /* "id-cmc-confirmCertAcceptance" */
3726330, /* "id-cmc-dataReturn" */
3727336, /* "id-cmc-decryptedPOP" */
3728335, /* "id-cmc-encryptedPOP" */
3729339, /* "id-cmc-getCRL" */
3730338, /* "id-cmc-getCert" */
3731328, /* "id-cmc-identification" */
3732329, /* "id-cmc-identityProof" */
3733337, /* "id-cmc-lraPOPWitness" */
3734344, /* "id-cmc-popLinkRandom" */
3735345, /* "id-cmc-popLinkWitness" */
3736343, /* "id-cmc-queryPending" */
3737333, /* "id-cmc-recipientNonce" */
3738341, /* "id-cmc-regInfo" */
3739342, /* "id-cmc-responseInfo" */
3740340, /* "id-cmc-revokeRequest" */
3741332, /* "id-cmc-senderNonce" */
3742327, /* "id-cmc-statusInfo" */
3743331, /* "id-cmc-transactionId" */
3744787, /* "id-ct-asciiTextWithCRLF" */
3745408, /* "id-ecPublicKey" */
3746508, /* "id-hex-multipart-message" */
3747507, /* "id-hex-partial-message" */
3748260, /* "id-it" */
3749302, /* "id-it-caKeyUpdateInfo" */
3750298, /* "id-it-caProtEncCert" */
3751311, /* "id-it-confirmWaitTime" */
3752303, /* "id-it-currentCRL" */
3753300, /* "id-it-encKeyPairTypes" */
3754310, /* "id-it-implicitConfirm" */
3755308, /* "id-it-keyPairParamRep" */
3756307, /* "id-it-keyPairParamReq" */
3757312, /* "id-it-origPKIMessage" */
3758301, /* "id-it-preferredSymmAlg" */
3759309, /* "id-it-revPassphrase" */
3760299, /* "id-it-signKeyPairTypes" */
3761305, /* "id-it-subscriptionRequest" */
3762306, /* "id-it-subscriptionResponse" */
3763784, /* "id-it-suppLangTags" */
3764304, /* "id-it-unsupportedOIDs" */
3765128, /* "id-kp" */
3766280, /* "id-mod-attribute-cert" */
3767274, /* "id-mod-cmc" */
3768277, /* "id-mod-cmp" */
3769284, /* "id-mod-cmp2000" */
3770273, /* "id-mod-crmf" */
3771283, /* "id-mod-dvcs" */
3772275, /* "id-mod-kea-profile-88" */
3773276, /* "id-mod-kea-profile-93" */
3774282, /* "id-mod-ocsp" */
3775278, /* "id-mod-qualified-cert-88" */
3776279, /* "id-mod-qualified-cert-93" */
3777281, /* "id-mod-timestamp-protocol" */
3778264, /* "id-on" */
3779347, /* "id-on-personalData" */
3780265, /* "id-pda" */
3781352, /* "id-pda-countryOfCitizenship" */
3782353, /* "id-pda-countryOfResidence" */
3783348, /* "id-pda-dateOfBirth" */
3784351, /* "id-pda-gender" */
3785349, /* "id-pda-placeOfBirth" */
3786175, /* "id-pe" */
3787261, /* "id-pkip" */
3788258, /* "id-pkix-mod" */
3789269, /* "id-pkix1-explicit-88" */
3790271, /* "id-pkix1-explicit-93" */
3791270, /* "id-pkix1-implicit-88" */
3792272, /* "id-pkix1-implicit-93" */
3793662, /* "id-ppl" */
3794267, /* "id-qcs" */
3795359, /* "id-qcs-pkixQCSyntax-v1" */
3796259, /* "id-qt" */
3797313, /* "id-regCtrl" */
3798316, /* "id-regCtrl-authenticator" */
3799319, /* "id-regCtrl-oldCertID" */
3800318, /* "id-regCtrl-pkiArchiveOptions" */
3801317, /* "id-regCtrl-pkiPublicationInfo" */
3802320, /* "id-regCtrl-protocolEncrKey" */
3803315, /* "id-regCtrl-regToken" */
3804314, /* "id-regInfo" */
3805322, /* "id-regInfo-certReq" */
3806321, /* "id-regInfo-utf8Pairs" */
3807191, /* "id-smime-aa" */
3808215, /* "id-smime-aa-contentHint" */
3809218, /* "id-smime-aa-contentIdentifier" */
3810221, /* "id-smime-aa-contentReference" */
3811240, /* "id-smime-aa-dvcs-dvc" */
3812217, /* "id-smime-aa-encapContentType" */
3813222, /* "id-smime-aa-encrypKeyPref" */
3814220, /* "id-smime-aa-equivalentLabels" */
3815232, /* "id-smime-aa-ets-CertificateRefs" */
3816233, /* "id-smime-aa-ets-RevocationRefs" */
3817238, /* "id-smime-aa-ets-archiveTimeStamp" */
3818237, /* "id-smime-aa-ets-certCRLTimestamp" */
3819234, /* "id-smime-aa-ets-certValues" */
3820227, /* "id-smime-aa-ets-commitmentType" */
3821231, /* "id-smime-aa-ets-contentTimestamp" */
3822236, /* "id-smime-aa-ets-escTimeStamp" */
3823230, /* "id-smime-aa-ets-otherSigCert" */
3824235, /* "id-smime-aa-ets-revocationValues" */
3825226, /* "id-smime-aa-ets-sigPolicyId" */
3826229, /* "id-smime-aa-ets-signerAttr" */
3827228, /* "id-smime-aa-ets-signerLocation" */
3828219, /* "id-smime-aa-macValue" */
3829214, /* "id-smime-aa-mlExpandHistory" */
3830216, /* "id-smime-aa-msgSigDigest" */
3831212, /* "id-smime-aa-receiptRequest" */
3832213, /* "id-smime-aa-securityLabel" */
3833239, /* "id-smime-aa-signatureType" */
3834223, /* "id-smime-aa-signingCertificate" */
3835224, /* "id-smime-aa-smimeEncryptCerts" */
3836225, /* "id-smime-aa-timeStampToken" */
3837192, /* "id-smime-alg" */
3838243, /* "id-smime-alg-3DESwrap" */
3839246, /* "id-smime-alg-CMS3DESwrap" */
3840247, /* "id-smime-alg-CMSRC2wrap" */
3841245, /* "id-smime-alg-ESDH" */
3842241, /* "id-smime-alg-ESDHwith3DES" */
3843242, /* "id-smime-alg-ESDHwithRC2" */
3844244, /* "id-smime-alg-RC2wrap" */
3845193, /* "id-smime-cd" */
3846248, /* "id-smime-cd-ldap" */
3847190, /* "id-smime-ct" */
3848210, /* "id-smime-ct-DVCSRequestData" */
3849211, /* "id-smime-ct-DVCSResponseData" */
3850208, /* "id-smime-ct-TDTInfo" */
3851207, /* "id-smime-ct-TSTInfo" */
3852205, /* "id-smime-ct-authData" */
3853786, /* "id-smime-ct-compressedData" */
3854209, /* "id-smime-ct-contentInfo" */
3855206, /* "id-smime-ct-publishCert" */
3856204, /* "id-smime-ct-receipt" */
3857195, /* "id-smime-cti" */
3858255, /* "id-smime-cti-ets-proofOfApproval" */
3859256, /* "id-smime-cti-ets-proofOfCreation" */
3860253, /* "id-smime-cti-ets-proofOfDelivery" */
3861251, /* "id-smime-cti-ets-proofOfOrigin" */
3862252, /* "id-smime-cti-ets-proofOfReceipt" */
3863254, /* "id-smime-cti-ets-proofOfSender" */
3864189, /* "id-smime-mod" */
3865196, /* "id-smime-mod-cms" */
3866197, /* "id-smime-mod-ess" */
3867202, /* "id-smime-mod-ets-eSigPolicy-88" */
3868203, /* "id-smime-mod-ets-eSigPolicy-97" */
3869200, /* "id-smime-mod-ets-eSignature-88" */
3870201, /* "id-smime-mod-ets-eSignature-97" */
3871199, /* "id-smime-mod-msg-v3" */
3872198, /* "id-smime-mod-oid" */
3873194, /* "id-smime-spq" */
3874250, /* "id-smime-spq-ets-sqt-unotice" */
3875249, /* "id-smime-spq-ets-sqt-uri" */
387634, /* "idea-cbc" */
387735, /* "idea-cfb" */
387836, /* "idea-ecb" */
387946, /* "idea-ofb" */
3880676, /* "identified-organization" */
3881461, /* "info" */
3882101, /* "initials" */
3883869, /* "internationaliSDNNumber" */
3884749, /* "ipsec3" */
3885750, /* "ipsec4" */
3886181, /* "iso" */
3887623, /* "issuer capabilities" */
3888645, /* "itu-t" */
3889492, /* "janetMailbox" */
3890646, /* "joint-iso-itu-t" */
3891150, /* "keyBag" */
3892773, /* "kisa" */
3893477, /* "lastModifiedBy" */
3894476, /* "lastModifiedTime" */
3895157, /* "localKeyID" */
389615, /* "localityName" */
3897480, /* "mXRecord" */
3898493, /* "mailPreferenceOption" */
3899467, /* "manager" */
3900 3, /* "md2" */
3901 7, /* "md2WithRSAEncryption" */
3902257, /* "md4" */
3903396, /* "md4WithRSAEncryption" */
3904 4, /* "md5" */
3905114, /* "md5-sha1" */
3906104, /* "md5WithRSA" */
3907 8, /* "md5WithRSAEncryption" */
390895, /* "mdc2" */
390996, /* "mdc2WithRSA" */
3910875, /* "member" */
3911602, /* "merchant initiated auth" */
3912514, /* "message extensions" */
391351, /* "messageDigest" */
3914911, /* "mgf1" */
3915506, /* "mime-mhs-bodies" */
3916505, /* "mime-mhs-headings" */
3917488, /* "mobileTelephoneNumber" */
3918481, /* "nSRecord" */
3919173, /* "name" */
3920681, /* "onBasis" */
3921379, /* "org" */
392217, /* "organizationName" */
3923491, /* "organizationalStatus" */
392418, /* "organizationalUnitName" */
3925475, /* "otherMailbox" */
3926876, /* "owner" */
3927489, /* "pagerTelephoneNumber" */
3928782, /* "password based MAC" */
3929374, /* "path" */
3930621, /* "payment gateway capabilities" */
3931 9, /* "pbeWithMD2AndDES-CBC" */
3932168, /* "pbeWithMD2AndRC2-CBC" */
3933112, /* "pbeWithMD5AndCast5CBC" */
393410, /* "pbeWithMD5AndDES-CBC" */
3935169, /* "pbeWithMD5AndRC2-CBC" */
3936148, /* "pbeWithSHA1And128BitRC2-CBC" */
3937144, /* "pbeWithSHA1And128BitRC4" */
3938147, /* "pbeWithSHA1And2-KeyTripleDES-CBC" */
3939146, /* "pbeWithSHA1And3-KeyTripleDES-CBC" */
3940149, /* "pbeWithSHA1And40BitRC2-CBC" */
3941145, /* "pbeWithSHA1And40BitRC4" */
3942170, /* "pbeWithSHA1AndDES-CBC" */
394368, /* "pbeWithSHA1AndRC2-CBC" */
3944499, /* "personalSignature" */
3945487, /* "personalTitle" */
3946464, /* "photo" */
3947863, /* "physicalDeliveryOfficeName" */
3948437, /* "pilot" */
3949439, /* "pilotAttributeSyntax" */
3950438, /* "pilotAttributeType" */
3951479, /* "pilotAttributeType27" */
3952456, /* "pilotDSA" */
3953441, /* "pilotGroups" */
3954444, /* "pilotObject" */
3955440, /* "pilotObjectClass" */
3956455, /* "pilotOrganization" */
3957445, /* "pilotPerson" */
3958186, /* "pkcs1" */
395927, /* "pkcs3" */
3960187, /* "pkcs5" */
396120, /* "pkcs7" */
396221, /* "pkcs7-data" */
396325, /* "pkcs7-digestData" */
396426, /* "pkcs7-encryptedData" */
396523, /* "pkcs7-envelopedData" */
396624, /* "pkcs7-signedAndEnvelopedData" */
396722, /* "pkcs7-signedData" */
3968151, /* "pkcs8ShroudedKeyBag" */
396947, /* "pkcs9" */
3970862, /* "postOfficeBox" */
3971861, /* "postalAddress" */
3972661, /* "postalCode" */
3973683, /* "ppBasis" */
3974872, /* "preferredDeliveryMethod" */
3975873, /* "presentationAddress" */
3976406, /* "prime-field" */
3977409, /* "prime192v1" */
3978410, /* "prime192v2" */
3979411, /* "prime192v3" */
3980412, /* "prime239v1" */
3981413, /* "prime239v2" */
3982414, /* "prime239v3" */
3983415, /* "prime256v1" */
3984886, /* "protocolInformation" */
3985510, /* "pseudonym" */
3986435, /* "pss" */
3987286, /* "qcStatements" */
3988457, /* "qualityLabelledData" */
3989450, /* "rFC822localPart" */
399098, /* "rc2-40-cbc" */
3991166, /* "rc2-64-cbc" */
399237, /* "rc2-cbc" */
399339, /* "rc2-cfb" */
399438, /* "rc2-ecb" */
399540, /* "rc2-ofb" */
3996 5, /* "rc4" */
399797, /* "rc4-40" */
3998915, /* "rc4-hmac-md5" */
3999120, /* "rc5-cbc" */
4000122, /* "rc5-cfb" */
4001121, /* "rc5-ecb" */
4002123, /* "rc5-ofb" */
4003870, /* "registeredAddress" */
4004460, /* "rfc822Mailbox" */
4005117, /* "ripemd160" */
4006119, /* "ripemd160WithRSA" */
4007400, /* "role" */
4008877, /* "roleOccupant" */
4009448, /* "room" */
4010463, /* "roomNumber" */
401119, /* "rsa" */
4012 6, /* "rsaEncryption" */
4013644, /* "rsaOAEPEncryptionSET" */
4014377, /* "rsaSignature" */
4015919, /* "rsaesOaep" */
4016912, /* "rsassaPss" */
4017124, /* "run length compression" */
4018482, /* "sOARecord" */
4019155, /* "safeContentsBag" */
4020291, /* "sbgp-autonomousSysNum" */
4021290, /* "sbgp-ipAddrBlock" */
4022292, /* "sbgp-routerIdentifier" */
4023159, /* "sdsiCertificate" */
4024859, /* "searchGuide" */
4025704, /* "secp112r1" */
4026705, /* "secp112r2" */
4027706, /* "secp128r1" */
4028707, /* "secp128r2" */
4029708, /* "secp160k1" */
4030709, /* "secp160r1" */
4031710, /* "secp160r2" */
4032711, /* "secp192k1" */
4033712, /* "secp224k1" */
4034713, /* "secp224r1" */
4035714, /* "secp256k1" */
4036715, /* "secp384r1" */
4037716, /* "secp521r1" */
4038154, /* "secretBag" */
4039474, /* "secretary" */
4040717, /* "sect113r1" */
4041718, /* "sect113r2" */
4042719, /* "sect131r1" */
4043720, /* "sect131r2" */
4044721, /* "sect163k1" */
4045722, /* "sect163r1" */
4046723, /* "sect163r2" */
4047724, /* "sect193r1" */
4048725, /* "sect193r2" */
4049726, /* "sect233k1" */
4050727, /* "sect233r1" */
4051728, /* "sect239k1" */
4052729, /* "sect283k1" */
4053730, /* "sect283r1" */
4054731, /* "sect409k1" */
4055732, /* "sect409r1" */
4056733, /* "sect571k1" */
4057734, /* "sect571r1" */
4058635, /* "secure device signature" */
4059878, /* "seeAlso" */
4060777, /* "seed-cbc" */
4061779, /* "seed-cfb" */
4062776, /* "seed-ecb" */
4063778, /* "seed-ofb" */
4064105, /* "serialNumber" */
4065625, /* "set-addPolicy" */
4066515, /* "set-attr" */
4067518, /* "set-brand" */
4068638, /* "set-brand-AmericanExpress" */
4069637, /* "set-brand-Diners" */
4070636, /* "set-brand-IATA-ATA" */
4071639, /* "set-brand-JCB" */
4072641, /* "set-brand-MasterCard" */
4073642, /* "set-brand-Novus" */
4074640, /* "set-brand-Visa" */
4075516, /* "set-policy" */
4076607, /* "set-policy-root" */
4077624, /* "set-rootKeyThumb" */
4078620, /* "setAttr-Cert" */
4079628, /* "setAttr-IssCap-CVM" */
4080630, /* "setAttr-IssCap-Sig" */
4081629, /* "setAttr-IssCap-T2" */
4082627, /* "setAttr-Token-B0Prime" */
4083626, /* "setAttr-Token-EMV" */
4084622, /* "setAttr-TokenType" */
4085619, /* "setCext-IssuerCapabilities" */
4086615, /* "setCext-PGWYcapabilities" */
4087616, /* "setCext-TokenIdentifier" */
4088618, /* "setCext-TokenType" */
4089617, /* "setCext-Track2Data" */
4090611, /* "setCext-cCertRequired" */
4091609, /* "setCext-certType" */
4092608, /* "setCext-hashedRoot" */
4093610, /* "setCext-merchData" */
4094613, /* "setCext-setExt" */
4095614, /* "setCext-setQualf" */
4096612, /* "setCext-tunneling" */
4097540, /* "setct-AcqCardCodeMsg" */
4098576, /* "setct-AcqCardCodeMsgTBE" */
4099570, /* "setct-AuthReqTBE" */
4100534, /* "setct-AuthReqTBS" */
4101527, /* "setct-AuthResBaggage" */
4102571, /* "setct-AuthResTBE" */
4103572, /* "setct-AuthResTBEX" */
4104535, /* "setct-AuthResTBS" */
4105536, /* "setct-AuthResTBSX" */
4106528, /* "setct-AuthRevReqBaggage" */
4107577, /* "setct-AuthRevReqTBE" */
4108541, /* "setct-AuthRevReqTBS" */
4109529, /* "setct-AuthRevResBaggage" */
4110542, /* "setct-AuthRevResData" */
4111578, /* "setct-AuthRevResTBE" */
4112579, /* "setct-AuthRevResTBEB" */
4113543, /* "setct-AuthRevResTBS" */
4114573, /* "setct-AuthTokenTBE" */
4115537, /* "setct-AuthTokenTBS" */
4116600, /* "setct-BCIDistributionTBS" */
4117558, /* "setct-BatchAdminReqData" */
4118592, /* "setct-BatchAdminReqTBE" */
4119559, /* "setct-BatchAdminResData" */
4120593, /* "setct-BatchAdminResTBE" */
4121599, /* "setct-CRLNotificationResTBS" */
4122598, /* "setct-CRLNotificationTBS" */
4123580, /* "setct-CapReqTBE" */
4124581, /* "setct-CapReqTBEX" */
4125544, /* "setct-CapReqTBS" */
4126545, /* "setct-CapReqTBSX" */
4127546, /* "setct-CapResData" */
4128582, /* "setct-CapResTBE" */
4129583, /* "setct-CapRevReqTBE" */
4130584, /* "setct-CapRevReqTBEX" */
4131547, /* "setct-CapRevReqTBS" */
4132548, /* "setct-CapRevReqTBSX" */
4133549, /* "setct-CapRevResData" */
4134585, /* "setct-CapRevResTBE" */
4135538, /* "setct-CapTokenData" */
4136530, /* "setct-CapTokenSeq" */
4137574, /* "setct-CapTokenTBE" */
4138575, /* "setct-CapTokenTBEX" */
4139539, /* "setct-CapTokenTBS" */
4140560, /* "setct-CardCInitResTBS" */
4141566, /* "setct-CertInqReqTBS" */
4142563, /* "setct-CertReqData" */
4143595, /* "setct-CertReqTBE" */
4144596, /* "setct-CertReqTBEX" */
4145564, /* "setct-CertReqTBS" */
4146565, /* "setct-CertResData" */
4147597, /* "setct-CertResTBE" */
4148586, /* "setct-CredReqTBE" */
4149587, /* "setct-CredReqTBEX" */
4150550, /* "setct-CredReqTBS" */
4151551, /* "setct-CredReqTBSX" */
4152552, /* "setct-CredResData" */
4153588, /* "setct-CredResTBE" */
4154589, /* "setct-CredRevReqTBE" */
4155590, /* "setct-CredRevReqTBEX" */
4156553, /* "setct-CredRevReqTBS" */
4157554, /* "setct-CredRevReqTBSX" */
4158555, /* "setct-CredRevResData" */
4159591, /* "setct-CredRevResTBE" */
4160567, /* "setct-ErrorTBS" */
4161526, /* "setct-HODInput" */
4162561, /* "setct-MeAqCInitResTBS" */
4163522, /* "setct-OIData" */
4164519, /* "setct-PANData" */
4165521, /* "setct-PANOnly" */
4166520, /* "setct-PANToken" */
4167556, /* "setct-PCertReqData" */
4168557, /* "setct-PCertResTBS" */
4169523, /* "setct-PI" */
4170532, /* "setct-PI-TBS" */
4171524, /* "setct-PIData" */
4172525, /* "setct-PIDataUnsigned" */
4173568, /* "setct-PIDualSignedTBE" */
4174569, /* "setct-PIUnsignedTBE" */
4175531, /* "setct-PInitResData" */
4176533, /* "setct-PResData" */
4177594, /* "setct-RegFormReqTBE" */
4178562, /* "setct-RegFormResTBS" */
4179604, /* "setext-pinAny" */
4180603, /* "setext-pinSecure" */
4181605, /* "setext-track2" */
418241, /* "sha" */
418364, /* "sha1" */
4184115, /* "sha1WithRSA" */
418565, /* "sha1WithRSAEncryption" */
4186675, /* "sha224" */
4187671, /* "sha224WithRSAEncryption" */
4188672, /* "sha256" */
4189668, /* "sha256WithRSAEncryption" */
4190673, /* "sha384" */
4191669, /* "sha384WithRSAEncryption" */
4192674, /* "sha512" */
4193670, /* "sha512WithRSAEncryption" */
419442, /* "shaWithRSAEncryption" */
419552, /* "signingTime" */
4196454, /* "simpleSecurityObject" */
4197496, /* "singleLevelQuality" */
419816, /* "stateOrProvinceName" */
4199660, /* "streetAddress" */
4200498, /* "subtreeMaximumQuality" */
4201497, /* "subtreeMinimumQuality" */
4202890, /* "supportedAlgorithms" */
4203874, /* "supportedApplicationContext" */
4204100, /* "surname" */
4205864, /* "telephoneNumber" */
4206866, /* "teletexTerminalIdentifier" */
4207865, /* "telexNumber" */
4208459, /* "textEncodedORAddress" */
4209293, /* "textNotice" */
4210106, /* "title" */
4211682, /* "tpBasis" */
4212436, /* "ucl" */
4213 0, /* "undefined" */
4214888, /* "uniqueMember" */
421555, /* "unstructuredAddress" */
421649, /* "unstructuredName" */
4217880, /* "userCertificate" */
4218465, /* "userClass" */
4219458, /* "userId" */
4220879, /* "userPassword" */
4221373, /* "valid" */
4222678, /* "wap" */
4223679, /* "wap-wsg" */
4224735, /* "wap-wsg-idm-ecid-wtls1" */
4225743, /* "wap-wsg-idm-ecid-wtls10" */
4226744, /* "wap-wsg-idm-ecid-wtls11" */
4227745, /* "wap-wsg-idm-ecid-wtls12" */
4228736, /* "wap-wsg-idm-ecid-wtls3" */
4229737, /* "wap-wsg-idm-ecid-wtls4" */
4230738, /* "wap-wsg-idm-ecid-wtls5" */
4231739, /* "wap-wsg-idm-ecid-wtls6" */
4232740, /* "wap-wsg-idm-ecid-wtls7" */
4233741, /* "wap-wsg-idm-ecid-wtls8" */
4234742, /* "wap-wsg-idm-ecid-wtls9" */
4235804, /* "whirlpool" */
4236868, /* "x121Address" */
4237503, /* "x500UniqueIdentifier" */
4238158, /* "x509Certificate" */
4239160, /* "x509Crl" */
4240125, /* "zlib compression" */
4241};
4242
4243static const unsigned int obj_objs[NUM_OBJ]={
4244 0, /* OBJ_undef 0 */
4245393, /* OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t */
4246404, /* OBJ_ccitt OBJ_itu_t */
4247645, /* OBJ_itu_t 0 */
4248434, /* OBJ_data 0 9 */
4249181, /* OBJ_iso 1 */
4250182, /* OBJ_member_body 1 2 */
4251379, /* OBJ_org 1 3 */
4252676, /* OBJ_identified_organization 1 3 */
4253646, /* OBJ_joint_iso_itu_t 2 */
425411, /* OBJ_X500 2 5 */
4255647, /* OBJ_international_organizations 2 23 */
4256380, /* OBJ_dod 1 3 6 */
425712, /* OBJ_X509 2 5 4 */
4258378, /* OBJ_X500algorithms 2 5 8 */
425981, /* OBJ_id_ce 2 5 29 */
4260512, /* OBJ_id_set 2 23 42 */
4261678, /* OBJ_wap 2 23 43 */
4262435, /* OBJ_pss 0 9 2342 */
4263183, /* OBJ_ISO_US 1 2 840 */
4264381, /* OBJ_iana 1 3 6 1 */
4265677, /* OBJ_certicom_arc 1 3 132 */
4266394, /* OBJ_selected_attribute_types 2 5 1 5 */
426713, /* OBJ_commonName 2 5 4 3 */
4268100, /* OBJ_surname 2 5 4 4 */
4269105, /* OBJ_serialNumber 2 5 4 5 */
427014, /* OBJ_countryName 2 5 4 6 */
427115, /* OBJ_localityName 2 5 4 7 */
427216, /* OBJ_stateOrProvinceName 2 5 4 8 */
4273660, /* OBJ_streetAddress 2 5 4 9 */
427417, /* OBJ_organizationName 2 5 4 10 */
427518, /* OBJ_organizationalUnitName 2 5 4 11 */
4276106, /* OBJ_title 2 5 4 12 */
4277107, /* OBJ_description 2 5 4 13 */
4278859, /* OBJ_searchGuide 2 5 4 14 */
4279860, /* OBJ_businessCategory 2 5 4 15 */
4280861, /* OBJ_postalAddress 2 5 4 16 */
4281661, /* OBJ_postalCode 2 5 4 17 */
4282862, /* OBJ_postOfficeBox 2 5 4 18 */
4283863, /* OBJ_physicalDeliveryOfficeName 2 5 4 19 */
4284864, /* OBJ_telephoneNumber 2 5 4 20 */
4285865, /* OBJ_telexNumber 2 5 4 21 */
4286866, /* OBJ_teletexTerminalIdentifier 2 5 4 22 */
4287867, /* OBJ_facsimileTelephoneNumber 2 5 4 23 */
4288868, /* OBJ_x121Address 2 5 4 24 */
4289869, /* OBJ_internationaliSDNNumber 2 5 4 25 */
4290870, /* OBJ_registeredAddress 2 5 4 26 */
4291871, /* OBJ_destinationIndicator 2 5 4 27 */
4292872, /* OBJ_preferredDeliveryMethod 2 5 4 28 */
4293873, /* OBJ_presentationAddress 2 5 4 29 */
4294874, /* OBJ_supportedApplicationContext 2 5 4 30 */
4295875, /* OBJ_member 2 5 4 31 */
4296876, /* OBJ_owner 2 5 4 32 */
4297877, /* OBJ_roleOccupant 2 5 4 33 */
4298878, /* OBJ_seeAlso 2 5 4 34 */
4299879, /* OBJ_userPassword 2 5 4 35 */
4300880, /* OBJ_userCertificate 2 5 4 36 */
4301881, /* OBJ_cACertificate 2 5 4 37 */
4302882, /* OBJ_authorityRevocationList 2 5 4 38 */
4303883, /* OBJ_certificateRevocationList 2 5 4 39 */
4304884, /* OBJ_crossCertificatePair 2 5 4 40 */
4305173, /* OBJ_name 2 5 4 41 */
430699, /* OBJ_givenName 2 5 4 42 */
4307101, /* OBJ_initials 2 5 4 43 */
4308509, /* OBJ_generationQualifier 2 5 4 44 */
4309503, /* OBJ_x500UniqueIdentifier 2 5 4 45 */
4310174, /* OBJ_dnQualifier 2 5 4 46 */
4311885, /* OBJ_enhancedSearchGuide 2 5 4 47 */
4312886, /* OBJ_protocolInformation 2 5 4 48 */
4313887, /* OBJ_distinguishedName 2 5 4 49 */
4314888, /* OBJ_uniqueMember 2 5 4 50 */
4315889, /* OBJ_houseIdentifier 2 5 4 51 */
4316890, /* OBJ_supportedAlgorithms 2 5 4 52 */
4317891, /* OBJ_deltaRevocationList 2 5 4 53 */
4318892, /* OBJ_dmdName 2 5 4 54 */
4319510, /* OBJ_pseudonym 2 5 4 65 */
4320400, /* OBJ_role 2 5 4 72 */
4321769, /* OBJ_subject_directory_attributes 2 5 29 9 */
432282, /* OBJ_subject_key_identifier 2 5 29 14 */
432383, /* OBJ_key_usage 2 5 29 15 */
432484, /* OBJ_private_key_usage_period 2 5 29 16 */
432585, /* OBJ_subject_alt_name 2 5 29 17 */
432686, /* OBJ_issuer_alt_name 2 5 29 18 */
432787, /* OBJ_basic_constraints 2 5 29 19 */
432888, /* OBJ_crl_number 2 5 29 20 */
4329141, /* OBJ_crl_reason 2 5 29 21 */
4330430, /* OBJ_hold_instruction_code 2 5 29 23 */
4331142, /* OBJ_invalidity_date 2 5 29 24 */
4332140, /* OBJ_delta_crl 2 5 29 27 */
4333770, /* OBJ_issuing_distribution_point 2 5 29 28 */
4334771, /* OBJ_certificate_issuer 2 5 29 29 */
4335666, /* OBJ_name_constraints 2 5 29 30 */
4336103, /* OBJ_crl_distribution_points 2 5 29 31 */
433789, /* OBJ_certificate_policies 2 5 29 32 */
4338747, /* OBJ_policy_mappings 2 5 29 33 */
433990, /* OBJ_authority_key_identifier 2 5 29 35 */
4340401, /* OBJ_policy_constraints 2 5 29 36 */
4341126, /* OBJ_ext_key_usage 2 5 29 37 */
4342857, /* OBJ_freshest_crl 2 5 29 46 */
4343748, /* OBJ_inhibit_any_policy 2 5 29 54 */
4344402, /* OBJ_target_information 2 5 29 55 */
4345403, /* OBJ_no_rev_avail 2 5 29 56 */
4346513, /* OBJ_set_ctype 2 23 42 0 */
4347514, /* OBJ_set_msgExt 2 23 42 1 */
4348515, /* OBJ_set_attr 2 23 42 3 */
4349516, /* OBJ_set_policy 2 23 42 5 */
4350517, /* OBJ_set_certExt 2 23 42 7 */
4351518, /* OBJ_set_brand 2 23 42 8 */
4352679, /* OBJ_wap_wsg 2 23 43 1 */
4353382, /* OBJ_Directory 1 3 6 1 1 */
4354383, /* OBJ_Management 1 3 6 1 2 */
4355384, /* OBJ_Experimental 1 3 6 1 3 */
4356385, /* OBJ_Private 1 3 6 1 4 */
4357386, /* OBJ_Security 1 3 6 1 5 */
4358387, /* OBJ_SNMPv2 1 3 6 1 6 */
4359388, /* OBJ_Mail 1 3 6 1 7 */
4360376, /* OBJ_algorithm 1 3 14 3 2 */
4361395, /* OBJ_clearance 2 5 1 5 55 */
436219, /* OBJ_rsa 2 5 8 1 1 */
436396, /* OBJ_mdc2WithRSA 2 5 8 3 100 */
436495, /* OBJ_mdc2 2 5 8 3 101 */
4365746, /* OBJ_any_policy 2 5 29 32 0 */
4366910, /* OBJ_anyExtendedKeyUsage 2 5 29 37 0 */
4367519, /* OBJ_setct_PANData 2 23 42 0 0 */
4368520, /* OBJ_setct_PANToken 2 23 42 0 1 */
4369521, /* OBJ_setct_PANOnly 2 23 42 0 2 */
4370522, /* OBJ_setct_OIData 2 23 42 0 3 */
4371523, /* OBJ_setct_PI 2 23 42 0 4 */
4372524, /* OBJ_setct_PIData 2 23 42 0 5 */
4373525, /* OBJ_setct_PIDataUnsigned 2 23 42 0 6 */
4374526, /* OBJ_setct_HODInput 2 23 42 0 7 */
4375527, /* OBJ_setct_AuthResBaggage 2 23 42 0 8 */
4376528, /* OBJ_setct_AuthRevReqBaggage 2 23 42 0 9 */
4377529, /* OBJ_setct_AuthRevResBaggage 2 23 42 0 10 */
4378530, /* OBJ_setct_CapTokenSeq 2 23 42 0 11 */
4379531, /* OBJ_setct_PInitResData 2 23 42 0 12 */
4380532, /* OBJ_setct_PI_TBS 2 23 42 0 13 */
4381533, /* OBJ_setct_PResData 2 23 42 0 14 */
4382534, /* OBJ_setct_AuthReqTBS 2 23 42 0 16 */
4383535, /* OBJ_setct_AuthResTBS 2 23 42 0 17 */
4384536, /* OBJ_setct_AuthResTBSX 2 23 42 0 18 */
4385537, /* OBJ_setct_AuthTokenTBS 2 23 42 0 19 */
4386538, /* OBJ_setct_CapTokenData 2 23 42 0 20 */
4387539, /* OBJ_setct_CapTokenTBS 2 23 42 0 21 */
4388540, /* OBJ_setct_AcqCardCodeMsg 2 23 42 0 22 */
4389541, /* OBJ_setct_AuthRevReqTBS 2 23 42 0 23 */
4390542, /* OBJ_setct_AuthRevResData 2 23 42 0 24 */
4391543, /* OBJ_setct_AuthRevResTBS 2 23 42 0 25 */
4392544, /* OBJ_setct_CapReqTBS 2 23 42 0 26 */
4393545, /* OBJ_setct_CapReqTBSX 2 23 42 0 27 */
4394546, /* OBJ_setct_CapResData 2 23 42 0 28 */
4395547, /* OBJ_setct_CapRevReqTBS 2 23 42 0 29 */
4396548, /* OBJ_setct_CapRevReqTBSX 2 23 42 0 30 */
4397549, /* OBJ_setct_CapRevResData 2 23 42 0 31 */
4398550, /* OBJ_setct_CredReqTBS 2 23 42 0 32 */
4399551, /* OBJ_setct_CredReqTBSX 2 23 42 0 33 */
4400552, /* OBJ_setct_CredResData 2 23 42 0 34 */
4401553, /* OBJ_setct_CredRevReqTBS 2 23 42 0 35 */
4402554, /* OBJ_setct_CredRevReqTBSX 2 23 42 0 36 */
4403555, /* OBJ_setct_CredRevResData 2 23 42 0 37 */
4404556, /* OBJ_setct_PCertReqData 2 23 42 0 38 */
4405557, /* OBJ_setct_PCertResTBS 2 23 42 0 39 */
4406558, /* OBJ_setct_BatchAdminReqData 2 23 42 0 40 */
4407559, /* OBJ_setct_BatchAdminResData 2 23 42 0 41 */
4408560, /* OBJ_setct_CardCInitResTBS 2 23 42 0 42 */
4409561, /* OBJ_setct_MeAqCInitResTBS 2 23 42 0 43 */
4410562, /* OBJ_setct_RegFormResTBS 2 23 42 0 44 */
4411563, /* OBJ_setct_CertReqData 2 23 42 0 45 */
4412564, /* OBJ_setct_CertReqTBS 2 23 42 0 46 */
4413565, /* OBJ_setct_CertResData 2 23 42 0 47 */
4414566, /* OBJ_setct_CertInqReqTBS 2 23 42 0 48 */
4415567, /* OBJ_setct_ErrorTBS 2 23 42 0 49 */
4416568, /* OBJ_setct_PIDualSignedTBE 2 23 42 0 50 */
4417569, /* OBJ_setct_PIUnsignedTBE 2 23 42 0 51 */
4418570, /* OBJ_setct_AuthReqTBE 2 23 42 0 52 */
4419571, /* OBJ_setct_AuthResTBE 2 23 42 0 53 */
4420572, /* OBJ_setct_AuthResTBEX 2 23 42 0 54 */
4421573, /* OBJ_setct_AuthTokenTBE 2 23 42 0 55 */
4422574, /* OBJ_setct_CapTokenTBE 2 23 42 0 56 */
4423575, /* OBJ_setct_CapTokenTBEX 2 23 42 0 57 */
4424576, /* OBJ_setct_AcqCardCodeMsgTBE 2 23 42 0 58 */
4425577, /* OBJ_setct_AuthRevReqTBE 2 23 42 0 59 */
4426578, /* OBJ_setct_AuthRevResTBE 2 23 42 0 60 */
4427579, /* OBJ_setct_AuthRevResTBEB 2 23 42 0 61 */
4428580, /* OBJ_setct_CapReqTBE 2 23 42 0 62 */
4429581, /* OBJ_setct_CapReqTBEX 2 23 42 0 63 */
4430582, /* OBJ_setct_CapResTBE 2 23 42 0 64 */
4431583, /* OBJ_setct_CapRevReqTBE 2 23 42 0 65 */
4432584, /* OBJ_setct_CapRevReqTBEX 2 23 42 0 66 */
4433585, /* OBJ_setct_CapRevResTBE 2 23 42 0 67 */
4434586, /* OBJ_setct_CredReqTBE 2 23 42 0 68 */
4435587, /* OBJ_setct_CredReqTBEX 2 23 42 0 69 */
4436588, /* OBJ_setct_CredResTBE 2 23 42 0 70 */
4437589, /* OBJ_setct_CredRevReqTBE 2 23 42 0 71 */
4438590, /* OBJ_setct_CredRevReqTBEX 2 23 42 0 72 */
4439591, /* OBJ_setct_CredRevResTBE 2 23 42 0 73 */
4440592, /* OBJ_setct_BatchAdminReqTBE 2 23 42 0 74 */
4441593, /* OBJ_setct_BatchAdminResTBE 2 23 42 0 75 */
4442594, /* OBJ_setct_RegFormReqTBE 2 23 42 0 76 */
4443595, /* OBJ_setct_CertReqTBE 2 23 42 0 77 */
4444596, /* OBJ_setct_CertReqTBEX 2 23 42 0 78 */
4445597, /* OBJ_setct_CertResTBE 2 23 42 0 79 */
4446598, /* OBJ_setct_CRLNotificationTBS 2 23 42 0 80 */
4447599, /* OBJ_setct_CRLNotificationResTBS 2 23 42 0 81 */
4448600, /* OBJ_setct_BCIDistributionTBS 2 23 42 0 82 */
4449601, /* OBJ_setext_genCrypt 2 23 42 1 1 */
4450602, /* OBJ_setext_miAuth 2 23 42 1 3 */
4451603, /* OBJ_setext_pinSecure 2 23 42 1 4 */
4452604, /* OBJ_setext_pinAny 2 23 42 1 5 */
4453605, /* OBJ_setext_track2 2 23 42 1 7 */
4454606, /* OBJ_setext_cv 2 23 42 1 8 */
4455620, /* OBJ_setAttr_Cert 2 23 42 3 0 */
4456621, /* OBJ_setAttr_PGWYcap 2 23 42 3 1 */
4457622, /* OBJ_setAttr_TokenType 2 23 42 3 2 */
4458623, /* OBJ_setAttr_IssCap 2 23 42 3 3 */
4459607, /* OBJ_set_policy_root 2 23 42 5 0 */
4460608, /* OBJ_setCext_hashedRoot 2 23 42 7 0 */
4461609, /* OBJ_setCext_certType 2 23 42 7 1 */
4462610, /* OBJ_setCext_merchData 2 23 42 7 2 */
4463611, /* OBJ_setCext_cCertRequired 2 23 42 7 3 */
4464612, /* OBJ_setCext_tunneling 2 23 42 7 4 */
4465613, /* OBJ_setCext_setExt 2 23 42 7 5 */
4466614, /* OBJ_setCext_setQualf 2 23 42 7 6 */
4467615, /* OBJ_setCext_PGWYcapabilities 2 23 42 7 7 */
4468616, /* OBJ_setCext_TokenIdentifier 2 23 42 7 8 */
4469617, /* OBJ_setCext_Track2Data 2 23 42 7 9 */
4470618, /* OBJ_setCext_TokenType 2 23 42 7 10 */
4471619, /* OBJ_setCext_IssuerCapabilities 2 23 42 7 11 */
4472636, /* OBJ_set_brand_IATA_ATA 2 23 42 8 1 */
4473640, /* OBJ_set_brand_Visa 2 23 42 8 4 */
4474641, /* OBJ_set_brand_MasterCard 2 23 42 8 5 */
4475637, /* OBJ_set_brand_Diners 2 23 42 8 30 */
4476638, /* OBJ_set_brand_AmericanExpress 2 23 42 8 34 */
4477639, /* OBJ_set_brand_JCB 2 23 42 8 35 */
4478805, /* OBJ_cryptopro 1 2 643 2 2 */
4479806, /* OBJ_cryptocom 1 2 643 2 9 */
4480184, /* OBJ_X9_57 1 2 840 10040 */
4481405, /* OBJ_ansi_X9_62 1 2 840 10045 */
4482389, /* OBJ_Enterprises 1 3 6 1 4 1 */
4483504, /* OBJ_mime_mhs 1 3 6 1 7 1 */
4484104, /* OBJ_md5WithRSA 1 3 14 3 2 3 */
448529, /* OBJ_des_ecb 1 3 14 3 2 6 */
448631, /* OBJ_des_cbc 1 3 14 3 2 7 */
448745, /* OBJ_des_ofb64 1 3 14 3 2 8 */
448830, /* OBJ_des_cfb64 1 3 14 3 2 9 */
4489377, /* OBJ_rsaSignature 1 3 14 3 2 11 */
449067, /* OBJ_dsa_2 1 3 14 3 2 12 */
449166, /* OBJ_dsaWithSHA 1 3 14 3 2 13 */
449242, /* OBJ_shaWithRSAEncryption 1 3 14 3 2 15 */
449332, /* OBJ_des_ede_ecb 1 3 14 3 2 17 */
449441, /* OBJ_sha 1 3 14 3 2 18 */
449564, /* OBJ_sha1 1 3 14 3 2 26 */
449670, /* OBJ_dsaWithSHA1_2 1 3 14 3 2 27 */
4497115, /* OBJ_sha1WithRSA 1 3 14 3 2 29 */
4498117, /* OBJ_ripemd160 1 3 36 3 2 1 */
4499143, /* OBJ_sxnet 1 3 101 1 4 1 */
4500721, /* OBJ_sect163k1 1 3 132 0 1 */
4501722, /* OBJ_sect163r1 1 3 132 0 2 */
4502728, /* OBJ_sect239k1 1 3 132 0 3 */
4503717, /* OBJ_sect113r1 1 3 132 0 4 */
4504718, /* OBJ_sect113r2 1 3 132 0 5 */
4505704, /* OBJ_secp112r1 1 3 132 0 6 */
4506705, /* OBJ_secp112r2 1 3 132 0 7 */
4507709, /* OBJ_secp160r1 1 3 132 0 8 */
4508708, /* OBJ_secp160k1 1 3 132 0 9 */
4509714, /* OBJ_secp256k1 1 3 132 0 10 */
4510723, /* OBJ_sect163r2 1 3 132 0 15 */
4511729, /* OBJ_sect283k1 1 3 132 0 16 */
4512730, /* OBJ_sect283r1 1 3 132 0 17 */
4513719, /* OBJ_sect131r1 1 3 132 0 22 */
4514720, /* OBJ_sect131r2 1 3 132 0 23 */
4515724, /* OBJ_sect193r1 1 3 132 0 24 */
4516725, /* OBJ_sect193r2 1 3 132 0 25 */
4517726, /* OBJ_sect233k1 1 3 132 0 26 */
4518727, /* OBJ_sect233r1 1 3 132 0 27 */
4519706, /* OBJ_secp128r1 1 3 132 0 28 */
4520707, /* OBJ_secp128r2 1 3 132 0 29 */
4521710, /* OBJ_secp160r2 1 3 132 0 30 */
4522711, /* OBJ_secp192k1 1 3 132 0 31 */
4523712, /* OBJ_secp224k1 1 3 132 0 32 */
4524713, /* OBJ_secp224r1 1 3 132 0 33 */
4525715, /* OBJ_secp384r1 1 3 132 0 34 */
4526716, /* OBJ_secp521r1 1 3 132 0 35 */
4527731, /* OBJ_sect409k1 1 3 132 0 36 */
4528732, /* OBJ_sect409r1 1 3 132 0 37 */
4529733, /* OBJ_sect571k1 1 3 132 0 38 */
4530734, /* OBJ_sect571r1 1 3 132 0 39 */
4531624, /* OBJ_set_rootKeyThumb 2 23 42 3 0 0 */
4532625, /* OBJ_set_addPolicy 2 23 42 3 0 1 */
4533626, /* OBJ_setAttr_Token_EMV 2 23 42 3 2 1 */
4534627, /* OBJ_setAttr_Token_B0Prime 2 23 42 3 2 2 */
4535628, /* OBJ_setAttr_IssCap_CVM 2 23 42 3 3 3 */
4536629, /* OBJ_setAttr_IssCap_T2 2 23 42 3 3 4 */
4537630, /* OBJ_setAttr_IssCap_Sig 2 23 42 3 3 5 */
4538642, /* OBJ_set_brand_Novus 2 23 42 8 6011 */
4539735, /* OBJ_wap_wsg_idm_ecid_wtls1 2 23 43 1 4 1 */
4540736, /* OBJ_wap_wsg_idm_ecid_wtls3 2 23 43 1 4 3 */
4541737, /* OBJ_wap_wsg_idm_ecid_wtls4 2 23 43 1 4 4 */
4542738, /* OBJ_wap_wsg_idm_ecid_wtls5 2 23 43 1 4 5 */
4543739, /* OBJ_wap_wsg_idm_ecid_wtls6 2 23 43 1 4 6 */
4544740, /* OBJ_wap_wsg_idm_ecid_wtls7 2 23 43 1 4 7 */
4545741, /* OBJ_wap_wsg_idm_ecid_wtls8 2 23 43 1 4 8 */
4546742, /* OBJ_wap_wsg_idm_ecid_wtls9 2 23 43 1 4 9 */
4547743, /* OBJ_wap_wsg_idm_ecid_wtls10 2 23 43 1 4 10 */
4548744, /* OBJ_wap_wsg_idm_ecid_wtls11 2 23 43 1 4 11 */
4549745, /* OBJ_wap_wsg_idm_ecid_wtls12 2 23 43 1 4 12 */
4550804, /* OBJ_whirlpool 1 0 10118 3 0 55 */
4551124, /* OBJ_rle_compression 1 1 1 1 666 1 */
4552773, /* OBJ_kisa 1 2 410 200004 */
4553807, /* OBJ_id_GostR3411_94_with_GostR3410_2001 1 2 643 2 2 3 */
4554808, /* OBJ_id_GostR3411_94_with_GostR3410_94 1 2 643 2 2 4 */
4555809, /* OBJ_id_GostR3411_94 1 2 643 2 2 9 */
4556810, /* OBJ_id_HMACGostR3411_94 1 2 643 2 2 10 */
4557811, /* OBJ_id_GostR3410_2001 1 2 643 2 2 19 */
4558812, /* OBJ_id_GostR3410_94 1 2 643 2 2 20 */
4559813, /* OBJ_id_Gost28147_89 1 2 643 2 2 21 */
4560815, /* OBJ_id_Gost28147_89_MAC 1 2 643 2 2 22 */
4561816, /* OBJ_id_GostR3411_94_prf 1 2 643 2 2 23 */
4562817, /* OBJ_id_GostR3410_2001DH 1 2 643 2 2 98 */
4563818, /* OBJ_id_GostR3410_94DH 1 2 643 2 2 99 */
4564 1, /* OBJ_rsadsi 1 2 840 113549 */
4565185, /* OBJ_X9cm 1 2 840 10040 4 */
4566127, /* OBJ_id_pkix 1 3 6 1 5 5 7 */
4567505, /* OBJ_mime_mhs_headings 1 3 6 1 7 1 1 */
4568506, /* OBJ_mime_mhs_bodies 1 3 6 1 7 1 2 */
4569119, /* OBJ_ripemd160WithRSA 1 3 36 3 3 1 2 */
4570631, /* OBJ_setAttr_GenCryptgrm 2 23 42 3 3 3 1 */
4571632, /* OBJ_setAttr_T2Enc 2 23 42 3 3 4 1 */
4572633, /* OBJ_setAttr_T2cleartxt 2 23 42 3 3 4 2 */
4573634, /* OBJ_setAttr_TokICCsig 2 23 42 3 3 5 1 */
4574635, /* OBJ_setAttr_SecDevSig 2 23 42 3 3 5 2 */
4575436, /* OBJ_ucl 0 9 2342 19200300 */
4576820, /* OBJ_id_Gost28147_89_None_KeyMeshing 1 2 643 2 2 14 0 */
4577819, /* OBJ_id_Gost28147_89_CryptoPro_KeyMeshing 1 2 643 2 2 14 1 */
4578845, /* OBJ_id_GostR3410_94_a 1 2 643 2 2 20 1 */
4579846, /* OBJ_id_GostR3410_94_aBis 1 2 643 2 2 20 2 */
4580847, /* OBJ_id_GostR3410_94_b 1 2 643 2 2 20 3 */
4581848, /* OBJ_id_GostR3410_94_bBis 1 2 643 2 2 20 4 */
4582821, /* OBJ_id_GostR3411_94_TestParamSet 1 2 643 2 2 30 0 */
4583822, /* OBJ_id_GostR3411_94_CryptoProParamSet 1 2 643 2 2 30 1 */
4584823, /* OBJ_id_Gost28147_89_TestParamSet 1 2 643 2 2 31 0 */
4585824, /* OBJ_id_Gost28147_89_CryptoPro_A_ParamSet 1 2 643 2 2 31 1 */
4586825, /* OBJ_id_Gost28147_89_CryptoPro_B_ParamSet 1 2 643 2 2 31 2 */
4587826, /* OBJ_id_Gost28147_89_CryptoPro_C_ParamSet 1 2 643 2 2 31 3 */
4588827, /* OBJ_id_Gost28147_89_CryptoPro_D_ParamSet 1 2 643 2 2 31 4 */
4589828, /* OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet 1 2 643 2 2 31 5 */
4590829, /* OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet 1 2 643 2 2 31 6 */
4591830, /* OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet 1 2 643 2 2 31 7 */
4592831, /* OBJ_id_GostR3410_94_TestParamSet 1 2 643 2 2 32 0 */
4593832, /* OBJ_id_GostR3410_94_CryptoPro_A_ParamSet 1 2 643 2 2 32 2 */
4594833, /* OBJ_id_GostR3410_94_CryptoPro_B_ParamSet 1 2 643 2 2 32 3 */
4595834, /* OBJ_id_GostR3410_94_CryptoPro_C_ParamSet 1 2 643 2 2 32 4 */
4596835, /* OBJ_id_GostR3410_94_CryptoPro_D_ParamSet 1 2 643 2 2 32 5 */
4597836, /* OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet 1 2 643 2 2 33 1 */
4598837, /* OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet 1 2 643 2 2 33 2 */
4599838, /* OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet 1 2 643 2 2 33 3 */
4600839, /* OBJ_id_GostR3410_2001_TestParamSet 1 2 643 2 2 35 0 */
4601840, /* OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet 1 2 643 2 2 35 1 */
4602841, /* OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet 1 2 643 2 2 35 2 */
4603842, /* OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet 1 2 643 2 2 35 3 */
4604843, /* OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet 1 2 643 2 2 36 0 */
4605844, /* OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet 1 2 643 2 2 36 1 */
4606 2, /* OBJ_pkcs 1 2 840 113549 1 */
4607431, /* OBJ_hold_instruction_none 1 2 840 10040 2 1 */
4608432, /* OBJ_hold_instruction_call_issuer 1 2 840 10040 2 2 */
4609433, /* OBJ_hold_instruction_reject 1 2 840 10040 2 3 */
4610116, /* OBJ_dsa 1 2 840 10040 4 1 */
4611113, /* OBJ_dsaWithSHA1 1 2 840 10040 4 3 */
4612406, /* OBJ_X9_62_prime_field 1 2 840 10045 1 1 */
4613407, /* OBJ_X9_62_characteristic_two_field 1 2 840 10045 1 2 */
4614408, /* OBJ_X9_62_id_ecPublicKey 1 2 840 10045 2 1 */
4615416, /* OBJ_ecdsa_with_SHA1 1 2 840 10045 4 1 */
4616791, /* OBJ_ecdsa_with_Recommended 1 2 840 10045 4 2 */
4617792, /* OBJ_ecdsa_with_Specified 1 2 840 10045 4 3 */
4618258, /* OBJ_id_pkix_mod 1 3 6 1 5 5 7 0 */
4619175, /* OBJ_id_pe 1 3 6 1 5 5 7 1 */
4620259, /* OBJ_id_qt 1 3 6 1 5 5 7 2 */
4621128, /* OBJ_id_kp 1 3 6 1 5 5 7 3 */
4622260, /* OBJ_id_it 1 3 6 1 5 5 7 4 */
4623261, /* OBJ_id_pkip 1 3 6 1 5 5 7 5 */
4624262, /* OBJ_id_alg 1 3 6 1 5 5 7 6 */
4625263, /* OBJ_id_cmc 1 3 6 1 5 5 7 7 */
4626264, /* OBJ_id_on 1 3 6 1 5 5 7 8 */
4627265, /* OBJ_id_pda 1 3 6 1 5 5 7 9 */
4628266, /* OBJ_id_aca 1 3 6 1 5 5 7 10 */
4629267, /* OBJ_id_qcs 1 3 6 1 5 5 7 11 */
4630268, /* OBJ_id_cct 1 3 6 1 5 5 7 12 */
4631662, /* OBJ_id_ppl 1 3 6 1 5 5 7 21 */
4632176, /* OBJ_id_ad 1 3 6 1 5 5 7 48 */
4633507, /* OBJ_id_hex_partial_message 1 3 6 1 7 1 1 1 */
4634508, /* OBJ_id_hex_multipart_message 1 3 6 1 7 1 1 2 */
463557, /* OBJ_netscape 2 16 840 1 113730 */
4636754, /* OBJ_camellia_128_ecb 0 3 4401 5 3 1 9 1 */
4637766, /* OBJ_camellia_128_ofb128 0 3 4401 5 3 1 9 3 */
4638757, /* OBJ_camellia_128_cfb128 0 3 4401 5 3 1 9 4 */
4639755, /* OBJ_camellia_192_ecb 0 3 4401 5 3 1 9 21 */
4640767, /* OBJ_camellia_192_ofb128 0 3 4401 5 3 1 9 23 */
4641758, /* OBJ_camellia_192_cfb128 0 3 4401 5 3 1 9 24 */
4642756, /* OBJ_camellia_256_ecb 0 3 4401 5 3 1 9 41 */
4643768, /* OBJ_camellia_256_ofb128 0 3 4401 5 3 1 9 43 */
4644759, /* OBJ_camellia_256_cfb128 0 3 4401 5 3 1 9 44 */
4645437, /* OBJ_pilot 0 9 2342 19200300 100 */
4646776, /* OBJ_seed_ecb 1 2 410 200004 1 3 */
4647777, /* OBJ_seed_cbc 1 2 410 200004 1 4 */
4648779, /* OBJ_seed_cfb128 1 2 410 200004 1 5 */
4649778, /* OBJ_seed_ofb128 1 2 410 200004 1 6 */
4650852, /* OBJ_id_GostR3411_94_with_GostR3410_94_cc 1 2 643 2 9 1 3 3 */
4651853, /* OBJ_id_GostR3411_94_with_GostR3410_2001_cc 1 2 643 2 9 1 3 4 */
4652850, /* OBJ_id_GostR3410_94_cc 1 2 643 2 9 1 5 3 */
4653851, /* OBJ_id_GostR3410_2001_cc 1 2 643 2 9 1 5 4 */
4654849, /* OBJ_id_Gost28147_89_cc 1 2 643 2 9 1 6 1 */
4655854, /* OBJ_id_GostR3410_2001_ParamSet_cc 1 2 643 2 9 1 8 1 */
4656186, /* OBJ_pkcs1 1 2 840 113549 1 1 */
465727, /* OBJ_pkcs3 1 2 840 113549 1 3 */
4658187, /* OBJ_pkcs5 1 2 840 113549 1 5 */
465920, /* OBJ_pkcs7 1 2 840 113549 1 7 */
466047, /* OBJ_pkcs9 1 2 840 113549 1 9 */
4661 3, /* OBJ_md2 1 2 840 113549 2 2 */
4662257, /* OBJ_md4 1 2 840 113549 2 4 */
4663 4, /* OBJ_md5 1 2 840 113549 2 5 */
4664797, /* OBJ_hmacWithMD5 1 2 840 113549 2 6 */
4665163, /* OBJ_hmacWithSHA1 1 2 840 113549 2 7 */
4666798, /* OBJ_hmacWithSHA224 1 2 840 113549 2 8 */
4667799, /* OBJ_hmacWithSHA256 1 2 840 113549 2 9 */
4668800, /* OBJ_hmacWithSHA384 1 2 840 113549 2 10 */
4669801, /* OBJ_hmacWithSHA512 1 2 840 113549 2 11 */
467037, /* OBJ_rc2_cbc 1 2 840 113549 3 2 */
4671 5, /* OBJ_rc4 1 2 840 113549 3 4 */
467244, /* OBJ_des_ede3_cbc 1 2 840 113549 3 7 */
4673120, /* OBJ_rc5_cbc 1 2 840 113549 3 8 */
4674643, /* OBJ_des_cdmf 1 2 840 113549 3 10 */
4675680, /* OBJ_X9_62_id_characteristic_two_basis 1 2 840 10045 1 2 3 */
4676684, /* OBJ_X9_62_c2pnb163v1 1 2 840 10045 3 0 1 */
4677685, /* OBJ_X9_62_c2pnb163v2 1 2 840 10045 3 0 2 */
4678686, /* OBJ_X9_62_c2pnb163v3 1 2 840 10045 3 0 3 */
4679687, /* OBJ_X9_62_c2pnb176v1 1 2 840 10045 3 0 4 */
4680688, /* OBJ_X9_62_c2tnb191v1 1 2 840 10045 3 0 5 */
4681689, /* OBJ_X9_62_c2tnb191v2 1 2 840 10045 3 0 6 */
4682690, /* OBJ_X9_62_c2tnb191v3 1 2 840 10045 3 0 7 */
4683691, /* OBJ_X9_62_c2onb191v4 1 2 840 10045 3 0 8 */
4684692, /* OBJ_X9_62_c2onb191v5 1 2 840 10045 3 0 9 */
4685693, /* OBJ_X9_62_c2pnb208w1 1 2 840 10045 3 0 10 */
4686694, /* OBJ_X9_62_c2tnb239v1 1 2 840 10045 3 0 11 */
4687695, /* OBJ_X9_62_c2tnb239v2 1 2 840 10045 3 0 12 */
4688696, /* OBJ_X9_62_c2tnb239v3 1 2 840 10045 3 0 13 */
4689697, /* OBJ_X9_62_c2onb239v4 1 2 840 10045 3 0 14 */
4690698, /* OBJ_X9_62_c2onb239v5 1 2 840 10045 3 0 15 */
4691699, /* OBJ_X9_62_c2pnb272w1 1 2 840 10045 3 0 16 */
4692700, /* OBJ_X9_62_c2pnb304w1 1 2 840 10045 3 0 17 */
4693701, /* OBJ_X9_62_c2tnb359v1 1 2 840 10045 3 0 18 */
4694702, /* OBJ_X9_62_c2pnb368w1 1 2 840 10045 3 0 19 */
4695703, /* OBJ_X9_62_c2tnb431r1 1 2 840 10045 3 0 20 */
4696409, /* OBJ_X9_62_prime192v1 1 2 840 10045 3 1 1 */
4697410, /* OBJ_X9_62_prime192v2 1 2 840 10045 3 1 2 */
4698411, /* OBJ_X9_62_prime192v3 1 2 840 10045 3 1 3 */
4699412, /* OBJ_X9_62_prime239v1 1 2 840 10045 3 1 4 */
4700413, /* OBJ_X9_62_prime239v2 1 2 840 10045 3 1 5 */
4701414, /* OBJ_X9_62_prime239v3 1 2 840 10045 3 1 6 */
4702415, /* OBJ_X9_62_prime256v1 1 2 840 10045 3 1 7 */
4703793, /* OBJ_ecdsa_with_SHA224 1 2 840 10045 4 3 1 */
4704794, /* OBJ_ecdsa_with_SHA256 1 2 840 10045 4 3 2 */
4705795, /* OBJ_ecdsa_with_SHA384 1 2 840 10045 4 3 3 */
4706796, /* OBJ_ecdsa_with_SHA512 1 2 840 10045 4 3 4 */
4707269, /* OBJ_id_pkix1_explicit_88 1 3 6 1 5 5 7 0 1 */
4708270, /* OBJ_id_pkix1_implicit_88 1 3 6 1 5 5 7 0 2 */
4709271, /* OBJ_id_pkix1_explicit_93 1 3 6 1 5 5 7 0 3 */
4710272, /* OBJ_id_pkix1_implicit_93 1 3 6 1 5 5 7 0 4 */
4711273, /* OBJ_id_mod_crmf 1 3 6 1 5 5 7 0 5 */
4712274, /* OBJ_id_mod_cmc 1 3 6 1 5 5 7 0 6 */
4713275, /* OBJ_id_mod_kea_profile_88 1 3 6 1 5 5 7 0 7 */
4714276, /* OBJ_id_mod_kea_profile_93 1 3 6 1 5 5 7 0 8 */
4715277, /* OBJ_id_mod_cmp 1 3 6 1 5 5 7 0 9 */
4716278, /* OBJ_id_mod_qualified_cert_88 1 3 6 1 5 5 7 0 10 */
4717279, /* OBJ_id_mod_qualified_cert_93 1 3 6 1 5 5 7 0 11 */
4718280, /* OBJ_id_mod_attribute_cert 1 3 6 1 5 5 7 0 12 */
4719281, /* OBJ_id_mod_timestamp_protocol 1 3 6 1 5 5 7 0 13 */
4720282, /* OBJ_id_mod_ocsp 1 3 6 1 5 5 7 0 14 */
4721283, /* OBJ_id_mod_dvcs 1 3 6 1 5 5 7 0 15 */
4722284, /* OBJ_id_mod_cmp2000 1 3 6 1 5 5 7 0 16 */
4723177, /* OBJ_info_access 1 3 6 1 5 5 7 1 1 */
4724285, /* OBJ_biometricInfo 1 3 6 1 5 5 7 1 2 */
4725286, /* OBJ_qcStatements 1 3 6 1 5 5 7 1 3 */
4726287, /* OBJ_ac_auditEntity 1 3 6 1 5 5 7 1 4 */
4727288, /* OBJ_ac_targeting 1 3 6 1 5 5 7 1 5 */
4728289, /* OBJ_aaControls 1 3 6 1 5 5 7 1 6 */
4729290, /* OBJ_sbgp_ipAddrBlock 1 3 6 1 5 5 7 1 7 */
4730291, /* OBJ_sbgp_autonomousSysNum 1 3 6 1 5 5 7 1 8 */
4731292, /* OBJ_sbgp_routerIdentifier 1 3 6 1 5 5 7 1 9 */
4732397, /* OBJ_ac_proxying 1 3 6 1 5 5 7 1 10 */
4733398, /* OBJ_sinfo_access 1 3 6 1 5 5 7 1 11 */
4734663, /* OBJ_proxyCertInfo 1 3 6 1 5 5 7 1 14 */
4735164, /* OBJ_id_qt_cps 1 3 6 1 5 5 7 2 1 */
4736165, /* OBJ_id_qt_unotice 1 3 6 1 5 5 7 2 2 */
4737293, /* OBJ_textNotice 1 3 6 1 5 5 7 2 3 */
4738129, /* OBJ_server_auth 1 3 6 1 5 5 7 3 1 */
4739130, /* OBJ_client_auth 1 3 6 1 5 5 7 3 2 */
4740131, /* OBJ_code_sign 1 3 6 1 5 5 7 3 3 */
4741132, /* OBJ_email_protect 1 3 6 1 5 5 7 3 4 */
4742294, /* OBJ_ipsecEndSystem 1 3 6 1 5 5 7 3 5 */
4743295, /* OBJ_ipsecTunnel 1 3 6 1 5 5 7 3 6 */
4744296, /* OBJ_ipsecUser 1 3 6 1 5 5 7 3 7 */
4745133, /* OBJ_time_stamp 1 3 6 1 5 5 7 3 8 */
4746180, /* OBJ_OCSP_sign 1 3 6 1 5 5 7 3 9 */
4747297, /* OBJ_dvcs 1 3 6 1 5 5 7 3 10 */
4748298, /* OBJ_id_it_caProtEncCert 1 3 6 1 5 5 7 4 1 */
4749299, /* OBJ_id_it_signKeyPairTypes 1 3 6 1 5 5 7 4 2 */
4750300, /* OBJ_id_it_encKeyPairTypes 1 3 6 1 5 5 7 4 3 */
4751301, /* OBJ_id_it_preferredSymmAlg 1 3 6 1 5 5 7 4 4 */
4752302, /* OBJ_id_it_caKeyUpdateInfo 1 3 6 1 5 5 7 4 5 */
4753303, /* OBJ_id_it_currentCRL 1 3 6 1 5 5 7 4 6 */
4754304, /* OBJ_id_it_unsupportedOIDs 1 3 6 1 5 5 7 4 7 */
4755305, /* OBJ_id_it_subscriptionRequest 1 3 6 1 5 5 7 4 8 */
4756306, /* OBJ_id_it_subscriptionResponse 1 3 6 1 5 5 7 4 9 */
4757307, /* OBJ_id_it_keyPairParamReq 1 3 6 1 5 5 7 4 10 */
4758308, /* OBJ_id_it_keyPairParamRep 1 3 6 1 5 5 7 4 11 */
4759309, /* OBJ_id_it_revPassphrase 1 3 6 1 5 5 7 4 12 */
4760310, /* OBJ_id_it_implicitConfirm 1 3 6 1 5 5 7 4 13 */
4761311, /* OBJ_id_it_confirmWaitTime 1 3 6 1 5 5 7 4 14 */
4762312, /* OBJ_id_it_origPKIMessage 1 3 6 1 5 5 7 4 15 */
4763784, /* OBJ_id_it_suppLangTags 1 3 6 1 5 5 7 4 16 */
4764313, /* OBJ_id_regCtrl 1 3 6 1 5 5 7 5 1 */
4765314, /* OBJ_id_regInfo 1 3 6 1 5 5 7 5 2 */
4766323, /* OBJ_id_alg_des40 1 3 6 1 5 5 7 6 1 */
4767324, /* OBJ_id_alg_noSignature 1 3 6 1 5 5 7 6 2 */
4768325, /* OBJ_id_alg_dh_sig_hmac_sha1 1 3 6 1 5 5 7 6 3 */
4769326, /* OBJ_id_alg_dh_pop 1 3 6 1 5 5 7 6 4 */
4770327, /* OBJ_id_cmc_statusInfo 1 3 6 1 5 5 7 7 1 */
4771328, /* OBJ_id_cmc_identification 1 3 6 1 5 5 7 7 2 */
4772329, /* OBJ_id_cmc_identityProof 1 3 6 1 5 5 7 7 3 */
4773330, /* OBJ_id_cmc_dataReturn 1 3 6 1 5 5 7 7 4 */
4774331, /* OBJ_id_cmc_transactionId 1 3 6 1 5 5 7 7 5 */
4775332, /* OBJ_id_cmc_senderNonce 1 3 6 1 5 5 7 7 6 */
4776333, /* OBJ_id_cmc_recipientNonce 1 3 6 1 5 5 7 7 7 */
4777334, /* OBJ_id_cmc_addExtensions 1 3 6 1 5 5 7 7 8 */
4778335, /* OBJ_id_cmc_encryptedPOP 1 3 6 1 5 5 7 7 9 */
4779336, /* OBJ_id_cmc_decryptedPOP 1 3 6 1 5 5 7 7 10 */
4780337, /* OBJ_id_cmc_lraPOPWitness 1 3 6 1 5 5 7 7 11 */
4781338, /* OBJ_id_cmc_getCert 1 3 6 1 5 5 7 7 15 */
4782339, /* OBJ_id_cmc_getCRL 1 3 6 1 5 5 7 7 16 */
4783340, /* OBJ_id_cmc_revokeRequest 1 3 6 1 5 5 7 7 17 */
4784341, /* OBJ_id_cmc_regInfo 1 3 6 1 5 5 7 7 18 */
4785342, /* OBJ_id_cmc_responseInfo 1 3 6 1 5 5 7 7 19 */
4786343, /* OBJ_id_cmc_queryPending 1 3 6 1 5 5 7 7 21 */
4787344, /* OBJ_id_cmc_popLinkRandom 1 3 6 1 5 5 7 7 22 */
4788345, /* OBJ_id_cmc_popLinkWitness 1 3 6 1 5 5 7 7 23 */
4789346, /* OBJ_id_cmc_confirmCertAcceptance 1 3 6 1 5 5 7 7 24 */
4790347, /* OBJ_id_on_personalData 1 3 6 1 5 5 7 8 1 */
4791858, /* OBJ_id_on_permanentIdentifier 1 3 6 1 5 5 7 8 3 */
4792348, /* OBJ_id_pda_dateOfBirth 1 3 6 1 5 5 7 9 1 */
4793349, /* OBJ_id_pda_placeOfBirth 1 3 6 1 5 5 7 9 2 */
4794351, /* OBJ_id_pda_gender 1 3 6 1 5 5 7 9 3 */
4795352, /* OBJ_id_pda_countryOfCitizenship 1 3 6 1 5 5 7 9 4 */
4796353, /* OBJ_id_pda_countryOfResidence 1 3 6 1 5 5 7 9 5 */
4797354, /* OBJ_id_aca_authenticationInfo 1 3 6 1 5 5 7 10 1 */
4798355, /* OBJ_id_aca_accessIdentity 1 3 6 1 5 5 7 10 2 */
4799356, /* OBJ_id_aca_chargingIdentity 1 3 6 1 5 5 7 10 3 */
4800357, /* OBJ_id_aca_group 1 3 6 1 5 5 7 10 4 */
4801358, /* OBJ_id_aca_role 1 3 6 1 5 5 7 10 5 */
4802399, /* OBJ_id_aca_encAttrs 1 3 6 1 5 5 7 10 6 */
4803359, /* OBJ_id_qcs_pkixQCSyntax_v1 1 3 6 1 5 5 7 11 1 */
4804360, /* OBJ_id_cct_crs 1 3 6 1 5 5 7 12 1 */
4805361, /* OBJ_id_cct_PKIData 1 3 6 1 5 5 7 12 2 */
4806362, /* OBJ_id_cct_PKIResponse 1 3 6 1 5 5 7 12 3 */
4807664, /* OBJ_id_ppl_anyLanguage 1 3 6 1 5 5 7 21 0 */
4808665, /* OBJ_id_ppl_inheritAll 1 3 6 1 5 5 7 21 1 */
4809667, /* OBJ_Independent 1 3 6 1 5 5 7 21 2 */
4810178, /* OBJ_ad_OCSP 1 3 6 1 5 5 7 48 1 */
4811179, /* OBJ_ad_ca_issuers 1 3 6 1 5 5 7 48 2 */
4812363, /* OBJ_ad_timeStamping 1 3 6 1 5 5 7 48 3 */
4813364, /* OBJ_ad_dvcs 1 3 6 1 5 5 7 48 4 */
4814785, /* OBJ_caRepository 1 3 6 1 5 5 7 48 5 */
4815780, /* OBJ_hmac_md5 1 3 6 1 5 5 8 1 1 */
4816781, /* OBJ_hmac_sha1 1 3 6 1 5 5 8 1 2 */
481758, /* OBJ_netscape_cert_extension 2 16 840 1 113730 1 */
481859, /* OBJ_netscape_data_type 2 16 840 1 113730 2 */
4819438, /* OBJ_pilotAttributeType 0 9 2342 19200300 100 1 */
4820439, /* OBJ_pilotAttributeSyntax 0 9 2342 19200300 100 3 */
4821440, /* OBJ_pilotObjectClass 0 9 2342 19200300 100 4 */
4822441, /* OBJ_pilotGroups 0 9 2342 19200300 100 10 */
4823108, /* OBJ_cast5_cbc 1 2 840 113533 7 66 10 */
4824112, /* OBJ_pbeWithMD5AndCast5_CBC 1 2 840 113533 7 66 12 */
4825782, /* OBJ_id_PasswordBasedMAC 1 2 840 113533 7 66 13 */
4826783, /* OBJ_id_DHBasedMac 1 2 840 113533 7 66 30 */
4827 6, /* OBJ_rsaEncryption 1 2 840 113549 1 1 1 */
4828 7, /* OBJ_md2WithRSAEncryption 1 2 840 113549 1 1 2 */
4829396, /* OBJ_md4WithRSAEncryption 1 2 840 113549 1 1 3 */
4830 8, /* OBJ_md5WithRSAEncryption 1 2 840 113549 1 1 4 */
483165, /* OBJ_sha1WithRSAEncryption 1 2 840 113549 1 1 5 */
4832644, /* OBJ_rsaOAEPEncryptionSET 1 2 840 113549 1 1 6 */
4833919, /* OBJ_rsaesOaep 1 2 840 113549 1 1 7 */
4834911, /* OBJ_mgf1 1 2 840 113549 1 1 8 */
4835912, /* OBJ_rsassaPss 1 2 840 113549 1 1 10 */
4836668, /* OBJ_sha256WithRSAEncryption 1 2 840 113549 1 1 11 */
4837669, /* OBJ_sha384WithRSAEncryption 1 2 840 113549 1 1 12 */
4838670, /* OBJ_sha512WithRSAEncryption 1 2 840 113549 1 1 13 */
4839671, /* OBJ_sha224WithRSAEncryption 1 2 840 113549 1 1 14 */
484028, /* OBJ_dhKeyAgreement 1 2 840 113549 1 3 1 */
4841 9, /* OBJ_pbeWithMD2AndDES_CBC 1 2 840 113549 1 5 1 */
484210, /* OBJ_pbeWithMD5AndDES_CBC 1 2 840 113549 1 5 3 */
4843168, /* OBJ_pbeWithMD2AndRC2_CBC 1 2 840 113549 1 5 4 */
4844169, /* OBJ_pbeWithMD5AndRC2_CBC 1 2 840 113549 1 5 6 */
4845170, /* OBJ_pbeWithSHA1AndDES_CBC 1 2 840 113549 1 5 10 */
484668, /* OBJ_pbeWithSHA1AndRC2_CBC 1 2 840 113549 1 5 11 */
484769, /* OBJ_id_pbkdf2 1 2 840 113549 1 5 12 */
4848161, /* OBJ_pbes2 1 2 840 113549 1 5 13 */
4849162, /* OBJ_pbmac1 1 2 840 113549 1 5 14 */
485021, /* OBJ_pkcs7_data 1 2 840 113549 1 7 1 */
485122, /* OBJ_pkcs7_signed 1 2 840 113549 1 7 2 */
485223, /* OBJ_pkcs7_enveloped 1 2 840 113549 1 7 3 */
485324, /* OBJ_pkcs7_signedAndEnveloped 1 2 840 113549 1 7 4 */
485425, /* OBJ_pkcs7_digest 1 2 840 113549 1 7 5 */
485526, /* OBJ_pkcs7_encrypted 1 2 840 113549 1 7 6 */
485648, /* OBJ_pkcs9_emailAddress 1 2 840 113549 1 9 1 */
485749, /* OBJ_pkcs9_unstructuredName 1 2 840 113549 1 9 2 */
485850, /* OBJ_pkcs9_contentType 1 2 840 113549 1 9 3 */
485951, /* OBJ_pkcs9_messageDigest 1 2 840 113549 1 9 4 */
486052, /* OBJ_pkcs9_signingTime 1 2 840 113549 1 9 5 */
486153, /* OBJ_pkcs9_countersignature 1 2 840 113549 1 9 6 */
486254, /* OBJ_pkcs9_challengePassword 1 2 840 113549 1 9 7 */
486355, /* OBJ_pkcs9_unstructuredAddress 1 2 840 113549 1 9 8 */
486456, /* OBJ_pkcs9_extCertAttributes 1 2 840 113549 1 9 9 */
4865172, /* OBJ_ext_req 1 2 840 113549 1 9 14 */
4866167, /* OBJ_SMIMECapabilities 1 2 840 113549 1 9 15 */
4867188, /* OBJ_SMIME 1 2 840 113549 1 9 16 */
4868156, /* OBJ_friendlyName 1 2 840 113549 1 9 20 */
4869157, /* OBJ_localKeyID 1 2 840 113549 1 9 21 */
4870681, /* OBJ_X9_62_onBasis 1 2 840 10045 1 2 3 1 */
4871682, /* OBJ_X9_62_tpBasis 1 2 840 10045 1 2 3 2 */
4872683, /* OBJ_X9_62_ppBasis 1 2 840 10045 1 2 3 3 */
4873417, /* OBJ_ms_csp_name 1 3 6 1 4 1 311 17 1 */
4874856, /* OBJ_LocalKeySet 1 3 6 1 4 1 311 17 2 */
4875390, /* OBJ_dcObject 1 3 6 1 4 1 1466 344 */
487691, /* OBJ_bf_cbc 1 3 6 1 4 1 3029 1 2 */
4877315, /* OBJ_id_regCtrl_regToken 1 3 6 1 5 5 7 5 1 1 */
4878316, /* OBJ_id_regCtrl_authenticator 1 3 6 1 5 5 7 5 1 2 */
4879317, /* OBJ_id_regCtrl_pkiPublicationInfo 1 3 6 1 5 5 7 5 1 3 */
4880318, /* OBJ_id_regCtrl_pkiArchiveOptions 1 3 6 1 5 5 7 5 1 4 */
4881319, /* OBJ_id_regCtrl_oldCertID 1 3 6 1 5 5 7 5 1 5 */
4882320, /* OBJ_id_regCtrl_protocolEncrKey 1 3 6 1 5 5 7 5 1 6 */
4883321, /* OBJ_id_regInfo_utf8Pairs 1 3 6 1 5 5 7 5 2 1 */
4884322, /* OBJ_id_regInfo_certReq 1 3 6 1 5 5 7 5 2 2 */
4885365, /* OBJ_id_pkix_OCSP_basic 1 3 6 1 5 5 7 48 1 1 */
4886366, /* OBJ_id_pkix_OCSP_Nonce 1 3 6 1 5 5 7 48 1 2 */
4887367, /* OBJ_id_pkix_OCSP_CrlID 1 3 6 1 5 5 7 48 1 3 */
4888368, /* OBJ_id_pkix_OCSP_acceptableResponses 1 3 6 1 5 5 7 48 1 4 */
4889369, /* OBJ_id_pkix_OCSP_noCheck 1 3 6 1 5 5 7 48 1 5 */
4890370, /* OBJ_id_pkix_OCSP_archiveCutoff 1 3 6 1 5 5 7 48 1 6 */
4891371, /* OBJ_id_pkix_OCSP_serviceLocator 1 3 6 1 5 5 7 48 1 7 */
4892372, /* OBJ_id_pkix_OCSP_extendedStatus 1 3 6 1 5 5 7 48 1 8 */
4893373, /* OBJ_id_pkix_OCSP_valid 1 3 6 1 5 5 7 48 1 9 */
4894374, /* OBJ_id_pkix_OCSP_path 1 3 6 1 5 5 7 48 1 10 */
4895375, /* OBJ_id_pkix_OCSP_trustRoot 1 3 6 1 5 5 7 48 1 11 */
4896418, /* OBJ_aes_128_ecb 2 16 840 1 101 3 4 1 1 */
4897419, /* OBJ_aes_128_cbc 2 16 840 1 101 3 4 1 2 */
4898420, /* OBJ_aes_128_ofb128 2 16 840 1 101 3 4 1 3 */
4899421, /* OBJ_aes_128_cfb128 2 16 840 1 101 3 4 1 4 */
4900788, /* OBJ_id_aes128_wrap 2 16 840 1 101 3 4 1 5 */
4901895, /* OBJ_aes_128_gcm 2 16 840 1 101 3 4 1 6 */
4902896, /* OBJ_aes_128_ccm 2 16 840 1 101 3 4 1 7 */
4903897, /* OBJ_id_aes128_wrap_pad 2 16 840 1 101 3 4 1 8 */
4904422, /* OBJ_aes_192_ecb 2 16 840 1 101 3 4 1 21 */
4905423, /* OBJ_aes_192_cbc 2 16 840 1 101 3 4 1 22 */
4906424, /* OBJ_aes_192_ofb128 2 16 840 1 101 3 4 1 23 */
4907425, /* OBJ_aes_192_cfb128 2 16 840 1 101 3 4 1 24 */
4908789, /* OBJ_id_aes192_wrap 2 16 840 1 101 3 4 1 25 */
4909898, /* OBJ_aes_192_gcm 2 16 840 1 101 3 4 1 26 */
4910899, /* OBJ_aes_192_ccm 2 16 840 1 101 3 4 1 27 */
4911900, /* OBJ_id_aes192_wrap_pad 2 16 840 1 101 3 4 1 28 */
4912426, /* OBJ_aes_256_ecb 2 16 840 1 101 3 4 1 41 */
4913427, /* OBJ_aes_256_cbc 2 16 840 1 101 3 4 1 42 */
4914428, /* OBJ_aes_256_ofb128 2 16 840 1 101 3 4 1 43 */
4915429, /* OBJ_aes_256_cfb128 2 16 840 1 101 3 4 1 44 */
4916790, /* OBJ_id_aes256_wrap 2 16 840 1 101 3 4 1 45 */
4917901, /* OBJ_aes_256_gcm 2 16 840 1 101 3 4 1 46 */
4918902, /* OBJ_aes_256_ccm 2 16 840 1 101 3 4 1 47 */
4919903, /* OBJ_id_aes256_wrap_pad 2 16 840 1 101 3 4 1 48 */
4920672, /* OBJ_sha256 2 16 840 1 101 3 4 2 1 */
4921673, /* OBJ_sha384 2 16 840 1 101 3 4 2 2 */
4922674, /* OBJ_sha512 2 16 840 1 101 3 4 2 3 */
4923675, /* OBJ_sha224 2 16 840 1 101 3 4 2 4 */
4924802, /* OBJ_dsa_with_SHA224 2 16 840 1 101 3 4 3 1 */
4925803, /* OBJ_dsa_with_SHA256 2 16 840 1 101 3 4 3 2 */
492671, /* OBJ_netscape_cert_type 2 16 840 1 113730 1 1 */
492772, /* OBJ_netscape_base_url 2 16 840 1 113730 1 2 */
492873, /* OBJ_netscape_revocation_url 2 16 840 1 113730 1 3 */
492974, /* OBJ_netscape_ca_revocation_url 2 16 840 1 113730 1 4 */
493075, /* OBJ_netscape_renewal_url 2 16 840 1 113730 1 7 */
493176, /* OBJ_netscape_ca_policy_url 2 16 840 1 113730 1 8 */
493277, /* OBJ_netscape_ssl_server_name 2 16 840 1 113730 1 12 */
493378, /* OBJ_netscape_comment 2 16 840 1 113730 1 13 */
493479, /* OBJ_netscape_cert_sequence 2 16 840 1 113730 2 5 */
4935139, /* OBJ_ns_sgc 2 16 840 1 113730 4 1 */
4936458, /* OBJ_userId 0 9 2342 19200300 100 1 1 */
4937459, /* OBJ_textEncodedORAddress 0 9 2342 19200300 100 1 2 */
4938460, /* OBJ_rfc822Mailbox 0 9 2342 19200300 100 1 3 */
4939461, /* OBJ_info 0 9 2342 19200300 100 1 4 */
4940462, /* OBJ_favouriteDrink 0 9 2342 19200300 100 1 5 */
4941463, /* OBJ_roomNumber 0 9 2342 19200300 100 1 6 */
4942464, /* OBJ_photo 0 9 2342 19200300 100 1 7 */
4943465, /* OBJ_userClass 0 9 2342 19200300 100 1 8 */
4944466, /* OBJ_host 0 9 2342 19200300 100 1 9 */
4945467, /* OBJ_manager 0 9 2342 19200300 100 1 10 */
4946468, /* OBJ_documentIdentifier 0 9 2342 19200300 100 1 11 */
4947469, /* OBJ_documentTitle 0 9 2342 19200300 100 1 12 */
4948470, /* OBJ_documentVersion 0 9 2342 19200300 100 1 13 */
4949471, /* OBJ_documentAuthor 0 9 2342 19200300 100 1 14 */
4950472, /* OBJ_documentLocation 0 9 2342 19200300 100 1 15 */
4951473, /* OBJ_homeTelephoneNumber 0 9 2342 19200300 100 1 20 */
4952474, /* OBJ_secretary 0 9 2342 19200300 100 1 21 */
4953475, /* OBJ_otherMailbox 0 9 2342 19200300 100 1 22 */
4954476, /* OBJ_lastModifiedTime 0 9 2342 19200300 100 1 23 */
4955477, /* OBJ_lastModifiedBy 0 9 2342 19200300 100 1 24 */
4956391, /* OBJ_domainComponent 0 9 2342 19200300 100 1 25 */
4957478, /* OBJ_aRecord 0 9 2342 19200300 100 1 26 */
4958479, /* OBJ_pilotAttributeType27 0 9 2342 19200300 100 1 27 */
4959480, /* OBJ_mXRecord 0 9 2342 19200300 100 1 28 */
4960481, /* OBJ_nSRecord 0 9 2342 19200300 100 1 29 */
4961482, /* OBJ_sOARecord 0 9 2342 19200300 100 1 30 */
4962483, /* OBJ_cNAMERecord 0 9 2342 19200300 100 1 31 */
4963484, /* OBJ_associatedDomain 0 9 2342 19200300 100 1 37 */
4964485, /* OBJ_associatedName 0 9 2342 19200300 100 1 38 */
4965486, /* OBJ_homePostalAddress 0 9 2342 19200300 100 1 39 */
4966487, /* OBJ_personalTitle 0 9 2342 19200300 100 1 40 */
4967488, /* OBJ_mobileTelephoneNumber 0 9 2342 19200300 100 1 41 */
4968489, /* OBJ_pagerTelephoneNumber 0 9 2342 19200300 100 1 42 */
4969490, /* OBJ_friendlyCountryName 0 9 2342 19200300 100 1 43 */
4970491, /* OBJ_organizationalStatus 0 9 2342 19200300 100 1 45 */
4971492, /* OBJ_janetMailbox 0 9 2342 19200300 100 1 46 */
4972493, /* OBJ_mailPreferenceOption 0 9 2342 19200300 100 1 47 */
4973494, /* OBJ_buildingName 0 9 2342 19200300 100 1 48 */
4974495, /* OBJ_dSAQuality 0 9 2342 19200300 100 1 49 */
4975496, /* OBJ_singleLevelQuality 0 9 2342 19200300 100 1 50 */
4976497, /* OBJ_subtreeMinimumQuality 0 9 2342 19200300 100 1 51 */
4977498, /* OBJ_subtreeMaximumQuality 0 9 2342 19200300 100 1 52 */
4978499, /* OBJ_personalSignature 0 9 2342 19200300 100 1 53 */
4979500, /* OBJ_dITRedirect 0 9 2342 19200300 100 1 54 */
4980501, /* OBJ_audio 0 9 2342 19200300 100 1 55 */
4981502, /* OBJ_documentPublisher 0 9 2342 19200300 100 1 56 */
4982442, /* OBJ_iA5StringSyntax 0 9 2342 19200300 100 3 4 */
4983443, /* OBJ_caseIgnoreIA5StringSyntax 0 9 2342 19200300 100 3 5 */
4984444, /* OBJ_pilotObject 0 9 2342 19200300 100 4 3 */
4985445, /* OBJ_pilotPerson 0 9 2342 19200300 100 4 4 */
4986446, /* OBJ_account 0 9 2342 19200300 100 4 5 */
4987447, /* OBJ_document 0 9 2342 19200300 100 4 6 */
4988448, /* OBJ_room 0 9 2342 19200300 100 4 7 */
4989449, /* OBJ_documentSeries 0 9 2342 19200300 100 4 9 */
4990392, /* OBJ_Domain 0 9 2342 19200300 100 4 13 */
4991450, /* OBJ_rFC822localPart 0 9 2342 19200300 100 4 14 */
4992451, /* OBJ_dNSDomain 0 9 2342 19200300 100 4 15 */
4993452, /* OBJ_domainRelatedObject 0 9 2342 19200300 100 4 17 */
4994453, /* OBJ_friendlyCountry 0 9 2342 19200300 100 4 18 */
4995454, /* OBJ_simpleSecurityObject 0 9 2342 19200300 100 4 19 */
4996455, /* OBJ_pilotOrganization 0 9 2342 19200300 100 4 20 */
4997456, /* OBJ_pilotDSA 0 9 2342 19200300 100 4 21 */
4998457, /* OBJ_qualityLabelledData 0 9 2342 19200300 100 4 22 */
4999189, /* OBJ_id_smime_mod 1 2 840 113549 1 9 16 0 */
5000190, /* OBJ_id_smime_ct 1 2 840 113549 1 9 16 1 */
5001191, /* OBJ_id_smime_aa 1 2 840 113549 1 9 16 2 */
5002192, /* OBJ_id_smime_alg 1 2 840 113549 1 9 16 3 */
5003193, /* OBJ_id_smime_cd 1 2 840 113549 1 9 16 4 */
5004194, /* OBJ_id_smime_spq 1 2 840 113549 1 9 16 5 */
5005195, /* OBJ_id_smime_cti 1 2 840 113549 1 9 16 6 */
5006158, /* OBJ_x509Certificate 1 2 840 113549 1 9 22 1 */
5007159, /* OBJ_sdsiCertificate 1 2 840 113549 1 9 22 2 */
5008160, /* OBJ_x509Crl 1 2 840 113549 1 9 23 1 */
5009144, /* OBJ_pbe_WithSHA1And128BitRC4 1 2 840 113549 1 12 1 1 */
5010145, /* OBJ_pbe_WithSHA1And40BitRC4 1 2 840 113549 1 12 1 2 */
5011146, /* OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC 1 2 840 113549 1 12 1 3 */
5012147, /* OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC 1 2 840 113549 1 12 1 4 */
5013148, /* OBJ_pbe_WithSHA1And128BitRC2_CBC 1 2 840 113549 1 12 1 5 */
5014149, /* OBJ_pbe_WithSHA1And40BitRC2_CBC 1 2 840 113549 1 12 1 6 */
5015171, /* OBJ_ms_ext_req 1 3 6 1 4 1 311 2 1 14 */
5016134, /* OBJ_ms_code_ind 1 3 6 1 4 1 311 2 1 21 */
5017135, /* OBJ_ms_code_com 1 3 6 1 4 1 311 2 1 22 */
5018136, /* OBJ_ms_ctl_sign 1 3 6 1 4 1 311 10 3 1 */
5019137, /* OBJ_ms_sgc 1 3 6 1 4 1 311 10 3 3 */
5020138, /* OBJ_ms_efs 1 3 6 1 4 1 311 10 3 4 */
5021648, /* OBJ_ms_smartcard_login 1 3 6 1 4 1 311 20 2 2 */
5022649, /* OBJ_ms_upn 1 3 6 1 4 1 311 20 2 3 */
5023751, /* OBJ_camellia_128_cbc 1 2 392 200011 61 1 1 1 2 */
5024752, /* OBJ_camellia_192_cbc 1 2 392 200011 61 1 1 1 3 */
5025753, /* OBJ_camellia_256_cbc 1 2 392 200011 61 1 1 1 4 */
5026907, /* OBJ_id_camellia128_wrap 1 2 392 200011 61 1 1 3 2 */
5027908, /* OBJ_id_camellia192_wrap 1 2 392 200011 61 1 1 3 3 */
5028909, /* OBJ_id_camellia256_wrap 1 2 392 200011 61 1 1 3 4 */
5029196, /* OBJ_id_smime_mod_cms 1 2 840 113549 1 9 16 0 1 */
5030197, /* OBJ_id_smime_mod_ess 1 2 840 113549 1 9 16 0 2 */
5031198, /* OBJ_id_smime_mod_oid 1 2 840 113549 1 9 16 0 3 */
5032199, /* OBJ_id_smime_mod_msg_v3 1 2 840 113549 1 9 16 0 4 */
5033200, /* OBJ_id_smime_mod_ets_eSignature_88 1 2 840 113549 1 9 16 0 5 */
5034201, /* OBJ_id_smime_mod_ets_eSignature_97 1 2 840 113549 1 9 16 0 6 */
5035202, /* OBJ_id_smime_mod_ets_eSigPolicy_88 1 2 840 113549 1 9 16 0 7 */
5036203, /* OBJ_id_smime_mod_ets_eSigPolicy_97 1 2 840 113549 1 9 16 0 8 */
5037204, /* OBJ_id_smime_ct_receipt 1 2 840 113549 1 9 16 1 1 */
5038205, /* OBJ_id_smime_ct_authData 1 2 840 113549 1 9 16 1 2 */
5039206, /* OBJ_id_smime_ct_publishCert 1 2 840 113549 1 9 16 1 3 */
5040207, /* OBJ_id_smime_ct_TSTInfo 1 2 840 113549 1 9 16 1 4 */
5041208, /* OBJ_id_smime_ct_TDTInfo 1 2 840 113549 1 9 16 1 5 */
5042209, /* OBJ_id_smime_ct_contentInfo 1 2 840 113549 1 9 16 1 6 */
5043210, /* OBJ_id_smime_ct_DVCSRequestData 1 2 840 113549 1 9 16 1 7 */
5044211, /* OBJ_id_smime_ct_DVCSResponseData 1 2 840 113549 1 9 16 1 8 */
5045786, /* OBJ_id_smime_ct_compressedData 1 2 840 113549 1 9 16 1 9 */
5046787, /* OBJ_id_ct_asciiTextWithCRLF 1 2 840 113549 1 9 16 1 27 */
5047212, /* OBJ_id_smime_aa_receiptRequest 1 2 840 113549 1 9 16 2 1 */
5048213, /* OBJ_id_smime_aa_securityLabel 1 2 840 113549 1 9 16 2 2 */
5049214, /* OBJ_id_smime_aa_mlExpandHistory 1 2 840 113549 1 9 16 2 3 */
5050215, /* OBJ_id_smime_aa_contentHint 1 2 840 113549 1 9 16 2 4 */
5051216, /* OBJ_id_smime_aa_msgSigDigest 1 2 840 113549 1 9 16 2 5 */
5052217, /* OBJ_id_smime_aa_encapContentType 1 2 840 113549 1 9 16 2 6 */
5053218, /* OBJ_id_smime_aa_contentIdentifier 1 2 840 113549 1 9 16 2 7 */
5054219, /* OBJ_id_smime_aa_macValue 1 2 840 113549 1 9 16 2 8 */
5055220, /* OBJ_id_smime_aa_equivalentLabels 1 2 840 113549 1 9 16 2 9 */
5056221, /* OBJ_id_smime_aa_contentReference 1 2 840 113549 1 9 16 2 10 */
5057222, /* OBJ_id_smime_aa_encrypKeyPref 1 2 840 113549 1 9 16 2 11 */
5058223, /* OBJ_id_smime_aa_signingCertificate 1 2 840 113549 1 9 16 2 12 */
5059224, /* OBJ_id_smime_aa_smimeEncryptCerts 1 2 840 113549 1 9 16 2 13 */
5060225, /* OBJ_id_smime_aa_timeStampToken 1 2 840 113549 1 9 16 2 14 */
5061226, /* OBJ_id_smime_aa_ets_sigPolicyId 1 2 840 113549 1 9 16 2 15 */
5062227, /* OBJ_id_smime_aa_ets_commitmentType 1 2 840 113549 1 9 16 2 16 */
5063228, /* OBJ_id_smime_aa_ets_signerLocation 1 2 840 113549 1 9 16 2 17 */
5064229, /* OBJ_id_smime_aa_ets_signerAttr 1 2 840 113549 1 9 16 2 18 */
5065230, /* OBJ_id_smime_aa_ets_otherSigCert 1 2 840 113549 1 9 16 2 19 */
5066231, /* OBJ_id_smime_aa_ets_contentTimestamp 1 2 840 113549 1 9 16 2 20 */
5067232, /* OBJ_id_smime_aa_ets_CertificateRefs 1 2 840 113549 1 9 16 2 21 */
5068233, /* OBJ_id_smime_aa_ets_RevocationRefs 1 2 840 113549 1 9 16 2 22 */
5069234, /* OBJ_id_smime_aa_ets_certValues 1 2 840 113549 1 9 16 2 23 */
5070235, /* OBJ_id_smime_aa_ets_revocationValues 1 2 840 113549 1 9 16 2 24 */
5071236, /* OBJ_id_smime_aa_ets_escTimeStamp 1 2 840 113549 1 9 16 2 25 */
5072237, /* OBJ_id_smime_aa_ets_certCRLTimestamp 1 2 840 113549 1 9 16 2 26 */
5073238, /* OBJ_id_smime_aa_ets_archiveTimeStamp 1 2 840 113549 1 9 16 2 27 */
5074239, /* OBJ_id_smime_aa_signatureType 1 2 840 113549 1 9 16 2 28 */
5075240, /* OBJ_id_smime_aa_dvcs_dvc 1 2 840 113549 1 9 16 2 29 */
5076241, /* OBJ_id_smime_alg_ESDHwith3DES 1 2 840 113549 1 9 16 3 1 */
5077242, /* OBJ_id_smime_alg_ESDHwithRC2 1 2 840 113549 1 9 16 3 2 */
5078243, /* OBJ_id_smime_alg_3DESwrap 1 2 840 113549 1 9 16 3 3 */
5079244, /* OBJ_id_smime_alg_RC2wrap 1 2 840 113549 1 9 16 3 4 */
5080245, /* OBJ_id_smime_alg_ESDH 1 2 840 113549 1 9 16 3 5 */
5081246, /* OBJ_id_smime_alg_CMS3DESwrap 1 2 840 113549 1 9 16 3 6 */
5082247, /* OBJ_id_smime_alg_CMSRC2wrap 1 2 840 113549 1 9 16 3 7 */
5083125, /* OBJ_zlib_compression 1 2 840 113549 1 9 16 3 8 */
5084893, /* OBJ_id_alg_PWRI_KEK 1 2 840 113549 1 9 16 3 9 */
5085248, /* OBJ_id_smime_cd_ldap 1 2 840 113549 1 9 16 4 1 */
5086249, /* OBJ_id_smime_spq_ets_sqt_uri 1 2 840 113549 1 9 16 5 1 */
5087250, /* OBJ_id_smime_spq_ets_sqt_unotice 1 2 840 113549 1 9 16 5 2 */
5088251, /* OBJ_id_smime_cti_ets_proofOfOrigin 1 2 840 113549 1 9 16 6 1 */
5089252, /* OBJ_id_smime_cti_ets_proofOfReceipt 1 2 840 113549 1 9 16 6 2 */
5090253, /* OBJ_id_smime_cti_ets_proofOfDelivery 1 2 840 113549 1 9 16 6 3 */
5091254, /* OBJ_id_smime_cti_ets_proofOfSender 1 2 840 113549 1 9 16 6 4 */
5092255, /* OBJ_id_smime_cti_ets_proofOfApproval 1 2 840 113549 1 9 16 6 5 */
5093256, /* OBJ_id_smime_cti_ets_proofOfCreation 1 2 840 113549 1 9 16 6 6 */
5094150, /* OBJ_keyBag 1 2 840 113549 1 12 10 1 1 */
5095151, /* OBJ_pkcs8ShroudedKeyBag 1 2 840 113549 1 12 10 1 2 */
5096152, /* OBJ_certBag 1 2 840 113549 1 12 10 1 3 */
5097153, /* OBJ_crlBag 1 2 840 113549 1 12 10 1 4 */
5098154, /* OBJ_secretBag 1 2 840 113549 1 12 10 1 5 */
5099155, /* OBJ_safeContentsBag 1 2 840 113549 1 12 10 1 6 */
510034, /* OBJ_idea_cbc 1 3 6 1 4 1 188 7 1 1 2 */
5101};
5102
diff --git a/src/lib/libcrypto/objects/obj_mac.h b/src/lib/libcrypto/objects/obj_mac.h
deleted file mode 100644
index b5ea7cdab4..0000000000
--- a/src/lib/libcrypto/objects/obj_mac.h
+++ /dev/null
@@ -1,4032 +0,0 @@
1/* crypto/objects/obj_mac.h */
2
3/* THIS FILE IS GENERATED FROM objects.txt by objects.pl via the
4 * following command:
5 * perl objects.pl objects.txt obj_mac.num obj_mac.h
6 */
7
8/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
9 * All rights reserved.
10 *
11 * This package is an SSL implementation written
12 * by Eric Young (eay@cryptsoft.com).
13 * The implementation was written so as to conform with Netscapes SSL.
14 *
15 * This library is free for commercial and non-commercial use as long as
16 * the following conditions are aheared to. The following conditions
17 * apply to all code found in this distribution, be it the RC4, RSA,
18 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
19 * included with this distribution is covered by the same copyright terms
20 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
21 *
22 * Copyright remains Eric Young's, and as such any Copyright notices in
23 * the code are not to be removed.
24 * If this package is used in a product, Eric Young should be given attribution
25 * as the author of the parts of the library used.
26 * This can be in the form of a textual message at program startup or
27 * in documentation (online or textual) provided with the package.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 * 1. Redistributions of source code must retain the copyright
33 * notice, this list of conditions and the following disclaimer.
34 * 2. Redistributions in binary form must reproduce the above copyright
35 * notice, this list of conditions and the following disclaimer in the
36 * documentation and/or other materials provided with the distribution.
37 * 3. All advertising materials mentioning features or use of this software
38 * must display the following acknowledgement:
39 * "This product includes cryptographic software written by
40 * Eric Young (eay@cryptsoft.com)"
41 * The word 'cryptographic' can be left out if the rouines from the library
42 * being used are not cryptographic related :-).
43 * 4. If you include any Windows specific code (or a derivative thereof) from
44 * the apps directory (application code) you must include an acknowledgement:
45 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
46 *
47 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
48 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 *
59 * The licence and distribution terms for any publically available version or
60 * derivative of this code cannot be changed. i.e. this code cannot simply be
61 * copied and put under another distribution licence
62 * [including the GNU Public Licence.]
63 */
64
65#define SN_undef "UNDEF"
66#define LN_undef "undefined"
67#define NID_undef 0
68#define OBJ_undef 0L
69
70#define SN_itu_t "ITU-T"
71#define LN_itu_t "itu-t"
72#define NID_itu_t 645
73#define OBJ_itu_t 0L
74
75#define NID_ccitt 404
76#define OBJ_ccitt OBJ_itu_t
77
78#define SN_iso "ISO"
79#define LN_iso "iso"
80#define NID_iso 181
81#define OBJ_iso 1L
82
83#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T"
84#define LN_joint_iso_itu_t "joint-iso-itu-t"
85#define NID_joint_iso_itu_t 646
86#define OBJ_joint_iso_itu_t 2L
87
88#define NID_joint_iso_ccitt 393
89#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t
90
91#define SN_member_body "member-body"
92#define LN_member_body "ISO Member Body"
93#define NID_member_body 182
94#define OBJ_member_body OBJ_iso,2L
95
96#define SN_identified_organization "identified-organization"
97#define NID_identified_organization 676
98#define OBJ_identified_organization OBJ_iso,3L
99
100#define SN_hmac_md5 "HMAC-MD5"
101#define LN_hmac_md5 "hmac-md5"
102#define NID_hmac_md5 780
103#define OBJ_hmac_md5 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L
104
105#define SN_hmac_sha1 "HMAC-SHA1"
106#define LN_hmac_sha1 "hmac-sha1"
107#define NID_hmac_sha1 781
108#define OBJ_hmac_sha1 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L
109
110#define SN_certicom_arc "certicom-arc"
111#define NID_certicom_arc 677
112#define OBJ_certicom_arc OBJ_identified_organization,132L
113
114#define SN_international_organizations "international-organizations"
115#define LN_international_organizations "International Organizations"
116#define NID_international_organizations 647
117#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L
118
119#define SN_wap "wap"
120#define NID_wap 678
121#define OBJ_wap OBJ_international_organizations,43L
122
123#define SN_wap_wsg "wap-wsg"
124#define NID_wap_wsg 679
125#define OBJ_wap_wsg OBJ_wap,1L
126
127#define SN_selected_attribute_types "selected-attribute-types"
128#define LN_selected_attribute_types "Selected Attribute Types"
129#define NID_selected_attribute_types 394
130#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L
131
132#define SN_clearance "clearance"
133#define NID_clearance 395
134#define OBJ_clearance OBJ_selected_attribute_types,55L
135
136#define SN_ISO_US "ISO-US"
137#define LN_ISO_US "ISO US Member Body"
138#define NID_ISO_US 183
139#define OBJ_ISO_US OBJ_member_body,840L
140
141#define SN_X9_57 "X9-57"
142#define LN_X9_57 "X9.57"
143#define NID_X9_57 184
144#define OBJ_X9_57 OBJ_ISO_US,10040L
145
146#define SN_X9cm "X9cm"
147#define LN_X9cm "X9.57 CM ?"
148#define NID_X9cm 185
149#define OBJ_X9cm OBJ_X9_57,4L
150
151#define SN_dsa "DSA"
152#define LN_dsa "dsaEncryption"
153#define NID_dsa 116
154#define OBJ_dsa OBJ_X9cm,1L
155
156#define SN_dsaWithSHA1 "DSA-SHA1"
157#define LN_dsaWithSHA1 "dsaWithSHA1"
158#define NID_dsaWithSHA1 113
159#define OBJ_dsaWithSHA1 OBJ_X9cm,3L
160
161#define SN_ansi_X9_62 "ansi-X9-62"
162#define LN_ansi_X9_62 "ANSI X9.62"
163#define NID_ansi_X9_62 405
164#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L
165
166#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L
167
168#define SN_X9_62_prime_field "prime-field"
169#define NID_X9_62_prime_field 406
170#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L
171
172#define SN_X9_62_characteristic_two_field "characteristic-two-field"
173#define NID_X9_62_characteristic_two_field 407
174#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L
175
176#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis"
177#define NID_X9_62_id_characteristic_two_basis 680
178#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L
179
180#define SN_X9_62_onBasis "onBasis"
181#define NID_X9_62_onBasis 681
182#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L
183
184#define SN_X9_62_tpBasis "tpBasis"
185#define NID_X9_62_tpBasis 682
186#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L
187
188#define SN_X9_62_ppBasis "ppBasis"
189#define NID_X9_62_ppBasis 683
190#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L
191
192#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L
193
194#define SN_X9_62_id_ecPublicKey "id-ecPublicKey"
195#define NID_X9_62_id_ecPublicKey 408
196#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L
197
198#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L
199
200#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L
201
202#define SN_X9_62_c2pnb163v1 "c2pnb163v1"
203#define NID_X9_62_c2pnb163v1 684
204#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L
205
206#define SN_X9_62_c2pnb163v2 "c2pnb163v2"
207#define NID_X9_62_c2pnb163v2 685
208#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L
209
210#define SN_X9_62_c2pnb163v3 "c2pnb163v3"
211#define NID_X9_62_c2pnb163v3 686
212#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L
213
214#define SN_X9_62_c2pnb176v1 "c2pnb176v1"
215#define NID_X9_62_c2pnb176v1 687
216#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L
217
218#define SN_X9_62_c2tnb191v1 "c2tnb191v1"
219#define NID_X9_62_c2tnb191v1 688
220#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L
221
222#define SN_X9_62_c2tnb191v2 "c2tnb191v2"
223#define NID_X9_62_c2tnb191v2 689
224#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L
225
226#define SN_X9_62_c2tnb191v3 "c2tnb191v3"
227#define NID_X9_62_c2tnb191v3 690
228#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L
229
230#define SN_X9_62_c2onb191v4 "c2onb191v4"
231#define NID_X9_62_c2onb191v4 691
232#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L
233
234#define SN_X9_62_c2onb191v5 "c2onb191v5"
235#define NID_X9_62_c2onb191v5 692
236#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L
237
238#define SN_X9_62_c2pnb208w1 "c2pnb208w1"
239#define NID_X9_62_c2pnb208w1 693
240#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L
241
242#define SN_X9_62_c2tnb239v1 "c2tnb239v1"
243#define NID_X9_62_c2tnb239v1 694
244#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L
245
246#define SN_X9_62_c2tnb239v2 "c2tnb239v2"
247#define NID_X9_62_c2tnb239v2 695
248#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L
249
250#define SN_X9_62_c2tnb239v3 "c2tnb239v3"
251#define NID_X9_62_c2tnb239v3 696
252#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L
253
254#define SN_X9_62_c2onb239v4 "c2onb239v4"
255#define NID_X9_62_c2onb239v4 697
256#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L
257
258#define SN_X9_62_c2onb239v5 "c2onb239v5"
259#define NID_X9_62_c2onb239v5 698
260#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L
261
262#define SN_X9_62_c2pnb272w1 "c2pnb272w1"
263#define NID_X9_62_c2pnb272w1 699
264#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L
265
266#define SN_X9_62_c2pnb304w1 "c2pnb304w1"
267#define NID_X9_62_c2pnb304w1 700
268#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L
269
270#define SN_X9_62_c2tnb359v1 "c2tnb359v1"
271#define NID_X9_62_c2tnb359v1 701
272#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L
273
274#define SN_X9_62_c2pnb368w1 "c2pnb368w1"
275#define NID_X9_62_c2pnb368w1 702
276#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L
277
278#define SN_X9_62_c2tnb431r1 "c2tnb431r1"
279#define NID_X9_62_c2tnb431r1 703
280#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L
281
282#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L
283
284#define SN_X9_62_prime192v1 "prime192v1"
285#define NID_X9_62_prime192v1 409
286#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L
287
288#define SN_X9_62_prime192v2 "prime192v2"
289#define NID_X9_62_prime192v2 410
290#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L
291
292#define SN_X9_62_prime192v3 "prime192v3"
293#define NID_X9_62_prime192v3 411
294#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L
295
296#define SN_X9_62_prime239v1 "prime239v1"
297#define NID_X9_62_prime239v1 412
298#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L
299
300#define SN_X9_62_prime239v2 "prime239v2"
301#define NID_X9_62_prime239v2 413
302#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L
303
304#define SN_X9_62_prime239v3 "prime239v3"
305#define NID_X9_62_prime239v3 414
306#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L
307
308#define SN_X9_62_prime256v1 "prime256v1"
309#define NID_X9_62_prime256v1 415
310#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L
311
312#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L
313
314#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1"
315#define NID_ecdsa_with_SHA1 416
316#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L
317
318#define SN_ecdsa_with_Recommended "ecdsa-with-Recommended"
319#define NID_ecdsa_with_Recommended 791
320#define OBJ_ecdsa_with_Recommended OBJ_X9_62_id_ecSigType,2L
321
322#define SN_ecdsa_with_Specified "ecdsa-with-Specified"
323#define NID_ecdsa_with_Specified 792
324#define OBJ_ecdsa_with_Specified OBJ_X9_62_id_ecSigType,3L
325
326#define SN_ecdsa_with_SHA224 "ecdsa-with-SHA224"
327#define NID_ecdsa_with_SHA224 793
328#define OBJ_ecdsa_with_SHA224 OBJ_ecdsa_with_Specified,1L
329
330#define SN_ecdsa_with_SHA256 "ecdsa-with-SHA256"
331#define NID_ecdsa_with_SHA256 794
332#define OBJ_ecdsa_with_SHA256 OBJ_ecdsa_with_Specified,2L
333
334#define SN_ecdsa_with_SHA384 "ecdsa-with-SHA384"
335#define NID_ecdsa_with_SHA384 795
336#define OBJ_ecdsa_with_SHA384 OBJ_ecdsa_with_Specified,3L
337
338#define SN_ecdsa_with_SHA512 "ecdsa-with-SHA512"
339#define NID_ecdsa_with_SHA512 796
340#define OBJ_ecdsa_with_SHA512 OBJ_ecdsa_with_Specified,4L
341
342#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L
343
344#define SN_secp112r1 "secp112r1"
345#define NID_secp112r1 704
346#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L
347
348#define SN_secp112r2 "secp112r2"
349#define NID_secp112r2 705
350#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L
351
352#define SN_secp128r1 "secp128r1"
353#define NID_secp128r1 706
354#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L
355
356#define SN_secp128r2 "secp128r2"
357#define NID_secp128r2 707
358#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L
359
360#define SN_secp160k1 "secp160k1"
361#define NID_secp160k1 708
362#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L
363
364#define SN_secp160r1 "secp160r1"
365#define NID_secp160r1 709
366#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L
367
368#define SN_secp160r2 "secp160r2"
369#define NID_secp160r2 710
370#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L
371
372#define SN_secp192k1 "secp192k1"
373#define NID_secp192k1 711
374#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L
375
376#define SN_secp224k1 "secp224k1"
377#define NID_secp224k1 712
378#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L
379
380#define SN_secp224r1 "secp224r1"
381#define NID_secp224r1 713
382#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L
383
384#define SN_secp256k1 "secp256k1"
385#define NID_secp256k1 714
386#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L
387
388#define SN_secp384r1 "secp384r1"
389#define NID_secp384r1 715
390#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L
391
392#define SN_secp521r1 "secp521r1"
393#define NID_secp521r1 716
394#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L
395
396#define SN_sect113r1 "sect113r1"
397#define NID_sect113r1 717
398#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L
399
400#define SN_sect113r2 "sect113r2"
401#define NID_sect113r2 718
402#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L
403
404#define SN_sect131r1 "sect131r1"
405#define NID_sect131r1 719
406#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L
407
408#define SN_sect131r2 "sect131r2"
409#define NID_sect131r2 720
410#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L
411
412#define SN_sect163k1 "sect163k1"
413#define NID_sect163k1 721
414#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L
415
416#define SN_sect163r1 "sect163r1"
417#define NID_sect163r1 722
418#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L
419
420#define SN_sect163r2 "sect163r2"
421#define NID_sect163r2 723
422#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L
423
424#define SN_sect193r1 "sect193r1"
425#define NID_sect193r1 724
426#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L
427
428#define SN_sect193r2 "sect193r2"
429#define NID_sect193r2 725
430#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L
431
432#define SN_sect233k1 "sect233k1"
433#define NID_sect233k1 726
434#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L
435
436#define SN_sect233r1 "sect233r1"
437#define NID_sect233r1 727
438#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L
439
440#define SN_sect239k1 "sect239k1"
441#define NID_sect239k1 728
442#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L
443
444#define SN_sect283k1 "sect283k1"
445#define NID_sect283k1 729
446#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L
447
448#define SN_sect283r1 "sect283r1"
449#define NID_sect283r1 730
450#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L
451
452#define SN_sect409k1 "sect409k1"
453#define NID_sect409k1 731
454#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L
455
456#define SN_sect409r1 "sect409r1"
457#define NID_sect409r1 732
458#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L
459
460#define SN_sect571k1 "sect571k1"
461#define NID_sect571k1 733
462#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L
463
464#define SN_sect571r1 "sect571r1"
465#define NID_sect571r1 734
466#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L
467
468#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L
469
470#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1"
471#define NID_wap_wsg_idm_ecid_wtls1 735
472#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L
473
474#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3"
475#define NID_wap_wsg_idm_ecid_wtls3 736
476#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L
477
478#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4"
479#define NID_wap_wsg_idm_ecid_wtls4 737
480#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L
481
482#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5"
483#define NID_wap_wsg_idm_ecid_wtls5 738
484#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L
485
486#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6"
487#define NID_wap_wsg_idm_ecid_wtls6 739
488#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L
489
490#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7"
491#define NID_wap_wsg_idm_ecid_wtls7 740
492#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L
493
494#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8"
495#define NID_wap_wsg_idm_ecid_wtls8 741
496#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L
497
498#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9"
499#define NID_wap_wsg_idm_ecid_wtls9 742
500#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L
501
502#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10"
503#define NID_wap_wsg_idm_ecid_wtls10 743
504#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L
505
506#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11"
507#define NID_wap_wsg_idm_ecid_wtls11 744
508#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L
509
510#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12"
511#define NID_wap_wsg_idm_ecid_wtls12 745
512#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L
513
514#define SN_cast5_cbc "CAST5-CBC"
515#define LN_cast5_cbc "cast5-cbc"
516#define NID_cast5_cbc 108
517#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L
518
519#define SN_cast5_ecb "CAST5-ECB"
520#define LN_cast5_ecb "cast5-ecb"
521#define NID_cast5_ecb 109
522
523#define SN_cast5_cfb64 "CAST5-CFB"
524#define LN_cast5_cfb64 "cast5-cfb"
525#define NID_cast5_cfb64 110
526
527#define SN_cast5_ofb64 "CAST5-OFB"
528#define LN_cast5_ofb64 "cast5-ofb"
529#define NID_cast5_ofb64 111
530
531#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC"
532#define NID_pbeWithMD5AndCast5_CBC 112
533#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L
534
535#define SN_id_PasswordBasedMAC "id-PasswordBasedMAC"
536#define LN_id_PasswordBasedMAC "password based MAC"
537#define NID_id_PasswordBasedMAC 782
538#define OBJ_id_PasswordBasedMAC OBJ_ISO_US,113533L,7L,66L,13L
539
540#define SN_id_DHBasedMac "id-DHBasedMac"
541#define LN_id_DHBasedMac "Diffie-Hellman based MAC"
542#define NID_id_DHBasedMac 783
543#define OBJ_id_DHBasedMac OBJ_ISO_US,113533L,7L,66L,30L
544
545#define SN_rsadsi "rsadsi"
546#define LN_rsadsi "RSA Data Security, Inc."
547#define NID_rsadsi 1
548#define OBJ_rsadsi OBJ_ISO_US,113549L
549
550#define SN_pkcs "pkcs"
551#define LN_pkcs "RSA Data Security, Inc. PKCS"
552#define NID_pkcs 2
553#define OBJ_pkcs OBJ_rsadsi,1L
554
555#define SN_pkcs1 "pkcs1"
556#define NID_pkcs1 186
557#define OBJ_pkcs1 OBJ_pkcs,1L
558
559#define LN_rsaEncryption "rsaEncryption"
560#define NID_rsaEncryption 6
561#define OBJ_rsaEncryption OBJ_pkcs1,1L
562
563#define SN_md2WithRSAEncryption "RSA-MD2"
564#define LN_md2WithRSAEncryption "md2WithRSAEncryption"
565#define NID_md2WithRSAEncryption 7
566#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L
567
568#define SN_md4WithRSAEncryption "RSA-MD4"
569#define LN_md4WithRSAEncryption "md4WithRSAEncryption"
570#define NID_md4WithRSAEncryption 396
571#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L
572
573#define SN_md5WithRSAEncryption "RSA-MD5"
574#define LN_md5WithRSAEncryption "md5WithRSAEncryption"
575#define NID_md5WithRSAEncryption 8
576#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L
577
578#define SN_sha1WithRSAEncryption "RSA-SHA1"
579#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption"
580#define NID_sha1WithRSAEncryption 65
581#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L
582
583#define SN_rsaesOaep "RSAES-OAEP"
584#define LN_rsaesOaep "rsaesOaep"
585#define NID_rsaesOaep 919
586#define OBJ_rsaesOaep OBJ_pkcs1,7L
587
588#define SN_mgf1 "MGF1"
589#define LN_mgf1 "mgf1"
590#define NID_mgf1 911
591#define OBJ_mgf1 OBJ_pkcs1,8L
592
593#define SN_rsassaPss "RSASSA-PSS"
594#define LN_rsassaPss "rsassaPss"
595#define NID_rsassaPss 912
596#define OBJ_rsassaPss OBJ_pkcs1,10L
597
598#define SN_sha256WithRSAEncryption "RSA-SHA256"
599#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption"
600#define NID_sha256WithRSAEncryption 668
601#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L
602
603#define SN_sha384WithRSAEncryption "RSA-SHA384"
604#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption"
605#define NID_sha384WithRSAEncryption 669
606#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L
607
608#define SN_sha512WithRSAEncryption "RSA-SHA512"
609#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption"
610#define NID_sha512WithRSAEncryption 670
611#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L
612
613#define SN_sha224WithRSAEncryption "RSA-SHA224"
614#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption"
615#define NID_sha224WithRSAEncryption 671
616#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L
617
618#define SN_pkcs3 "pkcs3"
619#define NID_pkcs3 27
620#define OBJ_pkcs3 OBJ_pkcs,3L
621
622#define LN_dhKeyAgreement "dhKeyAgreement"
623#define NID_dhKeyAgreement 28
624#define OBJ_dhKeyAgreement OBJ_pkcs3,1L
625
626#define SN_pkcs5 "pkcs5"
627#define NID_pkcs5 187
628#define OBJ_pkcs5 OBJ_pkcs,5L
629
630#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES"
631#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC"
632#define NID_pbeWithMD2AndDES_CBC 9
633#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L
634
635#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES"
636#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC"
637#define NID_pbeWithMD5AndDES_CBC 10
638#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L
639
640#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64"
641#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC"
642#define NID_pbeWithMD2AndRC2_CBC 168
643#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L
644
645#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64"
646#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC"
647#define NID_pbeWithMD5AndRC2_CBC 169
648#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L
649
650#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES"
651#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC"
652#define NID_pbeWithSHA1AndDES_CBC 170
653#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L
654
655#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64"
656#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC"
657#define NID_pbeWithSHA1AndRC2_CBC 68
658#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L
659
660#define LN_id_pbkdf2 "PBKDF2"
661#define NID_id_pbkdf2 69
662#define OBJ_id_pbkdf2 OBJ_pkcs5,12L
663
664#define LN_pbes2 "PBES2"
665#define NID_pbes2 161
666#define OBJ_pbes2 OBJ_pkcs5,13L
667
668#define LN_pbmac1 "PBMAC1"
669#define NID_pbmac1 162
670#define OBJ_pbmac1 OBJ_pkcs5,14L
671
672#define SN_pkcs7 "pkcs7"
673#define NID_pkcs7 20
674#define OBJ_pkcs7 OBJ_pkcs,7L
675
676#define LN_pkcs7_data "pkcs7-data"
677#define NID_pkcs7_data 21
678#define OBJ_pkcs7_data OBJ_pkcs7,1L
679
680#define LN_pkcs7_signed "pkcs7-signedData"
681#define NID_pkcs7_signed 22
682#define OBJ_pkcs7_signed OBJ_pkcs7,2L
683
684#define LN_pkcs7_enveloped "pkcs7-envelopedData"
685#define NID_pkcs7_enveloped 23
686#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L
687
688#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData"
689#define NID_pkcs7_signedAndEnveloped 24
690#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L
691
692#define LN_pkcs7_digest "pkcs7-digestData"
693#define NID_pkcs7_digest 25
694#define OBJ_pkcs7_digest OBJ_pkcs7,5L
695
696#define LN_pkcs7_encrypted "pkcs7-encryptedData"
697#define NID_pkcs7_encrypted 26
698#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L
699
700#define SN_pkcs9 "pkcs9"
701#define NID_pkcs9 47
702#define OBJ_pkcs9 OBJ_pkcs,9L
703
704#define LN_pkcs9_emailAddress "emailAddress"
705#define NID_pkcs9_emailAddress 48
706#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L
707
708#define LN_pkcs9_unstructuredName "unstructuredName"
709#define NID_pkcs9_unstructuredName 49
710#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L
711
712#define LN_pkcs9_contentType "contentType"
713#define NID_pkcs9_contentType 50
714#define OBJ_pkcs9_contentType OBJ_pkcs9,3L
715
716#define LN_pkcs9_messageDigest "messageDigest"
717#define NID_pkcs9_messageDigest 51
718#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L
719
720#define LN_pkcs9_signingTime "signingTime"
721#define NID_pkcs9_signingTime 52
722#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L
723
724#define LN_pkcs9_countersignature "countersignature"
725#define NID_pkcs9_countersignature 53
726#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L
727
728#define LN_pkcs9_challengePassword "challengePassword"
729#define NID_pkcs9_challengePassword 54
730#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L
731
732#define LN_pkcs9_unstructuredAddress "unstructuredAddress"
733#define NID_pkcs9_unstructuredAddress 55
734#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L
735
736#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes"
737#define NID_pkcs9_extCertAttributes 56
738#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L
739
740#define SN_ext_req "extReq"
741#define LN_ext_req "Extension Request"
742#define NID_ext_req 172
743#define OBJ_ext_req OBJ_pkcs9,14L
744
745#define SN_SMIMECapabilities "SMIME-CAPS"
746#define LN_SMIMECapabilities "S/MIME Capabilities"
747#define NID_SMIMECapabilities 167
748#define OBJ_SMIMECapabilities OBJ_pkcs9,15L
749
750#define SN_SMIME "SMIME"
751#define LN_SMIME "S/MIME"
752#define NID_SMIME 188
753#define OBJ_SMIME OBJ_pkcs9,16L
754
755#define SN_id_smime_mod "id-smime-mod"
756#define NID_id_smime_mod 189
757#define OBJ_id_smime_mod OBJ_SMIME,0L
758
759#define SN_id_smime_ct "id-smime-ct"
760#define NID_id_smime_ct 190
761#define OBJ_id_smime_ct OBJ_SMIME,1L
762
763#define SN_id_smime_aa "id-smime-aa"
764#define NID_id_smime_aa 191
765#define OBJ_id_smime_aa OBJ_SMIME,2L
766
767#define SN_id_smime_alg "id-smime-alg"
768#define NID_id_smime_alg 192
769#define OBJ_id_smime_alg OBJ_SMIME,3L
770
771#define SN_id_smime_cd "id-smime-cd"
772#define NID_id_smime_cd 193
773#define OBJ_id_smime_cd OBJ_SMIME,4L
774
775#define SN_id_smime_spq "id-smime-spq"
776#define NID_id_smime_spq 194
777#define OBJ_id_smime_spq OBJ_SMIME,5L
778
779#define SN_id_smime_cti "id-smime-cti"
780#define NID_id_smime_cti 195
781#define OBJ_id_smime_cti OBJ_SMIME,6L
782
783#define SN_id_smime_mod_cms "id-smime-mod-cms"
784#define NID_id_smime_mod_cms 196
785#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L
786
787#define SN_id_smime_mod_ess "id-smime-mod-ess"
788#define NID_id_smime_mod_ess 197
789#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L
790
791#define SN_id_smime_mod_oid "id-smime-mod-oid"
792#define NID_id_smime_mod_oid 198
793#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L
794
795#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3"
796#define NID_id_smime_mod_msg_v3 199
797#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L
798
799#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88"
800#define NID_id_smime_mod_ets_eSignature_88 200
801#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L
802
803#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97"
804#define NID_id_smime_mod_ets_eSignature_97 201
805#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L
806
807#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88"
808#define NID_id_smime_mod_ets_eSigPolicy_88 202
809#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L
810
811#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97"
812#define NID_id_smime_mod_ets_eSigPolicy_97 203
813#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L
814
815#define SN_id_smime_ct_receipt "id-smime-ct-receipt"
816#define NID_id_smime_ct_receipt 204
817#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L
818
819#define SN_id_smime_ct_authData "id-smime-ct-authData"
820#define NID_id_smime_ct_authData 205
821#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L
822
823#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert"
824#define NID_id_smime_ct_publishCert 206
825#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L
826
827#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo"
828#define NID_id_smime_ct_TSTInfo 207
829#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L
830
831#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo"
832#define NID_id_smime_ct_TDTInfo 208
833#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L
834
835#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo"
836#define NID_id_smime_ct_contentInfo 209
837#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L
838
839#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData"
840#define NID_id_smime_ct_DVCSRequestData 210
841#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L
842
843#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData"
844#define NID_id_smime_ct_DVCSResponseData 211
845#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L
846
847#define SN_id_smime_ct_compressedData "id-smime-ct-compressedData"
848#define NID_id_smime_ct_compressedData 786
849#define OBJ_id_smime_ct_compressedData OBJ_id_smime_ct,9L
850
851#define SN_id_ct_asciiTextWithCRLF "id-ct-asciiTextWithCRLF"
852#define NID_id_ct_asciiTextWithCRLF 787
853#define OBJ_id_ct_asciiTextWithCRLF OBJ_id_smime_ct,27L
854
855#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest"
856#define NID_id_smime_aa_receiptRequest 212
857#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L
858
859#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel"
860#define NID_id_smime_aa_securityLabel 213
861#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L
862
863#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory"
864#define NID_id_smime_aa_mlExpandHistory 214
865#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L
866
867#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint"
868#define NID_id_smime_aa_contentHint 215
869#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L
870
871#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest"
872#define NID_id_smime_aa_msgSigDigest 216
873#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L
874
875#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType"
876#define NID_id_smime_aa_encapContentType 217
877#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L
878
879#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier"
880#define NID_id_smime_aa_contentIdentifier 218
881#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L
882
883#define SN_id_smime_aa_macValue "id-smime-aa-macValue"
884#define NID_id_smime_aa_macValue 219
885#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L
886
887#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels"
888#define NID_id_smime_aa_equivalentLabels 220
889#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L
890
891#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference"
892#define NID_id_smime_aa_contentReference 221
893#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L
894
895#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref"
896#define NID_id_smime_aa_encrypKeyPref 222
897#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L
898
899#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate"
900#define NID_id_smime_aa_signingCertificate 223
901#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L
902
903#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts"
904#define NID_id_smime_aa_smimeEncryptCerts 224
905#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L
906
907#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken"
908#define NID_id_smime_aa_timeStampToken 225
909#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L
910
911#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId"
912#define NID_id_smime_aa_ets_sigPolicyId 226
913#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L
914
915#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType"
916#define NID_id_smime_aa_ets_commitmentType 227
917#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L
918
919#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation"
920#define NID_id_smime_aa_ets_signerLocation 228
921#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L
922
923#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr"
924#define NID_id_smime_aa_ets_signerAttr 229
925#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L
926
927#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert"
928#define NID_id_smime_aa_ets_otherSigCert 230
929#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L
930
931#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp"
932#define NID_id_smime_aa_ets_contentTimestamp 231
933#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L
934
935#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs"
936#define NID_id_smime_aa_ets_CertificateRefs 232
937#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L
938
939#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs"
940#define NID_id_smime_aa_ets_RevocationRefs 233
941#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L
942
943#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues"
944#define NID_id_smime_aa_ets_certValues 234
945#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L
946
947#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues"
948#define NID_id_smime_aa_ets_revocationValues 235
949#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L
950
951#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp"
952#define NID_id_smime_aa_ets_escTimeStamp 236
953#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L
954
955#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp"
956#define NID_id_smime_aa_ets_certCRLTimestamp 237
957#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L
958
959#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp"
960#define NID_id_smime_aa_ets_archiveTimeStamp 238
961#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L
962
963#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType"
964#define NID_id_smime_aa_signatureType 239
965#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L
966
967#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc"
968#define NID_id_smime_aa_dvcs_dvc 240
969#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L
970
971#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES"
972#define NID_id_smime_alg_ESDHwith3DES 241
973#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L
974
975#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2"
976#define NID_id_smime_alg_ESDHwithRC2 242
977#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L
978
979#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap"
980#define NID_id_smime_alg_3DESwrap 243
981#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L
982
983#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap"
984#define NID_id_smime_alg_RC2wrap 244
985#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L
986
987#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH"
988#define NID_id_smime_alg_ESDH 245
989#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L
990
991#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap"
992#define NID_id_smime_alg_CMS3DESwrap 246
993#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L
994
995#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap"
996#define NID_id_smime_alg_CMSRC2wrap 247
997#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L
998
999#define SN_id_alg_PWRI_KEK "id-alg-PWRI-KEK"
1000#define NID_id_alg_PWRI_KEK 893
1001#define OBJ_id_alg_PWRI_KEK OBJ_id_smime_alg,9L
1002
1003#define SN_id_smime_cd_ldap "id-smime-cd-ldap"
1004#define NID_id_smime_cd_ldap 248
1005#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L
1006
1007#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri"
1008#define NID_id_smime_spq_ets_sqt_uri 249
1009#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L
1010
1011#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice"
1012#define NID_id_smime_spq_ets_sqt_unotice 250
1013#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L
1014
1015#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin"
1016#define NID_id_smime_cti_ets_proofOfOrigin 251
1017#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L
1018
1019#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt"
1020#define NID_id_smime_cti_ets_proofOfReceipt 252
1021#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L
1022
1023#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery"
1024#define NID_id_smime_cti_ets_proofOfDelivery 253
1025#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L
1026
1027#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender"
1028#define NID_id_smime_cti_ets_proofOfSender 254
1029#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L
1030
1031#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval"
1032#define NID_id_smime_cti_ets_proofOfApproval 255
1033#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L
1034
1035#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation"
1036#define NID_id_smime_cti_ets_proofOfCreation 256
1037#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L
1038
1039#define LN_friendlyName "friendlyName"
1040#define NID_friendlyName 156
1041#define OBJ_friendlyName OBJ_pkcs9,20L
1042
1043#define LN_localKeyID "localKeyID"
1044#define NID_localKeyID 157
1045#define OBJ_localKeyID OBJ_pkcs9,21L
1046
1047#define SN_ms_csp_name "CSPName"
1048#define LN_ms_csp_name "Microsoft CSP Name"
1049#define NID_ms_csp_name 417
1050#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L
1051
1052#define SN_LocalKeySet "LocalKeySet"
1053#define LN_LocalKeySet "Microsoft Local Key set"
1054#define NID_LocalKeySet 856
1055#define OBJ_LocalKeySet 1L,3L,6L,1L,4L,1L,311L,17L,2L
1056
1057#define OBJ_certTypes OBJ_pkcs9,22L
1058
1059#define LN_x509Certificate "x509Certificate"
1060#define NID_x509Certificate 158
1061#define OBJ_x509Certificate OBJ_certTypes,1L
1062
1063#define LN_sdsiCertificate "sdsiCertificate"
1064#define NID_sdsiCertificate 159
1065#define OBJ_sdsiCertificate OBJ_certTypes,2L
1066
1067#define OBJ_crlTypes OBJ_pkcs9,23L
1068
1069#define LN_x509Crl "x509Crl"
1070#define NID_x509Crl 160
1071#define OBJ_x509Crl OBJ_crlTypes,1L
1072
1073#define OBJ_pkcs12 OBJ_pkcs,12L
1074
1075#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L
1076
1077#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128"
1078#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4"
1079#define NID_pbe_WithSHA1And128BitRC4 144
1080#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L
1081
1082#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40"
1083#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4"
1084#define NID_pbe_WithSHA1And40BitRC4 145
1085#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L
1086
1087#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES"
1088#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC"
1089#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146
1090#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L
1091
1092#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES"
1093#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC"
1094#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147
1095#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L
1096
1097#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128"
1098#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC"
1099#define NID_pbe_WithSHA1And128BitRC2_CBC 148
1100#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L
1101
1102#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40"
1103#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC"
1104#define NID_pbe_WithSHA1And40BitRC2_CBC 149
1105#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L
1106
1107#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L
1108
1109#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L
1110
1111#define LN_keyBag "keyBag"
1112#define NID_keyBag 150
1113#define OBJ_keyBag OBJ_pkcs12_BagIds,1L
1114
1115#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag"
1116#define NID_pkcs8ShroudedKeyBag 151
1117#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L
1118
1119#define LN_certBag "certBag"
1120#define NID_certBag 152
1121#define OBJ_certBag OBJ_pkcs12_BagIds,3L
1122
1123#define LN_crlBag "crlBag"
1124#define NID_crlBag 153
1125#define OBJ_crlBag OBJ_pkcs12_BagIds,4L
1126
1127#define LN_secretBag "secretBag"
1128#define NID_secretBag 154
1129#define OBJ_secretBag OBJ_pkcs12_BagIds,5L
1130
1131#define LN_safeContentsBag "safeContentsBag"
1132#define NID_safeContentsBag 155
1133#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L
1134
1135#define SN_md2 "MD2"
1136#define LN_md2 "md2"
1137#define NID_md2 3
1138#define OBJ_md2 OBJ_rsadsi,2L,2L
1139
1140#define SN_md4 "MD4"
1141#define LN_md4 "md4"
1142#define NID_md4 257
1143#define OBJ_md4 OBJ_rsadsi,2L,4L
1144
1145#define SN_md5 "MD5"
1146#define LN_md5 "md5"
1147#define NID_md5 4
1148#define OBJ_md5 OBJ_rsadsi,2L,5L
1149
1150#define SN_md5_sha1 "MD5-SHA1"
1151#define LN_md5_sha1 "md5-sha1"
1152#define NID_md5_sha1 114
1153
1154#define LN_hmacWithMD5 "hmacWithMD5"
1155#define NID_hmacWithMD5 797
1156#define OBJ_hmacWithMD5 OBJ_rsadsi,2L,6L
1157
1158#define LN_hmacWithSHA1 "hmacWithSHA1"
1159#define NID_hmacWithSHA1 163
1160#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L
1161
1162#define LN_hmacWithSHA224 "hmacWithSHA224"
1163#define NID_hmacWithSHA224 798
1164#define OBJ_hmacWithSHA224 OBJ_rsadsi,2L,8L
1165
1166#define LN_hmacWithSHA256 "hmacWithSHA256"
1167#define NID_hmacWithSHA256 799
1168#define OBJ_hmacWithSHA256 OBJ_rsadsi,2L,9L
1169
1170#define LN_hmacWithSHA384 "hmacWithSHA384"
1171#define NID_hmacWithSHA384 800
1172#define OBJ_hmacWithSHA384 OBJ_rsadsi,2L,10L
1173
1174#define LN_hmacWithSHA512 "hmacWithSHA512"
1175#define NID_hmacWithSHA512 801
1176#define OBJ_hmacWithSHA512 OBJ_rsadsi,2L,11L
1177
1178#define SN_rc2_cbc "RC2-CBC"
1179#define LN_rc2_cbc "rc2-cbc"
1180#define NID_rc2_cbc 37
1181#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L
1182
1183#define SN_rc2_ecb "RC2-ECB"
1184#define LN_rc2_ecb "rc2-ecb"
1185#define NID_rc2_ecb 38
1186
1187#define SN_rc2_cfb64 "RC2-CFB"
1188#define LN_rc2_cfb64 "rc2-cfb"
1189#define NID_rc2_cfb64 39
1190
1191#define SN_rc2_ofb64 "RC2-OFB"
1192#define LN_rc2_ofb64 "rc2-ofb"
1193#define NID_rc2_ofb64 40
1194
1195#define SN_rc2_40_cbc "RC2-40-CBC"
1196#define LN_rc2_40_cbc "rc2-40-cbc"
1197#define NID_rc2_40_cbc 98
1198
1199#define SN_rc2_64_cbc "RC2-64-CBC"
1200#define LN_rc2_64_cbc "rc2-64-cbc"
1201#define NID_rc2_64_cbc 166
1202
1203#define SN_rc4 "RC4"
1204#define LN_rc4 "rc4"
1205#define NID_rc4 5
1206#define OBJ_rc4 OBJ_rsadsi,3L,4L
1207
1208#define SN_rc4_40 "RC4-40"
1209#define LN_rc4_40 "rc4-40"
1210#define NID_rc4_40 97
1211
1212#define SN_des_ede3_cbc "DES-EDE3-CBC"
1213#define LN_des_ede3_cbc "des-ede3-cbc"
1214#define NID_des_ede3_cbc 44
1215#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L
1216
1217#define SN_rc5_cbc "RC5-CBC"
1218#define LN_rc5_cbc "rc5-cbc"
1219#define NID_rc5_cbc 120
1220#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L
1221
1222#define SN_rc5_ecb "RC5-ECB"
1223#define LN_rc5_ecb "rc5-ecb"
1224#define NID_rc5_ecb 121
1225
1226#define SN_rc5_cfb64 "RC5-CFB"
1227#define LN_rc5_cfb64 "rc5-cfb"
1228#define NID_rc5_cfb64 122
1229
1230#define SN_rc5_ofb64 "RC5-OFB"
1231#define LN_rc5_ofb64 "rc5-ofb"
1232#define NID_rc5_ofb64 123
1233
1234#define SN_ms_ext_req "msExtReq"
1235#define LN_ms_ext_req "Microsoft Extension Request"
1236#define NID_ms_ext_req 171
1237#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L
1238
1239#define SN_ms_code_ind "msCodeInd"
1240#define LN_ms_code_ind "Microsoft Individual Code Signing"
1241#define NID_ms_code_ind 134
1242#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L
1243
1244#define SN_ms_code_com "msCodeCom"
1245#define LN_ms_code_com "Microsoft Commercial Code Signing"
1246#define NID_ms_code_com 135
1247#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L
1248
1249#define SN_ms_ctl_sign "msCTLSign"
1250#define LN_ms_ctl_sign "Microsoft Trust List Signing"
1251#define NID_ms_ctl_sign 136
1252#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L
1253
1254#define SN_ms_sgc "msSGC"
1255#define LN_ms_sgc "Microsoft Server Gated Crypto"
1256#define NID_ms_sgc 137
1257#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L
1258
1259#define SN_ms_efs "msEFS"
1260#define LN_ms_efs "Microsoft Encrypted File System"
1261#define NID_ms_efs 138
1262#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L
1263
1264#define SN_ms_smartcard_login "msSmartcardLogin"
1265#define LN_ms_smartcard_login "Microsoft Smartcardlogin"
1266#define NID_ms_smartcard_login 648
1267#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L
1268
1269#define SN_ms_upn "msUPN"
1270#define LN_ms_upn "Microsoft Universal Principal Name"
1271#define NID_ms_upn 649
1272#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L
1273
1274#define SN_idea_cbc "IDEA-CBC"
1275#define LN_idea_cbc "idea-cbc"
1276#define NID_idea_cbc 34
1277#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L
1278
1279#define SN_idea_ecb "IDEA-ECB"
1280#define LN_idea_ecb "idea-ecb"
1281#define NID_idea_ecb 36
1282
1283#define SN_idea_cfb64 "IDEA-CFB"
1284#define LN_idea_cfb64 "idea-cfb"
1285#define NID_idea_cfb64 35
1286
1287#define SN_idea_ofb64 "IDEA-OFB"
1288#define LN_idea_ofb64 "idea-ofb"
1289#define NID_idea_ofb64 46
1290
1291#define SN_bf_cbc "BF-CBC"
1292#define LN_bf_cbc "bf-cbc"
1293#define NID_bf_cbc 91
1294#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L
1295
1296#define SN_bf_ecb "BF-ECB"
1297#define LN_bf_ecb "bf-ecb"
1298#define NID_bf_ecb 92
1299
1300#define SN_bf_cfb64 "BF-CFB"
1301#define LN_bf_cfb64 "bf-cfb"
1302#define NID_bf_cfb64 93
1303
1304#define SN_bf_ofb64 "BF-OFB"
1305#define LN_bf_ofb64 "bf-ofb"
1306#define NID_bf_ofb64 94
1307
1308#define SN_id_pkix "PKIX"
1309#define NID_id_pkix 127
1310#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L
1311
1312#define SN_id_pkix_mod "id-pkix-mod"
1313#define NID_id_pkix_mod 258
1314#define OBJ_id_pkix_mod OBJ_id_pkix,0L
1315
1316#define SN_id_pe "id-pe"
1317#define NID_id_pe 175
1318#define OBJ_id_pe OBJ_id_pkix,1L
1319
1320#define SN_id_qt "id-qt"
1321#define NID_id_qt 259
1322#define OBJ_id_qt OBJ_id_pkix,2L
1323
1324#define SN_id_kp "id-kp"
1325#define NID_id_kp 128
1326#define OBJ_id_kp OBJ_id_pkix,3L
1327
1328#define SN_id_it "id-it"
1329#define NID_id_it 260
1330#define OBJ_id_it OBJ_id_pkix,4L
1331
1332#define SN_id_pkip "id-pkip"
1333#define NID_id_pkip 261
1334#define OBJ_id_pkip OBJ_id_pkix,5L
1335
1336#define SN_id_alg "id-alg"
1337#define NID_id_alg 262
1338#define OBJ_id_alg OBJ_id_pkix,6L
1339
1340#define SN_id_cmc "id-cmc"
1341#define NID_id_cmc 263
1342#define OBJ_id_cmc OBJ_id_pkix,7L
1343
1344#define SN_id_on "id-on"
1345#define NID_id_on 264
1346#define OBJ_id_on OBJ_id_pkix,8L
1347
1348#define SN_id_pda "id-pda"
1349#define NID_id_pda 265
1350#define OBJ_id_pda OBJ_id_pkix,9L
1351
1352#define SN_id_aca "id-aca"
1353#define NID_id_aca 266
1354#define OBJ_id_aca OBJ_id_pkix,10L
1355
1356#define SN_id_qcs "id-qcs"
1357#define NID_id_qcs 267
1358#define OBJ_id_qcs OBJ_id_pkix,11L
1359
1360#define SN_id_cct "id-cct"
1361#define NID_id_cct 268
1362#define OBJ_id_cct OBJ_id_pkix,12L
1363
1364#define SN_id_ppl "id-ppl"
1365#define NID_id_ppl 662
1366#define OBJ_id_ppl OBJ_id_pkix,21L
1367
1368#define SN_id_ad "id-ad"
1369#define NID_id_ad 176
1370#define OBJ_id_ad OBJ_id_pkix,48L
1371
1372#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88"
1373#define NID_id_pkix1_explicit_88 269
1374#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L
1375
1376#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88"
1377#define NID_id_pkix1_implicit_88 270
1378#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L
1379
1380#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93"
1381#define NID_id_pkix1_explicit_93 271
1382#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L
1383
1384#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93"
1385#define NID_id_pkix1_implicit_93 272
1386#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L
1387
1388#define SN_id_mod_crmf "id-mod-crmf"
1389#define NID_id_mod_crmf 273
1390#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L
1391
1392#define SN_id_mod_cmc "id-mod-cmc"
1393#define NID_id_mod_cmc 274
1394#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L
1395
1396#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88"
1397#define NID_id_mod_kea_profile_88 275
1398#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L
1399
1400#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93"
1401#define NID_id_mod_kea_profile_93 276
1402#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L
1403
1404#define SN_id_mod_cmp "id-mod-cmp"
1405#define NID_id_mod_cmp 277
1406#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L
1407
1408#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88"
1409#define NID_id_mod_qualified_cert_88 278
1410#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L
1411
1412#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93"
1413#define NID_id_mod_qualified_cert_93 279
1414#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L
1415
1416#define SN_id_mod_attribute_cert "id-mod-attribute-cert"
1417#define NID_id_mod_attribute_cert 280
1418#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L
1419
1420#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol"
1421#define NID_id_mod_timestamp_protocol 281
1422#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L
1423
1424#define SN_id_mod_ocsp "id-mod-ocsp"
1425#define NID_id_mod_ocsp 282
1426#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L
1427
1428#define SN_id_mod_dvcs "id-mod-dvcs"
1429#define NID_id_mod_dvcs 283
1430#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L
1431
1432#define SN_id_mod_cmp2000 "id-mod-cmp2000"
1433#define NID_id_mod_cmp2000 284
1434#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L
1435
1436#define SN_info_access "authorityInfoAccess"
1437#define LN_info_access "Authority Information Access"
1438#define NID_info_access 177
1439#define OBJ_info_access OBJ_id_pe,1L
1440
1441#define SN_biometricInfo "biometricInfo"
1442#define LN_biometricInfo "Biometric Info"
1443#define NID_biometricInfo 285
1444#define OBJ_biometricInfo OBJ_id_pe,2L
1445
1446#define SN_qcStatements "qcStatements"
1447#define NID_qcStatements 286
1448#define OBJ_qcStatements OBJ_id_pe,3L
1449
1450#define SN_ac_auditEntity "ac-auditEntity"
1451#define NID_ac_auditEntity 287
1452#define OBJ_ac_auditEntity OBJ_id_pe,4L
1453
1454#define SN_ac_targeting "ac-targeting"
1455#define NID_ac_targeting 288
1456#define OBJ_ac_targeting OBJ_id_pe,5L
1457
1458#define SN_aaControls "aaControls"
1459#define NID_aaControls 289
1460#define OBJ_aaControls OBJ_id_pe,6L
1461
1462#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock"
1463#define NID_sbgp_ipAddrBlock 290
1464#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L
1465
1466#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum"
1467#define NID_sbgp_autonomousSysNum 291
1468#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L
1469
1470#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier"
1471#define NID_sbgp_routerIdentifier 292
1472#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L
1473
1474#define SN_ac_proxying "ac-proxying"
1475#define NID_ac_proxying 397
1476#define OBJ_ac_proxying OBJ_id_pe,10L
1477
1478#define SN_sinfo_access "subjectInfoAccess"
1479#define LN_sinfo_access "Subject Information Access"
1480#define NID_sinfo_access 398
1481#define OBJ_sinfo_access OBJ_id_pe,11L
1482
1483#define SN_proxyCertInfo "proxyCertInfo"
1484#define LN_proxyCertInfo "Proxy Certificate Information"
1485#define NID_proxyCertInfo 663
1486#define OBJ_proxyCertInfo OBJ_id_pe,14L
1487
1488#define SN_id_qt_cps "id-qt-cps"
1489#define LN_id_qt_cps "Policy Qualifier CPS"
1490#define NID_id_qt_cps 164
1491#define OBJ_id_qt_cps OBJ_id_qt,1L
1492
1493#define SN_id_qt_unotice "id-qt-unotice"
1494#define LN_id_qt_unotice "Policy Qualifier User Notice"
1495#define NID_id_qt_unotice 165
1496#define OBJ_id_qt_unotice OBJ_id_qt,2L
1497
1498#define SN_textNotice "textNotice"
1499#define NID_textNotice 293
1500#define OBJ_textNotice OBJ_id_qt,3L
1501
1502#define SN_server_auth "serverAuth"
1503#define LN_server_auth "TLS Web Server Authentication"
1504#define NID_server_auth 129
1505#define OBJ_server_auth OBJ_id_kp,1L
1506
1507#define SN_client_auth "clientAuth"
1508#define LN_client_auth "TLS Web Client Authentication"
1509#define NID_client_auth 130
1510#define OBJ_client_auth OBJ_id_kp,2L
1511
1512#define SN_code_sign "codeSigning"
1513#define LN_code_sign "Code Signing"
1514#define NID_code_sign 131
1515#define OBJ_code_sign OBJ_id_kp,3L
1516
1517#define SN_email_protect "emailProtection"
1518#define LN_email_protect "E-mail Protection"
1519#define NID_email_protect 132
1520#define OBJ_email_protect OBJ_id_kp,4L
1521
1522#define SN_ipsecEndSystem "ipsecEndSystem"
1523#define LN_ipsecEndSystem "IPSec End System"
1524#define NID_ipsecEndSystem 294
1525#define OBJ_ipsecEndSystem OBJ_id_kp,5L
1526
1527#define SN_ipsecTunnel "ipsecTunnel"
1528#define LN_ipsecTunnel "IPSec Tunnel"
1529#define NID_ipsecTunnel 295
1530#define OBJ_ipsecTunnel OBJ_id_kp,6L
1531
1532#define SN_ipsecUser "ipsecUser"
1533#define LN_ipsecUser "IPSec User"
1534#define NID_ipsecUser 296
1535#define OBJ_ipsecUser OBJ_id_kp,7L
1536
1537#define SN_time_stamp "timeStamping"
1538#define LN_time_stamp "Time Stamping"
1539#define NID_time_stamp 133
1540#define OBJ_time_stamp OBJ_id_kp,8L
1541
1542#define SN_OCSP_sign "OCSPSigning"
1543#define LN_OCSP_sign "OCSP Signing"
1544#define NID_OCSP_sign 180
1545#define OBJ_OCSP_sign OBJ_id_kp,9L
1546
1547#define SN_dvcs "DVCS"
1548#define LN_dvcs "dvcs"
1549#define NID_dvcs 297
1550#define OBJ_dvcs OBJ_id_kp,10L
1551
1552#define SN_id_it_caProtEncCert "id-it-caProtEncCert"
1553#define NID_id_it_caProtEncCert 298
1554#define OBJ_id_it_caProtEncCert OBJ_id_it,1L
1555
1556#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes"
1557#define NID_id_it_signKeyPairTypes 299
1558#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L
1559
1560#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes"
1561#define NID_id_it_encKeyPairTypes 300
1562#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L
1563
1564#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg"
1565#define NID_id_it_preferredSymmAlg 301
1566#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L
1567
1568#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo"
1569#define NID_id_it_caKeyUpdateInfo 302
1570#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L
1571
1572#define SN_id_it_currentCRL "id-it-currentCRL"
1573#define NID_id_it_currentCRL 303
1574#define OBJ_id_it_currentCRL OBJ_id_it,6L
1575
1576#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs"
1577#define NID_id_it_unsupportedOIDs 304
1578#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L
1579
1580#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest"
1581#define NID_id_it_subscriptionRequest 305
1582#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L
1583
1584#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse"
1585#define NID_id_it_subscriptionResponse 306
1586#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L
1587
1588#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq"
1589#define NID_id_it_keyPairParamReq 307
1590#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L
1591
1592#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep"
1593#define NID_id_it_keyPairParamRep 308
1594#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L
1595
1596#define SN_id_it_revPassphrase "id-it-revPassphrase"
1597#define NID_id_it_revPassphrase 309
1598#define OBJ_id_it_revPassphrase OBJ_id_it,12L
1599
1600#define SN_id_it_implicitConfirm "id-it-implicitConfirm"
1601#define NID_id_it_implicitConfirm 310
1602#define OBJ_id_it_implicitConfirm OBJ_id_it,13L
1603
1604#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime"
1605#define NID_id_it_confirmWaitTime 311
1606#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L
1607
1608#define SN_id_it_origPKIMessage "id-it-origPKIMessage"
1609#define NID_id_it_origPKIMessage 312
1610#define OBJ_id_it_origPKIMessage OBJ_id_it,15L
1611
1612#define SN_id_it_suppLangTags "id-it-suppLangTags"
1613#define NID_id_it_suppLangTags 784
1614#define OBJ_id_it_suppLangTags OBJ_id_it,16L
1615
1616#define SN_id_regCtrl "id-regCtrl"
1617#define NID_id_regCtrl 313
1618#define OBJ_id_regCtrl OBJ_id_pkip,1L
1619
1620#define SN_id_regInfo "id-regInfo"
1621#define NID_id_regInfo 314
1622#define OBJ_id_regInfo OBJ_id_pkip,2L
1623
1624#define SN_id_regCtrl_regToken "id-regCtrl-regToken"
1625#define NID_id_regCtrl_regToken 315
1626#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L
1627
1628#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator"
1629#define NID_id_regCtrl_authenticator 316
1630#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L
1631
1632#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo"
1633#define NID_id_regCtrl_pkiPublicationInfo 317
1634#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L
1635
1636#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions"
1637#define NID_id_regCtrl_pkiArchiveOptions 318
1638#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L
1639
1640#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID"
1641#define NID_id_regCtrl_oldCertID 319
1642#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L
1643
1644#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey"
1645#define NID_id_regCtrl_protocolEncrKey 320
1646#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L
1647
1648#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs"
1649#define NID_id_regInfo_utf8Pairs 321
1650#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L
1651
1652#define SN_id_regInfo_certReq "id-regInfo-certReq"
1653#define NID_id_regInfo_certReq 322
1654#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L
1655
1656#define SN_id_alg_des40 "id-alg-des40"
1657#define NID_id_alg_des40 323
1658#define OBJ_id_alg_des40 OBJ_id_alg,1L
1659
1660#define SN_id_alg_noSignature "id-alg-noSignature"
1661#define NID_id_alg_noSignature 324
1662#define OBJ_id_alg_noSignature OBJ_id_alg,2L
1663
1664#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1"
1665#define NID_id_alg_dh_sig_hmac_sha1 325
1666#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L
1667
1668#define SN_id_alg_dh_pop "id-alg-dh-pop"
1669#define NID_id_alg_dh_pop 326
1670#define OBJ_id_alg_dh_pop OBJ_id_alg,4L
1671
1672#define SN_id_cmc_statusInfo "id-cmc-statusInfo"
1673#define NID_id_cmc_statusInfo 327
1674#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L
1675
1676#define SN_id_cmc_identification "id-cmc-identification"
1677#define NID_id_cmc_identification 328
1678#define OBJ_id_cmc_identification OBJ_id_cmc,2L
1679
1680#define SN_id_cmc_identityProof "id-cmc-identityProof"
1681#define NID_id_cmc_identityProof 329
1682#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L
1683
1684#define SN_id_cmc_dataReturn "id-cmc-dataReturn"
1685#define NID_id_cmc_dataReturn 330
1686#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L
1687
1688#define SN_id_cmc_transactionId "id-cmc-transactionId"
1689#define NID_id_cmc_transactionId 331
1690#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L
1691
1692#define SN_id_cmc_senderNonce "id-cmc-senderNonce"
1693#define NID_id_cmc_senderNonce 332
1694#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L
1695
1696#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce"
1697#define NID_id_cmc_recipientNonce 333
1698#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L
1699
1700#define SN_id_cmc_addExtensions "id-cmc-addExtensions"
1701#define NID_id_cmc_addExtensions 334
1702#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L
1703
1704#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP"
1705#define NID_id_cmc_encryptedPOP 335
1706#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L
1707
1708#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP"
1709#define NID_id_cmc_decryptedPOP 336
1710#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L
1711
1712#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness"
1713#define NID_id_cmc_lraPOPWitness 337
1714#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L
1715
1716#define SN_id_cmc_getCert "id-cmc-getCert"
1717#define NID_id_cmc_getCert 338
1718#define OBJ_id_cmc_getCert OBJ_id_cmc,15L
1719
1720#define SN_id_cmc_getCRL "id-cmc-getCRL"
1721#define NID_id_cmc_getCRL 339
1722#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L
1723
1724#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest"
1725#define NID_id_cmc_revokeRequest 340
1726#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L
1727
1728#define SN_id_cmc_regInfo "id-cmc-regInfo"
1729#define NID_id_cmc_regInfo 341
1730#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L
1731
1732#define SN_id_cmc_responseInfo "id-cmc-responseInfo"
1733#define NID_id_cmc_responseInfo 342
1734#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L
1735
1736#define SN_id_cmc_queryPending "id-cmc-queryPending"
1737#define NID_id_cmc_queryPending 343
1738#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L
1739
1740#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom"
1741#define NID_id_cmc_popLinkRandom 344
1742#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L
1743
1744#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness"
1745#define NID_id_cmc_popLinkWitness 345
1746#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L
1747
1748#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance"
1749#define NID_id_cmc_confirmCertAcceptance 346
1750#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L
1751
1752#define SN_id_on_personalData "id-on-personalData"
1753#define NID_id_on_personalData 347
1754#define OBJ_id_on_personalData OBJ_id_on,1L
1755
1756#define SN_id_on_permanentIdentifier "id-on-permanentIdentifier"
1757#define LN_id_on_permanentIdentifier "Permanent Identifier"
1758#define NID_id_on_permanentIdentifier 858
1759#define OBJ_id_on_permanentIdentifier OBJ_id_on,3L
1760
1761#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth"
1762#define NID_id_pda_dateOfBirth 348
1763#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L
1764
1765#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth"
1766#define NID_id_pda_placeOfBirth 349
1767#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L
1768
1769#define SN_id_pda_gender "id-pda-gender"
1770#define NID_id_pda_gender 351
1771#define OBJ_id_pda_gender OBJ_id_pda,3L
1772
1773#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship"
1774#define NID_id_pda_countryOfCitizenship 352
1775#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L
1776
1777#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence"
1778#define NID_id_pda_countryOfResidence 353
1779#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L
1780
1781#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo"
1782#define NID_id_aca_authenticationInfo 354
1783#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L
1784
1785#define SN_id_aca_accessIdentity "id-aca-accessIdentity"
1786#define NID_id_aca_accessIdentity 355
1787#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L
1788
1789#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity"
1790#define NID_id_aca_chargingIdentity 356
1791#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L
1792
1793#define SN_id_aca_group "id-aca-group"
1794#define NID_id_aca_group 357
1795#define OBJ_id_aca_group OBJ_id_aca,4L
1796
1797#define SN_id_aca_role "id-aca-role"
1798#define NID_id_aca_role 358
1799#define OBJ_id_aca_role OBJ_id_aca,5L
1800
1801#define SN_id_aca_encAttrs "id-aca-encAttrs"
1802#define NID_id_aca_encAttrs 399
1803#define OBJ_id_aca_encAttrs OBJ_id_aca,6L
1804
1805#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1"
1806#define NID_id_qcs_pkixQCSyntax_v1 359
1807#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L
1808
1809#define SN_id_cct_crs "id-cct-crs"
1810#define NID_id_cct_crs 360
1811#define OBJ_id_cct_crs OBJ_id_cct,1L
1812
1813#define SN_id_cct_PKIData "id-cct-PKIData"
1814#define NID_id_cct_PKIData 361
1815#define OBJ_id_cct_PKIData OBJ_id_cct,2L
1816
1817#define SN_id_cct_PKIResponse "id-cct-PKIResponse"
1818#define NID_id_cct_PKIResponse 362
1819#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L
1820
1821#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage"
1822#define LN_id_ppl_anyLanguage "Any language"
1823#define NID_id_ppl_anyLanguage 664
1824#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L
1825
1826#define SN_id_ppl_inheritAll "id-ppl-inheritAll"
1827#define LN_id_ppl_inheritAll "Inherit all"
1828#define NID_id_ppl_inheritAll 665
1829#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L
1830
1831#define SN_Independent "id-ppl-independent"
1832#define LN_Independent "Independent"
1833#define NID_Independent 667
1834#define OBJ_Independent OBJ_id_ppl,2L
1835
1836#define SN_ad_OCSP "OCSP"
1837#define LN_ad_OCSP "OCSP"
1838#define NID_ad_OCSP 178
1839#define OBJ_ad_OCSP OBJ_id_ad,1L
1840
1841#define SN_ad_ca_issuers "caIssuers"
1842#define LN_ad_ca_issuers "CA Issuers"
1843#define NID_ad_ca_issuers 179
1844#define OBJ_ad_ca_issuers OBJ_id_ad,2L
1845
1846#define SN_ad_timeStamping "ad_timestamping"
1847#define LN_ad_timeStamping "AD Time Stamping"
1848#define NID_ad_timeStamping 363
1849#define OBJ_ad_timeStamping OBJ_id_ad,3L
1850
1851#define SN_ad_dvcs "AD_DVCS"
1852#define LN_ad_dvcs "ad dvcs"
1853#define NID_ad_dvcs 364
1854#define OBJ_ad_dvcs OBJ_id_ad,4L
1855
1856#define SN_caRepository "caRepository"
1857#define LN_caRepository "CA Repository"
1858#define NID_caRepository 785
1859#define OBJ_caRepository OBJ_id_ad,5L
1860
1861#define OBJ_id_pkix_OCSP OBJ_ad_OCSP
1862
1863#define SN_id_pkix_OCSP_basic "basicOCSPResponse"
1864#define LN_id_pkix_OCSP_basic "Basic OCSP Response"
1865#define NID_id_pkix_OCSP_basic 365
1866#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L
1867
1868#define SN_id_pkix_OCSP_Nonce "Nonce"
1869#define LN_id_pkix_OCSP_Nonce "OCSP Nonce"
1870#define NID_id_pkix_OCSP_Nonce 366
1871#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L
1872
1873#define SN_id_pkix_OCSP_CrlID "CrlID"
1874#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID"
1875#define NID_id_pkix_OCSP_CrlID 367
1876#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L
1877
1878#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses"
1879#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses"
1880#define NID_id_pkix_OCSP_acceptableResponses 368
1881#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L
1882
1883#define SN_id_pkix_OCSP_noCheck "noCheck"
1884#define LN_id_pkix_OCSP_noCheck "OCSP No Check"
1885#define NID_id_pkix_OCSP_noCheck 369
1886#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L
1887
1888#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff"
1889#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff"
1890#define NID_id_pkix_OCSP_archiveCutoff 370
1891#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L
1892
1893#define SN_id_pkix_OCSP_serviceLocator "serviceLocator"
1894#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator"
1895#define NID_id_pkix_OCSP_serviceLocator 371
1896#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L
1897
1898#define SN_id_pkix_OCSP_extendedStatus "extendedStatus"
1899#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status"
1900#define NID_id_pkix_OCSP_extendedStatus 372
1901#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L
1902
1903#define SN_id_pkix_OCSP_valid "valid"
1904#define NID_id_pkix_OCSP_valid 373
1905#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L
1906
1907#define SN_id_pkix_OCSP_path "path"
1908#define NID_id_pkix_OCSP_path 374
1909#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L
1910
1911#define SN_id_pkix_OCSP_trustRoot "trustRoot"
1912#define LN_id_pkix_OCSP_trustRoot "Trust Root"
1913#define NID_id_pkix_OCSP_trustRoot 375
1914#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L
1915
1916#define SN_algorithm "algorithm"
1917#define LN_algorithm "algorithm"
1918#define NID_algorithm 376
1919#define OBJ_algorithm 1L,3L,14L,3L,2L
1920
1921#define SN_md5WithRSA "RSA-NP-MD5"
1922#define LN_md5WithRSA "md5WithRSA"
1923#define NID_md5WithRSA 104
1924#define OBJ_md5WithRSA OBJ_algorithm,3L
1925
1926#define SN_des_ecb "DES-ECB"
1927#define LN_des_ecb "des-ecb"
1928#define NID_des_ecb 29
1929#define OBJ_des_ecb OBJ_algorithm,6L
1930
1931#define SN_des_cbc "DES-CBC"
1932#define LN_des_cbc "des-cbc"
1933#define NID_des_cbc 31
1934#define OBJ_des_cbc OBJ_algorithm,7L
1935
1936#define SN_des_ofb64 "DES-OFB"
1937#define LN_des_ofb64 "des-ofb"
1938#define NID_des_ofb64 45
1939#define OBJ_des_ofb64 OBJ_algorithm,8L
1940
1941#define SN_des_cfb64 "DES-CFB"
1942#define LN_des_cfb64 "des-cfb"
1943#define NID_des_cfb64 30
1944#define OBJ_des_cfb64 OBJ_algorithm,9L
1945
1946#define SN_rsaSignature "rsaSignature"
1947#define NID_rsaSignature 377
1948#define OBJ_rsaSignature OBJ_algorithm,11L
1949
1950#define SN_dsa_2 "DSA-old"
1951#define LN_dsa_2 "dsaEncryption-old"
1952#define NID_dsa_2 67
1953#define OBJ_dsa_2 OBJ_algorithm,12L
1954
1955#define SN_dsaWithSHA "DSA-SHA"
1956#define LN_dsaWithSHA "dsaWithSHA"
1957#define NID_dsaWithSHA 66
1958#define OBJ_dsaWithSHA OBJ_algorithm,13L
1959
1960#define SN_shaWithRSAEncryption "RSA-SHA"
1961#define LN_shaWithRSAEncryption "shaWithRSAEncryption"
1962#define NID_shaWithRSAEncryption 42
1963#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L
1964
1965#define SN_des_ede_ecb "DES-EDE"
1966#define LN_des_ede_ecb "des-ede"
1967#define NID_des_ede_ecb 32
1968#define OBJ_des_ede_ecb OBJ_algorithm,17L
1969
1970#define SN_des_ede3_ecb "DES-EDE3"
1971#define LN_des_ede3_ecb "des-ede3"
1972#define NID_des_ede3_ecb 33
1973
1974#define SN_des_ede_cbc "DES-EDE-CBC"
1975#define LN_des_ede_cbc "des-ede-cbc"
1976#define NID_des_ede_cbc 43
1977
1978#define SN_des_ede_cfb64 "DES-EDE-CFB"
1979#define LN_des_ede_cfb64 "des-ede-cfb"
1980#define NID_des_ede_cfb64 60
1981
1982#define SN_des_ede3_cfb64 "DES-EDE3-CFB"
1983#define LN_des_ede3_cfb64 "des-ede3-cfb"
1984#define NID_des_ede3_cfb64 61
1985
1986#define SN_des_ede_ofb64 "DES-EDE-OFB"
1987#define LN_des_ede_ofb64 "des-ede-ofb"
1988#define NID_des_ede_ofb64 62
1989
1990#define SN_des_ede3_ofb64 "DES-EDE3-OFB"
1991#define LN_des_ede3_ofb64 "des-ede3-ofb"
1992#define NID_des_ede3_ofb64 63
1993
1994#define SN_desx_cbc "DESX-CBC"
1995#define LN_desx_cbc "desx-cbc"
1996#define NID_desx_cbc 80
1997
1998#define SN_sha "SHA"
1999#define LN_sha "sha"
2000#define NID_sha 41
2001#define OBJ_sha OBJ_algorithm,18L
2002
2003#define SN_sha1 "SHA1"
2004#define LN_sha1 "sha1"
2005#define NID_sha1 64
2006#define OBJ_sha1 OBJ_algorithm,26L
2007
2008#define SN_dsaWithSHA1_2 "DSA-SHA1-old"
2009#define LN_dsaWithSHA1_2 "dsaWithSHA1-old"
2010#define NID_dsaWithSHA1_2 70
2011#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L
2012
2013#define SN_sha1WithRSA "RSA-SHA1-2"
2014#define LN_sha1WithRSA "sha1WithRSA"
2015#define NID_sha1WithRSA 115
2016#define OBJ_sha1WithRSA OBJ_algorithm,29L
2017
2018#define SN_ripemd160 "RIPEMD160"
2019#define LN_ripemd160 "ripemd160"
2020#define NID_ripemd160 117
2021#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L
2022
2023#define SN_ripemd160WithRSA "RSA-RIPEMD160"
2024#define LN_ripemd160WithRSA "ripemd160WithRSA"
2025#define NID_ripemd160WithRSA 119
2026#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L
2027
2028#define SN_sxnet "SXNetID"
2029#define LN_sxnet "Strong Extranet ID"
2030#define NID_sxnet 143
2031#define OBJ_sxnet 1L,3L,101L,1L,4L,1L
2032
2033#define SN_X500 "X500"
2034#define LN_X500 "directory services (X.500)"
2035#define NID_X500 11
2036#define OBJ_X500 2L,5L
2037
2038#define SN_X509 "X509"
2039#define NID_X509 12
2040#define OBJ_X509 OBJ_X500,4L
2041
2042#define SN_commonName "CN"
2043#define LN_commonName "commonName"
2044#define NID_commonName 13
2045#define OBJ_commonName OBJ_X509,3L
2046
2047#define SN_surname "SN"
2048#define LN_surname "surname"
2049#define NID_surname 100
2050#define OBJ_surname OBJ_X509,4L
2051
2052#define LN_serialNumber "serialNumber"
2053#define NID_serialNumber 105
2054#define OBJ_serialNumber OBJ_X509,5L
2055
2056#define SN_countryName "C"
2057#define LN_countryName "countryName"
2058#define NID_countryName 14
2059#define OBJ_countryName OBJ_X509,6L
2060
2061#define SN_localityName "L"
2062#define LN_localityName "localityName"
2063#define NID_localityName 15
2064#define OBJ_localityName OBJ_X509,7L
2065
2066#define SN_stateOrProvinceName "ST"
2067#define LN_stateOrProvinceName "stateOrProvinceName"
2068#define NID_stateOrProvinceName 16
2069#define OBJ_stateOrProvinceName OBJ_X509,8L
2070
2071#define SN_streetAddress "street"
2072#define LN_streetAddress "streetAddress"
2073#define NID_streetAddress 660
2074#define OBJ_streetAddress OBJ_X509,9L
2075
2076#define SN_organizationName "O"
2077#define LN_organizationName "organizationName"
2078#define NID_organizationName 17
2079#define OBJ_organizationName OBJ_X509,10L
2080
2081#define SN_organizationalUnitName "OU"
2082#define LN_organizationalUnitName "organizationalUnitName"
2083#define NID_organizationalUnitName 18
2084#define OBJ_organizationalUnitName OBJ_X509,11L
2085
2086#define SN_title "title"
2087#define LN_title "title"
2088#define NID_title 106
2089#define OBJ_title OBJ_X509,12L
2090
2091#define LN_description "description"
2092#define NID_description 107
2093#define OBJ_description OBJ_X509,13L
2094
2095#define LN_searchGuide "searchGuide"
2096#define NID_searchGuide 859
2097#define OBJ_searchGuide OBJ_X509,14L
2098
2099#define LN_businessCategory "businessCategory"
2100#define NID_businessCategory 860
2101#define OBJ_businessCategory OBJ_X509,15L
2102
2103#define LN_postalAddress "postalAddress"
2104#define NID_postalAddress 861
2105#define OBJ_postalAddress OBJ_X509,16L
2106
2107#define LN_postalCode "postalCode"
2108#define NID_postalCode 661
2109#define OBJ_postalCode OBJ_X509,17L
2110
2111#define LN_postOfficeBox "postOfficeBox"
2112#define NID_postOfficeBox 862
2113#define OBJ_postOfficeBox OBJ_X509,18L
2114
2115#define LN_physicalDeliveryOfficeName "physicalDeliveryOfficeName"
2116#define NID_physicalDeliveryOfficeName 863
2117#define OBJ_physicalDeliveryOfficeName OBJ_X509,19L
2118
2119#define LN_telephoneNumber "telephoneNumber"
2120#define NID_telephoneNumber 864
2121#define OBJ_telephoneNumber OBJ_X509,20L
2122
2123#define LN_telexNumber "telexNumber"
2124#define NID_telexNumber 865
2125#define OBJ_telexNumber OBJ_X509,21L
2126
2127#define LN_teletexTerminalIdentifier "teletexTerminalIdentifier"
2128#define NID_teletexTerminalIdentifier 866
2129#define OBJ_teletexTerminalIdentifier OBJ_X509,22L
2130
2131#define LN_facsimileTelephoneNumber "facsimileTelephoneNumber"
2132#define NID_facsimileTelephoneNumber 867
2133#define OBJ_facsimileTelephoneNumber OBJ_X509,23L
2134
2135#define LN_x121Address "x121Address"
2136#define NID_x121Address 868
2137#define OBJ_x121Address OBJ_X509,24L
2138
2139#define LN_internationaliSDNNumber "internationaliSDNNumber"
2140#define NID_internationaliSDNNumber 869
2141#define OBJ_internationaliSDNNumber OBJ_X509,25L
2142
2143#define LN_registeredAddress "registeredAddress"
2144#define NID_registeredAddress 870
2145#define OBJ_registeredAddress OBJ_X509,26L
2146
2147#define LN_destinationIndicator "destinationIndicator"
2148#define NID_destinationIndicator 871
2149#define OBJ_destinationIndicator OBJ_X509,27L
2150
2151#define LN_preferredDeliveryMethod "preferredDeliveryMethod"
2152#define NID_preferredDeliveryMethod 872
2153#define OBJ_preferredDeliveryMethod OBJ_X509,28L
2154
2155#define LN_presentationAddress "presentationAddress"
2156#define NID_presentationAddress 873
2157#define OBJ_presentationAddress OBJ_X509,29L
2158
2159#define LN_supportedApplicationContext "supportedApplicationContext"
2160#define NID_supportedApplicationContext 874
2161#define OBJ_supportedApplicationContext OBJ_X509,30L
2162
2163#define SN_member "member"
2164#define NID_member 875
2165#define OBJ_member OBJ_X509,31L
2166
2167#define SN_owner "owner"
2168#define NID_owner 876
2169#define OBJ_owner OBJ_X509,32L
2170
2171#define LN_roleOccupant "roleOccupant"
2172#define NID_roleOccupant 877
2173#define OBJ_roleOccupant OBJ_X509,33L
2174
2175#define SN_seeAlso "seeAlso"
2176#define NID_seeAlso 878
2177#define OBJ_seeAlso OBJ_X509,34L
2178
2179#define LN_userPassword "userPassword"
2180#define NID_userPassword 879
2181#define OBJ_userPassword OBJ_X509,35L
2182
2183#define LN_userCertificate "userCertificate"
2184#define NID_userCertificate 880
2185#define OBJ_userCertificate OBJ_X509,36L
2186
2187#define LN_cACertificate "cACertificate"
2188#define NID_cACertificate 881
2189#define OBJ_cACertificate OBJ_X509,37L
2190
2191#define LN_authorityRevocationList "authorityRevocationList"
2192#define NID_authorityRevocationList 882
2193#define OBJ_authorityRevocationList OBJ_X509,38L
2194
2195#define LN_certificateRevocationList "certificateRevocationList"
2196#define NID_certificateRevocationList 883
2197#define OBJ_certificateRevocationList OBJ_X509,39L
2198
2199#define LN_crossCertificatePair "crossCertificatePair"
2200#define NID_crossCertificatePair 884
2201#define OBJ_crossCertificatePair OBJ_X509,40L
2202
2203#define SN_name "name"
2204#define LN_name "name"
2205#define NID_name 173
2206#define OBJ_name OBJ_X509,41L
2207
2208#define SN_givenName "GN"
2209#define LN_givenName "givenName"
2210#define NID_givenName 99
2211#define OBJ_givenName OBJ_X509,42L
2212
2213#define SN_initials "initials"
2214#define LN_initials "initials"
2215#define NID_initials 101
2216#define OBJ_initials OBJ_X509,43L
2217
2218#define LN_generationQualifier "generationQualifier"
2219#define NID_generationQualifier 509
2220#define OBJ_generationQualifier OBJ_X509,44L
2221
2222#define LN_x500UniqueIdentifier "x500UniqueIdentifier"
2223#define NID_x500UniqueIdentifier 503
2224#define OBJ_x500UniqueIdentifier OBJ_X509,45L
2225
2226#define SN_dnQualifier "dnQualifier"
2227#define LN_dnQualifier "dnQualifier"
2228#define NID_dnQualifier 174
2229#define OBJ_dnQualifier OBJ_X509,46L
2230
2231#define LN_enhancedSearchGuide "enhancedSearchGuide"
2232#define NID_enhancedSearchGuide 885
2233#define OBJ_enhancedSearchGuide OBJ_X509,47L
2234
2235#define LN_protocolInformation "protocolInformation"
2236#define NID_protocolInformation 886
2237#define OBJ_protocolInformation OBJ_X509,48L
2238
2239#define LN_distinguishedName "distinguishedName"
2240#define NID_distinguishedName 887
2241#define OBJ_distinguishedName OBJ_X509,49L
2242
2243#define LN_uniqueMember "uniqueMember"
2244#define NID_uniqueMember 888
2245#define OBJ_uniqueMember OBJ_X509,50L
2246
2247#define LN_houseIdentifier "houseIdentifier"
2248#define NID_houseIdentifier 889
2249#define OBJ_houseIdentifier OBJ_X509,51L
2250
2251#define LN_supportedAlgorithms "supportedAlgorithms"
2252#define NID_supportedAlgorithms 890
2253#define OBJ_supportedAlgorithms OBJ_X509,52L
2254
2255#define LN_deltaRevocationList "deltaRevocationList"
2256#define NID_deltaRevocationList 891
2257#define OBJ_deltaRevocationList OBJ_X509,53L
2258
2259#define SN_dmdName "dmdName"
2260#define NID_dmdName 892
2261#define OBJ_dmdName OBJ_X509,54L
2262
2263#define LN_pseudonym "pseudonym"
2264#define NID_pseudonym 510
2265#define OBJ_pseudonym OBJ_X509,65L
2266
2267#define SN_role "role"
2268#define LN_role "role"
2269#define NID_role 400
2270#define OBJ_role OBJ_X509,72L
2271
2272#define SN_X500algorithms "X500algorithms"
2273#define LN_X500algorithms "directory services - algorithms"
2274#define NID_X500algorithms 378
2275#define OBJ_X500algorithms OBJ_X500,8L
2276
2277#define SN_rsa "RSA"
2278#define LN_rsa "rsa"
2279#define NID_rsa 19
2280#define OBJ_rsa OBJ_X500algorithms,1L,1L
2281
2282#define SN_mdc2WithRSA "RSA-MDC2"
2283#define LN_mdc2WithRSA "mdc2WithRSA"
2284#define NID_mdc2WithRSA 96
2285#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L
2286
2287#define SN_mdc2 "MDC2"
2288#define LN_mdc2 "mdc2"
2289#define NID_mdc2 95
2290#define OBJ_mdc2 OBJ_X500algorithms,3L,101L
2291
2292#define SN_id_ce "id-ce"
2293#define NID_id_ce 81
2294#define OBJ_id_ce OBJ_X500,29L
2295
2296#define SN_subject_directory_attributes "subjectDirectoryAttributes"
2297#define LN_subject_directory_attributes "X509v3 Subject Directory Attributes"
2298#define NID_subject_directory_attributes 769
2299#define OBJ_subject_directory_attributes OBJ_id_ce,9L
2300
2301#define SN_subject_key_identifier "subjectKeyIdentifier"
2302#define LN_subject_key_identifier "X509v3 Subject Key Identifier"
2303#define NID_subject_key_identifier 82
2304#define OBJ_subject_key_identifier OBJ_id_ce,14L
2305
2306#define SN_key_usage "keyUsage"
2307#define LN_key_usage "X509v3 Key Usage"
2308#define NID_key_usage 83
2309#define OBJ_key_usage OBJ_id_ce,15L
2310
2311#define SN_private_key_usage_period "privateKeyUsagePeriod"
2312#define LN_private_key_usage_period "X509v3 Private Key Usage Period"
2313#define NID_private_key_usage_period 84
2314#define OBJ_private_key_usage_period OBJ_id_ce,16L
2315
2316#define SN_subject_alt_name "subjectAltName"
2317#define LN_subject_alt_name "X509v3 Subject Alternative Name"
2318#define NID_subject_alt_name 85
2319#define OBJ_subject_alt_name OBJ_id_ce,17L
2320
2321#define SN_issuer_alt_name "issuerAltName"
2322#define LN_issuer_alt_name "X509v3 Issuer Alternative Name"
2323#define NID_issuer_alt_name 86
2324#define OBJ_issuer_alt_name OBJ_id_ce,18L
2325
2326#define SN_basic_constraints "basicConstraints"
2327#define LN_basic_constraints "X509v3 Basic Constraints"
2328#define NID_basic_constraints 87
2329#define OBJ_basic_constraints OBJ_id_ce,19L
2330
2331#define SN_crl_number "crlNumber"
2332#define LN_crl_number "X509v3 CRL Number"
2333#define NID_crl_number 88
2334#define OBJ_crl_number OBJ_id_ce,20L
2335
2336#define SN_crl_reason "CRLReason"
2337#define LN_crl_reason "X509v3 CRL Reason Code"
2338#define NID_crl_reason 141
2339#define OBJ_crl_reason OBJ_id_ce,21L
2340
2341#define SN_invalidity_date "invalidityDate"
2342#define LN_invalidity_date "Invalidity Date"
2343#define NID_invalidity_date 142
2344#define OBJ_invalidity_date OBJ_id_ce,24L
2345
2346#define SN_delta_crl "deltaCRL"
2347#define LN_delta_crl "X509v3 Delta CRL Indicator"
2348#define NID_delta_crl 140
2349#define OBJ_delta_crl OBJ_id_ce,27L
2350
2351#define SN_issuing_distribution_point "issuingDistributionPoint"
2352#define LN_issuing_distribution_point "X509v3 Issuing Distrubution Point"
2353#define NID_issuing_distribution_point 770
2354#define OBJ_issuing_distribution_point OBJ_id_ce,28L
2355
2356#define SN_certificate_issuer "certificateIssuer"
2357#define LN_certificate_issuer "X509v3 Certificate Issuer"
2358#define NID_certificate_issuer 771
2359#define OBJ_certificate_issuer OBJ_id_ce,29L
2360
2361#define SN_name_constraints "nameConstraints"
2362#define LN_name_constraints "X509v3 Name Constraints"
2363#define NID_name_constraints 666
2364#define OBJ_name_constraints OBJ_id_ce,30L
2365
2366#define SN_crl_distribution_points "crlDistributionPoints"
2367#define LN_crl_distribution_points "X509v3 CRL Distribution Points"
2368#define NID_crl_distribution_points 103
2369#define OBJ_crl_distribution_points OBJ_id_ce,31L
2370
2371#define SN_certificate_policies "certificatePolicies"
2372#define LN_certificate_policies "X509v3 Certificate Policies"
2373#define NID_certificate_policies 89
2374#define OBJ_certificate_policies OBJ_id_ce,32L
2375
2376#define SN_any_policy "anyPolicy"
2377#define LN_any_policy "X509v3 Any Policy"
2378#define NID_any_policy 746
2379#define OBJ_any_policy OBJ_certificate_policies,0L
2380
2381#define SN_policy_mappings "policyMappings"
2382#define LN_policy_mappings "X509v3 Policy Mappings"
2383#define NID_policy_mappings 747
2384#define OBJ_policy_mappings OBJ_id_ce,33L
2385
2386#define SN_authority_key_identifier "authorityKeyIdentifier"
2387#define LN_authority_key_identifier "X509v3 Authority Key Identifier"
2388#define NID_authority_key_identifier 90
2389#define OBJ_authority_key_identifier OBJ_id_ce,35L
2390
2391#define SN_policy_constraints "policyConstraints"
2392#define LN_policy_constraints "X509v3 Policy Constraints"
2393#define NID_policy_constraints 401
2394#define OBJ_policy_constraints OBJ_id_ce,36L
2395
2396#define SN_ext_key_usage "extendedKeyUsage"
2397#define LN_ext_key_usage "X509v3 Extended Key Usage"
2398#define NID_ext_key_usage 126
2399#define OBJ_ext_key_usage OBJ_id_ce,37L
2400
2401#define SN_freshest_crl "freshestCRL"
2402#define LN_freshest_crl "X509v3 Freshest CRL"
2403#define NID_freshest_crl 857
2404#define OBJ_freshest_crl OBJ_id_ce,46L
2405
2406#define SN_inhibit_any_policy "inhibitAnyPolicy"
2407#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy"
2408#define NID_inhibit_any_policy 748
2409#define OBJ_inhibit_any_policy OBJ_id_ce,54L
2410
2411#define SN_target_information "targetInformation"
2412#define LN_target_information "X509v3 AC Targeting"
2413#define NID_target_information 402
2414#define OBJ_target_information OBJ_id_ce,55L
2415
2416#define SN_no_rev_avail "noRevAvail"
2417#define LN_no_rev_avail "X509v3 No Revocation Available"
2418#define NID_no_rev_avail 403
2419#define OBJ_no_rev_avail OBJ_id_ce,56L
2420
2421#define SN_anyExtendedKeyUsage "anyExtendedKeyUsage"
2422#define LN_anyExtendedKeyUsage "Any Extended Key Usage"
2423#define NID_anyExtendedKeyUsage 910
2424#define OBJ_anyExtendedKeyUsage OBJ_ext_key_usage,0L
2425
2426#define SN_netscape "Netscape"
2427#define LN_netscape "Netscape Communications Corp."
2428#define NID_netscape 57
2429#define OBJ_netscape 2L,16L,840L,1L,113730L
2430
2431#define SN_netscape_cert_extension "nsCertExt"
2432#define LN_netscape_cert_extension "Netscape Certificate Extension"
2433#define NID_netscape_cert_extension 58
2434#define OBJ_netscape_cert_extension OBJ_netscape,1L
2435
2436#define SN_netscape_data_type "nsDataType"
2437#define LN_netscape_data_type "Netscape Data Type"
2438#define NID_netscape_data_type 59
2439#define OBJ_netscape_data_type OBJ_netscape,2L
2440
2441#define SN_netscape_cert_type "nsCertType"
2442#define LN_netscape_cert_type "Netscape Cert Type"
2443#define NID_netscape_cert_type 71
2444#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L
2445
2446#define SN_netscape_base_url "nsBaseUrl"
2447#define LN_netscape_base_url "Netscape Base Url"
2448#define NID_netscape_base_url 72
2449#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L
2450
2451#define SN_netscape_revocation_url "nsRevocationUrl"
2452#define LN_netscape_revocation_url "Netscape Revocation Url"
2453#define NID_netscape_revocation_url 73
2454#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L
2455
2456#define SN_netscape_ca_revocation_url "nsCaRevocationUrl"
2457#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url"
2458#define NID_netscape_ca_revocation_url 74
2459#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L
2460
2461#define SN_netscape_renewal_url "nsRenewalUrl"
2462#define LN_netscape_renewal_url "Netscape Renewal Url"
2463#define NID_netscape_renewal_url 75
2464#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L
2465
2466#define SN_netscape_ca_policy_url "nsCaPolicyUrl"
2467#define LN_netscape_ca_policy_url "Netscape CA Policy Url"
2468#define NID_netscape_ca_policy_url 76
2469#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L
2470
2471#define SN_netscape_ssl_server_name "nsSslServerName"
2472#define LN_netscape_ssl_server_name "Netscape SSL Server Name"
2473#define NID_netscape_ssl_server_name 77
2474#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L
2475
2476#define SN_netscape_comment "nsComment"
2477#define LN_netscape_comment "Netscape Comment"
2478#define NID_netscape_comment 78
2479#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L
2480
2481#define SN_netscape_cert_sequence "nsCertSequence"
2482#define LN_netscape_cert_sequence "Netscape Certificate Sequence"
2483#define NID_netscape_cert_sequence 79
2484#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L
2485
2486#define SN_ns_sgc "nsSGC"
2487#define LN_ns_sgc "Netscape Server Gated Crypto"
2488#define NID_ns_sgc 139
2489#define OBJ_ns_sgc OBJ_netscape,4L,1L
2490
2491#define SN_org "ORG"
2492#define LN_org "org"
2493#define NID_org 379
2494#define OBJ_org OBJ_iso,3L
2495
2496#define SN_dod "DOD"
2497#define LN_dod "dod"
2498#define NID_dod 380
2499#define OBJ_dod OBJ_org,6L
2500
2501#define SN_iana "IANA"
2502#define LN_iana "iana"
2503#define NID_iana 381
2504#define OBJ_iana OBJ_dod,1L
2505
2506#define OBJ_internet OBJ_iana
2507
2508#define SN_Directory "directory"
2509#define LN_Directory "Directory"
2510#define NID_Directory 382
2511#define OBJ_Directory OBJ_internet,1L
2512
2513#define SN_Management "mgmt"
2514#define LN_Management "Management"
2515#define NID_Management 383
2516#define OBJ_Management OBJ_internet,2L
2517
2518#define SN_Experimental "experimental"
2519#define LN_Experimental "Experimental"
2520#define NID_Experimental 384
2521#define OBJ_Experimental OBJ_internet,3L
2522
2523#define SN_Private "private"
2524#define LN_Private "Private"
2525#define NID_Private 385
2526#define OBJ_Private OBJ_internet,4L
2527
2528#define SN_Security "security"
2529#define LN_Security "Security"
2530#define NID_Security 386
2531#define OBJ_Security OBJ_internet,5L
2532
2533#define SN_SNMPv2 "snmpv2"
2534#define LN_SNMPv2 "SNMPv2"
2535#define NID_SNMPv2 387
2536#define OBJ_SNMPv2 OBJ_internet,6L
2537
2538#define LN_Mail "Mail"
2539#define NID_Mail 388
2540#define OBJ_Mail OBJ_internet,7L
2541
2542#define SN_Enterprises "enterprises"
2543#define LN_Enterprises "Enterprises"
2544#define NID_Enterprises 389
2545#define OBJ_Enterprises OBJ_Private,1L
2546
2547#define SN_dcObject "dcobject"
2548#define LN_dcObject "dcObject"
2549#define NID_dcObject 390
2550#define OBJ_dcObject OBJ_Enterprises,1466L,344L
2551
2552#define SN_mime_mhs "mime-mhs"
2553#define LN_mime_mhs "MIME MHS"
2554#define NID_mime_mhs 504
2555#define OBJ_mime_mhs OBJ_Mail,1L
2556
2557#define SN_mime_mhs_headings "mime-mhs-headings"
2558#define LN_mime_mhs_headings "mime-mhs-headings"
2559#define NID_mime_mhs_headings 505
2560#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L
2561
2562#define SN_mime_mhs_bodies "mime-mhs-bodies"
2563#define LN_mime_mhs_bodies "mime-mhs-bodies"
2564#define NID_mime_mhs_bodies 506
2565#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L
2566
2567#define SN_id_hex_partial_message "id-hex-partial-message"
2568#define LN_id_hex_partial_message "id-hex-partial-message"
2569#define NID_id_hex_partial_message 507
2570#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L
2571
2572#define SN_id_hex_multipart_message "id-hex-multipart-message"
2573#define LN_id_hex_multipart_message "id-hex-multipart-message"
2574#define NID_id_hex_multipart_message 508
2575#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L
2576
2577#define SN_rle_compression "RLE"
2578#define LN_rle_compression "run length compression"
2579#define NID_rle_compression 124
2580#define OBJ_rle_compression 1L,1L,1L,1L,666L,1L
2581
2582#define SN_zlib_compression "ZLIB"
2583#define LN_zlib_compression "zlib compression"
2584#define NID_zlib_compression 125
2585#define OBJ_zlib_compression OBJ_id_smime_alg,8L
2586
2587#define OBJ_csor 2L,16L,840L,1L,101L,3L
2588
2589#define OBJ_nistAlgorithms OBJ_csor,4L
2590
2591#define OBJ_aes OBJ_nistAlgorithms,1L
2592
2593#define SN_aes_128_ecb "AES-128-ECB"
2594#define LN_aes_128_ecb "aes-128-ecb"
2595#define NID_aes_128_ecb 418
2596#define OBJ_aes_128_ecb OBJ_aes,1L
2597
2598#define SN_aes_128_cbc "AES-128-CBC"
2599#define LN_aes_128_cbc "aes-128-cbc"
2600#define NID_aes_128_cbc 419
2601#define OBJ_aes_128_cbc OBJ_aes,2L
2602
2603#define SN_aes_128_ofb128 "AES-128-OFB"
2604#define LN_aes_128_ofb128 "aes-128-ofb"
2605#define NID_aes_128_ofb128 420
2606#define OBJ_aes_128_ofb128 OBJ_aes,3L
2607
2608#define SN_aes_128_cfb128 "AES-128-CFB"
2609#define LN_aes_128_cfb128 "aes-128-cfb"
2610#define NID_aes_128_cfb128 421
2611#define OBJ_aes_128_cfb128 OBJ_aes,4L
2612
2613#define SN_id_aes128_wrap "id-aes128-wrap"
2614#define NID_id_aes128_wrap 788
2615#define OBJ_id_aes128_wrap OBJ_aes,5L
2616
2617#define SN_aes_128_gcm "id-aes128-GCM"
2618#define LN_aes_128_gcm "aes-128-gcm"
2619#define NID_aes_128_gcm 895
2620#define OBJ_aes_128_gcm OBJ_aes,6L
2621
2622#define SN_aes_128_ccm "id-aes128-CCM"
2623#define LN_aes_128_ccm "aes-128-ccm"
2624#define NID_aes_128_ccm 896
2625#define OBJ_aes_128_ccm OBJ_aes,7L
2626
2627#define SN_id_aes128_wrap_pad "id-aes128-wrap-pad"
2628#define NID_id_aes128_wrap_pad 897
2629#define OBJ_id_aes128_wrap_pad OBJ_aes,8L
2630
2631#define SN_aes_192_ecb "AES-192-ECB"
2632#define LN_aes_192_ecb "aes-192-ecb"
2633#define NID_aes_192_ecb 422
2634#define OBJ_aes_192_ecb OBJ_aes,21L
2635
2636#define SN_aes_192_cbc "AES-192-CBC"
2637#define LN_aes_192_cbc "aes-192-cbc"
2638#define NID_aes_192_cbc 423
2639#define OBJ_aes_192_cbc OBJ_aes,22L
2640
2641#define SN_aes_192_ofb128 "AES-192-OFB"
2642#define LN_aes_192_ofb128 "aes-192-ofb"
2643#define NID_aes_192_ofb128 424
2644#define OBJ_aes_192_ofb128 OBJ_aes,23L
2645
2646#define SN_aes_192_cfb128 "AES-192-CFB"
2647#define LN_aes_192_cfb128 "aes-192-cfb"
2648#define NID_aes_192_cfb128 425
2649#define OBJ_aes_192_cfb128 OBJ_aes,24L
2650
2651#define SN_id_aes192_wrap "id-aes192-wrap"
2652#define NID_id_aes192_wrap 789
2653#define OBJ_id_aes192_wrap OBJ_aes,25L
2654
2655#define SN_aes_192_gcm "id-aes192-GCM"
2656#define LN_aes_192_gcm "aes-192-gcm"
2657#define NID_aes_192_gcm 898
2658#define OBJ_aes_192_gcm OBJ_aes,26L
2659
2660#define SN_aes_192_ccm "id-aes192-CCM"
2661#define LN_aes_192_ccm "aes-192-ccm"
2662#define NID_aes_192_ccm 899
2663#define OBJ_aes_192_ccm OBJ_aes,27L
2664
2665#define SN_id_aes192_wrap_pad "id-aes192-wrap-pad"
2666#define NID_id_aes192_wrap_pad 900
2667#define OBJ_id_aes192_wrap_pad OBJ_aes,28L
2668
2669#define SN_aes_256_ecb "AES-256-ECB"
2670#define LN_aes_256_ecb "aes-256-ecb"
2671#define NID_aes_256_ecb 426
2672#define OBJ_aes_256_ecb OBJ_aes,41L
2673
2674#define SN_aes_256_cbc "AES-256-CBC"
2675#define LN_aes_256_cbc "aes-256-cbc"
2676#define NID_aes_256_cbc 427
2677#define OBJ_aes_256_cbc OBJ_aes,42L
2678
2679#define SN_aes_256_ofb128 "AES-256-OFB"
2680#define LN_aes_256_ofb128 "aes-256-ofb"
2681#define NID_aes_256_ofb128 428
2682#define OBJ_aes_256_ofb128 OBJ_aes,43L
2683
2684#define SN_aes_256_cfb128 "AES-256-CFB"
2685#define LN_aes_256_cfb128 "aes-256-cfb"
2686#define NID_aes_256_cfb128 429
2687#define OBJ_aes_256_cfb128 OBJ_aes,44L
2688
2689#define SN_id_aes256_wrap "id-aes256-wrap"
2690#define NID_id_aes256_wrap 790
2691#define OBJ_id_aes256_wrap OBJ_aes,45L
2692
2693#define SN_aes_256_gcm "id-aes256-GCM"
2694#define LN_aes_256_gcm "aes-256-gcm"
2695#define NID_aes_256_gcm 901
2696#define OBJ_aes_256_gcm OBJ_aes,46L
2697
2698#define SN_aes_256_ccm "id-aes256-CCM"
2699#define LN_aes_256_ccm "aes-256-ccm"
2700#define NID_aes_256_ccm 902
2701#define OBJ_aes_256_ccm OBJ_aes,47L
2702
2703#define SN_id_aes256_wrap_pad "id-aes256-wrap-pad"
2704#define NID_id_aes256_wrap_pad 903
2705#define OBJ_id_aes256_wrap_pad OBJ_aes,48L
2706
2707#define SN_aes_128_cfb1 "AES-128-CFB1"
2708#define LN_aes_128_cfb1 "aes-128-cfb1"
2709#define NID_aes_128_cfb1 650
2710
2711#define SN_aes_192_cfb1 "AES-192-CFB1"
2712#define LN_aes_192_cfb1 "aes-192-cfb1"
2713#define NID_aes_192_cfb1 651
2714
2715#define SN_aes_256_cfb1 "AES-256-CFB1"
2716#define LN_aes_256_cfb1 "aes-256-cfb1"
2717#define NID_aes_256_cfb1 652
2718
2719#define SN_aes_128_cfb8 "AES-128-CFB8"
2720#define LN_aes_128_cfb8 "aes-128-cfb8"
2721#define NID_aes_128_cfb8 653
2722
2723#define SN_aes_192_cfb8 "AES-192-CFB8"
2724#define LN_aes_192_cfb8 "aes-192-cfb8"
2725#define NID_aes_192_cfb8 654
2726
2727#define SN_aes_256_cfb8 "AES-256-CFB8"
2728#define LN_aes_256_cfb8 "aes-256-cfb8"
2729#define NID_aes_256_cfb8 655
2730
2731#define SN_aes_128_ctr "AES-128-CTR"
2732#define LN_aes_128_ctr "aes-128-ctr"
2733#define NID_aes_128_ctr 904
2734
2735#define SN_aes_192_ctr "AES-192-CTR"
2736#define LN_aes_192_ctr "aes-192-ctr"
2737#define NID_aes_192_ctr 905
2738
2739#define SN_aes_256_ctr "AES-256-CTR"
2740#define LN_aes_256_ctr "aes-256-ctr"
2741#define NID_aes_256_ctr 906
2742
2743#define SN_aes_128_xts "AES-128-XTS"
2744#define LN_aes_128_xts "aes-128-xts"
2745#define NID_aes_128_xts 913
2746
2747#define SN_aes_256_xts "AES-256-XTS"
2748#define LN_aes_256_xts "aes-256-xts"
2749#define NID_aes_256_xts 914
2750
2751#define SN_des_cfb1 "DES-CFB1"
2752#define LN_des_cfb1 "des-cfb1"
2753#define NID_des_cfb1 656
2754
2755#define SN_des_cfb8 "DES-CFB8"
2756#define LN_des_cfb8 "des-cfb8"
2757#define NID_des_cfb8 657
2758
2759#define SN_des_ede3_cfb1 "DES-EDE3-CFB1"
2760#define LN_des_ede3_cfb1 "des-ede3-cfb1"
2761#define NID_des_ede3_cfb1 658
2762
2763#define SN_des_ede3_cfb8 "DES-EDE3-CFB8"
2764#define LN_des_ede3_cfb8 "des-ede3-cfb8"
2765#define NID_des_ede3_cfb8 659
2766
2767#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L
2768
2769#define SN_sha256 "SHA256"
2770#define LN_sha256 "sha256"
2771#define NID_sha256 672
2772#define OBJ_sha256 OBJ_nist_hashalgs,1L
2773
2774#define SN_sha384 "SHA384"
2775#define LN_sha384 "sha384"
2776#define NID_sha384 673
2777#define OBJ_sha384 OBJ_nist_hashalgs,2L
2778
2779#define SN_sha512 "SHA512"
2780#define LN_sha512 "sha512"
2781#define NID_sha512 674
2782#define OBJ_sha512 OBJ_nist_hashalgs,3L
2783
2784#define SN_sha224 "SHA224"
2785#define LN_sha224 "sha224"
2786#define NID_sha224 675
2787#define OBJ_sha224 OBJ_nist_hashalgs,4L
2788
2789#define OBJ_dsa_with_sha2 OBJ_nistAlgorithms,3L
2790
2791#define SN_dsa_with_SHA224 "dsa_with_SHA224"
2792#define NID_dsa_with_SHA224 802
2793#define OBJ_dsa_with_SHA224 OBJ_dsa_with_sha2,1L
2794
2795#define SN_dsa_with_SHA256 "dsa_with_SHA256"
2796#define NID_dsa_with_SHA256 803
2797#define OBJ_dsa_with_SHA256 OBJ_dsa_with_sha2,2L
2798
2799#define SN_hold_instruction_code "holdInstructionCode"
2800#define LN_hold_instruction_code "Hold Instruction Code"
2801#define NID_hold_instruction_code 430
2802#define OBJ_hold_instruction_code OBJ_id_ce,23L
2803
2804#define OBJ_holdInstruction OBJ_X9_57,2L
2805
2806#define SN_hold_instruction_none "holdInstructionNone"
2807#define LN_hold_instruction_none "Hold Instruction None"
2808#define NID_hold_instruction_none 431
2809#define OBJ_hold_instruction_none OBJ_holdInstruction,1L
2810
2811#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer"
2812#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer"
2813#define NID_hold_instruction_call_issuer 432
2814#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L
2815
2816#define SN_hold_instruction_reject "holdInstructionReject"
2817#define LN_hold_instruction_reject "Hold Instruction Reject"
2818#define NID_hold_instruction_reject 433
2819#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L
2820
2821#define SN_data "data"
2822#define NID_data 434
2823#define OBJ_data OBJ_itu_t,9L
2824
2825#define SN_pss "pss"
2826#define NID_pss 435
2827#define OBJ_pss OBJ_data,2342L
2828
2829#define SN_ucl "ucl"
2830#define NID_ucl 436
2831#define OBJ_ucl OBJ_pss,19200300L
2832
2833#define SN_pilot "pilot"
2834#define NID_pilot 437
2835#define OBJ_pilot OBJ_ucl,100L
2836
2837#define LN_pilotAttributeType "pilotAttributeType"
2838#define NID_pilotAttributeType 438
2839#define OBJ_pilotAttributeType OBJ_pilot,1L
2840
2841#define LN_pilotAttributeSyntax "pilotAttributeSyntax"
2842#define NID_pilotAttributeSyntax 439
2843#define OBJ_pilotAttributeSyntax OBJ_pilot,3L
2844
2845#define LN_pilotObjectClass "pilotObjectClass"
2846#define NID_pilotObjectClass 440
2847#define OBJ_pilotObjectClass OBJ_pilot,4L
2848
2849#define LN_pilotGroups "pilotGroups"
2850#define NID_pilotGroups 441
2851#define OBJ_pilotGroups OBJ_pilot,10L
2852
2853#define LN_iA5StringSyntax "iA5StringSyntax"
2854#define NID_iA5StringSyntax 442
2855#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L
2856
2857#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax"
2858#define NID_caseIgnoreIA5StringSyntax 443
2859#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L
2860
2861#define LN_pilotObject "pilotObject"
2862#define NID_pilotObject 444
2863#define OBJ_pilotObject OBJ_pilotObjectClass,3L
2864
2865#define LN_pilotPerson "pilotPerson"
2866#define NID_pilotPerson 445
2867#define OBJ_pilotPerson OBJ_pilotObjectClass,4L
2868
2869#define SN_account "account"
2870#define NID_account 446
2871#define OBJ_account OBJ_pilotObjectClass,5L
2872
2873#define SN_document "document"
2874#define NID_document 447
2875#define OBJ_document OBJ_pilotObjectClass,6L
2876
2877#define SN_room "room"
2878#define NID_room 448
2879#define OBJ_room OBJ_pilotObjectClass,7L
2880
2881#define LN_documentSeries "documentSeries"
2882#define NID_documentSeries 449
2883#define OBJ_documentSeries OBJ_pilotObjectClass,9L
2884
2885#define SN_Domain "domain"
2886#define LN_Domain "Domain"
2887#define NID_Domain 392
2888#define OBJ_Domain OBJ_pilotObjectClass,13L
2889
2890#define LN_rFC822localPart "rFC822localPart"
2891#define NID_rFC822localPart 450
2892#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L
2893
2894#define LN_dNSDomain "dNSDomain"
2895#define NID_dNSDomain 451
2896#define OBJ_dNSDomain OBJ_pilotObjectClass,15L
2897
2898#define LN_domainRelatedObject "domainRelatedObject"
2899#define NID_domainRelatedObject 452
2900#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L
2901
2902#define LN_friendlyCountry "friendlyCountry"
2903#define NID_friendlyCountry 453
2904#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L
2905
2906#define LN_simpleSecurityObject "simpleSecurityObject"
2907#define NID_simpleSecurityObject 454
2908#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L
2909
2910#define LN_pilotOrganization "pilotOrganization"
2911#define NID_pilotOrganization 455
2912#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L
2913
2914#define LN_pilotDSA "pilotDSA"
2915#define NID_pilotDSA 456
2916#define OBJ_pilotDSA OBJ_pilotObjectClass,21L
2917
2918#define LN_qualityLabelledData "qualityLabelledData"
2919#define NID_qualityLabelledData 457
2920#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L
2921
2922#define SN_userId "UID"
2923#define LN_userId "userId"
2924#define NID_userId 458
2925#define OBJ_userId OBJ_pilotAttributeType,1L
2926
2927#define LN_textEncodedORAddress "textEncodedORAddress"
2928#define NID_textEncodedORAddress 459
2929#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L
2930
2931#define SN_rfc822Mailbox "mail"
2932#define LN_rfc822Mailbox "rfc822Mailbox"
2933#define NID_rfc822Mailbox 460
2934#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L
2935
2936#define SN_info "info"
2937#define NID_info 461
2938#define OBJ_info OBJ_pilotAttributeType,4L
2939
2940#define LN_favouriteDrink "favouriteDrink"
2941#define NID_favouriteDrink 462
2942#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L
2943
2944#define LN_roomNumber "roomNumber"
2945#define NID_roomNumber 463
2946#define OBJ_roomNumber OBJ_pilotAttributeType,6L
2947
2948#define SN_photo "photo"
2949#define NID_photo 464
2950#define OBJ_photo OBJ_pilotAttributeType,7L
2951
2952#define LN_userClass "userClass"
2953#define NID_userClass 465
2954#define OBJ_userClass OBJ_pilotAttributeType,8L
2955
2956#define SN_host "host"
2957#define NID_host 466
2958#define OBJ_host OBJ_pilotAttributeType,9L
2959
2960#define SN_manager "manager"
2961#define NID_manager 467
2962#define OBJ_manager OBJ_pilotAttributeType,10L
2963
2964#define LN_documentIdentifier "documentIdentifier"
2965#define NID_documentIdentifier 468
2966#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L
2967
2968#define LN_documentTitle "documentTitle"
2969#define NID_documentTitle 469
2970#define OBJ_documentTitle OBJ_pilotAttributeType,12L
2971
2972#define LN_documentVersion "documentVersion"
2973#define NID_documentVersion 470
2974#define OBJ_documentVersion OBJ_pilotAttributeType,13L
2975
2976#define LN_documentAuthor "documentAuthor"
2977#define NID_documentAuthor 471
2978#define OBJ_documentAuthor OBJ_pilotAttributeType,14L
2979
2980#define LN_documentLocation "documentLocation"
2981#define NID_documentLocation 472
2982#define OBJ_documentLocation OBJ_pilotAttributeType,15L
2983
2984#define LN_homeTelephoneNumber "homeTelephoneNumber"
2985#define NID_homeTelephoneNumber 473
2986#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L
2987
2988#define SN_secretary "secretary"
2989#define NID_secretary 474
2990#define OBJ_secretary OBJ_pilotAttributeType,21L
2991
2992#define LN_otherMailbox "otherMailbox"
2993#define NID_otherMailbox 475
2994#define OBJ_otherMailbox OBJ_pilotAttributeType,22L
2995
2996#define LN_lastModifiedTime "lastModifiedTime"
2997#define NID_lastModifiedTime 476
2998#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L
2999
3000#define LN_lastModifiedBy "lastModifiedBy"
3001#define NID_lastModifiedBy 477
3002#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L
3003
3004#define SN_domainComponent "DC"
3005#define LN_domainComponent "domainComponent"
3006#define NID_domainComponent 391
3007#define OBJ_domainComponent OBJ_pilotAttributeType,25L
3008
3009#define LN_aRecord "aRecord"
3010#define NID_aRecord 478
3011#define OBJ_aRecord OBJ_pilotAttributeType,26L
3012
3013#define LN_pilotAttributeType27 "pilotAttributeType27"
3014#define NID_pilotAttributeType27 479
3015#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L
3016
3017#define LN_mXRecord "mXRecord"
3018#define NID_mXRecord 480
3019#define OBJ_mXRecord OBJ_pilotAttributeType,28L
3020
3021#define LN_nSRecord "nSRecord"
3022#define NID_nSRecord 481
3023#define OBJ_nSRecord OBJ_pilotAttributeType,29L
3024
3025#define LN_sOARecord "sOARecord"
3026#define NID_sOARecord 482
3027#define OBJ_sOARecord OBJ_pilotAttributeType,30L
3028
3029#define LN_cNAMERecord "cNAMERecord"
3030#define NID_cNAMERecord 483
3031#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L
3032
3033#define LN_associatedDomain "associatedDomain"
3034#define NID_associatedDomain 484
3035#define OBJ_associatedDomain OBJ_pilotAttributeType,37L
3036
3037#define LN_associatedName "associatedName"
3038#define NID_associatedName 485
3039#define OBJ_associatedName OBJ_pilotAttributeType,38L
3040
3041#define LN_homePostalAddress "homePostalAddress"
3042#define NID_homePostalAddress 486
3043#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L
3044
3045#define LN_personalTitle "personalTitle"
3046#define NID_personalTitle 487
3047#define OBJ_personalTitle OBJ_pilotAttributeType,40L
3048
3049#define LN_mobileTelephoneNumber "mobileTelephoneNumber"
3050#define NID_mobileTelephoneNumber 488
3051#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L
3052
3053#define LN_pagerTelephoneNumber "pagerTelephoneNumber"
3054#define NID_pagerTelephoneNumber 489
3055#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L
3056
3057#define LN_friendlyCountryName "friendlyCountryName"
3058#define NID_friendlyCountryName 490
3059#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L
3060
3061#define LN_organizationalStatus "organizationalStatus"
3062#define NID_organizationalStatus 491
3063#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L
3064
3065#define LN_janetMailbox "janetMailbox"
3066#define NID_janetMailbox 492
3067#define OBJ_janetMailbox OBJ_pilotAttributeType,46L
3068
3069#define LN_mailPreferenceOption "mailPreferenceOption"
3070#define NID_mailPreferenceOption 493
3071#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L
3072
3073#define LN_buildingName "buildingName"
3074#define NID_buildingName 494
3075#define OBJ_buildingName OBJ_pilotAttributeType,48L
3076
3077#define LN_dSAQuality "dSAQuality"
3078#define NID_dSAQuality 495
3079#define OBJ_dSAQuality OBJ_pilotAttributeType,49L
3080
3081#define LN_singleLevelQuality "singleLevelQuality"
3082#define NID_singleLevelQuality 496
3083#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L
3084
3085#define LN_subtreeMinimumQuality "subtreeMinimumQuality"
3086#define NID_subtreeMinimumQuality 497
3087#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L
3088
3089#define LN_subtreeMaximumQuality "subtreeMaximumQuality"
3090#define NID_subtreeMaximumQuality 498
3091#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L
3092
3093#define LN_personalSignature "personalSignature"
3094#define NID_personalSignature 499
3095#define OBJ_personalSignature OBJ_pilotAttributeType,53L
3096
3097#define LN_dITRedirect "dITRedirect"
3098#define NID_dITRedirect 500
3099#define OBJ_dITRedirect OBJ_pilotAttributeType,54L
3100
3101#define SN_audio "audio"
3102#define NID_audio 501
3103#define OBJ_audio OBJ_pilotAttributeType,55L
3104
3105#define LN_documentPublisher "documentPublisher"
3106#define NID_documentPublisher 502
3107#define OBJ_documentPublisher OBJ_pilotAttributeType,56L
3108
3109#define SN_id_set "id-set"
3110#define LN_id_set "Secure Electronic Transactions"
3111#define NID_id_set 512
3112#define OBJ_id_set OBJ_international_organizations,42L
3113
3114#define SN_set_ctype "set-ctype"
3115#define LN_set_ctype "content types"
3116#define NID_set_ctype 513
3117#define OBJ_set_ctype OBJ_id_set,0L
3118
3119#define SN_set_msgExt "set-msgExt"
3120#define LN_set_msgExt "message extensions"
3121#define NID_set_msgExt 514
3122#define OBJ_set_msgExt OBJ_id_set,1L
3123
3124#define SN_set_attr "set-attr"
3125#define NID_set_attr 515
3126#define OBJ_set_attr OBJ_id_set,3L
3127
3128#define SN_set_policy "set-policy"
3129#define NID_set_policy 516
3130#define OBJ_set_policy OBJ_id_set,5L
3131
3132#define SN_set_certExt "set-certExt"
3133#define LN_set_certExt "certificate extensions"
3134#define NID_set_certExt 517
3135#define OBJ_set_certExt OBJ_id_set,7L
3136
3137#define SN_set_brand "set-brand"
3138#define NID_set_brand 518
3139#define OBJ_set_brand OBJ_id_set,8L
3140
3141#define SN_setct_PANData "setct-PANData"
3142#define NID_setct_PANData 519
3143#define OBJ_setct_PANData OBJ_set_ctype,0L
3144
3145#define SN_setct_PANToken "setct-PANToken"
3146#define NID_setct_PANToken 520
3147#define OBJ_setct_PANToken OBJ_set_ctype,1L
3148
3149#define SN_setct_PANOnly "setct-PANOnly"
3150#define NID_setct_PANOnly 521
3151#define OBJ_setct_PANOnly OBJ_set_ctype,2L
3152
3153#define SN_setct_OIData "setct-OIData"
3154#define NID_setct_OIData 522
3155#define OBJ_setct_OIData OBJ_set_ctype,3L
3156
3157#define SN_setct_PI "setct-PI"
3158#define NID_setct_PI 523
3159#define OBJ_setct_PI OBJ_set_ctype,4L
3160
3161#define SN_setct_PIData "setct-PIData"
3162#define NID_setct_PIData 524
3163#define OBJ_setct_PIData OBJ_set_ctype,5L
3164
3165#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned"
3166#define NID_setct_PIDataUnsigned 525
3167#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L
3168
3169#define SN_setct_HODInput "setct-HODInput"
3170#define NID_setct_HODInput 526
3171#define OBJ_setct_HODInput OBJ_set_ctype,7L
3172
3173#define SN_setct_AuthResBaggage "setct-AuthResBaggage"
3174#define NID_setct_AuthResBaggage 527
3175#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L
3176
3177#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage"
3178#define NID_setct_AuthRevReqBaggage 528
3179#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L
3180
3181#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage"
3182#define NID_setct_AuthRevResBaggage 529
3183#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L
3184
3185#define SN_setct_CapTokenSeq "setct-CapTokenSeq"
3186#define NID_setct_CapTokenSeq 530
3187#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L
3188
3189#define SN_setct_PInitResData "setct-PInitResData"
3190#define NID_setct_PInitResData 531
3191#define OBJ_setct_PInitResData OBJ_set_ctype,12L
3192
3193#define SN_setct_PI_TBS "setct-PI-TBS"
3194#define NID_setct_PI_TBS 532
3195#define OBJ_setct_PI_TBS OBJ_set_ctype,13L
3196
3197#define SN_setct_PResData "setct-PResData"
3198#define NID_setct_PResData 533
3199#define OBJ_setct_PResData OBJ_set_ctype,14L
3200
3201#define SN_setct_AuthReqTBS "setct-AuthReqTBS"
3202#define NID_setct_AuthReqTBS 534
3203#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L
3204
3205#define SN_setct_AuthResTBS "setct-AuthResTBS"
3206#define NID_setct_AuthResTBS 535
3207#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L
3208
3209#define SN_setct_AuthResTBSX "setct-AuthResTBSX"
3210#define NID_setct_AuthResTBSX 536
3211#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L
3212
3213#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS"
3214#define NID_setct_AuthTokenTBS 537
3215#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L
3216
3217#define SN_setct_CapTokenData "setct-CapTokenData"
3218#define NID_setct_CapTokenData 538
3219#define OBJ_setct_CapTokenData OBJ_set_ctype,20L
3220
3221#define SN_setct_CapTokenTBS "setct-CapTokenTBS"
3222#define NID_setct_CapTokenTBS 539
3223#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L
3224
3225#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg"
3226#define NID_setct_AcqCardCodeMsg 540
3227#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L
3228
3229#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS"
3230#define NID_setct_AuthRevReqTBS 541
3231#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L
3232
3233#define SN_setct_AuthRevResData "setct-AuthRevResData"
3234#define NID_setct_AuthRevResData 542
3235#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L
3236
3237#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS"
3238#define NID_setct_AuthRevResTBS 543
3239#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L
3240
3241#define SN_setct_CapReqTBS "setct-CapReqTBS"
3242#define NID_setct_CapReqTBS 544
3243#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L
3244
3245#define SN_setct_CapReqTBSX "setct-CapReqTBSX"
3246#define NID_setct_CapReqTBSX 545
3247#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L
3248
3249#define SN_setct_CapResData "setct-CapResData"
3250#define NID_setct_CapResData 546
3251#define OBJ_setct_CapResData OBJ_set_ctype,28L
3252
3253#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS"
3254#define NID_setct_CapRevReqTBS 547
3255#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L
3256
3257#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX"
3258#define NID_setct_CapRevReqTBSX 548
3259#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L
3260
3261#define SN_setct_CapRevResData "setct-CapRevResData"
3262#define NID_setct_CapRevResData 549
3263#define OBJ_setct_CapRevResData OBJ_set_ctype,31L
3264
3265#define SN_setct_CredReqTBS "setct-CredReqTBS"
3266#define NID_setct_CredReqTBS 550
3267#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L
3268
3269#define SN_setct_CredReqTBSX "setct-CredReqTBSX"
3270#define NID_setct_CredReqTBSX 551
3271#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L
3272
3273#define SN_setct_CredResData "setct-CredResData"
3274#define NID_setct_CredResData 552
3275#define OBJ_setct_CredResData OBJ_set_ctype,34L
3276
3277#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS"
3278#define NID_setct_CredRevReqTBS 553
3279#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L
3280
3281#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX"
3282#define NID_setct_CredRevReqTBSX 554
3283#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L
3284
3285#define SN_setct_CredRevResData "setct-CredRevResData"
3286#define NID_setct_CredRevResData 555
3287#define OBJ_setct_CredRevResData OBJ_set_ctype,37L
3288
3289#define SN_setct_PCertReqData "setct-PCertReqData"
3290#define NID_setct_PCertReqData 556
3291#define OBJ_setct_PCertReqData OBJ_set_ctype,38L
3292
3293#define SN_setct_PCertResTBS "setct-PCertResTBS"
3294#define NID_setct_PCertResTBS 557
3295#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L
3296
3297#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData"
3298#define NID_setct_BatchAdminReqData 558
3299#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L
3300
3301#define SN_setct_BatchAdminResData "setct-BatchAdminResData"
3302#define NID_setct_BatchAdminResData 559
3303#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L
3304
3305#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS"
3306#define NID_setct_CardCInitResTBS 560
3307#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L
3308
3309#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS"
3310#define NID_setct_MeAqCInitResTBS 561
3311#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L
3312
3313#define SN_setct_RegFormResTBS "setct-RegFormResTBS"
3314#define NID_setct_RegFormResTBS 562
3315#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L
3316
3317#define SN_setct_CertReqData "setct-CertReqData"
3318#define NID_setct_CertReqData 563
3319#define OBJ_setct_CertReqData OBJ_set_ctype,45L
3320
3321#define SN_setct_CertReqTBS "setct-CertReqTBS"
3322#define NID_setct_CertReqTBS 564
3323#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L
3324
3325#define SN_setct_CertResData "setct-CertResData"
3326#define NID_setct_CertResData 565
3327#define OBJ_setct_CertResData OBJ_set_ctype,47L
3328
3329#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS"
3330#define NID_setct_CertInqReqTBS 566
3331#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L
3332
3333#define SN_setct_ErrorTBS "setct-ErrorTBS"
3334#define NID_setct_ErrorTBS 567
3335#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L
3336
3337#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE"
3338#define NID_setct_PIDualSignedTBE 568
3339#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L
3340
3341#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE"
3342#define NID_setct_PIUnsignedTBE 569
3343#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L
3344
3345#define SN_setct_AuthReqTBE "setct-AuthReqTBE"
3346#define NID_setct_AuthReqTBE 570
3347#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L
3348
3349#define SN_setct_AuthResTBE "setct-AuthResTBE"
3350#define NID_setct_AuthResTBE 571
3351#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L
3352
3353#define SN_setct_AuthResTBEX "setct-AuthResTBEX"
3354#define NID_setct_AuthResTBEX 572
3355#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L
3356
3357#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE"
3358#define NID_setct_AuthTokenTBE 573
3359#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L
3360
3361#define SN_setct_CapTokenTBE "setct-CapTokenTBE"
3362#define NID_setct_CapTokenTBE 574
3363#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L
3364
3365#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX"
3366#define NID_setct_CapTokenTBEX 575
3367#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L
3368
3369#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE"
3370#define NID_setct_AcqCardCodeMsgTBE 576
3371#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L
3372
3373#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE"
3374#define NID_setct_AuthRevReqTBE 577
3375#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L
3376
3377#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE"
3378#define NID_setct_AuthRevResTBE 578
3379#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L
3380
3381#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB"
3382#define NID_setct_AuthRevResTBEB 579
3383#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L
3384
3385#define SN_setct_CapReqTBE "setct-CapReqTBE"
3386#define NID_setct_CapReqTBE 580
3387#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L
3388
3389#define SN_setct_CapReqTBEX "setct-CapReqTBEX"
3390#define NID_setct_CapReqTBEX 581
3391#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L
3392
3393#define SN_setct_CapResTBE "setct-CapResTBE"
3394#define NID_setct_CapResTBE 582
3395#define OBJ_setct_CapResTBE OBJ_set_ctype,64L
3396
3397#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE"
3398#define NID_setct_CapRevReqTBE 583
3399#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L
3400
3401#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX"
3402#define NID_setct_CapRevReqTBEX 584
3403#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L
3404
3405#define SN_setct_CapRevResTBE "setct-CapRevResTBE"
3406#define NID_setct_CapRevResTBE 585
3407#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L
3408
3409#define SN_setct_CredReqTBE "setct-CredReqTBE"
3410#define NID_setct_CredReqTBE 586
3411#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L
3412
3413#define SN_setct_CredReqTBEX "setct-CredReqTBEX"
3414#define NID_setct_CredReqTBEX 587
3415#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L
3416
3417#define SN_setct_CredResTBE "setct-CredResTBE"
3418#define NID_setct_CredResTBE 588
3419#define OBJ_setct_CredResTBE OBJ_set_ctype,70L
3420
3421#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE"
3422#define NID_setct_CredRevReqTBE 589
3423#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L
3424
3425#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX"
3426#define NID_setct_CredRevReqTBEX 590
3427#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L
3428
3429#define SN_setct_CredRevResTBE "setct-CredRevResTBE"
3430#define NID_setct_CredRevResTBE 591
3431#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L
3432
3433#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE"
3434#define NID_setct_BatchAdminReqTBE 592
3435#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L
3436
3437#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE"
3438#define NID_setct_BatchAdminResTBE 593
3439#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L
3440
3441#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE"
3442#define NID_setct_RegFormReqTBE 594
3443#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L
3444
3445#define SN_setct_CertReqTBE "setct-CertReqTBE"
3446#define NID_setct_CertReqTBE 595
3447#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L
3448
3449#define SN_setct_CertReqTBEX "setct-CertReqTBEX"
3450#define NID_setct_CertReqTBEX 596
3451#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L
3452
3453#define SN_setct_CertResTBE "setct-CertResTBE"
3454#define NID_setct_CertResTBE 597
3455#define OBJ_setct_CertResTBE OBJ_set_ctype,79L
3456
3457#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS"
3458#define NID_setct_CRLNotificationTBS 598
3459#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L
3460
3461#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS"
3462#define NID_setct_CRLNotificationResTBS 599
3463#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L
3464
3465#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS"
3466#define NID_setct_BCIDistributionTBS 600
3467#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L
3468
3469#define SN_setext_genCrypt "setext-genCrypt"
3470#define LN_setext_genCrypt "generic cryptogram"
3471#define NID_setext_genCrypt 601
3472#define OBJ_setext_genCrypt OBJ_set_msgExt,1L
3473
3474#define SN_setext_miAuth "setext-miAuth"
3475#define LN_setext_miAuth "merchant initiated auth"
3476#define NID_setext_miAuth 602
3477#define OBJ_setext_miAuth OBJ_set_msgExt,3L
3478
3479#define SN_setext_pinSecure "setext-pinSecure"
3480#define NID_setext_pinSecure 603
3481#define OBJ_setext_pinSecure OBJ_set_msgExt,4L
3482
3483#define SN_setext_pinAny "setext-pinAny"
3484#define NID_setext_pinAny 604
3485#define OBJ_setext_pinAny OBJ_set_msgExt,5L
3486
3487#define SN_setext_track2 "setext-track2"
3488#define NID_setext_track2 605
3489#define OBJ_setext_track2 OBJ_set_msgExt,7L
3490
3491#define SN_setext_cv "setext-cv"
3492#define LN_setext_cv "additional verification"
3493#define NID_setext_cv 606
3494#define OBJ_setext_cv OBJ_set_msgExt,8L
3495
3496#define SN_set_policy_root "set-policy-root"
3497#define NID_set_policy_root 607
3498#define OBJ_set_policy_root OBJ_set_policy,0L
3499
3500#define SN_setCext_hashedRoot "setCext-hashedRoot"
3501#define NID_setCext_hashedRoot 608
3502#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L
3503
3504#define SN_setCext_certType "setCext-certType"
3505#define NID_setCext_certType 609
3506#define OBJ_setCext_certType OBJ_set_certExt,1L
3507
3508#define SN_setCext_merchData "setCext-merchData"
3509#define NID_setCext_merchData 610
3510#define OBJ_setCext_merchData OBJ_set_certExt,2L
3511
3512#define SN_setCext_cCertRequired "setCext-cCertRequired"
3513#define NID_setCext_cCertRequired 611
3514#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L
3515
3516#define SN_setCext_tunneling "setCext-tunneling"
3517#define NID_setCext_tunneling 612
3518#define OBJ_setCext_tunneling OBJ_set_certExt,4L
3519
3520#define SN_setCext_setExt "setCext-setExt"
3521#define NID_setCext_setExt 613
3522#define OBJ_setCext_setExt OBJ_set_certExt,5L
3523
3524#define SN_setCext_setQualf "setCext-setQualf"
3525#define NID_setCext_setQualf 614
3526#define OBJ_setCext_setQualf OBJ_set_certExt,6L
3527
3528#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities"
3529#define NID_setCext_PGWYcapabilities 615
3530#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L
3531
3532#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier"
3533#define NID_setCext_TokenIdentifier 616
3534#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L
3535
3536#define SN_setCext_Track2Data "setCext-Track2Data"
3537#define NID_setCext_Track2Data 617
3538#define OBJ_setCext_Track2Data OBJ_set_certExt,9L
3539
3540#define SN_setCext_TokenType "setCext-TokenType"
3541#define NID_setCext_TokenType 618
3542#define OBJ_setCext_TokenType OBJ_set_certExt,10L
3543
3544#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities"
3545#define NID_setCext_IssuerCapabilities 619
3546#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L
3547
3548#define SN_setAttr_Cert "setAttr-Cert"
3549#define NID_setAttr_Cert 620
3550#define OBJ_setAttr_Cert OBJ_set_attr,0L
3551
3552#define SN_setAttr_PGWYcap "setAttr-PGWYcap"
3553#define LN_setAttr_PGWYcap "payment gateway capabilities"
3554#define NID_setAttr_PGWYcap 621
3555#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L
3556
3557#define SN_setAttr_TokenType "setAttr-TokenType"
3558#define NID_setAttr_TokenType 622
3559#define OBJ_setAttr_TokenType OBJ_set_attr,2L
3560
3561#define SN_setAttr_IssCap "setAttr-IssCap"
3562#define LN_setAttr_IssCap "issuer capabilities"
3563#define NID_setAttr_IssCap 623
3564#define OBJ_setAttr_IssCap OBJ_set_attr,3L
3565
3566#define SN_set_rootKeyThumb "set-rootKeyThumb"
3567#define NID_set_rootKeyThumb 624
3568#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L
3569
3570#define SN_set_addPolicy "set-addPolicy"
3571#define NID_set_addPolicy 625
3572#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L
3573
3574#define SN_setAttr_Token_EMV "setAttr-Token-EMV"
3575#define NID_setAttr_Token_EMV 626
3576#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L
3577
3578#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime"
3579#define NID_setAttr_Token_B0Prime 627
3580#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L
3581
3582#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM"
3583#define NID_setAttr_IssCap_CVM 628
3584#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L
3585
3586#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2"
3587#define NID_setAttr_IssCap_T2 629
3588#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L
3589
3590#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig"
3591#define NID_setAttr_IssCap_Sig 630
3592#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L
3593
3594#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm"
3595#define LN_setAttr_GenCryptgrm "generate cryptogram"
3596#define NID_setAttr_GenCryptgrm 631
3597#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L
3598
3599#define SN_setAttr_T2Enc "setAttr-T2Enc"
3600#define LN_setAttr_T2Enc "encrypted track 2"
3601#define NID_setAttr_T2Enc 632
3602#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L
3603
3604#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt"
3605#define LN_setAttr_T2cleartxt "cleartext track 2"
3606#define NID_setAttr_T2cleartxt 633
3607#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L
3608
3609#define SN_setAttr_TokICCsig "setAttr-TokICCsig"
3610#define LN_setAttr_TokICCsig "ICC or token signature"
3611#define NID_setAttr_TokICCsig 634
3612#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L
3613
3614#define SN_setAttr_SecDevSig "setAttr-SecDevSig"
3615#define LN_setAttr_SecDevSig "secure device signature"
3616#define NID_setAttr_SecDevSig 635
3617#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L
3618
3619#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA"
3620#define NID_set_brand_IATA_ATA 636
3621#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L
3622
3623#define SN_set_brand_Diners "set-brand-Diners"
3624#define NID_set_brand_Diners 637
3625#define OBJ_set_brand_Diners OBJ_set_brand,30L
3626
3627#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress"
3628#define NID_set_brand_AmericanExpress 638
3629#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L
3630
3631#define SN_set_brand_JCB "set-brand-JCB"
3632#define NID_set_brand_JCB 639
3633#define OBJ_set_brand_JCB OBJ_set_brand,35L
3634
3635#define SN_set_brand_Visa "set-brand-Visa"
3636#define NID_set_brand_Visa 640
3637#define OBJ_set_brand_Visa OBJ_set_brand,4L
3638
3639#define SN_set_brand_MasterCard "set-brand-MasterCard"
3640#define NID_set_brand_MasterCard 641
3641#define OBJ_set_brand_MasterCard OBJ_set_brand,5L
3642
3643#define SN_set_brand_Novus "set-brand-Novus"
3644#define NID_set_brand_Novus 642
3645#define OBJ_set_brand_Novus OBJ_set_brand,6011L
3646
3647#define SN_des_cdmf "DES-CDMF"
3648#define LN_des_cdmf "des-cdmf"
3649#define NID_des_cdmf 643
3650#define OBJ_des_cdmf OBJ_rsadsi,3L,10L
3651
3652#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET"
3653#define NID_rsaOAEPEncryptionSET 644
3654#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L
3655
3656#define SN_ipsec3 "Oakley-EC2N-3"
3657#define LN_ipsec3 "ipsec3"
3658#define NID_ipsec3 749
3659
3660#define SN_ipsec4 "Oakley-EC2N-4"
3661#define LN_ipsec4 "ipsec4"
3662#define NID_ipsec4 750
3663
3664#define SN_whirlpool "whirlpool"
3665#define NID_whirlpool 804
3666#define OBJ_whirlpool OBJ_iso,0L,10118L,3L,0L,55L
3667
3668#define SN_cryptopro "cryptopro"
3669#define NID_cryptopro 805
3670#define OBJ_cryptopro OBJ_member_body,643L,2L,2L
3671
3672#define SN_cryptocom "cryptocom"
3673#define NID_cryptocom 806
3674#define OBJ_cryptocom OBJ_member_body,643L,2L,9L
3675
3676#define SN_id_GostR3411_94_with_GostR3410_2001 "id-GostR3411-94-with-GostR3410-2001"
3677#define LN_id_GostR3411_94_with_GostR3410_2001 "GOST R 34.11-94 with GOST R 34.10-2001"
3678#define NID_id_GostR3411_94_with_GostR3410_2001 807
3679#define OBJ_id_GostR3411_94_with_GostR3410_2001 OBJ_cryptopro,3L
3680
3681#define SN_id_GostR3411_94_with_GostR3410_94 "id-GostR3411-94-with-GostR3410-94"
3682#define LN_id_GostR3411_94_with_GostR3410_94 "GOST R 34.11-94 with GOST R 34.10-94"
3683#define NID_id_GostR3411_94_with_GostR3410_94 808
3684#define OBJ_id_GostR3411_94_with_GostR3410_94 OBJ_cryptopro,4L
3685
3686#define SN_id_GostR3411_94 "md_gost94"
3687#define LN_id_GostR3411_94 "GOST R 34.11-94"
3688#define NID_id_GostR3411_94 809
3689#define OBJ_id_GostR3411_94 OBJ_cryptopro,9L
3690
3691#define SN_id_HMACGostR3411_94 "id-HMACGostR3411-94"
3692#define LN_id_HMACGostR3411_94 "HMAC GOST 34.11-94"
3693#define NID_id_HMACGostR3411_94 810
3694#define OBJ_id_HMACGostR3411_94 OBJ_cryptopro,10L
3695
3696#define SN_id_GostR3410_2001 "gost2001"
3697#define LN_id_GostR3410_2001 "GOST R 34.10-2001"
3698#define NID_id_GostR3410_2001 811
3699#define OBJ_id_GostR3410_2001 OBJ_cryptopro,19L
3700
3701#define SN_id_GostR3410_94 "gost94"
3702#define LN_id_GostR3410_94 "GOST R 34.10-94"
3703#define NID_id_GostR3410_94 812
3704#define OBJ_id_GostR3410_94 OBJ_cryptopro,20L
3705
3706#define SN_id_Gost28147_89 "gost89"
3707#define LN_id_Gost28147_89 "GOST 28147-89"
3708#define NID_id_Gost28147_89 813
3709#define OBJ_id_Gost28147_89 OBJ_cryptopro,21L
3710
3711#define SN_gost89_cnt "gost89-cnt"
3712#define NID_gost89_cnt 814
3713
3714#define SN_id_Gost28147_89_MAC "gost-mac"
3715#define LN_id_Gost28147_89_MAC "GOST 28147-89 MAC"
3716#define NID_id_Gost28147_89_MAC 815
3717#define OBJ_id_Gost28147_89_MAC OBJ_cryptopro,22L
3718
3719#define SN_id_GostR3411_94_prf "prf-gostr3411-94"
3720#define LN_id_GostR3411_94_prf "GOST R 34.11-94 PRF"
3721#define NID_id_GostR3411_94_prf 816
3722#define OBJ_id_GostR3411_94_prf OBJ_cryptopro,23L
3723
3724#define SN_id_GostR3410_2001DH "id-GostR3410-2001DH"
3725#define LN_id_GostR3410_2001DH "GOST R 34.10-2001 DH"
3726#define NID_id_GostR3410_2001DH 817
3727#define OBJ_id_GostR3410_2001DH OBJ_cryptopro,98L
3728
3729#define SN_id_GostR3410_94DH "id-GostR3410-94DH"
3730#define LN_id_GostR3410_94DH "GOST R 34.10-94 DH"
3731#define NID_id_GostR3410_94DH 818
3732#define OBJ_id_GostR3410_94DH OBJ_cryptopro,99L
3733
3734#define SN_id_Gost28147_89_CryptoPro_KeyMeshing "id-Gost28147-89-CryptoPro-KeyMeshing"
3735#define NID_id_Gost28147_89_CryptoPro_KeyMeshing 819
3736#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing OBJ_cryptopro,14L,1L
3737
3738#define SN_id_Gost28147_89_None_KeyMeshing "id-Gost28147-89-None-KeyMeshing"
3739#define NID_id_Gost28147_89_None_KeyMeshing 820
3740#define OBJ_id_Gost28147_89_None_KeyMeshing OBJ_cryptopro,14L,0L
3741
3742#define SN_id_GostR3411_94_TestParamSet "id-GostR3411-94-TestParamSet"
3743#define NID_id_GostR3411_94_TestParamSet 821
3744#define OBJ_id_GostR3411_94_TestParamSet OBJ_cryptopro,30L,0L
3745
3746#define SN_id_GostR3411_94_CryptoProParamSet "id-GostR3411-94-CryptoProParamSet"
3747#define NID_id_GostR3411_94_CryptoProParamSet 822
3748#define OBJ_id_GostR3411_94_CryptoProParamSet OBJ_cryptopro,30L,1L
3749
3750#define SN_id_Gost28147_89_TestParamSet "id-Gost28147-89-TestParamSet"
3751#define NID_id_Gost28147_89_TestParamSet 823
3752#define OBJ_id_Gost28147_89_TestParamSet OBJ_cryptopro,31L,0L
3753
3754#define SN_id_Gost28147_89_CryptoPro_A_ParamSet "id-Gost28147-89-CryptoPro-A-ParamSet"
3755#define NID_id_Gost28147_89_CryptoPro_A_ParamSet 824
3756#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet OBJ_cryptopro,31L,1L
3757
3758#define SN_id_Gost28147_89_CryptoPro_B_ParamSet "id-Gost28147-89-CryptoPro-B-ParamSet"
3759#define NID_id_Gost28147_89_CryptoPro_B_ParamSet 825
3760#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet OBJ_cryptopro,31L,2L
3761
3762#define SN_id_Gost28147_89_CryptoPro_C_ParamSet "id-Gost28147-89-CryptoPro-C-ParamSet"
3763#define NID_id_Gost28147_89_CryptoPro_C_ParamSet 826
3764#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet OBJ_cryptopro,31L,3L
3765
3766#define SN_id_Gost28147_89_CryptoPro_D_ParamSet "id-Gost28147-89-CryptoPro-D-ParamSet"
3767#define NID_id_Gost28147_89_CryptoPro_D_ParamSet 827
3768#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet OBJ_cryptopro,31L,4L
3769
3770#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet"
3771#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet 828
3772#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet OBJ_cryptopro,31L,5L
3773
3774#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet"
3775#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet 829
3776#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet OBJ_cryptopro,31L,6L
3777
3778#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet "id-Gost28147-89-CryptoPro-RIC-1-ParamSet"
3779#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet 830
3780#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet OBJ_cryptopro,31L,7L
3781
3782#define SN_id_GostR3410_94_TestParamSet "id-GostR3410-94-TestParamSet"
3783#define NID_id_GostR3410_94_TestParamSet 831
3784#define OBJ_id_GostR3410_94_TestParamSet OBJ_cryptopro,32L,0L
3785
3786#define SN_id_GostR3410_94_CryptoPro_A_ParamSet "id-GostR3410-94-CryptoPro-A-ParamSet"
3787#define NID_id_GostR3410_94_CryptoPro_A_ParamSet 832
3788#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet OBJ_cryptopro,32L,2L
3789
3790#define SN_id_GostR3410_94_CryptoPro_B_ParamSet "id-GostR3410-94-CryptoPro-B-ParamSet"
3791#define NID_id_GostR3410_94_CryptoPro_B_ParamSet 833
3792#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet OBJ_cryptopro,32L,3L
3793
3794#define SN_id_GostR3410_94_CryptoPro_C_ParamSet "id-GostR3410-94-CryptoPro-C-ParamSet"
3795#define NID_id_GostR3410_94_CryptoPro_C_ParamSet 834
3796#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet OBJ_cryptopro,32L,4L
3797
3798#define SN_id_GostR3410_94_CryptoPro_D_ParamSet "id-GostR3410-94-CryptoPro-D-ParamSet"
3799#define NID_id_GostR3410_94_CryptoPro_D_ParamSet 835
3800#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet OBJ_cryptopro,32L,5L
3801
3802#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet "id-GostR3410-94-CryptoPro-XchA-ParamSet"
3803#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet 836
3804#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet OBJ_cryptopro,33L,1L
3805
3806#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet "id-GostR3410-94-CryptoPro-XchB-ParamSet"
3807#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet 837
3808#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet OBJ_cryptopro,33L,2L
3809
3810#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet "id-GostR3410-94-CryptoPro-XchC-ParamSet"
3811#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet 838
3812#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet OBJ_cryptopro,33L,3L
3813
3814#define SN_id_GostR3410_2001_TestParamSet "id-GostR3410-2001-TestParamSet"
3815#define NID_id_GostR3410_2001_TestParamSet 839
3816#define OBJ_id_GostR3410_2001_TestParamSet OBJ_cryptopro,35L,0L
3817
3818#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet "id-GostR3410-2001-CryptoPro-A-ParamSet"
3819#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet 840
3820#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet OBJ_cryptopro,35L,1L
3821
3822#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet "id-GostR3410-2001-CryptoPro-B-ParamSet"
3823#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet 841
3824#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet OBJ_cryptopro,35L,2L
3825
3826#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet "id-GostR3410-2001-CryptoPro-C-ParamSet"
3827#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet 842
3828#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet OBJ_cryptopro,35L,3L
3829
3830#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet "id-GostR3410-2001-CryptoPro-XchA-ParamSet"
3831#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet 843
3832#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet OBJ_cryptopro,36L,0L
3833
3834#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet "id-GostR3410-2001-CryptoPro-XchB-ParamSet"
3835#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet 844
3836#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet OBJ_cryptopro,36L,1L
3837
3838#define SN_id_GostR3410_94_a "id-GostR3410-94-a"
3839#define NID_id_GostR3410_94_a 845
3840#define OBJ_id_GostR3410_94_a OBJ_id_GostR3410_94,1L
3841
3842#define SN_id_GostR3410_94_aBis "id-GostR3410-94-aBis"
3843#define NID_id_GostR3410_94_aBis 846
3844#define OBJ_id_GostR3410_94_aBis OBJ_id_GostR3410_94,2L
3845
3846#define SN_id_GostR3410_94_b "id-GostR3410-94-b"
3847#define NID_id_GostR3410_94_b 847
3848#define OBJ_id_GostR3410_94_b OBJ_id_GostR3410_94,3L
3849
3850#define SN_id_GostR3410_94_bBis "id-GostR3410-94-bBis"
3851#define NID_id_GostR3410_94_bBis 848
3852#define OBJ_id_GostR3410_94_bBis OBJ_id_GostR3410_94,4L
3853
3854#define SN_id_Gost28147_89_cc "id-Gost28147-89-cc"
3855#define LN_id_Gost28147_89_cc "GOST 28147-89 Cryptocom ParamSet"
3856#define NID_id_Gost28147_89_cc 849
3857#define OBJ_id_Gost28147_89_cc OBJ_cryptocom,1L,6L,1L
3858
3859#define SN_id_GostR3410_94_cc "gost94cc"
3860#define LN_id_GostR3410_94_cc "GOST 34.10-94 Cryptocom"
3861#define NID_id_GostR3410_94_cc 850
3862#define OBJ_id_GostR3410_94_cc OBJ_cryptocom,1L,5L,3L
3863
3864#define SN_id_GostR3410_2001_cc "gost2001cc"
3865#define LN_id_GostR3410_2001_cc "GOST 34.10-2001 Cryptocom"
3866#define NID_id_GostR3410_2001_cc 851
3867#define OBJ_id_GostR3410_2001_cc OBJ_cryptocom,1L,5L,4L
3868
3869#define SN_id_GostR3411_94_with_GostR3410_94_cc "id-GostR3411-94-with-GostR3410-94-cc"
3870#define LN_id_GostR3411_94_with_GostR3410_94_cc "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom"
3871#define NID_id_GostR3411_94_with_GostR3410_94_cc 852
3872#define OBJ_id_GostR3411_94_with_GostR3410_94_cc OBJ_cryptocom,1L,3L,3L
3873
3874#define SN_id_GostR3411_94_with_GostR3410_2001_cc "id-GostR3411-94-with-GostR3410-2001-cc"
3875#define LN_id_GostR3411_94_with_GostR3410_2001_cc "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom"
3876#define NID_id_GostR3411_94_with_GostR3410_2001_cc 853
3877#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc OBJ_cryptocom,1L,3L,4L
3878
3879#define SN_id_GostR3410_2001_ParamSet_cc "id-GostR3410-2001-ParamSet-cc"
3880#define LN_id_GostR3410_2001_ParamSet_cc "GOST R 3410-2001 Parameter Set Cryptocom"
3881#define NID_id_GostR3410_2001_ParamSet_cc 854
3882#define OBJ_id_GostR3410_2001_ParamSet_cc OBJ_cryptocom,1L,8L,1L
3883
3884#define SN_camellia_128_cbc "CAMELLIA-128-CBC"
3885#define LN_camellia_128_cbc "camellia-128-cbc"
3886#define NID_camellia_128_cbc 751
3887#define OBJ_camellia_128_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,2L
3888
3889#define SN_camellia_192_cbc "CAMELLIA-192-CBC"
3890#define LN_camellia_192_cbc "camellia-192-cbc"
3891#define NID_camellia_192_cbc 752
3892#define OBJ_camellia_192_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,3L
3893
3894#define SN_camellia_256_cbc "CAMELLIA-256-CBC"
3895#define LN_camellia_256_cbc "camellia-256-cbc"
3896#define NID_camellia_256_cbc 753
3897#define OBJ_camellia_256_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,4L
3898
3899#define SN_id_camellia128_wrap "id-camellia128-wrap"
3900#define NID_id_camellia128_wrap 907
3901#define OBJ_id_camellia128_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,2L
3902
3903#define SN_id_camellia192_wrap "id-camellia192-wrap"
3904#define NID_id_camellia192_wrap 908
3905#define OBJ_id_camellia192_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,3L
3906
3907#define SN_id_camellia256_wrap "id-camellia256-wrap"
3908#define NID_id_camellia256_wrap 909
3909#define OBJ_id_camellia256_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,4L
3910
3911#define OBJ_ntt_ds 0L,3L,4401L,5L
3912
3913#define OBJ_camellia OBJ_ntt_ds,3L,1L,9L
3914
3915#define SN_camellia_128_ecb "CAMELLIA-128-ECB"
3916#define LN_camellia_128_ecb "camellia-128-ecb"
3917#define NID_camellia_128_ecb 754
3918#define OBJ_camellia_128_ecb OBJ_camellia,1L
3919
3920#define SN_camellia_128_ofb128 "CAMELLIA-128-OFB"
3921#define LN_camellia_128_ofb128 "camellia-128-ofb"
3922#define NID_camellia_128_ofb128 766
3923#define OBJ_camellia_128_ofb128 OBJ_camellia,3L
3924
3925#define SN_camellia_128_cfb128 "CAMELLIA-128-CFB"
3926#define LN_camellia_128_cfb128 "camellia-128-cfb"
3927#define NID_camellia_128_cfb128 757
3928#define OBJ_camellia_128_cfb128 OBJ_camellia,4L
3929
3930#define SN_camellia_192_ecb "CAMELLIA-192-ECB"
3931#define LN_camellia_192_ecb "camellia-192-ecb"
3932#define NID_camellia_192_ecb 755
3933#define OBJ_camellia_192_ecb OBJ_camellia,21L
3934
3935#define SN_camellia_192_ofb128 "CAMELLIA-192-OFB"
3936#define LN_camellia_192_ofb128 "camellia-192-ofb"
3937#define NID_camellia_192_ofb128 767
3938#define OBJ_camellia_192_ofb128 OBJ_camellia,23L
3939
3940#define SN_camellia_192_cfb128 "CAMELLIA-192-CFB"
3941#define LN_camellia_192_cfb128 "camellia-192-cfb"
3942#define NID_camellia_192_cfb128 758
3943#define OBJ_camellia_192_cfb128 OBJ_camellia,24L
3944
3945#define SN_camellia_256_ecb "CAMELLIA-256-ECB"
3946#define LN_camellia_256_ecb "camellia-256-ecb"
3947#define NID_camellia_256_ecb 756
3948#define OBJ_camellia_256_ecb OBJ_camellia,41L
3949
3950#define SN_camellia_256_ofb128 "CAMELLIA-256-OFB"
3951#define LN_camellia_256_ofb128 "camellia-256-ofb"
3952#define NID_camellia_256_ofb128 768
3953#define OBJ_camellia_256_ofb128 OBJ_camellia,43L
3954
3955#define SN_camellia_256_cfb128 "CAMELLIA-256-CFB"
3956#define LN_camellia_256_cfb128 "camellia-256-cfb"
3957#define NID_camellia_256_cfb128 759
3958#define OBJ_camellia_256_cfb128 OBJ_camellia,44L
3959
3960#define SN_camellia_128_cfb1 "CAMELLIA-128-CFB1"
3961#define LN_camellia_128_cfb1 "camellia-128-cfb1"
3962#define NID_camellia_128_cfb1 760
3963
3964#define SN_camellia_192_cfb1 "CAMELLIA-192-CFB1"
3965#define LN_camellia_192_cfb1 "camellia-192-cfb1"
3966#define NID_camellia_192_cfb1 761
3967
3968#define SN_camellia_256_cfb1 "CAMELLIA-256-CFB1"
3969#define LN_camellia_256_cfb1 "camellia-256-cfb1"
3970#define NID_camellia_256_cfb1 762
3971
3972#define SN_camellia_128_cfb8 "CAMELLIA-128-CFB8"
3973#define LN_camellia_128_cfb8 "camellia-128-cfb8"
3974#define NID_camellia_128_cfb8 763
3975
3976#define SN_camellia_192_cfb8 "CAMELLIA-192-CFB8"
3977#define LN_camellia_192_cfb8 "camellia-192-cfb8"
3978#define NID_camellia_192_cfb8 764
3979
3980#define SN_camellia_256_cfb8 "CAMELLIA-256-CFB8"
3981#define LN_camellia_256_cfb8 "camellia-256-cfb8"
3982#define NID_camellia_256_cfb8 765
3983
3984#define SN_kisa "KISA"
3985#define LN_kisa "kisa"
3986#define NID_kisa 773
3987#define OBJ_kisa OBJ_member_body,410L,200004L
3988
3989#define SN_seed_ecb "SEED-ECB"
3990#define LN_seed_ecb "seed-ecb"
3991#define NID_seed_ecb 776
3992#define OBJ_seed_ecb OBJ_kisa,1L,3L
3993
3994#define SN_seed_cbc "SEED-CBC"
3995#define LN_seed_cbc "seed-cbc"
3996#define NID_seed_cbc 777
3997#define OBJ_seed_cbc OBJ_kisa,1L,4L
3998
3999#define SN_seed_cfb128 "SEED-CFB"
4000#define LN_seed_cfb128 "seed-cfb"
4001#define NID_seed_cfb128 779
4002#define OBJ_seed_cfb128 OBJ_kisa,1L,5L
4003
4004#define SN_seed_ofb128 "SEED-OFB"
4005#define LN_seed_ofb128 "seed-ofb"
4006#define NID_seed_ofb128 778
4007#define OBJ_seed_ofb128 OBJ_kisa,1L,6L
4008
4009#define SN_hmac "HMAC"
4010#define LN_hmac "hmac"
4011#define NID_hmac 855
4012
4013#define SN_cmac "CMAC"
4014#define LN_cmac "cmac"
4015#define NID_cmac 894
4016
4017#define SN_rc4_hmac_md5 "RC4-HMAC-MD5"
4018#define LN_rc4_hmac_md5 "rc4-hmac-md5"
4019#define NID_rc4_hmac_md5 915
4020
4021#define SN_aes_128_cbc_hmac_sha1 "AES-128-CBC-HMAC-SHA1"
4022#define LN_aes_128_cbc_hmac_sha1 "aes-128-cbc-hmac-sha1"
4023#define NID_aes_128_cbc_hmac_sha1 916
4024
4025#define SN_aes_192_cbc_hmac_sha1 "AES-192-CBC-HMAC-SHA1"
4026#define LN_aes_192_cbc_hmac_sha1 "aes-192-cbc-hmac-sha1"
4027#define NID_aes_192_cbc_hmac_sha1 917
4028
4029#define SN_aes_256_cbc_hmac_sha1 "AES-256-CBC-HMAC-SHA1"
4030#define LN_aes_256_cbc_hmac_sha1 "aes-256-cbc-hmac-sha1"
4031#define NID_aes_256_cbc_hmac_sha1 918
4032
diff --git a/src/lib/libcrypto/perlasm/alpha.pl b/src/lib/libcrypto/perlasm/alpha.pl
deleted file mode 100644
index 3dac571743..0000000000
--- a/src/lib/libcrypto/perlasm/alpha.pl
+++ /dev/null
@@ -1,434 +0,0 @@
1#!/usr/local/bin/perl
2
3package alpha;
4use Carp qw(croak cluck);
5
6$label="100";
7
8$n_debug=0;
9$smear_regs=1;
10$reg_alloc=1;
11
12$align="3";
13$com_start="#";
14
15sub main'asm_init_output { @out=(); }
16sub main'asm_get_output { return(@out); }
17sub main'get_labels { return(@labels); }
18sub main'external_label { push(@labels,@_); }
19
20# General registers
21
22%regs=( 'r0', '$0',
23 'r1', '$1',
24 'r2', '$2',
25 'r3', '$3',
26 'r4', '$4',
27 'r5', '$5',
28 'r6', '$6',
29 'r7', '$7',
30 'r8', '$8',
31 'r9', '$22',
32 'r10', '$23',
33 'r11', '$24',
34 'r12', '$25',
35 'r13', '$27',
36 'r14', '$28',
37 'r15', '$21', # argc == 5
38 'r16', '$20', # argc == 4
39 'r17', '$19', # argc == 3
40 'r18', '$18', # argc == 2
41 'r19', '$17', # argc == 1
42 'r20', '$16', # argc == 0
43 'r21', '$9', # save 0
44 'r22', '$10', # save 1
45 'r23', '$11', # save 2
46 'r24', '$12', # save 3
47 'r25', '$13', # save 4
48 'r26', '$14', # save 5
49
50 'a0', '$16',
51 'a1', '$17',
52 'a2', '$18',
53 'a3', '$19',
54 'a4', '$20',
55 'a5', '$21',
56
57 's0', '$9',
58 's1', '$10',
59 's2', '$11',
60 's3', '$12',
61 's4', '$13',
62 's5', '$14',
63 'zero', '$31',
64 'sp', '$30',
65 );
66
67$main'reg_s0="r21";
68$main'reg_s1="r22";
69$main'reg_s2="r23";
70$main'reg_s3="r24";
71$main'reg_s4="r25";
72$main'reg_s5="r26";
73
74@reg=( '$0', '$1' ,'$2' ,'$3' ,'$4' ,'$5' ,'$6' ,'$7' ,'$8',
75 '$22','$23','$24','$25','$20','$21','$27','$28');
76
77
78sub main'sub { &out3("subq",@_); }
79sub main'add { &out3("addq",@_); }
80sub main'mov { &out3("bis",$_[0],$_[0],$_[1]); }
81sub main'or { &out3("bis",@_); }
82sub main'bis { &out3("bis",@_); }
83sub main'br { &out1("br",@_); }
84sub main'ld { &out2("ldq",@_); }
85sub main'st { &out2("stq",@_); }
86sub main'cmpult { &out3("cmpult",@_); }
87sub main'cmplt { &out3("cmplt",@_); }
88sub main'bgt { &out2("bgt",@_); }
89sub main'ble { &out2("ble",@_); }
90sub main'blt { &out2("blt",@_); }
91sub main'mul { &out3("mulq",@_); }
92sub main'muh { &out3("umulh",@_); }
93
94$main'QWS=8;
95
96sub main'asm_add
97 {
98 push(@out,@_);
99 }
100
101sub main'asm_finish
102 {
103 &main'file_end();
104 print &main'asm_get_output();
105 }
106
107sub main'asm_init
108 {
109 ($type,$fn)=@_;
110 $filename=$fn;
111
112 &main'asm_init_output();
113 &main'comment("Don't even think of reading this code");
114 &main'comment("It was automatically generated by $filename");
115 &main'comment("Which is a perl program used to generate the alpha assember.");
116 &main'comment("eric <eay\@cryptsoft.com>");
117 &main'comment("");
118
119 $filename =~ s/\.pl$//;
120 &main'file($filename);
121 }
122
123sub conv
124 {
125 local($r)=@_;
126 local($v);
127
128 return($regs{$r}) if defined($regs{$r});
129 return($r);
130 }
131
132sub main'QWPw
133 {
134 local($off,$reg)=@_;
135
136 return(&main'QWP($off*8,$reg));
137 }
138
139sub main'QWP
140 {
141 local($off,$reg)=@_;
142
143 $ret="$off(".&conv($reg).")";
144 return($ret);
145 }
146
147sub out3
148 {
149 local($name,$p1,$p2,$p3)=@_;
150
151 $p1=&conv($p1);
152 $p2=&conv($p2);
153 $p3=&conv($p3);
154 push(@out,"\t$name\t");
155 $l=length($p1)+1;
156 push(@out,$p1.",");
157 $ll=3-($l+9)/8;
158 $tmp1=sprintf("\t" x $ll);
159 push(@out,$tmp1);
160
161 $l=length($p2)+1;
162 push(@out,$p2.",");
163 $ll=3-($l+9)/8;
164 $tmp1=sprintf("\t" x $ll);
165 push(@out,$tmp1);
166
167 push(@out,&conv($p3)."\n");
168 }
169
170sub out2
171 {
172 local($name,$p1,$p2,$p3)=@_;
173
174 $p1=&conv($p1);
175 $p2=&conv($p2);
176 push(@out,"\t$name\t");
177 $l=length($p1)+1;
178 push(@out,$p1.",");
179 $ll=3-($l+9)/8;
180 $tmp1=sprintf("\t" x $ll);
181 push(@out,$tmp1);
182
183 push(@out,&conv($p2)."\n");
184 }
185
186sub out1
187 {
188 local($name,$p1)=@_;
189
190 $p1=&conv($p1);
191 push(@out,"\t$name\t".$p1."\n");
192 }
193
194sub out0
195 {
196 push(@out,"\t$_[0]\n");
197 }
198
199sub main'file
200 {
201 local($file)=@_;
202
203 local($tmp)=<<"EOF";
204 # DEC Alpha assember
205 # Generated from perl scripts contains in SSLeay
206 .file 1 "$file.s"
207 .set noat
208EOF
209 push(@out,$tmp);
210 }
211
212sub main'function_begin
213 {
214 local($func)=@_;
215
216print STDERR "$func\n";
217 local($tmp)=<<"EOF";
218 .text
219 .align $align
220 .globl $func
221 .ent $func
222${func}:
223${func}..ng:
224 .frame \$30,0,\$26,0
225 .prologue 0
226EOF
227 push(@out,$tmp);
228 $stack=0;
229 }
230
231sub main'function_end
232 {
233 local($func)=@_;
234
235 local($tmp)=<<"EOF";
236 ret \$31,(\$26),1
237 .end $func
238EOF
239 push(@out,$tmp);
240 $stack=0;
241 %label=();
242 }
243
244sub main'function_end_A
245 {
246 local($func)=@_;
247
248 local($tmp)=<<"EOF";
249 ret \$31,(\$26),1
250EOF
251 push(@out,$tmp);
252 }
253
254sub main'function_end_B
255 {
256 local($func)=@_;
257
258 $func=$under.$func;
259
260 push(@out,"\t.end $func\n");
261 $stack=0;
262 %label=();
263 }
264
265sub main'wparam
266 {
267 local($num)=@_;
268
269 if ($num < 6)
270 {
271 $num=20-$num;
272 return("r$num");
273 }
274 else
275 { return(&main'QWP($stack+$num*8,"sp")); }
276 }
277
278sub main'stack_push
279 {
280 local($num)=@_;
281 $stack+=$num*8;
282 &main'sub("sp",$num*8,"sp");
283 }
284
285sub main'stack_pop
286 {
287 local($num)=@_;
288 $stack-=$num*8;
289 &main'add("sp",$num*8,"sp");
290 }
291
292sub main'swtmp
293 {
294 return(&main'QWP(($_[0])*8,"sp"));
295 }
296
297# Should use swtmp, which is above sp. Linix can trash the stack above esp
298#sub main'wtmp
299# {
300# local($num)=@_;
301#
302# return(&main'QWP(-($num+1)*4,"esp","",0));
303# }
304
305sub main'comment
306 {
307 foreach (@_)
308 {
309 if (/^\s*$/)
310 { push(@out,"\n"); }
311 else
312 { push(@out,"\t$com_start $_ $com_end\n"); }
313 }
314 }
315
316sub main'label
317 {
318 if (!defined($label{$_[0]}))
319 {
320 $label{$_[0]}=$label;
321 $label++;
322 }
323 return('$'.$label{$_[0]});
324 }
325
326sub main'set_label
327 {
328 if (!defined($label{$_[0]}))
329 {
330 $label{$_[0]}=$label;
331 $label++;
332 }
333# push(@out,".align $align\n") if ($_[1] != 0);
334 push(@out,'$'."$label{$_[0]}:\n");
335 }
336
337sub main'file_end
338 {
339 }
340
341sub main'data_word
342 {
343 push(@out,"\t.long $_[0]\n");
344 }
345
346@pool_free=();
347@pool_taken=();
348$curr_num=0;
349$max=0;
350
351sub main'init_pool
352 {
353 local($args)=@_;
354 local($i);
355
356 @pool_free=();
357 for ($i=(14+(6-$args)); $i >= 0; $i--)
358 {
359 push(@pool_free,"r$i");
360 }
361 print STDERR "START :register pool:@pool_free\n";
362 $curr_num=$max=0;
363 }
364
365sub main'fin_pool
366 {
367 printf STDERR "END %2d:register pool:@pool_free\n",$max;
368 }
369
370sub main'GR
371 {
372 local($r)=@_;
373 local($i,@n,$_);
374
375 foreach (@pool_free)
376 {
377 if ($r ne $_)
378 { push(@n,$_); }
379 else
380 {
381 $curr_num++;
382 $max=$curr_num if ($curr_num > $max);
383 }
384 }
385 @pool_free=@n;
386print STDERR "GR:@pool_free\n" if $reg_alloc;
387 return(@_);
388 }
389
390sub main'NR
391 {
392 local($num)=@_;
393 local(@ret);
394
395 $num=1 if $num == 0;
396 ($#pool_free >= ($num-1)) || croak "out of registers: want $num, have @pool_free";
397 while ($num > 0)
398 {
399 push(@ret,pop @pool_free);
400 $curr_num++;
401 $max=$curr_num if ($curr_num > $max);
402 $num--
403 }
404 print STDERR "nr @ret\n" if $n_debug;
405print STDERR "NR:@pool_free\n" if $reg_alloc;
406 return(@ret);
407
408 }
409
410sub main'FR
411 {
412 local(@r)=@_;
413 local(@a,$v,$w);
414
415 print STDERR "fr @r\n" if $n_debug;
416# cluck "fr @r";
417 for $w (@pool_free)
418 {
419 foreach $v (@r)
420 {
421 croak "double register free of $v (@pool_free)" if $w eq $v;
422 }
423 }
424 foreach $v (@r)
425 {
426 croak "bad argument to FR" if ($v !~ /^r\d+$/);
427 if ($smear_regs)
428 { unshift(@pool_free,$v); }
429 else { push(@pool_free,$v); }
430 $curr_num--;
431 }
432print STDERR "FR:@pool_free\n" if $reg_alloc;
433 }
4341;
diff --git a/src/lib/libcrypto/perlasm/x86masm.pl b/src/lib/libcrypto/perlasm/x86masm.pl
new file mode 100644
index 0000000000..f937d07c87
--- /dev/null
+++ b/src/lib/libcrypto/perlasm/x86masm.pl
@@ -0,0 +1,198 @@
1#!/usr/bin/env perl
2
3package x86masm;
4
5*out=\@::out;
6
7$::lbdecor="\$L"; # local label decoration
8$nmdecor="_"; # external name decoration
9
10$initseg="";
11$segment="";
12
13sub ::generic
14{ my ($opcode,@arg)=@_;
15
16 # fix hexadecimal constants
17 for (@arg) { s/(?<![\w\$\.])0x([0-9a-f]+)/0$1h/oi; }
18
19 if ($opcode =~ /lea/ && @arg[1] =~ s/.*PTR\s+(\(.*\))$/OFFSET $1/) # no []
20 { $opcode="mov"; }
21 elsif ($opcode !~ /movq/)
22 { # fix xmm references
23 $arg[0] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[1]=~/\bxmm[0-7]\b/i);
24 $arg[1] =~ s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i if ($arg[0]=~/\bxmm[0-7]\b/i);
25 }
26
27 &::emit($opcode,@arg);
28 1;
29}
30#
31# opcodes not covered by ::generic above, mostly inconsistent namings...
32#
33sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); }
34sub ::call_ptr { &::emit("call",@_); }
35sub ::jmp_ptr { &::emit("jmp",@_); }
36sub ::lock { &::data_byte(0xf0); }
37
38sub get_mem
39{ my($size,$addr,$reg1,$reg2,$idx)=@_;
40 my($post,$ret);
41
42 $ret .= "$size PTR " if ($size ne "");
43
44 $addr =~ s/^\s+//;
45 # prepend global references with optional underscore
46 $addr =~ s/^([^\+\-0-9][^\+\-]*)/&::islabel($1) or "$nmdecor$1"/ige;
47 # put address arithmetic expression in parenthesis
48 $addr="($addr)" if ($addr =~ /^.+[\-\+].+$/);
49
50 if (($addr ne "") && ($addr ne 0))
51 { if ($addr !~ /^-/) { $ret .= "$addr"; }
52 else { $post=$addr; }
53 }
54 $ret .= "[";
55
56 if ($reg2 ne "")
57 { $idx!=0 or $idx=1;
58 $ret .= "$reg2*$idx";
59 $ret .= "+$reg1" if ($reg1 ne "");
60 }
61 else
62 { $ret .= "$reg1"; }
63
64 $ret .= "$post]";
65 $ret =~ s/\+\]/]/; # in case $addr was the only argument
66 $ret =~ s/\[\s*\]//;
67
68 $ret;
69}
70sub ::BP { &get_mem("BYTE",@_); }
71sub ::WP { &get_mem("WORD",@_); }
72sub ::DWP { &get_mem("DWORD",@_); }
73sub ::QWP { &get_mem("QWORD",@_); }
74sub ::BC { "@_"; }
75sub ::DWC { "@_"; }
76
77sub ::file
78{ my $tmp=<<___;
79TITLE $_[0].asm
80IF \@Version LT 800
81ECHO MASM version 8.00 or later is strongly recommended.
82ENDIF
83.486
84.MODEL FLAT
85OPTION DOTNAME
86IF \@Version LT 800
87.text\$ SEGMENT PAGE 'CODE'
88ELSE
89.text\$ SEGMENT ALIGN(64) 'CODE'
90ENDIF
91___
92 push(@out,$tmp);
93 $segment = ".text\$";
94}
95
96sub ::function_begin_B
97{ my $func=shift;
98 my $global=($func !~ /^_/);
99 my $begin="${::lbdecor}_${func}_begin";
100
101 &::LABEL($func,$global?"$begin":"$nmdecor$func");
102 $func="ALIGN\t16\n".$nmdecor.$func."\tPROC";
103
104 if ($global) { $func.=" PUBLIC\n${begin}::\n"; }
105 else { $func.=" PRIVATE\n"; }
106 push(@out,$func);
107 $::stack=4;
108}
109sub ::function_end_B
110{ my $func=shift;
111
112 push(@out,"$nmdecor$func ENDP\n");
113 $::stack=0;
114 &::wipe_labels();
115}
116
117sub ::file_end
118{ my $xmmheader=<<___;
119.686
120.XMM
121IF \@Version LT 800
122XMMWORD STRUCT 16
123DQ 2 dup (?)
124XMMWORD ENDS
125ENDIF
126___
127 if (grep {/\b[x]?mm[0-7]\b/i} @out) {
128 grep {s/\.[3-7]86/$xmmheader/} @out;
129 }
130
131 push(@out,"$segment ENDS\n");
132
133 if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out)
134 { my $comm=<<___;
135.bss SEGMENT 'BSS'
136COMM ${nmdecor}OPENSSL_ia32cap_P:QWORD
137.bss ENDS
138___
139 # comment out OPENSSL_ia32cap_P declarations
140 grep {s/(^EXTERN\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out;
141 push (@out,$comm);
142 }
143 push (@out,$initseg) if ($initseg);
144 push (@out,"END\n");
145}
146
147sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } }
148
149*::set_label_B = sub
150{ my $l=shift; push(@out,$l.($l=~/^\Q${::lbdecor}\E[0-9]{3}/?":\n":"::\n")); };
151
152sub ::external_label
153{ foreach(@_)
154 { push(@out, "EXTERN\t".&::LABEL($_,$nmdecor.$_).":NEAR\n"); }
155}
156
157sub ::public_label
158{ push(@out,"PUBLIC\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); }
159
160sub ::data_byte
161{ push(@out,("DB\t").join(',',@_)."\n"); }
162
163sub ::data_short
164{ push(@out,("DW\t").join(',',@_)."\n"); }
165
166sub ::data_word
167{ push(@out,("DD\t").join(',',@_)."\n"); }
168
169sub ::align
170{ push(@out,"ALIGN\t$_[0]\n"); }
171
172sub ::picmeup
173{ my($dst,$sym)=@_;
174 &::lea($dst,&::DWP($sym));
175}
176
177sub ::initseg
178{ my $f=$nmdecor.shift;
179
180 $initseg.=<<___;
181.CRT\$XCU SEGMENT DWORD PUBLIC 'DATA'
182EXTERN $f:NEAR
183DD $f
184.CRT\$XCU ENDS
185___
186}
187
188sub ::dataseg
189{ push(@out,"$segment\tENDS\n_DATA\tSEGMENT\n"); $segment="_DATA"; }
190
191sub ::safeseh
192{ my $nm=shift;
193 push(@out,"IF \@Version GE 710\n");
194 push(@out,".SAFESEH ".&::LABEL($nm,$nmdecor.$nm)."\n");
195 push(@out,"ENDIF\n");
196}
197
1981;
diff --git a/src/lib/libcrypto/perlasm/x86ms.pl b/src/lib/libcrypto/perlasm/x86ms.pl
deleted file mode 100644
index a0be2934c2..0000000000
--- a/src/lib/libcrypto/perlasm/x86ms.pl
+++ /dev/null
@@ -1,472 +0,0 @@
1#!/usr/local/bin/perl
2
3package x86ms;
4
5$label="L000";
6
7%lb=( 'eax', 'al',
8 'ebx', 'bl',
9 'ecx', 'cl',
10 'edx', 'dl',
11 'ax', 'al',
12 'bx', 'bl',
13 'cx', 'cl',
14 'dx', 'dl',
15 );
16
17%hb=( 'eax', 'ah',
18 'ebx', 'bh',
19 'ecx', 'ch',
20 'edx', 'dh',
21 'ax', 'ah',
22 'bx', 'bh',
23 'cx', 'ch',
24 'dx', 'dh',
25 );
26
27sub main'asm_init_output { @out=(); }
28sub main'asm_get_output { return(@out); }
29sub main'get_labels { return(@labels); }
30sub main'external_label
31{
32 push(@labels,@_);
33 foreach (@_) {
34 push(@out, "EXTRN\t_$_:DWORD\n");
35 }
36}
37
38sub main'LB
39 {
40 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
41 return($lb{$_[0]});
42 }
43
44sub main'HB
45 {
46 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
47 return($hb{$_[0]});
48 }
49
50sub main'BP
51 {
52 &get_mem("BYTE",@_);
53 }
54
55sub main'DWP
56 {
57 &get_mem("DWORD",@_);
58 }
59
60sub main'QWP
61 {
62 &get_mem("QWORD",@_);
63 }
64
65sub main'BC
66 {
67 return @_;
68 }
69
70sub main'DWC
71 {
72 return @_;
73 }
74
75sub main'stack_push
76 {
77 local($num)=@_;
78 $stack+=$num*4;
79 &main'sub("esp",$num*4);
80 }
81
82sub main'stack_pop
83 {
84 local($num)=@_;
85 $stack-=$num*4;
86 &main'add("esp",$num*4);
87 }
88
89sub get_mem
90 {
91 local($size,$addr,$reg1,$reg2,$idx)=@_;
92 local($t,$post);
93 local($ret)="$size PTR ";
94
95 $addr =~ s/^\s+//;
96 if ($addr =~ /^(.+)\+(.+)$/)
97 {
98 $reg2=&conv($1);
99 $addr="_$2";
100 }
101 elsif ($addr =~ /^[_a-z][_a-z0-9]*$/i)
102 {
103 $addr="_$addr";
104 }
105
106 if ($addr =~ /^.+\-.+$/) { $addr="($addr)"; }
107
108 $reg1="$regs{$reg1}" if defined($regs{$reg1});
109 $reg2="$regs{$reg2}" if defined($regs{$reg2});
110 if (($addr ne "") && ($addr ne 0))
111 {
112 if ($addr !~ /^-/)
113 { $ret.=$addr; }
114 else { $post=$addr; }
115 }
116 if ($reg2 ne "")
117 {
118 $t="";
119 $t="*$idx" if ($idx != 0);
120 $reg1="+".$reg1 if ("$reg1$post" ne "");
121 $ret.="[$reg2$t$reg1$post]";
122 }
123 else
124 {
125 $ret.="[$reg1$post]"
126 }
127 $ret =~ s/\[\]//; # in case $addr was the only argument
128 return($ret);
129 }
130
131sub main'mov { &out2("mov",@_); }
132sub main'movb { &out2("mov",@_); }
133sub main'and { &out2("and",@_); }
134sub main'or { &out2("or",@_); }
135sub main'shl { &out2("shl",@_); }
136sub main'shr { &out2("shr",@_); }
137sub main'xor { &out2("xor",@_); }
138sub main'xorb { &out2("xor",@_); }
139sub main'add { &out2("add",@_); }
140sub main'adc { &out2("adc",@_); }
141sub main'sub { &out2("sub",@_); }
142sub main'sbb { &out2("sbb",@_); }
143sub main'rotl { &out2("rol",@_); }
144sub main'rotr { &out2("ror",@_); }
145sub main'exch { &out2("xchg",@_); }
146sub main'cmp { &out2("cmp",@_); }
147sub main'lea { &out2("lea",@_); }
148sub main'mul { &out1("mul",@_); }
149sub main'imul { &out2("imul",@_); }
150sub main'div { &out1("div",@_); }
151sub main'dec { &out1("dec",@_); }
152sub main'inc { &out1("inc",@_); }
153sub main'jmp { &out1("jmp",@_); }
154sub main'jmp_ptr { &out1p("jmp",@_); }
155sub main'je { &out1("je",@_); }
156sub main'jle { &out1("jle",@_); }
157sub main'jz { &out1("jz",@_); }
158sub main'jge { &out1("jge",@_); }
159sub main'jl { &out1("jl",@_); }
160sub main'ja { &out1("ja",@_); }
161sub main'jae { &out1("jae",@_); }
162sub main'jb { &out1("jb",@_); }
163sub main'jbe { &out1("jbe",@_); }
164sub main'jc { &out1("jc",@_); }
165sub main'jnc { &out1("jnc",@_); }
166sub main'jnz { &out1("jnz",@_); }
167sub main'jne { &out1("jne",@_); }
168sub main'jno { &out1("jno",@_); }
169sub main'push { &out1("push",@_); $stack+=4; }
170sub main'pop { &out1("pop",@_); $stack-=4; }
171sub main'pushf { &out0("pushfd"); $stack+=4; }
172sub main'popf { &out0("popfd"); $stack-=4; }
173sub main'bswap { &out1("bswap",@_); &using486(); }
174sub main'not { &out1("not",@_); }
175sub main'call { &out1("call",($_[0]=~/^\$L/?'':'_').$_[0]); }
176sub main'call_ptr { &out1p("call",@_); }
177sub main'ret { &out0("ret"); }
178sub main'nop { &out0("nop"); }
179sub main'test { &out2("test",@_); }
180sub main'bt { &out2("bt",@_); }
181sub main'leave { &out0("leave"); }
182sub main'cpuid { &out0("DW\t0A20Fh"); }
183sub main'rdtsc { &out0("DW\t0310Fh"); }
184sub main'halt { &out0("hlt"); }
185sub main'movz { &out2("movzx",@_); }
186sub main'neg { &out1("neg",@_); }
187sub main'cld { &out0("cld"); }
188
189# SSE2
190sub main'emms { &out0("emms"); }
191sub main'movd { &out2("movd",@_); }
192sub main'movq { &out2("movq",@_); }
193sub main'movdqu { &out2("movdqu",@_); }
194sub main'movdqa { &out2("movdqa",@_); }
195sub main'movdq2q{ &out2("movdq2q",@_); }
196sub main'movq2dq{ &out2("movq2dq",@_); }
197sub main'paddq { &out2("paddq",@_); }
198sub main'pmuludq{ &out2("pmuludq",@_); }
199sub main'psrlq { &out2("psrlq",@_); }
200sub main'psllq { &out2("psllq",@_); }
201sub main'pxor { &out2("pxor",@_); }
202sub main'por { &out2("por",@_); }
203sub main'pand { &out2("pand",@_); }
204
205sub out2
206 {
207 local($name,$p1,$p2)=@_;
208 local($l,$t,$line);
209
210 $line="\t$name\t";
211 $t=&conv($p1).",";
212 $l=length($t);
213 $line.="$t";
214 $l=4-($l+9)/8;
215 $line.="\t" x $l;
216 $line.=&conv($p2);
217 if ($line=~/\bxmm[0-7]\b/i) { $line=~s/\b[A-Z]+WORD\s+PTR/XMMWORD PTR/i; }
218 push(@out,$line."\n");
219 }
220
221sub out0
222 {
223 local($name)=@_;
224
225 push(@out,"\t$name\n");
226 }
227
228sub out1
229 {
230 local($name,$p1)=@_;
231 local($l,$t);
232
233 push(@out,"\t$name\t".&conv($p1)."\n");
234 }
235
236sub conv
237 {
238 local($p)=@_;
239
240 $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
241 return $p;
242 }
243
244sub using486
245 {
246 return if $using486;
247 $using486++;
248 grep(s/\.386/\.486/,@out);
249 }
250
251sub main'file
252 {
253 local($file)=@_;
254
255 local($tmp)=<<"EOF";
256 TITLE $file.asm
257 .386
258.model FLAT
259_TEXT\$ SEGMENT PAGE 'CODE'
260
261EOF
262 push(@out,$tmp);
263 }
264
265sub main'function_begin
266 {
267 local($func,$extra)=@_;
268
269 push(@labels,$func);
270
271 local($tmp)=<<"EOF";
272PUBLIC _$func
273$extra
274_$func PROC NEAR
275 push ebp
276 push ebx
277 push esi
278 push edi
279EOF
280 push(@out,$tmp);
281 $stack=20;
282 }
283
284sub main'function_begin_B
285 {
286 local($func,$extra)=@_;
287
288 local($tmp)=<<"EOF";
289PUBLIC _$func
290$extra
291_$func PROC NEAR
292EOF
293 push(@out,$tmp);
294 $stack=4;
295 }
296
297sub main'function_end
298 {
299 local($func)=@_;
300
301 local($tmp)=<<"EOF";
302 pop edi
303 pop esi
304 pop ebx
305 pop ebp
306 ret
307_$func ENDP
308EOF
309 push(@out,$tmp);
310 $stack=0;
311 %label=();
312 }
313
314sub main'function_end_B
315 {
316 local($func)=@_;
317
318 local($tmp)=<<"EOF";
319_$func ENDP
320EOF
321 push(@out,$tmp);
322 $stack=0;
323 %label=();
324 }
325
326sub main'function_end_A
327 {
328 local($func)=@_;
329
330 local($tmp)=<<"EOF";
331 pop edi
332 pop esi
333 pop ebx
334 pop ebp
335 ret
336EOF
337 push(@out,$tmp);
338 }
339
340sub main'file_end
341 {
342 # try to detect if SSE2 or MMX extensions were used...
343 my $xmmheader=<<___;
344.686
345.XMM
346IF \@Version LT 800
347XMMWORD STRUCT 16
348 DQ 2 dup (?)
349XMMWORD ENDS
350ENDIF
351___
352 if (grep {/\b[x]?mm[0-7]\b/i} @out) {
353 grep {s/\.[3-7]86/$xmmheader/} @out;
354 }
355 push(@out,"_TEXT\$ ENDS\n");
356 push(@out,"END\n");
357 }
358
359sub main'wparam
360 {
361 local($num)=@_;
362
363 return(&main'DWP($stack+$num*4,"esp","",0));
364 }
365
366sub main'swtmp
367 {
368 return(&main'DWP($_[0]*4,"esp","",0));
369 }
370
371# Should use swtmp, which is above esp. Linix can trash the stack above esp
372#sub main'wtmp
373# {
374# local($num)=@_;
375#
376# return(&main'DWP(-(($num+1)*4),"esp","",0));
377# }
378
379sub main'comment
380 {
381 foreach (@_)
382 {
383 push(@out,"\t; $_\n");
384 }
385 }
386
387sub main'public_label
388 {
389 $label{$_[0]}="_$_[0]" if (!defined($label{$_[0]}));
390 push(@out,"PUBLIC\t$label{$_[0]}\n");
391 }
392
393sub main'label
394 {
395 if (!defined($label{$_[0]}))
396 {
397 $label{$_[0]}="\$${label}${_[0]}";
398 $label++;
399 }
400 return($label{$_[0]});
401 }
402
403sub main'set_label
404 {
405 if (!defined($label{$_[0]}))
406 {
407 $label{$_[0]}="\$${label}${_[0]}";
408 $label++;
409 }
410 if ($_[1]!=0 && $_[1]>1)
411 {
412 main'align($_[1]);
413 }
414 if((defined $_[2]) && ($_[2] == 1))
415 {
416 push(@out,"$label{$_[0]}::\n");
417 }
418 elsif ($label{$_[0]} !~ /^\$/)
419 {
420 push(@out,"$label{$_[0]}\tLABEL PTR\n");
421 }
422 else
423 {
424 push(@out,"$label{$_[0]}:\n");
425 }
426 }
427
428sub main'data_byte
429 {
430 push(@out,"\tDB\t".join(',',@_)."\n");
431 }
432
433sub main'data_word
434 {
435 push(@out,"\tDD\t".join(',',@_)."\n");
436 }
437
438sub main'align
439 {
440 push(@out,"\tALIGN\t$_[0]\n");
441 }
442
443sub out1p
444 {
445 local($name,$p1)=@_;
446 local($l,$t);
447
448 push(@out,"\t$name\t".&conv($p1)."\n");
449 }
450
451sub main'picmeup
452 {
453 local($dst,$sym)=@_;
454 &main'lea($dst,&main'DWP($sym));
455 }
456
457sub main'blindpop { &out1("pop",@_); }
458
459sub main'initseg
460 {
461 local($f)=@_;
462 local($tmp)=<<___;
463OPTION DOTNAME
464.CRT\$XCU SEGMENT DWORD PUBLIC 'DATA'
465EXTRN _$f:NEAR
466DD _$f
467.CRT\$XCU ENDS
468___
469 push(@out,$tmp);
470 }
471
4721;
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl
deleted file mode 100644
index a4c947165e..0000000000
--- a/src/lib/libcrypto/perlasm/x86unix.pl
+++ /dev/null
@@ -1,725 +0,0 @@
1#!/usr/local/bin/perl
2
3package x86unix; # GAS actually...
4
5$label="L000";
6$const="";
7$constl=0;
8
9$align=($main'aout)?"4":"16";
10$under=($main'aout or $main'coff)?"_":"";
11$dot=($main'aout)?"":".";
12$com_start="#" if ($main'aout or $main'coff);
13
14sub main'asm_init_output { @out=(); }
15sub main'asm_get_output { return(@out); }
16sub main'get_labels { return(@labels); }
17sub main'external_label { push(@labels,@_); }
18
19if ($main'cpp)
20 {
21 $align="ALIGN";
22 $under="";
23 $com_start='/*';
24 $com_end='*/';
25 }
26
27%lb=( 'eax', '%al',
28 'ebx', '%bl',
29 'ecx', '%cl',
30 'edx', '%dl',
31 'ax', '%al',
32 'bx', '%bl',
33 'cx', '%cl',
34 'dx', '%dl',
35 );
36
37%hb=( 'eax', '%ah',
38 'ebx', '%bh',
39 'ecx', '%ch',
40 'edx', '%dh',
41 'ax', '%ah',
42 'bx', '%bh',
43 'cx', '%ch',
44 'dx', '%dh',
45 );
46
47%regs=( 'eax', '%eax',
48 'ebx', '%ebx',
49 'ecx', '%ecx',
50 'edx', '%edx',
51 'esi', '%esi',
52 'edi', '%edi',
53 'ebp', '%ebp',
54 'esp', '%esp',
55
56 'mm0', '%mm0',
57 'mm1', '%mm1',
58 'mm2', '%mm2',
59 'mm3', '%mm3',
60 'mm4', '%mm4',
61 'mm5', '%mm5',
62 'mm6', '%mm6',
63 'mm7', '%mm7',
64
65 'xmm0', '%xmm0',
66 'xmm1', '%xmm1',
67 'xmm2', '%xmm2',
68 'xmm3', '%xmm3',
69 'xmm4', '%xmm4',
70 'xmm5', '%xmm5',
71 'xmm6', '%xmm6',
72 'xmm7', '%xmm7',
73 );
74
75%reg_val=(
76 'eax', 0x00,
77 'ebx', 0x03,
78 'ecx', 0x01,
79 'edx', 0x02,
80 'esi', 0x06,
81 'edi', 0x07,
82 'ebp', 0x05,
83 'esp', 0x04,
84 );
85
86sub main'LB
87 {
88 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
89 return($lb{$_[0]});
90 }
91
92sub main'HB
93 {
94 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
95 return($hb{$_[0]});
96 }
97
98sub main'DWP
99 {
100 local($addr,$reg1,$reg2,$idx)=@_;
101
102 $ret="";
103 $addr =~ s/(^|[+ \t])([A-Za-z_]+[A-Za-z0-9_]+)($|[+ \t])/$1$under$2$3/;
104 $reg1="$regs{$reg1}" if defined($regs{$reg1});
105 $reg2="$regs{$reg2}" if defined($regs{$reg2});
106 $ret.=$addr if ($addr ne "") && ($addr ne 0);
107 if ($reg2 ne "")
108 {
109 if($idx ne "" && $idx != 0)
110 { $ret.="($reg1,$reg2,$idx)"; }
111 else
112 { $ret.="($reg1,$reg2)"; }
113 }
114 elsif ($reg1 ne "")
115 { $ret.="($reg1)" }
116 return($ret);
117 }
118
119sub main'QWP
120 {
121 return(&main'DWP(@_));
122 }
123
124sub main'BP
125 {
126 return(&main'DWP(@_));
127 }
128
129sub main'BC
130 {
131 return @_;
132 }
133
134sub main'DWC
135 {
136 return @_;
137 }
138
139#sub main'BP
140# {
141# local($addr,$reg1,$reg2,$idx)=@_;
142#
143# $ret="";
144#
145# $addr =~ s/(^|[+ \t])([A-Za-z_]+)($|[+ \t])/$1$under$2$3/;
146# $reg1="$regs{$reg1}" if defined($regs{$reg1});
147# $reg2="$regs{$reg2}" if defined($regs{$reg2});
148# $ret.=$addr if ($addr ne "") && ($addr ne 0);
149# if ($reg2 ne "")
150# { $ret.="($reg1,$reg2,$idx)"; }
151# else
152# { $ret.="($reg1)" }
153# return($ret);
154# }
155
156sub main'mov { &out2("movl",@_); }
157sub main'movb { &out2("movb",@_); }
158sub main'and { &out2("andl",@_); }
159sub main'or { &out2("orl",@_); }
160sub main'shl { &out2("sall",@_); }
161sub main'shr { &out2("shrl",@_); }
162sub main'xor { &out2("xorl",@_); }
163sub main'xorb { &out2("xorb",@_); }
164sub main'add { &out2($_[0]=~/%[a-d][lh]/?"addb":"addl",@_); }
165sub main'adc { &out2("adcl",@_); }
166sub main'sub { &out2("subl",@_); }
167sub main'sbb { &out2("sbbl",@_); }
168sub main'rotl { &out2("roll",@_); }
169sub main'rotr { &out2("rorl",@_); }
170sub main'exch { &out2($_[0]=~/%[a-d][lh]/?"xchgb":"xchgl",@_); }
171sub main'cmp { &out2("cmpl",@_); }
172sub main'lea { &out2("leal",@_); }
173sub main'mul { &out1("mull",@_); }
174sub main'imul { &out2("imull",@_); }
175sub main'div { &out1("divl",@_); }
176sub main'jmp { &out1("jmp",@_); }
177sub main'jmp_ptr { &out1p("jmp",@_); }
178sub main'je { &out1("je",@_); }
179sub main'jle { &out1("jle",@_); }
180sub main'jne { &out1("jne",@_); }
181sub main'jnz { &out1("jnz",@_); }
182sub main'jz { &out1("jz",@_); }
183sub main'jge { &out1("jge",@_); }
184sub main'jl { &out1("jl",@_); }
185sub main'ja { &out1("ja",@_); }
186sub main'jae { &out1("jae",@_); }
187sub main'jb { &out1("jb",@_); }
188sub main'jbe { &out1("jbe",@_); }
189sub main'jc { &out1("jc",@_); }
190sub main'jnc { &out1("jnc",@_); }
191sub main'jno { &out1("jno",@_); }
192sub main'dec { &out1("decl",@_); }
193sub main'inc { &out1($_[0]=~/%[a-d][hl]/?"incb":"incl",@_); }
194sub main'push { &out1("pushl",@_); $stack+=4; }
195sub main'pop { &out1("popl",@_); $stack-=4; }
196sub main'pushf { &out0("pushfl"); $stack+=4; }
197sub main'popf { &out0("popfl"); $stack-=4; }
198sub main'not { &out1("notl",@_); }
199sub main'call { my $pre=$under;
200 foreach $i (%label)
201 { if ($label{$i} eq $_[0]) { $pre=''; last; } }
202 &out1("call",$pre.$_[0]);
203 }
204sub main'call_ptr { &out1p("call",@_); }
205sub main'ret { &out0("ret"); }
206sub main'nop { &out0("nop"); }
207sub main'test { &out2("testl",@_); }
208sub main'bt { &out2("btl",@_); }
209sub main'leave { &out0("leave"); }
210sub main'cpuid { &out0(".byte\t0x0f,0xa2"); }
211sub main'rdtsc { &out0(".byte\t0x0f,0x31"); }
212sub main'halt { &out0("hlt"); }
213sub main'movz { &out2("movzbl",@_); }
214sub main'neg { &out1("negl",@_); }
215sub main'cld { &out0("cld"); }
216
217# SSE2
218sub main'emms { &out0("emms"); }
219sub main'movd { &out2("movd",@_); }
220sub main'movdqu { &out2("movdqu",@_); }
221sub main'movdqa { &out2("movdqa",@_); }
222sub main'movdq2q{ &out2("movdq2q",@_); }
223sub main'movq2dq{ &out2("movq2dq",@_); }
224sub main'paddq { &out2("paddq",@_); }
225sub main'pmuludq{ &out2("pmuludq",@_); }
226sub main'psrlq { &out2("psrlq",@_); }
227sub main'psllq { &out2("psllq",@_); }
228sub main'pxor { &out2("pxor",@_); }
229sub main'por { &out2("por",@_); }
230sub main'pand { &out2("pand",@_); }
231sub main'movq {
232 local($p1,$p2,$optimize)=@_;
233 if ($optimize && $p1=~/^mm[0-7]$/ && $p2=~/^mm[0-7]$/)
234 # movq between mmx registers can sink Intel CPUs
235 { push(@out,"\tpshufw\t\$0xe4,%$p2,%$p1\n"); }
236 else { &out2("movq",@_); }
237 }
238
239# The bswapl instruction is new for the 486. Emulate if i386.
240sub main'bswap
241 {
242 if ($main'i386)
243 {
244 &main'comment("bswapl @_");
245 &main'exch(main'HB(@_),main'LB(@_));
246 &main'rotr(@_,16);
247 &main'exch(main'HB(@_),main'LB(@_));
248 }
249 else
250 {
251 &out1("bswapl",@_);
252 }
253 }
254
255sub out2
256 {
257 local($name,$p1,$p2)=@_;
258 local($l,$ll,$t);
259 local(%special)=( "roll",0xD1C0,"rorl",0xD1C8,
260 "rcll",0xD1D0,"rcrl",0xD1D8,
261 "shll",0xD1E0,"shrl",0xD1E8,
262 "sarl",0xD1F8);
263
264 if ((defined($special{$name})) && defined($regs{$p1}) && ($p2 == 1))
265 {
266 $op=$special{$name}|$reg_val{$p1};
267 $tmp1=sprintf(".byte %d\n",($op>>8)&0xff);
268 $tmp2=sprintf(".byte %d\t",$op &0xff);
269 push(@out,$tmp1);
270 push(@out,$tmp2);
271
272 $p2=&conv($p2);
273 $p1=&conv($p1);
274 &main'comment("$name $p2 $p1");
275 return;
276 }
277
278 push(@out,"\t$name\t");
279 $t=&conv($p2).",";
280 $l=length($t);
281 push(@out,$t);
282 $ll=4-($l+9)/8;
283 $tmp1=sprintf("\t" x $ll);
284 push(@out,$tmp1);
285 push(@out,&conv($p1)."\n");
286 }
287
288sub out1
289 {
290 local($name,$p1)=@_;
291 local($l,$t);
292 local(%special)=("bswapl",0x0FC8);
293
294 if ((defined($special{$name})) && defined($regs{$p1}))
295 {
296 $op=$special{$name}|$reg_val{$p1};
297 $tmp1=sprintf(".byte %d\n",($op>>8)&0xff);
298 $tmp2=sprintf(".byte %d\t",$op &0xff);
299 push(@out,$tmp1);
300 push(@out,$tmp2);
301
302 $p2=&conv($p2);
303 $p1=&conv($p1);
304 &main'comment("$name $p2 $p1");
305 return;
306 }
307
308 push(@out,"\t$name\t".&conv($p1)."\n");
309 }
310
311sub out1p
312 {
313 local($name,$p1)=@_;
314 local($l,$t);
315
316 push(@out,"\t$name\t*".&conv($p1)."\n");
317 }
318
319sub out0
320 {
321 push(@out,"\t$_[0]\n");
322 }
323
324sub conv
325 {
326 local($p)=@_;
327
328# $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
329
330 $p=$regs{$p} if (defined($regs{$p}));
331
332 $p =~ s/^(-{0,1}[0-9A-Fa-f]+)$/\$$1/;
333 $p =~ s/^(0x[0-9A-Fa-f]+)$/\$$1/;
334 return $p;
335 }
336
337sub main'file
338 {
339 local($file)=@_;
340
341 local($tmp)=<<"EOF";
342 .file "$file.s"
343EOF
344 push(@out,$tmp);
345 }
346
347sub main'function_begin
348 {
349 local($func)=@_;
350
351 &main'external_label($func);
352 $func=$under.$func;
353
354 local($tmp)=<<"EOF";
355.text
356.globl $func
357EOF
358 push(@out,$tmp);
359 if ($main'cpp)
360 { $tmp=push(@out,"TYPE($func,\@function)\n"); }
361 elsif ($main'coff)
362 { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
363 elsif ($main'aout and !$main'pic)
364 { }
365 else { $tmp=push(@out,".type\t$func,\@function\n"); }
366 push(@out,".align\t$align\n");
367 push(@out,"$func:\n");
368 $tmp=<<"EOF";
369 pushl %ebp
370 pushl %ebx
371 pushl %esi
372 pushl %edi
373
374EOF
375 push(@out,$tmp);
376 $stack=20;
377 }
378
379sub main'function_begin_B
380 {
381 local($func,$extra)=@_;
382
383 &main'external_label($func);
384 $func=$under.$func;
385
386 local($tmp)=<<"EOF";
387.text
388.globl $func
389EOF
390 push(@out,$tmp);
391 if ($main'cpp)
392 { push(@out,"TYPE($func,\@function)\n"); }
393 elsif ($main'coff)
394 { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
395 elsif ($main'aout and !$main'pic)
396 { }
397 else { push(@out,".type $func,\@function\n"); }
398 push(@out,".align\t$align\n");
399 push(@out,"$func:\n");
400 $stack=4;
401 }
402
403sub main'function_end
404 {
405 local($func)=@_;
406
407 $func=$under.$func;
408
409 local($tmp)=<<"EOF";
410 popl %edi
411 popl %esi
412 popl %ebx
413 popl %ebp
414 ret
415${dot}L_${func}_end:
416EOF
417 push(@out,$tmp);
418
419 if ($main'cpp)
420 { push(@out,"SIZE($func,${dot}L_${func}_end-$func)\n"); }
421 elsif ($main'coff or $main'aout)
422 { }
423 else { push(@out,".size\t$func,${dot}L_${func}_end-$func\n"); }
424 push(@out,".ident \"$func\"\n");
425 $stack=0;
426 %label=();
427 }
428
429sub main'function_end_A
430 {
431 local($func)=@_;
432
433 local($tmp)=<<"EOF";
434 popl %edi
435 popl %esi
436 popl %ebx
437 popl %ebp
438 ret
439EOF
440 push(@out,$tmp);
441 }
442
443sub main'function_end_B
444 {
445 local($func)=@_;
446
447 $func=$under.$func;
448
449 push(@out,"${dot}L_${func}_end:\n");
450 if ($main'cpp)
451 { push(@out,"SIZE($func,${dot}L_${func}_end-$func)\n"); }
452 elsif ($main'coff or $main'aout)
453 { }
454 else { push(@out,".size\t$func,${dot}L_${func}_end-$func\n"); }
455 push(@out,".ident \"$func\"\n");
456 $stack=0;
457 %label=();
458 }
459
460sub main'wparam
461 {
462 local($num)=@_;
463
464 return(&main'DWP($stack+$num*4,"esp","",0));
465 }
466
467sub main'stack_push
468 {
469 local($num)=@_;
470 $stack+=$num*4;
471 &main'sub("esp",$num*4);
472 }
473
474sub main'stack_pop
475 {
476 local($num)=@_;
477 $stack-=$num*4;
478 &main'add("esp",$num*4);
479 }
480
481sub main'swtmp
482 {
483 return(&main'DWP($_[0]*4,"esp","",0));
484 }
485
486# Should use swtmp, which is above esp. Linix can trash the stack above esp
487#sub main'wtmp
488# {
489# local($num)=@_;
490#
491# return(&main'DWP(-($num+1)*4,"esp","",0));
492# }
493
494sub main'comment
495 {
496 if (!defined($com_start) or $main'elf)
497 { # Regarding $main'elf above...
498 # GNU and SVR4 as'es use different comment delimiters,
499 push(@out,"\n"); # so we just skip ELF comments...
500 return;
501 }
502 foreach (@_)
503 {
504 if (/^\s*$/)
505 { push(@out,"\n"); }
506 else
507 { push(@out,"\t$com_start $_ $com_end\n"); }
508 }
509 }
510
511sub main'public_label
512 {
513 $label{$_[0]}="${under}${_[0]}" if (!defined($label{$_[0]}));
514 push(@out,".globl\t$label{$_[0]}\n");
515 }
516
517sub main'label
518 {
519 if (!defined($label{$_[0]}))
520 {
521 $label{$_[0]}="${dot}${label}${_[0]}";
522 $label++;
523 }
524 return($label{$_[0]});
525 }
526
527sub main'set_label
528 {
529 if (!defined($label{$_[0]}))
530 {
531 $label{$_[0]}="${dot}${label}${_[0]}";
532 $label++;
533 }
534 if ($_[1]!=0)
535 {
536 if ($_[1]>1) { main'align($_[1]); }
537 else { push(@out,".align $align\n"); }
538 }
539 push(@out,"$label{$_[0]}:\n");
540 }
541
542sub main'file_end
543 {
544 # try to detect if SSE2 or MMX extensions were used on ELF platform...
545 if ($main'elf && grep {/\b%[x]*mm[0-7]\b|OPENSSL_ia32cap_P\b/i} @out) {
546 local($tmp);
547
548 push (@out,"\n.section\t.bss\n");
549 push (@out,".comm\t${under}OPENSSL_ia32cap_P,4,4\n");
550
551 return;
552 }
553
554 if ($const ne "")
555 {
556 push(@out,".section .rodata\n");
557 push(@out,$const);
558 $const="";
559 }
560 }
561
562sub main'data_byte
563 {
564 push(@out,"\t.byte\t".join(',',@_)."\n");
565 }
566
567sub main'data_word
568 {
569 push(@out,"\t.long\t".join(',',@_)."\n");
570 }
571
572sub main'align
573 {
574 my $val=$_[0],$p2,$i;
575 if ($main'aout) {
576 for ($p2=0;$val!=0;$val>>=1) { $p2++; }
577 $val=$p2-1;
578 $val.=",0x90";
579 }
580 push(@out,".align\t$val\n");
581 }
582
583# debug output functions: puts, putx, printf
584
585sub main'puts
586 {
587 &pushvars();
588 &main'push('$Lstring' . ++$constl);
589 &main'call('puts');
590 $stack-=4;
591 &main'add("esp",4);
592 &popvars();
593
594 $const .= "Lstring$constl:\n\t.string \"@_[0]\"\n";
595 }
596
597sub main'putx
598 {
599 &pushvars();
600 &main'push($_[0]);
601 &main'push('$Lstring' . ++$constl);
602 &main'call('printf');
603 &main'add("esp",8);
604 $stack-=8;
605 &popvars();
606
607 $const .= "Lstring$constl:\n\t.string \"\%X\"\n";
608 }
609
610sub main'printf
611 {
612 $ostack = $stack;
613 &pushvars();
614 for ($i = @_ - 1; $i >= 0; $i--)
615 {
616 if ($i == 0) # change this to support %s format strings
617 {
618 &main'push('$Lstring' . ++$constl);
619 $const .= "Lstring$constl:\n\t.string \"@_[$i]\"\n";
620 }
621 else
622 {
623 if ($_[$i] =~ /([0-9]*)\(%esp\)/)
624 {
625 &main'push(($1 + $stack - $ostack) . '(%esp)');
626 }
627 else
628 {
629 &main'push($_[$i]);
630 }
631 }
632 }
633 &main'call('printf');
634 $stack-=4*@_;
635 &main'add("esp",4*@_);
636 &popvars();
637 }
638
639sub pushvars
640 {
641 &main'pushf();
642 &main'push("edx");
643 &main'push("ecx");
644 &main'push("eax");
645 }
646
647sub popvars
648 {
649 &main'pop("eax");
650 &main'pop("ecx");
651 &main'pop("edx");
652 &main'popf();
653 }
654
655sub main'picmeup
656 {
657 local($dst,$sym)=@_;
658 if ($main'cpp)
659 {
660 local($tmp)=<<___;
661#if (defined(ELF) || defined(SOL)) && defined(PIC)
662 call 1f
6631: popl $regs{$dst}
664 addl \$_GLOBAL_OFFSET_TABLE_+[.-1b],$regs{$dst}
665 movl $sym\@GOT($regs{$dst}),$regs{$dst}
666#else
667 leal $sym,$regs{$dst}
668#endif
669___
670 push(@out,$tmp);
671 }
672 elsif ($main'pic && ($main'elf || $main'aout))
673 {
674 &main'call(&main'label("PIC_me_up"));
675 &main'set_label("PIC_me_up");
676 &main'blindpop($dst);
677 &main'add($dst,"\$${under}_GLOBAL_OFFSET_TABLE_+[.-".
678 &main'label("PIC_me_up") . "]");
679 &main'mov($dst,&main'DWP($under.$sym."\@GOT",$dst));
680 }
681 else
682 {
683 &main'lea($dst,&main'DWP($sym));
684 }
685 }
686
687sub main'blindpop { &out1("popl",@_); }
688
689sub main'initseg
690 {
691 local($f)=@_;
692 local($tmp);
693 if ($main'elf)
694 {
695 $tmp=<<___;
696.section .init
697 call $under$f
698 jmp .Linitalign
699.align $align
700.Linitalign:
701___
702 }
703 elsif ($main'coff)
704 {
705 $tmp=<<___; # applies to both Cygwin and Mingw
706.section .ctors
707.long $under$f
708___
709 }
710 elsif ($main'aout)
711 {
712 local($ctor)="${under}_GLOBAL_\$I\$$f";
713 $tmp=".text\n";
714 $tmp.=".type $ctor,\@function\n" if ($main'pic);
715 $tmp.=<<___; # OpenBSD way...
716.globl $ctor
717.align 2
718$ctor:
719 jmp $under$f
720___
721 }
722 push(@out,$tmp) if ($tmp);
723 }
724
7251;
diff --git a/src/lib/libcrypto/pqueue/Makefile b/src/lib/libcrypto/pqueue/Makefile
new file mode 100644
index 0000000000..fb36a0c876
--- /dev/null
+++ b/src/lib/libcrypto/pqueue/Makefile
@@ -0,0 +1,83 @@
1#
2# OpenSSL/crypto/pqueue/Makefile
3#
4
5DIR= pqueue
6TOP= ../..
7CC= cc
8INCLUDES=
9CFLAG=-g
10MAKEFILE= Makefile
11AR= ar r
12
13CFLAGS= $(INCLUDES) $(CFLAG)
14
15GENERAL=Makefile
16TEST=
17APPS=
18
19LIB=$(TOP)/libcrypto.a
20LIBSRC=pqueue.c
21LIBOBJ=pqueue.o
22
23SRC= $(LIBSRC)
24
25EXHEADER= pqueue.h
26HEADER= $(EXHEADER)
27
28ALL= $(GENERAL) $(SRC) $(HEADER)
29
30top:
31 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
32
33all: lib
34
35lib: $(LIBOBJ)
36 $(AR) $(LIB) $(LIBOBJ)
37 $(RANLIB) $(LIB) || echo Never mind.
38 @touch lib
39
40files:
41 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
42
43links:
44 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
45 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
46 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
47
48install:
49 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
50 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
51 do \
52 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
53 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
54 done;
55
56tags:
57 ctags $(SRC)
58
59tests:
60
61lint:
62 lint -DLINT $(INCLUDES) $(SRC)>fluff
63
64depend:
65 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
66 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
67
68dclean:
69 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
70 mv -f Makefile.new $(MAKEFILE)
71
72clean:
73 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
74
75# DO NOT DELETE THIS LINE -- make depend depends on it.
76
77pqueue.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
78pqueue.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
79pqueue.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
80pqueue.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
81pqueue.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
82pqueue.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
83pqueue.o: ../../include/openssl/symhacks.h ../cryptlib.h pqueue.c pqueue.h
diff --git a/src/lib/libcrypto/pqueue/pq_compat.h b/src/lib/libcrypto/pqueue/pq_compat.h
deleted file mode 100644
index 7b2c32725c..0000000000
--- a/src/lib/libcrypto/pqueue/pq_compat.h
+++ /dev/null
@@ -1,152 +0,0 @@
1/* crypto/pqueue/pqueue_compat.h */
2/*
3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
5 */
6/* ====================================================================
7 * Copyright (c) 1999-2005 The OpenSSL Project. 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 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * openssl-core@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#ifndef HEADER_PQ_COMPAT_H
61#define HEADER_PQ_COMPAT_H
62
63#include <openssl/opensslconf.h>
64#include <openssl/bn.h>
65
66/*
67 * The purpose of this header file is for supporting 64-bit integer
68 * manipulation on 32-bit (and lower) machines. Currently the only
69 * such environment is VMS, Utrix and those with smaller default integer
70 * sizes than 32 bits. For all such environment, we fall back to using
71 * BIGNUM. We may need to fine tune the conditions for systems that
72 * are incorrectly configured.
73 *
74 * The only clients of this code are (1) pqueue for priority, and
75 * (2) DTLS, for sequence number manipulation.
76 */
77
78#if (defined(THIRTY_TWO_BIT) && !defined(BN_LLONG)) || defined(SIXTEEN_BIT) || defined(EIGHT_BIT)
79
80#define PQ_64BIT_IS_INTEGER 0
81#define PQ_64BIT_IS_BIGNUM 1
82
83#define PQ_64BIT BIGNUM
84#define PQ_64BIT_CTX BN_CTX
85
86#define pq_64bit_init(x) BN_init(x)
87#define pq_64bit_free(x) BN_free(x)
88
89#define pq_64bit_ctx_new(ctx) BN_CTX_new()
90#define pq_64bit_ctx_free(x) BN_CTX_free(x)
91
92#define pq_64bit_assign(x, y) BN_copy(x, y)
93#define pq_64bit_assign_word(x, y) BN_set_word(x, y)
94#define pq_64bit_gt(x, y) BN_ucmp(x, y) >= 1 ? 1 : 0
95#define pq_64bit_eq(x, y) BN_ucmp(x, y) == 0 ? 1 : 0
96#define pq_64bit_add_word(x, w) BN_add_word(x, w)
97#define pq_64bit_sub(r, x, y) BN_sub(r, x, y)
98#define pq_64bit_sub_word(x, w) BN_sub_word(x, w)
99#define pq_64bit_mod(r, x, n, ctx) BN_mod(r, x, n, ctx)
100
101#define pq_64bit_bin2num(bn, bytes, len) BN_bin2bn(bytes, len, bn)
102#define pq_64bit_num2bin(bn, bytes) BN_bn2bin(bn, bytes)
103#define pq_64bit_get_word(x) BN_get_word(x)
104#define pq_64bit_is_bit_set(x, offset) BN_is_bit_set(x, offset)
105#define pq_64bit_lshift(r, x, shift) BN_lshift(r, x, shift)
106#define pq_64bit_set_bit(x, num) BN_set_bit(x, num)
107#define pq_64bit_get_length(x) BN_num_bits((x))
108
109#else
110
111#define PQ_64BIT_IS_INTEGER 1
112#define PQ_64BIT_IS_BIGNUM 0
113
114#if defined(SIXTY_FOUR_BIT)
115#define PQ_64BIT BN_ULONG
116#define PQ_64BIT_PRINT "%lld"
117#elif defined(SIXTY_FOUR_BIT_LONG)
118#define PQ_64BIT BN_ULONG
119#define PQ_64BIT_PRINT "%ld"
120#elif defined(THIRTY_TWO_BIT)
121#define PQ_64BIT BN_ULLONG
122#define PQ_64BIT_PRINT "%lld"
123#endif
124
125#define PQ_64BIT_CTX void
126
127#define pq_64bit_init(x)
128#define pq_64bit_free(x)
129#define pq_64bit_ctx_new(ctx) (ctx)
130#define pq_64bit_ctx_free(x)
131
132#define pq_64bit_assign(x, y) (*(x) = *(y))
133#define pq_64bit_assign_word(x, y) (*(x) = y)
134#define pq_64bit_gt(x, y) (*(x) > *(y))
135#define pq_64bit_eq(x, y) (*(x) == *(y))
136#define pq_64bit_add_word(x, w) (*(x) = (*(x) + (w)))
137#define pq_64bit_sub(r, x, y) (*(r) = (*(x) - *(y)))
138#define pq_64bit_sub_word(x, w) (*(x) = (*(x) - (w)))
139#define pq_64bit_mod(r, x, n, ctx)
140
141#define pq_64bit_bin2num(num, bytes, len) bytes_to_long_long(bytes, num)
142#define pq_64bit_num2bin(num, bytes) long_long_to_bytes(num, bytes)
143#define pq_64bit_get_word(x) *(x)
144#define pq_64bit_lshift(r, x, shift) (*(r) = (*(x) << (shift)))
145#define pq_64bit_set_bit(x, num) do { \
146 PQ_64BIT mask = 1; \
147 mask = mask << (num); \
148 *(x) |= mask; \
149 } while(0)
150#endif /* OPENSSL_SYS_VMS */
151
152#endif
diff --git a/src/lib/libcrypto/pqueue/pq_test.c b/src/lib/libcrypto/pqueue/pq_test.c
new file mode 100644
index 0000000000..8d496dfc65
--- /dev/null
+++ b/src/lib/libcrypto/pqueue/pq_test.c
@@ -0,0 +1,95 @@
1/* crypto/pqueue/pq_test.c */
2/*
3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
5 */
6/* ====================================================================
7 * Copyright (c) 1999-2005 The OpenSSL Project. 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 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * openssl-core@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#include "pqueue.h"
61
62int
63main(void)
64 {
65 pitem *item;
66 pqueue pq;
67
68 pq = pqueue_new();
69
70 item = pitem_new(3, NULL);
71 pqueue_insert(pq, item);
72
73 item = pitem_new(1, NULL);
74 pqueue_insert(pq, item);
75
76 item = pitem_new(2, NULL);
77 pqueue_insert(pq, item);
78
79 item = pqueue_find(pq, 1);
80 fprintf(stderr, "found %ld\n", item->priority);
81
82 item = pqueue_find(pq, 2);
83 fprintf(stderr, "found %ld\n", item->priority);
84
85 item = pqueue_find(pq, 3);
86 fprintf(stderr, "found %ld\n", item ? item->priority: 0);
87
88 pqueue_print(pq);
89
90 for(item = pqueue_pop(pq); item != NULL; item = pqueue_pop(pq))
91 pitem_free(item);
92
93 pqueue_free(pq);
94 return 0;
95 }
diff --git a/src/lib/libcrypto/pqueue/pqueue.c b/src/lib/libcrypto/pqueue/pqueue.c
new file mode 100644
index 0000000000..eab13a1250
--- /dev/null
+++ b/src/lib/libcrypto/pqueue/pqueue.c
@@ -0,0 +1,252 @@
1/* crypto/pqueue/pqueue.c */
2/*
3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
5 */
6/* ====================================================================
7 * Copyright (c) 1999-2005 The OpenSSL Project. 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 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * openssl-core@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#include "cryptlib.h"
61#include <openssl/bn.h>
62#include "pqueue.h"
63
64typedef struct _pqueue
65 {
66 pitem *items;
67 int count;
68 } pqueue_s;
69
70pitem *
71pitem_new(unsigned char *prio64be, void *data)
72 {
73 pitem *item = (pitem *) OPENSSL_malloc(sizeof(pitem));
74 if (item == NULL) return NULL;
75
76 memcpy(item->priority,prio64be,sizeof(item->priority));
77
78 item->data = data;
79 item->next = NULL;
80
81 return item;
82 }
83
84void
85pitem_free(pitem *item)
86 {
87 if (item == NULL) return;
88
89 OPENSSL_free(item);
90 }
91
92pqueue_s *
93pqueue_new()
94 {
95 pqueue_s *pq = (pqueue_s *) OPENSSL_malloc(sizeof(pqueue_s));
96 if (pq == NULL) return NULL;
97
98 memset(pq, 0x00, sizeof(pqueue_s));
99 return pq;
100 }
101
102void
103pqueue_free(pqueue_s *pq)
104 {
105 if (pq == NULL) return;
106
107 OPENSSL_free(pq);
108 }
109
110pitem *
111pqueue_insert(pqueue_s *pq, pitem *item)
112 {
113 pitem *curr, *next;
114
115 if (pq->items == NULL)
116 {
117 pq->items = item;
118 return item;
119 }
120
121 for(curr = NULL, next = pq->items;
122 next != NULL;
123 curr = next, next = next->next)
124 {
125 /* we can compare 64-bit value in big-endian encoding
126 * with memcmp:-) */
127 int cmp = memcmp(next->priority, item->priority,8);
128 if (cmp > 0) /* next > item */
129 {
130 item->next = next;
131
132 if (curr == NULL)
133 pq->items = item;
134 else
135 curr->next = item;
136
137 return item;
138 }
139
140 else if (cmp == 0) /* duplicates not allowed */
141 return NULL;
142 }
143
144 item->next = NULL;
145 curr->next = item;
146
147 return item;
148 }
149
150pitem *
151pqueue_peek(pqueue_s *pq)
152 {
153 return pq->items;
154 }
155
156pitem *
157pqueue_pop(pqueue_s *pq)
158 {
159 pitem *item = pq->items;
160
161 if (pq->items != NULL)
162 pq->items = pq->items->next;
163
164 return item;
165 }
166
167pitem *
168pqueue_find(pqueue_s *pq, unsigned char *prio64be)
169 {
170 pitem *next;
171 pitem *found = NULL;
172
173 if ( pq->items == NULL)
174 return NULL;
175
176 for ( next = pq->items; next->next != NULL; next = next->next)
177 {
178 if ( memcmp(next->priority, prio64be,8) == 0)
179 {
180 found = next;
181 break;
182 }
183 }
184
185 /* check the one last node */
186 if ( memcmp(next->priority, prio64be,8) ==0)
187 found = next;
188
189 if ( ! found)
190 return NULL;
191
192#if 0 /* find works in peek mode */
193 if ( prev == NULL)
194 pq->items = next->next;
195 else
196 prev->next = next->next;
197#endif
198
199 return found;
200 }
201
202void
203pqueue_print(pqueue_s *pq)
204 {
205 pitem *item = pq->items;
206
207 while(item != NULL)
208 {
209 printf("item\t%02x%02x%02x%02x%02x%02x%02x%02x\n",
210 item->priority[0],item->priority[1],
211 item->priority[2],item->priority[3],
212 item->priority[4],item->priority[5],
213 item->priority[6],item->priority[7]);
214 item = item->next;
215 }
216 }
217
218pitem *
219pqueue_iterator(pqueue_s *pq)
220 {
221 return pqueue_peek(pq);
222 }
223
224pitem *
225pqueue_next(pitem **item)
226 {
227 pitem *ret;
228
229 if ( item == NULL || *item == NULL)
230 return NULL;
231
232
233 /* *item != NULL */
234 ret = *item;
235 *item = (*item)->next;
236
237 return ret;
238 }
239
240int
241pqueue_size(pqueue_s *pq)
242{
243 pitem *item = pq->items;
244 int count = 0;
245
246 while(item != NULL)
247 {
248 count++;
249 item = item->next;
250 }
251 return count;
252}
diff --git a/src/lib/libcrypto/pqueue/pqueue.h b/src/lib/libcrypto/pqueue/pqueue.h
new file mode 100644
index 0000000000..87fc9037c8
--- /dev/null
+++ b/src/lib/libcrypto/pqueue/pqueue.h
@@ -0,0 +1,94 @@
1/* crypto/pqueue/pqueue.h */
2/*
3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
5 */
6/* ====================================================================
7 * Copyright (c) 1999-2005 The OpenSSL Project. 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 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * openssl-core@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59
60#ifndef HEADER_PQUEUE_H
61#define HEADER_PQUEUE_H
62
63#include <stdio.h>
64#include <stdlib.h>
65#include <string.h>
66
67typedef struct _pqueue *pqueue;
68
69typedef struct _pitem
70 {
71 unsigned char priority[8]; /* 64-bit value in big-endian encoding */
72 void *data;
73 struct _pitem *next;
74 } pitem;
75
76typedef struct _pitem *piterator;
77
78pitem *pitem_new(unsigned char *prio64be, void *data);
79void pitem_free(pitem *item);
80
81pqueue pqueue_new(void);
82void pqueue_free(pqueue pq);
83
84pitem *pqueue_insert(pqueue pq, pitem *item);
85pitem *pqueue_peek(pqueue pq);
86pitem *pqueue_pop(pqueue pq);
87pitem *pqueue_find(pqueue pq, unsigned char *prio64be);
88pitem *pqueue_iterator(pqueue pq);
89pitem *pqueue_next(piterator *iter);
90
91void pqueue_print(pqueue pq);
92int pqueue_size(pqueue pq);
93
94#endif /* ! HEADER_PQUEUE_H */
diff --git a/src/lib/libcrypto/evp/dig_eng.c b/src/lib/libcrypto/rand/rand_nw.c
index 64cdf9366c..8d5b8d2e32 100644
--- a/src/lib/libcrypto/evp/dig_eng.c
+++ b/src/lib/libcrypto/rand/rand_nw.c
@@ -1,4 +1,4 @@
1/* crypto/evp/digest.c */ 1/* crypto/rand/rand_nw.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,7 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ==================================================================== 58/* ====================================================================
59 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. 59 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
60 * 60 *
61 * Redistribution and use in source and binary forms, with or without 61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions 62 * modification, are permitted provided that the following conditions
@@ -109,72 +109,75 @@
109 * 109 *
110 */ 110 */
111 111
112#include <stdio.h>
113#include "cryptlib.h" 112#include "cryptlib.h"
114#include <openssl/objects.h> 113#include <openssl/rand.h>
115#include <openssl/evp.h> 114#include "rand_lcl.h"
116#ifndef OPENSSL_NO_ENGINE 115
117#include <openssl/engine.h> 116#if defined (OPENSSL_SYS_NETWARE)
117
118#if defined(NETWARE_LIBC)
119#include <nks/thread.h>
120#else
121#include <nwthread.h>
118#endif 122#endif
119#include "evp_locl.h"
120 123
121#ifndef OPENSSL_NO_ENGINE 124extern int GetProcessSwitchCount(void);
125#if !defined(NETWARE_LIBC) || (CURRENT_NDK_THRESHOLD < 509220000)
126extern void *RunningProcess; /* declare here same as found in newer NDKs */
127extern unsigned long GetSuperHighResolutionTimer(void);
128#endif
122 129
123#ifdef OPENSSL_FIPS 130 /* the FAQ indicates we need to provide at least 20 bytes (160 bits) of seed
131 */
132int RAND_poll(void)
133{
134 unsigned long l;
135 unsigned long tsc;
136 int i;
124 137
125static int do_evp_md_engine_full(EVP_MD_CTX *ctx, const EVP_MD **ptype, ENGINE *impl) 138 /* There are several options to gather miscellaneous data
126 { 139 * but for now we will loop checking the time stamp counter (rdtsc) and
127 if (*ptype) 140 * the SuperHighResolutionTimer. Each iteration will collect 8 bytes
128 { 141 * of data but it is treated as only 1 byte of entropy. The call to
129 /* Ensure an ENGINE left lying around from last time is cleared 142 * ThreadSwitchWithDelay() will introduce additional variability into
130 * (the previous check attempted to avoid this if the same 143 * the data returned by rdtsc.
131 * ENGINE and EVP_MD could be used). */ 144 *
132 if(ctx->engine) 145 * Applications can agument the seed material by adding additional
133 ENGINE_finish(ctx->engine); 146 * stuff with RAND_add() and should probably do so.
134 if(impl) 147 */
135 { 148 l = GetProcessSwitchCount();
136 if (!ENGINE_init(impl)) 149 RAND_add(&l,sizeof(l),1);
137 { 150
138 EVPerr(EVP_F_DO_EVP_MD_ENGINE_FULL,EVP_R_INITIALIZATION_ERROR); 151 /* need to cast the void* to unsigned long here */
139 return 0; 152 l = (unsigned long)RunningProcess;
140 } 153 RAND_add(&l,sizeof(l),1);
141 }
142 else
143 /* Ask if an ENGINE is reserved for this job */
144 impl = ENGINE_get_digest_engine((*ptype)->type);
145 if(impl)
146 {
147 /* There's an ENGINE for this job ... (apparently) */
148 const EVP_MD *d = ENGINE_get_digest(impl, (*ptype)->type);
149 if(!d)
150 {
151 /* Same comment from evp_enc.c */
152 EVPerr(EVP_F_DO_EVP_MD_ENGINE_FULL,EVP_R_INITIALIZATION_ERROR);
153 return 0;
154 }
155 /* We'll use the ENGINE's private digest definition */
156 *ptype = d;
157 /* Store the ENGINE functional reference so we know
158 * 'type' came from an ENGINE and we need to release
159 * it when done. */
160 ctx->engine = impl;
161 }
162 else
163 ctx->engine = NULL;
164 }
165 else
166 if(!ctx->digest)
167 {
168 EVPerr(EVP_F_DO_EVP_MD_ENGINE_FULL,EVP_R_NO_DIGEST_SET);
169 return 0;
170 }
171 return 1;
172 }
173 154
174void int_EVP_MD_init_engine_callbacks(void) 155 for( i=2; i<ENTROPY_NEEDED; i++)
175 { 156 {
176 int_EVP_MD_set_engine_callbacks( 157#ifdef __MWERKS__
177 ENGINE_init, ENGINE_finish, do_evp_md_engine_full); 158 asm
178 } 159 {
179#endif 160 rdtsc
161 mov tsc, eax
162 }
163#elif defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
164 asm volatile("rdtsc":"=a"(tsc)::"edx");
180#endif 165#endif
166
167 RAND_add(&tsc, sizeof(tsc), 1);
168
169 l = GetSuperHighResolutionTimer();
170 RAND_add(&l, sizeof(l), 0);
171
172# if defined(NETWARE_LIBC)
173 NXThreadYield();
174# else /* NETWARE_CLIB */
175 ThreadSwitchWithDelay();
176# endif
177 }
178
179 return 1;
180}
181
182#endif
183
diff --git a/src/lib/libcrypto/rc4/asm/rc4-ia64.S b/src/lib/libcrypto/rc4/asm/rc4-ia64.S
deleted file mode 100644
index 8210c47d04..0000000000
--- a/src/lib/libcrypto/rc4/asm/rc4-ia64.S
+++ /dev/null
@@ -1,159 +0,0 @@
1// ====================================================================
2// Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
3// project.
4//
5// Rights for redistribution and usage in source and binary forms are
6// granted according to the OpenSSL license. Warranty of any kind is
7// disclaimed.
8// ====================================================================
9
10.ident "rc4-ia64.S, Version 2.0"
11.ident "IA-64 ISA artwork by Andy Polyakov <appro@fy.chalmers.se>"
12
13// What's wrong with compiler generated code? Because of the nature of
14// C language, compiler doesn't [dare to] reorder load and stores. But
15// being memory-bound, RC4 should benefit from reorder [on in-order-
16// execution core such as IA-64]. But what can we reorder? At the very
17// least we can safely reorder references to key schedule in respect
18// to input and output streams. Secondly, from the first [close] glance
19// it appeared that it's possible to pull up some references to
20// elements of the key schedule itself. Original rationale ["prior
21// loads are not safe only for "degenerated" key schedule, when some
22// elements equal to the same value"] was kind of sloppy. I should have
23// formulated as it really was: if we assume that pulling up reference
24// to key[x+1] is not safe, then it would mean that key schedule would
25// "degenerate," which is never the case. The problem is that this
26// holds true in respect to references to key[x], but not to key[y].
27// Legitimate "collisions" do occur within every 256^2 bytes window.
28// Fortunately there're enough free instruction slots to keep prior
29// reference to key[x+1], detect "collision" and compensate for it.
30// All this without sacrificing a single clock cycle:-) Throughput is
31// ~210MBps on 900MHz CPU, which is is >3x faster than gcc generated
32// code and +30% - if compared to HP-UX C. Unrolling loop below should
33// give >30% on top of that...
34
35.text
36.explicit
37
38#if defined(_HPUX_SOURCE) && !defined(_LP64)
39# define ADDP addp4
40#else
41# define ADDP add
42#endif
43
44#ifndef SZ
45#define SZ 4 // this is set to sizeof(RC4_INT)
46#endif
47// SZ==4 seems to be optimal. At least SZ==8 is not any faster, not for
48// assembler implementation, while SZ==1 code is ~30% slower.
49#if SZ==1 // RC4_INT is unsigned char
50# define LDKEY ld1
51# define STKEY st1
52# define OFF 0
53#elif SZ==4 // RC4_INT is unsigned int
54# define LDKEY ld4
55# define STKEY st4
56# define OFF 2
57#elif SZ==8 // RC4_INT is unsigned long
58# define LDKEY ld8
59# define STKEY st8
60# define OFF 3
61#endif
62
63out=r8; // [expanded] output pointer
64inp=r9; // [expanded] output pointer
65prsave=r10;
66key=r28; // [expanded] pointer to RC4_KEY
67ksch=r29; // (key->data+255)[&~(sizeof(key->data)-1)]
68xx=r30;
69yy=r31;
70
71// void RC4(RC4_KEY *key,size_t len,const void *inp,void *out);
72.global RC4#
73.proc RC4#
74.align 32
75.skip 16
76RC4:
77 .prologue
78 .save ar.pfs,r2
79{ .mii; alloc r2=ar.pfs,4,12,0,16
80 .save pr,prsave
81 mov prsave=pr
82 ADDP key=0,in0 };;
83{ .mib; cmp.eq p6,p0=0,in1 // len==0?
84 .save ar.lc,r3
85 mov r3=ar.lc
86(p6) br.ret.spnt.many b0 };; // emergency exit
87
88 .body
89 .rotr dat[4],key_x[4],tx[2],rnd[2],key_y[2],ty[1];
90
91{ .mib; LDKEY xx=[key],SZ // load key->x
92 add in1=-1,in1 // adjust len for loop counter
93 nop.b 0 }
94{ .mib; ADDP inp=0,in2
95 ADDP out=0,in3
96 brp.loop.imp .Ltop,.Lexit-16 };;
97{ .mmi; LDKEY yy=[key] // load key->y
98 add ksch=SZ,key
99 mov ar.lc=in1 }
100{ .mmi; mov key_y[1]=r0 // guarantee inequality
101 // in first iteration
102 add xx=1,xx
103 mov pr.rot=1<<16 };;
104{ .mii; nop.m 0
105 dep key_x[1]=xx,r0,OFF,8
106 mov ar.ec=3 };; // note that epilogue counter
107 // is off by 1. I compensate
108 // for this at exit...
109.Ltop:
110// The loop is scheduled for 4*(n+2) spin-rate on Itanium 2, which
111// theoretically gives asymptotic performance of clock frequency
112// divided by 4 bytes per seconds, or 400MBps on 1.6GHz CPU. This is
113// for sizeof(RC4_INT)==4. For smaller RC4_INT STKEY inadvertently
114// splits the last bundle and you end up with 5*n spin-rate:-(
115// Originally the loop was scheduled for 3*n and relied on key
116// schedule to be aligned at 256*sizeof(RC4_INT) boundary. But
117// *(out++)=dat, which maps to st1, had same effect [inadvertent
118// bundle split] and holded the loop back. Rescheduling for 4*n
119// made it possible to eliminate dependence on specific alignment
120// and allow OpenSSH keep "abusing" our API. Reaching for 3*n would
121// require unrolling, sticking to variable shift instruction for
122// collecting output [to avoid starvation for integer shifter] and
123// copying of key schedule to controlled place in stack [so that
124// deposit instruction can serve as substitute for whole
125// key->data+((x&255)<<log2(sizeof(key->data[0])))]...
126{ .mmi; (p19) st1 [out]=dat[3],1 // *(out++)=dat
127 (p16) add xx=1,xx // x++
128 (p18) dep rnd[1]=rnd[1],r0,OFF,8 } // ((tx+ty)&255)<<OFF
129{ .mmi; (p16) add key_x[1]=ksch,key_x[1] // &key[xx&255]
130 (p17) add key_y[1]=ksch,key_y[1] };; // &key[yy&255]
131{ .mmi; (p16) LDKEY tx[0]=[key_x[1]] // tx=key[xx]
132 (p17) LDKEY ty[0]=[key_y[1]] // ty=key[yy]
133 (p16) dep key_x[0]=xx,r0,OFF,8 } // (xx&255)<<OFF
134{ .mmi; (p18) add rnd[1]=ksch,rnd[1] // &key[(tx+ty)&255]
135 (p16) cmp.ne.unc p20,p21=key_x[1],key_y[1] };;
136{ .mmi; (p18) LDKEY rnd[1]=[rnd[1]] // rnd=key[(tx+ty)&255]
137 (p16) ld1 dat[0]=[inp],1 } // dat=*(inp++)
138.pred.rel "mutex",p20,p21
139{ .mmi; (p21) add yy=yy,tx[1] // (p16)
140 (p20) add yy=yy,tx[0] // (p16) y+=tx
141 (p21) mov tx[0]=tx[1] };; // (p16)
142{ .mmi; (p17) STKEY [key_y[1]]=tx[1] // key[yy]=tx
143 (p17) STKEY [key_x[2]]=ty[0] // key[xx]=ty
144 (p16) dep key_y[0]=yy,r0,OFF,8 } // &key[yy&255]
145{ .mmb; (p17) add rnd[0]=tx[1],ty[0] // tx+=ty
146 (p18) xor dat[2]=dat[2],rnd[1] // dat^=rnd
147 br.ctop.sptk .Ltop };;
148.Lexit:
149{ .mib; STKEY [key]=yy,-SZ // save key->y
150 mov pr=prsave,0x1ffff
151 nop.b 0 }
152{ .mib; st1 [out]=dat[3],1 // compensate for truncated
153 // epilogue counter
154 add xx=-1,xx
155 nop.b 0 };;
156{ .mib; STKEY [key]=xx // save key->x
157 mov ar.lc=r3
158 br.ret.sptk.many b0 };;
159.endp RC4#
diff --git a/src/lib/libcrypto/rc4/rc4_fblk.c b/src/lib/libcrypto/rc4/rc4_utl.c
index 1b2a42979b..ab3f02fe6a 100644
--- a/src/lib/libcrypto/rc4/rc4_fblk.c
+++ b/src/lib/libcrypto/rc4/rc4_utl.c
@@ -1,9 +1,6 @@
1/* crypto/rc4/rc4_fblk.c */ 1/* crypto/rc4/rc4_utl.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project.
4 */
5/* ==================================================================== 2/* ====================================================================
6 * Copyright (c) 2008 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2011 The OpenSSL Project. All rights reserved.
7 * 4 *
8 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
@@ -20,12 +17,12 @@
20 * 3. All advertising materials mentioning features or use of this 17 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment: 18 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project 19 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 * 21 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without 23 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact 24 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org. 25 * openssl-core@openssl.org.
29 * 26 *
30 * 5. Products derived from this software may not be called "OpenSSL" 27 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written 28 * nor may "OpenSSL" appear in their names without prior written
@@ -34,7 +31,7 @@
34 * 6. Redistributions of any form whatsoever must retain the following 31 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment: 32 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project 33 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 * 35 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -49,27 +46,17 @@
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE. 47 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ==================================================================== 48 * ====================================================================
49 *
52 */ 50 */
53 51
54
55#include <openssl/rc4.h>
56#include "rc4_locl.h"
57#include <openssl/opensslv.h> 52#include <openssl/opensslv.h>
58#include <openssl/crypto.h> 53#include <openssl/crypto.h>
59#ifdef OPENSSL_FIPS 54#include <openssl/rc4.h>
60#include <openssl/fips.h>
61#endif
62
63/* FIPS mode blocking for RC4 has to be done separately since RC4_set_key
64 * may be implemented in an assembly language file.
65 */
66 55
67#ifdef OPENSSL_FIPS
68void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) 56void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
69 { 57 {
70 if (FIPS_mode()) 58#ifdef OPENSSL_FIPS
71 FIPS_BAD_ABORT(RC4) 59 fips_cipher_abort(RC4);
60#endif
72 private_RC4_set_key(key, len, data); 61 private_RC4_set_key(key, len, data);
73 } 62 }
74#endif
75
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..61ac6effc6
--- /dev/null
+++ b/src/lib/libcrypto/rc5/asm/rc5-586.pl
@@ -0,0 +1,110 @@
1#!/usr/local/bin/perl
2
3$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
4push(@INC,"${dir}","${dir}../../perlasm");
5require "x86asm.pl";
6require "cbc.pl";
7
8&asm_init($ARGV[0],"rc5-586.pl");
9
10$RC5_MAX_ROUNDS=16;
11$RC5_32_OFF=($RC5_MAX_ROUNDS+2)*4;
12$A="edi";
13$B="esi";
14$S="ebp";
15$tmp1="eax";
16$r="ebx";
17$tmpc="ecx";
18$tmp4="edx";
19
20&RC5_32_encrypt("RC5_32_encrypt",1);
21&RC5_32_encrypt("RC5_32_decrypt",0);
22&cbc("RC5_32_cbc_encrypt","RC5_32_encrypt","RC5_32_decrypt",0,4,5,3,-1,-1);
23&asm_finish();
24
25sub RC5_32_encrypt
26 {
27 local($name,$enc)=@_;
28
29 &function_begin_B($name,"");
30
31 &comment("");
32
33 &push("ebp");
34 &push("esi");
35 &push("edi");
36 &mov($tmp4,&wparam(0));
37 &mov($S,&wparam(1));
38
39 &comment("Load the 2 words");
40 &mov($A,&DWP(0,$tmp4,"",0));
41 &mov($B,&DWP(4,$tmp4,"",0));
42
43 &push($r);
44 &mov($r, &DWP(0,$S,"",0));
45
46 # encrypting part
47
48 if ($enc)
49 {
50 &add($A, &DWP(4+0,$S,"",0));
51 &add($B, &DWP(4+4,$S,"",0));
52
53 for ($i=0; $i<$RC5_MAX_ROUNDS; $i++)
54 {
55 &xor($A, $B);
56 &mov($tmp1, &DWP(12+$i*8,$S,"",0));
57 &mov($tmpc, $B);
58 &rotl($A, &LB("ecx"));
59 &add($A, $tmp1);
60
61 &xor($B, $A);
62 &mov($tmp1, &DWP(16+$i*8,$S,"",0));
63 &mov($tmpc, $A);
64 &rotl($B, &LB("ecx"));
65 &add($B, $tmp1);
66 if (($i == 7) || ($i == 11))
67 {
68 &cmp($r, $i+1);
69 &je(&label("rc5_exit"));
70 }
71 }
72 }
73 else
74 {
75 &cmp($r, 12);
76 &je(&label("rc5_dec_12"));
77 &cmp($r, 8);
78 &je(&label("rc5_dec_8"));
79 for ($i=$RC5_MAX_ROUNDS; $i > 0; $i--)
80 {
81 &set_label("rc5_dec_$i") if ($i == 12) || ($i == 8);
82 &mov($tmp1, &DWP($i*8+8,$S,"",0));
83 &sub($B, $tmp1);
84 &mov($tmpc, $A);
85 &rotr($B, &LB("ecx"));
86 &xor($B, $A);
87
88 &mov($tmp1, &DWP($i*8+4,$S,"",0));
89 &sub($A, $tmp1);
90 &mov($tmpc, $B);
91 &rotr($A, &LB("ecx"));
92 &xor($A, $B);
93 }
94 &sub($B, &DWP(4+4,$S,"",0));
95 &sub($A, &DWP(4+0,$S,"",0));
96 }
97
98 &set_label("rc5_exit");
99 &mov(&DWP(0,$tmp4,"",0),$A);
100 &mov(&DWP(4,$tmp4,"",0),$B);
101
102 &pop("ebx");
103 &pop("edi");
104 &pop("esi");
105 &pop("ebp");
106 &ret();
107 &function_end_B($name);
108 }
109
110
diff --git a/src/lib/libcrypto/bn/bn_opt.c b/src/lib/libcrypto/rc5/rc5_ecb.c
index 21cbb38f62..e72b535507 100644
--- a/src/lib/libcrypto/bn/bn_opt.c
+++ b/src/lib/libcrypto/rc5/rc5_ecb.c
@@ -1,4 +1,4 @@
1/* crypto/bn/bn_opt.c */ 1/* crypto/rc5/rc5_ecb.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,32 +56,25 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#ifndef BN_DEBUG 59#include <openssl/rc5.h>
60# undef NDEBUG /* avoid conflicting definitions */ 60#include "rc5_locl.h"
61# define NDEBUG 61#include <openssl/opensslv.h>
62#endif
63 62
64#include <assert.h> 63const char RC5_version[]="RC5" OPENSSL_VERSION_PTEXT;
65#include <limits.h>
66#include <stdio.h>
67#include "cryptlib.h"
68#include "bn_lcl.h"
69 64
70char *BN_options(void) 65void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out,
66 RC5_32_KEY *ks, int encrypt)
71 { 67 {
72 static int init=0; 68 unsigned long l,d[2];
73 static char data[16];
74 69
75 if (!init) 70 c2l(in,l); d[0]=l;
76 { 71 c2l(in,l); d[1]=l;
77 init++; 72 if (encrypt)
78#ifdef BN_LLONG 73 RC5_32_encrypt(d,ks);
79 BIO_snprintf(data,sizeof data,"bn(%d,%d)", 74 else
80 (int)sizeof(BN_ULLONG)*8,(int)sizeof(BN_ULONG)*8); 75 RC5_32_decrypt(d,ks);
81#else 76 l=d[0]; l2c(l,out);
82 BIO_snprintf(data,sizeof data,"bn(%d,%d)", 77 l=d[1]; l2c(l,out);
83 (int)sizeof(BN_ULONG)*8,(int)sizeof(BN_ULONG)*8); 78 l=d[0]=d[1]=0;
84#endif
85 }
86 return(data);
87 } 79 }
80
diff --git a/src/lib/libcrypto/asn1/a_hdr.c b/src/lib/libcrypto/rc5/rc5_enc.c
index d1c2a7b9e3..f327d32a76 100644
--- a/src/lib/libcrypto/asn1/a_hdr.c
+++ b/src/lib/libcrypto/rc5/rc5_enc.c
@@ -1,4 +1,4 @@
1/* crypto/asn1/a_hdr.c */ 1/* crypto/rc5/rc5_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -57,63 +57,159 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "cryptlib.h" 60#include <openssl/rc5.h>
61#include <openssl/asn1_mac.h> 61#include "rc5_locl.h"
62#include <openssl/asn1.h>
63 62
64int i2d_ASN1_HEADER(ASN1_HEADER *a, unsigned char **pp) 63void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out,
64 long length, RC5_32_KEY *ks, unsigned char *iv,
65 int encrypt)
65 { 66 {
66 M_ASN1_I2D_vars(a); 67 register unsigned long tin0,tin1;
68 register unsigned long tout0,tout1,xor0,xor1;
69 register long l=length;
70 unsigned long tin[2];
67 71
68 M_ASN1_I2D_len(a->header, i2d_ASN1_OCTET_STRING); 72 if (encrypt)
69 M_ASN1_I2D_len(a->data, a->meth->i2d); 73 {
70 74 c2l(iv,tout0);
71 M_ASN1_I2D_seq_total(); 75 c2l(iv,tout1);
72 76 iv-=8;
73 M_ASN1_I2D_put(a->header, i2d_ASN1_OCTET_STRING); 77 for (l-=8; l>=0; l-=8)
74 M_ASN1_I2D_put(a->data, a->meth->i2d); 78 {
75 79 c2l(in,tin0);
76 M_ASN1_I2D_finish(); 80 c2l(in,tin1);
81 tin0^=tout0;
82 tin1^=tout1;
83 tin[0]=tin0;
84 tin[1]=tin1;
85 RC5_32_encrypt(tin,ks);
86 tout0=tin[0]; l2c(tout0,out);
87 tout1=tin[1]; l2c(tout1,out);
88 }
89 if (l != -8)
90 {
91 c2ln(in,tin0,tin1,l+8);
92 tin0^=tout0;
93 tin1^=tout1;
94 tin[0]=tin0;
95 tin[1]=tin1;
96 RC5_32_encrypt(tin,ks);
97 tout0=tin[0]; l2c(tout0,out);
98 tout1=tin[1]; l2c(tout1,out);
99 }
100 l2c(tout0,iv);
101 l2c(tout1,iv);
102 }
103 else
104 {
105 c2l(iv,xor0);
106 c2l(iv,xor1);
107 iv-=8;
108 for (l-=8; l>=0; l-=8)
109 {
110 c2l(in,tin0); tin[0]=tin0;
111 c2l(in,tin1); tin[1]=tin1;
112 RC5_32_decrypt(tin,ks);
113 tout0=tin[0]^xor0;
114 tout1=tin[1]^xor1;
115 l2c(tout0,out);
116 l2c(tout1,out);
117 xor0=tin0;
118 xor1=tin1;
119 }
120 if (l != -8)
121 {
122 c2l(in,tin0); tin[0]=tin0;
123 c2l(in,tin1); tin[1]=tin1;
124 RC5_32_decrypt(tin,ks);
125 tout0=tin[0]^xor0;
126 tout1=tin[1]^xor1;
127 l2cn(tout0,tout1,out,l+8);
128 xor0=tin0;
129 xor1=tin1;
130 }
131 l2c(xor0,iv);
132 l2c(xor1,iv);
133 }
134 tin0=tin1=tout0=tout1=xor0=xor1=0;
135 tin[0]=tin[1]=0;
77 } 136 }
78 137
79ASN1_HEADER *d2i_ASN1_HEADER(ASN1_HEADER **a, const unsigned char **pp, 138void RC5_32_encrypt(unsigned long *d, RC5_32_KEY *key)
80 long length)
81 { 139 {
82 M_ASN1_D2I_vars(a,ASN1_HEADER *,ASN1_HEADER_new); 140 RC5_32_INT a,b,*s;
141
142 s=key->data;
83 143
84 M_ASN1_D2I_Init(); 144 a=d[0]+s[0];
85 M_ASN1_D2I_start_sequence(); 145 b=d[1]+s[1];
86 M_ASN1_D2I_get_x(ASN1_OCTET_STRING,ret->header,d2i_ASN1_OCTET_STRING); 146 E_RC5_32(a,b,s, 2);
87 if (ret->meth != NULL) 147 E_RC5_32(a,b,s, 4);
148 E_RC5_32(a,b,s, 6);
149 E_RC5_32(a,b,s, 8);
150 E_RC5_32(a,b,s,10);
151 E_RC5_32(a,b,s,12);
152 E_RC5_32(a,b,s,14);
153 E_RC5_32(a,b,s,16);
154 if (key->rounds == 12)
88 { 155 {
89 M_ASN1_D2I_get_x(void,ret->data,ret->meth->d2i); 156 E_RC5_32(a,b,s,18);
157 E_RC5_32(a,b,s,20);
158 E_RC5_32(a,b,s,22);
159 E_RC5_32(a,b,s,24);
90 } 160 }
91 else 161 else if (key->rounds == 16)
92 { 162 {
93 if (a != NULL) (*a)=ret; 163 /* Do a full expansion to avoid a jump */
94 return(ret); 164 E_RC5_32(a,b,s,18);
165 E_RC5_32(a,b,s,20);
166 E_RC5_32(a,b,s,22);
167 E_RC5_32(a,b,s,24);
168 E_RC5_32(a,b,s,26);
169 E_RC5_32(a,b,s,28);
170 E_RC5_32(a,b,s,30);
171 E_RC5_32(a,b,s,32);
95 } 172 }
96 M_ASN1_D2I_Finish(a,ASN1_HEADER_free,ASN1_F_D2I_ASN1_HEADER); 173 d[0]=a;
174 d[1]=b;
97 } 175 }
98 176
99ASN1_HEADER *ASN1_HEADER_new(void) 177void RC5_32_decrypt(unsigned long *d, RC5_32_KEY *key)
100 { 178 {
101 ASN1_HEADER *ret=NULL; 179 RC5_32_INT a,b,*s;
102 ASN1_CTX c;
103 180
104 M_ASN1_New_Malloc(ret,ASN1_HEADER); 181 s=key->data;
105 M_ASN1_New(ret->header,M_ASN1_OCTET_STRING_new);
106 ret->meth=NULL;
107 ret->data=NULL;
108 return(ret);
109 M_ASN1_New_Error(ASN1_F_ASN1_HEADER_NEW);
110 }
111 182
112void ASN1_HEADER_free(ASN1_HEADER *a) 183 a=d[0];
113 { 184 b=d[1];
114 if (a == NULL) return; 185 if (key->rounds == 16)
115 M_ASN1_OCTET_STRING_free(a->header); 186 {
116 if (a->meth != NULL) 187 D_RC5_32(a,b,s,32);
117 a->meth->destroy(a->data); 188 D_RC5_32(a,b,s,30);
118 OPENSSL_free(a); 189 D_RC5_32(a,b,s,28);
190 D_RC5_32(a,b,s,26);
191 /* Do a full expansion to avoid a jump */
192 D_RC5_32(a,b,s,24);
193 D_RC5_32(a,b,s,22);
194 D_RC5_32(a,b,s,20);
195 D_RC5_32(a,b,s,18);
196 }
197 else if (key->rounds == 12)
198 {
199 D_RC5_32(a,b,s,24);
200 D_RC5_32(a,b,s,22);
201 D_RC5_32(a,b,s,20);
202 D_RC5_32(a,b,s,18);
203 }
204 D_RC5_32(a,b,s,16);
205 D_RC5_32(a,b,s,14);
206 D_RC5_32(a,b,s,12);
207 D_RC5_32(a,b,s,10);
208 D_RC5_32(a,b,s, 8);
209 D_RC5_32(a,b,s, 6);
210 D_RC5_32(a,b,s, 4);
211 D_RC5_32(a,b,s, 2);
212 d[0]=a-s[0];
213 d[1]=b-s[1];
119 } 214 }
215
diff --git a/src/lib/libcrypto/des/des_lib.c b/src/lib/libcrypto/rc5/rc5_skey.c
index d4b3047932..a2e00a41c5 100644
--- a/src/lib/libcrypto/des/des_lib.c
+++ b/src/lib/libcrypto/rc5/rc5_skey.c
@@ -1,4 +1,4 @@
1/* crypto/des/ecb_enc.c */ 1/* crypto/rc5/rc5_skey.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,51 +56,58 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include "des_locl.h" 59#include <openssl/rc5.h>
60#include "des_ver.h" 60#include "rc5_locl.h"
61#include <openssl/opensslv.h>
62#include <openssl/bio.h>
63 61
64OPENSSL_GLOBAL const char libdes_version[]="libdes" OPENSSL_VERSION_PTEXT; 62void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data,
65OPENSSL_GLOBAL const char DES_version[]="DES" OPENSSL_VERSION_PTEXT; 63 int rounds)
66
67const char *DES_options(void)
68 { 64 {
69 static int init=1; 65 RC5_32_INT L[64],l,ll,A,B,*S,k;
70 static char buf[32]; 66 int i,j,m,c,t,ii,jj;
67
68 if ( (rounds != RC5_16_ROUNDS) &&
69 (rounds != RC5_12_ROUNDS) &&
70 (rounds != RC5_8_ROUNDS))
71 rounds=RC5_16_ROUNDS;
71 72
72 if (init) 73 key->rounds=rounds;
74 S= &(key->data[0]);
75 j=0;
76 for (i=0; i<=(len-8); i+=8)
77 {
78 c2l(data,l);
79 L[j++]=l;
80 c2l(data,l);
81 L[j++]=l;
82 }
83 ii=len-i;
84 if (ii)
73 { 85 {
74 const char *ptr,*unroll,*risc,*size; 86 k=len&0x07;
87 c2ln(data,l,ll,k);
88 L[j+0]=l;
89 L[j+1]=ll;
90 }
91
92 c=(len+3)/4;
93 t=(rounds+1)*2;
94 S[0]=RC5_32_P;
95 for (i=1; i<t; i++)
96 S[i]=(S[i-1]+RC5_32_Q)&RC5_32_MASK;
75 97
76#ifdef DES_PTR 98 j=(t>c)?t:c;
77 ptr="ptr"; 99 j*=3;
78#else 100 ii=jj=0;
79 ptr="idx"; 101 A=B=0;
80#endif 102 for (i=0; i<j; i++)
81#if defined(DES_RISC1) || defined(DES_RISC2) 103 {
82#ifdef DES_RISC1 104 k=(S[ii]+A+B)&RC5_32_MASK;
83 risc="risc1"; 105 A=S[ii]=ROTATE_l32(k,3);
84#endif 106 m=(int)(A+B);
85#ifdef DES_RISC2 107 k=(L[jj]+A+B)&RC5_32_MASK;
86 risc="risc2"; 108 B=L[jj]=ROTATE_l32(k,m);
87#endif 109 if (++ii >= t) ii=0;
88#else 110 if (++jj >= c) jj=0;
89 risc="cisc";
90#endif
91#ifdef DES_UNROLL
92 unroll="16";
93#else
94 unroll="4";
95#endif
96 if (sizeof(DES_LONG) != sizeof(long))
97 size="int";
98 else
99 size="long";
100 BIO_snprintf(buf,sizeof buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,
101 size);
102 init=0;
103 } 111 }
104 return(buf);
105 } 112 }
106 113
diff --git a/src/lib/libcrypto/asn1/a_meth.c b/src/lib/libcrypto/rc5/rc5cfb64.c
index 50bea917e3..3a8b60bc7a 100644
--- a/src/lib/libcrypto/asn1/a_meth.c
+++ b/src/lib/libcrypto/rc5/rc5cfb64.c
@@ -1,4 +1,4 @@
1/* crypto/asn1/a_meth.c */ 1/* crypto/rc5/rc5cfb64.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,29 +56,67 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <stdio.h> 59#include <openssl/rc5.h>
60#include "cryptlib.h" 60#include "rc5_locl.h"
61#include <openssl/buffer.h>
62#include <openssl/asn1.h>
63 61
64static ASN1_METHOD ia5string_meth={ 62/* The input and output encrypted as though 64bit cfb mode is being
65 (I2D_OF(void)) i2d_ASN1_IA5STRING, 63 * used. The extra state information to record how much of the
66 (D2I_OF(void)) d2i_ASN1_IA5STRING, 64 * 64bit block we have used is contained in *num;
67 (void *(*)(void))ASN1_STRING_new, 65 */
68 (void (*)(void *))ASN1_STRING_free};
69
70static ASN1_METHOD bit_string_meth={
71 (I2D_OF(void)) i2d_ASN1_BIT_STRING,
72 (D2I_OF(void)) d2i_ASN1_BIT_STRING,
73 (void *(*)(void))ASN1_STRING_new,
74 (void (*)(void *))ASN1_STRING_free};
75 66
76ASN1_METHOD *ASN1_IA5STRING_asn1_meth(void) 67void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out,
68 long length, RC5_32_KEY *schedule,
69 unsigned char *ivec, int *num, int encrypt)
77 { 70 {
78 return(&ia5string_meth); 71 register unsigned long v0,v1,t;
79 } 72 register int n= *num;
73 register long l=length;
74 unsigned long ti[2];
75 unsigned char *iv,c,cc;
80 76
81ASN1_METHOD *ASN1_BIT_STRING_asn1_meth(void) 77 iv=(unsigned char *)ivec;
82 { 78 if (encrypt)
83 return(&bit_string_meth); 79 {
80 while (l--)
81 {
82 if (n == 0)
83 {
84 c2l(iv,v0); ti[0]=v0;
85 c2l(iv,v1); ti[1]=v1;
86 RC5_32_encrypt((unsigned long *)ti,schedule);
87 iv=(unsigned char *)ivec;
88 t=ti[0]; l2c(t,iv);
89 t=ti[1]; l2c(t,iv);
90 iv=(unsigned char *)ivec;
91 }
92 c= *(in++)^iv[n];
93 *(out++)=c;
94 iv[n]=c;
95 n=(n+1)&0x07;
96 }
97 }
98 else
99 {
100 while (l--)
101 {
102 if (n == 0)
103 {
104 c2l(iv,v0); ti[0]=v0;
105 c2l(iv,v1); ti[1]=v1;
106 RC5_32_encrypt((unsigned long *)ti,schedule);
107 iv=(unsigned char *)ivec;
108 t=ti[0]; l2c(t,iv);
109 t=ti[1]; l2c(t,iv);
110 iv=(unsigned char *)ivec;
111 }
112 cc= *(in++);
113 c=iv[n];
114 iv[n]=cc;
115 *(out++)=c^cc;
116 n=(n+1)&0x07;
117 }
118 }
119 v0=v1=ti[0]=ti[1]=t=c=cc=0;
120 *num=n;
84 } 121 }
122
diff --git a/src/lib/libcrypto/dsa/dsa_utl.c b/src/lib/libcrypto/rc5/rc5ofb64.c
index 24c021d120..d412215f3c 100644
--- a/src/lib/libcrypto/dsa/dsa_utl.c
+++ b/src/lib/libcrypto/rc5/rc5ofb64.c
@@ -1,4 +1,4 @@
1/* crypto/dsa/dsa_lib.c */ 1/* crypto/rc5/rc5ofb64.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -56,40 +56,56 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59/* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ 59#include <openssl/rc5.h>
60#include "rc5_locl.h"
60 61
61#include <stdio.h> 62/* The input and output encrypted as though 64bit ofb mode is being
62#include "cryptlib.h" 63 * used. The extra state information to record how much of the
63#include <openssl/bn.h> 64 * 64bit block we have used is contained in *num;
64#include <openssl/dsa.h> 65 */
65#include <openssl/asn1.h> 66void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out,
66#ifndef OPENSSL_NO_ENGINE 67 long length, RC5_32_KEY *schedule,
67#include <openssl/engine.h> 68 unsigned char *ivec, int *num)
68#endif
69#ifndef OPENSSL_NO_DH
70#include <openssl/dh.h>
71#endif
72
73DSA_SIG *DSA_SIG_new(void)
74 { 69 {
75 DSA_SIG *sig; 70 register unsigned long v0,v1,t;
76 sig = OPENSSL_malloc(sizeof(DSA_SIG)); 71 register int n= *num;
77 if (!sig) 72 register long l=length;
78 return NULL; 73 unsigned char d[8];
79 sig->r = NULL; 74 register char *dp;
80 sig->s = NULL; 75 unsigned long ti[2];
81 return sig; 76 unsigned char *iv;
82 } 77 int save=0;
83 78
84void DSA_SIG_free(DSA_SIG *sig) 79 iv=(unsigned char *)ivec;
85 { 80 c2l(iv,v0);
86 if (sig) 81 c2l(iv,v1);
82 ti[0]=v0;
83 ti[1]=v1;
84 dp=(char *)d;
85 l2c(v0,dp);
86 l2c(v1,dp);
87 while (l--)
88 {
89 if (n == 0)
90 {
91 RC5_32_encrypt((unsigned long *)ti,schedule);
92 dp=(char *)d;
93 t=ti[0]; l2c(t,dp);
94 t=ti[1]; l2c(t,dp);
95 save++;
96 }
97 *(out++)= *(in++)^d[n];
98 n=(n+1)&0x07;
99 }
100 if (save)
87 { 101 {
88 if (sig->r) 102 v0=ti[0];
89 BN_free(sig->r); 103 v1=ti[1];
90 if (sig->s) 104 iv=(unsigned char *)ivec;
91 BN_free(sig->s); 105 l2c(v0,iv);
92 OPENSSL_free(sig); 106 l2c(v1,iv);
93 } 107 }
108 t=v0=v1=ti[0]=ti[1]=0;
109 *num=n;
94 } 110 }
95 111
diff --git a/src/lib/libcrypto/tmdiff.c b/src/lib/libcrypto/rc5/rc5speed.c
index 1c6e052ac9..8e363be535 100644
--- a/src/lib/libcrypto/tmdiff.c
+++ b/src/lib/libcrypto/rc5/rc5speed.c
@@ -1,4 +1,4 @@
1/* crypto/tmdiff.c */ 1/* crypto/rc5/rc5speed.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -55,33 +55,30 @@
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58#include <stdio.h>
59#include <stdlib.h>
60#include "cryptlib.h"
61#include <openssl/tmdiff.h>
62#if !defined(OPENSSL_SYS_MSDOS)
63#include OPENSSL_UNISTD
64#endif
65 58
66#ifdef TIMEB 59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
67#undef OPENSSL_SYS_WIN32 60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
68#undef TIMES
69#endif
70 61
71#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) && !(defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX_RHAPSODY) && !defined(OPENSSL_SYS_VXWORKS) 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
72# define TIMES 63#define TIMES
73#endif 64#endif
74 65
75#ifdef OPENSSL_SYS_NETWARE 66#include <stdio.h>
76#undef TIMES 67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#ifndef OPENSSL_SYS_NETWARE
73#include <signal.h>
77#endif 74#endif
78 75
79#if !defined(_IRIX) || defined (OPENSSL_SYS_NETWARE) 76#ifndef _IRIX
80# include <time.h> 77#include <time.h>
81#endif 78#endif
82#ifdef TIMES 79#ifdef TIMES
83# include <sys/types.h> 80#include <sys/types.h>
84# include <sys/times.h> 81#include <sys/times.h>
85#endif 82#endif
86 83
87/* Depending on the VMS version, the tms structure is perhaps defined. 84/* Depending on the VMS version, the tms structure is perhaps defined.
@@ -92,169 +89,189 @@
92#undef TIMES 89#undef TIMES
93#endif 90#endif
94 91
92#ifndef TIMES
93#include <sys/timeb.h>
94#endif
95
95#if defined(sun) || defined(__ultrix) 96#if defined(sun) || defined(__ultrix)
96#define _POSIX_SOURCE 97#define _POSIX_SOURCE
97#include <limits.h> 98#include <limits.h>
98#include <sys/param.h> 99#include <sys/param.h>
99#endif 100#endif
100 101
101#if !defined(TIMES) && !defined(OPENSSL_SYS_VXWORKS) && !defined(OPENSSL_SYS_NETWARE) 102#include <openssl/rc5.h>
102#include <sys/timeb.h>
103#endif
104
105#ifdef OPENSSL_SYS_WIN32
106#include <windows.h>
107#endif
108 103
109/* The following if from times(3) man page. It may need to be changed */ 104/* The following if from times(3) man page. It may need to be changed */
110#ifndef HZ 105#ifndef HZ
111# if defined(_SC_CLK_TCK) \ 106#ifndef CLK_TCK
112 && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000) 107#define HZ 100.0
113/* # define HZ ((double)sysconf(_SC_CLK_TCK)) */ 108#else /* CLK_TCK */
114# define HZ sysconf(_SC_CLK_TCK) 109#define HZ ((double)CLK_TCK)
115# else 110#endif
116# ifndef CLK_TCK
117# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
118# define HZ 100.0
119# else /* _BSD_CLK_TCK_ */
120# define HZ ((double)_BSD_CLK_TCK_)
121# endif
122# else /* CLK_TCK */
123# define HZ ((double)CLK_TCK)
124# endif
125# endif
126#endif 111#endif
127 112
128struct ms_tm 113#define BUFSIZE ((long)1024)
129 { 114long run=0;
130#ifdef TIMES 115
131 struct tms ms_tms; 116double Time_F(int s);
117#ifdef SIGALRM
118#if defined(__STDC__) || defined(sgi) || defined(_AIX)
119#define SIGRETTYPE void
132#else 120#else
133# ifdef OPENSSL_SYS_WIN32 121#define SIGRETTYPE int
134 HANDLE thread_id;
135 FILETIME ms_win32;
136# elif defined (OPENSSL_SYS_NETWARE)
137 clock_t ms_clock;
138# else
139# ifdef OPENSSL_SYS_VXWORKS
140 unsigned long ticks;
141# else
142 struct timeb ms_timeb;
143# endif
144# endif
145#endif 122#endif
146 };
147 123
148MS_TM *ms_time_new(void) 124SIGRETTYPE sig_done(int sig);
125SIGRETTYPE sig_done(int sig)
149 { 126 {
150 MS_TM *ret; 127 signal(SIGALRM,sig_done);
151 128 run=0;
152 ret=(MS_TM *)OPENSSL_malloc(sizeof(MS_TM)); 129#ifdef LINT
153 if (ret == NULL) 130 sig=sig;
154 return(NULL);
155 memset(ret,0,sizeof(MS_TM));
156#ifdef OPENSSL_SYS_WIN32
157 ret->thread_id=GetCurrentThread();
158#endif 131#endif
159 return ret;
160 } 132 }
133#endif
161 134
162void ms_time_free(MS_TM *a) 135#define START 0
136#define STOP 1
137
138double Time_F(int s)
163 { 139 {
164 if (a != NULL) 140 double ret;
165 OPENSSL_free(a); 141#ifdef TIMES
142 static struct tms tstart,tend;
143
144 if (s == START)
145 {
146 times(&tstart);
147 return(0);
148 }
149 else
150 {
151 times(&tend);
152 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
153 return((ret == 0.0)?1e-6:ret);
154 }
155#else /* !times() */
156 static struct timeb tstart,tend;
157 long i;
158
159 if (s == START)
160 {
161 ftime(&tstart);
162 return(0);
163 }
164 else
165 {
166 ftime(&tend);
167 i=(long)tend.millitm-(long)tstart.millitm;
168 ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
169 return((ret == 0.0)?1e-6:ret);
170 }
171#endif
166 } 172 }
167 173
168void ms_time_get(MS_TM *tm) 174int main(int argc, char **argv)
169 { 175 {
170#ifdef OPENSSL_SYS_WIN32 176 long count;
171 FILETIME tmpa,tmpb,tmpc; 177 static unsigned char buf[BUFSIZE];
178 static unsigned char key[] ={
179 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,
180 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10,
181 };
182 RC5_32_KEY sch;
183 double a,b,c,d;
184#ifndef SIGALRM
185 long ca,cb,cc;
172#endif 186#endif
173 187
174#ifdef TIMES 188#ifndef TIMES
175 times(&tm->ms_tms); 189 printf("To get the most accurate results, try to run this\n");
176#else 190 printf("program when this computer is idle.\n");
177# ifdef OPENSSL_SYS_WIN32
178 GetThreadTimes(tm->thread_id,&tmpa,&tmpb,&tmpc,&(tm->ms_win32));
179# elif defined (OPENSSL_SYS_NETWARE)
180 tm->ms_clock = clock();
181# else
182# ifdef OPENSSL_SYS_VXWORKS
183 tm->ticks = tickGet();
184# else
185 ftime(&tm->ms_timeb);
186# endif
187# endif
188#endif 191#endif
189 }
190 192
191double ms_time_diff(MS_TM *a, MS_TM *b) 193#ifndef SIGALRM
192 { 194 printf("First we calculate the approximate speed ...\n");
193 double ret; 195 RC5_32_set_key(&sch,16,key,12);
196 count=10;
197 do {
198 long i;
199 unsigned long data[2];
194 200
195#ifdef TIMES 201 count*=2;
196 ret = HZ; 202 Time_F(START);
197 ret = (b->ms_tms.tms_utime-a->ms_tms.tms_utime) / ret; 203 for (i=count; i; i--)
198#else 204 RC5_32_encrypt(data,&sch);
199# ifdef OPENSSL_SYS_WIN32 205 d=Time_F(STOP);
200 { 206 } while (d < 3.0);
201#ifdef __GNUC__ 207 ca=count/512;
202 signed long long la,lb; 208 cb=count;
209 cc=count*8/BUFSIZE+1;
210 printf("Doing RC5_32_set_key %ld times\n",ca);
211#define COND(d) (count != (d))
212#define COUNT(d) (d)
203#else 213#else
204 signed _int64 la,lb; 214#define COND(c) (run)
215#define COUNT(d) (count)
216 signal(SIGALRM,sig_done);
217 printf("Doing RC5_32_set_key for 10 seconds\n");
218 alarm(10);
205#endif 219#endif
206 la=a->ms_win32.dwHighDateTime; 220
207 lb=b->ms_win32.dwHighDateTime; 221 Time_F(START);
208 la<<=32; 222 for (count=0,run=1; COND(ca); count+=4)
209 lb<<=32; 223 {
210 la+=a->ms_win32.dwLowDateTime; 224 RC5_32_set_key(&sch,16,key,12);
211 lb+=b->ms_win32.dwLowDateTime; 225 RC5_32_set_key(&sch,16,key,12);
212 ret=((double)(lb-la))/1e7; 226 RC5_32_set_key(&sch,16,key,12);
213 } 227 RC5_32_set_key(&sch,16,key,12);
214# elif defined (OPENSSL_SYS_NETWARE) 228 }
215 ret= (double)(b->ms_clock - a->ms_clock); 229 d=Time_F(STOP);
216# else 230 printf("%ld RC5_32_set_key's in %.2f seconds\n",count,d);
217# ifdef OPENSSL_SYS_VXWORKS 231 a=((double)COUNT(ca))/d;
218 ret = (double)(b->ticks - a->ticks) / (double)sysClkRateGet(); 232
219# else 233#ifdef SIGALRM
220 ret= (double)(b->ms_timeb.time-a->ms_timeb.time)+ 234 printf("Doing RC5_32_encrypt's for 10 seconds\n");
221 (((double)b->ms_timeb.millitm)- 235 alarm(10);
222 ((double)a->ms_timeb.millitm))/1000.0; 236#else
223# endif 237 printf("Doing RC5_32_encrypt %ld times\n",cb);
224# endif
225#endif 238#endif
226 return((ret < 0.0000001)?0.0000001:ret); 239 Time_F(START);
227 } 240 for (count=0,run=1; COND(cb); count+=4)
241 {
242 unsigned long data[2];
228 243
229int ms_time_cmp(const MS_TM *a, const MS_TM *b) 244 RC5_32_encrypt(data,&sch);
230 { 245 RC5_32_encrypt(data,&sch);
231 double d; 246 RC5_32_encrypt(data,&sch);
232 int ret; 247 RC5_32_encrypt(data,&sch);
248 }
249 d=Time_F(STOP);
250 printf("%ld RC5_32_encrypt's in %.2f second\n",count,d);
251 b=((double)COUNT(cb)*8)/d;
233 252
234#ifdef TIMES 253#ifdef SIGALRM
235 d = HZ; 254 printf("Doing RC5_32_cbc_encrypt on %ld byte blocks for 10 seconds\n",
236 d = (b->ms_tms.tms_utime-a->ms_tms.tms_utime) / d; 255 BUFSIZE);
256 alarm(10);
237#else 257#else
238# ifdef OPENSSL_SYS_WIN32 258 printf("Doing RC5_32_cbc_encrypt %ld times on %ld byte blocks\n",cc,
239 d =(b->ms_win32.dwHighDateTime&0x000fffff)*10+b->ms_win32.dwLowDateTime/1e7; 259 BUFSIZE);
240 d-=(a->ms_win32.dwHighDateTime&0x000fffff)*10+a->ms_win32.dwLowDateTime/1e7;
241# elif defined (OPENSSL_SYS_NETWARE)
242 d= (double)(b->ms_clock - a->ms_clock);
243# else
244# ifdef OPENSSL_SYS_VXWORKS
245 d = (b->ticks - a->ticks);
246# else
247 d= (double)(b->ms_timeb.time-a->ms_timeb.time)+
248 (((double)b->ms_timeb.millitm)-(double)a->ms_timeb.millitm)/1000.0;
249# endif
250# endif
251#endif 260#endif
252 if (d == 0.0) 261 Time_F(START);
253 ret=0; 262 for (count=0,run=1; COND(cc); count++)
254 else if (d < 0) 263 RC5_32_cbc_encrypt(buf,buf,BUFSIZE,&sch,
255 ret= -1; 264 &(key[0]),RC5_ENCRYPT);
256 else 265 d=Time_F(STOP);
257 ret=1; 266 printf("%ld RC5_32_cbc_encrypt's of %ld byte blocks in %.2f second\n",
258 return(ret); 267 count,BUFSIZE,d);
259 } 268 c=((double)COUNT(cc)*BUFSIZE)/d;
260 269
270 printf("RC5_32/12/16 set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
271 printf("RC5_32/12/16 raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
272 printf("RC5_32/12/16 cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
273 exit(0);
274#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
275 return(0);
276#endif
277 }
diff --git a/src/lib/libcrypto/rsa/rsa_eng.c b/src/lib/libcrypto/rsa/rsa_eng.c
deleted file mode 100644
index 383a7045b2..0000000000
--- a/src/lib/libcrypto/rsa/rsa_eng.c
+++ /dev/null
@@ -1,348 +0,0 @@
1/* crypto/rsa/rsa_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 <openssl/crypto.h>
61#include "cryptlib.h"
62#include <openssl/lhash.h>
63#include <openssl/bn.h>
64#include <openssl/rsa.h>
65#include <openssl/rand.h>
66#ifndef OPENSSL_NO_ENGINE
67#include <openssl/engine.h>
68#endif
69
70const char RSA_version[]="RSA" OPENSSL_VERSION_PTEXT;
71
72static const RSA_METHOD *default_RSA_meth=NULL;
73
74RSA *RSA_new(void)
75 {
76 RSA *r=RSA_new_method(NULL);
77
78 return r;
79 }
80
81void RSA_set_default_method(const RSA_METHOD *meth)
82 {
83#ifdef OPENSSL_FIPS
84 if (FIPS_mode() && !(meth->flags & RSA_FLAG_FIPS_METHOD))
85 {
86 RSAerr(RSA_F_RSA_SET_DEFAULT_METHOD, RSA_R_NON_FIPS_METHOD);
87 return;
88 }
89#endif
90 default_RSA_meth = meth;
91 }
92
93const RSA_METHOD *RSA_get_default_method(void)
94 {
95 if (default_RSA_meth == NULL)
96 {
97#ifdef RSA_NULL
98 default_RSA_meth=RSA_null_method();
99#else
100#if 0 /* was: #ifdef RSAref */
101 default_RSA_meth=RSA_PKCS1_RSAref();
102#else
103 default_RSA_meth=RSA_PKCS1_SSLeay();
104#endif
105#endif
106 }
107
108 return default_RSA_meth;
109 }
110
111const RSA_METHOD *RSA_get_method(const RSA *rsa)
112 {
113 return rsa->meth;
114 }
115
116int RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
117 {
118 /* NB: The caller is specifically setting a method, so it's not up to us
119 * to deal with which ENGINE it comes from. */
120 const RSA_METHOD *mtmp;
121#ifdef OPENSSL_FIPS
122 if (FIPS_mode() && !(meth->flags & RSA_FLAG_FIPS_METHOD))
123 {
124 RSAerr(RSA_F_RSA_SET_METHOD, RSA_R_NON_FIPS_METHOD);
125 return 0;
126 }
127#endif
128 mtmp = rsa->meth;
129 if (mtmp->finish) mtmp->finish(rsa);
130#ifndef OPENSSL_NO_ENGINE
131 if (rsa->engine)
132 {
133 ENGINE_finish(rsa->engine);
134 rsa->engine = NULL;
135 }
136#endif
137 rsa->meth = meth;
138 if (meth->init) meth->init(rsa);
139 return 1;
140 }
141
142RSA *RSA_new_method(ENGINE *engine)
143 {
144 RSA *ret;
145
146 ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
147 if (ret == NULL)
148 {
149 RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
150 return NULL;
151 }
152
153 ret->meth = RSA_get_default_method();
154#ifndef OPENSSL_NO_ENGINE
155 if (engine)
156 {
157 if (!ENGINE_init(engine))
158 {
159 RSAerr(RSA_F_RSA_NEW_METHOD, ERR_R_ENGINE_LIB);
160 OPENSSL_free(ret);
161 return NULL;
162 }
163 ret->engine = engine;
164 }
165 else
166 ret->engine = ENGINE_get_default_RSA();
167 if(ret->engine)
168 {
169 ret->meth = ENGINE_get_RSA(ret->engine);
170 if(!ret->meth)
171 {
172 RSAerr(RSA_F_RSA_NEW_METHOD,
173 ERR_R_ENGINE_LIB);
174 ENGINE_finish(ret->engine);
175 OPENSSL_free(ret);
176 return NULL;
177 }
178 }
179#endif
180#ifdef OPENSSL_FIPS
181 if (FIPS_mode() && !(ret->meth->flags & RSA_FLAG_FIPS_METHOD))
182 {
183 RSAerr(RSA_F_RSA_NEW_METHOD, RSA_R_NON_FIPS_METHOD);
184#ifndef OPENSSL_NO_ENGINE
185 if (ret->engine)
186 ENGINE_finish(ret->engine);
187#endif
188 OPENSSL_free(ret);
189 return NULL;
190 }
191#endif
192
193 ret->pad=0;
194 ret->version=0;
195 ret->n=NULL;
196 ret->e=NULL;
197 ret->d=NULL;
198 ret->p=NULL;
199 ret->q=NULL;
200 ret->dmp1=NULL;
201 ret->dmq1=NULL;
202 ret->iqmp=NULL;
203 ret->references=1;
204 ret->_method_mod_n=NULL;
205 ret->_method_mod_p=NULL;
206 ret->_method_mod_q=NULL;
207 ret->blinding=NULL;
208 ret->mt_blinding=NULL;
209 ret->bignum_data=NULL;
210 ret->flags=ret->meth->flags;
211 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
212 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
213 {
214#ifndef OPENSSL_NO_ENGINE
215 if (ret->engine)
216 ENGINE_finish(ret->engine);
217#endif
218 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
219 OPENSSL_free(ret);
220 ret=NULL;
221 }
222 return(ret);
223 }
224
225void RSA_free(RSA *r)
226 {
227 int i;
228
229 if (r == NULL) return;
230
231 i=CRYPTO_add(&r->references,-1,CRYPTO_LOCK_RSA);
232#ifdef REF_PRINT
233 REF_PRINT("RSA",r);
234#endif
235 if (i > 0) return;
236#ifdef REF_CHECK
237 if (i < 0)
238 {
239 fprintf(stderr,"RSA_free, bad reference count\n");
240 abort();
241 }
242#endif
243
244 if (r->meth->finish)
245 r->meth->finish(r);
246#ifndef OPENSSL_NO_ENGINE
247 if (r->engine)
248 ENGINE_finish(r->engine);
249#endif
250
251 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);
252
253 if (r->n != NULL) BN_clear_free(r->n);
254 if (r->e != NULL) BN_clear_free(r->e);
255 if (r->d != NULL) BN_clear_free(r->d);
256 if (r->p != NULL) BN_clear_free(r->p);
257 if (r->q != NULL) BN_clear_free(r->q);
258 if (r->dmp1 != NULL) BN_clear_free(r->dmp1);
259 if (r->dmq1 != NULL) BN_clear_free(r->dmq1);
260 if (r->iqmp != NULL) BN_clear_free(r->iqmp);
261 if (r->blinding != NULL) BN_BLINDING_free(r->blinding);
262 if (r->mt_blinding != NULL) BN_BLINDING_free(r->mt_blinding);
263 if (r->bignum_data != NULL) OPENSSL_free_locked(r->bignum_data);
264 OPENSSL_free(r);
265 }
266
267int RSA_up_ref(RSA *r)
268 {
269 int i = CRYPTO_add(&r->references, 1, CRYPTO_LOCK_RSA);
270#ifdef REF_PRINT
271 REF_PRINT("RSA",r);
272#endif
273#ifdef REF_CHECK
274 if (i < 2)
275 {
276 fprintf(stderr, "RSA_up_ref, bad reference count\n");
277 abort();
278 }
279#endif
280 return ((i > 1) ? 1 : 0);
281 }
282
283int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
284 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
285 {
286 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, argl, argp,
287 new_func, dup_func, free_func);
288 }
289
290int RSA_set_ex_data(RSA *r, int idx, void *arg)
291 {
292 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
293 }
294
295void *RSA_get_ex_data(const RSA *r, int idx)
296 {
297 return(CRYPTO_get_ex_data(&r->ex_data,idx));
298 }
299
300int RSA_flags(const RSA *r)
301 {
302 return((r == NULL)?0:r->meth->flags);
303 }
304
305int RSA_memory_lock(RSA *r)
306 {
307 int i,j,k,off;
308 char *p;
309 BIGNUM *bn,**t[6],*b;
310 BN_ULONG *ul;
311
312 if (r->d == NULL) return(1);
313 t[0]= &r->d;
314 t[1]= &r->p;
315 t[2]= &r->q;
316 t[3]= &r->dmp1;
317 t[4]= &r->dmq1;
318 t[5]= &r->iqmp;
319 k=sizeof(BIGNUM)*6;
320 off=k/sizeof(BN_ULONG)+1;
321 j=1;
322 for (i=0; i<6; i++)
323 j+= (*t[i])->top;
324 if ((p=OPENSSL_malloc_locked((off+j)*sizeof(BN_ULONG))) == NULL)
325 {
326 RSAerr(RSA_F_RSA_MEMORY_LOCK,ERR_R_MALLOC_FAILURE);
327 return(0);
328 }
329 bn=(BIGNUM *)p;
330 ul=(BN_ULONG *)&(p[off]);
331 for (i=0; i<6; i++)
332 {
333 b= *(t[i]);
334 *(t[i])= &(bn[i]);
335 memcpy((char *)&(bn[i]),(char *)b,sizeof(BIGNUM));
336 bn[i].flags=BN_FLG_STATIC_DATA;
337 bn[i].d=ul;
338 memcpy((char *)ul,b->d,sizeof(BN_ULONG)*b->top);
339 ul+=b->top;
340 BN_clear_free(b);
341 }
342
343 /* I should fix this so it can still be done */
344 r->flags&= ~(RSA_FLAG_CACHE_PRIVATE|RSA_FLAG_CACHE_PUBLIC);
345
346 r->bignum_data=p;
347 return(1);
348 }
diff --git a/src/lib/libcrypto/rsa/rsa_x931g.c b/src/lib/libcrypto/rsa/rsa_x931g.c
deleted file mode 100644
index bf94f8be7a..0000000000
--- a/src/lib/libcrypto/rsa/rsa_x931g.c
+++ /dev/null
@@ -1,255 +0,0 @@
1/* crypto/rsa/rsa_gen.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 <string.h>
61#include <time.h>
62#include <openssl/err.h>
63#include <openssl/bn.h>
64#include <openssl/rsa.h>
65
66#ifndef OPENSSL_FIPS
67
68/* X9.31 RSA key derivation and generation */
69
70int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1, BIGNUM *q2,
71 const BIGNUM *Xp1, const BIGNUM *Xp2, const BIGNUM *Xp,
72 const BIGNUM *Xq1, const BIGNUM *Xq2, const BIGNUM *Xq,
73 const BIGNUM *e, BN_GENCB *cb)
74 {
75 BIGNUM *r0=NULL,*r1=NULL,*r2=NULL,*r3=NULL;
76 BN_CTX *ctx=NULL,*ctx2=NULL;
77
78 if (!rsa)
79 goto err;
80
81 ctx = BN_CTX_new();
82 if (!ctx)
83 goto err;
84 BN_CTX_start(ctx);
85
86 r0 = BN_CTX_get(ctx);
87 r1 = BN_CTX_get(ctx);
88 r2 = BN_CTX_get(ctx);
89 r3 = BN_CTX_get(ctx);
90
91 if (r3 == NULL)
92 goto err;
93 if (!rsa->e)
94 {
95 rsa->e = BN_dup(e);
96 if (!rsa->e)
97 goto err;
98 }
99 else
100 e = rsa->e;
101
102 /* If not all parameters present only calculate what we can.
103 * This allows test programs to output selective parameters.
104 */
105
106 if (Xp && !rsa->p)
107 {
108 rsa->p = BN_new();
109 if (!rsa->p)
110 goto err;
111
112 if (!BN_X931_derive_prime_ex(rsa->p, p1, p2,
113 Xp, Xp1, Xp2, e, ctx, cb))
114 goto err;
115 }
116
117 if (Xq && !rsa->q)
118 {
119 rsa->q = BN_new();
120 if (!rsa->q)
121 goto err;
122 if (!BN_X931_derive_prime_ex(rsa->q, q1, q2,
123 Xq, Xq1, Xq2, e, ctx, cb))
124 goto err;
125 }
126
127 if (!rsa->p || !rsa->q)
128 {
129 BN_CTX_end(ctx);
130 BN_CTX_free(ctx);
131 return 2;
132 }
133
134 /* Since both primes are set we can now calculate all remaining
135 * components.
136 */
137
138 /* calculate n */
139 rsa->n=BN_new();
140 if (rsa->n == NULL)
141 goto err;
142 if (!BN_mul(rsa->n,rsa->p,rsa->q,ctx))
143 goto err;
144
145 /* calculate d */
146 if (!BN_sub(r1,rsa->p,BN_value_one()))
147 goto err; /* p-1 */
148 if (!BN_sub(r2,rsa->q,BN_value_one()))
149 goto err; /* q-1 */
150 if (!BN_mul(r0,r1,r2,ctx))
151 goto err; /* (p-1)(q-1) */
152
153 if (!BN_gcd(r3, r1, r2, ctx))
154 goto err;
155
156 if (!BN_div(r0, NULL, r0, r3, ctx))
157 goto err; /* LCM((p-1)(q-1)) */
158
159 ctx2 = BN_CTX_new();
160 if (!ctx2)
161 goto err;
162
163 rsa->d=BN_mod_inverse(NULL,rsa->e,r0,ctx2); /* d */
164 if (rsa->d == NULL)
165 goto err;
166
167 /* calculate d mod (p-1) */
168 rsa->dmp1=BN_new();
169 if (rsa->dmp1 == NULL)
170 goto err;
171 if (!BN_mod(rsa->dmp1,rsa->d,r1,ctx))
172 goto err;
173
174 /* calculate d mod (q-1) */
175 rsa->dmq1=BN_new();
176 if (rsa->dmq1 == NULL)
177 goto err;
178 if (!BN_mod(rsa->dmq1,rsa->d,r2,ctx))
179 goto err;
180
181 /* calculate inverse of q mod p */
182 rsa->iqmp=BN_mod_inverse(NULL,rsa->q,rsa->p,ctx2);
183
184 err:
185 if (ctx)
186 {
187 BN_CTX_end(ctx);
188 BN_CTX_free(ctx);
189 }
190 if (ctx2)
191 BN_CTX_free(ctx2);
192 /* If this is set all calls successful */
193 if (rsa && rsa->iqmp != NULL)
194 return 1;
195
196 return 0;
197
198 }
199
200int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e, BN_GENCB *cb)
201 {
202 int ok = 0;
203 BIGNUM *Xp = NULL, *Xq = NULL;
204 BN_CTX *ctx = NULL;
205
206 ctx = BN_CTX_new();
207 if (!ctx)
208 goto error;
209
210 BN_CTX_start(ctx);
211 Xp = BN_CTX_get(ctx);
212 Xq = BN_CTX_get(ctx);
213 if (!BN_X931_generate_Xpq(Xp, Xq, bits, ctx))
214 goto error;
215
216 rsa->p = BN_new();
217 rsa->q = BN_new();
218 if (!rsa->p || !rsa->q)
219 goto error;
220
221 /* Generate two primes from Xp, Xq */
222
223 if (!BN_X931_generate_prime_ex(rsa->p, NULL, NULL, NULL, NULL, Xp,
224 e, ctx, cb))
225 goto error;
226
227 if (!BN_X931_generate_prime_ex(rsa->q, NULL, NULL, NULL, NULL, Xq,
228 e, ctx, cb))
229 goto error;
230
231 /* Since rsa->p and rsa->q are valid this call will just derive
232 * remaining RSA components.
233 */
234
235 if (!RSA_X931_derive_ex(rsa, NULL, NULL, NULL, NULL,
236 NULL, NULL, NULL, NULL, NULL, NULL, e, cb))
237 goto error;
238
239 ok = 1;
240
241 error:
242 if (ctx)
243 {
244 BN_CTX_end(ctx);
245 BN_CTX_free(ctx);
246 }
247
248 if (ok)
249 return 1;
250
251 return 0;
252
253 }
254
255#endif
diff --git a/src/lib/libcrypto/seed/Makefile b/src/lib/libcrypto/seed/Makefile
new file mode 100644
index 0000000000..4bc55e4916
--- /dev/null
+++ b/src/lib/libcrypto/seed/Makefile
@@ -0,0 +1,106 @@
1#
2# crypto/seed/Makefile
3#
4
5DIR= seed
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11MAKEFILE= Makefile
12AR= ar r
13
14CFLAGS= $(INCLUDES) $(CFLAG)
15
16GENERAL=Makefile
17TEST=
18APPS=
19
20LIB=$(TOP)/libcrypto.a
21LIBSRC=seed.c seed_ecb.c seed_cbc.c seed_cfb.c seed_ofb.c
22LIBOBJ=seed.o seed_ecb.o seed_cbc.o seed_cfb.o seed_ofb.o
23
24SRC= $(LIBSRC)
25
26EXHEADER= seed.h
27HEADER= seed_locl.h $(EXHEADER)
28
29ALL= $(GENERAL) $(SRC) $(HEADER)
30
31top:
32 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
33
34all: lib
35
36lib: $(LIBOBJ)
37 $(AR) $(LIB) $(LIBOBJ)
38 $(RANLIB) $(LIB) || echo Never mind.
39 @touch lib
40
41files:
42 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
43
44links:
45 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
46 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
47 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
48
49install:
50 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
51 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
52 do \
53 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
54 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
55 done;
56
57tags:
58 ctags $(SRC)
59
60tests:
61
62lint:
63 lint -DLINT $(INCLUDES) $(SRC)>fluff
64
65depend:
66 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
67 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
68
69dclean:
70 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
71 mv -f Makefile.new $(MAKEFILE)
72
73clean:
74 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
75
76# DO NOT DELETE THIS LINE -- make depend depends on it.
77
78seed.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
79seed.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
80seed.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
81seed.o: ../../include/openssl/seed.h ../../include/openssl/stack.h
82seed.o: ../../include/openssl/symhacks.h seed.c seed_locl.h
83seed_cbc.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
84seed_cbc.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
85seed_cbc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
86seed_cbc.o: ../../include/openssl/safestack.h ../../include/openssl/seed.h
87seed_cbc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
88seed_cbc.o: seed_cbc.c
89seed_cfb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
90seed_cfb.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
91seed_cfb.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
92seed_cfb.o: ../../include/openssl/safestack.h ../../include/openssl/seed.h
93seed_cfb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
94seed_cfb.o: seed_cfb.c
95seed_ecb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
96seed_ecb.o: ../../include/openssl/opensslconf.h
97seed_ecb.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
98seed_ecb.o: ../../include/openssl/safestack.h ../../include/openssl/seed.h
99seed_ecb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
100seed_ecb.o: seed_ecb.c
101seed_ofb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
102seed_ofb.o: ../../include/openssl/modes.h ../../include/openssl/opensslconf.h
103seed_ofb.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
104seed_ofb.o: ../../include/openssl/safestack.h ../../include/openssl/seed.h
105seed_ofb.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
106seed_ofb.o: seed_ofb.c
diff --git a/src/lib/libcrypto/seed/seed.c b/src/lib/libcrypto/seed/seed.c
new file mode 100644
index 0000000000..3e675a8d75
--- /dev/null
+++ b/src/lib/libcrypto/seed/seed.c
@@ -0,0 +1,336 @@
1/*
2 * Copyright (c) 2007 KISA(Korea Information Security Agency). 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. Neither the name of author nor the names of its contributors may
10 * be used to endorse or promote products derived from this software
11 * without specific prior written permission.
12 *
13 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 *
25 */
26#ifndef OPENSSL_NO_SEED
27
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31#ifdef WIN32
32#include <memory.h>
33#endif
34
35#include <openssl/crypto.h>
36#include <openssl/seed.h>
37#include "seed_locl.h"
38
39#ifdef SS /* can get defined on Solaris by inclusion of <stdlib.h> */
40#undef SS
41#endif
42
43static const seed_word SS[4][256] = { {
44 0x2989a1a8, 0x05858184, 0x16c6d2d4, 0x13c3d3d0, 0x14445054, 0x1d0d111c, 0x2c8ca0ac, 0x25052124,
45 0x1d4d515c, 0x03434340, 0x18081018, 0x1e0e121c, 0x11415150, 0x3cccf0fc, 0x0acac2c8, 0x23436360,
46 0x28082028, 0x04444044, 0x20002020, 0x1d8d919c, 0x20c0e0e0, 0x22c2e2e0, 0x08c8c0c8, 0x17071314,
47 0x2585a1a4, 0x0f8f838c, 0x03030300, 0x3b4b7378, 0x3b8bb3b8, 0x13031310, 0x12c2d2d0, 0x2ecee2ec,
48 0x30407070, 0x0c8c808c, 0x3f0f333c, 0x2888a0a8, 0x32023230, 0x1dcdd1dc, 0x36c6f2f4, 0x34447074,
49 0x2ccce0ec, 0x15859194, 0x0b0b0308, 0x17475354, 0x1c4c505c, 0x1b4b5358, 0x3d8db1bc, 0x01010100,
50 0x24042024, 0x1c0c101c, 0x33437370, 0x18889098, 0x10001010, 0x0cccc0cc, 0x32c2f2f0, 0x19c9d1d8,
51 0x2c0c202c, 0x27c7e3e4, 0x32427270, 0x03838380, 0x1b8b9398, 0x11c1d1d0, 0x06868284, 0x09c9c1c8,
52 0x20406060, 0x10405050, 0x2383a3a0, 0x2bcbe3e8, 0x0d0d010c, 0x3686b2b4, 0x1e8e929c, 0x0f4f434c,
53 0x3787b3b4, 0x1a4a5258, 0x06c6c2c4, 0x38487078, 0x2686a2a4, 0x12021210, 0x2f8fa3ac, 0x15c5d1d4,
54 0x21416160, 0x03c3c3c0, 0x3484b0b4, 0x01414140, 0x12425250, 0x3d4d717c, 0x0d8d818c, 0x08080008,
55 0x1f0f131c, 0x19899198, 0x00000000, 0x19091118, 0x04040004, 0x13435350, 0x37c7f3f4, 0x21c1e1e0,
56 0x3dcdf1fc, 0x36467274, 0x2f0f232c, 0x27072324, 0x3080b0b0, 0x0b8b8388, 0x0e0e020c, 0x2b8ba3a8,
57 0x2282a2a0, 0x2e4e626c, 0x13839390, 0x0d4d414c, 0x29496168, 0x3c4c707c, 0x09090108, 0x0a0a0208,
58 0x3f8fb3bc, 0x2fcfe3ec, 0x33c3f3f0, 0x05c5c1c4, 0x07878384, 0x14041014, 0x3ecef2fc, 0x24446064,
59 0x1eced2dc, 0x2e0e222c, 0x0b4b4348, 0x1a0a1218, 0x06060204, 0x21012120, 0x2b4b6368, 0x26466264,
60 0x02020200, 0x35c5f1f4, 0x12829290, 0x0a8a8288, 0x0c0c000c, 0x3383b3b0, 0x3e4e727c, 0x10c0d0d0,
61 0x3a4a7278, 0x07474344, 0x16869294, 0x25c5e1e4, 0x26062224, 0x00808080, 0x2d8da1ac, 0x1fcfd3dc,
62 0x2181a1a0, 0x30003030, 0x37073334, 0x2e8ea2ac, 0x36063234, 0x15051114, 0x22022220, 0x38083038,
63 0x34c4f0f4, 0x2787a3a4, 0x05454144, 0x0c4c404c, 0x01818180, 0x29c9e1e8, 0x04848084, 0x17879394,
64 0x35053134, 0x0bcbc3c8, 0x0ecec2cc, 0x3c0c303c, 0x31417170, 0x11011110, 0x07c7c3c4, 0x09898188,
65 0x35457174, 0x3bcbf3f8, 0x1acad2d8, 0x38c8f0f8, 0x14849094, 0x19495158, 0x02828280, 0x04c4c0c4,
66 0x3fcff3fc, 0x09494148, 0x39093138, 0x27476364, 0x00c0c0c0, 0x0fcfc3cc, 0x17c7d3d4, 0x3888b0b8,
67 0x0f0f030c, 0x0e8e828c, 0x02424240, 0x23032320, 0x11819190, 0x2c4c606c, 0x1bcbd3d8, 0x2484a0a4,
68 0x34043034, 0x31c1f1f0, 0x08484048, 0x02c2c2c0, 0x2f4f636c, 0x3d0d313c, 0x2d0d212c, 0x00404040,
69 0x3e8eb2bc, 0x3e0e323c, 0x3c8cb0bc, 0x01c1c1c0, 0x2a8aa2a8, 0x3a8ab2b8, 0x0e4e424c, 0x15455154,
70 0x3b0b3338, 0x1cccd0dc, 0x28486068, 0x3f4f737c, 0x1c8c909c, 0x18c8d0d8, 0x0a4a4248, 0x16465254,
71 0x37477374, 0x2080a0a0, 0x2dcde1ec, 0x06464244, 0x3585b1b4, 0x2b0b2328, 0x25456164, 0x3acaf2f8,
72 0x23c3e3e0, 0x3989b1b8, 0x3181b1b0, 0x1f8f939c, 0x1e4e525c, 0x39c9f1f8, 0x26c6e2e4, 0x3282b2b0,
73 0x31013130, 0x2acae2e8, 0x2d4d616c, 0x1f4f535c, 0x24c4e0e4, 0x30c0f0f0, 0x0dcdc1cc, 0x08888088,
74 0x16061214, 0x3a0a3238, 0x18485058, 0x14c4d0d4, 0x22426260, 0x29092128, 0x07070304, 0x33033330,
75 0x28c8e0e8, 0x1b0b1318, 0x05050104, 0x39497178, 0x10809090, 0x2a4a6268, 0x2a0a2228, 0x1a8a9298
76}, {
77 0x38380830, 0xe828c8e0, 0x2c2d0d21, 0xa42686a2, 0xcc0fcfc3, 0xdc1eced2, 0xb03383b3, 0xb83888b0,
78 0xac2f8fa3, 0x60204060, 0x54154551, 0xc407c7c3, 0x44044440, 0x6c2f4f63, 0x682b4b63, 0x581b4b53,
79 0xc003c3c3, 0x60224262, 0x30330333, 0xb43585b1, 0x28290921, 0xa02080a0, 0xe022c2e2, 0xa42787a3,
80 0xd013c3d3, 0x90118191, 0x10110111, 0x04060602, 0x1c1c0c10, 0xbc3c8cb0, 0x34360632, 0x480b4b43,
81 0xec2fcfe3, 0x88088880, 0x6c2c4c60, 0xa82888a0, 0x14170713, 0xc404c4c0, 0x14160612, 0xf434c4f0,
82 0xc002c2c2, 0x44054541, 0xe021c1e1, 0xd416c6d2, 0x3c3f0f33, 0x3c3d0d31, 0x8c0e8e82, 0x98188890,
83 0x28280820, 0x4c0e4e42, 0xf436c6f2, 0x3c3e0e32, 0xa42585a1, 0xf839c9f1, 0x0c0d0d01, 0xdc1fcfd3,
84 0xd818c8d0, 0x282b0b23, 0x64264662, 0x783a4a72, 0x24270723, 0x2c2f0f23, 0xf031c1f1, 0x70324272,
85 0x40024242, 0xd414c4d0, 0x40014141, 0xc000c0c0, 0x70334373, 0x64274763, 0xac2c8ca0, 0x880b8b83,
86 0xf437c7f3, 0xac2d8da1, 0x80008080, 0x1c1f0f13, 0xc80acac2, 0x2c2c0c20, 0xa82a8aa2, 0x34340430,
87 0xd012c2d2, 0x080b0b03, 0xec2ecee2, 0xe829c9e1, 0x5c1d4d51, 0x94148490, 0x18180810, 0xf838c8f0,
88 0x54174753, 0xac2e8ea2, 0x08080800, 0xc405c5c1, 0x10130313, 0xcc0dcdc1, 0x84068682, 0xb83989b1,
89 0xfc3fcff3, 0x7c3d4d71, 0xc001c1c1, 0x30310131, 0xf435c5f1, 0x880a8a82, 0x682a4a62, 0xb03181b1,
90 0xd011c1d1, 0x20200020, 0xd417c7d3, 0x00020202, 0x20220222, 0x04040400, 0x68284860, 0x70314171,
91 0x04070703, 0xd81bcbd3, 0x9c1d8d91, 0x98198991, 0x60214161, 0xbc3e8eb2, 0xe426c6e2, 0x58194951,
92 0xdc1dcdd1, 0x50114151, 0x90108090, 0xdc1cccd0, 0x981a8a92, 0xa02383a3, 0xa82b8ba3, 0xd010c0d0,
93 0x80018181, 0x0c0f0f03, 0x44074743, 0x181a0a12, 0xe023c3e3, 0xec2ccce0, 0x8c0d8d81, 0xbc3f8fb3,
94 0x94168692, 0x783b4b73, 0x5c1c4c50, 0xa02282a2, 0xa02181a1, 0x60234363, 0x20230323, 0x4c0d4d41,
95 0xc808c8c0, 0x9c1e8e92, 0x9c1c8c90, 0x383a0a32, 0x0c0c0c00, 0x2c2e0e22, 0xb83a8ab2, 0x6c2e4e62,
96 0x9c1f8f93, 0x581a4a52, 0xf032c2f2, 0x90128292, 0xf033c3f3, 0x48094941, 0x78384870, 0xcc0cccc0,
97 0x14150511, 0xf83bcbf3, 0x70304070, 0x74354571, 0x7c3f4f73, 0x34350531, 0x10100010, 0x00030303,
98 0x64244460, 0x6c2d4d61, 0xc406c6c2, 0x74344470, 0xd415c5d1, 0xb43484b0, 0xe82acae2, 0x08090901,
99 0x74364672, 0x18190911, 0xfc3ecef2, 0x40004040, 0x10120212, 0xe020c0e0, 0xbc3d8db1, 0x04050501,
100 0xf83acaf2, 0x00010101, 0xf030c0f0, 0x282a0a22, 0x5c1e4e52, 0xa82989a1, 0x54164652, 0x40034343,
101 0x84058581, 0x14140410, 0x88098981, 0x981b8b93, 0xb03080b0, 0xe425c5e1, 0x48084840, 0x78394971,
102 0x94178793, 0xfc3cccf0, 0x1c1e0e12, 0x80028282, 0x20210121, 0x8c0c8c80, 0x181b0b13, 0x5c1f4f53,
103 0x74374773, 0x54144450, 0xb03282b2, 0x1c1d0d11, 0x24250521, 0x4c0f4f43, 0x00000000, 0x44064642,
104 0xec2dcde1, 0x58184850, 0x50124252, 0xe82bcbe3, 0x7c3e4e72, 0xd81acad2, 0xc809c9c1, 0xfc3dcdf1,
105 0x30300030, 0x94158591, 0x64254561, 0x3c3c0c30, 0xb43686b2, 0xe424c4e0, 0xb83b8bb3, 0x7c3c4c70,
106 0x0c0e0e02, 0x50104050, 0x38390931, 0x24260622, 0x30320232, 0x84048480, 0x68294961, 0x90138393,
107 0x34370733, 0xe427c7e3, 0x24240420, 0xa42484a0, 0xc80bcbc3, 0x50134353, 0x080a0a02, 0x84078783,
108 0xd819c9d1, 0x4c0c4c40, 0x80038383, 0x8c0f8f83, 0xcc0ecec2, 0x383b0b33, 0x480a4a42, 0xb43787b3
109}, {
110 0xa1a82989, 0x81840585, 0xd2d416c6, 0xd3d013c3, 0x50541444, 0x111c1d0d, 0xa0ac2c8c, 0x21242505,
111 0x515c1d4d, 0x43400343, 0x10181808, 0x121c1e0e, 0x51501141, 0xf0fc3ccc, 0xc2c80aca, 0x63602343,
112 0x20282808, 0x40440444, 0x20202000, 0x919c1d8d, 0xe0e020c0, 0xe2e022c2, 0xc0c808c8, 0x13141707,
113 0xa1a42585, 0x838c0f8f, 0x03000303, 0x73783b4b, 0xb3b83b8b, 0x13101303, 0xd2d012c2, 0xe2ec2ece,
114 0x70703040, 0x808c0c8c, 0x333c3f0f, 0xa0a82888, 0x32303202, 0xd1dc1dcd, 0xf2f436c6, 0x70743444,
115 0xe0ec2ccc, 0x91941585, 0x03080b0b, 0x53541747, 0x505c1c4c, 0x53581b4b, 0xb1bc3d8d, 0x01000101,
116 0x20242404, 0x101c1c0c, 0x73703343, 0x90981888, 0x10101000, 0xc0cc0ccc, 0xf2f032c2, 0xd1d819c9,
117 0x202c2c0c, 0xe3e427c7, 0x72703242, 0x83800383, 0x93981b8b, 0xd1d011c1, 0x82840686, 0xc1c809c9,
118 0x60602040, 0x50501040, 0xa3a02383, 0xe3e82bcb, 0x010c0d0d, 0xb2b43686, 0x929c1e8e, 0x434c0f4f,
119 0xb3b43787, 0x52581a4a, 0xc2c406c6, 0x70783848, 0xa2a42686, 0x12101202, 0xa3ac2f8f, 0xd1d415c5,
120 0x61602141, 0xc3c003c3, 0xb0b43484, 0x41400141, 0x52501242, 0x717c3d4d, 0x818c0d8d, 0x00080808,
121 0x131c1f0f, 0x91981989, 0x00000000, 0x11181909, 0x00040404, 0x53501343, 0xf3f437c7, 0xe1e021c1,
122 0xf1fc3dcd, 0x72743646, 0x232c2f0f, 0x23242707, 0xb0b03080, 0x83880b8b, 0x020c0e0e, 0xa3a82b8b,
123 0xa2a02282, 0x626c2e4e, 0x93901383, 0x414c0d4d, 0x61682949, 0x707c3c4c, 0x01080909, 0x02080a0a,
124 0xb3bc3f8f, 0xe3ec2fcf, 0xf3f033c3, 0xc1c405c5, 0x83840787, 0x10141404, 0xf2fc3ece, 0x60642444,
125 0xd2dc1ece, 0x222c2e0e, 0x43480b4b, 0x12181a0a, 0x02040606, 0x21202101, 0x63682b4b, 0x62642646,
126 0x02000202, 0xf1f435c5, 0x92901282, 0x82880a8a, 0x000c0c0c, 0xb3b03383, 0x727c3e4e, 0xd0d010c0,
127 0x72783a4a, 0x43440747, 0x92941686, 0xe1e425c5, 0x22242606, 0x80800080, 0xa1ac2d8d, 0xd3dc1fcf,
128 0xa1a02181, 0x30303000, 0x33343707, 0xa2ac2e8e, 0x32343606, 0x11141505, 0x22202202, 0x30383808,
129 0xf0f434c4, 0xa3a42787, 0x41440545, 0x404c0c4c, 0x81800181, 0xe1e829c9, 0x80840484, 0x93941787,
130 0x31343505, 0xc3c80bcb, 0xc2cc0ece, 0x303c3c0c, 0x71703141, 0x11101101, 0xc3c407c7, 0x81880989,
131 0x71743545, 0xf3f83bcb, 0xd2d81aca, 0xf0f838c8, 0x90941484, 0x51581949, 0x82800282, 0xc0c404c4,
132 0xf3fc3fcf, 0x41480949, 0x31383909, 0x63642747, 0xc0c000c0, 0xc3cc0fcf, 0xd3d417c7, 0xb0b83888,
133 0x030c0f0f, 0x828c0e8e, 0x42400242, 0x23202303, 0x91901181, 0x606c2c4c, 0xd3d81bcb, 0xa0a42484,
134 0x30343404, 0xf1f031c1, 0x40480848, 0xc2c002c2, 0x636c2f4f, 0x313c3d0d, 0x212c2d0d, 0x40400040,
135 0xb2bc3e8e, 0x323c3e0e, 0xb0bc3c8c, 0xc1c001c1, 0xa2a82a8a, 0xb2b83a8a, 0x424c0e4e, 0x51541545,
136 0x33383b0b, 0xd0dc1ccc, 0x60682848, 0x737c3f4f, 0x909c1c8c, 0xd0d818c8, 0x42480a4a, 0x52541646,
137 0x73743747, 0xa0a02080, 0xe1ec2dcd, 0x42440646, 0xb1b43585, 0x23282b0b, 0x61642545, 0xf2f83aca,
138 0xe3e023c3, 0xb1b83989, 0xb1b03181, 0x939c1f8f, 0x525c1e4e, 0xf1f839c9, 0xe2e426c6, 0xb2b03282,
139 0x31303101, 0xe2e82aca, 0x616c2d4d, 0x535c1f4f, 0xe0e424c4, 0xf0f030c0, 0xc1cc0dcd, 0x80880888,
140 0x12141606, 0x32383a0a, 0x50581848, 0xd0d414c4, 0x62602242, 0x21282909, 0x03040707, 0x33303303,
141 0xe0e828c8, 0x13181b0b, 0x01040505, 0x71783949, 0x90901080, 0x62682a4a, 0x22282a0a, 0x92981a8a
142}, {
143 0x08303838, 0xc8e0e828, 0x0d212c2d, 0x86a2a426, 0xcfc3cc0f, 0xced2dc1e, 0x83b3b033, 0x88b0b838,
144 0x8fa3ac2f, 0x40606020, 0x45515415, 0xc7c3c407, 0x44404404, 0x4f636c2f, 0x4b63682b, 0x4b53581b,
145 0xc3c3c003, 0x42626022, 0x03333033, 0x85b1b435, 0x09212829, 0x80a0a020, 0xc2e2e022, 0x87a3a427,
146 0xc3d3d013, 0x81919011, 0x01111011, 0x06020406, 0x0c101c1c, 0x8cb0bc3c, 0x06323436, 0x4b43480b,
147 0xcfe3ec2f, 0x88808808, 0x4c606c2c, 0x88a0a828, 0x07131417, 0xc4c0c404, 0x06121416, 0xc4f0f434,
148 0xc2c2c002, 0x45414405, 0xc1e1e021, 0xc6d2d416, 0x0f333c3f, 0x0d313c3d, 0x8e828c0e, 0x88909818,
149 0x08202828, 0x4e424c0e, 0xc6f2f436, 0x0e323c3e, 0x85a1a425, 0xc9f1f839, 0x0d010c0d, 0xcfd3dc1f,
150 0xc8d0d818, 0x0b23282b, 0x46626426, 0x4a72783a, 0x07232427, 0x0f232c2f, 0xc1f1f031, 0x42727032,
151 0x42424002, 0xc4d0d414, 0x41414001, 0xc0c0c000, 0x43737033, 0x47636427, 0x8ca0ac2c, 0x8b83880b,
152 0xc7f3f437, 0x8da1ac2d, 0x80808000, 0x0f131c1f, 0xcac2c80a, 0x0c202c2c, 0x8aa2a82a, 0x04303434,
153 0xc2d2d012, 0x0b03080b, 0xcee2ec2e, 0xc9e1e829, 0x4d515c1d, 0x84909414, 0x08101818, 0xc8f0f838,
154 0x47535417, 0x8ea2ac2e, 0x08000808, 0xc5c1c405, 0x03131013, 0xcdc1cc0d, 0x86828406, 0x89b1b839,
155 0xcff3fc3f, 0x4d717c3d, 0xc1c1c001, 0x01313031, 0xc5f1f435, 0x8a82880a, 0x4a62682a, 0x81b1b031,
156 0xc1d1d011, 0x00202020, 0xc7d3d417, 0x02020002, 0x02222022, 0x04000404, 0x48606828, 0x41717031,
157 0x07030407, 0xcbd3d81b, 0x8d919c1d, 0x89919819, 0x41616021, 0x8eb2bc3e, 0xc6e2e426, 0x49515819,
158 0xcdd1dc1d, 0x41515011, 0x80909010, 0xccd0dc1c, 0x8a92981a, 0x83a3a023, 0x8ba3a82b, 0xc0d0d010,
159 0x81818001, 0x0f030c0f, 0x47434407, 0x0a12181a, 0xc3e3e023, 0xcce0ec2c, 0x8d818c0d, 0x8fb3bc3f,
160 0x86929416, 0x4b73783b, 0x4c505c1c, 0x82a2a022, 0x81a1a021, 0x43636023, 0x03232023, 0x4d414c0d,
161 0xc8c0c808, 0x8e929c1e, 0x8c909c1c, 0x0a32383a, 0x0c000c0c, 0x0e222c2e, 0x8ab2b83a, 0x4e626c2e,
162 0x8f939c1f, 0x4a52581a, 0xc2f2f032, 0x82929012, 0xc3f3f033, 0x49414809, 0x48707838, 0xccc0cc0c,
163 0x05111415, 0xcbf3f83b, 0x40707030, 0x45717435, 0x4f737c3f, 0x05313435, 0x00101010, 0x03030003,
164 0x44606424, 0x4d616c2d, 0xc6c2c406, 0x44707434, 0xc5d1d415, 0x84b0b434, 0xcae2e82a, 0x09010809,
165 0x46727436, 0x09111819, 0xcef2fc3e, 0x40404000, 0x02121012, 0xc0e0e020, 0x8db1bc3d, 0x05010405,
166 0xcaf2f83a, 0x01010001, 0xc0f0f030, 0x0a22282a, 0x4e525c1e, 0x89a1a829, 0x46525416, 0x43434003,
167 0x85818405, 0x04101414, 0x89818809, 0x8b93981b, 0x80b0b030, 0xc5e1e425, 0x48404808, 0x49717839,
168 0x87939417, 0xccf0fc3c, 0x0e121c1e, 0x82828002, 0x01212021, 0x8c808c0c, 0x0b13181b, 0x4f535c1f,
169 0x47737437, 0x44505414, 0x82b2b032, 0x0d111c1d, 0x05212425, 0x4f434c0f, 0x00000000, 0x46424406,
170 0xcde1ec2d, 0x48505818, 0x42525012, 0xcbe3e82b, 0x4e727c3e, 0xcad2d81a, 0xc9c1c809, 0xcdf1fc3d,
171 0x00303030, 0x85919415, 0x45616425, 0x0c303c3c, 0x86b2b436, 0xc4e0e424, 0x8bb3b83b, 0x4c707c3c,
172 0x0e020c0e, 0x40505010, 0x09313839, 0x06222426, 0x02323032, 0x84808404, 0x49616829, 0x83939013,
173 0x07333437, 0xc7e3e427, 0x04202424, 0x84a0a424, 0xcbc3c80b, 0x43535013, 0x0a02080a, 0x87838407,
174 0xc9d1d819, 0x4c404c0c, 0x83838003, 0x8f838c0f, 0xcec2cc0e, 0x0b33383b, 0x4a42480a, 0x87b3b437
175} };
176
177/* key schedule constants - golden ratio */
178#define KC0 0x9e3779b9
179#define KC1 0x3c6ef373
180#define KC2 0x78dde6e6
181#define KC3 0xf1bbcdcc
182#define KC4 0xe3779b99
183#define KC5 0xc6ef3733
184#define KC6 0x8dde6e67
185#define KC7 0x1bbcdccf
186#define KC8 0x3779b99e
187#define KC9 0x6ef3733c
188#define KC10 0xdde6e678
189#define KC11 0xbbcdccf1
190#define KC12 0x779b99e3
191#define KC13 0xef3733c6
192#define KC14 0xde6e678d
193#define KC15 0xbcdccf1b
194
195#if defined(OPENSSL_SMALL_FOOTPRINT)
196static const seed_word KC[] = {
197 KC0, KC1, KC2, KC3, KC4, KC5, KC6, KC7,
198 KC8, KC9, KC10, KC11, KC12, KC13, KC14, KC15 };
199#endif
200void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], SEED_KEY_SCHEDULE *ks)
201#ifdef OPENSSL_FIPS
202 {
203 fips_cipher_abort(SEED);
204 private_SEED_set_key(rawkey, ks);
205 }
206void private_SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], SEED_KEY_SCHEDULE *ks)
207#endif
208{
209 seed_word x1, x2, x3, x4;
210 seed_word t0, t1;
211
212 char2word(rawkey , x1);
213 char2word(rawkey+4 , x2);
214 char2word(rawkey+8 , x3);
215 char2word(rawkey+12, x4);
216
217 t0 = (x1 + x3 - KC0) & 0xffffffff;
218 t1 = (x2 - x4 + KC0) & 0xffffffff; KEYUPDATE_TEMP(t0, t1, &ks->data[0]);
219 KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC1); KEYUPDATE_TEMP(t0, t1, &ks->data[2]);
220
221#if !defined(OPENSSL_SMALL_FOOTPRINT)
222 KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC2); KEYUPDATE_TEMP(t0, t1, &ks->data[4]);
223 KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC3); KEYUPDATE_TEMP(t0, t1, &ks->data[6]);
224 KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC4); KEYUPDATE_TEMP(t0, t1, &ks->data[8]);
225 KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC5); KEYUPDATE_TEMP(t0, t1, &ks->data[10]);
226 KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC6); KEYUPDATE_TEMP(t0, t1, &ks->data[12]);
227 KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC7); KEYUPDATE_TEMP(t0, t1, &ks->data[14]);
228 KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC8); KEYUPDATE_TEMP(t0, t1, &ks->data[16]);
229 KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC9); KEYUPDATE_TEMP(t0, t1, &ks->data[18]);
230 KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC10); KEYUPDATE_TEMP(t0, t1, &ks->data[20]);
231 KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC11); KEYUPDATE_TEMP(t0, t1, &ks->data[22]);
232 KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC12); KEYUPDATE_TEMP(t0, t1, &ks->data[24]);
233 KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC13); KEYUPDATE_TEMP(t0, t1, &ks->data[26]);
234 KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC14); KEYUPDATE_TEMP(t0, t1, &ks->data[28]);
235 KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC15); KEYUPDATE_TEMP(t0, t1, &ks->data[30]);
236#else
237 {
238 int i;
239 for (i=2; i<16; i+=2) {
240 KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC[i]);
241 KEYUPDATE_TEMP(t0, t1, &ks->data[i*2]);
242 KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC[i+1]);
243 KEYUPDATE_TEMP(t0, t1, &ks->data[i*2+2]);
244 }
245 }
246#endif
247}
248
249void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], unsigned char d[SEED_BLOCK_SIZE], const SEED_KEY_SCHEDULE *ks)
250{
251 seed_word x1, x2, x3, x4;
252 seed_word t0, t1;
253
254 char2word(s, x1);
255 char2word(s+4, x2);
256 char2word(s+8, x3);
257 char2word(s+12, x4);
258
259#if !defined(OPENSSL_SMALL_FOOTPRINT)
260 E_SEED(t0, t1, x1, x2, x3, x4, 0);
261 E_SEED(t0, t1, x3, x4, x1, x2, 2);
262 E_SEED(t0, t1, x1, x2, x3, x4, 4);
263 E_SEED(t0, t1, x3, x4, x1, x2, 6);
264 E_SEED(t0, t1, x1, x2, x3, x4, 8);
265 E_SEED(t0, t1, x3, x4, x1, x2, 10);
266 E_SEED(t0, t1, x1, x2, x3, x4, 12);
267 E_SEED(t0, t1, x3, x4, x1, x2, 14);
268 E_SEED(t0, t1, x1, x2, x3, x4, 16);
269 E_SEED(t0, t1, x3, x4, x1, x2, 18);
270 E_SEED(t0, t1, x1, x2, x3, x4, 20);
271 E_SEED(t0, t1, x3, x4, x1, x2, 22);
272 E_SEED(t0, t1, x1, x2, x3, x4, 24);
273 E_SEED(t0, t1, x3, x4, x1, x2, 26);
274 E_SEED(t0, t1, x1, x2, x3, x4, 28);
275 E_SEED(t0, t1, x3, x4, x1, x2, 30);
276#else
277 {
278 int i;
279 for (i=0;i<30;i+=4) {
280 E_SEED(t0,t1,x1,x2,x3,x4,i);
281 E_SEED(t0,t1,x3,x4,x1,x2,i+2);
282 }
283 }
284#endif
285
286 word2char(x3, d);
287 word2char(x4, d+4);
288 word2char(x1, d+8);
289 word2char(x2, d+12);
290}
291
292void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], unsigned char d[SEED_BLOCK_SIZE], const SEED_KEY_SCHEDULE *ks)
293{
294 seed_word x1, x2, x3, x4;
295 seed_word t0, t1;
296
297 char2word(s, x1);
298 char2word(s+4, x2);
299 char2word(s+8, x3);
300 char2word(s+12, x4);
301
302#if !defined(OPENSSL_SMALL_FOOTPRINT)
303 E_SEED(t0, t1, x1, x2, x3, x4, 30);
304 E_SEED(t0, t1, x3, x4, x1, x2, 28);
305 E_SEED(t0, t1, x1, x2, x3, x4, 26);
306 E_SEED(t0, t1, x3, x4, x1, x2, 24);
307 E_SEED(t0, t1, x1, x2, x3, x4, 22);
308 E_SEED(t0, t1, x3, x4, x1, x2, 20);
309 E_SEED(t0, t1, x1, x2, x3, x4, 18);
310 E_SEED(t0, t1, x3, x4, x1, x2, 16);
311 E_SEED(t0, t1, x1, x2, x3, x4, 14);
312 E_SEED(t0, t1, x3, x4, x1, x2, 12);
313 E_SEED(t0, t1, x1, x2, x3, x4, 10);
314 E_SEED(t0, t1, x3, x4, x1, x2, 8);
315 E_SEED(t0, t1, x1, x2, x3, x4, 6);
316 E_SEED(t0, t1, x3, x4, x1, x2, 4);
317 E_SEED(t0, t1, x1, x2, x3, x4, 2);
318 E_SEED(t0, t1, x3, x4, x1, x2, 0);
319#else
320 {
321 int i;
322 for (i=30; i>0; i-=4) {
323 E_SEED(t0, t1, x1, x2, x3, x4, i);
324 E_SEED(t0, t1, x3, x4, x1, x2, i-2);
325
326 }
327 }
328#endif
329
330 word2char(x3, d);
331 word2char(x4, d+4);
332 word2char(x1, d+8);
333 word2char(x2, d+12);
334}
335
336#endif /* OPENSSL_NO_SEED */
diff --git a/src/lib/libcrypto/seed/seed.h b/src/lib/libcrypto/seed/seed.h
new file mode 100644
index 0000000000..c50fdd3607
--- /dev/null
+++ b/src/lib/libcrypto/seed/seed.h
@@ -0,0 +1,139 @@
1/*
2 * Copyright (c) 2007 KISA(Korea Information Security Agency). 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. Neither the name of author nor the names of its contributors may
10 * be used to endorse or promote products derived from this software
11 * without specific prior written permission.
12 *
13 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 *
25 */
26/* ====================================================================
27 * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
28 *
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
31 * are met:
32 *
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 *
36 * 2. Redistributions in binary form must reproduce the above copyright
37 * notice, this list of conditions and the following disclaimer in
38 * the documentation and/or other materials provided with the
39 * distribution.
40 *
41 * 3. All advertising materials mentioning features or use of this
42 * software must display the following acknowledgment:
43 * "This product includes software developed by the OpenSSL Project
44 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
45 *
46 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
47 * endorse or promote products derived from this software without
48 * prior written permission. For written permission, please contact
49 * openssl-core@openssl.org.
50 *
51 * 5. Products derived from this software may not be called "OpenSSL"
52 * nor may "OpenSSL" appear in their names without prior written
53 * permission of the OpenSSL Project.
54 *
55 * 6. Redistributions of any form whatsoever must retain the following
56 * acknowledgment:
57 * "This product includes software developed by the OpenSSL Project
58 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
59 *
60 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
61 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
63 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
64 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
65 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
66 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
67 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
68 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
69 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
70 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
71 * OF THE POSSIBILITY OF SUCH DAMAGE.
72 * ====================================================================
73 *
74 * This product includes cryptographic software written by Eric Young
75 * (eay@cryptsoft.com). This product includes software written by Tim
76 * Hudson (tjh@cryptsoft.com).
77 *
78 */
79
80
81#ifndef HEADER_SEED_H
82#define HEADER_SEED_H
83
84#include <openssl/opensslconf.h>
85#include <openssl/e_os2.h>
86#include <openssl/crypto.h>
87
88#ifdef OPENSSL_NO_SEED
89#error SEED is disabled.
90#endif
91
92#ifdef AES_LONG /* look whether we need 'long' to get 32 bits */
93# ifndef SEED_LONG
94# define SEED_LONG 1
95# endif
96#endif
97
98#if !defined(NO_SYS_TYPES_H)
99# include <sys/types.h>
100#endif
101
102#define SEED_BLOCK_SIZE 16
103#define SEED_KEY_LENGTH 16
104
105
106#ifdef __cplusplus
107extern "C" {
108#endif
109
110
111typedef struct seed_key_st {
112#ifdef SEED_LONG
113 unsigned long data[32];
114#else
115 unsigned int data[32];
116#endif
117} SEED_KEY_SCHEDULE;
118
119#ifdef OPENSSL_FIPS
120void private_SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], SEED_KEY_SCHEDULE *ks);
121#endif
122void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], SEED_KEY_SCHEDULE *ks);
123
124void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], unsigned char d[SEED_BLOCK_SIZE], const SEED_KEY_SCHEDULE *ks);
125void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], unsigned char d[SEED_BLOCK_SIZE], const SEED_KEY_SCHEDULE *ks);
126
127void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out, const SEED_KEY_SCHEDULE *ks, int enc);
128void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out,
129 size_t len, const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int enc);
130void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,
131 size_t len, const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int *num, int enc);
132void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,
133 size_t len, const SEED_KEY_SCHEDULE *ks, unsigned char ivec[SEED_BLOCK_SIZE], int *num);
134
135#ifdef __cplusplus
136}
137#endif
138
139#endif /* HEADER_SEED_H */
diff --git a/src/lib/libcrypto/seed/seed_cbc.c b/src/lib/libcrypto/seed/seed_cbc.c
new file mode 100644
index 0000000000..6c3f9b527a
--- /dev/null
+++ b/src/lib/libcrypto/seed/seed_cbc.c
@@ -0,0 +1,63 @@
1/* crypto/seed/seed_cbc.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-2007 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 */
51
52#include <openssl/seed.h>
53#include <openssl/modes.h>
54
55void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out,
56 size_t len, const SEED_KEY_SCHEDULE *ks,
57 unsigned char ivec[SEED_BLOCK_SIZE], int enc)
58 {
59 if (enc)
60 CRYPTO_cbc128_encrypt(in,out,len,ks,ivec,(block128_f)SEED_encrypt);
61 else
62 CRYPTO_cbc128_decrypt(in,out,len,ks,ivec,(block128_f)SEED_decrypt);
63 }
diff --git a/src/lib/libcrypto/seed/seed_cfb.c b/src/lib/libcrypto/seed/seed_cfb.c
new file mode 100644
index 0000000000..694597dd06
--- /dev/null
+++ b/src/lib/libcrypto/seed/seed_cfb.c
@@ -0,0 +1,116 @@
1/* crypto/seed/seed_cfb.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-2007 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 */
51/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
52 * All rights reserved.
53 *
54 * This package is an SSL implementation written
55 * by Eric Young (eay@cryptsoft.com).
56 * The implementation was written so as to conform with Netscapes SSL.
57 *
58 * This library is free for commercial and non-commercial use as long as
59 * the following conditions are aheared to. The following conditions
60 * apply to all code found in this distribution, be it the RC4, RSA,
61 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
62 * included with this distribution is covered by the same copyright terms
63 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
64 *
65 * Copyright remains Eric Young's, and as such any Copyright notices in
66 * the code are not to be removed.
67 * If this package is used in a product, Eric Young should be given attribution
68 * as the author of the parts of the library used.
69 * This can be in the form of a textual message at program startup or
70 * in documentation (online or textual) provided with the package.
71 *
72 * Redistribution and use in source and binary forms, with or without
73 * modification, are permitted provided that the following conditions
74 * are met:
75 * 1. Redistributions of source code must retain the copyright
76 * notice, this list of conditions and the following disclaimer.
77 * 2. Redistributions in binary form must reproduce the above copyright
78 * notice, this list of conditions and the following disclaimer in the
79 * documentation and/or other materials provided with the distribution.
80 * 3. All advertising materials mentioning features or use of this software
81 * must display the following acknowledgement:
82 * "This product includes cryptographic software written by
83 * Eric Young (eay@cryptsoft.com)"
84 * The word 'cryptographic' can be left out if the rouines from the library
85 * being used are not cryptographic related :-).
86 * 4. If you include any Windows specific code (or a derivative thereof) from
87 * the apps directory (application code) you must include an acknowledgement:
88 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
89 *
90 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
91 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
92 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
93 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
94 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
95 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
96 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
97 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
98 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
99 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100 * SUCH DAMAGE.
101 *
102 * The licence and distribution terms for any publically available version or
103 * derivative of this code cannot be changed. i.e. this code cannot simply be
104 * copied and put under another distribution licence
105 * [including the GNU Public Licence.]
106 */
107
108#include <openssl/seed.h>
109#include <openssl/modes.h>
110
111void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out,
112 size_t len, const SEED_KEY_SCHEDULE *ks,
113 unsigned char ivec[SEED_BLOCK_SIZE], int *num, int enc)
114 {
115 CRYPTO_cfb128_encrypt(in,out,len,ks,ivec,num,enc,(block128_f)SEED_encrypt);
116 }
diff --git a/src/lib/libcrypto/seed/seed_ecb.c b/src/lib/libcrypto/seed/seed_ecb.c
new file mode 100644
index 0000000000..e63f5ae14e
--- /dev/null
+++ b/src/lib/libcrypto/seed/seed_ecb.c
@@ -0,0 +1,60 @@
1/* crypto/seed/seed_ecb.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 2007 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 */
51
52#include <openssl/seed.h>
53
54void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out, const SEED_KEY_SCHEDULE *ks, int enc)
55 {
56 if (enc)
57 SEED_encrypt(in, out, ks);
58 else
59 SEED_decrypt(in, out, ks);
60 }
diff --git a/src/lib/libcrypto/seed/seed_locl.h b/src/lib/libcrypto/seed/seed_locl.h
new file mode 100644
index 0000000000..fd456b6422
--- /dev/null
+++ b/src/lib/libcrypto/seed/seed_locl.h
@@ -0,0 +1,116 @@
1/*
2 * Copyright (c) 2007 KISA(Korea Information Security Agency). 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. Neither the name of author nor the names of its contributors may
10 * be used to endorse or promote products derived from this software
11 * without specific prior written permission.
12 *
13 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 *
25 */
26#ifndef HEADER_SEED_LOCL_H
27#define HEADER_SEED_LOCL_H
28
29#include "openssl/e_os2.h"
30#include <openssl/seed.h>
31
32
33#ifdef SEED_LONG /* need 32-bit type */
34typedef unsigned long seed_word;
35#else
36typedef unsigned int seed_word;
37#endif
38
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#define G_FUNC(v) \
45 SS[0][(unsigned char) (v) & 0xff] ^ SS[1][(unsigned char) ((v)>>8) & 0xff] ^ \
46 SS[2][(unsigned char)((v)>>16) & 0xff] ^ SS[3][(unsigned char)((v)>>24) & 0xff]
47
48#define char2word(c, i) \
49 (i) = ((((seed_word)(c)[0]) << 24) | (((seed_word)(c)[1]) << 16) | (((seed_word)(c)[2]) << 8) | ((seed_word)(c)[3]))
50
51#define word2char(l, c) \
52 *((c)+0) = (unsigned char)((l)>>24) & 0xff; \
53 *((c)+1) = (unsigned char)((l)>>16) & 0xff; \
54 *((c)+2) = (unsigned char)((l)>> 8) & 0xff; \
55 *((c)+3) = (unsigned char)((l)) & 0xff
56
57#define KEYSCHEDULE_UPDATE0(T0, T1, X1, X2, X3, X4, KC) \
58 (T0) = (X3); \
59 (X3) = (((X3)<<8) ^ ((X4)>>24)) & 0xffffffff; \
60 (X4) = (((X4)<<8) ^ ((T0)>>24)) & 0xffffffff; \
61 (T0) = ((X1) + (X3) - (KC)) & 0xffffffff; \
62 (T1) = ((X2) + (KC) - (X4)) & 0xffffffff
63
64#define KEYSCHEDULE_UPDATE1(T0, T1, X1, X2, X3, X4, KC) \
65 (T0) = (X1); \
66 (X1) = (((X1)>>8) ^ ((X2)<<24)) & 0xffffffff; \
67 (X2) = (((X2)>>8) ^ ((T0)<<24)) & 0xffffffff; \
68 (T0) = ((X1) + (X3) - (KC)) & 0xffffffff; \
69 (T1) = ((X2) + (KC) - (X4)) & 0xffffffff
70
71#define KEYUPDATE_TEMP(T0, T1, K) \
72 (K)[0] = G_FUNC((T0)); \
73 (K)[1] = G_FUNC((T1))
74
75#define XOR_SEEDBLOCK(DST, SRC) \
76 ((DST))[0] ^= ((SRC))[0]; \
77 ((DST))[1] ^= ((SRC))[1]; \
78 ((DST))[2] ^= ((SRC))[2]; \
79 ((DST))[3] ^= ((SRC))[3]
80
81#define MOV_SEEDBLOCK(DST, SRC) \
82 ((DST))[0] = ((SRC))[0]; \
83 ((DST))[1] = ((SRC))[1]; \
84 ((DST))[2] = ((SRC))[2]; \
85 ((DST))[3] = ((SRC))[3]
86
87# define CHAR2WORD(C, I) \
88 char2word((C), (I)[0]); \
89 char2word((C+4), (I)[1]); \
90 char2word((C+8), (I)[2]); \
91 char2word((C+12), (I)[3])
92
93# define WORD2CHAR(I, C) \
94 word2char((I)[0], (C)); \
95 word2char((I)[1], (C+4)); \
96 word2char((I)[2], (C+8)); \
97 word2char((I)[3], (C+12))
98
99# define E_SEED(T0, T1, X1, X2, X3, X4, rbase) \
100 (T0) = (X3) ^ (ks->data)[(rbase)]; \
101 (T1) = (X4) ^ (ks->data)[(rbase)+1]; \
102 (T1) ^= (T0); \
103 (T1) = G_FUNC((T1)); \
104 (T0) = ((T0) + (T1)) & 0xffffffff; \
105 (T0) = G_FUNC((T0)); \
106 (T1) = ((T1) + (T0)) & 0xffffffff; \
107 (T1) = G_FUNC((T1)); \
108 (T0) = ((T0) + (T1)) & 0xffffffff; \
109 (X1) ^= (T0); \
110 (X2) ^= (T1)
111
112#ifdef __cplusplus
113}
114#endif
115
116#endif /* HEADER_SEED_LOCL_H */
diff --git a/src/lib/libcrypto/asn1/p8_key.c b/src/lib/libcrypto/seed/seed_ofb.c
index 3a31248e14..3c8ba33bb9 100644
--- a/src/lib/libcrypto/asn1/p8_key.c
+++ b/src/lib/libcrypto/seed/seed_ofb.c
@@ -1,4 +1,53 @@
1/* crypto/asn1/p8_key.c */ 1/* crypto/seed/seed_ofb.c -*- mode:C; c-file-style: "eay" -*- */
2/* ====================================================================
3 * Copyright (c) 1998-2007 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 51/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 52 * All rights reserved.
4 * 53 *
@@ -56,76 +105,12 @@
56 * [including the GNU Public Licence.] 105 * [including the GNU Public Licence.]
57 */ 106 */
58 107
59#include <stdio.h> 108#include <openssl/seed.h>
60#include "cryptlib.h" 109#include <openssl/modes.h>
61#include <openssl/asn1_mac.h>
62#include <openssl/objects.h>
63 110
64int i2d_X509_KEY(X509 *a, unsigned char **pp) 111void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out,
112 size_t len, const SEED_KEY_SCHEDULE *ks,
113 unsigned char ivec[SEED_BLOCK_SIZE], int *num)
65 { 114 {
66 M_ASN1_I2D_vars(a); 115 CRYPTO_ofb128_encrypt(in,out,len,ks,ivec,num,(block128_f)SEED_encrypt);
67
68 M_ASN1_I2D_len(a->cert_info, i2d_X509_CINF);
69 M_ASN1_I2D_len(a->sig_alg, i2d_X509_ALGOR);
70 M_ASN1_I2D_len(a->signature, i2d_ASN1_BIT_STRING);
71
72 M_ASN1_I2D_seq_total();
73
74 M_ASN1_I2D_put(a->cert_info, i2d_X509_CINF);
75 M_ASN1_I2D_put(a->sig_alg, i2d_X509_ALGOR);
76 M_ASN1_I2D_put(a->signature, i2d_ASN1_BIT_STRING);
77
78 M_ASN1_I2D_finish();
79 }
80
81X509 *d2i_X509_KEY(X509 **a, unsigned char **pp, long length)
82 {
83 M_ASN1_D2I_vars(a,X509 *,X509_new);
84
85 M_ASN1_D2I_Init();
86 M_ASN1_D2I_start_sequence();
87 M_ASN1_D2I_get(ret->cert_info,d2i_X509_CINF);
88 M_ASN1_D2I_get(ret->sig_alg,d2i_X509_ALGOR);
89 M_ASN1_D2I_get(ret->signature,d2i_ASN1_BIT_STRING);
90 M_ASN1_D2I_Finish(a,X509_free,ASN1_F_D2I_X509);
91 }
92
93X509 *X509_KEY_new(void)
94 {
95 X509_KEY *ret=NULL;
96
97 M_ASN1_New_OPENSSL_malloc(ret,X509_KEY);
98 ret->references=1;
99 ret->type=NID
100 M_ASN1_New(ret->cert_info,X509_CINF_new);
101 M_ASN1_New(ret->sig_alg,X509_ALGOR_new);
102 M_ASN1_New(ret->signature,ASN1_BIT_STRING_new);
103 return(ret);
104 M_ASN1_New_Error(ASN1_F_X509_NEW);
105 }
106
107void X509_KEY_free(X509 *a)
108 {
109 int i;
110
111 if (a == NULL) return;
112
113 i=CRYPTO_add_lock(&a->references,-1,CRYPTO_LOCK_X509_KEY);
114#ifdef REF_PRINT
115 REF_PRINT("X509_KEY",a);
116#endif
117 if (i > 0) return;
118#ifdef REF_CHECK
119 if (i < 0)
120 {
121 fprintf(stderr,"X509_KEY_free, bad reference count\n");
122 abort();
123 }
124#endif
125
126 X509_CINF_free(a->cert_info);
127 X509_ALGOR_free(a->sig_alg);
128 ASN1_BIT_STRING_free(a->signature);
129 OPENSSL_free(a);
130 } 116 }
131
diff --git a/src/lib/libcrypto/sha/asm/sha512-sse2.pl b/src/lib/libcrypto/sha/asm/sha512-sse2.pl
deleted file mode 100644
index 10902bf673..0000000000
--- a/src/lib/libcrypto/sha/asm/sha512-sse2.pl
+++ /dev/null
@@ -1,404 +0,0 @@
1#!/usr/bin/env perl
2#
3# ====================================================================
4# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
5# project. Rights for redistribution and usage in source and binary
6# forms are granted according to the OpenSSL license.
7# ====================================================================
8#
9# SHA512_Transform_SSE2.
10#
11# As the name suggests, this is an IA-32 SSE2 implementation of
12# SHA512_Transform. Motivating factor for the undertaken effort was that
13# SHA512 was observed to *consistently* perform *significantly* poorer
14# than SHA256 [2x and slower is common] on 32-bit platforms. On 64-bit
15# platforms on the other hand SHA512 tend to outperform SHA256 [~50%
16# seem to be common improvement factor]. All this is perfectly natural,
17# as SHA512 is a 64-bit algorithm. But isn't IA-32 SSE2 essentially
18# a 64-bit instruction set? Is it rich enough to implement SHA512?
19# If answer was "no," then you wouldn't have been reading this...
20#
21# Throughput performance in MBps (larger is better):
22#
23# 2.4GHz P4 1.4GHz AMD32 1.4GHz AMD64(*)
24# SHA256/gcc(*) 54 43 59
25# SHA512/gcc 17 23 92
26# SHA512/sse2 61(**) 57(**)
27# SHA512/icc 26 28
28# SHA256/icc(*) 65 54
29#
30# (*) AMD64 and SHA256 numbers are presented mostly for amusement or
31# reference purposes.
32# (**) I.e. it gives ~2-3x speed-up if compared with compiler generated
33# code. One can argue that hand-coded *non*-SSE2 implementation
34# would perform better than compiler generated one as well, and
35# that comparison is therefore not exactly fair. Well, as SHA512
36# puts enormous pressure on IA-32 GP register bank, I reckon that
37# hand-coded version wouldn't perform significantly better than
38# one compiled with icc, ~20% perhaps... So that this code would
39# still outperform it with distinguishing marginal. But feel free
40# to prove me wrong:-)
41# <appro@fy.chalmers.se>
42push(@INC,"perlasm","../../perlasm");
43require "x86asm.pl";
44
45&asm_init($ARGV[0],"sha512-sse2.pl",$ARGV[$#ARGV] eq "386");
46
47$K512="esi"; # K512[80] table, found at the end...
48#$W512="esp"; # $W512 is not just W512[16]: it comprises *two* copies
49 # of W512[16] and a copy of A-H variables...
50$W512_SZ=8*(16+16+8); # see above...
51#$Kidx="ebx"; # index in K512 table, advances from 0 to 80...
52$Widx="edx"; # index in W512, wraps around at 16...
53$data="edi"; # 16 qwords of input data...
54$A="mm0"; # B-D and
55$E="mm1"; # F-H are allocated dynamically...
56$Aoff=256+0; # A-H offsets relative to $W512...
57$Boff=256+8;
58$Coff=256+16;
59$Doff=256+24;
60$Eoff=256+32;
61$Foff=256+40;
62$Goff=256+48;
63$Hoff=256+56;
64
65sub SHA2_ROUND()
66{ local ($kidx,$widx)=@_;
67
68 # One can argue that one could reorder instructions for better
69 # performance. Well, I tried and it doesn't seem to make any
70 # noticeable difference. Modern out-of-order execution cores
71 # reorder instructions to their liking in either case and they
72 # apparently do decent job. So we can keep the code more
73 # readable/regular/comprehensible:-)
74
75 # I adhere to 64-bit %mmX registers in order to avoid/not care
76 # about #GP exceptions on misaligned 128-bit access, most
77 # notably in paddq with memory operand. Not to mention that
78 # SSE2 intructions operating on %mmX can be scheduled every
79 # cycle [and not every second one if operating on %xmmN].
80
81 &movq ("mm4",&QWP($Foff,$W512)); # load f
82 &movq ("mm5",&QWP($Goff,$W512)); # load g
83 &movq ("mm6",&QWP($Hoff,$W512)); # load h
84
85 &movq ("mm2",$E); # %mm2 is sliding right
86 &movq ("mm3",$E); # %mm3 is sliding left
87 &psrlq ("mm2",14);
88 &psllq ("mm3",23);
89 &movq ("mm7","mm2"); # %mm7 is T1
90 &pxor ("mm7","mm3");
91 &psrlq ("mm2",4);
92 &psllq ("mm3",23);
93 &pxor ("mm7","mm2");
94 &pxor ("mm7","mm3");
95 &psrlq ("mm2",23);
96 &psllq ("mm3",4);
97 &pxor ("mm7","mm2");
98 &pxor ("mm7","mm3"); # T1=Sigma1_512(e)
99
100 &movq (&QWP($Foff,$W512),$E); # f = e
101 &movq (&QWP($Goff,$W512),"mm4"); # g = f
102 &movq (&QWP($Hoff,$W512),"mm5"); # h = g
103
104 &pxor ("mm4","mm5"); # f^=g
105 &pand ("mm4",$E); # f&=e
106 &pxor ("mm4","mm5"); # f^=g
107 &paddq ("mm7","mm4"); # T1+=Ch(e,f,g)
108
109 &movq ("mm2",&QWP($Boff,$W512)); # load b
110 &movq ("mm3",&QWP($Coff,$W512)); # load c
111 &movq ($E,&QWP($Doff,$W512)); # e = d
112
113 &paddq ("mm7","mm6"); # T1+=h
114 &paddq ("mm7",&QWP(0,$K512,$kidx,8)); # T1+=K512[i]
115 &paddq ("mm7",&QWP(0,$W512,$widx,8)); # T1+=W512[i]
116 &paddq ($E,"mm7"); # e += T1
117
118 &movq ("mm4",$A); # %mm4 is sliding right
119 &movq ("mm5",$A); # %mm5 is sliding left
120 &psrlq ("mm4",28);
121 &psllq ("mm5",25);
122 &movq ("mm6","mm4"); # %mm6 is T2
123 &pxor ("mm6","mm5");
124 &psrlq ("mm4",6);
125 &psllq ("mm5",5);
126 &pxor ("mm6","mm4");
127 &pxor ("mm6","mm5");
128 &psrlq ("mm4",5);
129 &psllq ("mm5",6);
130 &pxor ("mm6","mm4");
131 &pxor ("mm6","mm5"); # T2=Sigma0_512(a)
132
133 &movq (&QWP($Boff,$W512),$A); # b = a
134 &movq (&QWP($Coff,$W512),"mm2"); # c = b
135 &movq (&QWP($Doff,$W512),"mm3"); # d = c
136
137 &movq ("mm4",$A); # %mm4=a
138 &por ($A,"mm3"); # a=a|c
139 &pand ("mm4","mm3"); # %mm4=a&c
140 &pand ($A,"mm2"); # a=(a|c)&b
141 &por ("mm4",$A); # %mm4=(a&c)|((a|c)&b)
142 &paddq ("mm6","mm4"); # T2+=Maj(a,b,c)
143
144 &movq ($A,"mm7"); # a=T1
145 &paddq ($A,"mm6"); # a+=T2
146}
147
148$func="sha512_block_sse2";
149
150&function_begin_B($func);
151 if (0) {# Caller is expected to check if it's appropriate to
152 # call this routine. Below 3 lines are retained for
153 # debugging purposes...
154 &picmeup("eax","OPENSSL_ia32cap");
155 &bt (&DWP(0,"eax"),26);
156 &jnc ("SHA512_Transform");
157 }
158
159 &push ("ebp");
160 &mov ("ebp","esp");
161 &push ("ebx");
162 &push ("esi");
163 &push ("edi");
164
165 &mov ($Widx,&DWP(8,"ebp")); # A-H state, 1st arg
166 &mov ($data,&DWP(12,"ebp")); # input data, 2nd arg
167 &call (&label("pic_point")); # make it PIC!
168&set_label("pic_point");
169 &blindpop($K512);
170 &lea ($K512,&DWP(&label("K512")."-".&label("pic_point"),$K512));
171
172 $W512 = "esp"; # start using %esp as W512
173 &sub ($W512,$W512_SZ);
174 &and ($W512,-16); # ensure 128-bit alignment
175
176 # make private copy of A-H
177 # v assume the worst and stick to unaligned load
178 &movdqu ("xmm0",&QWP(0,$Widx));
179 &movdqu ("xmm1",&QWP(16,$Widx));
180 &movdqu ("xmm2",&QWP(32,$Widx));
181 &movdqu ("xmm3",&QWP(48,$Widx));
182
183&align(8);
184&set_label("_chunk_loop");
185
186 &movdqa (&QWP($Aoff,$W512),"xmm0"); # a,b
187 &movdqa (&QWP($Coff,$W512),"xmm1"); # c,d
188 &movdqa (&QWP($Eoff,$W512),"xmm2"); # e,f
189 &movdqa (&QWP($Goff,$W512),"xmm3"); # g,h
190
191 &xor ($Widx,$Widx);
192
193 &movdq2q($A,"xmm0"); # load a
194 &movdq2q($E,"xmm2"); # load e
195
196 # Why aren't loops unrolled? It makes sense to unroll if
197 # execution time for loop body is comparable with branch
198 # penalties and/or if whole data-set resides in register bank.
199 # Neither is case here... Well, it would be possible to
200 # eliminate few store operations, but it would hardly affect
201 # so to say stop-watch performance, as there is a lot of
202 # available memory slots to fill. It will only relieve some
203 # pressure off memory bus...
204
205 # flip input stream byte order...
206 &mov ("eax",&DWP(0,$data,$Widx,8));
207 &mov ("ebx",&DWP(4,$data,$Widx,8));
208 &bswap ("eax");
209 &bswap ("ebx");
210 &mov (&DWP(0,$W512,$Widx,8),"ebx"); # W512[i]
211 &mov (&DWP(4,$W512,$Widx,8),"eax");
212 &mov (&DWP(128+0,$W512,$Widx,8),"ebx"); # copy of W512[i]
213 &mov (&DWP(128+4,$W512,$Widx,8),"eax");
214
215&align(8);
216&set_label("_1st_loop"); # 0-15
217 # flip input stream byte order...
218 &mov ("eax",&DWP(0+8,$data,$Widx,8));
219 &mov ("ebx",&DWP(4+8,$data,$Widx,8));
220 &bswap ("eax");
221 &bswap ("ebx");
222 &mov (&DWP(0+8,$W512,$Widx,8),"ebx"); # W512[i]
223 &mov (&DWP(4+8,$W512,$Widx,8),"eax");
224 &mov (&DWP(128+0+8,$W512,$Widx,8),"ebx"); # copy of W512[i]
225 &mov (&DWP(128+4+8,$W512,$Widx,8),"eax");
226&set_label("_1st_looplet");
227 &SHA2_ROUND($Widx,$Widx); &inc($Widx);
228
229&cmp ($Widx,15)
230&jl (&label("_1st_loop"));
231&je (&label("_1st_looplet")); # playing similar trick on 2nd loop
232 # does not improve performance...
233
234 $Kidx = "ebx"; # start using %ebx as Kidx
235 &mov ($Kidx,$Widx);
236
237&align(8);
238&set_label("_2nd_loop"); # 16-79
239 &and($Widx,0xf);
240
241 # 128-bit fragment! I update W512[i] and W512[i+1] in
242 # parallel:-) Note that I refer to W512[(i&0xf)+N] and not to
243 # W512[(i+N)&0xf]! This is exactly what I maintain the second
244 # copy of W512[16] for...
245 &movdqu ("xmm0",&QWP(8*1,$W512,$Widx,8)); # s0=W512[i+1]
246 &movdqa ("xmm2","xmm0"); # %xmm2 is sliding right
247 &movdqa ("xmm3","xmm0"); # %xmm3 is sliding left
248 &psrlq ("xmm2",1);
249 &psllq ("xmm3",56);
250 &movdqa ("xmm0","xmm2");
251 &pxor ("xmm0","xmm3");
252 &psrlq ("xmm2",6);
253 &psllq ("xmm3",7);
254 &pxor ("xmm0","xmm2");
255 &pxor ("xmm0","xmm3");
256 &psrlq ("xmm2",1);
257 &pxor ("xmm0","xmm2"); # s0 = sigma0_512(s0);
258
259 &movdqa ("xmm1",&QWP(8*14,$W512,$Widx,8)); # s1=W512[i+14]
260 &movdqa ("xmm4","xmm1"); # %xmm4 is sliding right
261 &movdqa ("xmm5","xmm1"); # %xmm5 is sliding left
262 &psrlq ("xmm4",6);
263 &psllq ("xmm5",3);
264 &movdqa ("xmm1","xmm4");
265 &pxor ("xmm1","xmm5");
266 &psrlq ("xmm4",13);
267 &psllq ("xmm5",42);
268 &pxor ("xmm1","xmm4");
269 &pxor ("xmm1","xmm5");
270 &psrlq ("xmm4",42);
271 &pxor ("xmm1","xmm4"); # s1 = sigma1_512(s1);
272
273 # + have to explictly load W512[i+9] as it's not 128-bit
274 # v aligned and paddq would throw an exception...
275 &movdqu ("xmm6",&QWP(8*9,$W512,$Widx,8));
276 &paddq ("xmm0","xmm1"); # s0 += s1
277 &paddq ("xmm0","xmm6"); # s0 += W512[i+9]
278 &paddq ("xmm0",&QWP(0,$W512,$Widx,8)); # s0 += W512[i]
279
280 &movdqa (&QWP(0,$W512,$Widx,8),"xmm0"); # W512[i] = s0
281 &movdqa (&QWP(16*8,$W512,$Widx,8),"xmm0"); # copy of W512[i]
282
283 # as the above fragment was 128-bit, we "owe" 2 rounds...
284 &SHA2_ROUND($Kidx,$Widx); &inc($Kidx); &inc($Widx);
285 &SHA2_ROUND($Kidx,$Widx); &inc($Kidx); &inc($Widx);
286
287&cmp ($Kidx,80);
288&jl (&label("_2nd_loop"));
289
290 # update A-H state
291 &mov ($Widx,&DWP(8,"ebp")); # A-H state, 1st arg
292 &movq (&QWP($Aoff,$W512),$A); # write out a
293 &movq (&QWP($Eoff,$W512),$E); # write out e
294 &movdqu ("xmm0",&QWP(0,$Widx));
295 &movdqu ("xmm1",&QWP(16,$Widx));
296 &movdqu ("xmm2",&QWP(32,$Widx));
297 &movdqu ("xmm3",&QWP(48,$Widx));
298 &paddq ("xmm0",&QWP($Aoff,$W512)); # 128-bit additions...
299 &paddq ("xmm1",&QWP($Coff,$W512));
300 &paddq ("xmm2",&QWP($Eoff,$W512));
301 &paddq ("xmm3",&QWP($Goff,$W512));
302 &movdqu (&QWP(0,$Widx),"xmm0");
303 &movdqu (&QWP(16,$Widx),"xmm1");
304 &movdqu (&QWP(32,$Widx),"xmm2");
305 &movdqu (&QWP(48,$Widx),"xmm3");
306
307&add ($data,16*8); # advance input data pointer
308&dec (&DWP(16,"ebp")); # decrement 3rd arg
309&jnz (&label("_chunk_loop"));
310
311 # epilogue
312 &emms (); # required for at least ELF and Win32 ABIs
313 &mov ("edi",&DWP(-12,"ebp"));
314 &mov ("esi",&DWP(-8,"ebp"));
315 &mov ("ebx",&DWP(-4,"ebp"));
316 &leave ();
317&ret ();
318
319&align(64);
320&set_label("K512"); # Yes! I keep it in the code segment!
321 &data_word(0xd728ae22,0x428a2f98); # u64
322 &data_word(0x23ef65cd,0x71374491); # u64
323 &data_word(0xec4d3b2f,0xb5c0fbcf); # u64
324 &data_word(0x8189dbbc,0xe9b5dba5); # u64
325 &data_word(0xf348b538,0x3956c25b); # u64
326 &data_word(0xb605d019,0x59f111f1); # u64
327 &data_word(0xaf194f9b,0x923f82a4); # u64
328 &data_word(0xda6d8118,0xab1c5ed5); # u64
329 &data_word(0xa3030242,0xd807aa98); # u64
330 &data_word(0x45706fbe,0x12835b01); # u64
331 &data_word(0x4ee4b28c,0x243185be); # u64
332 &data_word(0xd5ffb4e2,0x550c7dc3); # u64
333 &data_word(0xf27b896f,0x72be5d74); # u64
334 &data_word(0x3b1696b1,0x80deb1fe); # u64
335 &data_word(0x25c71235,0x9bdc06a7); # u64
336 &data_word(0xcf692694,0xc19bf174); # u64
337 &data_word(0x9ef14ad2,0xe49b69c1); # u64
338 &data_word(0x384f25e3,0xefbe4786); # u64
339 &data_word(0x8b8cd5b5,0x0fc19dc6); # u64
340 &data_word(0x77ac9c65,0x240ca1cc); # u64
341 &data_word(0x592b0275,0x2de92c6f); # u64
342 &data_word(0x6ea6e483,0x4a7484aa); # u64
343 &data_word(0xbd41fbd4,0x5cb0a9dc); # u64
344 &data_word(0x831153b5,0x76f988da); # u64
345 &data_word(0xee66dfab,0x983e5152); # u64
346 &data_word(0x2db43210,0xa831c66d); # u64
347 &data_word(0x98fb213f,0xb00327c8); # u64
348 &data_word(0xbeef0ee4,0xbf597fc7); # u64
349 &data_word(0x3da88fc2,0xc6e00bf3); # u64
350 &data_word(0x930aa725,0xd5a79147); # u64
351 &data_word(0xe003826f,0x06ca6351); # u64
352 &data_word(0x0a0e6e70,0x14292967); # u64
353 &data_word(0x46d22ffc,0x27b70a85); # u64
354 &data_word(0x5c26c926,0x2e1b2138); # u64
355 &data_word(0x5ac42aed,0x4d2c6dfc); # u64
356 &data_word(0x9d95b3df,0x53380d13); # u64
357 &data_word(0x8baf63de,0x650a7354); # u64
358 &data_word(0x3c77b2a8,0x766a0abb); # u64
359 &data_word(0x47edaee6,0x81c2c92e); # u64
360 &data_word(0x1482353b,0x92722c85); # u64
361 &data_word(0x4cf10364,0xa2bfe8a1); # u64
362 &data_word(0xbc423001,0xa81a664b); # u64
363 &data_word(0xd0f89791,0xc24b8b70); # u64
364 &data_word(0x0654be30,0xc76c51a3); # u64
365 &data_word(0xd6ef5218,0xd192e819); # u64
366 &data_word(0x5565a910,0xd6990624); # u64
367 &data_word(0x5771202a,0xf40e3585); # u64
368 &data_word(0x32bbd1b8,0x106aa070); # u64
369 &data_word(0xb8d2d0c8,0x19a4c116); # u64
370 &data_word(0x5141ab53,0x1e376c08); # u64
371 &data_word(0xdf8eeb99,0x2748774c); # u64
372 &data_word(0xe19b48a8,0x34b0bcb5); # u64
373 &data_word(0xc5c95a63,0x391c0cb3); # u64
374 &data_word(0xe3418acb,0x4ed8aa4a); # u64
375 &data_word(0x7763e373,0x5b9cca4f); # u64
376 &data_word(0xd6b2b8a3,0x682e6ff3); # u64
377 &data_word(0x5defb2fc,0x748f82ee); # u64
378 &data_word(0x43172f60,0x78a5636f); # u64
379 &data_word(0xa1f0ab72,0x84c87814); # u64
380 &data_word(0x1a6439ec,0x8cc70208); # u64
381 &data_word(0x23631e28,0x90befffa); # u64
382 &data_word(0xde82bde9,0xa4506ceb); # u64
383 &data_word(0xb2c67915,0xbef9a3f7); # u64
384 &data_word(0xe372532b,0xc67178f2); # u64
385 &data_word(0xea26619c,0xca273ece); # u64
386 &data_word(0x21c0c207,0xd186b8c7); # u64
387 &data_word(0xcde0eb1e,0xeada7dd6); # u64
388 &data_word(0xee6ed178,0xf57d4f7f); # u64
389 &data_word(0x72176fba,0x06f067aa); # u64
390 &data_word(0xa2c898a6,0x0a637dc5); # u64
391 &data_word(0xbef90dae,0x113f9804); # u64
392 &data_word(0x131c471b,0x1b710b35); # u64
393 &data_word(0x23047d84,0x28db77f5); # u64
394 &data_word(0x40c72493,0x32caab7b); # u64
395 &data_word(0x15c9bebc,0x3c9ebe0a); # u64
396 &data_word(0x9c100d4c,0x431d67c4); # u64
397 &data_word(0xcb3e42b6,0x4cc5d4be); # u64
398 &data_word(0xfc657e2a,0x597f299c); # u64
399 &data_word(0x3ad6faec,0x5fcb6fab); # u64
400 &data_word(0x4a475817,0x6c44198c); # u64
401
402&function_end_B($func);
403
404&asm_finish();
diff --git a/src/lib/libcrypto/sha/sha1s.cpp b/src/lib/libcrypto/sha/sha1s.cpp
deleted file mode 100644
index af23d1e0f2..0000000000
--- a/src/lib/libcrypto/sha/sha1s.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
1//
2// gettsc.inl
3//
4// gives access to the Pentium's (secret) cycle counter
5//
6// This software was written by Leonard Janke (janke@unixg.ubc.ca)
7// in 1996-7 and is entered, by him, into the public domain.
8
9#if defined(__WATCOMC__)
10void GetTSC(unsigned long&);
11#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
12#elif defined(__GNUC__)
13inline
14void GetTSC(unsigned long& tsc)
15{
16 asm volatile(".byte 15, 49\n\t"
17 : "=eax" (tsc)
18 :
19 : "%edx", "%eax");
20}
21#elif defined(_MSC_VER)
22inline
23void GetTSC(unsigned long& tsc)
24{
25 unsigned long a;
26 __asm _emit 0fh
27 __asm _emit 31h
28 __asm mov a, eax;
29 tsc=a;
30}
31#endif
32
33#include <stdio.h>
34#include <stdlib.h>
35#include <openssl/sha.h>
36
37#define sha1_block_x86 sha1_block_asm_data_order
38extern "C" {
39void sha1_block_x86(SHA_CTX *ctx, unsigned char *buffer,int num);
40}
41
42void main(int argc,char *argv[])
43 {
44 unsigned char buffer[64*256];
45 SHA_CTX ctx;
46 unsigned long s1,s2,e1,e2;
47 unsigned char k[16];
48 unsigned long data[2];
49 unsigned char iv[8];
50 int i,num=0,numm;
51 int j=0;
52
53 if (argc >= 2)
54 num=atoi(argv[1]);
55
56 if (num == 0) num=16;
57 if (num > 250) num=16;
58 numm=num+2;
59#if 0
60 num*=64;
61 numm*=64;
62#endif
63
64 for (j=0; j<6; j++)
65 {
66 for (i=0; i<10; i++) /**/
67 {
68 sha1_block_x86(&ctx,buffer,numm);
69 GetTSC(s1);
70 sha1_block_x86(&ctx,buffer,numm);
71 GetTSC(e1);
72 GetTSC(s2);
73 sha1_block_x86(&ctx,buffer,num);
74 GetTSC(e2);
75 sha1_block_x86(&ctx,buffer,num);
76 }
77
78 printf("sha1 (%d bytes) %d %d (%.2f)\n",num*64,
79 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
80 }
81 }
82
diff --git a/src/lib/libcrypto/sha/sha256t.c b/src/lib/libcrypto/sha/sha256t.c
new file mode 100644
index 0000000000..6b4a3bd001
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha256t.c
@@ -0,0 +1,147 @@
1/* crypto/sha/sha256t.c */
2/* ====================================================================
3 * Copyright (c) 2004 The OpenSSL Project. All rights reserved.
4 * ====================================================================
5 */
6#include <stdio.h>
7#include <string.h>
8#include <stdlib.h>
9
10#include <openssl/sha.h>
11#include <openssl/evp.h>
12
13#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA256)
14int main(int argc, char *argv[])
15{
16 printf("No SHA256 support\n");
17 return(0);
18}
19#else
20
21unsigned char app_b1[SHA256_DIGEST_LENGTH] = {
22 0xba,0x78,0x16,0xbf,0x8f,0x01,0xcf,0xea,
23 0x41,0x41,0x40,0xde,0x5d,0xae,0x22,0x23,
24 0xb0,0x03,0x61,0xa3,0x96,0x17,0x7a,0x9c,
25 0xb4,0x10,0xff,0x61,0xf2,0x00,0x15,0xad };
26
27unsigned char app_b2[SHA256_DIGEST_LENGTH] = {
28 0x24,0x8d,0x6a,0x61,0xd2,0x06,0x38,0xb8,
29 0xe5,0xc0,0x26,0x93,0x0c,0x3e,0x60,0x39,
30 0xa3,0x3c,0xe4,0x59,0x64,0xff,0x21,0x67,
31 0xf6,0xec,0xed,0xd4,0x19,0xdb,0x06,0xc1 };
32
33unsigned char app_b3[SHA256_DIGEST_LENGTH] = {
34 0xcd,0xc7,0x6e,0x5c,0x99,0x14,0xfb,0x92,
35 0x81,0xa1,0xc7,0xe2,0x84,0xd7,0x3e,0x67,
36 0xf1,0x80,0x9a,0x48,0xa4,0x97,0x20,0x0e,
37 0x04,0x6d,0x39,0xcc,0xc7,0x11,0x2c,0xd0 };
38
39unsigned char addenum_1[SHA224_DIGEST_LENGTH] = {
40 0x23,0x09,0x7d,0x22,0x34,0x05,0xd8,0x22,
41 0x86,0x42,0xa4,0x77,0xbd,0xa2,0x55,0xb3,
42 0x2a,0xad,0xbc,0xe4,0xbd,0xa0,0xb3,0xf7,
43 0xe3,0x6c,0x9d,0xa7 };
44
45unsigned char addenum_2[SHA224_DIGEST_LENGTH] = {
46 0x75,0x38,0x8b,0x16,0x51,0x27,0x76,0xcc,
47 0x5d,0xba,0x5d,0xa1,0xfd,0x89,0x01,0x50,
48 0xb0,0xc6,0x45,0x5c,0xb4,0xf5,0x8b,0x19,
49 0x52,0x52,0x25,0x25 };
50
51unsigned char addenum_3[SHA224_DIGEST_LENGTH] = {
52 0x20,0x79,0x46,0x55,0x98,0x0c,0x91,0xd8,
53 0xbb,0xb4,0xc1,0xea,0x97,0x61,0x8a,0x4b,
54 0xf0,0x3f,0x42,0x58,0x19,0x48,0xb2,0xee,
55 0x4e,0xe7,0xad,0x67 };
56
57int main (int argc,char **argv)
58{ unsigned char md[SHA256_DIGEST_LENGTH];
59 int i;
60 EVP_MD_CTX evp;
61
62 fprintf(stdout,"Testing SHA-256 ");
63
64 EVP_Digest ("abc",3,md,NULL,EVP_sha256(),NULL);
65 if (memcmp(md,app_b1,sizeof(app_b1)))
66 { fflush(stdout);
67 fprintf(stderr,"\nTEST 1 of 3 failed.\n");
68 return 1;
69 }
70 else
71 fprintf(stdout,"."); fflush(stdout);
72
73 EVP_Digest ("abcdbcde""cdefdefg""efghfghi""ghijhijk"
74 "ijkljklm""klmnlmno""mnopnopq",56,md,NULL,EVP_sha256(),NULL);
75 if (memcmp(md,app_b2,sizeof(app_b2)))
76 { fflush(stdout);
77 fprintf(stderr,"\nTEST 2 of 3 failed.\n");
78 return 1;
79 }
80 else
81 fprintf(stdout,"."); fflush(stdout);
82
83 EVP_MD_CTX_init (&evp);
84 EVP_DigestInit_ex (&evp,EVP_sha256(),NULL);
85 for (i=0;i<1000000;i+=160)
86 EVP_DigestUpdate (&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
87 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
88 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
89 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
90 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
91 (1000000-i)<160?1000000-i:160);
92 EVP_DigestFinal_ex (&evp,md,NULL);
93 EVP_MD_CTX_cleanup (&evp);
94
95 if (memcmp(md,app_b3,sizeof(app_b3)))
96 { fflush(stdout);
97 fprintf(stderr,"\nTEST 3 of 3 failed.\n");
98 return 1;
99 }
100 else
101 fprintf(stdout,"."); fflush(stdout);
102
103 fprintf(stdout," passed.\n"); fflush(stdout);
104
105 fprintf(stdout,"Testing SHA-224 ");
106
107 EVP_Digest ("abc",3,md,NULL,EVP_sha224(),NULL);
108 if (memcmp(md,addenum_1,sizeof(addenum_1)))
109 { fflush(stdout);
110 fprintf(stderr,"\nTEST 1 of 3 failed.\n");
111 return 1;
112 }
113 else
114 fprintf(stdout,"."); fflush(stdout);
115
116 EVP_Digest ("abcdbcde""cdefdefg""efghfghi""ghijhijk"
117 "ijkljklm""klmnlmno""mnopnopq",56,md,NULL,EVP_sha224(),NULL);
118 if (memcmp(md,addenum_2,sizeof(addenum_2)))
119 { fflush(stdout);
120 fprintf(stderr,"\nTEST 2 of 3 failed.\n");
121 return 1;
122 }
123 else
124 fprintf(stdout,"."); fflush(stdout);
125
126 EVP_MD_CTX_init (&evp);
127 EVP_DigestInit_ex (&evp,EVP_sha224(),NULL);
128 for (i=0;i<1000000;i+=64)
129 EVP_DigestUpdate (&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
130 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
131 (1000000-i)<64?1000000-i:64);
132 EVP_DigestFinal_ex (&evp,md,NULL);
133 EVP_MD_CTX_cleanup (&evp);
134
135 if (memcmp(md,addenum_3,sizeof(addenum_3)))
136 { fflush(stdout);
137 fprintf(stderr,"\nTEST 3 of 3 failed.\n");
138 return 1;
139 }
140 else
141 fprintf(stdout,"."); fflush(stdout);
142
143 fprintf(stdout," passed.\n"); fflush(stdout);
144
145 return 0;
146}
147#endif
diff --git a/src/lib/libcrypto/sha/sha512t.c b/src/lib/libcrypto/sha/sha512t.c
new file mode 100644
index 0000000000..210041d435
--- /dev/null
+++ b/src/lib/libcrypto/sha/sha512t.c
@@ -0,0 +1,184 @@
1/* crypto/sha/sha512t.c */
2/* ====================================================================
3 * Copyright (c) 2004 The OpenSSL Project. All rights reserved.
4 * ====================================================================
5 */
6#include <stdio.h>
7#include <string.h>
8#include <stdlib.h>
9
10#include <openssl/sha.h>
11#include <openssl/evp.h>
12#include <openssl/crypto.h>
13
14#if defined(OPENSSL_NO_SHA) || defined(OPENSSL_NO_SHA512)
15int main(int argc, char *argv[])
16{
17 printf("No SHA512 support\n");
18 return(0);
19}
20#else
21
22unsigned char app_c1[SHA512_DIGEST_LENGTH] = {
23 0xdd,0xaf,0x35,0xa1,0x93,0x61,0x7a,0xba,
24 0xcc,0x41,0x73,0x49,0xae,0x20,0x41,0x31,
25 0x12,0xe6,0xfa,0x4e,0x89,0xa9,0x7e,0xa2,
26 0x0a,0x9e,0xee,0xe6,0x4b,0x55,0xd3,0x9a,
27 0x21,0x92,0x99,0x2a,0x27,0x4f,0xc1,0xa8,
28 0x36,0xba,0x3c,0x23,0xa3,0xfe,0xeb,0xbd,
29 0x45,0x4d,0x44,0x23,0x64,0x3c,0xe8,0x0e,
30 0x2a,0x9a,0xc9,0x4f,0xa5,0x4c,0xa4,0x9f };
31
32unsigned char app_c2[SHA512_DIGEST_LENGTH] = {
33 0x8e,0x95,0x9b,0x75,0xda,0xe3,0x13,0xda,
34 0x8c,0xf4,0xf7,0x28,0x14,0xfc,0x14,0x3f,
35 0x8f,0x77,0x79,0xc6,0xeb,0x9f,0x7f,0xa1,
36 0x72,0x99,0xae,0xad,0xb6,0x88,0x90,0x18,
37 0x50,0x1d,0x28,0x9e,0x49,0x00,0xf7,0xe4,
38 0x33,0x1b,0x99,0xde,0xc4,0xb5,0x43,0x3a,
39 0xc7,0xd3,0x29,0xee,0xb6,0xdd,0x26,0x54,
40 0x5e,0x96,0xe5,0x5b,0x87,0x4b,0xe9,0x09 };
41
42unsigned char app_c3[SHA512_DIGEST_LENGTH] = {
43 0xe7,0x18,0x48,0x3d,0x0c,0xe7,0x69,0x64,
44 0x4e,0x2e,0x42,0xc7,0xbc,0x15,0xb4,0x63,
45 0x8e,0x1f,0x98,0xb1,0x3b,0x20,0x44,0x28,
46 0x56,0x32,0xa8,0x03,0xaf,0xa9,0x73,0xeb,
47 0xde,0x0f,0xf2,0x44,0x87,0x7e,0xa6,0x0a,
48 0x4c,0xb0,0x43,0x2c,0xe5,0x77,0xc3,0x1b,
49 0xeb,0x00,0x9c,0x5c,0x2c,0x49,0xaa,0x2e,
50 0x4e,0xad,0xb2,0x17,0xad,0x8c,0xc0,0x9b };
51
52unsigned char app_d1[SHA384_DIGEST_LENGTH] = {
53 0xcb,0x00,0x75,0x3f,0x45,0xa3,0x5e,0x8b,
54 0xb5,0xa0,0x3d,0x69,0x9a,0xc6,0x50,0x07,
55 0x27,0x2c,0x32,0xab,0x0e,0xde,0xd1,0x63,
56 0x1a,0x8b,0x60,0x5a,0x43,0xff,0x5b,0xed,
57 0x80,0x86,0x07,0x2b,0xa1,0xe7,0xcc,0x23,
58 0x58,0xba,0xec,0xa1,0x34,0xc8,0x25,0xa7 };
59
60unsigned char app_d2[SHA384_DIGEST_LENGTH] = {
61 0x09,0x33,0x0c,0x33,0xf7,0x11,0x47,0xe8,
62 0x3d,0x19,0x2f,0xc7,0x82,0xcd,0x1b,0x47,
63 0x53,0x11,0x1b,0x17,0x3b,0x3b,0x05,0xd2,
64 0x2f,0xa0,0x80,0x86,0xe3,0xb0,0xf7,0x12,
65 0xfc,0xc7,0xc7,0x1a,0x55,0x7e,0x2d,0xb9,
66 0x66,0xc3,0xe9,0xfa,0x91,0x74,0x60,0x39 };
67
68unsigned char app_d3[SHA384_DIGEST_LENGTH] = {
69 0x9d,0x0e,0x18,0x09,0x71,0x64,0x74,0xcb,
70 0x08,0x6e,0x83,0x4e,0x31,0x0a,0x4a,0x1c,
71 0xed,0x14,0x9e,0x9c,0x00,0xf2,0x48,0x52,
72 0x79,0x72,0xce,0xc5,0x70,0x4c,0x2a,0x5b,
73 0x07,0xb8,0xb3,0xdc,0x38,0xec,0xc4,0xeb,
74 0xae,0x97,0xdd,0xd8,0x7f,0x3d,0x89,0x85 };
75
76int main (int argc,char **argv)
77{ unsigned char md[SHA512_DIGEST_LENGTH];
78 int i;
79 EVP_MD_CTX evp;
80
81#ifdef OPENSSL_IA32_SSE2
82 /* Alternative to this is to call OpenSSL_add_all_algorithms...
83 * The below code is retained exclusively for debugging purposes. */
84 { char *env;
85
86 if ((env=getenv("OPENSSL_ia32cap")))
87 OPENSSL_ia32cap = strtoul (env,NULL,0);
88 }
89#endif
90
91 fprintf(stdout,"Testing SHA-512 ");
92
93 EVP_Digest ("abc",3,md,NULL,EVP_sha512(),NULL);
94 if (memcmp(md,app_c1,sizeof(app_c1)))
95 { fflush(stdout);
96 fprintf(stderr,"\nTEST 1 of 3 failed.\n");
97 return 1;
98 }
99 else
100 fprintf(stdout,"."); fflush(stdout);
101
102 EVP_Digest ("abcdefgh""bcdefghi""cdefghij""defghijk"
103 "efghijkl""fghijklm""ghijklmn""hijklmno"
104 "ijklmnop""jklmnopq""klmnopqr""lmnopqrs"
105 "mnopqrst""nopqrstu",112,md,NULL,EVP_sha512(),NULL);
106 if (memcmp(md,app_c2,sizeof(app_c2)))
107 { fflush(stdout);
108 fprintf(stderr,"\nTEST 2 of 3 failed.\n");
109 return 1;
110 }
111 else
112 fprintf(stdout,"."); fflush(stdout);
113
114 EVP_MD_CTX_init (&evp);
115 EVP_DigestInit_ex (&evp,EVP_sha512(),NULL);
116 for (i=0;i<1000000;i+=288)
117 EVP_DigestUpdate (&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
118 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
119 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
120 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
121 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
122 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
123 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
124 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
125 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
126 (1000000-i)<288?1000000-i:288);
127 EVP_DigestFinal_ex (&evp,md,NULL);
128 EVP_MD_CTX_cleanup (&evp);
129
130 if (memcmp(md,app_c3,sizeof(app_c3)))
131 { fflush(stdout);
132 fprintf(stderr,"\nTEST 3 of 3 failed.\n");
133 return 1;
134 }
135 else
136 fprintf(stdout,"."); fflush(stdout);
137
138 fprintf(stdout," passed.\n"); fflush(stdout);
139
140 fprintf(stdout,"Testing SHA-384 ");
141
142 EVP_Digest ("abc",3,md,NULL,EVP_sha384(),NULL);
143 if (memcmp(md,app_d1,sizeof(app_d1)))
144 { fflush(stdout);
145 fprintf(stderr,"\nTEST 1 of 3 failed.\n");
146 return 1;
147 }
148 else
149 fprintf(stdout,"."); fflush(stdout);
150
151 EVP_Digest ("abcdefgh""bcdefghi""cdefghij""defghijk"
152 "efghijkl""fghijklm""ghijklmn""hijklmno"
153 "ijklmnop""jklmnopq""klmnopqr""lmnopqrs"
154 "mnopqrst""nopqrstu",112,md,NULL,EVP_sha384(),NULL);
155 if (memcmp(md,app_d2,sizeof(app_d2)))
156 { fflush(stdout);
157 fprintf(stderr,"\nTEST 2 of 3 failed.\n");
158 return 1;
159 }
160 else
161 fprintf(stdout,"."); fflush(stdout);
162
163 EVP_MD_CTX_init (&evp);
164 EVP_DigestInit_ex (&evp,EVP_sha384(),NULL);
165 for (i=0;i<1000000;i+=64)
166 EVP_DigestUpdate (&evp, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
167 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
168 (1000000-i)<64?1000000-i:64);
169 EVP_DigestFinal_ex (&evp,md,NULL);
170 EVP_MD_CTX_cleanup (&evp);
171
172 if (memcmp(md,app_d3,sizeof(app_d3)))
173 { fflush(stdout);
174 fprintf(stderr,"\nTEST 3 of 3 failed.\n");
175 return 1;
176 }
177 else
178 fprintf(stdout,"."); fflush(stdout);
179
180 fprintf(stdout," passed.\n"); fflush(stdout);
181
182 return 0;
183}
184#endif
diff --git a/src/lib/libcrypto/srp/Makefile b/src/lib/libcrypto/srp/Makefile
new file mode 100644
index 0000000000..41859d46fa
--- /dev/null
+++ b/src/lib/libcrypto/srp/Makefile
@@ -0,0 +1,98 @@
1DIR= srp
2TOP= ../..
3CC= cc
4INCLUDES= -I.. -I$(TOP) -I../../include
5CFLAG=-g
6INSTALL_PREFIX=
7OPENSSLDIR= /usr/local/ssl
8INSTALLTOP=/usr/local/ssl
9MAKE= make -f Makefile.ssl
10MAKEDEPPROG= makedepend
11MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
12MAKEFILE= Makefile.ssl
13AR= ar r
14
15CFLAGS= $(INCLUDES) $(CFLAG)
16
17GENERAL=Makefile
18TEST=srptest.c
19APPS=
20
21LIB=$(TOP)/libcrypto.a
22LIBSRC=srp_lib.c srp_vfy.c
23LIBOBJ=srp_lib.o srp_vfy.o
24
25SRC= $(LIBSRC)
26
27EXHEADER= srp.h
28HEADER= $(EXHEADER)
29
30top:
31 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
32
33all: lib
34
35lib: $(LIBOBJ)
36 $(AR) $(LIB) $(LIBOBJ)
37 $(RANLIB) $(LIB) || echo Never mind.
38 @touch lib
39
40links:
41 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
42 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
43 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
44
45install:
46 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
47 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
48 do \
49 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
50 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
51 done;
52
53tags:
54 ctags $(SRC)
55
56tests:
57
58srptest: top srptest.c $(LIB)
59 $(CC) $(CFLAGS) -Wall -Werror -g -o srptest srptest.c $(LIB)
60
61lint:
62 lint -DLINT $(INCLUDES) $(SRC)>fluff
63
64depend:
65 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
66
67dclean:
68 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
69 mv -f Makefile.new $(MAKEFILE)
70
71clean:
72 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
73
74# DO NOT DELETE THIS LINE -- make depend depends on it.
75
76srp_lib.o: ../../e_os.h ../../include/openssl/asn1.h
77srp_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
78srp_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
79srp_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
80srp_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
81srp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
82srp_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
83srp_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
84srp_lib.o: ../../include/openssl/sha.h ../../include/openssl/srp.h
85srp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
86srp_lib.o: ../cryptlib.h srp_grps.h srp_lcl.h srp_lib.c
87srp_vfy.o: ../../e_os.h ../../include/openssl/asn1.h
88srp_vfy.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
89srp_vfy.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
90srp_vfy.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
91srp_vfy.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
92srp_vfy.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
93srp_vfy.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
94srp_vfy.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
95srp_vfy.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
96srp_vfy.o: ../../include/openssl/srp.h ../../include/openssl/stack.h
97srp_vfy.o: ../../include/openssl/symhacks.h ../../include/openssl/txt_db.h
98srp_vfy.o: ../cryptlib.h srp_lcl.h srp_vfy.c
diff --git a/src/lib/libcrypto/srp/srp.h b/src/lib/libcrypto/srp/srp.h
new file mode 100644
index 0000000000..7ec7825cad
--- /dev/null
+++ b/src/lib/libcrypto/srp/srp.h
@@ -0,0 +1,172 @@
1/* crypto/srp/srp.h */
2/* Written by Christophe Renou (christophe.renou@edelweb.fr) with
3 * the precious help of Peter Sylvester (peter.sylvester@edelweb.fr)
4 * for the EdelKey project and contributed to the OpenSSL project 2004.
5 */
6/* ====================================================================
7 * Copyright (c) 2004 The OpenSSL Project. 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 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * licensing@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59#ifndef __SRP_H__
60#define __SRP_H__
61
62#ifndef OPENSSL_NO_SRP
63
64#include <stdio.h>
65#include <string.h>
66
67#ifdef __cplusplus
68extern "C" {
69#endif
70
71#include <openssl/safestack.h>
72#include <openssl/bn.h>
73#include <openssl/crypto.h>
74
75typedef struct SRP_gN_cache_st
76 {
77 char *b64_bn;
78 BIGNUM *bn;
79 } SRP_gN_cache;
80
81
82DECLARE_STACK_OF(SRP_gN_cache)
83
84typedef struct SRP_user_pwd_st
85 {
86 char *id;
87 BIGNUM *s;
88 BIGNUM *v;
89 const BIGNUM *g;
90 const BIGNUM *N;
91 char *info;
92 } SRP_user_pwd;
93
94DECLARE_STACK_OF(SRP_user_pwd)
95
96typedef struct SRP_VBASE_st
97 {
98 STACK_OF(SRP_user_pwd) *users_pwd;
99 STACK_OF(SRP_gN_cache) *gN_cache;
100/* to simulate a user */
101 char *seed_key;
102 BIGNUM *default_g;
103 BIGNUM *default_N;
104 } SRP_VBASE;
105
106
107/*Structure interne pour retenir les couples N et g*/
108typedef struct SRP_gN_st
109 {
110 char *id;
111 BIGNUM *g;
112 BIGNUM *N;
113 } SRP_gN;
114
115DECLARE_STACK_OF(SRP_gN)
116
117SRP_VBASE *SRP_VBASE_new(char *seed_key);
118int SRP_VBASE_free(SRP_VBASE *vb);
119int SRP_VBASE_init(SRP_VBASE *vb, char * verifier_file);
120SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username);
121char *SRP_create_verifier(const char *user, const char *pass, char **salt,
122 char **verifier, const char *N, const char *g);
123int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt, BIGNUM **verifier, BIGNUM *N, BIGNUM *g);
124
125
126#define SRP_NO_ERROR 0
127#define SRP_ERR_VBASE_INCOMPLETE_FILE 1
128#define SRP_ERR_VBASE_BN_LIB 2
129#define SRP_ERR_OPEN_FILE 3
130#define SRP_ERR_MEMORY 4
131
132#define DB_srptype 0
133#define DB_srpverifier 1
134#define DB_srpsalt 2
135#define DB_srpid 3
136#define DB_srpgN 4
137#define DB_srpinfo 5
138#undef DB_NUMBER
139#define DB_NUMBER 6
140
141#define DB_SRP_INDEX 'I'
142#define DB_SRP_VALID 'V'
143#define DB_SRP_REVOKED 'R'
144#define DB_SRP_MODIF 'v'
145
146
147/* see srp.c */
148char * SRP_check_known_gN_param(BIGNUM* g, BIGNUM* N);
149SRP_gN *SRP_get_default_gN(const char * id) ;
150
151/* server side .... */
152BIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b, BIGNUM *N);
153BIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v);
154int SRP_Verify_A_mod_N(BIGNUM *A, BIGNUM *N);
155BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N) ;
156
157
158
159/* client side .... */
160BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass);
161BIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g);
162BIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x, BIGNUM *a, BIGNUM *u);
163int SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N);
164
165#define SRP_MINIMAL_N 1024
166
167#ifdef __cplusplus
168}
169#endif
170
171#endif
172#endif
diff --git a/src/lib/libcrypto/srp/srp_grps.h b/src/lib/libcrypto/srp/srp_grps.h
new file mode 100644
index 0000000000..8e3c35e3f5
--- /dev/null
+++ b/src/lib/libcrypto/srp/srp_grps.h
@@ -0,0 +1,517 @@
1/* start of generated data */
2
3static BN_ULONG bn_group_1024_value[] = {
4 bn_pack4(0x9FC6,0x1D2F,0xC0EB,0x06E3),
5 bn_pack4(0xFD51,0x38FE,0x8376,0x435B),
6 bn_pack4(0x2FD4,0xCBF4,0x976E,0xAA9A),
7 bn_pack4(0x68ED,0xBC3C,0x0572,0x6CC0),
8 bn_pack4(0xC529,0xF566,0x660E,0x57EC),
9 bn_pack4(0x8255,0x9B29,0x7BCF,0x1885),
10 bn_pack4(0xCE8E,0xF4AD,0x69B1,0x5D49),
11 bn_pack4(0x5DC7,0xD7B4,0x6154,0xD6B6),
12 bn_pack4(0x8E49,0x5C1D,0x6089,0xDAD1),
13 bn_pack4(0xE0D5,0xD8E2,0x50B9,0x8BE4),
14 bn_pack4(0x383B,0x4813,0xD692,0xC6E0),
15 bn_pack4(0xD674,0xDF74,0x96EA,0x81D3),
16 bn_pack4(0x9EA2,0x314C,0x9C25,0x6576),
17 bn_pack4(0x6072,0x6187,0x75FF,0x3C0B),
18 bn_pack4(0x9C33,0xF80A,0xFA8F,0xC5E8),
19 bn_pack4(0xEEAF,0x0AB9,0xADB3,0x8DD6)
20};
21static BIGNUM bn_group_1024 = {
22 bn_group_1024_value,
23 (sizeof bn_group_1024_value)/sizeof(BN_ULONG),
24 (sizeof bn_group_1024_value)/sizeof(BN_ULONG),
25 0,
26 BN_FLG_STATIC_DATA
27};
28
29static BN_ULONG bn_group_1536_value[] = {
30 bn_pack4(0xCF76,0xE3FE,0xD135,0xF9BB),
31 bn_pack4(0x1518,0x0F93,0x499A,0x234D),
32 bn_pack4(0x8CE7,0xA28C,0x2442,0xC6F3),
33 bn_pack4(0x5A02,0x1FFF,0x5E91,0x479E),
34 bn_pack4(0x7F8A,0x2FE9,0xB8B5,0x292E),
35 bn_pack4(0x837C,0x264A,0xE3A9,0xBEB8),
36 bn_pack4(0xE442,0x734A,0xF7CC,0xB7AE),
37 bn_pack4(0x6577,0x2E43,0x7D6C,0x7F8C),
38 bn_pack4(0xDB2F,0xD53D,0x24B7,0xC486),
39 bn_pack4(0x6EDF,0x0195,0x3934,0x9627),
40 bn_pack4(0x158B,0xFD3E,0x2B9C,0x8CF5),
41 bn_pack4(0x764E,0x3F4B,0x53DD,0x9DA1),
42 bn_pack4(0x4754,0x8381,0xDBC5,0xB1FC),
43 bn_pack4(0x9B60,0x9E0B,0xE3BA,0xB63D),
44 bn_pack4(0x8134,0xB1C8,0xB979,0x8914),
45 bn_pack4(0xDF02,0x8A7C,0xEC67,0xF0D0),
46 bn_pack4(0x80B6,0x55BB,0x9A22,0xE8DC),
47 bn_pack4(0x1558,0x903B,0xA0D0,0xF843),
48 bn_pack4(0x51C6,0xA94B,0xE460,0x7A29),
49 bn_pack4(0x5F4F,0x5F55,0x6E27,0xCBDE),
50 bn_pack4(0xBEEE,0xA961,0x4B19,0xCC4D),
51 bn_pack4(0xDBA5,0x1DF4,0x99AC,0x4C80),
52 bn_pack4(0xB1F1,0x2A86,0x17A4,0x7BBB),
53 bn_pack4(0x9DEF,0x3CAF,0xB939,0x277A)
54};
55static BIGNUM bn_group_1536 = {
56 bn_group_1536_value,
57 (sizeof bn_group_1536_value)/sizeof(BN_ULONG),
58 (sizeof bn_group_1536_value)/sizeof(BN_ULONG),
59 0,
60 BN_FLG_STATIC_DATA
61};
62
63static BN_ULONG bn_group_2048_value[] = {
64 bn_pack4(0x0FA7,0x111F,0x9E4A,0xFF73),
65 bn_pack4(0x9B65,0xE372,0xFCD6,0x8EF2),
66 bn_pack4(0x35DE,0x236D,0x525F,0x5475),
67 bn_pack4(0x94B5,0xC803,0xD89F,0x7AE4),
68 bn_pack4(0x71AE,0x35F8,0xE9DB,0xFBB6),
69 bn_pack4(0x2A56,0x98F3,0xA8D0,0xC382),
70 bn_pack4(0x9CCC,0x041C,0x7BC3,0x08D8),
71 bn_pack4(0xAF87,0x4E73,0x03CE,0x5329),
72 bn_pack4(0x6160,0x2790,0x04E5,0x7AE6),
73 bn_pack4(0x032C,0xFBDB,0xF52F,0xB378),
74 bn_pack4(0x5EA7,0x7A27,0x75D2,0xECFA),
75 bn_pack4(0x5445,0x23B5,0x24B0,0xD57D),
76 bn_pack4(0x5B9D,0x32E6,0x88F8,0x7748),
77 bn_pack4(0xF1D2,0xB907,0x8717,0x461A),
78 bn_pack4(0x76BD,0x207A,0x436C,0x6481),
79 bn_pack4(0xCA97,0xB43A,0x23FB,0x8016),
80 bn_pack4(0x1D28,0x1E44,0x6B14,0x773B),
81 bn_pack4(0x7359,0xD041,0xD5C3,0x3EA7),
82 bn_pack4(0xA80D,0x740A,0xDBF4,0xFF74),
83 bn_pack4(0x55F9,0x7993,0xEC97,0x5EEA),
84 bn_pack4(0x2918,0xA996,0x2F0B,0x93B8),
85 bn_pack4(0x661A,0x05FB,0xD5FA,0xAAE8),
86 bn_pack4(0xCF60,0x9517,0x9A16,0x3AB3),
87 bn_pack4(0xE808,0x3969,0xEDB7,0x67B0),
88 bn_pack4(0xCD7F,0x48A9,0xDA04,0xFD50),
89 bn_pack4(0xD523,0x12AB,0x4B03,0x310D),
90 bn_pack4(0x8193,0xE075,0x7767,0xA13D),
91 bn_pack4(0xA373,0x29CB,0xB4A0,0x99ED),
92 bn_pack4(0xFC31,0x9294,0x3DB5,0x6050),
93 bn_pack4(0xAF72,0xB665,0x1987,0xEE07),
94 bn_pack4(0xF166,0xDE5E,0x1389,0x582F),
95 bn_pack4(0xAC6B,0xDB41,0x324A,0x9A9B)
96};
97static BIGNUM bn_group_2048 = {
98 bn_group_2048_value,
99 (sizeof bn_group_2048_value)/sizeof(BN_ULONG),
100 (sizeof bn_group_2048_value)/sizeof(BN_ULONG),
101 0,
102 BN_FLG_STATIC_DATA
103};
104
105static BN_ULONG bn_group_3072_value[] = {
106 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
107 bn_pack4(0x4B82,0xD120,0xA93A,0xD2CA),
108 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
109 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
110 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
111 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
112 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
113 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
114 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
115 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
116 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
117 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
118 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
119 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
120 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
121 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
122 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
123 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
124 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
125 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
126 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
127 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
128 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
129 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
130 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
131 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
132 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
133 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
134 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
135 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
136 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
137 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
138 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
139 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
140 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
141 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
142 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
143 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
144 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
145 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
146 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
147 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
148 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
149 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
150 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
151 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
152 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
153 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
154};
155static BIGNUM bn_group_3072 = {
156 bn_group_3072_value,
157 (sizeof bn_group_3072_value)/sizeof(BN_ULONG),
158 (sizeof bn_group_3072_value)/sizeof(BN_ULONG),
159 0,
160 BN_FLG_STATIC_DATA
161};
162
163static BN_ULONG bn_group_4096_value[] = {
164 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
165 bn_pack4(0x4DF4,0x35C9,0x3406,0x3199),
166 bn_pack4(0x86FF,0xB7DC,0x90A6,0xC08F),
167 bn_pack4(0x93B4,0xEA98,0x8D8F,0xDDC1),
168 bn_pack4(0xD006,0x9127,0xD5B0,0x5AA9),
169 bn_pack4(0xB81B,0xDD76,0x2170,0x481C),
170 bn_pack4(0x1F61,0x2970,0xCEE2,0xD7AF),
171 bn_pack4(0x233B,0xA186,0x515B,0xE7ED),
172 bn_pack4(0x99B2,0x964F,0xA090,0xC3A2),
173 bn_pack4(0x287C,0x5947,0x4E6B,0xC05D),
174 bn_pack4(0x2E8E,0xFC14,0x1FBE,0xCAA6),
175 bn_pack4(0xDBBB,0xC2DB,0x04DE,0x8EF9),
176 bn_pack4(0x2583,0xE9CA,0x2AD4,0x4CE8),
177 bn_pack4(0x1A94,0x6834,0xB615,0x0BDA),
178 bn_pack4(0x99C3,0x2718,0x6AF4,0xE23C),
179 bn_pack4(0x8871,0x9A10,0xBDBA,0x5B26),
180 bn_pack4(0x1A72,0x3C12,0xA787,0xE6D7),
181 bn_pack4(0x4B82,0xD120,0xA921,0x0801),
182 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
183 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
184 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
185 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
186 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
187 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
188 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
189 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
190 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
191 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
192 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
193 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
194 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
195 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
196 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
197 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
198 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
199 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
200 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
201 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
202 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
203 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
204 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
205 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
206 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
207 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
208 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
209 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
210 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
211 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
212 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
213 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
214 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
215 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
216 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
217 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
218 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
219 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
220 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
221 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
222 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
223 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
224 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
225 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
226 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
227 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
228};
229static BIGNUM bn_group_4096 = {
230 bn_group_4096_value,
231 (sizeof bn_group_4096_value)/sizeof(BN_ULONG),
232 (sizeof bn_group_4096_value)/sizeof(BN_ULONG),
233 0,
234 BN_FLG_STATIC_DATA
235};
236
237static BN_ULONG bn_group_6144_value[] = {
238 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
239 bn_pack4(0xE694,0xF91E,0x6DCC,0x4024),
240 bn_pack4(0x12BF,0x2D5B,0x0B74,0x74D6),
241 bn_pack4(0x043E,0x8F66,0x3F48,0x60EE),
242 bn_pack4(0x387F,0xE8D7,0x6E3C,0x0468),
243 bn_pack4(0xDA56,0xC9EC,0x2EF2,0x9632),
244 bn_pack4(0xEB19,0xCCB1,0xA313,0xD55C),
245 bn_pack4(0xF550,0xAA3D,0x8A1F,0xBFF0),
246 bn_pack4(0x06A1,0xD58B,0xB7C5,0xDA76),
247 bn_pack4(0xA797,0x15EE,0xF29B,0xE328),
248 bn_pack4(0x14CC,0x5ED2,0x0F80,0x37E0),
249 bn_pack4(0xCC8F,0x6D7E,0xBF48,0xE1D8),
250 bn_pack4(0x4BD4,0x07B2,0x2B41,0x54AA),
251 bn_pack4(0x0F1D,0x45B7,0xFF58,0x5AC5),
252 bn_pack4(0x23A9,0x7A7E,0x36CC,0x88BE),
253 bn_pack4(0x59E7,0xC97F,0xBEC7,0xE8F3),
254 bn_pack4(0xB5A8,0x4031,0x900B,0x1C9E),
255 bn_pack4(0xD55E,0x702F,0x4698,0x0C82),
256 bn_pack4(0xF482,0xD7CE,0x6E74,0xFEF6),
257 bn_pack4(0xF032,0xEA15,0xD172,0x1D03),
258 bn_pack4(0x5983,0xCA01,0xC64B,0x92EC),
259 bn_pack4(0x6FB8,0xF401,0x378C,0xD2BF),
260 bn_pack4(0x3320,0x5151,0x2BD7,0xAF42),
261 bn_pack4(0xDB7F,0x1447,0xE6CC,0x254B),
262 bn_pack4(0x44CE,0x6CBA,0xCED4,0xBB1B),
263 bn_pack4(0xDA3E,0xDBEB,0xCF9B,0x14ED),
264 bn_pack4(0x1797,0x27B0,0x865A,0x8918),
265 bn_pack4(0xB06A,0x53ED,0x9027,0xD831),
266 bn_pack4(0xE5DB,0x382F,0x4130,0x01AE),
267 bn_pack4(0xF8FF,0x9406,0xAD9E,0x530E),
268 bn_pack4(0xC975,0x1E76,0x3DBA,0x37BD),
269 bn_pack4(0xC1D4,0xDCB2,0x6026,0x46DE),
270 bn_pack4(0x36C3,0xFAB4,0xD27C,0x7026),
271 bn_pack4(0x4DF4,0x35C9,0x3402,0x8492),
272 bn_pack4(0x86FF,0xB7DC,0x90A6,0xC08F),
273 bn_pack4(0x93B4,0xEA98,0x8D8F,0xDDC1),
274 bn_pack4(0xD006,0x9127,0xD5B0,0x5AA9),
275 bn_pack4(0xB81B,0xDD76,0x2170,0x481C),
276 bn_pack4(0x1F61,0x2970,0xCEE2,0xD7AF),
277 bn_pack4(0x233B,0xA186,0x515B,0xE7ED),
278 bn_pack4(0x99B2,0x964F,0xA090,0xC3A2),
279 bn_pack4(0x287C,0x5947,0x4E6B,0xC05D),
280 bn_pack4(0x2E8E,0xFC14,0x1FBE,0xCAA6),
281 bn_pack4(0xDBBB,0xC2DB,0x04DE,0x8EF9),
282 bn_pack4(0x2583,0xE9CA,0x2AD4,0x4CE8),
283 bn_pack4(0x1A94,0x6834,0xB615,0x0BDA),
284 bn_pack4(0x99C3,0x2718,0x6AF4,0xE23C),
285 bn_pack4(0x8871,0x9A10,0xBDBA,0x5B26),
286 bn_pack4(0x1A72,0x3C12,0xA787,0xE6D7),
287 bn_pack4(0x4B82,0xD120,0xA921,0x0801),
288 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
289 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
290 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
291 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
292 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
293 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
294 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
295 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
296 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
297 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
298 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
299 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
300 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
301 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
302 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
303 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
304 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
305 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
306 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
307 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
308 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
309 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
310 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
311 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
312 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
313 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
314 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
315 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
316 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
317 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
318 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
319 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
320 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
321 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
322 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
323 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
324 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
325 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
326 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
327 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
328 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
329 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
330 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
331 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
332 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
333 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
334};
335static BIGNUM bn_group_6144 = {
336 bn_group_6144_value,
337 (sizeof bn_group_6144_value)/sizeof(BN_ULONG),
338 (sizeof bn_group_6144_value)/sizeof(BN_ULONG),
339 0,
340 BN_FLG_STATIC_DATA
341};
342
343static BN_ULONG bn_group_8192_value[] = {
344 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF),
345 bn_pack4(0x60C9,0x80DD,0x98ED,0xD3DF),
346 bn_pack4(0xC81F,0x56E8,0x80B9,0x6E71),
347 bn_pack4(0x9E30,0x50E2,0x7656,0x94DF),
348 bn_pack4(0x9558,0xE447,0x5677,0xE9AA),
349 bn_pack4(0xC919,0x0DA6,0xFC02,0x6E47),
350 bn_pack4(0x889A,0x002E,0xD5EE,0x382B),
351 bn_pack4(0x4009,0x438B,0x481C,0x6CD7),
352 bn_pack4(0x3590,0x46F4,0xEB87,0x9F92),
353 bn_pack4(0xFAF3,0x6BC3,0x1ECF,0xA268),
354 bn_pack4(0xB1D5,0x10BD,0x7EE7,0x4D73),
355 bn_pack4(0xF9AB,0x4819,0x5DED,0x7EA1),
356 bn_pack4(0x64F3,0x1CC5,0x0846,0x851D),
357 bn_pack4(0x4597,0xE899,0xA025,0x5DC1),
358 bn_pack4(0xDF31,0x0EE0,0x74AB,0x6A36),
359 bn_pack4(0x6D2A,0x13F8,0x3F44,0xF82D),
360 bn_pack4(0x062B,0x3CF5,0xB3A2,0x78A6),
361 bn_pack4(0x7968,0x3303,0xED5B,0xDD3A),
362 bn_pack4(0xFA9D,0x4B7F,0xA2C0,0x87E8),
363 bn_pack4(0x4BCB,0xC886,0x2F83,0x85DD),
364 bn_pack4(0x3473,0xFC64,0x6CEA,0x306B),
365 bn_pack4(0x13EB,0x57A8,0x1A23,0xF0C7),
366 bn_pack4(0x2222,0x2E04,0xA403,0x7C07),
367 bn_pack4(0xE3FD,0xB8BE,0xFC84,0x8AD9),
368 bn_pack4(0x238F,0x16CB,0xE39D,0x652D),
369 bn_pack4(0x3423,0xB474,0x2BF1,0xC978),
370 bn_pack4(0x3AAB,0x639C,0x5AE4,0xF568),
371 bn_pack4(0x2576,0xF693,0x6BA4,0x2466),
372 bn_pack4(0x741F,0xA7BF,0x8AFC,0x47ED),
373 bn_pack4(0x3BC8,0x32B6,0x8D9D,0xD300),
374 bn_pack4(0xD8BE,0xC4D0,0x73B9,0x31BA),
375 bn_pack4(0x3877,0x7CB6,0xA932,0xDF8C),
376 bn_pack4(0x74A3,0x926F,0x12FE,0xE5E4),
377 bn_pack4(0xE694,0xF91E,0x6DBE,0x1159),
378 bn_pack4(0x12BF,0x2D5B,0x0B74,0x74D6),
379 bn_pack4(0x043E,0x8F66,0x3F48,0x60EE),
380 bn_pack4(0x387F,0xE8D7,0x6E3C,0x0468),
381 bn_pack4(0xDA56,0xC9EC,0x2EF2,0x9632),
382 bn_pack4(0xEB19,0xCCB1,0xA313,0xD55C),
383 bn_pack4(0xF550,0xAA3D,0x8A1F,0xBFF0),
384 bn_pack4(0x06A1,0xD58B,0xB7C5,0xDA76),
385 bn_pack4(0xA797,0x15EE,0xF29B,0xE328),
386 bn_pack4(0x14CC,0x5ED2,0x0F80,0x37E0),
387 bn_pack4(0xCC8F,0x6D7E,0xBF48,0xE1D8),
388 bn_pack4(0x4BD4,0x07B2,0x2B41,0x54AA),
389 bn_pack4(0x0F1D,0x45B7,0xFF58,0x5AC5),
390 bn_pack4(0x23A9,0x7A7E,0x36CC,0x88BE),
391 bn_pack4(0x59E7,0xC97F,0xBEC7,0xE8F3),
392 bn_pack4(0xB5A8,0x4031,0x900B,0x1C9E),
393 bn_pack4(0xD55E,0x702F,0x4698,0x0C82),
394 bn_pack4(0xF482,0xD7CE,0x6E74,0xFEF6),
395 bn_pack4(0xF032,0xEA15,0xD172,0x1D03),
396 bn_pack4(0x5983,0xCA01,0xC64B,0x92EC),
397 bn_pack4(0x6FB8,0xF401,0x378C,0xD2BF),
398 bn_pack4(0x3320,0x5151,0x2BD7,0xAF42),
399 bn_pack4(0xDB7F,0x1447,0xE6CC,0x254B),
400 bn_pack4(0x44CE,0x6CBA,0xCED4,0xBB1B),
401 bn_pack4(0xDA3E,0xDBEB,0xCF9B,0x14ED),
402 bn_pack4(0x1797,0x27B0,0x865A,0x8918),
403 bn_pack4(0xB06A,0x53ED,0x9027,0xD831),
404 bn_pack4(0xE5DB,0x382F,0x4130,0x01AE),
405 bn_pack4(0xF8FF,0x9406,0xAD9E,0x530E),
406 bn_pack4(0xC975,0x1E76,0x3DBA,0x37BD),
407 bn_pack4(0xC1D4,0xDCB2,0x6026,0x46DE),
408 bn_pack4(0x36C3,0xFAB4,0xD27C,0x7026),
409 bn_pack4(0x4DF4,0x35C9,0x3402,0x8492),
410 bn_pack4(0x86FF,0xB7DC,0x90A6,0xC08F),
411 bn_pack4(0x93B4,0xEA98,0x8D8F,0xDDC1),
412 bn_pack4(0xD006,0x9127,0xD5B0,0x5AA9),
413 bn_pack4(0xB81B,0xDD76,0x2170,0x481C),
414 bn_pack4(0x1F61,0x2970,0xCEE2,0xD7AF),
415 bn_pack4(0x233B,0xA186,0x515B,0xE7ED),
416 bn_pack4(0x99B2,0x964F,0xA090,0xC3A2),
417 bn_pack4(0x287C,0x5947,0x4E6B,0xC05D),
418 bn_pack4(0x2E8E,0xFC14,0x1FBE,0xCAA6),
419 bn_pack4(0xDBBB,0xC2DB,0x04DE,0x8EF9),
420 bn_pack4(0x2583,0xE9CA,0x2AD4,0x4CE8),
421 bn_pack4(0x1A94,0x6834,0xB615,0x0BDA),
422 bn_pack4(0x99C3,0x2718,0x6AF4,0xE23C),
423 bn_pack4(0x8871,0x9A10,0xBDBA,0x5B26),
424 bn_pack4(0x1A72,0x3C12,0xA787,0xE6D7),
425 bn_pack4(0x4B82,0xD120,0xA921,0x0801),
426 bn_pack4(0x43DB,0x5BFC,0xE0FD,0x108E),
427 bn_pack4(0x08E2,0x4FA0,0x74E5,0xAB31),
428 bn_pack4(0x7709,0x88C0,0xBAD9,0x46E2),
429 bn_pack4(0xBBE1,0x1757,0x7A61,0x5D6C),
430 bn_pack4(0x521F,0x2B18,0x177B,0x200C),
431 bn_pack4(0xD876,0x0273,0x3EC8,0x6A64),
432 bn_pack4(0xF12F,0xFA06,0xD98A,0x0864),
433 bn_pack4(0xCEE3,0xD226,0x1AD2,0xEE6B),
434 bn_pack4(0x1E8C,0x94E0,0x4A25,0x619D),
435 bn_pack4(0xABF5,0xAE8C,0xDB09,0x33D7),
436 bn_pack4(0xB397,0x0F85,0xA6E1,0xE4C7),
437 bn_pack4(0x8AEA,0x7157,0x5D06,0x0C7D),
438 bn_pack4(0xECFB,0x8504,0x58DB,0xEF0A),
439 bn_pack4(0xA855,0x21AB,0xDF1C,0xBA64),
440 bn_pack4(0xAD33,0x170D,0x0450,0x7A33),
441 bn_pack4(0x1572,0x8E5A,0x8AAA,0xC42D),
442 bn_pack4(0x15D2,0x2618,0x98FA,0x0510),
443 bn_pack4(0x3995,0x497C,0xEA95,0x6AE5),
444 bn_pack4(0xDE2B,0xCBF6,0x9558,0x1718),
445 bn_pack4(0xB5C5,0x5DF0,0x6F4C,0x52C9),
446 bn_pack4(0x9B27,0x83A2,0xEC07,0xA28F),
447 bn_pack4(0xE39E,0x772C,0x180E,0x8603),
448 bn_pack4(0x3290,0x5E46,0x2E36,0xCE3B),
449 bn_pack4(0xF174,0x6C08,0xCA18,0x217C),
450 bn_pack4(0x670C,0x354E,0x4ABC,0x9804),
451 bn_pack4(0x9ED5,0x2907,0x7096,0x966D),
452 bn_pack4(0x1C62,0xF356,0x2085,0x52BB),
453 bn_pack4(0x8365,0x5D23,0xDCA3,0xAD96),
454 bn_pack4(0x6916,0x3FA8,0xFD24,0xCF5F),
455 bn_pack4(0x98DA,0x4836,0x1C55,0xD39A),
456 bn_pack4(0xC200,0x7CB8,0xA163,0xBF05),
457 bn_pack4(0x4928,0x6651,0xECE4,0x5B3D),
458 bn_pack4(0xAE9F,0x2411,0x7C4B,0x1FE6),
459 bn_pack4(0xEE38,0x6BFB,0x5A89,0x9FA5),
460 bn_pack4(0x0BFF,0x5CB6,0xF406,0xB7ED),
461 bn_pack4(0xF44C,0x42E9,0xA637,0xED6B),
462 bn_pack4(0xE485,0xB576,0x625E,0x7EC6),
463 bn_pack4(0x4FE1,0x356D,0x6D51,0xC245),
464 bn_pack4(0x302B,0x0A6D,0xF25F,0x1437),
465 bn_pack4(0xEF95,0x19B3,0xCD3A,0x431B),
466 bn_pack4(0x514A,0x0879,0x8E34,0x04DD),
467 bn_pack4(0x020B,0xBEA6,0x3B13,0x9B22),
468 bn_pack4(0x2902,0x4E08,0x8A67,0xCC74),
469 bn_pack4(0xC4C6,0x628B,0x80DC,0x1CD1),
470 bn_pack4(0xC90F,0xDAA2,0x2168,0xC234),
471 bn_pack4(0xFFFF,0xFFFF,0xFFFF,0xFFFF)
472};
473static BIGNUM bn_group_8192 = {
474 bn_group_8192_value,
475 (sizeof bn_group_8192_value)/sizeof(BN_ULONG),
476 (sizeof bn_group_8192_value)/sizeof(BN_ULONG),
477 0,
478 BN_FLG_STATIC_DATA
479};
480
481static BN_ULONG bn_generator_19_value[] = {19} ;
482static BIGNUM bn_generator_19 = {
483 bn_generator_19_value,
484 1,
485 1,
486 0,
487 BN_FLG_STATIC_DATA
488};
489static BN_ULONG bn_generator_5_value[] = {5} ;
490static BIGNUM bn_generator_5 = {
491 bn_generator_5_value,
492 1,
493 1,
494 0,
495 BN_FLG_STATIC_DATA
496};
497static BN_ULONG bn_generator_2_value[] = {2} ;
498static BIGNUM bn_generator_2 = {
499 bn_generator_2_value,
500 1,
501 1,
502 0,
503 BN_FLG_STATIC_DATA
504};
505
506static SRP_gN knowngN[] = {
507 {"8192",&bn_generator_19 , &bn_group_8192},
508 {"6144",&bn_generator_5 , &bn_group_6144},
509 {"4096",&bn_generator_5 , &bn_group_4096},
510 {"3072",&bn_generator_5 , &bn_group_3072},
511 {"2048",&bn_generator_2 , &bn_group_2048},
512 {"1536",&bn_generator_2 , &bn_group_1536},
513 {"1024",&bn_generator_2 , &bn_group_1024},
514};
515#define KNOWN_GN_NUMBER sizeof(knowngN) / sizeof(SRP_gN)
516
517/* end of generated data */
diff --git a/src/lib/libcrypto/srp/srp_lcl.h b/src/lib/libcrypto/srp/srp_lcl.h
new file mode 100644
index 0000000000..42bda3f148
--- /dev/null
+++ b/src/lib/libcrypto/srp/srp_lcl.h
@@ -0,0 +1,83 @@
1/* crypto/srp/srp_lcl.h */
2/* Written by Peter Sylvester (peter.sylvester@edelweb.fr)
3 * for the EdelKey project and contributed to the OpenSSL project 2004.
4 */
5/* ====================================================================
6 * Copyright (c) 2004 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58#ifndef HEADER_SRP_LCL_H
59#define HEADER_SRP_LCL_H
60
61#include <openssl/srp.h>
62#include <openssl/sha.h>
63
64#if 0
65#define srp_bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \
66 fprintf(stderr,"\n");}
67#else
68#define srp_bn_print(a)
69#endif
70
71
72
73#ifdef __cplusplus
74extern "C" {
75#endif
76
77
78
79#ifdef __cplusplus
80}
81#endif
82
83#endif
diff --git a/src/lib/libcrypto/srp/srp_lib.c b/src/lib/libcrypto/srp/srp_lib.c
new file mode 100644
index 0000000000..7c1dcc5111
--- /dev/null
+++ b/src/lib/libcrypto/srp/srp_lib.c
@@ -0,0 +1,361 @@
1/* crypto/srp/srp_lib.c */
2/* Written by Christophe Renou (christophe.renou@edelweb.fr) with
3 * the precious help of Peter Sylvester (peter.sylvester@edelweb.fr)
4 * for the EdelKey project and contributed to the OpenSSL project 2004.
5 */
6/* ====================================================================
7 * Copyright (c) 2004 The OpenSSL Project. 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 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * licensing@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59#ifndef OPENSSL_NO_SRP
60#include "cryptlib.h"
61#include "srp_lcl.h"
62#include <openssl/srp.h>
63#include <openssl/evp.h>
64
65#if (BN_BYTES == 8)
66# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
67# define bn_pack4(a1,a2,a3,a4) ((a1##UI64<<48)|(a2##UI64<<32)|(a3##UI64<<16)|a4##UI64)
68# elif defined(__arch64__)
69# define bn_pack4(a1,a2,a3,a4) ((a1##UL<<48)|(a2##UL<<32)|(a3##UL<<16)|a4##UL)
70# else
71# define bn_pack4(a1,a2,a3,a4) ((a1##ULL<<48)|(a2##ULL<<32)|(a3##ULL<<16)|a4##ULL)
72# endif
73#elif (BN_BYTES == 4)
74# define bn_pack4(a1,a2,a3,a4) ((a3##UL<<16)|a4##UL), ((a1##UL<<16)|a2##UL)
75#else
76# error "unsupported BN_BYTES"
77#endif
78
79
80#include "srp_grps.h"
81
82static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
83 {
84 /* k = SHA1(N | PAD(g)) -- tls-srp draft 8 */
85
86 unsigned char digest[SHA_DIGEST_LENGTH];
87 unsigned char *tmp;
88 EVP_MD_CTX ctxt;
89 int longg ;
90 int longN = BN_num_bytes(N);
91
92 if ((tmp = OPENSSL_malloc(longN)) == NULL)
93 return NULL;
94 BN_bn2bin(N,tmp) ;
95
96 EVP_MD_CTX_init(&ctxt);
97 EVP_DigestInit_ex(&ctxt, EVP_sha1(), NULL);
98 EVP_DigestUpdate(&ctxt, tmp, longN);
99
100 memset(tmp, 0, longN);
101 longg = BN_bn2bin(g,tmp) ;
102 /* use the zeros behind to pad on left */
103 EVP_DigestUpdate(&ctxt, tmp + longg, longN-longg);
104 EVP_DigestUpdate(&ctxt, tmp, longg);
105 OPENSSL_free(tmp);
106
107 EVP_DigestFinal_ex(&ctxt, digest, NULL);
108 EVP_MD_CTX_cleanup(&ctxt);
109 return BN_bin2bn(digest, sizeof(digest), NULL);
110 }
111
112BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
113 {
114 /* k = SHA1(PAD(A) || PAD(B) ) -- tls-srp draft 8 */
115
116 BIGNUM *u;
117 unsigned char cu[SHA_DIGEST_LENGTH];
118 unsigned char *cAB;
119 EVP_MD_CTX ctxt;
120 int longN;
121 if ((A == NULL) ||(B == NULL) || (N == NULL))
122 return NULL;
123
124 longN= BN_num_bytes(N);
125
126 if ((cAB = OPENSSL_malloc(2*longN)) == NULL)
127 return NULL;
128
129 memset(cAB, 0, longN);
130
131 EVP_MD_CTX_init(&ctxt);
132 EVP_DigestInit_ex(&ctxt, EVP_sha1(), NULL);
133 EVP_DigestUpdate(&ctxt, cAB + BN_bn2bin(A,cAB+longN), longN);
134 EVP_DigestUpdate(&ctxt, cAB + BN_bn2bin(B,cAB+longN), longN);
135 OPENSSL_free(cAB);
136 EVP_DigestFinal_ex(&ctxt, cu, NULL);
137 EVP_MD_CTX_cleanup(&ctxt);
138
139 if (!(u = BN_bin2bn(cu, sizeof(cu), NULL)))
140 return NULL;
141 if (!BN_is_zero(u))
142 return u;
143 BN_free(u);
144 return NULL;
145}
146
147BIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b, BIGNUM *N)
148 {
149 BIGNUM *tmp = NULL, *S = NULL;
150 BN_CTX *bn_ctx;
151
152 if (u == NULL || A == NULL || v == NULL || b == NULL || N == NULL)
153 return NULL;
154
155 if ((bn_ctx = BN_CTX_new()) == NULL ||
156 (tmp = BN_new()) == NULL ||
157 (S = BN_new()) == NULL )
158 goto err;
159
160 /* S = (A*v**u) ** b */
161
162 if (!BN_mod_exp(tmp,v,u,N,bn_ctx))
163 goto err;
164 if (!BN_mod_mul(tmp,A,tmp,N,bn_ctx))
165 goto err;
166 if (!BN_mod_exp(S,tmp,b,N,bn_ctx))
167 goto err;
168err:
169 BN_CTX_free(bn_ctx);
170 BN_clear_free(tmp);
171 return S;
172 }
173
174BIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v)
175 {
176 BIGNUM *kv = NULL, *gb = NULL;
177 BIGNUM *B = NULL, *k = NULL;
178 BN_CTX *bn_ctx;
179
180 if (b == NULL || N == NULL || g == NULL || v == NULL ||
181 (bn_ctx = BN_CTX_new()) == NULL)
182 return NULL;
183
184 if ( (kv = BN_new()) == NULL ||
185 (gb = BN_new()) == NULL ||
186 (B = BN_new())== NULL)
187 goto err;
188
189 /* B = g**b + k*v */
190
191 if (!BN_mod_exp(gb,g,b,N,bn_ctx) ||
192 !(k = srp_Calc_k(N,g)) ||
193 !BN_mod_mul(kv,v,k,N,bn_ctx) ||
194 !BN_mod_add(B,gb,kv,N,bn_ctx))
195 {
196 BN_free(B);
197 B = NULL;
198 }
199err:
200 BN_CTX_free(bn_ctx);
201 BN_clear_free(kv);
202 BN_clear_free(gb);
203 BN_free(k);
204 return B;
205 }
206
207BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass)
208 {
209 unsigned char dig[SHA_DIGEST_LENGTH];
210 EVP_MD_CTX ctxt;
211 unsigned char *cs;
212
213 if ((s == NULL) ||
214 (user == NULL) ||
215 (pass == NULL))
216 return NULL;
217
218 if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
219 return NULL;
220
221 EVP_MD_CTX_init(&ctxt);
222 EVP_DigestInit_ex(&ctxt, EVP_sha1(), NULL);
223 EVP_DigestUpdate(&ctxt, user, strlen(user));
224 EVP_DigestUpdate(&ctxt, ":", 1);
225 EVP_DigestUpdate(&ctxt, pass, strlen(pass));
226 EVP_DigestFinal_ex(&ctxt, dig, NULL);
227
228 EVP_DigestInit_ex(&ctxt, EVP_sha1(), NULL);
229 BN_bn2bin(s,cs);
230 EVP_DigestUpdate(&ctxt, cs, BN_num_bytes(s));
231 OPENSSL_free(cs);
232 EVP_DigestUpdate(&ctxt, dig, sizeof(dig));
233 EVP_DigestFinal_ex(&ctxt, dig, NULL);
234 EVP_MD_CTX_cleanup(&ctxt);
235
236 return BN_bin2bn(dig, sizeof(dig), NULL);
237 }
238
239BIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g)
240 {
241 BN_CTX *bn_ctx;
242 BIGNUM * A = NULL;
243
244 if (a == NULL || N == NULL || g == NULL ||
245 (bn_ctx = BN_CTX_new()) == NULL)
246 return NULL;
247
248 if ((A = BN_new()) != NULL &&
249 !BN_mod_exp(A,g,a,N,bn_ctx))
250 {
251 BN_free(A);
252 A = NULL;
253 }
254 BN_CTX_free(bn_ctx);
255 return A;
256 }
257
258
259BIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x, BIGNUM *a, BIGNUM *u)
260 {
261 BIGNUM *tmp = NULL, *tmp2 = NULL, *tmp3 = NULL , *k = NULL, *K = NULL;
262 BN_CTX *bn_ctx;
263
264 if (u == NULL || B == NULL || N == NULL || g == NULL || x == NULL || a == NULL ||
265 (bn_ctx = BN_CTX_new()) == NULL)
266 return NULL;
267
268 if ((tmp = BN_new()) == NULL ||
269 (tmp2 = BN_new())== NULL ||
270 (tmp3 = BN_new())== NULL ||
271 (K = BN_new()) == NULL)
272 goto err;
273
274 if (!BN_mod_exp(tmp,g,x,N,bn_ctx))
275 goto err;
276 if (!(k = srp_Calc_k(N,g)))
277 goto err;
278 if (!BN_mod_mul(tmp2,tmp,k,N,bn_ctx))
279 goto err;
280 if (!BN_mod_sub(tmp,B,tmp2,N,bn_ctx))
281 goto err;
282
283 if (!BN_mod_mul(tmp3,u,x,N,bn_ctx))
284 goto err;
285 if (!BN_mod_add(tmp2,a,tmp3,N,bn_ctx))
286 goto err;
287 if (!BN_mod_exp(K,tmp,tmp2,N,bn_ctx))
288 goto err;
289
290err :
291 BN_CTX_free(bn_ctx);
292 BN_clear_free(tmp);
293 BN_clear_free(tmp2);
294 BN_clear_free(tmp3);
295 BN_free(k);
296 return K;
297 }
298
299int SRP_Verify_B_mod_N(BIGNUM *B, BIGNUM *N)
300 {
301 BIGNUM *r;
302 BN_CTX *bn_ctx;
303 int ret = 0;
304
305 if (B == NULL || N == NULL ||
306 (bn_ctx = BN_CTX_new()) == NULL)
307 return 0;
308
309 if ((r = BN_new()) == NULL)
310 goto err;
311 /* Checks if B % N == 0 */
312 if (!BN_nnmod(r,B,N,bn_ctx))
313 goto err;
314 ret = !BN_is_zero(r);
315err:
316 BN_CTX_free(bn_ctx);
317 BN_free(r);
318 return ret;
319 }
320
321int SRP_Verify_A_mod_N(BIGNUM *A, BIGNUM *N)
322 {
323 /* Checks if A % N == 0 */
324 return SRP_Verify_B_mod_N(A,N) ;
325 }
326
327
328/* Check if G and N are kwown parameters.
329 The values have been generated from the ietf-tls-srp draft version 8
330*/
331char *SRP_check_known_gN_param(BIGNUM *g, BIGNUM *N)
332 {
333 size_t i;
334 if ((g == NULL) || (N == NULL))
335 return 0;
336
337 srp_bn_print(g);
338 srp_bn_print(N);
339
340 for(i = 0; i < KNOWN_GN_NUMBER; i++)
341 {
342 if (BN_cmp(knowngN[i].g, g) == 0 && BN_cmp(knowngN[i].N, N) == 0)
343 return knowngN[i].id;
344 }
345 return NULL;
346 }
347
348SRP_gN *SRP_get_default_gN(const char *id)
349 {
350 size_t i;
351
352 if (id == NULL)
353 return knowngN;
354 for(i = 0; i < KNOWN_GN_NUMBER; i++)
355 {
356 if (strcmp(knowngN[i].id, id)==0)
357 return knowngN + i;
358 }
359 return NULL;
360 }
361#endif
diff --git a/src/lib/libcrypto/srp/srp_vfy.c b/src/lib/libcrypto/srp/srp_vfy.c
new file mode 100644
index 0000000000..4a3d13edf6
--- /dev/null
+++ b/src/lib/libcrypto/srp/srp_vfy.c
@@ -0,0 +1,658 @@
1/* crypto/srp/srp_vfy.c */
2/* Written by Christophe Renou (christophe.renou@edelweb.fr) with
3 * the precious help of Peter Sylvester (peter.sylvester@edelweb.fr)
4 * for the EdelKey project and contributed to the OpenSSL project 2004.
5 */
6/* ====================================================================
7 * Copyright (c) 2004 The OpenSSL Project. 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 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. All advertising materials mentioning features or use of this
22 * software must display the following acknowledgment:
23 * "This product includes software developed by the OpenSSL Project
24 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25 *
26 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27 * endorse or promote products derived from this software without
28 * prior written permission. For written permission, please contact
29 * licensing@OpenSSL.org.
30 *
31 * 5. Products derived from this software may not be called "OpenSSL"
32 * nor may "OpenSSL" appear in their names without prior written
33 * permission of the OpenSSL Project.
34 *
35 * 6. Redistributions of any form whatsoever must retain the following
36 * acknowledgment:
37 * "This product includes software developed by the OpenSSL Project
38 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39 *
40 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51 * OF THE POSSIBILITY OF SUCH DAMAGE.
52 * ====================================================================
53 *
54 * This product includes cryptographic software written by Eric Young
55 * (eay@cryptsoft.com). This product includes software written by Tim
56 * Hudson (tjh@cryptsoft.com).
57 *
58 */
59#ifndef OPENSSL_NO_SRP
60#include "cryptlib.h"
61#include "srp_lcl.h"
62#include <openssl/srp.h>
63#include <openssl/evp.h>
64#include <openssl/buffer.h>
65#include <openssl/rand.h>
66#include <openssl/txt_db.h>
67
68#define SRP_RANDOM_SALT_LEN 20
69#define MAX_LEN 2500
70
71static char b64table[] =
72 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./";
73
74/* the following two conversion routines have been inspired by code from Stanford */
75
76/*
77 * Convert a base64 string into raw byte array representation.
78 */
79static int t_fromb64(unsigned char *a, const char *src)
80 {
81 char *loc;
82 int i, j;
83 int size;
84
85 while(*src && (*src == ' ' || *src == '\t' || *src == '\n'))
86 ++src;
87 size = strlen(src);
88 i = 0;
89 while(i < size)
90 {
91 loc = strchr(b64table, src[i]);
92 if(loc == (char *) 0) break;
93 else a[i] = loc - b64table;
94 ++i;
95 }
96 size = i;
97 i = size - 1;
98 j = size;
99 while(1)
100 {
101 a[j] = a[i];
102 if(--i < 0) break;
103 a[j] |= (a[i] & 3) << 6;
104 --j;
105 a[j] = (unsigned char) ((a[i] & 0x3c) >> 2);
106 if(--i < 0) break;
107 a[j] |= (a[i] & 0xf) << 4;
108 --j;
109 a[j] = (unsigned char) ((a[i] & 0x30) >> 4);
110 if(--i < 0) break;
111 a[j] |= (a[i] << 2);
112
113 a[--j] = 0;
114 if(--i < 0) break;
115 }
116 while(a[j] == 0 && j <= size) ++j;
117 i = 0;
118 while (j <= size) a[i++] = a[j++];
119 return i;
120 }
121
122
123/*
124 * Convert a raw byte string into a null-terminated base64 ASCII string.
125 */
126static char *t_tob64(char *dst, const unsigned char *src, int size)
127 {
128 int c, pos = size % 3;
129 unsigned char b0 = 0, b1 = 0, b2 = 0, notleading = 0;
130 char *olddst = dst;
131
132 switch(pos)
133 {
134 case 1:
135 b2 = src[0];
136 break;
137 case 2:
138 b1 = src[0];
139 b2 = src[1];
140 break;
141 }
142
143 while(1)
144 {
145 c = (b0 & 0xfc) >> 2;
146 if(notleading || c != 0)
147 {
148 *dst++ = b64table[c];
149 notleading = 1;
150 }
151 c = ((b0 & 3) << 4) | ((b1 & 0xf0) >> 4);
152 if(notleading || c != 0)
153 {
154 *dst++ = b64table[c];
155 notleading = 1;
156 }
157 c = ((b1 & 0xf) << 2) | ((b2 & 0xc0) >> 6);
158 if(notleading || c != 0)
159 {
160 *dst++ = b64table[c];
161 notleading = 1;
162 }
163 c = b2 & 0x3f;
164 if(notleading || c != 0)
165 {
166 *dst++ = b64table[c];
167 notleading = 1;
168 }
169 if(pos >= size) break;
170 else
171 {
172 b0 = src[pos++];
173 b1 = src[pos++];
174 b2 = src[pos++];
175 }
176 }
177
178 *dst++ = '\0';
179 return olddst;
180 }
181
182static void SRP_user_pwd_free(SRP_user_pwd *user_pwd)
183 {
184 if (user_pwd == NULL)
185 return;
186 BN_free(user_pwd->s);
187 BN_clear_free(user_pwd->v);
188 OPENSSL_free(user_pwd->id);
189 OPENSSL_free(user_pwd->info);
190 OPENSSL_free(user_pwd);
191 }
192
193static SRP_user_pwd *SRP_user_pwd_new()
194 {
195 SRP_user_pwd *ret = OPENSSL_malloc(sizeof(SRP_user_pwd));
196 if (ret == NULL)
197 return NULL;
198 ret->N = NULL;
199 ret->g = NULL;
200 ret->s = NULL;
201 ret->v = NULL;
202 ret->id = NULL ;
203 ret->info = NULL;
204 return ret;
205 }
206
207static void SRP_user_pwd_set_gN(SRP_user_pwd *vinfo, const BIGNUM *g,
208 const BIGNUM *N)
209 {
210 vinfo->N = N;
211 vinfo->g = g;
212 }
213
214static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,
215 const char *info)
216 {
217 if (id != NULL && NULL == (vinfo->id = BUF_strdup(id)))
218 return 0;
219 return (info == NULL || NULL != (vinfo->info = BUF_strdup(info))) ;
220 }
221
222static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
223 const char *v)
224 {
225 unsigned char tmp[MAX_LEN];
226 int len;
227
228 if (strlen(s) > MAX_LEN || strlen(v) > MAX_LEN)
229 return 0;
230 len = t_fromb64(tmp, v);
231 if (NULL == (vinfo->v = BN_bin2bn(tmp, len, NULL)) )
232 return 0;
233 len = t_fromb64(tmp, s);
234 return ((vinfo->s = BN_bin2bn(tmp, len, NULL)) != NULL) ;
235 }
236
237static int SRP_user_pwd_set_sv_BN(SRP_user_pwd *vinfo, BIGNUM *s, BIGNUM *v)
238 {
239 vinfo->v = v;
240 vinfo->s = s;
241 return (vinfo->s != NULL && vinfo->v != NULL) ;
242 }
243
244SRP_VBASE *SRP_VBASE_new(char *seed_key)
245 {
246 SRP_VBASE *vb = (SRP_VBASE *) OPENSSL_malloc(sizeof(SRP_VBASE));
247
248 if (vb == NULL)
249 return NULL;
250 if (!(vb->users_pwd = sk_SRP_user_pwd_new_null()) ||
251 !(vb->gN_cache = sk_SRP_gN_cache_new_null()))
252 {
253 OPENSSL_free(vb);
254 return NULL;
255 }
256 vb->default_g = NULL;
257 vb->default_N = NULL;
258 vb->seed_key = NULL;
259 if ((seed_key != NULL) &&
260 (vb->seed_key = BUF_strdup(seed_key)) == NULL)
261 {
262 sk_SRP_user_pwd_free(vb->users_pwd);
263 sk_SRP_gN_cache_free(vb->gN_cache);
264 OPENSSL_free(vb);
265 return NULL;
266 }
267 return vb;
268 }
269
270
271int SRP_VBASE_free(SRP_VBASE *vb)
272 {
273 sk_SRP_user_pwd_pop_free(vb->users_pwd,SRP_user_pwd_free);
274 sk_SRP_gN_cache_free(vb->gN_cache);
275 OPENSSL_free(vb->seed_key);
276 OPENSSL_free(vb);
277 return 0;
278 }
279
280
281static SRP_gN_cache *SRP_gN_new_init(const char *ch)
282 {
283 unsigned char tmp[MAX_LEN];
284 int len;
285
286 SRP_gN_cache *newgN = (SRP_gN_cache *)OPENSSL_malloc(sizeof(SRP_gN_cache));
287 if (newgN == NULL)
288 return NULL;
289
290 if ((newgN->b64_bn = BUF_strdup(ch)) == NULL)
291 goto err;
292
293 len = t_fromb64(tmp, ch);
294 if ((newgN->bn = BN_bin2bn(tmp, len, NULL)))
295 return newgN;
296
297 OPENSSL_free(newgN->b64_bn);
298err:
299 OPENSSL_free(newgN);
300 return NULL;
301 }
302
303
304static void SRP_gN_free(SRP_gN_cache *gN_cache)
305 {
306 if (gN_cache == NULL)
307 return;
308 OPENSSL_free(gN_cache->b64_bn);
309 BN_free(gN_cache->bn);
310 OPENSSL_free(gN_cache);
311 }
312
313static SRP_gN *SRP_get_gN_by_id(const char *id, STACK_OF(SRP_gN) *gN_tab)
314 {
315 int i;
316
317 SRP_gN *gN;
318 if (gN_tab != NULL)
319 for(i = 0; i < sk_SRP_gN_num(gN_tab); i++)
320 {
321 gN = sk_SRP_gN_value(gN_tab, i);
322 if (gN && (id == NULL || strcmp(gN->id,id)==0))
323 return gN;
324 }
325
326 return SRP_get_default_gN(id);
327 }
328
329static BIGNUM *SRP_gN_place_bn(STACK_OF(SRP_gN_cache) *gN_cache, char *ch)
330 {
331 int i;
332 if (gN_cache == NULL)
333 return NULL;
334
335 /* search if we have already one... */
336 for(i = 0; i < sk_SRP_gN_cache_num(gN_cache); i++)
337 {
338 SRP_gN_cache *cache = sk_SRP_gN_cache_value(gN_cache, i);
339 if (strcmp(cache->b64_bn,ch)==0)
340 return cache->bn;
341 }
342 { /* it is the first time that we find it */
343 SRP_gN_cache *newgN = SRP_gN_new_init(ch);
344 if (newgN)
345 {
346 if (sk_SRP_gN_cache_insert(gN_cache,newgN,0)>0)
347 return newgN->bn;
348 SRP_gN_free(newgN);
349 }
350 }
351 return NULL;
352 }
353
354/* this function parses verifier file. Format is:
355 * string(index):base64(N):base64(g):0
356 * string(username):base64(v):base64(salt):int(index)
357 */
358
359
360int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file)
361 {
362 int error_code ;
363 STACK_OF(SRP_gN) *SRP_gN_tab = sk_SRP_gN_new_null();
364 char *last_index = NULL;
365 int i;
366 char **pp;
367
368 SRP_gN *gN = NULL;
369 SRP_user_pwd *user_pwd = NULL ;
370
371 TXT_DB *tmpdb = NULL;
372 BIO *in = BIO_new(BIO_s_file());
373
374 error_code = SRP_ERR_OPEN_FILE;
375
376 if (in == NULL || BIO_read_filename(in,verifier_file) <= 0)
377 goto err;
378
379 error_code = SRP_ERR_VBASE_INCOMPLETE_FILE;
380
381 if ((tmpdb =TXT_DB_read(in,DB_NUMBER)) == NULL)
382 goto err;
383
384 error_code = SRP_ERR_MEMORY;
385
386
387 if (vb->seed_key)
388 {
389 last_index = SRP_get_default_gN(NULL)->id;
390 }
391 for (i = 0; i < sk_OPENSSL_PSTRING_num(tmpdb->data); i++)
392 {
393 pp = sk_OPENSSL_PSTRING_value(tmpdb->data,i);
394 if (pp[DB_srptype][0] == DB_SRP_INDEX)
395 {
396 /*we add this couple in the internal Stack */
397
398 if ((gN = (SRP_gN *)OPENSSL_malloc(sizeof(SRP_gN))) == NULL)
399 goto err;
400
401 if (!(gN->id = BUF_strdup(pp[DB_srpid]))
402 || !(gN->N = SRP_gN_place_bn(vb->gN_cache,pp[DB_srpverifier]))
403 || !(gN->g = SRP_gN_place_bn(vb->gN_cache,pp[DB_srpsalt]))
404 || sk_SRP_gN_insert(SRP_gN_tab,gN,0) == 0)
405 goto err;
406
407 gN = NULL;
408
409 if (vb->seed_key != NULL)
410 {
411 last_index = pp[DB_srpid];
412 }
413 }
414 else if (pp[DB_srptype][0] == DB_SRP_VALID)
415 {
416 /* it is a user .... */
417 SRP_gN *lgN;
418 if ((lgN = SRP_get_gN_by_id(pp[DB_srpgN],SRP_gN_tab))!=NULL)
419 {
420 error_code = SRP_ERR_MEMORY;
421 if ((user_pwd = SRP_user_pwd_new()) == NULL)
422 goto err;
423
424 SRP_user_pwd_set_gN(user_pwd,lgN->g,lgN->N);
425 if (!SRP_user_pwd_set_ids(user_pwd, pp[DB_srpid],pp[DB_srpinfo]))
426 goto err;
427
428 error_code = SRP_ERR_VBASE_BN_LIB;
429 if (!SRP_user_pwd_set_sv(user_pwd, pp[DB_srpsalt],pp[DB_srpverifier]))
430 goto err;
431
432 if (sk_SRP_user_pwd_insert(vb->users_pwd, user_pwd, 0) == 0)
433 goto err;
434 user_pwd = NULL; /* abandon responsability */
435 }
436 }
437 }
438
439 if (last_index != NULL)
440 {
441 /* this means that we want to simulate a default user */
442
443 if (((gN = SRP_get_gN_by_id(last_index,SRP_gN_tab))==NULL))
444 {
445 error_code = SRP_ERR_VBASE_BN_LIB;
446 goto err;
447 }
448 vb->default_g = gN->g ;
449 vb->default_N = gN->N ;
450 gN = NULL ;
451 }
452 error_code = SRP_NO_ERROR;
453
454 err:
455 /* there may be still some leaks to fix, if this fails, the application terminates most likely */
456
457 if (gN != NULL)
458 {
459 OPENSSL_free(gN->id);
460 OPENSSL_free(gN);
461 }
462
463 SRP_user_pwd_free(user_pwd);
464
465 if (tmpdb) TXT_DB_free(tmpdb);
466 if (in) BIO_free_all(in);
467
468 sk_SRP_gN_free(SRP_gN_tab);
469
470 return error_code;
471
472 }
473
474
475SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)
476 {
477 int i;
478 SRP_user_pwd *user;
479 unsigned char digv[SHA_DIGEST_LENGTH];
480 unsigned char digs[SHA_DIGEST_LENGTH];
481 EVP_MD_CTX ctxt;
482
483 if (vb == NULL)
484 return NULL;
485 for(i = 0; i < sk_SRP_user_pwd_num(vb->users_pwd); i++)
486 {
487 user = sk_SRP_user_pwd_value(vb->users_pwd, i);
488 if (strcmp(user->id,username)==0)
489 return user;
490 }
491 if ((vb->seed_key == NULL) ||
492 (vb->default_g == NULL) ||
493 (vb->default_N == NULL))
494 return NULL;
495
496/* if the user is unknown we set parameters as well if we have a seed_key */
497
498 if ((user = SRP_user_pwd_new()) == NULL)
499 return NULL;
500
501 SRP_user_pwd_set_gN(user,vb->default_g,vb->default_N);
502
503 if (!SRP_user_pwd_set_ids(user,username,NULL))
504 goto err;
505
506 RAND_pseudo_bytes(digv, SHA_DIGEST_LENGTH);
507 EVP_MD_CTX_init(&ctxt);
508 EVP_DigestInit_ex(&ctxt, EVP_sha1(), NULL);
509 EVP_DigestUpdate(&ctxt, vb->seed_key, strlen(vb->seed_key));
510 EVP_DigestUpdate(&ctxt, username, strlen(username));
511 EVP_DigestFinal_ex(&ctxt, digs, NULL);
512 EVP_MD_CTX_cleanup(&ctxt);
513 if (SRP_user_pwd_set_sv_BN(user, BN_bin2bn(digs,SHA_DIGEST_LENGTH,NULL), BN_bin2bn(digv,SHA_DIGEST_LENGTH, NULL)))
514 return user;
515
516err: SRP_user_pwd_free(user);
517 return NULL;
518 }
519
520
521/*
522 create a verifier (*salt,*verifier,g and N are in base64)
523*/
524char *SRP_create_verifier(const char *user, const char *pass, char **salt,
525 char **verifier, const char *N, const char *g)
526 {
527 int len;
528 char * result=NULL;
529 char *vf;
530 BIGNUM *N_bn = NULL, *g_bn = NULL, *s = NULL, *v = NULL;
531 unsigned char tmp[MAX_LEN];
532 unsigned char tmp2[MAX_LEN];
533 char * defgNid = NULL;
534
535 if ((user == NULL)||
536 (pass == NULL)||
537 (salt == NULL)||
538 (verifier == NULL))
539 goto err;
540
541 if (N)
542 {
543 if (!(len = t_fromb64(tmp, N))) goto err;
544 N_bn = BN_bin2bn(tmp, len, NULL);
545 if (!(len = t_fromb64(tmp, g))) goto err;
546 g_bn = BN_bin2bn(tmp, len, NULL);
547 defgNid = "*";
548 }
549 else
550 {
551 SRP_gN * gN = SRP_get_gN_by_id(g, NULL) ;
552 if (gN == NULL)
553 goto err;
554 N_bn = gN->N;
555 g_bn = gN->g;
556 defgNid = gN->id;
557 }
558
559 if (*salt == NULL)
560 {
561 RAND_pseudo_bytes(tmp2, SRP_RANDOM_SALT_LEN);
562
563 s = BN_bin2bn(tmp2, SRP_RANDOM_SALT_LEN, NULL);
564 }
565 else
566 {
567 if (!(len = t_fromb64(tmp2, *salt)))
568 goto err;
569 s = BN_bin2bn(tmp2, len, NULL);
570 }
571
572
573 if(!SRP_create_verifier_BN(user, pass, &s, &v, N_bn, g_bn)) goto err;
574
575 BN_bn2bin(v,tmp);
576 if (((vf = OPENSSL_malloc(BN_num_bytes(v)*2)) == NULL))
577 goto err;
578 t_tob64(vf, tmp, BN_num_bytes(v));
579
580 *verifier = vf;
581 if (*salt == NULL)
582 {
583 char *tmp_salt;
584
585 if ((tmp_salt = OPENSSL_malloc(SRP_RANDOM_SALT_LEN * 2)) == NULL)
586 {
587 OPENSSL_free(vf);
588 goto err;
589 }
590 t_tob64(tmp_salt, tmp2, SRP_RANDOM_SALT_LEN);
591 *salt = tmp_salt;
592 }
593
594 result=defgNid;
595
596err:
597 if(N)
598 {
599 BN_free(N_bn);
600 BN_free(g_bn);
601 }
602 return result;
603 }
604
605/*
606 create a verifier (*salt,*verifier,g and N are BIGNUMs)
607*/
608int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt, BIGNUM **verifier, BIGNUM *N, BIGNUM *g)
609 {
610 int result=0;
611 BIGNUM *x = NULL;
612 BN_CTX *bn_ctx = BN_CTX_new();
613 unsigned char tmp2[MAX_LEN];
614
615 if ((user == NULL)||
616 (pass == NULL)||
617 (salt == NULL)||
618 (verifier == NULL)||
619 (N == NULL)||
620 (g == NULL)||
621 (bn_ctx == NULL))
622 goto err;
623
624 srp_bn_print(N);
625 srp_bn_print(g);
626
627 if (*salt == NULL)
628 {
629 RAND_pseudo_bytes(tmp2, SRP_RANDOM_SALT_LEN);
630
631 *salt = BN_bin2bn(tmp2,SRP_RANDOM_SALT_LEN,NULL);
632 }
633
634 x = SRP_Calc_x(*salt,user,pass);
635
636 *verifier = BN_new();
637 if(*verifier == NULL) goto err;
638
639 if (!BN_mod_exp(*verifier,g,x,N,bn_ctx))
640 {
641 BN_clear_free(*verifier);
642 goto err;
643 }
644
645 srp_bn_print(*verifier);
646
647 result=1;
648
649err:
650
651 BN_clear_free(x);
652 BN_CTX_free(bn_ctx);
653 return result;
654 }
655
656
657
658#endif
diff --git a/src/lib/libcrypto/srp/srptest.c b/src/lib/libcrypto/srp/srptest.c
new file mode 100644
index 0000000000..04b66b4544
--- /dev/null
+++ b/src/lib/libcrypto/srp/srptest.c
@@ -0,0 +1,162 @@
1#include <openssl/opensslconf.h>
2#ifdef OPENSSL_NO_SRP
3
4#include <stdio.h>
5
6int main(int argc, char *argv[])
7 {
8 printf("No SRP support\n");
9 return(0);
10 }
11
12#else
13
14#include <openssl/srp.h>
15#include <openssl/rand.h>
16#include <openssl/err.h>
17
18static void showbn(const char *name, const BIGNUM *bn)
19 {
20 fputs(name, stdout);
21 fputs(" = ", stdout);
22 BN_print_fp(stdout, bn);
23 putc('\n', stdout);
24 }
25
26#define RANDOM_SIZE 32 /* use 256 bits on each side */
27
28static int run_srp(const char *username, const char *client_pass, const char *server_pass)
29 {
30 int ret=-1;
31 BIGNUM *s = NULL;
32 BIGNUM *v = NULL;
33 BIGNUM *a = NULL;
34 BIGNUM *b = NULL;
35 BIGNUM *u = NULL;
36 BIGNUM *x = NULL;
37 BIGNUM *Apub = NULL;
38 BIGNUM *Bpub = NULL;
39 BIGNUM *Kclient = NULL;
40 BIGNUM *Kserver = NULL;
41 unsigned char rand_tmp[RANDOM_SIZE];
42 /* use builtin 1024-bit params */
43 SRP_gN *GN = SRP_get_default_gN("1024");
44
45 if(GN == NULL)
46 {
47 fprintf(stderr, "Failed to get SRP parameters\n");
48 return -1;
49 }
50 /* Set up server's password entry */
51 if(!SRP_create_verifier_BN(username, server_pass, &s, &v, GN->N, GN->g))
52 {
53 fprintf(stderr, "Failed to create SRP verifier\n");
54 return -1;
55 }
56
57 showbn("N", GN->N);
58 showbn("g", GN->g);
59 showbn("Salt", s);
60 showbn("Verifier", v);
61
62 /* Server random */
63 RAND_pseudo_bytes(rand_tmp, sizeof(rand_tmp));
64 b = BN_bin2bn(rand_tmp, sizeof(rand_tmp), NULL);
65 /* TODO - check b != 0 */
66 showbn("b", b);
67
68 /* Server's first message */
69 Bpub = SRP_Calc_B(b, GN->N, GN->g, v);
70 showbn("B", Bpub);
71
72 if(!SRP_Verify_B_mod_N(Bpub, GN->N))
73 {
74 fprintf(stderr, "Invalid B\n");
75 return -1;
76 }
77
78 /* Client random */
79 RAND_pseudo_bytes(rand_tmp, sizeof(rand_tmp));
80 a = BN_bin2bn(rand_tmp, sizeof(rand_tmp), NULL);
81 /* TODO - check a != 0 */
82 showbn("a", a);
83
84 /* Client's response */
85 Apub = SRP_Calc_A(a, GN->N, GN->g);
86 showbn("A", Apub);
87
88 if(!SRP_Verify_A_mod_N(Apub, GN->N))
89 {
90 fprintf(stderr, "Invalid A\n");
91 return -1;
92 }
93
94 /* Both sides calculate u */
95 u = SRP_Calc_u(Apub, Bpub, GN->N);
96
97 /* Client's key */
98 x = SRP_Calc_x(s, username, client_pass);
99 Kclient = SRP_Calc_client_key(GN->N, Bpub, GN->g, x, a, u);
100 showbn("Client's key", Kclient);
101
102 /* Server's key */
103 Kserver = SRP_Calc_server_key(Apub, v, u, b, GN->N);
104 showbn("Server's key", Kserver);
105
106 if(BN_cmp(Kclient, Kserver) == 0)
107 {
108 ret = 0;
109 }
110 else
111 {
112 fprintf(stderr, "Keys mismatch\n");
113 ret = 1;
114 }
115
116 BN_clear_free(Kclient);
117 BN_clear_free(Kserver);
118 BN_clear_free(x);
119 BN_free(u);
120 BN_free(Apub);
121 BN_clear_free(a);
122 BN_free(Bpub);
123 BN_clear_free(b);
124 BN_free(s);
125 BN_clear_free(v);
126
127 return ret;
128 }
129
130int main(int argc, char **argv)
131 {
132 BIO *bio_err;
133 bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
134
135 CRYPTO_malloc_debug_init();
136 CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
137 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
138
139 ERR_load_crypto_strings();
140
141 /* "Negative" test, expect a mismatch */
142 if(run_srp("alice", "password1", "password2") == 0)
143 {
144 fprintf(stderr, "Mismatched SRP run failed\n");
145 return 1;
146 }
147
148 /* "Positive" test, should pass */
149 if(run_srp("alice", "password", "password") != 0)
150 {
151 fprintf(stderr, "Plain SRP run failed\n");
152 return 1;
153 }
154
155 CRYPTO_cleanup_all_ex_data();
156 ERR_remove_thread_state(NULL);
157 ERR_free_strings();
158 CRYPTO_mem_leaks(bio_err);
159
160 return 0;
161 }
162#endif
diff --git a/src/lib/libcrypto/store/Makefile b/src/lib/libcrypto/store/Makefile
new file mode 100644
index 0000000000..0dcfd7857a
--- /dev/null
+++ b/src/lib/libcrypto/store/Makefile
@@ -0,0 +1,112 @@
1#
2# OpenSSL/crypto/store/Makefile
3#
4
5DIR= store
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10MAKEFILE= Makefile
11AR= ar r
12
13CFLAGS= $(INCLUDES) $(CFLAG)
14
15GENERAL=Makefile
16#TEST= storetest.c
17TEST=
18APPS=
19
20LIB=$(TOP)/libcrypto.a
21LIBSRC= str_err.c str_lib.c str_meth.c str_mem.c
22LIBOBJ= str_err.o str_lib.o str_meth.o str_mem.o
23
24SRC= $(LIBSRC)
25
26#EXHEADER= store.h str_compat.h
27EXHEADER= store.h
28HEADER= $(EXHEADER) str_locl.h
29
30ALL= $(GENERAL) $(SRC) $(HEADER)
31
32top:
33 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
34
35all: lib
36
37lib: $(LIBOBJ)
38 $(AR) $(LIB) $(LIBOBJ)
39 $(RANLIB) $(LIB) || echo Never mind.
40 @touch lib
41
42files:
43 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
44
45links:
46 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
47 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
48 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
49
50install:
51 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
52 @headerlist="$(EXHEADER)"; for i in $$headerlist; \
53 do \
54 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
55 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
56 done;
57
58tags:
59 ctags $(SRC)
60
61tests:
62
63lint:
64 lint -DLINT $(INCLUDES) $(SRC)>fluff
65
66depend:
67 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
68 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
69
70dclean:
71 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
72 mv -f Makefile.new $(MAKEFILE)
73
74clean:
75 rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
76
77# DO NOT DELETE THIS LINE -- make depend depends on it.
78
79str_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
80str_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
81str_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
82str_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
83str_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
84str_err.o: ../../include/openssl/store.h ../../include/openssl/symhacks.h
85str_err.o: str_err.c
86str_lib.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
87str_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
88str_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
89str_lib.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
90str_lib.o: ../../include/openssl/ecdsa.h ../../include/openssl/engine.h
91str_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
92str_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
93str_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
94str_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
95str_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/safestack.h
96str_lib.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
97str_lib.o: ../../include/openssl/store.h ../../include/openssl/symhacks.h
98str_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
99str_lib.o: str_lib.c str_locl.h
100str_mem.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
101str_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
102str_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
103str_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
104str_mem.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
105str_mem.o: ../../include/openssl/store.h ../../include/openssl/symhacks.h
106str_mem.o: str_locl.h str_mem.c
107str_meth.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
108str_meth.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
109str_meth.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
110str_meth.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
111str_meth.o: ../../include/openssl/store.h ../../include/openssl/symhacks.h
112str_meth.o: str_locl.h str_meth.c
diff --git a/src/lib/libcrypto/store/README b/src/lib/libcrypto/store/README
new file mode 100644
index 0000000000..966168f6a5
--- /dev/null
+++ b/src/lib/libcrypto/store/README
@@ -0,0 +1,95 @@
1The STORE type
2==============
3
4A STORE, as defined in this code section, is really a rather simple
5thing which stores objects and per-object associations to a number
6of attributes. What attributes are supported entirely depends on
7the particular implementation of a STORE. It has some support for
8generation of certain objects (for example, keys and CRLs).
9
10
11Supported object types
12----------------------
13
14For now, the objects that are supported are the following:
15
16X.509 certificate
17X.509 CRL
18private key
19public key
20number
21arbitrary (application) data
22
23The intention is that a STORE should be able to store everything
24needed by an application that wants a cert/key store, as well as
25the data a CA might need to store (this includes the serial number
26counter, which explains the support for numbers).
27
28
29Supported attribute types
30-------------------------
31
32For now, the following attributes are supported:
33
34Friendly Name - the value is a normal C string
35Key ID - the value is a 160 bit SHA1 hash
36Issuer Key ID - the value is a 160 bit SHA1 hash
37Subject Key ID - the value is a 160 bit SHA1 hash
38Issuer/Serial Hash - the value is a 160 bit SHA1 hash
39Issuer - the value is a X509_NAME
40Serial - the value is a BIGNUM
41Subject - the value is a X509_NAME
42Certificate Hash - the value is a 160 bit SHA1 hash
43Email - the value is a normal C string
44Filename - the value is a normal C string
45
46It is expected that these attributes should be enough to support
47the need from most, if not all, current applications. Applications
48that need to do certificate verification would typically use Subject
49Key ID, Issuer/Serial Hash or Subject to look up issuer certificates.
50S/MIME applications would typically use Email to look up recipient
51and signer certificates.
52
53There's added support for combined sets of attributes to search for,
54with the special OR attribute.
55
56
57Supported basic functionality
58-----------------------------
59
60The functions that are supported through the STORE type are these:
61
62generate_object - for example to generate keys and CRLs
63get_object - to look up one object
64 NOTE: this function is really rather
65 redundant and probably of lesser usage
66 than the list functions
67store_object - store an object and the attributes
68 associated with it
69modify_object - modify the attributes associated with
70 a specific object
71revoke_object - revoke an object
72 NOTE: this only marks an object as
73 invalid, it doesn't remove the object
74 from the database
75delete_object - remove an object from the database
76list_object - list objects associated with a given
77 set of attributes
78 NOTE: this is really four functions:
79 list_start, list_next, list_end and
80 list_endp
81update_store - update the internal data of the store
82lock_store - lock the store
83unlock_store - unlock the store
84
85The list functions need some extra explanation: list_start is
86used to set up a lookup. That's where the attributes to use in
87the search are set up. It returns a search context. list_next
88returns the next object searched for. list_end closes the search.
89list_endp is used to check if we have reached the end.
90
91A few words on the store functions as well: update_store is
92typically used by a CA application to update the internal
93structure of a database. This may for example involve automatic
94removal of expired certificates. lock_store and unlock_store
95are used for locking a store to allow exclusive writes.
diff --git a/src/lib/libcrypto/store/store.h b/src/lib/libcrypto/store/store.h
new file mode 100644
index 0000000000..0a28c7d5a2
--- /dev/null
+++ b/src/lib/libcrypto/store/store.h
@@ -0,0 +1,561 @@
1/* crypto/store/store.h -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2003.
4 */
5/* ====================================================================
6 * Copyright (c) 2003 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * openssl-core@openssl.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#ifndef HEADER_STORE_H
60#define HEADER_STORE_H
61
62#include <openssl/opensslconf.h>
63
64#ifdef OPENSSL_NO_STORE
65#error STORE is disabled.
66#endif
67
68#include <openssl/ossl_typ.h>
69#ifndef OPENSSL_NO_DEPRECATED
70#include <openssl/evp.h>
71#include <openssl/bn.h>
72#include <openssl/x509.h>
73#endif
74
75#ifdef __cplusplus
76extern "C" {
77#endif
78
79/* Already defined in ossl_typ.h */
80/* typedef struct store_st STORE; */
81/* typedef struct store_method_st STORE_METHOD; */
82
83
84/* All the following functions return 0, a negative number or NULL on error.
85 When everything is fine, they return a positive value or a non-NULL
86 pointer, all depending on their purpose. */
87
88/* Creators and destructor. */
89STORE *STORE_new_method(const STORE_METHOD *method);
90STORE *STORE_new_engine(ENGINE *engine);
91void STORE_free(STORE *ui);
92
93
94/* Give a user interface parametrised control commands. This can be used to
95 send down an integer, a data pointer or a function pointer, as well as
96 be used to get information from a STORE. */
97int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void));
98
99/* A control to set the directory with keys and certificates. Used by the
100 built-in directory level method. */
101#define STORE_CTRL_SET_DIRECTORY 0x0001
102/* A control to set a file to load. Used by the built-in file level method. */
103#define STORE_CTRL_SET_FILE 0x0002
104/* A control to set a configuration file to load. Can be used by any method
105 that wishes to load a configuration file. */
106#define STORE_CTRL_SET_CONF_FILE 0x0003
107/* A control to set a the section of the loaded configuration file. Can be
108 used by any method that wishes to load a configuration file. */
109#define STORE_CTRL_SET_CONF_SECTION 0x0004
110
111
112/* Some methods may use extra data */
113#define STORE_set_app_data(s,arg) STORE_set_ex_data(s,0,arg)
114#define STORE_get_app_data(s) STORE_get_ex_data(s,0)
115int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
116 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
117int STORE_set_ex_data(STORE *r,int idx,void *arg);
118void *STORE_get_ex_data(STORE *r, int idx);
119
120/* Use specific methods instead of the built-in one */
121const STORE_METHOD *STORE_get_method(STORE *store);
122const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth);
123
124/* The standard OpenSSL methods. */
125/* This is the in-memory method. It does everything except revoking and updating,
126 and is of course volatile. It's used by other methods that have an in-memory
127 cache. */
128const STORE_METHOD *STORE_Memory(void);
129#if 0 /* Not yet implemented */
130/* This is the directory store. It does everything except revoking and updating,
131 and uses STORE_Memory() to cache things in memory. */
132const STORE_METHOD *STORE_Directory(void);
133/* This is the file store. It does everything except revoking and updating,
134 and uses STORE_Memory() to cache things in memory. Certificates are added
135 to it with the store operation, and it will only get cached certificates. */
136const STORE_METHOD *STORE_File(void);
137#endif
138
139/* Store functions take a type code for the type of data they should store
140 or fetch */
141typedef enum STORE_object_types
142 {
143 STORE_OBJECT_TYPE_X509_CERTIFICATE= 0x01, /* X509 * */
144 STORE_OBJECT_TYPE_X509_CRL= 0x02, /* X509_CRL * */
145 STORE_OBJECT_TYPE_PRIVATE_KEY= 0x03, /* EVP_PKEY * */
146 STORE_OBJECT_TYPE_PUBLIC_KEY= 0x04, /* EVP_PKEY * */
147 STORE_OBJECT_TYPE_NUMBER= 0x05, /* BIGNUM * */
148 STORE_OBJECT_TYPE_ARBITRARY= 0x06, /* BUF_MEM * */
149 STORE_OBJECT_TYPE_NUM= 0x06 /* The amount of known
150 object types */
151 } STORE_OBJECT_TYPES;
152/* List of text strings corresponding to the object types. */
153extern const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1];
154
155/* Some store functions take a parameter list. Those parameters come with
156 one of the following codes. The comments following the codes below indicate
157 what type the value should be a pointer to. */
158typedef enum STORE_params
159 {
160 STORE_PARAM_EVP_TYPE= 0x01, /* int */
161 STORE_PARAM_BITS= 0x02, /* size_t */
162 STORE_PARAM_KEY_PARAMETERS= 0x03, /* ??? */
163 STORE_PARAM_KEY_NO_PARAMETERS= 0x04, /* N/A */
164 STORE_PARAM_AUTH_PASSPHRASE= 0x05, /* char * */
165 STORE_PARAM_AUTH_KRB5_TICKET= 0x06, /* void * */
166 STORE_PARAM_TYPE_NUM= 0x06 /* The amount of known
167 parameter types */
168 } STORE_PARAM_TYPES;
169/* Parameter value sizes. -1 means unknown, anything else is the required size. */
170extern const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1];
171
172/* Store functions take attribute lists. Those attributes come with codes.
173 The comments following the codes below indicate what type the value should
174 be a pointer to. */
175typedef enum STORE_attribs
176 {
177 STORE_ATTR_END= 0x00,
178 STORE_ATTR_FRIENDLYNAME= 0x01, /* C string */
179 STORE_ATTR_KEYID= 0x02, /* 160 bit string (SHA1) */
180 STORE_ATTR_ISSUERKEYID= 0x03, /* 160 bit string (SHA1) */
181 STORE_ATTR_SUBJECTKEYID= 0x04, /* 160 bit string (SHA1) */
182 STORE_ATTR_ISSUERSERIALHASH= 0x05, /* 160 bit string (SHA1) */
183 STORE_ATTR_ISSUER= 0x06, /* X509_NAME * */
184 STORE_ATTR_SERIAL= 0x07, /* BIGNUM * */
185 STORE_ATTR_SUBJECT= 0x08, /* X509_NAME * */
186 STORE_ATTR_CERTHASH= 0x09, /* 160 bit string (SHA1) */
187 STORE_ATTR_EMAIL= 0x0a, /* C string */
188 STORE_ATTR_FILENAME= 0x0b, /* C string */
189 STORE_ATTR_TYPE_NUM= 0x0b, /* The amount of known
190 attribute types */
191 STORE_ATTR_OR= 0xff /* This is a special
192 separator, which
193 expresses the OR
194 operation. */
195 } STORE_ATTR_TYPES;
196/* Attribute value sizes. -1 means unknown, anything else is the required size. */
197extern const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1];
198
199typedef enum STORE_certificate_status
200 {
201 STORE_X509_VALID= 0x00,
202 STORE_X509_EXPIRED= 0x01,
203 STORE_X509_SUSPENDED= 0x02,
204 STORE_X509_REVOKED= 0x03
205 } STORE_CERTIFICATE_STATUS;
206
207/* Engine store functions will return a structure that contains all the necessary
208 * information, including revokation status for certificates. This is really not
209 * needed for application authors, as the ENGINE framework functions will extract
210 * the OpenSSL-specific information when at all possible. However, for engine
211 * authors, it's crucial to know this structure. */
212typedef struct STORE_OBJECT_st
213 {
214 STORE_OBJECT_TYPES type;
215 union
216 {
217 struct
218 {
219 STORE_CERTIFICATE_STATUS status;
220 X509 *certificate;
221 } x509;
222 X509_CRL *crl;
223 EVP_PKEY *key;
224 BIGNUM *number;
225 BUF_MEM *arbitrary;
226 } data;
227 } STORE_OBJECT;
228DECLARE_STACK_OF(STORE_OBJECT)
229STORE_OBJECT *STORE_OBJECT_new(void);
230void STORE_OBJECT_free(STORE_OBJECT *data);
231
232
233
234/* The following functions handle the storage. They return 0, a negative number
235 or NULL on error, anything else on success. */
236X509 *STORE_get_certificate(STORE *e, OPENSSL_ITEM attributes[],
237 OPENSSL_ITEM parameters[]);
238int STORE_store_certificate(STORE *e, X509 *data, OPENSSL_ITEM attributes[],
239 OPENSSL_ITEM parameters[]);
240int STORE_modify_certificate(STORE *e, OPENSSL_ITEM search_attributes[],
241 OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[],
242 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
243int STORE_revoke_certificate(STORE *e, OPENSSL_ITEM attributes[],
244 OPENSSL_ITEM parameters[]);
245int STORE_delete_certificate(STORE *e, OPENSSL_ITEM attributes[],
246 OPENSSL_ITEM parameters[]);
247void *STORE_list_certificate_start(STORE *e, OPENSSL_ITEM attributes[],
248 OPENSSL_ITEM parameters[]);
249X509 *STORE_list_certificate_next(STORE *e, void *handle);
250int STORE_list_certificate_end(STORE *e, void *handle);
251int STORE_list_certificate_endp(STORE *e, void *handle);
252EVP_PKEY *STORE_generate_key(STORE *e, OPENSSL_ITEM attributes[],
253 OPENSSL_ITEM parameters[]);
254EVP_PKEY *STORE_get_private_key(STORE *e, OPENSSL_ITEM attributes[],
255 OPENSSL_ITEM parameters[]);
256int STORE_store_private_key(STORE *e, EVP_PKEY *data,
257 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
258int STORE_modify_private_key(STORE *e, OPENSSL_ITEM search_attributes[],
259 OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[],
260 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
261int STORE_revoke_private_key(STORE *e, OPENSSL_ITEM attributes[],
262 OPENSSL_ITEM parameters[]);
263int STORE_delete_private_key(STORE *e, OPENSSL_ITEM attributes[],
264 OPENSSL_ITEM parameters[]);
265void *STORE_list_private_key_start(STORE *e, OPENSSL_ITEM attributes[],
266 OPENSSL_ITEM parameters[]);
267EVP_PKEY *STORE_list_private_key_next(STORE *e, void *handle);
268int STORE_list_private_key_end(STORE *e, void *handle);
269int STORE_list_private_key_endp(STORE *e, void *handle);
270EVP_PKEY *STORE_get_public_key(STORE *e, OPENSSL_ITEM attributes[],
271 OPENSSL_ITEM parameters[]);
272int STORE_store_public_key(STORE *e, EVP_PKEY *data, OPENSSL_ITEM attributes[],
273 OPENSSL_ITEM parameters[]);
274int STORE_modify_public_key(STORE *e, OPENSSL_ITEM search_attributes[],
275 OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[],
276 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
277int STORE_revoke_public_key(STORE *e, OPENSSL_ITEM attributes[],
278 OPENSSL_ITEM parameters[]);
279int STORE_delete_public_key(STORE *e, OPENSSL_ITEM attributes[],
280 OPENSSL_ITEM parameters[]);
281void *STORE_list_public_key_start(STORE *e, OPENSSL_ITEM attributes[],
282 OPENSSL_ITEM parameters[]);
283EVP_PKEY *STORE_list_public_key_next(STORE *e, void *handle);
284int STORE_list_public_key_end(STORE *e, void *handle);
285int STORE_list_public_key_endp(STORE *e, void *handle);
286X509_CRL *STORE_generate_crl(STORE *e, OPENSSL_ITEM attributes[],
287 OPENSSL_ITEM parameters[]);
288X509_CRL *STORE_get_crl(STORE *e, OPENSSL_ITEM attributes[],
289 OPENSSL_ITEM parameters[]);
290int STORE_store_crl(STORE *e, X509_CRL *data, OPENSSL_ITEM attributes[],
291 OPENSSL_ITEM parameters[]);
292int STORE_modify_crl(STORE *e, OPENSSL_ITEM search_attributes[],
293 OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[],
294 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
295int STORE_delete_crl(STORE *e, OPENSSL_ITEM attributes[],
296 OPENSSL_ITEM parameters[]);
297void *STORE_list_crl_start(STORE *e, OPENSSL_ITEM attributes[],
298 OPENSSL_ITEM parameters[]);
299X509_CRL *STORE_list_crl_next(STORE *e, void *handle);
300int STORE_list_crl_end(STORE *e, void *handle);
301int STORE_list_crl_endp(STORE *e, void *handle);
302int STORE_store_number(STORE *e, BIGNUM *data, OPENSSL_ITEM attributes[],
303 OPENSSL_ITEM parameters[]);
304int STORE_modify_number(STORE *e, OPENSSL_ITEM search_attributes[],
305 OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[],
306 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
307BIGNUM *STORE_get_number(STORE *e, OPENSSL_ITEM attributes[],
308 OPENSSL_ITEM parameters[]);
309int STORE_delete_number(STORE *e, OPENSSL_ITEM attributes[],
310 OPENSSL_ITEM parameters[]);
311int STORE_store_arbitrary(STORE *e, BUF_MEM *data, OPENSSL_ITEM attributes[],
312 OPENSSL_ITEM parameters[]);
313int STORE_modify_arbitrary(STORE *e, OPENSSL_ITEM search_attributes[],
314 OPENSSL_ITEM add_sttributes[], OPENSSL_ITEM modify_attributes[],
315 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
316BUF_MEM *STORE_get_arbitrary(STORE *e, OPENSSL_ITEM attributes[],
317 OPENSSL_ITEM parameters[]);
318int STORE_delete_arbitrary(STORE *e, OPENSSL_ITEM attributes[],
319 OPENSSL_ITEM parameters[]);
320
321
322/* Create and manipulate methods */
323STORE_METHOD *STORE_create_method(char *name);
324void STORE_destroy_method(STORE_METHOD *store_method);
325
326/* These callback types are use for store handlers */
327typedef int (*STORE_INITIALISE_FUNC_PTR)(STORE *);
328typedef void (*STORE_CLEANUP_FUNC_PTR)(STORE *);
329typedef STORE_OBJECT *(*STORE_GENERATE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
330typedef STORE_OBJECT *(*STORE_GET_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
331typedef void *(*STORE_START_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
332typedef STORE_OBJECT *(*STORE_NEXT_OBJECT_FUNC_PTR)(STORE *, void *handle);
333typedef int (*STORE_END_OBJECT_FUNC_PTR)(STORE *, void *handle);
334typedef int (*STORE_HANDLE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
335typedef int (*STORE_STORE_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, STORE_OBJECT *data, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
336typedef int (*STORE_MODIFY_OBJECT_FUNC_PTR)(STORE *, STORE_OBJECT_TYPES type, OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[]);
337typedef int (*STORE_GENERIC_FUNC_PTR)(STORE *, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
338typedef int (*STORE_CTRL_FUNC_PTR)(STORE *, int cmd, long l, void *p, void (*f)(void));
339
340int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f);
341int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f);
342int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f);
343int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f);
344int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f);
345int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR store_f);
346int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f);
347int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f);
348int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f);
349int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f);
350int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f);
351int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR);
352int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR);
353int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR);
354int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f);
355
356STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm);
357STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm);
358STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm);
359STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm);
360STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm);
361STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm);
362STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm);
363STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm);
364STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm);
365STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm);
366STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm);
367STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm);
368STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm);
369STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm);
370STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm);
371
372/* Method helper structures and functions. */
373
374/* This structure is the result of parsing through the information in a list
375 of OPENSSL_ITEMs. It stores all the necessary information in a structured
376 way.*/
377typedef struct STORE_attr_info_st STORE_ATTR_INFO;
378
379/* Parse a list of OPENSSL_ITEMs and return a pointer to a STORE_ATTR_INFO.
380 Note that we do this in the list form, since the list of OPENSSL_ITEMs can
381 come in blocks separated with STORE_ATTR_OR. Note that the value returned
382 by STORE_parse_attrs_next() must be freed with STORE_ATTR_INFO_free(). */
383void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes);
384STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle);
385int STORE_parse_attrs_end(void *handle);
386int STORE_parse_attrs_endp(void *handle);
387
388/* Creator and destructor */
389STORE_ATTR_INFO *STORE_ATTR_INFO_new(void);
390int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs);
391
392/* Manipulators */
393char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code);
394unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs,
395 STORE_ATTR_TYPES code);
396X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code);
397BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code);
398int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
399 char *cstr, size_t cstr_size);
400int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
401 unsigned char *sha1str, size_t sha1str_size);
402int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
403 X509_NAME *dn);
404int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
405 BIGNUM *number);
406int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
407 char *cstr, size_t cstr_size);
408int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
409 unsigned char *sha1str, size_t sha1str_size);
410int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
411 X509_NAME *dn);
412int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
413 BIGNUM *number);
414
415/* Compare on basis of a bit pattern formed by the STORE_ATTR_TYPES values
416 in each contained attribute. */
417int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a,
418 const STORE_ATTR_INFO * const *b);
419/* Check if the set of attributes in a is within the range of attributes
420 set in b. */
421int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b);
422/* Check if the set of attributes in a are also set in b. */
423int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b);
424/* Same as STORE_ATTR_INFO_in(), but also checks the attribute values. */
425int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b);
426
427
428/* BEGIN ERROR CODES */
429/* The following lines are auto generated by the script mkerr.pl. Any changes
430 * made after this point may be overwritten when the script is next run.
431 */
432void ERR_load_STORE_strings(void);
433
434/* Error codes for the STORE functions. */
435
436/* Function codes. */
437#define STORE_F_MEM_DELETE 134
438#define STORE_F_MEM_GENERATE 135
439#define STORE_F_MEM_LIST_END 168
440#define STORE_F_MEM_LIST_NEXT 136
441#define STORE_F_MEM_LIST_START 137
442#define STORE_F_MEM_MODIFY 169
443#define STORE_F_MEM_STORE 138
444#define STORE_F_STORE_ATTR_INFO_GET0_CSTR 139
445#define STORE_F_STORE_ATTR_INFO_GET0_DN 140
446#define STORE_F_STORE_ATTR_INFO_GET0_NUMBER 141
447#define STORE_F_STORE_ATTR_INFO_GET0_SHA1STR 142
448#define STORE_F_STORE_ATTR_INFO_MODIFY_CSTR 143
449#define STORE_F_STORE_ATTR_INFO_MODIFY_DN 144
450#define STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER 145
451#define STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR 146
452#define STORE_F_STORE_ATTR_INFO_SET_CSTR 147
453#define STORE_F_STORE_ATTR_INFO_SET_DN 148
454#define STORE_F_STORE_ATTR_INFO_SET_NUMBER 149
455#define STORE_F_STORE_ATTR_INFO_SET_SHA1STR 150
456#define STORE_F_STORE_CERTIFICATE 170
457#define STORE_F_STORE_CTRL 161
458#define STORE_F_STORE_DELETE_ARBITRARY 158
459#define STORE_F_STORE_DELETE_CERTIFICATE 102
460#define STORE_F_STORE_DELETE_CRL 103
461#define STORE_F_STORE_DELETE_NUMBER 104
462#define STORE_F_STORE_DELETE_PRIVATE_KEY 105
463#define STORE_F_STORE_DELETE_PUBLIC_KEY 106
464#define STORE_F_STORE_GENERATE_CRL 107
465#define STORE_F_STORE_GENERATE_KEY 108
466#define STORE_F_STORE_GET_ARBITRARY 159
467#define STORE_F_STORE_GET_CERTIFICATE 109
468#define STORE_F_STORE_GET_CRL 110
469#define STORE_F_STORE_GET_NUMBER 111
470#define STORE_F_STORE_GET_PRIVATE_KEY 112
471#define STORE_F_STORE_GET_PUBLIC_KEY 113
472#define STORE_F_STORE_LIST_CERTIFICATE_END 114
473#define STORE_F_STORE_LIST_CERTIFICATE_ENDP 153
474#define STORE_F_STORE_LIST_CERTIFICATE_NEXT 115
475#define STORE_F_STORE_LIST_CERTIFICATE_START 116
476#define STORE_F_STORE_LIST_CRL_END 117
477#define STORE_F_STORE_LIST_CRL_ENDP 154
478#define STORE_F_STORE_LIST_CRL_NEXT 118
479#define STORE_F_STORE_LIST_CRL_START 119
480#define STORE_F_STORE_LIST_PRIVATE_KEY_END 120
481#define STORE_F_STORE_LIST_PRIVATE_KEY_ENDP 155
482#define STORE_F_STORE_LIST_PRIVATE_KEY_NEXT 121
483#define STORE_F_STORE_LIST_PRIVATE_KEY_START 122
484#define STORE_F_STORE_LIST_PUBLIC_KEY_END 123
485#define STORE_F_STORE_LIST_PUBLIC_KEY_ENDP 156
486#define STORE_F_STORE_LIST_PUBLIC_KEY_NEXT 124
487#define STORE_F_STORE_LIST_PUBLIC_KEY_START 125
488#define STORE_F_STORE_MODIFY_ARBITRARY 162
489#define STORE_F_STORE_MODIFY_CERTIFICATE 163
490#define STORE_F_STORE_MODIFY_CRL 164
491#define STORE_F_STORE_MODIFY_NUMBER 165
492#define STORE_F_STORE_MODIFY_PRIVATE_KEY 166
493#define STORE_F_STORE_MODIFY_PUBLIC_KEY 167
494#define STORE_F_STORE_NEW_ENGINE 133
495#define STORE_F_STORE_NEW_METHOD 132
496#define STORE_F_STORE_PARSE_ATTRS_END 151
497#define STORE_F_STORE_PARSE_ATTRS_ENDP 172
498#define STORE_F_STORE_PARSE_ATTRS_NEXT 152
499#define STORE_F_STORE_PARSE_ATTRS_START 171
500#define STORE_F_STORE_REVOKE_CERTIFICATE 129
501#define STORE_F_STORE_REVOKE_PRIVATE_KEY 130
502#define STORE_F_STORE_REVOKE_PUBLIC_KEY 131
503#define STORE_F_STORE_STORE_ARBITRARY 157
504#define STORE_F_STORE_STORE_CERTIFICATE 100
505#define STORE_F_STORE_STORE_CRL 101
506#define STORE_F_STORE_STORE_NUMBER 126
507#define STORE_F_STORE_STORE_PRIVATE_KEY 127
508#define STORE_F_STORE_STORE_PUBLIC_KEY 128
509
510/* Reason codes. */
511#define STORE_R_ALREADY_HAS_A_VALUE 127
512#define STORE_R_FAILED_DELETING_ARBITRARY 132
513#define STORE_R_FAILED_DELETING_CERTIFICATE 100
514#define STORE_R_FAILED_DELETING_KEY 101
515#define STORE_R_FAILED_DELETING_NUMBER 102
516#define STORE_R_FAILED_GENERATING_CRL 103
517#define STORE_R_FAILED_GENERATING_KEY 104
518#define STORE_R_FAILED_GETTING_ARBITRARY 133
519#define STORE_R_FAILED_GETTING_CERTIFICATE 105
520#define STORE_R_FAILED_GETTING_KEY 106
521#define STORE_R_FAILED_GETTING_NUMBER 107
522#define STORE_R_FAILED_LISTING_CERTIFICATES 108
523#define STORE_R_FAILED_LISTING_KEYS 109
524#define STORE_R_FAILED_MODIFYING_ARBITRARY 138
525#define STORE_R_FAILED_MODIFYING_CERTIFICATE 139
526#define STORE_R_FAILED_MODIFYING_CRL 140
527#define STORE_R_FAILED_MODIFYING_NUMBER 141
528#define STORE_R_FAILED_MODIFYING_PRIVATE_KEY 142
529#define STORE_R_FAILED_MODIFYING_PUBLIC_KEY 143
530#define STORE_R_FAILED_REVOKING_CERTIFICATE 110
531#define STORE_R_FAILED_REVOKING_KEY 111
532#define STORE_R_FAILED_STORING_ARBITRARY 134
533#define STORE_R_FAILED_STORING_CERTIFICATE 112
534#define STORE_R_FAILED_STORING_KEY 113
535#define STORE_R_FAILED_STORING_NUMBER 114
536#define STORE_R_NOT_IMPLEMENTED 128
537#define STORE_R_NO_CONTROL_FUNCTION 144
538#define STORE_R_NO_DELETE_ARBITRARY_FUNCTION 135
539#define STORE_R_NO_DELETE_NUMBER_FUNCTION 115
540#define STORE_R_NO_DELETE_OBJECT_FUNCTION 116
541#define STORE_R_NO_GENERATE_CRL_FUNCTION 117
542#define STORE_R_NO_GENERATE_OBJECT_FUNCTION 118
543#define STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION 136
544#define STORE_R_NO_GET_OBJECT_FUNCTION 119
545#define STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION 120
546#define STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION 131
547#define STORE_R_NO_LIST_OBJECT_END_FUNCTION 121
548#define STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION 122
549#define STORE_R_NO_LIST_OBJECT_START_FUNCTION 123
550#define STORE_R_NO_MODIFY_OBJECT_FUNCTION 145
551#define STORE_R_NO_REVOKE_OBJECT_FUNCTION 124
552#define STORE_R_NO_STORE 129
553#define STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION 137
554#define STORE_R_NO_STORE_OBJECT_FUNCTION 125
555#define STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION 126
556#define STORE_R_NO_VALUE 130
557
558#ifdef __cplusplus
559}
560#endif
561#endif
diff --git a/src/lib/libcrypto/store/str_err.c b/src/lib/libcrypto/store/str_err.c
new file mode 100644
index 0000000000..924edf0505
--- /dev/null
+++ b/src/lib/libcrypto/store/str_err.c
@@ -0,0 +1,211 @@
1/* crypto/store/str_err.c */
2/* ====================================================================
3 * Copyright (c) 1999-2006 The OpenSSL Project. 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@OpenSSL.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56/* NOTE: this file was auto generated by the mkerr.pl script: any changes
57 * made to it will be overwritten when the script next updates this file,
58 * only reason strings will be preserved.
59 */
60
61#include <stdio.h>
62#include <openssl/err.h>
63#include <openssl/store.h>
64
65/* BEGIN ERROR CODES */
66#ifndef OPENSSL_NO_ERR
67
68#define ERR_FUNC(func) ERR_PACK(ERR_LIB_STORE,func,0)
69#define ERR_REASON(reason) ERR_PACK(ERR_LIB_STORE,0,reason)
70
71static ERR_STRING_DATA STORE_str_functs[]=
72 {
73{ERR_FUNC(STORE_F_MEM_DELETE), "MEM_DELETE"},
74{ERR_FUNC(STORE_F_MEM_GENERATE), "MEM_GENERATE"},
75{ERR_FUNC(STORE_F_MEM_LIST_END), "MEM_LIST_END"},
76{ERR_FUNC(STORE_F_MEM_LIST_NEXT), "MEM_LIST_NEXT"},
77{ERR_FUNC(STORE_F_MEM_LIST_START), "MEM_LIST_START"},
78{ERR_FUNC(STORE_F_MEM_MODIFY), "MEM_MODIFY"},
79{ERR_FUNC(STORE_F_MEM_STORE), "MEM_STORE"},
80{ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_CSTR), "STORE_ATTR_INFO_get0_cstr"},
81{ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_DN), "STORE_ATTR_INFO_get0_dn"},
82{ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_NUMBER), "STORE_ATTR_INFO_get0_number"},
83{ERR_FUNC(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR), "STORE_ATTR_INFO_get0_sha1str"},
84{ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR), "STORE_ATTR_INFO_modify_cstr"},
85{ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_DN), "STORE_ATTR_INFO_modify_dn"},
86{ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER), "STORE_ATTR_INFO_modify_number"},
87{ERR_FUNC(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR), "STORE_ATTR_INFO_modify_sha1str"},
88{ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_CSTR), "STORE_ATTR_INFO_set_cstr"},
89{ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_DN), "STORE_ATTR_INFO_set_dn"},
90{ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_NUMBER), "STORE_ATTR_INFO_set_number"},
91{ERR_FUNC(STORE_F_STORE_ATTR_INFO_SET_SHA1STR), "STORE_ATTR_INFO_set_sha1str"},
92{ERR_FUNC(STORE_F_STORE_CERTIFICATE), "STORE_CERTIFICATE"},
93{ERR_FUNC(STORE_F_STORE_CTRL), "STORE_ctrl"},
94{ERR_FUNC(STORE_F_STORE_DELETE_ARBITRARY), "STORE_delete_arbitrary"},
95{ERR_FUNC(STORE_F_STORE_DELETE_CERTIFICATE), "STORE_delete_certificate"},
96{ERR_FUNC(STORE_F_STORE_DELETE_CRL), "STORE_delete_crl"},
97{ERR_FUNC(STORE_F_STORE_DELETE_NUMBER), "STORE_delete_number"},
98{ERR_FUNC(STORE_F_STORE_DELETE_PRIVATE_KEY), "STORE_delete_private_key"},
99{ERR_FUNC(STORE_F_STORE_DELETE_PUBLIC_KEY), "STORE_delete_public_key"},
100{ERR_FUNC(STORE_F_STORE_GENERATE_CRL), "STORE_generate_crl"},
101{ERR_FUNC(STORE_F_STORE_GENERATE_KEY), "STORE_generate_key"},
102{ERR_FUNC(STORE_F_STORE_GET_ARBITRARY), "STORE_get_arbitrary"},
103{ERR_FUNC(STORE_F_STORE_GET_CERTIFICATE), "STORE_get_certificate"},
104{ERR_FUNC(STORE_F_STORE_GET_CRL), "STORE_get_crl"},
105{ERR_FUNC(STORE_F_STORE_GET_NUMBER), "STORE_get_number"},
106{ERR_FUNC(STORE_F_STORE_GET_PRIVATE_KEY), "STORE_get_private_key"},
107{ERR_FUNC(STORE_F_STORE_GET_PUBLIC_KEY), "STORE_get_public_key"},
108{ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_END), "STORE_list_certificate_end"},
109{ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_ENDP), "STORE_list_certificate_endp"},
110{ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_NEXT), "STORE_list_certificate_next"},
111{ERR_FUNC(STORE_F_STORE_LIST_CERTIFICATE_START), "STORE_list_certificate_start"},
112{ERR_FUNC(STORE_F_STORE_LIST_CRL_END), "STORE_list_crl_end"},
113{ERR_FUNC(STORE_F_STORE_LIST_CRL_ENDP), "STORE_list_crl_endp"},
114{ERR_FUNC(STORE_F_STORE_LIST_CRL_NEXT), "STORE_list_crl_next"},
115{ERR_FUNC(STORE_F_STORE_LIST_CRL_START), "STORE_list_crl_start"},
116{ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_END), "STORE_list_private_key_end"},
117{ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP), "STORE_list_private_key_endp"},
118{ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT), "STORE_list_private_key_next"},
119{ERR_FUNC(STORE_F_STORE_LIST_PRIVATE_KEY_START), "STORE_list_private_key_start"},
120{ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_END), "STORE_list_public_key_end"},
121{ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP), "STORE_list_public_key_endp"},
122{ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT), "STORE_list_public_key_next"},
123{ERR_FUNC(STORE_F_STORE_LIST_PUBLIC_KEY_START), "STORE_list_public_key_start"},
124{ERR_FUNC(STORE_F_STORE_MODIFY_ARBITRARY), "STORE_modify_arbitrary"},
125{ERR_FUNC(STORE_F_STORE_MODIFY_CERTIFICATE), "STORE_modify_certificate"},
126{ERR_FUNC(STORE_F_STORE_MODIFY_CRL), "STORE_modify_crl"},
127{ERR_FUNC(STORE_F_STORE_MODIFY_NUMBER), "STORE_modify_number"},
128{ERR_FUNC(STORE_F_STORE_MODIFY_PRIVATE_KEY), "STORE_modify_private_key"},
129{ERR_FUNC(STORE_F_STORE_MODIFY_PUBLIC_KEY), "STORE_modify_public_key"},
130{ERR_FUNC(STORE_F_STORE_NEW_ENGINE), "STORE_new_engine"},
131{ERR_FUNC(STORE_F_STORE_NEW_METHOD), "STORE_new_method"},
132{ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_END), "STORE_parse_attrs_end"},
133{ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_ENDP), "STORE_parse_attrs_endp"},
134{ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_NEXT), "STORE_parse_attrs_next"},
135{ERR_FUNC(STORE_F_STORE_PARSE_ATTRS_START), "STORE_parse_attrs_start"},
136{ERR_FUNC(STORE_F_STORE_REVOKE_CERTIFICATE), "STORE_revoke_certificate"},
137{ERR_FUNC(STORE_F_STORE_REVOKE_PRIVATE_KEY), "STORE_revoke_private_key"},
138{ERR_FUNC(STORE_F_STORE_REVOKE_PUBLIC_KEY), "STORE_revoke_public_key"},
139{ERR_FUNC(STORE_F_STORE_STORE_ARBITRARY), "STORE_store_arbitrary"},
140{ERR_FUNC(STORE_F_STORE_STORE_CERTIFICATE), "STORE_store_certificate"},
141{ERR_FUNC(STORE_F_STORE_STORE_CRL), "STORE_store_crl"},
142{ERR_FUNC(STORE_F_STORE_STORE_NUMBER), "STORE_store_number"},
143{ERR_FUNC(STORE_F_STORE_STORE_PRIVATE_KEY), "STORE_store_private_key"},
144{ERR_FUNC(STORE_F_STORE_STORE_PUBLIC_KEY), "STORE_store_public_key"},
145{0,NULL}
146 };
147
148static ERR_STRING_DATA STORE_str_reasons[]=
149 {
150{ERR_REASON(STORE_R_ALREADY_HAS_A_VALUE) ,"already has a value"},
151{ERR_REASON(STORE_R_FAILED_DELETING_ARBITRARY),"failed deleting arbitrary"},
152{ERR_REASON(STORE_R_FAILED_DELETING_CERTIFICATE),"failed deleting certificate"},
153{ERR_REASON(STORE_R_FAILED_DELETING_KEY) ,"failed deleting key"},
154{ERR_REASON(STORE_R_FAILED_DELETING_NUMBER),"failed deleting number"},
155{ERR_REASON(STORE_R_FAILED_GENERATING_CRL),"failed generating crl"},
156{ERR_REASON(STORE_R_FAILED_GENERATING_KEY),"failed generating key"},
157{ERR_REASON(STORE_R_FAILED_GETTING_ARBITRARY),"failed getting arbitrary"},
158{ERR_REASON(STORE_R_FAILED_GETTING_CERTIFICATE),"failed getting certificate"},
159{ERR_REASON(STORE_R_FAILED_GETTING_KEY) ,"failed getting key"},
160{ERR_REASON(STORE_R_FAILED_GETTING_NUMBER),"failed getting number"},
161{ERR_REASON(STORE_R_FAILED_LISTING_CERTIFICATES),"failed listing certificates"},
162{ERR_REASON(STORE_R_FAILED_LISTING_KEYS) ,"failed listing keys"},
163{ERR_REASON(STORE_R_FAILED_MODIFYING_ARBITRARY),"failed modifying arbitrary"},
164{ERR_REASON(STORE_R_FAILED_MODIFYING_CERTIFICATE),"failed modifying certificate"},
165{ERR_REASON(STORE_R_FAILED_MODIFYING_CRL),"failed modifying crl"},
166{ERR_REASON(STORE_R_FAILED_MODIFYING_NUMBER),"failed modifying number"},
167{ERR_REASON(STORE_R_FAILED_MODIFYING_PRIVATE_KEY),"failed modifying private key"},
168{ERR_REASON(STORE_R_FAILED_MODIFYING_PUBLIC_KEY),"failed modifying public key"},
169{ERR_REASON(STORE_R_FAILED_REVOKING_CERTIFICATE),"failed revoking certificate"},
170{ERR_REASON(STORE_R_FAILED_REVOKING_KEY) ,"failed revoking key"},
171{ERR_REASON(STORE_R_FAILED_STORING_ARBITRARY),"failed storing arbitrary"},
172{ERR_REASON(STORE_R_FAILED_STORING_CERTIFICATE),"failed storing certificate"},
173{ERR_REASON(STORE_R_FAILED_STORING_KEY) ,"failed storing key"},
174{ERR_REASON(STORE_R_FAILED_STORING_NUMBER),"failed storing number"},
175{ERR_REASON(STORE_R_NOT_IMPLEMENTED) ,"not implemented"},
176{ERR_REASON(STORE_R_NO_CONTROL_FUNCTION) ,"no control function"},
177{ERR_REASON(STORE_R_NO_DELETE_ARBITRARY_FUNCTION),"no delete arbitrary function"},
178{ERR_REASON(STORE_R_NO_DELETE_NUMBER_FUNCTION),"no delete number function"},
179{ERR_REASON(STORE_R_NO_DELETE_OBJECT_FUNCTION),"no delete object function"},
180{ERR_REASON(STORE_R_NO_GENERATE_CRL_FUNCTION),"no generate crl function"},
181{ERR_REASON(STORE_R_NO_GENERATE_OBJECT_FUNCTION),"no generate object function"},
182{ERR_REASON(STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION),"no get object arbitrary function"},
183{ERR_REASON(STORE_R_NO_GET_OBJECT_FUNCTION),"no get object function"},
184{ERR_REASON(STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION),"no get object number function"},
185{ERR_REASON(STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION),"no list object endp function"},
186{ERR_REASON(STORE_R_NO_LIST_OBJECT_END_FUNCTION),"no list object end function"},
187{ERR_REASON(STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION),"no list object next function"},
188{ERR_REASON(STORE_R_NO_LIST_OBJECT_START_FUNCTION),"no list object start function"},
189{ERR_REASON(STORE_R_NO_MODIFY_OBJECT_FUNCTION),"no modify object function"},
190{ERR_REASON(STORE_R_NO_REVOKE_OBJECT_FUNCTION),"no revoke object function"},
191{ERR_REASON(STORE_R_NO_STORE) ,"no store"},
192{ERR_REASON(STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION),"no store object arbitrary function"},
193{ERR_REASON(STORE_R_NO_STORE_OBJECT_FUNCTION),"no store object function"},
194{ERR_REASON(STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION),"no store object number function"},
195{ERR_REASON(STORE_R_NO_VALUE) ,"no value"},
196{0,NULL}
197 };
198
199#endif
200
201void ERR_load_STORE_strings(void)
202 {
203#ifndef OPENSSL_NO_ERR
204
205 if (ERR_func_error_string(STORE_str_functs[0].error) == NULL)
206 {
207 ERR_load_strings(0,STORE_str_functs);
208 ERR_load_strings(0,STORE_str_reasons);
209 }
210#endif
211 }
diff --git a/src/lib/libcrypto/store/str_lib.c b/src/lib/libcrypto/store/str_lib.c
new file mode 100644
index 0000000000..f1dbcbd0e0
--- /dev/null
+++ b/src/lib/libcrypto/store/str_lib.c
@@ -0,0 +1,1828 @@
1/* crypto/store/str_lib.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2003.
4 */
5/* ====================================================================
6 * Copyright (c) 2003 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * openssl-core@openssl.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <string.h>
60#include <openssl/bn.h>
61#include <openssl/err.h>
62#ifndef OPENSSL_NO_ENGINE
63#include <openssl/engine.h>
64#endif
65#include <openssl/sha.h>
66#include <openssl/x509.h>
67#include "str_locl.h"
68
69const char * const STORE_object_type_string[STORE_OBJECT_TYPE_NUM+1] =
70 {
71 0,
72 "X.509 Certificate",
73 "X.509 CRL",
74 "Private Key",
75 "Public Key",
76 "Number",
77 "Arbitrary Data"
78 };
79
80const int STORE_param_sizes[STORE_PARAM_TYPE_NUM+1] =
81 {
82 0,
83 sizeof(int), /* EVP_TYPE */
84 sizeof(size_t), /* BITS */
85 -1, /* KEY_PARAMETERS */
86 0 /* KEY_NO_PARAMETERS */
87 };
88
89const int STORE_attr_sizes[STORE_ATTR_TYPE_NUM+1] =
90 {
91 0,
92 -1, /* FRIENDLYNAME: C string */
93 SHA_DIGEST_LENGTH, /* KEYID: SHA1 digest, 160 bits */
94 SHA_DIGEST_LENGTH, /* ISSUERKEYID: SHA1 digest, 160 bits */
95 SHA_DIGEST_LENGTH, /* SUBJECTKEYID: SHA1 digest, 160 bits */
96 SHA_DIGEST_LENGTH, /* ISSUERSERIALHASH: SHA1 digest, 160 bits */
97 sizeof(X509_NAME *), /* ISSUER: X509_NAME * */
98 sizeof(BIGNUM *), /* SERIAL: BIGNUM * */
99 sizeof(X509_NAME *), /* SUBJECT: X509_NAME * */
100 SHA_DIGEST_LENGTH, /* CERTHASH: SHA1 digest, 160 bits */
101 -1, /* EMAIL: C string */
102 -1, /* FILENAME: C string */
103 };
104
105STORE *STORE_new_method(const STORE_METHOD *method)
106 {
107 STORE *ret;
108
109 if (method == NULL)
110 {
111 STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_PASSED_NULL_PARAMETER);
112 return NULL;
113 }
114
115 ret=(STORE *)OPENSSL_malloc(sizeof(STORE));
116 if (ret == NULL)
117 {
118 STOREerr(STORE_F_STORE_NEW_METHOD,ERR_R_MALLOC_FAILURE);
119 return NULL;
120 }
121
122 ret->meth=method;
123
124 CRYPTO_new_ex_data(CRYPTO_EX_INDEX_STORE, ret, &ret->ex_data);
125 if (ret->meth->init && !ret->meth->init(ret))
126 {
127 STORE_free(ret);
128 ret = NULL;
129 }
130 return ret;
131 }
132
133STORE *STORE_new_engine(ENGINE *engine)
134 {
135 STORE *ret = NULL;
136 ENGINE *e = engine;
137 const STORE_METHOD *meth = 0;
138
139#ifdef OPENSSL_NO_ENGINE
140 e = NULL;
141#else
142 if (engine)
143 {
144 if (!ENGINE_init(engine))
145 {
146 STOREerr(STORE_F_STORE_NEW_ENGINE, ERR_R_ENGINE_LIB);
147 return NULL;
148 }
149 e = engine;
150 }
151 else
152 {
153 STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_PASSED_NULL_PARAMETER);
154 return NULL;
155 }
156 if(e)
157 {
158 meth = ENGINE_get_STORE(e);
159 if(!meth)
160 {
161 STOREerr(STORE_F_STORE_NEW_ENGINE,
162 ERR_R_ENGINE_LIB);
163 ENGINE_finish(e);
164 return NULL;
165 }
166 }
167#endif
168
169 ret = STORE_new_method(meth);
170 if (ret == NULL)
171 {
172 STOREerr(STORE_F_STORE_NEW_ENGINE,ERR_R_STORE_LIB);
173 return NULL;
174 }
175
176 ret->engine = e;
177
178 return(ret);
179 }
180
181void STORE_free(STORE *store)
182 {
183 if (store == NULL)
184 return;
185 if (store->meth->clean)
186 store->meth->clean(store);
187 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_STORE, store, &store->ex_data);
188 OPENSSL_free(store);
189 }
190
191int STORE_ctrl(STORE *store, int cmd, long i, void *p, void (*f)(void))
192 {
193 if (store == NULL)
194 {
195 STOREerr(STORE_F_STORE_CTRL,ERR_R_PASSED_NULL_PARAMETER);
196 return 0;
197 }
198 if (store->meth->ctrl)
199 return store->meth->ctrl(store, cmd, i, p, f);
200 STOREerr(STORE_F_STORE_CTRL,STORE_R_NO_CONTROL_FUNCTION);
201 return 0;
202 }
203
204
205int STORE_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
206 CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
207 {
208 return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_STORE, argl, argp,
209 new_func, dup_func, free_func);
210 }
211
212int STORE_set_ex_data(STORE *r, int idx, void *arg)
213 {
214 return(CRYPTO_set_ex_data(&r->ex_data,idx,arg));
215 }
216
217void *STORE_get_ex_data(STORE *r, int idx)
218 {
219 return(CRYPTO_get_ex_data(&r->ex_data,idx));
220 }
221
222const STORE_METHOD *STORE_get_method(STORE *store)
223 {
224 return store->meth;
225 }
226
227const STORE_METHOD *STORE_set_method(STORE *store, const STORE_METHOD *meth)
228 {
229 store->meth=meth;
230 return store->meth;
231 }
232
233
234/* API helpers */
235
236#define check_store(s,fncode,fnname,fnerrcode) \
237 do \
238 { \
239 if ((s) == NULL || (s)->meth == NULL) \
240 { \
241 STOREerr((fncode), ERR_R_PASSED_NULL_PARAMETER); \
242 return 0; \
243 } \
244 if ((s)->meth->fnname == NULL) \
245 { \
246 STOREerr((fncode), (fnerrcode)); \
247 return 0; \
248 } \
249 } \
250 while(0)
251
252/* API functions */
253
254X509 *STORE_get_certificate(STORE *s, OPENSSL_ITEM attributes[],
255 OPENSSL_ITEM parameters[])
256 {
257 STORE_OBJECT *object;
258 X509 *x;
259
260 check_store(s,STORE_F_STORE_GET_CERTIFICATE,
261 get_object,STORE_R_NO_GET_OBJECT_FUNCTION);
262
263 object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE,
264 attributes, parameters);
265 if (!object || !object->data.x509.certificate)
266 {
267 STOREerr(STORE_F_STORE_GET_CERTIFICATE,
268 STORE_R_FAILED_GETTING_CERTIFICATE);
269 return 0;
270 }
271 CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509);
272#ifdef REF_PRINT
273 REF_PRINT("X509",data);
274#endif
275 x = object->data.x509.certificate;
276 STORE_OBJECT_free(object);
277 return x;
278 }
279
280int STORE_store_certificate(STORE *s, X509 *data, OPENSSL_ITEM attributes[],
281 OPENSSL_ITEM parameters[])
282 {
283 STORE_OBJECT *object;
284 int i;
285
286 check_store(s,STORE_F_STORE_CERTIFICATE,
287 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
288
289 object = STORE_OBJECT_new();
290 if (!object)
291 {
292 STOREerr(STORE_F_STORE_STORE_CERTIFICATE,
293 ERR_R_MALLOC_FAILURE);
294 return 0;
295 }
296
297 CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509);
298#ifdef REF_PRINT
299 REF_PRINT("X509",data);
300#endif
301 object->data.x509.certificate = data;
302
303 i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE,
304 object, attributes, parameters);
305
306 STORE_OBJECT_free(object);
307
308 if (!i)
309 {
310 STOREerr(STORE_F_STORE_STORE_CERTIFICATE,
311 STORE_R_FAILED_STORING_CERTIFICATE);
312 return 0;
313 }
314 return 1;
315 }
316
317int STORE_modify_certificate(STORE *s, OPENSSL_ITEM search_attributes[],
318 OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[],
319 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[])
320 {
321 check_store(s,STORE_F_STORE_MODIFY_CERTIFICATE,
322 modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION);
323
324 if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE,
325 search_attributes, add_attributes, modify_attributes,
326 delete_attributes, parameters))
327 {
328 STOREerr(STORE_F_STORE_MODIFY_CERTIFICATE,
329 STORE_R_FAILED_MODIFYING_CERTIFICATE);
330 return 0;
331 }
332 return 1;
333 }
334
335int STORE_revoke_certificate(STORE *s, OPENSSL_ITEM attributes[],
336 OPENSSL_ITEM parameters[])
337 {
338 check_store(s,STORE_F_STORE_REVOKE_CERTIFICATE,
339 revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION);
340
341 if (!s->meth->revoke_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE,
342 attributes, parameters))
343 {
344 STOREerr(STORE_F_STORE_REVOKE_CERTIFICATE,
345 STORE_R_FAILED_REVOKING_CERTIFICATE);
346 return 0;
347 }
348 return 1;
349 }
350
351int STORE_delete_certificate(STORE *s, OPENSSL_ITEM attributes[],
352 OPENSSL_ITEM parameters[])
353 {
354 check_store(s,STORE_F_STORE_DELETE_CERTIFICATE,
355 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
356
357 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CERTIFICATE,
358 attributes, parameters))
359 {
360 STOREerr(STORE_F_STORE_DELETE_CERTIFICATE,
361 STORE_R_FAILED_DELETING_CERTIFICATE);
362 return 0;
363 }
364 return 1;
365 }
366
367void *STORE_list_certificate_start(STORE *s, OPENSSL_ITEM attributes[],
368 OPENSSL_ITEM parameters[])
369 {
370 void *handle;
371
372 check_store(s,STORE_F_STORE_LIST_CERTIFICATE_START,
373 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
374
375 handle = s->meth->list_object_start(s,
376 STORE_OBJECT_TYPE_X509_CERTIFICATE, attributes, parameters);
377 if (!handle)
378 {
379 STOREerr(STORE_F_STORE_LIST_CERTIFICATE_START,
380 STORE_R_FAILED_LISTING_CERTIFICATES);
381 return 0;
382 }
383 return handle;
384 }
385
386X509 *STORE_list_certificate_next(STORE *s, void *handle)
387 {
388 STORE_OBJECT *object;
389 X509 *x;
390
391 check_store(s,STORE_F_STORE_LIST_CERTIFICATE_NEXT,
392 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
393
394 object = s->meth->list_object_next(s, handle);
395 if (!object || !object->data.x509.certificate)
396 {
397 STOREerr(STORE_F_STORE_LIST_CERTIFICATE_NEXT,
398 STORE_R_FAILED_LISTING_CERTIFICATES);
399 return 0;
400 }
401 CRYPTO_add(&object->data.x509.certificate->references,1,CRYPTO_LOCK_X509);
402#ifdef REF_PRINT
403 REF_PRINT("X509",data);
404#endif
405 x = object->data.x509.certificate;
406 STORE_OBJECT_free(object);
407 return x;
408 }
409
410int STORE_list_certificate_end(STORE *s, void *handle)
411 {
412 check_store(s,STORE_F_STORE_LIST_CERTIFICATE_END,
413 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
414
415 if (!s->meth->list_object_end(s, handle))
416 {
417 STOREerr(STORE_F_STORE_LIST_CERTIFICATE_END,
418 STORE_R_FAILED_LISTING_CERTIFICATES);
419 return 0;
420 }
421 return 1;
422 }
423
424int STORE_list_certificate_endp(STORE *s, void *handle)
425 {
426 check_store(s,STORE_F_STORE_LIST_CERTIFICATE_ENDP,
427 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
428
429 if (!s->meth->list_object_endp(s, handle))
430 {
431 STOREerr(STORE_F_STORE_LIST_CERTIFICATE_ENDP,
432 STORE_R_FAILED_LISTING_CERTIFICATES);
433 return 0;
434 }
435 return 1;
436 }
437
438EVP_PKEY *STORE_generate_key(STORE *s, OPENSSL_ITEM attributes[],
439 OPENSSL_ITEM parameters[])
440 {
441 STORE_OBJECT *object;
442 EVP_PKEY *pkey;
443
444 check_store(s,STORE_F_STORE_GENERATE_KEY,
445 generate_object,STORE_R_NO_GENERATE_OBJECT_FUNCTION);
446
447 object = s->meth->generate_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
448 attributes, parameters);
449 if (!object || !object->data.key)
450 {
451 STOREerr(STORE_F_STORE_GENERATE_KEY,
452 STORE_R_FAILED_GENERATING_KEY);
453 return 0;
454 }
455 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
456#ifdef REF_PRINT
457 REF_PRINT("EVP_PKEY",data);
458#endif
459 pkey = object->data.key;
460 STORE_OBJECT_free(object);
461 return pkey;
462 }
463
464EVP_PKEY *STORE_get_private_key(STORE *s, OPENSSL_ITEM attributes[],
465 OPENSSL_ITEM parameters[])
466 {
467 STORE_OBJECT *object;
468 EVP_PKEY *pkey;
469
470 check_store(s,STORE_F_STORE_GET_PRIVATE_KEY,
471 get_object,STORE_R_NO_GET_OBJECT_FUNCTION);
472
473 object = s->meth->get_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
474 attributes, parameters);
475 if (!object || !object->data.key || !object->data.key)
476 {
477 STOREerr(STORE_F_STORE_GET_PRIVATE_KEY,
478 STORE_R_FAILED_GETTING_KEY);
479 return 0;
480 }
481 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
482#ifdef REF_PRINT
483 REF_PRINT("EVP_PKEY",data);
484#endif
485 pkey = object->data.key;
486 STORE_OBJECT_free(object);
487 return pkey;
488 }
489
490int STORE_store_private_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[],
491 OPENSSL_ITEM parameters[])
492 {
493 STORE_OBJECT *object;
494 int i;
495
496 check_store(s,STORE_F_STORE_STORE_PRIVATE_KEY,
497 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
498
499 object = STORE_OBJECT_new();
500 if (!object)
501 {
502 STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY,
503 ERR_R_MALLOC_FAILURE);
504 return 0;
505 }
506 object->data.key = EVP_PKEY_new();
507 if (!object->data.key)
508 {
509 STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY,
510 ERR_R_MALLOC_FAILURE);
511 return 0;
512 }
513
514 CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY);
515#ifdef REF_PRINT
516 REF_PRINT("EVP_PKEY",data);
517#endif
518 object->data.key = data;
519
520 i = s->meth->store_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY, object,
521 attributes, parameters);
522
523 STORE_OBJECT_free(object);
524
525 if (!i)
526 {
527 STOREerr(STORE_F_STORE_STORE_PRIVATE_KEY,
528 STORE_R_FAILED_STORING_KEY);
529 return 0;
530 }
531 return i;
532 }
533
534int STORE_modify_private_key(STORE *s, OPENSSL_ITEM search_attributes[],
535 OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[],
536 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[])
537 {
538 check_store(s,STORE_F_STORE_MODIFY_PRIVATE_KEY,
539 modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION);
540
541 if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
542 search_attributes, add_attributes, modify_attributes,
543 delete_attributes, parameters))
544 {
545 STOREerr(STORE_F_STORE_MODIFY_PRIVATE_KEY,
546 STORE_R_FAILED_MODIFYING_PRIVATE_KEY);
547 return 0;
548 }
549 return 1;
550 }
551
552int STORE_revoke_private_key(STORE *s, OPENSSL_ITEM attributes[],
553 OPENSSL_ITEM parameters[])
554 {
555 int i;
556
557 check_store(s,STORE_F_STORE_REVOKE_PRIVATE_KEY,
558 revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION);
559
560 i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
561 attributes, parameters);
562
563 if (!i)
564 {
565 STOREerr(STORE_F_STORE_REVOKE_PRIVATE_KEY,
566 STORE_R_FAILED_REVOKING_KEY);
567 return 0;
568 }
569 return i;
570 }
571
572int STORE_delete_private_key(STORE *s, OPENSSL_ITEM attributes[],
573 OPENSSL_ITEM parameters[])
574 {
575 check_store(s,STORE_F_STORE_DELETE_PRIVATE_KEY,
576 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
577
578 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
579 attributes, parameters))
580 {
581 STOREerr(STORE_F_STORE_DELETE_PRIVATE_KEY,
582 STORE_R_FAILED_DELETING_KEY);
583 return 0;
584 }
585 return 1;
586 }
587
588void *STORE_list_private_key_start(STORE *s, OPENSSL_ITEM attributes[],
589 OPENSSL_ITEM parameters[])
590 {
591 void *handle;
592
593 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_START,
594 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
595
596 handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PRIVATE_KEY,
597 attributes, parameters);
598 if (!handle)
599 {
600 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_START,
601 STORE_R_FAILED_LISTING_KEYS);
602 return 0;
603 }
604 return handle;
605 }
606
607EVP_PKEY *STORE_list_private_key_next(STORE *s, void *handle)
608 {
609 STORE_OBJECT *object;
610 EVP_PKEY *pkey;
611
612 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_NEXT,
613 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
614
615 object = s->meth->list_object_next(s, handle);
616 if (!object || !object->data.key || !object->data.key)
617 {
618 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_NEXT,
619 STORE_R_FAILED_LISTING_KEYS);
620 return 0;
621 }
622 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
623#ifdef REF_PRINT
624 REF_PRINT("EVP_PKEY",data);
625#endif
626 pkey = object->data.key;
627 STORE_OBJECT_free(object);
628 return pkey;
629 }
630
631int STORE_list_private_key_end(STORE *s, void *handle)
632 {
633 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_END,
634 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
635
636 if (!s->meth->list_object_end(s, handle))
637 {
638 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_END,
639 STORE_R_FAILED_LISTING_KEYS);
640 return 0;
641 }
642 return 1;
643 }
644
645int STORE_list_private_key_endp(STORE *s, void *handle)
646 {
647 check_store(s,STORE_F_STORE_LIST_PRIVATE_KEY_ENDP,
648 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
649
650 if (!s->meth->list_object_endp(s, handle))
651 {
652 STOREerr(STORE_F_STORE_LIST_PRIVATE_KEY_ENDP,
653 STORE_R_FAILED_LISTING_KEYS);
654 return 0;
655 }
656 return 1;
657 }
658
659EVP_PKEY *STORE_get_public_key(STORE *s, OPENSSL_ITEM attributes[],
660 OPENSSL_ITEM parameters[])
661 {
662 STORE_OBJECT *object;
663 EVP_PKEY *pkey;
664
665 check_store(s,STORE_F_STORE_GET_PUBLIC_KEY,
666 get_object,STORE_R_NO_GET_OBJECT_FUNCTION);
667
668 object = s->meth->get_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
669 attributes, parameters);
670 if (!object || !object->data.key || !object->data.key)
671 {
672 STOREerr(STORE_F_STORE_GET_PUBLIC_KEY,
673 STORE_R_FAILED_GETTING_KEY);
674 return 0;
675 }
676 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
677#ifdef REF_PRINT
678 REF_PRINT("EVP_PKEY",data);
679#endif
680 pkey = object->data.key;
681 STORE_OBJECT_free(object);
682 return pkey;
683 }
684
685int STORE_store_public_key(STORE *s, EVP_PKEY *data, OPENSSL_ITEM attributes[],
686 OPENSSL_ITEM parameters[])
687 {
688 STORE_OBJECT *object;
689 int i;
690
691 check_store(s,STORE_F_STORE_STORE_PUBLIC_KEY,
692 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
693
694 object = STORE_OBJECT_new();
695 if (!object)
696 {
697 STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY,
698 ERR_R_MALLOC_FAILURE);
699 return 0;
700 }
701 object->data.key = EVP_PKEY_new();
702 if (!object->data.key)
703 {
704 STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY,
705 ERR_R_MALLOC_FAILURE);
706 return 0;
707 }
708
709 CRYPTO_add(&data->references,1,CRYPTO_LOCK_EVP_PKEY);
710#ifdef REF_PRINT
711 REF_PRINT("EVP_PKEY",data);
712#endif
713 object->data.key = data;
714
715 i = s->meth->store_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY, object,
716 attributes, parameters);
717
718 STORE_OBJECT_free(object);
719
720 if (!i)
721 {
722 STOREerr(STORE_F_STORE_STORE_PUBLIC_KEY,
723 STORE_R_FAILED_STORING_KEY);
724 return 0;
725 }
726 return i;
727 }
728
729int STORE_modify_public_key(STORE *s, OPENSSL_ITEM search_attributes[],
730 OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[],
731 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[])
732 {
733 check_store(s,STORE_F_STORE_MODIFY_PUBLIC_KEY,
734 modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION);
735
736 if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
737 search_attributes, add_attributes, modify_attributes,
738 delete_attributes, parameters))
739 {
740 STOREerr(STORE_F_STORE_MODIFY_PUBLIC_KEY,
741 STORE_R_FAILED_MODIFYING_PUBLIC_KEY);
742 return 0;
743 }
744 return 1;
745 }
746
747int STORE_revoke_public_key(STORE *s, OPENSSL_ITEM attributes[],
748 OPENSSL_ITEM parameters[])
749 {
750 int i;
751
752 check_store(s,STORE_F_STORE_REVOKE_PUBLIC_KEY,
753 revoke_object,STORE_R_NO_REVOKE_OBJECT_FUNCTION);
754
755 i = s->meth->revoke_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
756 attributes, parameters);
757
758 if (!i)
759 {
760 STOREerr(STORE_F_STORE_REVOKE_PUBLIC_KEY,
761 STORE_R_FAILED_REVOKING_KEY);
762 return 0;
763 }
764 return i;
765 }
766
767int STORE_delete_public_key(STORE *s, OPENSSL_ITEM attributes[],
768 OPENSSL_ITEM parameters[])
769 {
770 check_store(s,STORE_F_STORE_DELETE_PUBLIC_KEY,
771 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
772
773 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
774 attributes, parameters))
775 {
776 STOREerr(STORE_F_STORE_DELETE_PUBLIC_KEY,
777 STORE_R_FAILED_DELETING_KEY);
778 return 0;
779 }
780 return 1;
781 }
782
783void *STORE_list_public_key_start(STORE *s, OPENSSL_ITEM attributes[],
784 OPENSSL_ITEM parameters[])
785 {
786 void *handle;
787
788 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_START,
789 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
790
791 handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_PUBLIC_KEY,
792 attributes, parameters);
793 if (!handle)
794 {
795 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_START,
796 STORE_R_FAILED_LISTING_KEYS);
797 return 0;
798 }
799 return handle;
800 }
801
802EVP_PKEY *STORE_list_public_key_next(STORE *s, void *handle)
803 {
804 STORE_OBJECT *object;
805 EVP_PKEY *pkey;
806
807 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_NEXT,
808 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
809
810 object = s->meth->list_object_next(s, handle);
811 if (!object || !object->data.key || !object->data.key)
812 {
813 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_NEXT,
814 STORE_R_FAILED_LISTING_KEYS);
815 return 0;
816 }
817 CRYPTO_add(&object->data.key->references,1,CRYPTO_LOCK_EVP_PKEY);
818#ifdef REF_PRINT
819 REF_PRINT("EVP_PKEY",data);
820#endif
821 pkey = object->data.key;
822 STORE_OBJECT_free(object);
823 return pkey;
824 }
825
826int STORE_list_public_key_end(STORE *s, void *handle)
827 {
828 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_END,
829 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
830
831 if (!s->meth->list_object_end(s, handle))
832 {
833 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_END,
834 STORE_R_FAILED_LISTING_KEYS);
835 return 0;
836 }
837 return 1;
838 }
839
840int STORE_list_public_key_endp(STORE *s, void *handle)
841 {
842 check_store(s,STORE_F_STORE_LIST_PUBLIC_KEY_ENDP,
843 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
844
845 if (!s->meth->list_object_endp(s, handle))
846 {
847 STOREerr(STORE_F_STORE_LIST_PUBLIC_KEY_ENDP,
848 STORE_R_FAILED_LISTING_KEYS);
849 return 0;
850 }
851 return 1;
852 }
853
854X509_CRL *STORE_generate_crl(STORE *s, OPENSSL_ITEM attributes[],
855 OPENSSL_ITEM parameters[])
856 {
857 STORE_OBJECT *object;
858 X509_CRL *crl;
859
860 check_store(s,STORE_F_STORE_GENERATE_CRL,
861 generate_object,STORE_R_NO_GENERATE_CRL_FUNCTION);
862
863 object = s->meth->generate_object(s, STORE_OBJECT_TYPE_X509_CRL,
864 attributes, parameters);
865 if (!object || !object->data.crl)
866 {
867 STOREerr(STORE_F_STORE_GENERATE_CRL,
868 STORE_R_FAILED_GENERATING_CRL);
869 return 0;
870 }
871 CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL);
872#ifdef REF_PRINT
873 REF_PRINT("X509_CRL",data);
874#endif
875 crl = object->data.crl;
876 STORE_OBJECT_free(object);
877 return crl;
878 }
879
880X509_CRL *STORE_get_crl(STORE *s, OPENSSL_ITEM attributes[],
881 OPENSSL_ITEM parameters[])
882 {
883 STORE_OBJECT *object;
884 X509_CRL *crl;
885
886 check_store(s,STORE_F_STORE_GET_CRL,
887 get_object,STORE_R_NO_GET_OBJECT_FUNCTION);
888
889 object = s->meth->get_object(s, STORE_OBJECT_TYPE_X509_CRL,
890 attributes, parameters);
891 if (!object || !object->data.crl)
892 {
893 STOREerr(STORE_F_STORE_GET_CRL,
894 STORE_R_FAILED_GETTING_KEY);
895 return 0;
896 }
897 CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL);
898#ifdef REF_PRINT
899 REF_PRINT("X509_CRL",data);
900#endif
901 crl = object->data.crl;
902 STORE_OBJECT_free(object);
903 return crl;
904 }
905
906int STORE_store_crl(STORE *s, X509_CRL *data, OPENSSL_ITEM attributes[],
907 OPENSSL_ITEM parameters[])
908 {
909 STORE_OBJECT *object;
910 int i;
911
912 check_store(s,STORE_F_STORE_STORE_CRL,
913 store_object,STORE_R_NO_STORE_OBJECT_FUNCTION);
914
915 object = STORE_OBJECT_new();
916 if (!object)
917 {
918 STOREerr(STORE_F_STORE_STORE_CRL,
919 ERR_R_MALLOC_FAILURE);
920 return 0;
921 }
922
923 CRYPTO_add(&data->references,1,CRYPTO_LOCK_X509_CRL);
924#ifdef REF_PRINT
925 REF_PRINT("X509_CRL",data);
926#endif
927 object->data.crl = data;
928
929 i = s->meth->store_object(s, STORE_OBJECT_TYPE_X509_CRL, object,
930 attributes, parameters);
931
932 STORE_OBJECT_free(object);
933
934 if (!i)
935 {
936 STOREerr(STORE_F_STORE_STORE_CRL,
937 STORE_R_FAILED_STORING_KEY);
938 return 0;
939 }
940 return i;
941 }
942
943int STORE_modify_crl(STORE *s, OPENSSL_ITEM search_attributes[],
944 OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[],
945 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[])
946 {
947 check_store(s,STORE_F_STORE_MODIFY_CRL,
948 modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION);
949
950 if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_X509_CRL,
951 search_attributes, add_attributes, modify_attributes,
952 delete_attributes, parameters))
953 {
954 STOREerr(STORE_F_STORE_MODIFY_CRL,
955 STORE_R_FAILED_MODIFYING_CRL);
956 return 0;
957 }
958 return 1;
959 }
960
961int STORE_delete_crl(STORE *s, OPENSSL_ITEM attributes[],
962 OPENSSL_ITEM parameters[])
963 {
964 check_store(s,STORE_F_STORE_DELETE_CRL,
965 delete_object,STORE_R_NO_DELETE_OBJECT_FUNCTION);
966
967 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_X509_CRL,
968 attributes, parameters))
969 {
970 STOREerr(STORE_F_STORE_DELETE_CRL,
971 STORE_R_FAILED_DELETING_KEY);
972 return 0;
973 }
974 return 1;
975 }
976
977void *STORE_list_crl_start(STORE *s, OPENSSL_ITEM attributes[],
978 OPENSSL_ITEM parameters[])
979 {
980 void *handle;
981
982 check_store(s,STORE_F_STORE_LIST_CRL_START,
983 list_object_start,STORE_R_NO_LIST_OBJECT_START_FUNCTION);
984
985 handle = s->meth->list_object_start(s, STORE_OBJECT_TYPE_X509_CRL,
986 attributes, parameters);
987 if (!handle)
988 {
989 STOREerr(STORE_F_STORE_LIST_CRL_START,
990 STORE_R_FAILED_LISTING_KEYS);
991 return 0;
992 }
993 return handle;
994 }
995
996X509_CRL *STORE_list_crl_next(STORE *s, void *handle)
997 {
998 STORE_OBJECT *object;
999 X509_CRL *crl;
1000
1001 check_store(s,STORE_F_STORE_LIST_CRL_NEXT,
1002 list_object_next,STORE_R_NO_LIST_OBJECT_NEXT_FUNCTION);
1003
1004 object = s->meth->list_object_next(s, handle);
1005 if (!object || !object->data.crl)
1006 {
1007 STOREerr(STORE_F_STORE_LIST_CRL_NEXT,
1008 STORE_R_FAILED_LISTING_KEYS);
1009 return 0;
1010 }
1011 CRYPTO_add(&object->data.crl->references,1,CRYPTO_LOCK_X509_CRL);
1012#ifdef REF_PRINT
1013 REF_PRINT("X509_CRL",data);
1014#endif
1015 crl = object->data.crl;
1016 STORE_OBJECT_free(object);
1017 return crl;
1018 }
1019
1020int STORE_list_crl_end(STORE *s, void *handle)
1021 {
1022 check_store(s,STORE_F_STORE_LIST_CRL_END,
1023 list_object_end,STORE_R_NO_LIST_OBJECT_END_FUNCTION);
1024
1025 if (!s->meth->list_object_end(s, handle))
1026 {
1027 STOREerr(STORE_F_STORE_LIST_CRL_END,
1028 STORE_R_FAILED_LISTING_KEYS);
1029 return 0;
1030 }
1031 return 1;
1032 }
1033
1034int STORE_list_crl_endp(STORE *s, void *handle)
1035 {
1036 check_store(s,STORE_F_STORE_LIST_CRL_ENDP,
1037 list_object_endp,STORE_R_NO_LIST_OBJECT_ENDP_FUNCTION);
1038
1039 if (!s->meth->list_object_endp(s, handle))
1040 {
1041 STOREerr(STORE_F_STORE_LIST_CRL_ENDP,
1042 STORE_R_FAILED_LISTING_KEYS);
1043 return 0;
1044 }
1045 return 1;
1046 }
1047
1048int STORE_store_number(STORE *s, BIGNUM *data, OPENSSL_ITEM attributes[],
1049 OPENSSL_ITEM parameters[])
1050 {
1051 STORE_OBJECT *object;
1052 int i;
1053
1054 check_store(s,STORE_F_STORE_STORE_NUMBER,
1055 store_object,STORE_R_NO_STORE_OBJECT_NUMBER_FUNCTION);
1056
1057 object = STORE_OBJECT_new();
1058 if (!object)
1059 {
1060 STOREerr(STORE_F_STORE_STORE_NUMBER,
1061 ERR_R_MALLOC_FAILURE);
1062 return 0;
1063 }
1064
1065 object->data.number = data;
1066
1067 i = s->meth->store_object(s, STORE_OBJECT_TYPE_NUMBER, object,
1068 attributes, parameters);
1069
1070 STORE_OBJECT_free(object);
1071
1072 if (!i)
1073 {
1074 STOREerr(STORE_F_STORE_STORE_NUMBER,
1075 STORE_R_FAILED_STORING_NUMBER);
1076 return 0;
1077 }
1078 return 1;
1079 }
1080
1081int STORE_modify_number(STORE *s, OPENSSL_ITEM search_attributes[],
1082 OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[],
1083 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[])
1084 {
1085 check_store(s,STORE_F_STORE_MODIFY_NUMBER,
1086 modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION);
1087
1088 if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_NUMBER,
1089 search_attributes, add_attributes, modify_attributes,
1090 delete_attributes, parameters))
1091 {
1092 STOREerr(STORE_F_STORE_MODIFY_NUMBER,
1093 STORE_R_FAILED_MODIFYING_NUMBER);
1094 return 0;
1095 }
1096 return 1;
1097 }
1098
1099BIGNUM *STORE_get_number(STORE *s, OPENSSL_ITEM attributes[],
1100 OPENSSL_ITEM parameters[])
1101 {
1102 STORE_OBJECT *object;
1103 BIGNUM *n;
1104
1105 check_store(s,STORE_F_STORE_GET_NUMBER,
1106 get_object,STORE_R_NO_GET_OBJECT_NUMBER_FUNCTION);
1107
1108 object = s->meth->get_object(s, STORE_OBJECT_TYPE_NUMBER, attributes,
1109 parameters);
1110 if (!object || !object->data.number)
1111 {
1112 STOREerr(STORE_F_STORE_GET_NUMBER,
1113 STORE_R_FAILED_GETTING_NUMBER);
1114 return 0;
1115 }
1116 n = object->data.number;
1117 object->data.number = NULL;
1118 STORE_OBJECT_free(object);
1119 return n;
1120 }
1121
1122int STORE_delete_number(STORE *s, OPENSSL_ITEM attributes[],
1123 OPENSSL_ITEM parameters[])
1124 {
1125 check_store(s,STORE_F_STORE_DELETE_NUMBER,
1126 delete_object,STORE_R_NO_DELETE_NUMBER_FUNCTION);
1127
1128 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_NUMBER, attributes,
1129 parameters))
1130 {
1131 STOREerr(STORE_F_STORE_DELETE_NUMBER,
1132 STORE_R_FAILED_DELETING_NUMBER);
1133 return 0;
1134 }
1135 return 1;
1136 }
1137
1138int STORE_store_arbitrary(STORE *s, BUF_MEM *data, OPENSSL_ITEM attributes[],
1139 OPENSSL_ITEM parameters[])
1140 {
1141 STORE_OBJECT *object;
1142 int i;
1143
1144 check_store(s,STORE_F_STORE_STORE_ARBITRARY,
1145 store_object,STORE_R_NO_STORE_OBJECT_ARBITRARY_FUNCTION);
1146
1147 object = STORE_OBJECT_new();
1148 if (!object)
1149 {
1150 STOREerr(STORE_F_STORE_STORE_ARBITRARY,
1151 ERR_R_MALLOC_FAILURE);
1152 return 0;
1153 }
1154
1155 object->data.arbitrary = data;
1156
1157 i = s->meth->store_object(s, STORE_OBJECT_TYPE_ARBITRARY, object,
1158 attributes, parameters);
1159
1160 STORE_OBJECT_free(object);
1161
1162 if (!i)
1163 {
1164 STOREerr(STORE_F_STORE_STORE_ARBITRARY,
1165 STORE_R_FAILED_STORING_ARBITRARY);
1166 return 0;
1167 }
1168 return 1;
1169 }
1170
1171int STORE_modify_arbitrary(STORE *s, OPENSSL_ITEM search_attributes[],
1172 OPENSSL_ITEM add_attributes[], OPENSSL_ITEM modify_attributes[],
1173 OPENSSL_ITEM delete_attributes[], OPENSSL_ITEM parameters[])
1174 {
1175 check_store(s,STORE_F_STORE_MODIFY_ARBITRARY,
1176 modify_object,STORE_R_NO_MODIFY_OBJECT_FUNCTION);
1177
1178 if (!s->meth->modify_object(s, STORE_OBJECT_TYPE_ARBITRARY,
1179 search_attributes, add_attributes, modify_attributes,
1180 delete_attributes, parameters))
1181 {
1182 STOREerr(STORE_F_STORE_MODIFY_ARBITRARY,
1183 STORE_R_FAILED_MODIFYING_ARBITRARY);
1184 return 0;
1185 }
1186 return 1;
1187 }
1188
1189BUF_MEM *STORE_get_arbitrary(STORE *s, OPENSSL_ITEM attributes[],
1190 OPENSSL_ITEM parameters[])
1191 {
1192 STORE_OBJECT *object;
1193 BUF_MEM *b;
1194
1195 check_store(s,STORE_F_STORE_GET_ARBITRARY,
1196 get_object,STORE_R_NO_GET_OBJECT_ARBITRARY_FUNCTION);
1197
1198 object = s->meth->get_object(s, STORE_OBJECT_TYPE_ARBITRARY,
1199 attributes, parameters);
1200 if (!object || !object->data.arbitrary)
1201 {
1202 STOREerr(STORE_F_STORE_GET_ARBITRARY,
1203 STORE_R_FAILED_GETTING_ARBITRARY);
1204 return 0;
1205 }
1206 b = object->data.arbitrary;
1207 object->data.arbitrary = NULL;
1208 STORE_OBJECT_free(object);
1209 return b;
1210 }
1211
1212int STORE_delete_arbitrary(STORE *s, OPENSSL_ITEM attributes[],
1213 OPENSSL_ITEM parameters[])
1214 {
1215 check_store(s,STORE_F_STORE_DELETE_ARBITRARY,
1216 delete_object,STORE_R_NO_DELETE_ARBITRARY_FUNCTION);
1217
1218 if (!s->meth->delete_object(s, STORE_OBJECT_TYPE_ARBITRARY, attributes,
1219 parameters))
1220 {
1221 STOREerr(STORE_F_STORE_DELETE_ARBITRARY,
1222 STORE_R_FAILED_DELETING_ARBITRARY);
1223 return 0;
1224 }
1225 return 1;
1226 }
1227
1228STORE_OBJECT *STORE_OBJECT_new(void)
1229 {
1230 STORE_OBJECT *object = OPENSSL_malloc(sizeof(STORE_OBJECT));
1231 if (object) memset(object, 0, sizeof(STORE_OBJECT));
1232 return object;
1233 }
1234void STORE_OBJECT_free(STORE_OBJECT *data)
1235 {
1236 if (!data) return;
1237 switch (data->type)
1238 {
1239 case STORE_OBJECT_TYPE_X509_CERTIFICATE:
1240 X509_free(data->data.x509.certificate);
1241 break;
1242 case STORE_OBJECT_TYPE_X509_CRL:
1243 X509_CRL_free(data->data.crl);
1244 break;
1245 case STORE_OBJECT_TYPE_PRIVATE_KEY:
1246 case STORE_OBJECT_TYPE_PUBLIC_KEY:
1247 EVP_PKEY_free(data->data.key);
1248 break;
1249 case STORE_OBJECT_TYPE_NUMBER:
1250 BN_free(data->data.number);
1251 break;
1252 case STORE_OBJECT_TYPE_ARBITRARY:
1253 BUF_MEM_free(data->data.arbitrary);
1254 break;
1255 }
1256 OPENSSL_free(data);
1257 }
1258
1259IMPLEMENT_STACK_OF(STORE_OBJECT*)
1260
1261
1262struct STORE_attr_info_st
1263 {
1264 unsigned char set[(STORE_ATTR_TYPE_NUM + 8) / 8];
1265 union
1266 {
1267 char *cstring;
1268 unsigned char *sha1string;
1269 X509_NAME *dn;
1270 BIGNUM *number;
1271 void *any;
1272 } values[STORE_ATTR_TYPE_NUM+1];
1273 size_t value_sizes[STORE_ATTR_TYPE_NUM+1];
1274 };
1275
1276#define ATTR_IS_SET(a,i) ((i) > 0 && (i) < STORE_ATTR_TYPE_NUM \
1277 && ((a)->set[(i) / 8] & (1 << ((i) % 8))))
1278#define SET_ATTRBIT(a,i) ((a)->set[(i) / 8] |= (1 << ((i) % 8)))
1279#define CLEAR_ATTRBIT(a,i) ((a)->set[(i) / 8] &= ~(1 << ((i) % 8)))
1280
1281STORE_ATTR_INFO *STORE_ATTR_INFO_new(void)
1282 {
1283 return (STORE_ATTR_INFO *)OPENSSL_malloc(sizeof(STORE_ATTR_INFO));
1284 }
1285static void STORE_ATTR_INFO_attr_free(STORE_ATTR_INFO *attrs,
1286 STORE_ATTR_TYPES code)
1287 {
1288 if (ATTR_IS_SET(attrs,code))
1289 {
1290 switch(code)
1291 {
1292 case STORE_ATTR_FRIENDLYNAME:
1293 case STORE_ATTR_EMAIL:
1294 case STORE_ATTR_FILENAME:
1295 STORE_ATTR_INFO_modify_cstr(attrs, code, NULL, 0);
1296 break;
1297 case STORE_ATTR_KEYID:
1298 case STORE_ATTR_ISSUERKEYID:
1299 case STORE_ATTR_SUBJECTKEYID:
1300 case STORE_ATTR_ISSUERSERIALHASH:
1301 case STORE_ATTR_CERTHASH:
1302 STORE_ATTR_INFO_modify_sha1str(attrs, code, NULL, 0);
1303 break;
1304 case STORE_ATTR_ISSUER:
1305 case STORE_ATTR_SUBJECT:
1306 STORE_ATTR_INFO_modify_dn(attrs, code, NULL);
1307 break;
1308 case STORE_ATTR_SERIAL:
1309 STORE_ATTR_INFO_modify_number(attrs, code, NULL);
1310 break;
1311 default:
1312 break;
1313 }
1314 }
1315 }
1316int STORE_ATTR_INFO_free(STORE_ATTR_INFO *attrs)
1317 {
1318 if (attrs)
1319 {
1320 STORE_ATTR_TYPES i;
1321 for(i = 0; i++ < STORE_ATTR_TYPE_NUM;)
1322 STORE_ATTR_INFO_attr_free(attrs, i);
1323 OPENSSL_free(attrs);
1324 }
1325 return 1;
1326 }
1327char *STORE_ATTR_INFO_get0_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code)
1328 {
1329 if (!attrs)
1330 {
1331 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR,
1332 ERR_R_PASSED_NULL_PARAMETER);
1333 return NULL;
1334 }
1335 if (ATTR_IS_SET(attrs,code))
1336 return attrs->values[code].cstring;
1337 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_CSTR,
1338 STORE_R_NO_VALUE);
1339 return NULL;
1340 }
1341unsigned char *STORE_ATTR_INFO_get0_sha1str(STORE_ATTR_INFO *attrs,
1342 STORE_ATTR_TYPES code)
1343 {
1344 if (!attrs)
1345 {
1346 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR,
1347 ERR_R_PASSED_NULL_PARAMETER);
1348 return NULL;
1349 }
1350 if (ATTR_IS_SET(attrs,code))
1351 return attrs->values[code].sha1string;
1352 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_SHA1STR,
1353 STORE_R_NO_VALUE);
1354 return NULL;
1355 }
1356X509_NAME *STORE_ATTR_INFO_get0_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code)
1357 {
1358 if (!attrs)
1359 {
1360 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN,
1361 ERR_R_PASSED_NULL_PARAMETER);
1362 return NULL;
1363 }
1364 if (ATTR_IS_SET(attrs,code))
1365 return attrs->values[code].dn;
1366 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_DN,
1367 STORE_R_NO_VALUE);
1368 return NULL;
1369 }
1370BIGNUM *STORE_ATTR_INFO_get0_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code)
1371 {
1372 if (!attrs)
1373 {
1374 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER,
1375 ERR_R_PASSED_NULL_PARAMETER);
1376 return NULL;
1377 }
1378 if (ATTR_IS_SET(attrs,code))
1379 return attrs->values[code].number;
1380 STOREerr(STORE_F_STORE_ATTR_INFO_GET0_NUMBER,
1381 STORE_R_NO_VALUE);
1382 return NULL;
1383 }
1384int STORE_ATTR_INFO_set_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1385 char *cstr, size_t cstr_size)
1386 {
1387 if (!attrs)
1388 {
1389 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1390 ERR_R_PASSED_NULL_PARAMETER);
1391 return 0;
1392 }
1393 if (!ATTR_IS_SET(attrs,code))
1394 {
1395 if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size)))
1396 return 1;
1397 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR,
1398 ERR_R_MALLOC_FAILURE);
1399 return 0;
1400 }
1401 STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, STORE_R_ALREADY_HAS_A_VALUE);
1402 return 0;
1403 }
1404int STORE_ATTR_INFO_set_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1405 unsigned char *sha1str, size_t sha1str_size)
1406 {
1407 if (!attrs)
1408 {
1409 STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR,
1410 ERR_R_PASSED_NULL_PARAMETER);
1411 return 0;
1412 }
1413 if (!ATTR_IS_SET(attrs,code))
1414 {
1415 if ((attrs->values[code].sha1string =
1416 (unsigned char *)BUF_memdup(sha1str,
1417 sha1str_size)))
1418 return 1;
1419 STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR,
1420 ERR_R_MALLOC_FAILURE);
1421 return 0;
1422 }
1423 STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, STORE_R_ALREADY_HAS_A_VALUE);
1424 return 0;
1425 }
1426int STORE_ATTR_INFO_set_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1427 X509_NAME *dn)
1428 {
1429 if (!attrs)
1430 {
1431 STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN,
1432 ERR_R_PASSED_NULL_PARAMETER);
1433 return 0;
1434 }
1435 if (!ATTR_IS_SET(attrs,code))
1436 {
1437 if ((attrs->values[code].dn = X509_NAME_dup(dn)))
1438 return 1;
1439 STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN,
1440 ERR_R_MALLOC_FAILURE);
1441 return 0;
1442 }
1443 STOREerr(STORE_F_STORE_ATTR_INFO_SET_DN, STORE_R_ALREADY_HAS_A_VALUE);
1444 return 0;
1445 }
1446int STORE_ATTR_INFO_set_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1447 BIGNUM *number)
1448 {
1449 if (!attrs)
1450 {
1451 STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER,
1452 ERR_R_PASSED_NULL_PARAMETER);
1453 return 0;
1454 }
1455 if (!ATTR_IS_SET(attrs,code))
1456 {
1457 if ((attrs->values[code].number = BN_dup(number)))
1458 return 1;
1459 STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER,
1460 ERR_R_MALLOC_FAILURE);
1461 return 0;
1462 }
1463 STOREerr(STORE_F_STORE_ATTR_INFO_SET_NUMBER, STORE_R_ALREADY_HAS_A_VALUE);
1464 return 0;
1465 }
1466int STORE_ATTR_INFO_modify_cstr(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1467 char *cstr, size_t cstr_size)
1468 {
1469 if (!attrs)
1470 {
1471 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_CSTR,
1472 ERR_R_PASSED_NULL_PARAMETER);
1473 return 0;
1474 }
1475 if (ATTR_IS_SET(attrs,code))
1476 {
1477 OPENSSL_free(attrs->values[code].cstring);
1478 attrs->values[code].cstring = NULL;
1479 CLEAR_ATTRBIT(attrs, code);
1480 }
1481 return STORE_ATTR_INFO_set_cstr(attrs, code, cstr, cstr_size);
1482 }
1483int STORE_ATTR_INFO_modify_sha1str(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1484 unsigned char *sha1str, size_t sha1str_size)
1485 {
1486 if (!attrs)
1487 {
1488 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_SHA1STR,
1489 ERR_R_PASSED_NULL_PARAMETER);
1490 return 0;
1491 }
1492 if (ATTR_IS_SET(attrs,code))
1493 {
1494 OPENSSL_free(attrs->values[code].sha1string);
1495 attrs->values[code].sha1string = NULL;
1496 CLEAR_ATTRBIT(attrs, code);
1497 }
1498 return STORE_ATTR_INFO_set_sha1str(attrs, code, sha1str, sha1str_size);
1499 }
1500int STORE_ATTR_INFO_modify_dn(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1501 X509_NAME *dn)
1502 {
1503 if (!attrs)
1504 {
1505 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_DN,
1506 ERR_R_PASSED_NULL_PARAMETER);
1507 return 0;
1508 }
1509 if (ATTR_IS_SET(attrs,code))
1510 {
1511 OPENSSL_free(attrs->values[code].dn);
1512 attrs->values[code].dn = NULL;
1513 CLEAR_ATTRBIT(attrs, code);
1514 }
1515 return STORE_ATTR_INFO_set_dn(attrs, code, dn);
1516 }
1517int STORE_ATTR_INFO_modify_number(STORE_ATTR_INFO *attrs, STORE_ATTR_TYPES code,
1518 BIGNUM *number)
1519 {
1520 if (!attrs)
1521 {
1522 STOREerr(STORE_F_STORE_ATTR_INFO_MODIFY_NUMBER,
1523 ERR_R_PASSED_NULL_PARAMETER);
1524 return 0;
1525 }
1526 if (ATTR_IS_SET(attrs,code))
1527 {
1528 OPENSSL_free(attrs->values[code].number);
1529 attrs->values[code].number = NULL;
1530 CLEAR_ATTRBIT(attrs, code);
1531 }
1532 return STORE_ATTR_INFO_set_number(attrs, code, number);
1533 }
1534
1535struct attr_list_ctx_st
1536 {
1537 OPENSSL_ITEM *attributes;
1538 };
1539void *STORE_parse_attrs_start(OPENSSL_ITEM *attributes)
1540 {
1541 if (attributes)
1542 {
1543 struct attr_list_ctx_st *context =
1544 (struct attr_list_ctx_st *)OPENSSL_malloc(sizeof(struct attr_list_ctx_st));
1545 if (context)
1546 context->attributes = attributes;
1547 else
1548 STOREerr(STORE_F_STORE_PARSE_ATTRS_START,
1549 ERR_R_MALLOC_FAILURE);
1550 return context;
1551 }
1552 STOREerr(STORE_F_STORE_PARSE_ATTRS_START, ERR_R_PASSED_NULL_PARAMETER);
1553 return 0;
1554 }
1555STORE_ATTR_INFO *STORE_parse_attrs_next(void *handle)
1556 {
1557 struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle;
1558
1559 if (context && context->attributes)
1560 {
1561 STORE_ATTR_INFO *attrs = NULL;
1562
1563 while(context->attributes
1564 && context->attributes->code != STORE_ATTR_OR
1565 && context->attributes->code != STORE_ATTR_END)
1566 {
1567 switch(context->attributes->code)
1568 {
1569 case STORE_ATTR_FRIENDLYNAME:
1570 case STORE_ATTR_EMAIL:
1571 case STORE_ATTR_FILENAME:
1572 if (!attrs) attrs = STORE_ATTR_INFO_new();
1573 if (attrs == NULL)
1574 {
1575 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1576 ERR_R_MALLOC_FAILURE);
1577 goto err;
1578 }
1579 STORE_ATTR_INFO_set_cstr(attrs,
1580 context->attributes->code,
1581 context->attributes->value,
1582 context->attributes->value_size);
1583 break;
1584 case STORE_ATTR_KEYID:
1585 case STORE_ATTR_ISSUERKEYID:
1586 case STORE_ATTR_SUBJECTKEYID:
1587 case STORE_ATTR_ISSUERSERIALHASH:
1588 case STORE_ATTR_CERTHASH:
1589 if (!attrs) attrs = STORE_ATTR_INFO_new();
1590 if (attrs == NULL)
1591 {
1592 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1593 ERR_R_MALLOC_FAILURE);
1594 goto err;
1595 }
1596 STORE_ATTR_INFO_set_sha1str(attrs,
1597 context->attributes->code,
1598 context->attributes->value,
1599 context->attributes->value_size);
1600 break;
1601 case STORE_ATTR_ISSUER:
1602 case STORE_ATTR_SUBJECT:
1603 if (!attrs) attrs = STORE_ATTR_INFO_new();
1604 if (attrs == NULL)
1605 {
1606 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1607 ERR_R_MALLOC_FAILURE);
1608 goto err;
1609 }
1610 STORE_ATTR_INFO_modify_dn(attrs,
1611 context->attributes->code,
1612 context->attributes->value);
1613 break;
1614 case STORE_ATTR_SERIAL:
1615 if (!attrs) attrs = STORE_ATTR_INFO_new();
1616 if (attrs == NULL)
1617 {
1618 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT,
1619 ERR_R_MALLOC_FAILURE);
1620 goto err;
1621 }
1622 STORE_ATTR_INFO_modify_number(attrs,
1623 context->attributes->code,
1624 context->attributes->value);
1625 break;
1626 }
1627 context->attributes++;
1628 }
1629 if (context->attributes->code == STORE_ATTR_OR)
1630 context->attributes++;
1631 return attrs;
1632 err:
1633 while(context->attributes
1634 && context->attributes->code != STORE_ATTR_OR
1635 && context->attributes->code != STORE_ATTR_END)
1636 context->attributes++;
1637 if (context->attributes->code == STORE_ATTR_OR)
1638 context->attributes++;
1639 return NULL;
1640 }
1641 STOREerr(STORE_F_STORE_PARSE_ATTRS_NEXT, ERR_R_PASSED_NULL_PARAMETER);
1642 return NULL;
1643 }
1644int STORE_parse_attrs_end(void *handle)
1645 {
1646 struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle;
1647
1648 if (context && context->attributes)
1649 {
1650#if 0
1651 OPENSSL_ITEM *attributes = context->attributes;
1652#endif
1653 OPENSSL_free(context);
1654 return 1;
1655 }
1656 STOREerr(STORE_F_STORE_PARSE_ATTRS_END, ERR_R_PASSED_NULL_PARAMETER);
1657 return 0;
1658 }
1659
1660int STORE_parse_attrs_endp(void *handle)
1661 {
1662 struct attr_list_ctx_st *context = (struct attr_list_ctx_st *)handle;
1663
1664 if (context && context->attributes)
1665 {
1666 return context->attributes->code == STORE_ATTR_END;
1667 }
1668 STOREerr(STORE_F_STORE_PARSE_ATTRS_ENDP, ERR_R_PASSED_NULL_PARAMETER);
1669 return 0;
1670 }
1671
1672static int attr_info_compare_compute_range(
1673 const unsigned char *abits, const unsigned char *bbits,
1674 unsigned int *alowp, unsigned int *ahighp,
1675 unsigned int *blowp, unsigned int *bhighp)
1676 {
1677 unsigned int alow = (unsigned int)-1, ahigh = 0;
1678 unsigned int blow = (unsigned int)-1, bhigh = 0;
1679 int i, res = 0;
1680
1681 for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++)
1682 {
1683 if (res == 0)
1684 {
1685 if (*abits < *bbits) res = -1;
1686 if (*abits > *bbits) res = 1;
1687 }
1688 if (*abits)
1689 {
1690 if (alow == (unsigned int)-1)
1691 {
1692 alow = i * 8;
1693 if (!(*abits & 0x01)) alow++;
1694 if (!(*abits & 0x02)) alow++;
1695 if (!(*abits & 0x04)) alow++;
1696 if (!(*abits & 0x08)) alow++;
1697 if (!(*abits & 0x10)) alow++;
1698 if (!(*abits & 0x20)) alow++;
1699 if (!(*abits & 0x40)) alow++;
1700 }
1701 ahigh = i * 8 + 7;
1702 if (!(*abits & 0x80)) ahigh++;
1703 if (!(*abits & 0x40)) ahigh++;
1704 if (!(*abits & 0x20)) ahigh++;
1705 if (!(*abits & 0x10)) ahigh++;
1706 if (!(*abits & 0x08)) ahigh++;
1707 if (!(*abits & 0x04)) ahigh++;
1708 if (!(*abits & 0x02)) ahigh++;
1709 }
1710 if (*bbits)
1711 {
1712 if (blow == (unsigned int)-1)
1713 {
1714 blow = i * 8;
1715 if (!(*bbits & 0x01)) blow++;
1716 if (!(*bbits & 0x02)) blow++;
1717 if (!(*bbits & 0x04)) blow++;
1718 if (!(*bbits & 0x08)) blow++;
1719 if (!(*bbits & 0x10)) blow++;
1720 if (!(*bbits & 0x20)) blow++;
1721 if (!(*bbits & 0x40)) blow++;
1722 }
1723 bhigh = i * 8 + 7;
1724 if (!(*bbits & 0x80)) bhigh++;
1725 if (!(*bbits & 0x40)) bhigh++;
1726 if (!(*bbits & 0x20)) bhigh++;
1727 if (!(*bbits & 0x10)) bhigh++;
1728 if (!(*bbits & 0x08)) bhigh++;
1729 if (!(*bbits & 0x04)) bhigh++;
1730 if (!(*bbits & 0x02)) bhigh++;
1731 }
1732 }
1733 if (ahigh + alow < bhigh + blow) res = -1;
1734 if (ahigh + alow > bhigh + blow) res = 1;
1735 if (alowp) *alowp = alow;
1736 if (ahighp) *ahighp = ahigh;
1737 if (blowp) *blowp = blow;
1738 if (bhighp) *bhighp = bhigh;
1739 return res;
1740 }
1741
1742int STORE_ATTR_INFO_compare(const STORE_ATTR_INFO * const *a,
1743 const STORE_ATTR_INFO * const *b)
1744 {
1745 if (a == b) return 0;
1746 if (!a) return -1;
1747 if (!b) return 1;
1748 return attr_info_compare_compute_range((*a)->set, (*b)->set, 0, 0, 0, 0);
1749 }
1750
1751int STORE_ATTR_INFO_in_range(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
1752 {
1753 unsigned int alow, ahigh, blow, bhigh;
1754
1755 if (a == b) return 1;
1756 if (!a) return 0;
1757 if (!b) return 0;
1758 attr_info_compare_compute_range(a->set, b->set,
1759 &alow, &ahigh, &blow, &bhigh);
1760 if (alow >= blow && ahigh <= bhigh)
1761 return 1;
1762 return 0;
1763 }
1764
1765int STORE_ATTR_INFO_in(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
1766 {
1767 unsigned char *abits, *bbits;
1768 int i;
1769
1770 if (a == b) return 1;
1771 if (!a) return 0;
1772 if (!b) return 0;
1773 abits = a->set;
1774 bbits = b->set;
1775 for (i = 0; i < (STORE_ATTR_TYPE_NUM + 8) / 8; i++, abits++, bbits++)
1776 {
1777 if (*abits && (*bbits & *abits) != *abits)
1778 return 0;
1779 }
1780 return 1;
1781 }
1782
1783int STORE_ATTR_INFO_in_ex(STORE_ATTR_INFO *a, STORE_ATTR_INFO *b)
1784 {
1785 STORE_ATTR_TYPES i;
1786
1787 if (a == b) return 1;
1788 if (!STORE_ATTR_INFO_in(a, b)) return 0;
1789 for (i = 1; i < STORE_ATTR_TYPE_NUM; i++)
1790 if (ATTR_IS_SET(a, i))
1791 {
1792 switch(i)
1793 {
1794 case STORE_ATTR_FRIENDLYNAME:
1795 case STORE_ATTR_EMAIL:
1796 case STORE_ATTR_FILENAME:
1797 if (strcmp(a->values[i].cstring,
1798 b->values[i].cstring))
1799 return 0;
1800 break;
1801 case STORE_ATTR_KEYID:
1802 case STORE_ATTR_ISSUERKEYID:
1803 case STORE_ATTR_SUBJECTKEYID:
1804 case STORE_ATTR_ISSUERSERIALHASH:
1805 case STORE_ATTR_CERTHASH:
1806 if (memcmp(a->values[i].sha1string,
1807 b->values[i].sha1string,
1808 a->value_sizes[i]))
1809 return 0;
1810 break;
1811 case STORE_ATTR_ISSUER:
1812 case STORE_ATTR_SUBJECT:
1813 if (X509_NAME_cmp(a->values[i].dn,
1814 b->values[i].dn))
1815 return 0;
1816 break;
1817 case STORE_ATTR_SERIAL:
1818 if (BN_cmp(a->values[i].number,
1819 b->values[i].number))
1820 return 0;
1821 break;
1822 default:
1823 break;
1824 }
1825 }
1826
1827 return 1;
1828 }
diff --git a/src/lib/libcrypto/engine/hw_aep_err.h b/src/lib/libcrypto/store/str_locl.h
index 8fe4cf921f..3f8cb75619 100644
--- a/src/lib/libcrypto/engine/hw_aep_err.h
+++ b/src/lib/libcrypto/store/str_locl.h
@@ -1,5 +1,9 @@
1/* crypto/store/str_locl.h -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2003.
4 */
1/* ==================================================================== 5/* ====================================================================
2 * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 6 * Copyright (c) 2003 The OpenSSL Project. All rights reserved.
3 * 7 *
4 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -52,50 +56,69 @@
52 * 56 *
53 */ 57 */
54 58
55#ifndef HEADER_AEPHK_ERR_H 59#ifndef HEADER_STORE_LOCL_H
56#define HEADER_AEPHK_ERR_H 60#define HEADER_STORE_LOCL_H
57 61
58/* BEGIN ERROR CODES */ 62#include <openssl/crypto.h>
59/* The following lines are auto generated by the script mkerr.pl. Any changes 63#include <openssl/store.h>
60 * made after this point may be overwritten when the script is next run. 64
61 */ 65#ifdef __cplusplus
62static void ERR_load_AEPHK_strings(void); 66extern "C" {
63static void ERR_unload_AEPHK_strings(void); 67#endif
64static void ERR_AEPHK_error(int function, int reason, char *file, int line); 68
65#define AEPHKerr(f,r) ERR_AEPHK_error((f),(r),__FILE__,__LINE__) 69struct store_method_st
70 {
71 char *name;
66 72
67/* Error codes for the AEPHK functions. */ 73 /* All the functions return a positive integer or non-NULL for success
74 and 0, a negative integer or NULL for failure */
68 75
69/* Function codes. */ 76 /* Initialise the STORE with private data */
70#define AEPHK_F_AEP_CTRL 100 77 STORE_INITIALISE_FUNC_PTR init;
71#define AEPHK_F_AEP_FINISH 101 78 /* Initialise the STORE with private data */
72#define AEPHK_F_AEP_GET_CONNECTION 102 79 STORE_CLEANUP_FUNC_PTR clean;
73#define AEPHK_F_AEP_INIT 103 80 /* Generate an object of a given type */
74#define AEPHK_F_AEP_MOD_EXP 104 81 STORE_GENERATE_OBJECT_FUNC_PTR generate_object;
75#define AEPHK_F_AEP_MOD_EXP_CRT 105 82 /* Get an object of a given type. This function isn't really very
76#define AEPHK_F_AEP_RAND 106 83 useful since the listing functions (below) can be used for the
77#define AEPHK_F_AEP_RSA_MOD_EXP 107 84 same purpose and are much more general. */
85 STORE_GET_OBJECT_FUNC_PTR get_object;
86 /* Store an object of a given type. */
87 STORE_STORE_OBJECT_FUNC_PTR store_object;
88 /* Modify the attributes bound to an object of a given type. */
89 STORE_MODIFY_OBJECT_FUNC_PTR modify_object;
90 /* Revoke an object of a given type. */
91 STORE_HANDLE_OBJECT_FUNC_PTR revoke_object;
92 /* Delete an object of a given type. */
93 STORE_HANDLE_OBJECT_FUNC_PTR delete_object;
94 /* List a bunch of objects of a given type and with the associated
95 attributes. */
96 STORE_START_OBJECT_FUNC_PTR list_object_start;
97 STORE_NEXT_OBJECT_FUNC_PTR list_object_next;
98 STORE_END_OBJECT_FUNC_PTR list_object_end;
99 STORE_END_OBJECT_FUNC_PTR list_object_endp;
100 /* Store-level function to make any necessary update operations. */
101 STORE_GENERIC_FUNC_PTR update_store;
102 /* Store-level function to get exclusive access to the store. */
103 STORE_GENERIC_FUNC_PTR lock_store;
104 /* Store-level function to release exclusive access to the store. */
105 STORE_GENERIC_FUNC_PTR unlock_store;
78 106
79/* Reason codes. */ 107 /* Generic control function */
80#define AEPHK_R_ALREADY_LOADED 100 108 STORE_CTRL_FUNC_PTR ctrl;
81#define AEPHK_R_CLOSE_HANDLES_FAILED 101 109 };
82#define AEPHK_R_CONNECTIONS_IN_USE 102
83#define AEPHK_R_CTRL_COMMAND_NOT_IMPLEMENTED 103
84#define AEPHK_R_FINALIZE_FAILED 104
85#define AEPHK_R_GET_HANDLE_FAILED 105
86#define AEPHK_R_GET_RANDOM_FAILED 106
87#define AEPHK_R_INIT_FAILURE 107
88#define AEPHK_R_MISSING_KEY_COMPONENTS 108
89#define AEPHK_R_MOD_EXP_CRT_FAILED 109
90#define AEPHK_R_MOD_EXP_FAILED 110
91#define AEPHK_R_NOT_LOADED 111
92#define AEPHK_R_OK 112
93#define AEPHK_R_RETURN_CONNECTION_FAILED 113
94#define AEPHK_R_SETBNCALLBACK_FAILURE 114
95#define AEPHK_R_SIZE_TOO_LARGE_OR_TOO_SMALL 116
96#define AEPHK_R_UNIT_FAILURE 115
97 110
111struct store_st
112 {
113 const STORE_METHOD *meth;
114 /* functional reference if 'meth' is ENGINE-provided */
115 ENGINE *engine;
116
117 CRYPTO_EX_DATA ex_data;
118 int references;
119 };
98#ifdef __cplusplus 120#ifdef __cplusplus
99} 121}
100#endif 122#endif
123
101#endif 124#endif
diff --git a/src/lib/libcrypto/store/str_mem.c b/src/lib/libcrypto/store/str_mem.c
new file mode 100644
index 0000000000..8ac4f7e55c
--- /dev/null
+++ b/src/lib/libcrypto/store/str_mem.c
@@ -0,0 +1,365 @@
1/* crypto/store/str_mem.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2003.
4 */
5/* ====================================================================
6 * Copyright (c) 2003 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * openssl-core@openssl.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <string.h>
60#include <openssl/err.h>
61#include "str_locl.h"
62
63/* The memory store is currently highly experimental. It's meant to become
64 a base store used by other stores for internal caching (for full caching
65 support, aging needs to be added).
66
67 The database use is meant to support as much attribute association as
68 possible, while providing for as small search ranges as possible.
69 This is currently provided for by sorting the entries by numbers that
70 are composed of bits set at the positions indicated by attribute type
71 codes. This provides for ranges determined by the highest attribute
72 type code value. A better idea might be to sort by values computed
73 from the range of attributes associated with the object (basically,
74 the difference between the highest and lowest attribute type code)
75 and it's distance from a base (basically, the lowest associated
76 attribute type code).
77*/
78
79typedef struct mem_object_data_st
80 {
81 STORE_OBJECT *object;
82 STORE_ATTR_INFO *attr_info;
83 int references;
84 } MEM_OBJECT_DATA;
85
86DECLARE_STACK_OF(MEM_OBJECT_DATA)
87struct mem_data_st
88 {
89 STACK_OF(MEM_OBJECT_DATA) *data; /* sorted with
90 * STORE_ATTR_INFO_compare(). */
91 unsigned int compute_components : 1; /* Currently unused, but can
92 be used to add attributes
93 from parts of the data. */
94 };
95
96DECLARE_STACK_OF(STORE_ATTR_INFO)
97struct mem_ctx_st
98 {
99 int type; /* The type we're searching for */
100 STACK_OF(STORE_ATTR_INFO) *search_attributes; /* Sets of
101 attributes to search for. Each
102 element is a STORE_ATTR_INFO. */
103 int search_index; /* which of the search attributes we
104 found a match for, -1 when we still
105 haven't found any */
106 int index; /* -1 as long as we're searching for
107 the first */
108 };
109
110static int mem_init(STORE *s);
111static void mem_clean(STORE *s);
112static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type,
113 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
114static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type,
115 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
116static int mem_store(STORE *s, STORE_OBJECT_TYPES type,
117 STORE_OBJECT *data, OPENSSL_ITEM attributes[],
118 OPENSSL_ITEM parameters[]);
119static int mem_modify(STORE *s, STORE_OBJECT_TYPES type,
120 OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[],
121 OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[],
122 OPENSSL_ITEM parameters[]);
123static int mem_delete(STORE *s, STORE_OBJECT_TYPES type,
124 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
125static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type,
126 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]);
127static STORE_OBJECT *mem_list_next(STORE *s, void *handle);
128static int mem_list_end(STORE *s, void *handle);
129static int mem_list_endp(STORE *s, void *handle);
130static int mem_lock(STORE *s, OPENSSL_ITEM attributes[],
131 OPENSSL_ITEM parameters[]);
132static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[],
133 OPENSSL_ITEM parameters[]);
134static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void));
135
136static STORE_METHOD store_memory =
137 {
138 "OpenSSL memory store interface",
139 mem_init,
140 mem_clean,
141 mem_generate,
142 mem_get,
143 mem_store,
144 mem_modify,
145 NULL, /* revoke */
146 mem_delete,
147 mem_list_start,
148 mem_list_next,
149 mem_list_end,
150 mem_list_endp,
151 NULL, /* update */
152 mem_lock,
153 mem_unlock,
154 mem_ctrl
155 };
156
157const STORE_METHOD *STORE_Memory(void)
158 {
159 return &store_memory;
160 }
161
162static int mem_init(STORE *s)
163 {
164 return 1;
165 }
166
167static void mem_clean(STORE *s)
168 {
169 return;
170 }
171
172static STORE_OBJECT *mem_generate(STORE *s, STORE_OBJECT_TYPES type,
173 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[])
174 {
175 STOREerr(STORE_F_MEM_GENERATE, STORE_R_NOT_IMPLEMENTED);
176 return 0;
177 }
178static STORE_OBJECT *mem_get(STORE *s, STORE_OBJECT_TYPES type,
179 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[])
180 {
181 void *context = mem_list_start(s, type, attributes, parameters);
182
183 if (context)
184 {
185 STORE_OBJECT *object = mem_list_next(s, context);
186
187 if (mem_list_end(s, context))
188 return object;
189 }
190 return NULL;
191 }
192static int mem_store(STORE *s, STORE_OBJECT_TYPES type,
193 STORE_OBJECT *data, OPENSSL_ITEM attributes[],
194 OPENSSL_ITEM parameters[])
195 {
196 STOREerr(STORE_F_MEM_STORE, STORE_R_NOT_IMPLEMENTED);
197 return 0;
198 }
199static int mem_modify(STORE *s, STORE_OBJECT_TYPES type,
200 OPENSSL_ITEM search_attributes[], OPENSSL_ITEM add_attributes[],
201 OPENSSL_ITEM modify_attributes[], OPENSSL_ITEM delete_attributes[],
202 OPENSSL_ITEM parameters[])
203 {
204 STOREerr(STORE_F_MEM_MODIFY, STORE_R_NOT_IMPLEMENTED);
205 return 0;
206 }
207static int mem_delete(STORE *s, STORE_OBJECT_TYPES type,
208 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[])
209 {
210 STOREerr(STORE_F_MEM_DELETE, STORE_R_NOT_IMPLEMENTED);
211 return 0;
212 }
213
214/* The list functions may be the hardest to understand. Basically,
215 mem_list_start compiles a stack of attribute info elements, and
216 puts that stack into the context to be returned. mem_list_next
217 will then find the first matching element in the store, and then
218 walk all the way to the end of the store (since any combination
219 of attribute bits above the starting point may match the searched
220 for bit pattern...). */
221static void *mem_list_start(STORE *s, STORE_OBJECT_TYPES type,
222 OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[])
223 {
224 struct mem_ctx_st *context =
225 (struct mem_ctx_st *)OPENSSL_malloc(sizeof(struct mem_ctx_st));
226 void *attribute_context = NULL;
227 STORE_ATTR_INFO *attrs = NULL;
228
229 if (!context)
230 {
231 STOREerr(STORE_F_MEM_LIST_START, ERR_R_MALLOC_FAILURE);
232 return 0;
233 }
234 memset(context, 0, sizeof(struct mem_ctx_st));
235
236 attribute_context = STORE_parse_attrs_start(attributes);
237 if (!attribute_context)
238 {
239 STOREerr(STORE_F_MEM_LIST_START, ERR_R_STORE_LIB);
240 goto err;
241 }
242
243 while((attrs = STORE_parse_attrs_next(attribute_context)))
244 {
245 if (context->search_attributes == NULL)
246 {
247 context->search_attributes =
248 sk_STORE_ATTR_INFO_new(STORE_ATTR_INFO_compare);
249 if (!context->search_attributes)
250 {
251 STOREerr(STORE_F_MEM_LIST_START,
252 ERR_R_MALLOC_FAILURE);
253 goto err;
254 }
255 }
256 sk_STORE_ATTR_INFO_push(context->search_attributes,attrs);
257 }
258 if (!STORE_parse_attrs_endp(attribute_context))
259 goto err;
260 STORE_parse_attrs_end(attribute_context);
261 context->search_index = -1;
262 context->index = -1;
263 return context;
264 err:
265 if (attribute_context) STORE_parse_attrs_end(attribute_context);
266 mem_list_end(s, context);
267 return NULL;
268 }
269static STORE_OBJECT *mem_list_next(STORE *s, void *handle)
270 {
271 int i;
272 struct mem_ctx_st *context = (struct mem_ctx_st *)handle;
273 struct mem_object_data_st key = { 0, 0, 1 };
274 struct mem_data_st *store =
275 (struct mem_data_st *)STORE_get_ex_data(s, 1);
276 int srch;
277 int cres = 0;
278
279 if (!context)
280 {
281 STOREerr(STORE_F_MEM_LIST_NEXT, ERR_R_PASSED_NULL_PARAMETER);
282 return NULL;
283 }
284 if (!store)
285 {
286 STOREerr(STORE_F_MEM_LIST_NEXT, STORE_R_NO_STORE);
287 return NULL;
288 }
289
290 if (context->search_index == -1)
291 {
292 for (i = 0;
293 i < sk_STORE_ATTR_INFO_num(context->search_attributes);
294 i++)
295 {
296 key.attr_info
297 = sk_STORE_ATTR_INFO_value(context->search_attributes,
298 i);
299 srch = sk_MEM_OBJECT_DATA_find_ex(store->data, &key);
300
301 if (srch >= 0)
302 {
303 context->search_index = srch;
304 break;
305 }
306 }
307 }
308 if (context->search_index < 0)
309 return NULL;
310
311 key.attr_info =
312 sk_STORE_ATTR_INFO_value(context->search_attributes,
313 context->search_index);
314 for(srch = context->search_index;
315 srch < sk_MEM_OBJECT_DATA_num(store->data)
316 && STORE_ATTR_INFO_in_range(key.attr_info,
317 sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info)
318 && !(cres = STORE_ATTR_INFO_in_ex(key.attr_info,
319 sk_MEM_OBJECT_DATA_value(store->data, srch)->attr_info));
320 srch++)
321 ;
322
323 context->search_index = srch;
324 if (cres)
325 return (sk_MEM_OBJECT_DATA_value(store->data, srch))->object;
326 return NULL;
327 }
328static int mem_list_end(STORE *s, void *handle)
329 {
330 struct mem_ctx_st *context = (struct mem_ctx_st *)handle;
331
332 if (!context)
333 {
334 STOREerr(STORE_F_MEM_LIST_END, ERR_R_PASSED_NULL_PARAMETER);
335 return 0;
336 }
337 if (context && context->search_attributes)
338 sk_STORE_ATTR_INFO_free(context->search_attributes);
339 if (context) OPENSSL_free(context);
340 return 1;
341 }
342static int mem_list_endp(STORE *s, void *handle)
343 {
344 struct mem_ctx_st *context = (struct mem_ctx_st *)handle;
345
346 if (!context
347 || context->search_index
348 == sk_STORE_ATTR_INFO_num(context->search_attributes))
349 return 1;
350 return 0;
351 }
352static int mem_lock(STORE *s, OPENSSL_ITEM attributes[],
353 OPENSSL_ITEM parameters[])
354 {
355 return 1;
356 }
357static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[],
358 OPENSSL_ITEM parameters[])
359 {
360 return 1;
361 }
362static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void))
363 {
364 return 1;
365 }
diff --git a/src/lib/libcrypto/store/str_meth.c b/src/lib/libcrypto/store/str_meth.c
new file mode 100644
index 0000000000..a46de03a26
--- /dev/null
+++ b/src/lib/libcrypto/store/str_meth.c
@@ -0,0 +1,250 @@
1/* crypto/store/str_meth.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2003.
4 */
5/* ====================================================================
6 * Copyright (c) 2003 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * openssl-core@openssl.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <string.h>
60#include <openssl/buffer.h>
61#include "str_locl.h"
62
63STORE_METHOD *STORE_create_method(char *name)
64 {
65 STORE_METHOD *store_method = (STORE_METHOD *)OPENSSL_malloc(sizeof(STORE_METHOD));
66
67 if (store_method)
68 {
69 memset(store_method, 0, sizeof(*store_method));
70 store_method->name = BUF_strdup(name);
71 }
72 return store_method;
73 }
74
75/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method
76 (that is, it hasn't been allocated using STORE_create_method(), you deserve
77 anything Murphy can throw at you and more! You have been warned. */
78void STORE_destroy_method(STORE_METHOD *store_method)
79 {
80 if (!store_method) return;
81 OPENSSL_free(store_method->name);
82 store_method->name = NULL;
83 OPENSSL_free(store_method);
84 }
85
86int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f)
87 {
88 sm->init = init_f;
89 return 1;
90 }
91
92int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f)
93 {
94 sm->clean = clean_f;
95 return 1;
96 }
97
98int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f)
99 {
100 sm->generate_object = generate_f;
101 return 1;
102 }
103
104int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f)
105 {
106 sm->get_object = get_f;
107 return 1;
108 }
109
110int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f)
111 {
112 sm->store_object = store_f;
113 return 1;
114 }
115
116int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR modify_f)
117 {
118 sm->modify_object = modify_f;
119 return 1;
120 }
121
122int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f)
123 {
124 sm->revoke_object = revoke_f;
125 return 1;
126 }
127
128int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f)
129 {
130 sm->delete_object = delete_f;
131 return 1;
132 }
133
134int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f)
135 {
136 sm->list_object_start = list_start_f;
137 return 1;
138 }
139
140int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f)
141 {
142 sm->list_object_next = list_next_f;
143 return 1;
144 }
145
146int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f)
147 {
148 sm->list_object_end = list_end_f;
149 return 1;
150 }
151
152int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR update_f)
153 {
154 sm->update_store = update_f;
155 return 1;
156 }
157
158int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR lock_f)
159 {
160 sm->lock_store = lock_f;
161 return 1;
162 }
163
164int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR unlock_f)
165 {
166 sm->unlock_store = unlock_f;
167 return 1;
168 }
169
170int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f)
171 {
172 sm->ctrl = ctrl_f;
173 return 1;
174 }
175
176STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm)
177 {
178 return sm->init;
179 }
180
181STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm)
182 {
183 return sm->clean;
184 }
185
186STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm)
187 {
188 return sm->generate_object;
189 }
190
191STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm)
192 {
193 return sm->get_object;
194 }
195
196STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm)
197 {
198 return sm->store_object;
199 }
200
201STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm)
202 {
203 return sm->modify_object;
204 }
205
206STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm)
207 {
208 return sm->revoke_object;
209 }
210
211STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm)
212 {
213 return sm->delete_object;
214 }
215
216STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm)
217 {
218 return sm->list_object_start;
219 }
220
221STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm)
222 {
223 return sm->list_object_next;
224 }
225
226STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm)
227 {
228 return sm->list_object_end;
229 }
230
231STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm)
232 {
233 return sm->update_store;
234 }
235
236STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm)
237 {
238 return sm->lock_store;
239 }
240
241STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm)
242 {
243 return sm->unlock_store;
244 }
245
246STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm)
247 {
248 return sm->ctrl;
249 }
250
diff --git a/src/lib/libcrypto/threads/netware.bat b/src/lib/libcrypto/threads/netware.bat
new file mode 100644
index 0000000000..0b3eca3caf
--- /dev/null
+++ b/src/lib/libcrypto/threads/netware.bat
@@ -0,0 +1,79 @@
1@echo off
2rem batch file to build multi-thread test ( mttest.nlm )
3
4rem command line arguments:
5rem debug => build using debug settings
6
7rem
8rem After building, copy mttest.nlm to the server and run it, you'll probably
9rem want to redirect stdout and stderr. An example command line would be
10rem "mttest.nlm -thread 20 -loops 10 -CAfile \openssl\apps\server.pem >mttest.out 2>mttest.err"
11rem
12
13del mttest.nlm
14
15set BLD_DEBUG=
16set CFLAGS=
17set LFLAGS=
18set LIBS=
19
20if "%1" == "DEBUG" set BLD_DEBUG=YES
21if "%1" == "debug" set BLD_DEBUG=YES
22
23if "%MWCIncludes%" == "" goto inc_error
24if "%PRELUDE%" == "" goto prelude_error
25if "%IMPORTS%" == "" goto imports_error
26
27set CFLAGS=-c -I..\..\outinc_nw -nosyspath -DOPENSSL_SYS_NETWARE -opt off -g -sym internal -maxerrors 20
28
29if "%BLD_DEBUG%" == "YES" set LIBS=..\..\out_nw.dbg\ssl.lib ..\..\out_nw.dbg\crypto.lib
30if "%BLD_DEBUG%" == "" set LIBS=..\..\out_nw\ssl.lib ..\..\out_nw\crypto.lib
31
32set LFLAGS=-msgstyle gcc -zerobss -stacksize 32768 -nostdlib -sym internal
33
34rem generate command file for metrowerks
35echo.
36echo Generating Metrowerks command file: mttest.def
37echo # dynamically generated command file for metrowerks build > mttest.def
38echo IMPORT @%IMPORTS%\clib.imp >> mttest.def
39echo IMPORT @%IMPORTS%\threads.imp >> mttest.def
40echo IMPORT @%IMPORTS%\ws2nlm.imp >> mttest.def
41echo IMPORT GetProcessSwitchCount >> mttest.def
42echo MODULE clib >> mttest.def
43
44rem compile
45echo.
46echo Compiling mttest.c
47mwccnlm.exe mttest.c %CFLAGS%
48if errorlevel 1 goto end
49
50rem link
51echo.
52echo Linking mttest.nlm
53mwldnlm.exe %LFLAGS% -screenname mttest -commandfile mttest.def mttest.o "%PRELUDE%" %LIBS% -o mttest.nlm
54if errorlevel 1 goto end
55
56goto end
57
58:inc_error
59echo.
60echo Environment variable MWCIncludes is not set - see install.nw
61goto end
62
63:prelude_error
64echo.
65echo Environment variable PRELUDE is not set - see install.nw
66goto end
67
68:imports_error
69echo.
70echo Environment variable IMPORTS is not set - see install.nw
71goto end
72
73
74:end
75set BLD_DEBUG=
76set CFLAGS=
77set LFLAGS=
78set LIBS=
79
diff --git a/src/lib/libcrypto/threads/pthreads-vms.com b/src/lib/libcrypto/threads/pthreads-vms.com
deleted file mode 100644
index 1cf92bdf57..0000000000
--- a/src/lib/libcrypto/threads/pthreads-vms.com
+++ /dev/null
@@ -1,14 +0,0 @@
1$! To compile mttest on VMS.
2$!
3$! WARNING: only tested with DEC C so far.
4$
5$ if (f$getsyi("cpu").lt.128)
6$ then
7$ arch := VAX
8$ else
9$ arch = f$edit( f$getsyi( "ARCH_NAME"), "UPCASE")
10$ if (arch .eqs. "") then arch = "UNK"
11$ endif
12$ define/user openssl [--.include.openssl]
13$ cc/def=PTHREADS mttest.c
14$ link mttest,[--.'arch'.exe.ssl]libssl/lib,[--.'arch'.exe.crypto]libcrypto/lib
diff --git a/src/lib/libcrypto/tmdiff.h b/src/lib/libcrypto/tmdiff.h
deleted file mode 100644
index af5c41c649..0000000000
--- a/src/lib/libcrypto/tmdiff.h
+++ /dev/null
@@ -1,93 +0,0 @@
1/* crypto/tmdiff.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/* Header for dynamic hash table routines
60 * Author - Eric Young
61 */
62/* ... erm yeah, "dynamic hash tables" you say?
63 *
64 * And what would dynamic hash tables have to do with any of this code *now*?
65 * AFAICS, this code is only referenced by crypto/bn/exp.c which is an unused
66 * file that I doubt compiles any more. speed.c is the only thing that could
67 * use this (and it has nothing to do with hash tables), yet it instead has its
68 * own duplication of all this stuff and looks, if anything, more complete. See
69 * the corresponding note in apps/speed.c.
70 * The Bemused - Geoff
71 */
72
73#ifndef HEADER_TMDIFF_H
74#define HEADER_TMDIFF_H
75
76#ifdef __cplusplus
77extern "C" {
78#endif
79
80typedef struct ms_tm MS_TM;
81
82MS_TM *ms_time_new(void );
83void ms_time_free(MS_TM *a);
84void ms_time_get(MS_TM *a);
85double ms_time_diff(MS_TM *start, MS_TM *end);
86int ms_time_cmp(const MS_TM *ap, const MS_TM *bp);
87
88#ifdef __cplusplus
89}
90#endif
91
92#endif
93
diff --git a/src/lib/libcrypto/ts/Makefile b/src/lib/libcrypto/ts/Makefile
new file mode 100644
index 0000000000..c18234555b
--- /dev/null
+++ b/src/lib/libcrypto/ts/Makefile
@@ -0,0 +1,269 @@
1#
2# SSLeay/crypto/ts/Makefile
3#
4
5DIR= ts
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I../../include
9CFLAG = -g
10INSTALL_PREFIX=
11OPENSSLDIR= /usr/local/ssl
12INSTALLTOP=/usr/local/ssl
13MAKEDEPPROG= makedepend
14MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
15MAKEFILE= Makefile
16AR= ar r
17
18PEX_LIBS=
19EX_LIBS=
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22
23GENERAL= Makefile
24TEST=
25APPS=
26
27LIB=$(TOP)/libcrypto.a
28LIBSRC= ts_err.c ts_req_utils.c ts_req_print.c ts_rsp_utils.c ts_rsp_print.c \
29 ts_rsp_sign.c ts_rsp_verify.c ts_verify_ctx.c ts_lib.c ts_conf.c \
30 ts_asn1.c
31LIBOBJ= ts_err.o ts_req_utils.o ts_req_print.o ts_rsp_utils.o ts_rsp_print.o \
32 ts_rsp_sign.o ts_rsp_verify.o ts_verify_ctx.o ts_lib.o ts_conf.o \
33 ts_asn1.o
34
35SRC= $(LIBSRC)
36
37EXHEADER= ts.h
38HEADER= $(EXHEADER)
39
40ALL= $(GENERAL) $(SRC) $(HEADER)
41
42top:
43 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
44
45test:
46
47all: lib
48
49lib: $(LIBOBJ)
50 $(AR) $(LIB) $(LIBOBJ)
51 $(RANLIB) $(LIB) || echo Never mind.
52 @touch lib
53
54files:
55 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
56
57links:
58 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
59 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
60 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
61
62install:
63 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
64 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
65 do \
66 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
67 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
68 done;
69
70tags:
71 ctags $(SRC)
72
73lint:
74 lint -DLINT $(INCLUDES) $(SRC)>fluff
75
76depend:
77 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(LIBSRC)
78
79dclean:
80 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
81 mv -f Makefile.new $(MAKEFILE)
82
83clean:
84 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff enc dec sign verify
85
86# DO NOT DELETE THIS LINE -- make depend depends on it.
87
88ts_asn1.o: ../../include/openssl/asn1.h ../../include/openssl/asn1t.h
89ts_asn1.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
90ts_asn1.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
91ts_asn1.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
92ts_asn1.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
93ts_asn1.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
94ts_asn1.o: ../../include/openssl/err.h ../../include/openssl/evp.h
95ts_asn1.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
96ts_asn1.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
97ts_asn1.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
98ts_asn1.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
99ts_asn1.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
100ts_asn1.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
101ts_asn1.o: ../../include/openssl/ts.h ../../include/openssl/x509.h
102ts_asn1.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
103ts_asn1.o: ts_asn1.c
104ts_conf.o: ../../e_os.h ../../include/openssl/asn1.h
105ts_conf.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
106ts_conf.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
107ts_conf.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
108ts_conf.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
109ts_conf.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
110ts_conf.o: ../../include/openssl/engine.h ../../include/openssl/err.h
111ts_conf.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
112ts_conf.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
113ts_conf.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
114ts_conf.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pem.h
115ts_conf.o: ../../include/openssl/pem2.h ../../include/openssl/pkcs7.h
116ts_conf.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
117ts_conf.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
118ts_conf.o: ../../include/openssl/symhacks.h ../../include/openssl/ts.h
119ts_conf.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
120ts_conf.o: ../../include/openssl/x509v3.h ../cryptlib.h ts_conf.c
121ts_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
122ts_err.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
123ts_err.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
124ts_err.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
125ts_err.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
126ts_err.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
127ts_err.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
128ts_err.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
129ts_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
130ts_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
131ts_err.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
132ts_err.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
133ts_err.o: ../../include/openssl/symhacks.h ../../include/openssl/ts.h
134ts_err.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
135ts_err.o: ../../include/openssl/x509v3.h ts_err.c
136ts_lib.o: ../../e_os.h ../../include/openssl/asn1.h ../../include/openssl/bio.h
137ts_lib.o: ../../include/openssl/bn.h ../../include/openssl/buffer.h
138ts_lib.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
139ts_lib.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
140ts_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
141ts_lib.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
142ts_lib.o: ../../include/openssl/err.h ../../include/openssl/evp.h
143ts_lib.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
144ts_lib.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h
145ts_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
146ts_lib.o: ../../include/openssl/pkcs7.h ../../include/openssl/rsa.h
147ts_lib.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
148ts_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
149ts_lib.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
150ts_lib.o: ../../include/openssl/x509v3.h ../cryptlib.h ts.h ts_lib.c
151ts_req_print.o: ../../e_os.h ../../include/openssl/asn1.h
152ts_req_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
153ts_req_print.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
154ts_req_print.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
155ts_req_print.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
156ts_req_print.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
157ts_req_print.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
158ts_req_print.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
159ts_req_print.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
160ts_req_print.o: ../../include/openssl/opensslconf.h
161ts_req_print.o: ../../include/openssl/opensslv.h
162ts_req_print.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
163ts_req_print.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
164ts_req_print.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
165ts_req_print.o: ../../include/openssl/symhacks.h ../../include/openssl/ts.h
166ts_req_print.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
167ts_req_print.o: ../../include/openssl/x509v3.h ../cryptlib.h ts_req_print.c
168ts_req_utils.o: ../../e_os.h ../../include/openssl/asn1.h
169ts_req_utils.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
170ts_req_utils.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
171ts_req_utils.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
172ts_req_utils.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
173ts_req_utils.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
174ts_req_utils.o: ../../include/openssl/err.h ../../include/openssl/evp.h
175ts_req_utils.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
176ts_req_utils.o: ../../include/openssl/objects.h
177ts_req_utils.o: ../../include/openssl/opensslconf.h
178ts_req_utils.o: ../../include/openssl/opensslv.h
179ts_req_utils.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
180ts_req_utils.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
181ts_req_utils.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
182ts_req_utils.o: ../../include/openssl/symhacks.h ../../include/openssl/ts.h
183ts_req_utils.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
184ts_req_utils.o: ../../include/openssl/x509v3.h ../cryptlib.h ts_req_utils.c
185ts_rsp_print.o: ../../e_os.h ../../include/openssl/asn1.h
186ts_rsp_print.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
187ts_rsp_print.o: ../../include/openssl/buffer.h ../../include/openssl/conf.h
188ts_rsp_print.o: ../../include/openssl/crypto.h ../../include/openssl/dh.h
189ts_rsp_print.o: ../../include/openssl/dsa.h ../../include/openssl/e_os2.h
190ts_rsp_print.o: ../../include/openssl/ec.h ../../include/openssl/ecdh.h
191ts_rsp_print.o: ../../include/openssl/ecdsa.h ../../include/openssl/err.h
192ts_rsp_print.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h
193ts_rsp_print.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h
194ts_rsp_print.o: ../../include/openssl/opensslconf.h
195ts_rsp_print.o: ../../include/openssl/opensslv.h
196ts_rsp_print.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
197ts_rsp_print.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
198ts_rsp_print.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
199ts_rsp_print.o: ../../include/openssl/symhacks.h ../../include/openssl/x509.h
200ts_rsp_print.o: ../../include/openssl/x509_vfy.h ../../include/openssl/x509v3.h
201ts_rsp_print.o: ../cryptlib.h ts.h ts_rsp_print.c
202ts_rsp_sign.o: ../../e_os.h ../../include/openssl/asn1.h
203ts_rsp_sign.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
204ts_rsp_sign.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
205ts_rsp_sign.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
206ts_rsp_sign.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
207ts_rsp_sign.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
208ts_rsp_sign.o: ../../include/openssl/err.h ../../include/openssl/evp.h
209ts_rsp_sign.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
210ts_rsp_sign.o: ../../include/openssl/objects.h
211ts_rsp_sign.o: ../../include/openssl/opensslconf.h
212ts_rsp_sign.o: ../../include/openssl/opensslv.h
213ts_rsp_sign.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
214ts_rsp_sign.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
215ts_rsp_sign.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
216ts_rsp_sign.o: ../../include/openssl/symhacks.h ../../include/openssl/ts.h
217ts_rsp_sign.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
218ts_rsp_sign.o: ../../include/openssl/x509v3.h ../cryptlib.h ts_rsp_sign.c
219ts_rsp_utils.o: ../../e_os.h ../../include/openssl/asn1.h
220ts_rsp_utils.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
221ts_rsp_utils.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
222ts_rsp_utils.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
223ts_rsp_utils.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
224ts_rsp_utils.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
225ts_rsp_utils.o: ../../include/openssl/err.h ../../include/openssl/evp.h
226ts_rsp_utils.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
227ts_rsp_utils.o: ../../include/openssl/objects.h
228ts_rsp_utils.o: ../../include/openssl/opensslconf.h
229ts_rsp_utils.o: ../../include/openssl/opensslv.h
230ts_rsp_utils.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
231ts_rsp_utils.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
232ts_rsp_utils.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
233ts_rsp_utils.o: ../../include/openssl/symhacks.h ../../include/openssl/ts.h
234ts_rsp_utils.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
235ts_rsp_utils.o: ../../include/openssl/x509v3.h ../cryptlib.h ts_rsp_utils.c
236ts_rsp_verify.o: ../../e_os.h ../../include/openssl/asn1.h
237ts_rsp_verify.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
238ts_rsp_verify.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
239ts_rsp_verify.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
240ts_rsp_verify.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
241ts_rsp_verify.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
242ts_rsp_verify.o: ../../include/openssl/err.h ../../include/openssl/evp.h
243ts_rsp_verify.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
244ts_rsp_verify.o: ../../include/openssl/objects.h
245ts_rsp_verify.o: ../../include/openssl/opensslconf.h
246ts_rsp_verify.o: ../../include/openssl/opensslv.h
247ts_rsp_verify.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
248ts_rsp_verify.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
249ts_rsp_verify.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
250ts_rsp_verify.o: ../../include/openssl/symhacks.h ../../include/openssl/ts.h
251ts_rsp_verify.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
252ts_rsp_verify.o: ../../include/openssl/x509v3.h ../cryptlib.h ts_rsp_verify.c
253ts_verify_ctx.o: ../../e_os.h ../../include/openssl/asn1.h
254ts_verify_ctx.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h
255ts_verify_ctx.o: ../../include/openssl/conf.h ../../include/openssl/crypto.h
256ts_verify_ctx.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h
257ts_verify_ctx.o: ../../include/openssl/e_os2.h ../../include/openssl/ec.h
258ts_verify_ctx.o: ../../include/openssl/ecdh.h ../../include/openssl/ecdsa.h
259ts_verify_ctx.o: ../../include/openssl/err.h ../../include/openssl/evp.h
260ts_verify_ctx.o: ../../include/openssl/lhash.h ../../include/openssl/obj_mac.h
261ts_verify_ctx.o: ../../include/openssl/objects.h
262ts_verify_ctx.o: ../../include/openssl/opensslconf.h
263ts_verify_ctx.o: ../../include/openssl/opensslv.h
264ts_verify_ctx.o: ../../include/openssl/ossl_typ.h ../../include/openssl/pkcs7.h
265ts_verify_ctx.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h
266ts_verify_ctx.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
267ts_verify_ctx.o: ../../include/openssl/symhacks.h ../../include/openssl/ts.h
268ts_verify_ctx.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
269ts_verify_ctx.o: ../../include/openssl/x509v3.h ../cryptlib.h ts_verify_ctx.c
diff --git a/src/lib/libcrypto/util/arx.pl b/src/lib/libcrypto/util/arx.pl
deleted file mode 100644
index ce62625c33..0000000000
--- a/src/lib/libcrypto/util/arx.pl
+++ /dev/null
@@ -1,15 +0,0 @@
1#!/bin/perl
2
3# Simple perl script to wrap round "ar" program and exclude any
4# object files in the environment variable EXCL_OBJ
5
6map { s/^.*\/([^\/]*)$/$1/ ; $EXCL{$_} = 1} split(' ', $ENV{EXCL_OBJ});
7
8#my @ks = keys %EXCL;
9#print STDERR "Excluding: @ks \n";
10
11my @ARGS = grep { !exists $EXCL{$_} } @ARGV;
12
13system @ARGS;
14
15exit $? >> 8;
diff --git a/src/lib/libcrypto/util/checkhash.pl b/src/lib/libcrypto/util/checkhash.pl
deleted file mode 100644
index c61fa72178..0000000000
--- a/src/lib/libcrypto/util/checkhash.pl
+++ /dev/null
@@ -1,222 +0,0 @@
1#!/usr/bin/env perl -w
2
3my $package = caller;
4
5if (!(defined $package))
6 {
7 my $retval = check_hashes(@ARGV);
8 exit $retval;
9 }
10
111;
12
13sub check_hashes
14 {
15
16 my @args = @_;
17
18 my $change_dir = "";
19 my $check_program = "sha/fips_standalone_sha1";
20
21 my $verbose = 0;
22 my $badfiles = 0;
23 my $rebuild = 0;
24 my $force_rewrite = 0;
25 my $hash_file = "fipshashes.c";
26 my $recurse = 0;
27
28 my @fingerprint_files;
29
30 while (@args)
31 {
32 my $arg = $args[0];
33 if ($arg eq "-chdir")
34 {
35 shift @args;
36 $change_dir = shift @args;
37 }
38 elsif ($arg eq "-rebuild")
39 {
40 shift @args;
41 $rebuild = 1;
42 }
43 elsif ($arg eq "-verbose")
44 {
45 shift @args;
46 $verbose = 1;
47 }
48 elsif ($arg eq "-force-rewrite")
49 {
50 shift @args;
51 $force_rewrite = 1;
52 }
53 elsif ($arg eq "-hash_file")
54 {
55 shift @args;
56 $hash_file = shift @args;
57 }
58 elsif ($arg eq "-recurse")
59 {
60 shift @args;
61 $recurse = 1;
62 }
63 elsif ($arg eq "-program_path")
64 {
65 shift @args;
66 $check_program = shift @args;
67 }
68 else
69 {
70 print STDERR "Unknown Option $arg";
71 return 1;
72 }
73
74 }
75
76 chdir $change_dir if $change_dir ne "";
77
78 if ($recurse)
79 {
80 @fingerprint_files = ("fingerprint.sha1",
81 <*/fingerprint.sha1>);
82 }
83 else
84 {
85 push @fingerprint_files, $hash_file;
86 }
87
88 foreach $fp (@fingerprint_files)
89 {
90 if (!open(IN, "$fp"))
91 {
92 print STDERR "Can't open file $fp";
93 return 1;
94 }
95 print STDERR "Opening Fingerprint file $fp\n" if $verbose;
96 my $dir = $fp;
97 $dir =~ s/[^\/]*$//;
98 while (<IN>)
99 {
100 chomp;
101 if (!(($file, $hash) = /^\"HMAC-SHA1\((.*)\)\s*=\s*(\w*)\",$/))
102 {
103 /^\"/ || next;
104 print STDERR "FATAL: Invalid syntax in file $fp\n";
105 print STDERR "Line:\n$_\n";
106 fatal_error();
107 return 1;
108 }
109 if (!$rebuild && length($hash) != 40)
110 {
111 print STDERR "FATAL: Invalid hash length in $fp for file $file\n";
112 fatal_error();
113 return 1;
114 }
115 push @hashed_files, "$dir$file";
116 if (exists $hashes{"$dir$file"})
117 {
118 print STDERR "FATAL: Duplicate Hash file $dir$file\n";
119 fatal_error();
120 return 1;
121 }
122 if (! -r "$dir$file")
123 {
124 print STDERR "FATAL: Can't access $dir$file\n";
125 fatal_error();
126 return 1;
127 }
128 $hashes{"$dir$file"} = $hash;
129 }
130 close IN;
131 }
132
133 @checked_hashes = `$check_program @hashed_files`;
134
135 if ($? != 0)
136 {
137 print STDERR "Error running hash program $check_program\n";
138 fatal_error();
139 return 1;
140 }
141
142 if (@checked_hashes != @hashed_files)
143 {
144 print STDERR "FATAL: hash count incorrect\n";
145 fatal_error();
146 return 1;
147 }
148
149 foreach (@checked_hashes)
150 {
151 chomp;
152 if (!(($file, $hash) = /^HMAC-SHA1\((.*)\)\s*=\s*(\w*)$/))
153 {
154 print STDERR "FATAL: Invalid syntax in file $fp\n";
155 print STDERR "Line:\n$_\n";
156 fatal_error();
157 return 1;
158 }
159 if (length($hash) != 40)
160 {
161 print STDERR "FATAL: Invalid hash length for file $file\n";
162 fatal_error();
163 return 1;
164 }
165 if ($hash ne $hashes{$file})
166 {
167 if ($rebuild)
168 {
169 print STDERR "Updating hash on file $file\n";
170 $hashes{$file} = $hash;
171 }
172 else
173 {
174 print STDERR "Hash check failed for file $file\n";
175 }
176 $badfiles++;
177 }
178 elsif ($verbose)
179 { print "Hash Check OK for $file\n";}
180 }
181
182
183 if ($badfiles && !$rebuild)
184 {
185 print STDERR "FATAL: hash mismatch on $badfiles files\n";
186 fatal_error();
187 return 1;
188 }
189
190 if ($badfiles || $force_rewrite)
191 {
192 print "Updating Hash file $hash_file\n";
193 if (!open(OUT, ">$hash_file"))
194 {
195 print STDERR "Error rewriting $hash_file";
196 return 1;
197 }
198 print OUT "const char * const FIPS_source_hashes[] = {\n";
199 foreach (@hashed_files)
200 {
201 print OUT "\"HMAC-SHA1($_)= $hashes{$_}\",\n";
202 }
203 print OUT "};\n";
204 close OUT;
205 }
206
207 if (!$badfiles)
208 {
209 print "FIPS hash check successful\n";
210 }
211
212 return 0;
213
214 }
215
216
217sub fatal_error
218 {
219 print STDERR "*** Your source code does not match the FIPS validated source ***\n";
220 }
221
222
diff --git a/src/lib/libcrypto/util/copy.pl b/src/lib/libcrypto/util/copy.pl
new file mode 100644
index 0000000000..eba6d5815e
--- /dev/null
+++ b/src/lib/libcrypto/util/copy.pl
@@ -0,0 +1,70 @@
1#!/usr/local/bin/perl
2
3use Fcntl;
4
5
6# copy.pl
7
8# Perl script 'copy' comment. On Windows the built in "copy" command also
9# copies timestamps: this messes up Makefile dependencies.
10
11my $stripcr = 0;
12
13my $arg;
14
15foreach $arg (@ARGV) {
16 if ($arg eq "-stripcr")
17 {
18 $stripcr = 1;
19 next;
20 }
21 $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob...
22 foreach (glob $arg)
23 {
24 push @filelist, $_;
25 }
26}
27
28$fnum = @filelist;
29
30if ($fnum <= 1)
31 {
32 die "Need at least two filenames";
33 }
34
35$dest = pop @filelist;
36
37if ($fnum > 2 && ! -d $dest)
38 {
39 die "Destination must be a directory";
40 }
41
42foreach (@filelist)
43 {
44 if (-d $dest)
45 {
46 $dfile = $_;
47 $dfile =~ s|^.*[/\\]([^/\\]*)$|$1|;
48 $dfile = "$dest/$dfile";
49 }
50 else
51 {
52 $dfile = $dest;
53 }
54 sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_";
55 sysopen(OUT, $dfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY)
56 || die "Can't Open $dfile";
57 while (sysread IN, $buf, 10240)
58 {
59 if ($stripcr)
60 {
61 $buf =~ tr/\015//d;
62 }
63 syswrite(OUT, $buf, length($buf));
64 }
65 close(IN);
66 close(OUT);
67 print "Copying: $_ to $dfile\n";
68 }
69
70
diff --git a/src/lib/libcrypto/util/deltree.com b/src/lib/libcrypto/util/deltree.com
deleted file mode 100644
index 9f36b1a5e9..0000000000
--- a/src/lib/libcrypto/util/deltree.com
+++ /dev/null
@@ -1,34 +0,0 @@
1$! DELTREE.COM
2$
3$ call deltree 'p1'
4$ exit $status
5$
6$ deltree: subroutine ! P1 is a name of a directory
7$ on control_y then goto dt_STOP
8$ on warning then goto dt_exit
9$ _dt_def = f$trnlnm("SYS$DISK")+f$directory()
10$ if f$parse(p1) .eqs. "" then exit
11$ set default 'f$parse(p1,,,"DEVICE")''f$parse(p1,,,"DIRECTORY")'
12$ p1 = f$parse(p1,,,"NAME") + f$parse(p1,,,"TYPE")
13$ _fp = f$parse(".DIR",p1)
14$ dt_loop:
15$ _f = f$search(_fp)
16$ if _f .eqs. "" then goto dt_loopend
17$ call deltree [.'f$parse(_f,,,"NAME")']*.*
18$ goto dt_loop
19$ dt_loopend:
20$ _fp = f$parse(p1,".;*")
21$ if f$search(_fp) .eqs. "" then goto dt_exit
22$ set noon
23$ set file/prot=(S:RWED,O:RWED,G:RWED,W:RWED) '_fp'
24$ set on
25$ delete/nolog '_fp'
26$ dt_exit:
27$ set default '_dt_def'
28$ goto dt_end
29$ dt_STOP:
30$ set default '_dt_def'
31$ stop/id=""
32$ exit
33$ dt_end:
34$ endsubroutine
diff --git a/src/lib/libcrypto/util/extract-section.pl b/src/lib/libcrypto/util/extract-section.pl
new file mode 100644
index 0000000000..7a0ba4f69a
--- /dev/null
+++ b/src/lib/libcrypto/util/extract-section.pl
@@ -0,0 +1,12 @@
1#!/usr/bin/perl
2
3while(<STDIN>) {
4 if (/=for\s+comment\s+openssl_manual_section:(\S+)/)
5 {
6 print "$1\n";
7 exit 0;
8 }
9}
10
11print "$ARGV[0]\n";
12
diff --git a/src/lib/libcrypto/util/fipslink.pl b/src/lib/libcrypto/util/fipslink.pl
deleted file mode 100644
index 3597bc1740..0000000000
--- a/src/lib/libcrypto/util/fipslink.pl
+++ /dev/null
@@ -1,78 +0,0 @@
1#!/usr/bin/perl
2
3sub check_env
4 {
5 my @ret;
6 foreach (@_)
7 {
8 die "Environment variable $_ not defined!\n" unless exists $ENV{$_};
9 push @ret, $ENV{$_};
10 }
11 return @ret;
12 }
13
14
15my ($fips_cc,$fips_cc_args, $fips_link,$fips_target, $fips_libdir, $sha1_exe)
16 = check_env("FIPS_CC", "FIPS_CC_ARGS", "FIPS_LINK", "FIPS_TARGET",
17 "FIPSLIB_D", "FIPS_SHA1_EXE");
18
19
20
21if (exists $ENV{"PREMAIN_DSO_EXE"})
22 {
23 $fips_premain_dso = $ENV{"PREMAIN_DSO_EXE"};
24 }
25 else
26 {
27 $fips_premain_dso = "";
28 }
29
30check_hash($sha1_exe, "fips_premain.c");
31check_hash($sha1_exe, "fipscanister.lib");
32
33
34print "Integrity check OK\n";
35
36print "$fips_cc $fips_cc_args $fips_libdir/fips_premain.c\n";
37system "$fips_cc $fips_cc_args $fips_libdir/fips_premain.c";
38die "First stage Compile failure" if $? != 0;
39
40print "$fips_link @ARGV\n";
41system "$fips_link @ARGV";
42die "First stage Link failure" if $? != 0;
43
44
45print "$fips_premain_dso $fips_target\n";
46$fips_hash=`$fips_premain_dso $fips_target`;
47chomp $fips_hash;
48die "Get hash failure" if $? != 0;
49
50
51print "$fips_cc -DHMAC_SHA1_SIG=\\\"$fips_hash\\\" $fips_cc_args $fips_libdir/fips_premain.c\n";
52system "$fips_cc -DHMAC_SHA1_SIG=\\\"$fips_hash\\\" $fips_cc_args $fips_libdir/fips_premain.c";
53die "Second stage Compile failure" if $? != 0;
54
55
56print "$fips_link @ARGV\n";
57system "$fips_link @ARGV";
58die "Second stage Link failure" if $? != 0;
59
60sub check_hash
61 {
62 my ($sha1_exe, $filename) = @_;
63 my ($hashfile, $hashval);
64
65 open(IN, "${fips_libdir}/${filename}.sha1") || die "Cannot open file hash file ${fips_libdir}/${filename}.sha1";
66 $hashfile = <IN>;
67 close IN;
68 $hashval = `$sha1_exe ${fips_libdir}/$filename`;
69 chomp $hashfile;
70 chomp $hashval;
71 $hashfile =~ s/^.*=\s+//;
72 $hashval =~ s/^.*=\s+//;
73 die "Invalid hash syntax in file" if (length($hashfile) != 40);
74 die "Invalid hash received for file" if (length($hashval) != 40);
75 die "***HASH VALUE MISMATCH FOR FILE $filename ***" if ($hashval ne $hashfile);
76 }
77
78
diff --git a/src/lib/libcrypto/util/mkrc.pl b/src/lib/libcrypto/util/mkrc.pl
new file mode 100755
index 0000000000..0ceadcf8d1
--- /dev/null
+++ b/src/lib/libcrypto/util/mkrc.pl
@@ -0,0 +1,71 @@
1#!/bin/env perl
2#
3open FD,"crypto/opensslv.h";
4while(<FD>) {
5 if (/OPENSSL_VERSION_NUMBER\s+(0x[0-9a-f]+)/i) {
6 $ver = hex($1);
7 $v1 = ($ver>>28);
8 $v2 = ($ver>>20)&0xff;
9 $v3 = ($ver>>12)&0xff;
10 $v4 = ($ver>> 4)&0xff;
11 $beta = $ver&0xf;
12 $version = "$v1.$v2.$v3";
13 if ($beta==0xf) { $version .= chr(ord('a')+$v4-1) if ($v4); }
14 elsif ($beta==0){ $version .= "-dev"; }
15 else { $version .= "-beta$beta"; }
16 last;
17 }
18}
19close(FD);
20
21$filename = $ARGV[0]; $filename =~ /(.*)\.([^.]+)$/;
22$basename = $1;
23$extname = $2;
24
25if ($extname =~ /dll/i) { $description = "OpenSSL shared library"; }
26else { $description = "OpenSSL application"; }
27
28print <<___;
29#include <winver.h>
30
31LANGUAGE 0x09,0x01
32
331 VERSIONINFO
34 FILEVERSION $v1,$v2,$v3,$v4
35 PRODUCTVERSION $v1,$v2,$v3,$v4
36 FILEFLAGSMASK 0x3fL
37#ifdef _DEBUG
38 FILEFLAGS 0x01L
39#else
40 FILEFLAGS 0x00L
41#endif
42 FILEOS VOS__WINDOWS32
43 FILETYPE VFT_DLL
44 FILESUBTYPE 0x0L
45BEGIN
46 BLOCK "StringFileInfo"
47 BEGIN
48 BLOCK "040904b0"
49 BEGIN
50 // Required:
51 VALUE "CompanyName", "The OpenSSL Project, http://www.openssl.org/\\0"
52 VALUE "FileDescription", "$description\\0"
53 VALUE "FileVersion", "$version\\0"
54 VALUE "InternalName", "$basename\\0"
55 VALUE "OriginalFilename", "$filename\\0"
56 VALUE "ProductName", "The OpenSSL Toolkit\\0"
57 VALUE "ProductVersion", "$version\\0"
58 // Optional:
59 //VALUE "Comments", "\\0"
60 VALUE "LegalCopyright", "Copyright © 1998-2006 The OpenSSL Project. Copyright © 1995-1998 Eric A. Young, Tim J. Hudson. All rights reserved.\\0"
61 //VALUE "LegalTrademarks", "\\0"
62 //VALUE "PrivateBuild", "\\0"
63 //VALUE "SpecialBuild", "\\0"
64 END
65 END
66 BLOCK "VarFileInfo"
67 BEGIN
68 VALUE "Translation", 0x409, 0x4b0
69 END
70END
71___
diff --git a/src/lib/libcrypto/util/mksdef.pl b/src/lib/libcrypto/util/mksdef.pl
deleted file mode 100644
index 065dc675f1..0000000000
--- a/src/lib/libcrypto/util/mksdef.pl
+++ /dev/null
@@ -1,87 +0,0 @@
1
2# Perl script to split libeay32.def into two distinct DEF files for use in
3# fipdso mode. It works out symbols in each case by running "link" command and
4# parsing the output to find the list of missing symbols then splitting
5# libeay32.def based on the result.
6
7
8# Get list of unknown symbols
9
10my @deferr = `link @ARGV`;
11
12my $preamble = "";
13my @fipsdll;
14my @fipsrest;
15my %nosym;
16
17# Add symbols to a hash for easy lookup
18
19foreach (@deferr)
20 {
21 if (/^.*symbol (\S+)$/)
22 {
23 $nosym{$1} = 1;
24 }
25 }
26
27open (IN, "ms/libeay32.def") || die "Can't Open DEF file for spliting";
28
29my $started = 0;
30
31# Parse libeay32.def into two arrays depending on whether the symbol matches
32# the missing list.
33
34
35foreach (<IN>)
36 {
37 if (/^\s*(\S+)\s*(\@\S+)\s*$/)
38 {
39 $started = 1;
40 if (exists $nosym{$1})
41 {
42 push @fipsrest, $_;
43 }
44 else
45 {
46 my $imptmp = sprintf " %-39s %s\n",
47 "$1=libosslfips.$1", $2;
48 push @fipsrest, $imptmp;
49 push @fipsdll, "\t$1\n";
50 }
51 }
52 $preamble .= $_ unless $started;
53 }
54
55close IN;
56
57# Hack! Add some additional exports needed for libcryptofips.dll
58#
59
60push @fipsdll, "\tOPENSSL_showfatal\n";
61push @fipsdll, "\tOPENSSL_cpuid_setup\n";
62
63# Write out DEF files for each array
64
65write_def("ms/libosslfips.def", "LIBOSSLFIPS", $preamble, \@fipsdll);
66write_def("ms/libeayfips.def", "", $preamble, \@fipsrest);
67
68
69sub write_def
70 {
71 my ($fnam, $defname, $preamble, $rdefs) = @_;
72 open (OUT, ">$fnam") || die "Can't Open DEF file $fnam for Writing\n";
73
74 if ($defname ne "")
75 {
76 $preamble =~ s/LIBEAY32/$defname/g;
77 $preamble =~ s/LIBEAY/$defname/g;
78 }
79 print OUT $preamble;
80 foreach (@$rdefs)
81 {
82 print OUT $_;
83 }
84 close OUT;
85 }
86
87
diff --git a/src/lib/libcrypto/util/pl/BC-16.pl b/src/lib/libcrypto/util/pl/BC-16.pl
deleted file mode 100644
index 8030653daa..0000000000
--- a/src/lib/libcrypto/util/pl/BC-16.pl
+++ /dev/null
@@ -1,151 +0,0 @@
1#!/usr/local/bin/perl
2# VCw16lib.pl - the file for Visual C++ 1.52b for windows, static libraries
3#
4
5$o='\\';
6$cp='copy';
7$rm='del';
8
9# C compiler stuff
10$cc='bcc';
11
12if ($debug)
13 { $op="-v "; }
14else { $op="-O "; }
15
16$cflags="-d -ml $op -DL_ENDIAN";
17# I add the stack opt
18$base_lflags="/c /C";
19$lflags="$base_lflags";
20
21if ($win16)
22 {
23 $shlib=1;
24 $cflags.=" -DOPENSSL_SYSNAME_WIN16";
25 $app_cflag="-W";
26 $lib_cflag="-WD";
27 $lflags.="/Twe";
28 }
29else
30 {
31 $cflags.=" -DOENSSL_SYSNAME_MSDOS";
32 $lflags.=" /Tde";
33 }
34
35if ($shlib)
36 {
37 $mlflags=" /Twd $base_lflags"; # stack if defined in .def file
38 $libs="libw ldllcew";
39 $no_asm=1;
40 }
41else
42 { $mlflags=''; }
43
44$obj='.obj';
45$ofile="-o";
46
47# EXE linking stuff
48$link="tlink";
49$efile="";
50$exep='.exe';
51$ex_libs="CL";
52$ex_libs.=$no_sock?"":" winsock.lib";
53
54$app_ex_obj="C0L.obj ";
55$shlib_ex_obj="" if ($shlib);
56
57# static library stuff
58$mklib='tlib';
59$ranlib='echo no ranlib';
60$plib="";
61$libp=".lib";
62$shlibp=($shlib)?".dll":".lib";
63$lfile='';
64
65$asm='bcc -c -B -Tml';
66$afile='/o';
67if ($no_asm || $fips)
68 {
69 $bn_asm_obj='';
70 $bn_asm_src='';
71 }
72elsif ($asmbits == 32)
73 {
74 $bn_asm_obj='crypto\bn\asm\x86w32.obj';
75 $bn_asm_src='crypto\bn\asm\x86w32.asm';
76 }
77else
78 {
79 $bn_asm_obj='crypto\bn\asm\x86w16.obj';
80 $bn_asm_src='crypto\bn\asm\x86w16.asm';
81 }
82
83sub do_lib_rule
84 {
85 local($target,$name,$shlib)=@_;
86 local($ret,$Name);
87
88 $taget =~ s/\//$o/g if $o ne '/';
89 ($Name=$name) =~ tr/a-z/A-Z/;
90
91 $ret.="$target: \$(${Name}OBJ)\n";
92 $ret.="\t\$(RM) \$(O_$Name)\n";
93
94 # Due to a pathetic line length limit, I unwrap the args.
95 local($lib_names)="";
96 local($dll_names)="";
97 foreach $_ (sort split(/\s+/,$Vars{"${Name}OBJ"}))
98 {
99 $lib_names.=" +$_ &\n";
100 $dll_names.=" $_\n";
101 }
102
103 if (!$shlib)
104 {
105 $ret.="\t\$(MKLIB) $target & <<|\n$lib_names\n,\n|\n";
106 }
107 else
108 {
109 local($ex)=($Name eq "SSL")?' $(L_CRYPTO) winsock':"";
110 $ret.="\t\$(LINK) \$(MLFLAGS) @&&|\n";
111 $ret.=$dll_names;
112 $ret.="\n $target\n\n $ex $libs\nms$o${name}16.def;\n|\n";
113 ($out_lib=$target) =~ s/O_/L_/;
114 $ret.="\timplib /nowep $out_lib $target\n\n";
115 }
116 $ret.="\n";
117 return($ret);
118 }
119
120sub do_link_rule
121 {
122 local($target,$files,$dep_libs,$libs,$sha1file,$openssl)=@_;
123 local($ret,$f,$_,@f);
124
125 $file =~ s/\//$o/g if $o ne '/';
126 $n=&bname($target);
127 $ret.="$target: $files $dep_libs\n";
128 $ret.=" \$(LINK) @&&|";
129
130 # Due to a pathetic line length limit, I have to unwrap the args.
131 $ret.=" \$(LFLAGS) ";
132 if ($files =~ /\(([^)]*)\)$/)
133 {
134 $ret.=" \$(APP_EX_OBJ)";
135 foreach $_ (sort split(/\s+/,$Vars{$1}))
136 { $ret.="\n $r $_ +"; }
137 chop($ret);
138 $ret.="\n";
139 }
140 else
141 { $ret.="\n $r \$(APP_EX_OBJ) $files\n"; }
142 $ret.=" $target\n\n $libs\n\n|\n";
143 if (defined $sha1file)
144 {
145 $ret.=" $openssl sha1 -hmac etaonrishdlcupfm -binary $target > $sha1file";
146 }
147 $ret.="\n";
148 return($ret);
149 }
150
1511;
diff --git a/src/lib/libcrypto/util/pl/VC-16.pl b/src/lib/libcrypto/util/pl/VC-16.pl
deleted file mode 100644
index 564ba3fd08..0000000000
--- a/src/lib/libcrypto/util/pl/VC-16.pl
+++ /dev/null
@@ -1,177 +0,0 @@
1#!/usr/local/bin/perl
2# VCw16lib.pl - the file for Visual C++ 1.52b for windows, static libraries
3#
4
5$ssl= "ssleay16";
6$crypto="libeay16";
7
8$o='\\';
9$cp='copy';
10$rm='del';
11
12# C compiler stuff
13$cc='cl';
14
15$out_def="out16";
16$tmp_def="tmp16";
17$inc_def="inc16";
18
19if ($debug)
20 {
21 $op="/Od /Zi /Zd";
22 $base_lflags="/CO";
23 }
24else {
25 $op="/G2 /f- /Ocgnotb2";
26 }
27$base_lflags.=" /FARCALL /NOLOGO /NOD /SEG:1024 /ONERROR:NOEXE /NOE /PACKC:60000";
28if ($win16) { $base_lflags.=" /PACKD:60000"; }
29
30$cflags="/ALw /Gx- /Gt256 /Gf $op /W3 /WX -DL_ENDIAN /nologo";
31# I add the stack opt
32$lflags="$base_lflags /STACK:20000";
33
34if ($win16)
35 {
36 $cflags.=" -DOPENSSL_SYSNAME_WIN16";
37 $app_cflag="/Gw /FPi87";
38 $lib_cflag="/Gw";
39 $lib_cflag.=" -D_WINDLL -D_DLL" if $shlib;
40 $lib_cflag.=" -DWIN16TTY" if !$shlib;
41 $lflags.=" /ALIGN:256";
42 $ex_libs.="oldnames llibcewq libw";
43 }
44else
45 {
46 $no_sock=1;
47 $cflags.=" -DMSDOS";
48 $lflags.=" /EXEPACK";
49 $ex_libs.="oldnames.lib llibce.lib";
50 }
51
52if ($shlib)
53 {
54 $mlflags="$base_lflags";
55 $libs="oldnames ldllcew libw";
56 $shlib_ex_obj="";
57# $no_asm=1;
58 $out_def="out16dll";
59 $tmp_def="tmp16dll";
60 }
61else
62 { $mlflags=''; }
63
64$app_ex_obj="";
65
66$obj='.obj';
67$ofile="/Fo";
68
69# EXE linking stuff
70$link="link";
71$efile="";
72$exep='.exe';
73$ex_libs.=$no_sock?"":" winsock";
74
75# static library stuff
76$mklib='lib /PAGESIZE:1024';
77$ranlib='';
78$plib="";
79$libp=".lib";
80$shlibp=($shlib)?".dll":".lib";
81$lfile='';
82
83$asm='ml /Cp /c /Cx';
84$afile='/Fo';
85
86$bn_asm_obj='';
87$bn_asm_src='';
88$des_enc_obj='';
89$des_enc_src='';
90$bf_enc_obj='';
91$bf_enc_src='';
92
93if (!$no_asm && !$fips)
94 {
95 if ($asmbits == 32)
96 {
97 $bn_asm_obj='crypto\bn\asm\x86w32.obj';
98 $bn_asm_src='crypto\bn\asm\x86w32.asm';
99 }
100 else
101 {
102 $bn_asm_obj='crypto\bn\asm\x86w16.obj';
103 $bn_asm_src='crypto\bn\asm\x86w16.asm';
104 }
105 }
106
107sub do_lib_rule
108 {
109 local($objs,$target,$name,$shlib)=@_;
110 local($ret,$Name);
111
112 $taget =~ s/\//$o/g if $o ne '/';
113 ($Name=$name) =~ tr/a-z/A-Z/;
114
115# $target="\$(LIB_D)$o$target";
116 $ret.="$target: $objs\n";
117# $ret.="\t\$(RM) \$(O_$Name)\n";
118
119 # Due to a pathetic line length limit, I unwrap the args.
120 local($lib_names)="";
121 local($dll_names)=" \$(SHLIB_EX_OBJ) +\n";
122 ($obj)= ($objs =~ /\((.*)\)/);
123 foreach $_ (sort split(/\s+/,$Vars{$obj}))
124 {
125 $lib_names.="+$_ &\n";
126 $dll_names.=" $_ +\n";
127 }
128
129 if (!$shlib)
130 {
131 $ret.="\tdel $target\n";
132 $ret.="\t\$(MKLIB) @<<\n$target\ny\n$lib_names\n\n<<\n";
133 }
134 else
135 {
136 local($ex)=($target =~ /O_SSL/)?'$(L_CRYPTO)':"";
137 $ex.=' winsock';
138 $ret.="\t\$(LINK) \$(MLFLAGS) @<<\n";
139 $ret.=$dll_names;
140 $ret.="\n $target\n\n $ex $libs\nms$o${name}.def;\n<<\n";
141 ($out_lib=$target) =~ s/O_/L_/;
142 $ret.="\timplib /noignorecase /nowep $out_lib $target\n";
143 }
144 $ret.="\n";
145 return($ret);
146 }
147
148sub do_link_rule
149 {
150 local($target,$files,$dep_libs,$libs,$sha1file,$openssl)=@_;
151 local($ret,$f,$_,@f);
152
153 $file =~ s/\//$o/g if $o ne '/';
154 $n=&bname($targer);
155 $ret.="$target: $files $dep_libs\n";
156 $ret.=" \$(LINK) \$(LFLAGS) @<<\n";
157
158 # Due to a pathetic line length limit, I have to unwrap the args.
159 if ($files =~ /\(([^)]*)\)$/)
160 {
161 @a=('$(APP_EX_OBJ)');
162 push(@a,sort split(/\s+/,$Vars{$1}));
163 for $_ (@a)
164 { $ret.=" $_ +\n"; }
165 }
166 else
167 { $ret.=" \$(APP_EX_OBJ) $files"; }
168 $ret.="\n $target\n\n $libs\n\n<<\n";
169 if (defined $sha1file)
170 {
171 $ret.=" $openssl sha1 -hmac etaonrishdlcupfm -binary $target > $sha1file";
172 }
173 $ret.="\n";
174 return($ret);
175 }
176
1771;
diff --git a/src/lib/libcrypto/util/pl/VC-32-GMAKE.pl b/src/lib/libcrypto/util/pl/VC-32-GMAKE.pl
deleted file mode 100644
index b5bbcac6c2..0000000000
--- a/src/lib/libcrypto/util/pl/VC-32-GMAKE.pl
+++ /dev/null
@@ -1,222 +0,0 @@
1#!/usr/local/bin/perl
2# VCw32lib.pl - the file for Visual C++ 4.[01] for windows NT, static libraries
3#
4
5
6if ($fips && !$shlib)
7 {
8 $crypto="libeayfips32";
9 $crypto_compat = "libeaycompat32.lib";
10 }
11else
12 {
13 $crypto="libeay32";
14 }
15$ssl= "ssleay32";
16
17$o='/';
18#$cp='copy nul+'; # Timestamps get stuffed otherwise
19#$rm='del';
20
21$cp='cp';
22$rm='rm';
23
24$zlib_lib="zlib1.lib";
25
26# C compiler stuff
27$cc='cl';
28$cflags=' -MD -W3 -WX -Ox -O2 -Ob2 -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
29$cflags.=' -D_CRT_SECURE_NO_DEPRECATE'; # shut up VC8
30$cflags.=' -D_CRT_NONSTDC_NO_DEPRECATE'; # shut up VC8
31$lflags="-nologo -subsystem:console -machine:I386 -opt:ref";
32$mlflags='';
33
34$out_def="gmout32";
35$tmp_def="gmtmp32";
36$inc_def="gminc32";
37
38if ($debug)
39 {
40 $cflags=" -MDd -W3 -WX -Zi -Yd -Od -nologo -DOPENSSL_SYSNAME_WIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG -DDSO_WIN32";
41 $lflags.=" -debug";
42 $mlflags.=' -debug';
43 }
44$cflags .= " -DOPENSSL_SYSNAME_WINNT" if $NT == 1;
45
46$obj='.obj';
47$ofile="-Fo";
48
49# EXE linking stuff
50$link="link";
51$efile="-out:";
52$exep='.exe';
53if ($no_sock)
54 { $ex_libs=""; }
55else { $ex_libs="wsock32.lib user32.lib gdi32.lib"; }
56
57# static library stuff
58$mklib='lib';
59$ranlib='';
60$plib="";
61$libp=".lib";
62$shlibp=($shlib)?".dll":".lib";
63$lfile='-out:';
64
65$shlib_ex_obj="";
66$app_ex_obj="setargv.obj";
67if ($nasm) {
68 $asm='nasmw -f win32';
69 $afile='-o ';
70} else {
71 $asm='ml -Cp -coff -c -Cx';
72 $asm.=" -Zi" if $debug;
73 $afile='-Fo';
74}
75
76$bn_asm_obj='';
77$bn_asm_src='';
78$des_enc_obj='';
79$des_enc_src='';
80$bf_enc_obj='';
81$bf_enc_src='';
82
83if (!$no_asm && !$fips)
84 {
85 $bn_asm_obj='crypto/bn/asm/bn_win32.obj';
86 $bn_asm_src='crypto/bn/asm/bn_win32.asm';
87 $des_enc_obj='crypto/des/asm/d_win32.obj crypto/des/asm/y_win32.obj';
88 $des_enc_src='crypto/des/asm/d_win32.asm crypto/des/asm/y_win32.asm';
89 $bf_enc_obj='crypto/bf/asm/b_win32.obj';
90 $bf_enc_src='crypto/bf/asm/b_win32.asm';
91 $cast_enc_obj='crypto/cast/asm/c_win32.obj';
92 $cast_enc_src='crypto/cast/asm/c_win32.asm';
93 $rc4_enc_obj='crypto/rc4/asm/r4_win32.obj';
94 $rc4_enc_src='crypto/rc4/asm/r4_win32.asm';
95 $rc5_enc_obj='crypto/rc5/asm/r5_win32.obj';
96 $rc5_enc_src='crypto/rc5/asm/r5_win32.asm';
97 $md5_asm_obj='crypto/md5/asm/m5_win32.obj';
98 $md5_asm_src='crypto/md5/asm/m5_win32.asm';
99 $sha1_asm_obj='crypto/sha/asm/s1_win32.obj';
100 $sha1_asm_src='crypto/sha/asm/s1_win32.asm';
101 $rmd160_asm_obj='crypto/ripemd/asm/rm_win32.obj';
102 $rmd160_asm_src='crypto/ripemd/asm/rm_win32.asm';
103 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
104 }
105
106if ($shlib)
107 {
108 $mlflags.=" $lflags -dll";
109# $cflags =~ s| -MD| -MT|;
110 $lib_cflag=" -D_WINDLL";
111 $out_def="gmout32dll";
112 $tmp_def="gmtmp32dll";
113 }
114
115$cflags.=" -Fd$out_def";
116
117sub do_lib_rule
118 {
119 local($objs,$target,$name,$shlib,$ign,$base_addr, $fips_get_sig, $fips_premain_src)=@_;
120 local($ret,$Name);
121
122 $taget =~ s/\//$o/g if $o ne '/';
123 ($Name=$name) =~ tr/a-z/A-Z/;
124 my $base_arg;
125 if ($base_addr ne "")
126 {
127 $base_arg= " -base:$base_addr";
128 }
129 else
130 {
131 $base_arg = "";
132 }
133
134
135# $target="\$(LIB_D)$o$target";
136 if (!$shlib)
137 {
138# $ret.="\t\$(RM) \$(O_$Name)\n";
139 $ret.="$target: $objs\n";
140 $ex =' advapi32.lib';
141 $ret.="\t\$(MKLIB) $lfile$target $objs $ex\n\n";
142 }
143 else
144 {
145 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
146 $ex.=' wsock32.lib gdi32.lib advapi32.lib user32.lib';
147 $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/;
148 if (defined $fips_get_sig)
149 {
150 $ret.="$target: \$(O_FIPSCANISTER) $objs $fips_get_sig\n";
151 $ret.="\tFIPS_LINK=\$(LINK) ";
152 $ret.="FIPS_CC=\$(CC) ";
153 $ret.="FIPS_CC_ARGS=\"-Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\" ";
154 $ret.="FIPS_PREMAIN_DSO=$fips_get_sig ";
155 $ret.="FIPS_TARGET=$target ";
156 $ret.="FIPS_LIBDIR=\$(FIPSLIB_D) ";
157 $ret.="\$(FIPSLINK) \$(MLFLAGS) $base_arg $efile$target ";
158 $ret.="-def:ms/${Name}.def \$(SHLIB_EX_OBJ) $objs ";
159 $ret.="\$(OBJ_D)${o}fips_premain.obj $ex\n\n";
160 }
161 else
162 {
163 $ret.="$target: $objs\n";
164 $ret.="\t\$(LINK) \$(MLFLAGS) $base_arg $efile$target /def:ms/${Name}.def \$(SHLIB_EX_OBJ) $objs $ex\n\n";
165 }
166 }
167 $ret.="\n";
168 return($ret);
169 }
170
171sub do_link_rule
172 {
173 local($target,$files,$dep_libs,$libs,$standalone)=@_;
174 local($ret,$_);
175 $file =~ s/\//$o/g if $o ne '/';
176 $n=&bname($targer);
177 if ($standalone)
178 {
179 $ret.="$target: $files $dep_libs\n";
180 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target ";
181 $ret.="$files $libs\n\n";
182 }
183 elsif ($fips && !$shlib)
184 {
185 $ret.="$target: \$(O_FIPSCANISTER) $files $dep_libs\n";
186 $ret.="\tFIPS_LINK=\$(LINK) ";
187 $ret.="FIPS_CC=\$(CC) ";
188 $ret.="FIPS_CC_ARGS=\"-Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\" ";
189 $ret.="FIPS_PREMAIN_DSO= ";
190 $ret.="FIPS_TARGET=$target ";
191 $ret.="FIPS_LIBDIR=\$(FIPSLIB_D) ";
192 $ret.=" \$(FIPSLINK) \$(LFLAGS) $efile$target ";
193 $ret.="\$(APP_EX_OBJ) $files \$(OBJ_D)${o}fips_premain.obj $libs\n\n";
194 }
195 else
196 {
197 $ret.="$target: $files $dep_libs\n";
198 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target ";
199 $ret.="\$(APP_EX_OBJ) $files $libs\n\n";
200 }
201 $ret.="\n";
202 return($ret);
203 }
204
205sub do_rlink_rule
206 {
207 local($target,$files,$check_hash, $deps)=@_;
208 local($ret,$_);
209
210 $file =~ s/\//$o/g if $o ne '/';
211 $n=&bname($targer);
212 $ret.="$target: $check_hash $files $deps\n";
213 $ret.="\t\$(PERL) util${o}checkhash.pl -chdir fips-1.0 -program_path ..$o$check_hash\n";
214 $ret.="\t\$(MKCANISTER) $target $files\n";
215 $ret.="\t$check_hash $target > $target.sha1\n";
216 $ret.="\t\$(CP) fips-1.0${o}fips_premain.c \$(FIPSLIB_D)\n";
217 $ret.="\t$check_hash \$(FIPSLIB_D)${o}fips_premain.c > \$(FIPSLIB_D)${o}fips_premain.c.sha1\n\n";
218 return($ret);
219 }
220
221
2221;
diff --git a/src/lib/libcrypto/util/pl/VC-CE.pl b/src/lib/libcrypto/util/pl/VC-CE.pl
deleted file mode 100644
index 2fd0c4dd32..0000000000
--- a/src/lib/libcrypto/util/pl/VC-CE.pl
+++ /dev/null
@@ -1,116 +0,0 @@
1#!/usr/local/bin/perl
2# VC-CE.pl - the file for eMbedded Visual C++ 3.0 for windows CE, static libraries
3#
4
5$ssl= "ssleay32";
6$crypto="libeay32";
7$RSAref="RSAref32";
8
9$o='\\';
10$cp='copy nul+'; # Timestamps get stuffed otherwise
11$rm='del';
12
13# C compiler stuff
14$cc='$(CC)';
15$cflags=' /W3 /WX /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo $(WCETARGETDEFS) -DUNICODE -D_UNICODE -DWIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -I$(WCECOMPAT)/include';
16$lflags='/nologo /subsystem:windowsce,$(WCELDVERSION) /machine:$(WCELDMACHINE) /opt:ref';
17$mlflags='';
18
19$out_def='out32_$(TARGETCPU)';
20$tmp_def='tmp32_$(TARGETCPU)';
21$inc_def="inc32";
22
23if ($debug)
24 {
25 $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DWIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG -DDSO_WIN32";
26 $lflags.=" /debug";
27 $mlflags.=' /debug';
28 }
29
30$obj='.obj';
31$ofile="/Fo";
32
33# EXE linking stuff
34$link="link";
35$efile="/out:";
36$exep='.exe';
37if ($no_sock)
38 { $ex_libs=""; }
39else { $ex_libs='winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib $(WCELDFLAGS)'; }
40
41# static library stuff
42$mklib='lib';
43$ranlib='';
44$plib="";
45$libp=".lib";
46$shlibp=($shlib)?".dll":".lib";
47$lfile='/out:';
48
49$shlib_ex_obj="";
50$app_ex_obj="";
51$app_ex_obj="";
52
53$bn_asm_obj='';
54$bn_asm_src='';
55$des_enc_obj='';
56$des_enc_src='';
57$bf_enc_obj='';
58$bf_enc_src='';
59
60if ($shlib)
61 {
62 $mlflags.=" $lflags /dll";
63# $cflags =~ s| /MD| /MT|;
64 $lib_cflag=" -D_WINDLL -D_DLL";
65 $out_def='out32dll_$(TARGETCPU)';
66 $tmp_def='tmp32dll_$(TARGETCPU)';
67 }
68
69$cflags.=" /Fd$out_def";
70
71sub do_lib_rule
72 {
73 local($objs,$target,$name,$shlib)=@_;
74 local($ret,$Name);
75
76 $taget =~ s/\//$o/g if $o ne '/';
77 ($Name=$name) =~ tr/a-z/A-Z/;
78
79# $target="\$(LIB_D)$o$target";
80 $ret.="$target: $objs\n";
81 if (!$shlib)
82 {
83# $ret.="\t\$(RM) \$(O_$Name)\n";
84 $ex =' ';
85 $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs $ex\n<<\n";
86 }
87 else
88 {
89 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
90# $ex.=' winsock.lib coredll.lib $(WCECOMPAT)/lib/wcecompatex.lib';
91 $ex.=' winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib';
92 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
93 }
94 $ret.="\n";
95 return($ret);
96 }
97
98sub do_link_rule
99 {
100 local($target,$files,$dep_libs,$libs,$sha1file,$openssl)=@_;
101 local($ret,$_);
102
103 $file =~ s/\//$o/g if $o ne '/';
104 $n=&bname($targer);
105 $ret.="$target: $files $dep_libs\n";
106 $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n";
107 $ret.=" \$(APP_EX_OBJ) $files $libs\n<<\n";
108 if (defined $sha1file)
109 {
110 $ret.=" $openssl sha1 -hmac etaonrishdlcupfm -binary $target > $sha1file";
111 }
112 $ret.="\n";
113 return($ret);
114 }
115
1161;
diff --git a/src/lib/libcrypto/util/pl/netware.pl b/src/lib/libcrypto/util/pl/netware.pl
new file mode 100644
index 0000000000..c78bcfc874
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/netware.pl
@@ -0,0 +1,532 @@
1# Metrowerks Codewarrior or gcc / nlmconv for NetWare
2#
3
4$version_header = "crypto/opensslv.h";
5open(IN, "$version_header") or die "Couldn't open $version_header: $!";
6while (<IN>) {
7 if (/^#define[\s\t]+OPENSSL_VERSION_NUMBER[\s\t]+0x(\d)(\d{2})(\d{2})(\d{2})/)
8 {
9 # die "OpenSSL version detected: $1.$2.$3.$4\n";
10 #$nlmvernum = "$1,$2,$3";
11 $nlmvernum = "$1,".($2*10+$3).",".($4*1);
12 #$nlmverstr = "$1.".($2*1).".".($3*1).($4?(chr(96+$4)):"");
13 break;
14 }
15}
16close(IN) or die "Couldn't close $version_header: $!";
17
18$readme_file = "README";
19open(IN, $readme_file) or die "Couldn't open $readme_file: $!";
20while (<IN>) {
21 if (/^[\s\t]+OpenSSL[\s\t]+(\d)\.(\d{1,2})\.(\d{1,2})([a-z])(.*)/)
22 {
23 #$nlmvernum = "$1,$2,$3";
24 #$nlmvernum = "$1,".($2*10+$3).",".($4*1);
25 $nlmverstr = "$1.$2.$3$4$5";
26 }
27 elsif (/^[\s\t]+(Copyright \(c\) \d{4}\-\d{4} The OpenSSL Project)$/)
28 {
29 $nlmcpystr = $1;
30 }
31 break if ($nlmvernum && $nlmcpystr);
32}
33close(IN) or die "Couldn't close $readme_file: $!";
34
35# Define stacksize here
36$nlmstack = "32768";
37
38# some default settings here in case we failed to find them in README
39$nlmvernum = "1,0,0" if (!$nlmvernum);
40$nlmverstr = "OpenSSL" if (!$nlmverstr);
41$nlmcpystr = "Copyright (c) 1998-now The OpenSSL Project" if (!$nlmcpystr);
42
43# die "OpenSSL copyright: $nlmcpystr\nOpenSSL verstring: $nlmverstr\nOpenSSL vernumber: $nlmvernum\n";
44
45# The import files and other misc imports needed to link
46@misc_imports = ("GetProcessSwitchCount", "RunningProcess",
47 "GetSuperHighResolutionTimer");
48if ($LIBC)
49{
50 @import_files = ("libc.imp");
51 @module_files = ("libc");
52 $libarch = "LIBC";
53}
54else
55{
56 # clib build
57 @import_files = ("clib.imp");
58 push(@import_files, "socklib.imp") if ($BSDSOCK);
59 @module_files = ("clib");
60 # push(@misc_imports, "_rt_modu64%16", "_rt_divu64%16");
61 $libarch = "CLIB";
62}
63if ($BSDSOCK)
64{
65 $libarch .= "-BSD";
66}
67else
68{
69 $libarch .= "-WS2";
70 push(@import_files, "ws2nlm.imp");
71}
72
73# The "IMPORTS" environment variable must be set and point to the location
74# where import files (*.imp) can be found.
75# Example: set IMPORTS=c:\ndk\nwsdk\imports
76$import_path = $ENV{"IMPORTS"} || die ("IMPORTS environment variable not set\n");
77
78
79# The "PRELUDE" environment variable must be set and point to the location
80# and name of the prelude source to link with ( nwpre.obj is recommended ).
81# Example: set PRELUDE=c:\codewar\novell support\metrowerks support\libraries\runtime\nwpre.obj
82$prelude = $ENV{"PRELUDE"} || die ("PRELUDE environment variable not set\n");
83
84# The "INCLUDES" environment variable must be set and point to the location
85# where import files (*.imp) can be found.
86$include_path = $ENV{"INCLUDE"} || die ("INCLUDES environment variable not set\n");
87$include_path =~ s/\\/\//g;
88$include_path = join(" -I", split(/;/, $include_path));
89
90# check for gcc compiler
91$gnuc = $ENV{"GNUC"};
92
93#$ssl= "ssleay32";
94#$crypto="libeay32";
95
96if ($gnuc)
97{
98 # C compiler
99 $cc='gcc';
100 # Linker
101 $link='nlmconv';
102 # librarian
103 $mklib='ar';
104 $o='/';
105 # cp command
106 $cp='cp -af';
107 # rm command
108 $rm='rm -f';
109 # mv command
110 $mv='mv -f';
111 # mkdir command
112 $mkdir='gmkdir';
113 #$ranlib='ranlib';
114}
115else
116{
117 # C compiler
118 $cc='mwccnlm';
119 # Linker
120 $link='mwldnlm';
121 # librarian
122 $mklib='mwldnlm';
123 # Path separator
124 $o='\\';
125 # cp command
126 $cp='copy >nul:';
127 # rm command
128 $rm='del /f /q';
129}
130
131# assembler
132if ($nw_nasm)
133{
134 $asm=(`nasm -v 2>NUL` gt `nasmw -v 2>NUL`?"nasm":"nasmw");
135 if ($gnuc)
136 {
137 $asm.=" -s -f elf";
138 }
139 else
140 {
141 $asm.=" -s -f coff -d __coff__";
142 }
143 $afile="-o ";
144 $asm.=" -g" if $debug;
145}
146elsif ($nw_mwasm)
147{
148 $asm="mwasmnlm -maxerrors 20";
149 $afile="-o ";
150 $asm.=" -g" if $debug;
151}
152elsif ($nw_masm)
153{
154# masm assembly settings - it should be possible to use masm but haven't
155# got it working.
156# $asm='ml /Cp /coff /c /Cx';
157# $asm.=" /Zi" if $debug;
158# $afile='/Fo';
159 die("Support for masm assembler not yet functional\n");
160}
161else
162{
163 $asm="";
164 $afile="";
165}
166
167
168
169if ($gnuc)
170{
171 # compile flags for GNUC
172 # additional flags based upon debug | non-debug
173 if ($debug)
174 {
175 $cflags="-g -DDEBUG";
176 }
177 else
178 {
179 $cflags="-O2";
180 }
181 $cflags.=" -nostdinc -I$include_path \\
182 -fno-builtin -fpcc-struct-return -fno-strict-aliasing \\
183 -funsigned-char -Wall -Wno-unused -Wno-uninitialized";
184
185 # link flags
186 $lflags="-T";
187}
188else
189{
190 # compile flags for CodeWarrior
191 # additional flags based upon debug | non-debug
192 if ($debug)
193 {
194 $cflags="-opt off -g -sym internal -DDEBUG";
195 }
196 else
197 {
198 # CodeWarrior compiler has a problem with optimizations for floating
199 # points - no optimizations until further investigation
200 # $cflags="-opt all";
201 }
202
203 # NOTES: Several c files in the crypto subdirectory include headers from
204 # their local directories. Metrowerks wouldn't find these h files
205 # without adding individual include directives as compile flags
206 # or modifying the c files. Instead of adding individual include
207 # paths for each subdirectory a recursive include directive
208 # is used ( -ir crypto ).
209 #
210 # A similar issue exists for the engines and apps subdirectories.
211 #
212 # Turned off the "possible" warnings ( -w nopossible ). Metrowerks
213 # complained a lot about various stuff. May want to turn back
214 # on for further development.
215 $cflags.=" -nostdinc -ir crypto -ir engines -ir apps -I$include_path \\
216 -msgstyle gcc -align 4 -processor pentium -char unsigned \\
217 -w on -w nolargeargs -w nopossible -w nounusedarg -w nounusedexpr \\
218 -w noimplicitconv -relax_pointers -nosyspath -maxerrors 20";
219
220 # link flags
221 $lflags="-msgstyle gcc -zerobss -nostdlib -sym internal -commandfile";
222}
223
224# common defines
225$cflags.=" -DL_ENDIAN -DOPENSSL_SYSNAME_NETWARE -U_WIN32";
226
227# If LibC build add in NKS_LIBC define and set the entry/exit
228# routines - The default entry/exit routines are for CLib and don't exist
229# in LibC
230if ($LIBC)
231{
232 $cflags.=" -DNETWARE_LIBC";
233 $nlmstart = "_LibCPrelude";
234 $nlmexit = "_LibCPostlude";
235 @nlm_flags = ("pseudopreemption", "flag_on 64");
236}
237else
238{
239 $cflags.=" -DNETWARE_CLIB";
240 $nlmstart = "_Prelude";
241 $nlmexit = "_Stop";
242}
243
244# If BSD Socket support is requested, set a define for the compiler
245if ($BSDSOCK)
246{
247 $cflags.=" -DNETWARE_BSDSOCK";
248 if (!$LIBC)
249 {
250 $cflags.=" -DNETDB_USE_INTERNET";
251 }
252}
253
254
255# linking stuff
256# for the output directories use the mk1mf.pl values with "_nw" appended
257if ($shlib)
258{
259 if ($LIBC)
260 {
261 $out_def.="_nw_libc_nlm";
262 $tmp_def.="_nw_libc_nlm";
263 $inc_def.="_nw_libc_nlm";
264 }
265 else # NETWARE_CLIB
266 {
267 $out_def.="_nw_clib_nlm";
268 $tmp_def.="_nw_clib_nlm";
269 $inc_def.="_nw_clib_nlm";
270 }
271}
272else
273{
274 if ($gnuc) # GNUC Tools
275 {
276 $libp=".a";
277 $shlibp=".a";
278 $lib_flags="-cr";
279 }
280 else # CodeWarrior
281 {
282 $libp=".lib";
283 $shlibp=".lib";
284 $lib_flags="-nodefaults -type library -o";
285 }
286 if ($LIBC)
287 {
288 $out_def.="_nw_libc";
289 $tmp_def.="_nw_libc";
290 $inc_def.="_nw_libc";
291 }
292 else # NETWARE_CLIB
293 {
294 $out_def.="_nw_clib";
295 $tmp_def.="_nw_clib";
296 $inc_def.="_nw_clib";
297 }
298}
299
300# used by mk1mf.pl
301$obj='.o';
302$ofile='-o ';
303$efile='';
304$exep='.nlm';
305$ex_libs='';
306
307if (!$no_asm)
308{
309 $bn_asm_obj="\$(OBJ_D)${o}bn-nw${obj}";
310 $bn_asm_src="crypto${o}bn${o}asm${o}bn-nw.asm";
311 $bnco_asm_obj="\$(OBJ_D)${o}co-nw${obj}";
312 $bnco_asm_src="crypto${o}bn${o}asm${o}co-nw.asm";
313 $aes_asm_obj="\$(OBJ_D)${o}a-nw${obj}";
314 $aes_asm_src="crypto${o}aes${o}asm${o}a-nw.asm";
315 $des_enc_obj="\$(OBJ_D)${o}d-nw${obj} \$(OBJ_D)${o}y-nw${obj}";
316 $des_enc_src="crypto${o}des${o}asm${o}d-nw.asm crypto${o}des${o}asm${o}y-nw.asm";
317 $bf_enc_obj="\$(OBJ_D)${o}b-nw${obj}";
318 $bf_enc_src="crypto${o}bf${o}asm${o}b-nw.asm";
319 $cast_enc_obj="\$(OBJ_D)${o}c-nw${obj}";
320 $cast_enc_src="crypto${o}cast${o}asm${o}c-nw.asm";
321 $rc4_enc_obj="\$(OBJ_D)${o}r4-nw${obj}";
322 $rc4_enc_src="crypto${o}rc4${o}asm${o}r4-nw.asm";
323 $rc5_enc_obj="\$(OBJ_D)${o}r5-nw${obj}";
324 $rc5_enc_src="crypto${o}rc5${o}asm${o}r5-nw.asm";
325 $md5_asm_obj="\$(OBJ_D)${o}m5-nw${obj}";
326 $md5_asm_src="crypto${o}md5${o}asm${o}m5-nw.asm";
327 $sha1_asm_obj="\$(OBJ_D)${o}s1-nw${obj} \$(OBJ_D)${o}sha256-nw${obj} \$(OBJ_D)${o}sha512-nw${obj}";
328 $sha1_asm_src="crypto${o}sha${o}asm${o}s1-nw.asm crypto${o}sha${o}asm${o}sha256-nw.asm crypto${o}sha${o}asm${o}sha512-nw.asm";
329 $rmd160_asm_obj="\$(OBJ_D)${o}rm-nw${obj}";
330 $rmd160_asm_src="crypto${o}ripemd${o}asm${o}rm-nw.asm";
331 $whirlpool_asm_obj="\$(OBJ_D)${o}wp-nw${obj}";
332 $whirlpool_asm_src="crypto${o}whrlpool${o}asm${o}wp-nw.asm";
333 $cpuid_asm_obj="\$(OBJ_D)${o}x86cpuid-nw${obj}";
334 $cpuid_asm_src="crypto${o}x86cpuid-nw.asm";
335 $cflags.=" -DOPENSSL_CPUID_OBJ -DBN_ASM -DOPENSSL_BN_ASM_PART_WORDS -DMD5_ASM -DWHIRLPOOL_ASM";
336 $cflags.=" -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM";
337 $cflags.=" -DAES_ASM -DRMD160_ASM";
338}
339else
340{
341 $bn_asm_obj='';
342 $bn_asm_src='';
343 $bnco_asm_obj='';
344 $bnco_asm_src='';
345 $aes_asm_obj='';
346 $aes_asm_src='';
347 $des_enc_obj='';
348 $des_enc_src='';
349 $bf_enc_obj='';
350 $bf_enc_src='';
351 $cast_enc_obj='';
352 $cast_enc_src='';
353 $rc4_enc_obj='';
354 $rc4_enc_src='';
355 $rc5_enc_obj='';
356 $rc5_enc_src='';
357 $md5_asm_obj='';
358 $md5_asm_src='';
359 $sha1_asm_obj='';
360 $sha1_asm_src='';
361 $rmd160_asm_obj='';
362 $rmd160_asm_src='';
363 $whirlpool_asm_obj='';
364 $whirlpool_asm_src='';
365 $cpuid_asm_obj='';
366 $cpuid_asm_src='';
367}
368
369# create the *.def linker command files in \openssl\netware\ directory
370sub do_def_file
371{
372 # strip off the leading path
373 my($target) = bname(shift);
374 my($i);
375
376 if ($target =~ /(.*).nlm/)
377 {
378 $target = $1;
379 }
380
381 # special case for openssl - the mk1mf.pl defines E_EXE = openssl
382 if ($target =~ /E_EXE/)
383 {
384 $target =~ s/\$\(E_EXE\)/openssl/;
385 }
386
387 # Note: originally tried to use full path ( \openssl\netware\$target.def )
388 # Metrowerks linker choked on this with an assertion failure. bug???
389 #
390 my($def_file) = "netware${o}$target.def";
391
392 open(DEF_OUT, ">$def_file") || die("unable to open file $def_file\n");
393
394 print( DEF_OUT "# command file generated by netware.pl for NLM target.\n" );
395 print( DEF_OUT "# do not edit this file - all your changes will be lost!!\n" );
396 print( DEF_OUT "#\n");
397 print( DEF_OUT "DESCRIPTION \"$target ($libarch) - OpenSSL $nlmverstr\"\n");
398 print( DEF_OUT "COPYRIGHT \"$nlmcpystr\"\n");
399 print( DEF_OUT "VERSION $nlmvernum\n");
400 print( DEF_OUT "STACK $nlmstack\n");
401 print( DEF_OUT "START $nlmstart\n");
402 print( DEF_OUT "EXIT $nlmexit\n");
403
404 # special case for openssl
405 if ($target eq "openssl")
406 {
407 print( DEF_OUT "SCREENNAME \"OpenSSL $nlmverstr\"\n");
408 }
409 else
410 {
411 print( DEF_OUT "SCREENNAME \"DEFAULT\"\n");
412 }
413
414 foreach $i (@misc_imports)
415 {
416 print( DEF_OUT "IMPORT $i\n");
417 }
418
419 foreach $i (@import_files)
420 {
421 print( DEF_OUT "IMPORT \@$import_path${o}$i\n");
422 }
423
424 foreach $i (@module_files)
425 {
426 print( DEF_OUT "MODULE $i\n");
427 }
428
429 foreach $i (@nlm_flags)
430 {
431 print( DEF_OUT "$i\n");
432 }
433
434 if ($gnuc)
435 {
436 if ($target =~ /openssl/)
437 {
438 print( DEF_OUT "INPUT ${tmp_def}${o}openssl${obj}\n");
439 print( DEF_OUT "INPUT ${tmp_def}${o}openssl${libp}\n");
440 }
441 else
442 {
443 print( DEF_OUT "INPUT ${tmp_def}${o}${target}${obj}\n");
444 }
445 print( DEF_OUT "INPUT $prelude\n");
446 print( DEF_OUT "INPUT ${out_def}${o}${ssl}${libp} ${out_def}${o}${crypto}${libp}\n");
447 print( DEF_OUT "OUTPUT $target.nlm\n");
448 }
449
450 close(DEF_OUT);
451 return($def_file);
452}
453
454sub do_lib_rule
455{
456 my($objs,$target,$name,$shlib)=@_;
457 my($ret);
458
459 $ret.="$target: $objs\n";
460 if (!$shlib)
461 {
462 $ret.="\t\@echo Building Lib: $name\n";
463 $ret.="\t\$(MKLIB) $lib_flags $target $objs\n";
464 $ret.="\t\@echo .\n"
465 }
466 else
467 {
468 die( "Building as NLM not currently supported!" );
469 }
470
471 $ret.="\n";
472 return($ret);
473}
474
475sub do_link_rule
476{
477 my($target,$files,$dep_libs,$libs)=@_;
478 my($ret);
479 my($def_file) = do_def_file($target);
480
481 $ret.="$target: $files $dep_libs\n";
482
483 # NOTE: When building the test nlms no screen name is given
484 # which causes the console screen to be used. By using the console
485 # screen there is no "<press any key to continue>" message which
486 # requires user interaction. The test script ( do_tests.pl ) needs
487 # to be able to run the tests without requiring user interaction.
488 #
489 # However, the sample program "openssl.nlm" is used by the tests and is
490 # a interactive sample so a screen is desired when not be run by the
491 # tests. To solve the problem, two versions of the program are built:
492 # openssl2 - no screen used by tests
493 # openssl - default screen - use for normal interactive modes
494 #
495
496 # special case for openssl - the mk1mf.pl defines E_EXE = openssl
497 if ($target =~ /E_EXE/)
498 {
499 my($target2) = $target;
500
501 $target2 =~ s/\(E_EXE\)/\(E_EXE\)2/;
502
503 # openssl2
504 my($def_file2) = do_def_file($target2);
505
506 if ($gnuc)
507 {
508 $ret.="\t\$(MKLIB) $lib_flags \$(TMP_D)${o}\$(E_EXE).a \$(filter-out \$(TMP_D)${o}\$(E_EXE)${obj},$files)\n";
509 $ret.="\t\$(LINK) \$(LFLAGS) $def_file2\n";
510 $ret.="\t\@$mv \$(E_EXE)2.nlm \$(TEST_D)\n";
511 }
512 else
513 {
514 $ret.="\t\$(LINK) \$(LFLAGS) $def_file2 $files \"$prelude\" $libs -o $target2\n";
515 }
516 }
517 if ($gnuc)
518 {
519 $ret.="\t\$(LINK) \$(LFLAGS) $def_file\n";
520 $ret.="\t\@$mv \$(\@F) \$(TEST_D)\n";
521 }
522 else
523 {
524 $ret.="\t\$(LINK) \$(LFLAGS) $def_file $files \"$prelude\" $libs -o $target\n";
525 }
526
527 $ret.="\n";
528 return($ret);
529
530}
531
5321;
diff --git a/src/lib/libcrypto/vms_rms.h b/src/lib/libcrypto/vms_rms.h
new file mode 100755
index 0000000000..00a00d993f
--- /dev/null
+++ b/src/lib/libcrypto/vms_rms.h
@@ -0,0 +1,51 @@
1
2#ifdef NAML$C_MAXRSS
3
4# define CC_RMS_NAMX cc$rms_naml
5# define FAB_NAMX fab$l_naml
6# define FAB_OR_NAML( fab, naml) naml
7# define FAB_OR_NAML_DNA naml$l_long_defname
8# define FAB_OR_NAML_DNS naml$l_long_defname_size
9# define FAB_OR_NAML_FNA naml$l_long_filename
10# define FAB_OR_NAML_FNS naml$l_long_filename_size
11# define NAMX_ESA naml$l_long_expand
12# define NAMX_ESL naml$l_long_expand_size
13# define NAMX_ESS naml$l_long_expand_alloc
14# define NAMX_NOP naml$b_nop
15# define SET_NAMX_NO_SHORT_UPCASE( nam) nam.naml$v_no_short_upcase = 1
16
17# if __INITIAL_POINTER_SIZE == 64
18# define NAMX_DNA_FNA_SET(fab) fab.fab$l_dna = (__char_ptr32) -1; \
19 fab.fab$l_fna = (__char_ptr32) -1;
20# else /* __INITIAL_POINTER_SIZE == 64 */
21# define NAMX_DNA_FNA_SET(fab) fab.fab$l_dna = (char *) -1; \
22 fab.fab$l_fna = (char *) -1;
23# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
24
25# define NAMX_MAXRSS NAML$C_MAXRSS
26# define NAMX_STRUCT NAML
27
28#else /* def NAML$C_MAXRSS */
29
30# define CC_RMS_NAMX cc$rms_nam
31# define FAB_NAMX fab$l_nam
32# define FAB_OR_NAML( fab, naml) fab
33# define FAB_OR_NAML_DNA fab$l_dna
34# define FAB_OR_NAML_DNS fab$b_dns
35# define FAB_OR_NAML_FNA fab$l_fna
36# define FAB_OR_NAML_FNS fab$b_fns
37# define NAMX_ESA nam$l_esa
38# define NAMX_ESL nam$b_esl
39# define NAMX_ESS nam$b_ess
40# define NAMX_NOP nam$b_nop
41# define NAMX_DNA_FNA_SET(fab)
42# define NAMX_MAXRSS NAM$C_MAXRSS
43# define NAMX_STRUCT NAM
44# ifdef NAM$M_NO_SHORT_UPCASE
45# define SET_NAMX_NO_SHORT_UPCASE( nam) naml.naml$v_no_short_upcase = 1
46# else /* def NAM$M_NO_SHORT_UPCASE */
47# define SET_NAMX_NO_SHORT_UPCASE( nam)
48# endif /* def NAM$M_NO_SHORT_UPCASE [else] */
49
50#endif /* def NAML$C_MAXRSS [else] */
51
diff --git a/src/lib/libcrypto/whrlpool/Makefile b/src/lib/libcrypto/whrlpool/Makefile
new file mode 100644
index 0000000000..f4d46e4d17
--- /dev/null
+++ b/src/lib/libcrypto/whrlpool/Makefile
@@ -0,0 +1,96 @@
1#
2# crypto/whrlpool/Makefile
3#
4
5DIR= whrlpool
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=
10CFLAG=-g
11MAKEFILE= Makefile
12AR= ar r
13
14WP_ASM_OBJ=wp_block.o
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17ASFLAGS= $(INCLUDES) $(ASFLAG)
18AFLAGS= $(ASFLAGS)
19
20GENERAL=Makefile
21TEST=wp_test.c
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC=wp_dgst.c wp_block.c
26LIBOBJ=wp_dgst.o $(WP_ASM_OBJ)
27
28SRC= $(LIBSRC)
29
30EXHEADER= whrlpool.h
31HEADER= wp_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 $(RANLIB) $(LIB) || echo Never mind.
43 @touch lib
44
45wp-mmx.s: asm/wp-mmx.pl ../perlasm/x86asm.pl
46 $(PERL) asm/wp-mmx.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@
47
48wp-x86_64.s: asm/wp-x86_64.pl
49 $(PERL) asm/wp-x86_64.pl $(PERLASM_SCHEME) > $@
50
51$(LIBOBJ): $(LIBSRC)
52
53files:
54 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
55
56links:
57 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
58 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
59 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
60
61install:
62 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
63 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
64 do \
65 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
66 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
67 done;
68
69tags:
70 ctags $(SRC)
71
72tests:
73
74lint:
75 lint -DLINT $(INCLUDES) $(SRC)>fluff
76
77depend:
78 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
79 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(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 rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
87
88# DO NOT DELETE THIS LINE -- make depend depends on it.
89
90wp_block.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
91wp_block.o: ../../include/openssl/whrlpool.h wp_block.c wp_locl.h
92wp_dgst.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
93wp_dgst.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
94wp_dgst.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
95wp_dgst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
96wp_dgst.o: ../../include/openssl/whrlpool.h wp_dgst.c wp_locl.h
diff --git a/src/lib/libcrypto/whrlpool/wp_test.c b/src/lib/libcrypto/whrlpool/wp_test.c
new file mode 100644
index 0000000000..c68c2c62ca
--- /dev/null
+++ b/src/lib/libcrypto/whrlpool/wp_test.c
@@ -0,0 +1,228 @@
1/* ====================================================================
2 * Copyright (c) 2005 The OpenSSL Project. All rights reserved.
3 * ====================================================================
4 */
5#include <stdio.h>
6#include <string.h>
7#include <stdlib.h>
8
9#include <openssl/whrlpool.h>
10#include <openssl/crypto.h>
11
12#if defined(OPENSSL_NO_WHIRLPOOL)
13int main(int argc, char *argv[])
14{
15 printf("No Whirlpool support\n");
16 return(0);
17}
18#else
19
20/* ISO/IEC 10118-3 test vector set */
21unsigned char iso_test_1[WHIRLPOOL_DIGEST_LENGTH] = {
22 0x19,0xFA,0x61,0xD7,0x55,0x22,0xA4,0x66,
23 0x9B,0x44,0xE3,0x9C,0x1D,0x2E,0x17,0x26,
24 0xC5,0x30,0x23,0x21,0x30,0xD4,0x07,0xF8,
25 0x9A,0xFE,0xE0,0x96,0x49,0x97,0xF7,0xA7,
26 0x3E,0x83,0xBE,0x69,0x8B,0x28,0x8F,0xEB,
27 0xCF,0x88,0xE3,0xE0,0x3C,0x4F,0x07,0x57,
28 0xEA,0x89,0x64,0xE5,0x9B,0x63,0xD9,0x37,
29 0x08,0xB1,0x38,0xCC,0x42,0xA6,0x6E,0xB3 };
30
31unsigned char iso_test_2[WHIRLPOOL_DIGEST_LENGTH] = {
32 0x8A,0xCA,0x26,0x02,0x79,0x2A,0xEC,0x6F,
33 0x11,0xA6,0x72,0x06,0x53,0x1F,0xB7,0xD7,
34 0xF0,0xDF,0xF5,0x94,0x13,0x14,0x5E,0x69,
35 0x73,0xC4,0x50,0x01,0xD0,0x08,0x7B,0x42,
36 0xD1,0x1B,0xC6,0x45,0x41,0x3A,0xEF,0xF6,
37 0x3A,0x42,0x39,0x1A,0x39,0x14,0x5A,0x59,
38 0x1A,0x92,0x20,0x0D,0x56,0x01,0x95,0xE5,
39 0x3B,0x47,0x85,0x84,0xFD,0xAE,0x23,0x1A };
40
41unsigned char iso_test_3[WHIRLPOOL_DIGEST_LENGTH] = {
42 0x4E,0x24,0x48,0xA4,0xC6,0xF4,0x86,0xBB,
43 0x16,0xB6,0x56,0x2C,0x73,0xB4,0x02,0x0B,
44 0xF3,0x04,0x3E,0x3A,0x73,0x1B,0xCE,0x72,
45 0x1A,0xE1,0xB3,0x03,0xD9,0x7E,0x6D,0x4C,
46 0x71,0x81,0xEE,0xBD,0xB6,0xC5,0x7E,0x27,
47 0x7D,0x0E,0x34,0x95,0x71,0x14,0xCB,0xD6,
48 0xC7,0x97,0xFC,0x9D,0x95,0xD8,0xB5,0x82,
49 0xD2,0x25,0x29,0x20,0x76,0xD4,0xEE,0xF5 };
50
51unsigned char iso_test_4[WHIRLPOOL_DIGEST_LENGTH] = {
52 0x37,0x8C,0x84,0xA4,0x12,0x6E,0x2D,0xC6,
53 0xE5,0x6D,0xCC,0x74,0x58,0x37,0x7A,0xAC,
54 0x83,0x8D,0x00,0x03,0x22,0x30,0xF5,0x3C,
55 0xE1,0xF5,0x70,0x0C,0x0F,0xFB,0x4D,0x3B,
56 0x84,0x21,0x55,0x76,0x59,0xEF,0x55,0xC1,
57 0x06,0xB4,0xB5,0x2A,0xC5,0xA4,0xAA,0xA6,
58 0x92,0xED,0x92,0x00,0x52,0x83,0x8F,0x33,
59 0x62,0xE8,0x6D,0xBD,0x37,0xA8,0x90,0x3E };
60
61unsigned char iso_test_5[WHIRLPOOL_DIGEST_LENGTH] = {
62 0xF1,0xD7,0x54,0x66,0x26,0x36,0xFF,0xE9,
63 0x2C,0x82,0xEB,0xB9,0x21,0x2A,0x48,0x4A,
64 0x8D,0x38,0x63,0x1E,0xAD,0x42,0x38,0xF5,
65 0x44,0x2E,0xE1,0x3B,0x80,0x54,0xE4,0x1B,
66 0x08,0xBF,0x2A,0x92,0x51,0xC3,0x0B,0x6A,
67 0x0B,0x8A,0xAE,0x86,0x17,0x7A,0xB4,0xA6,
68 0xF6,0x8F,0x67,0x3E,0x72,0x07,0x86,0x5D,
69 0x5D,0x98,0x19,0xA3,0xDB,0xA4,0xEB,0x3B };
70
71unsigned char iso_test_6[WHIRLPOOL_DIGEST_LENGTH] = {
72 0xDC,0x37,0xE0,0x08,0xCF,0x9E,0xE6,0x9B,
73 0xF1,0x1F,0x00,0xED,0x9A,0xBA,0x26,0x90,
74 0x1D,0xD7,0xC2,0x8C,0xDE,0xC0,0x66,0xCC,
75 0x6A,0xF4,0x2E,0x40,0xF8,0x2F,0x3A,0x1E,
76 0x08,0xEB,0xA2,0x66,0x29,0x12,0x9D,0x8F,
77 0xB7,0xCB,0x57,0x21,0x1B,0x92,0x81,0xA6,
78 0x55,0x17,0xCC,0x87,0x9D,0x7B,0x96,0x21,
79 0x42,0xC6,0x5F,0x5A,0x7A,0xF0,0x14,0x67 };
80
81unsigned char iso_test_7[WHIRLPOOL_DIGEST_LENGTH] = {
82 0x46,0x6E,0xF1,0x8B,0xAB,0xB0,0x15,0x4D,
83 0x25,0xB9,0xD3,0x8A,0x64,0x14,0xF5,0xC0,
84 0x87,0x84,0x37,0x2B,0xCC,0xB2,0x04,0xD6,
85 0x54,0x9C,0x4A,0xFA,0xDB,0x60,0x14,0x29,
86 0x4D,0x5B,0xD8,0xDF,0x2A,0x6C,0x44,0xE5,
87 0x38,0xCD,0x04,0x7B,0x26,0x81,0xA5,0x1A,
88 0x2C,0x60,0x48,0x1E,0x88,0xC5,0xA2,0x0B,
89 0x2C,0x2A,0x80,0xCF,0x3A,0x9A,0x08,0x3B };
90
91unsigned char iso_test_8[WHIRLPOOL_DIGEST_LENGTH] = {
92 0x2A,0x98,0x7E,0xA4,0x0F,0x91,0x70,0x61,
93 0xF5,0xD6,0xF0,0xA0,0xE4,0x64,0x4F,0x48,
94 0x8A,0x7A,0x5A,0x52,0xDE,0xEE,0x65,0x62,
95 0x07,0xC5,0x62,0xF9,0x88,0xE9,0x5C,0x69,
96 0x16,0xBD,0xC8,0x03,0x1B,0xC5,0xBE,0x1B,
97 0x7B,0x94,0x76,0x39,0xFE,0x05,0x0B,0x56,
98 0x93,0x9B,0xAA,0xA0,0xAD,0xFF,0x9A,0xE6,
99 0x74,0x5B,0x7B,0x18,0x1C,0x3B,0xE3,0xFD };
100
101unsigned char iso_test_9[WHIRLPOOL_DIGEST_LENGTH] = {
102 0x0C,0x99,0x00,0x5B,0xEB,0x57,0xEF,0xF5,
103 0x0A,0x7C,0xF0,0x05,0x56,0x0D,0xDF,0x5D,
104 0x29,0x05,0x7F,0xD8,0x6B,0x20,0xBF,0xD6,
105 0x2D,0xEC,0xA0,0xF1,0xCC,0xEA,0x4A,0xF5,
106 0x1F,0xC1,0x54,0x90,0xED,0xDC,0x47,0xAF,
107 0x32,0xBB,0x2B,0x66,0xC3,0x4F,0xF9,0xAD,
108 0x8C,0x60,0x08,0xAD,0x67,0x7F,0x77,0x12,
109 0x69,0x53,0xB2,0x26,0xE4,0xED,0x8B,0x01 };
110
111int main (int argc,char *argv[])
112{ unsigned char md[WHIRLPOOL_DIGEST_LENGTH];
113 int i;
114 WHIRLPOOL_CTX ctx;
115
116#ifdef OPENSSL_IA32_SSE2
117 /* Alternative to this is to call OpenSSL_add_all_algorithms...
118 * The below code is retained exclusively for debugging purposes. */
119 { char *env;
120
121 if ((env=getenv("OPENSSL_ia32cap")))
122 OPENSSL_ia32cap = strtoul (env,NULL,0);
123 }
124#endif
125
126 fprintf(stdout,"Testing Whirlpool ");
127
128 WHIRLPOOL("",0,md);
129 if (memcmp(md,iso_test_1,sizeof(iso_test_1)))
130 { fflush(stdout);
131 fprintf(stderr,"\nTEST 1 of 9 failed.\n");
132 return 1;
133 }
134 else
135 fprintf(stdout,"."); fflush(stdout);
136
137 WHIRLPOOL("a",1,md);
138 if (memcmp(md,iso_test_2,sizeof(iso_test_2)))
139 { fflush(stdout);
140 fprintf(stderr,"\nTEST 2 of 9 failed.\n");
141 return 1;
142 }
143 else
144 fprintf(stdout,"."); fflush(stdout);
145
146 WHIRLPOOL("abc",3,md);
147 if (memcmp(md,iso_test_3,sizeof(iso_test_3)))
148 { fflush(stdout);
149 fprintf(stderr,"\nTEST 3 of 9 failed.\n");
150 return 1;
151 }
152 else
153 fprintf(stdout,"."); fflush(stdout);
154
155 WHIRLPOOL("message digest",14,md);
156 if (memcmp(md,iso_test_4,sizeof(iso_test_4)))
157 { fflush(stdout);
158 fprintf(stderr,"\nTEST 4 of 9 failed.\n");
159 return 1;
160 }
161 else
162 fprintf(stdout,"."); fflush(stdout);
163
164 WHIRLPOOL("abcdefghijklmnopqrstuvwxyz",26,md);
165 if (memcmp(md,iso_test_5,sizeof(iso_test_5)))
166 { fflush(stdout);
167 fprintf(stderr,"\nTEST 5 of 9 failed.\n");
168 return 1;
169 }
170 else
171 fprintf(stdout,"."); fflush(stdout);
172
173 WHIRLPOOL( "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
174 "abcdefghijklmnopqrstuvwxyz"
175 "0123456789",62,md);
176 if (memcmp(md,iso_test_6,sizeof(iso_test_6)))
177 { fflush(stdout);
178 fprintf(stderr,"\nTEST 6 of 9 failed.\n");
179 return 1;
180 }
181 else
182 fprintf(stdout,"."); fflush(stdout);
183
184 WHIRLPOOL( "1234567890""1234567890""1234567890""1234567890"
185 "1234567890""1234567890""1234567890""1234567890",80,md);
186 if (memcmp(md,iso_test_7,sizeof(iso_test_7)))
187 { fflush(stdout);
188 fprintf(stderr,"\nTEST 7 of 9 failed.\n");
189 return 1;
190 }
191 else
192 fprintf(stdout,"."); fflush(stdout);
193
194 WHIRLPOOL("abcdbcdecdefdefgefghfghighijhijk",32,md);
195 if (memcmp(md,iso_test_8,sizeof(iso_test_8)))
196 { fflush(stdout);
197 fprintf(stderr,"\nTEST 8 of 9 failed.\n");
198 return 1;
199 }
200 else
201 fprintf(stdout,"."); fflush(stdout);
202
203 WHIRLPOOL_Init (&ctx);
204 for (i=0;i<1000000;i+=288)
205 WHIRLPOOL_Update (&ctx, "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
206 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
207 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
208 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
209 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
210 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
211 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
212 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa"
213 "aaaaaaaa""aaaaaaaa""aaaaaaaa""aaaaaaaa",
214 (1000000-i)<288?1000000-i:288);
215 WHIRLPOOL_Final (md,&ctx);
216 if (memcmp(md,iso_test_9,sizeof(iso_test_9)))
217 { fflush(stdout);
218 fprintf(stderr,"\nTEST 9 of 9 failed.\n");
219 return 1;
220 }
221 else
222 fprintf(stdout,"."); fflush(stdout);
223
224 fprintf(stdout," passed.\n"); fflush(stdout);
225
226 return 0;
227}
228#endif
diff --git a/src/lib/libcrypto/x509v3/v3_addr.c b/src/lib/libcrypto/x509v3/v3_addr.c
new file mode 100644
index 0000000000..df46a4983b
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/v3_addr.c
@@ -0,0 +1,1338 @@
1/*
2 * Contributed to the OpenSSL Project by the American Registry for
3 * Internet Numbers ("ARIN").
4 */
5/* ====================================================================
6 * Copyright (c) 2006 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 */
57
58/*
59 * Implementation of RFC 3779 section 2.2.
60 */
61
62#include <stdio.h>
63#include <stdlib.h>
64
65#include "cryptlib.h"
66#include <openssl/conf.h>
67#include <openssl/asn1.h>
68#include <openssl/asn1t.h>
69#include <openssl/buffer.h>
70#include <openssl/x509v3.h>
71
72#ifndef OPENSSL_NO_RFC3779
73
74/*
75 * OpenSSL ASN.1 template translation of RFC 3779 2.2.3.
76 */
77
78ASN1_SEQUENCE(IPAddressRange) = {
79 ASN1_SIMPLE(IPAddressRange, min, ASN1_BIT_STRING),
80 ASN1_SIMPLE(IPAddressRange, max, ASN1_BIT_STRING)
81} ASN1_SEQUENCE_END(IPAddressRange)
82
83ASN1_CHOICE(IPAddressOrRange) = {
84 ASN1_SIMPLE(IPAddressOrRange, u.addressPrefix, ASN1_BIT_STRING),
85 ASN1_SIMPLE(IPAddressOrRange, u.addressRange, IPAddressRange)
86} ASN1_CHOICE_END(IPAddressOrRange)
87
88ASN1_CHOICE(IPAddressChoice) = {
89 ASN1_SIMPLE(IPAddressChoice, u.inherit, ASN1_NULL),
90 ASN1_SEQUENCE_OF(IPAddressChoice, u.addressesOrRanges, IPAddressOrRange)
91} ASN1_CHOICE_END(IPAddressChoice)
92
93ASN1_SEQUENCE(IPAddressFamily) = {
94 ASN1_SIMPLE(IPAddressFamily, addressFamily, ASN1_OCTET_STRING),
95 ASN1_SIMPLE(IPAddressFamily, ipAddressChoice, IPAddressChoice)
96} ASN1_SEQUENCE_END(IPAddressFamily)
97
98ASN1_ITEM_TEMPLATE(IPAddrBlocks) =
99 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0,
100 IPAddrBlocks, IPAddressFamily)
101ASN1_ITEM_TEMPLATE_END(IPAddrBlocks)
102
103IMPLEMENT_ASN1_FUNCTIONS(IPAddressRange)
104IMPLEMENT_ASN1_FUNCTIONS(IPAddressOrRange)
105IMPLEMENT_ASN1_FUNCTIONS(IPAddressChoice)
106IMPLEMENT_ASN1_FUNCTIONS(IPAddressFamily)
107
108/*
109 * How much buffer space do we need for a raw address?
110 */
111#define ADDR_RAW_BUF_LEN 16
112
113/*
114 * What's the address length associated with this AFI?
115 */
116static int length_from_afi(const unsigned afi)
117{
118 switch (afi) {
119 case IANA_AFI_IPV4:
120 return 4;
121 case IANA_AFI_IPV6:
122 return 16;
123 default:
124 return 0;
125 }
126}
127
128/*
129 * Extract the AFI from an IPAddressFamily.
130 */
131unsigned int v3_addr_get_afi(const IPAddressFamily *f)
132{
133 return ((f != NULL &&
134 f->addressFamily != NULL &&
135 f->addressFamily->data != NULL)
136 ? ((f->addressFamily->data[0] << 8) |
137 (f->addressFamily->data[1]))
138 : 0);
139}
140
141/*
142 * Expand the bitstring form of an address into a raw byte array.
143 * At the moment this is coded for simplicity, not speed.
144 */
145static int addr_expand(unsigned char *addr,
146 const ASN1_BIT_STRING *bs,
147 const int length,
148 const unsigned char fill)
149{
150 if (bs->length < 0 || bs->length > length)
151 return 0;
152 if (bs->length > 0) {
153 memcpy(addr, bs->data, bs->length);
154 if ((bs->flags & 7) != 0) {
155 unsigned char mask = 0xFF >> (8 - (bs->flags & 7));
156 if (fill == 0)
157 addr[bs->length - 1] &= ~mask;
158 else
159 addr[bs->length - 1] |= mask;
160 }
161 }
162 memset(addr + bs->length, fill, length - bs->length);
163 return 1;
164}
165
166/*
167 * Extract the prefix length from a bitstring.
168 */
169#define addr_prefixlen(bs) ((int) ((bs)->length * 8 - ((bs)->flags & 7)))
170
171/*
172 * i2r handler for one address bitstring.
173 */
174static int i2r_address(BIO *out,
175 const unsigned afi,
176 const unsigned char fill,
177 const ASN1_BIT_STRING *bs)
178{
179 unsigned char addr[ADDR_RAW_BUF_LEN];
180 int i, n;
181
182 if (bs->length < 0)
183 return 0;
184 switch (afi) {
185 case IANA_AFI_IPV4:
186 if (!addr_expand(addr, bs, 4, fill))
187 return 0;
188 BIO_printf(out, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
189 break;
190 case IANA_AFI_IPV6:
191 if (!addr_expand(addr, bs, 16, fill))
192 return 0;
193 for (n = 16; n > 1 && addr[n-1] == 0x00 && addr[n-2] == 0x00; n -= 2)
194 ;
195 for (i = 0; i < n; i += 2)
196 BIO_printf(out, "%x%s", (addr[i] << 8) | addr[i+1], (i < 14 ? ":" : ""));
197 if (i < 16)
198 BIO_puts(out, ":");
199 if (i == 0)
200 BIO_puts(out, ":");
201 break;
202 default:
203 for (i = 0; i < bs->length; i++)
204 BIO_printf(out, "%s%02x", (i > 0 ? ":" : ""), bs->data[i]);
205 BIO_printf(out, "[%d]", (int) (bs->flags & 7));
206 break;
207 }
208 return 1;
209}
210
211/*
212 * i2r handler for a sequence of addresses and ranges.
213 */
214static int i2r_IPAddressOrRanges(BIO *out,
215 const int indent,
216 const IPAddressOrRanges *aors,
217 const unsigned afi)
218{
219 int i;
220 for (i = 0; i < sk_IPAddressOrRange_num(aors); i++) {
221 const IPAddressOrRange *aor = sk_IPAddressOrRange_value(aors, i);
222 BIO_printf(out, "%*s", indent, "");
223 switch (aor->type) {
224 case IPAddressOrRange_addressPrefix:
225 if (!i2r_address(out, afi, 0x00, aor->u.addressPrefix))
226 return 0;
227 BIO_printf(out, "/%d\n", addr_prefixlen(aor->u.addressPrefix));
228 continue;
229 case IPAddressOrRange_addressRange:
230 if (!i2r_address(out, afi, 0x00, aor->u.addressRange->min))
231 return 0;
232 BIO_puts(out, "-");
233 if (!i2r_address(out, afi, 0xFF, aor->u.addressRange->max))
234 return 0;
235 BIO_puts(out, "\n");
236 continue;
237 }
238 }
239 return 1;
240}
241
242/*
243 * i2r handler for an IPAddrBlocks extension.
244 */
245static int i2r_IPAddrBlocks(const X509V3_EXT_METHOD *method,
246 void *ext,
247 BIO *out,
248 int indent)
249{
250 const IPAddrBlocks *addr = ext;
251 int i;
252 for (i = 0; i < sk_IPAddressFamily_num(addr); i++) {
253 IPAddressFamily *f = sk_IPAddressFamily_value(addr, i);
254 const unsigned int afi = v3_addr_get_afi(f);
255 switch (afi) {
256 case IANA_AFI_IPV4:
257 BIO_printf(out, "%*sIPv4", indent, "");
258 break;
259 case IANA_AFI_IPV6:
260 BIO_printf(out, "%*sIPv6", indent, "");
261 break;
262 default:
263 BIO_printf(out, "%*sUnknown AFI %u", indent, "", afi);
264 break;
265 }
266 if (f->addressFamily->length > 2) {
267 switch (f->addressFamily->data[2]) {
268 case 1:
269 BIO_puts(out, " (Unicast)");
270 break;
271 case 2:
272 BIO_puts(out, " (Multicast)");
273 break;
274 case 3:
275 BIO_puts(out, " (Unicast/Multicast)");
276 break;
277 case 4:
278 BIO_puts(out, " (MPLS)");
279 break;
280 case 64:
281 BIO_puts(out, " (Tunnel)");
282 break;
283 case 65:
284 BIO_puts(out, " (VPLS)");
285 break;
286 case 66:
287 BIO_puts(out, " (BGP MDT)");
288 break;
289 case 128:
290 BIO_puts(out, " (MPLS-labeled VPN)");
291 break;
292 default:
293 BIO_printf(out, " (Unknown SAFI %u)",
294 (unsigned) f->addressFamily->data[2]);
295 break;
296 }
297 }
298 switch (f->ipAddressChoice->type) {
299 case IPAddressChoice_inherit:
300 BIO_puts(out, ": inherit\n");
301 break;
302 case IPAddressChoice_addressesOrRanges:
303 BIO_puts(out, ":\n");
304 if (!i2r_IPAddressOrRanges(out,
305 indent + 2,
306 f->ipAddressChoice->u.addressesOrRanges,
307 afi))
308 return 0;
309 break;
310 }
311 }
312 return 1;
313}
314
315/*
316 * Sort comparison function for a sequence of IPAddressOrRange
317 * elements.
318 *
319 * There's no sane answer we can give if addr_expand() fails, and an
320 * assertion failure on externally supplied data is seriously uncool,
321 * so we just arbitrarily declare that if given invalid inputs this
322 * function returns -1. If this messes up your preferred sort order
323 * for garbage input, tough noogies.
324 */
325static int IPAddressOrRange_cmp(const IPAddressOrRange *a,
326 const IPAddressOrRange *b,
327 const int length)
328{
329 unsigned char addr_a[ADDR_RAW_BUF_LEN], addr_b[ADDR_RAW_BUF_LEN];
330 int prefixlen_a = 0, prefixlen_b = 0;
331 int r;
332
333 switch (a->type) {
334 case IPAddressOrRange_addressPrefix:
335 if (!addr_expand(addr_a, a->u.addressPrefix, length, 0x00))
336 return -1;
337 prefixlen_a = addr_prefixlen(a->u.addressPrefix);
338 break;
339 case IPAddressOrRange_addressRange:
340 if (!addr_expand(addr_a, a->u.addressRange->min, length, 0x00))
341 return -1;
342 prefixlen_a = length * 8;
343 break;
344 }
345
346 switch (b->type) {
347 case IPAddressOrRange_addressPrefix:
348 if (!addr_expand(addr_b, b->u.addressPrefix, length, 0x00))
349 return -1;
350 prefixlen_b = addr_prefixlen(b->u.addressPrefix);
351 break;
352 case IPAddressOrRange_addressRange:
353 if (!addr_expand(addr_b, b->u.addressRange->min, length, 0x00))
354 return -1;
355 prefixlen_b = length * 8;
356 break;
357 }
358
359 if ((r = memcmp(addr_a, addr_b, length)) != 0)
360 return r;
361 else
362 return prefixlen_a - prefixlen_b;
363}
364
365/*
366 * IPv4-specific closure over IPAddressOrRange_cmp, since sk_sort()
367 * comparision routines are only allowed two arguments.
368 */
369static int v4IPAddressOrRange_cmp(const IPAddressOrRange * const *a,
370 const IPAddressOrRange * const *b)
371{
372 return IPAddressOrRange_cmp(*a, *b, 4);
373}
374
375/*
376 * IPv6-specific closure over IPAddressOrRange_cmp, since sk_sort()
377 * comparision routines are only allowed two arguments.
378 */
379static int v6IPAddressOrRange_cmp(const IPAddressOrRange * const *a,
380 const IPAddressOrRange * const *b)
381{
382 return IPAddressOrRange_cmp(*a, *b, 16);
383}
384
385/*
386 * Calculate whether a range collapses to a prefix.
387 * See last paragraph of RFC 3779 2.2.3.7.
388 */
389static int range_should_be_prefix(const unsigned char *min,
390 const unsigned char *max,
391 const int length)
392{
393 unsigned char mask;
394 int i, j;
395
396 OPENSSL_assert(memcmp(min, max, length) <= 0);
397 for (i = 0; i < length && min[i] == max[i]; i++)
398 ;
399 for (j = length - 1; j >= 0 && min[j] == 0x00 && max[j] == 0xFF; j--)
400 ;
401 if (i < j)
402 return -1;
403 if (i > j)
404 return i * 8;
405 mask = min[i] ^ max[i];
406 switch (mask) {
407 case 0x01: j = 7; break;
408 case 0x03: j = 6; break;
409 case 0x07: j = 5; break;
410 case 0x0F: j = 4; break;
411 case 0x1F: j = 3; break;
412 case 0x3F: j = 2; break;
413 case 0x7F: j = 1; break;
414 default: return -1;
415 }
416 if ((min[i] & mask) != 0 || (max[i] & mask) != mask)
417 return -1;
418 else
419 return i * 8 + j;
420}
421
422/*
423 * Construct a prefix.
424 */
425static int make_addressPrefix(IPAddressOrRange **result,
426 unsigned char *addr,
427 const int prefixlen)
428{
429 int bytelen = (prefixlen + 7) / 8, bitlen = prefixlen % 8;
430 IPAddressOrRange *aor = IPAddressOrRange_new();
431
432 if (aor == NULL)
433 return 0;
434 aor->type = IPAddressOrRange_addressPrefix;
435 if (aor->u.addressPrefix == NULL &&
436 (aor->u.addressPrefix = ASN1_BIT_STRING_new()) == NULL)
437 goto err;
438 if (!ASN1_BIT_STRING_set(aor->u.addressPrefix, addr, bytelen))
439 goto err;
440 aor->u.addressPrefix->flags &= ~7;
441 aor->u.addressPrefix->flags |= ASN1_STRING_FLAG_BITS_LEFT;
442 if (bitlen > 0) {
443 aor->u.addressPrefix->data[bytelen - 1] &= ~(0xFF >> bitlen);
444 aor->u.addressPrefix->flags |= 8 - bitlen;
445 }
446
447 *result = aor;
448 return 1;
449
450 err:
451 IPAddressOrRange_free(aor);
452 return 0;
453}
454
455/*
456 * Construct a range. If it can be expressed as a prefix,
457 * return a prefix instead. Doing this here simplifies
458 * the rest of the code considerably.
459 */
460static int make_addressRange(IPAddressOrRange **result,
461 unsigned char *min,
462 unsigned char *max,
463 const int length)
464{
465 IPAddressOrRange *aor;
466 int i, prefixlen;
467
468 if ((prefixlen = range_should_be_prefix(min, max, length)) >= 0)
469 return make_addressPrefix(result, min, prefixlen);
470
471 if ((aor = IPAddressOrRange_new()) == NULL)
472 return 0;
473 aor->type = IPAddressOrRange_addressRange;
474 OPENSSL_assert(aor->u.addressRange == NULL);
475 if ((aor->u.addressRange = IPAddressRange_new()) == NULL)
476 goto err;
477 if (aor->u.addressRange->min == NULL &&
478 (aor->u.addressRange->min = ASN1_BIT_STRING_new()) == NULL)
479 goto err;
480 if (aor->u.addressRange->max == NULL &&
481 (aor->u.addressRange->max = ASN1_BIT_STRING_new()) == NULL)
482 goto err;
483
484 for (i = length; i > 0 && min[i - 1] == 0x00; --i)
485 ;
486 if (!ASN1_BIT_STRING_set(aor->u.addressRange->min, min, i))
487 goto err;
488 aor->u.addressRange->min->flags &= ~7;
489 aor->u.addressRange->min->flags |= ASN1_STRING_FLAG_BITS_LEFT;
490 if (i > 0) {
491 unsigned char b = min[i - 1];
492 int j = 1;
493 while ((b & (0xFFU >> j)) != 0)
494 ++j;
495 aor->u.addressRange->min->flags |= 8 - j;
496 }
497
498 for (i = length; i > 0 && max[i - 1] == 0xFF; --i)
499 ;
500 if (!ASN1_BIT_STRING_set(aor->u.addressRange->max, max, i))
501 goto err;
502 aor->u.addressRange->max->flags &= ~7;
503 aor->u.addressRange->max->flags |= ASN1_STRING_FLAG_BITS_LEFT;
504 if (i > 0) {
505 unsigned char b = max[i - 1];
506 int j = 1;
507 while ((b & (0xFFU >> j)) != (0xFFU >> j))
508 ++j;
509 aor->u.addressRange->max->flags |= 8 - j;
510 }
511
512 *result = aor;
513 return 1;
514
515 err:
516 IPAddressOrRange_free(aor);
517 return 0;
518}
519
520/*
521 * Construct a new address family or find an existing one.
522 */
523static IPAddressFamily *make_IPAddressFamily(IPAddrBlocks *addr,
524 const unsigned afi,
525 const unsigned *safi)
526{
527 IPAddressFamily *f;
528 unsigned char key[3];
529 unsigned keylen;
530 int i;
531
532 key[0] = (afi >> 8) & 0xFF;
533 key[1] = afi & 0xFF;
534 if (safi != NULL) {
535 key[2] = *safi & 0xFF;
536 keylen = 3;
537 } else {
538 keylen = 2;
539 }
540
541 for (i = 0; i < sk_IPAddressFamily_num(addr); i++) {
542 f = sk_IPAddressFamily_value(addr, i);
543 OPENSSL_assert(f->addressFamily->data != NULL);
544 if (f->addressFamily->length == keylen &&
545 !memcmp(f->addressFamily->data, key, keylen))
546 return f;
547 }
548
549 if ((f = IPAddressFamily_new()) == NULL)
550 goto err;
551 if (f->ipAddressChoice == NULL &&
552 (f->ipAddressChoice = IPAddressChoice_new()) == NULL)
553 goto err;
554 if (f->addressFamily == NULL &&
555 (f->addressFamily = ASN1_OCTET_STRING_new()) == NULL)
556 goto err;
557 if (!ASN1_OCTET_STRING_set(f->addressFamily, key, keylen))
558 goto err;
559 if (!sk_IPAddressFamily_push(addr, f))
560 goto err;
561
562 return f;
563
564 err:
565 IPAddressFamily_free(f);
566 return NULL;
567}
568
569/*
570 * Add an inheritance element.
571 */
572int v3_addr_add_inherit(IPAddrBlocks *addr,
573 const unsigned afi,
574 const unsigned *safi)
575{
576 IPAddressFamily *f = make_IPAddressFamily(addr, afi, safi);
577 if (f == NULL ||
578 f->ipAddressChoice == NULL ||
579 (f->ipAddressChoice->type == IPAddressChoice_addressesOrRanges &&
580 f->ipAddressChoice->u.addressesOrRanges != NULL))
581 return 0;
582 if (f->ipAddressChoice->type == IPAddressChoice_inherit &&
583 f->ipAddressChoice->u.inherit != NULL)
584 return 1;
585 if (f->ipAddressChoice->u.inherit == NULL &&
586 (f->ipAddressChoice->u.inherit = ASN1_NULL_new()) == NULL)
587 return 0;
588 f->ipAddressChoice->type = IPAddressChoice_inherit;
589 return 1;
590}
591
592/*
593 * Construct an IPAddressOrRange sequence, or return an existing one.
594 */
595static IPAddressOrRanges *make_prefix_or_range(IPAddrBlocks *addr,
596 const unsigned afi,
597 const unsigned *safi)
598{
599 IPAddressFamily *f = make_IPAddressFamily(addr, afi, safi);
600 IPAddressOrRanges *aors = NULL;
601
602 if (f == NULL ||
603 f->ipAddressChoice == NULL ||
604 (f->ipAddressChoice->type == IPAddressChoice_inherit &&
605 f->ipAddressChoice->u.inherit != NULL))
606 return NULL;
607 if (f->ipAddressChoice->type == IPAddressChoice_addressesOrRanges)
608 aors = f->ipAddressChoice->u.addressesOrRanges;
609 if (aors != NULL)
610 return aors;
611 if ((aors = sk_IPAddressOrRange_new_null()) == NULL)
612 return NULL;
613 switch (afi) {
614 case IANA_AFI_IPV4:
615 (void) sk_IPAddressOrRange_set_cmp_func(aors, v4IPAddressOrRange_cmp);
616 break;
617 case IANA_AFI_IPV6:
618 (void) sk_IPAddressOrRange_set_cmp_func(aors, v6IPAddressOrRange_cmp);
619 break;
620 }
621 f->ipAddressChoice->type = IPAddressChoice_addressesOrRanges;
622 f->ipAddressChoice->u.addressesOrRanges = aors;
623 return aors;
624}
625
626/*
627 * Add a prefix.
628 */
629int v3_addr_add_prefix(IPAddrBlocks *addr,
630 const unsigned afi,
631 const unsigned *safi,
632 unsigned char *a,
633 const int prefixlen)
634{
635 IPAddressOrRanges *aors = make_prefix_or_range(addr, afi, safi);
636 IPAddressOrRange *aor;
637 if (aors == NULL || !make_addressPrefix(&aor, a, prefixlen))
638 return 0;
639 if (sk_IPAddressOrRange_push(aors, aor))
640 return 1;
641 IPAddressOrRange_free(aor);
642 return 0;
643}
644
645/*
646 * Add a range.
647 */
648int v3_addr_add_range(IPAddrBlocks *addr,
649 const unsigned afi,
650 const unsigned *safi,
651 unsigned char *min,
652 unsigned char *max)
653{
654 IPAddressOrRanges *aors = make_prefix_or_range(addr, afi, safi);
655 IPAddressOrRange *aor;
656 int length = length_from_afi(afi);
657 if (aors == NULL)
658 return 0;
659 if (!make_addressRange(&aor, min, max, length))
660 return 0;
661 if (sk_IPAddressOrRange_push(aors, aor))
662 return 1;
663 IPAddressOrRange_free(aor);
664 return 0;
665}
666
667/*
668 * Extract min and max values from an IPAddressOrRange.
669 */
670static int extract_min_max(IPAddressOrRange *aor,
671 unsigned char *min,
672 unsigned char *max,
673 int length)
674{
675 if (aor == NULL || min == NULL || max == NULL)
676 return 0;
677 switch (aor->type) {
678 case IPAddressOrRange_addressPrefix:
679 return (addr_expand(min, aor->u.addressPrefix, length, 0x00) &&
680 addr_expand(max, aor->u.addressPrefix, length, 0xFF));
681 case IPAddressOrRange_addressRange:
682 return (addr_expand(min, aor->u.addressRange->min, length, 0x00) &&
683 addr_expand(max, aor->u.addressRange->max, length, 0xFF));
684 }
685 return 0;
686}
687
688/*
689 * Public wrapper for extract_min_max().
690 */
691int v3_addr_get_range(IPAddressOrRange *aor,
692 const unsigned afi,
693 unsigned char *min,
694 unsigned char *max,
695 const int length)
696{
697 int afi_length = length_from_afi(afi);
698 if (aor == NULL || min == NULL || max == NULL ||
699 afi_length == 0 || length < afi_length ||
700 (aor->type != IPAddressOrRange_addressPrefix &&
701 aor->type != IPAddressOrRange_addressRange) ||
702 !extract_min_max(aor, min, max, afi_length))
703 return 0;
704
705 return afi_length;
706}
707
708/*
709 * Sort comparision function for a sequence of IPAddressFamily.
710 *
711 * The last paragraph of RFC 3779 2.2.3.3 is slightly ambiguous about
712 * the ordering: I can read it as meaning that IPv6 without a SAFI
713 * comes before IPv4 with a SAFI, which seems pretty weird. The
714 * examples in appendix B suggest that the author intended the
715 * null-SAFI rule to apply only within a single AFI, which is what I
716 * would have expected and is what the following code implements.
717 */
718static int IPAddressFamily_cmp(const IPAddressFamily * const *a_,
719 const IPAddressFamily * const *b_)
720{
721 const ASN1_OCTET_STRING *a = (*a_)->addressFamily;
722 const ASN1_OCTET_STRING *b = (*b_)->addressFamily;
723 int len = ((a->length <= b->length) ? a->length : b->length);
724 int cmp = memcmp(a->data, b->data, len);
725 return cmp ? cmp : a->length - b->length;
726}
727
728/*
729 * Check whether an IPAddrBLocks is in canonical form.
730 */
731int v3_addr_is_canonical(IPAddrBlocks *addr)
732{
733 unsigned char a_min[ADDR_RAW_BUF_LEN], a_max[ADDR_RAW_BUF_LEN];
734 unsigned char b_min[ADDR_RAW_BUF_LEN], b_max[ADDR_RAW_BUF_LEN];
735 IPAddressOrRanges *aors;
736 int i, j, k;
737
738 /*
739 * Empty extension is cannonical.
740 */
741 if (addr == NULL)
742 return 1;
743
744 /*
745 * Check whether the top-level list is in order.
746 */
747 for (i = 0; i < sk_IPAddressFamily_num(addr) - 1; i++) {
748 const IPAddressFamily *a = sk_IPAddressFamily_value(addr, i);
749 const IPAddressFamily *b = sk_IPAddressFamily_value(addr, i + 1);
750 if (IPAddressFamily_cmp(&a, &b) >= 0)
751 return 0;
752 }
753
754 /*
755 * Top level's ok, now check each address family.
756 */
757 for (i = 0; i < sk_IPAddressFamily_num(addr); i++) {
758 IPAddressFamily *f = sk_IPAddressFamily_value(addr, i);
759 int length = length_from_afi(v3_addr_get_afi(f));
760
761 /*
762 * Inheritance is canonical. Anything other than inheritance or
763 * a SEQUENCE OF IPAddressOrRange is an ASN.1 error or something.
764 */
765 if (f == NULL || f->ipAddressChoice == NULL)
766 return 0;
767 switch (f->ipAddressChoice->type) {
768 case IPAddressChoice_inherit:
769 continue;
770 case IPAddressChoice_addressesOrRanges:
771 break;
772 default:
773 return 0;
774 }
775
776 /*
777 * It's an IPAddressOrRanges sequence, check it.
778 */
779 aors = f->ipAddressChoice->u.addressesOrRanges;
780 if (sk_IPAddressOrRange_num(aors) == 0)
781 return 0;
782 for (j = 0; j < sk_IPAddressOrRange_num(aors) - 1; j++) {
783 IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, j);
784 IPAddressOrRange *b = sk_IPAddressOrRange_value(aors, j + 1);
785
786 if (!extract_min_max(a, a_min, a_max, length) ||
787 !extract_min_max(b, b_min, b_max, length))
788 return 0;
789
790 /*
791 * Punt misordered list, overlapping start, or inverted range.
792 */
793 if (memcmp(a_min, b_min, length) >= 0 ||
794 memcmp(a_min, a_max, length) > 0 ||
795 memcmp(b_min, b_max, length) > 0)
796 return 0;
797
798 /*
799 * Punt if adjacent or overlapping. Check for adjacency by
800 * subtracting one from b_min first.
801 */
802 for (k = length - 1; k >= 0 && b_min[k]-- == 0x00; k--)
803 ;
804 if (memcmp(a_max, b_min, length) >= 0)
805 return 0;
806
807 /*
808 * Check for range that should be expressed as a prefix.
809 */
810 if (a->type == IPAddressOrRange_addressRange &&
811 range_should_be_prefix(a_min, a_max, length) >= 0)
812 return 0;
813 }
814
815 /*
816 * Check range to see if it's inverted or should be a
817 * prefix.
818 */
819 j = sk_IPAddressOrRange_num(aors) - 1;
820 {
821 IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, j);
822 if (a != NULL && a->type == IPAddressOrRange_addressRange) {
823 if (!extract_min_max(a, a_min, a_max, length))
824 return 0;
825 if (memcmp(a_min, a_max, length) > 0 ||
826 range_should_be_prefix(a_min, a_max, length) >= 0)
827 return 0;
828 }
829 }
830 }
831
832 /*
833 * If we made it through all that, we're happy.
834 */
835 return 1;
836}
837
838/*
839 * Whack an IPAddressOrRanges into canonical form.
840 */
841static int IPAddressOrRanges_canonize(IPAddressOrRanges *aors,
842 const unsigned afi)
843{
844 int i, j, length = length_from_afi(afi);
845
846 /*
847 * Sort the IPAddressOrRanges sequence.
848 */
849 sk_IPAddressOrRange_sort(aors);
850
851 /*
852 * Clean up representation issues, punt on duplicates or overlaps.
853 */
854 for (i = 0; i < sk_IPAddressOrRange_num(aors) - 1; i++) {
855 IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, i);
856 IPAddressOrRange *b = sk_IPAddressOrRange_value(aors, i + 1);
857 unsigned char a_min[ADDR_RAW_BUF_LEN], a_max[ADDR_RAW_BUF_LEN];
858 unsigned char b_min[ADDR_RAW_BUF_LEN], b_max[ADDR_RAW_BUF_LEN];
859
860 if (!extract_min_max(a, a_min, a_max, length) ||
861 !extract_min_max(b, b_min, b_max, length))
862 return 0;
863
864 /*
865 * Punt inverted ranges.
866 */
867 if (memcmp(a_min, a_max, length) > 0 ||
868 memcmp(b_min, b_max, length) > 0)
869 return 0;
870
871 /*
872 * Punt overlaps.
873 */
874 if (memcmp(a_max, b_min, length) >= 0)
875 return 0;
876
877 /*
878 * Merge if a and b are adjacent. We check for
879 * adjacency by subtracting one from b_min first.
880 */
881 for (j = length - 1; j >= 0 && b_min[j]-- == 0x00; j--)
882 ;
883 if (memcmp(a_max, b_min, length) == 0) {
884 IPAddressOrRange *merged;
885 if (!make_addressRange(&merged, a_min, b_max, length))
886 return 0;
887 (void) sk_IPAddressOrRange_set(aors, i, merged);
888 (void) sk_IPAddressOrRange_delete(aors, i + 1);
889 IPAddressOrRange_free(a);
890 IPAddressOrRange_free(b);
891 --i;
892 continue;
893 }
894 }
895
896 /*
897 * Check for inverted final range.
898 */
899 j = sk_IPAddressOrRange_num(aors) - 1;
900 {
901 IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, j);
902 if (a != NULL && a->type == IPAddressOrRange_addressRange) {
903 unsigned char a_min[ADDR_RAW_BUF_LEN], a_max[ADDR_RAW_BUF_LEN];
904 extract_min_max(a, a_min, a_max, length);
905 if (memcmp(a_min, a_max, length) > 0)
906 return 0;
907 }
908 }
909
910 return 1;
911}
912
913/*
914 * Whack an IPAddrBlocks extension into canonical form.
915 */
916int v3_addr_canonize(IPAddrBlocks *addr)
917{
918 int i;
919 for (i = 0; i < sk_IPAddressFamily_num(addr); i++) {
920 IPAddressFamily *f = sk_IPAddressFamily_value(addr, i);
921 if (f->ipAddressChoice->type == IPAddressChoice_addressesOrRanges &&
922 !IPAddressOrRanges_canonize(f->ipAddressChoice->u.addressesOrRanges,
923 v3_addr_get_afi(f)))
924 return 0;
925 }
926 (void) sk_IPAddressFamily_set_cmp_func(addr, IPAddressFamily_cmp);
927 sk_IPAddressFamily_sort(addr);
928 OPENSSL_assert(v3_addr_is_canonical(addr));
929 return 1;
930}
931
932/*
933 * v2i handler for the IPAddrBlocks extension.
934 */
935static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,
936 struct v3_ext_ctx *ctx,
937 STACK_OF(CONF_VALUE) *values)
938{
939 static const char v4addr_chars[] = "0123456789.";
940 static const char v6addr_chars[] = "0123456789.:abcdefABCDEF";
941 IPAddrBlocks *addr = NULL;
942 char *s = NULL, *t;
943 int i;
944
945 if ((addr = sk_IPAddressFamily_new(IPAddressFamily_cmp)) == NULL) {
946 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
947 return NULL;
948 }
949
950 for (i = 0; i < sk_CONF_VALUE_num(values); i++) {
951 CONF_VALUE *val = sk_CONF_VALUE_value(values, i);
952 unsigned char min[ADDR_RAW_BUF_LEN], max[ADDR_RAW_BUF_LEN];
953 unsigned afi, *safi = NULL, safi_;
954 const char *addr_chars;
955 int prefixlen, i1, i2, delim, length;
956
957 if ( !name_cmp(val->name, "IPv4")) {
958 afi = IANA_AFI_IPV4;
959 } else if (!name_cmp(val->name, "IPv6")) {
960 afi = IANA_AFI_IPV6;
961 } else if (!name_cmp(val->name, "IPv4-SAFI")) {
962 afi = IANA_AFI_IPV4;
963 safi = &safi_;
964 } else if (!name_cmp(val->name, "IPv6-SAFI")) {
965 afi = IANA_AFI_IPV6;
966 safi = &safi_;
967 } else {
968 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_EXTENSION_NAME_ERROR);
969 X509V3_conf_err(val);
970 goto err;
971 }
972
973 switch (afi) {
974 case IANA_AFI_IPV4:
975 addr_chars = v4addr_chars;
976 break;
977 case IANA_AFI_IPV6:
978 addr_chars = v6addr_chars;
979 break;
980 }
981
982 length = length_from_afi(afi);
983
984 /*
985 * Handle SAFI, if any, and BUF_strdup() so we can null-terminate
986 * the other input values.
987 */
988 if (safi != NULL) {
989 *safi = strtoul(val->value, &t, 0);
990 t += strspn(t, " \t");
991 if (*safi > 0xFF || *t++ != ':') {
992 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_SAFI);
993 X509V3_conf_err(val);
994 goto err;
995 }
996 t += strspn(t, " \t");
997 s = BUF_strdup(t);
998 } else {
999 s = BUF_strdup(val->value);
1000 }
1001 if (s == NULL) {
1002 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
1003 goto err;
1004 }
1005
1006 /*
1007 * Check for inheritance. Not worth additional complexity to
1008 * optimize this (seldom-used) case.
1009 */
1010 if (!strcmp(s, "inherit")) {
1011 if (!v3_addr_add_inherit(addr, afi, safi)) {
1012 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_INHERITANCE);
1013 X509V3_conf_err(val);
1014 goto err;
1015 }
1016 OPENSSL_free(s);
1017 s = NULL;
1018 continue;
1019 }
1020
1021 i1 = strspn(s, addr_chars);
1022 i2 = i1 + strspn(s + i1, " \t");
1023 delim = s[i2++];
1024 s[i1] = '\0';
1025
1026 if (a2i_ipadd(min, s) != length) {
1027 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_IPADDRESS);
1028 X509V3_conf_err(val);
1029 goto err;
1030 }
1031
1032 switch (delim) {
1033 case '/':
1034 prefixlen = (int) strtoul(s + i2, &t, 10);
1035 if (t == s + i2 || *t != '\0') {
1036 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_EXTENSION_VALUE_ERROR);
1037 X509V3_conf_err(val);
1038 goto err;
1039 }
1040 if (!v3_addr_add_prefix(addr, afi, safi, min, prefixlen)) {
1041 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
1042 goto err;
1043 }
1044 break;
1045 case '-':
1046 i1 = i2 + strspn(s + i2, " \t");
1047 i2 = i1 + strspn(s + i1, addr_chars);
1048 if (i1 == i2 || s[i2] != '\0') {
1049 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_EXTENSION_VALUE_ERROR);
1050 X509V3_conf_err(val);
1051 goto err;
1052 }
1053 if (a2i_ipadd(max, s + i1) != length) {
1054 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_IPADDRESS);
1055 X509V3_conf_err(val);
1056 goto err;
1057 }
1058 if (memcmp(min, max, length_from_afi(afi)) > 0) {
1059 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_EXTENSION_VALUE_ERROR);
1060 X509V3_conf_err(val);
1061 goto err;
1062 }
1063 if (!v3_addr_add_range(addr, afi, safi, min, max)) {
1064 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
1065 goto err;
1066 }
1067 break;
1068 case '\0':
1069 if (!v3_addr_add_prefix(addr, afi, safi, min, length * 8)) {
1070 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
1071 goto err;
1072 }
1073 break;
1074 default:
1075 X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_EXTENSION_VALUE_ERROR);
1076 X509V3_conf_err(val);
1077 goto err;
1078 }
1079
1080 OPENSSL_free(s);
1081 s = NULL;
1082 }
1083
1084 /*
1085 * Canonize the result, then we're done.
1086 */
1087 if (!v3_addr_canonize(addr))
1088 goto err;
1089 return addr;
1090
1091 err:
1092 OPENSSL_free(s);
1093 sk_IPAddressFamily_pop_free(addr, IPAddressFamily_free);
1094 return NULL;
1095}
1096
1097/*
1098 * OpenSSL dispatch
1099 */
1100const X509V3_EXT_METHOD v3_addr = {
1101 NID_sbgp_ipAddrBlock, /* nid */
1102 0, /* flags */
1103 ASN1_ITEM_ref(IPAddrBlocks), /* template */
1104 0, 0, 0, 0, /* old functions, ignored */
1105 0, /* i2s */
1106 0, /* s2i */
1107 0, /* i2v */
1108 v2i_IPAddrBlocks, /* v2i */
1109 i2r_IPAddrBlocks, /* i2r */
1110 0, /* r2i */
1111 NULL /* extension-specific data */
1112};
1113
1114/*
1115 * Figure out whether extension sues inheritance.
1116 */
1117int v3_addr_inherits(IPAddrBlocks *addr)
1118{
1119 int i;
1120 if (addr == NULL)
1121 return 0;
1122 for (i = 0; i < sk_IPAddressFamily_num(addr); i++) {
1123 IPAddressFamily *f = sk_IPAddressFamily_value(addr, i);
1124 if (f->ipAddressChoice->type == IPAddressChoice_inherit)
1125 return 1;
1126 }
1127 return 0;
1128}
1129
1130/*
1131 * Figure out whether parent contains child.
1132 */
1133static int addr_contains(IPAddressOrRanges *parent,
1134 IPAddressOrRanges *child,
1135 int length)
1136{
1137 unsigned char p_min[ADDR_RAW_BUF_LEN], p_max[ADDR_RAW_BUF_LEN];
1138 unsigned char c_min[ADDR_RAW_BUF_LEN], c_max[ADDR_RAW_BUF_LEN];
1139 int p, c;
1140
1141 if (child == NULL || parent == child)
1142 return 1;
1143 if (parent == NULL)
1144 return 0;
1145
1146 p = 0;
1147 for (c = 0; c < sk_IPAddressOrRange_num(child); c++) {
1148 if (!extract_min_max(sk_IPAddressOrRange_value(child, c),
1149 c_min, c_max, length))
1150 return -1;
1151 for (;; p++) {
1152 if (p >= sk_IPAddressOrRange_num(parent))
1153 return 0;
1154 if (!extract_min_max(sk_IPAddressOrRange_value(parent, p),
1155 p_min, p_max, length))
1156 return 0;
1157 if (memcmp(p_max, c_max, length) < 0)
1158 continue;
1159 if (memcmp(p_min, c_min, length) > 0)
1160 return 0;
1161 break;
1162 }
1163 }
1164
1165 return 1;
1166}
1167
1168/*
1169 * Test whether a is a subset of b.
1170 */
1171int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b)
1172{
1173 int i;
1174 if (a == NULL || a == b)
1175 return 1;
1176 if (b == NULL || v3_addr_inherits(a) || v3_addr_inherits(b))
1177 return 0;
1178 (void) sk_IPAddressFamily_set_cmp_func(b, IPAddressFamily_cmp);
1179 for (i = 0; i < sk_IPAddressFamily_num(a); i++) {
1180 IPAddressFamily *fa = sk_IPAddressFamily_value(a, i);
1181 int j = sk_IPAddressFamily_find(b, fa);
1182 IPAddressFamily *fb;
1183 fb = sk_IPAddressFamily_value(b, j);
1184 if (fb == NULL)
1185 return 0;
1186 if (!addr_contains(fb->ipAddressChoice->u.addressesOrRanges,
1187 fa->ipAddressChoice->u.addressesOrRanges,
1188 length_from_afi(v3_addr_get_afi(fb))))
1189 return 0;
1190 }
1191 return 1;
1192}
1193
1194/*
1195 * Validation error handling via callback.
1196 */
1197#define validation_err(_err_) \
1198 do { \
1199 if (ctx != NULL) { \
1200 ctx->error = _err_; \
1201 ctx->error_depth = i; \
1202 ctx->current_cert = x; \
1203 ret = ctx->verify_cb(0, ctx); \
1204 } else { \
1205 ret = 0; \
1206 } \
1207 if (!ret) \
1208 goto done; \
1209 } while (0)
1210
1211/*
1212 * Core code for RFC 3779 2.3 path validation.
1213 */
1214static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx,
1215 STACK_OF(X509) *chain,
1216 IPAddrBlocks *ext)
1217{
1218 IPAddrBlocks *child = NULL;
1219 int i, j, ret = 1;
1220 X509 *x;
1221
1222 OPENSSL_assert(chain != NULL && sk_X509_num(chain) > 0);
1223 OPENSSL_assert(ctx != NULL || ext != NULL);
1224 OPENSSL_assert(ctx == NULL || ctx->verify_cb != NULL);
1225
1226 /*
1227 * Figure out where to start. If we don't have an extension to
1228 * check, we're done. Otherwise, check canonical form and
1229 * set up for walking up the chain.
1230 */
1231 if (ext != NULL) {
1232 i = -1;
1233 x = NULL;
1234 } else {
1235 i = 0;
1236 x = sk_X509_value(chain, i);
1237 OPENSSL_assert(x != NULL);
1238 if ((ext = x->rfc3779_addr) == NULL)
1239 goto done;
1240 }
1241 if (!v3_addr_is_canonical(ext))
1242 validation_err(X509_V_ERR_INVALID_EXTENSION);
1243 (void) sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp);
1244 if ((child = sk_IPAddressFamily_dup(ext)) == NULL) {
1245 X509V3err(X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL, ERR_R_MALLOC_FAILURE);
1246 ret = 0;
1247 goto done;
1248 }
1249
1250 /*
1251 * Now walk up the chain. No cert may list resources that its
1252 * parent doesn't list.
1253 */
1254 for (i++; i < sk_X509_num(chain); i++) {
1255 x = sk_X509_value(chain, i);
1256 OPENSSL_assert(x != NULL);
1257 if (!v3_addr_is_canonical(x->rfc3779_addr))
1258 validation_err(X509_V_ERR_INVALID_EXTENSION);
1259 if (x->rfc3779_addr == NULL) {
1260 for (j = 0; j < sk_IPAddressFamily_num(child); j++) {
1261 IPAddressFamily *fc = sk_IPAddressFamily_value(child, j);
1262 if (fc->ipAddressChoice->type != IPAddressChoice_inherit) {
1263 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
1264 break;
1265 }
1266 }
1267 continue;
1268 }
1269 (void) sk_IPAddressFamily_set_cmp_func(x->rfc3779_addr, IPAddressFamily_cmp);
1270 for (j = 0; j < sk_IPAddressFamily_num(child); j++) {
1271 IPAddressFamily *fc = sk_IPAddressFamily_value(child, j);
1272 int k = sk_IPAddressFamily_find(x->rfc3779_addr, fc);
1273 IPAddressFamily *fp = sk_IPAddressFamily_value(x->rfc3779_addr, k);
1274 if (fp == NULL) {
1275 if (fc->ipAddressChoice->type == IPAddressChoice_addressesOrRanges) {
1276 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
1277 break;
1278 }
1279 continue;
1280 }
1281 if (fp->ipAddressChoice->type == IPAddressChoice_addressesOrRanges) {
1282 if (fc->ipAddressChoice->type == IPAddressChoice_inherit ||
1283 addr_contains(fp->ipAddressChoice->u.addressesOrRanges,
1284 fc->ipAddressChoice->u.addressesOrRanges,
1285 length_from_afi(v3_addr_get_afi(fc))))
1286 sk_IPAddressFamily_set(child, j, fp);
1287 else
1288 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
1289 }
1290 }
1291 }
1292
1293 /*
1294 * Trust anchor can't inherit.
1295 */
1296 OPENSSL_assert(x != NULL);
1297 if (x->rfc3779_addr != NULL) {
1298 for (j = 0; j < sk_IPAddressFamily_num(x->rfc3779_addr); j++) {
1299 IPAddressFamily *fp = sk_IPAddressFamily_value(x->rfc3779_addr, j);
1300 if (fp->ipAddressChoice->type == IPAddressChoice_inherit &&
1301 sk_IPAddressFamily_find(child, fp) >= 0)
1302 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
1303 }
1304 }
1305
1306 done:
1307 sk_IPAddressFamily_free(child);
1308 return ret;
1309}
1310
1311#undef validation_err
1312
1313/*
1314 * RFC 3779 2.3 path validation -- called from X509_verify_cert().
1315 */
1316int v3_addr_validate_path(X509_STORE_CTX *ctx)
1317{
1318 return v3_addr_validate_path_internal(ctx, ctx->chain, NULL);
1319}
1320
1321/*
1322 * RFC 3779 2.3 path validation of an extension.
1323 * Test whether chain covers extension.
1324 */
1325int v3_addr_validate_resource_set(STACK_OF(X509) *chain,
1326 IPAddrBlocks *ext,
1327 int allow_inheritance)
1328{
1329 if (ext == NULL)
1330 return 1;
1331 if (chain == NULL || sk_X509_num(chain) == 0)
1332 return 0;
1333 if (!allow_inheritance && v3_addr_inherits(ext))
1334 return 0;
1335 return v3_addr_validate_path_internal(NULL, chain, ext);
1336}
1337
1338#endif /* OPENSSL_NO_RFC3779 */
diff --git a/src/lib/libcrypto/x509v3/v3_asid.c b/src/lib/libcrypto/x509v3/v3_asid.c
new file mode 100644
index 0000000000..1587e8ed72
--- /dev/null
+++ b/src/lib/libcrypto/x509v3/v3_asid.c
@@ -0,0 +1,890 @@
1/*
2 * Contributed to the OpenSSL Project by the American Registry for
3 * Internet Numbers ("ARIN").
4 */
5/* ====================================================================
6 * Copyright (c) 2006 The OpenSSL Project. 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 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 */
57
58/*
59 * Implementation of RFC 3779 section 3.2.
60 */
61
62#include <stdio.h>
63#include <string.h>
64#include "cryptlib.h"
65#include <openssl/conf.h>
66#include <openssl/asn1.h>
67#include <openssl/asn1t.h>
68#include <openssl/x509v3.h>
69#include <openssl/x509.h>
70#include <openssl/bn.h>
71
72#ifndef OPENSSL_NO_RFC3779
73
74/*
75 * OpenSSL ASN.1 template translation of RFC 3779 3.2.3.
76 */
77
78ASN1_SEQUENCE(ASRange) = {
79 ASN1_SIMPLE(ASRange, min, ASN1_INTEGER),
80 ASN1_SIMPLE(ASRange, max, ASN1_INTEGER)
81} ASN1_SEQUENCE_END(ASRange)
82
83ASN1_CHOICE(ASIdOrRange) = {
84 ASN1_SIMPLE(ASIdOrRange, u.id, ASN1_INTEGER),
85 ASN1_SIMPLE(ASIdOrRange, u.range, ASRange)
86} ASN1_CHOICE_END(ASIdOrRange)
87
88ASN1_CHOICE(ASIdentifierChoice) = {
89 ASN1_SIMPLE(ASIdentifierChoice, u.inherit, ASN1_NULL),
90 ASN1_SEQUENCE_OF(ASIdentifierChoice, u.asIdsOrRanges, ASIdOrRange)
91} ASN1_CHOICE_END(ASIdentifierChoice)
92
93ASN1_SEQUENCE(ASIdentifiers) = {
94 ASN1_EXP_OPT(ASIdentifiers, asnum, ASIdentifierChoice, 0),
95 ASN1_EXP_OPT(ASIdentifiers, rdi, ASIdentifierChoice, 1)
96} ASN1_SEQUENCE_END(ASIdentifiers)
97
98IMPLEMENT_ASN1_FUNCTIONS(ASRange)
99IMPLEMENT_ASN1_FUNCTIONS(ASIdOrRange)
100IMPLEMENT_ASN1_FUNCTIONS(ASIdentifierChoice)
101IMPLEMENT_ASN1_FUNCTIONS(ASIdentifiers)
102
103/*
104 * i2r method for an ASIdentifierChoice.
105 */
106static int i2r_ASIdentifierChoice(BIO *out,
107 ASIdentifierChoice *choice,
108 int indent,
109 const char *msg)
110{
111 int i;
112 char *s;
113 if (choice == NULL)
114 return 1;
115 BIO_printf(out, "%*s%s:\n", indent, "", msg);
116 switch (choice->type) {
117 case ASIdentifierChoice_inherit:
118 BIO_printf(out, "%*sinherit\n", indent + 2, "");
119 break;
120 case ASIdentifierChoice_asIdsOrRanges:
121 for (i = 0; i < sk_ASIdOrRange_num(choice->u.asIdsOrRanges); i++) {
122 ASIdOrRange *aor = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
123 switch (aor->type) {
124 case ASIdOrRange_id:
125 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.id)) == NULL)
126 return 0;
127 BIO_printf(out, "%*s%s\n", indent + 2, "", s);
128 OPENSSL_free(s);
129 break;
130 case ASIdOrRange_range:
131 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.range->min)) == NULL)
132 return 0;
133 BIO_printf(out, "%*s%s-", indent + 2, "", s);
134 OPENSSL_free(s);
135 if ((s = i2s_ASN1_INTEGER(NULL, aor->u.range->max)) == NULL)
136 return 0;
137 BIO_printf(out, "%s\n", s);
138 OPENSSL_free(s);
139 break;
140 default:
141 return 0;
142 }
143 }
144 break;
145 default:
146 return 0;
147 }
148 return 1;
149}
150
151/*
152 * i2r method for an ASIdentifier extension.
153 */
154static int i2r_ASIdentifiers(const X509V3_EXT_METHOD *method,
155 void *ext,
156 BIO *out,
157 int indent)
158{
159 ASIdentifiers *asid = ext;
160 return (i2r_ASIdentifierChoice(out, asid->asnum, indent,
161 "Autonomous System Numbers") &&
162 i2r_ASIdentifierChoice(out, asid->rdi, indent,
163 "Routing Domain Identifiers"));
164}
165
166/*
167 * Sort comparision function for a sequence of ASIdOrRange elements.
168 */
169static int ASIdOrRange_cmp(const ASIdOrRange * const *a_,
170 const ASIdOrRange * const *b_)
171{
172 const ASIdOrRange *a = *a_, *b = *b_;
173
174 OPENSSL_assert((a->type == ASIdOrRange_id && a->u.id != NULL) ||
175 (a->type == ASIdOrRange_range && a->u.range != NULL &&
176 a->u.range->min != NULL && a->u.range->max != NULL));
177
178 OPENSSL_assert((b->type == ASIdOrRange_id && b->u.id != NULL) ||
179 (b->type == ASIdOrRange_range && b->u.range != NULL &&
180 b->u.range->min != NULL && b->u.range->max != NULL));
181
182 if (a->type == ASIdOrRange_id && b->type == ASIdOrRange_id)
183 return ASN1_INTEGER_cmp(a->u.id, b->u.id);
184
185 if (a->type == ASIdOrRange_range && b->type == ASIdOrRange_range) {
186 int r = ASN1_INTEGER_cmp(a->u.range->min, b->u.range->min);
187 return r != 0 ? r : ASN1_INTEGER_cmp(a->u.range->max, b->u.range->max);
188 }
189
190 if (a->type == ASIdOrRange_id)
191 return ASN1_INTEGER_cmp(a->u.id, b->u.range->min);
192 else
193 return ASN1_INTEGER_cmp(a->u.range->min, b->u.id);
194}
195
196/*
197 * Add an inherit element.
198 */
199int v3_asid_add_inherit(ASIdentifiers *asid, int which)
200{
201 ASIdentifierChoice **choice;
202 if (asid == NULL)
203 return 0;
204 switch (which) {
205 case V3_ASID_ASNUM:
206 choice = &asid->asnum;
207 break;
208 case V3_ASID_RDI:
209 choice = &asid->rdi;
210 break;
211 default:
212 return 0;
213 }
214 if (*choice == NULL) {
215 if ((*choice = ASIdentifierChoice_new()) == NULL)
216 return 0;
217 OPENSSL_assert((*choice)->u.inherit == NULL);
218 if (((*choice)->u.inherit = ASN1_NULL_new()) == NULL)
219 return 0;
220 (*choice)->type = ASIdentifierChoice_inherit;
221 }
222 return (*choice)->type == ASIdentifierChoice_inherit;
223}
224
225/*
226 * Add an ID or range to an ASIdentifierChoice.
227 */
228int v3_asid_add_id_or_range(ASIdentifiers *asid,
229 int which,
230 ASN1_INTEGER *min,
231 ASN1_INTEGER *max)
232{
233 ASIdentifierChoice **choice;
234 ASIdOrRange *aor;
235 if (asid == NULL)
236 return 0;
237 switch (which) {
238 case V3_ASID_ASNUM:
239 choice = &asid->asnum;
240 break;
241 case V3_ASID_RDI:
242 choice = &asid->rdi;
243 break;
244 default:
245 return 0;
246 }
247 if (*choice != NULL && (*choice)->type == ASIdentifierChoice_inherit)
248 return 0;
249 if (*choice == NULL) {
250 if ((*choice = ASIdentifierChoice_new()) == NULL)
251 return 0;
252 OPENSSL_assert((*choice)->u.asIdsOrRanges == NULL);
253 (*choice)->u.asIdsOrRanges = sk_ASIdOrRange_new(ASIdOrRange_cmp);
254 if ((*choice)->u.asIdsOrRanges == NULL)
255 return 0;
256 (*choice)->type = ASIdentifierChoice_asIdsOrRanges;
257 }
258 if ((aor = ASIdOrRange_new()) == NULL)
259 return 0;
260 if (max == NULL) {
261 aor->type = ASIdOrRange_id;
262 aor->u.id = min;
263 } else {
264 aor->type = ASIdOrRange_range;
265 if ((aor->u.range = ASRange_new()) == NULL)
266 goto err;
267 ASN1_INTEGER_free(aor->u.range->min);
268 aor->u.range->min = min;
269 ASN1_INTEGER_free(aor->u.range->max);
270 aor->u.range->max = max;
271 }
272 if (!(sk_ASIdOrRange_push((*choice)->u.asIdsOrRanges, aor)))
273 goto err;
274 return 1;
275
276 err:
277 ASIdOrRange_free(aor);
278 return 0;
279}
280
281/*
282 * Extract min and max values from an ASIdOrRange.
283 */
284static void extract_min_max(ASIdOrRange *aor,
285 ASN1_INTEGER **min,
286 ASN1_INTEGER **max)
287{
288 OPENSSL_assert(aor != NULL && min != NULL && max != NULL);
289 switch (aor->type) {
290 case ASIdOrRange_id:
291 *min = aor->u.id;
292 *max = aor->u.id;
293 return;
294 case ASIdOrRange_range:
295 *min = aor->u.range->min;
296 *max = aor->u.range->max;
297 return;
298 }
299}
300
301/*
302 * Check whether an ASIdentifierChoice is in canonical form.
303 */
304static int ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice)
305{
306 ASN1_INTEGER *a_max_plus_one = NULL;
307 BIGNUM *bn = NULL;
308 int i, ret = 0;
309
310 /*
311 * Empty element or inheritance is canonical.
312 */
313 if (choice == NULL || choice->type == ASIdentifierChoice_inherit)
314 return 1;
315
316 /*
317 * If not a list, or if empty list, it's broken.
318 */
319 if (choice->type != ASIdentifierChoice_asIdsOrRanges ||
320 sk_ASIdOrRange_num(choice->u.asIdsOrRanges) == 0)
321 return 0;
322
323 /*
324 * It's a list, check it.
325 */
326 for (i = 0; i < sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1; i++) {
327 ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
328 ASIdOrRange *b = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i + 1);
329 ASN1_INTEGER *a_min, *a_max, *b_min, *b_max;
330
331 extract_min_max(a, &a_min, &a_max);
332 extract_min_max(b, &b_min, &b_max);
333
334 /*
335 * Punt misordered list, overlapping start, or inverted range.
336 */
337 if (ASN1_INTEGER_cmp(a_min, b_min) >= 0 ||
338 ASN1_INTEGER_cmp(a_min, a_max) > 0 ||
339 ASN1_INTEGER_cmp(b_min, b_max) > 0)
340 goto done;
341
342 /*
343 * Calculate a_max + 1 to check for adjacency.
344 */
345 if ((bn == NULL && (bn = BN_new()) == NULL) ||
346 ASN1_INTEGER_to_BN(a_max, bn) == NULL ||
347 !BN_add_word(bn, 1) ||
348 (a_max_plus_one = BN_to_ASN1_INTEGER(bn, a_max_plus_one)) == NULL) {
349 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL,
350 ERR_R_MALLOC_FAILURE);
351 goto done;
352 }
353
354 /*
355 * Punt if adjacent or overlapping.
356 */
357 if (ASN1_INTEGER_cmp(a_max_plus_one, b_min) >= 0)
358 goto done;
359 }
360
361 /*
362 * Check for inverted range.
363 */
364 i = sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1;
365 {
366 ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
367 ASN1_INTEGER *a_min, *a_max;
368 if (a != NULL && a->type == ASIdOrRange_range) {
369 extract_min_max(a, &a_min, &a_max);
370 if (ASN1_INTEGER_cmp(a_min, a_max) > 0)
371 goto done;
372 }
373 }
374
375 ret = 1;
376
377 done:
378 ASN1_INTEGER_free(a_max_plus_one);
379 BN_free(bn);
380 return ret;
381}
382
383/*
384 * Check whether an ASIdentifier extension is in canonical form.
385 */
386int v3_asid_is_canonical(ASIdentifiers *asid)
387{
388 return (asid == NULL ||
389 (ASIdentifierChoice_is_canonical(asid->asnum) &&
390 ASIdentifierChoice_is_canonical(asid->rdi)));
391}
392
393/*
394 * Whack an ASIdentifierChoice into canonical form.
395 */
396static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
397{
398 ASN1_INTEGER *a_max_plus_one = NULL;
399 BIGNUM *bn = NULL;
400 int i, ret = 0;
401
402 /*
403 * Nothing to do for empty element or inheritance.
404 */
405 if (choice == NULL || choice->type == ASIdentifierChoice_inherit)
406 return 1;
407
408 /*
409 * If not a list, or if empty list, it's broken.
410 */
411 if (choice->type != ASIdentifierChoice_asIdsOrRanges ||
412 sk_ASIdOrRange_num(choice->u.asIdsOrRanges) == 0) {
413 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
414 X509V3_R_EXTENSION_VALUE_ERROR);
415 return 0;
416 }
417
418 /*
419 * We have a non-empty list. Sort it.
420 */
421 sk_ASIdOrRange_sort(choice->u.asIdsOrRanges);
422
423 /*
424 * Now check for errors and suboptimal encoding, rejecting the
425 * former and fixing the latter.
426 */
427 for (i = 0; i < sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1; i++) {
428 ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
429 ASIdOrRange *b = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i + 1);
430 ASN1_INTEGER *a_min, *a_max, *b_min, *b_max;
431
432 extract_min_max(a, &a_min, &a_max);
433 extract_min_max(b, &b_min, &b_max);
434
435 /*
436 * Make sure we're properly sorted (paranoia).
437 */
438 OPENSSL_assert(ASN1_INTEGER_cmp(a_min, b_min) <= 0);
439
440 /*
441 * Punt inverted ranges.
442 */
443 if (ASN1_INTEGER_cmp(a_min, a_max) > 0 ||
444 ASN1_INTEGER_cmp(b_min, b_max) > 0)
445 goto done;
446
447 /*
448 * Check for overlaps.
449 */
450 if (ASN1_INTEGER_cmp(a_max, b_min) >= 0) {
451 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
452 X509V3_R_EXTENSION_VALUE_ERROR);
453 goto done;
454 }
455
456 /*
457 * Calculate a_max + 1 to check for adjacency.
458 */
459 if ((bn == NULL && (bn = BN_new()) == NULL) ||
460 ASN1_INTEGER_to_BN(a_max, bn) == NULL ||
461 !BN_add_word(bn, 1) ||
462 (a_max_plus_one = BN_to_ASN1_INTEGER(bn, a_max_plus_one)) == NULL) {
463 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE, ERR_R_MALLOC_FAILURE);
464 goto done;
465 }
466
467 /*
468 * If a and b are adjacent, merge them.
469 */
470 if (ASN1_INTEGER_cmp(a_max_plus_one, b_min) == 0) {
471 ASRange *r;
472 switch (a->type) {
473 case ASIdOrRange_id:
474 if ((r = OPENSSL_malloc(sizeof(ASRange))) == NULL) {
475 X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
476 ERR_R_MALLOC_FAILURE);
477 goto done;
478 }
479 r->min = a_min;
480 r->max = b_max;
481 a->type = ASIdOrRange_range;
482 a->u.range = r;
483 break;
484 case ASIdOrRange_range:
485 ASN1_INTEGER_free(a->u.range->max);
486 a->u.range->max = b_max;
487 break;
488 }
489 switch (b->type) {
490 case ASIdOrRange_id:
491 b->u.id = NULL;
492 break;
493 case ASIdOrRange_range:
494 b->u.range->max = NULL;
495 break;
496 }
497 ASIdOrRange_free(b);
498 (void) sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1);
499 i--;
500 continue;
501 }
502 }
503
504 /*
505 * Check for final inverted range.
506 */
507 i = sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1;
508 {
509 ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
510 ASN1_INTEGER *a_min, *a_max;
511 if (a != NULL && a->type == ASIdOrRange_range) {
512 extract_min_max(a, &a_min, &a_max);
513 if (ASN1_INTEGER_cmp(a_min, a_max) > 0)
514 goto done;
515 }
516 }
517
518 OPENSSL_assert(ASIdentifierChoice_is_canonical(choice)); /* Paranoia */
519
520 ret = 1;
521
522 done:
523 ASN1_INTEGER_free(a_max_plus_one);
524 BN_free(bn);
525 return ret;
526}
527
528/*
529 * Whack an ASIdentifier extension into canonical form.
530 */
531int v3_asid_canonize(ASIdentifiers *asid)
532{
533 return (asid == NULL ||
534 (ASIdentifierChoice_canonize(asid->asnum) &&
535 ASIdentifierChoice_canonize(asid->rdi)));
536}
537
538/*
539 * v2i method for an ASIdentifier extension.
540 */
541static void *v2i_ASIdentifiers(const struct v3_ext_method *method,
542 struct v3_ext_ctx *ctx,
543 STACK_OF(CONF_VALUE) *values)
544{
545 ASN1_INTEGER *min = NULL, *max = NULL;
546 ASIdentifiers *asid = NULL;
547 int i;
548
549 if ((asid = ASIdentifiers_new()) == NULL) {
550 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
551 return NULL;
552 }
553
554 for (i = 0; i < sk_CONF_VALUE_num(values); i++) {
555 CONF_VALUE *val = sk_CONF_VALUE_value(values, i);
556 int i1, i2, i3, is_range, which;
557
558 /*
559 * Figure out whether this is an AS or an RDI.
560 */
561 if ( !name_cmp(val->name, "AS")) {
562 which = V3_ASID_ASNUM;
563 } else if (!name_cmp(val->name, "RDI")) {
564 which = V3_ASID_RDI;
565 } else {
566 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, X509V3_R_EXTENSION_NAME_ERROR);
567 X509V3_conf_err(val);
568 goto err;
569 }
570
571 /*
572 * Handle inheritance.
573 */
574 if (!strcmp(val->value, "inherit")) {
575 if (v3_asid_add_inherit(asid, which))
576 continue;
577 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, X509V3_R_INVALID_INHERITANCE);
578 X509V3_conf_err(val);
579 goto err;
580 }
581
582 /*
583 * Number, range, or mistake, pick it apart and figure out which.
584 */
585 i1 = strspn(val->value, "0123456789");
586 if (val->value[i1] == '\0') {
587 is_range = 0;
588 } else {
589 is_range = 1;
590 i2 = i1 + strspn(val->value + i1, " \t");
591 if (val->value[i2] != '-') {
592 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, X509V3_R_INVALID_ASNUMBER);
593 X509V3_conf_err(val);
594 goto err;
595 }
596 i2++;
597 i2 = i2 + strspn(val->value + i2, " \t");
598 i3 = i2 + strspn(val->value + i2, "0123456789");
599 if (val->value[i3] != '\0') {
600 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, X509V3_R_INVALID_ASRANGE);
601 X509V3_conf_err(val);
602 goto err;
603 }
604 }
605
606 /*
607 * Syntax is ok, read and add it.
608 */
609 if (!is_range) {
610 if (!X509V3_get_value_int(val, &min)) {
611 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
612 goto err;
613 }
614 } else {
615 char *s = BUF_strdup(val->value);
616 if (s == NULL) {
617 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
618 goto err;
619 }
620 s[i1] = '\0';
621 min = s2i_ASN1_INTEGER(NULL, s);
622 max = s2i_ASN1_INTEGER(NULL, s + i2);
623 OPENSSL_free(s);
624 if (min == NULL || max == NULL) {
625 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
626 goto err;
627 }
628 if (ASN1_INTEGER_cmp(min, max) > 0) {
629 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, X509V3_R_EXTENSION_VALUE_ERROR);
630 goto err;
631 }
632 }
633 if (!v3_asid_add_id_or_range(asid, which, min, max)) {
634 X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
635 goto err;
636 }
637 min = max = NULL;
638 }
639
640 /*
641 * Canonize the result, then we're done.
642 */
643 if (!v3_asid_canonize(asid))
644 goto err;
645 return asid;
646
647 err:
648 ASIdentifiers_free(asid);
649 ASN1_INTEGER_free(min);
650 ASN1_INTEGER_free(max);
651 return NULL;
652}
653
654/*
655 * OpenSSL dispatch.
656 */
657const X509V3_EXT_METHOD v3_asid = {
658 NID_sbgp_autonomousSysNum, /* nid */
659 0, /* flags */
660 ASN1_ITEM_ref(ASIdentifiers), /* template */
661 0, 0, 0, 0, /* old functions, ignored */
662 0, /* i2s */
663 0, /* s2i */
664 0, /* i2v */
665 v2i_ASIdentifiers, /* v2i */
666 i2r_ASIdentifiers, /* i2r */
667 0, /* r2i */
668 NULL /* extension-specific data */
669};
670
671/*
672 * Figure out whether extension uses inheritance.
673 */
674int v3_asid_inherits(ASIdentifiers *asid)
675{
676 return (asid != NULL &&
677 ((asid->asnum != NULL &&
678 asid->asnum->type == ASIdentifierChoice_inherit) ||
679 (asid->rdi != NULL &&
680 asid->rdi->type == ASIdentifierChoice_inherit)));
681}
682
683/*
684 * Figure out whether parent contains child.
685 */
686static int asid_contains(ASIdOrRanges *parent, ASIdOrRanges *child)
687{
688 ASN1_INTEGER *p_min, *p_max, *c_min, *c_max;
689 int p, c;
690
691 if (child == NULL || parent == child)
692 return 1;
693 if (parent == NULL)
694 return 0;
695
696 p = 0;
697 for (c = 0; c < sk_ASIdOrRange_num(child); c++) {
698 extract_min_max(sk_ASIdOrRange_value(child, c), &c_min, &c_max);
699 for (;; p++) {
700 if (p >= sk_ASIdOrRange_num(parent))
701 return 0;
702 extract_min_max(sk_ASIdOrRange_value(parent, p), &p_min, &p_max);
703 if (ASN1_INTEGER_cmp(p_max, c_max) < 0)
704 continue;
705 if (ASN1_INTEGER_cmp(p_min, c_min) > 0)
706 return 0;
707 break;
708 }
709 }
710
711 return 1;
712}
713
714/*
715 * Test whether a is a subet of b.
716 */
717int v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b)
718{
719 return (a == NULL ||
720 a == b ||
721 (b != NULL &&
722 !v3_asid_inherits(a) &&
723 !v3_asid_inherits(b) &&
724 asid_contains(b->asnum->u.asIdsOrRanges,
725 a->asnum->u.asIdsOrRanges) &&
726 asid_contains(b->rdi->u.asIdsOrRanges,
727 a->rdi->u.asIdsOrRanges)));
728}
729
730/*
731 * Validation error handling via callback.
732 */
733#define validation_err(_err_) \
734 do { \
735 if (ctx != NULL) { \
736 ctx->error = _err_; \
737 ctx->error_depth = i; \
738 ctx->current_cert = x; \
739 ret = ctx->verify_cb(0, ctx); \
740 } else { \
741 ret = 0; \
742 } \
743 if (!ret) \
744 goto done; \
745 } while (0)
746
747/*
748 * Core code for RFC 3779 3.3 path validation.
749 */
750static int v3_asid_validate_path_internal(X509_STORE_CTX *ctx,
751 STACK_OF(X509) *chain,
752 ASIdentifiers *ext)
753{
754 ASIdOrRanges *child_as = NULL, *child_rdi = NULL;
755 int i, ret = 1, inherit_as = 0, inherit_rdi = 0;
756 X509 *x;
757
758 OPENSSL_assert(chain != NULL && sk_X509_num(chain) > 0);
759 OPENSSL_assert(ctx != NULL || ext != NULL);
760 OPENSSL_assert(ctx == NULL || ctx->verify_cb != NULL);
761
762 /*
763 * Figure out where to start. If we don't have an extension to
764 * check, we're done. Otherwise, check canonical form and
765 * set up for walking up the chain.
766 */
767 if (ext != NULL) {
768 i = -1;
769 x = NULL;
770 } else {
771 i = 0;
772 x = sk_X509_value(chain, i);
773 OPENSSL_assert(x != NULL);
774 if ((ext = x->rfc3779_asid) == NULL)
775 goto done;
776 }
777 if (!v3_asid_is_canonical(ext))
778 validation_err(X509_V_ERR_INVALID_EXTENSION);
779 if (ext->asnum != NULL) {
780 switch (ext->asnum->type) {
781 case ASIdentifierChoice_inherit:
782 inherit_as = 1;
783 break;
784 case ASIdentifierChoice_asIdsOrRanges:
785 child_as = ext->asnum->u.asIdsOrRanges;
786 break;
787 }
788 }
789 if (ext->rdi != NULL) {
790 switch (ext->rdi->type) {
791 case ASIdentifierChoice_inherit:
792 inherit_rdi = 1;
793 break;
794 case ASIdentifierChoice_asIdsOrRanges:
795 child_rdi = ext->rdi->u.asIdsOrRanges;
796 break;
797 }
798 }
799
800 /*
801 * Now walk up the chain. Extensions must be in canonical form, no
802 * cert may list resources that its parent doesn't list.
803 */
804 for (i++; i < sk_X509_num(chain); i++) {
805 x = sk_X509_value(chain, i);
806 OPENSSL_assert(x != NULL);
807 if (x->rfc3779_asid == NULL) {
808 if (child_as != NULL || child_rdi != NULL)
809 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
810 continue;
811 }
812 if (!v3_asid_is_canonical(x->rfc3779_asid))
813 validation_err(X509_V_ERR_INVALID_EXTENSION);
814 if (x->rfc3779_asid->asnum == NULL && child_as != NULL) {
815 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
816 child_as = NULL;
817 inherit_as = 0;
818 }
819 if (x->rfc3779_asid->asnum != NULL &&
820 x->rfc3779_asid->asnum->type == ASIdentifierChoice_asIdsOrRanges) {
821 if (inherit_as ||
822 asid_contains(x->rfc3779_asid->asnum->u.asIdsOrRanges, child_as)) {
823 child_as = x->rfc3779_asid->asnum->u.asIdsOrRanges;
824 inherit_as = 0;
825 } else {
826 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
827 }
828 }
829 if (x->rfc3779_asid->rdi == NULL && child_rdi != NULL) {
830 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
831 child_rdi = NULL;
832 inherit_rdi = 0;
833 }
834 if (x->rfc3779_asid->rdi != NULL &&
835 x->rfc3779_asid->rdi->type == ASIdentifierChoice_asIdsOrRanges) {
836 if (inherit_rdi ||
837 asid_contains(x->rfc3779_asid->rdi->u.asIdsOrRanges, child_rdi)) {
838 child_rdi = x->rfc3779_asid->rdi->u.asIdsOrRanges;
839 inherit_rdi = 0;
840 } else {
841 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
842 }
843 }
844 }
845
846 /*
847 * Trust anchor can't inherit.
848 */
849 OPENSSL_assert(x != NULL);
850 if (x->rfc3779_asid != NULL) {
851 if (x->rfc3779_asid->asnum != NULL &&
852 x->rfc3779_asid->asnum->type == ASIdentifierChoice_inherit)
853 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
854 if (x->rfc3779_asid->rdi != NULL &&
855 x->rfc3779_asid->rdi->type == ASIdentifierChoice_inherit)
856 validation_err(X509_V_ERR_UNNESTED_RESOURCE);
857 }
858
859 done:
860 return ret;
861}
862
863#undef validation_err
864
865/*
866 * RFC 3779 3.3 path validation -- called from X509_verify_cert().
867 */
868int v3_asid_validate_path(X509_STORE_CTX *ctx)
869{
870 return v3_asid_validate_path_internal(ctx, ctx->chain, NULL);
871}
872
873/*
874 * RFC 3779 3.3 path validation of an extension.
875 * Test whether chain covers extension.
876 */
877int v3_asid_validate_resource_set(STACK_OF(X509) *chain,
878 ASIdentifiers *ext,
879 int allow_inheritance)
880{
881 if (ext == NULL)
882 return 1;
883 if (chain == NULL || sk_X509_num(chain) == 0)
884 return 0;
885 if (!allow_inheritance && v3_asid_inherits(ext))
886 return 0;
887 return v3_asid_validate_path_internal(NULL, chain, ext);
888}
889
890#endif /* OPENSSL_NO_RFC3779 */