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, bschaepers/openssl-1.1 has been created
        at  c62a4c345eba723fcbd8ba281bbe46159b36bca5 (commit)

http://git.fawkesrobotics.org/fawkes.git/bschaepers/openssl-1.1

- *Log* ---------------------------------------------------------------
commit 601894ca7846ea1350d89e503acca56b3b3e9731
Author:     Bjoern Schaepers <bjoern.schaep...@rwth-aachen.de>
AuthorDate: Thu Dec 1 22:06:22 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaep...@rwth-aachen.de>
CommitDate: Thu Dec 1 22:06:22 2016 +0100

    Protobuf-Comm: Adapt to OpenSSL1.1

http://git.fawkesrobotics.org/fawkes.git/commit/601894c
http://trac.fawkesrobotics.org/changeset/601894c

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit b9fa850764185ad9c0cc4a9d6c2f682bca643389
Author:     Bjoern Schaepers <bjoern.schaep...@rwth-aachen.de>
AuthorDate: Thu Dec 1 22:06:50 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaep...@rwth-aachen.de>
CommitDate: Thu Dec 1 22:06:50 2016 +0100

    Netcomm: Adapt to OpenSSL1.1

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

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit c62a4c345eba723fcbd8ba281bbe46159b36bca5
Author:     Bjoern Schaepers <bjoern.schaep...@rwth-aachen.de>
AuthorDate: Thu Dec 1 22:07:33 2016 +0100
Commit:     Bjoern Schaepers <bjoern.schaep...@rwth-aachen.de>
CommitDate: Thu Dec 1 22:07:33 2016 +0100

    Iface-Generator: Adapt to OpenSSL1.1

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

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


- *Summary* -----------------------------------------------------------
 src/libs/interfaces/generator/digest.cpp |   11 ++++++-----
 src/libs/netcomm/crypto/decrypt.cpp      |    9 +++++----
 src/libs/netcomm/crypto/encrypt.cpp      |   17 +++++++++--------
 3 files changed, 20 insertions(+), 17 deletions(-)


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

- *commit* 601894ca7846ea1350d89e503acca56b3b3e9731 - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaep...@rwth-aachen.de>
Date:    Thu Dec 1 22:06:22 2016 +0100
Subject: Protobuf-Comm: Adapt to OpenSSL1.1

 src/libs/protobuf_comm/crypto.cpp |   17 +++++++++--------
 1 files changed, 9 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..fe432c6 100644
--- a/src/libs/protobuf_comm/crypto.cpp
+++ b/src/libs/protobuf_comm/crypto.cpp
@@ -43,6 +43,7 @@
 #  include <openssl/rand.h>
 #  include <openssl/sha.h>
 #  include <cstring>
+#  include <memory>
 #endif
 
 namespace protobuf_comm {
@@ -115,21 +116,21 @@ 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))
+  std::unique_ptr<EVP_CIPHER_CTX, void(*)(EVP_CIPHER_CTX*)> 
ctx(EVP_CIPHER_CTX_new(), EVP_CIPHER_CTX_free);
+  if ( ! EVP_EncryptInit(ctx.get(), evp_cipher, key_, iv_hash))
   {
     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.get(), enc_m, &outl,
                           (unsigned char *)plain.c_str(), plain.size()) )
   {
     throw std::runtime_error("EncryptUpdate failed");
   }
 
   int plen = 0;
-  if ( ! EVP_EncryptFinal_ex(&ctx, enc_m + outl, &plen) ) {
+  if ( ! EVP_EncryptFinal_ex(ctx.get(), enc_m + outl, &plen) ) {
     throw std::runtime_error("EncryptFinal failed");
   }
   outl += plen;
@@ -231,21 +232,21 @@ 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))
+  std::unique_ptr<EVP_CIPHER_CTX, void(*)(EVP_CIPHER_CTX*)> 
ctx(EVP_CIPHER_CTX_new(), EVP_CIPHER_CTX_free);
+  if ( ! EVP_DecryptInit(ctx.get(), evp_cipher, (const unsigned char 
*)keys_[cipher].c_str(), iv))
   {
     throw std::runtime_error("Could not initialize cipher context");
   }
 
   int outl = plain_size;
-  if ( ! EVP_DecryptUpdate(&ctx,
+  if ( ! EVP_DecryptUpdate(ctx.get(),
                           (unsigned char *)plain, &outl, enc_m, enc_size))
   {
     throw std::runtime_error("DecryptUpdate failed");
   }
 
   int plen = 0;
-  if ( ! EVP_DecryptFinal(&ctx, (unsigned char *)plain + outl, &plen) ) {
+  if ( ! EVP_DecryptFinal(ctx.get(), (unsigned char *)plain + outl, &plen) ) {
     throw std::runtime_error("DecryptFinal failed");
   }
   outl += plen;

- *commit* b9fa850764185ad9c0cc4a9d6c2f682bca643389 - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaep...@rwth-aachen.de>
Date:    Thu Dec 1 22:06:50 2016 +0100
Subject: Netcomm: Adapt to OpenSSL1.1

 src/libs/netcomm/crypto/decrypt.cpp |    9 +++++----
 src/libs/netcomm/crypto/encrypt.cpp |   17 +++++++++--------
 2 files changed, 14 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..bd18c25 100644
--- a/src/libs/netcomm/crypto/decrypt.cpp
+++ b/src/libs/netcomm/crypto/decrypt.cpp
@@ -24,6 +24,7 @@
 #include <netcomm/crypto/decrypt.h>
 #ifdef HAVE_LIBCRYPTO
 #  include <openssl/evp.h>
+#  include <memory>
 #else
 #  include <cstring>
 #endif
@@ -124,20 +125,20 @@ MessageDecryptor::decrypt()
   }
 
 #ifdef HAVE_LIBCRYPTO
-  EVP_CIPHER_CTX ctx;
-  if ( ! EVP_DecryptInit(&ctx, EVP_aes_128_ecb(), key, iv) ) {
+  std::unique_ptr<EVP_CIPHER_CTX, void(*)(EVP_CIPHER_CTX*)> 
ctx(EVP_CIPHER_CTX_new(), EVP_CIPHER_CTX_free);
+  if ( ! EVP_DecryptInit(ctx.get(), EVP_aes_128_ecb(), key, iv) ) {
     throw MessageDecryptionException("Could not initialize cipher context");
   }
 
   int outl = plain_buffer_length;
-  if ( ! EVP_DecryptUpdate(&ctx,
+  if ( ! EVP_DecryptUpdate(ctx.get(),
                           (unsigned char *)plain_buffer, &outl,
                           (unsigned char *)crypt_buffer, crypt_buffer_length) 
) {
     throw MessageDecryptionException("DecryptUpdate failed");
   }
 
   int plen = 0;
-  if ( ! EVP_DecryptFinal(&ctx, (unsigned char *)plain_buffer + outl, &plen) ) 
{
+  if ( ! EVP_DecryptFinal(ctx.get(), (unsigned char *)plain_buffer + outl, 
&plen) ) {
     throw MessageDecryptionException("DecryptFinal failed");
   }
   outl += plen;
diff --git a/src/libs/netcomm/crypto/encrypt.cpp 
b/src/libs/netcomm/crypto/encrypt.cpp
index 558110d..6d302dc 100644
--- a/src/libs/netcomm/crypto/encrypt.cpp
+++ b/src/libs/netcomm/crypto/encrypt.cpp
@@ -25,6 +25,7 @@
 
 #ifdef HAVE_LIBCRYPTO
 #  include <openssl/evp.h>
+#  include <memory>
 #else
 #  include <cstring>
 #endif
@@ -135,10 +136,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);
+  std::unique_ptr<EVP_CIPHER_CTX, void(*)(EVP_CIPHER_CTX*)> 
ctx(EVP_CIPHER_CTX_new(), EVP_CIPHER_CTX_free);
+  EVP_EncryptInit(ctx.get(), EVP_aes_128_ecb(), key, iv);
+  size_t rv = plain_buffer_length + EVP_CIPHER_CTX_block_size(ctx.get());
+  EVP_CIPHER_CTX_cleanup(ctx.get());
   return rv;
 #else
   return plain_buffer_length;
@@ -172,21 +173,21 @@ MessageEncryptor::encrypt()
   }
 
 #ifdef HAVE_LIBCRYPTO
-  EVP_CIPHER_CTX ctx;
-  if ( ! EVP_EncryptInit(&ctx, EVP_aes_128_ecb(), key, iv) ) {
+  std::unique_ptr<EVP_CIPHER_CTX, void(*)(EVP_CIPHER_CTX*)> 
ctx(EVP_CIPHER_CTX_new(), EVP_CIPHER_CTX_free);
+  if ( ! EVP_EncryptInit(ctx.get(), EVP_aes_128_ecb(), key, iv) ) {
     throw MessageEncryptionException("Could not initialize cipher context");
   }
 
 
   int outl = crypt_buffer_length;
-  if ( ! EVP_EncryptUpdate(&ctx,
+  if ( ! EVP_EncryptUpdate(ctx.get(),
                           (unsigned char *)crypt_buffer, &outl,
                           (unsigned char *)plain_buffer, plain_buffer_length) 
) {
     throw MessageEncryptionException("EncryptUpdate failed");
   }
 
   int plen = 0;
-  if ( ! EVP_EncryptFinal_ex(&ctx, (unsigned char *)crypt_buffer + outl, 
&plen) ) {
+  if ( ! EVP_EncryptFinal_ex(ctx.get(), (unsigned char *)crypt_buffer + outl, 
&plen) ) {
     throw MessageEncryptionException("EncryptFinal failed");
   }
   outl += plen;

- *commit* c62a4c345eba723fcbd8ba281bbe46159b36bca5 - - - - - - - - - -
Author:  Bjoern Schaepers <bjoern.schaep...@rwth-aachen.de>
Date:    Thu Dec 1 22:07:33 2016 +0100
Subject: Iface-Generator: Adapt to OpenSSL1.1

 src/libs/interfaces/generator/digest.cpp |   11 ++++++-----
 1 files changed, 6 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..2f916e2 100644
--- a/src/libs/interfaces/generator/digest.cpp
+++ b/src/libs/interfaces/generator/digest.cpp
@@ -25,6 +25,7 @@
 
 #include <cstdio>
 #include <openssl/evp.h>
+#include <memory>
 
 #define FILE_STEP 1024
 
@@ -44,8 +45,8 @@ InterfaceDigest::InterfaceDigest(std::string config_filename)
 {
   digest = NULL;
 
-  EVP_MD_CTX ctx;
-  if ( ! EVP_DigestInit(&ctx, EVP_md5())) {
+  std::unique_ptr<EVP_MD_CTX, void(*)(EVP_MD_CTX*)> ctx(EVP_MD_CTX_new(), 
EVP_MD_CTX_free);
+  if ( ! EVP_DigestInit(ctx.get(), EVP_md5())) {
     throw Exception("Could not initialize digest context");
   }
 
@@ -54,7 +55,7 @@ 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.get(), buf, rb) ) {
        fclose(f);
        throw Exception("Failed to update digest");
       }
@@ -66,10 +67,10 @@ InterfaceDigest::InterfaceDigest(std::string 
config_filename)
   }
   fclose(f);
 
-  digest_size=EVP_MD_CTX_size(&ctx);
+  digest_size=EVP_MD_CTX_size(ctx.get());
   digest = new unsigned char[digest_size];
 
-  if ( ! EVP_DigestFinal(&ctx, digest, NULL) ) {
+  if ( ! EVP_DigestFinal(ctx.get(), digest, NULL) ) {
     delete digest;
     digest = NULL;
     throw Exception("Could not finalize digest");




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org
_______________________________________________
fawkes-commits mailing list
fawkes-commits@lists.kbsg.rwth-aachen.de
https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits

Reply via email to