"Fossies" - the Fresh Open Source Software Archive

Member "vpnc-0.5.3/math_group.h" (19 Nov 2008, 2820 Bytes) of package /linux/privat/old/vpnc-0.5.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "math_group.h" see the Fossies "Dox" file reference documentation.

    1 /* borrowed from isakmpd-20030718 (-; */
    2 
    3 /*  $OpenBSD: math_group.h,v 1.7 2003/06/03 14:28:16 ho Exp $   */
    4 /*  $EOM: math_group.h,v 1.7 1999/04/17 23:20:40 niklas Exp $   */
    5 
    6 /*
    7  * Copyright (c) 1998 Niels Provos.  All rights reserved.
    8  * Copyright (c) 1999 Niklas Hallqvist.  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  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   29  */
   30 
   31 /*
   32  * This code was written under funding by Ericsson Radio Systems.
   33  */
   34 
   35 #ifndef __MATH_GROUP_H__
   36 #define __MATH_GROUP_H__
   37 
   38 #include <gcrypt.h>
   39 
   40 enum groups {
   41     MODP  /* F_p, Z modulo a prime */
   42 };
   43 
   44 #define OAKLEY_GRP_1    1
   45 #define OAKLEY_GRP_2    2
   46 #define OAKLEY_GRP_5    3
   47 
   48 /*
   49  * The group on which diffie hellmann calculations are done.
   50  */
   51 
   52 /* Description of F_p for Boot-Strapping */
   53 
   54 struct modp_dscr {
   55     int id;
   56     int bits; /* Key Bits provided by this group */
   57     const char *prime; /* Prime */
   58     const char *gen; /* Generator */
   59 };
   60 
   61 struct modp_group {
   62     gcry_mpi_t gen; /* Generator */
   63     gcry_mpi_t p; /* Prime */
   64     gcry_mpi_t a, b, c, d;
   65 };
   66 
   67 struct group {
   68     enum groups type;
   69     int id; /* Group ID */
   70     int bits; /* Number of key bits provided by this group */
   71     struct modp_group *group;
   72     const struct modp_dscr *group_dscr;
   73     void *a, *b, *c, *d;
   74     void *gen; /* Group Generator */
   75     int (*getlen) (struct group *);
   76     void (*getraw) (struct group *, void *, unsigned char *);
   77     int (*setraw) (struct group *, void *, unsigned char *, int);
   78     int (*setrandom) (struct group *, void *);
   79     int (*operation) (struct group *, void *, void *, void *);
   80 };
   81 
   82 /* Prototypes */
   83 
   84 void group_init(void);
   85 void group_free(struct group *);
   86 struct group *group_get(int);
   87 
   88 #endif /* _MATH_GROUP_H_ */