Mailing List Archive

Don't leak symbols into static library
Before patch below:

jas@mocca:~/src/libgcrypt$ nm -B src/.libs/libgcrypt.a |grep ' T '|grep -v gcry|grep -v __
000059c0 T Camellia_DecryptBlock
00005b90 T Camellia_Ekeygen
00005850 T Camellia_EncryptBlock
00003020 T camellia_decrypt128
000049b0 T camellia_decrypt256
00002530 T camellia_encrypt128
00003b10 T camellia_encrypt256
00000000 T camellia_setup128
00005b30 T camellia_setup192
00000f10 T camellia_setup256
00001d30 T ac_data_extract
jas@mocca:~/src/libgcrypt$

After patch below:

jas@mocca:~/src/libgcrypt$ nm -B src/.libs/libgcrypt.a |grep ' T '|grep -v gcry|grep -v __
jas@mocca:~/src/libgcrypt$

What do you think?

/Simon

Index: cipher/camellia.h
===================================================================
--- cipher/camellia.h (revision 1283)
+++ cipher/camellia.h (working copy)
@@ -1,6 +1,6 @@
/* camellia.h ver 1.2.0
*
- * Copyright (C) 2006,2007
+ * Copyright (C) 2006,2007,2008
* NTT (Nippon Telegraph and Telephone Corporation).
*
* This library is free software; you can redistribute it and/or
@@ -28,6 +28,7 @@
*
* This prefixes all external symbols with "foo_".
*/
+#define CAMELLIA_EXT_SYM_PREFIX _gcry_
#ifdef CAMELLIA_EXT_SYM_PREFIX
#define CAMELLIA_PREFIX1(x,y) x ## y
#define CAMELLIA_PREFIX2(x,y) CAMELLIA_PREFIX1(x,y)
Index: cipher/ac.c
===================================================================
--- cipher/ac.c (revision 1283)
+++ cipher/ac.c (working copy)
@@ -1,6 +1,6 @@
/* ac.c - Alternative interface for asymmetric cryptography.
Copyright (C) 2003, 2004, 2005, 2006
- 2007 Free Software Foundation, Inc.
+ 2007, 2008 Free Software Foundation, Inc.

This file is part of Libgcrypt.

@@ -1117,7 +1117,7 @@

(IDENTIFIER [...]
(ALGORITHM <list of named MPI values>)) */
-gcry_error_t
+static gcry_error_t
ac_data_extract (const char *identifier, const char *algorithm,
gcry_sexp_t sexp, gcry_ac_data_t *data)
{

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: Don't leak symbols into static library [ In reply to ]
On Fri, 18 Apr 2008 09:00, simon@josefsson.org said:

> 000059c0 T Camellia_DecryptBlock

Ooops. The linker script made it invisible to me.

> * This prefixes all external symbols with "foo_".
> */
> +#define CAMELLIA_EXT_SYM_PREFIX _gcry_

Okay, I put it into config.h to keep this file unmodified.

> Index: cipher/ac.c
> @@ -1117,7 +1117,7 @@
>
> (IDENTIFIER [...]
> (ALGORITHM <list of named MPI values>)) */
> -gcry_error_t
> +static gcry_error_t
> ac_data_extract (const char *identifier, const char *algorithm,
> gcry_sexp_t sexp, gcry_ac_data_t *data)


What is the reasons for this?


Salam-Shalom,

Werner

--
Die Gedanken sind frei. Auschnahme regelt ein Bundeschgesetz.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: Don't leak symbols into static library [ In reply to ]
Werner Koch <wk@gnupg.org> writes:

>> Index: cipher/ac.c
>> @@ -1117,7 +1117,7 @@
>>
>> (IDENTIFIER [...]
>> (ALGORITHM <list of named MPI values>)) */
>> -gcry_error_t
>> +static gcry_error_t
>> ac_data_extract (const char *identifier, const char *algorithm,
>> gcry_sexp_t sexp, gcry_ac_data_t *data)
>
>
> What is the reasons for this?

The same as for the camellia change: the 'ac_data_extract' function is
exported to the static library. As far as I could tell, the function is
only ever called from the same file it is defined in:

jas@mocca:~/src/libgcrypt$ rgrep ac_data_extract *|grep -v .svn
cipher/ac.c:ac_data_extract (const char *identifier, const char *algorithm,
cipher/ac.c: err = ac_data_extract ("private-key", handle->algorithm_name,
cipher/ac.c: err = ac_data_extract ("public-key", handle->algorithm_name,
cipher/ac.c: err = ac_data_extract ("enc-val", handle->algorithm_name,
cipher/ac.c: err = ac_data_extract ("sig-val", handle->algorithm_name,
Binary file cipher/.libs/libcipher.a matches
Binary file cipher/.libs/ac.o matches
cipher/ChangeLog: (ac_data_extract): Use GCRY_AC_FLAG_DEALLOC instead of
Binary file cipher/ac.o matches
Binary file src/.libs/libgcrypt.so.11 matches
Binary file src/.libs/libgcrypt.so.11.4.3 matches
Binary file src/.libs/libgcrypt.a matches
Binary file src/.libs/libgcrypt.so matches
jas@mocca:~/src/libgcrypt$

Thus, I think it should be marked as 'static'.

Note that it is not mentioned in the *.def file, so for shared libraries
you can't use the function anyway.

/Simon

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: Don't leak symbols into static library [ In reply to ]
On Fri, 18 Apr 2008 11:20, simon@josefsson.org said:

> The same as for the camellia change: the 'ac_data_extract' function is
> exported to the static library. As far as I could tell, the function is

Sorry, I somehow read gcry_ac_data_extract. I'll change it.


Salam-Shalom,

Werner

--
Die Gedanken sind frei. Auschnahme regelt ein Bundeschgesetz.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel