diff options
author | cvs2svn <admin@example.com> | 2014-04-15 18:01:19 +0000 |
---|---|---|
committer | cvs2svn <admin@example.com> | 2014-04-15 18:01:19 +0000 |
commit | 4b19b8991c2eb7c783fd93feac5ba804bf2a7221 (patch) | |
tree | 523a79fb780e63096ecf79af2283834ab6750ca4 /src/lib/libcrypto/srp | |
parent | f385533fd495dad9242f2eded4a9017f658ee678 (diff) | |
download | openbsd-openssl_1_0_1g.tar.gz openbsd-openssl_1_0_1g.tar.bz2 openbsd-openssl_1_0_1g.zip |
This commit was manufactured by cvs2git to create tag 'openssl_1_0_1g'.openssl_1_0_1g
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/srp/Makefile | 98 | ||||
-rw-r--r-- | src/lib/libcrypto/srp/srp.h | 172 | ||||
-rw-r--r-- | src/lib/libcrypto/srp/srp_grps.h | 517 | ||||
-rw-r--r-- | src/lib/libcrypto/srp/srp_lcl.h | 83 | ||||
-rw-r--r-- | src/lib/libcrypto/srp/srp_lib.c | 361 | ||||
-rw-r--r-- | src/lib/libcrypto/srp/srp_vfy.c | 658 | ||||
-rw-r--r-- | src/lib/libcrypto/srp/srptest.c | 162 |
7 files changed, 0 insertions, 2051 deletions
diff --git a/src/lib/libcrypto/srp/Makefile b/src/lib/libcrypto/srp/Makefile deleted file mode 100644 index 41859d46fa..0000000000 --- a/src/lib/libcrypto/srp/Makefile +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | DIR= srp | ||
2 | TOP= ../.. | ||
3 | CC= cc | ||
4 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
5 | CFLAG=-g | ||
6 | INSTALL_PREFIX= | ||
7 | OPENSSLDIR= /usr/local/ssl | ||
8 | INSTALLTOP=/usr/local/ssl | ||
9 | MAKE= make -f Makefile.ssl | ||
10 | MAKEDEPPROG= makedepend | ||
11 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
12 | MAKEFILE= Makefile.ssl | ||
13 | AR= ar r | ||
14 | |||
15 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
16 | |||
17 | GENERAL=Makefile | ||
18 | TEST=srptest.c | ||
19 | APPS= | ||
20 | |||
21 | LIB=$(TOP)/libcrypto.a | ||
22 | LIBSRC=srp_lib.c srp_vfy.c | ||
23 | LIBOBJ=srp_lib.o srp_vfy.o | ||
24 | |||
25 | SRC= $(LIBSRC) | ||
26 | |||
27 | EXHEADER= srp.h | ||
28 | HEADER= $(EXHEADER) | ||
29 | |||
30 | top: | ||
31 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
32 | |||
33 | all: lib | ||
34 | |||
35 | lib: $(LIBOBJ) | ||
36 | $(AR) $(LIB) $(LIBOBJ) | ||
37 | $(RANLIB) $(LIB) || echo Never mind. | ||
38 | @touch lib | ||
39 | |||
40 | links: | ||
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 | |||
45 | install: | ||
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 | |||
53 | tags: | ||
54 | ctags $(SRC) | ||
55 | |||
56 | tests: | ||
57 | |||
58 | srptest: top srptest.c $(LIB) | ||
59 | $(CC) $(CFLAGS) -Wall -Werror -g -o srptest srptest.c $(LIB) | ||
60 | |||
61 | lint: | ||
62 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
63 | |||
64 | depend: | ||
65 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
66 | |||
67 | dclean: | ||
68 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
69 | mv -f Makefile.new $(MAKEFILE) | ||
70 | |||
71 | clean: | ||
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 | |||
76 | srp_lib.o: ../../e_os.h ../../include/openssl/asn1.h | ||
77 | srp_lib.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
78 | srp_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
79 | srp_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
80 | srp_lib.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
81 | srp_lib.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
82 | srp_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
83 | srp_lib.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h | ||
84 | srp_lib.o: ../../include/openssl/sha.h ../../include/openssl/srp.h | ||
85 | srp_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
86 | srp_lib.o: ../cryptlib.h srp_grps.h srp_lcl.h srp_lib.c | ||
87 | srp_vfy.o: ../../e_os.h ../../include/openssl/asn1.h | ||
88 | srp_vfy.o: ../../include/openssl/bio.h ../../include/openssl/bn.h | ||
89 | srp_vfy.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
90 | srp_vfy.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
91 | srp_vfy.o: ../../include/openssl/evp.h ../../include/openssl/lhash.h | ||
92 | srp_vfy.o: ../../include/openssl/obj_mac.h ../../include/openssl/objects.h | ||
93 | srp_vfy.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
94 | srp_vfy.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h | ||
95 | srp_vfy.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
96 | srp_vfy.o: ../../include/openssl/srp.h ../../include/openssl/stack.h | ||
97 | srp_vfy.o: ../../include/openssl/symhacks.h ../../include/openssl/txt_db.h | ||
98 | srp_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 deleted file mode 100644 index 7ec7825cad..0000000000 --- a/src/lib/libcrypto/srp/srp.h +++ /dev/null | |||
@@ -1,172 +0,0 @@ | |||
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 | ||
68 | extern "C" { | ||
69 | #endif | ||
70 | |||
71 | #include <openssl/safestack.h> | ||
72 | #include <openssl/bn.h> | ||
73 | #include <openssl/crypto.h> | ||
74 | |||
75 | typedef struct SRP_gN_cache_st | ||
76 | { | ||
77 | char *b64_bn; | ||
78 | BIGNUM *bn; | ||
79 | } SRP_gN_cache; | ||
80 | |||
81 | |||
82 | DECLARE_STACK_OF(SRP_gN_cache) | ||
83 | |||
84 | typedef 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 | |||
94 | DECLARE_STACK_OF(SRP_user_pwd) | ||
95 | |||
96 | typedef 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*/ | ||
108 | typedef struct SRP_gN_st | ||
109 | { | ||
110 | char *id; | ||
111 | BIGNUM *g; | ||
112 | BIGNUM *N; | ||
113 | } SRP_gN; | ||
114 | |||
115 | DECLARE_STACK_OF(SRP_gN) | ||
116 | |||
117 | SRP_VBASE *SRP_VBASE_new(char *seed_key); | ||
118 | int SRP_VBASE_free(SRP_VBASE *vb); | ||
119 | int SRP_VBASE_init(SRP_VBASE *vb, char * verifier_file); | ||
120 | SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username); | ||
121 | char *SRP_create_verifier(const char *user, const char *pass, char **salt, | ||
122 | char **verifier, const char *N, const char *g); | ||
123 | int 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 */ | ||
148 | char * SRP_check_known_gN_param(BIGNUM* g, BIGNUM* N); | ||
149 | SRP_gN *SRP_get_default_gN(const char * id) ; | ||
150 | |||
151 | /* server side .... */ | ||
152 | BIGNUM *SRP_Calc_server_key(BIGNUM *A, BIGNUM *v, BIGNUM *u, BIGNUM *b, BIGNUM *N); | ||
153 | BIGNUM *SRP_Calc_B(BIGNUM *b, BIGNUM *N, BIGNUM *g, BIGNUM *v); | ||
154 | int SRP_Verify_A_mod_N(BIGNUM *A, BIGNUM *N); | ||
155 | BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N) ; | ||
156 | |||
157 | |||
158 | |||
159 | /* client side .... */ | ||
160 | BIGNUM *SRP_Calc_x(BIGNUM *s, const char *user, const char *pass); | ||
161 | BIGNUM *SRP_Calc_A(BIGNUM *a, BIGNUM *N, BIGNUM *g); | ||
162 | BIGNUM *SRP_Calc_client_key(BIGNUM *N, BIGNUM *B, BIGNUM *g, BIGNUM *x, BIGNUM *a, BIGNUM *u); | ||
163 | int 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 deleted file mode 100644 index 8e3c35e3f5..0000000000 --- a/src/lib/libcrypto/srp/srp_grps.h +++ /dev/null | |||
@@ -1,517 +0,0 @@ | |||
1 | /* start of generated data */ | ||
2 | |||
3 | static 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 | }; | ||
21 | static 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 | |||
29 | static 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 | }; | ||
55 | static 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 | |||
63 | static 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 | }; | ||
97 | static 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 | |||
105 | static 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 | }; | ||
155 | static 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 | |||
163 | static 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 | }; | ||
229 | static 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 | |||
237 | static 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 | }; | ||
335 | static 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 | |||
343 | static 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 | }; | ||
473 | static 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 | |||
481 | static BN_ULONG bn_generator_19_value[] = {19} ; | ||
482 | static BIGNUM bn_generator_19 = { | ||
483 | bn_generator_19_value, | ||
484 | 1, | ||
485 | 1, | ||
486 | 0, | ||
487 | BN_FLG_STATIC_DATA | ||
488 | }; | ||
489 | static BN_ULONG bn_generator_5_value[] = {5} ; | ||
490 | static BIGNUM bn_generator_5 = { | ||
491 | bn_generator_5_value, | ||
492 | 1, | ||
493 | 1, | ||
494 | 0, | ||
495 | BN_FLG_STATIC_DATA | ||
496 | }; | ||
497 | static BN_ULONG bn_generator_2_value[] = {2} ; | ||
498 | static BIGNUM bn_generator_2 = { | ||
499 | bn_generator_2_value, | ||
500 | 1, | ||
501 | 1, | ||
502 | 0, | ||
503 | BN_FLG_STATIC_DATA | ||
504 | }; | ||
505 | |||
506 | static 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 deleted file mode 100644 index 42bda3f148..0000000000 --- a/src/lib/libcrypto/srp/srp_lcl.h +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
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 | ||
74 | extern "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 deleted file mode 100644 index 7c1dcc5111..0000000000 --- a/src/lib/libcrypto/srp/srp_lib.c +++ /dev/null | |||
@@ -1,361 +0,0 @@ | |||
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 | |||
82 | static 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 | |||
112 | BIGNUM *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 | |||
147 | BIGNUM *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; | ||
168 | err: | ||
169 | BN_CTX_free(bn_ctx); | ||
170 | BN_clear_free(tmp); | ||
171 | return S; | ||
172 | } | ||
173 | |||
174 | BIGNUM *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 | } | ||
199 | err: | ||
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 | |||
207 | BIGNUM *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 | |||
239 | BIGNUM *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 | |||
259 | BIGNUM *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 | |||
290 | err : | ||
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 | |||
299 | int 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); | ||
315 | err: | ||
316 | BN_CTX_free(bn_ctx); | ||
317 | BN_free(r); | ||
318 | return ret; | ||
319 | } | ||
320 | |||
321 | int 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 | */ | ||
331 | char *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 | |||
348 | SRP_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 deleted file mode 100644 index 4a3d13edf6..0000000000 --- a/src/lib/libcrypto/srp/srp_vfy.c +++ /dev/null | |||
@@ -1,658 +0,0 @@ | |||
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 | |||
71 | static 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 | */ | ||
79 | static 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 | */ | ||
126 | static 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 | |||
182 | static 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 | |||
193 | static 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 | |||
207 | static 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 | |||
214 | static 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 | |||
222 | static 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 | |||
237 | static 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 | |||
244 | SRP_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 | |||
271 | int 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 | |||
281 | static 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); | ||
298 | err: | ||
299 | OPENSSL_free(newgN); | ||
300 | return NULL; | ||
301 | } | ||
302 | |||
303 | |||
304 | static 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 | |||
313 | static 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 | |||
329 | static 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 | |||
360 | int 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 | |||
475 | SRP_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 | |||
516 | err: 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 | */ | ||
524 | char *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 | |||
596 | err: | ||
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 | */ | ||
608 | int 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 | |||
649 | err: | ||
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 deleted file mode 100644 index 04b66b4544..0000000000 --- a/src/lib/libcrypto/srp/srptest.c +++ /dev/null | |||
@@ -1,162 +0,0 @@ | |||
1 | #include <openssl/opensslconf.h> | ||
2 | #ifdef OPENSSL_NO_SRP | ||
3 | |||
4 | #include <stdio.h> | ||
5 | |||
6 | int 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 | |||
18 | static 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 | |||
28 | static 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 | |||
130 | int 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 | ||