#11: include a field for a distribution- or variant- specific version number
------------------------+---------------------------------------------------
Reporter:  zooko        |     Owner:     
    Type:  enhancement  |    Status:  new
Priority:  major        |   Version:     
Keywords:               |  
------------------------+---------------------------------------------------

Comment(by zooko):

 I've been using a patch that does this in my local copy of Crypto++ and in
 the copy of Crypto++ that is bundled into my pycryptopp project (https
 ://tahoe-lafs.org/trac/pycryptopp). Here is the patch inline, and I'll
 also attach it as a file to this ticket:

 {{{
 Index: extraversion.h
 ===================================================================
 --- extraversion.h      (revision 0)
 +++ extraversion.h      (revision 0)
 @@ -0,0 +1,26 @@
 +/* If you are building this library without applying any patch to it,
 then
 + * please define CRYPTOPP_EXTRA_VERSION to "pristine". That will inform
 + * people that inspect the resulting library that you did not patch it.
 + *
 + * If you do patch it, please put an identifying version string for your
 + * patches into CRYPTOPP_EXTRA_VERSION. For example, the pycryptopp
 project
 + * includes a copy of Crypto++. The build script for pycryptopp
 automatically
 + * writes the current version of pycryptopp into extraversion.h so that
 if
 + * you link to or load a Crypto++ library you can tell whether it was one
 + * built by pycryptopp, and if so by what version of pycryptopp.
 + *
 + * Here is the build script that does that:
 + * https://tahoe-lafs.org/trac/pycryptopp/browser/setup.py
 + *
 + * Summary:
 + *
 + *   If you are building Crypto++ and are not applying any patch to it
 before
 + *   building, then please define CRYPTOPP_EXTRA_VERSION to "pristine",
 in
 + *   order to signal to anyone who inspects the resulting library that it
 + *   contains an unpatched version of Crypto++. If you are applying any
 + *   patches to it before building, then pleased define
 + *   CRYPTOPP_EXTRA_VERSION to be some version string with which people
 can
 + *   later look up what patches you applied,
 + */
 +
 +#define CRYPTOPP_EXTRA_VERSION "unspecified variant"
 Index: cryptlib.cpp
 ===================================================================
 --- cryptlib.cpp        (revision 532)
 +++ cryptlib.cpp        (working copy)
 @@ -16,8 +16,15 @@

  #include <memory>

 +#include "config.h"
 +
 +#include "extraversion.h"
 +const char *cryptopp_extra_version = CRYPTOPP_EXTRA_VERSION;
 +
  NAMESPACE_BEGIN(CryptoPP)

 +const char *const cryptopp_extra_version = CRYPTOPP_EXTRA_VERSION;
 +
  CRYPTOPP_COMPILE_ASSERT(sizeof(byte) == 1);
  CRYPTOPP_COMPILE_ASSERT(sizeof(word16) == 2);
  CRYPTOPP_COMPILE_ASSERT(sizeof(word32) == 4);
 Index: config.h
 ===================================================================
 --- config.h    (revision 532)
 +++ config.h    (working copy)
 @@ -1,6 +1,8 @@
  #ifndef CRYPTOPP_CONFIG_H
  #define CRYPTOPP_CONFIG_H

 +extern const char*cryptopp_extra_version;
 +
  // ***************** Important Settings ********************

  // define this if running on a big-endian CPU
 }}}

 Please apply this patch to Crypto++ trunk. If you do, then I can go ahead
 and ship my new version of pycryptopp with the following code in it:

 {{{
 --- a/pycryptopp/_pycryptoppmodule.cpp
 +++ b/pycryptopp/_pycryptoppmodule.cpp
 @@ -44,8 +44,15 @@ init_pycryptopp(void) {
      PyObject* version;

      /* a tuple of (Crypto++ version, extra-version) */
 -    #ifdef CRYPTOPP_EXTRA_VERSION
 -    version = Py_BuildValue("is", CRYPTOPP_VERSION,
 CRYPTOPP_EXTRA_VERSION);
 +    #if CRYPTOPP_VERSION >= 562
 +       /* starting in Crypto++ v5.6.2, there is a symbol named
 +          `cryptopp_extra_version' which is declared (external variable)
 in
 +          config.h and defined in cryptlib.cpp. Of course it is possible
 that
 +          the header file we've #include'd is from Crypto++ >= v5.6.2 but
 the
 +          dynamically linked library that we load is from an older
 version which
 +          doesn't have this symbol. In that case, the load will fail
 before we
 +          get this far. */
 +    version = Py_BuildValue("is", CRYPTOPP_VERSION,
 cryptopp_extra_version);
      #else
      version = Py_BuildValue("iO", CRYPTOPP_VERSION, Py_None);
      #endif
 }}}

 If you do not go ahead and commit the {{{cryptopp_extra_version}}} patch
 to Crypto++ trunk, then I will have to remove this code from the imminent
 new release of pycryptopp, because I won't be able to rely on all versions
 of Crypto++ newer than 562 having that symbol.

 Thank you!

-- 
Ticket URL: <http://sourceforge.net/apps/trac/cryptopp/ticket/11#comment:5>
cryptopp <http://sourceforge.net/projects/cryptopp/>
SF-project cryptopp

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to