From 5fc5d37330d3535a0f421632694d1e7918fc22d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 8 Apr 2014 11:38:09 +0200 Subject: Compiles correctly: app/build-native + gradle. --- app/openssl/crypto/jpake/jpake.h | 131 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 app/openssl/crypto/jpake/jpake.h (limited to 'app/openssl/crypto/jpake/jpake.h') diff --git a/app/openssl/crypto/jpake/jpake.h b/app/openssl/crypto/jpake/jpake.h new file mode 100644 index 00000000..fd143b4d --- /dev/null +++ b/app/openssl/crypto/jpake/jpake.h @@ -0,0 +1,131 @@ +/* + * Implement J-PAKE, as described in + * http://grouper.ieee.org/groups/1363/Research/contributions/hao-ryan-2008.pdf + * + * With hints from http://www.cl.cam.ac.uk/~fh240/software/JPAKE2.java. + */ + +#ifndef HEADER_JPAKE_H +#define HEADER_JPAKE_H + +#include + +#ifdef OPENSSL_NO_JPAKE +#error JPAKE is disabled. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef struct JPAKE_CTX JPAKE_CTX; + +/* Note that "g" in the ZKPs is not necessarily the J-PAKE g. */ +typedef struct + { + BIGNUM *gr; /* g^r (r random) */ + BIGNUM *b; /* b = r - x*h, h=hash(g, g^r, g^x, name) */ + } JPAKE_ZKP; + +typedef struct + { + BIGNUM *gx; /* g^x in step 1, g^(xa + xc + xd) * xb * s in step 2 */ + JPAKE_ZKP zkpx; /* ZKP(x) or ZKP(xb * s) */ + } JPAKE_STEP_PART; + +typedef struct + { + JPAKE_STEP_PART p1; /* g^x3, ZKP(x3) or g^x1, ZKP(x1) */ + JPAKE_STEP_PART p2; /* g^x4, ZKP(x4) or g^x2, ZKP(x2) */ + } JPAKE_STEP1; + +typedef JPAKE_STEP_PART JPAKE_STEP2; + +typedef struct + { + unsigned char hhk[SHA_DIGEST_LENGTH]; + } JPAKE_STEP3A; + +typedef struct + { + unsigned char hk[SHA_DIGEST_LENGTH]; + } JPAKE_STEP3B; + +/* Parameters are copied */ +JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name, + const BIGNUM *p, const BIGNUM *g, const BIGNUM *q, + const BIGNUM *secret); +void JPAKE_CTX_free(JPAKE_CTX *ctx); + +/* + * Note that JPAKE_STEP1 can be used multiple times before release + * without another init. + */ +void JPAKE_STEP1_init(JPAKE_STEP1 *s1); +int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx); +int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received); +void JPAKE_STEP1_release(JPAKE_STEP1 *s1); + +/* + * Note that JPAKE_STEP2 can be used multiple times before release + * without another init. + */ +void JPAKE_STEP2_init(JPAKE_STEP2 *s2); +int JPAKE_STEP2_generate(JPAKE_STEP2 *send, JPAKE_CTX *ctx); +int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received); +void JPAKE_STEP2_release(JPAKE_STEP2 *s2); + +/* + * Optionally verify the shared key. If the shared secrets do not + * match, the two ends will disagree about the shared key, but + * otherwise the protocol will succeed. + */ +void JPAKE_STEP3A_init(JPAKE_STEP3A *s3a); +int JPAKE_STEP3A_generate(JPAKE_STEP3A *send, JPAKE_CTX *ctx); +int JPAKE_STEP3A_process(JPAKE_CTX *ctx, const JPAKE_STEP3A *received); +void JPAKE_STEP3A_release(JPAKE_STEP3A *s3a); + +void JPAKE_STEP3B_init(JPAKE_STEP3B *s3b); +int JPAKE_STEP3B_generate(JPAKE_STEP3B *send, JPAKE_CTX *ctx); +int JPAKE_STEP3B_process(JPAKE_CTX *ctx, const JPAKE_STEP3B *received); +void JPAKE_STEP3B_release(JPAKE_STEP3B *s3b); + +/* + * the return value belongs to the library and will be released when + * ctx is released, and will change when a new handshake is performed. + */ +const BIGNUM *JPAKE_get_shared_key(JPAKE_CTX *ctx); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_JPAKE_strings(void); + +/* Error codes for the JPAKE functions. */ + +/* Function codes. */ +#define JPAKE_F_JPAKE_STEP1_PROCESS 101 +#define JPAKE_F_JPAKE_STEP2_PROCESS 102 +#define JPAKE_F_JPAKE_STEP3A_PROCESS 103 +#define JPAKE_F_JPAKE_STEP3B_PROCESS 104 +#define JPAKE_F_VERIFY_ZKP 100 + +/* Reason codes. */ +#define JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL 108 +#define JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL 109 +#define JPAKE_R_G_TO_THE_X4_IS_ONE 105 +#define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH 106 +#define JPAKE_R_HASH_OF_KEY_MISMATCH 107 +#define JPAKE_R_VERIFY_B_FAILED 102 +#define JPAKE_R_VERIFY_X3_FAILED 103 +#define JPAKE_R_VERIFY_X4_FAILED 104 +#define JPAKE_R_ZKP_VERIFY_FAILED 100 + +#ifdef __cplusplus +} +#endif +#endif -- cgit v1.2.3 From 3c3421afd8f74a3aa8d1011de07a8c18f9549210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 8 Apr 2014 12:04:17 +0200 Subject: Rename app->bitmask_android This way, gradle commands generate apks correctly named. --- app/openssl/crypto/jpake/jpake.h | 131 --------------------------------------- 1 file changed, 131 deletions(-) delete mode 100644 app/openssl/crypto/jpake/jpake.h (limited to 'app/openssl/crypto/jpake/jpake.h') diff --git a/app/openssl/crypto/jpake/jpake.h b/app/openssl/crypto/jpake/jpake.h deleted file mode 100644 index fd143b4d..00000000 --- a/app/openssl/crypto/jpake/jpake.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Implement J-PAKE, as described in - * http://grouper.ieee.org/groups/1363/Research/contributions/hao-ryan-2008.pdf - * - * With hints from http://www.cl.cam.ac.uk/~fh240/software/JPAKE2.java. - */ - -#ifndef HEADER_JPAKE_H -#define HEADER_JPAKE_H - -#include - -#ifdef OPENSSL_NO_JPAKE -#error JPAKE is disabled. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -typedef struct JPAKE_CTX JPAKE_CTX; - -/* Note that "g" in the ZKPs is not necessarily the J-PAKE g. */ -typedef struct - { - BIGNUM *gr; /* g^r (r random) */ - BIGNUM *b; /* b = r - x*h, h=hash(g, g^r, g^x, name) */ - } JPAKE_ZKP; - -typedef struct - { - BIGNUM *gx; /* g^x in step 1, g^(xa + xc + xd) * xb * s in step 2 */ - JPAKE_ZKP zkpx; /* ZKP(x) or ZKP(xb * s) */ - } JPAKE_STEP_PART; - -typedef struct - { - JPAKE_STEP_PART p1; /* g^x3, ZKP(x3) or g^x1, ZKP(x1) */ - JPAKE_STEP_PART p2; /* g^x4, ZKP(x4) or g^x2, ZKP(x2) */ - } JPAKE_STEP1; - -typedef JPAKE_STEP_PART JPAKE_STEP2; - -typedef struct - { - unsigned char hhk[SHA_DIGEST_LENGTH]; - } JPAKE_STEP3A; - -typedef struct - { - unsigned char hk[SHA_DIGEST_LENGTH]; - } JPAKE_STEP3B; - -/* Parameters are copied */ -JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name, - const BIGNUM *p, const BIGNUM *g, const BIGNUM *q, - const BIGNUM *secret); -void JPAKE_CTX_free(JPAKE_CTX *ctx); - -/* - * Note that JPAKE_STEP1 can be used multiple times before release - * without another init. - */ -void JPAKE_STEP1_init(JPAKE_STEP1 *s1); -int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx); -int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received); -void JPAKE_STEP1_release(JPAKE_STEP1 *s1); - -/* - * Note that JPAKE_STEP2 can be used multiple times before release - * without another init. - */ -void JPAKE_STEP2_init(JPAKE_STEP2 *s2); -int JPAKE_STEP2_generate(JPAKE_STEP2 *send, JPAKE_CTX *ctx); -int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received); -void JPAKE_STEP2_release(JPAKE_STEP2 *s2); - -/* - * Optionally verify the shared key. If the shared secrets do not - * match, the two ends will disagree about the shared key, but - * otherwise the protocol will succeed. - */ -void JPAKE_STEP3A_init(JPAKE_STEP3A *s3a); -int JPAKE_STEP3A_generate(JPAKE_STEP3A *send, JPAKE_CTX *ctx); -int JPAKE_STEP3A_process(JPAKE_CTX *ctx, const JPAKE_STEP3A *received); -void JPAKE_STEP3A_release(JPAKE_STEP3A *s3a); - -void JPAKE_STEP3B_init(JPAKE_STEP3B *s3b); -int JPAKE_STEP3B_generate(JPAKE_STEP3B *send, JPAKE_CTX *ctx); -int JPAKE_STEP3B_process(JPAKE_CTX *ctx, const JPAKE_STEP3B *received); -void JPAKE_STEP3B_release(JPAKE_STEP3B *s3b); - -/* - * the return value belongs to the library and will be released when - * ctx is released, and will change when a new handshake is performed. - */ -const BIGNUM *JPAKE_get_shared_key(JPAKE_CTX *ctx); - -/* BEGIN ERROR CODES */ -/* The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ -void ERR_load_JPAKE_strings(void); - -/* Error codes for the JPAKE functions. */ - -/* Function codes. */ -#define JPAKE_F_JPAKE_STEP1_PROCESS 101 -#define JPAKE_F_JPAKE_STEP2_PROCESS 102 -#define JPAKE_F_JPAKE_STEP3A_PROCESS 103 -#define JPAKE_F_JPAKE_STEP3B_PROCESS 104 -#define JPAKE_F_VERIFY_ZKP 100 - -/* Reason codes. */ -#define JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL 108 -#define JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL 109 -#define JPAKE_R_G_TO_THE_X4_IS_ONE 105 -#define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH 106 -#define JPAKE_R_HASH_OF_KEY_MISMATCH 107 -#define JPAKE_R_VERIFY_B_FAILED 102 -#define JPAKE_R_VERIFY_X3_FAILED 103 -#define JPAKE_R_VERIFY_X4_FAILED 104 -#define JPAKE_R_ZKP_VERIFY_FAILED 100 - -#ifdef __cplusplus -} -#endif -#endif -- cgit v1.2.3 From 1684c8f398922065a97e7da4dac4ac6a33cc5218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Wed, 9 Apr 2014 16:03:55 +0200 Subject: Back to the standard "app" module. This return to "app" instead of "bitmask_android" is due to this reading: https://developer.android.com/sdk/installing/studio-build.html#projectStructure I'll have to tweak the final apk name in build.gradle. --- app/openssl/crypto/jpake/jpake.h | 131 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 app/openssl/crypto/jpake/jpake.h (limited to 'app/openssl/crypto/jpake/jpake.h') diff --git a/app/openssl/crypto/jpake/jpake.h b/app/openssl/crypto/jpake/jpake.h new file mode 100644 index 00000000..fd143b4d --- /dev/null +++ b/app/openssl/crypto/jpake/jpake.h @@ -0,0 +1,131 @@ +/* + * Implement J-PAKE, as described in + * http://grouper.ieee.org/groups/1363/Research/contributions/hao-ryan-2008.pdf + * + * With hints from http://www.cl.cam.ac.uk/~fh240/software/JPAKE2.java. + */ + +#ifndef HEADER_JPAKE_H +#define HEADER_JPAKE_H + +#include + +#ifdef OPENSSL_NO_JPAKE +#error JPAKE is disabled. +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef struct JPAKE_CTX JPAKE_CTX; + +/* Note that "g" in the ZKPs is not necessarily the J-PAKE g. */ +typedef struct + { + BIGNUM *gr; /* g^r (r random) */ + BIGNUM *b; /* b = r - x*h, h=hash(g, g^r, g^x, name) */ + } JPAKE_ZKP; + +typedef struct + { + BIGNUM *gx; /* g^x in step 1, g^(xa + xc + xd) * xb * s in step 2 */ + JPAKE_ZKP zkpx; /* ZKP(x) or ZKP(xb * s) */ + } JPAKE_STEP_PART; + +typedef struct + { + JPAKE_STEP_PART p1; /* g^x3, ZKP(x3) or g^x1, ZKP(x1) */ + JPAKE_STEP_PART p2; /* g^x4, ZKP(x4) or g^x2, ZKP(x2) */ + } JPAKE_STEP1; + +typedef JPAKE_STEP_PART JPAKE_STEP2; + +typedef struct + { + unsigned char hhk[SHA_DIGEST_LENGTH]; + } JPAKE_STEP3A; + +typedef struct + { + unsigned char hk[SHA_DIGEST_LENGTH]; + } JPAKE_STEP3B; + +/* Parameters are copied */ +JPAKE_CTX *JPAKE_CTX_new(const char *name, const char *peer_name, + const BIGNUM *p, const BIGNUM *g, const BIGNUM *q, + const BIGNUM *secret); +void JPAKE_CTX_free(JPAKE_CTX *ctx); + +/* + * Note that JPAKE_STEP1 can be used multiple times before release + * without another init. + */ +void JPAKE_STEP1_init(JPAKE_STEP1 *s1); +int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx); +int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received); +void JPAKE_STEP1_release(JPAKE_STEP1 *s1); + +/* + * Note that JPAKE_STEP2 can be used multiple times before release + * without another init. + */ +void JPAKE_STEP2_init(JPAKE_STEP2 *s2); +int JPAKE_STEP2_generate(JPAKE_STEP2 *send, JPAKE_CTX *ctx); +int JPAKE_STEP2_process(JPAKE_CTX *ctx, const JPAKE_STEP2 *received); +void JPAKE_STEP2_release(JPAKE_STEP2 *s2); + +/* + * Optionally verify the shared key. If the shared secrets do not + * match, the two ends will disagree about the shared key, but + * otherwise the protocol will succeed. + */ +void JPAKE_STEP3A_init(JPAKE_STEP3A *s3a); +int JPAKE_STEP3A_generate(JPAKE_STEP3A *send, JPAKE_CTX *ctx); +int JPAKE_STEP3A_process(JPAKE_CTX *ctx, const JPAKE_STEP3A *received); +void JPAKE_STEP3A_release(JPAKE_STEP3A *s3a); + +void JPAKE_STEP3B_init(JPAKE_STEP3B *s3b); +int JPAKE_STEP3B_generate(JPAKE_STEP3B *send, JPAKE_CTX *ctx); +int JPAKE_STEP3B_process(JPAKE_CTX *ctx, const JPAKE_STEP3B *received); +void JPAKE_STEP3B_release(JPAKE_STEP3B *s3b); + +/* + * the return value belongs to the library and will be released when + * ctx is released, and will change when a new handshake is performed. + */ +const BIGNUM *JPAKE_get_shared_key(JPAKE_CTX *ctx); + +/* BEGIN ERROR CODES */ +/* The following lines are auto generated by the script mkerr.pl. Any changes + * made after this point may be overwritten when the script is next run. + */ +void ERR_load_JPAKE_strings(void); + +/* Error codes for the JPAKE functions. */ + +/* Function codes. */ +#define JPAKE_F_JPAKE_STEP1_PROCESS 101 +#define JPAKE_F_JPAKE_STEP2_PROCESS 102 +#define JPAKE_F_JPAKE_STEP3A_PROCESS 103 +#define JPAKE_F_JPAKE_STEP3B_PROCESS 104 +#define JPAKE_F_VERIFY_ZKP 100 + +/* Reason codes. */ +#define JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL 108 +#define JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL 109 +#define JPAKE_R_G_TO_THE_X4_IS_ONE 105 +#define JPAKE_R_HASH_OF_HASH_OF_KEY_MISMATCH 106 +#define JPAKE_R_HASH_OF_KEY_MISMATCH 107 +#define JPAKE_R_VERIFY_B_FAILED 102 +#define JPAKE_R_VERIFY_X3_FAILED 103 +#define JPAKE_R_VERIFY_X4_FAILED 104 +#define JPAKE_R_ZKP_VERIFY_FAILED 100 + +#ifdef __cplusplus +} +#endif +#endif -- cgit v1.2.3