s3:include: change smb_request->vuid to uint64_t
[Samba/gebeck_regimport.git] / source4 / heimdal / lib / hcrypto / dh.h
blob637f218bcf8222cae503a97d16398d9d2c94b02e
1 /*
2 * Copyright (c) 2006 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
35 * $Id$
38 #ifndef _HEIM_DH_H
39 #define _HEIM_DH_H 1
41 /* symbol renaming */
42 #define DH_null_method hc_DH_null_method
43 #define DH_tfm_method hc_DH_tfm_method
44 #define DH_ltm_method hc_DH_ltm_method
45 #define DH_new hc_DH_new
46 #define DH_new_method hc_DH_new_method
47 #define DH_free hc_DH_free
48 #define DH_up_ref hc_DH_up_ref
49 #define DH_size hc_DH_size
50 #define DH_set_default_method hc_DH_set_default_method
51 #define DH_get_default_method hc_DH_get_default_method
52 #define DH_set_method hc_DH_set_method
53 #define DH_get_method hc_DH_get_method
54 #define DH_set_ex_data hc_DH_set_ex_data
55 #define DH_get_ex_data hc_DH_get_ex_data
56 #define DH_generate_parameters_ex hc_DH_generate_parameters_ex
57 #define DH_check_pubkey hc_DH_check_pubkey
58 #define DH_generate_key hc_DH_generate_key
59 #define DH_compute_key hc_DH_compute_key
60 #define i2d_DHparams hc_i2d_DHparams
66 typedef struct DH DH;
67 typedef struct DH_METHOD DH_METHOD;
69 #include <hcrypto/bn.h>
70 #include <hcrypto/engine.h>
72 struct DH_METHOD {
73 const char *name;
74 int (*generate_key)(DH *);
75 int (*compute_key)(unsigned char *,const BIGNUM *,DH *);
76 int (*bn_mod_exp)(const DH *, BIGNUM *, const BIGNUM *,
77 const BIGNUM *, const BIGNUM *, BN_CTX *,
78 BN_MONT_CTX *);
79 int (*init)(DH *);
80 int (*finish)(DH *);
81 int flags;
82 void *app_data;
83 int (*generate_params)(DH *, int, int, BN_GENCB *);
86 struct DH {
87 int pad;
88 int version;
89 BIGNUM *p;
90 BIGNUM *g;
91 long length;
92 BIGNUM *pub_key;
93 BIGNUM *priv_key;
94 int flags;
95 void *method_mont_p;
96 BIGNUM *q;
97 BIGNUM *j;
98 void *seed;
99 int seedlen;
100 BIGNUM *counter;
101 int references;
102 struct CRYPTO_EX_DATA {
103 void *sk;
104 int dummy;
105 } ex_data;
106 const DH_METHOD *meth;
107 ENGINE *engine;
110 /* DH_check_pubkey return codes in `codes' argument. */
111 #define DH_CHECK_PUBKEY_TOO_SMALL 1
112 #define DH_CHECK_PUBKEY_TOO_LARGE 2
118 const DH_METHOD *DH_null_method(void);
119 const DH_METHOD *DH_tfm_method(void);
120 const DH_METHOD *DH_ltm_method(void);
122 DH * DH_new(void);
123 DH * DH_new_method(ENGINE *);
124 void DH_free(DH *);
125 int DH_up_ref(DH *);
127 int DH_size(const DH *);
130 void DH_set_default_method(const DH_METHOD *);
131 const DH_METHOD *
132 DH_get_default_method(void);
133 int DH_set_method(DH *, const DH_METHOD *);
135 int DH_set_ex_data(DH *, int, void *);
136 void * DH_get_ex_data(DH *, int);
138 int DH_generate_parameters_ex(DH *, int, int, BN_GENCB *);
139 int DH_check_pubkey(const DH *, const BIGNUM *, int *);
140 int DH_generate_key(DH *);
141 int DH_compute_key(unsigned char *,const BIGNUM *,DH *);
143 int i2d_DHparams(DH *, unsigned char **);
145 #endif /* _HEIM_DH_H */