Tidy up, don't exceed the number of requested bits.
[openssl.git] / crypto / jpake / jpaketest.c
index 13b2e1f11958cb4fc1ee9a5c80181c99388cd00c..eaba75ed8abe1b8e51d6696a1f884a02576ffd30 100644 (file)
@@ -1,3 +1,17 @@
+#include <openssl/opensslconf.h>
+
+#ifdef OPENSSL_NO_JPAKE
+
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+    printf("No J-PAKE support\n");
+    return(0);
+}
+
+#else
+
 #include <openssl/jpake.h>
 #include <openssl/err.h>
 
@@ -18,7 +32,7 @@ static int run_jpake(JPAKE_CTX *alice, JPAKE_CTX *bob)
     JPAKE_STEP3A alice_s3a;
     JPAKE_STEP3B bob_s3b;
 
-    // Alice -> Bob: step 1
+   /* Alice -> Bob: step 1 */
     puts("A->B s1");
     JPAKE_STEP1_init(&alice_s1);
     JPAKE_STEP1_generate(&alice_s1, alice);
@@ -30,7 +44,7 @@ static int run_jpake(JPAKE_CTX *alice, JPAKE_CTX *bob)
        }
     JPAKE_STEP1_release(&alice_s1);
 
-    // Bob -> Alice: step 1
+   /* Bob -> Alice: step 1 */
     puts("B->A s1");
     JPAKE_STEP1_init(&bob_s1);
     JPAKE_STEP1_generate(&bob_s1, bob);
@@ -42,7 +56,7 @@ static int run_jpake(JPAKE_CTX *alice, JPAKE_CTX *bob)
        }
     JPAKE_STEP1_release(&bob_s1);
 
-    // Alice -> Bob: step 2
+   /* Alice -> Bob: step 2 */
     puts("A->B s2");
     JPAKE_STEP2_init(&alice_s2);
     JPAKE_STEP2_generate(&alice_s2, alice);
@@ -54,7 +68,7 @@ static int run_jpake(JPAKE_CTX *alice, JPAKE_CTX *bob)
        }
     JPAKE_STEP2_release(&alice_s2);
 
-    // Bob -> Alice: step 2
+   /* Bob -> Alice: step 2 */
     puts("B->A s2");
     JPAKE_STEP2_init(&bob_s2);
     JPAKE_STEP2_generate(&bob_s2, bob);
@@ -69,7 +83,7 @@ static int run_jpake(JPAKE_CTX *alice, JPAKE_CTX *bob)
     showbn("Alice's key", JPAKE_get_shared_key(alice));
     showbn("Bob's key  ", JPAKE_get_shared_key(bob));
 
-    // Alice -> Bob: step 3a
+   /* Alice -> Bob: step 3a */
     puts("A->B s3a");
     JPAKE_STEP3A_init(&alice_s3a);
     JPAKE_STEP3A_generate(&alice_s3a, alice);
@@ -81,7 +95,7 @@ static int run_jpake(JPAKE_CTX *alice, JPAKE_CTX *bob)
        }
     JPAKE_STEP3A_release(&alice_s3a);
     
-    // Bob -> Alice: step 3b
+   /* Bob -> Alice: step 3b */
     puts("B->A s3b");
     JPAKE_STEP3B_init(&bob_s3b);
     JPAKE_STEP3B_generate(&bob_s3b, bob);
@@ -123,7 +137,7 @@ int main(int argc, char **argv)
     p = BN_new();
     BN_generate_prime(p, 1024, 1, NULL, NULL, NULL, NULL);
     */
-    // Use a safe prime for p (that we found earlier)
+   /* Use a safe prime for p (that we found earlier) */
     BN_hex2bn(&p, "F9E5B365665EA7A05A9C534502780FEE6F1AB5BD4F49947FD036DBD7E905269AF46EF28B0FC07487EE4F5D20FB3C0AF8E700F3A2FA3414970CBED44FEDFF80CE78D800F184BB82435D137AADA2C6C16523247930A63B85661D1FC817A51ACD96168E95898A1F83A79FFB529368AA7833ABD1B0C3AEDDB14D2E1A2F71D99F763F");
     showbn("p", p);
     g = BN_new();
@@ -135,7 +149,7 @@ int main(int argc, char **argv)
 
     BN_rand(secret, 32, -1, 0);
 
-    // A normal run, expect this to work...
+   /* A normal run, expect this to work... */
     alice = JPAKE_CTX_new("Alice", "Bob", p, g, q, secret);
     bob = JPAKE_CTX_new("Bob", "Alice", p, g, q, secret);
 
@@ -148,7 +162,7 @@ int main(int argc, char **argv)
     JPAKE_CTX_free(bob);
     JPAKE_CTX_free(alice);
 
-    // Now give Alice and Bob different secrets
+   /* Now give Alice and Bob different secrets */
     alice = JPAKE_CTX_new("Alice", "Bob", p, g, q, secret);
     BN_add_word(secret, 1);
     bob = JPAKE_CTX_new("Bob", "Alice", p, g, q, secret);
@@ -168,9 +182,11 @@ int main(int argc, char **argv)
     BN_free(p);
 
     CRYPTO_cleanup_all_ex_data();
-    ERR_remove_state(0);
+    ERR_remove_thread_state(NULL);
     ERR_free_strings();
     CRYPTO_mem_leaks(bio_err);
 
     return 0;
     }
+
+#endif