Add EC_GROUP_new_GFp prototype.
[openssl.git] / crypto / ec / ec.c
index df54b47c0bd65154420d37f4fb6658c2e8dfb1dd..faf7c75b0652bcb9362c02733c741daf33756f11 100644 (file)
@@ -14,7 +14,7 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "ec.h"
+#include "ec2.h"
 
 
 
@@ -27,15 +27,13 @@ EC *EC_new()
        ret->A = BN_new();
        ret->B = BN_new();
        ret->p = BN_new();
-       ret->h = BN_new();
        ret->is_in_mont = 0;
 
-       if (ret->A == NULL || ret->B == NULL || ret->p == NULL || ret->h == NULL)
+       if (ret->A == NULL || ret->B == NULL || ret->p == NULL)
        {
                if (ret->A != NULL) BN_free(ret->A);
                if (ret->B != NULL) BN_free(ret->B);
                if (ret->p != NULL) BN_free(ret->p);
-               if (ret->h != NULL) BN_free(ret->h);
                free(ret);
                return(NULL);
        }
@@ -50,7 +48,6 @@ void EC_clear_free(EC *E)
        if (E->A != NULL) BN_clear_free(E->A);
        if (E->B != NULL) BN_clear_free(E->B);
        if (E->p != NULL) BN_clear_free(E->p);
-       if (E->h != NULL) BN_clear_free(E->h);
        E->is_in_mont = 0;
        free(E);
 }
@@ -60,7 +57,7 @@ void EC_clear_free(EC *E)
 int EC_to_montgomery(EC *E, BN_MONTGOMERY *mont, BN_CTX *ctx)
 {
        assert(E != NULL);
-       assert(E->A != NULL && E->B != NULL && E->p != NULL && E->h != NULL);
+       assert(E->A != NULL && E->B != NULL && E->p != NULL);
 
        assert(mont != NULL);
        assert(mont->p != NULL);
@@ -75,9 +72,6 @@ int EC_to_montgomery(EC *E, BN_MONTGOMERY *mont, BN_CTX *ctx)
        if (!BN_lshift(E->B, E->B, mont->R_num_bits)) return 0;
        if (!BN_mod(E->B, E->B, mont->p, ctx)) return 0;
 
-       if (!BN_lshift(E->h, E->h, mont->R_num_bits)) return 0;
-       if (!BN_mod(E->h, E->h, mont->p, ctx)) return 0;
-
        E->is_in_mont = 1;
        return 1;
 
@@ -87,7 +81,7 @@ int EC_to_montgomery(EC *E, BN_MONTGOMERY *mont, BN_CTX *ctx)
 int EC_from_montgomery(EC *E, BN_MONTGOMERY *mont, BN_CTX *ctx)
 {
        assert(E != NULL);
-       assert(E->A != NULL && E->B != NULL && E->p != NULL && E->h != NULL);
+       assert(E->A != NULL && E->B != NULL && E->p != NULL);
 
        assert(mont != NULL);
        assert(mont->p != NULL);
@@ -98,23 +92,8 @@ int EC_from_montgomery(EC *E, BN_MONTGOMERY *mont, BN_CTX *ctx)
 
        if (!BN_mont_red(E->A, mont)) return 0;
        if (!BN_mont_red(E->B, mont)) return 0;
-       if (!BN_mont_red(E->h, mont)) return 0;
 
        E->is_in_mont = 0;
        return 1;
 }
 #endif /* MONTGOMERY */
-
-int EC_set_half(EC *E)
-/* h <- 1/2 mod p = (p + 1)/2 */
-{
-       assert(E != NULL);
-       assert(E->p != NULL);
-       assert(E->h != NULL);
-       assert(!E->is_in_mont);
-
-       if (BN_copy(E->h, E->p) == NULL) return 0; 
-       if (!BN_add_word(E->h, 1)) return 0;
-       if (!BN_rshift1(E->h, E->h)) return 0; 
-       return 1;
-}