GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / include / bcmcrypto / dh.h
blob6004b8da974a559e686e46289c8e886c4538c44d
1 /*
2 * dh.h: Diffie-Hellman header file.
4 * Code copied from openssl distribution and
5 * Modified just enough so that compiles and runs standalone
7 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
8 *
9 * Permission to use, copy, modify, and/or distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
16 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
18 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
19 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 * $Id: dh.h 241182 2011-02-17 21:50:03Z $
23 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
24 * All rights reserved.
26 * This package is an SSL implementation written
27 * by Eric Young (eay@cryptsoft.com).
28 * The implementation was written so as to conform with Netscapes SSL.
30 * This library is free for commercial and non-commercial use as long as
31 * the following conditions are aheared to. The following conditions
32 * apply to all code found in this distribution, be it the RC4, RSA,
33 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
34 * included with this distribution is covered by the same copyright terms
35 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
37 * Copyright remains Eric Young's, and as such any Copyright notices in
38 * the code are not to be removed.
39 * If this package is used in a product, Eric Young should be given attribution
40 * as the author of the parts of the library used.
41 * This can be in the form of a textual message at program startup or
42 * in documentation (online or textual) provided with the package.
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
46 * are met:
47 * 1. Redistributions of source code must retain the copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * "This product includes cryptographic software written by
55 * Eric Young (eay@cryptsoft.com)"
56 * The word 'cryptographic' can be left out if the rouines from the library
57 * being used are not cryptographic related :-).
58 * 4. If you include any Windows specific code (or a derivative thereof) from
59 * the apps directory (application code) you must include an acknowledgement:
60 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
62 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
63 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
66 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * SUCH DAMAGE.
74 * The licence and distribution terms for any publically available version or
75 * derivative of this code cannot be changed. i.e. this code cannot simply be
76 * copied and put under another distribution licence
77 * [including the GNU Public Licence.]
80 #ifndef HEADER_DH_H
81 #define HEADER_DH_H
83 #include <bcmcrypto/bn.h>
85 #define DH_FLAG_CACHE_MONT_P 0x01
87 typedef struct dh_st
89 BIGNUM *p;
90 BIGNUM *g;
91 long length; /* optional */
92 BIGNUM *pub_key; /* g^x */
93 BIGNUM *priv_key; /* x */
95 int flags;
96 BN_MONT_CTX *method_mont_p;
97 /* Place holders if we want to do X9.42 DH */
98 BIGNUM *q;
99 BIGNUM *j;
100 unsigned char *seed;
101 int seedlen;
102 BIGNUM *counter;
103 } DH;
105 #define DH_GENERATOR_2 2
106 /* #define DH_GENERATOR_3 3 */
107 #define DH_GENERATOR_5 5
109 /* DH_check error codes */
110 #define DH_CHECK_P_NOT_PRIME 0x01
111 #define DH_CHECK_P_NOT_SAFE_PRIME 0x02
112 #define DH_UNABLE_TO_CHECK_GENERATOR 0x04
113 #define DH_NOT_SUITABLE_GENERATOR 0x08
115 /* primes p where (p-1)/2 is prime too are called "safe"; we define
116 * this for backward compatibility:
118 #define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME
121 DH * DH_new(void);
122 void DH_free(DH *dh);
123 int DH_generate_key(unsigned char *key, DH *dh);
124 int DH_compute_key(unsigned char *key, unsigned char *pubbuf, int buflen, DH *dh);
125 int DH_compute_key_bn(unsigned char *key, BIGNUM *peer_key, DH *dh);
126 DH *DH_init(unsigned char *pbuf, int plen, int g);
128 /* for standalone test purposes */
129 int DH_size(const DH *dh);
130 DH * DH_generate_parameters(DH *dh, int prime_len, int generator,
131 void (*callback)(int, int, void *), void *cb_arg);
132 int DH_check(const DH *dh, int *codes);
134 #endif /* HEADER_DH_H */