[Fawkes Git] branch/thofmann/openssl110: created (0.5.0-3370-gd2332ae)

Till Hofmann hofmann at kbsg.rwth-aachen.de
Sun Nov 6 12:30:17 CET 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, thofmann/openssl110 has been created
        at  d2332aeff8d26dbc26c35251e75e145d5237c18a (commit)

http://git.fawkesrobotics.org/fawkes.git/thofmann/openssl110

- *Log* ---------------------------------------------------------------
commit 3b4f8439887946a3e0c524748e7d11a029ac88a1
Author:     Till Hofmann <hofmann at kbsg.rwth-aachen.de>
AuthorDate: Sun Nov 6 12:14:34 2016 +0100
Commit:     Till Hofmann <hofmann at kbsg.rwth-aachen.de>
CommitDate: Sun Nov 6 12:14:34 2016 +0100

    netcomm: add support for OpenSSL 1.1.0
    
    EVP_CIPHER_CTX was made opaque in OpenSSL 1.1.0. Use EVP_CIPHER_CTX_new
    and EVP_CIPHER_CTX_free to create EVP_CIPHER_CTX objects instead.
    
    This change is backwards compatible as EVP_CIPHER_CTX_new and
    EVP_CIPHER_CTX_free are available in older OpenSSL version, too.

http://git.fawkesrobotics.org/fawkes.git/commit/3b4f843
http://trac.fawkesrobotics.org/changeset/3b4f843

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit 17470e03e4d3d48abbe4bfce68bc1bc81a888a6e
Author:     Till Hofmann <hofmann at kbsg.rwth-aachen.de>
AuthorDate: Sun Nov 6 12:19:30 2016 +0100
Commit:     Till Hofmann <hofmann at kbsg.rwth-aachen.de>
CommitDate: Sun Nov 6 12:19:30 2016 +0100

    protobuf_comm: add support for OpenSSL 1.1.0
    
    EVP_CIPHER_CTX was made opaque in OpenSSL 1.1.0. Use CIPHER_CTX_new and
    EVP_CIPHER_CTX_free to create EVP_CIPHER_CTX objects instead.
    
    This change is backwards compatible as EVP_CIPHER_CTX_new and
    EVP_CIPHER_CTX_free are available in older OpenSSL version, too.

http://git.fawkesrobotics.org/fawkes.git/commit/17470e0
http://trac.fawkesrobotics.org/changeset/17470e0

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit d2332aeff8d26dbc26c35251e75e145d5237c18a
Author:     Till Hofmann <hofmann at kbsg.rwth-aachen.de>
AuthorDate: Sun Nov 6 12:24:05 2016 +0100
Commit:     Till Hofmann <hofmann at kbsg.rwth-aachen.de>
CommitDate: Sun Nov 6 12:24:05 2016 +0100

    protobuf_comm: add support for OpenSSL 1.1.0
    
    EVP_MD_CTX was made opaque in OpenSSL 1.1.0. Use EVP_MD_CTX_create
    EVP_MD_CTX_destroy to create EVP_MD_CTX objects instead.
    
    This change is backwards compatible as EVP_MD_CTX_create and
    EVP_MD_CTX_destroy are available in older OpenSSL version, too.

http://git.fawkesrobotics.org/fawkes.git/commit/d2332ae
http://trac.fawkesrobotics.org/changeset/d2332ae

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/libs/interfaces/generator/digest.cpp |   15 ++++++++++-----
 src/libs/protobuf_comm/crypto.cpp        |   24 ++++++++++++++++--------
 2 files changed, 26 insertions(+), 13 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* 3b4f8439887946a3e0c524748e7d11a029ac88a1 - - - - - - - - - -
Author:  Till Hofmann <hofmann at kbsg.rwth-aachen.de>
Date:    Sun Nov 6 12:14:34 2016 +0100
Subject: netcomm: add support for OpenSSL 1.1.0

 src/libs/netcomm/crypto/decrypt.cpp |   12 ++++++++----
 src/libs/netcomm/crypto/encrypt.cpp |   20 ++++++++++++--------
 2 files changed, 20 insertions(+), 12 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/netcomm/crypto/decrypt.cpp b/src/libs/netcomm/crypto/decrypt.cpp
index 2b808be..1a900bd 100644
--- a/src/libs/netcomm/crypto/decrypt.cpp
+++ b/src/libs/netcomm/crypto/decrypt.cpp
@@ -124,24 +124,28 @@ MessageDecryptor::decrypt()
   }
 
 #ifdef HAVE_LIBCRYPTO
-  EVP_CIPHER_CTX ctx;
-  if ( ! EVP_DecryptInit(&ctx, EVP_aes_128_ecb(), key, iv) ) {
+  EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
+  if ( ! EVP_DecryptInit(ctx, EVP_aes_128_ecb(), key, iv) ) {
+    EVP_CIPHER_CTX_free(ctx);
     throw MessageDecryptionException("Could not initialize cipher context");
   }
 
   int outl = plain_buffer_length;
-  if ( ! EVP_DecryptUpdate(&ctx,
+  if ( ! EVP_DecryptUpdate(ctx,
 			   (unsigned char *)plain_buffer, &outl,
 			   (unsigned char *)crypt_buffer, crypt_buffer_length) ) {
+    EVP_CIPHER_CTX_free(ctx);
     throw MessageDecryptionException("DecryptUpdate failed");
   }
 
   int plen = 0;
-  if ( ! EVP_DecryptFinal(&ctx, (unsigned char *)plain_buffer + outl, &plen) ) {
+  if ( ! EVP_DecryptFinal(ctx, (unsigned char *)plain_buffer + outl, &plen) ) {
+    EVP_CIPHER_CTX_free(ctx);
     throw MessageDecryptionException("DecryptFinal failed");
   }
   outl += plen;
 
+  EVP_CIPHER_CTX_free(ctx);
   return outl;
 #else
   // Plain-text copy-through for debugging.
diff --git a/src/libs/netcomm/crypto/encrypt.cpp b/src/libs/netcomm/crypto/encrypt.cpp
index 558110d..dfc8e15 100644
--- a/src/libs/netcomm/crypto/encrypt.cpp
+++ b/src/libs/netcomm/crypto/encrypt.cpp
@@ -135,10 +135,10 @@ MessageEncryptor::recommended_crypt_buffer_size()
   }
 
 #ifdef HAVE_LIBCRYPTO
-  EVP_CIPHER_CTX ctx;
-  EVP_EncryptInit(&ctx, EVP_aes_128_ecb(), key, iv);
-  size_t rv = plain_buffer_length + EVP_CIPHER_CTX_block_size(&ctx);
-  EVP_CIPHER_CTX_cleanup(&ctx);
+  EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
+  EVP_EncryptInit(ctx, EVP_aes_128_ecb(), key, iv);
+  size_t rv = plain_buffer_length + EVP_CIPHER_CTX_block_size(ctx);
+  EVP_CIPHER_CTX_free(ctx);
   return rv;
 #else
   return plain_buffer_length;
@@ -172,25 +172,29 @@ MessageEncryptor::encrypt()
   }
 
 #ifdef HAVE_LIBCRYPTO
-  EVP_CIPHER_CTX ctx;
-  if ( ! EVP_EncryptInit(&ctx, EVP_aes_128_ecb(), key, iv) ) {
+  EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
+  if ( ! EVP_EncryptInit(ctx, EVP_aes_128_ecb(), key, iv) ) {
+    EVP_CIPHER_CTX_free(ctx);
     throw MessageEncryptionException("Could not initialize cipher context");
   }
 
 
   int outl = crypt_buffer_length;
-  if ( ! EVP_EncryptUpdate(&ctx,
+  if ( ! EVP_EncryptUpdate(ctx,
 			   (unsigned char *)crypt_buffer, &outl,
 			   (unsigned char *)plain_buffer, plain_buffer_length) ) {
+    EVP_CIPHER_CTX_free(ctx);
     throw MessageEncryptionException("EncryptUpdate failed");
   }
 
   int plen = 0;
-  if ( ! EVP_EncryptFinal_ex(&ctx, (unsigned char *)crypt_buffer + outl, &plen) ) {
+  if ( ! EVP_EncryptFinal_ex(ctx, (unsigned char *)crypt_buffer + outl, &plen) ) {
+    EVP_CIPHER_CTX_free(ctx);
     throw MessageEncryptionException("EncryptFinal failed");
   }
   outl += plen;
  
+  EVP_CIPHER_CTX_free(ctx);
   return outl;
 #else
   /* Plain text copy-through for debugging

- *commit* 17470e03e4d3d48abbe4bfce68bc1bc81a888a6e - - - - - - - - - -
Author:  Till Hofmann <hofmann at kbsg.rwth-aachen.de>
Date:    Sun Nov 6 12:19:30 2016 +0100
Subject: protobuf_comm: add support for OpenSSL 1.1.0

 src/libs/protobuf_comm/crypto.cpp |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/protobuf_comm/crypto.cpp b/src/libs/protobuf_comm/crypto.cpp
index d42aead..3251f08 100644
--- a/src/libs/protobuf_comm/crypto.cpp
+++ b/src/libs/protobuf_comm/crypto.cpp
@@ -115,25 +115,29 @@ BufferEncryptor::encrypt(const std::string &plain, std::string &enc)
     enc_m += iv_size;
   }
 
-  EVP_CIPHER_CTX ctx;
-  if ( ! EVP_EncryptInit(&ctx, evp_cipher, key_, iv_hash))
+  EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
+  if ( ! EVP_EncryptInit(ctx, evp_cipher, key_, iv_hash))
   {
+    EVP_CIPHER_CTX_free(ctx);
     throw std::runtime_error("Could not initialize cipher context");
   }
 
   int outl = enc.size() - iv_size;
-  if ( ! EVP_EncryptUpdate(&ctx, enc_m, &outl,
+  if ( ! EVP_EncryptUpdate(ctx, enc_m, &outl,
 			   (unsigned char *)plain.c_str(), plain.size()) )
   {
+    EVP_CIPHER_CTX_free(ctx);
     throw std::runtime_error("EncryptUpdate failed");
   }
 
   int plen = 0;
-  if ( ! EVP_EncryptFinal_ex(&ctx, enc_m + outl, &plen) ) {
+  if ( ! EVP_EncryptFinal_ex(ctx, enc_m + outl, &plen) ) {
+    EVP_CIPHER_CTX_free(ctx);
     throw std::runtime_error("EncryptFinal failed");
   }
   outl += plen;
  
+  EVP_CIPHER_CTX_free(ctx);
   enc.resize(outl + iv_size);
 #else
   throw std::runtime_error("Encryption support not available");
@@ -231,25 +235,29 @@ BufferDecryptor::decrypt(int cipher, const void *enc, size_t enc_size, void *pla
   unsigned char *enc_m = (unsigned char *)enc + iv_size;
   enc_size -= iv_size;
 
-  EVP_CIPHER_CTX ctx;
-  if ( ! EVP_DecryptInit(&ctx, evp_cipher, (const unsigned char *)keys_[cipher].c_str(), iv))
+  EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
+  if ( ! EVP_DecryptInit(ctx, evp_cipher, (const unsigned char *)keys_[cipher].c_str(), iv))
   {
+    EVP_CIPHER_CTX_free(ctx);
     throw std::runtime_error("Could not initialize cipher context");
   }
 
   int outl = plain_size;
-  if ( ! EVP_DecryptUpdate(&ctx,
+  if ( ! EVP_DecryptUpdate(ctx,
 			   (unsigned char *)plain, &outl, enc_m, enc_size))
   {
+    EVP_CIPHER_CTX_free(ctx);
     throw std::runtime_error("DecryptUpdate failed");
   }
 
   int plen = 0;
-  if ( ! EVP_DecryptFinal(&ctx, (unsigned char *)plain + outl, &plen) ) {
+  if ( ! EVP_DecryptFinal(ctx, (unsigned char *)plain + outl, &plen) ) {
+    EVP_CIPHER_CTX_free(ctx);
     throw std::runtime_error("DecryptFinal failed");
   }
   outl += plen;
 
+  EVP_CIPHER_CTX_free(ctx);
   return outl;
 #else
   throw std::runtime_error("Decryption support not available");

- *commit* d2332aeff8d26dbc26c35251e75e145d5237c18a - - - - - - - - - -
Author:  Till Hofmann <hofmann at kbsg.rwth-aachen.de>
Date:    Sun Nov 6 12:24:05 2016 +0100
Subject: protobuf_comm: add support for OpenSSL 1.1.0

 src/libs/interfaces/generator/digest.cpp |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/interfaces/generator/digest.cpp b/src/libs/interfaces/generator/digest.cpp
index f37f2ab..8139d55 100644
--- a/src/libs/interfaces/generator/digest.cpp
+++ b/src/libs/interfaces/generator/digest.cpp
@@ -44,8 +44,9 @@ InterfaceDigest::InterfaceDigest(std::string config_filename)
 {
   digest = NULL;
 
-  EVP_MD_CTX ctx;
-  if ( ! EVP_DigestInit(&ctx, EVP_md5())) {
+  EVP_MD_CTX *ctx = EVP_MD_CTX_create();
+  if ( ! EVP_DigestInit(ctx, EVP_md5())) {
+    EVP_MD_CTX_destroy(ctx);
     throw Exception("Could not initialize digest context");
   }
 
@@ -54,26 +55,30 @@ InterfaceDigest::InterfaceDigest(std::string config_filename)
   while ( ! feof(f) && ! ferror(f) ) {
     size_t rb;
     if ((rb = fread(buf, 1, FILE_STEP, f)) > 0) {
-      if ( ! EVP_DigestUpdate(&ctx, buf, rb) ) {
+      if ( ! EVP_DigestUpdate(ctx, buf, rb) ) {
 	fclose(f);
+	EVP_MD_CTX_destroy(ctx);
 	throw Exception("Failed to update digest");
       }
     }
   }
   if ( ferror(f) ) {
     fclose(f);
+    EVP_MD_CTX_destroy(ctx);
     throw Exception("Failure while reading the file");
   }
   fclose(f);
 
-  digest_size=EVP_MD_CTX_size(&ctx);
+  digest_size=EVP_MD_CTX_size(ctx);
   digest = new unsigned char[digest_size];
 
-  if ( ! EVP_DigestFinal(&ctx, digest, NULL) ) {
+  if ( ! EVP_DigestFinal(ctx, digest, NULL) ) {
     delete digest;
     digest = NULL;
+    EVP_MD_CTX_destroy(ctx);
     throw Exception("Could not finalize digest");
   }
+  EVP_MD_CTX_destroy(ctx);
 }
 
 




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list