Eneboo - Documentación para desarrolladores
src/libdigidoc/openssl/crypto/jpake/jpake.h
Ir a la documentación de este archivo.
00001 /*
00002  * Implement J-PAKE, as described in
00003  * http://grouper.ieee.org/groups/1363/Research/contributions/hao-ryan-2008.pdf
00004  * 
00005  * With hints from http://www.cl.cam.ac.uk/~fh240/software/JPAKE2.java.
00006  */
00007 
00008 #ifndef HEADER_JPAKE_H
00009 #define HEADER_JPAKE_H
00010 
00011 #include <openssl/opensslconf.h>
00012 
00013 #ifdef OPENSSL_NO_JPAKE
00014 #error JPAKE is disabled.
00015 #endif
00016 
00017 #ifdef  __cplusplus
00018 extern "C" {
00019 #endif
00020 
00021 #include <openssl/bn.h>
00022 #include <openssl/sha.h>
00023 
00024 typedef struct JPAKE_CTX JPAKE_CTX;
00025 
00026 /* Note that "g" in the ZKPs is not necessarily the J-PAKE g. */
00027 typedef struct
00028     {
00029     BIGNUM *gr; /* g^r (r random) */
00030     BIGNUM *b;  /* b = r - x*h, h=hash(g, g^r, g^x, name) */
00031     } JPAKE_ZKP;
00032 
00033 typedef struct
00034     {
00035     BIGNUM *gx;       /* g^x in step 1, g^(xa + xc + xd) * xb * s in step 2 */
00036     JPAKE_ZKP zkpx;   /* ZKP(x) or ZKP(xb * s) */
00037     } JPAKE_STEP_PART;
00038 
00039 typedef struct
00040     {
00041     JPAKE_STEP_PART p1;   /* g^x3, ZKP(x3) or g^x1, ZKP(x1) */
00042     JPAKE_STEP_PART p2;   /* g^x4, ZKP(x4) or g^x2, ZKP(x2) */
00043     } JPAKE_STEP1;
00044 
00045 typedef JPAKE_STEP_PART JPAKE_STEP2;
00046 
00047 typedef struct
00048     {
00049     unsigned char hhk[SHA_DIGEST_LENGTH];
00050     } JPAKE_STEP3A;
00051 
00052 typedef struct
00053     {
00054     unsigned char hk[SHA_DIGEST_LENGTH];
00055     } JPAKE_STEP3B;
00056 
00057 /* Parameters are copied */
00058 JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name,
00059                          const BIGNUM *p, const BIGNUM *g, const BIGNUM *q,
00060                          const BIGNUM *secret);
00061 void JPAKE_CTX_free(JPAKE_CTX *ctx);
00062 
00063 /*
00064  * Note that JPAKE_STEP1 can be used multiple times before release
00065  * without another init.
00066  */
00067 void JPAKE_STEP1_init(JPAKE_STEP1 *s1);
00068 int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx);
00069 int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received);
00070 void JPAKE_STEP1_release(JPAKE_STEP1 *s1);
00071 
00072 /*
00073  * Note that JPAKE_STEP2 can be used multiple times before release
00074  * without another init.
00075  */
00076 void JPAKE_STEP2_init(JPAKE_STEP2 *s2);
00077 int JPAKE_STEP2_generate(JPAKE_STEP2 *send, JPAKE_CTX *ctx);
00078 int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received);
00079 void JPAKE_STEP2_release(JPAKE_STEP2 *s2);
00080 
00081 /*
00082  * Optionally verify the shared key. If the shared secrets do not
00083  * match, the two ends will disagree about the shared key, but
00084  * otherwise the protocol will succeed.
00085  */
00086 void JPAKE_STEP3A_init(JPAKE_STEP3A *s3a);
00087 int JPAKE_STEP3A_generate(JPAKE_STEP3A *send, JPAKE_CTX *ctx);
00088 int JPAKE_STEP3A_process(JPAKE_CTX *ctx, const JPAKE_STEP3A *received);
00089 void JPAKE_STEP3A_release(JPAKE_STEP3A *s3a);
00090 
00091 void JPAKE_STEP3B_init(JPAKE_STEP3B *s3b);
00092 int JPAKE_STEP3B_generate(JPAKE_STEP3B *send, JPAKE_CTX *ctx);
00093 int JPAKE_STEP3B_process(JPAKE_CTX *ctx, const JPAKE_STEP3B *received);
00094 void JPAKE_STEP3B_release(JPAKE_STEP3B *s3b);
00095 
00096 /*
00097  * the return value belongs to the library and will be released when
00098  * ctx is released, and will change when a new handshake is performed.
00099  */
00100 const BIGNUM *JPAKE_get_shared_key(JPAKE_CTX *ctx);
00101 
00102 /* BEGIN ERROR CODES */
00103 /* The following lines are auto generated by the script mkerr.pl. Any changes
00104  * made after this point may be overwritten when the script is next run.
00105  */
00106 void ERR_load_JPAKE_strings(void);
00107 
00108 /* Error codes for the JPAKE functions. */
00109 
00110 /* Function codes. */
00111 #define JPAKE_F_JPAKE_STEP1_PROCESS                      101
00112 #define JPAKE_F_JPAKE_STEP2_PROCESS                      102
00113 #define JPAKE_F_JPAKE_STEP3A_PROCESS                     103
00114 #define JPAKE_F_JPAKE_STEP3B_PROCESS                     104
00115 #define JPAKE_F_VERIFY_ZKP                               100
00116 
00117 /* Reason codes. */
00118 #define JPAKE_R_G_TO_THE_X4_IS_ONE                       105
00119 #define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH             106
00120 #define JPAKE_R_HASH_OF_KEY_MISMATCH                     107
00121 #define JPAKE_R_VERIFY_B_FAILED                          102
00122 #define JPAKE_R_VERIFY_X3_FAILED                         103
00123 #define JPAKE_R_VERIFY_X4_FAILED                         104
00124 #define JPAKE_R_ZKP_VERIFY_FAILED                        100
00125 
00126 #ifdef  __cplusplus
00127 }
00128 #endif
00129 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'