Sophie

Sophie

distrib > Mageia > 8 > armv7hl > by-pkgid > 5667d57806fe09dd4d8e99d86d2447b7 > files > 10

android-tools-10.0.0_r2-3.mga8.src.rpm

--- android-tools-9.0.0_r47/core/adb/client/auth.cpp.openssl	2019-09-03 04:46:52.650018990 +0200
+++ android-tools-9.0.0_r47/core/adb/client/auth.cpp	2019-09-03 04:59:02.410592827 +0200
@@ -34,7 +34,9 @@
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
 #include <crypto_utils/android_pubkey.h>
+#if defined(OPENSSL_IS_BORINGSSL)
 #include <openssl/base64.h>
+#endif
 #include <openssl/evp.h>
 #include <openssl/objects.h>
 #include <openssl/pem.h>
@@ -63,10 +63,14 @@ static bool calculate_public_key(std::st
     }
 
     size_t expected_length;
+#if defined(OPENSSL_IS_BORINGSSL)
     if (!EVP_EncodedLength(&expected_length, sizeof(binary_key_data))) {
         LOG(ERROR) << "Public key too large to base64 encode";
         return false;
     }
+#else
+    expected_length = 1 + ((sizeof(binary_key_data) + 2) / 3 * 4);
+#endif
 
     out->resize(expected_length);
     size_t actual_length = EVP_EncodeBlock(reinterpret_cast<uint8_t*>(out->data()), binary_key_data,
--- android-tools-9.0.0_r47/core/libcrypto_utils/android_pubkey.c.openssl	2019-09-03 01:32:10.745135078 +0200
+++ android-tools-9.0.0_r47/core/libcrypto_utils/android_pubkey.c	2019-09-03 05:10:20.819537173 +0200
@@ -65,6 +65,8 @@ bool android_pubkey_decode(const uint8_t
   const RSAPublicKey* key_struct = (RSAPublicKey*)key_buffer;
   bool ret = false;
   uint8_t modulus_buffer[ANDROID_PUBKEY_MODULUS_SIZE];
+  BIGNUM * n;
+  BIGNUM * e;
   RSA* new_key = RSA_new();
   if (!new_key) {
     goto cleanup;
@@ -81,14 +83,18 @@ bool android_pubkey_decode(const uint8_t
   // Convert the modulus to big-endian byte order as expected by BN_bin2bn.
   memcpy(modulus_buffer, key_struct->modulus, sizeof(modulus_buffer));
   reverse_bytes(modulus_buffer, sizeof(modulus_buffer));
-  new_key->n = BN_bin2bn(modulus_buffer, sizeof(modulus_buffer), NULL);
-  if (!new_key->n) {
+  n = BN_bin2bn(modulus_buffer, sizeof(modulus_buffer), NULL);
+  if (!n) {
     goto cleanup;
   }
 
   // Read the exponent.
-  new_key->e = BN_new();
-  if (!new_key->e || !BN_set_word(new_key->e, key_struct->exponent)) {
+  e = BN_new();
+  if (!e || !BN_set_word(e, key_struct->exponent)) {
+    goto cleanup;
+  }
+
+  if (!RSA_set0_key(new_key, n, e, NULL)) {
     goto cleanup;
   }
 
@@ -111,7 +117,7 @@ cleanup:
 }
 
 static bool android_pubkey_encode_bignum(const BIGNUM* num, uint8_t* buffer) {
-  if (!BN_bn2bin_padded(buffer, ANDROID_PUBKEY_MODULUS_SIZE, num)) {
+  if (!BN_bn2binpad(num, buffer, ANDROID_PUBKEY_MODULUS_SIZE)) {
     return false;
   }