Hi,

I would like to remove as many as possible symbols from the symbol table
that are not part of any API.  One way of doing that is making those
symbols static.  This might also have other positive side effects.

I've tried to find all variables and functions that are only used in 1
file, and then made them static.  This means that I've moved the
declarations of some of the functions from a _lcl.h file to the .c file.
This might give the impression that you're not supposed to use those
functions from other files, but if needed you could always change it
back later.

What might seem strange is the use of static in a header file, like in
md5_locl.h, but those files are actually only included in 1 .c file.  It
might be better to just move everything to the .c file in that case.

This currently removed the following symbols for me from libcrypto:
bn_add_part_words
bn_mul_high
bn_mul_low_normal
bn_mul_low_recursive
bn_mul_normal
bn_mul_part_recursive
bn_mul_recursive
bn_sqr_recursive
bn_sub_part_words
EC_EX_DATA_clear_free_all_data
EC_EX_DATA_clear_free_data
ec_GF2m_simple_add
ec_GF2m_simple_cmp
ec_GF2m_simple_dbl
ec_GF2m_simple_field_div
ec_GF2m_simple_field_mul
ec_GF2m_simple_field_sqr
ec_GF2m_simple_group_check_discriminant
ec_GF2m_simple_group_clear_finish
ec_GF2m_simple_group_copy
ec_GF2m_simple_group_finish
ec_GF2m_simple_group_get_curve
ec_GF2m_simple_group_get_degree
ec_GF2m_simple_group_init
ec_GF2m_simple_invert
ec_GF2m_simple_is_at_infinity
ec_GF2m_simple_is_on_curve
ec_GF2m_simple_make_affine
ec_GF2m_simple_oct2point
ec_GF2m_simple_point2oct
ec_GF2m_simple_point_clear_finish
ec_GF2m_simple_point_copy
ec_GF2m_simple_point_finish
ec_GF2m_simple_point_get_affine_coordinates
ec_GF2m_simple_point_init
ec_GF2m_simple_point_set_affine_coordinates
ec_GF2m_simple_point_set_to_infinity
ec_GF2m_simple_points_make_affine
ec_GF2m_simple_set_compressed_coordinates
ec_GFp_mont_field_decode
ec_GFp_mont_field_encode
ec_GFp_mont_field_mul
ec_GFp_mont_field_set_to_one
ec_GFp_mont_field_sqr
ec_GFp_mont_group_clear_finish
ec_GFp_mont_group_copy
ec_GFp_mont_group_finish
ec_GFp_mont_group_init
ec_GFp_mont_group_set_curve
ec_GFp_nist_field_mul
ec_GFp_nist_field_sqr
ec_GFp_nist_group_copy
ec_GFp_nist_group_set_curve
ec_GFp_simple_field_mul
ec_GFp_simple_field_sqr
md4_block_data_order
rand_ssleay_meth
ripemd160_block_data_order
x509_dir_lookup
x509_file_lookup
x509_name_ff

Anf from libssl:
do_dtls1_write
dtls1_clear_record_buffer
dtls1_client_hello
dtls1_get_record
dtls1_send_certificate_request
dtls1_send_client_certificate
dtls1_send_client_key_exchange
dtls1_send_client_verify
dtls1_send_hello_request
dtls1_send_server_certificate
dtls1_send_server_done
dtls1_send_server_hello
dtls1_send_server_key_exchange
ssl23_get_client_hello
ssl_bad_method
ssl_clear_cipher_ctx

I believe none of those are supposed to be exported.

Also note that some are actually missing in this list because I still
get them from an assembler file.


Kurt

diff --git a/crypto/asn1/x_name.c b/crypto/asn1/x_name.c
index 193f6d4..ee1b4f7 100644
--- a/crypto/asn1/x_name.c
+++ b/crypto/asn1/x_name.c
@@ -110,7 +110,7 @@ ASN1_ITEM_TEMPLATE_END(X509_NAME_INTERNAL)
  * to the external form.
  */
 
-const ASN1_EXTERN_FUNCS x509_name_ff = {
+static const ASN1_EXTERN_FUNCS x509_name_ff = {
 	NULL,
 	x509_name_ex_new,
 	x509_name_ex_free,
diff --git a/crypto/bn/bn_lcl.h b/crypto/bn/bn_lcl.h
index 27ac439..558dbd8 100644
--- a/crypto/bn/bn_lcl.h
+++ b/crypto/bn/bn_lcl.h
@@ -458,7 +458,6 @@ extern "C" {
 	}
 #endif /* !BN_LLONG */
 
-void bn_mul_normal(BN_ULONG *r,BN_ULONG *a,int na,BN_ULONG *b,int nb);
 void bn_mul_comba8(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
 void bn_mul_comba4(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b);
 void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp);
@@ -467,20 +466,6 @@ void bn_sqr_comba4(BN_ULONG *r,const BN_ULONG *a);
 int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n);
 int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
 	int cl, int dl);
-void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
-	int dna,int dnb,BN_ULONG *t);
-void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,
-	int n,int tna,int tnb,BN_ULONG *t);
-void bn_sqr_recursive(BN_ULONG *r,const BN_ULONG *a, int n2, BN_ULONG *t);
-void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n);
-void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
-	BN_ULONG *t);
-void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2,
-	BN_ULONG *t);
-BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
-	int cl, int dl);
-BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
-	int cl, int dl);
 int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num);
 
 #ifdef  __cplusplus
diff --git a/crypto/bn/bn_mul.c b/crypto/bn/bn_mul.c
index 312b467..41e7a63 100644
--- a/crypto/bn/bn_mul.c
+++ b/crypto/bn/bn_mul.c
@@ -66,6 +66,9 @@
 #include "cryptlib.h"
 #include "bn_lcl.h"
 
+static void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);
+static void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb);
+
 #if defined(OPENSSL_NO_ASM) || !defined(OPENSSL_BN_ASM_PART_WORDS)
 /* Here follows specialised variants of bn_add_words() and
    bn_sub_words().  They have the property performing operations on
@@ -77,7 +80,7 @@
    These functions should probably end up in bn_asm.c as soon as there are
    assembler counterparts for the systems that use assembler files.  */
 
-BN_ULONG bn_sub_part_words(BN_ULONG *r,
+static BN_ULONG bn_sub_part_words(BN_ULONG *r,
 	const BN_ULONG *a, const BN_ULONG *b,
 	int cl, int dl)
 	{
@@ -204,7 +207,8 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r,
 	}
 #endif
 
-BN_ULONG bn_add_part_words(BN_ULONG *r,
+/* unused? */
+static BN_ULONG bn_add_part_words(BN_ULONG *r,
 	const BN_ULONG *a, const BN_ULONG *b,
 	int cl, int dl)
 	{
@@ -389,7 +393,7 @@ BN_ULONG bn_add_part_words(BN_ULONG *r,
  * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
  * a[1]*b[1]
  */
-void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
+static void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
 	int dna, int dnb, BN_ULONG *t)
 	{
 	int n=n2/2,c1,c2;
@@ -545,7 +549,7 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
 
 /* n+tn is the word length
  * t needs to be n*4 is size, as does r */
-void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
+static void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
 	     int tna, int tnb, BN_ULONG *t)
 	{
 	int i,j,n2=n*2;
@@ -721,7 +725,8 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
 /* a and b must be the same size, which is n2.
  * r needs to be n2 words and t needs to be n2*2
  */
-void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
+/* unused? */
+static void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
 	     BN_ULONG *t)
 	{
 	int n=n2/2;
@@ -752,7 +757,8 @@ void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
  * l is the low words of the output.
  * t needs to be n2*3
  */
-void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
+/* unused? */
+static void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
 	     BN_ULONG *t)
 	{
 	int i,n;
@@ -1099,7 +1105,7 @@ err:
 	return(ret);
 	}
 
-void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
+static void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
 	{
 	BN_ULONG *rr;
 
@@ -1141,7 +1147,7 @@ void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb)
 		}
 	}
 
-void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
+static void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
 	{
 #ifdef BN_COUNT
 	fprintf(stderr," bn_mul_low_normal %d * %d\n",n,n);
diff --git a/crypto/bn/bn_sqr.c b/crypto/bn/bn_sqr.c
index 270d0cd..c795753 100644
--- a/crypto/bn/bn_sqr.c
+++ b/crypto/bn/bn_sqr.c
@@ -60,6 +60,8 @@
 #include "cryptlib.h"
 #include "bn_lcl.h"
 
+static void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t);
+
 /* r must not be a */
 /* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */
 int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
@@ -203,7 +205,7 @@ void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp)
  * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0])
  * a[1]*b[1]
  */
-void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t)
+static void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t)
 	{
 	int n=n2/2;
 	int zero,c1;
diff --git a/crypto/ec/ec2_smpl.c b/crypto/ec/ec2_smpl.c
index 01d8483..a4de4f1 100644
--- a/crypto/ec/ec2_smpl.c
+++ b/crypto/ec/ec2_smpl.c
@@ -71,6 +71,39 @@
 
 #include "ec_lcl.h"
 
+static int ec_GF2m_simple_group_init(EC_GROUP *group);
+static int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
+static int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx);
+static int ec_GF2m_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx);
+static int ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
+static int ec_GF2m_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
+static int ec_GF2m_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
+static int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx);
+static void ec_GF2m_simple_group_clear_finish(EC_GROUP *group);
+static int ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src);
+static void ec_GF2m_simple_group_finish(EC_GROUP *group);
+static int ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx);
+static int ec_GF2m_simple_group_get_degree(const EC_GROUP *group);
+static int ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);
+static int ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point);
+static int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx);
+static int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx);
+static int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
+	const unsigned char *buf, size_t len, BN_CTX *ctx);
+static size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
+	unsigned char *buf, size_t len, BN_CTX *ctx);
+static void ec_GF2m_simple_point_clear_finish(EC_POINT *point);
+static int ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src);
+static void ec_GF2m_simple_point_finish(EC_POINT *point);
+static int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
+	BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
+static int ec_GF2m_simple_point_init(EC_POINT *point);
+static int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
+	const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
+static int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point);
+static int ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx);
+static int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
+	const BIGNUM *x_, int y_bit, BN_CTX *ctx);
 
 const EC_METHOD *EC_GF2m_simple_method(void)
 	{
@@ -124,7 +157,7 @@ const EC_METHOD *EC_GF2m_simple_method(void)
 /* Initialize a GF(2^m)-based EC_GROUP structure.
  * Note that all other members are handled by EC_GROUP_new.
  */
-int ec_GF2m_simple_group_init(EC_GROUP *group)
+static int ec_GF2m_simple_group_init(EC_GROUP *group)
 	{
 	BN_init(&group->field);
 	BN_init(&group->a);
@@ -136,7 +169,7 @@ int ec_GF2m_simple_group_init(EC_GROUP *group)
 /* Free a GF(2^m)-based EC_GROUP structure.
  * Note that all other members are handled by EC_GROUP_free.
  */
-void ec_GF2m_simple_group_finish(EC_GROUP *group)
+static void ec_GF2m_simple_group_finish(EC_GROUP *group)
 	{
 	BN_free(&group->field);
 	BN_free(&group->a);
@@ -147,7 +180,7 @@ void ec_GF2m_simple_group_finish(EC_GROUP *group)
 /* Clear and free a GF(2^m)-based EC_GROUP structure.
  * Note that all other members are handled by EC_GROUP_clear_free.
  */
-void ec_GF2m_simple_group_clear_finish(EC_GROUP *group)
+static void ec_GF2m_simple_group_clear_finish(EC_GROUP *group)
 	{
 	BN_clear_free(&group->field);
 	BN_clear_free(&group->a);
@@ -164,7 +197,7 @@ void ec_GF2m_simple_group_clear_finish(EC_GROUP *group)
 /* Copy a GF(2^m)-based EC_GROUP structure.
  * Note that all other members are handled by EC_GROUP_copy.
  */
-int ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src)
+static int ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src)
 	{
 	int i;
 	if (!BN_copy(&dest->field, &src->field)) return 0;
@@ -218,7 +251,7 @@ int ec_GF2m_simple_group_set_curve(EC_GROUP *group,
 /* Get the curve parameters of an EC_GROUP structure.
  * If p, a, or b are NULL then there values will not be set but the method will return with success.
  */
-int ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
+static int ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
 	{
 	int ret = 0;
 	
@@ -245,7 +278,7 @@ int ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
 
 
 /* Gets the degree of the field.  For a curve over GF(2^m) this is the value m. */
-int ec_GF2m_simple_group_get_degree(const EC_GROUP *group)
+static int ec_GF2m_simple_group_get_degree(const EC_GROUP *group)
 	{
 	return BN_num_bits(&group->field)-1;
 	}
@@ -254,7 +287,7 @@ int ec_GF2m_simple_group_get_degree(const EC_GROUP *group)
 /* Checks the discriminant of the curve.
  * y^2 + x*y = x^3 + a*x^2 + b is an elliptic curve <=> b != 0 (mod p) 
  */
-int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
+static int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
 	{
 	int ret = 0;
 	BIGNUM *b;
@@ -292,7 +325,7 @@ err:
 
 
 /* Initializes an EC_POINT. */
-int ec_GF2m_simple_point_init(EC_POINT *point)
+static int ec_GF2m_simple_point_init(EC_POINT *point)
 	{
 	BN_init(&point->X);
 	BN_init(&point->Y);
@@ -302,7 +335,7 @@ int ec_GF2m_simple_point_init(EC_POINT *point)
 
 
 /* Frees an EC_POINT. */
-void ec_GF2m_simple_point_finish(EC_POINT *point)
+static void ec_GF2m_simple_point_finish(EC_POINT *point)
 	{
 	BN_free(&point->X);
 	BN_free(&point->Y);
@@ -311,7 +344,7 @@ void ec_GF2m_simple_point_finish(EC_POINT *point)
 
 
 /* Clears and frees an EC_POINT. */
-void ec_GF2m_simple_point_clear_finish(EC_POINT *point)
+static void ec_GF2m_simple_point_clear_finish(EC_POINT *point)
 	{
 	BN_clear_free(&point->X);
 	BN_clear_free(&point->Y);
@@ -321,7 +354,7 @@ void ec_GF2m_simple_point_clear_finish(EC_POINT *point)
 
 
 /* Copy the contents of one EC_POINT into another.  Assumes dest is initialized. */
-int ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src)
+static int ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src)
 	{
 	if (!BN_copy(&dest->X, &src->X)) return 0;
 	if (!BN_copy(&dest->Y, &src->Y)) return 0;
@@ -335,7 +368,7 @@ int ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src)
 /* Set an EC_POINT to the point at infinity.  
  * A point at infinity is represented by having Z=0.
  */
-int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
+static int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
 	{
 	point->Z_is_one = 0;
 	BN_zero(&point->Z);
@@ -346,7 +379,7 @@ int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
 /* Set the coordinates of an EC_POINT using affine coordinates. 
  * Note that the simple implementation only uses affine coordinates.
  */
-int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
+static int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
 	const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
 	{
 	int ret = 0;	
@@ -373,7 +406,7 @@ int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT
 /* Gets the affine coordinates of an EC_POINT. 
  * Note that the simple implementation only uses affine coordinates.
  */
-int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
+static int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
 	BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
 	{
 	int ret = 0;
@@ -421,7 +454,7 @@ int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_
  * the same method, but claim no priority date earlier than July 29, 1994
  * (and additionally fail to cite the EUROCRYPT '92 publication as prior art).
  */
-int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
+static int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
 	const BIGNUM *x_, int y_bit, BN_CTX *ctx)
 	{
 	BN_CTX *new_ctx = NULL;
@@ -495,7 +528,7 @@ int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p
  * If buf is NULL, the encoded length will be returned.
  * If the length len of buf is smaller than required an error will be returned.
  */
-size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
+static size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
 	unsigned char *buf, size_t len, BN_CTX *ctx)
 	{
 	size_t ret;
@@ -627,7 +660,7 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, po
 /* Converts an octet string representation to an EC_POINT. 
  * Note that the simple implementation only uses affine coordinates.
  */
-int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
+static int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
 	const unsigned char *buf, size_t len, BN_CTX *ctx)
 	{
 	point_conversion_form_t form;
@@ -742,7 +775,7 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
 /* Computes a + b and stores the result in r.  r could be a or b, a could be b.
  * Uses algorithm A.10.2 of IEEE P1363.
  */
-int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
+static int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
 	{
 	BN_CTX *new_ctx = NULL;
 	BIGNUM *x0, *y0, *x1, *y1, *x2, *y2, *s, *t;
@@ -844,13 +877,13 @@ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, co
 /* Computes 2 * a and stores the result in r.  r could be a.
  * Uses algorithm A.10.2 of IEEE P1363.
  */
-int ec_GF2m_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
+static int ec_GF2m_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
 	{
 	return ec_GF2m_simple_add(group, r, a, a, ctx);
 	}
 
 
-int ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
+static int ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
 	{
 	if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(&point->Y))
 		/* point is its own inverse */
@@ -862,7 +895,7 @@ int ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
 
 
 /* Indicates whether the given point is the point at infinity. */
-int ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
+static int ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
 	{
 	return BN_is_zero(&point->Z);
 	}
@@ -872,7 +905,7 @@ int ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
  * in the EC_GROUP.  A point is valid if it satisfies the Weierstrass equation:
  *      y^2 + x*y = x^3 + a*x^2 + b.
  */
-int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
+static int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
 	{
 	int ret = -1;
 	BN_CTX *new_ctx = NULL;
@@ -927,7 +960,7 @@ int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_
  *   0   equal (in affine coordinates)
  *   1   not equal
  */
-int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
+static int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
 	{
 	BIGNUM *aX, *aY, *bX, *bY;
 	BN_CTX *new_ctx = NULL;
@@ -969,7 +1002,7 @@ int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT
 
 
 /* Forces the given EC_POINT to internally use affine coordinates. */
-int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
+static int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
 	{
 	BN_CTX *new_ctx = NULL;
 	BIGNUM *x, *y;
@@ -1005,7 +1038,7 @@ int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *c
 
 
 /* Forces each of the EC_POINTs in the given array to use affine coordinates. */
-int ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)
+static int ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)
 	{
 	size_t i;
 
@@ -1019,21 +1052,21 @@ int ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POIN
 
 
 /* Wrapper to simple binary polynomial field multiplication implementation. */
-int ec_GF2m_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
+static int ec_GF2m_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
 	{
 	return BN_GF2m_mod_mul_arr(r, a, b, group->poly, ctx);
 	}
 
 
 /* Wrapper to simple binary polynomial field squaring implementation. */
-int ec_GF2m_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
+static int ec_GF2m_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
 	{
 	return BN_GF2m_mod_sqr_arr(r, a, group->poly, ctx);
 	}
 
 
 /* Wrapper to simple binary polynomial field division implementation. */
-int ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
+static int ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
 	{
 	return BN_GF2m_mod_div(r, a, b, &group->field, ctx);
 	}
diff --git a/crypto/ec/ec_lcl.h b/crypto/ec/ec_lcl.h
index 3e2c34b..058faf9 100644
--- a/crypto/ec/ec_lcl.h
+++ b/crypto/ec/ec_lcl.h
@@ -259,10 +259,7 @@ void *EC_EX_DATA_get_data(const EC_EXTRA_DATA *,
 	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
 void EC_EX_DATA_free_data(EC_EXTRA_DATA **,
 	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
-void EC_EX_DATA_clear_free_data(EC_EXTRA_DATA **,
-	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
 void EC_EX_DATA_free_all_data(EC_EXTRA_DATA **);
-void EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA **);
 
 
 
@@ -325,65 +322,10 @@ int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);
 int ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
 int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
 int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
-int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
-int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
-
-
-/* method functions in ecp_mont.c */
-int ec_GFp_mont_group_init(EC_GROUP *);
-int ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
-void ec_GFp_mont_group_finish(EC_GROUP *);
-void ec_GFp_mont_group_clear_finish(EC_GROUP *);
-int ec_GFp_mont_group_copy(EC_GROUP *, const EC_GROUP *);
-int ec_GFp_mont_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
-int ec_GFp_mont_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
-int ec_GFp_mont_field_encode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
-int ec_GFp_mont_field_decode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
-int ec_GFp_mont_field_set_to_one(const EC_GROUP *, BIGNUM *r, BN_CTX *);
-
-
-/* method functions in ecp_nist.c */
-int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src);
-int ec_GFp_nist_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
-int ec_GFp_nist_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
-int ec_GFp_nist_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
 
 
 /* method functions in ec2_smpl.c */
-int ec_GF2m_simple_group_init(EC_GROUP *);
-void ec_GF2m_simple_group_finish(EC_GROUP *);
-void ec_GF2m_simple_group_clear_finish(EC_GROUP *);
-int ec_GF2m_simple_group_copy(EC_GROUP *, const EC_GROUP *);
 int ec_GF2m_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
-int ec_GF2m_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *);
-int ec_GF2m_simple_group_get_degree(const EC_GROUP *);
-int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *);
-int ec_GF2m_simple_point_init(EC_POINT *);
-void ec_GF2m_simple_point_finish(EC_POINT *);
-void ec_GF2m_simple_point_clear_finish(EC_POINT *);
-int ec_GF2m_simple_point_copy(EC_POINT *, const EC_POINT *);
-int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *);
-int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *,
-	const BIGNUM *x, const BIGNUM *y, BN_CTX *);
-int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *, const EC_POINT *,
-	BIGNUM *x, BIGNUM *y, BN_CTX *);
-int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *,
-	const BIGNUM *x, int y_bit, BN_CTX *);
-size_t ec_GF2m_simple_point2oct(const EC_GROUP *, const EC_POINT *, point_conversion_form_t form,
-	unsigned char *buf, size_t len, BN_CTX *);
-int ec_GF2m_simple_oct2point(const EC_GROUP *, EC_POINT *,
-	const unsigned char *buf, size_t len, BN_CTX *);
-int ec_GF2m_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
-int ec_GF2m_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *);
-int ec_GF2m_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *);
-int ec_GF2m_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *);
-int ec_GF2m_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *);
-int ec_GF2m_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, BN_CTX *);
-int ec_GF2m_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *);
-int ec_GF2m_simple_points_make_affine(const EC_GROUP *, size_t num, EC_POINT *[], BN_CTX *);
-int ec_GF2m_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
-int ec_GF2m_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *);
-int ec_GF2m_simple_field_div(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *);
 
 
 /* method functions in ec2_mult.c */
diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c
index dd7da0f..109edfe 100644
--- a/crypto/ec/ec_lib.c
+++ b/crypto/ec/ec_lib.c
@@ -70,6 +70,9 @@
 
 static const char EC_version[] = "EC" OPENSSL_VERSION_PTEXT;
 
+static void EC_EX_DATA_clear_free_data(EC_EXTRA_DATA **ex_data,
+	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *));
+static void EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA **ex_data);
 
 /* functions for EC_GROUP objects */
 
@@ -622,7 +625,7 @@ void EC_EX_DATA_free_data(EC_EXTRA_DATA **ex_data,
 	}
 
 /* this has 'package' visibility */
-void EC_EX_DATA_clear_free_data(EC_EXTRA_DATA **ex_data,
+static void EC_EX_DATA_clear_free_data(EC_EXTRA_DATA **ex_data,
 	void *(*dup_func)(void *), void (*free_func)(void *), void (*clear_free_func)(void *))
 	{
 	EC_EXTRA_DATA **p;
@@ -667,7 +670,7 @@ void EC_EX_DATA_free_all_data(EC_EXTRA_DATA **ex_data)
 	}
 
 /* this has 'package' visibility */
-void EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA **ex_data)
+static void EC_EX_DATA_clear_free_all_data(EC_EXTRA_DATA **ex_data)
 	{
 	EC_EXTRA_DATA *d;
 
diff --git a/crypto/ec/ecp_mont.c b/crypto/ec/ecp_mont.c
index 9fc4a46..f8cf47b 100644
--- a/crypto/ec/ecp_mont.c
+++ b/crypto/ec/ecp_mont.c
@@ -65,6 +65,16 @@
 
 #include "ec_lcl.h"
 
+static int ec_GFp_mont_group_init(EC_GROUP *group);
+static int ec_GFp_mont_field_decode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
+static int ec_GFp_mont_field_encode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
+static int ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
+static int ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx);
+static int ec_GFp_mont_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
+static void ec_GFp_mont_group_clear_finish(EC_GROUP *group);
+static int ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src);
+static void ec_GFp_mont_group_finish(EC_GROUP *group);
+static int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
 
 const EC_METHOD *EC_GFp_mont_method(void)
 	{
@@ -112,7 +122,7 @@ const EC_METHOD *EC_GFp_mont_method(void)
 	}
 
 
-int ec_GFp_mont_group_init(EC_GROUP *group)
+static int ec_GFp_mont_group_init(EC_GROUP *group)
 	{
 	int ok;
 
@@ -123,7 +133,7 @@ int ec_GFp_mont_group_init(EC_GROUP *group)
 	}
 
 
-void ec_GFp_mont_group_finish(EC_GROUP *group)
+static void ec_GFp_mont_group_finish(EC_GROUP *group)
 	{
 	if (group->field_data1 != NULL)
 		{
@@ -139,7 +149,7 @@ void ec_GFp_mont_group_finish(EC_GROUP *group)
 	}
 
 
-void ec_GFp_mont_group_clear_finish(EC_GROUP *group)
+static void ec_GFp_mont_group_clear_finish(EC_GROUP *group)
 	{
 	if (group->field_data1 != NULL)
 		{
@@ -155,7 +165,7 @@ void ec_GFp_mont_group_clear_finish(EC_GROUP *group)
 	}
 
 
-int ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src)
+static int ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src)
 	{
 	if (dest->field_data1 != NULL)
 		{
@@ -194,7 +204,7 @@ int ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src)
 	}
 
 
-int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
+static int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
 	{
 	BN_CTX *new_ctx = NULL;
 	BN_MONT_CTX *mont = NULL;
@@ -254,7 +264,7 @@ int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *
 	}
 
 
-int ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
+static int ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
 	{
 	if (group->field_data1 == NULL)
 		{
@@ -266,7 +276,7 @@ int ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, con
 	}
 
 
-int ec_GFp_mont_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
+static int ec_GFp_mont_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
 	{
 	if (group->field_data1 == NULL)
 		{
@@ -278,7 +288,7 @@ int ec_GFp_mont_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_
 	}
 
 
-int ec_GFp_mont_field_encode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
+static int ec_GFp_mont_field_encode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
 	{
 	if (group->field_data1 == NULL)
 		{
@@ -290,7 +300,7 @@ int ec_GFp_mont_field_encode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
 	}
 
 
-int ec_GFp_mont_field_decode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
+static int ec_GFp_mont_field_decode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
 	{
 	if (group->field_data1 == NULL)
 		{
@@ -302,7 +312,7 @@ int ec_GFp_mont_field_decode(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
 	}
 
 
-int ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx)
+static int ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx)
 	{
 	if (group->field_data2 == NULL)
 		{
diff --git a/crypto/ec/ecp_nist.c b/crypto/ec/ecp_nist.c
index 71893d5..5eda02f 100644
--- a/crypto/ec/ecp_nist.c
+++ b/crypto/ec/ecp_nist.c
@@ -67,6 +67,14 @@
 #include <openssl/obj_mac.h>
 #include "ec_lcl.h"
 
+static int ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
+	const BIGNUM *b, BN_CTX *ctx);
+static int ec_GFp_nist_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
+	BN_CTX *ctx);
+static int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src);
+static int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p,
+	const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
+
 const EC_METHOD *EC_GFp_nist_method(void)
 	{
 	static const EC_METHOD ret = {
@@ -116,14 +124,14 @@ const EC_METHOD *EC_GFp_nist_method(void)
 #define	NO_32_BIT_TYPE
 #endif
 
-int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src)
+static int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src)
 	{
 	dest->field_mod_func = src->field_mod_func;
 
 	return ec_GFp_simple_group_copy(dest, src);
 	}
 
-int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p,
+static int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p,
 	const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
 	{
 	int ret = 0;
@@ -184,7 +192,7 @@ int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p,
 	}
 
 
-int ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
+static int ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
 	const BIGNUM *b, BN_CTX *ctx)
 	{
 	int	ret=0;
@@ -210,7 +218,7 @@ err:
 	}
 
 
-int ec_GFp_nist_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
+static int ec_GFp_nist_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a,
 	BN_CTX *ctx)
 	{
 	int	ret=0;
diff --git a/crypto/ec/ecp_smpl.c b/crypto/ec/ecp_smpl.c
index 4d26f8b..bc19953 100644
--- a/crypto/ec/ecp_smpl.c
+++ b/crypto/ec/ecp_smpl.c
@@ -67,6 +67,9 @@
 
 #include "ec_lcl.h"
 
+static int ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
+static int ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
+
 const EC_METHOD *EC_GFp_simple_method(void)
 	{
 	static const EC_METHOD ret = {
@@ -1704,13 +1707,13 @@ int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT
 	}
 
 
-int ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
+static int ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
 	{
 	return BN_mod_mul(r, a, b, &group->field, ctx);
 	}
 
 
-int ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
+static int ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
 	{
 	return BN_mod_sqr(r, a, &group->field, ctx);
 	}
diff --git a/crypto/md4/md4_dgst.c b/crypto/md4/md4_dgst.c
index e0c42e8..f5221ca 100644
--- a/crypto/md4/md4_dgst.c
+++ b/crypto/md4/md4_dgst.c
@@ -84,7 +84,7 @@ int MD4_Init(MD4_CTX *c)
 #ifdef X
 #undef X
 #endif
-void md4_block_data_order (MD4_CTX *c, const void *data_, size_t num)
+static void md4_block_data_order (MD4_CTX *c, const void *data_, size_t num)
 	{
 	const unsigned char *data=data_;
 	register unsigned MD32_REG_T A,B,C,D,l;
diff --git a/crypto/md4/md4_locl.h b/crypto/md4/md4_locl.h
index c8085b0..b2a7510 100644
--- a/crypto/md4/md4_locl.h
+++ b/crypto/md4/md4_locl.h
@@ -65,7 +65,7 @@
 #define MD4_LONG_LOG2 2 /* default to 32 bits */
 #endif
 
-void md4_block_data_order (MD4_CTX *c, const void *p,size_t num);
+static void md4_block_data_order (MD4_CTX *c, const void *p,size_t num);
 
 #define DATA_ORDER_IS_LITTLE_ENDIAN
 
diff --git a/crypto/md5/md5_dgst.c b/crypto/md5/md5_dgst.c
index beace63..daca535 100644
--- a/crypto/md5/md5_dgst.c
+++ b/crypto/md5/md5_dgst.c
@@ -84,7 +84,7 @@ int MD5_Init(MD5_CTX *c)
 #ifdef X
 #undef X
 #endif
-void md5_block_data_order (MD5_CTX *c, const void *data_, size_t num)
+static void md5_block_data_order (MD5_CTX *c, const void *data_, size_t num)
 	{
 	const unsigned char *data=data_;
 	register unsigned MD32_REG_T A,B,C,D,l;
diff --git a/crypto/md5/md5_locl.h b/crypto/md5/md5_locl.h
index 968d577..0e1573e 100644
--- a/crypto/md5/md5_locl.h
+++ b/crypto/md5/md5_locl.h
@@ -74,7 +74,7 @@
 # endif
 #endif
 
-void md5_block_data_order (MD5_CTX *c, const void *p,size_t num);
+static void md5_block_data_order (MD5_CTX *c, const void *p,size_t num);
 
 #define DATA_ORDER_IS_LITTLE_ENDIAN
 
diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c
index cfc7877..740879c 100644
--- a/crypto/rand/md_rand.c
+++ b/crypto/rand/md_rand.c
@@ -162,7 +162,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num);
 static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num);
 static int ssleay_rand_status(void);
 
-RAND_METHOD rand_ssleay_meth={
+static RAND_METHOD rand_ssleay_meth={
 	ssleay_rand_seed,
 	ssleay_rand_bytes,
 	ssleay_rand_cleanup,
diff --git a/crypto/ripemd/rmd_dgst.c b/crypto/ripemd/rmd_dgst.c
index 59b017f..7da9eba 100644
--- a/crypto/ripemd/rmd_dgst.c
+++ b/crypto/ripemd/rmd_dgst.c
@@ -84,7 +84,7 @@ int RIPEMD160_Init(RIPEMD160_CTX *c)
 #ifdef X
 #undef X
 #endif
-void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, size_t num)
+static void ripemd160_block_data_order (RIPEMD160_CTX *ctx, const void *p, size_t num)
 	{
 	const unsigned char *data=p;
 	register unsigned MD32_REG_T A,B,C,D,E;
diff --git a/crypto/ripemd/rmd_locl.h b/crypto/ripemd/rmd_locl.h
index f14b346..caf6651 100644
--- a/crypto/ripemd/rmd_locl.h
+++ b/crypto/ripemd/rmd_locl.h
@@ -76,7 +76,7 @@
 # endif
 #endif
 
-void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,size_t num);
+static void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,size_t num);
 
 #define DATA_ORDER_IS_LITTLE_ENDIAN
 
diff --git a/crypto/sha/sha256.c b/crypto/sha/sha256.c
index 8952d87..7af9042 100644
--- a/crypto/sha/sha256.c
+++ b/crypto/sha/sha256.c
@@ -110,7 +110,7 @@ int SHA224_Final (unsigned char *md, SHA256_CTX *c)
 #ifndef SHA256_ASM
 static
 #endif
-void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num);
+static void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num);
 
 #include "md32_common.h"
 
diff --git a/crypto/sha/sha512.c b/crypto/sha/sha512.c
index 654b59a..3d7e841 100644
--- a/crypto/sha/sha512.c
+++ b/crypto/sha/sha512.c
@@ -120,7 +120,7 @@ int SHA512_Init (SHA512_CTX *c)
 #ifndef SHA512_ASM
 static
 #endif
-void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num);
+static void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num);
 
 int SHA512_Final (unsigned char *md, SHA512_CTX *c)
 	{
diff --git a/crypto/sha/sha_locl.h b/crypto/sha/sha_locl.h
index 672c26e..d61cd00 100644
--- a/crypto/sha/sha_locl.h
+++ b/crypto/sha/sha_locl.h
@@ -108,7 +108,7 @@ static void sha_block_data_order (SHA_CTX *c, const void *p,size_t num);
 #ifndef SHA1_ASM
 static
 #endif
-void sha1_block_data_order (SHA_CTX *c, const void *p,size_t num);
+static void sha1_block_data_order (SHA_CTX *c, const void *p,size_t num);
 
 #else
 # error "Either SHA_0 or SHA_1 must be defined."
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
index b355de9..a50381b 100644
--- a/crypto/x509/by_dir.c
+++ b/crypto/x509/by_dir.c
@@ -102,7 +102,7 @@ static void free_dir(X509_LOOKUP *lu);
 static int add_cert_dir(BY_DIR *ctx,const char *dir,int type);
 static int get_cert_by_subject(X509_LOOKUP *xl,int type,X509_NAME *name,
 	X509_OBJECT *ret);
-X509_LOOKUP_METHOD x509_dir_lookup=
+static X509_LOOKUP_METHOD x509_dir_lookup=
 	{
 	"Load certs from files in a directory",
 	new_dir,		/* new */
diff --git a/crypto/x509/by_file.c b/crypto/x509/by_file.c
index 57b08ee..fe566a5 100644
--- a/crypto/x509/by_file.c
+++ b/crypto/x509/by_file.c
@@ -70,7 +70,7 @@
 
 static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
 	long argl, char **ret);
-X509_LOOKUP_METHOD x509_file_lookup=
+static X509_LOOKUP_METHOD x509_file_lookup=
 	{
 	"Load file into cache",
 	NULL,		/* new */
diff --git a/ssl/d1_both.c b/ssl/d1_both.c
index 87c8c93..a5460fe 100644
--- a/ssl/d1_both.c
+++ b/ssl/d1_both.c
@@ -139,6 +139,7 @@ static void dtls1_set_message_header_int(SSL *s, unsigned char mt,
 static int dtls1_retransmit_buffered_messages(SSL *s);
 static long dtls1_get_message_fragment(SSL *s, int st1, int stn, 
 	long max, int *ok);
+static void dtls1_clear_record_buffer(SSL *s);
 
 static hm_fragment *
 dtls1_hm_fragment_new(unsigned long frag_len)
@@ -1070,7 +1071,7 @@ dtls1_retransmit_message(SSL *s, unsigned short seq, unsigned long frag_off,
 	}
 
 /* call this function when the buffered messages are no longer needed */
-void
+static void
 dtls1_clear_record_buffer(SSL *s)
 	{
 	pitem *item;
diff --git a/ssl/d1_clnt.c b/ssl/d1_clnt.c
index 1623a2a..081ff84 100644
--- a/ssl/d1_clnt.c
+++ b/ssl/d1_clnt.c
@@ -126,6 +126,10 @@
 
 static const SSL_METHOD *dtls1_get_client_method(int ver);
 static int dtls1_get_hello_verify(SSL *s);
+static int dtls1_client_hello(SSL *s);
+static int dtls1_send_client_certificate(SSL *s);
+static int dtls1_send_client_key_exchange(SSL *s);
+static int dtls1_send_client_verify(SSL *s);
 
 static const SSL_METHOD *dtls1_get_client_method(int ver)
 	{
@@ -527,7 +531,7 @@ end:
 	return(ret);
 	}
 
-int dtls1_client_hello(SSL *s)
+static int dtls1_client_hello(SSL *s)
 	{
 	unsigned char *buf;
 	unsigned char *p,*d;
@@ -691,7 +695,7 @@ f_err:
 	return -1;
 	}
 
-int dtls1_send_client_key_exchange(SSL *s)
+static int dtls1_send_client_key_exchange(SSL *s)
 	{
 	unsigned char *p,*d;
 	int n;
@@ -991,7 +995,7 @@ err:
 	return(-1);
 	}
 
-int dtls1_send_client_verify(SSL *s)
+static int dtls1_send_client_verify(SSL *s)
 	{
 	unsigned char *p,*d;
 	unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH];
@@ -1071,7 +1075,7 @@ err:
 	return(-1);
 	}
 
-int dtls1_send_client_certificate(SSL *s)
+static int dtls1_send_client_certificate(SSL *s)
 	{
 	X509 *x509=NULL;
 	EVP_PKEY *pkey=NULL;
diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c
index 2e35db8..2775a21 100644
--- a/ssl/d1_pkt.c
+++ b/ssl/d1_pkt.c
@@ -180,6 +180,8 @@ static int dtls1_buffer_record(SSL *s, record_pqueue *q,
 	unsigned char *priority);
 static int dtls1_process_record(SSL *s);
 static void dtls1_clear_timeouts(SSL *s);
+static int do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len, int create_empty_fragment);
+
 
 /* copy buffered record into SSL structure */
 static int
@@ -520,7 +522,7 @@ err:
  * ssl->s3->rrec.length, - number of bytes
  */
 /* used only by dtls1_read_bytes */
-int dtls1_get_record(SSL *s)
+static int dtls1_get_record(SSL *s)
 	{
 	int ssl_major,ssl_minor,al;
 	int i,n;
@@ -1289,7 +1291,7 @@ int dtls1_write_bytes(SSL *s, int type, const void *buf_, int len)
 	return tot + i;
 	}
 
-int do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len, int create_empty_fragment)
+static int do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len, int create_empty_fragment)
 	{
 	unsigned char *p,*pseq;
 	int i,mac_size,clear=0;
diff --git a/ssl/d1_srvr.c b/ssl/d1_srvr.c
index 9401105..2702690 100644
--- a/ssl/d1_srvr.c
+++ b/ssl/d1_srvr.c
@@ -127,6 +127,12 @@
 
 static const SSL_METHOD *dtls1_get_server_method(int ver);
 static int dtls1_send_hello_verify_request(SSL *s);
+static int dtls1_send_certificate_request(SSL *s);
+static int dtls1_send_hello_request(SSL *s);
+static int dtls1_send_server_certificate(SSL *s);
+static int dtls1_send_server_done(SSL *s);
+static int dtls1_send_server_hello(SSL *s);
+static int dtls1_send_server_key_exchange(SSL *s);
 
 static const SSL_METHOD *dtls1_get_server_method(int ver)
 	{
@@ -592,7 +598,7 @@ end:
 	return(ret);
 	}
 
-int dtls1_send_hello_request(SSL *s)
+static int dtls1_send_hello_request(SSL *s)
 	{
 	unsigned char *p;
 
@@ -658,7 +664,7 @@ int dtls1_send_hello_verify_request(SSL *s)
 	return(dtls1_do_write(s,SSL3_RT_HANDSHAKE));
 	}
 
-int dtls1_send_server_hello(SSL *s)
+static int dtls1_send_server_hello(SSL *s)
 	{
 	unsigned char *buf;
 	unsigned char *p,*d;
@@ -737,7 +743,7 @@ int dtls1_send_server_hello(SSL *s)
 	return(dtls1_do_write(s,SSL3_RT_HANDSHAKE));
 	}
 
-int dtls1_send_server_done(SSL *s)
+static int dtls1_send_server_done(SSL *s)
 	{
 	unsigned char *p;
 
@@ -761,7 +767,7 @@ int dtls1_send_server_done(SSL *s)
 	return(dtls1_do_write(s,SSL3_RT_HANDSHAKE));
 	}
 
-int dtls1_send_server_key_exchange(SSL *s)
+static int dtls1_send_server_key_exchange(SSL *s)
 	{
 #ifndef OPENSSL_NO_RSA
 	unsigned char *q;
@@ -1107,7 +1113,7 @@ err:
 	return(-1);
 	}
 
-int dtls1_send_server_certificate(SSL *s)
+static int dtls1_send_server_certificate(SSL *s)
 	{
 	unsigned long l;
 	X509 *x;
diff --git a/ssl/s23_srvr.c b/ssl/s23_srvr.c
index ddf5d4c..25a7fd5 100644
--- a/ssl/s23_srvr.c
+++ b/ssl/s23_srvr.c
@@ -117,7 +117,7 @@
 #include <openssl/evp.h>
 
 static const SSL_METHOD *ssl23_get_server_method(int ver);
-int ssl23_get_client_hello(SSL *s);
+static int ssl23_get_client_hello(SSL *s);
 static const SSL_METHOD *ssl23_get_server_method(int ver)
 	{
 #ifndef OPENSSL_NO_SSL2
@@ -228,7 +228,7 @@ end:
 	}
 
 
-int ssl23_get_client_hello(SSL *s)
+static int ssl23_get_client_hello(SSL *s)
 	{
 	char buf_space[11]; /* Request this many bytes in initial read.
 	                     * We can detect SSL 3.0/TLS 1.0 Client Hellos
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index ccfe399..0e0ebcf 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -159,6 +159,8 @@
 
 const char *SSL_version_str=OPENSSL_VERSION_TEXT;
 
+static void ssl_clear_cipher_ctx(SSL *s);
+
 SSL3_ENC_METHOD ssl3_undef_enc_method={
 	/* evil casts, but these functions are only called if there's a library bug */
 	(int (*)(SSL *,int))ssl_undefined_function,
@@ -2286,7 +2288,8 @@ int ssl_undefined_const_function(const SSL *s)
 	return(0);
 	}
 
-SSL_METHOD *ssl_bad_method(int ver)
+/* Unused? */
+static SSL_METHOD *ssl_bad_method(int ver)
 	{
 	SSLerr(SSL_F_SSL_BAD_METHOD,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
 	return(NULL);
@@ -2434,7 +2437,7 @@ err:
 	return(ret);
 	}
 
-void ssl_clear_cipher_ctx(SSL *s)
+static void ssl_clear_cipher_ctx(SSL *s)
 	{
 	if (s->enc_read_ctx != NULL)
 		{
diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h
index a65071a..cee76c2 100644
--- a/ssl/ssl_locl.h
+++ b/ssl/ssl_locl.h
@@ -566,8 +566,6 @@ OPENSSL_EXTERN SSL_CIPHER ssl2_ciphers[];
 OPENSSL_EXTERN SSL_CIPHER ssl3_ciphers[];
 
 
-SSL_METHOD *ssl_bad_method(int ver);
-
 extern SSL3_ENC_METHOD TLSv1_enc_data;
 extern SSL3_ENC_METHOD SSLv3_enc_data;
 extern SSL3_ENC_METHOD DTLSv1_enc_data;
@@ -757,7 +755,6 @@ const SSL_METHOD *func_name(void)  \
 	return &func_name##_data; \
 	}
 
-void ssl_clear_cipher_ctx(SSL *s);
 int ssl_clear_bad_session(SSL *s);
 CERT *ssl_cert_new(void);
 CERT *ssl_cert_dup(CERT *cert);
@@ -910,7 +907,6 @@ int dtls1_read_failed(SSL *s, int code);
 int dtls1_buffer_message(SSL *s, int ccs);
 int dtls1_retransmit_message(SSL *s, unsigned short seq, 
 	unsigned long frag_off, int *found);
-void dtls1_clear_record_buffer(SSL *s);
 void dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr);
 void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr);
 void dtls1_reset_seq_numbers(SSL *s, int rw);
@@ -932,11 +928,6 @@ int ssl3_get_key_exchange(SSL *s);
 int ssl3_get_server_certificate(SSL *s);
 int ssl3_check_cert_and_algorithm(SSL *s);
 
-int dtls1_client_hello(SSL *s);
-int dtls1_send_client_certificate(SSL *s);
-int dtls1_send_client_key_exchange(SSL *s);
-int dtls1_send_client_verify(SSL *s);
-
 /* some server-only functions */
 int ssl3_get_client_hello(SSL *s);
 int ssl3_send_server_hello(SSL *s);
@@ -949,15 +940,6 @@ int ssl3_get_client_certificate(SSL *s);
 int ssl3_get_client_key_exchange(SSL *s);
 int ssl3_get_cert_verify(SSL *s);
 
-int dtls1_send_hello_request(SSL *s);
-int dtls1_send_server_hello(SSL *s);
-int dtls1_send_server_certificate(SSL *s);
-int dtls1_send_server_key_exchange(SSL *s);
-int dtls1_send_certificate_request(SSL *s);
-int dtls1_send_server_done(SSL *s);
-
-
-
 int ssl23_accept(SSL *s);
 int ssl23_connect(SSL *s);
 int ssl23_read_bytes(SSL *s, int n);
@@ -977,9 +959,6 @@ void dtls1_clear(SSL *s);
 long dtls1_ctrl(SSL *s,int cmd, long larg, void *parg);
 
 long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok);
-int dtls1_get_record(SSL *s);
-int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
-	unsigned int len, int create_empty_fragement);
 int dtls1_dispatch_alert(SSL *s);
 int dtls1_enc(SSL *s, int snd);
 

Reply via email to