Mageia Bugzilla – Attachment 10479 Details for
Bug 23853
Update android-tools to 9.0.0_r21
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
libcrypto utils openssl patch
libcrypto_utils-openssl-1.1.patch (text/plain), 2.64 KB, created by
Kristoffer Grundström
on 2018-11-17 01:13:58 CET
(
hide
)
Description:
libcrypto utils openssl patch
Filename:
MIME Type:
Creator:
Kristoffer Grundström
Created:
2018-11-17 01:13:58 CET
Size:
2.64 KB
patch
obsolete
>--- platform/system/core/libcrypto_utils/android_pubkey.c.omv~ 2017-09-02 14:38:59.204591842 +0200 >+++ platform/system/core/libcrypto_utils/android_pubkey.c 2017-09-02 14:58:51.204164288 +0200 >@@ -81,16 +81,17 @@ 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) { >+ BIGNUM *new_key_n = BN_bin2bn(modulus_buffer, sizeof(modulus_buffer), NULL); >+ if (!new_key_n) { > goto cleanup; > } > > // Read the exponent. >- new_key->e = BN_new(); >- if (!new_key->e || !BN_set_word(new_key->e, key_struct->exponent)) { >+ BIGNUM *new_key_e = BN_new(); >+ if (!new_key_e || !BN_set_word(new_key_e, key_struct->exponent)) { > goto cleanup; > } >+ RSA_set0_key(new_key, new_key_n, new_key_e, NULL); > > // Note that we don't extract the montgomery parameters n0inv and rr from > // the RSAPublicKey structure. They assume a word size of 32 bits, but >@@ -111,7 +112,11 @@ cleanup: > } > > static bool android_pubkey_encode_bignum(const BIGNUM* num, uint8_t* buffer) { >+#ifdef OPENSSL_IS_BORINGSSL > if (!BN_bn2bin_padded(buffer, ANDROID_PUBKEY_MODULUS_SIZE, num)) { >+#else >+ if (!BN_bn2binpad(num, buffer, ANDROID_PUBKEY_MODULUS_SIZE)) { >+#endif > return false; > } > >@@ -135,28 +140,30 @@ bool android_pubkey_encode(const RSA* ke > // Store the modulus size. > key_struct->modulus_size_words = ANDROID_PUBKEY_MODULUS_SIZE_WORDS; > >+ const BIGNUM *key_n, *key_e; >+ RSA_get0_key(key, &key_n, &key_e, NULL); > // Compute and store n0inv = -1 / N[0] mod 2^32. > if (!ctx || !r32 || !n0inv || !BN_set_bit(r32, 32) || >- !BN_mod(n0inv, key->n, r32, ctx) || >+ !BN_mod(n0inv, key_n, r32, ctx) || > !BN_mod_inverse(n0inv, n0inv, r32, ctx) || !BN_sub(n0inv, r32, n0inv)) { > goto cleanup; > } > key_struct->n0inv = (uint32_t)BN_get_word(n0inv); > > // Store the modulus. >- if (!android_pubkey_encode_bignum(key->n, key_struct->modulus)) { >+ if (!android_pubkey_encode_bignum(key_n, key_struct->modulus)) { > goto cleanup; > } > > // Compute and store rr = (2^(rsa_size)) ^ 2 mod N. > if (!ctx || !rr || !BN_set_bit(rr, ANDROID_PUBKEY_MODULUS_SIZE * 8) || >- !BN_mod_sqr(rr, rr, key->n, ctx) || >+ !BN_mod_sqr(rr, rr, key_n, ctx) || > !android_pubkey_encode_bignum(rr, key_struct->rr)) { > goto cleanup; > } > > // Store the exponent. >- key_struct->exponent = (uint32_t)BN_get_word(key->e); >+ key_struct->exponent = (uint32_t)BN_get_word(key_e); > > ret = true; >
--- platform/system/core/libcrypto_utils/android_pubkey.c.omv~ 2017-09-02 14:38:59.204591842 +0200 +++ platform/system/core/libcrypto_utils/android_pubkey.c 2017-09-02 14:58:51.204164288 +0200 @@ -81,16 +81,17 @@ 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) { + BIGNUM *new_key_n = BN_bin2bn(modulus_buffer, sizeof(modulus_buffer), NULL); + if (!new_key_n) { goto cleanup; } // Read the exponent. - new_key->e = BN_new(); - if (!new_key->e || !BN_set_word(new_key->e, key_struct->exponent)) { + BIGNUM *new_key_e = BN_new(); + if (!new_key_e || !BN_set_word(new_key_e, key_struct->exponent)) { goto cleanup; } + RSA_set0_key(new_key, new_key_n, new_key_e, NULL); // Note that we don't extract the montgomery parameters n0inv and rr from // the RSAPublicKey structure. They assume a word size of 32 bits, but @@ -111,7 +112,11 @@ cleanup: } static bool android_pubkey_encode_bignum(const BIGNUM* num, uint8_t* buffer) { +#ifdef OPENSSL_IS_BORINGSSL if (!BN_bn2bin_padded(buffer, ANDROID_PUBKEY_MODULUS_SIZE, num)) { +#else + if (!BN_bn2binpad(num, buffer, ANDROID_PUBKEY_MODULUS_SIZE)) { +#endif return false; } @@ -135,28 +140,30 @@ bool android_pubkey_encode(const RSA* ke // Store the modulus size. key_struct->modulus_size_words = ANDROID_PUBKEY_MODULUS_SIZE_WORDS; + const BIGNUM *key_n, *key_e; + RSA_get0_key(key, &key_n, &key_e, NULL); // Compute and store n0inv = -1 / N[0] mod 2^32. if (!ctx || !r32 || !n0inv || !BN_set_bit(r32, 32) || - !BN_mod(n0inv, key->n, r32, ctx) || + !BN_mod(n0inv, key_n, r32, ctx) || !BN_mod_inverse(n0inv, n0inv, r32, ctx) || !BN_sub(n0inv, r32, n0inv)) { goto cleanup; } key_struct->n0inv = (uint32_t)BN_get_word(n0inv); // Store the modulus. - if (!android_pubkey_encode_bignum(key->n, key_struct->modulus)) { + if (!android_pubkey_encode_bignum(key_n, key_struct->modulus)) { goto cleanup; } // Compute and store rr = (2^(rsa_size)) ^ 2 mod N. if (!ctx || !rr || !BN_set_bit(rr, ANDROID_PUBKEY_MODULUS_SIZE * 8) || - !BN_mod_sqr(rr, rr, key->n, ctx) || + !BN_mod_sqr(rr, rr, key_n, ctx) || !android_pubkey_encode_bignum(rr, key_struct->rr)) { goto cleanup; } // Store the exponent. - key_struct->exponent = (uint32_t)BN_get_word(key->e); + key_struct->exponent = (uint32_t)BN_get_word(key_e); ret = true;
View Attachment As Raw
Actions:
View
Attachments on
bug 23853
:
10474
|
10475
|
10476
|
10477
|
10478
|
10479
|
10480
|
10481
|
10482
|
11104
|
11105
|
11106
|
11107
|
11108
|
11109
|
11110
|
11111
|
11112
|
11113
|
11114